@cssxio/unplugin 0.10.0 → 0.12.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-3C3MRH6A.js +1 -0
- package/dist/chunk-62JIYM5O.js +3 -0
- package/dist/chunk-6TMSHR6Z.js +1 -0
- package/dist/chunk-6WHEMH4N.js +1 -0
- package/dist/chunk-CUKIYXQD.js +1 -0
- package/dist/chunk-ERSPVOTN.js +1 -0
- package/dist/chunk-EWDPJYCI.js +1 -0
- package/dist/chunk-FBSYCQYI.js +1 -0
- package/dist/chunk-FNYQGV2A.js +1 -0
- package/dist/chunk-JFKLWSSR.js +5 -0
- package/dist/chunk-KLVVGFBR.js +2 -0
- package/dist/chunk-KR26IZKN.js +1 -0
- package/dist/chunk-M2QORA5D.js +5 -0
- package/dist/chunk-N3X67A2E.js +1 -0
- package/dist/chunk-P7NG4XOZ.js +0 -0
- package/dist/chunk-RMB4J65B.js +0 -0
- package/dist/chunk-SV3MUUMI.js +1 -0
- package/dist/chunk-VSO4AWLZ.js +1 -0
- package/dist/chunk-WIZLK3SX.js +1 -0
- package/dist/chunk-XCE7ZTGW.js +3 -0
- package/dist/chunk-YYF5QU33.js +1 -0
- package/dist/chunk-YZ7P3BSQ.js +1 -0
- package/dist/chunk-ZCSG362J.js +1 -0
- package/dist/chunk-ZDJ2ZX5V.js +1 -0
- package/dist/compile-cssx-stylesheet-BC4-zPLW.d.cts +17 -0
- package/dist/compile-cssx-stylesheet-CyrCVIOq.d.ts +17 -0
- package/dist/create-universal-esbuild-hooks-OCPLHVMY.js +1 -0
- package/dist/development-coordinator-6IH5C7KS.js +1 -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 +8 -134
- package/dist/index.d.ts +8 -134
- package/dist/index.js +1 -1
- package/dist/module-cssx-data-C58vi376.d.cts +12 -0
- package/dist/module-cssx-data-CeyCcQqm.d.ts +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-development-server-I7PSPICB.js +1 -0
- package/dist/next-loader.cjs +16 -15
- 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/project-scan-EIM7BVPC.js +1 -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-DF-aQ6hZ.d.cts +42 -0
- package/dist/stylesheet-types-DF-aQ6hZ.d.ts +42 -0
- package/dist/transform-astro-sx-HBUDGJ5K.js +2 -0
- package/dist/transform-babel-cssx-module-U4DGJILK.js +1 -0
- package/dist/transform-runtime.cjs +12 -0
- package/dist/transform-runtime.d.cts +114 -0
- package/dist/transform-runtime.d.ts +114 -0
- package/dist/transform-runtime.js +2 -0
- package/dist/transform-vue-sfc-ACOOMWIS.js +6 -0
- package/dist/try-transform-native-static-create-345K2PAR.js +1 -0
- package/dist/try-transform-native-static-sx-MGM7DLG4.js +1 -0
- package/dist/unplugin-factory-runtime.cjs +18 -0
- package/dist/unplugin-factory-runtime.d.cts +48 -0
- package/dist/unplugin-factory-runtime.d.ts +48 -0
- package/dist/unplugin-factory-runtime.js +1 -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/dist/with-class-name-manifest-455KRGHY.js +1 -0
- package/package.json +18 -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,181 @@
|
|
|
1
|
+
import { C as CssxPluginOptions } from './options-BbhZj-Sb.js';
|
|
2
|
+
import { c as compileCssxStylesheet } from './compile-cssx-stylesheet-CyrCVIOq.js';
|
|
3
|
+
import { M as ModuleCssxData } from './module-cssx-data-CeyCcQqm.js';
|
|
4
|
+
import { c as CssxStylesheet } from './stylesheet-types-DF-aQ6hZ.js';
|
|
5
|
+
import { N as NextDevelopmentHmrConnection } from './next-development-server-CBPFB9EC.js';
|
|
6
|
+
export { p as publishNextDevelopmentStylesheet, s as startNextDevelopmentServer, a as stopNextDevelopmentServer, w as waitForNextDevelopmentStylesheet } from './next-development-server-CBPFB9EC.js';
|
|
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 };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import{a as J}from"./chunk-FNYQGV2A.js";import{a as F,b as X,c as j,d as me}from"./chunk-M2QORA5D.js";import{a as V,b as q}from"./chunk-VSO4AWLZ.js";import{b as ne,d as se}from"./chunk-YZ7P3BSQ.js";import"./chunk-JFKLWSSR.js";import"./chunk-CUKIYXQD.js";import"./chunk-ZDJ2ZX5V.js";import"./chunk-6WHEMH4N.js";import"./chunk-P7NG4XOZ.js";import{a as M,b as te,c as D}from"./chunk-62JIYM5O.js";import"./chunk-6TMSHR6Z.js";import"./chunk-ERSPVOTN.js";import{c as re}from"./chunk-YYF5QU33.js";import{b as k,f as ee,i as W}from"./chunk-ZCSG362J.js";import"./chunk-3C3MRH6A.js";import"./chunk-SV3MUUMI.js";var oe=new WeakMap;function ie(e){let n=oe.get(e);return n||(n={revision:0,clients:new Set},oe.set(e,n)),n}function ae(e,n){e.write(`data: ${JSON.stringify(n)}
|
|
2
|
+
|
|
3
|
+
`)}function z(e,n){let s=ie(e);n.setHeader("Content-Type","text/event-stream; charset=utf-8"),n.setHeader("Cache-Control","no-cache, no-transform"),n.setHeader("Connection","keep-alive"),s.clients.add(n),n.write(`: connected
|
|
4
|
+
|
|
5
|
+
`),s.latest&&ae(n,s.latest),n.on("close",()=>s.clients.delete(n))}function U(e,n){let s=ie(e),a={css:n,revision:Math.max(Date.now(),s.revision+1)};s.revision=a.revision,s.latest=a;for(let t of s.clients)ae(t,a)}import{Buffer as I}from"buffer";function G(e,n){let s=JSON.stringify(`/${e.replaceAll("\\","/")}`),a=JSON.stringify(`${e.replaceAll("\\","/")}.events`);return`if (typeof document !== "undefined" && typeof EventSource !== "undefined") {
|
|
6
|
+
const key = "__cssxViteStylesheetHmr";
|
|
7
|
+
const state = globalThis[key] || (globalThis[key] = { installed: false, revision: 0, style: undefined, source: undefined, stylesheetLink: undefined });
|
|
8
|
+
if (!state.installed) {
|
|
9
|
+
state.installed = true;
|
|
10
|
+
const source = new EventSource(${n===void 0?"import.meta.env.BASE_URL":JSON.stringify(n)} + ${a});
|
|
11
|
+
state.source = source;
|
|
12
|
+
source.onmessage = (event) => {
|
|
13
|
+
const payload = JSON.parse(event.data);
|
|
14
|
+
if (!payload || typeof payload.css !== "string" || payload.revision <= state.revision) return;
|
|
15
|
+
if (state.style?.isConnected) {
|
|
16
|
+
state.style.textContent = payload.css;
|
|
17
|
+
} else {
|
|
18
|
+
const style = document.createElement("style");
|
|
19
|
+
style.dataset.cssxDevelopmentStylesheet = "";
|
|
20
|
+
style.textContent = payload.css;
|
|
21
|
+
const cachedLink = state.stylesheetLink;
|
|
22
|
+
const stylesheetLink = cachedLink?.isConnected ? cachedLink : [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
23
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${s}),
|
|
24
|
+
);
|
|
25
|
+
if (stylesheetLink) {
|
|
26
|
+
state.stylesheetLink = stylesheetLink;
|
|
27
|
+
stylesheetLink.after(style);
|
|
28
|
+
} else {
|
|
29
|
+
document.head.append(style);
|
|
30
|
+
}
|
|
31
|
+
state.style = style;
|
|
32
|
+
}
|
|
33
|
+
state.revision = payload.revision;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}`}var pe=1024*1024,ye=4096,he=8,le="data-cssx-vite-hmr";function B(e,n){if(!e)return;if(Array.isArray(e)){for(let a=0;a+1<e.length;a+=2)if(String(e[a]).toLowerCase()===n)return e[a+1];return}return Object.entries(e).find(([a])=>a.toLowerCase()===n)?.[1]}function ge(e){if(!e)return e;if(Array.isArray(e)){let n=[];for(let s=0;s+1<e.length;s+=2){let a=String(e[s]);a.toLowerCase()!=="content-length"&&a.toLowerCase()!=="etag"&&n.push(e[s],e[s+1])}return n}return Object.fromEntries(Object.entries(e).filter(([n])=>n.toLowerCase()!=="content-length"&&n.toLowerCase()!=="etag"))}function ve(e,n,s="/"){if(e.includes(le))return e;let a=`<script ${le}>${G(n,s)}</script>`,t=/<\/body\s*>/i,f=/<\/html\s*>/i;return t.test(e)?e.replace(t,y=>`${a}${y}`):f.test(e)?e.replace(f,y=>`${a}${y}`):`${e}${a}`}function de(e,n="/"){let s=0;return(a,t,f)=>{let y=a.headers?.accept,p=Array.isArray(y)?y.join(","):y;if(a.method!=="GET"||!p?.includes("text/html")||s>=he){f();return}s++;let v=!1,c=()=>{v||(v=!0,s--)},w=t.write.bind(t),h=t.end.bind(t),C=t.writeHead?.bind(t),T=t.flushHeaders?.bind(t),H=[],b=0,R=!1,l=t.getHeader("content-type"),u=t.getHeader("content-encoding"),m=t.getHeader("content-length"),r=t.getHeader("etag"),o=()=>{t.headersSent!==!0&&(t.removeHeader("content-length"),t.removeHeader("etag"),m=void 0,r=void 0)};C&&(t.writeHead=((d,i,S)=>{let x=typeof i=="string"?S:i;l=B(x,"content-type")??t.getHeader("content-type"),u=B(x,"content-encoding")??t.getHeader("content-encoding"),m=B(x,"content-length")??t.getHeader("content-length"),r=B(x,"etag")??t.getHeader("etag");let O=String(l??"").toLowerCase().startsWith("text/html")&&u===void 0,_=O?ge(x):x;return O&&(o(),m=void 0,r=void 0),typeof i=="string"?C(d,i,_):C(d,_)})),T&&(t.flushHeaders=(()=>{l=t.getHeader("content-type"),u=t.getHeader("content-encoding"),m=t.getHeader("content-length"),r=t.getHeader("etag"),String(l??"").toLowerCase().startsWith("text/html")&&u===void 0&&o(),T()}));let g=()=>{for(let d of H)w(d);H.length=0,b=0},L=(d,i,S)=>{let x=typeof i=="string"?i:void 0,N=typeof d=="string"?I.from(d,x):I.from(d);return b+N.byteLength>pe||H.length>=ye?(R=!0,g(),c(),!1):(H.push(N),b+=N.byteLength,(typeof i=="function"?i:S)?.(),!0)};t.once("close",()=>{H.length=0,b=0,c()}),t.once("finish",c),t.write=((d,i,S)=>R?typeof i=="function"?w(d,i):w(d,i,S):L(d,i,S)?!0:typeof i=="function"?w(d,i):w(d,i,S)),t.end=((d,i,S)=>{let x=typeof i=="function"?i:S;if(R||d!==void 0&&!L(d,typeof i=="string"?i:void 0))return typeof i=="function"?h(d,i):h(d,i,S);let N=String(l??t.getHeader("content-type")??"").toLowerCase(),O=u??t.getHeader("content-encoding"),_=N.startsWith("text/html")&&O===void 0,$=I.concat(H,b);if(_){let Q=$.toString("utf8"),Z=ve(Q,e,n);Z!==Q&&!(t.headersSent===!0&&(m!==void 0||r!==void 0))&&($=I.from(Z),o())}return H.length=0,b=0,x?h($,x):h($)}),f()}}function K(e,n){let{cssFileName:s,sourceMap:a,rollupDataById:t}=n,f=ee(e.config.base,s),y=`${f}.events`,p=de(s,e.config.base??"/");e.watcher?.on("unlink",v=>{t.delete(k(v)),A({...n,root:e.config.root??process.cwd()}).then(c=>U(e,D(c,s))).catch(c=>{console.warn(`CSSX: Vite stylesheet update failed: ${c instanceof Error?c.message:String(c)}`)})}),e.middlewares.use((v,c,w)=>{let h=v.url?.split("?",1)[0];if(h===y){z(e,c);return}if(h!==f&&(h!==`${f}.map`||!a))return p(v,c,w);A({...n,root:e.config.root??process.cwd()}).then(C=>{if(h===`${f}.map`){c.setHeader("Content-Type","application/json; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(C.map?te(C.map,s):"");return}c.setHeader("Content-Type","text/css; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(D(C,s))}).catch(C=>{c.setHeader("Content-Type","text/plain; charset=utf-8"),c.end(C instanceof Error?C.message:"Unable to compile CSSX development stylesheet.")})})}async function A(e){let{options:n,rollupDataById:s,getTheme:a}=e,t=await a(),f=n.coordination==="manifest"?await ne(e.root??process.cwd(),n):[...s.values()];return M(f,t,n.layer,e.sourceMap,n.darkMode,n.preflight)}import{readFile as Se}from"fs/promises";import{resolve as xe}from"path";var we=64,ce=16*1024*1024,Ce=256;function ue(e){let n=0,s,a;return()=>e.isReady()?(n++,s||(s=new Promise(t=>setImmediate(t)).then(async()=>{let t=-1;do{t=n;let f=await e.getConnection();if(!f)return;let y=W(e.options),p=await M([...e.dataById.values()],await e.getTheme(),y.layer,e.sourceMap,y.darkMode,y.preflight),v=D(p,e.cssFileName);v!==a&&(await j(f,v),a=v)}while(t!==n)}).catch(t=>{console.warn(`CSSX: Rollup stylesheet update failed: ${t instanceof Error?t.message:String(t)}`)}).finally(()=>{s=void 0})),s):Promise.resolve()}function He(e){let n=xe(e.root,".cssx/rollup.css"),s=!1,a=!1,t,f,y=!0,p=new Map,v=0,c=new Map,w,h=l=>{let u=p.get(l);u&&(v-=u.size,p.delete(l))},C=l=>{if(typeof l=="string")return l.length*2;if(!l||typeof l!="object")return 0;let u=l,m=typeof u.code=="string"?u.code.length*2:0,r=u.map===void 0?0:(JSON.stringify(u.map)?.length??0)*2;return m+r},T=(l,u,m)=>{let r=C(m);if(r>ce){h(l);return}for(h(l);p.size>=we||v+r>ce;){let o=p.keys().next().value;if(o===void 0)break;h(o)}p.set(l,{sourceSignature:V(u),result:m,size:r}),v+=r},H=ue({...e,getConnection:()=>t,isReady:()=>a}),b=async l=>{let u=k(l),m=e.dataById.get(u);if(!(!y||!m?.cssOnlySignature))try{let r=await Se(u,"utf8");if(p.get(u)?.sourceSignature===V(r))return;let o=await e.transformSource(r,l),g=e.dataById.get(u);if(!g||g.cssOnlySignature!==m.cssOnlySignature){h(u);return}T(u,r,o),await H()}catch(r){r.code!=="ENOENT"&&console.warn(`CSSX: Rollup stylesheet update failed: ${r instanceof Error?r.message:String(r)}`)}},R=l=>{if(!y)return Promise.resolve();let u=k(l);return!c.has(u)&&c.size>=Ce?Promise.resolve():(c.set(u,l),w||(w=(async()=>{for(;y&&c.size>0;){let m=c.entries().next().value;if(!m)break;c.delete(m[0]),await b(m[1])}})().finally(()=>{w=void 0;let m=c.values().next().value;y&&m!==void 0&&R(m)})),w)};return{buildStart(){s||(s=!0,t=F(e.root,n),f=J(e.root,n,W(e.options),t),f.catch(l=>{console.warn(`CSSX: Rollup development coordinator failed: ${String(l)}`)}))},buildEnd(){a=!0},closeWatcher:async()=>{await f?.then(l=>l(),()=>{}),y=!1,c.clear(),p.clear(),v=0,t&&X(e.root),t=void 0,f=void 0,s=!1,a=!1},getConnection:()=>t,takePrepared(l,u){let m=k(l),r=p.get(m);return!r||r.sourceSignature!==V(u)?{handled:!1}:(h(m),{handled:!0,result:r.result})},onTransformed(l){h(k(l))},async delete(l){let u=k(l);h(u),await se(e.root,u,W(e.options),null)},updateCssOnlySource:R,notifyStyles:()=>H()}}import{readFile as ke}from"fs/promises";var be=64,fe=256,Re=4;function Le(e,n,s,a){let t=new Map,f=new Map,y=[],p=!0,v=0,c=0,w,h,C=!1,T=(r,o)=>{if(t.size>=be&&!t.has(r)){let g=t.keys().next().value;g!==void 0&&t.delete(g)}t.set(r,o)},H=e.watcher?q(r=>{u(r)}):void 0,b=async r=>{v>=Re?await new Promise(o=>y.push(o)):v++;try{return await r()}finally{let o=y.shift();o?o():v--}},R=()=>p?(c++,w||(w=(async()=>{let r=-1;do{r=c;try{let o=await A(n),g=D(o,n.cssFileName);g!==h&&(U(e,g),h=g)}catch(o){console.warn(`CSSX: Vite stylesheet update failed: ${o instanceof Error?o.message:String(o)}`)}}while(p&&r!==c)})().finally(()=>{w=void 0})),w):Promise.resolve(),l=async(r,o,g,L)=>{let d=s.get(o)?.cssOnlySignature;if(!(!p||!d))try{let i=L??await ke(o,"utf8"),S=V(i);if(!p)return;if(g===S||t.get(o)===S)return{sourceId:S,handled:!0};let x=s.get(o);return await a(i,r),s.get(o)?.cssOnlySignature!==d?(t.delete(o),x&&s.set(o,x),{sourceId:S,handled:!1}):(T(o,S),await R(),{sourceId:S,handled:!0})}catch(i){t.delete(o),console.warn(`CSSX: Vite stylesheet update failed: ${i instanceof Error?i.message:String(i)}`);return}},u=(r,o)=>{let g=k(r),L=f.get(g);if(L)return L.rerun=!0,o!==void 0&&(L.source=o),L.promise;if(f.size>=fe)return C||(C=!0,console.warn(`CSSX: Vite stylesheet update queue reached the ${fe}-path limit.`)),Promise.resolve(!1);let d={promise:Promise.resolve(!1),rerun:!1,source:o};return d.promise=(async()=>{let i=!1;do{if(d.rerun=!1,!p)return i;let S=d.source;d.source=void 0;let x=await b(()=>l(r,g,d.sourceId,S));x!==void 0?(d.sourceId=x.sourceId,i=x.handled):i=!1}while(p&&d.rerun);return i})().finally(()=>{f.delete(g)}),f.set(g,d),d.promise},m=()=>{p=!1,H?.close(),t.clear(),f.clear()};return e.watcher?.on("close",m),K(e,n),{close:m,delete(r){let o=k(r);t.delete(o),H?.unwatch(o)},isActive:()=>p,isPrepared:(r,o)=>t.get(k(r))===V(o),notifyStyles:R,onTransformed(r,o){let g=s.get(k(r));g&&re(g)?(T(k(r),V(o)),H?.watch(r)):(t.delete(k(r)),H?.unwatch(r))},updateCssOnlySource:u}}import{basename as De}from"path";function Y(e,n){let s=JSON.stringify(`http://127.0.0.1:${e.port}/${e.token}`),a=JSON.stringify(n?`/${De(n)}`:"");return`if (typeof document !== "undefined") {
|
|
37
|
+
const key = "__cssxDevelopmentStylesheetHmr";
|
|
38
|
+
const state = globalThis[key] || (globalThis[key] = { installed: false, revision: -1, style: undefined });
|
|
39
|
+
if (!state.installed) {
|
|
40
|
+
state.installed = true;
|
|
41
|
+
state.refresh = async (revision, pushedCss) => {
|
|
42
|
+
if (state.refreshing) {
|
|
43
|
+
if (!state.pendingRevision || state.pendingRevision.revision < revision) {
|
|
44
|
+
state.pendingRevision = { revision, css: pushedCss };
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
state.refreshing = true;
|
|
49
|
+
try {
|
|
50
|
+
let css = pushedCss;
|
|
51
|
+
if (css === undefined) {
|
|
52
|
+
const response = await fetch(${s} + "/stylesheet?revision=" + revision, { cache: "no-store" });
|
|
53
|
+
if (!response.ok) return;
|
|
54
|
+
css = await response.text();
|
|
55
|
+
}
|
|
56
|
+
if (revision < state.revision) return;
|
|
57
|
+
const removeGeneratedRules = (owner) => {
|
|
58
|
+
let removed = false;
|
|
59
|
+
const rules = owner.cssRules;
|
|
60
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
61
|
+
const rule = rules[index];
|
|
62
|
+
if (rule.selectorText && /\\.(?:d[a-z0-9]+|s[a-z0-9]+x)\\b/.test(rule.selectorText)) {
|
|
63
|
+
owner.deleteRule(index);
|
|
64
|
+
removed = true;
|
|
65
|
+
} else if (rule.cssRules) {
|
|
66
|
+
removed = removeGeneratedRules(rule) || removed;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return removed;
|
|
70
|
+
};
|
|
71
|
+
const generatedSheets = state.generatedSheets;
|
|
72
|
+
const stylesheetCount = document.styleSheets.length - (state.style?.isConnected ? 1 : 0);
|
|
73
|
+
const sheetsChanged = generatedSheets !== undefined && (
|
|
74
|
+
stylesheetCount !== state.stylesheetCount ||
|
|
75
|
+
generatedSheets.some((sheet) => sheet.ownerNode && !sheet.ownerNode.isConnected)
|
|
76
|
+
);
|
|
77
|
+
if (generatedSheets === undefined || sheetsChanged) {
|
|
78
|
+
state.generatedSheets = [];
|
|
79
|
+
for (const sheet of document.styleSheets) {
|
|
80
|
+
if (sheet.ownerNode?.dataset?.cssxDevelopmentStylesheet !== undefined) continue;
|
|
81
|
+
try { if (removeGeneratedRules(sheet)) state.generatedSheets.push(sheet); } catch {}
|
|
82
|
+
}
|
|
83
|
+
state.stylesheetCount = stylesheetCount;
|
|
84
|
+
}
|
|
85
|
+
if (state.style?.isConnected) {
|
|
86
|
+
state.style.textContent = css;
|
|
87
|
+
} else {
|
|
88
|
+
const style = document.createElement("style");
|
|
89
|
+
style.dataset.cssxDevelopmentStylesheet = "";
|
|
90
|
+
style.textContent = css;
|
|
91
|
+
const cachedLink = state.stylesheetLink;
|
|
92
|
+
const stylesheetLink = ${a} ? (cachedLink?.isConnected ? cachedLink : [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
93
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${a}),
|
|
94
|
+
)) : undefined;
|
|
95
|
+
if (stylesheetLink) {
|
|
96
|
+
state.stylesheetLink = stylesheetLink;
|
|
97
|
+
stylesheetLink.after(style);
|
|
98
|
+
} else {
|
|
99
|
+
document.head.append(style);
|
|
100
|
+
}
|
|
101
|
+
state.style = style;
|
|
102
|
+
}
|
|
103
|
+
state.revision = revision;
|
|
104
|
+
} catch {}
|
|
105
|
+
finally {
|
|
106
|
+
state.refreshing = false;
|
|
107
|
+
const pending = state.pendingRevision;
|
|
108
|
+
state.pendingRevision = undefined;
|
|
109
|
+
if (pending !== undefined && pending.revision > state.revision) void state.refresh(pending.revision, pending.css);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
state.events = new EventSource(${s} + "/events");
|
|
113
|
+
state.events.onmessage = (event) => {
|
|
114
|
+
try {
|
|
115
|
+
const message = JSON.parse(event.data);
|
|
116
|
+
if (Number.isSafeInteger(message.revision) && message.revision > state.revision) {
|
|
117
|
+
void state.refresh(message.revision, message.css);
|
|
118
|
+
}
|
|
119
|
+
} catch {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}`}function Ve(e,n,s){return s?Y(s,e):`/* CSSX development stylesheet revision: ${n} */
|
|
123
|
+
if (typeof document !== "undefined" && typeof module !== "undefined" && module.hot) {
|
|
124
|
+
const key = "__cssxStylesheetHmr";
|
|
125
|
+
const state = globalThis[key] || (globalThis[key] = { revision: 0, staged: [], replacements: [] });
|
|
126
|
+
const stylesheetLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
|
|
127
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
128
|
+
);
|
|
129
|
+
const nextLink = stylesheetLink && (() => {
|
|
130
|
+
const path = new URL(stylesheetLink.href, document.baseURI).pathname;
|
|
131
|
+
return path.includes("/_next/");
|
|
132
|
+
})();
|
|
133
|
+
if (!state.installed) {
|
|
134
|
+
state.installed = true;
|
|
135
|
+
state.stage = () => {
|
|
136
|
+
const revision = ++state.revision;
|
|
137
|
+
state.staged = [];
|
|
138
|
+
state.replacements = [];
|
|
139
|
+
const links = [...document.querySelectorAll('link[rel="stylesheet"]')].filter((link) =>
|
|
140
|
+
new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
|
|
141
|
+
);
|
|
142
|
+
return Promise.all(
|
|
143
|
+
links.map(
|
|
144
|
+
(link) =>
|
|
145
|
+
new Promise((resolve) => {
|
|
146
|
+
const replacement = link.cloneNode();
|
|
147
|
+
const url = new URL(link.href, document.baseURI);
|
|
148
|
+
url.searchParams.set("cssx", String(revision));
|
|
149
|
+
replacement.href = url.href;
|
|
150
|
+
const finish = (loaded) => {
|
|
151
|
+
replacement.removeEventListener("load", onLoad);
|
|
152
|
+
replacement.removeEventListener("error", onError);
|
|
153
|
+
if (loaded) {
|
|
154
|
+
state.staged.push(link);
|
|
155
|
+
if (state.removeOnLoad) link.remove();
|
|
156
|
+
}
|
|
157
|
+
else replacement.remove();
|
|
158
|
+
resolve();
|
|
159
|
+
};
|
|
160
|
+
const onLoad = () => finish(true);
|
|
161
|
+
const onError = () => finish(false);
|
|
162
|
+
replacement.addEventListener("load", onLoad);
|
|
163
|
+
replacement.addEventListener("error", onError);
|
|
164
|
+
state.replacements.push(replacement);
|
|
165
|
+
link.after(replacement);
|
|
166
|
+
}),
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
module.hot.addStatusHandler((status) => {
|
|
171
|
+
if (status === "prepare" || status === "dispose") {
|
|
172
|
+
return state.stage();
|
|
173
|
+
}
|
|
174
|
+
if (status === "idle") {
|
|
175
|
+
for (const link of state.staged) link.remove();
|
|
176
|
+
state.staged = [];
|
|
177
|
+
state.replacements = [];
|
|
178
|
+
}
|
|
179
|
+
if (status === "abort" || status === "fail") {
|
|
180
|
+
for (const replacement of state.replacements) replacement.remove();
|
|
181
|
+
state.staged = [];
|
|
182
|
+
state.replacements = [];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
if (nextLink) module.hot.accept(() => void state.stage());
|
|
186
|
+
for (const updateKey of Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith("webpackHotUpdate"))) {
|
|
187
|
+
const update = globalThis[updateKey];
|
|
188
|
+
if (typeof update !== "function") continue;
|
|
189
|
+
globalThis[updateKey] = function (...args) {
|
|
190
|
+
void state.stage();
|
|
191
|
+
return update.apply(this, args);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (stylesheetLink) state.removeOnLoad = Boolean(nextLink);
|
|
195
|
+
}
|
|
196
|
+
}`}export{M as compileCssxStylesheet,A as compileViteDevelopmentStylesheet,K as configureViteDevelopmentServer,z as connectViteStylesheetClient,ue as createRollupDevelopmentNotifier,He as createRollupDevelopmentRuntime,Le as createViteDevelopmentRuntime,q as createViteNativeSourceWatcher,D as cssWithSourceMapComment,Ve as nativeStylesheetHmr,Y as nextDevelopmentStylesheetHmr,j as publishNextDevelopmentStylesheet,U as sendViteStyles,J as startDevelopmentCoordinator,F as startNextDevelopmentServer,X as stopNextDevelopmentServer,G as viteDevelopmentStylesheetHmr,me as waitForNextDevelopmentStylesheet};
|