@csszyx/unplugin 0.16.0 → 0.17.1
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 +1 -1
- package/dist/index.cjs +15 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +14 -4
- package/dist/jest-transform.cjs +186 -0
- package/dist/jest-transform.d.cts +112 -0
- package/dist/jest-transform.d.mts +110 -0
- package/dist/jest-transform.mjs +175 -0
- package/dist/next-prebuild.cjs +7 -6
- package/dist/next-prebuild.d.cts +12 -2
- package/dist/next-prebuild.d.mts +12 -2
- package/dist/next-prebuild.mjs +6 -5
- package/dist/next-turbo-loader.cjs +11 -9
- package/dist/next-turbo-loader.d.cts +1 -1
- package/dist/next-turbo-loader.d.mts +1 -1
- package/dist/next-turbo-loader.mjs +8 -6
- package/dist/next-watcher.cjs +124 -15
- package/dist/next-watcher.d.cts +16 -3
- package/dist/next-watcher.d.mts +16 -3
- package/dist/next-watcher.mjs +124 -15
- package/dist/shared/{unplugin.C-oQU1jl.mjs → unplugin.2uf-U76p.mjs} +1 -1
- package/dist/shared/{unplugin.BWnmKv07.cjs → unplugin.BKID6KXV.cjs} +5 -1
- package/dist/shared/{unplugin.PKo7wFzu.d.cts → unplugin.BO2_hyS3.d.cts} +38 -5
- package/dist/shared/{unplugin.DH_ij6cf.mjs → unplugin.Ba3O1r8M.mjs} +2 -6
- package/dist/shared/unplugin.BqKLlo1h.cjs +8 -0
- package/dist/shared/{unplugin.Vn9x8SBP.mjs → unplugin.C3bgc29e.mjs} +3 -2
- package/dist/shared/{unplugin.Ceq-N4jI.mjs → unplugin.CK-DfKTP.mjs} +21 -111
- package/dist/shared/{unplugin.COlI0dJs.d.mts → unplugin.C_2R8vIk.d.cts} +1 -1
- package/dist/shared/unplugin.CcSfaIVx.mjs +13547 -0
- package/dist/shared/{unplugin.rWOMecQs.d.cts → unplugin.CfXjAV63.d.mts} +1 -1
- package/dist/shared/{unplugin.J6ue_lRJ.cjs → unplugin.D0tMgokL.cjs} +24 -115
- package/dist/shared/{unplugin.DDSWQJYX.cjs → unplugin.DS6CFjim.cjs} +3 -8
- package/dist/shared/{unplugin.gksolKh2.cjs → unplugin.DXzIP7lP.cjs} +5 -4
- package/dist/shared/unplugin.DZdsqdQa.cjs +13635 -0
- package/dist/shared/unplugin.DcXM9sq5.mjs +109 -0
- package/dist/shared/unplugin.Defu9wGh.cjs +115 -0
- package/dist/shared/{unplugin.Bu2rzRtv.d.mts → unplugin.DptK3pl4.d.mts} +38 -5
- package/dist/shared/{unplugin.BGog1Bib.d.cts → unplugin.XdPo6azz.d.cts} +3 -0
- package/dist/shared/{unplugin.BGog1Bib.d.mts → unplugin.XdPo6azz.d.mts} +3 -0
- package/dist/shared/{unplugin.BzF0V2kw.cjs → unplugin.YcnV3Izb.cjs} +6 -6
- package/dist/shared/{unplugin.BLptVbUe.mjs → unplugin.eCo7_znv.mjs} +4 -2
- package/dist/shared/unplugin.wMeicb6E.mjs +6 -0
- package/dist/vite.cjs +14 -4
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +14 -4
- package/dist/webpack.cjs +14 -4
- package/dist/webpack.d.cts +1 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +14 -4
- package/package.json +22 -11
- package/dist/shared/unplugin.D3yBoTHP.cjs +0 -5462
- package/dist/shared/unplugin.Dx0ngYWw.mjs +0 -5381
package/dist/next-watcher.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { N as NextStateContext } from './shared/unplugin.
|
|
2
|
-
|
|
1
|
+
import { N as NextStateContext } from './shared/unplugin.XdPo6azz.mjs';
|
|
2
|
+
export { c as NEXT_WATCH_LOCK_COMMAND } from './shared/unplugin.XdPo6azz.mjs';
|
|
3
|
+
import { a as NextWatcherCycleOptions, N as NextWatcherCycleResult } from './shared/unplugin.CfXjAV63.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -11,6 +12,8 @@ type NextWatcherLoopCycleRunner = (context: NextStateContext, options: NextWatch
|
|
|
11
12
|
interface NextWatcherLoopTimerHooks {
|
|
12
13
|
setTimeout?: (callback: () => void, delayMs: number) => WatcherTimer;
|
|
13
14
|
clearTimeout?: (timer: WatcherTimer) => void;
|
|
15
|
+
/** Clock that times a wait on the loader's lock; `Date.now` by default. */
|
|
16
|
+
now?: () => number;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/** Filesystem events that can change the materialized safelist. */
|
|
@@ -22,6 +25,8 @@ interface NextSafelistWatcherOptions extends NextWatcherLoopTimerHooks {
|
|
|
22
25
|
debounceMs?: number;
|
|
23
26
|
runCycle?: NextWatcherLoopCycleRunner;
|
|
24
27
|
onError?: (error: unknown) => void;
|
|
28
|
+
/** Receives a notice the watcher keeps running through; dropped by default. */
|
|
29
|
+
onWarn?: (message: string) => void;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Validate one watcher event path against the flat safelist shard directory.
|
|
@@ -75,8 +80,16 @@ declare class NextSafelistWatcher {
|
|
|
75
80
|
get lastError(): unknown;
|
|
76
81
|
/**
|
|
77
82
|
* Materialize existing shards before accepting live filesystem events.
|
|
83
|
+
*
|
|
84
|
+
* `next watch` and `next dev` start together in the documented setup, so
|
|
85
|
+
* the Turbopack loader's first compile can hold the state lock at this
|
|
86
|
+
* exact moment. The initial cycle is then queued behind it instead of
|
|
87
|
+
* throwing, the same way a scheduled cycle waits.
|
|
88
|
+
*
|
|
89
|
+
* @returns The initial cycle's result, or `undefined` while it is queued
|
|
90
|
+
* behind the Turbopack loader.
|
|
78
91
|
*/
|
|
79
|
-
start(): NextWatcherCycleResult;
|
|
92
|
+
start(): NextWatcherCycleResult | undefined;
|
|
80
93
|
/**
|
|
81
94
|
* Queue a materialization cycle for one relevant shard filesystem event.
|
|
82
95
|
*
|
package/dist/next-watcher.mjs
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
|
-
import { r as runNextWatcherCycle } from './shared/unplugin.
|
|
2
|
+
import { r as runNextWatcherCycle, b as NextSafelistStateLockedError, a as NEXT_TURBO_LOADER_LOCK_COMMAND } from './shared/unplugin.eCo7_znv.mjs';
|
|
3
|
+
export { d as NEXT_WATCH_LOCK_COMMAND } from './shared/unplugin.eCo7_znv.mjs';
|
|
3
4
|
import 'node:fs';
|
|
4
|
-
import './shared/unplugin.
|
|
5
|
+
import './shared/unplugin.Ba3O1r8M.mjs';
|
|
5
6
|
import 'node:crypto';
|
|
7
|
+
import './shared/unplugin.wMeicb6E.mjs';
|
|
6
8
|
import 'node:os';
|
|
7
9
|
import 'proper-lockfile';
|
|
8
10
|
|
|
11
|
+
const LOADER_LOCK_RETRY_MIN_MS = 50;
|
|
12
|
+
const LOADER_LOCK_WARN_AFTER_MS = 1e3;
|
|
13
|
+
const LOADER_LOCK_GIVE_UP_AFTER_MS = 6e4;
|
|
14
|
+
function isHeldByTurbopackLoader(error) {
|
|
15
|
+
return error instanceof NextSafelistStateLockedError && error.holder.command === NEXT_TURBO_LOADER_LOCK_COMMAND;
|
|
16
|
+
}
|
|
9
17
|
class NextWatcherLoop {
|
|
10
18
|
context;
|
|
11
19
|
cycleOptions;
|
|
@@ -13,10 +21,15 @@ class NextWatcherLoop {
|
|
|
13
21
|
runCycle;
|
|
14
22
|
setTimeoutFn;
|
|
15
23
|
clearTimeoutFn;
|
|
24
|
+
nowFn;
|
|
16
25
|
onError;
|
|
26
|
+
onWarn;
|
|
17
27
|
timer;
|
|
18
28
|
disposed = false;
|
|
19
29
|
pendingReasons = /* @__PURE__ */ new Set();
|
|
30
|
+
/** When the current wait on the loader's lock began; unset while not waiting. */
|
|
31
|
+
loaderWaitStartedAt;
|
|
32
|
+
loaderWaitWarned = false;
|
|
20
33
|
lastResult;
|
|
21
34
|
lastError;
|
|
22
35
|
/**
|
|
@@ -30,7 +43,9 @@ class NextWatcherLoop {
|
|
|
30
43
|
this.runCycle = options.runCycle ?? runNextWatcherCycle;
|
|
31
44
|
this.setTimeoutFn = options.setTimeout ?? setTimeout;
|
|
32
45
|
this.clearTimeoutFn = options.clearTimeout ?? clearTimeout;
|
|
46
|
+
this.nowFn = options.now ?? Date.now;
|
|
33
47
|
this.onError = options.onError;
|
|
48
|
+
this.onWarn = options.onWarn;
|
|
34
49
|
}
|
|
35
50
|
/**
|
|
36
51
|
*
|
|
@@ -53,17 +68,7 @@ class NextWatcherLoop {
|
|
|
53
68
|
return;
|
|
54
69
|
}
|
|
55
70
|
this.pendingReasons.add(reason);
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.timer = this.setTimeoutFn(() => {
|
|
60
|
-
try {
|
|
61
|
-
this.runPendingCycle();
|
|
62
|
-
} catch (error) {
|
|
63
|
-
this.lastError = error;
|
|
64
|
-
this.onError?.(error);
|
|
65
|
-
}
|
|
66
|
-
}, this.debounceMs);
|
|
71
|
+
this.schedule(this.debounceMs);
|
|
67
72
|
}
|
|
68
73
|
/**
|
|
69
74
|
*
|
|
@@ -74,6 +79,32 @@ class NextWatcherLoop {
|
|
|
74
79
|
}
|
|
75
80
|
return this.runPendingCycle();
|
|
76
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Run the pending cycle now, or queue it when the Turbopack loader holds the
|
|
84
|
+
* lock.
|
|
85
|
+
*
|
|
86
|
+
* `flush` throws on every failure, which is what closing needs. Starting
|
|
87
|
+
* needs this instead: `next watch` and `next dev` start together, so the
|
|
88
|
+
* loader's first compile can hold the lock exactly when the initial cycle
|
|
89
|
+
* runs, and that overlap is not a failure.
|
|
90
|
+
*
|
|
91
|
+
* @returns The cycle result, or `undefined` when nothing was pending or the
|
|
92
|
+
* cycle is queued behind the loader.
|
|
93
|
+
*/
|
|
94
|
+
flushOrQueue() {
|
|
95
|
+
if (this.disposed || this.timer === void 0) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
const reasons = [...this.pendingReasons];
|
|
99
|
+
try {
|
|
100
|
+
return this.runPendingCycle();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (this.waitForLoader(error, reasons)) {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
77
108
|
/**
|
|
78
109
|
*
|
|
79
110
|
*/
|
|
@@ -85,6 +116,75 @@ class NextWatcherLoop {
|
|
|
85
116
|
this.pendingReasons.clear();
|
|
86
117
|
this.disposed = true;
|
|
87
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Run the pending cycle after `delayMs`, unless a run is already scheduled.
|
|
121
|
+
*
|
|
122
|
+
* @param delayMs - How long to wait before running it.
|
|
123
|
+
*/
|
|
124
|
+
schedule(delayMs) {
|
|
125
|
+
if (this.timer !== void 0) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.timer = this.setTimeoutFn(() => {
|
|
129
|
+
const reasons = [...this.pendingReasons];
|
|
130
|
+
try {
|
|
131
|
+
this.runPendingCycle();
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (this.waitForLoader(error, reasons)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.lastError = error;
|
|
137
|
+
this.onError?.(error);
|
|
138
|
+
}
|
|
139
|
+
}, delayMs);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Queue a cycle again when it failed only because the Turbopack loader holds
|
|
143
|
+
* the lock.
|
|
144
|
+
*
|
|
145
|
+
* Retried, not dropped: the loader's pass read the shards as they stood when
|
|
146
|
+
* it began, and the event that woke this cycle may be newer. The wait is
|
|
147
|
+
* timed from the first refusal, says so once when it runs long, and ends in
|
|
148
|
+
* a reported failure when it runs longer than any live loader could explain.
|
|
149
|
+
*
|
|
150
|
+
* @param error - What the cycle threw.
|
|
151
|
+
* @param reasons - The reasons the failed cycle carried, queued again with it.
|
|
152
|
+
* @returns True when nothing should be reported: the cycle is queued, or the
|
|
153
|
+
* loop was disposed meanwhile.
|
|
154
|
+
*/
|
|
155
|
+
waitForLoader(error, reasons) {
|
|
156
|
+
if (!isHeldByTurbopackLoader(error)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const now = this.nowFn();
|
|
160
|
+
this.loaderWaitStartedAt ??= now;
|
|
161
|
+
const waited = now - this.loaderWaitStartedAt;
|
|
162
|
+
if (waited > LOADER_LOCK_GIVE_UP_AFTER_MS) {
|
|
163
|
+
this.endLoaderWait();
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
if (waited >= LOADER_LOCK_WARN_AFTER_MS && !this.loaderWaitWarned) {
|
|
167
|
+
this.loaderWaitWarned = true;
|
|
168
|
+
const warn = this.onWarn ?? (() => {
|
|
169
|
+
});
|
|
170
|
+
warn(
|
|
171
|
+
`[csszyx] next watch is waiting for the safelist lock held by the Turbopack loader (process ${error.holder.pid}). Classes added meanwhile get no CSS until it is released; a lock left by a loader that exited is recovered within 30 s.`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (this.disposed) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
for (const reason of reasons) {
|
|
178
|
+
this.pendingReasons.add(reason);
|
|
179
|
+
}
|
|
180
|
+
this.schedule(Math.max(this.debounceMs, LOADER_LOCK_RETRY_MIN_MS));
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
/** Forget the current wait on the loader, once a cycle gets through or gives up. */
|
|
184
|
+
endLoaderWait() {
|
|
185
|
+
this.loaderWaitStartedAt = void 0;
|
|
186
|
+
this.loaderWaitWarned = false;
|
|
187
|
+
}
|
|
88
188
|
/**
|
|
89
189
|
*
|
|
90
190
|
*/
|
|
@@ -99,6 +199,7 @@ class NextWatcherLoop {
|
|
|
99
199
|
const result = this.runCycle(this.context, this.cycleOptions, reasons);
|
|
100
200
|
this.lastResult = result;
|
|
101
201
|
this.lastError = void 0;
|
|
202
|
+
this.endLoaderWait();
|
|
102
203
|
return result;
|
|
103
204
|
}
|
|
104
205
|
}
|
|
@@ -152,6 +253,14 @@ class NextSafelistWatcher {
|
|
|
152
253
|
}
|
|
153
254
|
/**
|
|
154
255
|
* Materialize existing shards before accepting live filesystem events.
|
|
256
|
+
*
|
|
257
|
+
* `next watch` and `next dev` start together in the documented setup, so
|
|
258
|
+
* the Turbopack loader's first compile can hold the state lock at this
|
|
259
|
+
* exact moment. The initial cycle is then queued behind it instead of
|
|
260
|
+
* throwing, the same way a scheduled cycle waits.
|
|
261
|
+
*
|
|
262
|
+
* @returns The initial cycle's result, or `undefined` while it is queued
|
|
263
|
+
* behind the Turbopack loader.
|
|
155
264
|
*/
|
|
156
265
|
start() {
|
|
157
266
|
if (this.closed) {
|
|
@@ -162,8 +271,8 @@ class NextSafelistWatcher {
|
|
|
162
271
|
}
|
|
163
272
|
this.started = true;
|
|
164
273
|
this.loop.notify("initial");
|
|
165
|
-
const result = this.loop.
|
|
166
|
-
if (!result) {
|
|
274
|
+
const result = this.loop.flushOrQueue();
|
|
275
|
+
if (!result && !this.loop.pending) {
|
|
167
276
|
throw new Error("[csszyx] Next safelist watcher failed to run its initial cycle.");
|
|
168
277
|
}
|
|
169
278
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import { extractCrossModuleRegistryEntries, extractCrossModuleForwards } from '@csszyx/compiler';
|
|
3
|
-
import { n as normalizePathSeparators } from './unplugin.
|
|
3
|
+
import { n as normalizePathSeparators } from './unplugin.wMeicb6E.mjs';
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
5
|
import { existsSync, statSync } from 'node:fs';
|
|
6
6
|
import { createHash, randomUUID } from 'node:crypto';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
const fs = require('node:fs');
|
|
5
|
-
const safelistSource = require('./unplugin.
|
|
5
|
+
const safelistSource = require('./unplugin.DS6CFjim.cjs');
|
|
6
6
|
const node_crypto = require('node:crypto');
|
|
7
7
|
const node_os = require('node:os');
|
|
8
8
|
const lockfile = require('proper-lockfile');
|
|
@@ -326,6 +326,8 @@ class NextSafelistStateLockedError extends Error {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
const NEXT_WATCH_LOCK_COMMAND = "csszyx next watch";
|
|
329
|
+
const NEXT_TURBO_LOADER_LOCK_COMMAND = "csszyx next turbo-loader";
|
|
330
|
+
const NEXT_PREBUILD_LOCK_COMMAND = "csszyx next prebuild";
|
|
329
331
|
function formatLiveLockError(metadata) {
|
|
330
332
|
return [
|
|
331
333
|
`csszyx Next safelist state is already locked by process ${metadata.pid}.`,
|
|
@@ -593,6 +595,8 @@ function runNextWatcherCycle(context, options = {}) {
|
|
|
593
595
|
}
|
|
594
596
|
}
|
|
595
597
|
|
|
598
|
+
exports.NEXT_PREBUILD_LOCK_COMMAND = NEXT_PREBUILD_LOCK_COMMAND;
|
|
599
|
+
exports.NEXT_TURBO_LOADER_LOCK_COMMAND = NEXT_TURBO_LOADER_LOCK_COMMAND;
|
|
596
600
|
exports.NEXT_WATCH_LOCK_COMMAND = NEXT_WATCH_LOCK_COMMAND;
|
|
597
601
|
exports.NextSafelistStateLockedError = NextSafelistStateLockedError;
|
|
598
602
|
exports.createNextStateContext = createNextStateContext;
|
|
@@ -523,6 +523,14 @@ interface PluginState {
|
|
|
523
523
|
* by a raw selector consumer.
|
|
524
524
|
*/
|
|
525
525
|
ownedClasses: Set<string>;
|
|
526
|
+
/**
|
|
527
|
+
* Owned classes that a mangle map WOULD carry: `ownedClasses` minus the
|
|
528
|
+
* authored ones and minus `manglePreserve`. Recorded whether or not
|
|
529
|
+
* mangling runs, because the bundle manifest lists them either way and used
|
|
530
|
+
* to read them off the map's keys — which is why the map had to be
|
|
531
|
+
* allocated on a build that never mangles.
|
|
532
|
+
*/
|
|
533
|
+
mangleEligible: string[];
|
|
526
534
|
/**
|
|
527
535
|
* Classes written through author-facing class/className attributes. Any
|
|
528
536
|
* overlap with ownedClasses must keep its original name because bundled
|
|
@@ -751,9 +759,18 @@ declare function unscopedMonorepoMessage(): string;
|
|
|
751
759
|
/**
|
|
752
760
|
* Whether a diagnostic is an advisory one — the class a build may hold back.
|
|
753
761
|
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
762
|
+
* Advisory means one thing: the styles are THERE, and the note is about how
|
|
763
|
+
* they got there. An `sz`-site nudge fallback took the runtime path where a
|
|
764
|
+
* compiled one was possible; the precedence advisory says which of two sources
|
|
765
|
+
* won. Everything else describes output that is absent or dead, and a
|
|
766
|
+
* production build has to print it.
|
|
767
|
+
*
|
|
768
|
+
* Asked positively on purpose. The predicate used to be "not one of three known
|
|
769
|
+
* kinds", which quietly made every key and value diagnostic advisory: a
|
|
770
|
+
* production build of a file with five typo'd keys printed nothing but a census
|
|
771
|
+
* calling them fallbacks, while `csszyx check` on the same tree named all six.
|
|
772
|
+
* A classifier written by exclusion cannot stay right as diagnostics are added,
|
|
773
|
+
* because a new one joins the silent side by default.
|
|
757
774
|
*
|
|
758
775
|
* @param message - One raw diagnostic line as an engine emitted it.
|
|
759
776
|
* @returns True when the diagnostic is advisory rather than a build result.
|
|
@@ -772,7 +789,7 @@ declare function isAdvisoryDiagnostic(message: string): boolean;
|
|
|
772
789
|
* Suppression is the right default; implying zero is not. One line costs
|
|
773
790
|
* nothing and keeps the difference visible.
|
|
774
791
|
*
|
|
775
|
-
* @param count - Advisory
|
|
792
|
+
* @param count - Advisory notes the build declined to list.
|
|
776
793
|
* @returns The disclosure, or null when nothing was held back.
|
|
777
794
|
*/
|
|
778
795
|
declare function suppressedAdvisoryMessage(count: number): string | null;
|
|
@@ -807,6 +824,22 @@ declare function resolveQuietMode(quiet: boolean | 'nudges' | QuietMode | undefi
|
|
|
807
824
|
* @returns true when the warning should be printed.
|
|
808
825
|
*/
|
|
809
826
|
declare function shouldEmitWarning(quiet: QuietMode, devOnly: boolean, isProduction: boolean): boolean;
|
|
827
|
+
/**
|
|
828
|
+
* Emit one key or value diagnostic — the family that says a class is dead.
|
|
829
|
+
*
|
|
830
|
+
* Its own channel because the two that existed both answer a different
|
|
831
|
+
* question: `emitMissingCssFallback` handles fallback sites, and the advisory
|
|
832
|
+
* channel handles notes about styles that ARE present. A typo'd key matched
|
|
833
|
+
* neither, so a production build dropped it on the floor while `csszyx check`
|
|
834
|
+
* on the same tree exited 1 and named it. Muted only by `quiet: true`, on the
|
|
835
|
+
* same reasoning as the missing-css channel: wrong output is not a usage nudge.
|
|
836
|
+
*
|
|
837
|
+
* @param quiet - Resolved quiet mode.
|
|
838
|
+
* @param message - Compiler diagnostic to classify and emit.
|
|
839
|
+
* @param id - Bundler module identifier included in the warning.
|
|
840
|
+
* @param emit - Warning output channel.
|
|
841
|
+
*/
|
|
842
|
+
declare function emitKeyValueDiagnostic(quiet: QuietMode, message: string, id: string, emit: (message: string) => void): void;
|
|
810
843
|
/**
|
|
811
844
|
* Whether a transform diagnostic describes missing CSS and may be printed.
|
|
812
845
|
*
|
|
@@ -1079,5 +1112,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
1079
1112
|
*/
|
|
1080
1113
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
1081
1114
|
|
|
1082
|
-
export {
|
|
1115
|
+
export { isPackagesSkippedSource as $, unplugin as A, deleteRSCModuleRecord as B, emitKeyValueDiagnostic as D, emitMissingCssFallback as E, esbuildPlugin as F, extractGlobalVarAliasesForManifest as H, fileMayContainSafelistableSz as I, findLocalImportSources as J, findRSCBoundaryViolation as K, findRSCGraphViolation as L, hasInjectableTailwindCandidate as N, hasTokens as O, hasUseClientDirective as T, hasUseServerDirective as U, isAdvisoryDiagnostic as W, isCompileSourceOptedIn as X, isHardIgnoredPath as Y, isMangleableCssId as Z, isMonorepoPackage as _, isRSCServerModule as a0, lateMangleCensusMessage as a1, mangleCodeClassesSync as a2, mangleEligibleClasses as a3, mangleHybridHazardMessage as a4, mergeThemes as a5, missingTailwindEntryMessage as a6, normalizeGlobalVarAliasesForCache as a7, parseThemeBlocks as a8, parseUtilityBlocks as a9, realContentHashDisabledMessage as aa, recordGlobalVarSourceFile as ab, resolveCompileSourceDirs as ac, resolveNativeCacheIdentity as ad, resolveQuietMode as ae, rollupPlugin as af, scanCustomPropertyNames as ag, shouldEmitMissingCssFallback as ah, shouldEmitWarning as ai, shouldHoldAdvisories as aj, shouldTrackGlobalVarSources as ak, shouldWarnMissingTailwindEntry as al, shouldWarnUnscopedMonorepo as am, skippedSzFilesMessage as an, suppressedAdvisoryMessage as ao, unscopedMonorepoMessage as ap, vitePlugin as aq, watchModeMangleMessage as ar, webpackPlugin as as, allocateMangleTokens as t, assertNoRSCBoundaryViolation as u, assertNoRSCGraphViolation as v, collectMangleHybridHazards as w, createGlobalVarMapAssetSource as x, createRSCModuleRecord as y, cssHasContentScope as z };
|
|
1083
1116
|
export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, QuietMode as Q, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n, MangleSelectorHazard as o, ParsedTheme as p, ParsedUtilities as q, RSCBoundaryViolation as r, RSCModuleRecord as s };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
import { n as normalizePathSeparators } from './unplugin.wMeicb6E.mjs';
|
|
4
5
|
|
|
5
6
|
function sortStrings(values) {
|
|
6
7
|
return [...values].sort((a, b) => {
|
|
@@ -10,11 +11,6 @@ function sortStrings(values) {
|
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
|
|
14
|
-
function normalizePathSeparators(value) {
|
|
15
|
-
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
const DEFAULT_RENAME_RETRIES = 5;
|
|
19
15
|
const DEFAULT_RENAME_RETRY_DELAY_MS = 10;
|
|
20
16
|
function isRetryableRenameError(error) {
|
|
@@ -255,4 +251,4 @@ function cssImportsTailwind(code) {
|
|
|
255
251
|
return TAILWIND_IMPORT.test(stripCssBlockComments(code));
|
|
256
252
|
}
|
|
257
253
|
|
|
258
|
-
export { SAFELIST_FILE as S, appendTailwindSourceDirective as a, cssImportsTailwind as b, computeSafelistRelPath as c, atomicWriteFileSync as d, removeLegacySafelists as e, findPostcssConfigWithoutCsszyx as f, assertNoLegacySourceStylesheet as g, stripCssBlockComments as h, findLegacySourceDirective as i, legacySourceMessage as l, missingPostcssPluginMessage as m,
|
|
254
|
+
export { SAFELIST_FILE as S, appendTailwindSourceDirective as a, cssImportsTailwind as b, computeSafelistRelPath as c, atomicWriteFileSync as d, removeLegacySafelists as e, findPostcssConfigWithoutCsszyx as f, assertNoLegacySourceStylesheet as g, stripCssBlockComments as h, findLegacySourceDirective as i, legacySourceMessage as l, missingPostcssPluginMessage as m, renderSafelistFile as r, sortStrings as s };
|
|
@@ -2,9 +2,10 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { extractCrossModuleForwards, extractCrossModuleRegistryEntries, ensureRustTransformAvailable, transformRust, transformWasm, transform } from '@csszyx/compiler';
|
|
4
4
|
import { DEFAULT_IMPORTED_STATIC_SZ } from '@csszyx/types';
|
|
5
|
-
import { c as collectSpecifierAliases, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, b as recordResolvedEntry, f as forwardVisitKey, M as MAX_FORWARD_HOPS, d as isReadableProviderFile, e as createTransformCacheKey, g as readTransformCache, w as writeTransformCache } from './unplugin.
|
|
6
|
-
import { n as normalizePathSeparators
|
|
5
|
+
import { c as collectSpecifierAliases, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, b as recordResolvedEntry, f as forwardVisitKey, M as MAX_FORWARD_HOPS, d as isReadableProviderFile, e as createTransformCacheKey, g as readTransformCache, w as writeTransformCache } from './unplugin.2uf-U76p.mjs';
|
|
6
|
+
import { n as normalizePathSeparators } from './unplugin.wMeicb6E.mjs';
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
|
+
import { s as sortStrings } from './unplugin.Ba3O1r8M.mjs';
|
|
8
9
|
|
|
9
10
|
function resolveImportedStaticSz(value) {
|
|
10
11
|
return value ?? DEFAULT_IMPORTED_STATIC_SZ;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
2
|
import path__default from 'node:path';
|
|
3
|
-
import { s as sortStrings } from './unplugin.
|
|
3
|
+
import { s as sortStrings } from './unplugin.Ba3O1r8M.mjs';
|
|
4
4
|
|
|
5
5
|
const EMPTY_THEME = {
|
|
6
6
|
colors: [],
|
|
@@ -266,26 +266,6 @@ function scanCustomPropertyNames(block) {
|
|
|
266
266
|
return names;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
const LEADING_WHITESPACE_RE = /^\s+/;
|
|
270
|
-
const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
|
|
271
|
-
const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
|
|
272
|
-
const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
|
|
273
|
-
function insertAfterUseDirective(code, insertion) {
|
|
274
|
-
let offset = 0;
|
|
275
|
-
while (offset < code.length) {
|
|
276
|
-
const triviaLength = leadingTriviaLength(code.slice(offset));
|
|
277
|
-
if (triviaLength === 0) break;
|
|
278
|
-
offset += triviaLength;
|
|
279
|
-
}
|
|
280
|
-
const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
|
|
281
|
-
if (!directive) return `${insertion}${code}`;
|
|
282
|
-
const insertionOffset = offset + directive[0].length;
|
|
283
|
-
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
284
|
-
}
|
|
285
|
-
function leadingTriviaLength(source) {
|
|
286
|
-
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
269
|
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
290
270
|
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
291
271
|
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
@@ -330,7 +310,7 @@ export default checksum;
|
|
|
330
310
|
`;
|
|
331
311
|
}
|
|
332
312
|
function isVirtualModule(id) {
|
|
333
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
313
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID || id === UNSERVED_VIRTUAL_ID;
|
|
334
314
|
}
|
|
335
315
|
function resolveVirtualModule(id) {
|
|
336
316
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -345,14 +325,32 @@ function resolveVirtualModule(id) {
|
|
|
345
325
|
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
346
326
|
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
347
327
|
}
|
|
328
|
+
if (id === UNSERVED_VIRTUAL_ID) {
|
|
329
|
+
return RESOLVED_UNSERVED_VIRTUAL_ID;
|
|
330
|
+
}
|
|
348
331
|
return void 0;
|
|
349
332
|
}
|
|
350
333
|
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
351
334
|
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
335
|
+
const UNSERVED_VIRTUAL_ID = "virtual:csszyx/unserved";
|
|
336
|
+
const RESOLVED_UNSERVED_VIRTUAL_ID = `\0${UNSERVED_VIRTUAL_ID}`;
|
|
352
337
|
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
353
338
|
const CENSUS_PLACEHOLDER = "___CSSZYX_CENSUS___";
|
|
354
339
|
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
355
340
|
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
341
|
+
const UNSERVED_PLACEHOLDER = "___CSSZYX_UNSERVED___";
|
|
342
|
+
function createUnservedRuntimeModule(classes) {
|
|
343
|
+
return `/**
|
|
344
|
+
* Auto-generated by csszyx: registers the class names this project's Tailwind
|
|
345
|
+
* produces no CSS for.
|
|
346
|
+
*
|
|
347
|
+
* @generated
|
|
348
|
+
*/
|
|
349
|
+
import { registerUnservedClasses } from '@csszyx/runtime';
|
|
350
|
+
|
|
351
|
+
registerUnservedClasses(${classes === void 0 ? UNSERVED_PLACEHOLDER : JSON.stringify(classes)});
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
356
354
|
function createMangleRuntimeModule(globalVarAliasPrefix, exposeDebugGlobal = false) {
|
|
357
355
|
return `/**
|
|
358
356
|
* Auto-generated by csszyx: registers the runtime mangle map from the bundle.
|
|
@@ -389,94 +387,6 @@ function createThemeGroupsModule(tokens) {
|
|
|
389
387
|
].join("\n");
|
|
390
388
|
}
|
|
391
389
|
|
|
392
|
-
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
393
|
-
function clauseNames(clauseBody) {
|
|
394
|
-
const names = [];
|
|
395
|
-
for (const part of clauseBody.split(",")) {
|
|
396
|
-
const trimmed = part.trim();
|
|
397
|
-
if (!trimmed) {
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
const spaceAt = trimmed.search(/\s/);
|
|
401
|
-
names.push(spaceAt === -1 ? trimmed : trimmed.slice(0, spaceAt));
|
|
402
|
-
}
|
|
403
|
-
return names;
|
|
404
|
-
}
|
|
405
|
-
function importsRuntimeHelper(code, helper) {
|
|
406
|
-
RUNTIME_IMPORT_CLAUSE_RE.lastIndex = 0;
|
|
407
|
-
for (let match = RUNTIME_IMPORT_CLAUSE_RE.exec(code); match; match = RUNTIME_IMPORT_CLAUSE_RE.exec(code)) {
|
|
408
|
-
if (clauseNames(match[1]).includes(helper)) {
|
|
409
|
-
return true;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
const RUNTIME_IMPORT_APPEND_RE = /(import\s+\{[^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/;
|
|
415
|
-
function findRuntimeImportClause(code) {
|
|
416
|
-
const match = RUNTIME_IMPORT_APPEND_RE.exec(code);
|
|
417
|
-
return match ? { statement: match[0], prefixWithBody: match[1] } : null;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function runtimeHelperGroupsFromUsage(usage) {
|
|
421
|
-
const slim = usage.usesSzPart === true && usage.szPartArgsProvable === true && usage.usesRuntime !== true && usage.usesMerge !== true;
|
|
422
|
-
const groups = { all: [], barrel: [], merge: [] };
|
|
423
|
-
const append = (helper, toMerge = false) => {
|
|
424
|
-
groups.all.push(helper);
|
|
425
|
-
(toMerge ? groups.merge : groups.barrel).push(helper);
|
|
426
|
-
};
|
|
427
|
-
if (usage.usesRuntime) append("_sz");
|
|
428
|
-
if (usage.usesMerge) append("_szMerge");
|
|
429
|
-
if (usage.usesSzcn) append("_szcn", slim);
|
|
430
|
-
if (usage.usesSzPart) append("_szPart", slim);
|
|
431
|
-
if (usage.usesSzvPick) append("__szvPick");
|
|
432
|
-
if (usage.usesSzvPick1) append("__szvPick1");
|
|
433
|
-
if (usage.usesColorVar) append("__szColorVar");
|
|
434
|
-
if (usage.usesSpacingVar) append("__szSpacingVar");
|
|
435
|
-
if (usage.usesUnitVar) append("__szUnitVar");
|
|
436
|
-
if (usage.usesBoolClass) append("__szBoolClass");
|
|
437
|
-
return groups;
|
|
438
|
-
}
|
|
439
|
-
function injectNextRuntimeImports(code, usage) {
|
|
440
|
-
const groups = runtimeHelperGroupsFromUsage(usage);
|
|
441
|
-
const helpers = groups.all;
|
|
442
|
-
if (helpers.length === 0) {
|
|
443
|
-
return { code, injected: [] };
|
|
444
|
-
}
|
|
445
|
-
const hasRuntimeImport = code.includes("@csszyx/runtime");
|
|
446
|
-
const missing = hasRuntimeImport ? helpers.filter((helper) => !importsRuntimeHelper(code, helper)) : helpers;
|
|
447
|
-
if (missing.length === 0) {
|
|
448
|
-
return { code, injected: [] };
|
|
449
|
-
}
|
|
450
|
-
if (groups.merge.length > 0) {
|
|
451
|
-
const mergeHelpers = missing.filter((helper) => groups.merge.includes(helper));
|
|
452
|
-
const barrelHelpers = missing.filter((helper) => groups.barrel.includes(helper));
|
|
453
|
-
let next = insertRuntimeImport(
|
|
454
|
-
code,
|
|
455
|
-
`import { ${mergeHelpers.join(", ")} } from '@csszyx/runtime/merge';
|
|
456
|
-
`
|
|
457
|
-
);
|
|
458
|
-
if (barrelHelpers.length > 0) {
|
|
459
|
-
next = insertRuntimeImport(
|
|
460
|
-
next,
|
|
461
|
-
`import { ${barrelHelpers.join(", ")} } from '@csszyx/runtime';
|
|
462
|
-
`
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
return { code: next, injected: missing };
|
|
466
|
-
}
|
|
467
|
-
return {
|
|
468
|
-
code: insertRuntimeImport(
|
|
469
|
-
code,
|
|
470
|
-
`import { ${missing.join(", ")} } from '@csszyx/runtime';
|
|
471
|
-
`
|
|
472
|
-
),
|
|
473
|
-
injected: missing
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
function insertRuntimeImport(code, importStmt) {
|
|
477
|
-
return insertAfterUseDirective(code, importStmt);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
390
|
const THEME_SCAN_IGNORE_DIRS = /* @__PURE__ */ new Set([
|
|
481
391
|
"node_modules",
|
|
482
392
|
".next",
|
|
@@ -587,4 +497,4 @@ function themeGroupsSpecifier(fromFile, themeGroupsFile) {
|
|
|
587
497
|
return relative.startsWith("./") || relative.startsWith("../") ? relative : `./${relative}`;
|
|
588
498
|
}
|
|
589
499
|
|
|
590
|
-
export { CHECKSUM_PLACEHOLDER as C, MANGLE_RUNTIME_VIRTUAL_ID as M, RESOLVED_VIRTUAL_MODULE_ID as R, THEME_GROUPS_VIRTUAL_ID as T, VAR_MANGLE_MAP_PLACEHOLDER as V, parseUtilityBlocks as a,
|
|
500
|
+
export { CHECKSUM_PLACEHOLDER as C, MANGLE_RUNTIME_VIRTUAL_ID as M, RESOLVED_VIRTUAL_MODULE_ID as R, THEME_GROUPS_VIRTUAL_ID as T, UNSERVED_VIRTUAL_ID as U, VAR_MANGLE_MAP_PLACEHOLDER as V, parseUtilityBlocks as a, createUnservedRuntimeModule as b, createMangleRuntimeModule as c, createMangleMapModule as d, ensureThemeGroupsFile as e, RESOLVED_VIRTUAL_CHECKSUM_ID as f, createChecksumModule as g, hasTokens as h, RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID as i, RESOLVED_UNSERVED_VIRTUAL_ID as j, RESOLVED_THEME_GROUPS_VIRTUAL_ID as k, createThemeGroupsModule as l, mergeThemes as m, isVirtualModule as n, discoverProjectTheme as o, parseThemeBlocks as p, CENSUS_PLACEHOLDER as q, resolveVirtualModule as r, scanCustomPropertyNames as s, themeGroupsSpecifier as t, THEME_GROUPS_FILE_MARKER as u, UNSERVED_PLACEHOLDER as v, MANGLE_MAP_PLACEHOLDER as w };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.
|
|
1
|
+
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.XdPo6azz.cjs';
|
|
2
2
|
|
|
3
3
|
/** Options for one synchronous watcher materialization cycle. */
|
|
4
4
|
interface NextWatcherCycleOptions {
|