@csszyx/unplugin 0.11.7 → 0.11.8
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.D6hes1O8.cjs → unplugin.C9dMG7ye.cjs} +5 -3
- package/dist/shared/{unplugin.PhOFTQpB.d.cts → unplugin.CNwV3RrQ.d.cts} +18 -5
- package/dist/shared/{unplugin.PhOFTQpB.d.mts → unplugin.CNwV3RrQ.d.mts} +18 -5
- package/dist/shared/unplugin.CcA7jP1r.cjs +48 -0
- package/dist/shared/{unplugin.CwcOd1q3.mjs → unplugin.D-K57LNR.mjs} +6 -1
- package/dist/shared/{unplugin.D8vSG36M.cjs → unplugin.DVCQC5wq.cjs} +6 -0
- package/dist/shared/{unplugin.CZKUWN1J.cjs → unplugin.DdtOZANG.cjs} +51 -50
- package/dist/shared/{unplugin.Dqt1aLCX.mjs → unplugin.Dg1tGPSd.mjs} +5 -3
- package/dist/shared/{unplugin.Rov-j_Wm.cjs → unplugin.DmuOKVS4.cjs} +21 -0
- package/dist/shared/{unplugin.ByAzFdqO.cjs → unplugin.DtPQz8Kg.cjs} +1072 -754
- package/dist/shared/{unplugin.CtHwCYxE.mjs → unplugin.DtYxS8M8.mjs} +1071 -754
- package/dist/shared/{unplugin.VSslRpfN.mjs → unplugin.Rl8sIkHi.mjs} +51 -50
- package/dist/shared/unplugin.TtmP77BS.mjs +40 -0
- package/dist/shared/unplugin.nnsa7OVW.mjs +49 -0
- 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
|
@@ -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.CcA7jP1r.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("--")) {
|
|
@@ -3,7 +3,7 @@ import * as fs from 'node:fs';
|
|
|
3
3
|
import { createHash, randomUUID } from 'node:crypto';
|
|
4
4
|
import { hostname } from 'node:os';
|
|
5
5
|
import lockfile from 'proper-lockfile';
|
|
6
|
-
import { s as sortStrings, e as escapeHtmlAttribute } from './unplugin.
|
|
6
|
+
import { s as sortStrings, e as escapeHtmlAttribute, r as renderTailwindScannerCandidates } from './unplugin.TtmP77BS.mjs';
|
|
7
7
|
|
|
8
8
|
const DEFAULT_RENAME_RETRIES = 5;
|
|
9
9
|
const DEFAULT_RENAME_RETRY_DELAY_MS = 10;
|
|
@@ -233,8 +233,10 @@ function renderTailwindSourceHtml(classNames) {
|
|
|
233
233
|
if (classNames.length === 0) {
|
|
234
234
|
return "<!-- csszyx Next safelist: empty -->\n";
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
const structuralHtml = classNames.map((className) => `<div class="${escapeHtmlAttribute(className)}"></div>`).join("\n");
|
|
237
|
+
const scannerCandidates = renderTailwindScannerCandidates(classNames);
|
|
238
|
+
return `${structuralHtml}
|
|
239
|
+
${scannerCandidates}`;
|
|
238
240
|
}
|
|
239
241
|
function createLockMetadata(options) {
|
|
240
242
|
const now = new Date(options.now ?? Date.now()).toISOString();
|
|
@@ -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;
|