tailwind-styled-v4 5.0.8 → 5.0.10
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/CHANGELOG.md +204 -416
- package/README.md +45 -15
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +63 -32
- package/dist/index.d.ts +63 -32
- package/dist/index.js +335 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -169
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.d.mts +10 -4
- package/dist/next.d.ts +10 -4
- package/dist/next.js +32 -45
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +30 -43
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +84 -126
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +68 -124
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +69 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +49 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
package/dist/turbopackLoader.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as fs3 from 'fs';
|
|
3
|
+
import fs3__default from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import path__default from 'path';
|
|
6
|
+
import 'crypto';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
4
8
|
|
|
5
9
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
6
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -13,45 +17,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
13
17
|
var __esm = (fn, res) => function __init() {
|
|
14
18
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
19
|
};
|
|
16
|
-
|
|
17
|
-
// packages/domain/shared/src/native-resolution.ts
|
|
18
|
-
function getNodeModuleRef() {
|
|
19
|
-
if (isBrowser) return null;
|
|
20
|
-
if (nodeModuleRef !== null) return nodeModuleRef;
|
|
21
|
-
try {
|
|
22
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
23
|
-
nodeModuleRef = test;
|
|
24
|
-
return test;
|
|
25
|
-
} catch {
|
|
26
|
-
nodeModuleRef = null;
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function getNodeFs() {
|
|
31
|
-
if (isBrowser) return { existsSync: () => false };
|
|
32
|
-
const nodeRequire = getNodeModuleRef();
|
|
33
|
-
if (!nodeRequire) return { existsSync: () => false };
|
|
34
|
-
if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)("node:fs");
|
|
35
|
-
return _nodeFs;
|
|
36
|
-
}
|
|
37
|
-
function getNodePath() {
|
|
38
|
-
if (isBrowser) return { resolve: () => "", dirname: "" };
|
|
39
|
-
const nodeRequire = getNodeModuleRef();
|
|
40
|
-
if (!nodeRequire) return { resolve: () => "", dirname: "" };
|
|
41
|
-
if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)("node:path");
|
|
42
|
-
return _nodePath;
|
|
43
|
-
}
|
|
44
|
-
function getRequire(_importMetaUrl) {
|
|
45
|
-
if (isBrowser) return () => {
|
|
46
|
-
throw new Error("node:module not available");
|
|
47
|
-
};
|
|
48
|
-
const nodeRequire = getNodeModuleRef();
|
|
49
|
-
if (!nodeRequire) return () => {
|
|
50
|
-
throw new Error("require not available");
|
|
51
|
-
};
|
|
52
|
-
if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
|
|
53
|
-
return _require;
|
|
54
|
-
}
|
|
55
20
|
function platformKey() {
|
|
56
21
|
if (isBrowser) return "browser";
|
|
57
22
|
return `${process.platform}-${process.arch}`;
|
|
@@ -62,24 +27,21 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
62
27
|
if (isBrowser) {
|
|
63
28
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
64
29
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
30
|
+
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
31
|
+
return { path: null, source: "not-found", platform, tried: [] };
|
|
32
|
+
}
|
|
68
33
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
69
34
|
if (envPath) {
|
|
70
|
-
if (
|
|
35
|
+
if (fs3.existsSync(envPath)) {
|
|
71
36
|
return { path: envPath, source: "env", platform, tried };
|
|
72
37
|
}
|
|
73
38
|
tried.push(`env:${envPath} (not found)`);
|
|
74
39
|
}
|
|
75
|
-
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
76
|
-
return { path: null, source: "not-found", platform, tried: ["disabled by env"] };
|
|
77
|
-
}
|
|
78
40
|
const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
|
|
79
41
|
for (const pkg of prebuiltPkgs) {
|
|
80
42
|
try {
|
|
81
|
-
const candidate =
|
|
82
|
-
if (
|
|
43
|
+
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
44
|
+
if (fs3.existsSync(candidate)) {
|
|
83
45
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
84
46
|
}
|
|
85
47
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -89,30 +51,43 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
89
51
|
}
|
|
90
52
|
const cwd = process.cwd();
|
|
91
53
|
const base = runtimeDir ?? cwd;
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
54
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
55
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
56
|
+
const localCandidates = [];
|
|
57
|
+
for (const bin of BINARY_NAMES) {
|
|
58
|
+
localCandidates.push(path.resolve(base, `${bin}.node`));
|
|
59
|
+
localCandidates.push(path.resolve(base, "..", `${bin}.node`));
|
|
60
|
+
localCandidates.push(path.resolve(base, `${bin}.${platform}.node`));
|
|
61
|
+
localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
62
|
+
}
|
|
63
|
+
for (const startDir of [cwd, base]) {
|
|
64
|
+
let dir = startDir;
|
|
65
|
+
for (let i = 0; i < 6; i++) {
|
|
66
|
+
const nativeDir = path.resolve(dir, "native");
|
|
67
|
+
for (const bin of BINARY_NAMES) {
|
|
68
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.node`));
|
|
69
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
70
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
71
|
+
localCandidates.push(path.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
72
|
+
}
|
|
73
|
+
const parent = path.resolve(dir, "..");
|
|
74
|
+
if (parent === dir) break;
|
|
75
|
+
dir = parent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
100
78
|
for (const candidate of localCandidates) {
|
|
101
79
|
tried.push(`local:${candidate}`);
|
|
102
|
-
if (
|
|
80
|
+
if (fs3.existsSync(candidate)) {
|
|
103
81
|
return { path: candidate, source: "local", platform, tried };
|
|
104
82
|
}
|
|
105
83
|
}
|
|
106
84
|
return { path: null, source: "not-found", platform, tried };
|
|
107
85
|
}
|
|
108
|
-
var isBrowser,
|
|
86
|
+
var isBrowser, _require, PLATFORM_MAP;
|
|
109
87
|
var init_native_resolution = __esm({
|
|
110
88
|
"packages/domain/shared/src/native-resolution.ts"() {
|
|
111
89
|
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
112
|
-
|
|
113
|
-
_nodeFs = null;
|
|
114
|
-
_nodePath = null;
|
|
115
|
-
_require = null;
|
|
90
|
+
_require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
116
91
|
PLATFORM_MAP = {
|
|
117
92
|
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
118
93
|
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
@@ -123,59 +98,26 @@ var init_native_resolution = __esm({
|
|
|
123
98
|
};
|
|
124
99
|
}
|
|
125
100
|
});
|
|
126
|
-
|
|
127
|
-
// packages/domain/shared/src/index.ts
|
|
128
|
-
function getNodeModuleRef2() {
|
|
129
|
-
if (isBrowser2) return null;
|
|
130
|
-
if (nodeModuleRef2 !== null) return nodeModuleRef2;
|
|
131
|
-
try {
|
|
132
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
133
|
-
nodeModuleRef2 = test;
|
|
134
|
-
return test;
|
|
135
|
-
} catch {
|
|
136
|
-
nodeModuleRef2 = null;
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function getNodeUrl() {
|
|
141
|
-
if (isBrowser2) throw new Error("node:url not available in browser");
|
|
142
|
-
const nodeRequire = getNodeModuleRef2();
|
|
143
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
144
|
-
if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)("node:url");
|
|
145
|
-
return _nodeUrl;
|
|
146
|
-
}
|
|
147
|
-
function getRequire2() {
|
|
148
|
-
if (isBrowser2) return (() => {
|
|
149
|
-
throw new Error("require not available in browser");
|
|
150
|
-
});
|
|
151
|
-
const nodeRequire = getNodeModuleRef2();
|
|
152
|
-
if (!nodeRequire) return (() => {
|
|
153
|
-
throw new Error("require not available");
|
|
154
|
-
});
|
|
155
|
-
return nodeRequire.createRequire(import.meta.url);
|
|
156
|
-
}
|
|
157
101
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
158
|
-
if (isBrowser2) return "";
|
|
159
102
|
try {
|
|
160
|
-
return
|
|
103
|
+
return path__default.dirname(fileURLToPath(importMetaUrl));
|
|
161
104
|
} catch {
|
|
162
105
|
return process.cwd();
|
|
163
106
|
}
|
|
164
107
|
}
|
|
165
|
-
var isBrowser2, nodeModuleRef2, _nodeUrl;
|
|
166
108
|
var init_src = __esm({
|
|
167
109
|
"packages/domain/shared/src/index.ts"() {
|
|
168
110
|
init_native_resolution();
|
|
169
|
-
|
|
170
|
-
nodeModuleRef2 = null;
|
|
171
|
-
_nodeUrl = null;
|
|
172
|
-
getRequire2();
|
|
111
|
+
createRequire(import.meta.url);
|
|
173
112
|
}
|
|
174
113
|
});
|
|
175
|
-
|
|
114
|
+
|
|
115
|
+
// packages/domain/compiler/src/nativeBridge.ts
|
|
116
|
+
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
176
117
|
var init_nativeBridge = __esm({
|
|
177
118
|
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
178
119
|
init_src();
|
|
120
|
+
_loadNative = (path4) => __require(path4);
|
|
179
121
|
log = (...args) => {
|
|
180
122
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
181
123
|
console.log("[compiler:native]", ...args);
|
|
@@ -202,11 +144,10 @@ var init_nativeBridge = __esm({
|
|
|
202
144
|
bridgeLoadAttempted = true;
|
|
203
145
|
try {
|
|
204
146
|
const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
|
|
205
|
-
const require2 = createRequire(import.meta.url);
|
|
206
147
|
const result = resolveNativeBinary(runtimeDir);
|
|
207
148
|
if (result.path && result.path.endsWith(".node")) {
|
|
208
149
|
try {
|
|
209
|
-
const binding =
|
|
150
|
+
const binding = _loadNative(result.path);
|
|
210
151
|
if (isValidNativeBridge(binding)) {
|
|
211
152
|
nativeBridge = binding;
|
|
212
153
|
log("Native bridge loaded successfully from:", result.path);
|
|
@@ -256,7 +197,7 @@ var runLoaderTransform = (ctx) => {
|
|
|
256
197
|
classes: result?.classes || []
|
|
257
198
|
};
|
|
258
199
|
};
|
|
259
|
-
var registerFileClasses = (
|
|
200
|
+
var registerFileClasses = (_filepath, _classes) => {
|
|
260
201
|
};
|
|
261
202
|
function parseBool(val, fallback = false) {
|
|
262
203
|
if (typeof val === "boolean") return val;
|
|
@@ -274,10 +215,13 @@ function detectRouter(resourcePath) {
|
|
|
274
215
|
if (/\/pages\//.test(normalized)) return "pages";
|
|
275
216
|
return "unknown";
|
|
276
217
|
}
|
|
218
|
+
var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
|
|
277
219
|
function isSkippable(resourcePath) {
|
|
278
220
|
const normalized = resourcePath.replace(/\\/g, "/");
|
|
279
221
|
return normalized.includes("/node_modules/") || normalized.endsWith(".d.ts") || normalized.endsWith(".d.mts") || normalized.endsWith(".d.cts") || // Skip CSS/assets
|
|
280
|
-
/\.(css|scss|sass|less|svg|png|jpg|jpeg|gif|webp|ico|woff|woff2|ttf|eot)$/.test(normalized)
|
|
222
|
+
/\.(css|scss|sass|less|svg|png|jpg|jpeg|gif|webp|ico|woff|woff2|ttf|eot)$/.test(normalized) || // Skip Next.js RSC entry files — Turbopack tidak punya exclude di rule level,
|
|
223
|
+
// jadi guard ini menggantikan NEXT_RSC_ENTRIES exclude yang ada di webpack path.
|
|
224
|
+
NEXT_RSC_ENTRIES.test(normalized);
|
|
281
225
|
}
|
|
282
226
|
function extractDirective(source) {
|
|
283
227
|
const match = source.match(/^(\s*["'](use client|use server)["']\s*;?\s*\n?)/);
|
|
@@ -290,29 +234,29 @@ var CYCLE_SENTINEL = "_cycle.txt";
|
|
|
290
234
|
var START_SENTINEL = "_start.txt";
|
|
291
235
|
var _workerCache = /* @__PURE__ */ new Map();
|
|
292
236
|
function getTwClassesDir(safelistPath) {
|
|
293
|
-
return
|
|
237
|
+
return path__default.join(path__default.dirname(safelistPath), "tw-classes");
|
|
294
238
|
}
|
|
295
239
|
function readSentinel(filePath) {
|
|
296
240
|
try {
|
|
297
|
-
return
|
|
241
|
+
return fs3__default.readFileSync(filePath, "utf-8").trim();
|
|
298
242
|
} catch {
|
|
299
243
|
return "";
|
|
300
244
|
}
|
|
301
245
|
}
|
|
302
246
|
function clearAndMarkCycle(twClassesDir, startId) {
|
|
303
247
|
try {
|
|
304
|
-
if (
|
|
305
|
-
for (const file of
|
|
248
|
+
if (fs3__default.existsSync(twClassesDir)) {
|
|
249
|
+
for (const file of fs3__default.readdirSync(twClassesDir)) {
|
|
306
250
|
if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
|
|
307
251
|
try {
|
|
308
|
-
|
|
252
|
+
fs3__default.unlinkSync(path__default.join(twClassesDir, file));
|
|
309
253
|
} catch {
|
|
310
254
|
}
|
|
311
255
|
}
|
|
312
256
|
} else {
|
|
313
|
-
|
|
257
|
+
fs3__default.mkdirSync(twClassesDir, { recursive: true });
|
|
314
258
|
}
|
|
315
|
-
|
|
259
|
+
fs3__default.writeFileSync(path__default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
316
260
|
_workerCache.set(twClassesDir, startId);
|
|
317
261
|
} catch {
|
|
318
262
|
}
|
|
@@ -320,32 +264,32 @@ function clearAndMarkCycle(twClassesDir, startId) {
|
|
|
320
264
|
function getPerFileSafelistPath(safelistDir, resourcePath) {
|
|
321
265
|
const normalized = resourcePath.replace(/\\/g, "/");
|
|
322
266
|
const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
|
|
323
|
-
return
|
|
267
|
+
return path__default.join(safelistDir, `${slug}.css`);
|
|
324
268
|
}
|
|
325
269
|
function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
326
270
|
if (!safelistPath || classes.length === 0) return;
|
|
327
271
|
try {
|
|
328
272
|
const twClassesDir = getTwClassesDir(safelistPath);
|
|
329
|
-
const startId = readSentinel(
|
|
330
|
-
const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(
|
|
273
|
+
const startId = readSentinel(path__default.join(twClassesDir, START_SENTINEL));
|
|
274
|
+
const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path__default.join(twClassesDir, CYCLE_SENTINEL));
|
|
331
275
|
if (startId && cachedCycle !== startId) {
|
|
332
276
|
clearAndMarkCycle(twClassesDir, startId);
|
|
333
|
-
} else if (!
|
|
334
|
-
|
|
277
|
+
} else if (!fs3__default.existsSync(twClassesDir)) {
|
|
278
|
+
fs3__default.mkdirSync(twClassesDir, { recursive: true });
|
|
335
279
|
}
|
|
336
280
|
const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
|
|
337
281
|
const sorted = [...new Set(classes)].sort();
|
|
338
282
|
const css = [
|
|
339
|
-
`/* tw-safelist: ${
|
|
283
|
+
`/* tw-safelist: ${path__default.basename(resourcePath)} \u2014 auto-generated */`,
|
|
340
284
|
"@layer utilities {",
|
|
341
285
|
sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
|
|
342
286
|
"}"
|
|
343
287
|
].join("\n");
|
|
344
288
|
try {
|
|
345
|
-
if (
|
|
289
|
+
if (fs3__default.readFileSync(outPath, "utf-8") === css) return;
|
|
346
290
|
} catch {
|
|
347
291
|
}
|
|
348
|
-
|
|
292
|
+
fs3__default.writeFileSync(outPath, css, "utf-8");
|
|
349
293
|
} catch {
|
|
350
294
|
}
|
|
351
295
|
}
|
|
@@ -354,7 +298,7 @@ function turbopackLoader(source, options = {}) {
|
|
|
354
298
|
const router = detectRouter(this.resourcePath);
|
|
355
299
|
const nextMajor = parseNum(options.nextMajor);
|
|
356
300
|
const debug = parseBool(options.debug);
|
|
357
|
-
const filename =
|
|
301
|
+
const filename = path__default.basename(this.resourcePath);
|
|
358
302
|
const effective = {
|
|
359
303
|
addDataAttr: parseBool(options.addDataAttr),
|
|
360
304
|
// App Router: selalu auto-detect client boundary
|
|
@@ -375,7 +319,7 @@ function turbopackLoader(source, options = {}) {
|
|
|
375
319
|
source: stripped,
|
|
376
320
|
options: effective
|
|
377
321
|
});
|
|
378
|
-
if (!output.changed
|
|
322
|
+
if (!output.changed) return source;
|
|
379
323
|
if (output.classes.length > 0) {
|
|
380
324
|
registerFileClasses(this.resourcePath, output.classes);
|
|
381
325
|
writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
|