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.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var path3 = require('path');
|
|
4
4
|
var url = require('url');
|
|
5
|
-
var fs = require('fs');
|
|
6
5
|
var module$1 = require('module');
|
|
6
|
+
var fs = require('fs');
|
|
7
7
|
var worker_threads = require('worker_threads');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
require('perf_hooks');
|
|
@@ -598,6 +598,147 @@ var init_native_bridge = __esm({
|
|
|
598
598
|
resetScannerBridgeCache = scannerBridgeLoader.reset;
|
|
599
599
|
}
|
|
600
600
|
});
|
|
601
|
+
var log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
602
|
+
var init_nativeBridge = __esm({
|
|
603
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
604
|
+
init_src();
|
|
605
|
+
log3 = (...args) => {
|
|
606
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
607
|
+
console.log("[compiler:native]", ...args);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
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";
|
|
611
|
+
nativeBridge = null;
|
|
612
|
+
bridgeLoadAttempted = false;
|
|
613
|
+
bridgeLoadError = null;
|
|
614
|
+
isValidNativeBridge = (mod) => {
|
|
615
|
+
const m = mod;
|
|
616
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
617
|
+
};
|
|
618
|
+
getNativeBridge = () => {
|
|
619
|
+
if (nativeBridge) {
|
|
620
|
+
return nativeBridge;
|
|
621
|
+
}
|
|
622
|
+
if (bridgeLoadAttempted) {
|
|
623
|
+
if (bridgeLoadError) {
|
|
624
|
+
throw bridgeLoadError;
|
|
625
|
+
}
|
|
626
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
627
|
+
}
|
|
628
|
+
bridgeLoadAttempted = true;
|
|
629
|
+
try {
|
|
630
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
631
|
+
const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
632
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
633
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
634
|
+
try {
|
|
635
|
+
const binding = require3(result.path);
|
|
636
|
+
if (isValidNativeBridge(binding)) {
|
|
637
|
+
nativeBridge = binding;
|
|
638
|
+
log3("Native bridge loaded successfully from:", result.path);
|
|
639
|
+
return nativeBridge;
|
|
640
|
+
}
|
|
641
|
+
} catch (e) {
|
|
642
|
+
log3("Failed to require native binding:", e);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
646
|
+
|
|
647
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
648
|
+
} catch (err) {
|
|
649
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
650
|
+
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
651
|
+
throw bridgeLoadError;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
655
|
+
try {
|
|
656
|
+
getNativeBridge();
|
|
657
|
+
} catch {
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
664
|
+
var tailwindEngine_exports = {};
|
|
665
|
+
__export(tailwindEngine_exports, {
|
|
666
|
+
generateRawCss: () => generateRawCss,
|
|
667
|
+
runCssPipeline: () => runCssPipeline,
|
|
668
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
669
|
+
});
|
|
670
|
+
function loadTailwindEngine() {
|
|
671
|
+
if (_twEngine) return _twEngine;
|
|
672
|
+
if (_twEngineError) throw _twEngineError;
|
|
673
|
+
try {
|
|
674
|
+
const tw = require2("tailwindcss");
|
|
675
|
+
if (typeof tw.compile !== "function") {
|
|
676
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
677
|
+
}
|
|
678
|
+
_twEngine = tw;
|
|
679
|
+
return _twEngine;
|
|
680
|
+
} catch (e) {
|
|
681
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
682
|
+
throw _twEngineError;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function generateRawCss(classes) {
|
|
686
|
+
if (classes.length === 0) return "";
|
|
687
|
+
const tw = loadTailwindEngine();
|
|
688
|
+
const compiler = tw.compile("@import 'tailwindcss';");
|
|
689
|
+
return compiler.build(classes);
|
|
690
|
+
}
|
|
691
|
+
function postProcessWithLightning(rawCss) {
|
|
692
|
+
if (!rawCss) return "";
|
|
693
|
+
const native = getNativeBridge();
|
|
694
|
+
if (typeof native.processTailwindCssLightning === "function") {
|
|
695
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
696
|
+
return result?.css ?? rawCss;
|
|
697
|
+
}
|
|
698
|
+
console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
|
|
699
|
+
return rawCss;
|
|
700
|
+
}
|
|
701
|
+
async function runCssPipeline(classes) {
|
|
702
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
703
|
+
if (unique.length === 0) {
|
|
704
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
705
|
+
}
|
|
706
|
+
const rawCss = generateRawCss(unique);
|
|
707
|
+
const native = getNativeBridge();
|
|
708
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
709
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
710
|
+
return {
|
|
711
|
+
css: finalCss,
|
|
712
|
+
classes: unique,
|
|
713
|
+
sizeBytes: finalCss.length,
|
|
714
|
+
optimized: hasLightning
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function runCssPipelineSync(classes) {
|
|
718
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
719
|
+
if (unique.length === 0) {
|
|
720
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
721
|
+
}
|
|
722
|
+
const rawCss = generateRawCss(unique);
|
|
723
|
+
const native = getNativeBridge();
|
|
724
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
725
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
726
|
+
return {
|
|
727
|
+
css: finalCss,
|
|
728
|
+
classes: unique,
|
|
729
|
+
sizeBytes: finalCss.length,
|
|
730
|
+
optimized: hasLightning
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
var require2, _twEngine, _twEngineError;
|
|
734
|
+
var init_tailwindEngine = __esm({
|
|
735
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
736
|
+
init_nativeBridge();
|
|
737
|
+
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
738
|
+
_twEngine = null;
|
|
739
|
+
_twEngineError = null;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
601
742
|
|
|
602
743
|
// packages/domain/engine/src/ir.ts
|
|
603
744
|
function registerPropertyName(id, name) {
|
|
@@ -2585,73 +2726,12 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
2585
2726
|
};
|
|
2586
2727
|
}
|
|
2587
2728
|
|
|
2588
|
-
// packages/domain/compiler/src/nativeBridge.ts
|
|
2589
|
-
init_src();
|
|
2590
|
-
var log3 = (...args) => {
|
|
2591
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
2592
|
-
console.log("[compiler:native]", ...args);
|
|
2593
|
-
}
|
|
2594
|
-
};
|
|
2595
|
-
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";
|
|
2596
|
-
var nativeBridge = null;
|
|
2597
|
-
var bridgeLoadAttempted = false;
|
|
2598
|
-
var bridgeLoadError = null;
|
|
2599
|
-
var isValidNativeBridge = (mod) => {
|
|
2600
|
-
const m = mod;
|
|
2601
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
2602
|
-
};
|
|
2603
|
-
var getNativeBridge = () => {
|
|
2604
|
-
if (nativeBridge) {
|
|
2605
|
-
return nativeBridge;
|
|
2606
|
-
}
|
|
2607
|
-
if (bridgeLoadAttempted) {
|
|
2608
|
-
if (bridgeLoadError) {
|
|
2609
|
-
throw bridgeLoadError;
|
|
2610
|
-
}
|
|
2611
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
2612
|
-
}
|
|
2613
|
-
bridgeLoadAttempted = true;
|
|
2614
|
-
try {
|
|
2615
|
-
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
2616
|
-
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
2617
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
2618
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
2619
|
-
try {
|
|
2620
|
-
const binding = require2(result.path);
|
|
2621
|
-
if (isValidNativeBridge(binding)) {
|
|
2622
|
-
nativeBridge = binding;
|
|
2623
|
-
log3("Native bridge loaded successfully from:", result.path);
|
|
2624
|
-
return nativeBridge;
|
|
2625
|
-
}
|
|
2626
|
-
} catch (e) {
|
|
2627
|
-
log3("Failed to require native binding:", e);
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
2631
|
-
|
|
2632
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
2633
|
-
} catch (err) {
|
|
2634
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
2635
|
-
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
2636
|
-
throw bridgeLoadError;
|
|
2637
|
-
}
|
|
2638
|
-
};
|
|
2639
|
-
|
|
2640
2729
|
// packages/domain/compiler/src/index.ts
|
|
2641
|
-
|
|
2642
|
-
const native = getNativeBridge();
|
|
2643
|
-
if (!native?.transformSource) {
|
|
2644
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2645
|
-
}
|
|
2646
|
-
const result = native.transformSource(classes.join(" "), { prefix: "" });
|
|
2647
|
-
if (!result) {
|
|
2648
|
-
throw new Error("FATAL: transformSource returned null");
|
|
2649
|
-
}
|
|
2650
|
-
return result;
|
|
2651
|
-
};
|
|
2730
|
+
init_nativeBridge();
|
|
2652
2731
|
var generateCssForClasses = async (classes, _tailwindConfig, _root) => {
|
|
2653
|
-
const
|
|
2654
|
-
|
|
2732
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2733
|
+
const result = await runCssPipeline2(classes);
|
|
2734
|
+
return result.css;
|
|
2655
2735
|
};
|
|
2656
2736
|
var mergeClassesStatic = (classes) => {
|
|
2657
2737
|
const result = normalizeAndDedupClasses(classes);
|