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.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module';
2
- import * as fs9 from 'fs';
3
- import fs9__default from 'fs';
4
- import * as path10 from 'path';
5
- import path10__default from 'path';
2
+ import * as fs10 from 'fs';
3
+ import fs10__default from 'fs';
4
+ import * as path11 from 'path';
5
+ import path11__default from 'path';
6
6
  import 'crypto';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { z } from 'zod';
@@ -62,11 +62,11 @@ function resolvePath(...segments) {
62
62
  return segments.join("/").replace(/\/+/g, "/");
63
63
  }
64
64
  }
65
- function existsSync(path11) {
65
+ function existsSync(path12) {
66
66
  if (isBrowser) return false;
67
67
  try {
68
68
  const nodeFs = __require(NODE_FS);
69
- return nodeFs.existsSync(path11);
69
+ return nodeFs.existsSync(path12);
70
70
  } catch {
71
71
  return false;
72
72
  }
@@ -140,7 +140,7 @@ function resolveNativeBinary(runtimeDir) {
140
140
  }
141
141
  const envPath = process.env.TW_NATIVE_PATH?.trim();
142
142
  if (envPath) {
143
- if (fs9.existsSync(envPath)) {
143
+ if (fs10.existsSync(envPath)) {
144
144
  return { path: envPath, source: "env", platform, tried };
145
145
  }
146
146
  tried.push(`env:${envPath} (not found)`);
@@ -149,7 +149,7 @@ function resolveNativeBinary(runtimeDir) {
149
149
  for (const pkg of prebuiltPkgs) {
150
150
  try {
151
151
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
152
- if (fs9.existsSync(candidate)) {
152
+ if (fs10.existsSync(candidate)) {
153
153
  return { path: candidate, source: "prebuilt", platform, tried };
154
154
  }
155
155
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -160,13 +160,13 @@ function resolveNativeBinary(runtimeDir) {
160
160
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
161
161
  const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
162
162
  if (runtimeDir) {
163
- for (const depth of ["..", path10.join("..", ".."), path10.join("..", "..", "..")]) {
164
- const pkgRoot = path10.resolve(runtimeDir, depth);
163
+ for (const depth of ["..", path11.join("..", ".."), path11.join("..", "..", "..")]) {
164
+ const pkgRoot = path11.resolve(runtimeDir, depth);
165
165
  for (const bin of BINARY_NAMES_SELF) {
166
166
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
167
- const candidate = path10.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
167
+ const candidate = path11.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
168
168
  tried.push(`self-bundled:${candidate}`);
169
- if (fs9.existsSync(candidate)) {
169
+ if (fs10.existsSync(candidate)) {
170
170
  return { path: candidate, source: "prebuilt", platform, tried };
171
171
  }
172
172
  }
@@ -178,29 +178,29 @@ function resolveNativeBinary(runtimeDir) {
178
178
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
179
179
  const localCandidates = [];
180
180
  for (const bin of BINARY_NAMES) {
181
- localCandidates.push(path10.resolve(base, `${bin}.node`));
182
- localCandidates.push(path10.resolve(base, "..", `${bin}.node`));
183
- localCandidates.push(path10.resolve(base, `${bin}.${platform}.node`));
184
- localCandidates.push(path10.resolve(base, `${bin}.${napiPlatform}.node`));
181
+ localCandidates.push(path11.resolve(base, `${bin}.node`));
182
+ localCandidates.push(path11.resolve(base, "..", `${bin}.node`));
183
+ localCandidates.push(path11.resolve(base, `${bin}.${platform}.node`));
184
+ localCandidates.push(path11.resolve(base, `${bin}.${napiPlatform}.node`));
185
185
  }
186
186
  for (const startDir of [cwd, base]) {
187
187
  let dir = startDir;
188
188
  for (let i = 0; i < 6; i++) {
189
- const nativeDir = path10.resolve(dir, "native");
189
+ const nativeDir = path11.resolve(dir, "native");
190
190
  for (const bin of BINARY_NAMES) {
191
- localCandidates.push(path10.resolve(nativeDir, `${bin}.node`));
192
- localCandidates.push(path10.resolve(nativeDir, `${bin}.${platform}.node`));
193
- localCandidates.push(path10.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
194
- localCandidates.push(path10.resolve(nativeDir, "target", "release", `${bin}.node`));
191
+ localCandidates.push(path11.resolve(nativeDir, `${bin}.node`));
192
+ localCandidates.push(path11.resolve(nativeDir, `${bin}.${platform}.node`));
193
+ localCandidates.push(path11.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
194
+ localCandidates.push(path11.resolve(nativeDir, "target", "release", `${bin}.node`));
195
195
  }
196
- const parent = path10.resolve(dir, "..");
196
+ const parent = path11.resolve(dir, "..");
197
197
  if (parent === dir) break;
198
198
  dir = parent;
199
199
  }
200
200
  }
201
201
  for (const candidate of localCandidates) {
202
202
  tried.push(`local:${candidate}`);
203
- if (fs9.existsSync(candidate)) {
203
+ if (fs10.existsSync(candidate)) {
204
204
  return { path: candidate, source: "local", platform, tried };
205
205
  }
206
206
  }
@@ -227,7 +227,7 @@ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttemp
227
227
  var init_nativeBridge = __esm({
228
228
  "packages/domain/compiler/src/nativeBridge.ts"() {
229
229
  init_src2();
230
- _loadNative = (path11) => __require(path11);
230
+ _loadNative = (path12) => __require(path12);
231
231
  log = (...args) => {
232
232
  if (process.env.DEBUG?.includes("compiler:native")) {
233
233
  console.log("[compiler:native]", ...args);
@@ -841,6 +841,56 @@ var init_streamingNative = __esm({
841
841
  init_nativeBridge();
842
842
  }
843
843
  });
844
+ function loadTailwindEngine() {
845
+ if (_twEngine) return _twEngine;
846
+ if (_twEngineError) throw _twEngineError;
847
+ try {
848
+ const tw = require2("tailwindcss");
849
+ if (typeof tw.compile !== "function") {
850
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
851
+ }
852
+ _twEngine = tw;
853
+ return _twEngine;
854
+ } catch (e) {
855
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
856
+ throw _twEngineError;
857
+ }
858
+ }
859
+ async function generateRawCss(classes, cssEntryContent, root) {
860
+ if (classes.length === 0) return "";
861
+ const tw = loadTailwindEngine();
862
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
863
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
864
+ const { dirname, resolve: resolve2 } = await import('path');
865
+ const projectRoot = root ?? process.cwd();
866
+ const req = createRequire(resolve2(projectRoot, "package.json"));
867
+ const loadStylesheet = async (id, base) => {
868
+ try {
869
+ 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;
870
+ const pkgPath = req.resolve(cssId);
871
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
872
+ } catch {
873
+ try {
874
+ const absPath = resolve2(base, id);
875
+ if (existsSync3(absPath)) {
876
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
877
+ }
878
+ } catch {
879
+ }
880
+ return { content: "", base };
881
+ }
882
+ };
883
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
884
+ return compiler.build(classes);
885
+ }
886
+ var require2, _twEngine, _twEngineError;
887
+ var init_tailwindEngine = __esm({
888
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
889
+ require2 = createRequire(import.meta.url);
890
+ _twEngine = null;
891
+ _twEngineError = null;
892
+ }
893
+ });
844
894
 
845
895
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
846
896
  var tailwindEngine_exports = {};
@@ -974,10 +1024,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
974
1024
  }
975
1025
  _cacheMisses++;
976
1026
  let rawCss;
977
- let usedRustCompiler = false;
978
- const theme = getThemeConfig();
979
- rawCss = await generateCssNative(unique, { theme });
980
- usedRustCompiler = true;
1027
+ try {
1028
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1029
+ } catch {
1030
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1031
+ }
981
1032
  let finalCss = rawCss;
982
1033
  if (minify) {
983
1034
  if (minifier === "fast") {
@@ -988,7 +1039,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
988
1039
  }
989
1040
  if (process.env.DEBUG?.includes("compiler")) {
990
1041
  console.log(
991
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1042
+ `[Compiler] Generated CSS from ${unique.length} classes`,
992
1043
  `Size: ${finalCss.length} bytes`
993
1044
  );
994
1045
  }
@@ -1017,11 +1068,12 @@ function processTailwindCssWithTargets(css, targets) {
1017
1068
  return result.css;
1018
1069
  }
1019
1070
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1020
- var init_tailwindEngine = __esm({
1071
+ var init_tailwindEngine2 = __esm({
1021
1072
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1022
1073
  init_nativeBridge();
1023
1074
  init_cssGeneratorNative();
1024
1075
  init_cssCompilationNative();
1076
+ init_tailwindEngine();
1025
1077
  createRequire(import.meta.url);
1026
1078
  _cssCache = /* @__PURE__ */ new Map();
1027
1079
  _cacheHits = 0;
@@ -1038,7 +1090,7 @@ var init_compiler = __esm({
1038
1090
  init_cssCompilationNative();
1039
1091
  init_idRegistryNative();
1040
1092
  init_streamingNative();
1041
- init_tailwindEngine();
1093
+ init_tailwindEngine2();
1042
1094
  }
1043
1095
  });
1044
1096
 
@@ -2284,7 +2336,7 @@ var init_src = __esm({
2284
2336
  };
2285
2337
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2286
2338
  try {
2287
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2339
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
2288
2340
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2289
2341
  return result.css;
2290
2342
  } catch {
@@ -2329,7 +2381,7 @@ var init_src = __esm({
2329
2381
  };
2330
2382
  scanProjectUsage = (dirs, cwd) => {
2331
2383
  const { batchExtractClasses: batchExtractClasses2 } = _require2("./parser");
2332
- const files = dirs.map((dir) => path10__default.resolve(cwd, dir));
2384
+ const files = dirs.map((dir) => path11__default.resolve(cwd, dir));
2333
2385
  const results = batchExtractClasses2(files) || [];
2334
2386
  const combined = {};
2335
2387
  for (const result of results) {
@@ -2346,13 +2398,13 @@ var init_src = __esm({
2346
2398
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2347
2399
  const allClasses = Object.keys(classes).sort();
2348
2400
  if (outputPath) {
2349
- fs9__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2401
+ fs10__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2350
2402
  }
2351
2403
  return allClasses;
2352
2404
  };
2353
2405
  loadSafelist = (safelistPath) => {
2354
2406
  try {
2355
- const content = fs9__default.readFileSync(safelistPath, "utf-8");
2407
+ const content = fs10__default.readFileSync(safelistPath, "utf-8");
2356
2408
  return JSON.parse(content);
2357
2409
  } catch {
2358
2410
  return [];
@@ -2366,8 +2418,8 @@ var init_src = __esm({
2366
2418
  "tailwind.config.cjs"
2367
2419
  ];
2368
2420
  for (const file of configFiles) {
2369
- const fullPath = path10__default.join(cwd, file);
2370
- if (fs9__default.existsSync(fullPath)) {
2421
+ const fullPath = path11__default.join(cwd, file);
2422
+ if (fs10__default.existsSync(fullPath)) {
2371
2423
  const mod = __require(fullPath);
2372
2424
  return mod.default || mod;
2373
2425
  }
@@ -2377,9 +2429,9 @@ var init_src = __esm({
2377
2429
  getContentPaths = (cwd = process.cwd()) => {
2378
2430
  return {
2379
2431
  content: [
2380
- path10__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2381
- path10__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2382
- path10__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2432
+ path11__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2433
+ path11__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2434
+ path11__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2383
2435
  ]
2384
2436
  };
2385
2437
  };
@@ -2799,7 +2851,7 @@ __export(internal_exports, {
2799
2851
  var init_internal = __esm({
2800
2852
  "packages/domain/compiler/src/internal.ts"() {
2801
2853
  init_src();
2802
- init_tailwindEngine();
2854
+ init_tailwindEngine2();
2803
2855
  init_compiler();
2804
2856
  init_parser();
2805
2857
  init_analyzer();
@@ -2837,17 +2889,17 @@ function getNative() {
2837
2889
  function* walkSourceFiles(dir) {
2838
2890
  let entries;
2839
2891
  try {
2840
- entries = fs9__default.readdirSync(dir, { withFileTypes: true });
2892
+ entries = fs10__default.readdirSync(dir, { withFileTypes: true });
2841
2893
  } catch {
2842
2894
  return;
2843
2895
  }
2844
2896
  for (const entry of entries) {
2845
- const fullPath = path10__default.join(dir, entry.name);
2897
+ const fullPath = path11__default.join(dir, entry.name);
2846
2898
  if (entry.isDirectory()) {
2847
2899
  if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
2848
2900
  yield* walkSourceFiles(fullPath);
2849
2901
  } else if (entry.isFile()) {
2850
- const ext = path10__default.extname(entry.name);
2902
+ const ext = path11__default.extname(entry.name);
2851
2903
  if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
2852
2904
  }
2853
2905
  }
@@ -2911,7 +2963,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2911
2963
  allConfigs.push(...configs);
2912
2964
  if (verbose) {
2913
2965
  process.stderr.write(
2914
- `[tw:static-state] ${path10__default.relative(srcDir, filePath)}: ${configs.length} komponen
2966
+ `[tw:static-state] ${path11__default.relative(srcDir, filePath)}: ${configs.length} komponen
2915
2967
  `
2916
2968
  );
2917
2969
  }
@@ -2922,7 +2974,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2922
2974
  if (filesScanned >= maxFiles) break;
2923
2975
  let source;
2924
2976
  try {
2925
- source = fs9__default.readFileSync(filePath, "utf-8");
2977
+ source = fs10__default.readFileSync(filePath, "utf-8");
2926
2978
  } catch {
2927
2979
  continue;
2928
2980
  }
@@ -2935,7 +2987,7 @@ function extractStaticStateCss(srcDir, options = {}) {
2935
2987
  allConfigs.push(...configs);
2936
2988
  if (verbose) {
2937
2989
  process.stderr.write(
2938
- `[tw:static-state] ${path10__default.relative(srcDir, filePath)}: ${configs.length} komponen
2990
+ `[tw:static-state] ${path11__default.relative(srcDir, filePath)}: ${configs.length} komponen
2939
2991
  `
2940
2992
  );
2941
2993
  }
@@ -3029,12 +3081,12 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3029
3081
  resolvedCss: options.resolvedCss || ""
3030
3082
  // ← ensure always passed
3031
3083
  });
3032
- const twClassesDir = path10__default.join(path10__default.dirname(safelistPath), "tw-classes");
3033
- fs9__default.mkdirSync(twClassesDir, { recursive: true });
3034
- const stateFilePath = path10__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3084
+ const twClassesDir = path11__default.join(path11__default.dirname(safelistPath), "tw-classes");
3085
+ fs10__default.mkdirSync(twClassesDir, { recursive: true });
3086
+ const stateFilePath = path11__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3035
3087
  if (result.rulesGenerated === 0) {
3036
3088
  try {
3037
- fs9__default.writeFileSync(
3089
+ fs10__default.writeFileSync(
3038
3090
  stateFilePath,
3039
3091
  "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
3040
3092
  "utf-8"
@@ -3044,7 +3096,7 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3044
3096
  return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
3045
3097
  }
3046
3098
  try {
3047
- fs9__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3099
+ fs10__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3048
3100
  return [
3049
3101
  `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
3050
3102
  ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
@@ -3074,8 +3126,8 @@ function setGlobalLogFile(filePath) {
3074
3126
  _globalLogFile = filePath;
3075
3127
  _logFileInitialized = false;
3076
3128
  try {
3077
- fs9__default.mkdirSync(path10__default.dirname(filePath), { recursive: true });
3078
- fs9__default.writeFileSync(
3129
+ fs10__default.mkdirSync(path11__default.dirname(filePath), { recursive: true });
3130
+ fs10__default.writeFileSync(
3079
3131
  filePath,
3080
3132
  `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
3081
3133
  `,
@@ -3088,7 +3140,7 @@ function setGlobalLogFile(filePath) {
3088
3140
  function writeToFile(line) {
3089
3141
  if (!_globalLogFile || !_logFileInitialized) return;
3090
3142
  try {
3091
- fs9__default.appendFileSync(_globalLogFile, line);
3143
+ fs10__default.appendFileSync(_globalLogFile, line);
3092
3144
  } catch {
3093
3145
  }
3094
3146
  }
@@ -3153,9 +3205,9 @@ function createDebugLogger(namespace, label) {
3153
3205
  }
3154
3206
  };
3155
3207
  }
3156
- function formatIssuePath(path11) {
3157
- if (!path11 || path11.length === 0) return "(root)";
3158
- return path11.map(
3208
+ function formatIssuePath(path12) {
3209
+ if (!path12 || path12.length === 0) return "(root)";
3210
+ return path12.map(
3159
3211
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3160
3212
  ).join(".");
3161
3213
  }
@@ -3163,9 +3215,9 @@ function loadNativeBinding(options) {
3163
3215
  const { runtimeDir, candidates, isValid } = options;
3164
3216
  const loadErrors = [];
3165
3217
  for (const candidate of candidates) {
3166
- const candidatePath = path10__default.resolve(runtimeDir, candidate);
3218
+ const candidatePath = path11__default.resolve(runtimeDir, candidate);
3167
3219
  try {
3168
- if (!fs9__default.existsSync(candidatePath) && !fs9__default.existsSync(candidatePath + ".node")) {
3220
+ if (!fs10__default.existsSync(candidatePath) && !fs10__default.existsSync(candidatePath + ".node")) {
3169
3221
  continue;
3170
3222
  }
3171
3223
  const mod = requireNativeModule(candidatePath);
@@ -3197,9 +3249,9 @@ function resolveNativeBindingCandidates(options) {
3197
3249
  }
3198
3250
  }
3199
3251
  if (!includeDefaultCandidates) return candidates;
3200
- if (fs9__default.existsSync(runtimeDir)) {
3252
+ if (fs10__default.existsSync(runtimeDir)) {
3201
3253
  try {
3202
- for (const entry of fs9__default.readdirSync(runtimeDir)) {
3254
+ for (const entry of fs10__default.readdirSync(runtimeDir)) {
3203
3255
  if (entry.endsWith(".node")) candidates.push(entry);
3204
3256
  }
3205
3257
  } catch {
@@ -3208,21 +3260,21 @@ function resolveNativeBindingCandidates(options) {
3208
3260
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
3209
3261
  const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
3210
3262
  for (const bin of BINARY_NAMES) {
3211
- candidates.push(path10__default.resolve(runtimeDir, `${bin}.node`));
3212
- candidates.push(path10__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3213
- candidates.push(path10__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3214
- candidates.push(path10__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3215
- candidates.push(path10__default.resolve(process.cwd(), "native", `${bin}.node`));
3216
- candidates.push(path10__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3217
- candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3218
- candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3219
- candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3263
+ candidates.push(path11__default.resolve(runtimeDir, `${bin}.node`));
3264
+ candidates.push(path11__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3265
+ candidates.push(path11__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3266
+ candidates.push(path11__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3267
+ candidates.push(path11__default.resolve(process.cwd(), "native", `${bin}.node`));
3268
+ candidates.push(path11__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3269
+ candidates.push(path11__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3270
+ candidates.push(path11__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3271
+ candidates.push(path11__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3220
3272
  }
3221
3273
  return Array.from(new Set(candidates));
3222
3274
  }
3223
3275
  function resolveRuntimeDir(dir, importMetaUrl) {
3224
3276
  try {
3225
- return path10__default.dirname(fileURLToPath(importMetaUrl));
3277
+ return path11__default.dirname(fileURLToPath(importMetaUrl));
3226
3278
  } catch {
3227
3279
  return process.cwd();
3228
3280
  }
@@ -3267,8 +3319,8 @@ var init_src2 = __esm({
3267
3319
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3268
3320
  static fromZod(err) {
3269
3321
  const first = err.issues?.[0] ?? err.errors?.[0];
3270
- const path11 = formatIssuePath(first?.path);
3271
- const message = first ? `${path11}: ${first.message}` : "Schema validation failed";
3322
+ const path12 = formatIssuePath(first?.path);
3323
+ const message = first ? `${path12}: ${first.message}` : "Schema validation failed";
3272
3324
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3273
3325
  }
3274
3326
  static wrap(source, code, err) {
@@ -3324,7 +3376,7 @@ function getDirname() {
3324
3376
  return __dirname;
3325
3377
  }
3326
3378
  if (typeof import.meta !== "undefined" && import.meta.url) {
3327
- return path10__default.dirname(fileURLToPath(import.meta.url));
3379
+ return path11__default.dirname(fileURLToPath(import.meta.url));
3328
3380
  }
3329
3381
  return process.cwd();
3330
3382
  }
@@ -3643,12 +3695,12 @@ init_src2();
3643
3695
  // packages/domain/scanner/src/cache-native.ts
3644
3696
  init_native_bridge();
3645
3697
  function defaultCachePath(rootDir, cacheDir) {
3646
- const dir = cacheDir ? path10__default.resolve(rootDir, cacheDir) : path10__default.join(process.cwd(), ".cache", "tailwind-styled");
3647
- return path10__default.join(dir, "scanner-cache.json");
3698
+ const dir = cacheDir ? path11__default.resolve(rootDir, cacheDir) : path11__default.join(process.cwd(), ".cache", "tailwind-styled");
3699
+ return path11__default.join(dir, "scanner-cache.json");
3648
3700
  }
3649
3701
  function readCache(rootDir, cacheDir) {
3650
3702
  const cachePath = defaultCachePath(rootDir, cacheDir);
3651
- fs9__default.mkdirSync(path10__default.dirname(cachePath), { recursive: true });
3703
+ fs10__default.mkdirSync(path11__default.dirname(cachePath), { recursive: true });
3652
3704
  const result = cacheReadNative(cachePath);
3653
3705
  if (!result) return [];
3654
3706
  return result.entries.map((e) => ({
@@ -3663,7 +3715,7 @@ function readCache(rootDir, cacheDir) {
3663
3715
  }
3664
3716
  function writeCache(rootDir, entries, cacheDir) {
3665
3717
  const cachePath = defaultCachePath(rootDir, cacheDir);
3666
- fs9__default.mkdirSync(path10__default.dirname(cachePath), { recursive: true });
3718
+ fs10__default.mkdirSync(path11__default.dirname(cachePath), { recursive: true });
3667
3719
  const success = cacheWriteNative(cachePath, entries);
3668
3720
  if (!success) {
3669
3721
  throw new Error(
@@ -3688,12 +3740,12 @@ init_native_bridge();
3688
3740
 
3689
3741
  // packages/domain/scanner/src/schemas.ts
3690
3742
  init_src2();
3691
- var formatIssuePath2 = (path11) => path11.length > 0 ? path11.map(
3743
+ var formatIssuePath2 = (path12) => path12.length > 0 ? path12.map(
3692
3744
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3693
3745
  ).join(".") : "<root>";
3694
3746
  var formatIssues2 = (error) => error.issues.map((issue) => {
3695
- const path11 = formatIssuePath2(issue.path);
3696
- return `${path11}: ${issue.message}`;
3747
+ const path12 = formatIssuePath2(issue.path);
3748
+ return `${path12}: ${issue.message}`;
3697
3749
  }).join("; ");
3698
3750
  var parseWithSchema2 = (schema, data, label) => {
3699
3751
  const parsed = schema.safeParse(data);
@@ -3753,7 +3805,7 @@ function getRuntimeDir() {
3753
3805
  return __dirname;
3754
3806
  }
3755
3807
  if (typeof import.meta !== "undefined" && import.meta.url) {
3756
- return path10__default.dirname(fileURLToPath(import.meta.url));
3808
+ return path11__default.dirname(fileURLToPath(import.meta.url));
3757
3809
  }
3758
3810
  return process.cwd();
3759
3811
  }
@@ -3768,7 +3820,7 @@ var createNativeParserLoader = () => {
3768
3820
  const loadNativeParserBinding = () => {
3769
3821
  if (_state.binding !== void 0) return _state.binding;
3770
3822
  const runtimeDir = getRuntimeDir();
3771
- const req = createRequire(path10__default.join(runtimeDir, "noop.cjs"));
3823
+ const req = createRequire(path11__default.join(runtimeDir, "noop.cjs"));
3772
3824
  const _platform = process.platform;
3773
3825
  const _arch = process.arch;
3774
3826
  const _platformArch = `${_platform}-${_arch}`;
@@ -3776,27 +3828,27 @@ var createNativeParserLoader = () => {
3776
3828
  const candidates = [
3777
3829
  // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
3778
3830
  // cwd = repo root saat run dari root, atau package dir saat workspaces
3779
- path10__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
3780
- path10__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
3781
- path10__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3831
+ path11__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
3832
+ path11__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
3833
+ path11__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3782
3834
  // runtimeDir = dist/ → naik 1 level ke package root (npm install case)
3783
3835
  // e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
3784
- path10__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
3785
- path10__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
3786
- path10__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3836
+ path11__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
3837
+ path11__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
3838
+ path11__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3787
3839
  // runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
3788
- path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
3789
- path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3840
+ path11__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
3841
+ path11__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3790
3842
  // 3 level fallback (jika package di-nest lebih dangkal)
3791
- path10__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
3792
- path10__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3843
+ path11__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
3844
+ path11__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3793
3845
  // ── binaryName lama: tailwind_styled_parser (backward compat) ──
3794
- path10__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
3795
- path10__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
3796
- path10__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
3797
- path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
3798
- path10__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
3799
- path10__default.resolve(
3846
+ path11__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
3847
+ path11__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
3848
+ path11__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
3849
+ path11__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
3850
+ path11__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
3851
+ path11__default.resolve(
3800
3852
  runtimeDir,
3801
3853
  "..",
3802
3854
  "..",
@@ -3808,7 +3860,7 @@ var createNativeParserLoader = () => {
3808
3860
  )
3809
3861
  ];
3810
3862
  for (const fullPath of candidates) {
3811
- if (!fs9__default.existsSync(fullPath)) continue;
3863
+ if (!fs10__default.existsSync(fullPath)) continue;
3812
3864
  try {
3813
3865
  const required = req(fullPath);
3814
3866
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -3849,19 +3901,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
3849
3901
  if (!currentDir) continue;
3850
3902
  const entries = (() => {
3851
3903
  try {
3852
- return fs9__default.readdirSync(currentDir, { withFileTypes: true });
3904
+ return fs10__default.readdirSync(currentDir, { withFileTypes: true });
3853
3905
  } catch {
3854
3906
  return [];
3855
3907
  }
3856
3908
  })();
3857
3909
  for (const entry of entries) {
3858
- const fullPath = path10__default.join(currentDir, entry.name);
3910
+ const fullPath = path11__default.join(currentDir, entry.name);
3859
3911
  if (entry.isDirectory()) {
3860
3912
  if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
3861
3913
  continue;
3862
3914
  }
3863
3915
  if (!entry.isFile()) continue;
3864
- if (!extensionSet.has(path10__default.extname(entry.name))) continue;
3916
+ if (!extensionSet.has(path11__default.extname(entry.name))) continue;
3865
3917
  candidates.push(fullPath);
3866
3918
  }
3867
3919
  }
@@ -3945,7 +3997,7 @@ function scanWorkspace2(rootDir, options = {}) {
3945
3997
  for (const filePath of candidates) {
3946
3998
  const stat = (() => {
3947
3999
  try {
3948
- return fs9__default.statSync(filePath);
4000
+ return fs10__default.statSync(filePath);
3949
4001
  } catch {
3950
4002
  return null;
3951
4003
  }
@@ -3971,7 +4023,7 @@ function scanWorkspace2(rootDir, options = {}) {
3971
4023
  for (const { filePath, stat, size, cached } of ranked) {
3972
4024
  const content = (() => {
3973
4025
  try {
3974
- return fs9__default.readFileSync(filePath, "utf8");
4026
+ return fs10__default.readFileSync(filePath, "utf8");
3975
4027
  } catch {
3976
4028
  return null;
3977
4029
  }
@@ -4034,6 +4086,70 @@ function scanWorkspace2(rootDir, options = {}) {
4034
4086
 
4035
4087
  // packages/presentation/next/src/withTailwindStyled.ts
4036
4088
  init_src2();
4089
+
4090
+ // packages/presentation/next/src/incrementalOrchestrator.ts
4091
+ init_src();
4092
+ var _fingerprintCache = /* @__PURE__ */ new Map();
4093
+ function getNative2() {
4094
+ try {
4095
+ return getNativeBridge();
4096
+ } catch {
4097
+ return null;
4098
+ }
4099
+ }
4100
+ function fingerprintFile(filePath) {
4101
+ try {
4102
+ const stat = fs10__default.statSync(filePath);
4103
+ const native = getNative2();
4104
+ if (native?.create_fingerprint) {
4105
+ const content = fs10__default.readFileSync(filePath, "utf-8");
4106
+ const hash = native.create_fingerprint(filePath, content);
4107
+ return { hash, mtime: stat.mtimeMs };
4108
+ }
4109
+ return { hash: `${stat.mtimeMs}-${stat.size}`, mtime: stat.mtimeMs };
4110
+ } catch {
4111
+ return null;
4112
+ }
4113
+ }
4114
+ function hasSourceChanged(sourceFiles) {
4115
+ if (_fingerprintCache.size === 0) {
4116
+ for (const f of sourceFiles) {
4117
+ const fp = fingerprintFile(f);
4118
+ if (fp) _fingerprintCache.set(f, fp);
4119
+ }
4120
+ return true;
4121
+ }
4122
+ let changed = false;
4123
+ for (const f of sourceFiles) {
4124
+ const prev = _fingerprintCache.get(f);
4125
+ const curr = fingerprintFile(f);
4126
+ if (!curr) continue;
4127
+ if (!prev || prev.hash !== curr.hash) {
4128
+ changed = true;
4129
+ _fingerprintCache.set(f, curr);
4130
+ }
4131
+ }
4132
+ for (const f of sourceFiles) {
4133
+ if (!_fingerprintCache.has(f)) {
4134
+ const fp = fingerprintFile(f);
4135
+ if (fp) {
4136
+ _fingerprintCache.set(f, fp);
4137
+ changed = true;
4138
+ }
4139
+ }
4140
+ }
4141
+ return changed;
4142
+ }
4143
+ function isIncrementalEnabled(cwd) {
4144
+ try {
4145
+ const configPath = path11__default.join(cwd, "tailwind-styled.config.json");
4146
+ if (!fs10__default.existsSync(configPath)) return false;
4147
+ const config = JSON.parse(fs10__default.readFileSync(configPath, "utf-8"));
4148
+ return config.compiler?.incremental === true;
4149
+ } catch {
4150
+ return false;
4151
+ }
4152
+ }
4037
4153
  var _fileStaticCssMap = /* @__PURE__ */ new Map();
4038
4154
  function setFileStaticCss(filepath, css) {
4039
4155
  if (css && css.trim()) {
@@ -4067,14 +4183,14 @@ var StaticCssWebpackPlugin = class _StaticCssWebpackPlugin {
4067
4183
  static PLUGIN_NAME = "TailwindStyledStaticCss";
4068
4184
  outPath;
4069
4185
  constructor(safelistPath) {
4070
- this.outPath = path10__default.join(path10__default.dirname(safelistPath), "_tw-state-static.css");
4186
+ this.outPath = path11__default.join(path11__default.dirname(safelistPath), "_tw-state-static.css");
4071
4187
  }
4072
4188
  apply(compiler) {
4073
4189
  compiler.hooks.done.tap(_StaticCssWebpackPlugin.PLUGIN_NAME, () => {
4074
4190
  try {
4075
4191
  const content = buildContent(_fileStaticCssMap);
4076
- fs9__default.mkdirSync(path10__default.dirname(this.outPath), { recursive: true });
4077
- fs9__default.writeFileSync(
4192
+ fs10__default.mkdirSync(path11__default.dirname(this.outPath), { recursive: true });
4193
+ fs10__default.writeFileSync(
4078
4194
  this.outPath,
4079
4195
  HEADER + (content || "/* no static rules yet */") + "\n",
4080
4196
  "utf-8"
@@ -4100,7 +4216,7 @@ function getDirnameFromUrl2(importMetaUrl) {
4100
4216
  const lastSlash = Math.max(importMetaUrl.lastIndexOf("/"), importMetaUrl.lastIndexOf("\\"));
4101
4217
  return lastSlash > 0 ? importMetaUrl.slice(0, lastSlash) : "";
4102
4218
  }
4103
- var require3 = createRequire(import.meta.url);
4219
+ var require4 = createRequire(import.meta.url);
4104
4220
  var resolveRuntimeDir2 = () => getDirnameFromUrl2(import.meta.url);
4105
4221
  var resolveLoaderPath2 = (basename) => {
4106
4222
  try {
@@ -4108,12 +4224,12 @@ var resolveLoaderPath2 = (basename) => {
4108
4224
  } catch {
4109
4225
  const runtimeDir = resolveRuntimeDir2();
4110
4226
  const candidates = [
4111
- path10__default.resolve(runtimeDir, `${basename}.mjs`),
4112
- path10__default.resolve(runtimeDir, `${basename}.js`),
4113
- path10__default.resolve(runtimeDir, `${basename}.cjs`)
4227
+ path11__default.resolve(runtimeDir, `${basename}.mjs`),
4228
+ path11__default.resolve(runtimeDir, `${basename}.js`),
4229
+ path11__default.resolve(runtimeDir, `${basename}.cjs`)
4114
4230
  ];
4115
4231
  for (const candidate of candidates) {
4116
- if (fs9__default.existsSync(candidate)) {
4232
+ if (fs10__default.existsSync(candidate)) {
4117
4233
  return candidate;
4118
4234
  }
4119
4235
  }
@@ -4124,8 +4240,8 @@ var resolveLoaderPath2 = (basename) => {
4124
4240
  };
4125
4241
  function checkNextVersion() {
4126
4242
  try {
4127
- const pkgPath = require3.resolve("next/package.json");
4128
- const { version } = require3(pkgPath);
4243
+ const pkgPath = require4.resolve("next/package.json");
4244
+ const { version } = require4(pkgPath);
4129
4245
  const major = Number.parseInt(version.split(".")[0], 10);
4130
4246
  if (major < 15) {
4131
4247
  console.warn(
@@ -4151,7 +4267,7 @@ var createLoaderOptions = (options) => {
4151
4267
  preserveImports: true
4152
4268
  };
4153
4269
  if (options.verbose !== void 0) opts.verbose = options.verbose;
4154
- opts.safelistPath = options.safelistPath ?? path10__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4270
+ opts.safelistPath = options.safelistPath ?? path11__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4155
4271
  return Object.freeze(opts);
4156
4272
  };
4157
4273
  var buildTurbopackRules = (loaderPath, loaderOptions) => {
@@ -4164,7 +4280,7 @@ var buildTurbopackRules = (loaderPath, loaderOptions) => {
4164
4280
  ])
4165
4281
  );
4166
4282
  };
4167
- var normalizeLoaderPath = (loaderPath) => path10__default.resolve(loaderPath);
4283
+ var normalizeLoaderPath = (loaderPath) => path11__default.resolve(loaderPath);
4168
4284
  var applyWebpackRule = (config, options, loaderPath) => {
4169
4285
  const loaderOptions = createLoaderOptions(options);
4170
4286
  const rules = config.module?.rules ?? [];
@@ -4181,7 +4297,7 @@ var applyWebpackRule = (config, options, loaderPath) => {
4181
4297
  enforce: "pre",
4182
4298
  use: [{ loader: loaderPath, options: loaderOptions }]
4183
4299
  };
4184
- const safelistPath = loaderOptions.safelistPath ?? path10__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4300
+ const safelistPath = loaderOptions.safelistPath ?? path11__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4185
4301
  const pluginAlreadyRegistered = (config.plugins ?? []).some(
4186
4302
  (p) => p?.constructor?.name === StaticCssWebpackPlugin.PLUGIN_NAME
4187
4303
  );
@@ -4281,17 +4397,17 @@ function withTailwindStyled(options = {}) {
4281
4397
  return fullCss.slice(startIdx, endIdx + 1);
4282
4398
  };
4283
4399
  var extractUtilitiesLayer = extractUtilitiesLayer2;
4284
- const twClassesDir = path10__default.join(path10__default.dirname(safelistPath), "tw-classes");
4285
- fs9__default.mkdirSync(twClassesDir, { recursive: true });
4286
- setGlobalLogFile(path10__default.join(twClassesDir, "_tw-build.log"));
4287
- fs9__default.writeFileSync(
4288
- path10__default.join(twClassesDir, "_start.txt"),
4400
+ const twClassesDir = path11__default.join(path11__default.dirname(safelistPath), "tw-classes");
4401
+ fs10__default.mkdirSync(twClassesDir, { recursive: true });
4402
+ setGlobalLogFile(path11__default.join(twClassesDir, "_tw-build.log"));
4403
+ fs10__default.writeFileSync(
4404
+ path11__default.join(twClassesDir, "_start.txt"),
4289
4405
  String(Date.now()),
4290
4406
  "utf-8"
4291
4407
  );
4292
- const stateStaticPath = path10__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
4408
+ const stateStaticPath = path11__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
4293
4409
  try {
4294
- fs9__default.writeFileSync(
4410
+ fs10__default.writeFileSync(
4295
4411
  stateStaticPath,
4296
4412
  "/* tw-state-static.css \u2014 placeholder, akan di-generate setelah scan */\n",
4297
4413
  "utf-8"
@@ -4307,14 +4423,14 @@ function withTailwindStyled(options = {}) {
4307
4423
  "src/index.css",
4308
4424
  "styles/globals.css"
4309
4425
  ];
4310
- const safelistDir = path10__default.dirname(safelistPath);
4426
+ const safelistDir = path11__default.dirname(safelistPath);
4311
4427
  for (const candidate of CSS_CANDIDATES) {
4312
- const candidatePath = path10__default.join(process.cwd(), candidate);
4313
- if (!fs9__default.existsSync(candidatePath)) continue;
4314
- const content = fs9__default.readFileSync(candidatePath, "utf-8");
4428
+ const candidatePath = path11__default.join(process.cwd(), candidate);
4429
+ if (!fs10__default.existsSync(candidatePath)) continue;
4430
+ const content = fs10__default.readFileSync(candidatePath, "utf-8");
4315
4431
  if (content.includes("_tw-state-static.css")) break;
4316
- const globalsDir = path10__default.dirname(candidatePath);
4317
- const rel = path10__default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
4432
+ const globalsDir = path11__default.dirname(candidatePath);
4433
+ const rel = path11__default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
4318
4434
  const importLine = `@import "./${rel}";`;
4319
4435
  const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
4320
4436
  let updated;
@@ -4328,7 +4444,7 @@ function withTailwindStyled(options = {}) {
4328
4444
  updated = `${importLine}
4329
4445
  ${content}`;
4330
4446
  }
4331
- fs9__default.writeFileSync(candidatePath, updated, "utf-8");
4447
+ fs10__default.writeFileSync(candidatePath, updated, "utf-8");
4332
4448
  if (options.verbose) {
4333
4449
  console.log(
4334
4450
  `[tailwind-styled] Auto-injected "${importLine}" into ${candidate}`
@@ -4340,27 +4456,27 @@ ${content}`;
4340
4456
  }
4341
4457
  if (!process.env.TW_NATIVE_PATH) {
4342
4458
  const runtimeDir = resolveRuntimeDir2();
4343
- const nativePath = path10__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
4344
- if (fs9__default.existsSync(nativePath)) {
4459
+ const nativePath = path11__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
4460
+ if (fs10__default.existsSync(nativePath)) {
4345
4461
  process.env.TW_NATIVE_PATH = nativePath;
4346
4462
  }
4347
4463
  }
4348
- const srcDir = path10__default.join(process.cwd(), "src");
4349
- if (fs9__default.existsSync(srcDir)) {
4464
+ const srcDir = path11__default.join(process.cwd(), "src");
4465
+ if (fs10__default.existsSync(srcDir)) {
4350
4466
  try {
4351
4467
  const result = scanWorkspace2(srcDir);
4352
4468
  if (result.uniqueClasses.length > 0) {
4353
4469
  let atomicWriteFile2 = function(filePath, content) {
4354
4470
  const tmpPath = `${filePath}.tmp`;
4355
4471
  try {
4356
- fs9__default.writeFileSync(tmpPath, content, "utf-8");
4357
- fs9__default.renameSync(tmpPath, filePath);
4472
+ fs10__default.writeFileSync(tmpPath, content, "utf-8");
4473
+ fs10__default.renameSync(tmpPath, filePath);
4358
4474
  } catch {
4359
4475
  try {
4360
- fs9__default.unlinkSync(tmpPath);
4476
+ fs10__default.unlinkSync(tmpPath);
4361
4477
  } catch {
4362
4478
  }
4363
- fs9__default.writeFileSync(filePath, content, "utf-8");
4479
+ fs10__default.writeFileSync(filePath, content, "utf-8");
4364
4480
  }
4365
4481
  };
4366
4482
  var atomicWriteFile = atomicWriteFile2;
@@ -4423,14 +4539,14 @@ ${content}`;
4423
4539
  "styles/globals.css"
4424
4540
  ];
4425
4541
  try {
4426
- const twConfigPath = path10__default.join(process.cwd(), "tailwind-styled.config.json");
4427
- if (fs9__default.existsSync(twConfigPath)) {
4428
- const twConfig = JSON.parse(fs9__default.readFileSync(twConfigPath, "utf-8"));
4542
+ const twConfigPath = path11__default.join(process.cwd(), "tailwind-styled.config.json");
4543
+ if (fs10__default.existsSync(twConfigPath)) {
4544
+ const twConfig = JSON.parse(fs10__default.readFileSync(twConfigPath, "utf-8"));
4429
4545
  const cssEntry = twConfig.css?.entry;
4430
4546
  if (cssEntry) {
4431
- const cssEntryPath = path10__default.join(process.cwd(), cssEntry);
4432
- if (fs9__default.existsSync(cssEntryPath)) {
4433
- cssEntryContent = fs9__default.readFileSync(cssEntryPath, "utf-8");
4547
+ const cssEntryPath = path11__default.join(process.cwd(), cssEntry);
4548
+ if (fs10__default.existsSync(cssEntryPath)) {
4549
+ cssEntryContent = fs10__default.readFileSync(cssEntryPath, "utf-8");
4434
4550
  }
4435
4551
  }
4436
4552
  }
@@ -4438,9 +4554,9 @@ ${content}`;
4438
4554
  }
4439
4555
  if (!cssEntryContent) {
4440
4556
  for (const candidate of CSS_CANDIDATES) {
4441
- const candidatePath = path10__default.join(process.cwd(), candidate);
4442
- if (fs9__default.existsSync(candidatePath)) {
4443
- cssEntryContent = fs9__default.readFileSync(candidatePath, "utf-8");
4557
+ const candidatePath = path11__default.join(process.cwd(), candidate);
4558
+ if (fs10__default.existsSync(candidatePath)) {
4559
+ cssEntryContent = fs10__default.readFileSync(candidatePath, "utf-8");
4444
4560
  break;
4445
4561
  }
4446
4562
  }
@@ -4448,46 +4564,52 @@ ${content}`;
4448
4564
  if (cssEntryContent) {
4449
4565
  cssEntryContent = cssEntryContent.replace(/@source\s+["'][^"']+["']\s*;?\s*/g, "").replace(/←[^\n]*/g, "").trim();
4450
4566
  }
4451
- const initialScanPath = path10__default.join(twClassesDir, "_initial-scan.css");
4452
- if (!fs9__default.existsSync(initialScanPath)) {
4567
+ const initialScanPath = path11__default.join(twClassesDir, "_initial-scan.css");
4568
+ if (!fs10__default.existsSync(initialScanPath)) {
4453
4569
  atomicWriteFile2(
4454
4570
  initialScanPath,
4455
4571
  "/* tw-classes: initial scan \u2014 generating... */\n@layer utilities {}\n"
4456
4572
  );
4457
4573
  }
4458
- void (async () => {
4459
- try {
4460
- const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
4461
- const generateCssForClasses2 = compiler.generateCssForClasses;
4462
- const css = await generateCssForClasses2(
4463
- filteredClasses,
4464
- {},
4465
- process.cwd(),
4466
- cssEntryContent ?? void 0,
4467
- process.env.NODE_ENV === "production"
4468
- // minify hanya di production
4469
- );
4470
- if (css) {
4471
- const utilitiesOnly = extractUtilitiesLayer2(css);
4472
- atomicWriteFile2(
4473
- initialScanPath,
4474
- `/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
4574
+ const sourceFiles = result.files?.map((f) => f.file) ?? [];
4575
+ const incremental = isIncrementalEnabled(process.cwd());
4576
+ if (incremental && fs10__default.existsSync(initialScanPath) && !hasSourceChanged(sourceFiles)) {
4577
+ if (options.verbose) console.log("[tailwind-styled] Incremental: tidak ada perubahan, skip regenerate CSS");
4578
+ } else {
4579
+ void (async () => {
4580
+ try {
4581
+ const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
4582
+ const generateCssForClasses2 = compiler.generateCssForClasses;
4583
+ const css = await generateCssForClasses2(
4584
+ filteredClasses,
4585
+ {},
4586
+ process.cwd(),
4587
+ cssEntryContent ?? void 0,
4588
+ process.env.NODE_ENV === "production"
4589
+ // minify hanya di production
4590
+ );
4591
+ if (css) {
4592
+ const utilitiesOnly = extractUtilitiesLayer2(css);
4593
+ atomicWriteFile2(
4594
+ initialScanPath,
4595
+ `/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
4475
4596
  ${utilitiesOnly}`
4597
+ );
4598
+ const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
4599
+ verbose: options.verbose ?? false,
4600
+ resolvedCss: css
4601
+ });
4602
+ if (options.verbose) console.log(summary);
4603
+ }
4604
+ } catch (err) {
4605
+ throw new Error(
4606
+ `[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
4607
+ ${err.message}`,
4608
+ { cause: err }
4476
4609
  );
4477
- const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
4478
- verbose: options.verbose ?? false,
4479
- resolvedCss: css
4480
- });
4481
- if (options.verbose) console.log(summary);
4482
4610
  }
4483
- } catch (err) {
4484
- throw new Error(
4485
- `[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
4486
- ${err.message}`,
4487
- { cause: err }
4488
- );
4489
- }
4490
- })();
4611
+ })();
4612
+ }
4491
4613
  }
4492
4614
  } catch (e) {
4493
4615
  throw new Error(