tailwind-styled-v4 5.0.7 → 5.0.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/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/next.d.mts +3 -37
- package/dist/next.d.ts +3 -37
- package/dist/next.js +14 -313
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +14 -313
- package/dist/next.mjs.map +1 -1
- package/dist/turbopackLoader.js +132 -86
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +132 -86
- 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 +88 -83
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +88 -83
- package/dist/webpackLoader.mjs.map +1 -1
- package/package.json +3 -3
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { NextConfig } from 'next';
|
|
2
3
|
|
|
3
4
|
declare const NextAdapterOptionsSchema: z.ZodObject<{
|
|
4
5
|
mode: z.ZodOptional<z.ZodLiteral<"zero-runtime">>;
|
|
@@ -33,47 +34,12 @@ interface TailwindStyledLoaderOptions {
|
|
|
33
34
|
incremental?: boolean;
|
|
34
35
|
verbose?: boolean;
|
|
35
36
|
preserveImports?: boolean;
|
|
36
|
-
/** Path ke safelist dev file — di-inject oleh TwSafelistDevPlugin (dev only) */
|
|
37
|
-
safelistPath?: string;
|
|
38
37
|
}
|
|
39
38
|
interface TailwindStyledNextOptions extends Pick<TailwindStyledLoaderOptions, "mode" | "autoClientBoundary" | "addDataAttr" | "hoist" | "routeCss" | "incremental" | "verbose"> {
|
|
40
39
|
include?: RegExp;
|
|
41
40
|
exclude?: RegExp;
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
options?: TailwindStyledLoaderOptions;
|
|
46
|
-
}
|
|
47
|
-
interface NextWebpackRule {
|
|
48
|
-
test?: RegExp;
|
|
49
|
-
exclude?: RegExp;
|
|
50
|
-
enforce?: "pre" | "post";
|
|
51
|
-
use?: NextWebpackUseEntry[];
|
|
52
|
-
}
|
|
53
|
-
interface NextWebpackConfig {
|
|
54
|
-
module?: {
|
|
55
|
-
rules?: NextWebpackRule[];
|
|
56
|
-
};
|
|
57
|
-
[key: string]: unknown;
|
|
58
|
-
}
|
|
59
|
-
interface NextWebpackOptions {
|
|
60
|
-
buildId: string;
|
|
61
|
-
dev: boolean;
|
|
62
|
-
isServer: boolean;
|
|
63
|
-
nextRuntime?: "nodejs" | "edge";
|
|
64
|
-
defaultLoaders: {
|
|
65
|
-
babel: unknown;
|
|
66
|
-
};
|
|
67
|
-
webpack: unknown;
|
|
68
|
-
dir: string;
|
|
69
|
-
config: Record<string, unknown>;
|
|
70
|
-
totalPages: number;
|
|
71
|
-
}
|
|
72
|
-
interface NextConfigWithTurbopack {
|
|
73
|
-
webpack?: ((config: NextWebpackConfig, options: NextWebpackOptions) => NextWebpackConfig | Promise<NextWebpackConfig>) | null | undefined;
|
|
74
|
-
turbopack?: Record<string, unknown>;
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
}
|
|
77
|
-
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfigWithTurbopack) => NextConfigWithTurbopack;
|
|
42
|
+
|
|
43
|
+
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
78
44
|
|
|
79
45
|
export { type NextAdapterOptionsInput, NextAdapterOptionsSchema, type TailwindStyledNextOptions, parseNextAdapterOptions, withTailwindStyled };
|
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { NextConfig } from 'next';
|
|
2
3
|
|
|
3
4
|
declare const NextAdapterOptionsSchema: z.ZodObject<{
|
|
4
5
|
mode: z.ZodOptional<z.ZodLiteral<"zero-runtime">>;
|
|
@@ -33,47 +34,12 @@ interface TailwindStyledLoaderOptions {
|
|
|
33
34
|
incremental?: boolean;
|
|
34
35
|
verbose?: boolean;
|
|
35
36
|
preserveImports?: boolean;
|
|
36
|
-
/** Path ke safelist dev file — di-inject oleh TwSafelistDevPlugin (dev only) */
|
|
37
|
-
safelistPath?: string;
|
|
38
37
|
}
|
|
39
38
|
interface TailwindStyledNextOptions extends Pick<TailwindStyledLoaderOptions, "mode" | "autoClientBoundary" | "addDataAttr" | "hoist" | "routeCss" | "incremental" | "verbose"> {
|
|
40
39
|
include?: RegExp;
|
|
41
40
|
exclude?: RegExp;
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
options?: TailwindStyledLoaderOptions;
|
|
46
|
-
}
|
|
47
|
-
interface NextWebpackRule {
|
|
48
|
-
test?: RegExp;
|
|
49
|
-
exclude?: RegExp;
|
|
50
|
-
enforce?: "pre" | "post";
|
|
51
|
-
use?: NextWebpackUseEntry[];
|
|
52
|
-
}
|
|
53
|
-
interface NextWebpackConfig {
|
|
54
|
-
module?: {
|
|
55
|
-
rules?: NextWebpackRule[];
|
|
56
|
-
};
|
|
57
|
-
[key: string]: unknown;
|
|
58
|
-
}
|
|
59
|
-
interface NextWebpackOptions {
|
|
60
|
-
buildId: string;
|
|
61
|
-
dev: boolean;
|
|
62
|
-
isServer: boolean;
|
|
63
|
-
nextRuntime?: "nodejs" | "edge";
|
|
64
|
-
defaultLoaders: {
|
|
65
|
-
babel: unknown;
|
|
66
|
-
};
|
|
67
|
-
webpack: unknown;
|
|
68
|
-
dir: string;
|
|
69
|
-
config: Record<string, unknown>;
|
|
70
|
-
totalPages: number;
|
|
71
|
-
}
|
|
72
|
-
interface NextConfigWithTurbopack {
|
|
73
|
-
webpack?: ((config: NextWebpackConfig, options: NextWebpackOptions) => NextWebpackConfig | Promise<NextWebpackConfig>) | null | undefined;
|
|
74
|
-
turbopack?: Record<string, unknown>;
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
}
|
|
77
|
-
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfigWithTurbopack) => NextConfigWithTurbopack;
|
|
42
|
+
|
|
43
|
+
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
78
44
|
|
|
79
45
|
export { type NextAdapterOptionsInput, NextAdapterOptionsSchema, type TailwindStyledNextOptions, parseNextAdapterOptions, withTailwindStyled };
|
package/dist/next.js
CHANGED
|
@@ -122,7 +122,7 @@ function resolveLoaderPath(loaderBasename, importMetaUrl) {
|
|
|
122
122
|
}).path;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
// packages/domain/shared/src/
|
|
125
|
+
// packages/domain/shared/src/index.ts
|
|
126
126
|
var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
127
127
|
var nodeModuleRef = null;
|
|
128
128
|
function getNodeModuleRef() {
|
|
@@ -137,211 +137,17 @@ function getNodeModuleRef() {
|
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var _require = null;
|
|
143
|
-
function getNodeFs() {
|
|
144
|
-
if (isBrowser2) return { existsSync: () => false };
|
|
145
|
-
const nodeRequire = getNodeModuleRef();
|
|
146
|
-
if (!nodeRequire) return { existsSync: () => false };
|
|
147
|
-
if (!_nodeFs) _nodeFs = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)))("node:fs");
|
|
148
|
-
return _nodeFs;
|
|
149
|
-
}
|
|
150
|
-
function getNodePath() {
|
|
151
|
-
if (isBrowser2) return { resolve: () => "", dirname: "" };
|
|
152
|
-
const nodeRequire = getNodeModuleRef();
|
|
153
|
-
if (!nodeRequire) return { resolve: () => "", dirname: "" };
|
|
154
|
-
if (!_nodePath) _nodePath = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)))("node:path");
|
|
155
|
-
return _nodePath;
|
|
156
|
-
}
|
|
157
|
-
function getRequire(_importMetaUrl) {
|
|
158
|
-
if (isBrowser2) return () => {
|
|
159
|
-
throw new Error("node:module not available");
|
|
160
|
-
};
|
|
161
|
-
const nodeRequire = getNodeModuleRef();
|
|
162
|
-
if (!nodeRequire) return () => {
|
|
163
|
-
throw new Error("require not available");
|
|
164
|
-
};
|
|
165
|
-
if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
|
|
166
|
-
return _require;
|
|
167
|
-
}
|
|
168
|
-
var PLATFORM_MAP = {
|
|
169
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
170
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
171
|
-
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
172
|
-
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
173
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
174
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
175
|
-
};
|
|
176
|
-
function platformKey() {
|
|
177
|
-
if (isBrowser2) return "browser";
|
|
178
|
-
return `${process.platform}-${process.arch}`;
|
|
179
|
-
}
|
|
180
|
-
function resolveNativeBinary(runtimeDir) {
|
|
181
|
-
const platform = platformKey();
|
|
182
|
-
const tried = [];
|
|
183
|
-
if (isBrowser2) {
|
|
184
|
-
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
185
|
-
}
|
|
186
|
-
const fs2 = getNodeFs();
|
|
187
|
-
const path2 = getNodePath();
|
|
188
|
-
const _req = getRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
189
|
-
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
190
|
-
if (envPath) {
|
|
191
|
-
if (fs2.existsSync(envPath)) {
|
|
192
|
-
return { path: envPath, source: "env", platform, tried };
|
|
193
|
-
}
|
|
194
|
-
tried.push(`env:${envPath} (not found)`);
|
|
195
|
-
}
|
|
196
|
-
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
197
|
-
return { path: null, source: "not-found", platform, tried: ["disabled by env"] };
|
|
198
|
-
}
|
|
199
|
-
const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
|
|
200
|
-
for (const pkg of prebuiltPkgs) {
|
|
201
|
-
try {
|
|
202
|
-
const candidate = _req.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
203
|
-
if (fs2.existsSync(candidate)) {
|
|
204
|
-
return { path: candidate, source: "prebuilt", platform, tried };
|
|
205
|
-
}
|
|
206
|
-
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
207
|
-
} catch {
|
|
208
|
-
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
const cwd = process.cwd();
|
|
212
|
-
const base = runtimeDir ?? cwd;
|
|
213
|
-
const localCandidates = [
|
|
214
|
-
path2.resolve(base, "tailwind_styled_parser.node"),
|
|
215
|
-
path2.resolve(base, "..", "tailwind_styled_parser.node"),
|
|
216
|
-
path2.resolve(cwd, "native", "tailwind_styled_parser.node"),
|
|
217
|
-
path2.resolve(cwd, "native", "target", "release", "tailwind_styled_parser.node"),
|
|
218
|
-
// napi-rs conventional output
|
|
219
|
-
path2.resolve(base, `tailwind_styled_parser.${platform}.node`)
|
|
220
|
-
];
|
|
221
|
-
for (const candidate of localCandidates) {
|
|
222
|
-
tried.push(`local:${candidate}`);
|
|
223
|
-
if (fs2.existsSync(candidate)) {
|
|
224
|
-
return { path: candidate, source: "local", platform, tried };
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return { path: null, source: "not-found", platform, tried };
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// packages/domain/shared/src/index.ts
|
|
231
|
-
var isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
232
|
-
var nodeModuleRef2 = null;
|
|
233
|
-
function getNodeModuleRef2() {
|
|
234
|
-
if (isBrowser3) return null;
|
|
235
|
-
if (nodeModuleRef2 !== null) return nodeModuleRef2;
|
|
236
|
-
try {
|
|
237
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
238
|
-
nodeModuleRef2 = test;
|
|
239
|
-
return test;
|
|
240
|
-
} catch {
|
|
241
|
-
nodeModuleRef2 = null;
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
var _nodeUrl = null;
|
|
246
|
-
function getNodeUrl() {
|
|
247
|
-
if (isBrowser3) throw new Error("node:url not available in browser");
|
|
248
|
-
const nodeRequire = getNodeModuleRef2();
|
|
249
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
250
|
-
if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)))("node:url");
|
|
251
|
-
return _nodeUrl;
|
|
252
|
-
}
|
|
253
|
-
function getRequire2() {
|
|
254
|
-
if (isBrowser3) return (() => {
|
|
140
|
+
function getRequire() {
|
|
141
|
+
if (isBrowser2) return (() => {
|
|
255
142
|
throw new Error("require not available in browser");
|
|
256
143
|
});
|
|
257
|
-
const nodeRequire =
|
|
144
|
+
const nodeRequire = getNodeModuleRef();
|
|
258
145
|
if (!nodeRequire) return (() => {
|
|
259
146
|
throw new Error("require not available");
|
|
260
147
|
});
|
|
261
148
|
return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
262
149
|
}
|
|
263
|
-
|
|
264
|
-
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
265
|
-
if (isBrowser3) return "";
|
|
266
|
-
try {
|
|
267
|
-
return getNodeUrl().fileURLToPath(importMetaUrl);
|
|
268
|
-
} catch {
|
|
269
|
-
return process.cwd();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
var log = (...args) => {
|
|
273
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
274
|
-
console.log("[compiler:native]", ...args);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
var 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";
|
|
278
|
-
var nativeBridge = null;
|
|
279
|
-
var bridgeLoadAttempted = false;
|
|
280
|
-
var bridgeLoadError = null;
|
|
281
|
-
var isValidNativeBridge = (mod) => {
|
|
282
|
-
const m = mod;
|
|
283
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
284
|
-
};
|
|
285
|
-
var getNativeBridge = () => {
|
|
286
|
-
if (nativeBridge) {
|
|
287
|
-
return nativeBridge;
|
|
288
|
-
}
|
|
289
|
-
if (bridgeLoadAttempted) {
|
|
290
|
-
if (bridgeLoadError) {
|
|
291
|
-
throw bridgeLoadError;
|
|
292
|
-
}
|
|
293
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
294
|
-
}
|
|
295
|
-
bridgeLoadAttempted = true;
|
|
296
|
-
try {
|
|
297
|
-
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
298
|
-
const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
299
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
300
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
301
|
-
try {
|
|
302
|
-
const binding = require3(result.path);
|
|
303
|
-
if (isValidNativeBridge(binding)) {
|
|
304
|
-
nativeBridge = binding;
|
|
305
|
-
log("Native bridge loaded successfully from:", result.path);
|
|
306
|
-
return nativeBridge;
|
|
307
|
-
}
|
|
308
|
-
} catch (e) {
|
|
309
|
-
log("Failed to require native binding:", e);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
313
|
-
|
|
314
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
315
|
-
} catch (err) {
|
|
316
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
317
|
-
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
318
|
-
throw bridgeLoadError;
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
// packages/domain/compiler/src/index.ts
|
|
323
|
-
var compileCssFromClasses = (classes, prefix) => {
|
|
324
|
-
const native = getNativeBridge();
|
|
325
|
-
if (!native?.transformSource) {
|
|
326
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
327
|
-
}
|
|
328
|
-
const result = native.transformSource(classes.join(" "), { prefix: "" });
|
|
329
|
-
if (!result) {
|
|
330
|
-
throw new Error("FATAL: transformSource returned null");
|
|
331
|
-
}
|
|
332
|
-
return result;
|
|
333
|
-
};
|
|
334
|
-
var buildStyleTag = (classes) => {
|
|
335
|
-
const result = compileCssFromClasses(classes);
|
|
336
|
-
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
337
|
-
};
|
|
338
|
-
var _routeClassMap = /* @__PURE__ */ new Map();
|
|
339
|
-
var getAllRouteClasses = () => {
|
|
340
|
-
return new Map(_routeClassMap);
|
|
341
|
-
};
|
|
342
|
-
var clearRouteClasses = () => {
|
|
343
|
-
_routeClassMap.clear();
|
|
344
|
-
};
|
|
150
|
+
getRequire();
|
|
345
151
|
|
|
346
152
|
// packages/presentation/next/src/withTailwindStyled.ts
|
|
347
153
|
function getDirnameFromUrl2(importMetaUrl) {
|
|
@@ -358,12 +164,12 @@ function getDirnameFromUrl2(importMetaUrl) {
|
|
|
358
164
|
return lastSlash > 0 ? importMetaUrl.slice(0, lastSlash) : "";
|
|
359
165
|
}
|
|
360
166
|
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
361
|
-
var
|
|
167
|
+
var resolveRuntimeDir = () => getDirnameFromUrl2((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
362
168
|
var resolveLoaderPath2 = (basename) => {
|
|
363
169
|
try {
|
|
364
170
|
return resolveLoaderPath(basename, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
|
|
365
171
|
} catch {
|
|
366
|
-
const runtimeDir =
|
|
172
|
+
const runtimeDir = resolveRuntimeDir();
|
|
367
173
|
const candidates = [
|
|
368
174
|
path__default.default.resolve(runtimeDir, `${basename}.mjs`),
|
|
369
175
|
path__default.default.resolve(runtimeDir, `${basename}.js`),
|
|
@@ -450,15 +256,14 @@ var applyWebpackRule = (config, options, loaderPath) => {
|
|
|
450
256
|
"@tailwind-styled/theme",
|
|
451
257
|
"@tailwind-styled/preset"
|
|
452
258
|
];
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
configAny.externals = [];
|
|
259
|
+
if (!config.externals) {
|
|
260
|
+
config.externals = [];
|
|
456
261
|
}
|
|
457
|
-
const ext =
|
|
262
|
+
const ext = config.externals;
|
|
458
263
|
if (Array.isArray(ext)) {
|
|
459
264
|
externalPackages.forEach((pkg) => {
|
|
460
265
|
const found = ext.find(
|
|
461
|
-
(e) => typeof e === "string" && e.includes(pkg) || typeof e === "object" && e !== null && Object.keys(e).some((k) => k.includes(pkg))
|
|
266
|
+
(e) => typeof e === "string" && e.includes(pkg) || typeof e === "object" && e !== null && !Array.isArray(e) && Object.keys(e).some((k) => k.includes(pkg))
|
|
462
267
|
);
|
|
463
268
|
if (!found) {
|
|
464
269
|
ext.push(pkg);
|
|
@@ -478,9 +283,10 @@ var mergeTurbopackRules = (existingRules, nextRules) => {
|
|
|
478
283
|
if (typeof current === "object" && current !== null && "loaders" in current) {
|
|
479
284
|
const typedCurrent = current;
|
|
480
285
|
if (Array.isArray(typedCurrent.loaders)) {
|
|
286
|
+
const incomingLoaders = incomingRule.loaders ?? [];
|
|
481
287
|
merged[pattern] = {
|
|
482
288
|
...current,
|
|
483
|
-
loaders: [...typedCurrent.loaders, ...
|
|
289
|
+
loaders: [...typedCurrent.loaders, ...incomingLoaders]
|
|
484
290
|
};
|
|
485
291
|
console.warn(
|
|
486
292
|
`[tailwind-styled] Turbopack rule '${pattern}' already exists. Appending tailwind-styled loader.`
|
|
@@ -495,96 +301,6 @@ var mergeTurbopackRules = (existingRules, nextRules) => {
|
|
|
495
301
|
}
|
|
496
302
|
return merged;
|
|
497
303
|
};
|
|
498
|
-
function escapeClassName(cls) {
|
|
499
|
-
return cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1");
|
|
500
|
-
}
|
|
501
|
-
var TwSafelistDevPlugin = class {
|
|
502
|
-
outputPath;
|
|
503
|
-
lastHash = "";
|
|
504
|
-
constructor(cwd) {
|
|
505
|
-
this.outputPath = path__default.default.resolve(cwd, ".next", "tw-classes", "_webpack-merged.css");
|
|
506
|
-
}
|
|
507
|
-
apply(compiler) {
|
|
508
|
-
const resetClasses = () => {
|
|
509
|
-
try {
|
|
510
|
-
clearRouteClasses();
|
|
511
|
-
} catch {
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
compiler.hooks.watchRun.tap("TwSafelistDevPlugin", resetClasses);
|
|
515
|
-
compiler.hooks.beforeRun.tap("TwSafelistDevPlugin", resetClasses);
|
|
516
|
-
compiler.hooks.afterCompile.tap("TwSafelistDevPlugin", () => {
|
|
517
|
-
try {
|
|
518
|
-
const routeMap = getAllRouteClasses();
|
|
519
|
-
const allClasses = /* @__PURE__ */ new Set();
|
|
520
|
-
for (const classes of routeMap.values()) {
|
|
521
|
-
for (const cls of classes) allClasses.add(cls);
|
|
522
|
-
}
|
|
523
|
-
if (allClasses.size === 0) return;
|
|
524
|
-
const sorted = [...allClasses].sort();
|
|
525
|
-
const hash = sorted.join(",");
|
|
526
|
-
if (hash === this.lastHash) return;
|
|
527
|
-
this.lastHash = hash;
|
|
528
|
-
const css = [
|
|
529
|
-
"/* tailwind-styled-v4 safelist \u2014 auto-generated, do not edit */",
|
|
530
|
-
"/* @tw-safelist */",
|
|
531
|
-
".tw-safelist {",
|
|
532
|
-
sorted.map((cls) => ` /* ${cls} */`).join("\n"),
|
|
533
|
-
"}",
|
|
534
|
-
// Juga emit sebagai @layer utilities agar v4 langsung generate
|
|
535
|
-
"@layer utilities {",
|
|
536
|
-
sorted.map((cls) => `.${escapeClassName(cls)} {}`).join("\n"),
|
|
537
|
-
"}"
|
|
538
|
-
].join("\n");
|
|
539
|
-
const dir = path__default.default.dirname(this.outputPath);
|
|
540
|
-
if (!fs__default.default.existsSync(dir)) fs__default.default.mkdirSync(dir, { recursive: true });
|
|
541
|
-
fs__default.default.writeFileSync(this.outputPath, css, "utf-8");
|
|
542
|
-
} catch {
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
var TwCssManifestPlugin = class {
|
|
548
|
-
apply(compiler) {
|
|
549
|
-
compiler.hooks.emit.tapAsync("TwCssManifestPlugin", async (compilation, callback) => {
|
|
550
|
-
if (compiler.options?.mode === "development") {
|
|
551
|
-
callback();
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
try {
|
|
555
|
-
const routeMap = getAllRouteClasses();
|
|
556
|
-
if (routeMap.size === 0) {
|
|
557
|
-
callback();
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
const manifest = {};
|
|
561
|
-
for (const [route, classes] of routeMap.entries()) {
|
|
562
|
-
if (classes.size === 0) continue;
|
|
563
|
-
let css = "";
|
|
564
|
-
try {
|
|
565
|
-
css = buildStyleTag(Array.from(classes)).replace(/<style[^>]*>/, "").replace(/<\/style>/, "").trim();
|
|
566
|
-
} catch {
|
|
567
|
-
}
|
|
568
|
-
if (!css) continue;
|
|
569
|
-
const filename = route === "/" ? "index.css" : route === "__global" ? "_global.css" : `${route.replace(/^\//, "").replace(/\//g, "_")}.css`;
|
|
570
|
-
const outputPath = `static/css/tw/${filename}`;
|
|
571
|
-
compilation.assets[outputPath] = {
|
|
572
|
-
source: () => css,
|
|
573
|
-
size: () => css.length
|
|
574
|
-
};
|
|
575
|
-
manifest[route] = filename;
|
|
576
|
-
}
|
|
577
|
-
const manifestJson = JSON.stringify({ routes: manifest }, null, 2);
|
|
578
|
-
compilation.assets["static/css/tw/css-manifest.json"] = {
|
|
579
|
-
source: () => manifestJson,
|
|
580
|
-
size: () => manifestJson.length
|
|
581
|
-
};
|
|
582
|
-
} catch {
|
|
583
|
-
}
|
|
584
|
-
callback();
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
304
|
function withTailwindStyled(options = {}) {
|
|
589
305
|
checkNextVersion();
|
|
590
306
|
const normalizedOptions = parseNextAdapterOptions(options);
|
|
@@ -593,12 +309,6 @@ function withTailwindStyled(options = {}) {
|
|
|
593
309
|
return function wrap(nextConfig = {}) {
|
|
594
310
|
const previousWebpack = nextConfig.webpack;
|
|
595
311
|
const loaderOptions = createLoaderOptions(normalizedOptions);
|
|
596
|
-
const safelistPath = path__default.default.resolve(
|
|
597
|
-
typeof process !== "undefined" ? process.cwd() : "",
|
|
598
|
-
".next",
|
|
599
|
-
"tailwind-styled-safelist.css"
|
|
600
|
-
// used as anchor; loader derives tw-classes/ from dirname
|
|
601
|
-
);
|
|
602
312
|
return {
|
|
603
313
|
...nextConfig,
|
|
604
314
|
webpack(config, webpackOptions) {
|
|
@@ -616,15 +326,6 @@ function withTailwindStyled(options = {}) {
|
|
|
616
326
|
"@tailwind-styled/plugin": "commonjs2 @tailwind-styled/plugin"
|
|
617
327
|
});
|
|
618
328
|
}
|
|
619
|
-
if (!finalConfig._twCssPluginAdded) {
|
|
620
|
-
const plugins = finalConfig.plugins ?? [];
|
|
621
|
-
plugins.push(new TwCssManifestPlugin());
|
|
622
|
-
if (webpackOptions.dev) {
|
|
623
|
-
plugins.push(new TwSafelistDevPlugin(webpackOptions.dir));
|
|
624
|
-
}
|
|
625
|
-
finalConfig.plugins = plugins;
|
|
626
|
-
finalConfig._twCssPluginAdded = true;
|
|
627
|
-
}
|
|
628
329
|
return finalConfig;
|
|
629
330
|
};
|
|
630
331
|
if (typeof previousWebpack !== "function") {
|
|
@@ -643,7 +344,7 @@ function withTailwindStyled(options = {}) {
|
|
|
643
344
|
...nextConfig.turbopack ?? {},
|
|
644
345
|
rules: mergeTurbopackRules(
|
|
645
346
|
nextConfig.turbopack?.rules ?? {},
|
|
646
|
-
buildTurbopackRules(turbopackLoaderPath,
|
|
347
|
+
buildTurbopackRules(turbopackLoaderPath, loaderOptions)
|
|
647
348
|
)
|
|
648
349
|
}
|
|
649
350
|
};
|