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/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">>;
|
|
@@ -24,56 +25,27 @@ declare const parseNextAdapterOptions: (options: unknown) => {
|
|
|
24
25
|
exclude?: RegExp | undefined;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
interface
|
|
28
|
+
interface TailwindStyledNextOptions {
|
|
29
|
+
/** @deprecated — handled by engine internally */
|
|
28
30
|
mode?: "zero-runtime";
|
|
31
|
+
/** @deprecated — handled by engine internally */
|
|
29
32
|
autoClientBoundary?: boolean;
|
|
33
|
+
/** @deprecated — handled by engine internally */
|
|
30
34
|
addDataAttr?: boolean;
|
|
35
|
+
/** @deprecated — handled by engine internally */
|
|
31
36
|
hoist?: boolean;
|
|
37
|
+
/** @deprecated — handled by engine internally */
|
|
32
38
|
routeCss?: boolean;
|
|
39
|
+
/** @deprecated — handled by engine internally */
|
|
33
40
|
incremental?: boolean;
|
|
41
|
+
/** Show detailed loader output */
|
|
34
42
|
verbose?: boolean;
|
|
35
|
-
|
|
36
|
-
/** Path ke safelist dev file — di-inject oleh TwSafelistDevPlugin (dev only) */
|
|
43
|
+
/** Path to generated safelist CSS file. Default: <cwd>/__tw_safelist.css */
|
|
37
44
|
safelistPath?: string;
|
|
38
|
-
}
|
|
39
|
-
interface TailwindStyledNextOptions extends Pick<TailwindStyledLoaderOptions, "mode" | "autoClientBoundary" | "addDataAttr" | "hoist" | "routeCss" | "incremental" | "verbose"> {
|
|
40
45
|
include?: RegExp;
|
|
41
46
|
exclude?: RegExp;
|
|
42
47
|
}
|
|
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;
|
|
48
|
+
|
|
49
|
+
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
78
50
|
|
|
79
51
|
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">>;
|
|
@@ -24,56 +25,27 @@ declare const parseNextAdapterOptions: (options: unknown) => {
|
|
|
24
25
|
exclude?: RegExp | undefined;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
interface
|
|
28
|
+
interface TailwindStyledNextOptions {
|
|
29
|
+
/** @deprecated — handled by engine internally */
|
|
28
30
|
mode?: "zero-runtime";
|
|
31
|
+
/** @deprecated — handled by engine internally */
|
|
29
32
|
autoClientBoundary?: boolean;
|
|
33
|
+
/** @deprecated — handled by engine internally */
|
|
30
34
|
addDataAttr?: boolean;
|
|
35
|
+
/** @deprecated — handled by engine internally */
|
|
31
36
|
hoist?: boolean;
|
|
37
|
+
/** @deprecated — handled by engine internally */
|
|
32
38
|
routeCss?: boolean;
|
|
39
|
+
/** @deprecated — handled by engine internally */
|
|
33
40
|
incremental?: boolean;
|
|
41
|
+
/** Show detailed loader output */
|
|
34
42
|
verbose?: boolean;
|
|
35
|
-
|
|
36
|
-
/** Path ke safelist dev file — di-inject oleh TwSafelistDevPlugin (dev only) */
|
|
43
|
+
/** Path to generated safelist CSS file. Default: <cwd>/__tw_safelist.css */
|
|
37
44
|
safelistPath?: string;
|
|
38
|
-
}
|
|
39
|
-
interface TailwindStyledNextOptions extends Pick<TailwindStyledLoaderOptions, "mode" | "autoClientBoundary" | "addDataAttr" | "hoist" | "routeCss" | "incremental" | "verbose"> {
|
|
40
45
|
include?: RegExp;
|
|
41
46
|
exclude?: RegExp;
|
|
42
47
|
}
|
|
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;
|
|
48
|
+
|
|
49
|
+
declare function withTailwindStyled(options?: TailwindStyledNextOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
78
50
|
|
|
79
51
|
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`),
|
|
@@ -394,17 +200,21 @@ function checkNextVersion() {
|
|
|
394
200
|
}
|
|
395
201
|
var DEFAULT_INCLUDE = /\.[jt]sx?$/;
|
|
396
202
|
var DEFAULT_EXCLUDE = /node_modules/;
|
|
203
|
+
var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
|
|
204
|
+
var buildExcludePattern = (userExclude) => {
|
|
205
|
+
if (!userExclude) return new RegExp(`(?:${DEFAULT_EXCLUDE.source})|(?:${NEXT_RSC_ENTRIES.source})`);
|
|
206
|
+
return new RegExp(`(?:${userExclude.source})|(?:${NEXT_RSC_ENTRIES.source})`);
|
|
207
|
+
};
|
|
397
208
|
var createLoaderOptions = (options) => {
|
|
398
209
|
const opts = {
|
|
399
|
-
mode:
|
|
400
|
-
|
|
210
|
+
mode: "zero-runtime",
|
|
211
|
+
// only supported mode
|
|
212
|
+
autoClientBoundary: true,
|
|
213
|
+
// always on (engine handles it)
|
|
401
214
|
preserveImports: true
|
|
402
215
|
};
|
|
403
|
-
if (options.addDataAttr !== void 0) opts.addDataAttr = options.addDataAttr;
|
|
404
|
-
if (options.hoist !== void 0) opts.hoist = options.hoist;
|
|
405
|
-
if (options.routeCss !== void 0) opts.routeCss = options.routeCss;
|
|
406
|
-
if (options.incremental !== void 0) opts.incremental = options.incremental;
|
|
407
216
|
if (options.verbose !== void 0) opts.verbose = options.verbose;
|
|
217
|
+
opts.safelistPath = options.safelistPath ?? path__default.default.join(process.cwd(), "__tw_safelist.css");
|
|
408
218
|
return Object.freeze(opts);
|
|
409
219
|
};
|
|
410
220
|
var buildTurbopackRules = (loaderPath, loaderOptions) => {
|
|
@@ -429,7 +239,9 @@ var applyWebpackRule = (config, options, loaderPath) => {
|
|
|
429
239
|
if (alreadyRegistered) return config;
|
|
430
240
|
const tailwindStyledRule = {
|
|
431
241
|
test: options.include ?? DEFAULT_INCLUDE,
|
|
432
|
-
|
|
242
|
+
// Selalu kecualikan Next.js RSC entry files (layout, page, dll) bahkan jika
|
|
243
|
+
// user menyuplai exclude pattern sendiri — lihat buildExcludePattern.
|
|
244
|
+
exclude: buildExcludePattern(options.exclude),
|
|
433
245
|
enforce: "pre",
|
|
434
246
|
use: [{ loader: loaderPath, options: loaderOptions }]
|
|
435
247
|
};
|
|
@@ -450,15 +262,14 @@ var applyWebpackRule = (config, options, loaderPath) => {
|
|
|
450
262
|
"@tailwind-styled/theme",
|
|
451
263
|
"@tailwind-styled/preset"
|
|
452
264
|
];
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
configAny.externals = [];
|
|
265
|
+
if (!config.externals) {
|
|
266
|
+
config.externals = [];
|
|
456
267
|
}
|
|
457
|
-
const ext =
|
|
268
|
+
const ext = config.externals;
|
|
458
269
|
if (Array.isArray(ext)) {
|
|
459
270
|
externalPackages.forEach((pkg) => {
|
|
460
271
|
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))
|
|
272
|
+
(e) => typeof e === "string" && e.includes(pkg) || typeof e === "object" && e !== null && !Array.isArray(e) && Object.keys(e).some((k) => k.includes(pkg))
|
|
462
273
|
);
|
|
463
274
|
if (!found) {
|
|
464
275
|
ext.push(pkg);
|
|
@@ -478,9 +289,10 @@ var mergeTurbopackRules = (existingRules, nextRules) => {
|
|
|
478
289
|
if (typeof current === "object" && current !== null && "loaders" in current) {
|
|
479
290
|
const typedCurrent = current;
|
|
480
291
|
if (Array.isArray(typedCurrent.loaders)) {
|
|
292
|
+
const incomingLoaders = incomingRule.loaders ?? [];
|
|
481
293
|
merged[pattern] = {
|
|
482
294
|
...current,
|
|
483
|
-
loaders: [...typedCurrent.loaders, ...
|
|
295
|
+
loaders: [...typedCurrent.loaders, ...incomingLoaders]
|
|
484
296
|
};
|
|
485
297
|
console.warn(
|
|
486
298
|
`[tailwind-styled] Turbopack rule '${pattern}' already exists. Appending tailwind-styled loader.`
|
|
@@ -495,96 +307,6 @@ var mergeTurbopackRules = (existingRules, nextRules) => {
|
|
|
495
307
|
}
|
|
496
308
|
return merged;
|
|
497
309
|
};
|
|
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
310
|
function withTailwindStyled(options = {}) {
|
|
589
311
|
checkNextVersion();
|
|
590
312
|
const normalizedOptions = parseNextAdapterOptions(options);
|
|
@@ -593,12 +315,6 @@ function withTailwindStyled(options = {}) {
|
|
|
593
315
|
return function wrap(nextConfig = {}) {
|
|
594
316
|
const previousWebpack = nextConfig.webpack;
|
|
595
317
|
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
318
|
return {
|
|
603
319
|
...nextConfig,
|
|
604
320
|
webpack(config, webpackOptions) {
|
|
@@ -616,15 +332,6 @@ function withTailwindStyled(options = {}) {
|
|
|
616
332
|
"@tailwind-styled/plugin": "commonjs2 @tailwind-styled/plugin"
|
|
617
333
|
});
|
|
618
334
|
}
|
|
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
335
|
return finalConfig;
|
|
629
336
|
};
|
|
630
337
|
if (typeof previousWebpack !== "function") {
|
|
@@ -643,7 +350,7 @@ function withTailwindStyled(options = {}) {
|
|
|
643
350
|
...nextConfig.turbopack ?? {},
|
|
644
351
|
rules: mergeTurbopackRules(
|
|
645
352
|
nextConfig.turbopack?.rules ?? {},
|
|
646
|
-
buildTurbopackRules(turbopackLoaderPath,
|
|
353
|
+
buildTurbopackRules(turbopackLoaderPath, loaderOptions)
|
|
647
354
|
)
|
|
648
355
|
}
|
|
649
356
|
};
|