tailwind-styled-v4 5.0.34 → 5.0.36

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.
Files changed (50) hide show
  1. package/README.md +458 -339
  2. package/dist/cli.js +9 -6
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +9 -6
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/compiler.js +60 -8
  7. package/dist/compiler.js.map +1 -1
  8. package/dist/compiler.mjs +60 -8
  9. package/dist/compiler.mjs.map +1 -1
  10. package/dist/engine.js +60 -8
  11. package/dist/engine.js.map +1 -1
  12. package/dist/engine.mjs +60 -8
  13. package/dist/engine.mjs.map +1 -1
  14. package/dist/index.browser.mjs +689 -508
  15. package/dist/index.browser.mjs.map +1 -1
  16. package/dist/index.js +98 -28
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +98 -28
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/next.js +304 -182
  21. package/dist/next.js.map +1 -1
  22. package/dist/next.mjs +304 -182
  23. package/dist/next.mjs.map +1 -1
  24. package/dist/shared.js +60 -8
  25. package/dist/shared.js.map +1 -1
  26. package/dist/shared.mjs +60 -8
  27. package/dist/shared.mjs.map +1 -1
  28. package/dist/svelte.js +4 -4
  29. package/dist/svelte.js.map +1 -1
  30. package/dist/svelte.mjs +4 -4
  31. package/dist/svelte.mjs.map +1 -1
  32. package/dist/turbopackLoader.js +60 -8
  33. package/dist/turbopackLoader.js.map +1 -1
  34. package/dist/turbopackLoader.mjs +60 -8
  35. package/dist/turbopackLoader.mjs.map +1 -1
  36. package/dist/tw.js +9 -6
  37. package/dist/tw.js.map +1 -1
  38. package/dist/tw.mjs +9 -6
  39. package/dist/tw.mjs.map +1 -1
  40. package/dist/vite.js +60 -8
  41. package/dist/vite.js.map +1 -1
  42. package/dist/vite.mjs +60 -8
  43. package/dist/vite.mjs.map +1 -1
  44. package/dist/vue.js +4 -4
  45. package/dist/vue.js.map +1 -1
  46. package/dist/vue.mjs +4 -4
  47. package/dist/vue.mjs.map +1 -1
  48. package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
  49. package/native/tailwind-styled-native.node +0 -0
  50. package/package.json +7 -5
package/dist/next.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var module$1 = require('module');
4
- var fs9 = require('fs');
5
- var path10 = require('path');
4
+ var fs10 = require('fs');
5
+ var path11 = require('path');
6
6
  require('crypto');
7
7
  var url = require('url');
8
8
  var zod = require('zod');
@@ -27,8 +27,8 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var fs9__namespace = /*#__PURE__*/_interopNamespace(fs9);
31
- var path10__namespace = /*#__PURE__*/_interopNamespace(path10);
30
+ var fs10__namespace = /*#__PURE__*/_interopNamespace(fs10);
31
+ var path11__namespace = /*#__PURE__*/_interopNamespace(path11);
32
32
 
33
33
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
34
34
  var __defProp = Object.defineProperty;
@@ -84,11 +84,11 @@ function resolvePath(...segments) {
84
84
  return segments.join("/").replace(/\/+/g, "/");
85
85
  }
86
86
  }
