@csszyx/unplugin 0.12.0 → 0.13.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/dist/index.cjs +8 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/next-config.cjs +3 -0
- package/dist/next-config.d.cts +10 -0
- package/dist/next-config.d.mts +10 -0
- package/dist/next-config.mjs +3 -0
- package/dist/next-prebuild.cjs +12 -5
- package/dist/next-prebuild.d.cts +7 -0
- package/dist/next-prebuild.d.mts +7 -0
- package/dist/next-prebuild.mjs +12 -5
- package/dist/next-turbo-loader.cjs +29 -11
- package/dist/next-turbo-loader.d.cts +10 -0
- package/dist/next-turbo-loader.d.mts +10 -0
- package/dist/next-turbo-loader.mjs +28 -10
- package/dist/next-watcher.cjs +1 -1
- package/dist/next-watcher.mjs +1 -1
- package/dist/shared/unplugin.4du3qMst.cjs +529 -0
- package/dist/shared/unplugin.5l4RHMQh.mjs +578 -0
- package/dist/shared/unplugin.BB0iWSds.mjs +495 -0
- package/dist/shared/{unplugin.DMcbmP01.mjs → unplugin.BU0O4IkX.mjs} +4 -1
- package/dist/shared/{unplugin.BK3XVHe8.cjs → unplugin.Bf4fNbp7.cjs} +318 -532
- package/dist/shared/{unplugin.Bb5TeU9B.cjs → unplugin.CUTa6bY9.cjs} +89 -1
- package/dist/shared/{unplugin.DblMogcN.cjs → unplugin.Cji6O5jv.cjs} +4 -1
- package/dist/shared/{unplugin.DXgxFHzO.mjs → unplugin.CogPHmDs.mjs} +73 -3
- package/dist/shared/{unplugin.CtnKJhAi.d.cts → unplugin.DCT7DDG6.d.cts} +75 -30
- package/dist/shared/{unplugin.CtnKJhAi.d.mts → unplugin.DCT7DDG6.d.mts} +75 -30
- package/dist/shared/unplugin.X9a9SL_s.cjs +612 -0
- package/dist/shared/{unplugin.B9vpjOhD.mjs → unplugin.ymMe428s.mjs} +288 -499
- package/dist/vite.cjs +3 -3
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +3 -3
- package/dist/webpack.cjs +3 -3
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +3 -3
- package/package.json +9 -9
- package/dist/shared/unplugin.C2lHQFii.cjs +0 -114
- package/dist/shared/unplugin.CBMJufQ8.mjs +0 -108
- package/dist/shared/unplugin.CDqY7kmk.mjs +0 -224
- package/dist/shared/unplugin.DbZ7tCfN.cjs +0 -248
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const compiler = require('@csszyx/compiler');
|
|
4
|
-
const node_crypto = require('node:crypto');
|
|
5
|
-
const fs = require('node:fs');
|
|
6
|
-
const path = require('node:path');
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceCompat(e) {
|
|
9
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
10
|
-
const n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
for (const k in e) {
|
|
13
|
-
n[k] = e[k];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
n.default = e;
|
|
17
|
-
return n;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
|
|
21
|
-
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
22
|
-
|
|
23
|
-
const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
|
|
24
|
-
function normalizePathSeparators(value) {
|
|
25
|
-
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function babelFallbackReason(error) {
|
|
29
|
-
if (error instanceof compiler.OxcNotImplementedError) {
|
|
30
|
-
return error.detail;
|
|
31
|
-
}
|
|
32
|
-
return error instanceof Error ? error.message : String(error);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const CACHE_SCHEMA_VERSION = 15;
|
|
36
|
-
function resolveTransformCacheDir(rootDir, cacheDir) {
|
|
37
|
-
return path__namespace.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
|
|
38
|
-
}
|
|
39
|
-
function createTransformCacheKey(input) {
|
|
40
|
-
const inputSha256 = node_crypto.createHash("sha256").update(input.source).digest("hex");
|
|
41
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
42
|
-
const keyMaterial = [
|
|
43
|
-
`schema=${CACHE_SCHEMA_VERSION}`,
|
|
44
|
-
`plugin=${input.pluginVersion}`,
|
|
45
|
-
`compiler=${input.compilerVersion}`,
|
|
46
|
-
`native=${input.nativeIdentity ?? "none"}`,
|
|
47
|
-
`parser=${input.parserMode}`,
|
|
48
|
-
`producer=${input.producer}`,
|
|
49
|
-
`astBudget=${input.astBudget ?? "default"}`,
|
|
50
|
-
`mangleVars=${input.mangleVars === true}`,
|
|
51
|
-
`mangleVarHoistMaxDepth=${input.mangleVarHoistMaxDepth ?? "default"}`,
|
|
52
|
-
`globalVarAliases=${JSON.stringify(globalVarAliases)}`,
|
|
53
|
-
`crossModuleStatics=${input.crossModuleStatics ?? "none"}`,
|
|
54
|
-
`filename=${input.filename}`,
|
|
55
|
-
`source=${inputSha256}`
|
|
56
|
-
].join("\n");
|
|
57
|
-
return {
|
|
58
|
-
key: node_crypto.createHash("sha256").update(keyMaterial).digest("hex").slice(0, 16),
|
|
59
|
-
inputSha256
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function readTransformCache(cacheRoot, input, precomputedKey) {
|
|
63
|
-
const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
|
|
64
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
65
|
-
const file = cacheEntryPath(cacheRoot, key);
|
|
66
|
-
let entry;
|
|
67
|
-
try {
|
|
68
|
-
entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
|
|
69
|
-
} catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
if (entry.version !== CACHE_SCHEMA_VERSION || entry.pluginVersion !== input.pluginVersion || entry.compilerVersion !== input.compilerVersion || entry.nativeIdentity !== (input.nativeIdentity ?? null) || entry.parserMode !== input.parserMode || entry.producer !== input.producer || entry.astBudget !== (input.astBudget ?? null) || entry.mangleVars !== (input.mangleVars === true) || entry.mangleVarHoistMaxDepth !== (input.mangleVarHoistMaxDepth ?? null) || !sameGlobalVarAliases(entry.globalVarAliases, globalVarAliases) || entry.filename !== input.filename || entry.inputSha256 !== inputSha256) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return deserializeResult(entry.result);
|
|
76
|
-
}
|
|
77
|
-
function writeTransformCache(cacheRoot, input, result, precomputedKey) {
|
|
78
|
-
const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
|
|
79
|
-
const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
|
|
80
|
-
const file = cacheEntryPath(cacheRoot, key);
|
|
81
|
-
const dir = path__namespace.dirname(file);
|
|
82
|
-
const tmp = path__namespace.join(dir, `.tmp-${process.pid}-${Date.now()}-${node_crypto.randomUUID()}.json`);
|
|
83
|
-
const entry = {
|
|
84
|
-
version: CACHE_SCHEMA_VERSION,
|
|
85
|
-
pluginVersion: input.pluginVersion,
|
|
86
|
-
compilerVersion: input.compilerVersion,
|
|
87
|
-
nativeIdentity: input.nativeIdentity ?? null,
|
|
88
|
-
parserMode: input.parserMode,
|
|
89
|
-
producer: input.producer,
|
|
90
|
-
astBudget: input.astBudget ?? null,
|
|
91
|
-
mangleVars: input.mangleVars === true,
|
|
92
|
-
mangleVarHoistMaxDepth: input.mangleVarHoistMaxDepth ?? null,
|
|
93
|
-
globalVarAliases,
|
|
94
|
-
filename: input.filename,
|
|
95
|
-
inputSha256,
|
|
96
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
97
|
-
result: serializeResult(result)
|
|
98
|
-
};
|
|
99
|
-
try {
|
|
100
|
-
fs__namespace.mkdirSync(dir, { recursive: true });
|
|
101
|
-
fs__namespace.writeFileSync(tmp, JSON.stringify(entry), "utf8");
|
|
102
|
-
fs__namespace.renameSync(tmp, file);
|
|
103
|
-
} catch {
|
|
104
|
-
try {
|
|
105
|
-
fs__namespace.rmSync(tmp, { force: true });
|
|
106
|
-
} catch {
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function evictOldTransformCacheEntries(cacheRoot, options) {
|
|
111
|
-
let deleted = 0;
|
|
112
|
-
const now = options.now ?? Date.now();
|
|
113
|
-
const survivors = [];
|
|
114
|
-
for (const file of listJsonFiles(cacheRoot)) {
|
|
115
|
-
try {
|
|
116
|
-
const entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
|
|
117
|
-
const timestamp = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : 0;
|
|
118
|
-
if (!Number.isFinite(timestamp) || now - timestamp > options.maxAgeMs) {
|
|
119
|
-
fs__namespace.rmSync(file, { force: true });
|
|
120
|
-
deleted++;
|
|
121
|
-
} else {
|
|
122
|
-
survivors.push({ file, timestamp });
|
|
123
|
-
}
|
|
124
|
-
} catch {
|
|
125
|
-
fs__namespace.rmSync(file, { force: true });
|
|
126
|
-
deleted++;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const overflow = survivors.length - options.maxEntries ;
|
|
130
|
-
if (overflow > 0) {
|
|
131
|
-
survivors.sort((a, b) => a.timestamp - b.timestamp);
|
|
132
|
-
for (const survivor of survivors.slice(0, overflow)) {
|
|
133
|
-
fs__namespace.rmSync(survivor.file, { force: true });
|
|
134
|
-
deleted++;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return deleted;
|
|
138
|
-
}
|
|
139
|
-
function cacheEntryPath(cacheRoot, key) {
|
|
140
|
-
return path__namespace.join(cacheRoot, key.slice(0, 2), `${key.slice(2)}.json`);
|
|
141
|
-
}
|
|
142
|
-
function serializeResult(result) {
|
|
143
|
-
return {
|
|
144
|
-
code: result.code,
|
|
145
|
-
transformed: result.transformed,
|
|
146
|
-
usesRuntime: result.usesRuntime,
|
|
147
|
-
usesMerge: result.usesMerge,
|
|
148
|
-
usesSzcn: result.usesSzcn,
|
|
149
|
-
usesSzPart: result.usesSzPart,
|
|
150
|
-
usesSzvPick: result.usesSzvPick,
|
|
151
|
-
usesSzvPick1: result.usesSzvPick1,
|
|
152
|
-
szPartArgsProvable: result.szPartArgsProvable,
|
|
153
|
-
usesColorVar: result.usesColorVar,
|
|
154
|
-
usesSpacingVar: result.usesSpacingVar,
|
|
155
|
-
usesUnitVar: result.usesUnitVar,
|
|
156
|
-
classes: [...result.classes],
|
|
157
|
-
rawClassNames: [...result.rawClassNames],
|
|
158
|
-
diagnostics: [...result.diagnostics],
|
|
159
|
-
recoveryTokens: [...result.recoveryTokens],
|
|
160
|
-
cssVariableMap: [...result.cssVariableMap ?? /* @__PURE__ */ new Map()]
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function deserializeResult(result) {
|
|
164
|
-
return {
|
|
165
|
-
code: result.code,
|
|
166
|
-
transformed: result.transformed,
|
|
167
|
-
usesRuntime: result.usesRuntime,
|
|
168
|
-
usesMerge: result.usesMerge,
|
|
169
|
-
usesSzcn: result.usesSzcn,
|
|
170
|
-
usesSzPart: result.usesSzPart,
|
|
171
|
-
usesSzvPick: result.usesSzvPick,
|
|
172
|
-
usesSzvPick1: result.usesSzvPick1,
|
|
173
|
-
szPartArgsProvable: result.szPartArgsProvable,
|
|
174
|
-
usesColorVar: result.usesColorVar,
|
|
175
|
-
usesSpacingVar: result.usesSpacingVar,
|
|
176
|
-
usesUnitVar: result.usesUnitVar,
|
|
177
|
-
classes: new Set(result.classes),
|
|
178
|
-
rawClassNames: new Set(result.rawClassNames),
|
|
179
|
-
diagnostics: [...result.diagnostics],
|
|
180
|
-
recoveryTokens: new Map(result.recoveryTokens),
|
|
181
|
-
cssVariableMap: new Map(result.cssVariableMap ?? [])
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function normalizeGlobalVarAliasEntries(aliases) {
|
|
185
|
-
if (!aliases || aliases.length === 0) {
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
const normalized = /* @__PURE__ */ new Map();
|
|
189
|
-
for (const [original, alias] of aliases) {
|
|
190
|
-
if (typeof original === "string" && typeof alias === "string") {
|
|
191
|
-
normalized.set(original, alias);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return [...normalized].sort(([left], [right]) => left.localeCompare(right));
|
|
195
|
-
}
|
|
196
|
-
function sameGlobalVarAliases(left, right) {
|
|
197
|
-
if (!Array.isArray(left) || left.length !== right.length) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
for (let index = 0; index < left.length; index++) {
|
|
201
|
-
const leftEntry = left[index];
|
|
202
|
-
const rightEntry = right[index];
|
|
203
|
-
if (leftEntry?.[0] !== rightEntry?.[0] || leftEntry?.[1] !== rightEntry?.[1]) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
function listJsonFiles(dir) {
|
|
210
|
-
let entries;
|
|
211
|
-
try {
|
|
212
|
-
entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
|
|
213
|
-
} catch {
|
|
214
|
-
return [];
|
|
215
|
-
}
|
|
216
|
-
const files = [];
|
|
217
|
-
for (const entry of entries) {
|
|
218
|
-
const fullPath = path__namespace.join(dir, entry.name);
|
|
219
|
-
if (entry.isDirectory()) {
|
|
220
|
-
files.push(...listJsonFiles(fullPath));
|
|
221
|
-
} else if (entry.isFile() && entry.name.endsWith(".json")) {
|
|
222
|
-
files.push(fullPath);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return files;
|
|
226
|
-
}
|
|
227
|
-
function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChars) {
|
|
228
|
-
let total = totalCodeChars;
|
|
229
|
-
while (cache.size > maxEntries || total > maxCodeChars && cache.size > 1) {
|
|
230
|
-
const oldest = cache.keys().next().value;
|
|
231
|
-
if (oldest === void 0) {
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
const evicted = cache.get(oldest);
|
|
235
|
-
cache.delete(oldest);
|
|
236
|
-
total -= evicted?.code.length ?? 0;
|
|
237
|
-
}
|
|
238
|
-
return total;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
exports.babelFallbackReason = babelFallbackReason;
|
|
242
|
-
exports.createTransformCacheKey = createTransformCacheKey;
|
|
243
|
-
exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
|
|
244
|
-
exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
|
|
245
|
-
exports.normalizePathSeparators = normalizePathSeparators;
|
|
246
|
-
exports.readTransformCache = readTransformCache;
|
|
247
|
-
exports.resolveTransformCacheDir = resolveTransformCacheDir;
|
|
248
|
-
exports.writeTransformCache = writeTransformCache;
|