tailwind-styled-v4 5.0.10 → 5.0.11
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 +245 -373
- package/dist/analyzer.js +75 -22
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +74 -21
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.js +4 -2
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +4 -2
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +20 -5
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +20 -5
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +174 -67
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +171 -64
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +7 -1
- package/dist/compiler.d.ts +7 -1
- package/dist/compiler.js +53 -27
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +53 -27
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.js +159 -61
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +159 -61
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +1512 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.d.mts +94 -12
- package/dist/index.d.ts +94 -12
- package/dist/index.js +436 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +436 -106
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +1946 -47
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +1929 -44
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +23 -10
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +23 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs.map +1 -1
- package/dist/scanner.js +72 -19
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +71 -18
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.js +32 -15
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +32 -15
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +38 -12
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -12
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +17 -5
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +17 -5
- package/dist/syntax.mjs.map +1 -1
- package/dist/theme.js +4 -2
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +4 -2
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +87 -33
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +87 -33
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +174 -67
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +171 -64
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +145 -63
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +145 -63
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +38 -12
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -12
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +20 -5
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +20 -5
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +29 -24
package/dist/turbopackLoader.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import * as fs3 from 'fs';
|
|
3
3
|
import fs3__default from 'fs';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as path3 from 'path';
|
|
5
|
+
import path3__default from 'path';
|
|
6
6
|
import 'crypto';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
@@ -49,28 +49,43 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
49
49
|
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
53
|
+
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
54
|
+
if (runtimeDir) {
|
|
55
|
+
for (const depth of ["..", path3.join("..", ".."), path3.join("..", "..", "..")]) {
|
|
56
|
+
const pkgRoot = path3.resolve(runtimeDir, depth);
|
|
57
|
+
for (const bin of BINARY_NAMES_SELF) {
|
|
58
|
+
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
59
|
+
const candidate = path3.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
60
|
+
tried.push(`self-bundled:${candidate}`);
|
|
61
|
+
if (fs3.existsSync(candidate)) {
|
|
62
|
+
return { path: candidate, source: "prebuilt", platform, tried };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
52
68
|
const cwd = process.cwd();
|
|
53
69
|
const base = runtimeDir ?? cwd;
|
|
54
|
-
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
55
70
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
56
71
|
const localCandidates = [];
|
|
57
72
|
for (const bin of BINARY_NAMES) {
|
|
58
|
-
localCandidates.push(
|
|
59
|
-
localCandidates.push(
|
|
60
|
-
localCandidates.push(
|
|
61
|
-
localCandidates.push(
|
|
73
|
+
localCandidates.push(path3.resolve(base, `${bin}.node`));
|
|
74
|
+
localCandidates.push(path3.resolve(base, "..", `${bin}.node`));
|
|
75
|
+
localCandidates.push(path3.resolve(base, `${bin}.${platform}.node`));
|
|
76
|
+
localCandidates.push(path3.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
62
77
|
}
|
|
63
78
|
for (const startDir of [cwd, base]) {
|
|
64
79
|
let dir = startDir;
|
|
65
80
|
for (let i = 0; i < 6; i++) {
|
|
66
|
-
const nativeDir =
|
|
81
|
+
const nativeDir = path3.resolve(dir, "native");
|
|
67
82
|
for (const bin of BINARY_NAMES) {
|
|
68
|
-
localCandidates.push(
|
|
69
|
-
localCandidates.push(
|
|
70
|
-
localCandidates.push(
|
|
71
|
-
localCandidates.push(
|
|
83
|
+
localCandidates.push(path3.resolve(nativeDir, `${bin}.node`));
|
|
84
|
+
localCandidates.push(path3.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
85
|
+
localCandidates.push(path3.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
86
|
+
localCandidates.push(path3.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
72
87
|
}
|
|
73
|
-
const parent =
|
|
88
|
+
const parent = path3.resolve(dir, "..");
|
|
74
89
|
if (parent === dir) break;
|
|
75
90
|
dir = parent;
|
|
76
91
|
}
|
|
@@ -89,18 +104,18 @@ var init_native_resolution = __esm({
|
|
|
89
104
|
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
90
105
|
_require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
91
106
|
PLATFORM_MAP = {
|
|
92
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
93
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
107
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
|
|
108
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
|
|
94
109
|
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
95
110
|
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
96
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
97
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
111
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
|
|
112
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
|
|
98
113
|
};
|
|
99
114
|
}
|
|
100
115
|
});
|
|
101
116
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
102
117
|
try {
|
|
103
|
-
return
|
|
118
|
+
return path3__default.dirname(fileURLToPath(importMetaUrl));
|
|
104
119
|
} catch {
|
|
105
120
|
return process.cwd();
|
|
106
121
|
}
|
|
@@ -234,7 +249,7 @@ var CYCLE_SENTINEL = "_cycle.txt";
|
|
|
234
249
|
var START_SENTINEL = "_start.txt";
|
|
235
250
|
var _workerCache = /* @__PURE__ */ new Map();
|
|
236
251
|
function getTwClassesDir(safelistPath) {
|
|
237
|
-
return
|
|
252
|
+
return path3__default.join(path3__default.dirname(safelistPath), "tw-classes");
|
|
238
253
|
}
|
|
239
254
|
function readSentinel(filePath) {
|
|
240
255
|
try {
|
|
@@ -243,35 +258,59 @@ function readSentinel(filePath) {
|
|
|
243
258
|
return "";
|
|
244
259
|
}
|
|
245
260
|
}
|
|
261
|
+
var _clearLock = false;
|
|
246
262
|
function clearAndMarkCycle(twClassesDir, startId) {
|
|
263
|
+
if (_clearLock) return;
|
|
264
|
+
_clearLock = true;
|
|
247
265
|
try {
|
|
248
266
|
if (fs3__default.existsSync(twClassesDir)) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
267
|
+
const tempDir = `${twClassesDir}_clearing_${Date.now()}`;
|
|
268
|
+
try {
|
|
269
|
+
fs3__default.renameSync(twClassesDir, tempDir);
|
|
270
|
+
fs3__default.mkdirSync(twClassesDir, { recursive: true });
|
|
271
|
+
const startFile = path3__default.join(tempDir, START_SENTINEL);
|
|
272
|
+
if (fs3__default.existsSync(startFile)) {
|
|
273
|
+
fs3__default.copyFileSync(startFile, path3__default.join(twClassesDir, START_SENTINEL));
|
|
274
|
+
}
|
|
275
|
+
const mergedFile = path3__default.join(tempDir, "_webpack-merged.css");
|
|
276
|
+
if (fs3__default.existsSync(mergedFile)) {
|
|
277
|
+
fs3__default.copyFileSync(mergedFile, path3__default.join(twClassesDir, "_webpack-merged.css"));
|
|
254
278
|
}
|
|
279
|
+
fs3__default.writeFileSync(path3__default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
280
|
+
_workerCache.set(twClassesDir, startId);
|
|
281
|
+
fs3__default.rmSync(tempDir, { recursive: true, force: true });
|
|
282
|
+
} catch {
|
|
283
|
+
for (const file of fs3__default.readdirSync(twClassesDir)) {
|
|
284
|
+
if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
|
|
285
|
+
try {
|
|
286
|
+
fs3__default.unlinkSync(path3__default.join(twClassesDir, file));
|
|
287
|
+
} catch {
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
fs3__default.writeFileSync(path3__default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
291
|
+
_workerCache.set(twClassesDir, startId);
|
|
255
292
|
}
|
|
256
293
|
} else {
|
|
257
294
|
fs3__default.mkdirSync(twClassesDir, { recursive: true });
|
|
295
|
+
fs3__default.writeFileSync(path3__default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
296
|
+
_workerCache.set(twClassesDir, startId);
|
|
258
297
|
}
|
|
259
|
-
fs3__default.writeFileSync(path__default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
260
|
-
_workerCache.set(twClassesDir, startId);
|
|
261
298
|
} catch {
|
|
299
|
+
} finally {
|
|
300
|
+
_clearLock = false;
|
|
262
301
|
}
|
|
263
302
|
}
|
|
264
303
|
function getPerFileSafelistPath(safelistDir, resourcePath) {
|
|
265
304
|
const normalized = resourcePath.replace(/\\/g, "/");
|
|
266
305
|
const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
|
|
267
|
-
return
|
|
306
|
+
return path3__default.join(safelistDir, `${slug}.css`);
|
|
268
307
|
}
|
|
269
308
|
function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
270
309
|
if (!safelistPath || classes.length === 0) return;
|
|
271
310
|
try {
|
|
272
311
|
const twClassesDir = getTwClassesDir(safelistPath);
|
|
273
|
-
const startId = readSentinel(
|
|
274
|
-
const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(
|
|
312
|
+
const startId = readSentinel(path3__default.join(twClassesDir, START_SENTINEL));
|
|
313
|
+
const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path3__default.join(twClassesDir, CYCLE_SENTINEL));
|
|
275
314
|
if (startId && cachedCycle !== startId) {
|
|
276
315
|
clearAndMarkCycle(twClassesDir, startId);
|
|
277
316
|
} else if (!fs3__default.existsSync(twClassesDir)) {
|
|
@@ -280,7 +319,7 @@ function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
|
280
319
|
const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
|
|
281
320
|
const sorted = [...new Set(classes)].sort();
|
|
282
321
|
const css = [
|
|
283
|
-
`/* tw-safelist: ${
|
|
322
|
+
`/* tw-safelist: ${path3__default.basename(resourcePath)} \u2014 auto-generated */`,
|
|
284
323
|
"@layer utilities {",
|
|
285
324
|
sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
|
|
286
325
|
"}"
|
|
@@ -289,7 +328,17 @@ function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
|
289
328
|
if (fs3__default.readFileSync(outPath, "utf-8") === css) return;
|
|
290
329
|
} catch {
|
|
291
330
|
}
|
|
292
|
-
|
|
331
|
+
const tmpPath = `${outPath}.tmp`;
|
|
332
|
+
try {
|
|
333
|
+
fs3__default.writeFileSync(tmpPath, css, "utf-8");
|
|
334
|
+
fs3__default.renameSync(tmpPath, outPath);
|
|
335
|
+
} catch {
|
|
336
|
+
try {
|
|
337
|
+
fs3__default.unlinkSync(tmpPath);
|
|
338
|
+
} catch {
|
|
339
|
+
}
|
|
340
|
+
fs3__default.writeFileSync(outPath, css, "utf-8");
|
|
341
|
+
}
|
|
293
342
|
} catch {
|
|
294
343
|
}
|
|
295
344
|
}
|
|
@@ -298,7 +347,7 @@ function turbopackLoader(source, options = {}) {
|
|
|
298
347
|
const router = detectRouter(this.resourcePath);
|
|
299
348
|
const nextMajor = parseNum(options.nextMajor);
|
|
300
349
|
const debug = parseBool(options.debug);
|
|
301
|
-
const filename =
|
|
350
|
+
const filename = path3__default.basename(this.resourcePath);
|
|
302
351
|
const effective = {
|
|
303
352
|
addDataAttr: parseBool(options.addDataAttr),
|
|
304
353
|
// App Router: selalu auto-detect client boundary
|
|
@@ -319,7 +368,12 @@ function turbopackLoader(source, options = {}) {
|
|
|
319
368
|
source: stripped,
|
|
320
369
|
options: effective
|
|
321
370
|
});
|
|
322
|
-
if (!output.changed)
|
|
371
|
+
if (!output.changed) {
|
|
372
|
+
if (output.classes.length > 0) {
|
|
373
|
+
writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
|
|
374
|
+
}
|
|
375
|
+
return source;
|
|
376
|
+
}
|
|
323
377
|
if (output.classes.length > 0) {
|
|
324
378
|
registerFileClasses(this.resourcePath, output.classes);
|
|
325
379
|
writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
|