@cssxio/unplugin 0.9.0 → 0.11.0
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/README.md +32 -20
- package/dist/chunk-3C7SCOHD.js +11 -0
- package/dist/chunk-5W5F6RBE.js +3 -0
- package/dist/chunk-663P2VZO.js +3 -0
- package/dist/chunk-7X733NFU.js +1 -0
- package/dist/chunk-AJOXGQDA.js +1 -0
- package/dist/chunk-ART2XI6B.js +5 -0
- package/dist/chunk-GPHROS5Y.js +1 -0
- package/dist/chunk-NTKLI2V7.js +1 -0
- package/dist/chunk-URWMD4HY.js +1 -0
- package/dist/chunk-V4DGCZJC.js +2 -0
- package/dist/chunk-VJ4HYXVU.js +1 -0
- package/dist/compile-cssx-stylesheet-CAnWFXMM.d.cts +17 -0
- package/dist/compile-cssx-stylesheet-CnatguKL.d.ts +17 -0
- package/dist/development-runtime.cjs +212 -0
- package/dist/development-runtime.d.cts +181 -0
- package/dist/development-runtime.d.ts +181 -0
- package/dist/development-runtime.js +196 -0
- package/dist/esbuild.cjs +14 -102
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +19 -102
- package/dist/index.d.cts +12 -56
- package/dist/index.d.ts +12 -56
- package/dist/index.js +1 -1
- package/dist/module-cssx-data-CtlcR7CZ.d.ts +12 -0
- package/dist/module-cssx-data-DfZiLJQL.d.cts +12 -0
- package/dist/next-development-server-CBPFB9EC.d.cts +17 -0
- package/dist/next-development-server-CBPFB9EC.d.ts +17 -0
- package/dist/next-loader.cjs +15 -14
- package/dist/next-loader.d.cts +3 -1
- package/dist/next-loader.d.ts +3 -1
- package/dist/next-loader.js +5 -4
- package/dist/next.cjs +1 -1
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +1 -1
- package/dist/{options-DkqShf7w.d.ts → options-BbhZj-Sb.d.cts} +4 -0
- package/dist/{options-DkqShf7w.d.cts → options-BbhZj-Sb.d.ts} +4 -0
- package/dist/rollup.cjs +17 -101
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +17 -101
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/stylesheet-types-mSM1XaBK.d.cts +40 -0
- package/dist/stylesheet-types-mSM1XaBK.d.ts +40 -0
- package/dist/transform-runtime.cjs +12 -0
- package/dist/transform-runtime.d.cts +71 -0
- package/dist/transform-runtime.d.ts +71 -0
- package/dist/transform-runtime.js +2 -0
- package/dist/vite.cjs +17 -101
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +17 -101
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +14 -4
- package/dist/chunk-5R7RC6XB.js +0 -13
- package/dist/chunk-KEHM5MVZ.js +0 -91
- package/dist/chunk-OHZUHF4D.js +0 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";var mr=Object.create;var me=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var hr=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fr(t))!gr.call(e,s)&&s!==r&&me(e,s,{get:()=>t[s],enumerable:!(n=ur(t,s))||n.enumerable});return e};var yr=(e,t,r)=>(r=e!=null?mr(pr(e)):{},et(t||!e||!e.__esModule?me(r,"default",{value:e,enumerable:!0}):r,e)),xr=e=>et(me({},"__esModule",{value:!0}),e);var Kr={};hr(Kr,{compileCssxStylesheet:()=>F,compileViteDevelopmentStylesheet:()=>ne,configureViteDevelopmentServer:()=>Ee,connectViteStylesheetClient:()=>Ne,createRollupDevelopmentNotifier:()=>Ke,createRollupDevelopmentRuntime:()=>nr,createViteDevelopmentRuntime:()=>lr,createViteNativeSourceWatcher:()=>He,cssWithSourceMapComment:()=>D,nativeStylesheetHmr:()=>dr,nextDevelopmentStylesheetHmr:()=>De,publishNextDevelopmentStylesheet:()=>K,sendViteStyles:()=>re,startDevelopmentCoordinator:()=>$e,startNextDevelopmentServer:()=>Re,stopNextDevelopmentServer:()=>Te,viteDevelopmentStylesheetHmr:()=>Oe,waitForNextDevelopmentStylesheet:()=>zt});module.exports=xr(Kr);var Y=require("path");function ue(e){if(!e||(0,Y.isAbsolute)(e))throw new Error("cssFileName must be a non-empty relative path.");let t=(0,Y.normalize)(e);if(t===".."||t.startsWith(`..${Y.sep}`))throw new Error("cssFileName must not escape the bundler output directory.");if(!t.endsWith(".css"))throw new Error("cssFileName must end in .css.");return t}function Le(e){if(e.mode!==void 0&&e.mode!=="development"&&e.mode!=="production")throw new Error('CSSX mode must be "development" or "production".');if(e.stableClassNameStrategy!==void 0&&e.stableClassNameStrategy!=="source-location"&&e.stableClassNameStrategy!=="module-order")throw new Error('CSSX stableClassNameStrategy must be "source-location" or "module-order".');if(e.sourceRoots&&e.sourceRoots.some(r=>typeof r!="string"||!r.trim()))throw new Error("CSSX sourceRoots must contain non-empty file-system paths.");let t=e.debug;if(t===null||t!==void 0&&typeof t!="boolean"&&(typeof t!="object"||typeof t.reportFile!="string"||!t.reportFile))throw new Error("CSSX debug must be a boolean or an object with a reportFile path.");if(e.naming!==void 0&&!["serial","hash","source"].includes(e.naming))throw new Error('CSSX naming must be "serial", "hash", or "source".');if(e.coordination!==void 0&&!["memory","manifest"].includes(e.coordination))throw new Error('CSSX coordination must be "memory" or "manifest".');if(e.stableClassNames&&e.naming&&e.naming!=="source")throw new Error('CSSX stableClassNames selects source naming and conflicts with naming. Use naming: "source".');if(e.stableClassNames&&e.coordination==="manifest")throw new Error("CSSX stableClassNames already selects source naming; remove it to use manifest coordination.");if(e.naming==="hash"&&e.className?.variant==="serial")throw new Error('CSSX naming: "hash" conflicts with className.variant: "serial".');if(e.naming==="serial"&&e.className?.variant==="random")throw new Error('CSSX naming: "serial" conflicts with className.variant: "random".');if(e.coordination==="manifest"&&!e.manifestPath)throw new Error('CSSX coordination: "manifest" requires manifestPath.');if(e.manifestPath&&e.coordination!=="manifest")throw new Error('CSSX manifestPath requires coordination: "manifest".');if(e.coordination==="manifest"&&e.classNameAllocator)throw new Error("CSSX manifest coordination cannot use a custom classNameAllocator.");if(e.theme!==void 0&&e.themeFile!==void 0)throw new Error("CSSX accepts either theme or themeFile, not both.");if(e.layer!==void 0&&!/^[A-Za-z_-][A-Za-z0-9_-]*$/.test(e.layer))throw new Error("CSSX layer must be a valid CSS layer identifier.");if(e.sourceMap!==void 0&&typeof e.sourceMap!="boolean")throw new Error("CSSX sourceMap must be a boolean.");if(e.darkMode!==void 0&&e.darkMode!=="media"&&e.darkMode!=="selector"&&e.darkMode!=="class")throw new Error('CSSX darkMode must be "media", "selector", or "class".');if(e.preflight!==void 0&&typeof e.preflight!="boolean")throw new Error("CSSX preflight must be a boolean.");if(e.reusabilityBudget!==void 0&&e.reusabilityBudget!=="auto"&&(!Number.isFinite(e.reusabilityBudget)||e.reusabilityBudget<0||e.reusabilityBudget>100))throw new Error('CSSX reusabilityBudget must be "auto" or a number from 0 through 100.');ue(e.cssFileName??"cssx.css")}var fe=require("fs/promises"),rt=require("path"),tt=new Map;async function Z(e,t=process.cwd()){if(e.themeFile===void 0)return e.theme;let r=(0,rt.resolve)(t,e.themeFile),n=await(0,fe.stat)(r,{bigint:!0}),s=`${n.dev}:${n.ino}:${n.size}:${n.mtimeNs}:${n.ctimeNs}`,o=tt.get(r);if(o?.signature===s)return o.source;let a=await(0,fe.readFile)(r,"utf8");return tt.set(r,{signature:s,source:a}),a}function R(e){return e.replaceAll("\\","/").split("?",1).join("")}function je(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var nt=require("path");function Ve(e,t){return`${e&&e!=="/"?`/${Sr(e)}`:""}/${ue(t).replaceAll(nt.sep,"/")}`}function Sr(e){let t=0,r=e.length;for(;e.charCodeAt(t)===47;)t++;for(;r>t&&e.charCodeAt(r-1)===47;)r--;return e.slice(t,r)}function Ie(e){let t=e.naming==="hash"?"random":e.naming==="serial"?"serial":void 0;if(t&&e.className?.variant&&e.className.variant!==t)throw new Error(`CSSX naming: "${e.naming}" conflicts with className.variant: "${e.className.variant}".`);return{...e.className,...t?{variant:t}:{}}}function pe(e){return{...e,mode:"development",sourceMap:e.sourceMap??!1,naming:"source",stableClassNames:!0,stableClassNameStrategy:"module-order",reusabilityBudget:0,className:{...e.className,variant:"random"},classNameAllocator:void 0,coordination:"memory",manifestPath:void 0}}var ge=require("@cssxio/compiler");var st='*,::before,::after,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-text-size-adjust:100%;tab-size:4;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:transparent;opacity:1}button,select{text-transform:none}button,input:where([type="button"],[type="reset"],[type="submit"]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit}textarea{resize:vertical}::placeholder{opacity:1}button,[role="button"]{cursor:pointer}:disabled{cursor:default}[hidden]:where(:not([hidden="until-found"])){display:none!important}';function Fe(e,t){let r=t.split(`
|
|
2
|
+
`);return{line:e.line+r.length-1,column:r.at(-1).length+e.column*+(r.length===1)}}var Cr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function oe(e){let t="",r=e<0?-e<<1|1:e<<1;do{let n=r&31;r>>>=5,r&&(n|=32),t+=Cr[n]}while(r);return t}function ot(e){let t=Array.from({length:Math.max(0,...e.map(i=>i.line))+1},()=>[]),r=0,n=0,s=0,o=0,a=0;for(let i of e)a*=+(i.line===o),o=i.line,t[i.line]?.push(`${oe(i.column-a)}${oe(i.source-r)}${oe(i.originalLine-n)}${oe(i.originalColumn-s)}`),a=i.column,r=i.source,n=i.originalLine,s=i.originalColumn;return t.map(i=>i.join(",")).join(";")}function it(e,t,r){let n=[...new Set(t.map(i=>r.get(i.candidate)?.id).filter(i=>!!i))].sort();if(n.length===0)return;let s=new Map(n.map((i,d)=>[i,d])),o=[],a=Fe({line:0,column:0},e);for(let i of t){let d=r.get(i.candidate);d&&o.push({...a,source:s.get(d.id),originalLine:d.line,originalColumn:d.column}),a=Fe(a,i.css)}return{version:3,sources:n,names:[],mappings:ot(o)}}async function F(e,t,r,n=!0,s,o=!0){let a=Object.create(null),i=Object.create(null),d=new Set,l=!0,m=new Map;for(let p of[...e].sort((g,v)=>g.id.localeCompare(v.id))){for(let[g,v]of Object.entries(p.candidates))if(g in a||(a[g]=v),p.id&&!m.has(g)){let h=p.origins?.[g];m.set(g,{id:p.id,line:h?.line??0,column:h?.column??0})}for(let[g,v]of Object.entries(p.composites??{})){let h=i[g];if(h&&h.join(" ")!==v.join(" "))throw new Error(`CSSX composite class collision for "${g}".`);i[g]=v}p.atomicClasses===void 0&&(l=!1);for(let g of p.atomicClasses??[])d.add(g)}let c=Object.keys(a).sort(),u=o?st:"";if(c.length===0)return{css:u&&r?`@layer ${r}{${u}}`:u};let y=await(0,ge.compileUtilities)(c,p=>a[p],t,(0,ge.createSelectorAliases)(i),l?d:void 0,{darkMode:s}),f=r?`@layer ${r}{`:"",S=`${f}${u}${y.css}${f?"}":""}`,w=n?it(`${f}${u}${y.prefixCss}`,y.entries,m):void 0;return{css:S,...w?{map:w}:{}}}function ie(e,t){return JSON.stringify({...e,file:t})}var at=require("path");function D(e,t){return e.map?`${e.css}
|
|
3
|
+
/*# sourceMappingURL=${(0,at.basename)(t)}.map */`:e.css}var $t=require("@cssxio/compiler"),Ht=require("fs"),j=require("fs/promises"),H=require("path");var lt=require("module"),ct=require("path"),_e=require("url");async function he(e,t,r={}){let n=(0,lt.createRequire)((0,ct.resolve)(t,"package.json")),s;try{s=n.resolve("@mdx-js/mdx")}catch{throw new Error("CSSX Next MDX support requires @mdx-js/mdx to be installed in the Next.js project.")}let o=await import((0,_e.pathToFileURL)(s).href),a=async i=>Promise.all((i??[]).map(async d=>{let[l,m]=typeof d=="string"?[d,void 0]:d,c=n.resolve(l),u=await import((0,_e.pathToFileURL)(c).href),y=u.default??u;return m===void 0?y:[y,m]}));return String(await o.compile(e,{outputFormat:"program",development:r.development??!1,remarkPlugins:await a(r.remarkPlugins),rehypePlugins:await a(r.rehypePlugins),recmaPlugins:await a(r.recmaPlugins)}))}var Xe=require("fs"),vr=require("fs/promises"),L=require("path");function k(e){let t=(0,L.resolve)(e);try{return Xe.realpathSync.native(t)}catch{let r=(0,L.dirname)(t),n=(0,L.basename)(t);for(;;)try{return(0,L.resolve)(Xe.realpathSync.native(r),n)}catch{let s=(0,L.dirname)(r);if(s===r)return t;n=(0,L.join)((0,L.basename)(r),n),r=s}}}var J=require("path");function ye(e,t,r){let n=r?k(e):(0,J.resolve)(e),s=r?k(t):(0,J.resolve)(t);return(0,J.relative)(n,s).replaceAll(J.sep,"/")}var X=require("@cssxio/compiler"),M=require("fs/promises"),xe=require("path"),dt=20,mt=5*6e4;async function ut(e,t,r){let n=(0,xe.resolve)(e),s=`${n}.lock`,o=Date.now(),a,i=0;for(;!a;){await(0,M.mkdir)((0,xe.dirname)(n),{recursive:!0});let d;try{d=await(0,M.open)(s,"wx")}catch(l){let m=l.code;if(m!=="EEXIST"){if(m!=="EACCES"&&m!=="EPERM")throw l;try{await(0,M.stat)(s)}catch(c){if(c.code==="ENOENT"){if(i+=1,i>1)throw l;await new Promise(u=>setTimeout(u,dt));continue}throw c}}if(i=0,await wr(s))continue;if(Date.now()-o>=mt)throw new Error(`Timed out waiting for CSSX class-name manifest lock: ${s}`);await new Promise(c=>setTimeout(c,dt));continue}try{await d.writeFile(`${process.pid}
|
|
4
|
+
${Date.now()}
|
|
5
|
+
`)}catch(l){throw await d.close().catch(()=>{}),await(0,M.rm)(s,{force:!0}).catch(()=>{}),l}a=d}try{let d=await br(n,t),l=await r(d),m=(0,X.snapshotClassNameAllocator)(d),c=`${n}.${process.pid}.${Date.now()}.tmp`;try{await(0,M.writeFile)(c,`${JSON.stringify(m,null,2)}
|
|
6
|
+
`,"utf8"),await(0,M.rename)(c,n)}catch(u){throw await(0,M.rm)(c,{force:!0}).catch(()=>{}),u}return l}finally{await a.close(),await(0,M.rm)(s,{force:!0})}}async function wr(e){try{let t=await(0,M.stat)(e),r;try{r=await(0,M.readFile)(e,"utf8")}catch(o){let a=o.code;if(a==="EACCES"||a==="EPERM")return!1;throw o}let[n]=r.split(`
|
|
7
|
+
`),s=Number(n);if(Number.isSafeInteger(s)&&s>0)try{return process.kill(s,0),!1}catch(o){return o.code!=="ESRCH"?!1:(await(0,M.rm)(e,{force:!0}),!0)}return Date.now()-t.mtimeMs<mt?!1:(await(0,M.rm)(e,{force:!0}),!0)}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function br(e,t){try{let r=JSON.parse(await(0,M.readFile)(e,"utf8")),n=(0,X.snapshotClassNameAllocator)((0,X.createClassNameAllocator)(t)).options;if(JSON.stringify(r.options)!==JSON.stringify(n))throw new Error("CSSX class-name manifest options do not match the active compiler options.");return(0,X.restoreClassNameAllocator)(r)}catch(r){if(r.code==="ENOENT")return(0,X.createClassNameAllocator)(t);throw r}}var ft=require("fs/promises"),$=require("path"),Nr=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".mdx",".md"]),pt=new Set([".git",".next",".open-next",".output",".turbo",".vercel","build","coverage","dist","node_modules","out","storybook-static"]);function We(e,t=[]){let r=(0,$.resolve)(e),n=t.map(o=>(0,$.resolve)(o)).find(o=>{let a=(0,$.relative)(o,r);return a===""||!a.startsWith(`..${$.sep}`)&&a!==".."&&!(0,$.isAbsolute)(a)});return(n?(0,$.relative)(n,r):r).split($.sep).some(o=>pt.has(o))}async function gt(e,t=[]){let r=[],n=[e,...t],s=new Set;for(;n.length>0;){let o=n.pop(),a=(0,$.resolve)(o);if(!s.has(a)){s.add(a);for(let i of await(0,ft.readdir)(o,{withFileTypes:!0})){let d=(0,$.join)(o,i.name);if(i.isDirectory()){pt.has(i.name)||n.push(d);continue}i.isFile()&&Nr.has(d.slice(d.lastIndexOf(".")))&&r.push(d)}}}return r.sort()}var ht=require("@cssxio/compiler");function Se(e){let t=[],r=/\bsx\s*\(/g;for(let n of e.matchAll(r)){let s=n.index,o=e.indexOf("(",s),a=0,i="";for(let d=o;d<e.length;d+=1){let l=e[d];if(i){l==="\\"?d+=1:l===i&&(i="");continue}if(l==='"'||l==="'"||l==="`")i=l;else if(l==="(")a+=1;else if(l===")"&&--a===0){t.push({start:s,end:d+1,code:e.slice(s,d+1)}),r.lastIndex=d+1;break}}}return t}function ee(e,t){return{code:e,rules:t.flatMap(r=>r.rules),candidates:Object.assign({},...t.map(r=>r.candidates)),composites:Object.assign({},...t.map(r=>r.composites)),atomicClasses:[...new Set(t.flatMap(r=>r.atomicClasses))],origins:Object.assign({},...t.map(r=>r.origins)),cssOnlySignature:e}}function Ce(e){let t="const style = ",r=e.indexOf(t)+t.length,n=e.indexOf(";",r);return e.slice(r,n)}async function yt(e,t,r,n,s={}){let o=Se(e);if(o.length===0)return null;let a=r.classNameAllocator??(0,ht.createClassNameAllocator)(),i=r.importSource??"@cssxio/cssx",d=[],l=e;for(let m of[...o].reverse()){let c=await n(`import { sx } from ${JSON.stringify(i)};
|
|
8
|
+
const style = ${m.code};`,`${t}.ts`,{...r,classNameAllocator:a},void 0,s),u=Ce(c.code);l=`${l.slice(0,m.start)}${u}${l.slice(m.end)}`,d.push({...c,atomicClasses:[],origins:{}})}return ee(l,d)}var bt=require("@cssxio/compiler"),Nt=require("@vue/compiler-sfc");function ve(e,t){let r=e.split(`
|
|
9
|
+
`).slice(0,t.line).reduce((n,s)=>n+s.length+1,0);return Math.min(e.length,r+t.column)}function we(e,t){let r=Math.min(e.length,t),n=e.slice(0,r).split(`
|
|
10
|
+
`).length-1,s=e.lastIndexOf(`
|
|
11
|
+
`,r-1)+1;return{line:n,column:r-s}}function Ue(e,t,r){let n={},s=e.slice(t);for(let[o,a]of Object.entries(r))n[o]=we(e,t+ve(s,a));return n}function xt(e,t,r,n,s){let o={};for(let[a,i]of Object.entries(s)){let d=ve(r,i);o[a]=we(e,t+Math.max(0,d-n))}return o}function St(e){return e.slice(1,-1).replace(/\\(['"\\bnfrtv])/g,(t,r)=>({b:"\b",n:`
|
|
12
|
+
`,f:"\f",r:"\r",t:" ",v:"\v"})[r]??r)}function Ct(e,t){if(!t)return e;let r=t==='"'?"'":'"';return e.replace(/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g,n=>{let s=n[0]==='"'?JSON.parse(n):St(n),o=JSON.stringify(s);return r==='"'?o:`'${o.slice(1,-1).replaceAll("'","\\'")}'`})}function vt(e,t){let r=-1,n;for(let s=0;s<t;s++){let o=e[s];if(n){o===n&&(n=void 0);continue}if(o==="<"&&/[A-Za-z]/.test(e[s+1])){r=s;continue}r!==-1&&(o===">"?r=-1:(o==='"'||o==="'")&&(n=o))}return n}async function wt(e,t,r,n,s,o={}){let a=Se(e);if(a.length===0)return null;let i=r.importSource??"@cssxio/cssx",d=[],l=e;for(let m of[...a].reverse()){let c=`import { sx } from ${JSON.stringify(i)};
|
|
13
|
+
const style = `,u=`${c}${m.code};`,y=await s(u,`${t}.cssx-vue-template.ts`,{...r,classNameAllocator:n},void 0,o),f=Ct(Ce(y.code),vt(e,m.start));l=`${l.slice(0,m.start)}${f}${l.slice(m.end)}`,d.push({...y,origins:xt(e,m.start,u,c.length,y.origins)})}return ee(l,d)}async function Ot(e,t,r,n,s={}){let o=t.split("?",1).join(""),a=(0,Nt.parse)(e,{filename:o});if(a.errors.length>0)throw new Error(a.errors[0].message);let i=r.classNameAllocator??(0,bt.createClassNameAllocator)(),d=[],l=[];for(let u of[a.descriptor.script,a.descriptor.scriptSetup]){if(!u?.content.includes(r.importSource??"@cssxio/cssx"))continue;let y=u.lang==="js"||u.lang==="jsx"||u.lang==="tsx"?u.lang:"ts",f=await n(u.content,`${o}.cssx-vue-script.${y}`,{...r,classNameAllocator:i},void 0,s);d.push({start:u.loc.start.offset,end:u.loc.end.offset,code:f.code}),l.push({...f,origins:Ue(e,u.loc.start.offset,f.origins)})}let m=a.descriptor.template;if(m?.content.includes("sx")){let u=await wt(m.content,o,r,i,n,s);u&&(d.push({start:m.loc.start.offset,end:m.loc.end.offset,code:u.code}),l.push({...u,origins:Ue(e,m.loc.start.offset,u.origins)}))}if(d.length===0)return null;let c=e;for(let u of d.sort((y,f)=>f.start-y.start))c=`${c.slice(0,u.start)}${u.code}${c.slice(u.end)}`;return ee(c,l)}var Mt=require("@babel/core"),Rt=yr(require("@cssxio/babel-plugin"),1),be=require("@cssxio/compiler");function Pt(e){return{className:`cssx-${je(e)}`,css:e}}function Et(e,t){return e&&t?`@layer ${t}{${e}}`:e}async function Tt(e,t,r,n,s={}){let o=r.importSource??"@cssxio/cssx",a=await Z(r),i=await(0,Mt.transformAsync)(e,{babelrc:!1,configFile:!1,filename:t,parserOpts:{plugins:["jsx","typescript"]},plugins:[[Rt.default,{importSource:o,classNameAllocator:r.classNameAllocator,theme:a,reusabilityBudget:r.reusabilityBudget,stableClassNames:r.stableClassNames,stableClassNameStrategy:r.stableClassNameStrategy,stableClassNameFileName:r.stableClassNameFileName,darkMode:r.darkMode}]],sourceMaps:!0,...n?{inputSourceMap:n}:{}}),d=i.metadata,{candidates:l,origins:m,composites:c,atomicClasses:u,cssOnlySignature:y}=d.cssx,f=Object.keys(l),S=s.compileCss===!1||f.length===0?"":(await(0,be.compileUtilities)(f,w=>l[w],a,(0,be.createSelectorAliases)(c),new Set(u),{darkMode:r.darkMode})).css;return{code:i.code,rules:S?[Pt(Et(S,r.layer))]:[],candidates:l,composites:c,atomicClasses:u,origins:m,cssOnlySignature:y,map:i.map}}var Or=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".vue"]);async function z(e,t,r={},n,s={}){Le(r);let o=r.importSource??"@cssxio/cssx",a=t.split("?",1).join("");return!Or.has(a.slice(a.lastIndexOf(".")))||!e.includes(o)?null:a.endsWith(".astro")?yt(e,t,r,z,s):a.endsWith(".vue")?Ot(e,t,r,z,s):Tt(e,a,r,n,s)}async function te(e,t){let r=k(e),n=await gt(r,t.sourceRoots?.map(m=>k((0,H.resolve)(r,m)))),s={...t};delete s.coordination,delete s.manifestPath,delete s.classNameAllocator;let o=async m=>{let c=[];for(let u of n){let y=await(0,j.readFile)(u,"utf8"),f=/\.(?:md|mdx)$/i.test(u);if(f&&!y.includes(t.importSource??"@cssxio/cssx"))continue;let S=f?await he(y,r,t.mdx):y,w=t.stableClassNames||t.naming==="source",p=await z(S,f?`${u}.tsx`:u,{...s,classNameAllocator:m,stableClassNames:w,...w?{stableClassNameFileName:ye(r,u,t.mode==="development")}:{}},void 0,{compileCss:!1});p&&c.push({id:u,candidates:p.candidates,composites:p.composites,atomicClasses:p.atomicClasses,origins:p.origins})}return c};if(t.coordination==="manifest")return ut(t.manifestPath,Ie(t),o);let a=W(r,t),i=Er(e,t),d=G.get(a);if(d)return await d,te(e,t);let l=(async()=>{let m=new Set;for(let c of n){let u;try{u=await(0,j.stat)(c,{bigint:!0})}catch(h){if(h.code!=="ENOENT")throw h;i.signatures.delete(c),i.modules.delete(c);continue}let y=`${u.dev}:${u.ino}:${u.size}:${u.mtimeNs}:${u.ctimeNs}`;if(i.signatures.get(c)===y){m.add(c);continue}let f;try{f=await(0,j.readFile)(c,"utf8")}catch(h){if(h.code!=="ENOENT")throw h;i.signatures.delete(c),i.modules.delete(c);continue}m.add(c);let S=/\.(?:md|mdx)$/i.test(c),w=f.includes(t.importSource??"@cssxio/cssx");if(S&&!w){i.modules.delete(c),i.signatures.set(c,y);continue}let p=S?await he(f,r,t.mdx):f,g=t.stableClassNames||t.naming==="source",v=await z(p,S?`${c}.tsx`:c,{...s,classNameAllocator:i.allocator,stableClassNames:g,...g?{stableClassNameFileName:ye(r,c,t.mode==="development")}:{}},void 0,{compileCss:!1});v?i.modules.set(c,{id:c,candidates:v.candidates,composites:v.composites,atomicClasses:v.atomicClasses,origins:v.origins}):i.modules.delete(c),i.signatures.set(c,y)}for(let c of i.signatures.keys())m.has(c)||(i.signatures.delete(c),i.modules.delete(c));return[...i.modules.values()].sort((c,u)=>c.id.localeCompare(u.id))})();G.set(a,l);try{return await l}finally{G.delete(a)}}async function Dt(e,t,r,n,s){if(r.coordination==="manifest")return!1;let o=W(e,r),a=G.get(o);a&&await a;let i=T.get(o);if(!i)return!1;let d=k(t),l;try{let c=await(0,j.stat)(d,{bigint:!0});if(s!==void 0&&await(0,j.readFile)(d,"utf8")!==s)return!1;l=`${c.dev}:${c.ino}:${c.size}:${c.mtimeNs}:${c.ctimeNs}`}catch(c){if(c.code==="ENOENT"){let u=T.get(o);return u?.signatures.delete(d),u?.modules.delete(d)??!1}throw c}let m=i.modules.has(d);return n?i.modules.set(d,{id:d,candidates:n.candidates,composites:n.composites,atomicClasses:n.atomicClasses,origins:n.origins}):i.modules.delete(d),i.signatures.set(d,l),m||n!==null}function Pr(e,t){let r=T.get(W(e,t));return r?[...r.modules.values()].sort((n,s)=>n.id.localeCompare(s.id)):void 0}function Lt(e,t){Je.add(W(e,t))}function Be(e,t){let r=W(e,t);Je.delete(r),le.get(r)?.stop(),T.delete(r)}function W(e,t){let r={...t};return delete r.coordination,delete r.manifestPath,delete r.classNameAllocator,`${k(e)}\0${JSON.stringify(r)}`}function Er(e,t){let r=W(e,t),n=T.get(r);return n||(n={allocator:t.classNameAllocator??(0,$t.createClassNameAllocator)(Ie(t)),modules:new Map,signatures:new Map},T.set(r,n),Mr(r)),n}function Mr(e){if(!(T.size<=kt))for(let t of T.keys()){if(T.size<=kt)return;t!==e&&!Je.has(t)&&!le.has(t)&&T.delete(t)}}var T=new Map,G=new Map,Je=new Set,kt=8,Rr=256,At=16,ae=0,Tr=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".md",".mdx"]);async function jt(e,t,r,n=()=>!1){let s=k(e),o=W(s,t),a=le.get(o);if(a)return Promise.resolve(a.stop);let i=G.get(o);i&&await i;let d=t.sourceRoots?.map(P=>(0,H.resolve)(s,P))??[],l=new Map,m=new Set,c=!1,u=!1,y,f=!1,S=!1,w=!1,p=!1,g=P=>{if(!(u||m.has(P))){if(m.size>=Rr){m.clear(),u=!0;return}m.add(P),G.has(o)&&(c=!0)}},v=(P=0)=>{y&&clearTimeout(y),y=setTimeout(()=>{y=void 0,C()},P)},h=async()=>{let P=await Ar(s,d,[...T.get(o)?.modules.values()??[]],t.themeFile?(0,H.resolve)(s,t.themeFile):void 0);if(f)return;let N=new Set(P);for(let[x,b]of l)N.has(x)||(b.close(),l.delete(x),ae--);for(let x of P){if(l.has(x))continue;if(ae>=At){w||(w=!0,console.warn(`CSSX: development source watcher reached the ${At}-directory limit.`));continue}let b;try{b=(0,Ht.watch)(x,(O,I)=>{if(f)return;if(I===null){u=!0,v(8);return}let A=(0,H.resolve)(x,I.toString());if(We(A,d)||n(A))return;if((0,H.extname)(A)===".css"&&k(A)===k((0,H.resolve)(s,t.themeFile??""))){g(A),v();return}let B=(0,H.extname)(A);if(O==="rename"&&B==="")u=!0;else if($r(B))g(A);else return;let Q=T.get(o)?.signatures.has(k(A))??!1;v(O==="rename"&&!Q?8:0)})}catch(O){p||(p=!0,console.warn(`CSSX: development source watcher could not watch ${x}: ${O instanceof Error?O.message:String(O)}`));continue}b.on("error",O=>{l.get(x)===b&&(l.delete(x),ae--,b.close(),console.warn(`CSSX: development source watcher stopped for ${x}: ${O.message}`))}),b.unref(),l.set(x,b),ae++}},C=async()=>{if(f||S)return;S=!0;let P=[...m],N=u,x=c;m.clear(),u=!1,c=!1;try{if(N){let b=await te(s,t);if(f){T.delete(o);return}await h(),f||await r(b)}else{let b=x;for(let O of P)t.themeFile&&k(O)===k((0,H.resolve)(s,t.themeFile))?b=!0:b=await kr(s,O,t)||b;if(b&&!f){let O=Pr(s,t);await r(O)}}}catch(b){f||console.warn(`CSSX: development source update failed: ${b instanceof Error?b.message:String(b)}`)}finally{S=!1,(u||m.size>0)&&!y&&v()}},E=()=>{f=!0,y&&clearTimeout(y),m.clear(),u=!1,c=!1;for(let P of l.values())P.close(),ae--;l.clear(),le.delete(o),T.delete(o)};return le.set(o,{stop:E}),await h().catch(P=>{console.warn(`CSSX: development source watcher could not start: ${P instanceof Error?P.message:String(P)}`)}),E}async function kr(e,t,r){let n=k(t),s=W(e,r),o=T.get(s),a=o?.signatures.get(n),i=o?.modules.has(n)??!1,d=G.get(s);d&&await d;let l=T.get(s);if(!l)return!1;let m=l.modules.has(n);try{let c=await(0,j.stat)(n,{bigint:!0}),u=`${c.dev}:${c.ino}:${c.size}:${c.mtimeNs}:${c.ctimeNs}`;if(l.signatures.get(n)===u)return a!==u;let y=await(0,j.readFile)(n,"utf8"),f=/\.(?:md|mdx)$/i.test(n);if(f&&!y.includes(r.importSource??"@cssxio/cssx"))return l.modules.delete(n),l.signatures.set(n,u),m;let S=f?await he(y,e,r.mdx):y,w=r.stableClassNames||r.naming==="source",p={...r};delete p.coordination,delete p.manifestPath,delete p.classNameAllocator;let g=await z(S,f?`${n}.tsx`:n,{...p,classNameAllocator:l.allocator,stableClassNames:w,...w?{stableClassNameFileName:ye(e,n,r.mode==="development")}:{}},void 0,{compileCss:!1});return g?l.modules.set(n,{id:n,candidates:g.candidates,composites:g.composites,atomicClasses:g.atomicClasses,origins:g.origins}):l.modules.delete(n),l.signatures.set(n,u),m||g!==null}catch(c){if(c.code==="ENOENT")return l.signatures.delete(n),l.modules.delete(n),m||i;throw c}}async function Ar(e,t,r,n){let s=new Set([e,...t,...r.map(a=>(0,H.dirname)(a.id)),...n?[(0,H.dirname)(n)]:[]]),o=[];for(let a of s){let i=(0,H.resolve)(a);if(!We(i,t))try{await(0,j.readdir)(i),o.push(i)}catch(d){if(d.code==="ENOENT")continue;throw d}}return o}function $r(e){return Tr.has(e)}var le=new Map;var Vt=new WeakMap;function It(e){let t=Vt.get(e);return t||(t={revision:0,clients:new Set},Vt.set(e,t)),t}function Ft(e,t){e.write(`data: ${JSON.stringify(t)}
|
|
14
|
+
|
|
15
|
+
`)}function Ne(e,t){let r=It(e);t.setHeader("Content-Type","text/event-stream; charset=utf-8"),t.setHeader("Cache-Control","no-cache, no-transform"),t.setHeader("Connection","keep-alive"),r.clients.add(t),t.write(`: connected
|
|
16
|
+
|
|
17
|
+
`),r.latest&&Ft(t,r.latest),t.on("close",()=>r.clients.delete(t))}function re(e,t){let r=It(e),n={css:t,revision:Math.max(Date.now(),r.revision+1)};r.revision=n.revision,r.latest=n;for(let s of r.clients)Ft(s,n)}var ce=require("buffer");function Oe(e,t){let r=JSON.stringify(`/${e.replaceAll("\\","/")}`),n=JSON.stringify(`${e.replaceAll("\\","/")}.events`);return`if (typeof document !== "undefined" && typeof EventSource !== "undefined") {
|
|
18
|
+
const key = "__cssxViteStylesheetHmr";
|
|
19
|
+
const state = globalThis[key] || (globalThis[key] = { installed: false, revision: 0, style: undefined, source: undefined, stylesheetLink: undefined });
|
|
20
|
+
if (!state.installed) {
|
|
21
|
+
state.installed = true;
|
|
22
|
+
const source = new EventSource(${t===void 0?"import.meta.env.BASE_URL":JSON.stringify(t)} + ${n});
|
|
23
|
+
state.source = source;
|
|
24
|
+
source.onmessage = (event) => {
|
|
25
|
+
const payload = JSON.parse(event.data);
|
|
26
|
+
if (!payload || typeof payload.css !== "string" || payload.revision <= state.revision) return;
|
|
27
|
+
if (state.style?.isConnected) {
|
|
28
|
+
state.style.textContent = payload.css;
|
|
29
|
+
} else {
|
|
30
|
+
const style = document.createElement("style");
|
|
31
|
+
style.dataset.cssxDevelopmentStylesheet = "";
|
|
32
|
+
style.textContent = payload.css;
|
|
33
|
+
const cachedLink = state.stylesheetLink;
|
|
34
|
+
const stylesheetLink = cachedLink?.isConnected ? cachedLink : [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
35
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${r}),
|
|
36
|
+
);
|
|
37
|
+
if (stylesheetLink) {
|
|
38
|
+
state.stylesheetLink = stylesheetLink;
|
|
39
|
+
stylesheetLink.after(style);
|
|
40
|
+
} else {
|
|
41
|
+
document.head.append(style);
|
|
42
|
+
}
|
|
43
|
+
state.style = style;
|
|
44
|
+
}
|
|
45
|
+
state.revision = payload.revision;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}`}var Hr=1024*1024,Dr=4096,Lr=8,_t="data-cssx-vite-hmr";function Pe(e,t){if(!e)return;if(Array.isArray(e)){for(let n=0;n+1<e.length;n+=2)if(String(e[n]).toLowerCase()===t)return e[n+1];return}return Object.entries(e).find(([n])=>n.toLowerCase()===t)?.[1]}function jr(e){if(!e)return e;if(Array.isArray(e)){let t=[];for(let r=0;r+1<e.length;r+=2){let n=String(e[r]);n.toLowerCase()!=="content-length"&&n.toLowerCase()!=="etag"&&t.push(e[r],e[r+1])}return t}return Object.fromEntries(Object.entries(e).filter(([t])=>t.toLowerCase()!=="content-length"&&t.toLowerCase()!=="etag"))}function Vr(e,t,r="/"){if(e.includes(_t))return e;let n=`<script ${_t}>${Oe(t,r)}</script>`,s=/<\/body\s*>/i,o=/<\/html\s*>/i;return s.test(e)?e.replace(s,a=>`${n}${a}`):o.test(e)?e.replace(o,a=>`${n}${a}`):`${e}${n}`}function Xt(e,t="/"){let r=0;return(n,s,o)=>{let a=n.headers?.accept,i=Array.isArray(a)?a.join(","):a;if(n.method!=="GET"||!i?.includes("text/html")||r>=Lr){o();return}r++;let d=!1,l=()=>{d||(d=!0,r--)},m=s.write.bind(s),c=s.end.bind(s),u=s.writeHead?.bind(s),y=s.flushHeaders?.bind(s),f=[],S=0,w=!1,p=s.getHeader("content-type"),g=s.getHeader("content-encoding"),v=s.getHeader("content-length"),h=s.getHeader("etag"),C=()=>{s.headersSent!==!0&&(s.removeHeader("content-length"),s.removeHeader("etag"),v=void 0,h=void 0)};u&&(s.writeHead=((N,x,b)=>{let O=typeof x=="string"?b:x;p=Pe(O,"content-type")??s.getHeader("content-type"),g=Pe(O,"content-encoding")??s.getHeader("content-encoding"),v=Pe(O,"content-length")??s.getHeader("content-length"),h=Pe(O,"etag")??s.getHeader("etag");let A=String(p??"").toLowerCase().startsWith("text/html")&&g===void 0,B=A?jr(O):O;return A&&(C(),v=void 0,h=void 0),typeof x=="string"?u(N,x,B):u(N,B)})),y&&(s.flushHeaders=(()=>{p=s.getHeader("content-type"),g=s.getHeader("content-encoding"),v=s.getHeader("content-length"),h=s.getHeader("etag"),String(p??"").toLowerCase().startsWith("text/html")&&g===void 0&&C(),y()}));let E=()=>{for(let N of f)m(N);f.length=0,S=0},P=(N,x,b)=>{let O=typeof x=="string"?x:void 0,I=typeof N=="string"?ce.Buffer.from(N,O):ce.Buffer.from(N);return S+I.byteLength>Hr||f.length>=Dr?(w=!0,E(),l(),!1):(f.push(I),S+=I.byteLength,(typeof x=="function"?x:b)?.(),!0)};s.once("close",()=>{f.length=0,S=0,l()}),s.once("finish",l),s.write=((N,x,b)=>w?typeof x=="function"?m(N,x):m(N,x,b):P(N,x,b)?!0:typeof x=="function"?m(N,x):m(N,x,b)),s.end=((N,x,b)=>{let O=typeof x=="function"?x:b;if(w||N!==void 0&&!P(N,typeof x=="string"?x:void 0))return typeof x=="function"?c(N,x):c(N,x,b);let I=String(p??s.getHeader("content-type")??"").toLowerCase(),A=g??s.getHeader("content-encoding"),B=I.startsWith("text/html")&&A===void 0,Q=ce.Buffer.concat(f,S);if(B){let Ye=Q.toString("utf8"),Ze=Vr(Ye,e,t);Ze!==Ye&&!(s.headersSent===!0&&(v!==void 0||h!==void 0))&&(Q=ce.Buffer.from(Ze),C())}return f.length=0,S=0,O?c(Q,O):c(Q)}),o()}}function Ee(e,t){let{cssFileName:r,sourceMap:n,rollupDataById:s}=t,o=Ve(e.config.base,r),a=`${o}.events`,i=Xt(r,e.config.base??"/");e.watcher?.on("unlink",d=>{s.delete(R(d)),ne({...t,root:e.config.root??process.cwd()}).then(l=>re(e,D(l,r))).catch(l=>{console.warn(`CSSX: Vite stylesheet update failed: ${l instanceof Error?l.message:String(l)}`)})}),e.middlewares.use((d,l,m)=>{let c=d.url?.split("?",1)[0];if(c===a){Ne(e,l);return}if(c!==o&&(c!==`${o}.map`||!n))return i(d,l,m);ne({...t,root:e.config.root??process.cwd()}).then(u=>{if(c===`${o}.map`){l.setHeader("Content-Type","application/json; charset=utf-8"),l.setHeader("Cache-Control","no-store"),l.end(u.map?ie(u.map,r):"");return}l.setHeader("Content-Type","text/css; charset=utf-8"),l.setHeader("Cache-Control","no-store"),l.end(D(u,r))}).catch(u=>{l.setHeader("Content-Type","text/plain; charset=utf-8"),l.end(u instanceof Error?u.message:"Unable to compile CSSX development stylesheet.")})})}async function ne(e){let{options:t,rollupDataById:r,getTheme:n}=e,s=await n(),o=t.coordination==="manifest"?await te(e.root??process.cwd(),t):[...r.values()];return F(o,s,t.layer,e.sourceMap,t.darkMode,t.preflight)}var Yt=require("crypto"),_=require("fs/promises"),Ae=require("path");var ze=require("buffer"),Bt=require("fs"),de=require("fs/promises"),Jt=require("http"),q=require("path");var Wt=require("path");function Ut(e,t){let r=(0,Wt.resolve)(e);return{port:Ir(r),token:Fr(`${r}:${t}`)}}function Ir(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return 4e4+(t>>>0)%2e4}function Fr(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var Me=new Map,Ge=new Map,_r=64;function Re(e,t){let r=(0,q.resolve)(e),n=Me.get(r);if(n)return n.references++,n.connection;let s=Ut(r,t),o=new Set,a=(0,q.resolve)(t);(0,Bt.mkdirSync)((0,q.dirname)(a),{recursive:!0});let i={connection:s,stylesheetFile:a,revision:0,ready:!1,clients:o,blockedClients:new Set,references:1},d=(0,Jt.createServer)((l,m)=>{let c=new URL(l.url??"/","http://127.0.0.1").pathname,u=`/${s.token}`;if(l.method==="OPTIONS"){m.writeHead(204,V()),m.end();return}if(l.method==="POST"&&c===`${u}/publish`){Xr(l).then(y=>l.headers["x-cssx-inline"]==="1"?y:(0,de.readFile)(a,"utf8")).then(y=>{Gt(i,y),m.writeHead(204,V()),m.end()},()=>{m.writeHead(503,V()),m.end()});return}if(l.method==="GET"&&c===`${u}/ready`){m.writeHead(i.ready?200:503,V()),m.end();return}if(l.method==="GET"&&c===`${u}/events`){if(o.size>=_r){m.writeHead(503,{...V(),"Retry-After":"1"}),m.end();return}m.writeHead(200,{...V(),"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache, no-transform",Connection:"keep-alive"}),o.add(m),qt(i,m),l.on("close",()=>{o.delete(m),i.blockedClients.delete(m)});return}if(l.method==="GET"&&c===`${u}/stylesheet`){(i.latestCss===void 0?(0,de.readFile)(a,"utf8"):Promise.resolve(i.latestCss)).then(y=>{m.writeHead(200,{...V(),"Content-Type":"text/css; charset=utf-8","Cache-Control":"no-store"}),m.end(y)},()=>{m.writeHead(503,{...V(),"Cache-Control":"no-store"}),m.end("CSSX development stylesheet is not ready.")});return}if(l.method==="GET"&&c===`${u}/generated.css.map`){(0,de.readFile)(`${a}.map`,"utf8").then(y=>{m.writeHead(200,{...V(),"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),m.end(y)},()=>{m.writeHead(404,V()),m.end()});return}m.writeHead(404,V()),m.end()});return d.on("error",l=>{console.warn(`CSSX: development stylesheet transport unavailable on port ${s.port}: ${l.message}`)}),i.server=d,d.listen(s.port,"127.0.0.1"),d.unref(),Me.set(r,i),Ge.set(qe(s),i),s}function Te(e){let t=Me.get((0,q.resolve)(e));if(t){if(t.references>1){t.references--;return}for(let r of t.clients)r.end();t.blockedClients.clear(),t.server?.close(),Me.delete((0,q.resolve)(e)),Ge.delete(qe(t.connection))}}async function K(e,t){let r=Ge.get(qe(e));if(r){let a=t??await(0,de.readFile)(r.stylesheetFile,"utf8");Gt(r,a);return}let n=`http://127.0.0.1:${e.port}/${e.token}/publish`,s={method:"POST",...t===void 0?{}:{body:t,headers:{"X-CSSX-Inline":"1"}}},o;for(let a=0;a<20;a++){try{let i=await fetch(n,s);if(i.status===204)return;o=new Error(`Unexpected HTTP status ${i.status}.`)}catch(i){o=i}await new Promise(i=>setTimeout(i,25))}throw new Error(`CSSX development stylesheet transport did not become available: ${String(o)}`)}function Xr(e){return new Promise((t,r)=>{let n=[];e.on("data",s=>n.push(ze.Buffer.from(s))),e.on("end",()=>t(ze.Buffer.concat(n).toString("utf8"))),e.on("error",r)})}async function zt(e){let t=`http://127.0.0.1:${e.port}/${e.token}/ready`;for(let r=0;r<300;r++){try{if((await fetch(t,{cache:"no-store"})).ok)return}catch{}await new Promise(n=>setTimeout(n,100))}throw new Error("CSSX Next.js development stylesheet did not become ready within 30 seconds.")}function Gt(e,t){if(e.ready&&e.latestCss===t)return;e.revision++,e.ready=!0,e.latestCss=t;let r=`data: ${JSON.stringify({revision:e.revision,css:t})}
|
|
49
|
+
|
|
50
|
+
`;for(let n of e.clients)Kt(e,n,r)}function qt(e,t){Kt(e,t,`data: ${JSON.stringify({revision:e.revision,css:e.latestCss})}
|
|
51
|
+
|
|
52
|
+
`)}function Kt(e,t,r){e.blockedClients.has(t)||t.write(r)||(e.blockedClients.add(t),t.once("drain",()=>{e.blockedClients.delete(t),e.clients.has(t)&&qt(e,t)}))}function qe(e){return`${e.port}:${e.token}`}function V(){return{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type, X-CSSX-Inline"}}var ke=new Map;function $e(e,t,r,n,s){let o=(0,Ae.resolve)(e),a=ke.get(o);if(a)return a;let i=(async()=>{Lt(o,r);let d;try{let l=await te(o,r),m=await Wr(o,t,r,l);await K(n,m),d=await jt(o,r,async u=>{let y=await Z(r,o),f=await F(u,y,r.layer,r.sourceMap,r.darkMode,r.preflight),S=D(f,"generated.css");S!==m&&(await K(n,S),m=S)},s);let c=!1;return()=>{c||(c=!0,d?.(),Be(o,r),ke.delete(o))}}catch(l){throw d?.(),Be(o,r),l}})();return ke.set(o,i),i.catch(d=>{console.warn(`CSSX: Next development coordinator could not start: ${d instanceof Error?d.message:String(d)}`),ke.delete(o)}),i}async function Wr(e,t,r,n){let s=await Z(r,e),o=await F(n,s,r.layer,r.sourceMap,r.darkMode,r.preflight);await(0,_.mkdir)((0,Ae.dirname)(t),{recursive:!0});let a=D(o,"generated.css");return await Qt(t,a),o.map&&await Qt(`${t}.map`,ie(o.map,"generated.css")),a}async function Qt(e,t){try{if(await(0,_.readFile)(e,"utf8")===t)return!1}catch(n){if(n.code!=="ENOENT")throw n}let r=`${e}.${process.pid}.${(0,Yt.randomUUID)()}.tmp`;try{return await(0,_.writeFile)(r,t),await(0,_.rename)(r,e),!0}catch(n){throw await(0,_.unlink)(r).catch(()=>{}),n}}var tr=require("fs/promises"),rr=require("path");var Zt=require("crypto");function U(e){return(0,Zt.createHash)("sha256").update(e).digest("hex")}var Ur=64,er=16*1024*1024,Br=256;function Ke(e){let t=0,r,n;return()=>e.isReady()?(t++,r||(r=new Promise(s=>setImmediate(s)).then(async()=>{let s=-1;do{s=t;let o=await e.getConnection();if(!o)return;let a=pe(e.options),i=await F([...e.dataById.values()],await e.getTheme(),a.layer,e.sourceMap,a.darkMode,a.preflight),d=D(i,e.cssFileName);d!==n&&(await K(o,d),n=d)}while(s!==t)}).catch(s=>{console.warn(`CSSX: Rollup stylesheet update failed: ${s instanceof Error?s.message:String(s)}`)}).finally(()=>{r=void 0})),r):Promise.resolve()}function nr(e){let t=(0,rr.resolve)(e.root,".cssx/rollup.css"),r=!1,n=!1,s,o,a=!0,i=new Map,d=0,l=new Map,m,c=p=>{let g=i.get(p);g&&(d-=g.size,i.delete(p))},u=p=>{if(typeof p=="string")return p.length*2;if(!p||typeof p!="object")return 0;let g=p,v=typeof g.code=="string"?g.code.length*2:0,h=g.map===void 0?0:(JSON.stringify(g.map)?.length??0)*2;return v+h},y=(p,g,v)=>{let h=u(v);if(h>er){c(p);return}for(c(p);i.size>=Ur||d+h>er;){let C=i.keys().next().value;if(C===void 0)break;c(C)}i.set(p,{sourceSignature:U(g),result:v,size:h}),d+=h},f=Ke({...e,getConnection:()=>s,isReady:()=>n}),S=async p=>{let g=R(p),v=e.dataById.get(g);if(!(!a||!v?.cssOnlySignature))try{let h=await(0,tr.readFile)(g,"utf8");if(i.get(g)?.sourceSignature===U(h))return;let C=await e.transformSource(h,p),E=e.dataById.get(g);if(!E||E.cssOnlySignature!==v.cssOnlySignature){c(g);return}y(g,h,C),await f()}catch(h){h.code!=="ENOENT"&&console.warn(`CSSX: Rollup stylesheet update failed: ${h instanceof Error?h.message:String(h)}`)}},w=p=>{if(!a)return Promise.resolve();let g=R(p);return!l.has(g)&&l.size>=Br?Promise.resolve():(l.set(g,p),m||(m=(async()=>{for(;a&&l.size>0;){let v=l.entries().next().value;if(!v)break;l.delete(v[0]),await S(v[1])}})().finally(()=>{m=void 0;let v=l.values().next().value;a&&v!==void 0&&w(v)})),m)};return{buildStart(){r||(r=!0,s=Re(e.root,t),o=$e(e.root,t,pe(e.options),s),o.catch(p=>{console.warn(`CSSX: Rollup development coordinator failed: ${String(p)}`)}))},buildEnd(){n=!0},closeWatcher:async()=>{await o?.then(p=>p(),()=>{}),a=!1,l.clear(),i.clear(),d=0,s&&Te(e.root),s=void 0,o=void 0,r=!1,n=!1},getConnection:()=>s,takePrepared(p,g){let v=R(p),h=i.get(v);return!h||h.sourceSignature!==U(g)?{handled:!1}:(c(v),{handled:!0,result:h.result})},onTransformed(p){c(R(p))},async delete(p){let g=R(p);c(g),await Dt(e.root,g,pe(e.options),null)},updateCssOnlySource:w,notifyStyles:()=>f()}}var ar=require("fs/promises");function sr(e){return e.rules.length>0||Object.keys(e.candidates).length>0||Object.keys(e.composites??{}).length>0}var or=require("fs"),se=require("path"),Jr=8,zr=256,Qe=0;function He(e,t=or.watch,r="Vite's watcher"){let n=new Map,s=new Map,o=new Map,a=!1,i=f=>{let S=o.get(f);S&&(clearTimeout(S),o.delete(f))},d=(f,S)=>{if(n.get(f)===S){n.delete(f),Qe--,S.watcher.close();for(let w of S.ids)s.delete(w),i(w);S.ids.clear()}},l=f=>{o.has(f)||o.size>=zr||o.set(f,setTimeout(()=>{o.delete(f),e(f)},2))},m=f=>{a=!0;for(let[S,w]of n)d(S,w);console.warn(`CSSX: native source watcher failed; using ${r}: ${f.message}`)};return{close:()=>{for(let[f,S]of n)d(f,S);s.clear();for(let f of o.values())clearTimeout(f);o.clear()},unwatch:f=>{let S=(0,se.resolve)(f);i(S);let w=s.get(S);if(!w)return;s.delete(S);let p=n.get(w);p?.ids.delete(S),p&&p.ids.size===0&&d(w,p)},watch:f=>{let S=(0,se.resolve)(f);if(a||s.has(S))return;let w=(0,se.dirname)(S),p=n.get(w);if(!p){if(Qe>=Jr)return;try{let g=new Set,v=t(w,{persistent:!1},(h,C)=>{let E=C===null?[...g]:[(0,se.resolve)(w,C.toString())].filter(P=>g.has(P));for(let P of E)l(P)});p={watcher:v,ids:g},n.set(w,p),Qe++,v.on("error",h=>{n.get(w)===p&&m(h)})}catch(g){m(g instanceof Error?g:new Error(String(g)));return}}p.ids.add(S),s.set(S,w)}}}var Gr=64,ir=256,qr=4;function lr(e,t,r,n){let s=new Map,o=new Map,a=[],i=!0,d=0,l=0,m,c,u=!1,y=(h,C)=>{if(s.size>=Gr&&!s.has(h)){let E=s.keys().next().value;E!==void 0&&s.delete(E)}s.set(h,C)},f=e.watcher?He(h=>{g(h)}):void 0,S=async h=>{d>=qr?await new Promise(C=>a.push(C)):d++;try{return await h()}finally{let C=a.shift();C?C():d--}},w=()=>i?(l++,m||(m=(async()=>{let h=-1;do{h=l;try{let C=await ne(t),E=D(C,t.cssFileName);E!==c&&(re(e,E),c=E)}catch(C){console.warn(`CSSX: Vite stylesheet update failed: ${C instanceof Error?C.message:String(C)}`)}}while(i&&h!==l)})().finally(()=>{m=void 0})),m):Promise.resolve(),p=async(h,C,E,P)=>{let N=r.get(C)?.cssOnlySignature;if(!(!i||!N))try{let x=P??await(0,ar.readFile)(C,"utf8"),b=U(x);if(!i)return;if(E===b||s.get(C)===b)return{sourceId:b,handled:!0};let O=r.get(C);return await n(x,h),r.get(C)?.cssOnlySignature!==N?(s.delete(C),O&&r.set(C,O),{sourceId:b,handled:!1}):(y(C,b),await w(),{sourceId:b,handled:!0})}catch(x){s.delete(C),console.warn(`CSSX: Vite stylesheet update failed: ${x instanceof Error?x.message:String(x)}`);return}},g=(h,C)=>{let E=R(h),P=o.get(E);if(P)return P.rerun=!0,C!==void 0&&(P.source=C),P.promise;if(o.size>=ir)return u||(u=!0,console.warn(`CSSX: Vite stylesheet update queue reached the ${ir}-path limit.`)),Promise.resolve(!1);let N={promise:Promise.resolve(!1),rerun:!1,source:C};return N.promise=(async()=>{let x=!1;do{if(N.rerun=!1,!i)return x;let b=N.source;N.source=void 0;let O=await S(()=>p(h,E,N.sourceId,b));O!==void 0?(N.sourceId=O.sourceId,x=O.handled):x=!1}while(i&&N.rerun);return x})().finally(()=>{o.delete(E)}),o.set(E,N),N.promise},v=()=>{i=!1,f?.close(),s.clear(),o.clear()};return e.watcher?.on("close",v),Ee(e,t),{close:v,delete(h){let C=R(h);s.delete(C),f?.unwatch(C)},isActive:()=>i,isPrepared:(h,C)=>s.get(R(h))===U(C),notifyStyles:w,onTransformed(h,C){let E=r.get(R(h));E&&sr(E)?(y(R(h),U(C)),f?.watch(h)):(s.delete(R(h)),f?.unwatch(h))},updateCssOnlySource:g}}var cr=require("path");function De(e,t){let r=JSON.stringify(`http://127.0.0.1:${e.port}/${e.token}`),n=JSON.stringify(t?`/${(0,cr.basename)(t)}`:"");return`if (typeof document !== "undefined") {
|
|
53
|
+
const key = "__cssxDevelopmentStylesheetHmr";
|
|
54
|
+
const state = globalThis[key] || (globalThis[key] = { installed: false, revision: -1, style: undefined });
|
|
55
|
+
if (!state.installed) {
|
|
56
|
+
state.installed = true;
|
|
57
|
+
state.refresh = async (revision, pushedCss) => {
|
|
58
|
+
if (state.refreshing) {
|
|
59
|
+
if (!state.pendingRevision || state.pendingRevision.revision < revision) {
|
|
60
|
+
state.pendingRevision = { revision, css: pushedCss };
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
state.refreshing = true;
|
|
65
|
+
try {
|
|
66
|
+
let css = pushedCss;
|
|
67
|
+
if (css === undefined) {
|
|
68
|
+
const response = await fetch(${r} + "/stylesheet?revision=" + revision, { cache: "no-store" });
|
|
69
|
+
if (!response.ok) return;
|
|
70
|
+
css = await response.text();
|
|
71
|
+
}
|
|
72
|
+
if (revision < state.revision) return;
|
|
73
|
+
const removeGeneratedRules = (owner) => {
|
|
74
|
+
let removed = false;
|
|
75
|
+
const rules = owner.cssRules;
|
|
76
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
77
|
+
const rule = rules[index];
|
|
78
|
+
if (rule.selectorText && /\\.(?:d[a-z0-9]+|s[a-z0-9]+x)\\b/.test(rule.selectorText)) {
|
|
79
|
+
owner.deleteRule(index);
|
|
80
|
+
removed = true;
|
|
81
|
+
} else if (rule.cssRules) {
|
|
82
|
+
removed = removeGeneratedRules(rule) || removed;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return removed;
|
|
86
|
+
};
|
|
87
|
+
const generatedSheets = state.generatedSheets;
|
|
88
|
+
const stylesheetCount = document.styleSheets.length - (state.style?.isConnected ? 1 : 0);
|
|
89
|
+
const sheetsChanged = generatedSheets !== undefined && (
|
|
90
|
+
stylesheetCount !== state.stylesheetCount ||
|
|
91
|
+
generatedSheets.some((sheet) => sheet.ownerNode && !sheet.ownerNode.isConnected)
|
|
92
|
+
);
|
|
93
|
+
if (generatedSheets === undefined || sheetsChanged) {
|
|
94
|
+
state.generatedSheets = [];
|
|
95
|
+
for (const sheet of document.styleSheets) {
|
|
96
|
+
if (sheet.ownerNode?.dataset?.cssxDevelopmentStylesheet !== undefined) continue;
|
|
97
|
+
try { if (removeGeneratedRules(sheet)) state.generatedSheets.push(sheet); } catch {}
|
|
98
|
+
}
|
|
99
|
+
state.stylesheetCount = stylesheetCount;
|
|
100
|
+
}
|
|
101
|
+
if (state.style?.isConnected) {
|
|
102
|
+
state.style.textContent = css;
|
|
103
|
+
} else {
|
|
104
|
+
const style = document.createElement("style");
|
|
105
|
+
style.dataset.cssxDevelopmentStylesheet = "";
|
|
106
|
+
style.textContent = css;
|
|
107
|
+
const cachedLink = state.stylesheetLink;
|
|
108
|
+
const stylesheetLink = ${n} ? (cachedLink?.isConnected ? cachedLink : [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
109
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${n}),
|
|
110
|
+
)) : undefined;
|
|
111
|
+
if (stylesheetLink) {
|
|
112
|
+
state.stylesheetLink = stylesheetLink;
|
|
113
|
+
stylesheetLink.after(style);
|
|
114
|
+
} else {
|
|
115
|
+
document.head.append(style);
|
|
116
|
+
}
|
|
117
|
+
state.style = style;
|
|
118
|
+
}
|
|
119
|
+
state.revision = revision;
|
|
120
|
+
} catch {}
|
|
121
|
+
finally {
|
|
122
|
+
state.refreshing = false;
|
|
123
|
+
const pending = state.pendingRevision;
|
|
124
|
+
state.pendingRevision = undefined;
|
|
125
|
+
if (pending !== undefined && pending.revision > state.revision) void state.refresh(pending.revision, pending.css);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
state.events = new EventSource(${r} + "/events");
|
|
129
|
+
state.events.onmessage = (event) => {
|
|
130
|
+
try {
|
|
131
|
+
const message = JSON.parse(event.data);
|
|
132
|
+
if (Number.isSafeInteger(message.revision) && message.revision > state.revision) {
|
|
133
|
+
void state.refresh(message.revision, message.css);
|
|
134
|
+
}
|
|
135
|
+
} catch {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}`}function dr(e,t,r){return r?De(r,e):`/* CSSX development stylesheet revision: ${t} */
|
|
139
|
+
if (typeof document !== "undefined" && typeof module !== "undefined" && module.hot) {
|
|
140
|
+
const key = "__cssxStylesheetHmr";
|
|
141
|
+
const state = globalThis[key] || (globalThis[key] = { revision: 0, staged: [], replacements: [] });
|
|
142
|
+
const stylesheetLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
143
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
144
|
+
);
|
|
145
|
+
const nextLink = stylesheetLink && (() => {
|
|
146
|
+
const path = new URL(stylesheetLink.href, document.baseURI).pathname;
|
|
147
|
+
return path.includes("/_next/");
|
|
148
|
+
})();
|
|
149
|
+
if (!state.installed) {
|
|
150
|
+
state.installed = true;
|
|
151
|
+
state.stage = () => {
|
|
152
|
+
const revision = ++state.revision;
|
|
153
|
+
state.staged = [];
|
|
154
|
+
state.replacements = [];
|
|
155
|
+
const links = [...document.querySelectorAll('link[rel="stylesheet"]')].filter((link) =>
|
|
156
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
157
|
+
);
|
|
158
|
+
return Promise.all(
|
|
159
|
+
links.map(
|
|
160
|
+
(link) =>
|
|
161
|
+
new Promise((resolve) => {
|
|
162
|
+
const replacement = link.cloneNode();
|
|
163
|
+
const url = new URL(link.href, document.baseURI);
|
|
164
|
+
url.searchParams.set("cssx", String(revision));
|
|
165
|
+
replacement.href = url.href;
|
|
166
|
+
const finish = (loaded) => {
|
|
167
|
+
replacement.removeEventListener("load", onLoad);
|
|
168
|
+
replacement.removeEventListener("error", onError);
|
|
169
|
+
if (loaded) {
|
|
170
|
+
state.staged.push(link);
|
|
171
|
+
if (state.removeOnLoad) link.remove();
|
|
172
|
+
}
|
|
173
|
+
else replacement.remove();
|
|
174
|
+
resolve();
|
|
175
|
+
};
|
|
176
|
+
const onLoad = () => finish(true);
|
|
177
|
+
const onError = () => finish(false);
|
|
178
|
+
replacement.addEventListener("load", onLoad);
|
|
179
|
+
replacement.addEventListener("error", onError);
|
|
180
|
+
state.replacements.push(replacement);
|
|
181
|
+
link.after(replacement);
|
|
182
|
+
}),
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
module.hot.addStatusHandler((status) => {
|
|
187
|
+
if (status === "prepare" || status === "dispose") {
|
|
188
|
+
return state.stage();
|
|
189
|
+
}
|
|
190
|
+
if (status === "idle") {
|
|
191
|
+
for (const link of state.staged) link.remove();
|
|
192
|
+
state.staged = [];
|
|
193
|
+
state.replacements = [];
|
|
194
|
+
}
|
|
195
|
+
if (status === "abort" || status === "fail") {
|
|
196
|
+
for (const replacement of state.replacements) replacement.remove();
|
|
197
|
+
state.staged = [];
|
|
198
|
+
state.replacements = [];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (nextLink) module.hot.accept(() => void state.stage());
|
|
202
|
+
for (const updateKey of Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith("webpackHotUpdate"))) {
|
|
203
|
+
const update = globalThis[updateKey];
|
|
204
|
+
if (typeof update !== "function") continue;
|
|
205
|
+
globalThis[updateKey] = function (...args) {
|
|
206
|
+
void state.stage();
|
|
207
|
+
return update.apply(this, args);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
if (stylesheetLink) state.removeOnLoad = Boolean(nextLink);
|
|
211
|
+
}
|
|
212
|
+
}`}0&&(module.exports={compileCssxStylesheet,compileViteDevelopmentStylesheet,configureViteDevelopmentServer,connectViteStylesheetClient,createRollupDevelopmentNotifier,createRollupDevelopmentRuntime,createViteDevelopmentRuntime,createViteNativeSourceWatcher,cssWithSourceMapComment,nativeStylesheetHmr,nextDevelopmentStylesheetHmr,publishNextDevelopmentStylesheet,sendViteStyles,startDevelopmentCoordinator,startNextDevelopmentServer,stopNextDevelopmentServer,viteDevelopmentStylesheetHmr,waitForNextDevelopmentStylesheet});
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { C as CssxPluginOptions } from './options-BbhZj-Sb.cjs';
|
|
2
|
+
import { c as compileCssxStylesheet } from './compile-cssx-stylesheet-CAnWFXMM.cjs';
|
|
3
|
+
import { M as ModuleCssxData } from './module-cssx-data-DfZiLJQL.cjs';
|
|
4
|
+
import { a as CssxStylesheet } from './stylesheet-types-mSM1XaBK.cjs';
|
|
5
|
+
import { N as NextDevelopmentHmrConnection } from './next-development-server-CBPFB9EC.cjs';
|
|
6
|
+
export { p as publishNextDevelopmentStylesheet, s as startNextDevelopmentServer, a as stopNextDevelopmentServer, w as waitForNextDevelopmentStylesheet } from './next-development-server-CBPFB9EC.cjs';
|
|
7
|
+
import { FSWatcher } from 'node:fs';
|
|
8
|
+
import '@cssxio/compiler';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adds a source map comment to CSS when a map exists.
|
|
12
|
+
*
|
|
13
|
+
* @param compiled Generated stylesheet data.
|
|
14
|
+
* @param fileName Name of the emitted CSS file.
|
|
15
|
+
* @returns CSS with a relative source map comment, or unchanged CSS without a map.
|
|
16
|
+
*/
|
|
17
|
+
declare function cssWithSourceMapComment(compiled: CssxStylesheet, fileName: string): string;
|
|
18
|
+
|
|
19
|
+
/** Callback invoked after one streamed response chunk is accepted. */
|
|
20
|
+
type WriteCallback = (error?: Error | null) => void;
|
|
21
|
+
/** Encoding accepted by Node's writable response methods. */
|
|
22
|
+
type WriteEncoding = BufferEncoding | WriteCallback;
|
|
23
|
+
/** Header values accepted by Node's HTTP/1 response methods. */
|
|
24
|
+
type ViteHtmlHeaderValue = number | string | readonly string[];
|
|
25
|
+
/** Header object or alternating name/value list accepted by writeHead. */
|
|
26
|
+
type ViteHtmlHeaders = Record<string, ViteHtmlHeaderValue | undefined> | readonly ViteHtmlHeaderValue[];
|
|
27
|
+
/** Minimal request fields used to identify browser document requests. */
|
|
28
|
+
interface ViteHtmlRequestLike {
|
|
29
|
+
readonly headers?: {
|
|
30
|
+
readonly accept?: string | readonly string[];
|
|
31
|
+
};
|
|
32
|
+
readonly method?: string;
|
|
33
|
+
readonly url?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Minimal response fields used to add a bridge to a bounded HTML response. */
|
|
36
|
+
interface ViteHtmlResponseLike {
|
|
37
|
+
end(chunk?: string | Uint8Array, encodingOrCallback?: WriteEncoding, callback?: WriteCallback): this;
|
|
38
|
+
getHeader(name: string): number | string | readonly string[] | undefined;
|
|
39
|
+
readonly headersSent?: boolean;
|
|
40
|
+
once(event: 'close' | 'finish', listener: () => void): this;
|
|
41
|
+
removeHeader(name: string): void;
|
|
42
|
+
write(chunk: string | Uint8Array, encodingOrCallback?: WriteEncoding, callback?: WriteCallback): boolean;
|
|
43
|
+
writeHead?(statusCode: number, statusMessageOrHeaders?: string | ViteHtmlHeaders, headers?: ViteHtmlHeaders): this;
|
|
44
|
+
flushHeaders?(): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** HTTP response surface shared by Vite's event and SSR bridge middlewares. */
|
|
48
|
+
interface ViteDevelopmentServerResponse extends ViteHtmlResponseLike {
|
|
49
|
+
on(event: 'close', listener: () => void): unknown;
|
|
50
|
+
setHeader(name: string, value: string): void;
|
|
51
|
+
}
|
|
52
|
+
/** Development server APIs used to serve and refresh the in-memory stylesheet. */
|
|
53
|
+
interface ViteServerLike {
|
|
54
|
+
/** Server configuration used to determine the base URL. */
|
|
55
|
+
readonly config: {
|
|
56
|
+
readonly base?: string;
|
|
57
|
+
readonly root?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Optional file watcher used to remove deleted modules. */
|
|
60
|
+
readonly watcher?: {
|
|
61
|
+
/** Registers listeners for normalized and backend-level file events. */
|
|
62
|
+
on(event: string, listener: (...args: any[]) => void): unknown;
|
|
63
|
+
};
|
|
64
|
+
/** Middleware stack that serves the development stylesheet and source map. */
|
|
65
|
+
readonly middlewares: {
|
|
66
|
+
/** Adds one development server middleware handler. */
|
|
67
|
+
use(handler: (request: ViteHtmlRequestLike, response: ViteDevelopmentServerResponse, next: () => void) => void): void;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Configuration captured by the Vite development server. */
|
|
71
|
+
interface ViteDevelopmentServerOptions {
|
|
72
|
+
/** Relative stylesheet output path. */
|
|
73
|
+
readonly cssFileName: string;
|
|
74
|
+
/** Project root used for project-wide scans. */
|
|
75
|
+
readonly root?: string;
|
|
76
|
+
/** Whether a stylesheet source map is served. */
|
|
77
|
+
readonly sourceMap: boolean;
|
|
78
|
+
/** CSSX compiler options used to generate the development stylesheet. */
|
|
79
|
+
readonly options: CssxPluginOptions;
|
|
80
|
+
/** Transformed module data retained while the server is running. */
|
|
81
|
+
readonly rollupDataById: Map<string, ModuleCssxData>;
|
|
82
|
+
/** Loads the active theme source. */
|
|
83
|
+
readonly getTheme: () => Promise<string | undefined>;
|
|
84
|
+
}
|
|
85
|
+
/** Registers the stylesheet-serving middleware and deleted-module watcher. */
|
|
86
|
+
declare function configureViteDevelopmentServer(server: ViteServerLike, configuration: ViteDevelopmentServerOptions): void;
|
|
87
|
+
/** Compiles the complete stylesheet from cached metadata for a push or stylesheet request. */
|
|
88
|
+
declare function compileViteDevelopmentStylesheet(configuration: ViteDevelopmentServerOptions): Promise<Awaited<ReturnType<typeof compileCssxStylesheet>>>;
|
|
89
|
+
|
|
90
|
+
/** Initializes the cached dev stylesheet and watches only directories with CSSX sources. */
|
|
91
|
+
declare function startDevelopmentCoordinator(root: string, styleSheetFile: string, options: CssxPluginOptions, connection: NextDevelopmentHmrConnection, isHandledByBundler?: (path: string) => boolean): Promise<() => void>;
|
|
92
|
+
|
|
93
|
+
/** Settings needed to publish cached Rollup stylesheet metadata during watch mode. */
|
|
94
|
+
interface RollupDevelopmentNotifierOptions {
|
|
95
|
+
/** CSS asset filename used for the source map comment. */
|
|
96
|
+
readonly cssFileName: string;
|
|
97
|
+
/** Reads the active theme source. */
|
|
98
|
+
readonly getTheme: () => Promise<string | undefined>;
|
|
99
|
+
/** Returns the active stylesheet transport after startup. */
|
|
100
|
+
readonly getConnection: () => NextDevelopmentHmrConnection | undefined | Promise<NextDevelopmentHmrConnection | undefined>;
|
|
101
|
+
/** Whether the initial watch build has completed. */
|
|
102
|
+
readonly isReady: () => boolean;
|
|
103
|
+
/** Development compiler options. */
|
|
104
|
+
readonly options: CssxPluginOptions;
|
|
105
|
+
/** Whether to emit a CSS source map. */
|
|
106
|
+
readonly sourceMap: boolean;
|
|
107
|
+
/** Transformed source metadata retained by this plugin instance. */
|
|
108
|
+
readonly dataById: Map<string, ModuleCssxData>;
|
|
109
|
+
}
|
|
110
|
+
/** Coalesces Rollup watch updates and publishes only distinct stylesheet revisions. */
|
|
111
|
+
declare function createRollupDevelopmentNotifier(configuration: RollupDevelopmentNotifierOptions): () => Promise<void>;
|
|
112
|
+
/** Owns the watch lifecycle and stylesheet transport for one Rollup development build. */
|
|
113
|
+
declare function createRollupDevelopmentRuntime<TTransformResult>(configuration: Omit<RollupDevelopmentNotifierOptions, 'getConnection' | 'isReady'> & {
|
|
114
|
+
readonly root: string;
|
|
115
|
+
readonly transformSource: (source: string, id: string) => Promise<TTransformResult>;
|
|
116
|
+
}): {
|
|
117
|
+
buildStart(): void;
|
|
118
|
+
buildEnd(): void;
|
|
119
|
+
closeWatcher: () => Promise<void>;
|
|
120
|
+
getConnection: () => NextDevelopmentHmrConnection | undefined;
|
|
121
|
+
takePrepared(id: string, source: string): {
|
|
122
|
+
readonly handled: boolean;
|
|
123
|
+
readonly result?: TTransformResult;
|
|
124
|
+
};
|
|
125
|
+
onTransformed(id: string): void;
|
|
126
|
+
delete(id: string): Promise<void>;
|
|
127
|
+
updateCssOnlySource: (id: string) => Promise<void>;
|
|
128
|
+
notifyStyles: () => Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** Creates and owns one Vite development transport and its bounded source watcher. */
|
|
132
|
+
declare function createViteDevelopmentRuntime(server: ViteServerLike, configuration: ViteDevelopmentServerOptions, dataById: Map<string, ModuleCssxData>, transformSource: (source: string, id: string) => Promise<unknown>): {
|
|
133
|
+
close: () => void;
|
|
134
|
+
delete(id: string): void;
|
|
135
|
+
isActive: () => boolean;
|
|
136
|
+
isPrepared: (id: string, source: string) => boolean;
|
|
137
|
+
notifyStyles: () => Promise<void>;
|
|
138
|
+
onTransformed(id: string, source: string): void;
|
|
139
|
+
updateCssOnlySource: (id: string, source?: string) => Promise<boolean>;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** Creates a browser bridge that replaces CSSX rules without waiting for JavaScript HMR. */
|
|
143
|
+
declare function nextDevelopmentStylesheetHmr(connection: NextDevelopmentHmrConnection, stylesheetName?: string): string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a browser-only Webpack/Rspack HMR bridge for manually linked CSSX assets.
|
|
147
|
+
*
|
|
148
|
+
* @param cssFileName Generated CSSX asset file name.
|
|
149
|
+
* @returns Browser HMR bridge source.
|
|
150
|
+
*/
|
|
151
|
+
declare function nativeStylesheetHmr(cssFileName: string, styleRevision: string, connection?: NextDevelopmentHmrConnection): string;
|
|
152
|
+
|
|
153
|
+
/** Writable response used by one connected browser stylesheet stream. */
|
|
154
|
+
interface ViteStylesheetStream {
|
|
155
|
+
/** Writes one SSE frame to the connected browser. */
|
|
156
|
+
write(chunk: string): void;
|
|
157
|
+
/** Sets response headers before streaming starts. */
|
|
158
|
+
setHeader(name: string, value: string): void;
|
|
159
|
+
/** Registers cleanup when the browser disconnects. */
|
|
160
|
+
on(event: 'close', listener: () => void): void;
|
|
161
|
+
}
|
|
162
|
+
/** Registers a browser on the Vite development stylesheet stream. */
|
|
163
|
+
declare function connectViteStylesheetClient(server: object, client: ViteStylesheetStream): void;
|
|
164
|
+
/** Pushes a complete stylesheet update to every connected development browser. */
|
|
165
|
+
declare function sendViteStyles(server: object, css: string): void;
|
|
166
|
+
|
|
167
|
+
/** Minimal injectable shape of Node's directory watcher for resource tests. */
|
|
168
|
+
type NativeWatch = (directory: string, options: {
|
|
169
|
+
readonly persistent: false;
|
|
170
|
+
}, listener: (eventType: 'change' | 'rename', fileName: string | Buffer | null) => void) => FSWatcher;
|
|
171
|
+
/** Watches only directories with transformed CSSX modules and coalesces saves. */
|
|
172
|
+
declare function createViteNativeSourceWatcher(onChange: (id: string) => void | Promise<void>, watch?: NativeWatch, fallbackWatcher?: string): {
|
|
173
|
+
close: () => void;
|
|
174
|
+
unwatch: (id: string) => void;
|
|
175
|
+
watch: (id: string) => void;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** Creates the browser bridge that atomically replaces the Vite development stylesheet. */
|
|
179
|
+
declare function viteDevelopmentStylesheetHmr(cssFileName: string, baseUrl?: string): string;
|
|
180
|
+
|
|
181
|
+
export { compileCssxStylesheet, compileViteDevelopmentStylesheet, configureViteDevelopmentServer, connectViteStylesheetClient, createRollupDevelopmentNotifier, createRollupDevelopmentRuntime, createViteDevelopmentRuntime, createViteNativeSourceWatcher, cssWithSourceMapComment, nativeStylesheetHmr, nextDevelopmentStylesheetHmr, sendViteStyles, startDevelopmentCoordinator, viteDevelopmentStylesheetHmr };
|