tailwind-styled-v4 5.0.8 → 5.0.10

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 (140) hide show
  1. package/CHANGELOG.md +204 -416
  2. package/README.md +45 -15
  3. package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
  4. package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
  5. package/dist/analyzer.d.mts +5 -3
  6. package/dist/analyzer.d.ts +5 -3
  7. package/dist/analyzer.js +563 -468
  8. package/dist/analyzer.js.map +1 -1
  9. package/dist/analyzer.mjs +562 -467
  10. package/dist/analyzer.mjs.map +1 -1
  11. package/dist/animate.d.mts +4 -7
  12. package/dist/animate.d.ts +4 -7
  13. package/dist/animate.js +171 -265
  14. package/dist/animate.js.map +1 -1
  15. package/dist/animate.mjs +165 -264
  16. package/dist/animate.mjs.map +1 -1
  17. package/dist/atomic.d.mts +22 -1
  18. package/dist/atomic.d.ts +22 -1
  19. package/dist/atomic.js +221 -165
  20. package/dist/atomic.js.map +1 -1
  21. package/dist/atomic.mjs +200 -165
  22. package/dist/atomic.mjs.map +1 -1
  23. package/dist/cli.d.mts +60 -1
  24. package/dist/cli.d.ts +60 -1
  25. package/dist/cli.js +1261 -1517
  26. package/dist/cli.js.map +1 -1
  27. package/dist/cli.mjs +1238 -1513
  28. package/dist/cli.mjs.map +1 -1
  29. package/dist/compiler.d.mts +38 -7
  30. package/dist/compiler.d.ts +38 -7
  31. package/dist/compiler.js +174 -197
  32. package/dist/compiler.js.map +1 -1
  33. package/dist/compiler.mjs +151 -194
  34. package/dist/compiler.mjs.map +1 -1
  35. package/dist/devtools.js +7 -31
  36. package/dist/devtools.js.map +1 -1
  37. package/dist/devtools.mjs +7 -31
  38. package/dist/devtools.mjs.map +1 -1
  39. package/dist/engine.d.mts +134 -63
  40. package/dist/engine.d.ts +134 -63
  41. package/dist/engine.js +2863 -2482
  42. package/dist/engine.js.map +1 -1
  43. package/dist/engine.mjs +2852 -2485
  44. package/dist/engine.mjs.map +1 -1
  45. package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
  46. package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
  47. package/dist/index.d.mts +63 -32
  48. package/dist/index.d.ts +63 -32
  49. package/dist/index.js +335 -169
  50. package/dist/index.js.map +1 -1
  51. package/dist/index.mjs +315 -169
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
  54. package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
  55. package/dist/next.d.mts +10 -4
  56. package/dist/next.d.ts +10 -4
  57. package/dist/next.js +32 -45
  58. package/dist/next.js.map +1 -1
  59. package/dist/next.mjs +30 -43
  60. package/dist/next.mjs.map +1 -1
  61. package/dist/plugin-api.d.mts +8 -2
  62. package/dist/plugin-api.d.ts +8 -2
  63. package/dist/plugin-api.js +14 -2
  64. package/dist/plugin-api.js.map +1 -1
  65. package/dist/plugin-api.mjs +14 -3
  66. package/dist/plugin-api.mjs.map +1 -1
  67. package/dist/plugin-registry.js +51 -11
  68. package/dist/plugin-registry.js.map +1 -1
  69. package/dist/plugin-registry.mjs +51 -11
  70. package/dist/plugin-registry.mjs.map +1 -1
  71. package/dist/plugin.d.mts +5 -7
  72. package/dist/plugin.d.ts +5 -7
  73. package/dist/plugin.js +16 -15
  74. package/dist/plugin.js.map +1 -1
  75. package/dist/plugin.mjs +16 -16
  76. package/dist/plugin.mjs.map +1 -1
  77. package/dist/rspack.js +17 -38
  78. package/dist/rspack.js.map +1 -1
  79. package/dist/rspack.mjs +15 -36
  80. package/dist/rspack.mjs.map +1 -1
  81. package/dist/runtime.d.mts +2 -2
  82. package/dist/runtime.d.ts +2 -2
  83. package/dist/scanner.d.mts +10 -1
  84. package/dist/scanner.d.ts +10 -1
  85. package/dist/scanner.js +298 -124
  86. package/dist/scanner.js.map +1 -1
  87. package/dist/scanner.mjs +296 -124
  88. package/dist/scanner.mjs.map +1 -1
  89. package/dist/shared.d.mts +1 -1
  90. package/dist/shared.d.ts +1 -1
  91. package/dist/shared.js +104 -176
  92. package/dist/shared.js.map +1 -1
  93. package/dist/shared.mjs +85 -176
  94. package/dist/shared.mjs.map +1 -1
  95. package/dist/storybook-addon.d.mts +1 -1
  96. package/dist/storybook-addon.d.ts +1 -1
  97. package/dist/svelte.d.mts +1 -1
  98. package/dist/svelte.d.ts +1 -1
  99. package/dist/svelte.js +166 -3
  100. package/dist/svelte.js.map +1 -1
  101. package/dist/svelte.mjs +143 -1
  102. package/dist/svelte.mjs.map +1 -1
  103. package/dist/syntax.js +21 -21
  104. package/dist/syntax.js.map +1 -1
  105. package/dist/syntax.mjs +21 -21
  106. package/dist/syntax.mjs.map +1 -1
  107. package/dist/testing.js +9 -1
  108. package/dist/testing.js.map +1 -1
  109. package/dist/testing.mjs +9 -1
  110. package/dist/testing.mjs.map +1 -1
  111. package/dist/theme.d.mts +2 -2
  112. package/dist/theme.d.ts +2 -2
  113. package/dist/theme.js +40 -112
  114. package/dist/theme.js.map +1 -1
  115. package/dist/theme.mjs +37 -110
  116. package/dist/theme.mjs.map +1 -1
  117. package/dist/turbopackLoader.js +84 -126
  118. package/dist/turbopackLoader.js.map +1 -1
  119. package/dist/turbopackLoader.mjs +68 -124
  120. package/dist/turbopackLoader.mjs.map +1 -1
  121. package/dist/tw.js +1256 -1517
  122. package/dist/tw.js.map +1 -1
  123. package/dist/tw.mjs +1236 -1513
  124. package/dist/tw.mjs.map +1 -1
  125. package/dist/vite.js +1783 -823
  126. package/dist/vite.js.map +1 -1
  127. package/dist/vite.mjs +1767 -821
  128. package/dist/vite.mjs.map +1 -1
  129. package/dist/vue.d.mts +1 -1
  130. package/dist/vue.d.ts +1 -1
  131. package/dist/vue.js +165 -4
  132. package/dist/vue.js.map +1 -1
  133. package/dist/vue.mjs +141 -1
  134. package/dist/vue.mjs.map +1 -1
  135. package/dist/webpackLoader.js +69 -108
  136. package/dist/webpackLoader.js.map +1 -1
  137. package/dist/webpackLoader.mjs +49 -104
  138. package/dist/webpackLoader.mjs.map +1 -1
  139. package/native/tailwind-styled-native.node +0 -0
  140. package/package.json +22 -24
