tailwind-styled-v4 5.0.16 → 5.0.18

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 (62) hide show
  1. package/dist/atomic.js +14 -14
  2. package/dist/atomic.js.map +1 -1
  3. package/dist/atomic.mjs +14 -14
  4. package/dist/atomic.mjs.map +1 -1
  5. package/dist/cli.js +14 -14
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cli.mjs +14 -14
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/compiler.js +14 -14
  10. package/dist/compiler.js.map +1 -1
  11. package/dist/compiler.mjs +14 -14
  12. package/dist/compiler.mjs.map +1 -1
  13. package/dist/engine.js +14 -14
  14. package/dist/engine.js.map +1 -1
  15. package/dist/engine.mjs +14 -14
  16. package/dist/engine.mjs.map +1 -1
  17. package/dist/index.browser.mjs +5 -66
  18. package/dist/index.browser.mjs.map +1 -1
  19. package/dist/index.js +64 -105
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +64 -105
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/next.js +14 -14
  24. package/dist/next.js.map +1 -1
  25. package/dist/next.mjs +14 -14
  26. package/dist/next.mjs.map +1 -1
  27. package/dist/plugin.d.mts +3 -3
  28. package/dist/plugin.d.ts +3 -3
  29. package/dist/plugin.js.map +1 -1
  30. package/dist/plugin.mjs.map +1 -1
  31. package/dist/shared.d.mts +2 -3
  32. package/dist/shared.d.ts +2 -3
  33. package/dist/shared.js +14 -14
  34. package/dist/shared.js.map +1 -1
  35. package/dist/shared.mjs +14 -14
  36. package/dist/shared.mjs.map +1 -1
  37. package/dist/svelte.js +24 -42
  38. package/dist/svelte.js.map +1 -1
  39. package/dist/svelte.mjs +24 -42
  40. package/dist/svelte.mjs.map +1 -1
  41. package/dist/turbopackLoader.js +14 -14
  42. package/dist/turbopackLoader.js.map +1 -1
  43. package/dist/turbopackLoader.mjs +14 -14
  44. package/dist/turbopackLoader.mjs.map +1 -1
  45. package/dist/tw.js +14 -14
  46. package/dist/tw.js.map +1 -1
  47. package/dist/tw.mjs +14 -14
  48. package/dist/tw.mjs.map +1 -1
  49. package/dist/vite.js +14 -14
  50. package/dist/vite.js.map +1 -1
  51. package/dist/vite.mjs +14 -14
  52. package/dist/vite.mjs.map +1 -1
  53. package/dist/vue.js +24 -42
  54. package/dist/vue.js.map +1 -1
  55. package/dist/vue.mjs +24 -42
  56. package/dist/vue.mjs.map +1 -1
  57. package/dist/webpackLoader.js +14 -14
  58. package/dist/webpackLoader.js.map +1 -1
  59. package/dist/webpackLoader.mjs +14 -14
  60. package/dist/webpackLoader.mjs.map +1 -1
  61. package/native/tailwind-styled-native.node +0 -0
  62. package/package.json +1 -4
package/dist/index.js CHANGED
@@ -885,15 +885,27 @@ function resolveNativeBinary(runtimeDir) {
885
885
  }
886
886
  tried.push(`env:${envPath} (not found)`);
887
887
  }
