tailwind-styled-v4 5.0.7 → 5.0.8
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/cli.js +62 -52
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +62 -52
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +8 -3
- package/dist/compiler.d.ts +8 -3
- package/dist/compiler.js +214 -127
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +195 -103
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +146 -66
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +146 -66
- package/dist/engine.mjs.map +1 -1
- package/dist/next.d.mts +3 -37
- package/dist/next.d.ts +3 -37
- package/dist/next.js +14 -313
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +14 -313
- package/dist/next.mjs.map +1 -1
- package/dist/turbopackLoader.js +132 -86
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +132 -86
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +62 -52
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +62 -52
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +146 -66
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +146 -66
- package/dist/vite.mjs.map +1 -1
- package/dist/webpackLoader.js +88 -83
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +88 -83
- package/dist/webpackLoader.mjs.map +1 -1
- package/package.json +3 -3
package/dist/engine.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path3 from 'path';
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
|
-
import fs from 'fs';
|
|
4
3
|
import { createRequire } from 'module';
|
|
4
|
+
import fs from 'fs';
|
|
5
5
|
import { Worker } from 'worker_threads';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import 'perf_hooks';
|
|
@@ -590,6 +590,147 @@ var init_native_bridge = __esm({
|
|
|
590
590
|
resetScannerBridgeCache = scannerBridgeLoader.reset;
|
|
591
591
|
}
|
|
592
592
|
});
|
|
593
|
+
var log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
594
|
+
var init_nativeBridge = __esm({
|
|
595
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
596
|
+
init_src();
|
|
597
|
+
log3 = (...args) => {
|
|
598
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
599
|
+
console.log("[compiler:native]", ...args);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
|
|
603
|
+
nativeBridge = null;
|
|
604
|
+
bridgeLoadAttempted = false;
|
|
605
|
+
bridgeLoadError = null;
|
|
606
|
+
isValidNativeBridge = (mod) => {
|
|
607
|
+
const m = mod;
|
|
608
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
609
|
+
};
|
|
610
|
+
getNativeBridge = () => {
|
|
611
|
+
if (nativeBridge) {
|
|
612
|
+
return nativeBridge;
|
|
613
|
+
}
|
|
614
|
+
if (bridgeLoadAttempted) {
|
|
615
|
+
if (bridgeLoadError) {
|
|
616
|
+
throw bridgeLoadError;
|
|
617
|
+
}
|
|
618
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
619
|
+
}
|
|
620
|
+
bridgeLoadAttempted = true;
|
|
621
|
+
try {
|
|
622
|
+
const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
|
|
623
|
+
const require3 = createRequire(import.meta.url);
|
|
624
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
625
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
626
|
+
try {
|
|
627
|
+
const binding = require3(result.path);
|
|
628
|
+
if (isValidNativeBridge(binding)) {
|
|
629
|
+
nativeBridge = binding;
|
|
630
|
+
log3("Native bridge loaded successfully from:", result.path);
|
|
631
|
+
return nativeBridge;
|
|
632
|
+
}
|
|
633
|
+
} catch (e) {
|
|
634
|
+
log3("Failed to require native binding:", e);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
638
|
+
|
|
639
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
640
|
+
} catch (err) {
|
|
641
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
642
|
+
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
643
|
+
throw bridgeLoadError;
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
647
|
+
try {
|
|
648
|
+
getNativeBridge();
|
|
649
|
+
} catch {
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
656
|
+
var tailwindEngine_exports = {};
|
|
657
|
+
__export(tailwindEngine_exports, {
|
|
658
|
+
generateRawCss: () => generateRawCss,
|
|
659
|
+
runCssPipeline: () => runCssPipeline,
|
|
660
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
661
|
+
});
|
|
662
|
+
function loadTailwindEngine() {
|
|
663
|
+
if (_twEngine) return _twEngine;
|
|
664
|
+
if (_twEngineError) throw _twEngineError;
|
|
665
|
+
try {
|
|
666
|
+
const tw = require2("tailwindcss");
|
|
667
|
+
if (typeof tw.compile !== "function") {
|
|
668
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
669
|
+
}
|
|
670
|
+
_twEngine = tw;
|
|
671
|
+
return _twEngine;
|
|
672
|
+
} catch (e) {
|
|
673
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
674
|
+
throw _twEngineError;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function generateRawCss(classes) {
|
|
678
|
+
if (classes.length === 0) return "";
|
|
679
|
+
const tw = loadTailwindEngine();
|
|
680
|
+
const compiler = tw.compile("@import 'tailwindcss';");
|
|
681
|
+
return compiler.build(classes);
|
|
682
|
+
}
|
|
683
|
+
function postProcessWithLightning(rawCss) {
|
|
684
|
+
if (!rawCss) return "";
|
|
685
|
+
const native = getNativeBridge();
|
|
686
|
+
if (typeof native.processTailwindCssLightning === "function") {
|
|
687
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
688
|
+
return result?.css ?? rawCss;
|
|
689
|
+
}
|
|
690
|
+
console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
|
|
691
|
+
return rawCss;
|
|
692
|
+
}
|
|
693
|
+
async function runCssPipeline(classes) {
|
|
694
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
695
|
+
if (unique.length === 0) {
|
|
696
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
697
|
+
}
|
|
698
|
+
const rawCss = generateRawCss(unique);
|
|
699
|
+
const native = getNativeBridge();
|
|
700
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
701
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
702
|
+
return {
|
|
703
|
+
css: finalCss,
|
|
704
|
+
classes: unique,
|
|
705
|
+
sizeBytes: finalCss.length,
|
|
706
|
+
optimized: hasLightning
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function runCssPipelineSync(classes) {
|
|
710
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
711
|
+
if (unique.length === 0) {
|
|
712
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
713
|
+
}
|
|
714
|
+
const rawCss = generateRawCss(unique);
|
|
715
|
+
const native = getNativeBridge();
|
|
716
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
717
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
718
|
+
return {
|
|
719
|
+
css: finalCss,
|
|
720
|
+
classes: unique,
|
|
721
|
+
sizeBytes: finalCss.length,
|
|
722
|
+
optimized: hasLightning
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
var require2, _twEngine, _twEngineError;
|
|
726
|
+
var init_tailwindEngine = __esm({
|
|
727
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
728
|
+
init_nativeBridge();
|
|
729
|
+
require2 = createRequire(import.meta.url);
|
|
730
|
+
_twEngine = null;
|
|
731
|
+
_twEngineError = null;
|
|
732
|
+
}
|
|
733
|
+
});
|
|
593
734
|
|
|
594
735
|
// packages/domain/engine/src/ir.ts
|
|
595
736
|
function registerPropertyName(id, name) {
|
|
@@ -2577,73 +2718,12 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
2577
2718
|
};
|
|
2578
2719
|
}
|
|
2579
2720
|
|
|
2580
|
-
// packages/domain/compiler/src/nativeBridge.ts
|
|
2581
|
-
init_src();
|
|
2582
|
-
var log3 = (...args) => {
|
|
2583
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
2584
|
-
console.log("[compiler:native]", ...args);
|
|
2585
|
-
}
|
|
2586
|
-
};
|
|
2587
|
-
var NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
|
|
2588
|
-
var nativeBridge = null;
|
|
2589
|
-
var bridgeLoadAttempted = false;
|
|
2590
|
-
var bridgeLoadError = null;
|
|
2591
|
-
var isValidNativeBridge = (mod) => {
|
|
2592
|
-
const m = mod;
|
|
2593
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
2594
|
-
};
|
|
2595
|
-
var getNativeBridge = () => {
|
|
2596
|
-
if (nativeBridge) {
|
|
2597
|
-
return nativeBridge;
|
|
2598
|
-
}
|
|
2599
|
-
if (bridgeLoadAttempted) {
|
|
2600
|
-
if (bridgeLoadError) {
|
|
2601
|
-
throw bridgeLoadError;
|
|
2602
|
-
}
|
|
2603
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
2604
|
-
}
|
|
2605
|
-
bridgeLoadAttempted = true;
|
|
2606
|
-
try {
|
|
2607
|
-
const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
|
|
2608
|
-
const require2 = createRequire(import.meta.url);
|
|
2609
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
2610
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
2611
|
-
try {
|
|
2612
|
-
const binding = require2(result.path);
|
|
2613
|
-
if (isValidNativeBridge(binding)) {
|
|
2614
|
-
nativeBridge = binding;
|
|
2615
|
-
log3("Native bridge loaded successfully from:", result.path);
|
|
2616
|
-
return nativeBridge;
|
|
2617
|
-
}
|
|
2618
|
-
} catch (e) {
|
|
2619
|
-
log3("Failed to require native binding:", e);
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
2623
|
-
|
|
2624
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
2625
|
-
} catch (err) {
|
|
2626
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
2627
|
-
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
2628
|
-
throw bridgeLoadError;
|
|
2629
|
-
}
|
|
2630
|
-
};
|
|
2631
|
-
|
|
2632
2721
|
// packages/domain/compiler/src/index.ts
|
|
2633
|
-
|
|
2634
|
-
const native = getNativeBridge();
|
|
2635
|
-
if (!native?.transformSource) {
|
|
2636
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2637
|
-
}
|
|
2638
|
-
const result = native.transformSource(classes.join(" "), { prefix: "" });
|
|
2639
|
-
if (!result) {
|
|
2640
|
-
throw new Error("FATAL: transformSource returned null");
|
|
2641
|
-
}
|
|
2642
|
-
return result;
|
|
2643
|
-
};
|
|
2722
|
+
init_nativeBridge();
|
|
2644
2723
|
var generateCssForClasses = async (classes, _tailwindConfig, _root) => {
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2724
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2725
|
+
const result = await runCssPipeline2(classes);
|
|
2726
|
+
return result.css;
|
|
2647
2727
|
};
|
|
2648
2728
|
var mergeClassesStatic = (classes) => {
|
|
2649
2729
|
const result = normalizeAndDedupClasses(classes);
|