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/compiler.d.mts
CHANGED
|
@@ -103,6 +103,13 @@ interface NativeBridge {
|
|
|
103
103
|
classes: string[];
|
|
104
104
|
};
|
|
105
105
|
compileCssLightning?: (classes: string[]) => string;
|
|
106
|
+
/** Post-process raw Tailwind-generated CSS dengan LightningCSS di Rust */
|
|
107
|
+
processTailwindCssLightning?: (css: string) => {
|
|
108
|
+
css: string;
|
|
109
|
+
size_bytes: number;
|
|
110
|
+
resolved_classes: string[];
|
|
111
|
+
unknown_classes: string[];
|
|
112
|
+
};
|
|
106
113
|
}
|
|
107
114
|
interface NativeTransformResult {
|
|
108
115
|
code: string;
|
|
@@ -267,10 +274,8 @@ declare const shouldSkipFile: (filepath: string) => boolean;
|
|
|
267
274
|
declare const fileToRoute: (filepath: string) => string | null;
|
|
268
275
|
declare const getAllRoutes: () => string[];
|
|
269
276
|
declare const getRouteClasses: (route: string) => Set<string>;
|
|
270
|
-
declare const getAllRouteClasses: () => Map<string, Set<string>>;
|
|
271
277
|
declare const registerFileClasses: (filepath: string, classes: string[]) => void;
|
|
272
278
|
declare const registerGlobalClasses: (classes: string[]) => void;
|
|
273
|
-
declare const clearRouteClasses: () => void;
|
|
274
279
|
declare const getIncrementalEngine: () => unknown;
|
|
275
280
|
declare const resetIncrementalEngine: () => void;
|
|
276
281
|
declare const IncrementalEngine: {
|
|
@@ -289,4 +294,4 @@ declare const classifyNode: (node: unknown) => string;
|
|
|
289
294
|
declare const detectConflicts: (classes: string[]) => string[];
|
|
290
295
|
declare const bucketSort: (classes: string[]) => string[];
|
|
291
296
|
|
|
292
|
-
export { BucketEngine, type ClassExtractResult, type ComponentMetadata, IncrementalEngine, type LoaderOutput, type NativeBridge, type NativeRscResult, type NativeTransformResult, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode,
|
|
297
|
+
export { BucketEngine, type ClassExtractResult, type ComponentMetadata, IncrementalEngine, type LoaderOutput, type NativeBridge, type NativeRscResult, type NativeTransformResult, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode, compileCssFromClasses, compileCssNative, compileVariantTable, compileVariants, detectConflicts, diffClassLists, eliminateDeadCss, extractAllClasses, extractClassesFromSource, extractComponentUsage, fileToRoute, findDeadVariants, generateCssForClasses, generateSafelist, getAllRoutes, getBucketEngine, getContentPaths, getIncrementalEngine, getNativeBridge, getRouteClasses, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, isAlreadyTransformed, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, normalizeAndDedupClasses, normalizeClasses, optimizeCss, parseClasses, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetIncrementalEngine, resetNativeBridgeCache, runElimination, runLoaderTransform, scanProjectUsage, shouldProcess, shouldSkipFile, transformSource };
|
package/dist/compiler.d.ts
CHANGED
|
@@ -103,6 +103,13 @@ interface NativeBridge {
|
|
|
103
103
|
classes: string[];
|
|
104
104
|
};
|
|
105
105
|
compileCssLightning?: (classes: string[]) => string;
|
|
106
|
+
/** Post-process raw Tailwind-generated CSS dengan LightningCSS di Rust */
|
|
107
|
+
processTailwindCssLightning?: (css: string) => {
|
|
108
|
+
css: string;
|
|
109
|
+
size_bytes: number;
|
|
110
|
+
resolved_classes: string[];
|
|
111
|
+
unknown_classes: string[];
|
|
112
|
+
};
|
|
106
113
|
}
|
|
107
114
|
interface NativeTransformResult {
|
|
108
115
|
code: string;
|
|
@@ -267,10 +274,8 @@ declare const shouldSkipFile: (filepath: string) => boolean;
|
|
|
267
274
|
declare const fileToRoute: (filepath: string) => string | null;
|
|
268
275
|
declare const getAllRoutes: () => string[];
|
|
269
276
|
declare const getRouteClasses: (route: string) => Set<string>;
|
|
270
|
-
declare const getAllRouteClasses: () => Map<string, Set<string>>;
|
|
271
277
|
declare const registerFileClasses: (filepath: string, classes: string[]) => void;
|
|
272
278
|
declare const registerGlobalClasses: (classes: string[]) => void;
|
|
273
|
-
declare const clearRouteClasses: () => void;
|
|
274
279
|
declare const getIncrementalEngine: () => unknown;
|
|
275
280
|
declare const resetIncrementalEngine: () => void;
|
|
276
281
|
declare const IncrementalEngine: {
|
|
@@ -289,4 +294,4 @@ declare const classifyNode: (node: unknown) => string;
|
|
|
289
294
|
declare const detectConflicts: (classes: string[]) => string[];
|
|
290
295
|
declare const bucketSort: (classes: string[]) => string[];
|
|
291
296
|
|
|
292
|
-
export { BucketEngine, type ClassExtractResult, type ComponentMetadata, IncrementalEngine, type LoaderOutput, type NativeBridge, type NativeRscResult, type NativeTransformResult, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode,
|
|
297
|
+
export { BucketEngine, type ClassExtractResult, type ComponentMetadata, IncrementalEngine, type LoaderOutput, type NativeBridge, type NativeRscResult, type NativeTransformResult, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode, compileCssFromClasses, compileCssNative, compileVariantTable, compileVariants, detectConflicts, diffClassLists, eliminateDeadCss, extractAllClasses, extractClassesFromSource, extractComponentUsage, fileToRoute, findDeadVariants, generateCssForClasses, generateSafelist, getAllRoutes, getBucketEngine, getContentPaths, getIncrementalEngine, getNativeBridge, getRouteClasses, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, isAlreadyTransformed, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, normalizeAndDedupClasses, normalizeClasses, optimizeCss, parseClasses, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetIncrementalEngine, resetNativeBridgeCache, runElimination, runLoaderTransform, scanProjectUsage, shouldProcess, shouldSkipFile, transformSource };
|
package/dist/compiler.js
CHANGED
|
@@ -4,16 +4,23 @@ var module$1 = require('module');
|
|
|
4
4
|
|
|
5
5
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
6
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
9
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
10
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
11
|
}) : x)(function(x) {
|
|
10
12
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
13
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
14
|
});
|
|
15
|
+
var __esm = (fn, res) => function __init() {
|
|
16
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
+
};
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
13
22
|
|
|
14
23
|
// packages/domain/shared/src/native-resolution.ts
|
|
15
|
-
var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
16
|
-
var nodeModuleRef = null;
|
|
17
24
|
function getNodeModuleRef() {
|
|
18
25
|
if (isBrowser) return null;
|
|
19
26
|
if (nodeModuleRef !== null) return nodeModuleRef;
|
|
@@ -26,9 +33,6 @@ function getNodeModuleRef() {
|
|
|
26
33
|
return null;
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
|
-
var _nodeFs = null;
|
|
30
|
-
var _nodePath = null;
|
|
31
|
-
var _require = null;
|
|
32
36
|
function getNodeFs() {
|
|
33
37
|
if (isBrowser) return { existsSync: () => false };
|
|
34
38
|
const nodeRequire = getNodeModuleRef();
|
|
@@ -54,14 +58,6 @@ function getRequire(_importMetaUrl) {
|
|
|
54
58
|
if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
|
|
55
59
|
return _require;
|
|
56
60
|
}
|
|
57
|
-
var PLATFORM_MAP = {
|
|
58
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
59
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
60
|
-
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
61
|
-
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
62
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
63
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
64
|
-
};
|
|
65
61
|
function platformKey() {
|
|
66
62
|
if (isBrowser) return "browser";
|
|
67
63
|
return `${process.platform}-${process.arch}`;
|
|
@@ -115,10 +111,26 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
115
111
|
}
|
|
116
112
|
return { path: null, source: "not-found", platform, tried };
|
|
117
113
|
}
|
|
114
|
+
var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _require, PLATFORM_MAP;
|
|
115
|
+
var init_native_resolution = __esm({
|
|
116
|
+
"packages/domain/shared/src/native-resolution.ts"() {
|
|
117
|
+
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
118
|
+
nodeModuleRef = null;
|
|
119
|
+
_nodeFs = null;
|
|
120
|
+
_nodePath = null;
|
|
121
|
+
_require = null;
|
|
122
|
+
PLATFORM_MAP = {
|
|
123
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
124
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
125
|
+
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
126
|
+
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
127
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
128
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
118
132
|
|
|
119
133
|
// packages/domain/shared/src/index.ts
|
|
120
|
-
var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
121
|
-
var nodeModuleRef2 = null;
|
|
122
134
|
function getNodeModuleRef2() {
|
|
123
135
|
if (isBrowser2) return null;
|
|
124
136
|
if (nodeModuleRef2 !== null) return nodeModuleRef2;
|
|
@@ -131,7 +143,6 @@ function getNodeModuleRef2() {
|
|
|
131
143
|
return null;
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
|
-
var _nodeUrl = null;
|
|
135
146
|
function getNodeUrl() {
|
|
136
147
|
if (isBrowser2) throw new Error("node:url not available in browser");
|
|
137
148
|
const nodeRequire = getNodeModuleRef2();
|
|
@@ -149,7 +160,6 @@ function getRequire2() {
|
|
|
149
160
|
});
|
|
150
161
|
return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
|
|
151
162
|
}
|
|
152
|
-
getRequire2();
|
|
153
163
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
154
164
|
if (isBrowser2) return "";
|
|
155
165
|
try {
|
|
@@ -158,74 +168,177 @@ function resolveRuntimeDir(dir, importMetaUrl) {
|
|
|
158
168
|
return process.cwd();
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var bridgeLoadError = null;
|
|
170
|
-
var isValidNativeBridge = (mod) => {
|
|
171
|
-
const m = mod;
|
|
172
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
173
|
-
};
|
|
174
|
-
var getNativeBridge = () => {
|
|
175
|
-
if (nativeBridge) {
|
|
176
|
-
return nativeBridge;
|
|
177
|
-
}
|
|
178
|
-
if (bridgeLoadAttempted) {
|
|
179
|
-
if (bridgeLoadError) {
|
|
180
|
-
throw bridgeLoadError;
|
|
181
|
-
}
|
|
182
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
171
|
+
var isBrowser2, nodeModuleRef2, _nodeUrl;
|
|
172
|
+
var init_src = __esm({
|
|
173
|
+
"packages/domain/shared/src/index.ts"() {
|
|
174
|
+
init_native_resolution();
|
|
175
|
+
isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
176
|
+
nodeModuleRef2 = null;
|
|
177
|
+
_nodeUrl = null;
|
|
178
|
+
getRequire2();
|
|
183
179
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
});
|
|
181
|
+
var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge; exports.getNativeBridge = void 0; exports.resetNativeBridgeCache = void 0; exports.adaptNativeResult = void 0;
|
|
182
|
+
var init_nativeBridge = __esm({
|
|
183
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
184
|
+
init_src();
|
|
185
|
+
log = (...args) => {
|
|
186
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
187
|
+
console.log("[compiler:native]", ...args);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
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";
|
|
191
|
+
nativeBridge = null;
|
|
192
|
+
bridgeLoadAttempted = false;
|
|
193
|
+
bridgeLoadError = null;
|
|
194
|
+
isValidNativeBridge = (mod) => {
|
|
195
|
+
const m = mod;
|
|
196
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
197
|
+
};
|
|
198
|
+
exports.getNativeBridge = () => {
|
|
199
|
+
if (nativeBridge) {
|
|
200
|
+
return nativeBridge;
|
|
201
|
+
}
|
|
202
|
+
if (bridgeLoadAttempted) {
|
|
203
|
+
if (bridgeLoadError) {
|
|
204
|
+
throw bridgeLoadError;
|
|
205
|
+
}
|
|
206
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
207
|
+
}
|
|
208
|
+
bridgeLoadAttempted = true;
|
|
190
209
|
try {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
210
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
|
|
211
|
+
const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
|
|
212
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
213
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
214
|
+
try {
|
|
215
|
+
const binding = require3(result.path);
|
|
216
|
+
if (isValidNativeBridge(binding)) {
|
|
217
|
+
nativeBridge = binding;
|
|
218
|
+
log("Native bridge loaded successfully from:", result.path);
|
|
219
|
+
return nativeBridge;
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
log("Failed to require native binding:", e);
|
|
223
|
+
}
|
|
196
224
|
}
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
226
|
+
|
|
227
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
228
|
+
} catch (err) {
|
|
229
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
230
|
+
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
231
|
+
throw bridgeLoadError;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
exports.resetNativeBridgeCache = () => {
|
|
235
|
+
nativeBridge = null;
|
|
236
|
+
bridgeLoadAttempted = false;
|
|
237
|
+
bridgeLoadError = null;
|
|
238
|
+
log("Native bridge cache reset");
|
|
239
|
+
};
|
|
240
|
+
exports.adaptNativeResult = (raw) => {
|
|
241
|
+
return {
|
|
242
|
+
code: raw.code ?? "",
|
|
243
|
+
classes: raw.classes ?? [],
|
|
244
|
+
changed: raw.changed ?? false,
|
|
245
|
+
rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
|
|
246
|
+
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
250
|
+
try {
|
|
251
|
+
exports.getNativeBridge();
|
|
252
|
+
} catch {
|
|
199
253
|
}
|
|
200
254
|
}
|
|
201
|
-
|
|
255
|
+
}
|
|
256
|
+
});
|
|
202
257
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
258
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
259
|
+
var tailwindEngine_exports = {};
|
|
260
|
+
__export(tailwindEngine_exports, {
|
|
261
|
+
generateRawCss: () => generateRawCss,
|
|
262
|
+
runCssPipeline: () => runCssPipeline,
|
|
263
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
264
|
+
});
|
|
265
|
+
function loadTailwindEngine() {
|
|
266
|
+
if (_twEngine) return _twEngine;
|
|
267
|
+
if (_twEngineError) throw _twEngineError;
|
|
268
|
+
try {
|
|
269
|
+
const tw = require2("tailwindcss");
|
|
270
|
+
if (typeof tw.compile !== "function") {
|
|
271
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
272
|
+
}
|
|
273
|
+
_twEngine = tw;
|
|
274
|
+
return _twEngine;
|
|
275
|
+
} catch (e) {
|
|
276
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
277
|
+
throw _twEngineError;
|
|
208
278
|
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
279
|
+
}
|
|
280
|
+
function generateRawCss(classes) {
|
|
281
|
+
if (classes.length === 0) return "";
|
|
282
|
+
const tw = loadTailwindEngine();
|
|
283
|
+
const compiler = tw.compile("@import 'tailwindcss';");
|
|
284
|
+
return compiler.build(classes);
|
|
285
|
+
}
|
|
286
|
+
function postProcessWithLightning(rawCss) {
|
|
287
|
+
if (!rawCss) return "";
|
|
288
|
+
const native = exports.getNativeBridge();
|
|
289
|
+
if (typeof native.processTailwindCssLightning === "function") {
|
|
290
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
291
|
+
return result?.css ?? rawCss;
|
|
292
|
+
}
|
|
293
|
+
console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
|
|
294
|
+
return rawCss;
|
|
295
|
+
}
|
|
296
|
+
async function runCssPipeline(classes) {
|
|
297
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
298
|
+
if (unique.length === 0) {
|
|
299
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
300
|
+
}
|
|
301
|
+
const rawCss = generateRawCss(unique);
|
|
302
|
+
const native = exports.getNativeBridge();
|
|
303
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
304
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
217
305
|
return {
|
|
218
|
-
|
|
219
|
-
classes:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
306
|
+
css: finalCss,
|
|
307
|
+
classes: unique,
|
|
308
|
+
sizeBytes: finalCss.length,
|
|
309
|
+
optimized: hasLightning
|
|
223
310
|
};
|
|
224
|
-
}
|
|
311
|
+
}
|
|
312
|
+
function runCssPipelineSync(classes) {
|
|
313
|
+
const unique = [...new Set(classes.filter(Boolean))];
|
|
314
|
+
if (unique.length === 0) {
|
|
315
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
316
|
+
}
|
|
317
|
+
const rawCss = generateRawCss(unique);
|
|
318
|
+
const native = exports.getNativeBridge();
|
|
319
|
+
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
320
|
+
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
321
|
+
return {
|
|
322
|
+
css: finalCss,
|
|
323
|
+
classes: unique,
|
|
324
|
+
sizeBytes: finalCss.length,
|
|
325
|
+
optimized: hasLightning
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
var require2, _twEngine, _twEngineError;
|
|
329
|
+
var init_tailwindEngine = __esm({
|
|
330
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
331
|
+
init_nativeBridge();
|
|
332
|
+
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
|
|
333
|
+
_twEngine = null;
|
|
334
|
+
_twEngineError = null;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
225
337
|
|
|
226
338
|
// packages/domain/compiler/src/index.ts
|
|
339
|
+
init_nativeBridge();
|
|
227
340
|
var transformSource = (source, opts) => {
|
|
228
|
-
const native = getNativeBridge();
|
|
341
|
+
const native = exports.getNativeBridge();
|
|
229
342
|
if (!native?.transformSource) {
|
|
230
343
|
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
231
344
|
}
|
|
@@ -236,14 +349,14 @@ var transformSource = (source, opts) => {
|
|
|
236
349
|
return result;
|
|
237
350
|
};
|
|
238
351
|
var hasTwUsage = (source) => {
|
|
239
|
-
const native = getNativeBridge();
|
|
352
|
+
const native = exports.getNativeBridge();
|
|
240
353
|
if (!native?.hasTwUsage) {
|
|
241
354
|
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
242
355
|
}
|
|
243
356
|
return native.hasTwUsage(source);
|
|
244
357
|
};
|
|
245
358
|
var isAlreadyTransformed = (source) => {
|
|
246
|
-
const native = getNativeBridge();
|
|
359
|
+
const native = exports.getNativeBridge();
|
|
247
360
|
if (!native?.isAlreadyTransformed) {
|
|
248
361
|
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
249
362
|
}
|
|
@@ -253,7 +366,7 @@ var shouldProcess = (source) => {
|
|
|
253
366
|
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
254
367
|
};
|
|
255
368
|
var compileCssFromClasses = (classes, prefix) => {
|
|
256
|
-
const native = getNativeBridge();
|
|
369
|
+
const native = exports.getNativeBridge();
|
|
257
370
|
if (!native?.transformSource) {
|
|
258
371
|
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
259
372
|
}
|
|
@@ -271,18 +384,19 @@ var compileCssNative = (classes, prefix = null) => {
|
|
|
271
384
|
return compileCssFromClasses(classes, prefix);
|
|
272
385
|
};
|
|
273
386
|
var generateCssForClasses = async (classes, _tailwindConfig, _root) => {
|
|
274
|
-
const
|
|
275
|
-
|
|
387
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
388
|
+
const result = await runCssPipeline2(classes);
|
|
389
|
+
return result.css;
|
|
276
390
|
};
|
|
277
391
|
var extractAllClasses = (source) => {
|
|
278
|
-
const native = getNativeBridge();
|
|
392
|
+
const native = exports.getNativeBridge();
|
|
279
393
|
if (!native?.extractAllClasses) {
|
|
280
394
|
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
281
395
|
}
|
|
282
396
|
return native.extractAllClasses(source) || [];
|
|
283
397
|
};
|
|
284
398
|
var extractClassesFromSource = (source) => {
|
|
285
|
-
const native = getNativeBridge();
|
|
399
|
+
const native = exports.getNativeBridge();
|
|
286
400
|
if (!native?.extractClassesFromSource) {
|
|
287
401
|
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
288
402
|
}
|
|
@@ -290,14 +404,14 @@ var extractClassesFromSource = (source) => {
|
|
|
290
404
|
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
291
405
|
};
|
|
292
406
|
var astExtractClasses = (source, filename) => {
|
|
293
|
-
const native = getNativeBridge();
|
|
407
|
+
const native = exports.getNativeBridge();
|
|
294
408
|
if (!native?.extractClassesFromSource) {
|
|
295
409
|
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
296
410
|
}
|
|
297
411
|
return native.extractClassesFromSource(source) || [];
|
|
298
412
|
};
|
|
299
413
|
var parseClasses = (raw) => {
|
|
300
|
-
const native = getNativeBridge();
|
|
414
|
+
const native = exports.getNativeBridge();
|
|
301
415
|
if (!native?.parseClasses) {
|
|
302
416
|
return parseClassesJs(raw);
|
|
303
417
|
}
|
|
@@ -339,7 +453,7 @@ function normalizeAndDedupClassesJs(raw) {
|
|
|
339
453
|
};
|
|
340
454
|
}
|
|
341
455
|
var normalizeAndDedupClasses = (raw) => {
|
|
342
|
-
const native = getNativeBridge();
|
|
456
|
+
const native = exports.getNativeBridge();
|
|
343
457
|
if (!native?.normalizeAndDedupClasses) {
|
|
344
458
|
return normalizeAndDedupClassesJs(raw);
|
|
345
459
|
}
|
|
@@ -401,42 +515,42 @@ var scanProjectUsage = (dirs, cwd) => {
|
|
|
401
515
|
return combined;
|
|
402
516
|
};
|
|
403
517
|
var extractComponentUsage = (source) => {
|
|
404
|
-
const native = getNativeBridge();
|
|
518
|
+
const native = exports.getNativeBridge();
|
|
405
519
|
if (!native?.extractComponentUsage) {
|
|
406
520
|
throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
|
|
407
521
|
}
|
|
408
522
|
return native.extractComponentUsage(source) || [];
|
|
409
523
|
};
|
|
410
524
|
var diffClassLists = (previous, current) => {
|
|
411
|
-
const native = getNativeBridge();
|
|
525
|
+
const native = exports.getNativeBridge();
|
|
412
526
|
if (!native?.diffClassLists) {
|
|
413
527
|
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
414
528
|
}
|
|
415
529
|
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
416
530
|
};
|
|
417
531
|
var batchExtractClasses = (filePaths) => {
|
|
418
|
-
const native = getNativeBridge();
|
|
532
|
+
const native = exports.getNativeBridge();
|
|
419
533
|
if (!native?.batchExtractClasses) {
|
|
420
534
|
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
421
535
|
}
|
|
422
536
|
return native.batchExtractClasses(filePaths) || [];
|
|
423
537
|
};
|
|
424
538
|
var checkAgainstSafelist = (classes, safelist) => {
|
|
425
|
-
const native = getNativeBridge();
|
|
539
|
+
const native = exports.getNativeBridge();
|
|
426
540
|
if (!native?.checkAgainstSafelist) {
|
|
427
541
|
throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
|
|
428
542
|
}
|
|
429
543
|
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
430
544
|
};
|
|
431
545
|
var hoistComponents = (source) => {
|
|
432
|
-
const native = getNativeBridge();
|
|
546
|
+
const native = exports.getNativeBridge();
|
|
433
547
|
if (!native?.hoistComponents) {
|
|
434
548
|
throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
|
|
435
549
|
}
|
|
436
550
|
return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
|
|
437
551
|
};
|
|
438
552
|
var compileVariantTable = (configJson) => {
|
|
439
|
-
const native = getNativeBridge();
|
|
553
|
+
const native = exports.getNativeBridge();
|
|
440
554
|
if (!native?.compileVariantTable) {
|
|
441
555
|
throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
|
|
442
556
|
}
|
|
@@ -446,28 +560,28 @@ var compileVariants = (componentId, config) => {
|
|
|
446
560
|
return compileVariantTable(JSON.stringify({ componentId, ...config }));
|
|
447
561
|
};
|
|
448
562
|
var classifyAndSortClasses = (classes) => {
|
|
449
|
-
const native = getNativeBridge();
|
|
563
|
+
const native = exports.getNativeBridge();
|
|
450
564
|
if (!native?.classifyAndSortClasses) {
|
|
451
565
|
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
452
566
|
}
|
|
453
567
|
return native.classifyAndSortClasses(classes) || [];
|
|
454
568
|
};
|
|
455
569
|
var mergeCssDeclarations = (cssChunks) => {
|
|
456
|
-
const native = getNativeBridge();
|
|
570
|
+
const native = exports.getNativeBridge();
|
|
457
571
|
if (!native?.mergeCssDeclarations) {
|
|
458
572
|
throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
|
|
459
573
|
}
|
|
460
574
|
return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
|
|
461
575
|
};
|
|
462
576
|
var analyzeClassUsage = (classes, scanResultJson, css) => {
|
|
463
|
-
const native = getNativeBridge();
|
|
577
|
+
const native = exports.getNativeBridge();
|
|
464
578
|
if (!native?.analyzeClassUsage) {
|
|
465
579
|
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
466
580
|
}
|
|
467
581
|
return native.analyzeClassUsage(classes, scanResultJson, css) || [];
|
|
468
582
|
};
|
|
469
583
|
var analyzeRsc = (source, filename) => {
|
|
470
|
-
const native = getNativeBridge();
|
|
584
|
+
const native = exports.getNativeBridge();
|
|
471
585
|
if (!native?.analyzeRsc) {
|
|
472
586
|
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
473
587
|
}
|
|
@@ -501,7 +615,7 @@ var injectServerOnlyComment = (source) => {
|
|
|
501
615
|
${source}`;
|
|
502
616
|
};
|
|
503
617
|
var analyzeClasses = (filesJson, cwd, flags) => {
|
|
504
|
-
const native = getNativeBridge();
|
|
618
|
+
const native = exports.getNativeBridge();
|
|
505
619
|
if (!native?.analyzeClasses) {
|
|
506
620
|
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
507
621
|
}
|
|
@@ -578,43 +692,21 @@ var fileToRoute = (filepath) => {
|
|
|
578
692
|
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
579
693
|
return "__global";
|
|
580
694
|
}
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
const pagesMatch = normalized.match(/\/pages\/(.+?)\.[tj]sx?$/);
|
|
586
|
-
if (pagesMatch) {
|
|
587
|
-
const pagePath = pagesMatch[1];
|
|
588
|
-
if (pagePath.startsWith("_") || pagePath.startsWith("api/")) return "__global";
|
|
589
|
-
return pagePath === "index" ? "/" : `/${pagePath}`;
|
|
590
|
-
}
|
|
695
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
696
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
697
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
698
|
+
if (rootPage) return "/";
|
|
591
699
|
return null;
|
|
592
700
|
};
|
|
593
701
|
var getAllRoutes = () => {
|
|
594
|
-
return
|
|
702
|
+
return ["/", "__global"];
|
|
595
703
|
};
|
|
596
|
-
var _routeClassMap = /* @__PURE__ */ new Map();
|
|
597
704
|
var getRouteClasses = (route) => {
|
|
598
|
-
return
|
|
599
|
-
};
|
|
600
|
-
var getAllRouteClasses = () => {
|
|
601
|
-
return new Map(_routeClassMap);
|
|
705
|
+
return /* @__PURE__ */ new Set();
|
|
602
706
|
};
|
|
603
707
|
var registerFileClasses = (filepath, classes) => {
|
|
604
|
-
if (!classes.length) return;
|
|
605
|
-
const route = fileToRoute(filepath) ?? "__global";
|
|
606
|
-
const existing = _routeClassMap.get(route) ?? /* @__PURE__ */ new Set();
|
|
607
|
-
for (const cls of classes) existing.add(cls);
|
|
608
|
-
_routeClassMap.set(route, existing);
|
|
609
708
|
};
|
|
610
709
|
var registerGlobalClasses = (classes) => {
|
|
611
|
-
if (!classes.length) return;
|
|
612
|
-
const existing = _routeClassMap.get("__global") ?? /* @__PURE__ */ new Set();
|
|
613
|
-
for (const cls of classes) existing.add(cls);
|
|
614
|
-
_routeClassMap.set("__global", existing);
|
|
615
|
-
};
|
|
616
|
-
var clearRouteClasses = () => {
|
|
617
|
-
_routeClassMap.clear();
|
|
618
710
|
};
|
|
619
711
|
var incrementalEngineInstance = null;
|
|
620
712
|
var getIncrementalEngine = () => {
|
|
@@ -663,7 +755,6 @@ var bucketSort = (classes) => {
|
|
|
663
755
|
|
|
664
756
|
exports.BucketEngine = BucketEngine;
|
|
665
757
|
exports.IncrementalEngine = IncrementalEngine;
|
|
666
|
-
exports.adaptNativeResult = adaptNativeResult;
|
|
667
758
|
exports.analyzeClassUsage = analyzeClassUsage;
|
|
668
759
|
exports.analyzeClasses = analyzeClasses;
|
|
669
760
|
exports.analyzeFile = analyzeFile;
|
|
@@ -676,7 +767,6 @@ exports.buildStyleTag = buildStyleTag;
|
|
|
676
767
|
exports.checkAgainstSafelist = checkAgainstSafelist;
|
|
677
768
|
exports.classifyAndSortClasses = classifyAndSortClasses;
|
|
678
769
|
exports.classifyNode = classifyNode;
|
|
679
|
-
exports.clearRouteClasses = clearRouteClasses;
|
|
680
770
|
exports.compileCssFromClasses = compileCssFromClasses;
|
|
681
771
|
exports.compileCssNative = compileCssNative;
|
|
682
772
|
exports.compileVariantTable = compileVariantTable;
|
|
@@ -691,12 +781,10 @@ exports.fileToRoute = fileToRoute;
|
|
|
691
781
|
exports.findDeadVariants = findDeadVariants;
|
|
692
782
|
exports.generateCssForClasses = generateCssForClasses;
|
|
693
783
|
exports.generateSafelist = generateSafelist;
|
|
694
|
-
exports.getAllRouteClasses = getAllRouteClasses;
|
|
695
784
|
exports.getAllRoutes = getAllRoutes;
|
|
696
785
|
exports.getBucketEngine = getBucketEngine;
|
|
697
786
|
exports.getContentPaths = getContentPaths;
|
|
698
787
|
exports.getIncrementalEngine = getIncrementalEngine;
|
|
699
|
-
exports.getNativeBridge = getNativeBridge;
|
|
700
788
|
exports.getRouteClasses = getRouteClasses;
|
|
701
789
|
exports.hasTwUsage = hasTwUsage;
|
|
702
790
|
exports.hoistComponents = hoistComponents;
|
|
@@ -715,7 +803,6 @@ exports.registerFileClasses = registerFileClasses;
|
|
|
715
803
|
exports.registerGlobalClasses = registerGlobalClasses;
|
|
716
804
|
exports.resetBucketEngine = resetBucketEngine;
|
|
717
805
|
exports.resetIncrementalEngine = resetIncrementalEngine;
|
|
718
|
-
exports.resetNativeBridgeCache = resetNativeBridgeCache;
|
|
719
806
|
exports.runElimination = runElimination;
|
|
720
807
|
exports.runLoaderTransform = runLoaderTransform;
|
|
721
808
|
exports.scanProjectUsage = scanProjectUsage;
|