package/dist/index.mjs CHANGED
@@ -1,5 +1,10 @@
1
+ import * as path from 'path';
2
+ import { dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import 'crypto';
5
+ import * as fs from 'fs';
6
+ import { createRequire } from 'module';
1
7
  import React3 from 'react';
2
- import { twMerge as twMerge$1 } from 'tailwind-merge';
3
8
 
4
9
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
5
10
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -8,6 +13,119 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
13
  if (typeof require !== "undefined") return require.apply(this, arguments);
9
14
  throw Error('Dynamic require of "' + x + '" is not supported');
10
15
  });
16
+ var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
17
+ var _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
18
+ var PLATFORM_MAP = {
19
+ "linux-x64": ["@tailwind-styled/native-linux-x64"],
20
+ "linux-arm64": ["@tailwind-styled/native-linux-arm64"],
21
+ "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
22
+ "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
23
+ "win32-x64": ["@tailwind-styled/native-win32-x64"],
24
+ "win32-arm64": ["@tailwind-styled/native-win32-arm64"]
25
+ };
26
+ function platformKey() {
27
+ if (isBrowser) return "browser";
28
+ return `${process.platform}-${process.arch}`;
29
+ }
30
+ function resolveNativeBinary(runtimeDir) {
31
+ const platform = platformKey();
32
+ const tried = [];
33
+ if (isBrowser) {
34
+ return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
35
+ }
36
+ if (process.env.TWS_DISABLE_NATIVE === "1") {
37
+ return { path: null, source: "not-found", platform, tried: [] };
38
+ }
39
+ const envPath = process.env.TW_NATIVE_PATH?.trim();
40
+ if (envPath) {
41
+ if (fs.existsSync(envPath)) {
42
+ return { path: envPath, source: "env", platform, tried };
43
+ }
44
+ tried.push(`env:${envPath} (not found)`);
45
+ }
46
+ const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
47
+ for (const pkg of prebuiltPkgs) {
48
+ try {
49
+ const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
50
+ if (fs.existsSync(candidate)) {
51
+ return { path: candidate, source: "prebuilt", platform, tried };
52
+ }
53
+ tried.push(`prebuilt:${pkg} (resolved but missing)`);
54
+ } catch {
55
+ tried.push(`prebuilt:${pkg} (not installed)`);
56
+ }
57
+ }
58
+ const cwd = process.cwd();
59
+ const base = runtimeDir ?? cwd;
60
+ const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
61
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
62
+ const localCandidates = [];
63
+ for (const bin of BINARY_NAMES) {
64
+ localCandidates.push(path.resolve(base, `${bin}.node`));
65
+ localCandidates.push(path.resolve(base, "..", `${bin}.node`));
66
+ localCandidates.push(path.resolve(base, `${bin}.${platform}.node`));
67
+ localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`));
68
+ }
69
+ for (const startDir of [cwd, base]) {
70
+ let dir = startDir;
71
+ for (let i = 0; i < 6; i++) {
72
+ const nativeDir = path.resolve(dir, "native");
73
+ for (const bin of BINARY_NAMES) {
74
+ localCandidates.push(path.resolve(nativeDir, `${bin}.node`));
75
+ localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`));
76
+ localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
77
+ localCandidates.push(path.resolve(nativeDir, "target", "release", `${bin}.node`));
78
+ }
79
+ const parent = path.resolve(dir, "..");
80
+ if (parent === dir) break;
81
+ dir = parent;
82
+ }
83
+ }
84
+ for (const candidate of localCandidates) {
85
+ tried.push(`local:${candidate}`);
86
+ if (fs.existsSync(candidate)) {
87
+ return { path: candidate, source: "local", platform, tried };
88
+ }
89
+ }
90
+ return { path: null, source: "not-found", platform, tried };
91
+ }
92
+
93
+ // packages/domain/shared/src/index.ts
94
+ createRequire(import.meta.url);
95
+
96
+ // packages/domain/core/src/native.ts
97
+ var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
98
+ var NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/core] Native binding is required but not available.\nPlease ensure you have run: npm run build:rust";
99
+ var _loadNative = (path3) => __require(path3);
100
+ var nativeBinding = null;
101
+ var bindingLoadAttempted = false;
102
+ var getBinding = () => {
103
+ if (isBrowser2) {
104
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE + "\n\nNative bindings are not available in browser. Use the compiled CSS output instead.");
105
+ }
106
+ if (nativeBinding) return nativeBinding;
107
+ if (bindingLoadAttempted) {
108
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
109
+ }
110
+ bindingLoadAttempted = true;
111
+ try {
112
+ const runtimeDir = isBrowser2 ? "" : dirname(fileURLToPath(import.meta.url));
113
+ const result = isBrowser2 ? { path: null, source: "not-found", platform: "browser", tried: [] } : resolveNativeBinary(runtimeDir);
114
+ if (result.path && result.path.endsWith(".node")) {
115
+ const mod = _loadNative(result.path);
116
+ if (mod?.batchSplitClasses) {
117
+ nativeBinding = mod;
118
+ return nativeBinding;
119
+ }
120
+ }
121
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
122
+
123
+ Tried: ${result.tried.join("\n")}`);
124
+ } catch (err) {
125
+ throw err instanceof Error ? err : new Error(String(err));
126
+ }
127
+ };
128
+ var getNativeBinding = getBinding;
11
129
 
12
130
  // packages/domain/core/src/containerQuery.ts
13
131
  var CONTAINER_BREAKPOINTS = {
@@ -79,6 +197,13 @@ var LAYOUT_MAP = {
79
197
  "justify-end": "justify-content:flex-end"
80
198
  };
81
199
  function layoutClassesToCss(classes) {
200
+ try {
201
+ const native = getNativeBinding();
202
+ if (native?.layoutClassesToCss) {
203
+ return native.layoutClassesToCss(classes);
204
+ }
205
+ } catch {
206
+ }
82
207
  const decls = [];
83
208
  for (const cls of classes.trim().split(/\s+/)) {
84
209
  if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
@@ -142,18 +267,36 @@ function processContainer(tag, container, containerName) {
142
267
  }
143
268
  function generateContainerCss(tag, container, containerName) {
144
269
  const id = hashContainer(tag, container, containerName);
270
+ try {
271
+ const native = getNativeBinding();
272
+ if (native?.buildContainerRules) {
273
+ const breakpoints = Object.entries(container).map(([key, value]) => ({
274
+ key,
275
+ classes: typeof value === "string" ? value : value.classes
276
+ }));
277
+ return native.buildContainerRules(id, breakpoints, containerName ?? null);
278
+ }
279
+ } catch {
280
+ }
145
281
  return buildContainerRules(id, container, containerName);
146
282
  }
147
283
  function getContainerRegistry() {
148
284
  return containerRegistry;
149
285
  }
286
+
287
+ // packages/domain/core/src/merge.ts
150
288
  function normalizeClassInput(classLists) {
151
289
  return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
152
290
  }
153
291
  function createTwMerge(_options = {}) {
154
- return function twMerge4(...classLists) {
292
+ return function twMerge2(...classLists) {
155
293
  const clean = normalizeClassInput(classLists);
156
- return twMerge$1(clean.join(" "));
294
+ if (clean.length === 0) return "";
295
+ const native = getNativeBinding();
296
+ if (!native?.twMergeMany) {
297
+ throw new Error("FATAL: Native binding 'twMergeMany' is required but not available.");
298
+ }
299
+ return native.twMergeMany(clean);
157
300
  };
158
301
  }
159
302
  var twMerge = createTwMerge();
@@ -176,113 +319,12 @@ function hashState(tag, state) {
176
319
  const hash = key.split("").reduce((h, char) => (h << 5) + h ^ char.charCodeAt(0), 5381);
177
320
  return `tw-s-${Math.abs(hash).toString(36).slice(0, 6)}`;
178
321
  }
179
- var TW_MAP = {
180
- // Display
181
- hidden: "display:none",
182
- block: "display:block",
183
- flex: "display:flex",
184
- inline: "display:inline",
185
- "inline-flex": "display:inline-flex",
186
- grid: "display:grid",
187
- // Opacity
188
- "opacity-0": "opacity:0",
189
- "opacity-5": "opacity:0.05",
190
- "opacity-10": "opacity:0.1",
191
- "opacity-20": "opacity:0.2",
192
- "opacity-25": "opacity:0.25",
193
- "opacity-30": "opacity:0.3",
194
- "opacity-40": "opacity:0.4",
195
- "opacity-50": "opacity:0.5",
196
- "opacity-60": "opacity:0.6",
197
- "opacity-70": "opacity:0.7",
198
- "opacity-75": "opacity:0.75",
199
- "opacity-80": "opacity:0.8",
200
- "opacity-90": "opacity:0.9",
201
- "opacity-95": "opacity:0.95",
202
- "opacity-100": "opacity:1",
203
- // Cursor
204
- "cursor-pointer": "cursor:pointer",
205
- "cursor-not-allowed": "cursor:not-allowed",
206
- "cursor-default": "cursor:default",
207
- "cursor-wait": "cursor:wait",
208
- "cursor-move": "cursor:move",
209
- "cursor-grab": "cursor:grab",
210
- "cursor-grabbing": "cursor:grabbing",
211
- // Pointer events
212
- "pointer-events-none": "pointer-events:none",
213
- "pointer-events-auto": "pointer-events:auto",
214
- // Scale
215
- "scale-90": "transform:scale(0.9)",
216
- "scale-95": "transform:scale(0.95)",
217
- "scale-100": "transform:scale(1)",
218
- "scale-105": "transform:scale(1.05)",
219
- "scale-110": "transform:scale(1.1)",
220
- // Translate
221
- "translate-x-0": "transform:translateX(0)",
222
- "translate-y-0": "transform:translateY(0)",
223
- "-translate-x-1": "transform:translateX(-0.25rem)",
224
- "-translate-y-1": "transform:translateY(-0.25rem)",
225
- "translate-x-1": "transform:translateX(0.25rem)",
226
- "translate-y-1": "transform:translateY(0.25rem)",
227
- // Ring
228
- ring: "box-shadow:0 0 0 3px rgba(59,130,246,0.5)",
229
- "ring-2": "box-shadow:0 0 0 2px rgba(59,130,246,0.5)",
230
- "ring-4": "box-shadow:0 0 0 4px rgba(59,130,246,0.5)",
231
- "ring-inset": "box-shadow:inset 0 0 0 3px rgba(59,130,246,0.5)",
232
- // Border
233
- border: "border-width:1px",
234
- "border-2": "border-width:2px",
235
- "border-transparent": "border-color:transparent",
236
- // Outline
237
- "outline-none": "outline:2px solid transparent;outline-offset:2px",
238
- outline: "outline:2px solid currentColor",
239
- // Overflow
240
- "overflow-hidden": "overflow:hidden",
241
- "overflow-auto": "overflow:auto",
242
- "overflow-scroll": "overflow:scroll",
243
- // Text decoration
244
- underline: "text-decoration-line:underline",
245
- "no-underline": "text-decoration-line:none",
246
- "line-through": "text-decoration-line:line-through",
247
- // Font weight
248
- "font-bold": "font-weight:700",
249
- "font-semibold": "font-weight:600",
250
- "font-medium": "font-weight:500",
251
- "font-normal": "font-weight:400",
252
- // Background colors (common)
253
- "bg-transparent": "background-color:transparent",
254
- "bg-white": "background-color:#fff",
255
- "bg-black": "background-color:#000",
256
- "bg-blue-500": "background-color:rgb(59,130,246)",
257
- "bg-blue-600": "background-color:rgb(37,99,235)",
258
- "bg-red-500": "background-color:rgb(239,68,68)",
259
- "bg-green-500": "background-color:rgb(34,197,94)",
260
- "bg-yellow-500": "background-color:rgb(234,179,8)",
261
- "bg-zinc-900": "background-color:rgb(24,24,27)",
262
- "bg-zinc-800": "background-color:rgb(39,39,42)",
263
- // Text colors
264
- "text-white": "color:#fff",
265
- "text-black": "color:#000",
266
- "text-blue-500": "color:rgb(59,130,246)",
267
- "text-red-500": "color:rgb(239,68,68)",
268
- "text-zinc-400": "color:rgb(161,161,170)",
269
- "text-zinc-500": "color:rgb(113,113,122)"
270
- };
271
322
  function twClassesToCss(classes) {
272
- const decls = [];
273
- for (const cls of classes.trim().split(/\s+/)) {
274
- if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
275
- else if (cls.includes("[") && cls.includes("]")) {
276
- const val = cls.match(/\[(.+)\]/)?.[1];
277
- if (!val) continue;
278
- if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
279
- else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
280
- else if (cls.startsWith("w-[")) decls.push(`width:${val}`);
281
- else if (cls.startsWith("h-[")) decls.push(`height:${val}`);
282
- else if (cls.startsWith("opacity-[")) decls.push(`opacity:${val}`);
283
- }
323
+ const native = getNativeBinding();
324
+ if (!native?.twClassesToCss) {
325
+ throw new Error("FATAL: Native binding 'twClassesToCss' is required but not available.");
284
326
  }
285
- return decls.join(";");
327
+ return native.twClassesToCss(classes);
286
328
  }
287
329
  function injectStateStyles(id, state) {
288
330
  if (typeof document === "undefined") return;
@@ -335,28 +377,50 @@ function getStateRegistry() {
335
377
 
336
378
  // packages/domain/core/src/createComponent.ts
337
379
  var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
338
- function parseSubComponentNames(template) {
339
- const matches = [...template.matchAll(/\[(\w+)\]/g)];
340
- return [...new Set(matches.map((m) => m[1]))];
380
+ function parseSubComponentBlocks(template) {
381
+ const native = getNativeBinding();
382
+ if (!native?.parseSubcomponentBlocksNapi) {
383
+ throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
384
+ }
385
+ const result = native.parseSubcomponentBlocksNapi(template, "tw");
386
+ const raw = JSON.parse(result.subMapJson);
387
+ return new Map(Object.entries(raw));
341
388
  }
342
389
  function extractBaseClasses(template) {
343
- return template.replace(/\[\w+\]\s*\{[^}]*\}/g, "").replace(/\s+/g, " ").trim();
390
+ try {
391
+ const native = getNativeBinding();
392
+ if (native?.parseSubcomponentBlocksNapi) {
393
+ const result = native.parseSubcomponentBlocksNapi(template, "tw");
394
+ return result.baseClasses;
395
+ }
396
+ } catch {
397
+ }
398
+ return template.replace(/(?:\[[a-zA-Z][a-zA-Z0-9_-]*\]|[a-zA-Z][a-zA-Z0-9_-]*)\s*\{[^}]*\}/g, "").replace(/\s+/g, " ").trim();
344
399
  }
345
- function createSubComponentAccessor(parentDisplayName, name) {
400
+ function createSubComponentAccessor(parentDisplayName, name, classes) {
346
401
  const SubComponent = ({
347
402
  children,
348
403
  className
349
- }) => React3.createElement(React3.Fragment, null, children);
404
+ }) => React3.createElement(
405
+ "span",
406
+ { className: className ? `${classes} ${className}` : classes },
407
+ children
408
+ );
350
409
  SubComponent.displayName = `${parentDisplayName}[${name}]`;
351
410
  return SubComponent;
352
411
  }
353
- function registerSubComponents(component, template) {
354
- const names = parseSubComponentNames(template);
412
+ function registerSubComponents(component, template, configSub) {
355
413
  const displayName = component.displayName ?? "tw";
356
414
  const map = component;
357
- for (const name of names) {
415
+ if (configSub) {
416
+ for (const [name, classes] of Object.entries(configSub)) {
417
+ map[name] = createSubComponentAccessor(displayName, name, classes.trim().replace(/\s+/g, " "));
418
+ }
419
+ }
420
+ const blocks = parseSubComponentBlocks(template);
421
+ for (const [name, classes] of blocks) {
358
422
  if (!(name in map)) {
359
- map[name] = createSubComponentAccessor(displayName, name);
423
+ map[name] = createSubComponentAccessor(displayName, name, classes);
360
424
  }
361
425
  }
362
426
  }
@@ -376,14 +440,15 @@ function makeFilterProps(variantKeys) {
376
440
  };
377
441
  }
378
442
  function resolveVariants(variants, props, defaults) {
379
- const classes = [];
380
- for (const key in variants) {
381
- const value = props[key] ?? defaults[key];
382
- if (value !== void 0 && variants[key][String(value)]) {
383
- classes.push(variants[key][String(value)]);
384
- }
443
+ const binding = getNativeBinding();
444
+ if (!binding?.resolveSimpleVariants) {
445
+ throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
385
446
  }
386
- return classes.join(" ");
447
+ const cleanProps = {};
448
+ for (const [k, v] of Object.entries(props)) {
449
+ if (v !== void 0 && v !== null) cleanProps[k] = String(v);
450
+ }
451
+ return binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
387
452
  }
388
453
  function resolveCompound(compounds, props) {
389
454
  const classes = [];
@@ -407,13 +472,21 @@ function carryOverSubComponents(target, source) {
407
472
  function attachExtend(component, originalTag, base, config) {
408
473
  function extendWithClasses(stringsOrConfig) {
409
474
  if (Array.isArray(stringsOrConfig) && "raw" in stringsOrConfig) {
410
- const extra = stringsOrConfig.raw.join("").trim().replace(/\s+/g, " ");
411
- const merged2 = twMerge(extractBaseClasses(base), extra);
475
+ const rawExtra = stringsOrConfig.raw.join("").trim().replace(/\s+/g, " ");
476
+ const merged2 = twMerge(extractBaseClasses(base), extractBaseClasses(rawExtra));
412
477
  const extended2 = createComponent(
413
478
  originalTag,
414
479
  typeof config === "string" ? merged2 : { ...config, base: merged2 }
415
480
  );
416
481
  carryOverSubComponents(extended2, component);
482
+ const extendSubBlocks = parseSubComponentBlocks(rawExtra);
483
+ if (extendSubBlocks.size > 0) {
484
+ const extComp = extended2;
485
+ const displayName = extended2.displayName ?? "tw";
486
+ for (const [subName, subClasses] of extendSubBlocks) {
487
+ extComp[subName] = createSubComponentAccessor(displayName, subName, subClasses);
488
+ }
489
+ }
417
490
  return extended2;
418
491
  }
419
492
  const extCfg = stringsOrConfig;
@@ -471,6 +544,7 @@ function createComponent(tag, config) {
471
544
  const stateConfig = typeof config === "string" ? void 0 : config.state;
472
545
  const containerConfig = typeof config === "string" ? void 0 : config.container;
473
546
  const containerName = typeof config === "string" ? void 0 : config.containerName;
547
+ const configSub = typeof config === "string" ? void 0 : config.sub;
474
548
  const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
475
549
  const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
476
550
  const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
@@ -489,8 +563,8 @@ function createComponent(tag, config) {
489
563
  const component2 = baseComponent2;
490
564
  component2.displayName = `tw.${tagLabel}`;
491
565
  const result2 = attachExtend(component2, tag, base, config);
492
- registerSubComponents(result2, base);
493
- return result2;
566
+ registerSubComponents(result2, base, configSub);
567
+ return wrapWithSubProxy(result2, tagLabel);
494
568
  }
495
569
  const baseComponent = React3.forwardRef((props, ref) => {
496
570
  const { className, ...rest } = props;
@@ -506,9 +580,39 @@ function createComponent(tag, config) {
506
580
  const component = baseComponent;
507
581
  component.displayName = `tw.${tagLabel}`;
508
582
  const result = attachExtend(component, tag, base, config);
509
- registerSubComponents(result, base);
510
- return result;
583
+ registerSubComponents(result, base, configSub);
584
+ return wrapWithSubProxy(result, tagLabel);
585
+ }
586
+ var SKIP_PROXY_KEYS = /* @__PURE__ */ new Set([
587
+ "extend",
588
+ "withVariants",
589
+ "animate",
590
+ "withSub",
591
+ "displayName",
592
+ "$$typeof",
593
+ "render",
594
+ "prototype",
595
+ "__esModule",
596
+ "then"
597
+ ]);
598
+ function wrapWithSubProxy(component, tagLabel) {
599
+ return new Proxy(component, {
600
+ get(target, prop) {
601
+ const value = target[prop];
602
+ if (value !== void 0) return value;
603
+ if (typeof prop === "symbol") return value;
604
+ if (SKIP_PROXY_KEYS.has(prop)) return value;
605
+ const Fallback = ({
606
+ children,
607
+ className
608
+ }) => React3.createElement("span", { className }, children);
609
+ Fallback.displayName = `tw.${tagLabel}.${prop}(fallback)`;
610
+ return Fallback;
611
+ }
612
+ });
511
613
  }
614
+
615
+ // packages/domain/core/src/cv.ts
512
616
  var __generatedRegistry = {};
513
617
  function lookupGenerated(componentId, props, defaultVariants) {
514
618
  const table = __generatedRegistry[componentId];
@@ -517,27 +621,40 @@ function lookupGenerated(componentId, props, defaultVariants) {
517
621
  const key = Object.keys(merged).sort().filter((k) => k !== "className").map((k) => `${k}:${String(merged[k])}`).join("|");
518
622
  return table[key];
519
623
  }
520
- function resolveVariantsJS(config, props) {
624
+ function resolveVariantsNative(config, props) {
521
625
  const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
522
- const classes = [];
523
- if (base) classes.push(...base.split(" ").filter(Boolean));
524
- const resolved = { ...defaultVariants, ...props };
525
- for (const [key, variantMap] of Object.entries(variants)) {
526
- const value = resolved[key];
527
- if (value !== void 0 && value !== null) {
528
- const variantClass = variantMap[String(value)];
529
- if (variantClass) classes.push(...variantClass.split(" ").filter(Boolean));
626
+ const binding = getNativeBinding();
627
+ if (binding?.resolveSimpleVariants) {
628
+ const mergedProps = {};
629
+ for (const [k, v] of Object.entries(defaultVariants)) {
630
+ if (v !== void 0 && v !== null) mergedProps[k] = String(v);
530
631
  }
531
- }
532
- for (const compound of compoundVariants) {
533
- const { class: compoundClass, className: compoundClassName, ...conditions } = compound;
534
- const matches = Object.entries(conditions).every(([key, val]) => resolved[key] === val);
535
- if (matches) {
536
- if (compoundClass) classes.push(...String(compoundClass).split(" ").filter(Boolean));
537
- if (compoundClassName) classes.push(...String(compoundClassName).split(" ").filter(Boolean));
632
+ for (const [k, v] of Object.entries(props)) {
633
+ if (v !== void 0 && v !== null && k !== "className") {
634
+ mergedProps[k] = String(v);
635
+ }
636
+ }
637
+ let result = binding.resolveSimpleVariants(
638
+ base || null,
639
+ variants,
640
+ {},
641
+ // already merged into mergedProps
642
+ mergedProps
643
+ );
644
+ const resolved = { ...defaultVariants, ...props };
645
+ const extra = [];
646
+ for (const compound of compoundVariants) {
647
+ const { class: compoundClass, className: compoundClassName, ...conditions } = compound;
648
+ const matches = Object.entries(conditions).every(([key, val]) => resolved[key] === val);
649
+ if (matches) {
650
+ if (compoundClass) extra.push(String(compoundClass));
651
+ if (compoundClassName) extra.push(String(compoundClassName));
652
+ }
538
653
  }
654
+ if (extra.length > 0) result = `${result} ${extra.join(" ")}`.trim();
655
+ return result;
539
656
  }
540
- return [...new Set(classes)].join(" ");
657
+ throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
541
658
  }
542
659
  function cv(config, componentId) {
543
660
  if (process.env.NODE_ENV !== "production") {
@@ -556,18 +673,34 @@ function cv(config, componentId) {
556
673
  props,
557
674
  config.defaultVariants
558
675
  );
559
- result = generated ?? resolveVariantsJS(config, props);
676
+ result = generated ?? resolveVariantsNative(config, props);
560
677
  } else {
561
- result = resolveVariantsJS(config, props);
678
+ result = resolveVariantsNative(config, props);
562
679
  }
563
- return props.className ? twMerge$1(result, props.className) : result;
680
+ return props.className ? twMerge(result, props.className) : result;
564
681
  };
565
682
  }
683
+
684
+ // packages/domain/core/src/cx.ts
566
685
  function cn(...inputs) {
567
- return inputs.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
686
+ const native = getNativeBinding();
687
+ if (!native?.resolveClassNames) {
688
+ throw new Error("FATAL: Native binding 'resolveClassNames' is required but not available.");
689
+ }
690
+ const strings = inputs.flat().filter(Boolean);
691
+ return native.resolveClassNames(strings);
568
692
  }
569
693
  function cx(...inputs) {
570
- return twMerge$1(...inputs.filter(Boolean));
694
+ const filtered = inputs.flat().filter(Boolean);
695
+ if (filtered.length === 0) return "";
696
+ const native = getNativeBinding();
697
+ if (!native?.twMergeMany && !native?.twMerge) {
698
+ throw new Error("FATAL: Native binding 'twMerge' or 'twMergeMany' is required but not available.");
699
+ }
700
+ if (native.twMergeMany) {
701
+ return native.twMergeMany(filtered);
702
+ }
703
+ return native.twMerge(filtered.join(" "));
571
704
  }
572
705
  var cxm = cx;
573
706
  var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
@@ -857,8 +990,8 @@ function tokenVarRef(prefix, group, name) {
857
990
  }
858
991
  function resolveTokenRef(tokens, prefix, value) {
859
992
  if (value.startsWith("token:")) {
860
- const path = value.slice(6);
861
- const [group, name] = path.split(".");
993
+ const path3 = value.slice(6);
994
+ const [group, name] = path3.split(".");
862
995
  if (group && name && tokens[group]?.[name] !== void 0) {
863
996
  return tokenVarRef(prefix, group, name);
864
997
  }
@@ -957,13 +1090,13 @@ function createStyledSystem(config) {
957
1090
  return createComponent(runtimeTag, merged);
958
1091
  };
959
1092
  }
960
- function token(path) {
961
- const [group, name] = path.split(".");
962
- if (!group || !name) return path;
1093
+ function token(path3) {
1094
+ const [group, name] = path3.split(".");
1095
+ if (!group || !name) return path3;
963
1096
  return tokenVarRef(prefix, group, name);
964
1097
  }
965
- function rawToken(path) {
966
- const [group, name] = path.split(".");
1098
+ function rawToken(path3) {
1099
+ const [group, name] = path3.split(".");
967
1100
  if (!group || !name) return void 0;
968
1101
  return tokens[group]?.[name];
969
1102
  }
@@ -1002,9 +1135,9 @@ function createStyledSystem(config) {
1002
1135
  tokens
1003
1136
  });
1004
1137
  }
1005
- var SUB_RE = /\[([a-zA-Z][a-zA-Z0-9_-]*)\]\s*\{([^}]*)\}/g;
1138
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
1006
1139
  var COMMENT_RE = /\/\/[^\n]*/g;
1007
- function parseTemplate(strings, exprs) {
1140
+ function parseTemplateFallback(strings, exprs) {
1008
1141
  const raw = strings.raw.reduce((acc, str, i) => {
1009
1142
  const expr = exprs[i];
1010
1143
  const exprStr = typeof expr === "function" ? "" : expr ?? "";
@@ -1015,17 +1148,30 @@ function parseTemplate(strings, exprs) {
1015
1148
  let match;
1016
1149
  SUB_RE.lastIndex = 0;
1017
1150
  while ((match = SUB_RE.exec(raw)) !== null) {
1018
- const name = match[1];
1019
- const inner = match[2].replace(COMMENT_RE, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1151
+ const name = match[1] ?? match[2];
1152
+ const inner = match[3].replace(COMMENT_RE, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1020
1153
  subs[name] = inner;
1021
1154
  base = base.replace(match[0], "");
1022
1155
  }
1023
1156
  const cleanBase = base.replace(COMMENT_RE, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1024
- return {
1025
- base: cleanBase,
1026
- subs,
1027
- hasSubs: Object.keys(subs).length > 0
1028
- };
1157
+ return { base: cleanBase, subs, hasSubs: Object.keys(subs).length > 0 };
1158
+ }
1159
+ function parseTemplate(strings, exprs) {
1160
+ const raw = strings.raw.reduce((acc, str, i) => {
1161
+ const expr = exprs[i];
1162
+ const exprStr = typeof expr === "function" ? "" : expr ?? "";
1163
+ return acc + str + String(exprStr);
1164
+ }, "");
1165
+ try {
1166
+ const binding = getNativeBinding();
1167
+ if (binding?.parseTemplate) {
1168
+ const result = binding.parseTemplate(raw);
1169
+ const subs = result.hasSubs ? JSON.parse(result.subsJson) : {};
1170
+ return { base: result.base, subs, hasSubs: result.hasSubs };
1171
+ }
1172
+ } catch {
1173
+ }
1174
+ return parseTemplateFallback(strings, exprs);
1029
1175
  }
1030
1176
  function makeTag(tag) {
1031
1177
  return ((stringsOrConfig, ...exprs) => {