@csszyx/unplugin 0.11.7 → 0.11.9
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 -1
- package/dist/css-mangler.cjs +9 -6
- package/dist/css-mangler.mjs +9 -6
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/next-config.cjs +1 -1
- package/dist/next-config.mjs +1 -1
- package/dist/next-prebuild.cjs +5 -5
- package/dist/next-prebuild.mjs +5 -5
- package/dist/next-turbo-loader.cjs +7 -12
- package/dist/next-turbo-loader.mjs +7 -12
- package/dist/next-watcher.cjs +2 -2
- package/dist/next-watcher.mjs +2 -2
- package/dist/shared/{unplugin.Dqt1aLCX.mjs → unplugin.7TELUwsj.mjs} +5 -3
- package/dist/shared/unplugin.B3XoSRB8.mjs +40 -0
- package/dist/shared/unplugin.BkRah5Ot.cjs +48 -0
- package/dist/shared/{unplugin.VSslRpfN.mjs → unplugin.Bqx2WfBV.mjs} +51 -50
- package/dist/shared/{unplugin.PhOFTQpB.d.cts → unplugin.CjCKWnoX.d.cts} +25 -6
- package/dist/shared/{unplugin.PhOFTQpB.d.mts → unplugin.CjCKWnoX.d.mts} +25 -6
- package/dist/shared/{unplugin.CwcOd1q3.mjs → unplugin.D-K57LNR.mjs} +6 -1
- package/dist/shared/{unplugin.ByAzFdqO.cjs → unplugin.DUI48s3S.cjs} +1181 -766
- package/dist/shared/{unplugin.D8vSG36M.cjs → unplugin.DVCQC5wq.cjs} +6 -0
- package/dist/shared/{unplugin.Rov-j_Wm.cjs → unplugin.DmuOKVS4.cjs} +21 -0
- package/dist/shared/{unplugin.D6hes1O8.cjs → unplugin.WVn08Fln.cjs} +5 -3
- package/dist/shared/{unplugin.CZKUWN1J.cjs → unplugin.jZsBqx54.cjs} +51 -50
- package/dist/shared/unplugin.nnsa7OVW.mjs +49 -0
- package/dist/shared/{unplugin.CtHwCYxE.mjs → unplugin.wx3cvxxX.mjs} +1180 -766
- package/dist/vite.cjs +4 -4
- package/dist/vite.d.cts +2 -25
- package/dist/vite.d.mts +1 -25
- package/dist/vite.mjs +4 -8
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +2 -5
- package/dist/webpack.d.mts +1 -5
- package/dist/webpack.mjs +4 -8
- package/package.json +7 -7
- package/dist/shared/unplugin.B1mblcm-.mjs +0 -9
- package/dist/shared/unplugin.B3RHYokB.mjs +0 -29
- package/dist/shared/unplugin.BCwRIUs_.cjs +0 -12
|
@@ -19,6 +19,11 @@ function _interopNamespaceCompat(e) {
|
|
|
19
19
|
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
|
|
20
20
|
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
21
21
|
|
|
22
|
+
const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
|
|
23
|
+
function normalizePathSeparators(value) {
|
|
24
|
+
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
const CACHE_SCHEMA_VERSION = 10;
|
|
23
28
|
function resolveTransformCacheDir(rootDir, cacheDir) {
|
|
24
29
|
return path__namespace.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
|
|
@@ -221,6 +226,7 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
|
|
|
221
226
|
exports.createTransformCacheKey = createTransformCacheKey;
|
|
222
227
|
exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
|
|
223
228
|
exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
|
|
229
|
+
exports.normalizePathSeparators = normalizePathSeparators;
|
|
224
230
|
exports.readTransformCache = readTransformCache;
|
|
225
231
|
exports.resolveTransformCacheDir = resolveTransformCacheDir;
|
|
226
232
|
exports.writeTransformCache = writeTransformCache;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const LEADING_WHITESPACE_RE = /^\s+/;
|
|
4
|
+
const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
|
|
5
|
+
const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
|
|
6
|
+
const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
|
|
7
|
+
function insertAfterUseDirective(code, insertion) {
|
|
8
|
+
let offset = 0;
|
|
9
|
+
while (offset < code.length) {
|
|
10
|
+
const triviaLength = leadingTriviaLength(code.slice(offset));
|
|
11
|
+
if (triviaLength === 0) break;
|
|
12
|
+
offset += triviaLength;
|
|
13
|
+
}
|
|
14
|
+
const directive = code.slice(offset).match(USE_DIRECTIVE_RE);
|
|
15
|
+
if (!directive) return `${insertion}${code}`;
|
|
16
|
+
const insertionOffset = offset + directive[0].length;
|
|
17
|
+
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
18
|
+
}
|
|
19
|
+
function leadingTriviaLength(source) {
|
|
20
|
+
return source.match(LEADING_WHITESPACE_RE)?.[0].length ?? source.match(LINE_COMMENT_RE)?.[0].length ?? source.match(BLOCK_COMMENT_RE)?.[0].length ?? 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
3
23
|
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
4
24
|
function clauseNames(clauseBody) {
|
|
5
25
|
const names = [];
|
|
@@ -30,3 +50,4 @@ function findRuntimeImportClause(code) {
|
|
|
30
50
|
|
|
31
51
|
exports.findRuntimeImportClause = findRuntimeImportClause;
|
|
32
52
|
exports.importsRuntimeHelper = importsRuntimeHelper;
|
|
53
|
+
exports.insertAfterUseDirective = insertAfterUseDirective;
|
|
@@ -5,7 +5,7 @@ const fs = require('node:fs');
|
|
|
5
5
|
const node_crypto = require('node:crypto');
|
|
6
6
|
const node_os = require('node:os');
|
|
7
7
|
const lockfile = require('proper-lockfile');
|
|
8
|
-
const htmlEscape = require('./unplugin.
|
|
8
|
+
const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
11
|
|
|
@@ -253,8 +253,10 @@ function renderTailwindSourceHtml(classNames) {
|
|
|
253
253
|
if (classNames.length === 0) {
|
|
254
254
|
return "<!-- csszyx Next safelist: empty -->\n";
|
|
255
255
|
}
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
const structuralHtml = classNames.map((className) => `<div class="${htmlEscape.escapeHtmlAttribute(className)}"></div>`).join("\n");
|
|
257
|
+
const scannerCandidates = htmlEscape.renderTailwindScannerCandidates(classNames);
|
|
258
|
+
return `${structuralHtml}
|
|
259
|
+
${scannerCandidates}`;
|
|
258
260
|
}
|
|
259
261
|
function createLockMetadata(options) {
|
|
260
262
|
const now = new Date(options.now ?? Date.now()).toISOString();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const compiler = require('@csszyx/compiler');
|
|
5
|
-
const transformCache = require('./unplugin.
|
|
5
|
+
const transformCache = require('./unplugin.DVCQC5wq.cjs');
|
|
6
6
|
const node_crypto = require('node:crypto');
|
|
7
|
-
const htmlEscape = require('./unplugin.
|
|
7
|
+
const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
|
|
8
8
|
|
|
9
9
|
function readPackageVersion(relativePackageJson, fromUrl) {
|
|
10
10
|
try {
|
|
@@ -61,61 +61,19 @@ function stripJsCommentsAndStrings(source) {
|
|
|
61
61
|
const char = source[index];
|
|
62
62
|
const peek = index + 1 < length ? source[index + 1] : "";
|
|
63
63
|
if (char === "/" && peek === "/") {
|
|
64
|
-
index
|
|
65
|
-
while (index < length && source[index] !== "\n") {
|
|
66
|
-
index++;
|
|
67
|
-
}
|
|
64
|
+
index = skipLineComment(source, index);
|
|
68
65
|
continue;
|
|
69
66
|
}
|
|
70
67
|
if (char === "/" && peek === "*") {
|
|
71
|
-
index
|
|
72
|
-
while (index + 1 < length && !(source[index] === "*" && source[index + 1] === "/")) {
|
|
73
|
-
index++;
|
|
74
|
-
}
|
|
75
|
-
index = Math.min(length, index + 2);
|
|
68
|
+
index = skipBlockComment(source, index);
|
|
76
69
|
continue;
|
|
77
70
|
}
|
|
78
71
|
if (char === "/" && isRegexLiteralStart(out)) {
|
|
79
|
-
index
|
|
80
|
-
let inCharClass = false;
|
|
81
|
-
while (index < length) {
|
|
82
|
-
const current = source[index];
|
|
83
|
-
if (current === "\\" && index + 1 < length) {
|
|
84
|
-
index += 2;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
if (current === "[") {
|
|
88
|
-
inCharClass = true;
|
|
89
|
-
index++;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (current === "]") {
|
|
93
|
-
inCharClass = false;
|
|
94
|
-
index++;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (current === "/" && !inCharClass) {
|
|
98
|
-
index++;
|
|
99
|
-
while (/[a-z]/i.test(source[index] ?? "")) {
|
|
100
|
-
index++;
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
index++;
|
|
105
|
-
}
|
|
72
|
+
index = skipRegexLiteral(source, index);
|
|
106
73
|
continue;
|
|
107
74
|
}
|
|
108
75
|
if (char === '"' || char === "'" || char === "`") {
|
|
109
|
-
|
|
110
|
-
index++;
|
|
111
|
-
while (index < length && source[index] !== quote) {
|
|
112
|
-
if (source[index] === "\\" && index + 1 < length) {
|
|
113
|
-
index += 2;
|
|
114
|
-
} else {
|
|
115
|
-
index++;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
index++;
|
|
76
|
+
index = skipQuotedSource(source, index, char);
|
|
119
77
|
continue;
|
|
120
78
|
}
|
|
121
79
|
out += char;
|
|
@@ -123,6 +81,46 @@ function stripJsCommentsAndStrings(source) {
|
|
|
123
81
|
}
|
|
124
82
|
return out;
|
|
125
83
|
}
|
|
84
|
+
function skipLineComment(source, start) {
|
|
85
|
+
const newline = source.indexOf("\n", start + 2);
|
|
86
|
+
return newline === -1 ? source.length : newline;
|
|
87
|
+
}
|
|
88
|
+
function skipBlockComment(source, start) {
|
|
89
|
+
const close = source.indexOf("*/", start + 2);
|
|
90
|
+
return close === -1 ? source.length : close + 2;
|
|
91
|
+
}
|
|
92
|
+
function skipRegexLiteral(source, start) {
|
|
93
|
+
let index = start + 1;
|
|
94
|
+
let inCharClass = false;
|
|
95
|
+
while (index < source.length) {
|
|
96
|
+
const current = source[index];
|
|
97
|
+
if (current === "\\" && index + 1 < source.length) {
|
|
98
|
+
index += 2;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (current === "[") {
|
|
102
|
+
inCharClass = true;
|
|
103
|
+
} else if (current === "]") {
|
|
104
|
+
inCharClass = false;
|
|
105
|
+
} else if (current === "/" && !inCharClass) {
|
|
106
|
+
return skipRegexFlags(source, index + 1);
|
|
107
|
+
}
|
|
108
|
+
index++;
|
|
109
|
+
}
|
|
110
|
+
return index;
|
|
111
|
+
}
|
|
112
|
+
function skipRegexFlags(source, start) {
|
|
113
|
+
let index = start;
|
|
114
|
+
while (/[a-z]/i.test(source[index] ?? "")) index++;
|
|
115
|
+
return index;
|
|
116
|
+
}
|
|
117
|
+
function skipQuotedSource(source, start, quote) {
|
|
118
|
+
let index = start + 1;
|
|
119
|
+
while (index < source.length && source[index] !== quote) {
|
|
120
|
+
index += source[index] === "\\" && index + 1 < source.length ? 2 : 1;
|
|
121
|
+
}
|
|
122
|
+
return index + 1;
|
|
123
|
+
}
|
|
126
124
|
function isRegexLiteralStart(emitted) {
|
|
127
125
|
const trimmed = emitted.trimEnd();
|
|
128
126
|
const previous = trimmed.length > 0 ? trimmed.charAt(trimmed.length - 1) : void 0;
|
|
@@ -176,13 +174,16 @@ function createNextSourceTransformCacheInput(input, filename, producer) {
|
|
|
176
174
|
};
|
|
177
175
|
}
|
|
178
176
|
function normalizeSourceFilename(filename) {
|
|
179
|
-
return
|
|
177
|
+
return transformCache.normalizePathSeparators(filename);
|
|
180
178
|
}
|
|
181
179
|
function normalizeGlobalVarAliasesForCache(aliases) {
|
|
182
180
|
if (!aliases) {
|
|
183
181
|
return [];
|
|
184
182
|
}
|
|
185
|
-
|
|
183
|
+
let entries;
|
|
184
|
+
if (aliases instanceof Map) entries = aliases.entries();
|
|
185
|
+
else if (Array.isArray(aliases)) entries = aliases;
|
|
186
|
+
else entries = Object.entries(aliases);
|
|
186
187
|
const normalized = /* @__PURE__ */ new Map();
|
|
187
188
|
for (const [original, alias] of entries) {
|
|
188
189
|
if (original.startsWith("--") && alias.startsWith("--")) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const LEADING_WHITESPACE_RE = /^\s+/;
|
|
2
|
+
const LINE_COMMENT_RE = /^\/\/[^\n]*(?:\n|$)/;
|
|
3
|
+
const BLOCK_COMMENT_RE = /^\/\*[\s\S]*?\*\//;
|
|
4
|
+
const USE_DIRECTIVE_RE = /^['"]use (?:client|server)['"];?\s*/;
|
|
5
|
+
function insertAfterUseDirective(code, insertion) {
|
|
6
|
+
let offset = 0;
|
|
7
|
+
while (offset < code.length) {
|
|
8
|
+
const triviaLength = leadingTriviaLength(code.slice(offset));
|
|
9
|
+
if (triviaLength === 0) break;
|
|
10
|
+
offset += triviaLength;
|
|
11
|
+
}
|
|
12
|
+
const directive = code.slice(offset).match(USE_DIRECTIVE_RE);
|
|
13
|
+
if (!directive) return `${insertion}${code}`;
|
|
14
|
+
const insertionOffset = offset + directive[0].length;
|
|
15
|
+
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
16
|
+
}
|
|
17
|
+
function leadingTriviaLength(source) {
|
|
18
|
+
return source.match(LEADING_WHITESPACE_RE)?.[0].length ?? source.match(LINE_COMMENT_RE)?.[0].length ?? source.match(BLOCK_COMMENT_RE)?.[0].length ?? 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
22
|
+
function clauseNames(clauseBody) {
|
|
23
|
+
const names = [];
|
|
24
|
+
for (const part of clauseBody.split(",")) {
|
|
25
|
+
const trimmed = part.trim();
|
|
26
|
+
if (!trimmed) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const spaceAt = trimmed.search(/\s/);
|
|
30
|
+
names.push(spaceAt === -1 ? trimmed : trimmed.slice(0, spaceAt));
|
|
31
|
+
}
|
|
32
|
+
return names;
|
|
33
|
+
}
|
|
34
|
+
function importsRuntimeHelper(code, helper) {
|
|
35
|
+
RUNTIME_IMPORT_CLAUSE_RE.lastIndex = 0;
|
|
36
|
+
for (let match = RUNTIME_IMPORT_CLAUSE_RE.exec(code); match; match = RUNTIME_IMPORT_CLAUSE_RE.exec(code)) {
|
|
37
|
+
if (clauseNames(match[1]).includes(helper)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const RUNTIME_IMPORT_APPEND_RE = /(import\s+\{[^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/;
|
|
44
|
+
function findRuntimeImportClause(code) {
|
|
45
|
+
const match = RUNTIME_IMPORT_APPEND_RE.exec(code);
|
|
46
|
+
return match ? { statement: match[0], prefixWithBody: match[1] } : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { insertAfterUseDirective as a, findRuntimeImportClause as f, importsRuntimeHelper as i };
|