888
+ const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
889
+ for (const pkg of prebuiltPkgs) {
890
+ try {
891
+ const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
892
+ if (fs3__namespace.existsSync(candidate)) {
893
+ return { path: candidate, source: "prebuilt", platform, tried };
894
+ }
895
+ tried.push(`prebuilt:${pkg} (resolved but missing)`);
896
+ } catch {
897
+ tried.push(`prebuilt:${pkg} (not installed)`);
898
+ }
899
+ }
888
900
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
889
- const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser", "index"];
901
+ const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
890
902
  if (runtimeDir) {
891
903
  for (const depth of ["..", path9__namespace.join("..", ".."), path9__namespace.join("..", "..", "..")]) {
892
904
  const pkgRoot = path9__namespace.resolve(runtimeDir, depth);
893
905
  for (const bin of BINARY_NAMES_SELF) {
894
906
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
895
907
  const candidate = path9__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
896
- tried.push(`native:${candidate}`);
908
+ tried.push(`self-bundled:${candidate}`);
897
909
  if (fs3__namespace.existsSync(candidate)) {
898
910
  return { path: candidate, source: "prebuilt", platform, tried };
899
911
  }
@@ -901,18 +913,6 @@ function resolveNativeBinary(runtimeDir) {
901
913
  }
902
914
  }
903
915
  }
904
- const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
905
- for (const pkg of prebuiltPkgs) {
906
- try {
907
- const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
908
- if (fs3__namespace.existsSync(candidate)) {
909
- return { path: candidate, source: "prebuilt", platform, tried };
910
- }
911
- tried.push(`prebuilt:${pkg} (resolved but missing)`);
912
- } catch {
913
- tried.push(`prebuilt:${pkg} (not installed)`);
914
- }
915
- }
916
916
  const cwd = process.cwd();
917
917
  const base = runtimeDir ?? cwd;
918
918
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
@@ -4796,31 +4796,24 @@ var init_native_bridge2 = __esm({
4796
4796
 
4797
4797
  // packages/domain/core/src/native.ts
4798
4798
  init_src2();
4799
- var isBrowser4 = typeof window !== "undefined" && typeof document !== "undefined";
4800
- var NATIVE_UNAVAILABLE_MESSAGE2 = "[tailwind-styled/core] Native binding is required but not available.\nMake sure:\n 1. .node files were copied to dist/ during build\n 2. You installed the correct native package for your platform\n 3. npm run build:rust was executed successfully";
4799
+ var isBrowser4 = typeof window !== "undefined" || typeof document !== "undefined";
4800
+ var NATIVE_UNAVAILABLE_MESSAGE2 = "[tailwind-styled/core] Native binding is required but not available.\nPlease ensure you have run: npm run build:rust";
4801
4801
  var _nodeRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
4802
4802
  var _loadNative2 = (path15) => _nodeRequire(path15);
4803
4803
  var nativeBinding = null;
4804
4804
  var bindingLoadAttempted = false;
4805
- var bindingError = null;
4806
4805
  var getBinding = () => {
4807
- if (nativeBinding) return nativeBinding;
4808
- if (bindingError) {
4809
- throw bindingError;
4806
+ if (isBrowser4) {
4807
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE2 + "\n\nNative bindings are not available in browser. Use the compiled CSS output instead.");
4810
4808
  }
4809
+ if (nativeBinding) return nativeBinding;
4811
4810
  if (bindingLoadAttempted) {
4812
4811
  throw new Error(NATIVE_UNAVAILABLE_MESSAGE2);
4813
4812
  }
4814
4813
  bindingLoadAttempted = true;
4815
4814
  try {
4816
- if (isBrowser4) {
4817
- bindingError = new Error(
4818
- "[tailwind-styled/core] Cannot use template literals (tw`...`) in browser environment.\n\nTemplate literal parsing requires native Rust bindings compiled to WebAssembly,\nwhich is not currently supported.\n\nSolutions:\n1. Use object config only: tw.button({ base: '...', variants: {...} })\n2. Pre-compile components on the server (Next.js Server Components)\n3. Use @tailwind-styled browser-safe packages if available\n\nFor more info: https://github.com/Dictionar32/css-in-rust/discussions"
4819
- );
4820
- throw bindingError;
4821
- }
4822
- const runtimeDir = path9.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))));
4823
- const result = resolveNativeBinary(runtimeDir);
4815
+ const runtimeDir = isBrowser4 ? "" : path9.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))));
4816
+ const result = isBrowser4 ? { path: null, source: "not-found", platform: "browser", tried: [] } : resolveNativeBinary(runtimeDir);
4824
4817
  if (result.path && result.path.endsWith(".node")) {
4825
4818
  const mod = _loadNative2(result.path);
4826
4819
  if (mod?.batchSplitClasses) {
@@ -4828,22 +4821,11 @@ var getBinding = () => {
4828
4821
  return nativeBinding;
4829
4822
  }
4830
4823
  }
4831
- bindingError = new Error(
4832
- `${NATIVE_UNAVAILABLE_MESSAGE2}
4833
-
4834
- Resolution Attempts:
4835
- ${result.tried.map((t2) => ` - ${t2}`).join("\n")}
4824
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE2}
4836
4825
 
4837
- Quick fixes:
4838
- 1. npm run build:rust # Build native binaries
4839
- 2. npm install # Reinstall with pre-built binaries
4840
- 3. TW_NATIVE_PATH=/path/to/index.node npm run dev # Specify binary path`
4841
- );
4842
- throw bindingError;
4826
+ Tried: ${result.tried.join("\n")}`);
4843
4827
  } catch (err) {
4844
- const error = err instanceof Error ? err : new Error(String(err));
4845
- bindingError = error;
4846
- throw error;
4828
+ throw err instanceof Error ? err : new Error(String(err));
4847
4829
  }
4848
4830
  };
4849
4831
  var getNativeBinding = getBinding;
@@ -5510,70 +5492,49 @@ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
5510
5492
  );
5511
5493
  return table[key];
5512
5494
  }
5513
- function resolveVariantsNative(config, props) {
5514
- const { variants = {}, defaultVariants = {} } = config;
5515
- try {
5516
- const binding = getNativeBinding();
5517
- if (!binding?.resolveVariants) {
5518
- throw new Error("resolveVariants not available");
5495
+ var _configJsonCache = /* @__PURE__ */ new WeakMap();
5496
+ function _getConfigJson(config) {
5497
+ let json = _configJsonCache.get(config);
5498
+ if (!json) {
5499
+ const cfgObj = config;
5500
+ const cfgStr = JSON.stringify(cfgObj);
5501
+ const parsed = JSON.parse(cfgStr);
5502
+ if ("defaultVariants" in parsed && !("default_variants" in parsed)) {
5503
+ parsed.default_variants = parsed.defaultVariants;
5504
+ delete parsed.defaultVariants;
5519
5505
  }
5520
- const variantKeys = Object.keys(variants);
5521
- const configJson = (() => {
5522
- const cfgObj = config;
5523
- const cfgStr = JSON.stringify(cfgObj);
5524
- const parsed = JSON.parse(cfgStr);
5525
- if ("defaultVariants" in parsed && !("default_variants" in parsed)) {
5526
- parsed.default_variants = parsed.defaultVariants;
5527
- delete parsed.defaultVariants;
5528
- }
5529
- if ("compoundVariants" in parsed && !("compound_variants" in parsed)) {
5530
- parsed.compound_variants = parsed.compoundVariants;
5531
- delete parsed.compoundVariants;
5532
- }
5533
- if (!("variants" in parsed) || parsed.variants == null) {
5534
- parsed.variants = {};
5535
- }
5536
- return JSON.stringify(parsed);
5537
- })();
5538
- const cleanProps = {};
5539
- for (const k of variantKeys) {
5540
- const dv = defaultVariants[k];
5541
- if (dv !== void 0 && dv !== null) cleanProps[k] = String(dv);
5506
+ if ("compoundVariants" in parsed && !("compound_variants" in parsed)) {
5507
+ parsed.compound_variants = parsed.compoundVariants;
5508
+ delete parsed.compoundVariants;
5542
5509
  }
5543
- for (const k of variantKeys) {
5544
- const v = props[k];
5545
- if (v !== void 0 && v !== null) cleanProps[k] = String(v);
5546
- }
5547
- const propsJson = JSON.stringify(cleanProps);
5548
- const result = binding.resolveVariants(configJson, propsJson);
5549
- return result?.classes ?? "";
5550
- } catch (_err) {
5551
- if (process.env.NODE_ENV !== "production") {
5552
- console.warn("[cv() fallback] getNativeBinding threw error, using JS fallback");
5553
- }
5554
- const result = [];
5555
- const { base = "", compoundVariants = [] } = config;
5556
- if (base) result.push(base);
5557
- const merged = { ...defaultVariants };
5558
- for (const [key, values] of Object.entries(variants || {})) {
5559
- const selected = props[key] ?? defaultVariants?.[key];
5560
- if (selected !== void 0 && selected !== null) merged[key] = selected;
5561
- if (selected && typeof values === "object" && values !== null) {
5562
- const variantValues = values;
5563
- if (variantValues[String(selected)]) {
5564
- result.push(variantValues[String(selected)]);
5565
- }
5566
- }
5567
- }
5568
- for (const compound of compoundVariants) {
5569
- const { class: compoundClass, ...conditions } = compound;
5570
- const matches = Object.entries(conditions).every(
5571
- ([k, v]) => String(merged[k]) === String(v)
5572
- );
5573
- if (matches && compoundClass) result.push(compoundClass);
5510
+ if (!("variants" in parsed) || parsed.variants == null) {
5511
+ parsed.variants = {};
5574
5512
  }
5575
- return result.join(" ");
5513
+ json = JSON.stringify(parsed);
5514
+ _configJsonCache.set(config, json);
5576
5515
  }
5516
+ return json;
5517
+ }
5518
+ function resolveVariantsNative(config, props) {
5519
+ const { variants = {}, defaultVariants = {} } = config;
5520
+ const binding = getNativeBinding();
5521
+ if (!binding?.resolveVariants) {
5522
+ throw new Error("FATAL: Native binding 'resolveVariants' is required but not available. Build cannot continue.");
5523
+ }
5524
+ const variantKeys = Object.keys(variants);
5525
+ const configJson = _getConfigJson(config);
5526
+ const cleanProps = {};
5527
+ for (const k of variantKeys) {
5528
+ const dv = defaultVariants[k];
5529
+ if (dv !== void 0 && dv !== null) cleanProps[k] = String(dv);
5530
+ }
5531
+ for (const k of variantKeys) {
5532
+ const v = props[k];
5533
+ if (v !== void 0 && v !== null) cleanProps[k] = String(v);
5534
+ }
5535
+ const propsJson = JSON.stringify(cleanProps);
5536
+ const result = binding.resolveVariants(configJson, propsJson);
5537
+ return result.classes;
5577
5538
  }
5578
5539
  function cv(config, componentId) {
5579
5540
  if (process.env.NODE_ENV !== "production") {
@@ -6067,9 +6028,7 @@ function parseTemplate(strings, exprs) {
6067
6028
  if (cached) return cached;
6068
6029
  const binding = getNativeBinding();
6069
6030
  if (!binding?.parseTemplate) {
6070
- throw new Error(
6071
- "FATAL: Native binding 'parseTemplate' is required but not available in this environment.\n\nThis function is only available on Node.js with native bindings loaded.\nFor browser environments, use object config instead:\n tw.button({ base: '...', variants: {...} })"
6072
- );
6031
+ throw new Error("FATAL: Native binding 'parseTemplate' is required but not available.");
6073
6032
  }
6074
6033
  const r = binding.parseTemplate(raw);
6075
6034
  const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};