tailwind-styled-v4 5.1.10 → 5.1.12

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.d.mts CHANGED
@@ -288,15 +288,45 @@ interface ThemeConfig$1 {
288
288
 
289
289
  /**
290
290
  * tailwind-styled-v4 — createTwMerge()
291
- * Pure Node.js — requires native Rust binding.
291
+ *
292
+ * Native Rust binding (twMergeRaw) is used when available (Node.js, build
293
+ * time, SSR) for maximum performance/parity with the rest of the pipeline.
294
+ *
295
+ * Browser fallback (Bug C — "Uncaught Error: Native binding 'twMergeRaw' is
296
+ * required but not available." crashing in the browser):
297
+ *
298
+ * createComponent.ts calls twMerge() unconditionally inside the React render
299
+ * function for EVERY tw.* component, on EVERY render — including the very
300
+ * first client-side render of any component that runs/re-renders in the
301
+ * browser. A `.node` native addon can never load inside a browser JS engine,
302
+ * so this isn't a rare edge case, it's unconditional: any tw.* component
303
+ * rendering client-side needs a working fallback path.
304
+ *
305
+ * getNativeBinding() returns `null` (not a throw) when running in the
306
+ * browser — see native.ts. When that happens we use mergeFallback.ts, a
307
+ * hand-written pure-TS port of the SAME algorithm as `tw_merge_raw` in
308
+ * tw_merge.rs (conflict_group / split_variants / merge_class_string),
309
+ * instead of the third-party `tailwind-merge` package. This keeps merge
310
+ * behavior defined by one algorithm — ours — rather than risking the
311
+ * browser and the server silently disagreeing on merged className output
312
+ * because two different implementations drifted apart. The cost: when
313
+ * tw_merge.rs's conflict_group() changes, mergeFallback.ts must be updated
314
+ * by hand to match (see comments there).
292
315
  */
293
316
 
294
317
  interface MergeOptions {
318
+ /**
319
+ * NOTE: not currently applied — matches the native path, which calls
320
+ * `native.twMergeRaw(inputs)` without ever forwarding a prefix either.
321
+ * Kept on the type for API stability; wire it through conflictGroup()
322
+ * in mergeFallback.ts (and tw_merge_raw on the Rust side) together if a
323
+ * custom Tailwind prefix needs to be supported correctly end-to-end.
324
+ */
295
325
  prefix?: string;
296
326
  separator?: string;
297
327
  theme?: ThemeConfig$1;
298
328
  }
299
- declare function createTwMerge(_options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
329
+ declare function createTwMerge(options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
300
330
  declare const twMerge: (...classLists: Array<string | undefined | null | false>) => string;
301
331
  declare function mergeWithRules(rules: Record<string, (classes: string[]) => string>, ...classLists: string[]): string;
302
332
 
package/dist/index.d.ts CHANGED
@@ -288,15 +288,45 @@ interface ThemeConfig$1 {
288
288
 
289
289
  /**
290
290
  * tailwind-styled-v4 — createTwMerge()
291
- * Pure Node.js — requires native Rust binding.
291
+ *
292
+ * Native Rust binding (twMergeRaw) is used when available (Node.js, build
293
+ * time, SSR) for maximum performance/parity with the rest of the pipeline.
294
+ *
295
+ * Browser fallback (Bug C — "Uncaught Error: Native binding 'twMergeRaw' is
296
+ * required but not available." crashing in the browser):
297
+ *
298
+ * createComponent.ts calls twMerge() unconditionally inside the React render
299
+ * function for EVERY tw.* component, on EVERY render — including the very
300
+ * first client-side render of any component that runs/re-renders in the
301
+ * browser. A `.node` native addon can never load inside a browser JS engine,
302
+ * so this isn't a rare edge case, it's unconditional: any tw.* component
303
+ * rendering client-side needs a working fallback path.
304
+ *
305
+ * getNativeBinding() returns `null` (not a throw) when running in the
306
+ * browser — see native.ts. When that happens we use mergeFallback.ts, a
307
+ * hand-written pure-TS port of the SAME algorithm as `tw_merge_raw` in
308
+ * tw_merge.rs (conflict_group / split_variants / merge_class_string),
309
+ * instead of the third-party `tailwind-merge` package. This keeps merge
310
+ * behavior defined by one algorithm — ours — rather than risking the
311
+ * browser and the server silently disagreeing on merged className output
312
+ * because two different implementations drifted apart. The cost: when
313
+ * tw_merge.rs's conflict_group() changes, mergeFallback.ts must be updated
314
+ * by hand to match (see comments there).
292
315
  */
293
316
 
294
317
  interface MergeOptions {
318
+ /**
319
+ * NOTE: not currently applied — matches the native path, which calls
320
+ * `native.twMergeRaw(inputs)` without ever forwarding a prefix either.
321
+ * Kept on the type for API stability; wire it through conflictGroup()
322
+ * in mergeFallback.ts (and tw_merge_raw on the Rust side) together if a
323
+ * custom Tailwind prefix needs to be supported correctly end-to-end.
324
+ */
295
325
  prefix?: string;
296
326
  separator?: string;
297
327
  theme?: ThemeConfig$1;
298
328
  }
299
- declare function createTwMerge(_options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
329
+ declare function createTwMerge(options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
300
330
  declare const twMerge: (...classLists: Array<string | undefined | null | false>) => string;
301
331
  declare function mergeWithRules(rules: Record<string, (classes: string[]) => string>, ...classLists: string[]): string;
302
332
 
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -247,7 +248,7 @@ var nativeBinding = null;
247
248
  var bindingLoadAttempted = false;
248
249
  var getBinding = () => {
249
250
  if (isBrowser2) {
250
- throw new Error(NATIVE_UNAVAILABLE_MESSAGE + "\n\nNative bindings are not available in browser. Use the compiled CSS output instead.");
251
+ return null;
251
252
  }
252
253
  if (nativeBinding) return nativeBinding;
253
254
  if (bindingLoadAttempted) {
@@ -255,10 +256,10 @@ var getBinding = () => {
255
256
  }
256
257
  bindingLoadAttempted = true;
257
258
  try {
258
- const runtimeDir = isBrowser2 ? "" : (0, import_node_path2.dirname)(
259
+ const runtimeDir = (0, import_node_path2.dirname)(
259
260
  typeof __filename !== "undefined" ? __filename : typeof import_meta2 !== "undefined" && importMetaUrl ? (0, import_node_url2.fileURLToPath)(importMetaUrl) : process.cwd()
260
261
  );
261
- const result = isBrowser2 ? { path: null, source: "not-found", platform: "browser", tried: [] } : resolveNativeBinary(runtimeDir);
262
+ const result = resolveNativeBinary(runtimeDir);
262
263
  if (result.path && result.path.endsWith(".node")) {
263
264
  const mod = _loadNative(result.path);
264
265
  if (mod?.batchSplitClasses) {
@@ -397,7 +398,291 @@ function getContainerRegistry() {
397
398
 
398
399
  // packages/domain/core/src/merge.ts
399
400
  init_cjs_shims();
400
- function createTwMerge(_options = {}) {
401
+
402
+ // packages/domain/core/src/mergeFallback.ts
403
+ init_cjs_shims();
404
+ var TEXT_SIZE_SUFFIXES = /* @__PURE__ */ new Set([
405
+ "xs",
406
+ "sm",
407
+ "base",
408
+ "lg",
409
+ "xl",
410
+ "2xl",
411
+ "3xl",
412
+ "4xl",
413
+ "5xl",
414
+ "6xl",
415
+ "7xl",
416
+ "8xl",
417
+ "9xl"
418
+ ]);
419
+ function isTextSize(suffix) {
420
+ if (TEXT_SIZE_SUFFIXES.has(suffix)) return true;
421
+ if (suffix.startsWith("[")) return true;
422
+ return false;
423
+ }
424
+ function isAsciiDigits(s) {
425
+ if (s.length === 0) return true;
426
+ for (let i = 0; i < s.length; i++) {
427
+ const code = s.charCodeAt(i);
428
+ if (code < 48 || code > 57) return false;
429
+ }
430
+ return true;
431
+ }
432
+ function isU32(s) {
433
+ return s.length > 0 && /^[0-9]+$/.test(s);
434
+ }
435
+ var DISPLAY_VALUES = /* @__PURE__ */ new Set([
436
+ "block",
437
+ "inline-block",
438
+ "inline",
439
+ "flex",
440
+ "inline-flex",
441
+ "grid",
442
+ "inline-grid",
443
+ "table",
444
+ "inline-table",
445
+ "table-row",
446
+ "table-cell",
447
+ "table-column",
448
+ "table-caption",
449
+ "contents",
450
+ "list-item",
451
+ "hidden",
452
+ "flow-root"
453
+ ]);
454
+ var POSITION_VALUES = /* @__PURE__ */ new Set(["static", "relative", "absolute", "fixed", "sticky"]);
455
+ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
456
+ "thin",
457
+ "extralight",
458
+ "light",
459
+ "normal",
460
+ "medium",
461
+ "semibold",
462
+ "bold",
463
+ "extrabold",
464
+ "black"
465
+ ]);
466
+ var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
467
+ var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
468
+ var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
469
+ function conflictGroup(base) {
470
+ const bracket = base.indexOf("[");
471
+ if (bracket !== -1) {
472
+ const prefix = base.slice(0, bracket).replace(/-+$/, "");
473
+ return prefix.length > 0 ? prefix : "arbitrary";
474
+ }
475
+ if (DISPLAY_VALUES.has(base)) return "display";
476
+ if (POSITION_VALUES.has(base)) return "position";
477
+ if (base.startsWith("overflow-x-")) return "overflow-x";
478
+ if (base.startsWith("overflow-y-")) return "overflow-y";
479
+ if (base.startsWith("overflow-")) return "overflow";
480
+ if (base.startsWith("flex-")) return "flex";
481
+ if (base.startsWith("grid-cols-")) return "grid-cols";
482
+ if (base.startsWith("grid-rows-")) return "grid-rows";
483
+ if (base.startsWith("grid-flow-")) return "grid-flow";
484
+ if (base.startsWith("col-")) return "col";
485
+ if (base.startsWith("row-")) return "row";
486
+ if (base === "grow" || base.startsWith("grow-")) return "grow";
487
+ if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
488
+ if (base.startsWith("gap-x-")) return "gap-x";
489
+ if (base.startsWith("gap-y-")) return "gap-y";
490
+ if (base.startsWith("gap-")) return "gap";
491
+ if (base.startsWith("justify-items-")) return "justify-items";
492
+ if (base.startsWith("justify-self-")) return "justify-self";
493
+ if (base.startsWith("justify-")) return "justify";
494
+ if (base.startsWith("items-")) return "items";
495
+ if (base.startsWith("self-")) return "self";
496
+ if (base.startsWith("place-content-")) return "place-content";
497
+ if (base.startsWith("place-items-")) return "place-items";
498
+ if (base.startsWith("place-self-")) return "place-self";
499
+ if (base.startsWith("content-")) return "content";
500
+ if (base.startsWith("px-")) return "px";
501
+ if (base.startsWith("py-")) return "py";
502
+ if (base.startsWith("pt-")) return "pt";
503
+ if (base.startsWith("pr-")) return "pr";
504
+ if (base.startsWith("pb-")) return "pb";
505
+ if (base.startsWith("pl-")) return "pl";
506
+ if (base.startsWith("ps-")) return "ps";
507
+ if (base.startsWith("pe-")) return "pe";
508
+ if (base.startsWith("p-")) return "p";
509
+ if (base.startsWith("mx-")) return "mx";
510
+ if (base.startsWith("my-")) return "my";
511
+ if (base.startsWith("mt-")) return "mt";
512
+ if (base.startsWith("mr-")) return "mr";
513
+ if (base.startsWith("mb-")) return "mb";
514
+ if (base.startsWith("ml-")) return "ml";
515
+ if (base.startsWith("ms-")) return "ms";
516
+ if (base.startsWith("me-")) return "me";
517
+ if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
518
+ if (base.startsWith("space-x-")) return "space-x";
519
+ if (base.startsWith("space-y-")) return "space-y";
520
+ if (base.startsWith("size-")) return "size";
521
+ if (base.startsWith("min-w-")) return "min-w";
522
+ if (base.startsWith("max-w-")) return "max-w";
523
+ if (base.startsWith("w-")) return "w";
524
+ if (base.startsWith("min-h-")) return "min-h";
525
+ if (base.startsWith("max-h-")) return "max-h";
526
+ if (base.startsWith("h-")) return "h";
527
+ if (base.startsWith("inset-x-")) return "inset-x";
528
+ if (base.startsWith("inset-y-")) return "inset-y";
529
+ if (base.startsWith("inset-")) return "inset";
530
+ if (base.startsWith("top-")) return "top";
531
+ if (base.startsWith("right-") || base.startsWith("end-")) return "right";
532
+ if (base.startsWith("bottom-")) return "bottom";
533
+ if (base.startsWith("left-") || base.startsWith("start-")) return "left";
534
+ if (base.startsWith("z-")) return "z";
535
+ if (base.startsWith("opacity-")) return "opacity";
536
+ if (base.startsWith("bg-")) {
537
+ if (base.startsWith("bg-opacity-")) return "bg-opacity";
538
+ return "bg";
539
+ }
540
+ if (base.startsWith("from-")) return "from";
541
+ if (base.startsWith("via-")) return "via";
542
+ if (base.startsWith("to-")) return "to";
543
+ if (base.startsWith("text-")) {
544
+ const suffix = base.slice("text-".length);
545
+ if (isTextSize(suffix)) return "text-size";
546
+ if (suffix.startsWith("opacity-")) return "text-opacity";
547
+ if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
548
+ return "text-color";
549
+ }
550
+ if (base.startsWith("font-")) {
551
+ const suffix = base.slice("font-".length);
552
+ if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
553
+ return "font-family";
554
+ }
555
+ if (base.startsWith("leading-")) return "leading";
556
+ if (base.startsWith("tracking-")) return "tracking";
557
+ if (base.startsWith("border-")) {
558
+ const suffix = base.slice("border-".length);
559
+ const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
560
+ if (sidePrefix) {
561
+ const side = suffix.slice(0, 1);
562
+ const rest = suffix.slice(2);
563
+ if (isU32(rest) || rest.length === 0) return `border-${side}-width`;
564
+ return `border-${side}-color`;
565
+ }
566
+ if (isU32(suffix) || suffix.length === 0) return "border-width";
567
+ if (suffix.startsWith("opacity-")) return "border-opacity";
568
+ if (suffix === "collapse" || suffix === "separate") return "border-collapse";
569
+ if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
570
+ return "border-color";
571
+ }
572
+ if (base === "border") return "border-width";
573
+ if (base.startsWith("outline-")) return "outline";
574
+ if (base === "outline") return "outline";
575
+ if (base.startsWith("rounded-t") || base.startsWith("rounded-r") || base.startsWith("rounded-b") || base.startsWith("rounded-l") || base.startsWith("rounded-s") || base.startsWith("rounded-e")) {
576
+ const firstChar = base.slice("rounded-".length).charAt(0) || "x";
577
+ return `rounded-${firstChar}`;
578
+ }
579
+ if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
580
+ if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
581
+ if (base.startsWith("ring-offset-")) return "ring-offset";
582
+ if (base === "ring") return "ring-width";
583
+ if (base.startsWith("ring-")) {
584
+ const rest = base.slice("ring-".length);
585
+ const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
586
+ if (isWidth) return "ring-width";
587
+ if (rest === "inset") return "ring-inset";
588
+ return "ring-color";
589
+ }
590
+ if (base.startsWith("rotate-")) return "rotate";
591
+ if (base.startsWith("scale-x-")) return "scale-x";
592
+ if (base.startsWith("scale-y-")) return "scale-y";
593
+ if (base.startsWith("scale-")) return "scale";
594
+ if (base.startsWith("translate-x-")) return "translate-x";
595
+ if (base.startsWith("translate-y-")) return "translate-y";
596
+ if (base.startsWith("skew-x-")) return "skew-x";
597
+ if (base.startsWith("skew-y-")) return "skew-y";
598
+ if (base === "transition" || base.startsWith("transition-")) return "transition";
599
+ if (base.startsWith("duration-")) return "duration";
600
+ if (base.startsWith("ease-")) return "ease";
601
+ if (base.startsWith("delay-")) return "delay";
602
+ if (base === "animate" || base.startsWith("animate-")) return "animate";
603
+ if (base.startsWith("cursor-")) return "cursor";
604
+ if (base.startsWith("pointer-events-")) return "pointer-events";
605
+ if (base.startsWith("select-")) return "select";
606
+ if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
607
+ if (base.startsWith("object-")) return "object";
608
+ if (base.startsWith("aspect-")) return "aspect";
609
+ if (base.startsWith("order-")) return "order";
610
+ if (base.startsWith("whitespace-")) return "whitespace";
611
+ if (base.startsWith("list-")) return "list";
612
+ if (base.startsWith("fill-")) return "fill";
613
+ if (base.startsWith("stroke-")) return "stroke";
614
+ if (base.startsWith("backdrop-")) {
615
+ const rest = base.slice("backdrop-".length);
616
+ const seg = rest.split("-")[0] || "x";
617
+ return `backdrop-${seg}`;
618
+ }
619
+ if (base.startsWith("scroll-")) return "scroll";
620
+ if (base.startsWith("snap-")) return "snap";
621
+ if (base.startsWith("touch-")) return "touch";
622
+ if (base.startsWith("decoration-")) return "text-decoration";
623
+ if (base.startsWith("caret-")) return "caret";
624
+ if (base.startsWith("accent-")) return "accent";
625
+ if (base.startsWith("appearance-")) return "appearance";
626
+ if (base === "isolate" || base === "isolation-auto") return "isolation";
627
+ if (base.startsWith("mix-blend-")) return "mix-blend";
628
+ if (base.startsWith("bg-blend-")) return "bg-blend";
629
+ if (base.startsWith("float-")) return "float";
630
+ if (base.startsWith("clear-")) return "clear";
631
+ if (base.startsWith("break-")) return "break";
632
+ if (base.startsWith("columns-")) return "columns";
633
+ return null;
634
+ }
635
+ function splitVariants(klass) {
636
+ let depth = 0;
637
+ let lastColon = 0;
638
+ for (let i = 0; i < klass.length; i++) {
639
+ const ch = klass.charCodeAt(i);
640
+ if (ch === 91) depth++;
641
+ else if (ch === 93) depth = depth > 0 ? depth - 1 : 0;
642
+ else if (ch === 58 && depth === 0) lastColon = i + 1;
643
+ }
644
+ if (lastColon === 0) return ["", klass];
645
+ return [klass.slice(0, lastColon), klass.slice(lastColon)];
646
+ }
647
+ function mergeClassStringJs(input) {
648
+ const tokens = input.split(/\s+/).filter(Boolean);
649
+ if (tokens.length === 0) return "";
650
+ if (tokens.length === 1) return tokens[0];
651
+ const groupOwner = /* @__PURE__ */ new Map();
652
+ const slots = [];
653
+ for (const token of tokens) {
654
+ const [variants, base] = splitVariants(token);
655
+ const group = conflictGroup(base);
656
+ if (group !== null) {
657
+ const key = `${variants}::${group}`;
658
+ const prevIdx = groupOwner.get(key);
659
+ if (prevIdx !== void 0) slots[prevIdx] = null;
660
+ groupOwner.set(key, slots.length);
661
+ slots.push(token);
662
+ } else {
663
+ slots.push(token);
664
+ }
665
+ }
666
+ return slots.filter((s) => s !== null).join(" ");
667
+ }
668
+ function twMergeRawJs(classLists) {
669
+ const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
670
+ if (joined.length === 0) return "";
671
+ return mergeClassStringJs(joined);
672
+ }
673
+
674
+ // packages/domain/core/src/merge.ts
675
+ var warnedFallback = false;
676
+ function warnFallbackOnce() {
677
+ if (warnedFallback) return;
678
+ warnedFallback = true;
679
+ if (typeof console !== "undefined") {
680
+ console.warn(
681
+ "[tailwind-styled-v4] Native binding 'twMergeRaw' tidak tersedia (normal di browser) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil className tetap benar; ini cuma informasi, bukan error."
682
+ );
683
+ }
684
+ }
685
+ function createTwMerge(options = {}) {
401
686
  return function twMerge2(...classLists) {
402
687
  const inputs = [];
403
688
  for (let i = 0; i < classLists.length; i++) {
@@ -406,10 +691,11 @@ function createTwMerge(_options = {}) {
406
691
  }
407
692
  if (inputs.length === 0) return "";
408
693
  const native = getNativeBinding();
409
- if (!native?.twMergeRaw) {
410
- throw new Error("Native binding 'twMergeRaw' is required but not available.");
694
+ if (native?.twMergeRaw) {
695
+ return native.twMergeRaw(inputs);
411
696
  }
412
- return native.twMergeRaw(inputs);
697
+ warnFallbackOnce();
698
+ return twMergeRawJs(inputs);
413
699
  };
414
700
  }
415
701
  var twMerge = createTwMerge();
@@ -899,8 +1185,49 @@ function wrapWithSubProxy(component, tagLabel) {
899
1185
  });
900
1186
  }
901
1187
 
1188
+ // packages/domain/core/src/parseTemplateFallback.ts
1189
+ init_cjs_shims();
1190
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
1191
+ var COMMENT_RE = /\/\/[^\n]*/g;
1192
+ function collapseSpaces(s) {
1193
+ return s.replace(/\s+/g, " ").trim();
1194
+ }
1195
+ function cleanBlock(raw) {
1196
+ const noComments = raw.replace(COMMENT_RE, "");
1197
+ const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
1198
+ return collapseSpaces(lines.join(" "));
1199
+ }
1200
+ function parseTemplateJs(raw) {
1201
+ const subs = {};
1202
+ let base = raw;
1203
+ for (const match of raw.matchAll(SUB_RE)) {
1204
+ const fullMatch = match[0];
1205
+ const name = match[1] ?? match[2] ?? "";
1206
+ const innerRaw = match[3] ?? "";
1207
+ if (name) {
1208
+ subs[name] = cleanBlock(innerRaw);
1209
+ }
1210
+ base = base.replace(fullMatch, "");
1211
+ }
1212
+ return {
1213
+ base: cleanBlock(base),
1214
+ subs,
1215
+ hasSubs: Object.keys(subs).length > 0
1216
+ };
1217
+ }
1218
+
902
1219
  // packages/domain/core/src/twProxy.ts
903
1220
  var _parsedTemplateCache = /* @__PURE__ */ new Map();
1221
+ var warnedParseTemplateFallback = false;
1222
+ function warnParseTemplateFallbackOnce() {
1223
+ if (warnedParseTemplateFallback) return;
1224
+ warnedParseTemplateFallback = true;
1225
+ if (typeof console !== "undefined") {
1226
+ console.warn(
1227
+ "[tailwind-styled-v4] Native binding 'parseTemplate' tidak tersedia (normal di browser, untuk komponen yang di-chain dengan .extend/.withVariants/.animate/.withSub) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil tetap benar; ini cuma informasi, bukan error."
1228
+ );
1229
+ }
1230
+ }
904
1231
  function parseTemplate(strings, exprs) {
905
1232
  const raw = strings.raw.reduce((acc, str, i) => {
906
1233
  const expr = exprs[i];
@@ -910,12 +1237,15 @@ function parseTemplate(strings, exprs) {
910
1237
  const cached = _parsedTemplateCache.get(raw);
911
1238
  if (cached) return cached;
912
1239
  const binding = getNativeBinding();
913
- if (!binding?.parseTemplate) {
914
- throw new Error("FATAL: Native binding 'parseTemplate' is required but not available.");
1240
+ let result;
1241
+ if (binding?.parseTemplate) {
1242
+ const r = binding.parseTemplate(raw);
1243
+ const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
1244
+ result = { base: r.base, subs, hasSubs: r.hasSubs };
1245
+ } else {
1246
+ warnParseTemplateFallbackOnce();
1247
+ result = parseTemplateJs(raw);
915
1248
  }
916
- const r = binding.parseTemplate(raw);
917
- const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
918
- const result = { base: r.base, subs, hasSubs: r.hasSubs };
919
1249
  _parsedTemplateCache.set(raw, result);
920
1250
  return result;
921
1251
  }