tailwind-styled-v4 5.1.22 → 5.1.24

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 (61) hide show
  1. package/README.md +216 -0
  2. package/dist/atomic.js +34 -4
  3. package/dist/atomic.js.map +1 -1
  4. package/dist/atomic.mjs +31 -2
  5. package/dist/atomic.mjs.map +1 -1
  6. package/dist/cli.js +132 -97
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +129 -95
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/compiler.d.mts +195 -1
  11. package/dist/compiler.d.ts +195 -1
  12. package/dist/compiler.js +356 -12
  13. package/dist/compiler.js.map +1 -1
  14. package/dist/compiler.mjs +340 -10
  15. package/dist/compiler.mjs.map +1 -1
  16. package/dist/engine.js +194 -164
  17. package/dist/engine.js.map +1 -1
  18. package/dist/engine.mjs +184 -155
  19. package/dist/engine.mjs.map +1 -1
  20. package/dist/index.browser.mjs +136 -14
  21. package/dist/index.browser.mjs.map +1 -1
  22. package/dist/index.d.mts +45 -4
  23. package/dist/index.d.ts +45 -4
  24. package/dist/index.js +166 -9
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +177 -21
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/next.js +489 -158
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +483 -153
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/runtime-css.js +1 -1
  33. package/dist/runtime-css.js.map +1 -1
  34. package/dist/runtime-css.mjs +1 -1
  35. package/dist/runtime-css.mjs.map +1 -1
  36. package/dist/runtime.js +17 -0
  37. package/dist/runtime.js.map +1 -1
  38. package/dist/runtime.mjs +23 -0
  39. package/dist/runtime.mjs.map +1 -1
  40. package/dist/shared.js +91 -61
  41. package/dist/shared.js.map +1 -1
  42. package/dist/shared.mjs +85 -56
  43. package/dist/shared.mjs.map +1 -1
  44. package/dist/turbopackLoader.js +79 -49
  45. package/dist/turbopackLoader.js.map +1 -1
  46. package/dist/turbopackLoader.mjs +76 -47
  47. package/dist/turbopackLoader.mjs.map +1 -1
  48. package/dist/tw.js +132 -97
  49. package/dist/tw.js.map +1 -1
  50. package/dist/tw.mjs +129 -95
  51. package/dist/tw.mjs.map +1 -1
  52. package/dist/vite.js +157 -127
  53. package/dist/vite.js.map +1 -1
  54. package/dist/vite.mjs +150 -121
  55. package/dist/vite.mjs.map +1 -1
  56. package/dist/webpackLoader.js +39 -9
  57. package/dist/webpackLoader.js.map +1 -1
  58. package/dist/webpackLoader.mjs +36 -7
  59. package/dist/webpackLoader.mjs.map +1 -1
  60. package/package.json +1 -1
  61. package/CHANGELOG.md +0 -182
package/dist/shared.mjs CHANGED
@@ -230,9 +230,9 @@ function parseNative(schema, data, context) {
230
230
  const result = schema.safeParse(data);
231
231
  if (!result.success) {
232
232
  const first = result.error.issues[0];
233
- const path8 = first?.path?.join(".") ?? "(root)";
233
+ const path9 = first?.path?.join(".") ?? "(root)";
234
234
  throw new Error(
235
- `[${context}] Native binding returned unexpected data: ${path8}: ${first?.message ?? "validation failed"}`
235
+ `[${context}] Native binding returned unexpected data: ${path9}: ${first?.message ?? "validation failed"}`
236
236
  );
237
237
  }
238
238
  return result.data;
@@ -666,11 +666,11 @@ function resolvePath(...segments) {
666
666
  return segments.join("/").replace(/\/+/g, "/");
667
667
  }
668
668
  }
