@cssxio/unplugin 0.4.0 → 0.4.2
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 +6 -0
- package/dist/chunk-VCJX4HRK.js +93 -0
- package/dist/esbuild.cjs +7 -7
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/{options-CHY4_3I-.d.cts → options-Cx1s2I5t.d.cts} +2 -0
- package/dist/{options-CHY4_3I-.d.ts → options-Cx1s2I5t.d.ts} +2 -0
- package/dist/rollup.cjs +6 -6
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +6 -6
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/vite.cjs +6 -6
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-7MEM7X4W.js +0 -93
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cssxio/unplugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Universal bundler plugin for CSSX.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"sideEffects": false,
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@babel/core": "^7.29.7",
|
|
53
|
-
"@cssxio/babel-plugin": "^0.2
|
|
54
|
-
"@cssxio/compiler": "^0.2
|
|
53
|
+
"@cssxio/babel-plugin": "^0.4.2",
|
|
54
|
+
"@cssxio/compiler": "^0.4.2",
|
|
55
55
|
"unplugin": "^3.3.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
package/dist/chunk-7MEM7X4W.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import{createClassNameAllocator as Q}from"@cssxio/compiler";import{createUnplugin as $e}from"unplugin";import{Buffer as Le}from"buffer";import{mkdir as Fe,unlink as Be,writeFile as je}from"fs/promises";import{basename as Ee,dirname as De,resolve as D}from"path";import{compileUtilities as te,createSelectorAliases as se}from"@cssxio/compiler";import{basename as ne}from"path";async function S(e,t,s,r=!0,n){let c=Object.create(null),f=Object.create(null),o=new Set,y=!0,i=new Map;for(let h of[...e].sort((l,u)=>l.id.localeCompare(u.id))){for(let[l,u]of Object.entries(h.candidates))if(l in c||(c[l]=u),h.id&&!i.has(l)){let p=h.origins?.[l];i.set(l,{id:h.id,line:p?.line??0,column:p?.column??0})}for(let[l,u]of Object.entries(h.composites??{})){let p=f[l];if(p&&p.join(" ")!==u.join(" "))throw new Error(`CSSX composite class collision for "${l}".`);f[l]=u}h.atomicClasses===void 0&&(y=!1);for(let l of h.atomicClasses??[])o.add(l)}let g=Object.keys(c).sort();if(g.length===0)return{css:""};let x=await te(g,h=>c[h],t,se(f),y?o:void 0,{darkMode:n}),a=x.css&&s?`@layer ${s}{`:"",d=`${a}${x.css}${a?"}":""}`,m=r?re(`${a}${x.prefixCss}`,x.entries,i):void 0;return{css:d,...m?{map:m}:{}}}function b(e,t){return e.map?`${e.css}
|
|
2
|
-
/*# sourceMappingURL=${ne(t)}.map */`:e.css}function R(e,t){return JSON.stringify({...e,file:t})}function re(e,t,s){let r=[...new Set(t.map(o=>s.get(o.candidate)?.id).filter(o=>!!o))].sort();if(r.length===0)return;let n=new Map(r.map((o,y)=>[o,y])),c=[],f=U({line:0,column:0},e);for(let o of t){let y=s.get(o.candidate);y&&c.push({...f,source:n.get(y.id),originalLine:y.line,originalColumn:y.column}),f=U(f,o.css)}return{version:3,sources:r,names:[],mappings:oe(c)}}function U(e,t){let s=t.split(`
|
|
3
|
-
`);return{line:e.line+s.length-1,column:s.at(-1).length+e.column*+(s.length===1)}}function oe(e){let t=Array.from({length:Math.max(0,...e.map(o=>o.line))+1},()=>[]),s=0,r=0,n=0,c=0,f=0;for(let o of e)f*=+(o.line===c),c=o.line,t[o.line]?.push(`${P(o.column-f)}${P(o.source-s)}${P(o.originalLine-r)}${P(o.originalColumn-n)}`),f=o.column,s=o.source,r=o.originalLine,n=o.originalColumn;return t.map(o=>o.join(",")).join(";")}var ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function P(e){let t="",s=e<0?-e<<1|1:e<<1;do{let r=s&31;s>>>=5,s&&(r|=32),t+=ae[r]}while(s);return t}import{readFile as ie}from"fs/promises";import{dirname as le,isAbsolute as de,normalize as ce,resolve as O,sep as H}from"path";async function v(e){return e.themeFile===void 0?e.theme:ie(O(process.cwd(),e.themeFile),"utf8")}function I(e){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")throw new Error('CSSX darkMode must be "media" or "selector".');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.');B(e.cssFileName??"cssx.css")}function F(e){let t=2166136261;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function k(e,t){return B(e).replaceAll("[hash]",F(t))}function $(e,t){return`${e&&e!=="/"?`/${e.replace(/^\/+|\/+$/g,"")}`:""}/${B(t).replaceAll(H,"/")}`}function L(e,t,s){return t.outdir?O(e,t.outdir,s):t.outfile?O(le(O(e,t.outfile)),s):O(e,s)}function w(e){return e.split("?",1).join("")}function B(e){if(!e||de(e))throw new Error("cssFileName must be a non-empty relative path.");let t=ce(e);if(t===".."||t.startsWith(`..${H}`))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 V(e,t,s){let r=e.getNativeBuildContext?.();if(!r||r.framework!=="webpack"&&r.framework!=="rspack")return;let n=r.loaderContext?._module;if(!n)return;let c=n.buildInfo??(n.buildInfo={});c[s]=t}function j(e,t,s,r,n,c,f,o){let y=e.name??e.options?.name;y==="server"||y==="edge-server"||e.hooks.thisCompilation.tap("@cssxio/unplugin",i=>{i.hooks.processAssets.tapPromise({name:"@cssxio/unplugin",stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},async()=>{let g=[...i.modules].map(m=>me(m,c)).filter(m=>m!==void 0),x=ue(g,f?.values()??[]),a=await S(x,await s(),r,n,o);if(!a.css)return;let d=k(t,a.css);if(i.getAsset?.(d))throw new Error(`CSSX CSS asset collision at "${d}".`);if(i.emitAsset(d,new e.webpack.sources.RawSource(b(a,d))),a.map){let m=`${d}.map`;if(i.getAsset?.(m))throw new Error(`CSSX CSS map asset collision at "${m}".`);i.emitAsset(m,new e.webpack.sources.RawSource(R(a.map,d)))}})})}function ue(e,t){let s=new Map,r=[];for(let n of t)n.id?s.set(n.id,n):r.push(n);for(let n of e)n.id?s.set(n.id,n):r.push(n);return[...s.values(),...r]}function me(e,t){let s=e.buildInfo?.[t];if(!s||typeof s!="object")return;let{id:r,candidates:n,composites:c,atomicClasses:f,origins:o}=s;return{id:typeof r=="string"?r:"",candidates:n&&typeof n=="object"?n:{},composites:c&&typeof c=="object"?c:{},...Array.isArray(f)?{atomicClasses:f}:{},origins:o&&typeof o=="object"?o:{}}}import{transformAsync as pe}from"@babel/core";import fe from"@cssxio/babel-plugin";import{compileUtilities as ye,createClassNameAllocator as ge,createSelectorAliases as he}from"@cssxio/compiler";var Ce=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro"]);async function M(e,t,s={},r){I(s);let n=s.importSource??"@cssxio/cssx",c=t.split("?",1).join("");if(!Ce.has(c.slice(c.lastIndexOf(".")))||!e.includes(n))return null;if(c.endsWith(".astro"))return xe(e,t,s);let f=await v(s),o=await pe(e,{babelrc:!1,configFile:!1,filename:c,parserOpts:{plugins:["jsx","typescript"]},plugins:[[fe,{importSource:n,classNameAllocator:s.classNameAllocator,theme:f,reusabilityBudget:s.reusabilityBudget,stableClassNames:s.stableClassNames,darkMode:s.darkMode}]],sourceMaps:!0,...r?{inputSourceMap:r}:{}}),y=o.metadata,{candidates:i,origins:g,composites:x,atomicClasses:a,cssOnlySignature:d}=y.cssx,m=Object.keys(i),h=m.length===0?"":(await ye(m,l=>i[l],f,he(x),new Set(a),{darkMode:s.darkMode})).css;return{code:o.code,rules:h?[ke(be(h,s.layer))]:[],candidates:i,composites:x,atomicClasses:a,origins:g,cssOnlySignature:d,map:o.map}}async function xe(e,t,s){let r=Se(e);if(r.length===0)return null;let n=s.classNameAllocator??ge(),c=s.importSource??"@cssxio/cssx",f={},o={},y=[],i=e;for(let g of[...r].reverse()){let x=await M(`import { sx } from ${JSON.stringify(c)};
|
|
4
|
-
const style = ${g.code};`,`${t}.ts`,{...s,classNameAllocator:n}),a=we(x.code);i=`${i.slice(0,g.start)}${a}${i.slice(g.end)}`,Object.assign(f,x.candidates),Object.assign(o,x.composites),y.push(...x.rules)}return{code:i,rules:y,candidates:f,composites:o,atomicClasses:[],origins:{},cssOnlySignature:i}}function Se(e){let t=[],s=/\bsx\s*\(/g;for(let r of e.matchAll(s)){let n=r.index,c=e.indexOf("(",n),f=0,o="";for(let y=c;y<e.length;y+=1){let i=e[y];if(o){i==="\\"?y+=1:i===o&&(o="");continue}if(i==='"'||i==="'"||i==="`")o=i;else if(i==="(")f+=1;else if(i===")"&&--f===0){t.push({start:n,end:y+1,code:e.slice(n,y+1)}),s.lastIndex=y+1;break}}}return t}function we(e){let t="const style = ",s=e.indexOf(t)+t.length,r=e.indexOf(";",s);return e.slice(s,r)}function _(e,t){if(!e||typeof e!="object")return;let s=e.getCombinedSourcemap;if(typeof s!="function")return;let r=s.call(e);if(!r||typeof r!="object")return;let n=r;if(!(n.version!==3||!Array.isArray(n.sources)||typeof n.mappings!="string"))return{version:n.version,sources:[...n.sources],names:[...n.names??[]],mappings:n.mappings,file:n.file??t.split("?",1).join(""),...n.sourceRoot?{sourceRoot:n.sourceRoot}:{},...n.sourcesContent?{sourcesContent:[...n.sourcesContent]}:{}}}function ke(e){return{className:`cssx-${F(e)}`,css:e}}function be(e,t){return e&&t?`@layer ${t}{${e}}`:e}function E(e,t,s=Date.now()){e.ws.send({type:"update",updates:[{type:"css-update",path:t,acceptedPath:t,timestamp:s}]})}import{Buffer as W}from"buffer";import{mkdir as ve,readFile as Me,realpath as Re,unlink as X,writeFile as q}from"fs/promises";import{basename as z,dirname as Oe,resolve as J}from"path";import{createClassNameAllocator as Ne}from"@cssxio/compiler";var Ae=/\.[cm]?[jt]sx?$/;function K(e={}){let t=new Map,s=Ne(),r,n;return{name:"@cssxio/unplugin",setup(c){let f=c.initialOptions.absWorkingDir??process.cwd();c.initialOptions.metafile=!0,c.onLoad({filter:Ae},async({path:o})=>{let y=await Me(o,"utf8"),i=await M(y,o,{...e,classNameAllocator:s});if(!i)return;let g=await G(o);return t.set(g,{id:g,candidates:i.candidates,composites:i.composites,atomicClasses:i.atomicClasses,origins:i.origins}),{contents:i.code,loader:Ie(o)}}),c.onEnd(async o=>{if(!o.metafile)return;let y=new Set(await Promise.all(Object.keys(o.metafile.inputs).map(m=>G(J(f,m)))));for(let m of t.keys())y.has(m)||t.delete(m);let i=await Pe([...t],e),g=L(f,c.initialOptions,k(e.cssFileName??"cssx.css",i.css));if(!i.css){r&&await X(r).catch(()=>{}),n&&await X(n).catch(()=>{}),r=void 0,n=void 0;return}let x=i.map?`${i.css}
|
|
5
|
-
/*# sourceMappingURL=${z(g)}.map */`:i.css,a=`${g}.map`,d=i.map?JSON.stringify({...i.map,file:z(g)}):void 0;if(c.initialOptions.write===!1){if(!o.outputFiles)return;if(o.outputFiles.some(m=>m.path===g))throw new Error(`CSSX CSS asset collision at "${g}".`);o.outputFiles.push({path:g,contents:W.from(x),hash:"",text:x}),d&&o.outputFiles.push({path:a,contents:W.from(d),hash:"",text:d});return}await ve(Oe(g),{recursive:!0}),await q(g,x),d&&await q(a,d),r=g,n=d?a:void 0})}}}async function Pe(e,t){let s=await v(t);return S(e.map(([,r])=>r),s,t.layer,t.sourceMap??!0,t.darkMode)}function Ie(e){return/\.tsx?$/.test(e)?"ts":"js"}async function G(e){return Re(e).catch(()=>J(e))}var N="@cssxio/unplugin/rules",Te=/\.(?:[cm]?[jt]sx?|astro)(?:\?.*)?$/,Z=new Map;function Ue(e,t){return`${e}\0${JSON.stringify(t)}`}function T(e,t){let s=Ue(e,t),r=Z.get(s);return r||(r={classNameAllocator:Q(),transformedDataById:new Map},Z.set(s,r)),r}function He(e){let t=e.getNativeBuildContext?.();return t&&(t.framework==="webpack"||t.framework==="rspack")?t.loaderContext?.rootContext??process.cwd():void 0}function Ve(e,t,s){let r=new Set;for(let n of t)e.moduleGraph?.invalidateModule(n,r,s,!0);for(let n of r){if(!n.id)continue;let c=e.runner?.evaluatedModules?.getModuleById(n.id);c&&e.runner?.evaluatedModules?.invalidateModule(c)}}function _e(e){return!e||typeof e!="object"?{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""}:We(e[N])}function We(e){if(!e||typeof e!="object")return{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""};let{id:t,rules:s,candidates:r,composites:n,atomicClasses:c,origins:f,cssOnlySignature:o}=e;return{id:typeof t=="string"?t:"",rules:Array.isArray(s)?s:[],candidates:r&&typeof r=="object"?r:{},composites:n&&typeof n=="object"?n:{},...Array.isArray(c)?{atomicClasses:c}:{},origins:f&&typeof f=="object"?f:{},cssOnlySignature:typeof o=="string"?o:""}}var Xe=(e={},t)=>{I(e);let s=e.cssFileName??"cssx.css",r=e.sourceMap??!0,n=new Map,c=Q(),f=new Map,o,y=process.cwd(),i,g=()=>v(e),x=async function(a,d){let m=new Set(Object.values(d).flatMap(p=>p.type==="chunk"?Object.keys(p.modules??{}):[]).map(w));if(t.framework!=="vite")for(let p of n.keys())m.has(p)||n.delete(p);let h=t.framework==="vite"?[...n.values()]:[...m].map(p=>{let C=_e(this.getModuleInfo(p)?.meta);return Object.keys(C.candidates).length>0?C:n.get(p)??C}),l=await S(h,await g(),e.layer,r,e.darkMode);if(!l.css)return;let u=k(s,l.css);if(Object.hasOwn(d,u))throw new Error(`CSSX CSS asset collision at "${u}".`);if(this.emitFile({type:"asset",fileName:u,source:b(l,u)}),l.map){let p=`${u}.map`;if(Object.hasOwn(d,p))throw new Error(`CSSX CSS map asset collision at "${p}".`);this.emitFile({type:"asset",fileName:p,source:R(l.map,u)})}};return{name:"@cssxio/unplugin",enforce:"pre",transform:{filter:{id:Te},async handler(a,d){e.themeFile&&this.addWatchFile?.(D(process.cwd(),e.themeFile));let m=He(this),h=m?T(m,e):void 0,l=await M(a,d,{...e,classNameAllocator:h?.classNameAllocator??c},_(this,d)),u={id:w(d),rules:l?.rules??[],candidates:l?.candidates??{},composites:l?.composites??{},atomicClasses:l?.atomicClasses??[],origins:l?.origins??{},cssOnlySignature:l?.cssOnlySignature??""};V(this,u,N);let p=w(d);(l||p===d)&&(n.set(p,u),f.set(D(y,p),u),h?.transformedDataById.set(p,u)),t.framework==="vite"&&i&&E(i,$("/",s));let C=l?.code??a;return{code:(t.framework==="webpack"||t.framework==="rspack")&&l?`${C}
|
|
6
|
-
${qe(s)}`:C,meta:{[N]:u},...l?.map?{map:l.map}:{}}}},watchChange(a,d){d.event==="delete"&&n.delete(w(a))},rollup:{generateBundle:x},vite:{generateBundle:x,configureServer(a){i=a;let d=$(a.config.base,s),m=$("/",s);a.watcher?.on("unlink",h=>{n.delete(w(h)),E(a,m)}),a.middlewares.use((h,l,u)=>{let p=h.url?.split("?",1)[0];if(p!==d&&(p!==`${d}.map`||!r))return u();g().then(C=>S([...n.values()],C,e.layer,r,e.darkMode)).then(C=>{if(p===`${d}.map`){l.setHeader("Content-Type","application/json; charset=utf-8"),l.setHeader("Cache-Control","no-store"),l.end(C.map?R(C.map,s):"");return}l.setHeader("Content-Type","text/css; charset=utf-8"),l.setHeader("Cache-Control","no-store"),l.end(b(C,s))}).catch(C=>{l.setHeader("Content-Type","text/plain; charset=utf-8"),l.end(C instanceof Error?C.message:"Unable to compile CSSX development stylesheet.")})})},hotUpdate:{order:"pre",async handler(a){let d=this.environment;if(!d||d.name==="client")return;let m=a.modules.filter(u=>{let p=n.get(w(u.id??""));return!!(p&&p.cssOnlySignature&&p.atomicClasses?.length===0)});if(m.length===0)return;let h=new Map(m.map(u=>[u,n.get(w(u.id)).cssOnlySignature]));for(let u of m)u.url&&await d.transformRequest(u.url);if(m.every(u=>{let p=n.get(w(u.id));return!!(p&&p.atomicClasses.length===0&&p.cssOnlySignature===h.get(u))}))return Ve(d,m,a.timestamp),a.modules.filter(u=>!m.includes(u))}}},...t.framework==="webpack"?{webpack(a){let d=T(a.context??a.options?.context??process.cwd(),e);j(a,s,g,e.layer,r,N,d.transformedDataById,e.darkMode)}}:{},...t.framework==="rspack"?{rspack(a){let d=T(a.context??a.options?.context??process.cwd(),e);j(a,s,g,e.layer,r,N,d.transformedDataById,e.darkMode)}}:{},...t.framework==="esbuild"?{esbuild:{config(a){a.metafile=!0},setup(a){let d=a.initialOptions.absWorkingDir??process.cwd();y=d,a.onEnd(async m=>{if(!m.metafile)return;let h=new Set(Object.keys(m.metafile.inputs).map(C=>D(d,C)));for(let C of f.keys())h.has(C)||f.delete(C);let l=await S([...f.values()],await g(),e.layer,r,e.darkMode),u=L(d,a.initialOptions,k(s,l.css));if(!l.css){o&&await Be(o).catch(()=>{}),o=void 0;return}let p=b(l,Ee(u));if(a.initialOptions.write===!1){let C=m.outputFiles;if(!C)return;let Y={path:u,contents:Le.from(p),hash:"",text:p};if(C.findIndex(ee=>ee.path===u)!==-1)throw new Error(`CSSX CSS asset collision at "${u}".`);C.push(Y);return}await Fe(De(u),{recursive:!0}),await je(u,p),o=u})}}}:{}}},A=$e(Xe);function qe(e){return`if (typeof document !== "undefined" && typeof module !== "undefined" && module.hot) {
|
|
7
|
-
const key = "__cssxStylesheetHmr";
|
|
8
|
-
const state = globalThis[key] || (globalThis[key] = { revision: 0, staged: [], replacements: [] });
|
|
9
|
-
const stylesheetLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
10
|
-
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
11
|
-
);
|
|
12
|
-
const nextLink = stylesheetLink && (() => {
|
|
13
|
-
const path = new URL(stylesheetLink.href, document.baseURI).pathname;
|
|
14
|
-
return path.includes("/_next/");
|
|
15
|
-
})();
|
|
16
|
-
if (!state.installed) {
|
|
17
|
-
state.installed = true;
|
|
18
|
-
state.stage = () => {
|
|
19
|
-
const revision = ++state.revision;
|
|
20
|
-
state.staged = [];
|
|
21
|
-
state.replacements = [];
|
|
22
|
-
const links = [...document.querySelectorAll('link[rel="stylesheet"]')].filter((link) =>
|
|
23
|
-
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
24
|
-
);
|
|
25
|
-
return Promise.all(
|
|
26
|
-
links.map(
|
|
27
|
-
(link) =>
|
|
28
|
-
new Promise((resolve) => {
|
|
29
|
-
const replacement = link.cloneNode();
|
|
30
|
-
const url = new URL(link.href, document.baseURI);
|
|
31
|
-
url.searchParams.set("cssx", String(revision));
|
|
32
|
-
replacement.href = url.href;
|
|
33
|
-
const finish = (loaded) => {
|
|
34
|
-
replacement.removeEventListener("load", onLoad);
|
|
35
|
-
replacement.removeEventListener("error", onError);
|
|
36
|
-
if (loaded) {
|
|
37
|
-
state.staged.push(link);
|
|
38
|
-
if (state.removeOnLoad) link.remove();
|
|
39
|
-
}
|
|
40
|
-
else replacement.remove();
|
|
41
|
-
resolve();
|
|
42
|
-
};
|
|
43
|
-
const onLoad = () => finish(true);
|
|
44
|
-
const onError = () => finish(false);
|
|
45
|
-
replacement.addEventListener("load", onLoad);
|
|
46
|
-
replacement.addEventListener("error", onError);
|
|
47
|
-
state.replacements.push(replacement);
|
|
48
|
-
link.after(replacement);
|
|
49
|
-
}),
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
module.hot.addStatusHandler((status) => {
|
|
54
|
-
if (status === "prepare" || status === "dispose") {
|
|
55
|
-
return state.stage();
|
|
56
|
-
}
|
|
57
|
-
if (status === "idle") {
|
|
58
|
-
for (const link of state.staged) link.remove();
|
|
59
|
-
state.staged = [];
|
|
60
|
-
state.replacements = [];
|
|
61
|
-
}
|
|
62
|
-
if (status === "abort" || status === "fail") {
|
|
63
|
-
for (const replacement of state.replacements) replacement.remove();
|
|
64
|
-
state.staged = [];
|
|
65
|
-
state.replacements = [];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
if (nextLink) module.hot.accept(() => void state.stage());
|
|
69
|
-
for (const updateKey of Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith("webpackHotUpdate"))) {
|
|
70
|
-
const update = globalThis[updateKey];
|
|
71
|
-
if (typeof update !== "function") continue;
|
|
72
|
-
globalThis[updateKey] = function (...args) {
|
|
73
|
-
void state.stage();
|
|
74
|
-
return update.apply(this, args);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (stylesheetLink) {
|
|
78
|
-
state.removeOnLoad = Boolean(nextLink);
|
|
79
|
-
const refresh = async () => {
|
|
80
|
-
try {
|
|
81
|
-
const url = new URL(stylesheetLink.href, document.baseURI);
|
|
82
|
-
url.searchParams.set("cssx-probe", String(Date.now()));
|
|
83
|
-
const css = await fetch(url.href, { cache: "no-store" }).then((response) => response.text());
|
|
84
|
-
if (state.css && state.css !== css) void state.stage();
|
|
85
|
-
state.css = css;
|
|
86
|
-
} catch {
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
void refresh();
|
|
90
|
-
state.poll = setInterval(() => void refresh(), 500);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}`}var Rt=A.vite,Ot=A.rollup,Nt=A.webpack,At=A.rspack,Pt=A;export{S as a,M as b,Xe as c,A as d,Rt as e,Ot as f,Nt as g,At as h,Pt as i,K as j};
|