tailwind-styled-v4 5.0.7 → 5.0.9
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/CHANGELOG.md +184 -410
- package/README.md +45 -15
- 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/index.d.mts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +72 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -19
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +12 -40
- package/dist/next.d.ts +12 -40
- package/dist/next.js +27 -320
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +27 -320
- package/dist/next.mjs.map +1 -1
- package/dist/turbopackLoader.js +137 -88
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +137 -88
- 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 +92 -83
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +92 -83
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +3 -3
package/dist/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var module$1 = require('module');
|
|
3
4
|
var path3 = require('path');
|
|
4
5
|
var url = require('url');
|
|
5
6
|
var fs = require('fs');
|
|
6
|
-
var module$1 = require('module');
|
|
7
7
|
var worker_threads = require('worker_threads');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
require('perf_hooks');
|
|
@@ -415,6 +415,147 @@ var init_src = __esm({
|
|
|
415
415
|
_require2 = getRequire2();
|
|
416
416
|
}
|
|
417
417
|
});
|
|
418
|
+
var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
419
|
+
var init_nativeBridge = __esm({
|
|
420
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
421
|
+
init_src();
|
|
422
|
+
log = (...args) => {
|
|
423
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
424
|
+
console.log("[compiler:native]", ...args);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
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";
|
|
428
|
+
nativeBridge = null;
|
|
429
|
+
bridgeLoadAttempted = false;
|
|
430
|
+
bridgeLoadError = null;
|
|
431
|
+
isValidNativeBridge = (mod) => {
|
|
432
|
+
const m = mod;
|
|
433
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
434
|
+
};
|
|
435
|
+
getNativeBridge = () => {
|
|
436
|
+
if (nativeBridge) {
|
|
437
|
+
return nativeBridge;
|
|
438
|
+
}
|
|
439
|
+
if (bridgeLoadAttempted) {
|
|
440
|
+
if (bridgeLoadError) {
|
|
441
|
+
throw bridgeLoadError;
|
|
442
|
+
}
|
|
443
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
444
|
+
}
|
|
445
|
+
bridgeLoadAttempted = true;
|
|
446
|
+
try {
|
|
447
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
448
|
+
const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
449
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
450
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
451
|
+
try {
|
|
452
|
+
const binding = require3(result.path);
|
|
453
|
+
if (isValidNativeBridge(binding)) {
|
|
454
|
+
nativeBridge = binding;
|
|
455
|
+
log("Native bridge loaded successfully from:", result.path);
|
|
456
|
+
return nativeBridge;
|
|
457
|
+
}
|
|
458
|
+
} catch (e) {
|
|
459
|
+
log("Failed to require native binding:", e);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
463
|
+
|
|
464
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
465
|
+
} catch (err) {
|
|
466
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
467
|
+
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
468
|
+
throw bridgeLoadError;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
472
|
+
try {
|
|
473
|
+
getNativeBridge();
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
481
|
+
var tailwindEngine_exports = {};
|
|
482
|
+
__export(tailwindEngine_exports, {
|
|
483
|
+
generateRawCss: () => generateRawCss,
|
|
484
|
+
runCssPipeline: () => runCssPipeline,
|
|
485
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
486
|
+
});
|
|
487
|
+
function loadTailwindEngine() {
|
|
488
|
+
if (_twEngine) return _twEngine;
|
|
489
|
+
if (_twEngineError) throw _twEngineError;
|
|
490
|
+
try {
|
|
491
|
+
const tw = require2("tailwindcss");
|
|
492
|
+
if (typeof tw.compile !== "function") {
|
|
493
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
494
|
+
}
|
|
495
|
+
_twEngine = tw;
|
|
496
|
+
return _twEngine;
|
|
497
|
+
} catch (e) {
|
|
498
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
499
|
+
throw _twEngineError;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function generateRawCss(classes) {
|
|
503
|
+
if (classes.length === 0) return "";
|
|
504
|
+
const tw = loadTailwindEngine();
|
|
505
|
+
const compiler = tw.compile("@import 'tailwindcss';");
|
|
506
|
+
return compiler.build(classes);
|
|
507
|
+
}
|
|
508
|
+
function postProcessWithLightning(rawCss) {
|
|
509
|
+
if (!rawCss) return "";
|
|
510
|
+
const native = getNativeBridge();
|
|
511
|
+
if (typeof native.processTailwindCssLightning === "function") {
|
|
512
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
513
|
+
return result?.css ?? rawCss;
|
|
514
|
+
}
|
|
515
|
+
console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
|
|
516
|
+
return rawCss;
|
|
517
|
+
}
|
|
518
|
+
async function runCssPipeline(classes) {
|
|
519
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
520
|
+
if (unique.length === 0) {
|
|
521
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
522
|
+
}
|
|
523
|
+
const rawCss = generateRawCss(unique);
|
|
524
|
+
const native = getNativeBridge();
|
|
525
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
526
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
527
|
+
return {
|
|
528
|
+
css: finalCss,
|
|
529
|
+
classes: unique,
|
|
530
|
+
sizeBytes: finalCss.length,
|
|
531
|
+
optimized: hasLightning
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function runCssPipelineSync(classes) {
|
|
535
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
536
|
+
if (unique.length === 0) {
|
|
537
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
538
|
+
}
|
|
539
|
+
const rawCss = generateRawCss(unique);
|
|
540
|
+
const native = getNativeBridge();
|
|
541
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
542
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
543
|
+
return {
|
|
544
|
+
css: finalCss,
|
|
545
|
+
classes: unique,
|
|
546
|
+
sizeBytes: finalCss.length,
|
|
547
|
+
optimized: hasLightning
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
var require2, _twEngine, _twEngineError;
|
|
551
|
+
var init_tailwindEngine = __esm({
|
|
552
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
553
|
+
init_nativeBridge();
|
|
554
|
+
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
555
|
+
_twEngine = null;
|
|
556
|
+
_twEngineError = null;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
418
559
|
|
|
419
560
|
// packages/domain/scanner/src/native-bridge.ts
|
|
420
561
|
var native_bridge_exports = {};
|
|
@@ -599,59 +740,8 @@ var init_native_bridge = __esm({
|
|
|
599
740
|
}
|
|
600
741
|
});
|
|
601
742
|
|
|
602
|
-
// packages/domain/compiler/src/nativeBridge.ts
|
|
603
|
-
init_src();
|
|
604
|
-
var log = (...args) => {
|
|
605
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
606
|
-
console.log("[compiler:native]", ...args);
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
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";
|
|
610
|
-
var nativeBridge = null;
|
|
611
|
-
var bridgeLoadAttempted = false;
|
|
612
|
-
var bridgeLoadError = null;
|
|
613
|
-
var isValidNativeBridge = (mod) => {
|
|
614
|
-
const m = mod;
|
|
615
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
616
|
-
};
|
|
617
|
-
var getNativeBridge = () => {
|
|
618
|
-
if (nativeBridge) {
|
|
619
|
-
return nativeBridge;
|
|
620
|
-
}
|
|
621
|
-
if (bridgeLoadAttempted) {
|
|
622
|
-
if (bridgeLoadError) {
|
|
623
|
-
throw bridgeLoadError;
|
|
624
|
-
}
|
|
625
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
626
|
-
}
|
|
627
|
-
bridgeLoadAttempted = true;
|
|
628
|
-
try {
|
|
629
|
-
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
630
|
-
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
631
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
632
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
633
|
-
try {
|
|
634
|
-
const binding = require2(result.path);
|
|
635
|
-
if (isValidNativeBridge(binding)) {
|
|
636
|
-
nativeBridge = binding;
|
|
637
|
-
log("Native bridge loaded successfully from:", result.path);
|
|
638
|
-
return nativeBridge;
|
|
639
|
-
}
|
|
640
|
-
} catch (e) {
|
|
641
|
-
log("Failed to require native binding:", e);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
645
|
-
|
|
646
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
647
|
-
} catch (err) {
|
|
648
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
649
|
-
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
650
|
-
throw bridgeLoadError;
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
|
|
654
743
|
// packages/domain/compiler/src/index.ts
|
|
744
|
+
init_nativeBridge();
|
|
655
745
|
var transformSource = (source, opts) => {
|
|
656
746
|
const native = getNativeBridge();
|
|
657
747
|
if (!native?.transformSource) {
|
|
@@ -663,20 +753,10 @@ var transformSource = (source, opts) => {
|
|
|
663
753
|
}
|
|
664
754
|
return result;
|
|
665
755
|
};
|
|
666
|
-
var compileCssFromClasses = (classes, prefix) => {
|
|
667
|
-
const native = getNativeBridge();
|
|
668
|
-
if (!native?.transformSource) {
|
|
669
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
670
|
-
}
|
|
671
|
-
const result = native.transformSource(classes.join(" "), { prefix: "" });
|
|
672
|
-
if (!result) {
|
|
673
|
-
throw new Error("FATAL: transformSource returned null");
|
|
674
|
-
}
|
|
675
|
-
return result;
|
|
676
|
-
};
|
|
677
756
|
var generateCssForClasses = async (classes, _tailwindConfig, _root) => {
|
|
678
|
-
const
|
|
679
|
-
|
|
757
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
758
|
+
const result = await runCssPipeline2(classes);
|
|
759
|
+
return result.css;
|
|
680
760
|
};
|
|
681
761
|
var mergeClassesStatic = (classes) => {
|
|
682
762
|
const result = normalizeAndDedupClasses(classes);
|