tailwind-styled-v4 5.0.7 → 5.0.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/CHANGELOG.md +184 -410
- package/README.md +45 -15
- package/dist/cli.js +62 -52
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +62 -52
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +8 -3
- package/dist/compiler.d.ts +8 -3
- package/dist/compiler.js +214 -127
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +195 -103
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +146 -66
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +146 -66
- package/dist/engine.mjs.map +1 -1
- package/dist/index.d.mts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +72 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -19
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +12 -40
- package/dist/next.d.ts +12 -40
- package/dist/next.js +27 -320
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +27 -320
- package/dist/next.mjs.map +1 -1
- package/dist/turbopackLoader.js +137 -88
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +137 -88
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +62 -52
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +62 -52
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +146 -66
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +146 -66
- package/dist/vite.mjs.map +1 -1
- package/dist/webpackLoader.js +92 -83
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +92 -83
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +3 -3
package/dist/turbopackLoader.js
CHANGED
|
@@ -11,16 +11,18 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
|
11
11
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
12
12
|
|
|
13
13
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
15
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
16
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
16
17
|
}) : x)(function(x) {
|
|
17
18
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
18
19
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
19
20
|
});
|
|
21
|
+
var __esm = (fn, res) => function __init() {
|
|
22
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
23
|
+
};
|
|
20
24
|
|
|
21
25
|
// packages/domain/shared/src/native-resolution.ts
|
|
22
|
-
var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
23
|
-
var nodeModuleRef = null;
|
|
24
26
|
function getNodeModuleRef() {
|
|
25
27
|
if (isBrowser) return null;
|
|
26
28
|
if (nodeModuleRef !== null) return nodeModuleRef;
|
|
@@ -33,9 +35,6 @@ function getNodeModuleRef() {
|
|
|
33
35
|
return null;
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
var _nodeFs = null;
|
|
37
|
-
var _nodePath = null;
|
|
38
|
-
var _require = null;
|
|
39
38
|
function getNodeFs() {
|
|
40
39
|
if (isBrowser) return { existsSync: () => false };
|
|
41
40
|
const nodeRequire = getNodeModuleRef();
|
|
@@ -61,14 +60,6 @@ function getRequire(_importMetaUrl) {
|
|
|
61
60
|
if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
|
|
62
61
|
return _require;
|
|
63
62
|
}
|
|
64
|
-
var PLATFORM_MAP = {
|
|
65
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
66
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
67
|
-
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
68
|
-
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
69
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
70
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
71
|
-
};
|
|
72
63
|
function platformKey() {
|
|
73
64
|
if (isBrowser) return "browser";
|
|
74
65
|
return `${process.platform}-${process.arch}`;
|
|
@@ -122,10 +113,26 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
122
113
|
}
|
|
123
114
|
return { path: null, source: "not-found", platform, tried };
|
|
124
115
|
}
|
|
116
|
+
var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _require, PLATFORM_MAP;
|
|
117
|
+
var init_native_resolution = __esm({
|
|
118
|
+
"packages/domain/shared/src/native-resolution.ts"() {
|
|
119
|
+
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
120
|
+
nodeModuleRef = null;
|
|
121
|
+
_nodeFs = null;
|
|
122
|
+
_nodePath = null;
|
|
123
|
+
_require = null;
|
|
124
|
+
PLATFORM_MAP = {
|
|
125
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
126
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
127
|
+
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
128
|
+
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
129
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
130
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
});
|
|
125
134
|
|
|
126
135
|
// packages/domain/shared/src/index.ts
|
|
127
|
-
var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
128
|
-
var nodeModuleRef2 = null;
|
|
129
136
|
function getNodeModuleRef2() {
|
|
130
137
|
if (isBrowser2) return null;
|
|
131
138
|
if (nodeModuleRef2 !== null) return nodeModuleRef2;
|
|
@@ -138,7 +145,6 @@ function getNodeModuleRef2() {
|
|
|
138
145
|
return null;
|
|
139
146
|
}
|
|
140
147
|
}
|
|
141
|
-
var _nodeUrl = null;
|
|
142
148
|
function getNodeUrl() {
|
|
143
149
|
if (isBrowser2) throw new Error("node:url not available in browser");
|
|
144
150
|
const nodeRequire = getNodeModuleRef2();
|
|
@@ -156,7 +162,6 @@ function getRequire2() {
|
|
|
156
162
|
});
|
|
157
163
|
return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
|
|
158
164
|
}
|
|
159
|
-
getRequire2();
|
|
160
165
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
161
166
|
if (isBrowser2) return "";
|
|
162
167
|
try {
|
|
@@ -165,57 +170,80 @@ function resolveRuntimeDir(dir, importMetaUrl) {
|
|
|
165
170
|
return process.cwd();
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
var bridgeLoadError = null;
|
|
177
|
-
var isValidNativeBridge = (mod) => {
|
|
178
|
-
const m = mod;
|
|
179
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
180
|
-
};
|
|
181
|
-
var getNativeBridge = () => {
|
|
182
|
-
if (nativeBridge) {
|
|
183
|
-
return nativeBridge;
|
|
184
|
-
}
|
|
185
|
-
if (bridgeLoadAttempted) {
|
|
186
|
-
if (bridgeLoadError) {
|
|
187
|
-
throw bridgeLoadError;
|
|
188
|
-
}
|
|
189
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
173
|
+
var isBrowser2, nodeModuleRef2, _nodeUrl;
|
|
174
|
+
var init_src = __esm({
|
|
175
|
+
"packages/domain/shared/src/index.ts"() {
|
|
176
|
+
init_native_resolution();
|
|
177
|
+
isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
178
|
+
nodeModuleRef2 = null;
|
|
179
|
+
_nodeUrl = null;
|
|
180
|
+
getRequire2();
|
|
190
181
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
});
|
|
183
|
+
var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
184
|
+
var init_nativeBridge = __esm({
|
|
185
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
186
|
+
init_src();
|
|
187
|
+
log = (...args) => {
|
|
188
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
189
|
+
console.log("[compiler:native]", ...args);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
|
|
193
|
+
nativeBridge = null;
|
|
194
|
+
bridgeLoadAttempted = false;
|
|
195
|
+
bridgeLoadError = null;
|
|
196
|
+
isValidNativeBridge = (mod) => {
|
|
197
|
+
const m = mod;
|
|
198
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
199
|
+
};
|
|
200
|
+
getNativeBridge = () => {
|
|
201
|
+
if (nativeBridge) {
|
|
202
|
+
return nativeBridge;
|
|
203
|
+
}
|
|
204
|
+
if (bridgeLoadAttempted) {
|
|
205
|
+
if (bridgeLoadError) {
|
|
206
|
+
throw bridgeLoadError;
|
|
203
207
|
}
|
|
204
|
-
|
|
205
|
-
log("Failed to require native binding:", e);
|
|
208
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
206
209
|
}
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
bridgeLoadAttempted = true;
|
|
211
|
+
try {
|
|
212
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
|
|
213
|
+
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
|
|
214
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
215
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
216
|
+
try {
|
|
217
|
+
const binding = require2(result.path);
|
|
218
|
+
if (isValidNativeBridge(binding)) {
|
|
219
|
+
nativeBridge = binding;
|
|
220
|
+
log("Native bridge loaded successfully from:", result.path);
|
|
221
|
+
return nativeBridge;
|
|
222
|
+
}
|
|
223
|
+
} catch (e) {
|
|
224
|
+
log("Failed to require native binding:", e);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
209
228
|
|
|
210
229
|
Tried paths: ${result.tried.join("\n")}`);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
230
|
+
} catch (err) {
|
|
231
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
232
|
+
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
233
|
+
throw bridgeLoadError;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
237
|
+
try {
|
|
238
|
+
getNativeBridge();
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
241
|
+
}
|
|
215
242
|
}
|
|
216
|
-
};
|
|
243
|
+
});
|
|
217
244
|
|
|
218
245
|
// packages/domain/compiler/src/index.ts
|
|
246
|
+
init_nativeBridge();
|
|
219
247
|
var transformSource = (source, opts) => {
|
|
220
248
|
const native = getNativeBridge();
|
|
221
249
|
if (!native?.transformSource) {
|
|
@@ -236,30 +264,7 @@ var runLoaderTransform = (ctx) => {
|
|
|
236
264
|
classes: result?.classes || []
|
|
237
265
|
};
|
|
238
266
|
};
|
|
239
|
-
var fileToRoute = (filepath) => {
|
|
240
|
-
const normalized = filepath.replace(/\\/g, "/");
|
|
241
|
-
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
242
|
-
return "__global";
|
|
243
|
-
}
|
|
244
|
-
const appPageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
245
|
-
if (appPageMatch) return `/${appPageMatch[1]}`;
|
|
246
|
-
const appRootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
247
|
-
if (appRootPage) return "/";
|
|
248
|
-
const pagesMatch = normalized.match(/\/pages\/(.+?)\.[tj]sx?$/);
|
|
249
|
-
if (pagesMatch) {
|
|
250
|
-
const pagePath = pagesMatch[1];
|
|
251
|
-
if (pagePath.startsWith("_") || pagePath.startsWith("api/")) return "__global";
|
|
252
|
-
return pagePath === "index" ? "/" : `/${pagePath}`;
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
};
|
|
256
|
-
var _routeClassMap = /* @__PURE__ */ new Map();
|
|
257
267
|
var registerFileClasses = (filepath, classes) => {
|
|
258
|
-
if (!classes.length) return;
|
|
259
|
-
const route = fileToRoute(filepath) ?? "__global";
|
|
260
|
-
const existing = _routeClassMap.get(route) ?? /* @__PURE__ */ new Set();
|
|
261
|
-
for (const cls of classes) existing.add(cls);
|
|
262
|
-
_routeClassMap.set(route, existing);
|
|
263
268
|
};
|
|
264
269
|
function parseBool(val, fallback = false) {
|
|
265
270
|
if (typeof val === "boolean") return val;
|
|
@@ -277,10 +282,13 @@ function detectRouter(resourcePath) {
|
|
|
277
282
|
if (/\/pages\//.test(normalized)) return "pages";
|
|
278
283
|
return "unknown";
|
|
279
284
|
}
|
|
285
|
+
var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
|
|
280
286
|
function isSkippable(resourcePath) {
|
|
281
287
|
const normalized = resourcePath.replace(/\\/g, "/");
|
|
282
288
|
return normalized.includes("/node_modules/") || normalized.endsWith(".d.ts") || normalized.endsWith(".d.mts") || normalized.endsWith(".d.cts") || // Skip CSS/assets
|
|
283
|
-
/\.(css|scss|sass|less|svg|png|jpg|jpeg|gif|webp|ico|woff|woff2|ttf|eot)$/.test(normalized)
|
|
289
|
+
/\.(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,
|
|
290
|
+
// jadi guard ini menggantikan NEXT_RSC_ENTRIES exclude yang ada di webpack path.
|
|
291
|
+
NEXT_RSC_ENTRIES.test(normalized);
|
|
284
292
|
}
|
|
285
293
|
function extractDirective(source) {
|
|
286
294
|
const match = source.match(/^(\s*["'](use client|use server)["']\s*;?\s*\n?)/);
|
|
@@ -289,6 +297,37 @@ function extractDirective(source) {
|
|
|
289
297
|
const stripped = source.slice(match[0].length);
|
|
290
298
|
return { directive, stripped };
|
|
291
299
|
}
|
|
300
|
+
var CYCLE_SENTINEL = "_cycle.txt";
|
|
301
|
+
var START_SENTINEL = "_start.txt";
|
|
302
|
+
var _workerCache = /* @__PURE__ */ new Map();
|
|
303
|
+
function getTwClassesDir(safelistPath) {
|
|
304
|
+
return path__default.default.join(path__default.default.dirname(safelistPath), "tw-classes");
|
|
305
|
+
}
|
|
306
|
+
function readSentinel(filePath) {
|
|
307
|
+
try {
|
|
308
|
+
return fs__default.default.readFileSync(filePath, "utf-8").trim();
|
|
309
|
+
} catch {
|
|
310
|
+
return "";
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function clearAndMarkCycle(twClassesDir, startId) {
|
|
314
|
+
try {
|
|
315
|
+
if (fs__default.default.existsSync(twClassesDir)) {
|
|
316
|
+
for (const file of fs__default.default.readdirSync(twClassesDir)) {
|
|
317
|
+
if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
|
|
318
|
+
try {
|
|
319
|
+
fs__default.default.unlinkSync(path__default.default.join(twClassesDir, file));
|
|
320
|
+
} catch {
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
fs__default.default.mkdirSync(twClassesDir, { recursive: true });
|
|
325
|
+
}
|
|
326
|
+
fs__default.default.writeFileSync(path__default.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
|
|
327
|
+
_workerCache.set(twClassesDir, startId);
|
|
328
|
+
} catch {
|
|
329
|
+
}
|
|
330
|
+
}
|
|
292
331
|
function getPerFileSafelistPath(safelistDir, resourcePath) {
|
|
293
332
|
const normalized = resourcePath.replace(/\\/g, "/");
|
|
294
333
|
const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
|
|
@@ -297,9 +336,15 @@ function getPerFileSafelistPath(safelistDir, resourcePath) {
|
|
|
297
336
|
function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
298
337
|
if (!safelistPath || classes.length === 0) return;
|
|
299
338
|
try {
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
339
|
+
const twClassesDir = getTwClassesDir(safelistPath);
|
|
340
|
+
const startId = readSentinel(path__default.default.join(twClassesDir, START_SENTINEL));
|
|
341
|
+
const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path__default.default.join(twClassesDir, CYCLE_SENTINEL));
|
|
342
|
+
if (startId && cachedCycle !== startId) {
|
|
343
|
+
clearAndMarkCycle(twClassesDir, startId);
|
|
344
|
+
} else if (!fs__default.default.existsSync(twClassesDir)) {
|
|
345
|
+
fs__default.default.mkdirSync(twClassesDir, { recursive: true });
|
|
346
|
+
}
|
|
347
|
+
const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
|
|
303
348
|
const sorted = [...new Set(classes)].sort();
|
|
304
349
|
const css = [
|
|
305
350
|
`/* tw-safelist: ${path__default.default.basename(resourcePath)} \u2014 auto-generated */`,
|
|
@@ -307,6 +352,10 @@ function writePerFileSafelist(safelistPath, resourcePath, classes) {
|
|
|
307
352
|
sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
|
|
308
353
|
"}"
|
|
309
354
|
].join("\n");
|
|
355
|
+
try {
|
|
356
|
+
if (fs__default.default.readFileSync(outPath, "utf-8") === css) return;
|
|
357
|
+
} catch {
|
|
358
|
+
}
|
|
310
359
|
fs__default.default.writeFileSync(outPath, css, "utf-8");
|
|
311
360
|
} catch {
|
|
312
361
|
}
|
|
@@ -337,7 +386,7 @@ function turbopackLoader(source, options = {}) {
|
|
|
337
386
|
source: stripped,
|
|
338
387
|
options: effective
|
|
339
388
|
});
|
|
340
|
-
if (!output.changed
|
|
389
|
+
if (!output.changed) return source;
|
|
341
390
|
if (output.classes.length > 0) {
|
|
342
391
|
registerFileClasses(this.resourcePath, output.classes);
|
|
343
392
|
writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
|