tailwind-styled-v4 5.1.11 → 5.1.13
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.
- package/dist/index.browser.mjs +224 -156
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +226 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -156
- package/dist/index.mjs.map +1 -1
- package/dist/runtime-css.js +1 -0
- package/dist/runtime-css.mjs +1 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.mjs +1 -0
- package/dist/svelte.js +143 -136
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -136
- package/dist/svelte.mjs.map +1 -1
- package/dist/theme.js +1 -0
- package/dist/theme.mjs +1 -0
- package/dist/vue.js +144 -137
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +144 -137
- package/dist/vue.mjs.map +1 -1
- package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +1 -1
- package/dist/metafile-cjs.json +0 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -28,22 +28,27 @@ if (typeof window !== "undefined") {
|
|
|
28
28
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
29
29
|
}
|
|
30
30
|
var _hashContainerCache = /* @__PURE__ */ new Map();
|
|
31
|
+
function _fnvHash6(s) {
|
|
32
|
+
let h = 2166136261;
|
|
33
|
+
for (let i = 0; i < s.length; i++) {
|
|
34
|
+
h ^= s.charCodeAt(i);
|
|
35
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
36
|
+
}
|
|
37
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
38
|
+
}
|
|
31
39
|
function hashContainer(tag, container, name) {
|
|
32
40
|
const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
33
41
|
const cached = _hashContainerCache.get(sortedKey);
|
|
34
42
|
if (cached) return cached;
|
|
35
43
|
const native = getNativeBinding();
|
|
36
|
-
|
|
37
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
38
|
-
}
|
|
39
|
-
const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
44
|
+
const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
|
|
40
45
|
_hashContainerCache.set(sortedKey, id);
|
|
41
46
|
return id;
|
|
42
47
|
}
|
|
43
48
|
function layoutClassesToCss(classes) {
|
|
44
49
|
const native = getNativeBinding();
|
|
45
50
|
if (!native?.layoutClassesToCss) {
|
|
46
|
-
|
|
51
|
+
return "";
|
|
47
52
|
}
|
|
48
53
|
return native.layoutClassesToCss(classes);
|
|
49
54
|
}
|
|
@@ -200,96 +205,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
|
|
|
200
205
|
var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
201
206
|
var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
|
|
202
207
|
var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
|
|
203
|
-
function conflictGroup(base) {
|
|
204
|
-
const
|
|
208
|
+
function conflictGroup(base, prefix = "") {
|
|
209
|
+
const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
|
|
210
|
+
const bracket = b.indexOf("[");
|
|
205
211
|
if (bracket !== -1) {
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
if (DISPLAY_VALUES.has(
|
|
210
|
-
if (POSITION_VALUES.has(
|
|
211
|
-
if (
|
|
212
|
-
if (
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
if (
|
|
217
|
-
if (
|
|
218
|
-
if (
|
|
219
|
-
if (
|
|
220
|
-
if (
|
|
221
|
-
if (
|
|
222
|
-
if (
|
|
223
|
-
if (
|
|
224
|
-
if (
|
|
225
|
-
if (
|
|
226
|
-
if (
|
|
227
|
-
if (
|
|
228
|
-
if (
|
|
229
|
-
if (
|
|
230
|
-
if (
|
|
231
|
-
if (
|
|
232
|
-
if (
|
|
233
|
-
if (
|
|
234
|
-
if (
|
|
235
|
-
if (
|
|
236
|
-
if (
|
|
237
|
-
if (
|
|
238
|
-
if (
|
|
239
|
-
if (
|
|
240
|
-
if (
|
|
241
|
-
if (
|
|
242
|
-
if (
|
|
243
|
-
if (
|
|
244
|
-
if (
|
|
245
|
-
if (
|
|
246
|
-
if (
|
|
247
|
-
if (
|
|
248
|
-
if (
|
|
249
|
-
if (
|
|
250
|
-
if (
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
253
|
-
if (
|
|
254
|
-
if (
|
|
255
|
-
if (
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
if (
|
|
259
|
-
if (
|
|
260
|
-
if (
|
|
261
|
-
if (
|
|
262
|
-
if (
|
|
263
|
-
if (
|
|
264
|
-
if (
|
|
265
|
-
if (
|
|
266
|
-
if (
|
|
267
|
-
if (
|
|
268
|
-
if (
|
|
269
|
-
if (
|
|
270
|
-
if (
|
|
271
|
-
if (
|
|
212
|
+
const grp = b.slice(0, bracket).replace(/-+$/, "");
|
|
213
|
+
return grp.length > 0 ? grp : "arbitrary";
|
|
214
|
+
}
|
|
215
|
+
if (DISPLAY_VALUES.has(b)) return "display";
|
|
216
|
+
if (POSITION_VALUES.has(b)) return "position";
|
|
217
|
+
if (b.startsWith("overflow-x-")) return "overflow-x";
|
|
218
|
+
if (b.startsWith("overflow-y-")) return "overflow-y";
|
|
219
|
+
if (b.startsWith("overflow-")) return "overflow";
|
|
220
|
+
if (b.startsWith("flex-")) return "flex";
|
|
221
|
+
if (b.startsWith("grid-cols-")) return "grid-cols";
|
|
222
|
+
if (b.startsWith("grid-rows-")) return "grid-rows";
|
|
223
|
+
if (b.startsWith("grid-flow-")) return "grid-flow";
|
|
224
|
+
if (b.startsWith("col-")) return "col";
|
|
225
|
+
if (b.startsWith("row-")) return "row";
|
|
226
|
+
if (b === "grow" || b.startsWith("grow-")) return "grow";
|
|
227
|
+
if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
|
|
228
|
+
if (b.startsWith("gap-x-")) return "gap-x";
|
|
229
|
+
if (b.startsWith("gap-y-")) return "gap-y";
|
|
230
|
+
if (b.startsWith("gap-")) return "gap";
|
|
231
|
+
if (b.startsWith("justify-items-")) return "justify-items";
|
|
232
|
+
if (b.startsWith("justify-self-")) return "justify-self";
|
|
233
|
+
if (b.startsWith("justify-")) return "justify";
|
|
234
|
+
if (b.startsWith("items-")) return "items";
|
|
235
|
+
if (b.startsWith("self-")) return "self";
|
|
236
|
+
if (b.startsWith("place-content-")) return "place-content";
|
|
237
|
+
if (b.startsWith("place-items-")) return "place-items";
|
|
238
|
+
if (b.startsWith("place-self-")) return "place-self";
|
|
239
|
+
if (b.startsWith("content-")) return "content";
|
|
240
|
+
if (b.startsWith("px-")) return "px";
|
|
241
|
+
if (b.startsWith("py-")) return "py";
|
|
242
|
+
if (b.startsWith("pt-")) return "pt";
|
|
243
|
+
if (b.startsWith("pr-")) return "pr";
|
|
244
|
+
if (b.startsWith("pb-")) return "pb";
|
|
245
|
+
if (b.startsWith("pl-")) return "pl";
|
|
246
|
+
if (b.startsWith("ps-")) return "ps";
|
|
247
|
+
if (b.startsWith("pe-")) return "pe";
|
|
248
|
+
if (b.startsWith("p-")) return "p";
|
|
249
|
+
if (b.startsWith("mx-")) return "mx";
|
|
250
|
+
if (b.startsWith("my-")) return "my";
|
|
251
|
+
if (b.startsWith("mt-")) return "mt";
|
|
252
|
+
if (b.startsWith("mr-")) return "mr";
|
|
253
|
+
if (b.startsWith("mb-")) return "mb";
|
|
254
|
+
if (b.startsWith("ml-")) return "ml";
|
|
255
|
+
if (b.startsWith("ms-")) return "ms";
|
|
256
|
+
if (b.startsWith("me-")) return "me";
|
|
257
|
+
if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
|
|
258
|
+
if (b.startsWith("space-x-")) return "space-x";
|
|
259
|
+
if (b.startsWith("space-y-")) return "space-y";
|
|
260
|
+
if (b.startsWith("size-")) return "size";
|
|
261
|
+
if (b.startsWith("min-w-")) return "min-w";
|
|
262
|
+
if (b.startsWith("max-w-")) return "max-w";
|
|
263
|
+
if (b.startsWith("w-")) return "w";
|
|
264
|
+
if (b.startsWith("min-h-")) return "min-h";
|
|
265
|
+
if (b.startsWith("max-h-")) return "max-h";
|
|
266
|
+
if (b.startsWith("h-")) return "h";
|
|
267
|
+
if (b.startsWith("inset-x-")) return "inset-x";
|
|
268
|
+
if (b.startsWith("inset-y-")) return "inset-y";
|
|
269
|
+
if (b.startsWith("inset-")) return "inset";
|
|
270
|
+
if (b.startsWith("top-")) return "top";
|
|
271
|
+
if (b.startsWith("right-") || b.startsWith("end-")) return "right";
|
|
272
|
+
if (b.startsWith("bottom-")) return "bottom";
|
|
273
|
+
if (b.startsWith("left-") || b.startsWith("start-")) return "left";
|
|
274
|
+
if (b.startsWith("z-")) return "z";
|
|
275
|
+
if (b.startsWith("opacity-")) return "opacity";
|
|
276
|
+
if (b.startsWith("bg-")) {
|
|
277
|
+
if (b.startsWith("bg-opacity-")) return "bg-opacity";
|
|
272
278
|
return "bg";
|
|
273
279
|
}
|
|
274
|
-
if (
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
if (
|
|
278
|
-
const suffix =
|
|
280
|
+
if (b.startsWith("from-")) return "from";
|
|
281
|
+
if (b.startsWith("via-")) return "via";
|
|
282
|
+
if (b.startsWith("to-")) return "to";
|
|
283
|
+
if (b.startsWith("text-")) {
|
|
284
|
+
const suffix = b.slice("text-".length);
|
|
279
285
|
if (isTextSize(suffix)) return "text-size";
|
|
280
286
|
if (suffix.startsWith("opacity-")) return "text-opacity";
|
|
281
287
|
if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
|
|
282
288
|
return "text-color";
|
|
283
289
|
}
|
|
284
|
-
if (
|
|
285
|
-
const suffix =
|
|
290
|
+
if (b.startsWith("font-")) {
|
|
291
|
+
const suffix = b.slice("font-".length);
|
|
286
292
|
if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
|
|
287
293
|
return "font-family";
|
|
288
294
|
}
|
|
289
|
-
if (
|
|
290
|
-
if (
|
|
291
|
-
if (
|
|
292
|
-
const suffix =
|
|
295
|
+
if (b.startsWith("leading-")) return "leading";
|
|
296
|
+
if (b.startsWith("tracking-")) return "tracking";
|
|
297
|
+
if (b.startsWith("border-")) {
|
|
298
|
+
const suffix = b.slice("border-".length);
|
|
293
299
|
const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
|
|
294
300
|
if (sidePrefix) {
|
|
295
301
|
const side = suffix.slice(0, 1);
|
|
@@ -303,67 +309,67 @@ function conflictGroup(base) {
|
|
|
303
309
|
if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
|
|
304
310
|
return "border-color";
|
|
305
311
|
}
|
|
306
|
-
if (
|
|
307
|
-
if (
|
|
308
|
-
if (
|
|
309
|
-
if (
|
|
310
|
-
const firstChar =
|
|
312
|
+
if (b === "border") return "border-width";
|
|
313
|
+
if (b.startsWith("outline-")) return "outline";
|
|
314
|
+
if (b === "outline") return "outline";
|
|
315
|
+
if (b.startsWith("rounded-t") || b.startsWith("rounded-r") || b.startsWith("rounded-b") || b.startsWith("rounded-l") || b.startsWith("rounded-s") || b.startsWith("rounded-e")) {
|
|
316
|
+
const firstChar = b.slice("rounded-".length).charAt(0) || "x";
|
|
311
317
|
return `rounded-${firstChar}`;
|
|
312
318
|
}
|
|
313
|
-
if (
|
|
314
|
-
if (
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
317
|
-
if (
|
|
318
|
-
const rest =
|
|
319
|
+
if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
|
|
320
|
+
if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
|
|
321
|
+
if (b.startsWith("ring-offset-")) return "ring-offset";
|
|
322
|
+
if (b === "ring") return "ring-width";
|
|
323
|
+
if (b.startsWith("ring-")) {
|
|
324
|
+
const rest = b.slice("ring-".length);
|
|
319
325
|
const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
|
|
320
326
|
if (isWidth) return "ring-width";
|
|
321
327
|
if (rest === "inset") return "ring-inset";
|
|
322
328
|
return "ring-color";
|
|
323
329
|
}
|
|
324
|
-
if (
|
|
325
|
-
if (
|
|
326
|
-
if (
|
|
327
|
-
if (
|
|
328
|
-
if (
|
|
329
|
-
if (
|
|
330
|
-
if (
|
|
331
|
-
if (
|
|
332
|
-
if (
|
|
333
|
-
if (
|
|
334
|
-
if (
|
|
335
|
-
if (
|
|
336
|
-
if (
|
|
337
|
-
if (
|
|
338
|
-
if (
|
|
339
|
-
if (
|
|
340
|
-
if (
|
|
341
|
-
if (
|
|
342
|
-
if (
|
|
343
|
-
if (
|
|
344
|
-
if (
|
|
345
|
-
if (
|
|
346
|
-
if (
|
|
347
|
-
if (
|
|
348
|
-
if (
|
|
349
|
-
const rest =
|
|
330
|
+
if (b.startsWith("rotate-")) return "rotate";
|
|
331
|
+
if (b.startsWith("scale-x-")) return "scale-x";
|
|
332
|
+
if (b.startsWith("scale-y-")) return "scale-y";
|
|
333
|
+
if (b.startsWith("scale-")) return "scale";
|
|
334
|
+
if (b.startsWith("translate-x-")) return "translate-x";
|
|
335
|
+
if (b.startsWith("translate-y-")) return "translate-y";
|
|
336
|
+
if (b.startsWith("skew-x-")) return "skew-x";
|
|
337
|
+
if (b.startsWith("skew-y-")) return "skew-y";
|
|
338
|
+
if (b === "transition" || b.startsWith("transition-")) return "transition";
|
|
339
|
+
if (b.startsWith("duration-")) return "duration";
|
|
340
|
+
if (b.startsWith("ease-")) return "ease";
|
|
341
|
+
if (b.startsWith("delay-")) return "delay";
|
|
342
|
+
if (b === "animate" || b.startsWith("animate-")) return "animate";
|
|
343
|
+
if (b.startsWith("cursor-")) return "cursor";
|
|
344
|
+
if (b.startsWith("pointer-events-")) return "pointer-events";
|
|
345
|
+
if (b.startsWith("select-")) return "select";
|
|
346
|
+
if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
|
|
347
|
+
if (b.startsWith("object-")) return "object";
|
|
348
|
+
if (b.startsWith("aspect-")) return "aspect";
|
|
349
|
+
if (b.startsWith("order-")) return "order";
|
|
350
|
+
if (b.startsWith("whitespace-")) return "whitespace";
|
|
351
|
+
if (b.startsWith("list-")) return "list";
|
|
352
|
+
if (b.startsWith("fill-")) return "fill";
|
|
353
|
+
if (b.startsWith("stroke-")) return "stroke";
|
|
354
|
+
if (b.startsWith("backdrop-")) {
|
|
355
|
+
const rest = b.slice("backdrop-".length);
|
|
350
356
|
const seg = rest.split("-")[0] || "x";
|
|
351
357
|
return `backdrop-${seg}`;
|
|
352
358
|
}
|
|
353
|
-
if (
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
357
|
-
if (
|
|
358
|
-
if (
|
|
359
|
-
if (
|
|
360
|
-
if (
|
|
361
|
-
if (
|
|
362
|
-
if (
|
|
363
|
-
if (
|
|
364
|
-
if (
|
|
365
|
-
if (
|
|
366
|
-
if (
|
|
359
|
+
if (b.startsWith("scroll-")) return "scroll";
|
|
360
|
+
if (b.startsWith("snap-")) return "snap";
|
|
361
|
+
if (b.startsWith("touch-")) return "touch";
|
|
362
|
+
if (b.startsWith("decoration-")) return "text-decoration";
|
|
363
|
+
if (b.startsWith("caret-")) return "caret";
|
|
364
|
+
if (b.startsWith("accent-")) return "accent";
|
|
365
|
+
if (b.startsWith("appearance-")) return "appearance";
|
|
366
|
+
if (b === "isolate" || b === "isolation-auto") return "isolation";
|
|
367
|
+
if (b.startsWith("mix-blend-")) return "mix-blend";
|
|
368
|
+
if (b.startsWith("bg-blend-")) return "bg-blend";
|
|
369
|
+
if (b.startsWith("float-")) return "float";
|
|
370
|
+
if (b.startsWith("clear-")) return "clear";
|
|
371
|
+
if (b.startsWith("break-")) return "break";
|
|
372
|
+
if (b.startsWith("columns-")) return "columns";
|
|
367
373
|
return null;
|
|
368
374
|
}
|
|
369
375
|
function splitVariants(klass) {
|
|
@@ -378,7 +384,7 @@ function splitVariants(klass) {
|
|
|
378
384
|
if (lastColon === 0) return ["", klass];
|
|
379
385
|
return [klass.slice(0, lastColon), klass.slice(lastColon)];
|
|
380
386
|
}
|
|
381
|
-
function mergeClassStringJs(input) {
|
|
387
|
+
function mergeClassStringJs(input, prefix = "") {
|
|
382
388
|
const tokens = input.split(/\s+/).filter(Boolean);
|
|
383
389
|
if (tokens.length === 0) return "";
|
|
384
390
|
if (tokens.length === 1) return tokens[0];
|
|
@@ -386,7 +392,7 @@ function mergeClassStringJs(input) {
|
|
|
386
392
|
const slots = [];
|
|
387
393
|
for (const token of tokens) {
|
|
388
394
|
const [variants, base] = splitVariants(token);
|
|
389
|
-
const group = conflictGroup(base);
|
|
395
|
+
const group = conflictGroup(base, prefix);
|
|
390
396
|
if (group !== null) {
|
|
391
397
|
const key = `${variants}::${group}`;
|
|
392
398
|
const prevIdx = groupOwner.get(key);
|
|
@@ -399,10 +405,10 @@ function mergeClassStringJs(input) {
|
|
|
399
405
|
}
|
|
400
406
|
return slots.filter((s) => s !== null).join(" ");
|
|
401
407
|
}
|
|
402
|
-
function twMergeRawJs(classLists) {
|
|
408
|
+
function twMergeRawJs(classLists, prefix = "") {
|
|
403
409
|
const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
|
|
404
410
|
if (joined.length === 0) return "";
|
|
405
|
-
return mergeClassStringJs(joined);
|
|
411
|
+
return mergeClassStringJs(joined, prefix);
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
// packages/domain/core/src/merge.ts
|
|
@@ -417,6 +423,7 @@ function warnFallbackOnce() {
|
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
425
|
function createTwMerge(options = {}) {
|
|
426
|
+
const prefix = options.prefix ?? "";
|
|
420
427
|
return function twMerge2(...classLists) {
|
|
421
428
|
const inputs = [];
|
|
422
429
|
for (let i = 0; i < classLists.length; i++) {
|
|
@@ -425,11 +432,16 @@ function createTwMerge(options = {}) {
|
|
|
425
432
|
}
|
|
426
433
|
if (inputs.length === 0) return "";
|
|
427
434
|
const native = getNativeBinding();
|
|
428
|
-
if (native
|
|
429
|
-
|
|
435
|
+
if (native) {
|
|
436
|
+
if (prefix && native.twMergeRawWithOptions) {
|
|
437
|
+
return native.twMergeRawWithOptions(inputs, { prefix });
|
|
438
|
+
}
|
|
439
|
+
if (native.twMergeRaw) {
|
|
440
|
+
return native.twMergeRaw(inputs);
|
|
441
|
+
}
|
|
430
442
|
}
|
|
431
443
|
warnFallbackOnce();
|
|
432
|
-
return twMergeRawJs(inputs);
|
|
444
|
+
return twMergeRawJs(inputs, prefix);
|
|
433
445
|
};
|
|
434
446
|
}
|
|
435
447
|
var twMerge = createTwMerge();
|
|
@@ -442,28 +454,63 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
442
454
|
return classes.join(" ");
|
|
443
455
|
}
|
|
444
456
|
|
|
457
|
+
// packages/domain/core/src/parseTemplateFallback.ts
|
|
458
|
+
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
459
|
+
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
460
|
+
function collapseSpaces(s) {
|
|
461
|
+
return s.replace(/\s+/g, " ").trim();
|
|
462
|
+
}
|
|
463
|
+
function cleanBlock(raw) {
|
|
464
|
+
const noComments = raw.replace(COMMENT_RE, "");
|
|
465
|
+
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
466
|
+
return collapseSpaces(lines.join(" "));
|
|
467
|
+
}
|
|
468
|
+
function parseTemplateJs(raw) {
|
|
469
|
+
const subs = {};
|
|
470
|
+
let base = raw;
|
|
471
|
+
for (const match of raw.matchAll(SUB_RE)) {
|
|
472
|
+
const fullMatch = match[0];
|
|
473
|
+
const name = match[1] ?? match[2] ?? "";
|
|
474
|
+
const innerRaw = match[3] ?? "";
|
|
475
|
+
if (name) {
|
|
476
|
+
subs[name] = cleanBlock(innerRaw);
|
|
477
|
+
}
|
|
478
|
+
base = base.replace(fullMatch, "");
|
|
479
|
+
}
|
|
480
|
+
return {
|
|
481
|
+
base: collapseSpaces(base),
|
|
482
|
+
subs,
|
|
483
|
+
hasSubs: Object.keys(subs).length > 0
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
445
487
|
// packages/domain/core/src/stateEngine.ts
|
|
446
488
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
447
489
|
if (typeof window !== "undefined") {
|
|
448
490
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
449
491
|
}
|
|
450
492
|
var _hashStateCache = /* @__PURE__ */ new Map();
|
|
493
|
+
function _fnvHash62(s) {
|
|
494
|
+
let h = 2166136261;
|
|
495
|
+
for (let i = 0; i < s.length; i++) {
|
|
496
|
+
h ^= s.charCodeAt(i);
|
|
497
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
498
|
+
}
|
|
499
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
500
|
+
}
|
|
451
501
|
function hashState(tag, state) {
|
|
452
502
|
const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
|
|
453
503
|
const cached = _hashStateCache.get(sortedKey);
|
|
454
504
|
if (cached) return cached;
|
|
455
505
|
const native = getNativeBinding();
|
|
456
|
-
|
|
457
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
458
|
-
}
|
|
459
|
-
const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
506
|
+
const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
|
|
460
507
|
_hashStateCache.set(sortedKey, id);
|
|
461
508
|
return id;
|
|
462
509
|
}
|
|
463
510
|
function generateStateRules(id, state) {
|
|
464
511
|
const native = getNativeBinding();
|
|
465
512
|
if (!native?.generateRuntimeStateCss) {
|
|
466
|
-
|
|
513
|
+
return [];
|
|
467
514
|
}
|
|
468
515
|
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
469
516
|
}
|
|
@@ -551,7 +598,13 @@ function _getParsedTemplate(template) {
|
|
|
551
598
|
}
|
|
552
599
|
const native = getNativeBinding();
|
|
553
600
|
if (!native?.parseSubcomponentBlocksNapi) {
|
|
554
|
-
|
|
601
|
+
const fb = parseTemplateJs(template);
|
|
602
|
+
const result2 = {
|
|
603
|
+
baseClasses: fb.base,
|
|
604
|
+
subMap: new Map(Object.entries(fb.subs))
|
|
605
|
+
};
|
|
606
|
+
_templateParseCache.set(template, result2);
|
|
607
|
+
return result2;
|
|
555
608
|
}
|
|
556
609
|
const r = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
557
610
|
const raw = JSON.parse(r.subMapJson);
|
|
@@ -703,10 +756,16 @@ function resolveVariants(variants, props, defaults) {
|
|
|
703
756
|
}
|
|
704
757
|
const binding = getNativeBinding();
|
|
705
758
|
if (!binding?.resolveSimpleVariants) {
|
|
706
|
-
|
|
759
|
+
const classes = [];
|
|
760
|
+
for (const key of Object.keys(variants)) {
|
|
761
|
+
const propValue = cleanProps[key] ?? defaults[key];
|
|
762
|
+
if (propValue !== void 0 && variants[key]?.[propValue]) {
|
|
763
|
+
classes.push(variants[key][propValue]);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
return classes.join(" ").trim().replace(/\s+/g, " ");
|
|
707
767
|
}
|
|
708
|
-
|
|
709
|
-
return result.trim().replace(/\s+/g, " ");
|
|
768
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
|
|
710
769
|
}
|
|
711
770
|
function resolveStates(statesConfig, stateKeys, statesLookup, props) {
|
|
712
771
|
if (statesLookup && stateKeys.length > 0) {
|
|
@@ -930,7 +989,10 @@ function parseTemplate(strings, exprs) {
|
|
|
930
989
|
if (cached) return cached;
|
|
931
990
|
const binding = getNativeBinding();
|
|
932
991
|
if (!binding?.parseTemplate) {
|
|
933
|
-
|
|
992
|
+
const fb = parseTemplateJs(raw);
|
|
993
|
+
const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
|
|
994
|
+
_parsedTemplateCache.set(raw, result2);
|
|
995
|
+
return result2;
|
|
934
996
|
}
|
|
935
997
|
const r = binding.parseTemplate(raw);
|
|
936
998
|
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
@@ -1245,19 +1307,25 @@ function cn(...inputs) {
|
|
|
1245
1307
|
}
|
|
1246
1308
|
if (strings.length === 0) return "";
|
|
1247
1309
|
const native = getNativeBinding();
|
|
1248
|
-
if (
|
|
1310
|
+
if (native?.resolveClassNames) {
|
|
1311
|
+
return native.resolveClassNames(strings);
|
|
1312
|
+
}
|
|
1313
|
+
if (native !== null) {
|
|
1249
1314
|
throw new Error("Native binding 'resolveClassNames' is required but not available.");
|
|
1250
1315
|
}
|
|
1251
|
-
return
|
|
1316
|
+
return strings.filter(Boolean).join(" ");
|
|
1252
1317
|
}
|
|
1253
1318
|
function cx(...inputs) {
|
|
1254
1319
|
const filtered = inputs.flat().filter(Boolean);
|
|
1255
1320
|
if (filtered.length === 0) return "";
|
|
1256
1321
|
const native = getNativeBinding();
|
|
1257
|
-
if (
|
|
1322
|
+
if (native?.twMergeMany) {
|
|
1323
|
+
return native.twMergeMany(filtered);
|
|
1324
|
+
}
|
|
1325
|
+
if (native !== null) {
|
|
1258
1326
|
throw new Error("Native binding 'twMergeMany' is required but not available.");
|
|
1259
1327
|
}
|
|
1260
|
-
return
|
|
1328
|
+
return twMergeRawJs(filtered);
|
|
1261
1329
|
}
|
|
1262
1330
|
var cxm = cx;
|
|
1263
1331
|
|