669
- function existsSync(path8) {
669
+ function existsSync(path9) {
670
670
  if (isBrowser2) return false;
671
671
  try {
672
672
  const nodeFs = __require(NODE_FS);
673
- return nodeFs.existsSync(path8);
673
+ return nodeFs.existsSync(path9);
674
674
  } catch {
675
675
  return false;
676
676
  }
@@ -1024,9 +1024,9 @@ var init_native_resolution = __esm({
1024
1024
  // packages/domain/shared/src/observability.ts
1025
1025
  function createObservabilityClient(opts = {}) {
1026
1026
  const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
1027
- async function fetchJson(path8) {
1027
+ async function fetchJson(path9) {
1028
1028
  try {
1029
- const res = await fetch(`${baseUrl}${path8}`, {
1029
+ const res = await fetch(`${baseUrl}${path9}`, {
1030
1030
  signal: AbortSignal.timeout(timeoutMs)
1031
1031
  });
1032
1032
  if (!res.ok) return null;
@@ -1067,7 +1067,7 @@ var init_nativeBridge = __esm({
1067
1067
  "use strict";
1068
1068
  init_esm_shims();
1069
1069
  init_src2();
1070
- _loadNative = (path8) => __require(path8);
1070
+ _loadNative = (path9) => __require(path9);
1071
1071
  log = (...args) => {
1072
1072
  if (process.env.DEBUG?.includes("compiler:native")) {
1073
1073
  console.log("[compiler:native]", ...args);
@@ -2901,9 +2901,35 @@ var init_routeGraph = __esm({
2901
2901
  }
2902
2902
  });
2903
2903
 
2904
- // packages/domain/compiler/src/index.ts
2904
+ // packages/domain/compiler/src/semanticComponentAnalyzer.ts
2905
+ var init_semanticComponentAnalyzer = __esm({
2906
+ "packages/domain/compiler/src/semanticComponentAnalyzer.ts"() {
2907
+ "use strict";
2908
+ init_esm_shims();
2909
+ }
2910
+ });
2911
+
2912
+ // packages/domain/compiler/src/typeGeneratorFromMetadata.ts
2913
+ var init_typeGeneratorFromMetadata = __esm({
2914
+ "packages/domain/compiler/src/typeGeneratorFromMetadata.ts"() {
2915
+ "use strict";
2916
+ init_esm_shims();
2917
+ }
2918
+ });
2919
+
2920
+ // packages/domain/compiler/src/typeGenerationPlugin.ts
2905
2921
  import fs3 from "fs";
2906
2922
  import path4 from "path";
2923
+ var init_typeGenerationPlugin = __esm({
2924
+ "packages/domain/compiler/src/typeGenerationPlugin.ts"() {
2925
+ "use strict";
2926
+ init_esm_shims();
2927
+ }
2928
+ });
2929
+
2930
+ // packages/domain/compiler/src/index.ts
2931
+ import fs4 from "fs";
2932
+ import path5 from "path";
2907
2933
  import { createRequire as createRequire4 } from "module";
2908
2934
  function _layoutClassesToCss(classes) {
2909
2935
  const native = getNativeBridge();
@@ -2952,6 +2978,9 @@ var init_src = __esm({
2952
2978
  init_redis();
2953
2979
  init_watch();
2954
2980
  init_routeGraph();
2981
+ init_semanticComponentAnalyzer();
2982
+ init_typeGeneratorFromMetadata();
2983
+ init_typeGenerationPlugin();
2955
2984
  _require2 = createRequire4(
2956
2985
  typeof __require !== "undefined" ? typeof __filename !== "undefined" ? `file://${__filename}` : "file://unknown" : import.meta.url
2957
2986
  );
@@ -3046,7 +3075,7 @@ var init_src = __esm({
3046
3075
  };
3047
3076
  scanProjectUsage = (dirs, cwd) => {
3048
3077
  const { batchExtractClasses: batchExtractClasses2 } = _require2("./parser");
3049
- const files = dirs.map((dir) => path4.resolve(cwd, dir));
3078
+ const files = dirs.map((dir) => path5.resolve(cwd, dir));
3050
3079
  const results = batchExtractClasses2(files) || [];
3051
3080
  const combined = {};
3052
3081
  for (const result of results) {
@@ -3063,13 +3092,13 @@ var init_src = __esm({
3063
3092
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
3064
3093
  const allClasses = Object.keys(classes).sort();
3065
3094
  if (outputPath) {
3066
- fs3.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
3095
+ fs4.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
3067
3096
  }
3068
3097
  return allClasses;
3069
3098
  };
3070
3099
  loadSafelist = (safelistPath) => {
3071
3100
  try {
3072
- const content = fs3.readFileSync(safelistPath, "utf-8");
3101
+ const content = fs4.readFileSync(safelistPath, "utf-8");
3073
3102
  return JSON.parse(content);
3074
3103
  } catch {
3075
3104
  return [];
@@ -3083,8 +3112,8 @@ var init_src = __esm({
3083
3112
  "tailwind.config.cjs"
3084
3113
  ];
3085
3114
  for (const file of configFiles) {
3086
- const fullPath = path4.join(cwd, file);
3087
- if (fs3.existsSync(fullPath)) {
3115
+ const fullPath = path5.join(cwd, file);
3116
+ if (fs4.existsSync(fullPath)) {
3088
3117
  const mod = __require(fullPath);
3089
3118
  return mod.default || mod;
3090
3119
  }
@@ -3094,9 +3123,9 @@ var init_src = __esm({
3094
3123
  getContentPaths = (cwd = process.cwd()) => {
3095
3124
  return {
3096
3125
  content: [
3097
- path4.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
3098
- path4.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
3099
- path4.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
3126
+ path5.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
3127
+ path5.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
3128
+ path5.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
3100
3129
  ]
3101
3130
  };
3102
3131
  };
@@ -3554,8 +3583,8 @@ var init_internal = __esm({
3554
3583
  });
3555
3584
 
3556
3585
  // packages/domain/shared/src/staticStateExtractor.ts
3557
- import fs4 from "fs";
3558
- import path5 from "path";
3586
+ import fs5 from "fs";
3587
+ import path6 from "path";
3559
3588
  function getNative() {
3560
3589
  if (_native) return _native;
3561
3590
  try {
@@ -3585,17 +3614,17 @@ function getNative() {
3585
3614
  function* walkSourceFiles(dir) {
3586
3615
  let entries;
3587
3616
  try {
3588
- entries = fs4.readdirSync(dir, { withFileTypes: true });
3617
+ entries = fs5.readdirSync(dir, { withFileTypes: true });
3589
3618
  } catch {
3590
3619
  return;
3591
3620
  }
3592
3621
  for (const entry of entries) {
3593
- const fullPath = path5.join(dir, entry.name);
3622
+ const fullPath = path6.join(dir, entry.name);
3594
3623
  if (entry.isDirectory()) {
3595
3624
  if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
3596
3625
  yield* walkSourceFiles(fullPath);
3597
3626
  } else if (entry.isFile()) {
3598
- const ext = path5.extname(entry.name);
3627
+ const ext = path6.extname(entry.name);
3599
3628
  if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
3600
3629
  }
3601
3630
  }
@@ -3659,7 +3688,7 @@ function extractStaticStateCss(srcDir, options = {}) {
3659
3688
  allConfigs.push(...configs);
3660
3689
  if (verbose) {
3661
3690
  process.stderr.write(
3662
- `[tw:static-state] ${path5.relative(srcDir, filePath)}: ${configs.length} komponen
3691
+ `[tw:static-state] ${path6.relative(srcDir, filePath)}: ${configs.length} komponen
3663
3692
  `
3664
3693
  );
3665
3694
  }
@@ -3670,7 +3699,7 @@ function extractStaticStateCss(srcDir, options = {}) {
3670
3699
  if (filesScanned >= maxFiles) break;
3671
3700
  let source;
3672
3701
  try {
3673
- source = fs4.readFileSync(filePath, "utf-8");
3702
+ source = fs5.readFileSync(filePath, "utf-8");
3674
3703
  } catch {
3675
3704
  continue;
3676
3705
  }
@@ -3683,7 +3712,7 @@ function extractStaticStateCss(srcDir, options = {}) {
3683
3712
  allConfigs.push(...configs);
3684
3713
  if (verbose) {
3685
3714
  process.stderr.write(
3686
- `[tw:static-state] ${path5.relative(srcDir, filePath)}: ${configs.length} komponen
3715
+ `[tw:static-state] ${path6.relative(srcDir, filePath)}: ${configs.length} komponen
3687
3716
  `
3688
3717
  );
3689
3718
  }
@@ -3777,12 +3806,12 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3777
3806
  resolvedCss: options.resolvedCss || ""
3778
3807
  // ← ensure always passed
3779
3808
  });
3780
- const twClassesDir = path5.join(path5.dirname(safelistPath), "tw-classes");
3781
- fs4.mkdirSync(twClassesDir, { recursive: true });
3782
- const stateFilePath = path5.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3809
+ const twClassesDir = path6.join(path6.dirname(safelistPath), "tw-classes");
3810
+ fs5.mkdirSync(twClassesDir, { recursive: true });
3811
+ const stateFilePath = path6.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3783
3812
  if (result.rulesGenerated === 0) {
3784
3813
  try {
3785
- fs4.writeFileSync(
3814
+ fs5.writeFileSync(
3786
3815
  stateFilePath,
3787
3816
  "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
3788
3817
  "utf-8"
@@ -3792,7 +3821,7 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3792
3821
  return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
3793
3822
  }
3794
3823
  try {
3795
- fs4.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3824
+ fs5.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3796
3825
  return [
3797
3826
  `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
3798
3827
  ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
@@ -3817,8 +3846,8 @@ var init_staticStateExtractor = __esm({
3817
3846
  });
3818
3847
 
3819
3848
  // packages/domain/shared/src/logger.ts
3820
- import fs5 from "fs";
3821
- import path6 from "path";
3849
+ import fs6 from "fs";
3850
+ import path7 from "path";
3822
3851
  function getEnvLevel() {
3823
3852
  const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
3824
3853
  if (env && env in LEVELS) return env;
@@ -3828,8 +3857,8 @@ function setGlobalLogFile(filePath) {
3828
3857
  _globalLogFile = filePath;
3829
3858
  _logFileInitialized = false;
3830
3859
  try {
3831
- fs5.mkdirSync(path6.dirname(filePath), { recursive: true });
3832
- fs5.writeFileSync(
3860
+ fs6.mkdirSync(path7.dirname(filePath), { recursive: true });
3861
+ fs6.writeFileSync(
3833
3862
  filePath,
3834
3863
  `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
3835
3864
  `,
@@ -3842,7 +3871,7 @@ function setGlobalLogFile(filePath) {
3842
3871
  function writeToFile(line) {
3843
3872
  if (!_globalLogFile || !_logFileInitialized) return;
3844
3873
  try {
3845
- fs5.appendFileSync(_globalLogFile, line);
3874
+ fs6.appendFileSync(_globalLogFile, line);
3846
3875
  } catch {
3847
3876
  }
3848
3877
  }
@@ -3883,8 +3912,8 @@ var init_logger = __esm({
3883
3912
 
3884
3913
  // packages/domain/shared/src/index.ts
3885
3914
  import { createHash } from "crypto";
3886
- import fs6 from "fs";
3887
- import path7 from "path";
3915
+ import fs7 from "fs";
3916
+ import path8 from "path";
3888
3917
  import { fileURLToPath as fileURLToPath2 } from "url";
3889
3918
  import { createRequire as createRequire5 } from "module";
3890
3919
  function createLogger2(namespace) {
@@ -3916,9 +3945,9 @@ function createDebugLogger(namespace, label) {
3916
3945
  }
3917
3946
  };
3918
3947
  }
3919
- function formatIssuePath(path8) {
3920
- if (!path8 || path8.length === 0) return "(root)";
3921
- return path8.map(
3948
+ function formatIssuePath(path9) {
3949
+ if (!path9 || path9.length === 0) return "(root)";
3950
+ return path9.map(
3922
3951
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3923
3952
  ).join(".");
3924
3953
  }
@@ -3932,9 +3961,9 @@ function loadNativeBinding(options) {
3932
3961
  const { runtimeDir, candidates, isValid } = options;
3933
3962
  const loadErrors = [];
3934
3963
  for (const candidate of candidates) {
3935
- const candidatePath = path7.resolve(runtimeDir, candidate);
3964
+ const candidatePath = path8.resolve(runtimeDir, candidate);
3936
3965
  try {
3937
- if (!fs6.existsSync(candidatePath) && !fs6.existsSync(candidatePath + ".node")) {
3966
+ if (!fs7.existsSync(candidatePath) && !fs7.existsSync(candidatePath + ".node")) {
3938
3967
  continue;
3939
3968
  }
3940
3969
  const mod = requireNativeModule(candidatePath);
@@ -3966,9 +3995,9 @@ function resolveNativeBindingCandidates(options) {
3966
3995
  }
3967
3996
  }
3968
3997
  if (!includeDefaultCandidates) return candidates;
3969
- if (fs6.existsSync(runtimeDir)) {
3998
+ if (fs7.existsSync(runtimeDir)) {
3970
3999
  try {
3971
- for (const entry of fs6.readdirSync(runtimeDir)) {
4000
+ for (const entry of fs7.readdirSync(runtimeDir)) {
3972
4001
  if (entry.endsWith(".node")) candidates.push(entry);
3973
4002
  }
3974
4003
  } catch {
@@ -3977,22 +4006,22 @@ function resolveNativeBindingCandidates(options) {
3977
4006
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
3978
4007
  const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
3979
4008
  for (const bin of BINARY_NAMES) {
3980
- candidates.push(path7.resolve(runtimeDir, `${bin}.node`));
3981
- candidates.push(path7.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3982
- candidates.push(path7.resolve(runtimeDir, "..", "native", `${bin}.node`));
3983
- candidates.push(path7.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3984
- candidates.push(path7.resolve(process.cwd(), "native", `${bin}.node`));
3985
- candidates.push(path7.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3986
- candidates.push(path7.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3987
- candidates.push(path7.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3988
- candidates.push(path7.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
4009
+ candidates.push(path8.resolve(runtimeDir, `${bin}.node`));
4010
+ candidates.push(path8.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
4011
+ candidates.push(path8.resolve(runtimeDir, "..", "native", `${bin}.node`));
4012
+ candidates.push(path8.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
4013
+ candidates.push(path8.resolve(process.cwd(), "native", `${bin}.node`));
4014
+ candidates.push(path8.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
4015
+ candidates.push(path8.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
4016
+ candidates.push(path8.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
4017
+ candidates.push(path8.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3989
4018
  }
3990
4019
  return Array.from(new Set(candidates));
3991
4020
  }
3992
4021
  function resolveRuntimeDir(dir, importMetaUrl) {
3993
- if (dir) return path7.resolve(dir);
4022
+ if (dir) return path8.resolve(dir);
3994
4023
  try {
3995
- return path7.dirname(fileURLToPath2(importMetaUrl));
4024
+ return path8.dirname(fileURLToPath2(importMetaUrl));
3996
4025
  } catch {
3997
4026
  return process.cwd();
3998
4027
  }
@@ -4057,8 +4086,8 @@ var init_src2 = __esm({
4057
4086
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
4058
4087
  static fromZod(err) {
4059
4088
  const first = err.issues?.[0] ?? err.errors?.[0];
4060
- const path8 = formatIssuePath(first?.path);
4061
- const message = first ? `${path8}: ${first.message}` : "Schema validation failed";
4089
+ const path9 = formatIssuePath(first?.path);
4090
+ const message = first ? `${path9}: ${first.message}` : "Schema validation failed";
4062
4091
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
4063
4092
  }
4064
4093
  static wrap(source, code, err) {