87
- function existsSync(path11) {
87
+ function existsSync(path12) {
88
88
  if (isBrowser) return false;
89
89
  try {
90
90
  const nodeFs = __require(NODE_FS);
91
- return nodeFs.existsSync(path11);
91
+ return nodeFs.existsSync(path12);
92
92
  } catch {
93
93
  return false;
94
94
  }
@@ -162,7 +162,7 @@ function resolveNativeBinary(runtimeDir) {
162
162
  }
163
163
  const envPath = process.env.TW_NATIVE_PATH?.trim();
164
164
  if (envPath) {
165
- if (fs9__namespace.existsSync(envPath)) {
165
+ if (fs10__namespace.existsSync(envPath)) {
166
166
  return { path: envPath, source: "env", platform, tried };
167
167
  }
168
168
  tried.push(`env:${envPath} (not found)`);
@@ -171,7 +171,7 @@ function resolveNativeBinary(runtimeDir) {
171
171
  for (const pkg of prebuiltPkgs) {
172
172
  try {
173
173
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
174
- if (fs9__namespace.existsSync(candidate)) {
174
+ if (fs10__namespace.existsSync(candidate)) {
175
175
  return { path: candidate, source: "prebuilt", platform, tried };
176
176
  }
177
177
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -182,13 +182,13 @@ function resolveNativeBinary(runtimeDir) {
182
182
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
183
183
  const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
184
184
  if (runtimeDir) {
185
- for (const depth of ["..", path10__namespace.join("..", ".."), path10__namespace.join("..", "..", "..")]) {
186
- const pkgRoot = path10__namespace.resolve(runtimeDir, depth);
185
+ for (const depth of ["..", path11__namespace.join("..", ".."), path11__namespace.join("..", "..", "..")]) {
186
+ const pkgRoot = path11__namespace.resolve(runtimeDir, depth);
187
187
  for (const bin of BINARY_NAMES_SELF) {
188
188
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
189
- const candidate = path10__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
189
+ const candidate = path11__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
190
190
  tried.push(`self-bundled:${candidate}`);
191
- if (fs9__namespace.existsSync(candidate)) {
191
+ if (fs10__namespace.existsSync(candidate)) {
192
192
  return { path: candidate, source: "prebuilt", platform, tried };
193
193
  }
194
194
  }
@@ -200,29 +200,29 @@ function resolveNativeBinary(runtimeDir) {
200
200
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
201
201
  const localCandidates = [];
202
202
  for (const bin of BINARY_NAMES) {
203
- localCandidates.push(path10__namespace.resolve(base, `${bin}.node`));
204
- localCandidates.push(path10__namespace.resolve(base, "..", `${bin}.node`));
205
- localCandidates.push(path10__namespace.resolve(base, `${bin}.${platform}.node`));
206
- localCandidates.push(path10__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
203
+ localCandidates.push(path11__namespace.resolve(base, `${bin}.node`));
204
+ localCandidates.push(path11__namespace.resolve(base, "..", `${bin}.node`));
205
+ localCandidates.push(path11__namespace.resolve(base, `${bin}.${platform}.node`));
206
+ localCandidates.push(path11__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
207
207
  }
208
208
  for (const startDir of [cwd, base]) {
209
209
  let dir = startDir;
210
210
  for (let i = 0; i < 6; i++) {
211
- const nativeDir = path10__namespace.resolve(dir, "native");
211
+ const nativeDir = path11__namespace.resolve(dir, "native");
212
212
  for (const bin of BINARY_NAMES) {
213
- localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.node`));
214
- localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
215
- localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
216
- localCandidates.push(path10__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
213
+ localCandidates.push(path11__namespace.resolve(nativeDir, `${bin}.node`));
214
+ localCandidates.push(path11__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
215
+ localCandidates.push(path11__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
216
+ localCandidates.push(path11__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
217
217
  }
218
- const parent = path10__namespace.resolve(dir, "..");
218
+ const parent = path11__namespace.resolve(dir, "..");
219
219
  if (parent === dir) break;
220
220
  dir = parent;
221
221
  }
222
222
  }
223
223
  for (const candidate of localCandidates) {
224
224
  tried.push(`local:${candidate}`);
225
- if (fs9__namespace.existsSync(candidate)) {
225
+ if (fs10__namespace.existsSync(candidate)) {
226
226
  return { path: candidate, source: "local", platform, tried };
227
227
  }
228
228
  }
@@ -249,7 +249,7 @@ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttemp
249
249
  var init_nativeBridge = __esm({
250
250
  "packages/domain/compiler/src/nativeBridge.ts"() {
251
251
  init_src2();
252
- _loadNative = (path11) => __require(path11);
252
+ _loadNative = (path12) => __require(path12);
253
253
  log = (...args) => {
254
254
  if (process.env.DEBUG?.includes("compiler:native")) {
255
255
  console.log("[compiler:native]", ...args);
@@ -863,6 +863,56 @@ var init_streamingNative = __esm({
863
863
  init_nativeBridge();
864
864
  }
865
865
  });
866
+ function loadTailwindEngine() {
867
+ if (_twEngine) return _twEngine;
868
+ if (_twEngineError) throw _twEngineError;
869
+ try {
870
+ const tw = require2("tailwindcss");
871
+ if (typeof tw.compile !== "function") {
872
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
873
+ }
874
+ _twEngine = tw;
875
+ return _twEngine;
876
+ } catch (e) {
877
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
878
+ throw _twEngineError;
879
+ }
880
+ }
881
+ async function generateRawCss(classes, cssEntryContent, root) {
882
+ if (classes.length === 0) return "";
883
+ const tw = loadTailwindEngine();
884
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
885
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
886
+ const { dirname, resolve: resolve2 } = await import('path');
887
+ const projectRoot = root ?? process.cwd();
888
+ const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
889
+ const loadStylesheet = async (id, base) => {
890
+ try {
891
+ const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
892
+ const pkgPath = req.resolve(cssId);
893
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
894
+ } catch {
895
+ try {
896
+ const absPath = resolve2(base, id);
897
+ if (existsSync3(absPath)) {
898
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
899
+ }
900
+ } catch {
901
+ }
902
+ return { content: "", base };
903
+ }
904
+ };
905
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
906
+ return compiler.build(classes);
907
+ }
908
+ var require2, _twEngine, _twEngineError;
909
+ var init_tailwindEngine = __esm({
910
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
911
+ 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)));
912
+ _twEngine = null;
913
+ _twEngineError = null;
914
+ }
915
+ });
866
916
 
867
917
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
868
918
  var tailwindEngine_exports = {};
@@ -996,10 +1046,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
996
1046
  }
997
1047
  _cacheMisses++;
998
1048
  let rawCss;
999
- let usedRustCompiler = false;
1000
- const theme = getThemeConfig();
1001
- rawCss = await generateCssNative(unique, { theme });
1002
- usedRustCompiler = true;
1049
+ try {
1050
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1051
+ } catch {
1052
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1053
+ }
1003
1054
  let finalCss = rawCss;
1004
1055
  if (minify) {
1005
1056
  if (minifier === "fast") {
@@ -1010,7 +1061,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1010
1061
  }
1011
1062
  if (process.env.DEBUG?.includes("compiler")) {
1012
1063
  console.log(
1013
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1064
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1014
1065
  `Size: ${finalCss.length} bytes`
1015
1066
  );
1016
1067
  }
@@ -1039,11 +1090,12 @@ function processTailwindCssWithTargets(css, targets) {
1039
1090
  return result.css;
1040
1091
  }
1041
1092
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1042
- var init_tailwindEngine = __esm({
1093
+ var init_tailwindEngine2 = __esm({
1043
1094
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1044
1095
  init_nativeBridge();
1045
1096
  init_cssGeneratorNative();
1046
1097
  init_cssCompilationNative();
1098
+ init_tailwindEngine();
1047
1099
  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)));
1048
1100
  _cssCache = /* @__PURE__ */ new Map();
1049
1101
  _cacheHits = 0;
@@ -1060,7 +1112,7 @@ var init_compiler = __esm({
1060
1112
  init_cssCompilationNative();
1061
1113
  init_idRegistryNative();
1062
1114
  init_streamingNative();
1063
- init_tailwindEngine();
1115
+ init_tailwindEngine2();
1064
1116
  }
1065
1117
  });
1066
1118
 
@@ -2306,7 +2358,7 @@ var init_src = __esm({
2306
2358
  };
2307
2359
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2308
2360
  try {
2309
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2361
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2310
2362
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2311
2363
  return result.css;
2312
2364
  } catch {
@@ -2351,7 +2403,7 @@ var init_src = __esm({
2351
2403
  };
2352
2404
  scanProjectUsage = (dirs, cwd) => {
2353
2405
  const { batchExtractClasses: batchExtractClasses2 } = _require2("./parser");
2354
- const files = dirs.map((dir) => path10__namespace.default.resolve(cwd, dir));
2406
+ const files = dirs.map((dir) => path11__namespace.default.resolve(cwd, dir));
2355
2407
  const results = batchExtractClasses2(files) || [];
2356
2408
  const combined = {};
2357
2409
  for (const result of results) {
@@ -2368,13 +2420,13 @@ var init_src = __esm({
2368
2420
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2369
2421
  const allClasses = Object.keys(classes).sort();
2370
2422
  if (outputPath) {
2371
- fs9__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2423
+ fs10__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2372
2424
  }
2373
2425
  return allClasses;
2374
2426
  };
2375
2427
  loadSafelist = (safelistPath) => {
2376
2428
  try {
2377
- const content = fs9__namespace.default.readFileSync(safelistPath, "utf-8");
2429
+ const content = fs10__namespace.default.readFileSync(safelistPath, "utf-8");
2378
2430
  return JSON.parse(content);
2379
2431
  } catch {
2380
2432
  return [];
@@ -2388,8 +2440,8 @@ var init_src = __esm({
2388
2440
  "tailwind.config.cjs"
2389
2441
  ];
2390
2442
  for (const file of configFiles) {
2391
- const fullPath = path10__namespace.default.join(cwd, file);
2392
- if (fs9__namespace.default.existsSync(fullPath)) {
2443
+ const fullPath = path11__namespace.default.join(cwd, file);
2444
+ if (fs10__namespace.default.existsSync(fullPath)) {
2393
2445
  const mod = __require(fullPath);
2394
2446
  return mod.default || mod;
2395
2447
  }
@@ -2399,9 +2451,9 @@ var init_src = __esm({
2399
2451
  getContentPaths = (cwd = process.cwd()) => {
2400
2452
  return {
2401
2453
  content: [
2402
- path10__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2403
- path10__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2404
- path10__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2454
+ path11__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2455
+ path11__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2456
+ path11__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2405
2457
  ]
2406
2458
  };
2407
2459
  };
@@ -2821,7 +2873,7 @@ __export(internal_exports, {
2821
2873
  var init_internal = __esm({
2822
2874
  "packages/domain/compiler/src/internal.ts"() {
2823
2875
  init_src();
2824
- init_tailwindEngine();
2876
+ init_tailwindEngine2();
2825
2877
  init_compiler();
2826
2878
  init_parser();
2827
2879
  init_analyzer();
@@ -2859,17 +2911,17 @@ function getNative() {
2859
2911
  function* walkSourceFiles(dir) {
2860
2912
  let entries;
2861
2913
  try {
2862
- entries = fs9__namespace.default.readdirSync(dir, { withFileTypes: true });
2914
+ entries = fs10__namespace.default.readdirSync(dir, { withFileTypes: true });
2863
2915
  } catch {
2864
2916
  return;
2865
2917
  }
2866
2918
  for (const entry of entries) {
2867
- const fullPath = path10__namespace.default.join(dir, entry.name);
2919
+ const fullPath = path11__namespace.default.join(dir, entry.name);
2868
2920
  if (entry.isDirectory()) {
2869
2921
  if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
2870
2922
  yield* walkSourceFiles(fullPath);
2871
2923
  } else if (entry.isFile()) {
2872
- const ext = path10__namespace.default.extname(entry.name);
2924
+ const ext = path11__namespace.default.extname(entry.name);
2873
2925
  if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
2874
2926
  }
2875
2927
  }
@@ -2933,7 +2985,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2933
2985
  allConfigs.push(...configs);
2934
2986
  if (verbose) {
2935
2987
  process.stderr.write(
2936
- `[tw:static-state] ${path10__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
2988
+ `[tw:static-state] ${path11__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
2937
2989
  `
2938
2990
  );
2939
2991
  }
@@ -2944,7 +2996,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2944
2996
  if (filesScanned >= maxFiles) break;
2945
2997
  let source;
2946
2998
  try {
2947
- source = fs9__namespace.default.readFileSync(filePath, "utf-8");
2999
+ source = fs10__namespace.default.readFileSync(filePath, "utf-8");
2948
3000
  } catch {
2949
3001
  continue;
2950
3002
  }
@@ -2957,7 +3009,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2957
3009
  allConfigs.push(...configs);
2958
3010
  if (verbose) {
2959
3011
  process.stderr.write(
2960
- `[tw:static-state] ${path10__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
3012
+ `[tw:static-state] ${path11__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
2961
3013
  `
2962
3014
  );
2963
3015
  }
@@ -3051,12 +3103,12 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3051
3103
  resolvedCss: options.resolvedCss || ""
3052
3104
  // ← ensure always passed
3053
3105
  });
3054
- const twClassesDir = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "tw-classes");
3055
- fs9__namespace.default.mkdirSync(twClassesDir, { recursive: true });
3056
- const stateFilePath = path10__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3106
+ const twClassesDir = path11__namespace.default.join(path11__namespace.default.dirname(safelistPath), "tw-classes");
3107
+ fs10__namespace.default.mkdirSync(twClassesDir, { recursive: true });
3108
+ const stateFilePath = path11__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3057
3109
  if (result.rulesGenerated === 0) {
3058
3110
  try {
3059
- fs9__namespace.default.writeFileSync(
3111
+ fs10__namespace.default.writeFileSync(
3060
3112
  stateFilePath,
3061
3113
  "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
3062
3114
  "utf-8"
@@ -3066,7 +3118,7 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3066
3118
  return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
3067
3119
  }
3068
3120
  try {
3069
- fs9__namespace.default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3121
+ fs10__namespace.default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3070
3122
  return [
3071
3123
  `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
3072
3124
  ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
@@ -3096,8 +3148,8 @@ function setGlobalLogFile(filePath) {
3096
3148
  _globalLogFile = filePath;
3097
3149
  _logFileInitialized = false;
3098
3150
  try {
3099
- fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(filePath), { recursive: true });
3100
- fs9__namespace.default.writeFileSync(
3151
+ fs10__namespace.default.mkdirSync(path11__namespace.default.dirname(filePath), { recursive: true });
3152
+ fs10__namespace.default.writeFileSync(
3101
3153
  filePath,
3102
3154
  `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
3103
3155
  `,
@@ -3110,7 +3162,7 @@ function setGlobalLogFile(filePath) {
3110
3162
  function writeToFile(line) {
3111
3163
  if (!_globalLogFile || !_logFileInitialized) return;
3112
3164
  try {
3113
- fs9__namespace.default.appendFileSync(_globalLogFile, line);
3165
+ fs10__namespace.default.appendFileSync(_globalLogFile, line);
3114
3166
  } catch {
3115
3167
  }
3116
3168
  }
@@ -3175,9 +3227,9 @@ function createDebugLogger(namespace, label) {
3175
3227
  }
3176
3228
  };
3177
3229
  }
3178
- function formatIssuePath(path11) {
3179
- if (!path11 || path11.length === 0) return "(root)";
3180
- return path11.map(
3230
+ function formatIssuePath(path12) {
3231
+ if (!path12 || path12.length === 0) return "(root)";
3232
+ return path12.map(
3181
3233
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3182
3234
  ).join(".");
3183
3235
  }
@@ -3185,9 +3237,9 @@ function loadNativeBinding(options) {
3185
3237
  const { runtimeDir, candidates, isValid } = options;
3186
3238
  const loadErrors = [];
3187
3239
  for (const candidate of candidates) {
3188
- const candidatePath = path10__namespace.default.resolve(runtimeDir, candidate);
3240
+ const candidatePath = path11__namespace.default.resolve(runtimeDir, candidate);
3189
3241
  try {
3190
- if (!fs9__namespace.default.existsSync(candidatePath) && !fs9__namespace.default.existsSync(candidatePath + ".node")) {
3242
+ if (!fs10__namespace.default.existsSync(candidatePath) && !fs10__namespace.default.existsSync(candidatePath + ".node")) {
3191
3243
  continue;
3192
3244
  }
3193
3245
  const mod = requireNativeModule(candidatePath);
@@ -3219,9 +3271,9 @@ function resolveNativeBindingCandidates(options) {
3219
3271
  }
3220
3272
  }
3221
3273
  if (!includeDefaultCandidates) return candidates;
3222
- if (fs9__namespace.default.existsSync(runtimeDir)) {
3274
+ if (fs10__namespace.default.existsSync(runtimeDir)) {
3223
3275
  try {
3224
- for (const entry of fs9__namespace.default.readdirSync(runtimeDir)) {
3276
+ for (const entry of fs10__namespace.default.readdirSync(runtimeDir)) {
3225
3277
  if (entry.endsWith(".node")) candidates.push(entry);
3226
3278
  }
3227
3279
  } catch {
@@ -3230,21 +3282,21 @@ function resolveNativeBindingCandidates(options) {
3230
3282
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
3231
3283
  const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
3232
3284
  for (const bin of BINARY_NAMES) {
3233
- candidates.push(path10__namespace.default.resolve(runtimeDir, `${bin}.node`));
3234
- candidates.push(path10__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3235
- candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3236
- candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3237
- candidates.push(path10__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
3238
- candidates.push(path10__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3239
- candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3240
- candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3241
- candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3285
+ candidates.push(path11__namespace.default.resolve(runtimeDir, `${bin}.node`));
3286
+ candidates.push(path11__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3287
+ candidates.push(path11__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3288
+ candidates.push(path11__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3289
+ candidates.push(path11__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
3290
+ candidates.push(path11__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3291
+ candidates.push(path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3292
+ candidates.push(path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3293
+ candidates.push(path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3242
3294
  }
3243
3295
  return Array.from(new Set(candidates));
3244
3296
  }
3245
3297
  function resolveRuntimeDir(dir, importMetaUrl) {
3246
3298
  try {
3247
- return path10__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
3299
+ return path11__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
3248
3300
  } catch {
3249
3301
  return process.cwd();
3250
3302
  }
@@ -3289,8 +3341,8 @@ var init_src2 = __esm({
3289
3341
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3290
3342
  static fromZod(err) {
3291
3343
  const first = err.issues?.[0] ?? err.errors?.[0];
3292
- const path11 = formatIssuePath(first?.path);
3293
- const message = first ? `${path11}: ${first.message}` : "Schema validation failed";
3344
+ const path12 = formatIssuePath(first?.path);
3345
+ const message = first ? `${path12}: ${first.message}` : "Schema validation failed";
3294
3346
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3295
3347
  }
3296
3348
  static wrap(source, code, err) {
@@ -3346,7 +3398,7 @@ function getDirname() {
3346
3398
  return __dirname;
3347
3399
  }
3348
3400
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))) {
3349
- return path10__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3401
+ return path11__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3350
3402
  }
3351
3403
  return process.cwd();
3352
3404
  }
@@ -3665,12 +3717,12 @@ init_src2();
3665
3717
  // packages/domain/scanner/src/cache-native.ts
3666
3718
  init_native_bridge();
3667
3719
  function defaultCachePath(rootDir, cacheDir) {
3668
- const dir = cacheDir ? path10__namespace.default.resolve(rootDir, cacheDir) : path10__namespace.default.join(process.cwd(), ".cache", "tailwind-styled");
3669
- return path10__namespace.default.join(dir, "scanner-cache.json");
3720
+ const dir = cacheDir ? path11__namespace.default.resolve(rootDir, cacheDir) : path11__namespace.default.join(process.cwd(), ".cache", "tailwind-styled");
3721
+ return path11__namespace.default.join(dir, "scanner-cache.json");
3670
3722
  }
3671
3723
  function readCache(rootDir, cacheDir) {
3672
3724
  const cachePath = defaultCachePath(rootDir, cacheDir);
3673
- fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(cachePath), { recursive: true });
3725
+ fs10__namespace.default.mkdirSync(path11__namespace.default.dirname(cachePath), { recursive: true });
3674
3726
  const result = cacheReadNative(cachePath);
3675
3727
  if (!result) return [];
3676
3728
  return result.entries.map((e) => ({
@@ -3685,7 +3737,7 @@ function readCache(rootDir, cacheDir) {
3685
3737
  }
3686
3738
  function writeCache(rootDir, entries, cacheDir) {
3687
3739
  const cachePath = defaultCachePath(rootDir, cacheDir);
3688
- fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(cachePath), { recursive: true });
3740
+ fs10__namespace.default.mkdirSync(path11__namespace.default.dirname(cachePath), { recursive: true });
3689
3741
  const success = cacheWriteNative(cachePath, entries);
3690
3742
  if (!success) {
3691
3743
  throw new Error(
@@ -3710,12 +3762,12 @@ init_native_bridge();
3710
3762
 
3711
3763
  // packages/domain/scanner/src/schemas.ts
3712
3764
  init_src2();
3713
- var formatIssuePath2 = (path11) => path11.length > 0 ? path11.map(
3765
+ var formatIssuePath2 = (path12) => path12.length > 0 ? path12.map(
3714
3766
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3715
3767
  ).join(".") : "<root>";
3716
3768
  var formatIssues2 = (error) => error.issues.map((issue) => {
3717
- const path11 = formatIssuePath2(issue.path);
3718
- return `${path11}: ${issue.message}`;
3769
+ const path12 = formatIssuePath2(issue.path);
3770
+ return `${path12}: ${issue.message}`;
3719
3771
  }).join("; ");
3720
3772
  var parseWithSchema2 = (schema, data, label) => {
3721
3773
  const parsed = schema.safeParse(data);
@@ -3775,7 +3827,7 @@ function getRuntimeDir() {
3775
3827
  return __dirname;
3776
3828
  }
3777
3829
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))) {
3778
- return path10__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3830
+ return path11__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3779
3831
  }
3780
3832
  return process.cwd();
3781
3833
  }
@@ -3790,7 +3842,7 @@ var createNativeParserLoader = () => {
3790
3842
  const loadNativeParserBinding = () => {
3791
3843
  if (_state.binding !== void 0) return _state.binding;
3792
3844
  const runtimeDir = getRuntimeDir();
3793
- const req = module$1.createRequire(path10__namespace.default.join(runtimeDir, "noop.cjs"));
3845
+ const req = module$1.createRequire(path11__namespace.default.join(runtimeDir, "noop.cjs"));
3794
3846
  const _platform = process.platform;
3795
3847
  const _arch = process.arch;
3796
3848
  const _platformArch = `${_platform}-${_arch}`;
@@ -3798,27 +3850,27 @@ var createNativeParserLoader = () => {
3798
3850
  const candidates = [
3799
3851
  // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
3800
3852
  // cwd = repo root saat run dari root, atau package dir saat workspaces
3801
- path10__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
3802
- path10__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
3803
- path10__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3853
+ path11__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
3854
+ path11__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
3855
+ path11__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3804
3856
  // runtimeDir = dist/ → naik 1 level ke package root (npm install case)
3805
3857
  // e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
3806
- path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
3807
- path10__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
3808
- path10__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3858
+ path11__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
3859
+ path11__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
3860
+ path11__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3809
3861
  // runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
3810
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
3811
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3862
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
3863
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3812
3864
  // 3 level fallback (jika package di-nest lebih dangkal)
3813
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
3814
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3865
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
3866
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3815
3867
  // ── binaryName lama: tailwind_styled_parser (backward compat) ──
3816
- path10__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
3817
- path10__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
3818
- path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
3819
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
3820
- path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
3821
- path10__namespace.default.resolve(
3868
+ path11__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
3869
+ path11__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
3870
+ path11__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
3871
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
3872
+ path11__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
3873
+ path11__namespace.default.resolve(
3822
3874
  runtimeDir,
3823
3875
  "..",
3824
3876
  "..",
@@ -3830,7 +3882,7 @@ var createNativeParserLoader = () => {
3830
3882
  )
3831
3883
  ];
3832
3884
  for (const fullPath of candidates) {
3833
- if (!fs9__namespace.default.existsSync(fullPath)) continue;
3885
+ if (!fs10__namespace.default.existsSync(fullPath)) continue;
3834
3886
  try {
3835
3887
  const required = req(fullPath);
3836
3888
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -3871,19 +3923,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
3871
3923
  if (!currentDir) continue;
3872
3924
  const entries = (() => {
3873
3925
  try {
3874
- return fs9__namespace.default.readdirSync(currentDir, { withFileTypes: true });
3926
+ return fs10__namespace.default.readdirSync(currentDir, { withFileTypes: true });
3875
3927
  } catch {
3876
3928
  return [];
3877
3929
  }
3878
3930
  })();
3879
3931
  for (const entry of entries) {
3880
- const fullPath = path10__namespace.default.join(currentDir, entry.name);
3932
+ const fullPath = path11__namespace.default.join(currentDir, entry.name);
3881
3933
  if (entry.isDirectory()) {
3882
3934
  if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
3883
3935
  continue;
3884
3936
  }
3885
3937
  if (!entry.isFile()) continue;
3886
- if (!extensionSet.has(path10__namespace.default.extname(entry.name))) continue;
3938
+ if (!extensionSet.has(path11__namespace.default.extname(entry.name))) continue;
3887
3939
  candidates.push(fullPath);
3888
3940
  }
3889
3941
  }
@@ -3967,7 +4019,7 @@ function scanWorkspace2(rootDir, options = {}) {
3967
4019
  for (const filePath of candidates) {
3968
4020
  const stat = (() => {
3969
4021
  try {
3970
- return fs9__namespace.default.statSync(filePath);
4022
+ return fs10__namespace.default.statSync(filePath);
3971
4023
  } catch {
3972
4024
  return null;
3973
4025
  }
@@ -3993,7 +4045,7 @@ function scanWorkspace2(rootDir, options = {}) {
3993
4045
  for (const { filePath, stat, size, cached } of ranked) {
3994
4046
  const content = (() => {
3995
4047
  try {
3996
- return fs9__namespace.default.readFileSync(filePath, "utf8");
4048
+ return fs10__namespace.default.readFileSync(filePath, "utf8");
3997
4049
  } catch {
3998
4050
  return null;
3999
4051
  }
@@ -4056,6 +4108,70 @@ function scanWorkspace2(rootDir, options = {}) {
4056
4108
 
4057
4109
  // packages/presentation/next/src/withTailwindStyled.ts
4058
4110
  init_src2();
4111
+
4112
+ // packages/presentation/next/src/incrementalOrchestrator.ts
4113
+ init_src();
4114
+ var _fingerprintCache = /* @__PURE__ */ new Map();
4115
+ function getNative2() {
4116
+ try {
4117
+ return getNativeBridge();
4118
+ } catch {
4119
+ return null;
4120
+ }
4121
+ }
4122
+ function fingerprintFile(filePath) {
4123
+ try {
4124
+ const stat = fs10__namespace.default.statSync(filePath);
4125
+ const native = getNative2();
4126
+ if (native?.create_fingerprint) {
4127
+ const content = fs10__namespace.default.readFileSync(filePath, "utf-8");
4128
+ const hash = native.create_fingerprint(filePath, content);
4129
+ return { hash, mtime: stat.mtimeMs };
4130
+ }
4131
+ return { hash: `${stat.mtimeMs}-${stat.size}`, mtime: stat.mtimeMs };
4132
+ } catch {
4133
+ return null;
4134
+ }
4135
+ }
4136
+ function hasSourceChanged(sourceFiles) {
4137
+ if (_fingerprintCache.size === 0) {
4138
+ for (const f of sourceFiles) {
4139
+ const fp = fingerprintFile(f);
4140
+ if (fp) _fingerprintCache.set(f, fp);
4141
+ }
4142
+ return true;
4143
+ }
4144
+ let changed = false;
4145
+ for (const f of sourceFiles) {
4146
+ const prev = _fingerprintCache.get(f);
4147
+ const curr = fingerprintFile(f);
4148
+ if (!curr) continue;
4149
+ if (!prev || prev.hash !== curr.hash) {
4150
+ changed = true;
4151
+ _fingerprintCache.set(f, curr);
4152
+ }
4153
+ }
4154
+ for (const f of sourceFiles) {
4155
+ if (!_fingerprintCache.has(f)) {
4156
+ const fp = fingerprintFile(f);
4157
+ if (fp) {
4158
+ _fingerprintCache.set(f, fp);
4159
+ changed = true;
4160
+ }
4161
+ }
4162
+ }
4163
+ return changed;
4164
+ }
4165
+ function isIncrementalEnabled(cwd) {
4166
+ try {
4167
+ const configPath = path11__namespace.default.join(cwd, "tailwind-styled.config.json");
4168
+ if (!fs10__namespace.default.existsSync(configPath)) return false;
4169
+ const config = JSON.parse(fs10__namespace.default.readFileSync(configPath, "utf-8"));
4170
+ return config.compiler?.incremental === true;
4171
+ } catch {
4172
+ return false;
4173
+ }
4174
+ }
4059
4175
  var _fileStaticCssMap = /* @__PURE__ */ new Map();
4060
4176
  function setFileStaticCss(filepath, css) {
4061
4177
  if (css && css.trim()) {
@@ -4089,14 +4205,14 @@ var StaticCssWebpackPlugin = class _StaticCssWebpackPlugin {
4089
4205
  static PLUGIN_NAME = "TailwindStyledStaticCss";
4090
4206
  outPath;
4091
4207
  constructor(safelistPath) {
4092
- this.outPath = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "_tw-state-static.css");
4208
+ this.outPath = path11__namespace.default.join(path11__namespace.default.dirname(safelistPath), "_tw-state-static.css");
4093
4209
  }
4094
4210
  apply(compiler) {
4095
4211
  compiler.hooks.done.tap(_StaticCssWebpackPlugin.PLUGIN_NAME, () => {
4096
4212
  try {
4097
4213
  const content = buildContent(_fileStaticCssMap);
4098
- fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(this.outPath), { recursive: true });
4099
- fs9__namespace.default.writeFileSync(
4214
+ fs10__namespace.default.mkdirSync(path11__namespace.default.dirname(this.outPath), { recursive: true });
4215
+ fs10__namespace.default.writeFileSync(
4100
4216
  this.outPath,
4101
4217
  HEADER + (content || "/* no static rules yet */") + "\n",
4102
4218
  "utf-8"
@@ -4122,7 +4238,7 @@ function getDirnameFromUrl2(importMetaUrl) {
4122
4238
  const lastSlash = Math.max(importMetaUrl.lastIndexOf("/"), importMetaUrl.lastIndexOf("\\"));
4123
4239
  return lastSlash > 0 ? importMetaUrl.slice(0, lastSlash) : "";
4124
4240
  }
4125
- var 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)));
4241
+ var require4 = 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)));
4126
4242
  var resolveRuntimeDir2 = () => getDirnameFromUrl2((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
4127
4243
  var resolveLoaderPath2 = (basename) => {
4128
4244
  try {
@@ -4130,12 +4246,12 @@ var resolveLoaderPath2 = (basename) => {
4130
4246
  } catch {
4131
4247
  const runtimeDir = resolveRuntimeDir2();
4132
4248
  const candidates = [
4133
- path10__namespace.default.resolve(runtimeDir, `${basename}.mjs`),
4134
- path10__namespace.default.resolve(runtimeDir, `${basename}.js`),
4135
- path10__namespace.default.resolve(runtimeDir, `${basename}.cjs`)
4249
+ path11__namespace.default.resolve(runtimeDir, `${basename}.mjs`),
4250
+ path11__namespace.default.resolve(runtimeDir, `${basename}.js`),
4251
+ path11__namespace.default.resolve(runtimeDir, `${basename}.cjs`)
4136
4252
  ];
4137
4253
  for (const candidate of candidates) {
4138
- if (fs9__namespace.default.existsSync(candidate)) {
4254
+ if (fs10__namespace.default.existsSync(candidate)) {
4139
4255
  return candidate;
4140
4256
  }
4141
4257
  }
@@ -4146,8 +4262,8 @@ var resolveLoaderPath2 = (basename) => {
4146
4262
  };
4147
4263
  function checkNextVersion() {
4148
4264
  try {
4149
- const pkgPath = require3.resolve("next/package.json");
4150
- const { version } = require3(pkgPath);
4265
+ const pkgPath = require4.resolve("next/package.json");
4266
+ const { version } = require4(pkgPath);
4151
4267
  const major = Number.parseInt(version.split(".")[0], 10);
4152
4268
  if (major < 15) {
4153
4269
  console.warn(
@@ -4173,7 +4289,7 @@ var createLoaderOptions = (options) => {
4173
4289
  preserveImports: true
4174
4290
  };
4175
4291
  if (options.verbose !== void 0) opts.verbose = options.verbose;
4176
- opts.safelistPath = options.safelistPath ?? path10__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4292
+ opts.safelistPath = options.safelistPath ?? path11__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4177
4293
  return Object.freeze(opts);
4178
4294
  };
4179
4295
  var buildTurbopackRules = (loaderPath, loaderOptions) => {
@@ -4186,7 +4302,7 @@ var buildTurbopackRules = (loaderPath, loaderOptions) => {
4186
4302
  ])
4187
4303
  );
4188
4304
  };
4189
- var normalizeLoaderPath = (loaderPath) => path10__namespace.default.resolve(loaderPath);
4305
+ var normalizeLoaderPath = (loaderPath) => path11__namespace.default.resolve(loaderPath);
4190
4306
  var applyWebpackRule = (config, options, loaderPath) => {
4191
4307
  const loaderOptions = createLoaderOptions(options);
4192
4308
  const rules = config.module?.rules ?? [];
@@ -4203,7 +4319,7 @@ var applyWebpackRule = (config, options, loaderPath) => {
4203
4319
  enforce: "pre",
4204
4320
  use: [{ loader: loaderPath, options: loaderOptions }]
4205
4321
  };
4206
- const safelistPath = loaderOptions.safelistPath ?? path10__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4322
+ const safelistPath = loaderOptions.safelistPath ?? path11__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4207
4323
  const pluginAlreadyRegistered = (config.plugins ?? []).some(
4208
4324
  (p) => p?.constructor?.name === StaticCssWebpackPlugin.PLUGIN_NAME
4209
4325
  );
@@ -4303,17 +4419,17 @@ function withTailwindStyled(options = {}) {
4303
4419
  return fullCss.slice(startIdx, endIdx + 1);
4304
4420
  };
4305
4421
  var extractUtilitiesLayer = extractUtilitiesLayer2;
4306
- const twClassesDir = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "tw-classes");
4307
- fs9__namespace.default.mkdirSync(twClassesDir, { recursive: true });
4308
- setGlobalLogFile(path10__namespace.default.join(twClassesDir, "_tw-build.log"));
4309
- fs9__namespace.default.writeFileSync(
4310
- path10__namespace.default.join(twClassesDir, "_start.txt"),
4422
+ const twClassesDir = path11__namespace.default.join(path11__namespace.default.dirname(safelistPath), "tw-classes");
4423
+ fs10__namespace.default.mkdirSync(twClassesDir, { recursive: true });
4424
+ setGlobalLogFile(path11__namespace.default.join(twClassesDir, "_tw-build.log"));
4425
+ fs10__namespace.default.writeFileSync(
4426
+ path11__namespace.default.join(twClassesDir, "_start.txt"),
4311
4427
  String(Date.now()),
4312
4428
  "utf-8"
4313
4429
  );
4314
- const stateStaticPath = path10__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
4430
+ const stateStaticPath = path11__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
4315
4431
  try {
4316
- fs9__namespace.default.writeFileSync(
4432
+ fs10__namespace.default.writeFileSync(
4317
4433
  stateStaticPath,
4318
4434
  "/* tw-state-static.css \u2014 placeholder, akan di-generate setelah scan */\n",
4319
4435
  "utf-8"
@@ -4329,14 +4445,14 @@ function withTailwindStyled(options = {}) {
4329
4445
  "src/index.css",
4330
4446
  "styles/globals.css"
4331
4447
  ];
4332
- const safelistDir = path10__namespace.default.dirname(safelistPath);
4448
+ const safelistDir = path11__namespace.default.dirname(safelistPath);
4333
4449
  for (const candidate of CSS_CANDIDATES) {
4334
- const candidatePath = path10__namespace.default.join(process.cwd(), candidate);
4335
- if (!fs9__namespace.default.existsSync(candidatePath)) continue;
4336
- const content = fs9__namespace.default.readFileSync(candidatePath, "utf-8");
4450
+ const candidatePath = path11__namespace.default.join(process.cwd(), candidate);
4451
+ if (!fs10__namespace.default.existsSync(candidatePath)) continue;
4452
+ const content = fs10__namespace.default.readFileSync(candidatePath, "utf-8");
4337
4453
  if (content.includes("_tw-state-static.css")) break;
4338
- const globalsDir = path10__namespace.default.dirname(candidatePath);
4339
- const rel = path10__namespace.default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
4454
+ const globalsDir = path11__namespace.default.dirname(candidatePath);
4455
+ const rel = path11__namespace.default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
4340
4456
  const importLine = `@import "./${rel}";`;
4341
4457
  const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
4342
4458
  let updated;
@@ -4350,7 +4466,7 @@ function withTailwindStyled(options = {}) {
4350
4466
  updated = `${importLine}
4351
4467
  ${content}`;
4352
4468
  }
4353
- fs9__namespace.default.writeFileSync(candidatePath, updated, "utf-8");
4469
+ fs10__namespace.default.writeFileSync(candidatePath, updated, "utf-8");
4354
4470
  if (options.verbose) {
4355
4471
  console.log(
4356
4472
  `[tailwind-styled] Auto-injected "${importLine}" into ${candidate}`
@@ -4362,27 +4478,27 @@ ${content}`;
4362
4478
  }
4363
4479
  if (!process.env.TW_NATIVE_PATH) {
4364
4480
  const runtimeDir = resolveRuntimeDir2();
4365
- const nativePath = path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
4366
- if (fs9__namespace.default.existsSync(nativePath)) {
4481
+ const nativePath = path11__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
4482
+ if (fs10__namespace.default.existsSync(nativePath)) {
4367
4483
  process.env.TW_NATIVE_PATH = nativePath;
4368
4484
  }
4369
4485
  }
4370
- const srcDir = path10__namespace.default.join(process.cwd(), "src");
4371
- if (fs9__namespace.default.existsSync(srcDir)) {
4486
+ const srcDir = path11__namespace.default.join(process.cwd(), "src");
4487
+ if (fs10__namespace.default.existsSync(srcDir)) {
4372
4488
  try {
4373
4489
  const result = scanWorkspace2(srcDir);
4374
4490
  if (result.uniqueClasses.length > 0) {
4375
4491
  let atomicWriteFile2 = function(filePath, content) {
4376
4492
  const tmpPath = `${filePath}.tmp`;
4377
4493
  try {
4378
- fs9__namespace.default.writeFileSync(tmpPath, content, "utf-8");
4379
- fs9__namespace.default.renameSync(tmpPath, filePath);
4494
+ fs10__namespace.default.writeFileSync(tmpPath, content, "utf-8");
4495
+ fs10__namespace.default.renameSync(tmpPath, filePath);
4380
4496
  } catch {
4381
4497
  try {
4382
- fs9__namespace.default.unlinkSync(tmpPath);
4498
+ fs10__namespace.default.unlinkSync(tmpPath);
4383
4499
  } catch {
4384
4500
  }
4385
- fs9__namespace.default.writeFileSync(filePath, content, "utf-8");
4501
+ fs10__namespace.default.writeFileSync(filePath, content, "utf-8");
4386
4502
  }
4387
4503
  };
4388
4504
  var atomicWriteFile = atomicWriteFile2;
@@ -4445,14 +4561,14 @@ ${content}`;
4445
4561
  "styles/globals.css"
4446
4562
  ];
4447
4563
  try {
4448
- const twConfigPath = path10__namespace.default.join(process.cwd(), "tailwind-styled.config.json");
4449
- if (fs9__namespace.default.existsSync(twConfigPath)) {
4450
- const twConfig = JSON.parse(fs9__namespace.default.readFileSync(twConfigPath, "utf-8"));
4564
+ const twConfigPath = path11__namespace.default.join(process.cwd(), "tailwind-styled.config.json");
4565
+ if (fs10__namespace.default.existsSync(twConfigPath)) {
4566
+ const twConfig = JSON.parse(fs10__namespace.default.readFileSync(twConfigPath, "utf-8"));
4451
4567
  const cssEntry = twConfig.css?.entry;
4452
4568
  if (cssEntry) {
4453
- const cssEntryPath = path10__namespace.default.join(process.cwd(), cssEntry);
4454
- if (fs9__namespace.default.existsSync(cssEntryPath)) {
4455
- cssEntryContent = fs9__namespace.default.readFileSync(cssEntryPath, "utf-8");
4569
+ const cssEntryPath = path11__namespace.default.join(process.cwd(), cssEntry);
4570
+ if (fs10__namespace.default.existsSync(cssEntryPath)) {
4571
+ cssEntryContent = fs10__namespace.default.readFileSync(cssEntryPath, "utf-8");
4456
4572
  }
4457
4573
  }
4458
4574
  }
@@ -4460,9 +4576,9 @@ ${content}`;
4460
4576
  }
4461
4577
  if (!cssEntryContent) {
4462
4578
  for (const candidate of CSS_CANDIDATES) {
4463
- const candidatePath = path10__namespace.default.join(process.cwd(), candidate);
4464
- if (fs9__namespace.default.existsSync(candidatePath)) {
4465
- cssEntryContent = fs9__namespace.default.readFileSync(candidatePath, "utf-8");
4579
+ const candidatePath = path11__namespace.default.join(process.cwd(), candidate);
4580
+ if (fs10__namespace.default.existsSync(candidatePath)) {
4581
+ cssEntryContent = fs10__namespace.default.readFileSync(candidatePath, "utf-8");
4466
4582
  break;
4467
4583
  }
4468
4584
  }
@@ -4470,46 +4586,52 @@ ${content}`;
4470
4586
  if (cssEntryContent) {
4471
4587
  cssEntryContent = cssEntryContent.replace(/@source\s+["'][^"']+["']\s*;?\s*/g, "").replace(/←[^\n]*/g, "").trim();
4472
4588
  }
4473
- const initialScanPath = path10__namespace.default.join(twClassesDir, "_initial-scan.css");
4474
- if (!fs9__namespace.default.existsSync(initialScanPath)) {
4589
+ const initialScanPath = path11__namespace.default.join(twClassesDir, "_initial-scan.css");
4590
+ if (!fs10__namespace.default.existsSync(initialScanPath)) {
4475
4591
  atomicWriteFile2(
4476
4592
  initialScanPath,
4477
4593
  "/* tw-classes: initial scan \u2014 generating... */\n@layer utilities {}\n"
4478
4594
  );
4479
4595
  }
4480
- void (async () => {
4481
- try {
4482
- const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
4483
- const generateCssForClasses2 = compiler.generateCssForClasses;
4484
- const css = await generateCssForClasses2(
4485
- filteredClasses,
4486
- {},
4487
- process.cwd(),
4488
- cssEntryContent ?? void 0,
4489
- process.env.NODE_ENV === "production"
4490
- // minify hanya di production
4491
- );
4492
- if (css) {
4493
- const utilitiesOnly = extractUtilitiesLayer2(css);
4494
- atomicWriteFile2(
4495
- initialScanPath,
4496
- `/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
4596
+ const sourceFiles = result.files?.map((f) => f.file) ?? [];
4597
+ const incremental = isIncrementalEnabled(process.cwd());
4598
+ if (incremental && fs10__namespace.default.existsSync(initialScanPath) && !hasSourceChanged(sourceFiles)) {
4599
+ if (options.verbose) console.log("[tailwind-styled] Incremental: tidak ada perubahan, skip regenerate CSS");
4600
+ } else {
4601
+ void (async () => {
4602
+ try {
4603
+ const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
4604
+ const generateCssForClasses2 = compiler.generateCssForClasses;
4605
+ const css = await generateCssForClasses2(
4606
+ filteredClasses,
4607
+ {},
4608
+ process.cwd(),
4609
+ cssEntryContent ?? void 0,
4610
+ process.env.NODE_ENV === "production"
4611
+ // minify hanya di production
4612
+ );
4613
+ if (css) {
4614
+ const utilitiesOnly = extractUtilitiesLayer2(css);
4615
+ atomicWriteFile2(
4616
+ initialScanPath,
4617
+ `/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
4497
4618
  ${utilitiesOnly}`
4619
+ );
4620
+ const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
4621
+ verbose: options.verbose ?? false,
4622
+ resolvedCss: css
4623
+ });
4624
+ if (options.verbose) console.log(summary);
4625
+ }
4626
+ } catch (err) {
4627
+ throw new Error(
4628
+ `[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
4629
+ ${err.message}`,
4630
+ { cause: err }
4498
4631
  );
4499
- const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
4500
- verbose: options.verbose ?? false,
4501
- resolvedCss: css
4502
- });
4503
- if (options.verbose) console.log(summary);
4504
4632
  }
4505
- } catch (err) {
4506
- throw new Error(
4507
- `[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
4508
- ${err.message}`,
4509
- { cause: err }
4510
- );
4511
- }
4512
- })();
4633
+ })();
4634
+ }
4513
4635
  }
4514
4636
  } catch (e) {
4515
4637
  throw new Error(