tailwind-styled-v4 5.0.11 → 5.0.13
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/README.md +100 -4
- package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
- package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
- package/dist/analyzer.d.mts +4 -4
- package/dist/analyzer.d.ts +4 -4
- package/dist/analyzer.js +34 -69
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +33 -68
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -0
- package/dist/animate.d.ts +4 -0
- package/dist/animate.js +33 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +33 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +57 -6
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +57 -6
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +404 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +401 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2700 -212
- package/dist/compiler.d.ts +2700 -212
- package/dist/compiler.js +1996 -503
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1847 -448
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +17 -4
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +17 -4
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +11 -470
- package/dist/engine.d.ts +11 -470
- package/dist/engine.js +2777 -455
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2776 -454
- package/dist/engine.mjs.map +1 -1
- package/dist/index-BDQw13kn.d.ts +464 -0
- package/dist/index-DJv28Uzq.d.mts +464 -0
- package/dist/index.browser.mjs +143 -255
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +23 -39
- package/dist/index.d.ts +23 -39
- package/dist/index.js +7234 -1400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7234 -1400
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +44 -1
- package/dist/next.d.ts +44 -1
- package/dist/next.js +3224 -1065
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3223 -1066
- package/dist/next.mjs.map +1 -1
- package/dist/rspack.d.mts +9 -0
- package/dist/rspack.d.ts +9 -0
- package/dist/rspack.js +99 -61
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +99 -61
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime-css.d.mts +8 -0
- package/dist/runtime-css.d.ts +8 -0
- package/dist/runtime-css.js +23 -7
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +23 -7
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/scanner.js +16 -37
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +15 -36
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +107 -1
- package/dist/shared.d.ts +107 -1
- package/dist/shared.js +3014 -466
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +3008 -445
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +39 -35
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -34
- package/dist/svelte.mjs.map +1 -1
- package/dist/theme.js +85 -76
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +83 -74
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +2351 -187
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +2351 -187
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +404 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +401 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +2657 -320
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +2657 -320
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +39 -35
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -34
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +190 -33
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +190 -33
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/index.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
- package/package.json +9 -4
- package/CHANGELOG.md +0 -285
package/dist/next.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
2
|
+
import * as fs9 from 'fs';
|
|
3
|
+
import fs9__default from 'fs';
|
|
4
|
+
import * as path10 from 'path';
|
|
5
|
+
import path10__default from 'path';
|
|
6
6
|
import 'crypto';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -62,11 +62,11 @@ function resolvePath(...segments) {
|
|
|
62
62
|
return segments.join("/").replace(/\/+/g, "/");
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function existsSync(
|
|
65
|
+
function existsSync(path11) {
|
|
66
66
|
if (isBrowser) return false;
|
|
67
67
|
try {
|
|
68
68
|
const nodeFs = __require(NODE_FS);
|
|
69
|
-
return nodeFs.existsSync(
|
|
69
|
+
return nodeFs.existsSync(path11);
|
|
70
70
|
} catch {
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
@@ -135,12 +135,12 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
135
135
|
if (isBrowser2) {
|
|
136
136
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
137
137
|
}
|
|
138
|
-
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
138
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
139
139
|
return { path: null, source: "not-found", platform, tried: [] };
|
|
140
140
|
}
|
|
141
141
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
142
142
|
if (envPath) {
|
|
143
|
-
if (
|
|
143
|
+
if (fs9.existsSync(envPath)) {
|
|
144
144
|
return { path: envPath, source: "env", platform, tried };
|
|
145
145
|
}
|
|
146
146
|
tried.push(`env:${envPath} (not found)`);
|
|
@@ -149,7 +149,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
149
149
|
for (const pkg of prebuiltPkgs) {
|
|
150
150
|
try {
|
|
151
151
|
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
152
|
-
if (
|
|
152
|
+
if (fs9.existsSync(candidate)) {
|
|
153
153
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
154
154
|
}
|
|
155
155
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -160,13 +160,13 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
160
160
|
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
161
161
|
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
162
162
|
if (runtimeDir) {
|
|
163
|
-
for (const depth of ["..",
|
|
164
|
-
const pkgRoot =
|
|
163
|
+
for (const depth of ["..", path10.join("..", ".."), path10.join("..", "..", "..")]) {
|
|
164
|
+
const pkgRoot = path10.resolve(runtimeDir, depth);
|
|
165
165
|
for (const bin of BINARY_NAMES_SELF) {
|
|
166
166
|
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
167
|
-
const candidate =
|
|
167
|
+
const candidate = path10.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
168
168
|
tried.push(`self-bundled:${candidate}`);
|
|
169
|
-
if (
|
|
169
|
+
if (fs9.existsSync(candidate)) {
|
|
170
170
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -178,29 +178,29 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
178
178
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
179
179
|
const localCandidates = [];
|
|
180
180
|
for (const bin of BINARY_NAMES) {
|
|
181
|
-
localCandidates.push(
|
|
182
|
-
localCandidates.push(
|
|
183
|
-
localCandidates.push(
|
|
184
|
-
localCandidates.push(
|
|
181
|
+
localCandidates.push(path10.resolve(base, `${bin}.node`));
|
|
182
|
+
localCandidates.push(path10.resolve(base, "..", `${bin}.node`));
|
|
183
|
+
localCandidates.push(path10.resolve(base, `${bin}.${platform}.node`));
|
|
184
|
+
localCandidates.push(path10.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
185
185
|
}
|
|
186
186
|
for (const startDir of [cwd, base]) {
|
|
187
187
|
let dir = startDir;
|
|
188
188
|
for (let i = 0; i < 6; i++) {
|
|
189
|
-
const nativeDir =
|
|
189
|
+
const nativeDir = path10.resolve(dir, "native");
|
|
190
190
|
for (const bin of BINARY_NAMES) {
|
|
191
|
-
localCandidates.push(
|
|
192
|
-
localCandidates.push(
|
|
193
|
-
localCandidates.push(
|
|
194
|
-
localCandidates.push(
|
|
191
|
+
localCandidates.push(path10.resolve(nativeDir, `${bin}.node`));
|
|
192
|
+
localCandidates.push(path10.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
193
|
+
localCandidates.push(path10.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
194
|
+
localCandidates.push(path10.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
195
195
|
}
|
|
196
|
-
const parent =
|
|
196
|
+
const parent = path10.resolve(dir, "..");
|
|
197
197
|
if (parent === dir) break;
|
|
198
198
|
dir = parent;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
for (const candidate of localCandidates) {
|
|
202
202
|
tried.push(`local:${candidate}`);
|
|
203
|
-
if (
|
|
203
|
+
if (fs9.existsSync(candidate)) {
|
|
204
204
|
return { path: candidate, source: "local", platform, tried };
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -221,648 +221,723 @@ var init_native_resolution = __esm({
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
process.
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
error(...args) {
|
|
236
|
-
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
237
|
-
`);
|
|
238
|
-
},
|
|
239
|
-
log(...args) {
|
|
240
|
-
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
241
|
-
`);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
function createDebugLogger(namespace, label) {
|
|
246
|
-
const prefix = `[${namespace}]`;
|
|
247
|
-
return (msg) => {
|
|
248
|
-
if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
|
|
249
|
-
console.debug(prefix, msg);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function formatIssuePath(path7) {
|
|
254
|
-
if (!path7 || path7.length === 0) return "(root)";
|
|
255
|
-
return path7.map(
|
|
256
|
-
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
257
|
-
).join(".");
|
|
258
|
-
}
|
|
259
|
-
function loadNativeBinding(options) {
|
|
260
|
-
const { runtimeDir, candidates, isValid } = options;
|
|
261
|
-
const loadErrors = [];
|
|
262
|
-
for (const candidate of candidates) {
|
|
263
|
-
const candidatePath = path5__default.resolve(runtimeDir, candidate);
|
|
264
|
-
try {
|
|
265
|
-
if (!fs5__default.existsSync(candidatePath) && !fs5__default.existsSync(candidatePath + ".node")) {
|
|
266
|
-
continue;
|
|
224
|
+
|
|
225
|
+
// packages/domain/compiler/src/nativeBridge.ts
|
|
226
|
+
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, resetNativeBridgeCache, adaptNativeResult;
|
|
227
|
+
var init_nativeBridge = __esm({
|
|
228
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
229
|
+
init_src2();
|
|
230
|
+
_loadNative = (path11) => __require(path11);
|
|
231
|
+
log = (...args) => {
|
|
232
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
233
|
+
console.log("[compiler:native]", ...args);
|
|
267
234
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
235
|
+
};
|
|
236
|
+
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";
|
|
237
|
+
nativeBridge = null;
|
|
238
|
+
bridgeLoadAttempted = false;
|
|
239
|
+
bridgeLoadError = null;
|
|
240
|
+
isValidNativeBridge = (mod) => {
|
|
241
|
+
const m = mod;
|
|
242
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
243
|
+
};
|
|
244
|
+
getNativeBridge = () => {
|
|
245
|
+
if (nativeBridge) {
|
|
246
|
+
return nativeBridge;
|
|
247
|
+
}
|
|
248
|
+
if (bridgeLoadAttempted) {
|
|
249
|
+
if (bridgeLoadError) {
|
|
250
|
+
throw bridgeLoadError;
|
|
251
|
+
}
|
|
252
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
253
|
+
}
|
|
254
|
+
bridgeLoadAttempted = true;
|
|
255
|
+
try {
|
|
256
|
+
const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
|
|
257
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
258
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
259
|
+
try {
|
|
260
|
+
const binding = _loadNative(result.path);
|
|
261
|
+
if (isValidNativeBridge(binding)) {
|
|
262
|
+
nativeBridge = binding;
|
|
263
|
+
log("Native bridge loaded successfully from:", result.path);
|
|
264
|
+
return nativeBridge;
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
log("Failed to require native binding:", e);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
271
|
+
|
|
272
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
275
|
+
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
276
|
+
throw bridgeLoadError;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
resetNativeBridgeCache = () => {
|
|
280
|
+
nativeBridge = null;
|
|
281
|
+
bridgeLoadAttempted = false;
|
|
282
|
+
bridgeLoadError = null;
|
|
283
|
+
log("Native bridge cache reset");
|
|
284
|
+
};
|
|
285
|
+
adaptNativeResult = (raw) => {
|
|
286
|
+
return {
|
|
287
|
+
code: raw.code ?? "",
|
|
288
|
+
classes: raw.classes ?? [],
|
|
289
|
+
changed: raw.changed ?? false,
|
|
290
|
+
rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
|
|
291
|
+
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
295
|
+
try {
|
|
296
|
+
getNativeBridge();
|
|
297
|
+
} catch {
|
|
271
298
|
}
|
|
272
|
-
loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
|
|
273
|
-
} catch (e) {
|
|
274
|
-
loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
|
|
275
299
|
}
|
|
276
300
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
} = options;
|
|
288
|
-
const runtimeDir = options.runtimeDir || process.cwd();
|
|
289
|
-
const candidates = [];
|
|
290
|
-
for (const envVar of envVarNames) {
|
|
291
|
-
const envPath = process.env[envVar];
|
|
292
|
-
if (envPath) {
|
|
293
|
-
candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
|
|
294
|
-
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// packages/domain/compiler/src/compiler/cssGeneratorNative.ts
|
|
304
|
+
async function generateCssNative(classes, options) {
|
|
305
|
+
const { theme } = options;
|
|
306
|
+
const native = getNativeBridge();
|
|
307
|
+
if (!native?.generateCssNative) {
|
|
308
|
+
throw new Error(
|
|
309
|
+
"FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
|
|
310
|
+
);
|
|
295
311
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
312
|
+
const themeJson = JSON.stringify(theme);
|
|
313
|
+
const css = native.generateCssNative(classes, themeJson);
|
|
314
|
+
return css;
|
|
315
|
+
}
|
|
316
|
+
function getCacheStats() {
|
|
317
|
+
try {
|
|
318
|
+
const native = getNativeBridge();
|
|
319
|
+
if (!native?.getCacheStats) {
|
|
320
|
+
return null;
|
|
303
321
|
}
|
|
322
|
+
const [hits, misses] = native.getCacheStats();
|
|
323
|
+
return { hits, misses };
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
304
326
|
}
|
|
305
|
-
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
306
|
-
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
307
|
-
for (const bin of BINARY_NAMES) {
|
|
308
|
-
candidates.push(path5__default.resolve(runtimeDir, `${bin}.node`));
|
|
309
|
-
candidates.push(path5__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
310
|
-
candidates.push(path5__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
311
|
-
candidates.push(path5__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
312
|
-
candidates.push(path5__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
313
|
-
candidates.push(path5__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
314
|
-
candidates.push(path5__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
315
|
-
candidates.push(path5__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
316
|
-
candidates.push(path5__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
317
|
-
}
|
|
318
|
-
return Array.from(new Set(candidates));
|
|
319
327
|
}
|
|
320
|
-
function
|
|
328
|
+
function clearThemeCache() {
|
|
321
329
|
try {
|
|
322
|
-
|
|
330
|
+
const native = getNativeBridge();
|
|
331
|
+
if (!native?.clearThemeCache) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
native.clearThemeCache();
|
|
323
335
|
} catch {
|
|
324
|
-
return process.cwd();
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
|
-
var
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
init_workerResolver();
|
|
331
|
-
init_native_resolution();
|
|
332
|
-
TwError = class _TwError extends Error {
|
|
333
|
-
/** @deprecated Gunakan source */
|
|
334
|
-
domain;
|
|
335
|
-
source;
|
|
336
|
-
code;
|
|
337
|
-
originalCause;
|
|
338
|
-
constructor(domainOrSource, code, message, cause) {
|
|
339
|
-
super(message);
|
|
340
|
-
this.name = "TwError";
|
|
341
|
-
this.domain = domainOrSource;
|
|
342
|
-
this.source = domainOrSource;
|
|
343
|
-
this.code = code;
|
|
344
|
-
this.originalCause = cause;
|
|
345
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
|
|
346
|
-
}
|
|
347
|
-
static fromIo(code, message) {
|
|
348
|
-
return new _TwError("io", code, message);
|
|
349
|
-
}
|
|
350
|
-
static fromCompile(code, message) {
|
|
351
|
-
return new _TwError("compile", code, message);
|
|
352
|
-
}
|
|
353
|
-
static fromRust(err) {
|
|
354
|
-
if (err instanceof _TwError) return err;
|
|
355
|
-
if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
|
|
356
|
-
if (err && typeof err === "object") {
|
|
357
|
-
const e = err;
|
|
358
|
-
return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
|
|
359
|
-
}
|
|
360
|
-
return new _TwError("rust", "RUST_ERROR", String(err), err);
|
|
361
|
-
}
|
|
362
|
-
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
363
|
-
static fromZod(err) {
|
|
364
|
-
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
365
|
-
const path7 = formatIssuePath(first?.path);
|
|
366
|
-
const message = first ? `${path7}: ${first.message}` : "Schema validation failed";
|
|
367
|
-
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
368
|
-
}
|
|
369
|
-
static wrap(source, code, err) {
|
|
370
|
-
if (err instanceof _TwError) return err;
|
|
371
|
-
if (err instanceof Error) return new _TwError(source, code, err.message, err);
|
|
372
|
-
return new _TwError(source, code, String(err), err);
|
|
373
|
-
}
|
|
374
|
-
toString() {
|
|
375
|
-
return `TwError [${this.source}:${this.code}] ${this.message}`;
|
|
376
|
-
}
|
|
377
|
-
toJSON() {
|
|
378
|
-
return { name: this.name, source: this.source, code: this.code, message: this.message };
|
|
379
|
-
}
|
|
380
|
-
toCliMessage() {
|
|
381
|
-
return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
_require2 = createRequire(import.meta.url);
|
|
338
|
+
var init_cssGeneratorNative = __esm({
|
|
339
|
+
"packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
|
|
340
|
+
init_nativeBridge();
|
|
385
341
|
}
|
|
386
342
|
});
|
|
387
343
|
|
|
388
|
-
// packages/domain/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
cacheReadNative: () => cacheReadNative,
|
|
394
|
-
cacheWriteNative: () => cacheWriteNative,
|
|
395
|
-
collectFilesNative: () => collectFilesNative,
|
|
396
|
-
computeCacheStatsNative: () => computeCacheStatsNative,
|
|
397
|
-
extractClassesNative: () => extractClassesNative,
|
|
398
|
-
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
399
|
-
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
400
|
-
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
401
|
-
hashContentNative: () => hashContentNative,
|
|
402
|
-
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
403
|
-
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
404
|
-
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
405
|
-
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
406
|
-
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
407
|
-
scanCacheGet: () => scanCacheGet,
|
|
408
|
-
scanCacheInvalidate: () => scanCacheInvalidate,
|
|
409
|
-
scanCachePut: () => scanCachePut,
|
|
410
|
-
scanCacheStats: () => scanCacheStats,
|
|
411
|
-
scanFileNative: () => scanFileNative,
|
|
412
|
-
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
413
|
-
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
414
|
-
startWatchNative: () => startWatchNative,
|
|
415
|
-
stopWatchNative: () => stopWatchNative
|
|
416
|
-
});
|
|
417
|
-
function getDirname() {
|
|
418
|
-
if (typeof __dirname !== "undefined") {
|
|
419
|
-
return __dirname;
|
|
420
|
-
}
|
|
421
|
-
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
422
|
-
return path5__default.dirname(fileURLToPath(import.meta.url));
|
|
423
|
-
}
|
|
424
|
-
return process.cwd();
|
|
344
|
+
// packages/domain/compiler/src/compiler/compilationNative.ts
|
|
345
|
+
function compileCssNative2(classes, prefix) {
|
|
346
|
+
const native = getNativeBridge();
|
|
347
|
+
if (!native?.compileCss) throw new Error("compileCss not available");
|
|
348
|
+
return native.compileCss(classes, prefix);
|
|
425
349
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
350
|
+
function compileCssLightning(classes) {
|
|
351
|
+
const native = getNativeBridge();
|
|
352
|
+
if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
|
|
353
|
+
return native.compileCssLightning(classes);
|
|
428
354
|
}
|
|
429
|
-
function
|
|
430
|
-
const
|
|
431
|
-
if (
|
|
432
|
-
|
|
433
|
-
"rust",
|
|
434
|
-
"SCANNER_EXTRACT_FAILED",
|
|
435
|
-
"Native extractClassesFromSource returned null/undefined"
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
return result;
|
|
355
|
+
function extractTwStateConfigsNative(source, filename) {
|
|
356
|
+
const native = getNativeBridge();
|
|
357
|
+
if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
|
|
358
|
+
return native.extractTwStateConfigs(source, filename);
|
|
439
359
|
}
|
|
440
|
-
function
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
"rust",
|
|
445
|
-
"SCANNER_HASH_FAILED",
|
|
446
|
-
"Native hashFileContent returned null/undefined"
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
return result;
|
|
360
|
+
function generateStaticStateCssNative(inputs, resolvedCss) {
|
|
361
|
+
const native = getNativeBridge();
|
|
362
|
+
if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
|
|
363
|
+
return native.generateStaticStateCss(inputs, resolvedCss ?? null);
|
|
450
364
|
}
|
|
451
|
-
function
|
|
452
|
-
|
|
365
|
+
function extractAndGenerateStateCssNative(source, filename) {
|
|
366
|
+
const native = getNativeBridge();
|
|
367
|
+
if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
|
|
368
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
453
369
|
}
|
|
454
|
-
function
|
|
370
|
+
function layoutClassesToCss(classes) {
|
|
371
|
+
const native = getNativeBridge();
|
|
372
|
+
if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
|
|
373
|
+
return native.layoutClassesToCss(classes);
|
|
374
|
+
}
|
|
375
|
+
function hashContent(input, algorithm = "sha256", length = 8) {
|
|
376
|
+
const native = getNativeBridge();
|
|
377
|
+
if (!native?.hashContent) throw new Error("hashContent not available");
|
|
378
|
+
return native.hashContent(input, algorithm, length);
|
|
379
|
+
}
|
|
380
|
+
function extractTwContainerConfigs(source) {
|
|
381
|
+
const native = getNativeBridge();
|
|
382
|
+
if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
|
|
383
|
+
return native.extractTwContainerConfigs(source);
|
|
384
|
+
}
|
|
385
|
+
function parseAtomicClass(twClass) {
|
|
386
|
+
const native = getNativeBridge();
|
|
387
|
+
if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
|
|
388
|
+
return native.parseAtomicClass(twClass);
|
|
389
|
+
}
|
|
390
|
+
function generateAtomicCss(rulesJson) {
|
|
391
|
+
const native = getNativeBridge();
|
|
392
|
+
if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
|
|
393
|
+
return native.generateAtomicCss(rulesJson);
|
|
394
|
+
}
|
|
395
|
+
function toAtomicClasses(twClasses) {
|
|
396
|
+
const native = getNativeBridge();
|
|
397
|
+
if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
|
|
398
|
+
return native.toAtomicClasses(twClasses);
|
|
399
|
+
}
|
|
400
|
+
function clearAtomicRegistry() {
|
|
401
|
+
const native = getNativeBridge();
|
|
402
|
+
if (!native?.clearAtomicRegistry) return;
|
|
403
|
+
native.clearAtomicRegistry();
|
|
404
|
+
}
|
|
405
|
+
function atomicRegistrySize() {
|
|
406
|
+
const native = getNativeBridge();
|
|
407
|
+
if (!native?.atomicRegistrySize) return 0;
|
|
408
|
+
return native.atomicRegistrySize();
|
|
409
|
+
}
|
|
410
|
+
var init_compilationNative = __esm({
|
|
411
|
+
"packages/domain/compiler/src/compiler/compilationNative.ts"() {
|
|
412
|
+
init_nativeBridge();
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
// packages/domain/compiler/src/compiler/cssCompilationNative.ts
|
|
417
|
+
function compileClass(input) {
|
|
418
|
+
const native = getNativeBridge();
|
|
419
|
+
if (!native?.compile_class) throw new Error("compile_class not available");
|
|
420
|
+
const resultJson = native.compile_class(input);
|
|
455
421
|
try {
|
|
456
|
-
|
|
457
|
-
return true;
|
|
422
|
+
return JSON.parse(resultJson);
|
|
458
423
|
} catch {
|
|
459
|
-
return
|
|
424
|
+
return {
|
|
425
|
+
selector: "",
|
|
426
|
+
declarations: "",
|
|
427
|
+
properties: [],
|
|
428
|
+
specificity: 0
|
|
429
|
+
};
|
|
460
430
|
}
|
|
461
431
|
}
|
|
462
|
-
function
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
432
|
+
function compileClasses(inputs) {
|
|
433
|
+
const native = getNativeBridge();
|
|
434
|
+
if (!native?.compile_classes) throw new Error("compile_classes not available");
|
|
435
|
+
const resultJson = native.compile_classes(inputs);
|
|
436
|
+
try {
|
|
437
|
+
return JSON.parse(resultJson);
|
|
438
|
+
} catch {
|
|
439
|
+
return {
|
|
440
|
+
css: "",
|
|
441
|
+
resolved_classes: [],
|
|
442
|
+
unknown_classes: [],
|
|
443
|
+
size_bytes: 0,
|
|
444
|
+
duration_ms: 0
|
|
445
|
+
};
|
|
470
446
|
}
|
|
471
|
-
return result;
|
|
472
447
|
}
|
|
473
|
-
function
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
476
|
-
|
|
477
|
-
"rust",
|
|
478
|
-
"SCANNER_CACHE_WRITE_FAILED",
|
|
479
|
-
"Native cacheWrite returned null/undefined"
|
|
480
|
-
);
|
|
481
|
-
}
|
|
482
|
-
return result;
|
|
448
|
+
function compileToCss(input, minify) {
|
|
449
|
+
const native = getNativeBridge();
|
|
450
|
+
if (!native?.compile_to_css) throw new Error("compile_to_css not available");
|
|
451
|
+
return native.compile_to_css(input, minify ?? false);
|
|
483
452
|
}
|
|
484
|
-
function
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
cachedMtimeMs,
|
|
489
|
-
cachedSize,
|
|
490
|
-
cachedHitCount,
|
|
491
|
-
cachedLastSeenMs,
|
|
492
|
-
nowMs
|
|
493
|
-
);
|
|
494
|
-
if (result === null || result === void 0) {
|
|
495
|
-
throw new TwError(
|
|
496
|
-
"rust",
|
|
497
|
-
"SCANNER_CACHE_PRIORITY_FAILED",
|
|
498
|
-
"Native cachePriority returned null/undefined"
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
return result;
|
|
453
|
+
function compileToCssBatch(inputs, minify) {
|
|
454
|
+
const native = getNativeBridge();
|
|
455
|
+
if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
|
|
456
|
+
return native.compile_to_css_batch(inputs, minify ?? false);
|
|
502
457
|
}
|
|
503
|
-
function
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
return binding.batchExtractClasses(filePaths) ?? [];
|
|
458
|
+
function minifyCss(css) {
|
|
459
|
+
const native = getNativeBridge();
|
|
460
|
+
if (!native?.minify_css) throw new Error("minify_css not available");
|
|
461
|
+
return native.minify_css(css);
|
|
509
462
|
}
|
|
510
|
-
function
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
513
|
-
|
|
463
|
+
function compileAnimation(animationName, from, to) {
|
|
464
|
+
const native = getNativeBridge();
|
|
465
|
+
if (!native?.compile_animation) throw new Error("compile_animation not available");
|
|
466
|
+
const resultJson = native.compile_animation(animationName, from, to);
|
|
467
|
+
try {
|
|
468
|
+
return JSON.parse(resultJson);
|
|
469
|
+
} catch {
|
|
470
|
+
return {
|
|
471
|
+
animation_id: "",
|
|
472
|
+
keyframes_css: "",
|
|
473
|
+
animation_rule: "",
|
|
474
|
+
duration_ms: 0
|
|
475
|
+
};
|
|
514
476
|
}
|
|
515
|
-
return binding.scanCacheGet(filePath, contentHash) ?? null;
|
|
516
477
|
}
|
|
517
|
-
function
|
|
518
|
-
const
|
|
519
|
-
if (!
|
|
520
|
-
|
|
478
|
+
function compileKeyframes(name, stopsJson) {
|
|
479
|
+
const native = getNativeBridge();
|
|
480
|
+
if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
|
|
481
|
+
const resultJson = native.compile_keyframes(name, stopsJson);
|
|
482
|
+
try {
|
|
483
|
+
return JSON.parse(resultJson);
|
|
484
|
+
} catch {
|
|
485
|
+
return {
|
|
486
|
+
animation_id: "",
|
|
487
|
+
keyframes_css: "",
|
|
488
|
+
animation_rule: "",
|
|
489
|
+
duration_ms: 0
|
|
490
|
+
};
|
|
521
491
|
}
|
|
522
|
-
binding.scanCachePut(filePath, contentHash, classes, mtimeMs, size);
|
|
523
492
|
}
|
|
524
|
-
function
|
|
525
|
-
const
|
|
526
|
-
if (!
|
|
527
|
-
|
|
493
|
+
function compileTheme(tokensJson, themeName, prefix) {
|
|
494
|
+
const native = getNativeBridge();
|
|
495
|
+
if (!native?.compile_theme) throw new Error("compile_theme not available");
|
|
496
|
+
const resultJson = native.compile_theme(tokensJson, themeName, prefix);
|
|
497
|
+
try {
|
|
498
|
+
return JSON.parse(resultJson);
|
|
499
|
+
} catch {
|
|
500
|
+
return {
|
|
501
|
+
selector: ":root",
|
|
502
|
+
variables: [],
|
|
503
|
+
variables_css: "",
|
|
504
|
+
theme_name: themeName
|
|
505
|
+
};
|
|
528
506
|
}
|
|
529
|
-
binding.scanCacheInvalidate(filePath);
|
|
530
507
|
}
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
return binding.scanCacheStats();
|
|
508
|
+
function twMerge(classString) {
|
|
509
|
+
const native = getNativeBridge();
|
|
510
|
+
if (!native?.tw_merge) throw new Error("tw_merge not available");
|
|
511
|
+
return native.tw_merge(classString);
|
|
537
512
|
}
|
|
538
|
-
function
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
return binding.scanFile(filePath);
|
|
513
|
+
function twMergeMany(classStrings) {
|
|
514
|
+
const native = getNativeBridge();
|
|
515
|
+
if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
|
|
516
|
+
return native.tw_merge_many(classStrings);
|
|
544
517
|
}
|
|
545
|
-
function
|
|
546
|
-
const
|
|
547
|
-
if (!
|
|
548
|
-
|
|
518
|
+
function twMergeWithSeparator(classString, options) {
|
|
519
|
+
const native = getNativeBridge();
|
|
520
|
+
if (!native?.tw_merge_with_separator)
|
|
521
|
+
throw new Error("tw_merge_with_separator not available");
|
|
522
|
+
const opts = {
|
|
523
|
+
separator: options.separator,
|
|
524
|
+
debug: options.debug
|
|
525
|
+
};
|
|
526
|
+
return native.tw_merge_with_separator(classString, opts);
|
|
549
527
|
}
|
|
550
|
-
function
|
|
551
|
-
const
|
|
552
|
-
if (!
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
528
|
+
function twMergeManyWithSeparator(classStrings, options) {
|
|
529
|
+
const native = getNativeBridge();
|
|
530
|
+
if (!native?.tw_merge_many_with_separator)
|
|
531
|
+
throw new Error("tw_merge_many_with_separator not available");
|
|
532
|
+
const opts = {
|
|
533
|
+
separator: options.separator,
|
|
534
|
+
debug: options.debug
|
|
535
|
+
};
|
|
536
|
+
return native.tw_merge_many_with_separator(classStrings, opts);
|
|
537
|
+
}
|
|
538
|
+
function twMergeRaw(classLists) {
|
|
539
|
+
const native = getNativeBridge();
|
|
540
|
+
if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
|
|
541
|
+
return native.tw_merge_raw(classLists);
|
|
542
|
+
}
|
|
543
|
+
var init_cssCompilationNative = __esm({
|
|
544
|
+
"packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
|
|
545
|
+
init_nativeBridge();
|
|
561
546
|
}
|
|
562
|
-
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// packages/domain/compiler/src/compiler/idRegistryNative.ts
|
|
550
|
+
function idRegistryCreate() {
|
|
551
|
+
const native = getNativeBridge();
|
|
552
|
+
if (!native?.id_registry_create) throw new Error("id_registry_create not available");
|
|
553
|
+
return native.id_registry_create();
|
|
563
554
|
}
|
|
564
|
-
function
|
|
565
|
-
const
|
|
566
|
-
if (!
|
|
567
|
-
return
|
|
555
|
+
function idRegistryGenerate(handle, name) {
|
|
556
|
+
const native = getNativeBridge();
|
|
557
|
+
if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
|
|
558
|
+
return native.id_registry_generate(handle, name);
|
|
568
559
|
}
|
|
569
|
-
function
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
572
|
-
return
|
|
573
|
-
entries.map((e) => ({ file: e.file, lastSeenMs: e.lastSeenMs ?? 0 })),
|
|
574
|
-
maxAgeMs ?? null,
|
|
575
|
-
checkExists ?? null
|
|
576
|
-
);
|
|
560
|
+
function idRegistryLookup(handle, name) {
|
|
561
|
+
const native = getNativeBridge();
|
|
562
|
+
if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
|
|
563
|
+
return native.id_registry_lookup(handle, name);
|
|
577
564
|
}
|
|
578
|
-
function
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
565
|
+
function idRegistryNext(handle) {
|
|
566
|
+
const native = getNativeBridge();
|
|
567
|
+
if (!native?.id_registry_next) throw new Error("id_registry_next not available");
|
|
568
|
+
return native.id_registry_next(handle);
|
|
569
|
+
}
|
|
570
|
+
function idRegistryDestroy(handle) {
|
|
571
|
+
const native = getNativeBridge();
|
|
572
|
+
if (!native?.id_registry_destroy) return;
|
|
573
|
+
native.id_registry_destroy(handle);
|
|
574
|
+
}
|
|
575
|
+
function idRegistryReset(handle) {
|
|
576
|
+
const native = getNativeBridge();
|
|
577
|
+
if (!native?.id_registry_reset) return;
|
|
578
|
+
native.id_registry_reset(handle);
|
|
579
|
+
}
|
|
580
|
+
function idRegistrySnapshot(handle) {
|
|
581
|
+
const native = getNativeBridge();
|
|
582
|
+
if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
|
|
583
|
+
const snapshotJson = native.id_registry_snapshot(handle);
|
|
581
584
|
try {
|
|
582
|
-
return
|
|
585
|
+
return JSON.parse(snapshotJson);
|
|
583
586
|
} catch {
|
|
584
|
-
return
|
|
587
|
+
return {
|
|
588
|
+
handle,
|
|
589
|
+
next_id: 0,
|
|
590
|
+
entries: [],
|
|
591
|
+
total_entries: 0
|
|
592
|
+
};
|
|
585
593
|
}
|
|
586
594
|
}
|
|
587
|
-
function
|
|
588
|
-
const
|
|
589
|
-
if (!
|
|
590
|
-
return
|
|
595
|
+
function idRegistryActiveCount() {
|
|
596
|
+
const native = getNativeBridge();
|
|
597
|
+
if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
|
|
598
|
+
return native.id_registry_active_count();
|
|
591
599
|
}
|
|
592
|
-
function
|
|
600
|
+
function registerPropertyName(propertyName) {
|
|
601
|
+
const native = getNativeBridge();
|
|
602
|
+
if (!native?.register_property_name)
|
|
603
|
+
throw new Error("register_property_name not available");
|
|
604
|
+
return native.register_property_name(propertyName);
|
|
605
|
+
}
|
|
606
|
+
function registerValueName(valueName) {
|
|
607
|
+
const native = getNativeBridge();
|
|
608
|
+
if (!native?.register_value_name) throw new Error("register_value_name not available");
|
|
609
|
+
return native.register_value_name(valueName);
|
|
610
|
+
}
|
|
611
|
+
function propertyIdToString(propertyId) {
|
|
612
|
+
const native = getNativeBridge();
|
|
613
|
+
if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
|
|
614
|
+
return native.property_id_to_string(propertyId);
|
|
615
|
+
}
|
|
616
|
+
function valueIdToString(valueId) {
|
|
617
|
+
const native = getNativeBridge();
|
|
618
|
+
if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
|
|
619
|
+
return native.value_id_to_string(valueId);
|
|
620
|
+
}
|
|
621
|
+
function reverseLookupProperty(propertyId) {
|
|
622
|
+
const native = getNativeBridge();
|
|
623
|
+
if (!native?.reverse_lookup_property)
|
|
624
|
+
throw new Error("reverse_lookup_property not available");
|
|
625
|
+
return native.reverse_lookup_property(propertyId);
|
|
626
|
+
}
|
|
627
|
+
function reverseLookupValue(valueId) {
|
|
628
|
+
const native = getNativeBridge();
|
|
629
|
+
if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
|
|
630
|
+
return native.reverse_lookup_value(valueId);
|
|
631
|
+
}
|
|
632
|
+
function idRegistryExport(handle) {
|
|
633
|
+
const native = getNativeBridge();
|
|
634
|
+
if (!native?.id_registry_export) throw new Error("id_registry_export not available");
|
|
635
|
+
return native.id_registry_export(handle);
|
|
636
|
+
}
|
|
637
|
+
function idRegistryImport(importedData) {
|
|
638
|
+
const native = getNativeBridge();
|
|
639
|
+
if (!native?.id_registry_import) throw new Error("id_registry_import not available");
|
|
640
|
+
return native.id_registry_import(importedData);
|
|
641
|
+
}
|
|
642
|
+
var init_idRegistryNative = __esm({
|
|
643
|
+
"packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
|
|
644
|
+
init_nativeBridge();
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// packages/domain/compiler/src/compiler/streamingNative.ts
|
|
649
|
+
function processFileChange(fileChangeJson) {
|
|
650
|
+
const native = getNativeBridge();
|
|
651
|
+
if (!native?.process_file_change) throw new Error("process_file_change not available");
|
|
652
|
+
const resultJson = native.process_file_change(fileChangeJson);
|
|
593
653
|
try {
|
|
594
|
-
|
|
595
|
-
if (!binding.startWatch) return null;
|
|
596
|
-
return binding.startWatch(rootDir);
|
|
654
|
+
return JSON.parse(resultJson);
|
|
597
655
|
} catch {
|
|
598
|
-
return
|
|
656
|
+
return {
|
|
657
|
+
file_path: "",
|
|
658
|
+
status: "error",
|
|
659
|
+
old_classes: [],
|
|
660
|
+
new_classes: [],
|
|
661
|
+
added_classes: [],
|
|
662
|
+
removed_classes: [],
|
|
663
|
+
changed: false,
|
|
664
|
+
fingerprint: "",
|
|
665
|
+
error: "Failed to parse result"
|
|
666
|
+
};
|
|
599
667
|
}
|
|
600
668
|
}
|
|
601
|
-
function
|
|
669
|
+
function computeIncrementalDiff(oldScanJson, newScanJson) {
|
|
670
|
+
const native = getNativeBridge();
|
|
671
|
+
if (!native?.compute_incremental_diff)
|
|
672
|
+
throw new Error("compute_incremental_diff not available");
|
|
673
|
+
const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
|
|
602
674
|
try {
|
|
603
|
-
|
|
604
|
-
if (!binding.pollWatchEvents) return [];
|
|
605
|
-
return binding.pollWatchEvents(handleId);
|
|
675
|
+
return JSON.parse(resultJson);
|
|
606
676
|
} catch {
|
|
607
|
-
return
|
|
677
|
+
return {
|
|
678
|
+
is_changed: false,
|
|
679
|
+
changes_count: 0,
|
|
680
|
+
diff: {
|
|
681
|
+
added_files: [],
|
|
682
|
+
removed_files: [],
|
|
683
|
+
modified_files: [],
|
|
684
|
+
added_classes: [],
|
|
685
|
+
removed_classes: [],
|
|
686
|
+
total_changes: 0
|
|
687
|
+
},
|
|
688
|
+
processing_time_ms: 0
|
|
689
|
+
};
|
|
608
690
|
}
|
|
609
691
|
}
|
|
610
|
-
function
|
|
692
|
+
function createFingerprint(filePath, fileContent) {
|
|
693
|
+
const native = getNativeBridge();
|
|
694
|
+
if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
|
|
695
|
+
const fingerprintJson = native.create_fingerprint(filePath, fileContent);
|
|
611
696
|
try {
|
|
612
|
-
|
|
613
|
-
if (!binding.stopWatch) return false;
|
|
614
|
-
return binding.stopWatch(handleId);
|
|
697
|
+
return JSON.parse(fingerprintJson);
|
|
615
698
|
} catch {
|
|
616
|
-
return
|
|
699
|
+
return {
|
|
700
|
+
file_path: filePath,
|
|
701
|
+
content_hash: "",
|
|
702
|
+
size_bytes: fileContent.length,
|
|
703
|
+
mtime_ms: Date.now(),
|
|
704
|
+
class_hash: "",
|
|
705
|
+
signature: ""
|
|
706
|
+
};
|
|
617
707
|
}
|
|
618
708
|
}
|
|
619
|
-
function
|
|
709
|
+
function injectStateHash(css, stateHash) {
|
|
710
|
+
const native = getNativeBridge();
|
|
711
|
+
if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
|
|
712
|
+
const resultJson = native.inject_state_hash(css, stateHash);
|
|
620
713
|
try {
|
|
621
|
-
|
|
622
|
-
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
714
|
+
return JSON.parse(resultJson);
|
|
623
715
|
} catch {
|
|
624
|
-
return
|
|
716
|
+
return {
|
|
717
|
+
injected: false,
|
|
718
|
+
state_hash: stateHash,
|
|
719
|
+
affected_files: 0,
|
|
720
|
+
total_injected_bytes: 0
|
|
721
|
+
};
|
|
625
722
|
}
|
|
626
723
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
loadError: null,
|
|
640
|
-
candidatePaths: []
|
|
641
|
-
};
|
|
642
|
-
const throwNativeBindingError = () => {
|
|
643
|
-
const lines = [
|
|
644
|
-
"FATAL: Native scanner binding not found.",
|
|
645
|
-
"",
|
|
646
|
-
"This package requires the Rust native binding 'tailwind_styled_parser.node'.",
|
|
647
|
-
"The binding was not found in any of these paths:",
|
|
648
|
-
..._state.candidatePaths.map((p) => ` - ${p}`),
|
|
649
|
-
""
|
|
650
|
-
];
|
|
651
|
-
if (_state.loadError) {
|
|
652
|
-
lines.push("Load error:", ` ${_state.loadError}`, "");
|
|
653
|
-
}
|
|
654
|
-
lines.push(
|
|
655
|
-
"To fix this, run:",
|
|
656
|
-
" npm run build:rust",
|
|
657
|
-
"",
|
|
658
|
-
"This will build the native Rust module from the 'native/' directory.",
|
|
659
|
-
"If you're using this package in a CI/CD environment, ensure Rust toolchain is installed",
|
|
660
|
-
"and 'npm run build:rust' is executed before running tests or building."
|
|
661
|
-
);
|
|
662
|
-
throw new TwError("rust", "SCANNER_NATIVE_BINDING_NOT_FOUND", lines.join("\n"));
|
|
663
|
-
};
|
|
664
|
-
const scannerGetBinding2 = () => {
|
|
665
|
-
const cachedBinding = _state.binding;
|
|
666
|
-
if (cachedBinding !== void 0) {
|
|
667
|
-
if (cachedBinding !== null) {
|
|
668
|
-
return cachedBinding;
|
|
669
|
-
}
|
|
670
|
-
return throwNativeBindingError();
|
|
671
|
-
}
|
|
672
|
-
const runtimeDir = getDirname();
|
|
673
|
-
const candidates = resolveNativeBindingCandidates({
|
|
674
|
-
runtimeDir,
|
|
675
|
-
includeDefaultCandidates: true
|
|
676
|
-
});
|
|
677
|
-
_state.candidatePaths = candidates;
|
|
678
|
-
const { binding, loadErrors } = loadNativeBinding({
|
|
679
|
-
runtimeDir,
|
|
680
|
-
candidates,
|
|
681
|
-
isValid: isValidScannerBinding,
|
|
682
|
-
invalidExportMessage: "Module loaded but missing expected scanner binding functions"
|
|
683
|
-
});
|
|
684
|
-
if (binding) {
|
|
685
|
-
log(`scanner native binding loaded successfully`);
|
|
686
|
-
_state.binding = binding;
|
|
687
|
-
return _state.binding;
|
|
688
|
-
}
|
|
689
|
-
if (loadErrors.length > 0) {
|
|
690
|
-
_state.loadError = loadErrors.map((e) => `${e.path}: ${e.message}`).join("; ");
|
|
691
|
-
}
|
|
692
|
-
_state.binding = null;
|
|
693
|
-
return throwNativeBindingError();
|
|
694
|
-
};
|
|
695
|
-
return {
|
|
696
|
-
get: scannerGetBinding2,
|
|
697
|
-
scannerGetBinding: scannerGetBinding2,
|
|
698
|
-
reset: () => {
|
|
699
|
-
_state.binding = void 0;
|
|
700
|
-
_state.loadError = null;
|
|
701
|
-
_state.candidatePaths = [];
|
|
702
|
-
}
|
|
703
|
-
};
|
|
724
|
+
function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
|
|
725
|
+
const native = getNativeBridge();
|
|
726
|
+
if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
|
|
727
|
+
const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
|
|
728
|
+
try {
|
|
729
|
+
return JSON.parse(resultJson);
|
|
730
|
+
} catch {
|
|
731
|
+
return {
|
|
732
|
+
entries_before: 0,
|
|
733
|
+
entries_after: 0,
|
|
734
|
+
entries_removed: 0,
|
|
735
|
+
freed_bytes: 0
|
|
704
736
|
};
|
|
705
|
-
scannerBridgeLoader = createScannerBridgeLoader();
|
|
706
|
-
scannerGetBinding = scannerBridgeLoader.get;
|
|
707
|
-
resetScannerBridgeCache = scannerBridgeLoader.reset;
|
|
708
737
|
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
bridgeLoadAttempted = false;
|
|
725
|
-
bridgeLoadError = null;
|
|
726
|
-
isValidNativeBridge = (mod) => {
|
|
727
|
-
const m = mod;
|
|
728
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
729
|
-
};
|
|
730
|
-
getNativeBridge = () => {
|
|
731
|
-
if (nativeBridge) {
|
|
732
|
-
return nativeBridge;
|
|
733
|
-
}
|
|
734
|
-
if (bridgeLoadAttempted) {
|
|
735
|
-
if (bridgeLoadError) {
|
|
736
|
-
throw bridgeLoadError;
|
|
737
|
-
}
|
|
738
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
739
|
-
}
|
|
740
|
-
bridgeLoadAttempted = true;
|
|
741
|
-
try {
|
|
742
|
-
const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
|
|
743
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
744
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
745
|
-
try {
|
|
746
|
-
const binding = _loadNative(result.path);
|
|
747
|
-
if (isValidNativeBridge(binding)) {
|
|
748
|
-
nativeBridge = binding;
|
|
749
|
-
log3("Native bridge loaded successfully from:", result.path);
|
|
750
|
-
return nativeBridge;
|
|
751
|
-
}
|
|
752
|
-
} catch (e) {
|
|
753
|
-
log3("Failed to require native binding:", e);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
757
|
-
|
|
758
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
759
|
-
} catch (err) {
|
|
760
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
761
|
-
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
762
|
-
throw bridgeLoadError;
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
resetNativeBridgeCache = () => {
|
|
766
|
-
nativeBridge = null;
|
|
767
|
-
bridgeLoadAttempted = false;
|
|
768
|
-
bridgeLoadError = null;
|
|
769
|
-
log3("Native bridge cache reset");
|
|
738
|
+
}
|
|
739
|
+
function rebuildWorkspaceResult(rootDir, extensions) {
|
|
740
|
+
const native = getNativeBridge();
|
|
741
|
+
if (!native?.rebuild_workspace_result)
|
|
742
|
+
throw new Error("rebuild_workspace_result not available");
|
|
743
|
+
const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
|
|
744
|
+
try {
|
|
745
|
+
return JSON.parse(resultJson);
|
|
746
|
+
} catch {
|
|
747
|
+
return {
|
|
748
|
+
total_files_scanned: 0,
|
|
749
|
+
total_classes_found: 0,
|
|
750
|
+
unique_classes: 0,
|
|
751
|
+
build_time_ms: 0,
|
|
752
|
+
files_with_changes: 0
|
|
770
753
|
};
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function scanFileNative(filePath, fileContent) {
|
|
757
|
+
const native = getNativeBridge();
|
|
758
|
+
if (!native?.scan_file_native) throw new Error("scan_file_native not available");
|
|
759
|
+
const resultJson = native.scan_file_native(filePath, fileContent);
|
|
760
|
+
try {
|
|
761
|
+
return JSON.parse(resultJson);
|
|
762
|
+
} catch {
|
|
763
|
+
return {
|
|
764
|
+
file: filePath,
|
|
765
|
+
classes: [],
|
|
766
|
+
added_classes: [],
|
|
767
|
+
removed_classes: [],
|
|
768
|
+
changed: false
|
|
779
769
|
};
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function scanFilesBatchNative(filesJson) {
|
|
773
|
+
const native = getNativeBridge();
|
|
774
|
+
if (!native?.scan_files_batch_native)
|
|
775
|
+
throw new Error("scan_files_batch_native not available");
|
|
776
|
+
const resultJson = native.scan_files_batch_native(filesJson);
|
|
777
|
+
try {
|
|
778
|
+
return JSON.parse(resultJson);
|
|
779
|
+
} catch {
|
|
780
|
+
return [];
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
var init_streamingNative = __esm({
|
|
784
|
+
"packages/domain/compiler/src/compiler/streamingNative.ts"() {
|
|
785
|
+
init_nativeBridge();
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
|
|
789
|
-
// packages/domain/compiler/src/tailwindEngine.ts
|
|
789
|
+
// packages/domain/compiler/src/compiler/tailwindEngine.ts
|
|
790
790
|
var tailwindEngine_exports = {};
|
|
791
791
|
__export(tailwindEngine_exports, {
|
|
792
|
-
|
|
792
|
+
clearCache: () => clearCache,
|
|
793
|
+
getCacheStats: () => getCacheStats2,
|
|
793
794
|
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
794
795
|
runCssPipeline: () => runCssPipeline,
|
|
795
796
|
runCssPipelineSync: () => runCssPipelineSync
|
|
796
797
|
});
|
|
797
|
-
function
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
798
|
+
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
799
|
+
const sorted = [...classes].sort().join(",");
|
|
800
|
+
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
801
|
+
return `${sorted}|${flags}`;
|
|
802
|
+
}
|
|
803
|
+
function _evictOldestIfNeeded() {
|
|
804
|
+
if (_cssCache.size >= MAX_CACHE_SIZE) {
|
|
805
|
+
const firstKey = _cssCache.keys().next().value;
|
|
806
|
+
if (firstKey !== void 0) {
|
|
807
|
+
_cssCache.delete(firstKey);
|
|
804
808
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function getCacheStats2() {
|
|
812
|
+
const total = _cacheHits + _cacheMisses;
|
|
813
|
+
return {
|
|
814
|
+
hits: _cacheHits,
|
|
815
|
+
misses: _cacheMisses,
|
|
816
|
+
hitRate: total > 0 ? _cacheHits / total : 0,
|
|
817
|
+
size: _cssCache.size,
|
|
818
|
+
maxSize: MAX_CACHE_SIZE
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
function clearCache() {
|
|
822
|
+
_cssCache.clear();
|
|
823
|
+
_cacheHits = 0;
|
|
824
|
+
_cacheMisses = 0;
|
|
825
|
+
}
|
|
826
|
+
function getThemeConfig() {
|
|
827
|
+
return {
|
|
828
|
+
colors: {
|
|
829
|
+
slate: {
|
|
830
|
+
"50": "#f8fafc",
|
|
831
|
+
"100": "#f1f5f9",
|
|
832
|
+
"200": "#e2e8f0",
|
|
833
|
+
"300": "#cbd5e1",
|
|
834
|
+
"400": "#94a3b8",
|
|
835
|
+
"500": "#64748b",
|
|
836
|
+
"600": "#475569",
|
|
837
|
+
"700": "#334155",
|
|
838
|
+
"800": "#1e293b",
|
|
839
|
+
"900": "#0f172a"
|
|
840
|
+
},
|
|
841
|
+
gray: {
|
|
842
|
+
"50": "#f9fafb",
|
|
843
|
+
"100": "#f3f4f6",
|
|
844
|
+
"200": "#e5e7eb",
|
|
845
|
+
"300": "#d1d5db",
|
|
846
|
+
"400": "#9ca3af",
|
|
847
|
+
"500": "#6b7280",
|
|
848
|
+
"600": "#4b5563",
|
|
849
|
+
"700": "#374151",
|
|
850
|
+
"800": "#1f2937",
|
|
851
|
+
"900": "#111827"
|
|
852
|
+
},
|
|
853
|
+
white: "#ffffff",
|
|
854
|
+
black: "#000000",
|
|
855
|
+
red: {
|
|
856
|
+
"500": "#ef4444",
|
|
857
|
+
"600": "#dc2626"
|
|
858
|
+
},
|
|
859
|
+
blue: {
|
|
860
|
+
"500": "#3b82f6",
|
|
861
|
+
"600": "#1e40af"
|
|
835
862
|
}
|
|
836
|
-
|
|
863
|
+
},
|
|
864
|
+
spacing: {
|
|
865
|
+
"0": "0px",
|
|
866
|
+
"1": "0.25rem",
|
|
867
|
+
"2": "0.5rem",
|
|
868
|
+
"3": "0.75rem",
|
|
869
|
+
"4": "1rem",
|
|
870
|
+
"5": "1.25rem",
|
|
871
|
+
"6": "1.5rem",
|
|
872
|
+
"8": "2rem",
|
|
873
|
+
"10": "2.5rem",
|
|
874
|
+
"12": "3rem",
|
|
875
|
+
"16": "4rem",
|
|
876
|
+
"20": "5rem",
|
|
877
|
+
"24": "6rem"
|
|
878
|
+
},
|
|
879
|
+
breakpoints: {
|
|
880
|
+
"sm": "640px",
|
|
881
|
+
"md": "768px",
|
|
882
|
+
"lg": "1024px",
|
|
883
|
+
"xl": "1280px",
|
|
884
|
+
"2xl": "1536px"
|
|
837
885
|
}
|
|
838
886
|
};
|
|
839
|
-
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
840
|
-
return compiler.build(classes);
|
|
841
887
|
}
|
|
842
888
|
function postProcessWithLightning(rawCss) {
|
|
843
889
|
if (!rawCss) return "";
|
|
844
890
|
const native = getNativeBridge();
|
|
845
|
-
if (
|
|
891
|
+
if (!native?.processTailwindCssLightning) {
|
|
846
892
|
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
847
893
|
}
|
|
848
894
|
const result = native.processTailwindCssLightning(rawCss);
|
|
849
|
-
|
|
895
|
+
if (!result?.css) {
|
|
896
|
+
throw new Error("FATAL: processTailwindCssLightning returned null");
|
|
897
|
+
}
|
|
898
|
+
return result.css;
|
|
850
899
|
}
|
|
851
900
|
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
852
|
-
const
|
|
901
|
+
const filtered = classes.filter(Boolean);
|
|
902
|
+
const uniqueMap = /* @__PURE__ */ new Map();
|
|
903
|
+
filtered.forEach((cls) => uniqueMap.set(cls, cls));
|
|
904
|
+
const unique = Array.from(uniqueMap.values());
|
|
853
905
|
if (unique.length === 0) {
|
|
854
906
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
855
907
|
}
|
|
856
|
-
const
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
908
|
+
const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
|
|
909
|
+
const cached = _cssCache.get(cacheKey);
|
|
910
|
+
if (cached) {
|
|
911
|
+
_cacheHits++;
|
|
912
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
913
|
+
console.log(
|
|
914
|
+
`[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats2().hitRate * 100).toFixed(1)}%)`
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
return cached;
|
|
918
|
+
}
|
|
919
|
+
_cacheMisses++;
|
|
920
|
+
let rawCss;
|
|
921
|
+
let usedRustCompiler = false;
|
|
922
|
+
const theme = getThemeConfig();
|
|
923
|
+
rawCss = await generateCssNative(unique, { theme });
|
|
924
|
+
usedRustCompiler = true;
|
|
925
|
+
const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
|
|
926
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
927
|
+
console.log(
|
|
928
|
+
`[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
|
|
929
|
+
`Size: ${finalCss.length} bytes`
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
const result = {
|
|
861
933
|
css: finalCss,
|
|
862
934
|
classes: unique,
|
|
863
935
|
sizeBytes: finalCss.length,
|
|
864
|
-
optimized:
|
|
936
|
+
optimized: minify
|
|
865
937
|
};
|
|
938
|
+
_evictOldestIfNeeded();
|
|
939
|
+
_cssCache.set(cacheKey, result);
|
|
940
|
+
return result;
|
|
866
941
|
}
|
|
867
942
|
function runCssPipelineSync(_classes) {
|
|
868
943
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
@@ -873,137 +948,63 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
873
948
|
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
874
949
|
}
|
|
875
950
|
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
876
|
-
|
|
951
|
+
if (!result?.css) {
|
|
952
|
+
throw new Error("FATAL: processTailwindCssWithTargets returned null");
|
|
953
|
+
}
|
|
954
|
+
return result.css;
|
|
877
955
|
}
|
|
878
|
-
var
|
|
956
|
+
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
879
957
|
var init_tailwindEngine = __esm({
|
|
880
|
-
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
958
|
+
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
881
959
|
init_nativeBridge();
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
960
|
+
init_cssGeneratorNative();
|
|
961
|
+
createRequire(import.meta.url);
|
|
962
|
+
_cssCache = /* @__PURE__ */ new Map();
|
|
963
|
+
_cacheHits = 0;
|
|
964
|
+
_cacheMisses = 0;
|
|
965
|
+
MAX_CACHE_SIZE = 100;
|
|
885
966
|
}
|
|
886
967
|
});
|
|
887
968
|
|
|
888
|
-
// packages/domain/compiler/src/index.ts
|
|
889
|
-
var
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
969
|
+
// packages/domain/compiler/src/compiler/index.ts
|
|
970
|
+
var init_compiler = __esm({
|
|
971
|
+
"packages/domain/compiler/src/compiler/index.ts"() {
|
|
972
|
+
init_cssGeneratorNative();
|
|
973
|
+
init_compilationNative();
|
|
974
|
+
init_cssCompilationNative();
|
|
975
|
+
init_idRegistryNative();
|
|
976
|
+
init_streamingNative();
|
|
977
|
+
init_tailwindEngine();
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
// packages/domain/compiler/src/parser/index.ts
|
|
982
|
+
var parser_exports = {};
|
|
983
|
+
__export(parser_exports, {
|
|
899
984
|
astExtractClasses: () => astExtractClasses,
|
|
900
985
|
batchExtractClasses: () => batchExtractClasses,
|
|
901
|
-
bucketSort: () => bucketSort,
|
|
902
|
-
buildStyleTag: () => buildStyleTag,
|
|
903
986
|
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
904
|
-
classifyAndSortClasses: () => classifyAndSortClasses,
|
|
905
|
-
classifyNode: () => classifyNode,
|
|
906
|
-
compileCssFromClasses: () => compileCssFromClasses,
|
|
907
|
-
compileCssNative: () => compileCssNative,
|
|
908
|
-
compileVariantTable: () => compileVariantTable,
|
|
909
|
-
compileVariants: () => compileVariants,
|
|
910
|
-
detectConflicts: () => detectConflicts,
|
|
911
987
|
diffClassLists: () => diffClassLists,
|
|
912
|
-
eliminateDeadCss: () => eliminateDeadCss,
|
|
913
988
|
extractAllClasses: () => extractAllClasses,
|
|
914
989
|
extractClassesFromSource: () => extractClassesFromSource,
|
|
915
990
|
extractComponentUsage: () => extractComponentUsage,
|
|
916
|
-
fileToRoute: () => fileToRoute,
|
|
917
|
-
findDeadVariants: () => findDeadVariants,
|
|
918
|
-
generateCssForClasses: () => generateCssForClasses,
|
|
919
|
-
generateSafelist: () => generateSafelist,
|
|
920
|
-
getAllRoutes: () => getAllRoutes,
|
|
921
|
-
getBucketEngine: () => getBucketEngine,
|
|
922
|
-
getContentPaths: () => getContentPaths,
|
|
923
|
-
getIncrementalEngine: () => getIncrementalEngine,
|
|
924
|
-
getNativeBridge: () => getNativeBridge,
|
|
925
|
-
getRouteClasses: () => getRouteClasses,
|
|
926
|
-
hasTwUsage: () => hasTwUsage,
|
|
927
|
-
hoistComponents: () => hoistComponents,
|
|
928
|
-
injectClientDirective: () => injectClientDirective,
|
|
929
|
-
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
930
|
-
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
931
|
-
loadSafelist: () => loadSafelist,
|
|
932
|
-
loadTailwindConfig: () => loadTailwindConfig,
|
|
933
991
|
mergeClassesStatic: () => mergeClassesStatic,
|
|
934
|
-
mergeCssDeclarations: () => mergeCssDeclarations,
|
|
935
992
|
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
936
993
|
normalizeClasses: () => normalizeClasses,
|
|
937
|
-
|
|
938
|
-
parseClasses: () => parseClasses,
|
|
939
|
-
registerFileClasses: () => registerFileClasses,
|
|
940
|
-
registerGlobalClasses: () => registerGlobalClasses,
|
|
941
|
-
resetBucketEngine: () => resetBucketEngine,
|
|
942
|
-
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
943
|
-
resetNativeBridgeCache: () => resetNativeBridgeCache,
|
|
944
|
-
runElimination: () => runElimination,
|
|
945
|
-
runLoaderTransform: () => runLoaderTransform,
|
|
946
|
-
scanProjectUsage: () => scanProjectUsage,
|
|
947
|
-
shouldProcess: () => shouldProcess,
|
|
948
|
-
shouldSkipFile: () => shouldSkipFile,
|
|
949
|
-
transformSource: () => transformSource
|
|
994
|
+
parseClasses: () => parseClasses
|
|
950
995
|
});
|
|
951
|
-
var
|
|
952
|
-
var
|
|
953
|
-
"packages/domain/compiler/src/index.ts"() {
|
|
996
|
+
var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
|
|
997
|
+
var init_parser = __esm({
|
|
998
|
+
"packages/domain/compiler/src/parser/index.ts"() {
|
|
954
999
|
init_nativeBridge();
|
|
955
|
-
|
|
1000
|
+
parseClasses = (raw) => {
|
|
956
1001
|
const native = getNativeBridge();
|
|
957
|
-
if (!native?.
|
|
958
|
-
throw new Error("FATAL: Native binding '
|
|
959
|
-
}
|
|
960
|
-
const result = native.transformSource(source, opts);
|
|
961
|
-
if (!result) {
|
|
962
|
-
throw new Error("FATAL: transformSource returned null");
|
|
1002
|
+
if (!native?.parseClasses) {
|
|
1003
|
+
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
963
1004
|
}
|
|
964
|
-
return
|
|
1005
|
+
return native.parseClasses(raw) || [];
|
|
965
1006
|
};
|
|
966
|
-
|
|
967
|
-
const native = getNativeBridge();
|
|
968
|
-
if (!native?.hasTwUsage) {
|
|
969
|
-
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
970
|
-
}
|
|
971
|
-
return native.hasTwUsage(source);
|
|
972
|
-
};
|
|
973
|
-
isAlreadyTransformed = (source) => {
|
|
974
|
-
const native = getNativeBridge();
|
|
975
|
-
if (!native?.isAlreadyTransformed) {
|
|
976
|
-
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
977
|
-
}
|
|
978
|
-
return native.isAlreadyTransformed(source);
|
|
979
|
-
};
|
|
980
|
-
shouldProcess = (source) => {
|
|
981
|
-
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
982
|
-
};
|
|
983
|
-
compileCssFromClasses = (classes, prefix) => {
|
|
984
|
-
const native = getNativeBridge();
|
|
985
|
-
if (!native?.transformSource) {
|
|
986
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
987
|
-
}
|
|
988
|
-
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
989
|
-
if (!result) {
|
|
990
|
-
throw new Error("FATAL: transformSource returned null");
|
|
991
|
-
}
|
|
992
|
-
return result;
|
|
993
|
-
};
|
|
994
|
-
buildStyleTag = (classes) => {
|
|
995
|
-
const result = compileCssFromClasses(classes);
|
|
996
|
-
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
997
|
-
};
|
|
998
|
-
compileCssNative = (classes, prefix = null) => {
|
|
999
|
-
return compileCssFromClasses(classes, prefix);
|
|
1000
|
-
};
|
|
1001
|
-
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
1002
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
1003
|
-
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
1004
|
-
return result.css;
|
|
1005
|
-
};
|
|
1006
|
-
extractAllClasses = (source) => {
|
|
1007
|
+
extractAllClasses = (source) => {
|
|
1007
1008
|
const native = getNativeBridge();
|
|
1008
1009
|
if (!native?.extractAllClasses) {
|
|
1009
1010
|
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
@@ -1018,20 +1019,13 @@ var init_src2 = __esm({
|
|
|
1018
1019
|
const result = native.extractClassesFromSource(source);
|
|
1019
1020
|
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
1020
1021
|
};
|
|
1021
|
-
astExtractClasses = (source,
|
|
1022
|
+
astExtractClasses = (source, _filename) => {
|
|
1022
1023
|
const native = getNativeBridge();
|
|
1023
1024
|
if (!native?.extractClassesFromSource) {
|
|
1024
1025
|
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1025
1026
|
}
|
|
1026
1027
|
return native.extractClassesFromSource(source) || [];
|
|
1027
1028
|
};
|
|
1028
|
-
parseClasses = (raw) => {
|
|
1029
|
-
const native = getNativeBridge();
|
|
1030
|
-
if (!native?.parseClasses) {
|
|
1031
|
-
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
1032
|
-
}
|
|
1033
|
-
return native.parseClasses(raw) || [];
|
|
1034
|
-
};
|
|
1035
1029
|
normalizeClasses = (raw) => {
|
|
1036
1030
|
const result = normalizeAndDedupClasses(raw);
|
|
1037
1031
|
return result?.normalized || "";
|
|
@@ -1048,85 +1042,6 @@ var init_src2 = __esm({
|
|
|
1048
1042
|
const result = native.normalizeAndDedupClasses(raw);
|
|
1049
1043
|
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
1050
1044
|
};
|
|
1051
|
-
eliminateDeadCss = (css, deadClasses) => {
|
|
1052
|
-
const native = getNativeBridge();
|
|
1053
|
-
if (!native?.processTailwindCssLightning) {
|
|
1054
|
-
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
1055
|
-
}
|
|
1056
|
-
const deadSet = deadClasses;
|
|
1057
|
-
const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
|
|
1058
|
-
const m = rule.match(/\.([a-zA-Z0-9_-]+)/);
|
|
1059
|
-
return !m || !deadSet.has(m[1]);
|
|
1060
|
-
}).join("\n");
|
|
1061
|
-
const compiled = native.processTailwindCssLightning(pruned);
|
|
1062
|
-
return (compiled?.css ?? pruned).trim();
|
|
1063
|
-
};
|
|
1064
|
-
findDeadVariants = (variantConfig, usage) => {
|
|
1065
|
-
const unused = [];
|
|
1066
|
-
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
1067
|
-
for (const component of configs) {
|
|
1068
|
-
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
1069
|
-
const variants = component.variants;
|
|
1070
|
-
for (const [key, values] of Object.entries(variants)) {
|
|
1071
|
-
for (const [value] of Object.entries(values)) {
|
|
1072
|
-
if (!componentUsage.has(`${key}:${value}`)) {
|
|
1073
|
-
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
return {
|
|
1079
|
-
unusedCount: unused.length,
|
|
1080
|
-
unused
|
|
1081
|
-
};
|
|
1082
|
-
};
|
|
1083
|
-
runElimination = (css, scanResult) => {
|
|
1084
|
-
const native = getNativeBridge();
|
|
1085
|
-
if (!native?.detectDeadCode) {
|
|
1086
|
-
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
1087
|
-
}
|
|
1088
|
-
const dead = native.detectDeadCode(
|
|
1089
|
-
JSON.stringify(scanResult),
|
|
1090
|
-
css
|
|
1091
|
-
);
|
|
1092
|
-
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
1093
|
-
};
|
|
1094
|
-
optimizeCss = (css) => {
|
|
1095
|
-
const native = getNativeBridge();
|
|
1096
|
-
if (!native?.detectDeadCode) {
|
|
1097
|
-
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
1098
|
-
}
|
|
1099
|
-
const deadResult = native.detectDeadCode(
|
|
1100
|
-
JSON.stringify({ uniqueClasses: [] }),
|
|
1101
|
-
css
|
|
1102
|
-
);
|
|
1103
|
-
if (!native?.processTailwindCssLightning) {
|
|
1104
|
-
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
1105
|
-
}
|
|
1106
|
-
const deadSet = new Set(deadResult.deadInCss ?? []);
|
|
1107
|
-
const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
|
|
1108
|
-
const selectorMatch = rule.match(/\.([a-zA-Z0-9_-]+)/);
|
|
1109
|
-
if (!selectorMatch) return true;
|
|
1110
|
-
return !deadSet.has(selectorMatch[1]);
|
|
1111
|
-
}).join("\n");
|
|
1112
|
-
const compiled = native.processTailwindCssLightning(pruned);
|
|
1113
|
-
return (compiled?.css ?? pruned).trim();
|
|
1114
|
-
};
|
|
1115
|
-
scanProjectUsage = (dirs, cwd) => {
|
|
1116
|
-
const path7 = __require("path");
|
|
1117
|
-
const files = dirs.map((dir) => path7.resolve(cwd, dir));
|
|
1118
|
-
const results = batchExtractClasses(files) || [];
|
|
1119
|
-
const combined = {};
|
|
1120
|
-
for (const result of results) {
|
|
1121
|
-
if (result.ok && result.classes) {
|
|
1122
|
-
for (const cls of result.classes) {
|
|
1123
|
-
if (!combined[cls]) combined[cls] = {};
|
|
1124
|
-
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
return combined;
|
|
1129
|
-
};
|
|
1130
1045
|
extractComponentUsage = (source) => {
|
|
1131
1046
|
const native = getNativeBridge();
|
|
1132
1047
|
if (!native?.extractComponentUsage) {
|
|
@@ -1134,13 +1049,6 @@ var init_src2 = __esm({
|
|
|
1134
1049
|
}
|
|
1135
1050
|
return native.extractComponentUsage(source) || [];
|
|
1136
1051
|
};
|
|
1137
|
-
diffClassLists = (previous, current) => {
|
|
1138
|
-
const native = getNativeBridge();
|
|
1139
|
-
if (!native?.diffClassLists) {
|
|
1140
|
-
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
1141
|
-
}
|
|
1142
|
-
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
1143
|
-
};
|
|
1144
1052
|
batchExtractClasses = (filePaths) => {
|
|
1145
1053
|
const native = getNativeBridge();
|
|
1146
1054
|
if (!native?.batchExtractClasses) {
|
|
@@ -1155,225 +1063,2356 @@ var init_src2 = __esm({
|
|
|
1155
1063
|
}
|
|
1156
1064
|
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
1157
1065
|
};
|
|
1158
|
-
|
|
1066
|
+
diffClassLists = (previous, current) => {
|
|
1159
1067
|
const native = getNativeBridge();
|
|
1160
|
-
if (!native?.
|
|
1161
|
-
throw new Error("FATAL: Native binding '
|
|
1068
|
+
if (!native?.diffClassLists) {
|
|
1069
|
+
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
1162
1070
|
}
|
|
1163
|
-
return native.
|
|
1071
|
+
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
1164
1072
|
};
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
// packages/domain/compiler/src/analyzer/analyzerNative.ts
|
|
1077
|
+
function detectDeadCode(scanResultJson, css) {
|
|
1078
|
+
const native = getNativeBridge();
|
|
1079
|
+
if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
|
|
1080
|
+
return native.detectDeadCode(scanResultJson, css);
|
|
1081
|
+
}
|
|
1082
|
+
function analyzeClassUsageNative(classes, scanResultJson, css) {
|
|
1083
|
+
const native = getNativeBridge();
|
|
1084
|
+
if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
|
|
1085
|
+
return native.analyzeClassUsage(classes, scanResultJson, css);
|
|
1086
|
+
}
|
|
1087
|
+
function analyzeClassesNative(filesJson, cwd, flags) {
|
|
1088
|
+
const native = getNativeBridge();
|
|
1089
|
+
if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
|
|
1090
|
+
return native.analyzeClasses(filesJson, cwd, flags ?? 0);
|
|
1091
|
+
}
|
|
1092
|
+
function analyzeRscNative(source, filename) {
|
|
1093
|
+
const native = getNativeBridge();
|
|
1094
|
+
if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
|
|
1095
|
+
return native.analyzeRsc(source, filename);
|
|
1096
|
+
}
|
|
1097
|
+
function optimizeCssNative(css) {
|
|
1098
|
+
const native = getNativeBridge();
|
|
1099
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
1100
|
+
const result = native.processTailwindCssLightning(css);
|
|
1101
|
+
return {
|
|
1102
|
+
css: result.css,
|
|
1103
|
+
originalSize: css.length,
|
|
1104
|
+
optimizedSize: result.size_bytes,
|
|
1105
|
+
reductionPercentage: (css.length - result.size_bytes) / css.length * 100
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
function processTailwindCssLightning(css) {
|
|
1109
|
+
const native = getNativeBridge();
|
|
1110
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
1111
|
+
return native.processTailwindCssLightning(css);
|
|
1112
|
+
}
|
|
1113
|
+
function eliminateDeadCssNative(css, deadClasses) {
|
|
1114
|
+
const native = getNativeBridge();
|
|
1115
|
+
if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
|
|
1116
|
+
return native.eliminateDeadCss(css, deadClasses);
|
|
1117
|
+
}
|
|
1118
|
+
function hoistComponentsNative(source) {
|
|
1119
|
+
const native = getNativeBridge();
|
|
1120
|
+
if (!native?.hoistComponents) throw new Error("hoistComponents not available");
|
|
1121
|
+
return native.hoistComponents(source);
|
|
1122
|
+
}
|
|
1123
|
+
function compileVariantTableNative(configJson) {
|
|
1124
|
+
const native = getNativeBridge();
|
|
1125
|
+
if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
|
|
1126
|
+
return native.compileVariantTable(configJson);
|
|
1127
|
+
}
|
|
1128
|
+
function classifyAndSortClassesNative(classes) {
|
|
1129
|
+
const native = getNativeBridge();
|
|
1130
|
+
if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
|
|
1131
|
+
return native.classifyAndSortClasses(classes);
|
|
1132
|
+
}
|
|
1133
|
+
function mergeCssDeclarationsNative(cssChunks) {
|
|
1134
|
+
const native = getNativeBridge();
|
|
1135
|
+
if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
|
|
1136
|
+
return native.mergeCssDeclarations(cssChunks);
|
|
1137
|
+
}
|
|
1138
|
+
var init_analyzerNative = __esm({
|
|
1139
|
+
"packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
|
|
1140
|
+
init_nativeBridge();
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
// packages/domain/compiler/src/analyzer/themeResolutionNative.ts
|
|
1145
|
+
function resolveVariants(configJson) {
|
|
1146
|
+
const native = getNativeBridge();
|
|
1147
|
+
if (!native?.resolve_variants) throw new Error("resolve_variants not available");
|
|
1148
|
+
const resultJson = native.resolve_variants(configJson);
|
|
1149
|
+
try {
|
|
1150
|
+
return JSON.parse(resultJson);
|
|
1151
|
+
} catch {
|
|
1152
|
+
return {
|
|
1153
|
+
variants: [],
|
|
1154
|
+
supported: [],
|
|
1155
|
+
deprecated: [],
|
|
1156
|
+
conflicting: []
|
|
1171
1157
|
};
|
|
1172
|
-
|
|
1173
|
-
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function validateThemeConfig(configJson) {
|
|
1161
|
+
const native = getNativeBridge();
|
|
1162
|
+
if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
|
|
1163
|
+
const resultJson = native.validate_variant_config(configJson);
|
|
1164
|
+
try {
|
|
1165
|
+
return JSON.parse(resultJson);
|
|
1166
|
+
} catch {
|
|
1167
|
+
return {
|
|
1168
|
+
is_valid: false,
|
|
1169
|
+
errors: ["Unable to parse configuration"],
|
|
1170
|
+
warnings: [],
|
|
1171
|
+
suggestions: []
|
|
1174
1172
|
};
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function resolveCascade(baseThemeJson, overridesJson) {
|
|
1176
|
+
const native = getNativeBridge();
|
|
1177
|
+
if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
|
|
1178
|
+
const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
|
|
1179
|
+
try {
|
|
1180
|
+
return JSON.parse(resultJson);
|
|
1181
|
+
} catch {
|
|
1182
|
+
return {
|
|
1183
|
+
base_theme: {},
|
|
1184
|
+
user_overrides: {},
|
|
1185
|
+
merged_theme: {},
|
|
1186
|
+
conflict_resolutions: []
|
|
1181
1187
|
};
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function resolveClassNames(classNames, themeJson) {
|
|
1191
|
+
const native = getNativeBridge();
|
|
1192
|
+
if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
|
|
1193
|
+
const resultJson = native.resolve_class_names(classNames, themeJson);
|
|
1194
|
+
try {
|
|
1195
|
+
return JSON.parse(resultJson);
|
|
1196
|
+
} catch {
|
|
1197
|
+
return [];
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
function resolveConflictGroup(groupName, themeJson) {
|
|
1201
|
+
const native = getNativeBridge();
|
|
1202
|
+
if (!native?.resolve_conflict_group)
|
|
1203
|
+
throw new Error("resolve_conflict_group not available");
|
|
1204
|
+
const resultJson = native.resolve_conflict_group(groupName, themeJson);
|
|
1205
|
+
try {
|
|
1206
|
+
return JSON.parse(resultJson);
|
|
1207
|
+
} catch {
|
|
1208
|
+
return {
|
|
1209
|
+
group_name: groupName,
|
|
1210
|
+
conflicting_classes: [],
|
|
1211
|
+
description: "",
|
|
1212
|
+
resolution_strategy: "last-wins"
|
|
1188
1213
|
};
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
function resolveThemeValue(keyPath, themeJson) {
|
|
1217
|
+
const native = getNativeBridge();
|
|
1218
|
+
if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
|
|
1219
|
+
return native.resolve_theme_value(keyPath, themeJson);
|
|
1220
|
+
}
|
|
1221
|
+
function resolveSimpleVariants(configJson) {
|
|
1222
|
+
const native = getNativeBridge();
|
|
1223
|
+
if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
|
|
1224
|
+
const resultJson = native.resolve_simple_variants(configJson);
|
|
1225
|
+
try {
|
|
1226
|
+
return JSON.parse(resultJson);
|
|
1227
|
+
} catch {
|
|
1228
|
+
return [];
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
var init_themeResolutionNative = __esm({
|
|
1232
|
+
"packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
|
|
1233
|
+
init_nativeBridge();
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// packages/domain/compiler/src/analyzer/scannerNative.ts
|
|
1238
|
+
function scanWorkspace(root, extensions) {
|
|
1239
|
+
const native = getNativeBridge();
|
|
1240
|
+
if (!native?.scan_workspace) throw new Error("scan_workspace not available");
|
|
1241
|
+
return native.scan_workspace(root, extensions);
|
|
1242
|
+
}
|
|
1243
|
+
function extractClassesFromSourceNative(source) {
|
|
1244
|
+
const native = getNativeBridge();
|
|
1245
|
+
if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
|
|
1246
|
+
return native.extract_classes_from_source(source);
|
|
1247
|
+
}
|
|
1248
|
+
function batchExtractClassesNative(filePaths) {
|
|
1249
|
+
const native = getNativeBridge();
|
|
1250
|
+
if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
|
|
1251
|
+
return native.batch_extract_classes(filePaths);
|
|
1252
|
+
}
|
|
1253
|
+
function checkAgainstSafelistNative(classes, safelist) {
|
|
1254
|
+
const native = getNativeBridge();
|
|
1255
|
+
if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
|
|
1256
|
+
return native.check_against_safelist(classes, safelist);
|
|
1257
|
+
}
|
|
1258
|
+
function scanFile(filePath) {
|
|
1259
|
+
const native = getNativeBridge();
|
|
1260
|
+
if (!native?.scan_file) throw new Error("scan_file not available");
|
|
1261
|
+
return native.scan_file(filePath);
|
|
1262
|
+
}
|
|
1263
|
+
function collectFiles(root, extensions) {
|
|
1264
|
+
const native = getNativeBridge();
|
|
1265
|
+
if (!native?.collect_files) throw new Error("collect_files not available");
|
|
1266
|
+
return native.collect_files(root, extensions);
|
|
1267
|
+
}
|
|
1268
|
+
function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
|
|
1269
|
+
const native = getNativeBridge();
|
|
1270
|
+
if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
|
|
1271
|
+
return native.walk_and_prefilter_source_files(root, extensions);
|
|
1272
|
+
}
|
|
1273
|
+
function generateSubComponentTypes(root, outputPath) {
|
|
1274
|
+
const native = getNativeBridge();
|
|
1275
|
+
if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
|
|
1276
|
+
return native.generate_sub_component_types(root, outputPath);
|
|
1277
|
+
}
|
|
1278
|
+
var init_scannerNative = __esm({
|
|
1279
|
+
"packages/domain/compiler/src/analyzer/scannerNative.ts"() {
|
|
1280
|
+
init_nativeBridge();
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
// packages/domain/compiler/src/analyzer/index.ts
|
|
1285
|
+
var init_analyzer = __esm({
|
|
1286
|
+
"packages/domain/compiler/src/analyzer/index.ts"() {
|
|
1287
|
+
init_analyzerNative();
|
|
1288
|
+
init_themeResolutionNative();
|
|
1289
|
+
init_scannerNative();
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
|
|
1293
|
+
// packages/domain/compiler/src/cache/cacheNative.ts
|
|
1294
|
+
function getCacheStatistics() {
|
|
1295
|
+
const native = getNativeBridge();
|
|
1296
|
+
if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
|
|
1297
|
+
const statsJson = native.get_cache_statistics();
|
|
1298
|
+
try {
|
|
1299
|
+
return JSON.parse(statsJson);
|
|
1300
|
+
} catch {
|
|
1301
|
+
return {
|
|
1302
|
+
parse_cache: { hits: 0, misses: 0, size: 0 },
|
|
1303
|
+
resolve_cache: { hits: 0, misses: 0, size: 0 },
|
|
1304
|
+
compile_cache: { hits: 0, misses: 0, size: 0 },
|
|
1305
|
+
css_gen_cache: { hits: 0, misses: 0, size: 0 },
|
|
1306
|
+
overall_hit_rate: 0,
|
|
1307
|
+
total_memory_bytes: 0
|
|
1195
1308
|
};
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function clearAllCaches() {
|
|
1312
|
+
const native = getNativeBridge();
|
|
1313
|
+
if (!native?.clear_all_caches) return;
|
|
1314
|
+
try {
|
|
1315
|
+
native.clear_all_caches();
|
|
1316
|
+
} catch {
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
function clearParseCache() {
|
|
1320
|
+
const native = getNativeBridge();
|
|
1321
|
+
if (!native?.clear_parse_cache) return;
|
|
1322
|
+
try {
|
|
1323
|
+
native.clear_parse_cache();
|
|
1324
|
+
} catch {
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function clearResolveCache() {
|
|
1328
|
+
const native = getNativeBridge();
|
|
1329
|
+
if (!native?.clear_resolve_cache) return;
|
|
1330
|
+
try {
|
|
1331
|
+
native.clear_resolve_cache();
|
|
1332
|
+
} catch {
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function clearCompileCache() {
|
|
1336
|
+
const native = getNativeBridge();
|
|
1337
|
+
if (!native?.clear_compile_cache) return;
|
|
1338
|
+
try {
|
|
1339
|
+
native.clear_compile_cache();
|
|
1340
|
+
} catch {
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function clearCssGenCache() {
|
|
1344
|
+
const native = getNativeBridge();
|
|
1345
|
+
if (!native?.clear_css_gen_cache) return;
|
|
1346
|
+
try {
|
|
1347
|
+
native.clear_css_gen_cache();
|
|
1348
|
+
} catch {
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
|
|
1352
|
+
const native = getNativeBridge();
|
|
1353
|
+
if (!native?.get_cache_optimization_hints)
|
|
1354
|
+
throw new Error("get_cache_optimization_hints not available");
|
|
1355
|
+
const hintsJson = native.get_cache_optimization_hints(
|
|
1356
|
+
Math.min(100, Math.max(0, hitRatePercent)),
|
|
1357
|
+
Math.max(1, memoryUsedMb)
|
|
1358
|
+
);
|
|
1359
|
+
try {
|
|
1360
|
+
return JSON.parse(hintsJson);
|
|
1361
|
+
} catch {
|
|
1362
|
+
return {
|
|
1363
|
+
current_strategy: "unknown",
|
|
1364
|
+
recommended_strategy: "increase_size",
|
|
1365
|
+
estimated_improvement_percent: 0,
|
|
1366
|
+
suggested_memory_mb: 256,
|
|
1367
|
+
notes: ["Unable to analyze cache statistics"]
|
|
1202
1368
|
};
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
|
|
1372
|
+
const native = getNativeBridge();
|
|
1373
|
+
if (!native?.estimate_optimal_cache_config_native)
|
|
1374
|
+
throw new Error("estimate_optimal_cache_config_native not available");
|
|
1375
|
+
const configJson = native.estimate_optimal_cache_config_native(
|
|
1376
|
+
Math.max(64, totalBudgetMb),
|
|
1377
|
+
workloadType
|
|
1378
|
+
);
|
|
1379
|
+
try {
|
|
1380
|
+
return JSON.parse(configJson);
|
|
1381
|
+
} catch {
|
|
1382
|
+
return {
|
|
1383
|
+
parse_cache_size: 128,
|
|
1384
|
+
resolve_cache_size: 64,
|
|
1385
|
+
compile_cache_size: 256,
|
|
1386
|
+
css_gen_cache_size: 128,
|
|
1387
|
+
recommended_eviction_policy: "lru",
|
|
1388
|
+
ttl_seconds: 3600,
|
|
1389
|
+
expected_hit_rate_percent: 75
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function cacheRead(cachePath) {
|
|
1394
|
+
const native = getNativeBridge();
|
|
1395
|
+
if (!native?.cache_read) throw new Error("cache_read not available");
|
|
1396
|
+
const result = native.cache_read(cachePath);
|
|
1397
|
+
try {
|
|
1398
|
+
return JSON.parse(result.entries_json || "[]");
|
|
1399
|
+
} catch {
|
|
1400
|
+
return [];
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
function cacheWrite(cachePath, entries) {
|
|
1404
|
+
const native = getNativeBridge();
|
|
1405
|
+
if (!native?.cache_write) throw new Error("cache_write not available");
|
|
1406
|
+
try {
|
|
1407
|
+
const result = native.cache_write(
|
|
1408
|
+
cachePath,
|
|
1409
|
+
entries.map((e) => ({
|
|
1410
|
+
file: e.file,
|
|
1411
|
+
content_hash: e.contentHash,
|
|
1412
|
+
classes: e.classes,
|
|
1413
|
+
mtime_ms: e.mtimeMs,
|
|
1414
|
+
size_bytes: e.sizeBytes
|
|
1415
|
+
}))
|
|
1416
|
+
);
|
|
1417
|
+
return typeof result === "boolean" ? result : result === true;
|
|
1418
|
+
} catch {
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
function cachePriority(mtimeMs, sizeBytes, hitCount) {
|
|
1423
|
+
const native = getNativeBridge();
|
|
1424
|
+
if (!native?.cache_priority) throw new Error("cache_priority not available");
|
|
1425
|
+
return native.cache_priority(mtimeMs, sizeBytes, hitCount);
|
|
1426
|
+
}
|
|
1427
|
+
var init_cacheNative = __esm({
|
|
1428
|
+
"packages/domain/compiler/src/cache/cacheNative.ts"() {
|
|
1429
|
+
init_nativeBridge();
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
// packages/domain/compiler/src/cache/index.ts
|
|
1434
|
+
var init_cache = __esm({
|
|
1435
|
+
"packages/domain/compiler/src/cache/index.ts"() {
|
|
1436
|
+
init_cacheNative();
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
// packages/domain/compiler/src/redis/redisNative.ts
|
|
1441
|
+
function redisPing() {
|
|
1442
|
+
const native = getNativeBridge();
|
|
1443
|
+
if (!native?.redis_ping) throw new Error("redis_ping not available");
|
|
1444
|
+
return native.redis_ping();
|
|
1445
|
+
}
|
|
1446
|
+
function redisGet(key) {
|
|
1447
|
+
const native = getNativeBridge();
|
|
1448
|
+
if (!native?.redis_get) throw new Error("redis_get not available");
|
|
1449
|
+
const result = native.redis_get(key);
|
|
1450
|
+
return result === "nil" ? null : result;
|
|
1451
|
+
}
|
|
1452
|
+
function redisSet(key, value, ttl_seconds) {
|
|
1453
|
+
const native = getNativeBridge();
|
|
1454
|
+
if (!native?.redis_set) throw new Error("redis_set not available");
|
|
1455
|
+
return native.redis_set(key, value, ttl_seconds);
|
|
1456
|
+
}
|
|
1457
|
+
function redisDelete(key) {
|
|
1458
|
+
const native = getNativeBridge();
|
|
1459
|
+
if (!native?.redis_delete) throw new Error("redis_delete not available");
|
|
1460
|
+
return native.redis_delete(key);
|
|
1461
|
+
}
|
|
1462
|
+
function redisExists(key) {
|
|
1463
|
+
const native = getNativeBridge();
|
|
1464
|
+
if (!native?.redis_exists) throw new Error("redis_exists not available");
|
|
1465
|
+
return native.redis_exists(key);
|
|
1466
|
+
}
|
|
1467
|
+
function redisMget(keys) {
|
|
1468
|
+
const native = getNativeBridge();
|
|
1469
|
+
if (!native?.redis_mget) throw new Error("redis_mget not available");
|
|
1470
|
+
const result = native.redis_mget(keys);
|
|
1471
|
+
try {
|
|
1472
|
+
return JSON.parse(result);
|
|
1473
|
+
} catch {
|
|
1474
|
+
return keys.map(() => null);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function redisMset(pairs) {
|
|
1478
|
+
const native = getNativeBridge();
|
|
1479
|
+
if (!native?.redis_mset) throw new Error("redis_mset not available");
|
|
1480
|
+
return native.redis_mset(pairs);
|
|
1481
|
+
}
|
|
1482
|
+
function redisFlushDb() {
|
|
1483
|
+
const native = getNativeBridge();
|
|
1484
|
+
if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
|
|
1485
|
+
return native.redis_flush_db();
|
|
1486
|
+
}
|
|
1487
|
+
function redisFlushAll() {
|
|
1488
|
+
const native = getNativeBridge();
|
|
1489
|
+
if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
|
|
1490
|
+
return native.redis_flush_all();
|
|
1491
|
+
}
|
|
1492
|
+
function redisPoolConnect(host, port, pool_size) {
|
|
1493
|
+
const native = getNativeBridge();
|
|
1494
|
+
if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
|
|
1495
|
+
return native.redis_pool_connect(host, port, pool_size);
|
|
1496
|
+
}
|
|
1497
|
+
function redisPoolStats() {
|
|
1498
|
+
const native = getNativeBridge();
|
|
1499
|
+
if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
|
|
1500
|
+
const result = native.redis_pool_stats();
|
|
1501
|
+
try {
|
|
1502
|
+
return JSON.parse(result);
|
|
1503
|
+
} catch {
|
|
1504
|
+
return {
|
|
1505
|
+
connected_count: 0,
|
|
1506
|
+
idle_count: 0,
|
|
1507
|
+
waiting_count: 0,
|
|
1508
|
+
total_requests: 0,
|
|
1509
|
+
total_errors: 0
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function redisPoolReconnect() {
|
|
1514
|
+
const native = getNativeBridge();
|
|
1515
|
+
if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
|
|
1516
|
+
return native.redis_pool_reconnect();
|
|
1517
|
+
}
|
|
1518
|
+
function redisEnableCluster(initial_nodes) {
|
|
1519
|
+
const native = getNativeBridge();
|
|
1520
|
+
if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
|
|
1521
|
+
const result = native.redis_enable_cluster(initial_nodes);
|
|
1522
|
+
try {
|
|
1523
|
+
return JSON.parse(result);
|
|
1524
|
+
} catch {
|
|
1525
|
+
return {
|
|
1526
|
+
enabled: false,
|
|
1527
|
+
cluster_state: "error",
|
|
1528
|
+
nodes: [],
|
|
1529
|
+
slots_assigned: 0,
|
|
1530
|
+
slots_ok: 0,
|
|
1531
|
+
slots_fail: 0
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
function redisDisableCluster() {
|
|
1536
|
+
const native = getNativeBridge();
|
|
1537
|
+
if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
|
|
1538
|
+
return native.redis_disable_cluster();
|
|
1539
|
+
}
|
|
1540
|
+
function redisClusterStatus() {
|
|
1541
|
+
const native = getNativeBridge();
|
|
1542
|
+
if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
|
|
1543
|
+
const result = native.redis_cluster_status();
|
|
1544
|
+
try {
|
|
1545
|
+
return JSON.parse(result);
|
|
1546
|
+
} catch {
|
|
1547
|
+
return {
|
|
1548
|
+
enabled: false,
|
|
1549
|
+
cluster_state: "unknown",
|
|
1550
|
+
nodes: [],
|
|
1551
|
+
slots_assigned: 0,
|
|
1552
|
+
slots_ok: 0,
|
|
1553
|
+
slots_fail: 0
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
function redisSubscribe(channel) {
|
|
1558
|
+
const native = getNativeBridge();
|
|
1559
|
+
if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
|
|
1560
|
+
return native.redis_subscribe(channel);
|
|
1561
|
+
}
|
|
1562
|
+
function redisPublish(channel, message) {
|
|
1563
|
+
const native = getNativeBridge();
|
|
1564
|
+
if (!native?.redis_publish) throw new Error("redis_publish not available");
|
|
1565
|
+
return native.redis_publish(channel, message);
|
|
1566
|
+
}
|
|
1567
|
+
function redisExpirationSet(key, ttl_seconds) {
|
|
1568
|
+
const native = getNativeBridge();
|
|
1569
|
+
if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
|
|
1570
|
+
return native.redis_expiration_set(key, ttl_seconds);
|
|
1571
|
+
}
|
|
1572
|
+
function redisExpirationGet(key) {
|
|
1573
|
+
const native = getNativeBridge();
|
|
1574
|
+
if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
|
|
1575
|
+
const result = native.redis_expiration_get(key);
|
|
1576
|
+
try {
|
|
1577
|
+
return JSON.parse(result);
|
|
1578
|
+
} catch {
|
|
1579
|
+
return {
|
|
1580
|
+
key,
|
|
1581
|
+
ttl_seconds: -1,
|
|
1582
|
+
expiration_timestamp: 0,
|
|
1583
|
+
is_persistent: true
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function redisInfo() {
|
|
1588
|
+
const native = getNativeBridge();
|
|
1589
|
+
if (!native?.redis_info) throw new Error("redis_info not available");
|
|
1590
|
+
return native.redis_info();
|
|
1591
|
+
}
|
|
1592
|
+
function redisMonitor() {
|
|
1593
|
+
const native = getNativeBridge();
|
|
1594
|
+
if (!native?.redis_monitor) throw new Error("redis_monitor not available");
|
|
1595
|
+
return native.redis_monitor();
|
|
1596
|
+
}
|
|
1597
|
+
function redisCacheSize() {
|
|
1598
|
+
const native = getNativeBridge();
|
|
1599
|
+
if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
|
|
1600
|
+
return native.redis_cache_size();
|
|
1601
|
+
}
|
|
1602
|
+
function redisCacheKeyCount() {
|
|
1603
|
+
const native = getNativeBridge();
|
|
1604
|
+
if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
|
|
1605
|
+
return native.redis_cache_key_count();
|
|
1606
|
+
}
|
|
1607
|
+
function redisCacheClear() {
|
|
1608
|
+
const native = getNativeBridge();
|
|
1609
|
+
if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
|
|
1610
|
+
return native.redis_cache_clear();
|
|
1611
|
+
}
|
|
1612
|
+
function redisCacheHitRate() {
|
|
1613
|
+
const native = getNativeBridge();
|
|
1614
|
+
if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
|
|
1615
|
+
return native.redis_cache_hit_rate();
|
|
1616
|
+
}
|
|
1617
|
+
function redisEnablePersistence(mode) {
|
|
1618
|
+
const native = getNativeBridge();
|
|
1619
|
+
if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
|
|
1620
|
+
return native.redis_enable_persistence(mode);
|
|
1621
|
+
}
|
|
1622
|
+
function redisDisablePersistence() {
|
|
1623
|
+
const native = getNativeBridge();
|
|
1624
|
+
if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
|
|
1625
|
+
return native.redis_disable_persistence();
|
|
1626
|
+
}
|
|
1627
|
+
function redisSnapshot() {
|
|
1628
|
+
const native = getNativeBridge();
|
|
1629
|
+
if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
|
|
1630
|
+
return native.redis_snapshot();
|
|
1631
|
+
}
|
|
1632
|
+
function redisMemoryStats() {
|
|
1633
|
+
const native = getNativeBridge();
|
|
1634
|
+
if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
|
|
1635
|
+
return native.redis_memory_stats();
|
|
1636
|
+
}
|
|
1637
|
+
function redisOptimizeMemory() {
|
|
1638
|
+
const native = getNativeBridge();
|
|
1639
|
+
if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
|
|
1640
|
+
return native.redis_optimize_memory();
|
|
1641
|
+
}
|
|
1642
|
+
function redisSetEvictionPolicy(policy) {
|
|
1643
|
+
const native = getNativeBridge();
|
|
1644
|
+
if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
|
|
1645
|
+
return native.redis_set_eviction_policy(policy);
|
|
1646
|
+
}
|
|
1647
|
+
function redisGetEvictionPolicy() {
|
|
1648
|
+
const native = getNativeBridge();
|
|
1649
|
+
if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
|
|
1650
|
+
return native.redis_get_eviction_policy();
|
|
1651
|
+
}
|
|
1652
|
+
function redisReplicate(target_host, target_port) {
|
|
1653
|
+
const native = getNativeBridge();
|
|
1654
|
+
if (!native?.redis_replicate) throw new Error("redis_replicate not available");
|
|
1655
|
+
return native.redis_replicate(target_host, target_port);
|
|
1656
|
+
}
|
|
1657
|
+
function redisReplicationStatus() {
|
|
1658
|
+
const native = getNativeBridge();
|
|
1659
|
+
if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
|
|
1660
|
+
return native.redis_replication_status();
|
|
1661
|
+
}
|
|
1662
|
+
function redisCacheSync(peers) {
|
|
1663
|
+
const native = getNativeBridge();
|
|
1664
|
+
if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
|
|
1665
|
+
return native.redis_cache_sync(peers);
|
|
1666
|
+
}
|
|
1667
|
+
function redisEnableCacheWarming(key_pattern) {
|
|
1668
|
+
const native = getNativeBridge();
|
|
1669
|
+
if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
|
|
1670
|
+
return native.redis_enable_cache_warming(key_pattern);
|
|
1671
|
+
}
|
|
1672
|
+
function redisDisableCacheWarming() {
|
|
1673
|
+
const native = getNativeBridge();
|
|
1674
|
+
if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
|
|
1675
|
+
return native.redis_disable_cache_warming();
|
|
1676
|
+
}
|
|
1677
|
+
function redisDiagnose() {
|
|
1678
|
+
const native = getNativeBridge();
|
|
1679
|
+
if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
|
|
1680
|
+
return native.redis_diagnose();
|
|
1681
|
+
}
|
|
1682
|
+
var init_redisNative = __esm({
|
|
1683
|
+
"packages/domain/compiler/src/redis/redisNative.ts"() {
|
|
1684
|
+
init_nativeBridge();
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
|
|
1688
|
+
// packages/domain/compiler/src/redis/index.ts
|
|
1689
|
+
var init_redis = __esm({
|
|
1690
|
+
"packages/domain/compiler/src/redis/index.ts"() {
|
|
1691
|
+
init_redisNative();
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
|
|
1695
|
+
// packages/domain/compiler/src/watch/watchSystemNative.ts
|
|
1696
|
+
function startWatch(root_path, patterns) {
|
|
1697
|
+
const native = getNativeBridge();
|
|
1698
|
+
if (!native?.start_watch) throw new Error("start_watch not available");
|
|
1699
|
+
return native.start_watch(root_path, patterns);
|
|
1700
|
+
}
|
|
1701
|
+
function pollWatchEvents(handle, timeout_ms) {
|
|
1702
|
+
const native = getNativeBridge();
|
|
1703
|
+
if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
|
|
1704
|
+
const result = native.poll_watch_events(handle, timeout_ms);
|
|
1705
|
+
try {
|
|
1706
|
+
return JSON.parse(result);
|
|
1707
|
+
} catch {
|
|
1708
|
+
return [];
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function stopWatch(handle) {
|
|
1712
|
+
const native = getNativeBridge();
|
|
1713
|
+
if (!native?.stop_watch) throw new Error("stop_watch not available");
|
|
1714
|
+
return native.stop_watch(handle);
|
|
1715
|
+
}
|
|
1716
|
+
function watchAddPattern(handle, pattern) {
|
|
1717
|
+
const native = getNativeBridge();
|
|
1718
|
+
if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
|
|
1719
|
+
return native.watch_add_pattern(handle, pattern);
|
|
1720
|
+
}
|
|
1721
|
+
function watchRemovePattern(handle, pattern) {
|
|
1722
|
+
const native = getNativeBridge();
|
|
1723
|
+
if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
|
|
1724
|
+
return native.watch_remove_pattern(handle, pattern);
|
|
1725
|
+
}
|
|
1726
|
+
function watchGetActiveHandles() {
|
|
1727
|
+
const native = getNativeBridge();
|
|
1728
|
+
if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
|
|
1729
|
+
const result = native.watch_get_active_handles();
|
|
1730
|
+
try {
|
|
1731
|
+
return JSON.parse(result);
|
|
1732
|
+
} catch {
|
|
1733
|
+
return [];
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function watchClearAll() {
|
|
1737
|
+
const native = getNativeBridge();
|
|
1738
|
+
if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
|
|
1739
|
+
return native.watch_clear_all();
|
|
1740
|
+
}
|
|
1741
|
+
function watchEventTypeToString(event_type_code) {
|
|
1742
|
+
const native = getNativeBridge();
|
|
1743
|
+
if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
|
|
1744
|
+
return native.watch_event_type_to_string(event_type_code);
|
|
1745
|
+
}
|
|
1746
|
+
function isWatchRunning(handle) {
|
|
1747
|
+
const native = getNativeBridge();
|
|
1748
|
+
if (!native?.is_watch_running) throw new Error("is_watch_running not available");
|
|
1749
|
+
return native.is_watch_running(handle);
|
|
1750
|
+
}
|
|
1751
|
+
function getWatchStats() {
|
|
1752
|
+
const native = getNativeBridge();
|
|
1753
|
+
if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
|
|
1754
|
+
const result = native.get_watch_stats();
|
|
1755
|
+
try {
|
|
1756
|
+
return JSON.parse(result);
|
|
1757
|
+
} catch {
|
|
1758
|
+
return {
|
|
1759
|
+
active_watchers: 0,
|
|
1760
|
+
total_events: 0,
|
|
1761
|
+
events_this_second: 0,
|
|
1762
|
+
average_latency_ms: 0,
|
|
1763
|
+
largest_batch_size: 0
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
function watchPause(handle) {
|
|
1768
|
+
const native = getNativeBridge();
|
|
1769
|
+
if (!native?.watch_pause) throw new Error("watch_pause not available");
|
|
1770
|
+
return native.watch_pause(handle);
|
|
1771
|
+
}
|
|
1772
|
+
function watchResume(handle) {
|
|
1773
|
+
const native = getNativeBridge();
|
|
1774
|
+
if (!native?.watch_resume) throw new Error("watch_resume not available");
|
|
1775
|
+
return native.watch_resume(handle);
|
|
1776
|
+
}
|
|
1777
|
+
function scanCacheOptimizations() {
|
|
1778
|
+
const native = getNativeBridge();
|
|
1779
|
+
if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
|
|
1780
|
+
return native.scan_cache_optimizations();
|
|
1781
|
+
}
|
|
1782
|
+
function getPluginHooks() {
|
|
1783
|
+
const native = getNativeBridge();
|
|
1784
|
+
if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
|
|
1785
|
+
const result = native.get_plugin_hooks();
|
|
1786
|
+
try {
|
|
1787
|
+
return JSON.parse(result);
|
|
1788
|
+
} catch {
|
|
1789
|
+
return [];
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function registerPluginHook(hook_name, handler_id) {
|
|
1793
|
+
const native = getNativeBridge();
|
|
1794
|
+
if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
|
|
1795
|
+
return native.register_plugin_hook(hook_name, handler_id);
|
|
1796
|
+
}
|
|
1797
|
+
function unregisterPluginHook(hook_name, handler_id) {
|
|
1798
|
+
const native = getNativeBridge();
|
|
1799
|
+
if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
|
|
1800
|
+
return native.unregister_plugin_hook(hook_name, handler_id);
|
|
1801
|
+
}
|
|
1802
|
+
function emitPluginHook(hook_name, data_json) {
|
|
1803
|
+
const native = getNativeBridge();
|
|
1804
|
+
if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
|
|
1805
|
+
return native.emit_plugin_hook(hook_name, data_json);
|
|
1806
|
+
}
|
|
1807
|
+
function getCompilationMetrics() {
|
|
1808
|
+
const native = getNativeBridge();
|
|
1809
|
+
if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
|
|
1810
|
+
return native.get_compilation_metrics();
|
|
1811
|
+
}
|
|
1812
|
+
function resetCompilationMetrics() {
|
|
1813
|
+
const native = getNativeBridge();
|
|
1814
|
+
if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
|
|
1815
|
+
return native.reset_compilation_metrics();
|
|
1816
|
+
}
|
|
1817
|
+
function validateCssOutput(css) {
|
|
1818
|
+
const native = getNativeBridge();
|
|
1819
|
+
if (!native?.validate_css_output) throw new Error("validate_css_output not available");
|
|
1820
|
+
return native.validate_css_output(css);
|
|
1821
|
+
}
|
|
1822
|
+
function getCompilerDiagnostics() {
|
|
1823
|
+
const native = getNativeBridge();
|
|
1824
|
+
if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
|
|
1825
|
+
return native.get_compiler_diagnostics();
|
|
1826
|
+
}
|
|
1827
|
+
var init_watchSystemNative = __esm({
|
|
1828
|
+
"packages/domain/compiler/src/watch/watchSystemNative.ts"() {
|
|
1829
|
+
init_nativeBridge();
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
|
|
1833
|
+
// packages/domain/compiler/src/watch/index.ts
|
|
1834
|
+
var init_watch = __esm({
|
|
1835
|
+
"packages/domain/compiler/src/watch/index.ts"() {
|
|
1836
|
+
init_watchSystemNative();
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
|
|
1840
|
+
// packages/domain/compiler/src/index.ts
|
|
1841
|
+
var src_exports = {};
|
|
1842
|
+
__export(src_exports, {
|
|
1843
|
+
BucketEngine: () => BucketEngine,
|
|
1844
|
+
IncrementalEngine: () => IncrementalEngine,
|
|
1845
|
+
adaptNativeResult: () => adaptNativeResult,
|
|
1846
|
+
analyzeClassUsageNative: () => analyzeClassUsageNative,
|
|
1847
|
+
analyzeClasses: () => analyzeClasses,
|
|
1848
|
+
analyzeClassesNative: () => analyzeClassesNative,
|
|
1849
|
+
analyzeFile: () => analyzeFile,
|
|
1850
|
+
analyzeRscNative: () => analyzeRscNative,
|
|
1851
|
+
analyzeVariantUsage: () => analyzeVariantUsage,
|
|
1852
|
+
astExtractClasses: () => astExtractClasses,
|
|
1853
|
+
atomicRegistrySize: () => atomicRegistrySize,
|
|
1854
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
1855
|
+
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
1856
|
+
bucketSort: () => bucketSort,
|
|
1857
|
+
buildStyleTag: () => buildStyleTag,
|
|
1858
|
+
cachePriority: () => cachePriority,
|
|
1859
|
+
cacheRead: () => cacheRead,
|
|
1860
|
+
cacheWrite: () => cacheWrite,
|
|
1861
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
1862
|
+
checkAgainstSafelistNative: () => checkAgainstSafelistNative,
|
|
1863
|
+
classifyAndSortClassesNative: () => classifyAndSortClassesNative,
|
|
1864
|
+
classifyNode: () => classifyNode,
|
|
1865
|
+
clearAllCaches: () => clearAllCaches,
|
|
1866
|
+
clearAtomicRegistry: () => clearAtomicRegistry,
|
|
1867
|
+
clearCompileCache: () => clearCompileCache,
|
|
1868
|
+
clearCssGenCache: () => clearCssGenCache,
|
|
1869
|
+
clearParseCache: () => clearParseCache,
|
|
1870
|
+
clearResolveCache: () => clearResolveCache,
|
|
1871
|
+
clearThemeCache: () => clearThemeCache,
|
|
1872
|
+
collectFiles: () => collectFiles,
|
|
1873
|
+
compileAnimation: () => compileAnimation,
|
|
1874
|
+
compileClass: () => compileClass,
|
|
1875
|
+
compileClasses: () => compileClasses,
|
|
1876
|
+
compileCssFromClasses: () => compileCssFromClasses,
|
|
1877
|
+
compileCssLightning: () => compileCssLightning,
|
|
1878
|
+
compileCssNative2: () => compileCssNative2,
|
|
1879
|
+
compileKeyframes: () => compileKeyframes,
|
|
1880
|
+
compileTheme: () => compileTheme,
|
|
1881
|
+
compileToCss: () => compileToCss,
|
|
1882
|
+
compileToCssBatch: () => compileToCssBatch,
|
|
1883
|
+
compileVariantTableNative: () => compileVariantTableNative,
|
|
1884
|
+
computeIncrementalDiff: () => computeIncrementalDiff,
|
|
1885
|
+
createFingerprint: () => createFingerprint,
|
|
1886
|
+
detectConflicts: () => detectConflicts,
|
|
1887
|
+
detectDeadCode: () => detectDeadCode,
|
|
1888
|
+
diffClassLists: () => diffClassLists,
|
|
1889
|
+
eliminateDeadCss: () => eliminateDeadCss,
|
|
1890
|
+
eliminateDeadCssNative: () => eliminateDeadCssNative,
|
|
1891
|
+
emitPluginHook: () => emitPluginHook,
|
|
1892
|
+
estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
|
|
1893
|
+
extractAllClasses: () => extractAllClasses,
|
|
1894
|
+
extractAndGenerateStateCss: () => extractAndGenerateStateCss,
|
|
1895
|
+
extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
|
|
1896
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
1897
|
+
extractClassesFromSourceNative: () => extractClassesFromSourceNative,
|
|
1898
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
1899
|
+
extractContainerCssFromSource: () => extractContainerCssFromSource,
|
|
1900
|
+
extractTwContainerConfigs: () => extractTwContainerConfigs,
|
|
1901
|
+
extractTwStateConfigs: () => extractTwStateConfigs,
|
|
1902
|
+
extractTwStateConfigsNative: () => extractTwStateConfigsNative,
|
|
1903
|
+
fileToRoute: () => fileToRoute,
|
|
1904
|
+
findDeadVariants: () => findDeadVariants,
|
|
1905
|
+
generateAtomicCss: () => generateAtomicCss,
|
|
1906
|
+
generateCssForClasses: () => generateCssForClasses,
|
|
1907
|
+
generateCssNative: () => generateCssNative,
|
|
1908
|
+
generateSafelist: () => generateSafelist,
|
|
1909
|
+
generateStaticStateCss: () => generateStaticStateCss,
|
|
1910
|
+
generateStaticStateCssNative: () => generateStaticStateCssNative,
|
|
1911
|
+
generateSubComponentTypes: () => generateSubComponentTypes,
|
|
1912
|
+
getAllRoutes: () => getAllRoutes,
|
|
1913
|
+
getBucketEngine: () => getBucketEngine,
|
|
1914
|
+
getCacheOptimizationHints: () => getCacheOptimizationHints,
|
|
1915
|
+
getCacheStatistics: () => getCacheStatistics,
|
|
1916
|
+
getCacheStats: () => getCacheStats,
|
|
1917
|
+
getCompilationMetrics: () => getCompilationMetrics,
|
|
1918
|
+
getCompilerDiagnostics: () => getCompilerDiagnostics,
|
|
1919
|
+
getContentPaths: () => getContentPaths,
|
|
1920
|
+
getIncrementalEngine: () => getIncrementalEngine,
|
|
1921
|
+
getNativeBridge: () => getNativeBridge,
|
|
1922
|
+
getPluginHooks: () => getPluginHooks,
|
|
1923
|
+
getRouteClasses: () => getRouteClasses,
|
|
1924
|
+
getWatchStats: () => getWatchStats,
|
|
1925
|
+
hasTwUsage: () => hasTwUsage,
|
|
1926
|
+
hashContent: () => hashContent,
|
|
1927
|
+
hoistComponentsNative: () => hoistComponentsNative,
|
|
1928
|
+
idRegistryActiveCount: () => idRegistryActiveCount,
|
|
1929
|
+
idRegistryCreate: () => idRegistryCreate,
|
|
1930
|
+
idRegistryDestroy: () => idRegistryDestroy,
|
|
1931
|
+
idRegistryExport: () => idRegistryExport,
|
|
1932
|
+
idRegistryGenerate: () => idRegistryGenerate,
|
|
1933
|
+
idRegistryImport: () => idRegistryImport,
|
|
1934
|
+
idRegistryLookup: () => idRegistryLookup,
|
|
1935
|
+
idRegistryNext: () => idRegistryNext,
|
|
1936
|
+
idRegistryReset: () => idRegistryReset,
|
|
1937
|
+
idRegistrySnapshot: () => idRegistrySnapshot,
|
|
1938
|
+
injectClientDirective: () => injectClientDirective,
|
|
1939
|
+
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
1940
|
+
injectStateHash: () => injectStateHash,
|
|
1941
|
+
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
1942
|
+
isWatchRunning: () => isWatchRunning,
|
|
1943
|
+
layoutClassesToCss: () => layoutClassesToCss,
|
|
1944
|
+
loadSafelist: () => loadSafelist,
|
|
1945
|
+
loadTailwindConfig: () => loadTailwindConfig,
|
|
1946
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
1947
|
+
mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
|
|
1948
|
+
minifyCss: () => minifyCss,
|
|
1949
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
1950
|
+
normalizeClasses: () => normalizeClasses,
|
|
1951
|
+
optimizeCssNative: () => optimizeCssNative,
|
|
1952
|
+
parseAtomicClass: () => parseAtomicClass,
|
|
1953
|
+
parseClasses: () => parseClasses,
|
|
1954
|
+
pollWatchEvents: () => pollWatchEvents,
|
|
1955
|
+
processFileChange: () => processFileChange,
|
|
1956
|
+
processTailwindCssLightning: () => processTailwindCssLightning,
|
|
1957
|
+
propertyIdToString: () => propertyIdToString,
|
|
1958
|
+
pruneStaleCacheEntries: () => pruneStaleCacheEntries,
|
|
1959
|
+
rebuildWorkspaceResult: () => rebuildWorkspaceResult,
|
|
1960
|
+
redisCacheClear: () => redisCacheClear,
|
|
1961
|
+
redisCacheHitRate: () => redisCacheHitRate,
|
|
1962
|
+
redisCacheKeyCount: () => redisCacheKeyCount,
|
|
1963
|
+
redisCacheSize: () => redisCacheSize,
|
|
1964
|
+
redisCacheSync: () => redisCacheSync,
|
|
1965
|
+
redisClusterStatus: () => redisClusterStatus,
|
|
1966
|
+
redisDelete: () => redisDelete,
|
|
1967
|
+
redisDiagnose: () => redisDiagnose,
|
|
1968
|
+
redisDisableCacheWarming: () => redisDisableCacheWarming,
|
|
1969
|
+
redisDisableCluster: () => redisDisableCluster,
|
|
1970
|
+
redisDisablePersistence: () => redisDisablePersistence,
|
|
1971
|
+
redisEnableCacheWarming: () => redisEnableCacheWarming,
|
|
1972
|
+
redisEnableCluster: () => redisEnableCluster,
|
|
1973
|
+
redisEnablePersistence: () => redisEnablePersistence,
|
|
1974
|
+
redisExists: () => redisExists,
|
|
1975
|
+
redisExpirationGet: () => redisExpirationGet,
|
|
1976
|
+
redisExpirationSet: () => redisExpirationSet,
|
|
1977
|
+
redisFlushAll: () => redisFlushAll,
|
|
1978
|
+
redisFlushDb: () => redisFlushDb,
|
|
1979
|
+
redisGet: () => redisGet,
|
|
1980
|
+
redisGetEvictionPolicy: () => redisGetEvictionPolicy,
|
|
1981
|
+
redisInfo: () => redisInfo,
|
|
1982
|
+
redisMemoryStats: () => redisMemoryStats,
|
|
1983
|
+
redisMget: () => redisMget,
|
|
1984
|
+
redisMonitor: () => redisMonitor,
|
|
1985
|
+
redisMset: () => redisMset,
|
|
1986
|
+
redisOptimizeMemory: () => redisOptimizeMemory,
|
|
1987
|
+
redisPing: () => redisPing,
|
|
1988
|
+
redisPoolConnect: () => redisPoolConnect,
|
|
1989
|
+
redisPoolReconnect: () => redisPoolReconnect,
|
|
1990
|
+
redisPoolStats: () => redisPoolStats,
|
|
1991
|
+
redisPublish: () => redisPublish,
|
|
1992
|
+
redisReplicate: () => redisReplicate,
|
|
1993
|
+
redisReplicationStatus: () => redisReplicationStatus,
|
|
1994
|
+
redisSet: () => redisSet,
|
|
1995
|
+
redisSetEvictionPolicy: () => redisSetEvictionPolicy,
|
|
1996
|
+
redisSnapshot: () => redisSnapshot,
|
|
1997
|
+
redisSubscribe: () => redisSubscribe,
|
|
1998
|
+
registerFileClasses: () => registerFileClasses,
|
|
1999
|
+
registerGlobalClasses: () => registerGlobalClasses,
|
|
2000
|
+
registerPluginHook: () => registerPluginHook,
|
|
2001
|
+
registerPropertyName: () => registerPropertyName,
|
|
2002
|
+
registerValueName: () => registerValueName,
|
|
2003
|
+
resetBucketEngine: () => resetBucketEngine,
|
|
2004
|
+
resetCompilationMetrics: () => resetCompilationMetrics,
|
|
2005
|
+
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
2006
|
+
resetNativeBridgeCache: () => resetNativeBridgeCache,
|
|
2007
|
+
resolveCascade: () => resolveCascade,
|
|
2008
|
+
resolveClassNames: () => resolveClassNames,
|
|
2009
|
+
resolveConflictGroup: () => resolveConflictGroup,
|
|
2010
|
+
resolveSimpleVariants: () => resolveSimpleVariants,
|
|
2011
|
+
resolveThemeValue: () => resolveThemeValue,
|
|
2012
|
+
resolveVariants: () => resolveVariants,
|
|
2013
|
+
reverseLookupProperty: () => reverseLookupProperty,
|
|
2014
|
+
reverseLookupValue: () => reverseLookupValue,
|
|
2015
|
+
runCssPipeline: () => runCssPipeline,
|
|
2016
|
+
runElimination: () => runElimination,
|
|
2017
|
+
runLoaderTransform: () => runLoaderTransform,
|
|
2018
|
+
scanCacheOptimizations: () => scanCacheOptimizations,
|
|
2019
|
+
scanFile: () => scanFile,
|
|
2020
|
+
scanFileNative: () => scanFileNative,
|
|
2021
|
+
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
2022
|
+
scanProjectUsage: () => scanProjectUsage,
|
|
2023
|
+
scanWorkspace: () => scanWorkspace,
|
|
2024
|
+
shouldProcess: () => shouldProcess,
|
|
2025
|
+
shouldSkipFile: () => shouldSkipFile,
|
|
2026
|
+
startWatch: () => startWatch,
|
|
2027
|
+
stopWatch: () => stopWatch,
|
|
2028
|
+
toAtomicClasses: () => toAtomicClasses,
|
|
2029
|
+
transformSource: () => transformSource,
|
|
2030
|
+
twMerge: () => twMerge,
|
|
2031
|
+
twMergeMany: () => twMergeMany,
|
|
2032
|
+
twMergeManyWithSeparator: () => twMergeManyWithSeparator,
|
|
2033
|
+
twMergeRaw: () => twMergeRaw,
|
|
2034
|
+
twMergeWithSeparator: () => twMergeWithSeparator,
|
|
2035
|
+
unregisterPluginHook: () => unregisterPluginHook,
|
|
2036
|
+
validateCssOutput: () => validateCssOutput,
|
|
2037
|
+
validateThemeConfig: () => validateThemeConfig,
|
|
2038
|
+
valueIdToString: () => valueIdToString,
|
|
2039
|
+
walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
|
|
2040
|
+
watchAddPattern: () => watchAddPattern,
|
|
2041
|
+
watchClearAll: () => watchClearAll,
|
|
2042
|
+
watchEventTypeToString: () => watchEventTypeToString,
|
|
2043
|
+
watchGetActiveHandles: () => watchGetActiveHandles,
|
|
2044
|
+
watchPause: () => watchPause,
|
|
2045
|
+
watchRemovePattern: () => watchRemovePattern,
|
|
2046
|
+
watchResume: () => watchResume
|
|
2047
|
+
});
|
|
2048
|
+
function _layoutClassesToCss(classes) {
|
|
2049
|
+
const native = getNativeBridge();
|
|
2050
|
+
if (!native?.layoutClassesToCss) {
|
|
2051
|
+
throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
|
|
2052
|
+
}
|
|
2053
|
+
return native.layoutClassesToCss(classes);
|
|
2054
|
+
}
|
|
2055
|
+
function _hashContainer(tag, containerJson, name) {
|
|
2056
|
+
const sortedKey = tag + (name ?? "") + containerJson;
|
|
2057
|
+
const native = getNativeBridge();
|
|
2058
|
+
if (!native?.hashContent) {
|
|
2059
|
+
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
2060
|
+
}
|
|
2061
|
+
return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
2062
|
+
}
|
|
2063
|
+
function extractContainerCssFromSource(source) {
|
|
2064
|
+
const native = getNativeBridge();
|
|
2065
|
+
if (!native?.extractTwContainerConfigs) {
|
|
2066
|
+
throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
|
|
2067
|
+
}
|
|
2068
|
+
const configs = native.extractTwContainerConfigs(source);
|
|
2069
|
+
const rules = [];
|
|
2070
|
+
for (const cfg of configs) {
|
|
2071
|
+
const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
|
|
2072
|
+
for (const { key, classes } of cfg.breakpoints) {
|
|
2073
|
+
const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
|
|
2074
|
+
const css = _layoutClassesToCss(classes);
|
|
2075
|
+
if (!css) continue;
|
|
2076
|
+
const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
2077
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return rules.join("\n");
|
|
2081
|
+
}
|
|
2082
|
+
var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
2083
|
+
var init_src = __esm({
|
|
2084
|
+
"packages/domain/compiler/src/index.ts"() {
|
|
2085
|
+
init_nativeBridge();
|
|
2086
|
+
init_compiler();
|
|
2087
|
+
init_parser();
|
|
2088
|
+
init_analyzer();
|
|
2089
|
+
init_cache();
|
|
2090
|
+
init_redis();
|
|
2091
|
+
init_watch();
|
|
2092
|
+
transformSource = (source, opts) => {
|
|
2093
|
+
const native = getNativeBridge();
|
|
2094
|
+
if (!native?.transformSource) {
|
|
2095
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2096
|
+
}
|
|
2097
|
+
const result = native.transformSource(source, opts);
|
|
2098
|
+
if (!result) {
|
|
2099
|
+
throw new Error("FATAL: transformSource returned null");
|
|
2100
|
+
}
|
|
2101
|
+
return result;
|
|
2102
|
+
};
|
|
2103
|
+
hasTwUsage = (source) => {
|
|
2104
|
+
const native = getNativeBridge();
|
|
2105
|
+
if (!native?.hasTwUsage) {
|
|
2106
|
+
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
2107
|
+
}
|
|
2108
|
+
return native.hasTwUsage(source);
|
|
2109
|
+
};
|
|
2110
|
+
isAlreadyTransformed = (source) => {
|
|
2111
|
+
const native = getNativeBridge();
|
|
2112
|
+
if (!native?.isAlreadyTransformed) {
|
|
2113
|
+
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
2114
|
+
}
|
|
2115
|
+
return native.isAlreadyTransformed(source);
|
|
2116
|
+
};
|
|
2117
|
+
shouldProcess = (source) => {
|
|
2118
|
+
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
2119
|
+
};
|
|
2120
|
+
compileCssFromClasses = (classes, prefix) => {
|
|
2121
|
+
const native = getNativeBridge();
|
|
2122
|
+
if (!native?.transformSource) {
|
|
2123
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2124
|
+
}
|
|
2125
|
+
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
2126
|
+
if (!result) {
|
|
2127
|
+
throw new Error("FATAL: transformSource returned null");
|
|
2128
|
+
}
|
|
2129
|
+
return result;
|
|
2130
|
+
};
|
|
2131
|
+
buildStyleTag = (classes) => {
|
|
2132
|
+
const result = compileCssFromClasses(classes);
|
|
2133
|
+
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
2134
|
+
};
|
|
2135
|
+
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2136
|
+
try {
|
|
2137
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2138
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2139
|
+
return result.css;
|
|
2140
|
+
} catch {
|
|
2141
|
+
const native = getNativeBridge();
|
|
2142
|
+
if (!native?.transformSource) {
|
|
2143
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2144
|
+
}
|
|
2145
|
+
const result = native.transformSource(classes.join(" "), {});
|
|
2146
|
+
return result?.code || "";
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
eliminateDeadCss = (css, deadClasses) => {
|
|
2150
|
+
const native = getNativeBridge();
|
|
2151
|
+
if (!native?.eliminateDeadCss) {
|
|
2152
|
+
throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
|
|
2153
|
+
}
|
|
2154
|
+
return native.eliminateDeadCss(css, Array.from(deadClasses));
|
|
2155
|
+
};
|
|
2156
|
+
findDeadVariants = (variantConfig, usage) => {
|
|
2157
|
+
const unused = [];
|
|
2158
|
+
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
2159
|
+
for (const component of configs) {
|
|
2160
|
+
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
2161
|
+
const variants = component.variants;
|
|
2162
|
+
for (const [key, values] of Object.entries(variants)) {
|
|
2163
|
+
for (const [value] of Object.entries(values)) {
|
|
2164
|
+
if (!componentUsage.has(`${key}:${value}`)) {
|
|
2165
|
+
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
return { unusedCount: unused.length, unused };
|
|
2171
|
+
};
|
|
2172
|
+
runElimination = (css, scanResult) => {
|
|
2173
|
+
const native = getNativeBridge();
|
|
2174
|
+
if (!native?.detectDeadCode) {
|
|
2175
|
+
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
2176
|
+
}
|
|
2177
|
+
const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
|
|
2178
|
+
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
2179
|
+
};
|
|
2180
|
+
scanProjectUsage = (dirs, cwd) => {
|
|
2181
|
+
const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
|
|
2182
|
+
const files = dirs.map((dir) => path10__default.resolve(cwd, dir));
|
|
2183
|
+
const results = batchExtractClasses2(files) || [];
|
|
2184
|
+
const combined = {};
|
|
2185
|
+
for (const result of results) {
|
|
2186
|
+
if (result.ok && result.classes) {
|
|
2187
|
+
for (const cls of result.classes) {
|
|
2188
|
+
if (!combined[cls]) combined[cls] = {};
|
|
2189
|
+
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
return combined;
|
|
2194
|
+
};
|
|
2195
|
+
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
2196
|
+
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
2197
|
+
const allClasses = Object.keys(classes).sort();
|
|
2198
|
+
if (outputPath) {
|
|
2199
|
+
fs9__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
2200
|
+
}
|
|
2201
|
+
return allClasses;
|
|
2202
|
+
};
|
|
2203
|
+
loadSafelist = (safelistPath) => {
|
|
2204
|
+
try {
|
|
2205
|
+
const content = fs9__default.readFileSync(safelistPath, "utf-8");
|
|
2206
|
+
return JSON.parse(content);
|
|
2207
|
+
} catch {
|
|
2208
|
+
return [];
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
2212
|
+
const configFiles = [
|
|
2213
|
+
"tailwind.config.ts",
|
|
2214
|
+
"tailwind.config.js",
|
|
2215
|
+
"tailwind.config.mjs",
|
|
2216
|
+
"tailwind.config.cjs"
|
|
2217
|
+
];
|
|
2218
|
+
for (const file of configFiles) {
|
|
2219
|
+
const fullPath = path10__default.join(cwd, file);
|
|
2220
|
+
if (fs9__default.existsSync(fullPath)) {
|
|
2221
|
+
const mod = __require(fullPath);
|
|
2222
|
+
return mod.default || mod;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return {};
|
|
2226
|
+
};
|
|
2227
|
+
getContentPaths = (cwd = process.cwd()) => {
|
|
2228
|
+
return {
|
|
2229
|
+
content: [
|
|
2230
|
+
path10__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
2231
|
+
path10__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
2232
|
+
path10__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
2233
|
+
]
|
|
2234
|
+
};
|
|
2235
|
+
};
|
|
2236
|
+
_CONTAINER_BREAKPOINTS = {
|
|
2237
|
+
xs: "240px",
|
|
2238
|
+
sm: "320px",
|
|
2239
|
+
md: "640px",
|
|
2240
|
+
lg: "1024px",
|
|
2241
|
+
xl: "1280px",
|
|
2242
|
+
"2xl": "1536px"
|
|
2243
|
+
};
|
|
2244
|
+
runLoaderTransform = (ctx) => {
|
|
2245
|
+
const { filepath, source, options } = ctx;
|
|
2246
|
+
const result = transformSource(source, { filename: filepath, ...options });
|
|
2247
|
+
let staticCss;
|
|
2248
|
+
try {
|
|
2249
|
+
const cssChunks = [];
|
|
2250
|
+
const stateRules = extractAndGenerateStateCss(source, filepath);
|
|
2251
|
+
if (stateRules.length > 0) {
|
|
2252
|
+
cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
|
|
2253
|
+
}
|
|
2254
|
+
const containerCss = extractContainerCssFromSource(source);
|
|
2255
|
+
if (containerCss) cssChunks.push(containerCss);
|
|
2256
|
+
const combined = cssChunks.join("\n").trim();
|
|
2257
|
+
if (combined) staticCss = combined;
|
|
2258
|
+
} catch (err) {
|
|
2259
|
+
console.debug("Static CSS extraction warning:", err);
|
|
2260
|
+
}
|
|
2261
|
+
return {
|
|
2262
|
+
code: result?.code || "",
|
|
2263
|
+
changed: result?.changed || false,
|
|
2264
|
+
classes: result?.classes || [],
|
|
2265
|
+
staticCss
|
|
2266
|
+
};
|
|
2267
|
+
};
|
|
2268
|
+
shouldSkipFile = (filepath) => {
|
|
2269
|
+
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
2270
|
+
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
2271
|
+
for (const p of SKIP_PATHS) {
|
|
2272
|
+
if (filepath.includes(p)) return true;
|
|
2273
|
+
}
|
|
2274
|
+
for (const ext of skipExtensions) {
|
|
2275
|
+
if (filepath.endsWith(ext)) return true;
|
|
2276
|
+
}
|
|
2277
|
+
return false;
|
|
2278
|
+
};
|
|
2279
|
+
fileToRoute = (filepath) => {
|
|
2280
|
+
const normalized = filepath.replace(/\\/g, "/");
|
|
2281
|
+
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
2282
|
+
return "__global";
|
|
2283
|
+
}
|
|
2284
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
2285
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
2286
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
2287
|
+
if (rootPage) return "/";
|
|
2288
|
+
return null;
|
|
2289
|
+
};
|
|
2290
|
+
getAllRoutes = () => {
|
|
2291
|
+
const native = getNativeBridge();
|
|
2292
|
+
if (!native?.analyzeClasses) {
|
|
2293
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
2294
|
+
}
|
|
2295
|
+
return ["/", "__global"];
|
|
2296
|
+
};
|
|
2297
|
+
getRouteClasses = (_route) => /* @__PURE__ */ new Set();
|
|
2298
|
+
registerFileClasses = (_filepath, _classes) => {
|
|
2299
|
+
};
|
|
2300
|
+
registerGlobalClasses = (_classes) => {
|
|
2301
|
+
};
|
|
2302
|
+
_incrementalEngineInstance = null;
|
|
2303
|
+
getIncrementalEngine = () => {
|
|
2304
|
+
if (!_incrementalEngineInstance) {
|
|
2305
|
+
_incrementalEngineInstance = new IncrementalEngine();
|
|
2306
|
+
}
|
|
2307
|
+
return _incrementalEngineInstance;
|
|
2308
|
+
};
|
|
2309
|
+
resetIncrementalEngine = () => {
|
|
2310
|
+
_incrementalEngineInstance = null;
|
|
2311
|
+
};
|
|
2312
|
+
IncrementalEngine = class {
|
|
2313
|
+
compile(source) {
|
|
2314
|
+
return transformSource(source);
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
getBucketEngine = () => {
|
|
2318
|
+
const native = getNativeBridge();
|
|
2319
|
+
if (!native?.classifyAndSortClasses) {
|
|
2320
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2321
|
+
}
|
|
2322
|
+
return {
|
|
2323
|
+
add: (className) => className,
|
|
2324
|
+
get: (_bucket) => []
|
|
2325
|
+
};
|
|
2326
|
+
};
|
|
2327
|
+
resetBucketEngine = () => {
|
|
2328
|
+
};
|
|
2329
|
+
BucketEngine = class {
|
|
2330
|
+
add(className) {
|
|
2331
|
+
return className;
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
classifyNode = (_node) => {
|
|
2335
|
+
const native = getNativeBridge();
|
|
2336
|
+
if (!native?.classifyAndSortClasses) {
|
|
2337
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2338
|
+
}
|
|
2339
|
+
return "unknown";
|
|
2340
|
+
};
|
|
2341
|
+
detectConflicts = (_classes) => {
|
|
2342
|
+
const native = getNativeBridge();
|
|
2343
|
+
if (!native?.analyzeClassUsage) {
|
|
2344
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
2345
|
+
}
|
|
2346
|
+
return [];
|
|
2347
|
+
};
|
|
2348
|
+
bucketSort = (classes) => {
|
|
2349
|
+
const native = getNativeBridge();
|
|
2350
|
+
if (!native?.classifyAndSortClasses) {
|
|
2351
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2352
|
+
}
|
|
2353
|
+
const sorted = native.classifyAndSortClasses(classes);
|
|
2354
|
+
return sorted.map((c) => c.raw ?? c);
|
|
2355
|
+
};
|
|
2356
|
+
analyzeFile = (source, filename) => {
|
|
2357
|
+
const native = getNativeBridge();
|
|
2358
|
+
if (!native?.analyzeRsc) {
|
|
2359
|
+
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
2360
|
+
}
|
|
2361
|
+
const rsc = native.analyzeRsc(source, filename);
|
|
2362
|
+
return {
|
|
2363
|
+
isServer: rsc?.isServer ?? true,
|
|
2364
|
+
needsClientDirective: rsc?.needsClientDirective ?? false,
|
|
2365
|
+
clientReasons: rsc?.clientReasons ?? [],
|
|
2366
|
+
interactiveClasses: [],
|
|
2367
|
+
canStaticResolveVariants: true
|
|
2368
|
+
};
|
|
2369
|
+
};
|
|
2370
|
+
analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
|
|
2371
|
+
return { resolved: {}, dynamic: [] };
|
|
2372
|
+
};
|
|
2373
|
+
injectClientDirective = (source) => {
|
|
2374
|
+
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
2375
|
+
return '"use client";\n' + source;
|
|
2376
|
+
}
|
|
2377
|
+
return source;
|
|
2378
|
+
};
|
|
2379
|
+
injectServerOnlyComment = (source) => {
|
|
2380
|
+
return `/* @server-only */
|
|
2381
|
+
${source}`;
|
|
2382
|
+
};
|
|
2383
|
+
analyzeClasses = (filesJson, cwd, flags) => {
|
|
2384
|
+
const native = getNativeBridge();
|
|
2385
|
+
if (!native?.analyzeClasses) {
|
|
2386
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
2387
|
+
}
|
|
2388
|
+
return native.analyzeClasses(filesJson, cwd, flags);
|
|
2389
|
+
};
|
|
2390
|
+
extractTwStateConfigs = (source, filename) => {
|
|
2391
|
+
const native = getNativeBridge();
|
|
2392
|
+
if (!native?.extractTwStateConfigs) {
|
|
2393
|
+
throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
|
|
2394
|
+
}
|
|
2395
|
+
return native.extractTwStateConfigs(source, filename);
|
|
2396
|
+
};
|
|
2397
|
+
generateStaticStateCss = (entries, _themeConfig) => {
|
|
2398
|
+
const rules = [];
|
|
2399
|
+
for (const entry of entries) {
|
|
2400
|
+
const stateConfig = JSON.parse(entry.statesJson);
|
|
2401
|
+
for (const [stateName, classes] of Object.entries(stateConfig)) {
|
|
2402
|
+
rules.push({
|
|
2403
|
+
selector: `.${entry.componentName}[data-state="${stateName}"]`,
|
|
2404
|
+
declarations: classes,
|
|
2405
|
+
cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
|
|
2406
|
+
componentName: entry.componentName,
|
|
2407
|
+
stateName
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return rules;
|
|
2412
|
+
};
|
|
2413
|
+
extractAndGenerateStateCss = (source, filename) => {
|
|
2414
|
+
const entries = extractTwStateConfigs(source, filename);
|
|
2415
|
+
return generateStaticStateCss(entries);
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
|
|
2420
|
+
// packages/domain/compiler/src/internal.ts
|
|
2421
|
+
var internal_exports = {};
|
|
2422
|
+
__export(internal_exports, {
|
|
2423
|
+
adaptNativeResult: () => adaptNativeResult,
|
|
2424
|
+
analyzeClassUsageNative: () => analyzeClassUsageNative,
|
|
2425
|
+
analyzeClasses: () => analyzeClasses,
|
|
2426
|
+
analyzeClassesNative: () => analyzeClassesNative,
|
|
2427
|
+
analyzeFile: () => analyzeFile,
|
|
2428
|
+
analyzeRscNative: () => analyzeRscNative,
|
|
2429
|
+
analyzeVariantUsage: () => analyzeVariantUsage,
|
|
2430
|
+
astExtractClasses: () => astExtractClasses,
|
|
2431
|
+
atomicRegistrySize: () => atomicRegistrySize,
|
|
2432
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
2433
|
+
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
2434
|
+
bucketSort: () => bucketSort,
|
|
2435
|
+
buildStyleTag: () => buildStyleTag,
|
|
2436
|
+
cachePriority: () => cachePriority,
|
|
2437
|
+
cacheRead: () => cacheRead,
|
|
2438
|
+
cacheWrite: () => cacheWrite,
|
|
2439
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
2440
|
+
checkAgainstSafelistNative: () => checkAgainstSafelistNative,
|
|
2441
|
+
classifyAndSortClassesNative: () => classifyAndSortClassesNative,
|
|
2442
|
+
classifyNode: () => classifyNode,
|
|
2443
|
+
clearAllCaches: () => clearAllCaches,
|
|
2444
|
+
clearAtomicRegistry: () => clearAtomicRegistry,
|
|
2445
|
+
clearCache: () => clearCache,
|
|
2446
|
+
clearCompileCache: () => clearCompileCache,
|
|
2447
|
+
clearCssGenCache: () => clearCssGenCache,
|
|
2448
|
+
clearParseCache: () => clearParseCache,
|
|
2449
|
+
clearResolveCache: () => clearResolveCache,
|
|
2450
|
+
clearThemeCache: () => clearThemeCache,
|
|
2451
|
+
collectFiles: () => collectFiles,
|
|
2452
|
+
compileAnimation: () => compileAnimation,
|
|
2453
|
+
compileClass: () => compileClass,
|
|
2454
|
+
compileClasses: () => compileClasses,
|
|
2455
|
+
compileCssFromClasses: () => compileCssFromClasses,
|
|
2456
|
+
compileCssLightning: () => compileCssLightning,
|
|
2457
|
+
compileCssNative2: () => compileCssNative2,
|
|
2458
|
+
compileKeyframes: () => compileKeyframes,
|
|
2459
|
+
compileTheme: () => compileTheme,
|
|
2460
|
+
compileToCss: () => compileToCss,
|
|
2461
|
+
compileToCssBatch: () => compileToCssBatch,
|
|
2462
|
+
compileVariantTableNative: () => compileVariantTableNative,
|
|
2463
|
+
computeIncrementalDiff: () => computeIncrementalDiff,
|
|
2464
|
+
createFingerprint: () => createFingerprint,
|
|
2465
|
+
detectConflicts: () => detectConflicts,
|
|
2466
|
+
detectDeadCode: () => detectDeadCode,
|
|
2467
|
+
diffClassLists: () => diffClassLists,
|
|
2468
|
+
eliminateDeadCss: () => eliminateDeadCss,
|
|
2469
|
+
eliminateDeadCssNative: () => eliminateDeadCssNative,
|
|
2470
|
+
emitPluginHook: () => emitPluginHook,
|
|
2471
|
+
estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
|
|
2472
|
+
extractAllClasses: () => extractAllClasses,
|
|
2473
|
+
extractAndGenerateStateCss: () => extractAndGenerateStateCss,
|
|
2474
|
+
extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
|
|
2475
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
2476
|
+
extractClassesFromSourceNative: () => extractClassesFromSourceNative,
|
|
2477
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
2478
|
+
extractContainerCssFromSource: () => extractContainerCssFromSource,
|
|
2479
|
+
extractTwContainerConfigs: () => extractTwContainerConfigs,
|
|
2480
|
+
extractTwStateConfigs: () => extractTwStateConfigs,
|
|
2481
|
+
extractTwStateConfigsNative: () => extractTwStateConfigsNative,
|
|
2482
|
+
fileToRoute: () => fileToRoute,
|
|
2483
|
+
findDeadVariants: () => findDeadVariants,
|
|
2484
|
+
generateAtomicCss: () => generateAtomicCss,
|
|
2485
|
+
generateCssForClasses: () => generateCssForClasses,
|
|
2486
|
+
generateCssNative: () => generateCssNative,
|
|
2487
|
+
generateSafelist: () => generateSafelist,
|
|
2488
|
+
generateStaticStateCss: () => generateStaticStateCss,
|
|
2489
|
+
generateStaticStateCssNative: () => generateStaticStateCssNative,
|
|
2490
|
+
generateSubComponentTypes: () => generateSubComponentTypes,
|
|
2491
|
+
getAllRoutes: () => getAllRoutes,
|
|
2492
|
+
getBucketEngine: () => getBucketEngine,
|
|
2493
|
+
getCacheOptimizationHints: () => getCacheOptimizationHints,
|
|
2494
|
+
getCacheStatistics: () => getCacheStatistics,
|
|
2495
|
+
getCacheStats: () => getCacheStats2,
|
|
2496
|
+
getCompilationMetrics: () => getCompilationMetrics,
|
|
2497
|
+
getCompilerDiagnostics: () => getCompilerDiagnostics,
|
|
2498
|
+
getContentPaths: () => getContentPaths,
|
|
2499
|
+
getIncrementalEngine: () => getIncrementalEngine,
|
|
2500
|
+
getNativeBridge: () => getNativeBridge,
|
|
2501
|
+
getPluginHooks: () => getPluginHooks,
|
|
2502
|
+
getRouteClasses: () => getRouteClasses,
|
|
2503
|
+
getWatchStats: () => getWatchStats,
|
|
2504
|
+
hasTwUsage: () => hasTwUsage,
|
|
2505
|
+
hashContent: () => hashContent,
|
|
2506
|
+
hoistComponentsNative: () => hoistComponentsNative,
|
|
2507
|
+
idRegistryActiveCount: () => idRegistryActiveCount,
|
|
2508
|
+
idRegistryCreate: () => idRegistryCreate,
|
|
2509
|
+
idRegistryDestroy: () => idRegistryDestroy,
|
|
2510
|
+
idRegistryExport: () => idRegistryExport,
|
|
2511
|
+
idRegistryGenerate: () => idRegistryGenerate,
|
|
2512
|
+
idRegistryImport: () => idRegistryImport,
|
|
2513
|
+
idRegistryLookup: () => idRegistryLookup,
|
|
2514
|
+
idRegistryNext: () => idRegistryNext,
|
|
2515
|
+
idRegistryReset: () => idRegistryReset,
|
|
2516
|
+
idRegistrySnapshot: () => idRegistrySnapshot,
|
|
2517
|
+
injectClientDirective: () => injectClientDirective,
|
|
2518
|
+
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
2519
|
+
injectStateHash: () => injectStateHash,
|
|
2520
|
+
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
2521
|
+
isWatchRunning: () => isWatchRunning,
|
|
2522
|
+
layoutClassesToCss: () => layoutClassesToCss,
|
|
2523
|
+
loadSafelist: () => loadSafelist,
|
|
2524
|
+
loadTailwindConfig: () => loadTailwindConfig,
|
|
2525
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
2526
|
+
mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
|
|
2527
|
+
minifyCss: () => minifyCss,
|
|
2528
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
2529
|
+
normalizeClasses: () => normalizeClasses,
|
|
2530
|
+
optimizeCssNative: () => optimizeCssNative,
|
|
2531
|
+
parseAtomicClass: () => parseAtomicClass,
|
|
2532
|
+
parseClasses: () => parseClasses,
|
|
2533
|
+
pollWatchEvents: () => pollWatchEvents,
|
|
2534
|
+
processFileChange: () => processFileChange,
|
|
2535
|
+
processTailwindCssLightning: () => processTailwindCssLightning,
|
|
2536
|
+
propertyIdToString: () => propertyIdToString,
|
|
2537
|
+
pruneStaleCacheEntries: () => pruneStaleCacheEntries,
|
|
2538
|
+
rebuildWorkspaceResult: () => rebuildWorkspaceResult,
|
|
2539
|
+
redisCacheClear: () => redisCacheClear,
|
|
2540
|
+
redisCacheHitRate: () => redisCacheHitRate,
|
|
2541
|
+
redisCacheKeyCount: () => redisCacheKeyCount,
|
|
2542
|
+
redisCacheSize: () => redisCacheSize,
|
|
2543
|
+
redisCacheSync: () => redisCacheSync,
|
|
2544
|
+
redisClusterStatus: () => redisClusterStatus,
|
|
2545
|
+
redisDelete: () => redisDelete,
|
|
2546
|
+
redisDiagnose: () => redisDiagnose,
|
|
2547
|
+
redisDisableCacheWarming: () => redisDisableCacheWarming,
|
|
2548
|
+
redisDisableCluster: () => redisDisableCluster,
|
|
2549
|
+
redisDisablePersistence: () => redisDisablePersistence,
|
|
2550
|
+
redisEnableCacheWarming: () => redisEnableCacheWarming,
|
|
2551
|
+
redisEnableCluster: () => redisEnableCluster,
|
|
2552
|
+
redisEnablePersistence: () => redisEnablePersistence,
|
|
2553
|
+
redisExists: () => redisExists,
|
|
2554
|
+
redisExpirationGet: () => redisExpirationGet,
|
|
2555
|
+
redisExpirationSet: () => redisExpirationSet,
|
|
2556
|
+
redisFlushAll: () => redisFlushAll,
|
|
2557
|
+
redisFlushDb: () => redisFlushDb,
|
|
2558
|
+
redisGet: () => redisGet,
|
|
2559
|
+
redisGetEvictionPolicy: () => redisGetEvictionPolicy,
|
|
2560
|
+
redisInfo: () => redisInfo,
|
|
2561
|
+
redisMemoryStats: () => redisMemoryStats,
|
|
2562
|
+
redisMget: () => redisMget,
|
|
2563
|
+
redisMonitor: () => redisMonitor,
|
|
2564
|
+
redisMset: () => redisMset,
|
|
2565
|
+
redisOptimizeMemory: () => redisOptimizeMemory,
|
|
2566
|
+
redisPing: () => redisPing,
|
|
2567
|
+
redisPoolConnect: () => redisPoolConnect,
|
|
2568
|
+
redisPoolReconnect: () => redisPoolReconnect,
|
|
2569
|
+
redisPoolStats: () => redisPoolStats,
|
|
2570
|
+
redisPublish: () => redisPublish,
|
|
2571
|
+
redisReplicate: () => redisReplicate,
|
|
2572
|
+
redisReplicationStatus: () => redisReplicationStatus,
|
|
2573
|
+
redisSet: () => redisSet,
|
|
2574
|
+
redisSetEvictionPolicy: () => redisSetEvictionPolicy,
|
|
2575
|
+
redisSnapshot: () => redisSnapshot,
|
|
2576
|
+
redisSubscribe: () => redisSubscribe,
|
|
2577
|
+
registerFileClasses: () => registerFileClasses,
|
|
2578
|
+
registerGlobalClasses: () => registerGlobalClasses,
|
|
2579
|
+
registerPluginHook: () => registerPluginHook,
|
|
2580
|
+
registerPropertyName: () => registerPropertyName,
|
|
2581
|
+
registerValueName: () => registerValueName,
|
|
2582
|
+
resetBucketEngine: () => resetBucketEngine,
|
|
2583
|
+
resetCompilationMetrics: () => resetCompilationMetrics,
|
|
2584
|
+
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
2585
|
+
resolveCascade: () => resolveCascade,
|
|
2586
|
+
resolveClassNames: () => resolveClassNames,
|
|
2587
|
+
resolveConflictGroup: () => resolveConflictGroup,
|
|
2588
|
+
resolveSimpleVariants: () => resolveSimpleVariants,
|
|
2589
|
+
resolveThemeValue: () => resolveThemeValue,
|
|
2590
|
+
resolveVariants: () => resolveVariants,
|
|
2591
|
+
reverseLookupProperty: () => reverseLookupProperty,
|
|
2592
|
+
reverseLookupValue: () => reverseLookupValue,
|
|
2593
|
+
runCssPipeline: () => runCssPipeline,
|
|
2594
|
+
runCssPipelineSync: () => runCssPipelineSync,
|
|
2595
|
+
runElimination: () => runElimination,
|
|
2596
|
+
runLoaderTransform: () => runLoaderTransform,
|
|
2597
|
+
scanCacheOptimizations: () => scanCacheOptimizations,
|
|
2598
|
+
scanFile: () => scanFile,
|
|
2599
|
+
scanFileNative: () => scanFileNative,
|
|
2600
|
+
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
2601
|
+
scanProjectUsage: () => scanProjectUsage,
|
|
2602
|
+
scanWorkspace: () => scanWorkspace,
|
|
2603
|
+
shouldProcess: () => shouldProcess,
|
|
2604
|
+
shouldSkipFile: () => shouldSkipFile,
|
|
2605
|
+
startWatch: () => startWatch,
|
|
2606
|
+
stopWatch: () => stopWatch,
|
|
2607
|
+
toAtomicClasses: () => toAtomicClasses,
|
|
2608
|
+
transformSource: () => transformSource,
|
|
2609
|
+
twMerge: () => twMerge,
|
|
2610
|
+
twMergeMany: () => twMergeMany,
|
|
2611
|
+
twMergeManyWithSeparator: () => twMergeManyWithSeparator,
|
|
2612
|
+
twMergeRaw: () => twMergeRaw,
|
|
2613
|
+
twMergeWithSeparator: () => twMergeWithSeparator,
|
|
2614
|
+
unregisterPluginHook: () => unregisterPluginHook,
|
|
2615
|
+
validateCssOutput: () => validateCssOutput,
|
|
2616
|
+
validateThemeConfig: () => validateThemeConfig,
|
|
2617
|
+
valueIdToString: () => valueIdToString,
|
|
2618
|
+
walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
|
|
2619
|
+
watchAddPattern: () => watchAddPattern,
|
|
2620
|
+
watchClearAll: () => watchClearAll,
|
|
2621
|
+
watchEventTypeToString: () => watchEventTypeToString,
|
|
2622
|
+
watchGetActiveHandles: () => watchGetActiveHandles,
|
|
2623
|
+
watchPause: () => watchPause,
|
|
2624
|
+
watchRemovePattern: () => watchRemovePattern,
|
|
2625
|
+
watchResume: () => watchResume
|
|
2626
|
+
});
|
|
2627
|
+
var init_internal = __esm({
|
|
2628
|
+
"packages/domain/compiler/src/internal.ts"() {
|
|
2629
|
+
init_src();
|
|
2630
|
+
init_tailwindEngine();
|
|
2631
|
+
init_compiler();
|
|
2632
|
+
init_parser();
|
|
2633
|
+
init_analyzer();
|
|
2634
|
+
init_cache();
|
|
2635
|
+
init_redis();
|
|
2636
|
+
init_watch();
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
function getNative() {
|
|
2640
|
+
if (_native) return _native;
|
|
2641
|
+
try {
|
|
2642
|
+
const mod = (init_internal(), __toCommonJS(internal_exports));
|
|
2643
|
+
if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
|
|
2644
|
+
return null;
|
|
2645
|
+
}
|
|
2646
|
+
_native = {
|
|
2647
|
+
extractTwStateConfigs: mod.extractTwStateConfigs,
|
|
2648
|
+
generateStaticStateCss: mod.generateStaticStateCss,
|
|
2649
|
+
extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
|
|
2650
|
+
((source, filename) => {
|
|
2651
|
+
const configs = mod.extractTwStateConfigs(source, filename);
|
|
2652
|
+
if (configs.length === 0) return [];
|
|
2653
|
+
return mod.generateStaticStateCss(configs.map((c) => ({
|
|
2654
|
+
tag: c.tag,
|
|
2655
|
+
componentName: c.componentName,
|
|
2656
|
+
statesJson: c.statesJson
|
|
2657
|
+
})));
|
|
2658
|
+
})
|
|
2659
|
+
};
|
|
2660
|
+
return _native;
|
|
2661
|
+
} catch {
|
|
2662
|
+
return null;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
function* walkSourceFiles(dir) {
|
|
2666
|
+
let entries;
|
|
2667
|
+
try {
|
|
2668
|
+
entries = fs9__default.readdirSync(dir, { withFileTypes: true });
|
|
2669
|
+
} catch {
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2672
|
+
for (const entry of entries) {
|
|
2673
|
+
const fullPath = path10__default.join(dir, entry.name);
|
|
2674
|
+
if (entry.isDirectory()) {
|
|
2675
|
+
if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
|
|
2676
|
+
yield* walkSourceFiles(fullPath);
|
|
2677
|
+
} else if (entry.isFile()) {
|
|
2678
|
+
const ext = path10__default.extname(entry.name);
|
|
2679
|
+
if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
function buildCssHeader(result) {
|
|
2684
|
+
return [
|
|
2685
|
+
"/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
2686
|
+
" * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
|
|
2687
|
+
" * DO NOT EDIT. Re-generated on each build.",
|
|
2688
|
+
" *",
|
|
2689
|
+
` * Files scanned: ${result.filesScanned}`,
|
|
2690
|
+
` * Files with states: ${result.filesWithStates}`,
|
|
2691
|
+
` * Components found: ${result.componentsFound}`,
|
|
2692
|
+
` * Rules generated: ${result.rulesGenerated}`,
|
|
2693
|
+
` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
|
|
2694
|
+
" *",
|
|
2695
|
+
' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
|
|
2696
|
+
" * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
|
|
2697
|
+
" * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */",
|
|
2698
|
+
""
|
|
2699
|
+
].join("\n");
|
|
2700
|
+
}
|
|
2701
|
+
function extractStaticStateCss(srcDir, options = {}) {
|
|
2702
|
+
const { verbose = false, maxFiles = Infinity } = options;
|
|
2703
|
+
const native = getNative();
|
|
2704
|
+
if (!native) {
|
|
2705
|
+
if (verbose) {
|
|
2706
|
+
process.stderr.write(
|
|
2707
|
+
"[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
|
|
2708
|
+
);
|
|
2709
|
+
}
|
|
2710
|
+
return {
|
|
2711
|
+
filesScanned: 0,
|
|
2712
|
+
filesWithStates: 0,
|
|
2713
|
+
componentsFound: 0,
|
|
2714
|
+
rulesGenerated: 0,
|
|
2715
|
+
rulesSkipped: 0,
|
|
2716
|
+
generatedCss: "",
|
|
2717
|
+
rules: []
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
const allConfigs = [];
|
|
2721
|
+
let filesScanned = 0;
|
|
2722
|
+
let filesWithStates = 0;
|
|
2723
|
+
if (native.walkAndPrefilterSourceFiles) {
|
|
2724
|
+
const prefiltered = native.walkAndPrefilterSourceFiles(
|
|
2725
|
+
srcDir,
|
|
2726
|
+
[".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
|
|
2727
|
+
["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
|
|
2728
|
+
// Required substrings — AND logic, identik dengan JS pre-filter di bawah
|
|
2729
|
+
["states:", "tw."],
|
|
2730
|
+
maxFiles === Infinity ? null : maxFiles,
|
|
2731
|
+
null
|
|
2732
|
+
// sequential — parallel mode opsional untuk large monorepo
|
|
2733
|
+
);
|
|
2734
|
+
for (const { path: filePath, content: source } of prefiltered) {
|
|
2735
|
+
filesScanned++;
|
|
2736
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
2737
|
+
if (configs.length > 0) {
|
|
2738
|
+
filesWithStates++;
|
|
2739
|
+
allConfigs.push(...configs);
|
|
2740
|
+
if (verbose) {
|
|
2741
|
+
process.stderr.write(
|
|
2742
|
+
`[tw:static-state] ${path10__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2743
|
+
`
|
|
2744
|
+
);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
} else {
|
|
2749
|
+
for (const filePath of walkSourceFiles(srcDir)) {
|
|
2750
|
+
if (filesScanned >= maxFiles) break;
|
|
2751
|
+
let source;
|
|
2752
|
+
try {
|
|
2753
|
+
source = fs9__default.readFileSync(filePath, "utf-8");
|
|
2754
|
+
} catch {
|
|
2755
|
+
continue;
|
|
2756
|
+
}
|
|
2757
|
+
filesScanned++;
|
|
2758
|
+
if (!source.includes("states:") && !source.includes("states :")) continue;
|
|
2759
|
+
if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
|
|
2760
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
2761
|
+
if (configs.length > 0) {
|
|
2762
|
+
filesWithStates++;
|
|
2763
|
+
allConfigs.push(...configs);
|
|
2764
|
+
if (verbose) {
|
|
2765
|
+
process.stderr.write(
|
|
2766
|
+
`[tw:static-state] ${path10__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2767
|
+
`
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
if (allConfigs.length === 0) {
|
|
2774
|
+
return {
|
|
2775
|
+
filesScanned,
|
|
2776
|
+
filesWithStates: 0,
|
|
2777
|
+
componentsFound: 0,
|
|
2778
|
+
rulesGenerated: 0,
|
|
2779
|
+
rulesSkipped: 0,
|
|
2780
|
+
generatedCss: "",
|
|
2781
|
+
rules: []
|
|
2782
|
+
};
|
|
2783
|
+
}
|
|
2784
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2785
|
+
const uniqueConfigs = [];
|
|
2786
|
+
for (const config of allConfigs) {
|
|
2787
|
+
const key = `${config.tag}::${config.statesJson}`;
|
|
2788
|
+
if (!seen.has(key)) {
|
|
2789
|
+
seen.add(key);
|
|
2790
|
+
uniqueConfigs.push({
|
|
2791
|
+
tag: config.tag,
|
|
2792
|
+
componentName: config.componentName,
|
|
2793
|
+
statesJson: config.statesJson
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
|
|
2798
|
+
const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
|
|
2799
|
+
try {
|
|
2800
|
+
const stateMap = JSON.parse(cfg.statesJson);
|
|
2801
|
+
return total + Object.keys(stateMap).length;
|
|
2802
|
+
} catch {
|
|
2803
|
+
return total;
|
|
2804
|
+
}
|
|
2805
|
+
}, 0) - allRules.length;
|
|
2806
|
+
const byComponent = /* @__PURE__ */ new Map();
|
|
2807
|
+
for (const rule of allRules) {
|
|
2808
|
+
const existing = byComponent.get(rule.componentName) ?? [];
|
|
2809
|
+
existing.push(rule);
|
|
2810
|
+
byComponent.set(rule.componentName, existing);
|
|
2811
|
+
}
|
|
2812
|
+
const cssBlocks = [];
|
|
2813
|
+
for (const [componentName, rules] of byComponent) {
|
|
2814
|
+
cssBlocks.push(`/* ${componentName} */`);
|
|
2815
|
+
for (const rule of rules) {
|
|
2816
|
+
cssBlocks.push(`/* state: ${rule.stateName} */`);
|
|
2817
|
+
cssBlocks.push(rule.cssRule);
|
|
2818
|
+
}
|
|
2819
|
+
cssBlocks.push("");
|
|
2820
|
+
}
|
|
2821
|
+
const result = {
|
|
2822
|
+
filesScanned,
|
|
2823
|
+
filesWithStates,
|
|
2824
|
+
componentsFound: allConfigs.length,
|
|
2825
|
+
rulesGenerated: allRules.length,
|
|
2826
|
+
rulesSkipped: Math.max(0, rulesSkipped),
|
|
2827
|
+
generatedCss: cssBlocks.join("\n"),
|
|
2828
|
+
rules: allRules
|
|
2829
|
+
};
|
|
2830
|
+
result.generatedCss = buildCssHeader(result) + result.generatedCss;
|
|
2831
|
+
return result;
|
|
2832
|
+
}
|
|
2833
|
+
function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
2834
|
+
const result = extractStaticStateCss(srcDir, options);
|
|
2835
|
+
const twClassesDir = path10__default.join(path10__default.dirname(safelistPath), "tw-classes");
|
|
2836
|
+
fs9__default.mkdirSync(twClassesDir, { recursive: true });
|
|
2837
|
+
const stateFilePath = path10__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
2838
|
+
if (result.rulesGenerated === 0) {
|
|
2839
|
+
try {
|
|
2840
|
+
fs9__default.writeFileSync(
|
|
2841
|
+
stateFilePath,
|
|
2842
|
+
"/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
|
|
2843
|
+
"utf-8"
|
|
2844
|
+
);
|
|
2845
|
+
} catch {
|
|
2846
|
+
}
|
|
2847
|
+
return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
|
|
2848
|
+
}
|
|
2849
|
+
try {
|
|
2850
|
+
fs9__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
|
|
2851
|
+
return [
|
|
2852
|
+
`[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
|
|
2853
|
+
` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
|
|
2854
|
+
` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
|
|
2855
|
+
` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
|
|
2856
|
+
].join("\n");
|
|
2857
|
+
} catch (writeErr) {
|
|
2858
|
+
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
2859
|
+
return `[tw:static-state] gagal tulis state CSS: ${msg}`;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
|
|
2863
|
+
var init_staticStateExtractor = __esm({
|
|
2864
|
+
"packages/domain/shared/src/staticStateExtractor.ts"() {
|
|
2865
|
+
SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
|
|
2866
|
+
IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
|
|
2867
|
+
_native = null;
|
|
2868
|
+
TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
|
|
2869
|
+
}
|
|
2870
|
+
});
|
|
2871
|
+
function getEnvLevel() {
|
|
2872
|
+
const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
|
|
2873
|
+
if (env && env in LEVELS) return env;
|
|
2874
|
+
return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
|
|
2875
|
+
}
|
|
2876
|
+
function setGlobalLogFile(filePath) {
|
|
2877
|
+
_globalLogFile = filePath;
|
|
2878
|
+
_logFileInitialized = false;
|
|
2879
|
+
try {
|
|
2880
|
+
fs9__default.mkdirSync(path10__default.dirname(filePath), { recursive: true });
|
|
2881
|
+
fs9__default.writeFileSync(
|
|
2882
|
+
filePath,
|
|
2883
|
+
`# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2884
|
+
`,
|
|
2885
|
+
"utf-8"
|
|
2886
|
+
);
|
|
2887
|
+
_logFileInitialized = true;
|
|
2888
|
+
} catch {
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
function writeToFile(line) {
|
|
2892
|
+
if (!_globalLogFile || !_logFileInitialized) return;
|
|
2893
|
+
try {
|
|
2894
|
+
fs9__default.appendFileSync(_globalLogFile, line);
|
|
2895
|
+
} catch {
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
function createLogger(prefix, level) {
|
|
2899
|
+
const loggerState = {
|
|
2900
|
+
currentLevel: getEnvLevel(),
|
|
2901
|
+
setLevel(l) {
|
|
2902
|
+
this.currentLevel = l;
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
const log4 = (msgLevel, stream, args) => {
|
|
2906
|
+
if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
|
|
2907
|
+
const line = `[${prefix}] ${args.map(String).join(" ")}
|
|
2908
|
+
`;
|
|
2909
|
+
process[stream].write(line);
|
|
2910
|
+
writeToFile(line);
|
|
2911
|
+
};
|
|
2912
|
+
return {
|
|
2913
|
+
error: (...a) => log4("error", "stderr", a),
|
|
2914
|
+
warn: (...a) => log4("warn", "stderr", a),
|
|
2915
|
+
info: (...a) => log4("info", "stdout", a),
|
|
2916
|
+
debug: (...a) => log4("debug", "stderr", a),
|
|
2917
|
+
setLevel: loggerState.setLevel,
|
|
2918
|
+
setLogFile: (filePath) => setGlobalLogFile(filePath)
|
|
2919
|
+
};
|
|
2920
|
+
}
|
|
2921
|
+
var LEVELS, _globalLogFile, _logFileInitialized;
|
|
2922
|
+
var init_logger = __esm({
|
|
2923
|
+
"packages/domain/shared/src/logger.ts"() {
|
|
2924
|
+
LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
2925
|
+
_globalLogFile = null;
|
|
2926
|
+
_logFileInitialized = false;
|
|
2927
|
+
createLogger("tailwind-styled");
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
function createLogger2(namespace) {
|
|
2931
|
+
const prefix = `[${namespace}]`;
|
|
2932
|
+
return {
|
|
2933
|
+
warn(...args) {
|
|
2934
|
+
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
2935
|
+
`);
|
|
2936
|
+
},
|
|
2937
|
+
debug(...args) {
|
|
2938
|
+
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
2939
|
+
`);
|
|
2940
|
+
},
|
|
2941
|
+
error(...args) {
|
|
2942
|
+
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
2943
|
+
`);
|
|
2944
|
+
},
|
|
2945
|
+
log(...args) {
|
|
2946
|
+
process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
|
|
2947
|
+
`);
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
function createDebugLogger(namespace, label) {
|
|
2952
|
+
const prefix = `[${namespace}]`;
|
|
2953
|
+
return (msg) => {
|
|
2954
|
+
if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
|
|
2955
|
+
console.debug(prefix, msg);
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
function formatIssuePath(path11) {
|
|
2960
|
+
if (!path11 || path11.length === 0) return "(root)";
|
|
2961
|
+
return path11.map(
|
|
2962
|
+
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
2963
|
+
).join(".");
|
|
2964
|
+
}
|
|
2965
|
+
function loadNativeBinding(options) {
|
|
2966
|
+
const { runtimeDir, candidates, isValid } = options;
|
|
2967
|
+
const loadErrors = [];
|
|
2968
|
+
for (const candidate of candidates) {
|
|
2969
|
+
const candidatePath = path10__default.resolve(runtimeDir, candidate);
|
|
2970
|
+
try {
|
|
2971
|
+
if (!fs9__default.existsSync(candidatePath) && !fs9__default.existsSync(candidatePath + ".node")) {
|
|
2972
|
+
continue;
|
|
2973
|
+
}
|
|
2974
|
+
const mod = requireNativeModule(candidatePath);
|
|
2975
|
+
if (mod && isValid(mod)) {
|
|
2976
|
+
return { binding: mod, loadErrors, loadedPath: candidatePath };
|
|
2977
|
+
}
|
|
2978
|
+
loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
|
|
2979
|
+
} catch (e) {
|
|
2980
|
+
loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
return { binding: null, loadErrors };
|
|
2984
|
+
}
|
|
2985
|
+
function requireNativeModule(p) {
|
|
2986
|
+
return _require2(p);
|
|
2987
|
+
}
|
|
2988
|
+
function resolveNativeBindingCandidates(options) {
|
|
2989
|
+
const {
|
|
2990
|
+
envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
|
|
2991
|
+
includeDefaultCandidates = true,
|
|
2992
|
+
enforceNodeExtensionForEnvPath = false
|
|
2993
|
+
} = options;
|
|
2994
|
+
const runtimeDir = options.runtimeDir || process.cwd();
|
|
2995
|
+
const candidates = [];
|
|
2996
|
+
for (const envVar of envVarNames) {
|
|
2997
|
+
const envPath = process.env[envVar];
|
|
2998
|
+
if (envPath) {
|
|
2999
|
+
candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
if (!includeDefaultCandidates) return candidates;
|
|
3003
|
+
if (fs9__default.existsSync(runtimeDir)) {
|
|
3004
|
+
try {
|
|
3005
|
+
for (const entry of fs9__default.readdirSync(runtimeDir)) {
|
|
3006
|
+
if (entry.endsWith(".node")) candidates.push(entry);
|
|
3007
|
+
}
|
|
3008
|
+
} catch {
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
3012
|
+
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
3013
|
+
for (const bin of BINARY_NAMES) {
|
|
3014
|
+
candidates.push(path10__default.resolve(runtimeDir, `${bin}.node`));
|
|
3015
|
+
candidates.push(path10__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
3016
|
+
candidates.push(path10__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
3017
|
+
candidates.push(path10__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3018
|
+
candidates.push(path10__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
3019
|
+
candidates.push(path10__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
3020
|
+
candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
3021
|
+
candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3022
|
+
candidates.push(path10__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
3023
|
+
}
|
|
3024
|
+
return Array.from(new Set(candidates));
|
|
3025
|
+
}
|
|
3026
|
+
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
3027
|
+
try {
|
|
3028
|
+
return path10__default.dirname(fileURLToPath(importMetaUrl));
|
|
3029
|
+
} catch {
|
|
3030
|
+
return process.cwd();
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
var TwError, _require2;
|
|
3034
|
+
var init_src2 = __esm({
|
|
3035
|
+
"packages/domain/shared/src/index.ts"() {
|
|
3036
|
+
init_workerResolver();
|
|
3037
|
+
init_native_resolution();
|
|
3038
|
+
init_staticStateExtractor();
|
|
3039
|
+
init_logger();
|
|
3040
|
+
TwError = class _TwError extends Error {
|
|
3041
|
+
/** @deprecated Gunakan source */
|
|
3042
|
+
domain;
|
|
3043
|
+
source;
|
|
3044
|
+
code;
|
|
3045
|
+
originalCause;
|
|
3046
|
+
constructor(domainOrSource, code, message, cause) {
|
|
3047
|
+
super(message);
|
|
3048
|
+
this.name = "TwError";
|
|
3049
|
+
this.domain = domainOrSource;
|
|
3050
|
+
this.source = domainOrSource;
|
|
3051
|
+
this.code = code;
|
|
3052
|
+
this.originalCause = cause;
|
|
3053
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
|
|
3054
|
+
}
|
|
3055
|
+
static fromIo(code, message) {
|
|
3056
|
+
return new _TwError("io", code, message);
|
|
3057
|
+
}
|
|
3058
|
+
static fromCompile(code, message) {
|
|
3059
|
+
return new _TwError("compile", code, message);
|
|
3060
|
+
}
|
|
3061
|
+
static fromRust(err) {
|
|
3062
|
+
if (err instanceof _TwError) return err;
|
|
3063
|
+
if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
|
|
3064
|
+
if (err && typeof err === "object") {
|
|
3065
|
+
const e = err;
|
|
3066
|
+
return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
|
|
3067
|
+
}
|
|
3068
|
+
return new _TwError("rust", "RUST_ERROR", String(err), err);
|
|
3069
|
+
}
|
|
3070
|
+
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
3071
|
+
static fromZod(err) {
|
|
3072
|
+
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
3073
|
+
const path11 = formatIssuePath(first?.path);
|
|
3074
|
+
const message = first ? `${path11}: ${first.message}` : "Schema validation failed";
|
|
3075
|
+
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
3076
|
+
}
|
|
3077
|
+
static wrap(source, code, err) {
|
|
3078
|
+
if (err instanceof _TwError) return err;
|
|
3079
|
+
if (err instanceof Error) return new _TwError(source, code, err.message, err);
|
|
3080
|
+
return new _TwError(source, code, String(err), err);
|
|
3081
|
+
}
|
|
3082
|
+
toString() {
|
|
3083
|
+
return `TwError [${this.source}:${this.code}] ${this.message}`;
|
|
3084
|
+
}
|
|
3085
|
+
toJSON() {
|
|
3086
|
+
return { name: this.name, source: this.source, code: this.code, message: this.message };
|
|
3087
|
+
}
|
|
3088
|
+
toCliMessage() {
|
|
3089
|
+
return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
_require2 = createRequire(import.meta.url);
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
|
|
3096
|
+
// packages/domain/scanner/src/native-bridge.ts
|
|
3097
|
+
var native_bridge_exports = {};
|
|
3098
|
+
__export(native_bridge_exports, {
|
|
3099
|
+
batchExtractClassesNative: () => batchExtractClassesNative2,
|
|
3100
|
+
cachePriorityNative: () => cachePriorityNative,
|
|
3101
|
+
cacheReadNative: () => cacheReadNative,
|
|
3102
|
+
cacheWriteNative: () => cacheWriteNative,
|
|
3103
|
+
collectFilesNative: () => collectFilesNative,
|
|
3104
|
+
computeCacheStatsNative: () => computeCacheStatsNative,
|
|
3105
|
+
extractClassesNative: () => extractClassesNative,
|
|
3106
|
+
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
3107
|
+
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
3108
|
+
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
3109
|
+
hashContentNative: () => hashContentNative,
|
|
3110
|
+
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
3111
|
+
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
3112
|
+
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
3113
|
+
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
3114
|
+
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
3115
|
+
scanCacheGet: () => scanCacheGet,
|
|
3116
|
+
scanCacheInvalidate: () => scanCacheInvalidate,
|
|
3117
|
+
scanCachePut: () => scanCachePut,
|
|
3118
|
+
scanCacheStats: () => scanCacheStats,
|
|
3119
|
+
scanFileNative: () => scanFileNative2,
|
|
3120
|
+
scanFilesBatchNative: () => scanFilesBatchNative2,
|
|
3121
|
+
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
3122
|
+
startWatchNative: () => startWatchNative,
|
|
3123
|
+
stopWatchNative: () => stopWatchNative
|
|
3124
|
+
});
|
|
3125
|
+
function getDirname() {
|
|
3126
|
+
if (typeof __dirname !== "undefined") {
|
|
3127
|
+
return __dirname;
|
|
3128
|
+
}
|
|
3129
|
+
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
3130
|
+
return path10__default.dirname(fileURLToPath(import.meta.url));
|
|
3131
|
+
}
|
|
3132
|
+
return process.cwd();
|
|
3133
|
+
}
|
|
3134
|
+
function scanWorkspaceNative(root, extensions) {
|
|
3135
|
+
return scannerGetBinding().scanWorkspace(root, extensions ?? null);
|
|
3136
|
+
}
|
|
3137
|
+
function extractClassesNative(source) {
|
|
3138
|
+
const result = scannerGetBinding().extractClassesFromSource?.(source);
|
|
3139
|
+
if (result === null || result === void 0) {
|
|
3140
|
+
throw new TwError(
|
|
3141
|
+
"rust",
|
|
3142
|
+
"SCANNER_EXTRACT_FAILED",
|
|
3143
|
+
"Native extractClassesFromSource returned null/undefined"
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3146
|
+
return result;
|
|
3147
|
+
}
|
|
3148
|
+
function hashContentNative(content) {
|
|
3149
|
+
const result = scannerGetBinding().hashFileContent?.(content);
|
|
3150
|
+
if (result === null || result === void 0) {
|
|
3151
|
+
throw new TwError(
|
|
3152
|
+
"rust",
|
|
3153
|
+
"SCANNER_HASH_FAILED",
|
|
3154
|
+
"Native hashFileContent returned null/undefined"
|
|
3155
|
+
);
|
|
3156
|
+
}
|
|
3157
|
+
return result;
|
|
3158
|
+
}
|
|
3159
|
+
function isRustCacheAvailable() {
|
|
3160
|
+
return true;
|
|
3161
|
+
}
|
|
3162
|
+
function hasNativeScannerBinding() {
|
|
3163
|
+
try {
|
|
3164
|
+
scannerBridgeLoader.get();
|
|
3165
|
+
return true;
|
|
3166
|
+
} catch {
|
|
3167
|
+
return false;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
function cacheReadNative(cachePath) {
|
|
3171
|
+
const result = scannerGetBinding().cacheRead?.(cachePath);
|
|
3172
|
+
if (result === null || result === void 0) {
|
|
3173
|
+
throw new TwError(
|
|
3174
|
+
"rust",
|
|
3175
|
+
"SCANNER_CACHE_READ_FAILED",
|
|
3176
|
+
"Native cacheRead returned null/undefined"
|
|
3177
|
+
);
|
|
3178
|
+
}
|
|
3179
|
+
return result;
|
|
3180
|
+
}
|
|
3181
|
+
function cacheWriteNative(cachePath, entries) {
|
|
3182
|
+
const result = scannerGetBinding().cacheWrite?.(cachePath, entries);
|
|
3183
|
+
if (result === null || result === void 0) {
|
|
3184
|
+
throw new TwError(
|
|
3185
|
+
"rust",
|
|
3186
|
+
"SCANNER_CACHE_WRITE_FAILED",
|
|
3187
|
+
"Native cacheWrite returned null/undefined"
|
|
3188
|
+
);
|
|
3189
|
+
}
|
|
3190
|
+
return result;
|
|
3191
|
+
}
|
|
3192
|
+
function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHitCount, cachedLastSeenMs, nowMs = Date.now()) {
|
|
3193
|
+
const result = scannerGetBinding().cachePriority?.(
|
|
3194
|
+
mtimeMs,
|
|
3195
|
+
size,
|
|
3196
|
+
cachedMtimeMs,
|
|
3197
|
+
cachedSize,
|
|
3198
|
+
cachedHitCount,
|
|
3199
|
+
cachedLastSeenMs,
|
|
3200
|
+
nowMs
|
|
3201
|
+
);
|
|
3202
|
+
if (result === null || result === void 0) {
|
|
3203
|
+
throw new TwError(
|
|
3204
|
+
"rust",
|
|
3205
|
+
"SCANNER_CACHE_PRIORITY_FAILED",
|
|
3206
|
+
"Native cachePriority returned null/undefined"
|
|
3207
|
+
);
|
|
3208
|
+
}
|
|
3209
|
+
return result;
|
|
3210
|
+
}
|
|
3211
|
+
function batchExtractClassesNative2(filePaths) {
|
|
3212
|
+
const binding = scannerGetBinding();
|
|
3213
|
+
if (!binding.batchExtractClasses) {
|
|
3214
|
+
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
3215
|
+
}
|
|
3216
|
+
return binding.batchExtractClasses(filePaths) ?? [];
|
|
3217
|
+
}
|
|
3218
|
+
function scanCacheGet(filePath, contentHash) {
|
|
3219
|
+
const binding = scannerGetBinding();
|
|
3220
|
+
if (!binding.scanCacheGet) {
|
|
3221
|
+
throw new Error("FATAL: Native binding 'scanCacheGet' is required but not available.");
|
|
3222
|
+
}
|
|
3223
|
+
return binding.scanCacheGet(filePath, contentHash) ?? null;
|
|
3224
|
+
}
|
|
3225
|
+
function scanCachePut(filePath, contentHash, classes, mtimeMs, size) {
|
|
3226
|
+
const binding = scannerGetBinding();
|
|
3227
|
+
if (!binding.scanCachePut) {
|
|
3228
|
+
throw new Error("FATAL: Native binding 'scanCachePut' is required but not available.");
|
|
3229
|
+
}
|
|
3230
|
+
binding.scanCachePut(filePath, contentHash, classes, mtimeMs, size);
|
|
3231
|
+
}
|
|
3232
|
+
function scanCacheInvalidate(filePath) {
|
|
3233
|
+
const binding = scannerGetBinding();
|
|
3234
|
+
if (!binding.scanCacheInvalidate) {
|
|
3235
|
+
throw new Error("FATAL: Native binding 'scanCacheInvalidate' is required but not available.");
|
|
3236
|
+
}
|
|
3237
|
+
binding.scanCacheInvalidate(filePath);
|
|
3238
|
+
}
|
|
3239
|
+
function scanCacheStats() {
|
|
3240
|
+
const binding = scannerGetBinding();
|
|
3241
|
+
if (!binding.scanCacheStats) {
|
|
3242
|
+
throw new Error("FATAL: Native binding 'scanCacheStats' is required but not available.");
|
|
3243
|
+
}
|
|
3244
|
+
return binding.scanCacheStats();
|
|
3245
|
+
}
|
|
3246
|
+
function scanFileNative2(filePath) {
|
|
3247
|
+
const binding = scannerGetBinding();
|
|
3248
|
+
if (!binding.scanFile) {
|
|
3249
|
+
throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
|
|
3250
|
+
}
|
|
3251
|
+
return binding.scanFile(filePath);
|
|
3252
|
+
}
|
|
3253
|
+
function collectFilesNative(root, extensions, ignoreDirs) {
|
|
3254
|
+
const binding = scannerGetBinding();
|
|
3255
|
+
if (!binding.collectFiles) return null;
|
|
3256
|
+
return binding.collectFiles(root, extensions, ignoreDirs);
|
|
3257
|
+
}
|
|
3258
|
+
function scanFilesBatchNative2(filePaths) {
|
|
3259
|
+
const binding = scannerGetBinding();
|
|
3260
|
+
if (!binding.scanFilesBatch) {
|
|
3261
|
+
return filePaths.map((fp) => {
|
|
3262
|
+
try {
|
|
3263
|
+
const r = binding.scanFile?.(fp);
|
|
3264
|
+
return r ? { file: r.file, classes: r.classes, hash: r.hash ?? "" } : { file: fp, classes: [], hash: "" };
|
|
3265
|
+
} catch {
|
|
3266
|
+
return { file: fp, classes: [], hash: "" };
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
return binding.scanFilesBatch(filePaths);
|
|
3271
|
+
}
|
|
3272
|
+
function generateSubComponentTypesNative(root, outputPath) {
|
|
3273
|
+
const binding = scannerGetBinding();
|
|
3274
|
+
if (!binding.generateSubComponentTypes) return null;
|
|
3275
|
+
return binding.generateSubComponentTypes(root, outputPath ?? null);
|
|
3276
|
+
}
|
|
3277
|
+
function pruneStaleEntriesNative(entries, maxAgeMs, checkExists) {
|
|
3278
|
+
const binding = scannerGetBinding();
|
|
3279
|
+
if (!binding.pruneStaleEntries) return null;
|
|
3280
|
+
return binding.pruneStaleEntries(
|
|
3281
|
+
entries.map((e) => ({ file: e.file, lastSeenMs: e.lastSeenMs ?? 0 })),
|
|
3282
|
+
maxAgeMs ?? null,
|
|
3283
|
+
checkExists ?? null
|
|
3284
|
+
);
|
|
3285
|
+
}
|
|
3286
|
+
function rebuildWorkspaceResultNative(files) {
|
|
3287
|
+
const binding = scannerBridgeLoader.get();
|
|
3288
|
+
if (!binding?.rebuildWorkspaceResult) return null;
|
|
3289
|
+
try {
|
|
3290
|
+
return binding.rebuildWorkspaceResult(files);
|
|
3291
|
+
} catch {
|
|
3292
|
+
return null;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
function computeCacheStatsNative(filesClasses, sizes, top) {
|
|
3296
|
+
const binding = scannerGetBinding();
|
|
3297
|
+
if (!binding.computeCacheStats) return null;
|
|
3298
|
+
return binding.computeCacheStats(filesClasses, sizes, top ?? null);
|
|
3299
|
+
}
|
|
3300
|
+
function startWatchNative(rootDir) {
|
|
3301
|
+
try {
|
|
3302
|
+
const binding = scannerGetBinding();
|
|
3303
|
+
if (!binding.startWatch) return null;
|
|
3304
|
+
return binding.startWatch(rootDir);
|
|
3305
|
+
} catch {
|
|
3306
|
+
return null;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
function pollWatchEventsNative(handleId) {
|
|
3310
|
+
try {
|
|
3311
|
+
const binding = scannerGetBinding();
|
|
3312
|
+
if (!binding.pollWatchEvents) return [];
|
|
3313
|
+
return binding.pollWatchEvents(handleId);
|
|
3314
|
+
} catch {
|
|
3315
|
+
return [];
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
function stopWatchNative(handleId) {
|
|
3319
|
+
try {
|
|
3320
|
+
const binding = scannerGetBinding();
|
|
3321
|
+
if (!binding.stopWatch) return false;
|
|
3322
|
+
return binding.stopWatch(handleId);
|
|
3323
|
+
} catch {
|
|
3324
|
+
return false;
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
function hasNativeWatchBinding() {
|
|
3328
|
+
try {
|
|
3329
|
+
const binding = scannerGetBinding();
|
|
3330
|
+
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
3331
|
+
} catch {
|
|
3332
|
+
return false;
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
3336
|
+
var init_native_bridge = __esm({
|
|
3337
|
+
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
3338
|
+
init_src2();
|
|
3339
|
+
log2 = createDebugLogger("scanner:native");
|
|
3340
|
+
isValidScannerBinding = (module) => {
|
|
3341
|
+
const candidate = module;
|
|
3342
|
+
return !!(candidate && (candidate.scanWorkspace || candidate.extractClassesFromSource || candidate.hashFileContent || candidate.cacheRead || candidate.cacheWrite));
|
|
1212
3343
|
};
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
3344
|
+
createScannerBridgeLoader = () => {
|
|
3345
|
+
const _state = {
|
|
3346
|
+
binding: void 0,
|
|
3347
|
+
loadError: null,
|
|
3348
|
+
candidatePaths: []
|
|
1218
3349
|
};
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
analyzeClasses = (filesJson, cwd, flags) => {
|
|
1231
|
-
const native = getNativeBridge();
|
|
1232
|
-
if (!native?.analyzeClasses) {
|
|
1233
|
-
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
1234
|
-
}
|
|
1235
|
-
return native.analyzeClasses(filesJson, cwd, flags);
|
|
1236
|
-
};
|
|
1237
|
-
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
1238
|
-
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
1239
|
-
const allClasses = Object.keys(classes).sort();
|
|
1240
|
-
if (outputPath) {
|
|
1241
|
-
const fs6 = __require("fs");
|
|
1242
|
-
fs6.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
1243
|
-
}
|
|
1244
|
-
return allClasses;
|
|
1245
|
-
};
|
|
1246
|
-
loadSafelist = (safelistPath) => {
|
|
1247
|
-
const fs6 = __require("fs");
|
|
1248
|
-
try {
|
|
1249
|
-
const content = fs6.readFileSync(safelistPath, "utf-8");
|
|
1250
|
-
return JSON.parse(content);
|
|
1251
|
-
} catch {
|
|
1252
|
-
return [];
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
1256
|
-
const fs6 = __require("fs");
|
|
1257
|
-
const path7 = __require("path");
|
|
1258
|
-
const configFiles = [
|
|
1259
|
-
"tailwind.config.ts",
|
|
1260
|
-
"tailwind.config.js",
|
|
1261
|
-
"tailwind.config.mjs",
|
|
1262
|
-
"tailwind.config.cjs"
|
|
1263
|
-
];
|
|
1264
|
-
for (const file of configFiles) {
|
|
1265
|
-
const fullPath = path7.join(cwd, file);
|
|
1266
|
-
if (fs6.existsSync(fullPath)) {
|
|
1267
|
-
const mod = __require(fullPath);
|
|
1268
|
-
return mod.default || mod;
|
|
3350
|
+
const throwNativeBindingError = () => {
|
|
3351
|
+
const lines = [
|
|
3352
|
+
"FATAL: Native scanner binding not found.",
|
|
3353
|
+
"",
|
|
3354
|
+
"This package requires the Rust native binding 'tailwind_styled_parser.node'.",
|
|
3355
|
+
"The binding was not found in any of these paths:",
|
|
3356
|
+
..._state.candidatePaths.map((p) => ` - ${p}`),
|
|
3357
|
+
""
|
|
3358
|
+
];
|
|
3359
|
+
if (_state.loadError) {
|
|
3360
|
+
lines.push("Load error:", ` ${_state.loadError}`, "");
|
|
1269
3361
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
path7.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
1280
|
-
]
|
|
3362
|
+
lines.push(
|
|
3363
|
+
"To fix this, run:",
|
|
3364
|
+
" npm run build:rust",
|
|
3365
|
+
"",
|
|
3366
|
+
"This will build the native Rust module from the 'native/' directory.",
|
|
3367
|
+
"If you're using this package in a CI/CD environment, ensure Rust toolchain is installed",
|
|
3368
|
+
"and 'npm run build:rust' is executed before running tests or building."
|
|
3369
|
+
);
|
|
3370
|
+
throw new TwError("rust", "SCANNER_NATIVE_BINDING_NOT_FOUND", lines.join("\n"));
|
|
1281
3371
|
};
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
3372
|
+
const scannerGetBinding2 = () => {
|
|
3373
|
+
const cachedBinding = _state.binding;
|
|
3374
|
+
if (cachedBinding !== void 0) {
|
|
3375
|
+
if (cachedBinding !== null) {
|
|
3376
|
+
return cachedBinding;
|
|
3377
|
+
}
|
|
3378
|
+
return throwNativeBindingError();
|
|
3379
|
+
}
|
|
3380
|
+
const runtimeDir = getDirname();
|
|
3381
|
+
const candidates = resolveNativeBindingCandidates({
|
|
3382
|
+
runtimeDir,
|
|
3383
|
+
includeDefaultCandidates: true
|
|
3384
|
+
});
|
|
3385
|
+
_state.candidatePaths = candidates;
|
|
3386
|
+
const { binding, loadErrors } = loadNativeBinding({
|
|
3387
|
+
runtimeDir,
|
|
3388
|
+
candidates,
|
|
3389
|
+
isValid: isValidScannerBinding,
|
|
3390
|
+
invalidExportMessage: "Module loaded but missing expected scanner binding functions"
|
|
3391
|
+
});
|
|
3392
|
+
if (binding) {
|
|
3393
|
+
log2(`scanner native binding loaded successfully`);
|
|
3394
|
+
_state.binding = binding;
|
|
3395
|
+
return _state.binding;
|
|
3396
|
+
}
|
|
3397
|
+
if (loadErrors.length > 0) {
|
|
3398
|
+
_state.loadError = loadErrors.map((e) => `${e.path}: ${e.message}`).join("; ");
|
|
3399
|
+
}
|
|
3400
|
+
_state.binding = null;
|
|
3401
|
+
return throwNativeBindingError();
|
|
1290
3402
|
};
|
|
1291
|
-
};
|
|
1292
|
-
shouldSkipFile = (filepath) => {
|
|
1293
|
-
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
1294
|
-
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
1295
|
-
for (const p of SKIP_PATHS) {
|
|
1296
|
-
if (filepath.includes(p)) return true;
|
|
1297
|
-
}
|
|
1298
|
-
for (const ext of skipExtensions) {
|
|
1299
|
-
if (filepath.endsWith(ext)) return true;
|
|
1300
|
-
}
|
|
1301
|
-
return false;
|
|
1302
|
-
};
|
|
1303
|
-
fileToRoute = (filepath) => {
|
|
1304
|
-
const normalized = filepath.replace(/\\/g, "/");
|
|
1305
|
-
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
1306
|
-
return "__global";
|
|
1307
|
-
}
|
|
1308
|
-
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
1309
|
-
if (pageMatch) return `/${pageMatch[1]}`;
|
|
1310
|
-
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
1311
|
-
if (rootPage) return "/";
|
|
1312
|
-
return null;
|
|
1313
|
-
};
|
|
1314
|
-
getAllRoutes = () => {
|
|
1315
|
-
const native = getNativeBridge();
|
|
1316
|
-
if (!native?.analyzeClasses) {
|
|
1317
|
-
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
1318
|
-
}
|
|
1319
|
-
return ["/", "__global"];
|
|
1320
|
-
};
|
|
1321
|
-
getRouteClasses = (_route) => {
|
|
1322
|
-
return /* @__PURE__ */ new Set();
|
|
1323
|
-
};
|
|
1324
|
-
registerFileClasses = (_filepath, _classes) => {
|
|
1325
|
-
};
|
|
1326
|
-
registerGlobalClasses = (_classes) => {
|
|
1327
|
-
};
|
|
1328
|
-
_incrementalEngineInstance = null;
|
|
1329
|
-
getIncrementalEngine = () => {
|
|
1330
|
-
if (!_incrementalEngineInstance) {
|
|
1331
|
-
_incrementalEngineInstance = new IncrementalEngine();
|
|
1332
|
-
}
|
|
1333
|
-
return _incrementalEngineInstance;
|
|
1334
|
-
};
|
|
1335
|
-
resetIncrementalEngine = () => {
|
|
1336
|
-
_incrementalEngineInstance = null;
|
|
1337
|
-
};
|
|
1338
|
-
IncrementalEngine = class {
|
|
1339
|
-
compile(source) {
|
|
1340
|
-
return transformSource(source);
|
|
1341
|
-
}
|
|
1342
|
-
};
|
|
1343
|
-
getBucketEngine = () => {
|
|
1344
|
-
const native = getNativeBridge();
|
|
1345
|
-
if (!native?.classifyAndSortClasses) {
|
|
1346
|
-
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1347
|
-
}
|
|
1348
3403
|
return {
|
|
1349
|
-
|
|
1350
|
-
|
|
3404
|
+
get: scannerGetBinding2,
|
|
3405
|
+
scannerGetBinding: scannerGetBinding2,
|
|
3406
|
+
reset: () => {
|
|
3407
|
+
_state.binding = void 0;
|
|
3408
|
+
_state.loadError = null;
|
|
3409
|
+
_state.candidatePaths = [];
|
|
3410
|
+
}
|
|
1351
3411
|
};
|
|
1352
3412
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
add(className) {
|
|
1357
|
-
return className;
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
classifyNode = (_node) => {
|
|
1361
|
-
const native = getNativeBridge();
|
|
1362
|
-
if (!native?.classifyAndSortClasses) {
|
|
1363
|
-
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1364
|
-
}
|
|
1365
|
-
return "unknown";
|
|
1366
|
-
};
|
|
1367
|
-
detectConflicts = (classes) => {
|
|
1368
|
-
const native = getNativeBridge();
|
|
1369
|
-
if (!native?.analyzeClassUsage) {
|
|
1370
|
-
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
1371
|
-
}
|
|
1372
|
-
return [];
|
|
1373
|
-
};
|
|
1374
|
-
bucketSort = (classes) => {
|
|
1375
|
-
return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
|
|
1376
|
-
};
|
|
3413
|
+
scannerBridgeLoader = createScannerBridgeLoader();
|
|
3414
|
+
scannerGetBinding = scannerBridgeLoader.get;
|
|
3415
|
+
resetScannerBridgeCache = scannerBridgeLoader.reset;
|
|
1377
3416
|
}
|
|
1378
3417
|
});
|
|
1379
3418
|
var formatIssues = (error) => error.issues.map((issue) => {
|
|
@@ -1399,20 +3438,20 @@ var NextAdapterOptionsSchema = z.object({
|
|
|
1399
3438
|
var parseNextAdapterOptions = (options) => parseWithSchema(NextAdapterOptionsSchema, options ?? {}, "next adapter options are invalid");
|
|
1400
3439
|
|
|
1401
3440
|
// packages/presentation/next/src/withTailwindStyled.ts
|
|
1402
|
-
|
|
3441
|
+
init_src2();
|
|
1403
3442
|
|
|
1404
3443
|
// packages/domain/scanner/src/index.ts
|
|
1405
|
-
|
|
3444
|
+
init_src2();
|
|
1406
3445
|
|
|
1407
3446
|
// packages/domain/scanner/src/cache-native.ts
|
|
1408
3447
|
init_native_bridge();
|
|
1409
3448
|
function defaultCachePath(rootDir, cacheDir) {
|
|
1410
|
-
const dir = cacheDir ?
|
|
1411
|
-
return
|
|
3449
|
+
const dir = cacheDir ? path10__default.resolve(rootDir, cacheDir) : path10__default.join(process.cwd(), ".cache", "tailwind-styled");
|
|
3450
|
+
return path10__default.join(dir, "scanner-cache.json");
|
|
1412
3451
|
}
|
|
1413
3452
|
function readCache(rootDir, cacheDir) {
|
|
1414
3453
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1415
|
-
|
|
3454
|
+
fs9__default.mkdirSync(path10__default.dirname(cachePath), { recursive: true });
|
|
1416
3455
|
const result = cacheReadNative(cachePath);
|
|
1417
3456
|
if (!result) return [];
|
|
1418
3457
|
return result.entries.map((e) => ({
|
|
@@ -1427,7 +3466,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1427
3466
|
}
|
|
1428
3467
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1429
3468
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1430
|
-
|
|
3469
|
+
fs9__default.mkdirSync(path10__default.dirname(cachePath), { recursive: true });
|
|
1431
3470
|
const success = cacheWriteNative(cachePath, entries);
|
|
1432
3471
|
if (!success) {
|
|
1433
3472
|
throw new Error(
|
|
@@ -1451,13 +3490,13 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
|
|
|
1451
3490
|
init_native_bridge();
|
|
1452
3491
|
|
|
1453
3492
|
// packages/domain/scanner/src/schemas.ts
|
|
1454
|
-
|
|
1455
|
-
var formatIssuePath2 = (
|
|
3493
|
+
init_src2();
|
|
3494
|
+
var formatIssuePath2 = (path11) => path11.length > 0 ? path11.map(
|
|
1456
3495
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1457
3496
|
).join(".") : "<root>";
|
|
1458
3497
|
var formatIssues2 = (error) => error.issues.map((issue) => {
|
|
1459
|
-
const
|
|
1460
|
-
return `${
|
|
3498
|
+
const path11 = formatIssuePath2(issue.path);
|
|
3499
|
+
return `${path11}: ${issue.message}`;
|
|
1461
3500
|
}).join("; ");
|
|
1462
3501
|
var parseWithSchema2 = (schema, data, label) => {
|
|
1463
3502
|
const parsed = schema.safeParse(data);
|
|
@@ -1511,13 +3550,13 @@ var parseScanWorkspaceOptions = (options) => parseWithSchema2(ScanWorkspaceOptio
|
|
|
1511
3550
|
var parseScanWorkspaceResult = (result) => parseWithSchema2(ScanWorkspaceResultSchema, result, "scanner workspace result is invalid");
|
|
1512
3551
|
|
|
1513
3552
|
// packages/domain/scanner/src/index.ts
|
|
1514
|
-
var
|
|
3553
|
+
var log3 = createLogger2("scanner");
|
|
1515
3554
|
function getRuntimeDir() {
|
|
1516
3555
|
if (typeof __dirname !== "undefined" && __dirname.length > 0) {
|
|
1517
3556
|
return __dirname;
|
|
1518
3557
|
}
|
|
1519
3558
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
1520
|
-
return
|
|
3559
|
+
return path10__default.dirname(fileURLToPath(import.meta.url));
|
|
1521
3560
|
}
|
|
1522
3561
|
return process.cwd();
|
|
1523
3562
|
}
|
|
@@ -1527,12 +3566,12 @@ var createNativeParserLoader = () => {
|
|
|
1527
3566
|
initError: null
|
|
1528
3567
|
};
|
|
1529
3568
|
const debugNative = (message) => {
|
|
1530
|
-
|
|
3569
|
+
log3.debug(`[native] ${message}`);
|
|
1531
3570
|
};
|
|
1532
3571
|
const loadNativeParserBinding = () => {
|
|
1533
3572
|
if (_state.binding !== void 0) return _state.binding;
|
|
1534
3573
|
const runtimeDir = getRuntimeDir();
|
|
1535
|
-
const req = createRequire(
|
|
3574
|
+
const req = createRequire(path10__default.join(runtimeDir, "noop.cjs"));
|
|
1536
3575
|
const _platform = process.platform;
|
|
1537
3576
|
const _arch = process.arch;
|
|
1538
3577
|
const _platformArch = `${_platform}-${_arch}`;
|
|
@@ -1540,27 +3579,27 @@ var createNativeParserLoader = () => {
|
|
|
1540
3579
|
const candidates = [
|
|
1541
3580
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
1542
3581
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
3582
|
+
path10__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
3583
|
+
path10__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3584
|
+
path10__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
1546
3585
|
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
1547
3586
|
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
3587
|
+
path10__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
3588
|
+
path10__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3589
|
+
path10__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
1551
3590
|
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
1552
|
-
|
|
1553
|
-
|
|
3591
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3592
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
1554
3593
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
1555
|
-
|
|
1556
|
-
|
|
3594
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3595
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
1557
3596
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
3597
|
+
path10__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
3598
|
+
path10__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
3599
|
+
path10__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
3600
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3601
|
+
path10__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3602
|
+
path10__default.resolve(
|
|
1564
3603
|
runtimeDir,
|
|
1565
3604
|
"..",
|
|
1566
3605
|
"..",
|
|
@@ -1572,7 +3611,7 @@ var createNativeParserLoader = () => {
|
|
|
1572
3611
|
)
|
|
1573
3612
|
];
|
|
1574
3613
|
for (const fullPath of candidates) {
|
|
1575
|
-
if (!
|
|
3614
|
+
if (!fs9__default.existsSync(fullPath)) continue;
|
|
1576
3615
|
try {
|
|
1577
3616
|
const required = req(fullPath);
|
|
1578
3617
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -1613,19 +3652,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
1613
3652
|
if (!currentDir) continue;
|
|
1614
3653
|
const entries = (() => {
|
|
1615
3654
|
try {
|
|
1616
|
-
return
|
|
3655
|
+
return fs9__default.readdirSync(currentDir, { withFileTypes: true });
|
|
1617
3656
|
} catch {
|
|
1618
3657
|
return [];
|
|
1619
3658
|
}
|
|
1620
3659
|
})();
|
|
1621
3660
|
for (const entry of entries) {
|
|
1622
|
-
const fullPath =
|
|
3661
|
+
const fullPath = path10__default.join(currentDir, entry.name);
|
|
1623
3662
|
if (entry.isDirectory()) {
|
|
1624
3663
|
if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
|
|
1625
3664
|
continue;
|
|
1626
3665
|
}
|
|
1627
3666
|
if (!entry.isFile()) continue;
|
|
1628
|
-
if (!extensionSet.has(
|
|
3667
|
+
if (!extensionSet.has(path10__default.extname(entry.name))) continue;
|
|
1629
3668
|
candidates.push(fullPath);
|
|
1630
3669
|
}
|
|
1631
3670
|
}
|
|
@@ -1651,9 +3690,9 @@ function scanSource(source) {
|
|
|
1651
3690
|
"FATAL: Native parser binding is required but not available.\nThis package requires native Rust bindings.\n\nResolution steps:\n1. Build the native Rust module: npm run build:rust"
|
|
1652
3691
|
);
|
|
1653
3692
|
}
|
|
1654
|
-
function
|
|
1655
|
-
const { scanFileNative:
|
|
1656
|
-
const result =
|
|
3693
|
+
function scanFile2(filePath) {
|
|
3694
|
+
const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
|
|
3695
|
+
const result = scanFileNative3(filePath);
|
|
1657
3696
|
if (!result.ok) {
|
|
1658
3697
|
throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
|
|
1659
3698
|
}
|
|
@@ -1663,7 +3702,7 @@ function scanFile(filePath) {
|
|
|
1663
3702
|
...result.hash ? { hash: result.hash } : {}
|
|
1664
3703
|
};
|
|
1665
3704
|
}
|
|
1666
|
-
function
|
|
3705
|
+
function scanWorkspace2(rootDir, options = {}) {
|
|
1667
3706
|
const normalizedOptions = parseScanWorkspaceOptions(options);
|
|
1668
3707
|
const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
|
|
1669
3708
|
const extensionSet = buildExtensionSet(includeExtensions);
|
|
@@ -1697,7 +3736,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1697
3736
|
try {
|
|
1698
3737
|
return readCache(rootDir, normalizedOptions.cacheDir);
|
|
1699
3738
|
} catch (error) {
|
|
1700
|
-
|
|
3739
|
+
log3.debug(
|
|
1701
3740
|
`cache read failed, continuing without persisted cache: ${error instanceof Error ? error.message : String(error)}`
|
|
1702
3741
|
);
|
|
1703
3742
|
return [];
|
|
@@ -1709,7 +3748,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1709
3748
|
for (const filePath of candidates) {
|
|
1710
3749
|
const stat = (() => {
|
|
1711
3750
|
try {
|
|
1712
|
-
return
|
|
3751
|
+
return fs9__default.statSync(filePath);
|
|
1713
3752
|
} catch {
|
|
1714
3753
|
return null;
|
|
1715
3754
|
}
|
|
@@ -1735,7 +3774,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1735
3774
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
1736
3775
|
const content = (() => {
|
|
1737
3776
|
try {
|
|
1738
|
-
return
|
|
3777
|
+
return fs9__default.readFileSync(filePath, "utf8");
|
|
1739
3778
|
} catch {
|
|
1740
3779
|
return null;
|
|
1741
3780
|
}
|
|
@@ -1743,7 +3782,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1743
3782
|
if (!content) continue;
|
|
1744
3783
|
const hash = hashContentNative(content);
|
|
1745
3784
|
if (cached && cached.hash === hash && cached.mtimeMs === stat.mtimeMs && cached.size === size) {
|
|
1746
|
-
|
|
3785
|
+
log3.debug(`cache HIT ${filePath}`);
|
|
1747
3786
|
processResult({ file: filePath, classes: cached.classes });
|
|
1748
3787
|
updatedEntries.push({
|
|
1749
3788
|
file: filePath,
|
|
@@ -1755,7 +3794,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1755
3794
|
});
|
|
1756
3795
|
continue;
|
|
1757
3796
|
}
|
|
1758
|
-
|
|
3797
|
+
log3.debug(`cache MISS ${filePath}`);
|
|
1759
3798
|
const classes = scanSource(content);
|
|
1760
3799
|
processResult({ file: filePath, classes });
|
|
1761
3800
|
updatedEntries.push({
|
|
@@ -1770,7 +3809,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1770
3809
|
try {
|
|
1771
3810
|
writeCache(rootDir, updatedEntries, normalizedOptions.cacheDir);
|
|
1772
3811
|
} catch (error) {
|
|
1773
|
-
|
|
3812
|
+
log3.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1774
3813
|
}
|
|
1775
3814
|
return parseScanWorkspaceResult({
|
|
1776
3815
|
files,
|
|
@@ -1786,7 +3825,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1786
3825
|
}
|
|
1787
3826
|
} else {
|
|
1788
3827
|
for (const filePath of candidates) {
|
|
1789
|
-
processResult(
|
|
3828
|
+
processResult(scanFile2(filePath));
|
|
1790
3829
|
}
|
|
1791
3830
|
}
|
|
1792
3831
|
return parseScanWorkspaceResult({
|
|
@@ -1796,6 +3835,60 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1796
3835
|
});
|
|
1797
3836
|
}
|
|
1798
3837
|
|
|
3838
|
+
// packages/presentation/next/src/withTailwindStyled.ts
|
|
3839
|
+
init_src2();
|
|
3840
|
+
var _fileStaticCssMap = /* @__PURE__ */ new Map();
|
|
3841
|
+
function setFileStaticCss(filepath, css) {
|
|
3842
|
+
if (css && css.trim()) {
|
|
3843
|
+
_fileStaticCssMap.set(filepath, css.trim());
|
|
3844
|
+
} else {
|
|
3845
|
+
_fileStaticCssMap.delete(filepath);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
function buildContent(map) {
|
|
3849
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3850
|
+
const rules = [];
|
|
3851
|
+
for (const css of map.values()) {
|
|
3852
|
+
for (const chunk of css.split(/(?<=\})\s*/)) {
|
|
3853
|
+
const rule = chunk.trim();
|
|
3854
|
+
if (rule && !seen.has(rule)) {
|
|
3855
|
+
seen.add(rule);
|
|
3856
|
+
rules.push(rule);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
return rules.join("\n");
|
|
3861
|
+
}
|
|
3862
|
+
var HEADER = `/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
|
|
3863
|
+
* Import di globals.css: @import "./_tw-state-static.css";
|
|
3864
|
+
* Berisi: state CSS (.tw-s-*[data-*="true"]) + container queries (@container .tw-cq-*).
|
|
3865
|
+
* Di-rebuild penuh setiap webpack compilation selesai \u2014 tidak ada stale rules.
|
|
3866
|
+
*/
|
|
3867
|
+
|
|
3868
|
+
`;
|
|
3869
|
+
var StaticCssWebpackPlugin = class _StaticCssWebpackPlugin {
|
|
3870
|
+
static PLUGIN_NAME = "TailwindStyledStaticCss";
|
|
3871
|
+
outPath;
|
|
3872
|
+
constructor(safelistPath) {
|
|
3873
|
+
this.outPath = path10__default.join(path10__default.dirname(safelistPath), "_tw-state-static.css");
|
|
3874
|
+
}
|
|
3875
|
+
apply(compiler) {
|
|
3876
|
+
compiler.hooks.done.tap(_StaticCssWebpackPlugin.PLUGIN_NAME, () => {
|
|
3877
|
+
try {
|
|
3878
|
+
const content = buildContent(_fileStaticCssMap);
|
|
3879
|
+
fs9__default.mkdirSync(path10__default.dirname(this.outPath), { recursive: true });
|
|
3880
|
+
fs9__default.writeFileSync(
|
|
3881
|
+
this.outPath,
|
|
3882
|
+
HEADER + (content || "/* no static rules yet */") + "\n",
|
|
3883
|
+
"utf-8"
|
|
3884
|
+
);
|
|
3885
|
+
} catch (e) {
|
|
3886
|
+
console.warn("[tailwind-styled] Could not write _tw-state-static.css:", e);
|
|
3887
|
+
}
|
|
3888
|
+
});
|
|
3889
|
+
}
|
|
3890
|
+
};
|
|
3891
|
+
|
|
1799
3892
|
// packages/presentation/next/src/withTailwindStyled.ts
|
|
1800
3893
|
function getDirnameFromUrl2(importMetaUrl) {
|
|
1801
3894
|
if (typeof importMetaUrl !== "string") return "";
|
|
@@ -1818,12 +3911,12 @@ var resolveLoaderPath2 = (basename) => {
|
|
|
1818
3911
|
} catch {
|
|
1819
3912
|
const runtimeDir = resolveRuntimeDir2();
|
|
1820
3913
|
const candidates = [
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
3914
|
+
path10__default.resolve(runtimeDir, `${basename}.mjs`),
|
|
3915
|
+
path10__default.resolve(runtimeDir, `${basename}.js`),
|
|
3916
|
+
path10__default.resolve(runtimeDir, `${basename}.cjs`)
|
|
1824
3917
|
];
|
|
1825
3918
|
for (const candidate of candidates) {
|
|
1826
|
-
if (
|
|
3919
|
+
if (fs9__default.existsSync(candidate)) {
|
|
1827
3920
|
return candidate;
|
|
1828
3921
|
}
|
|
1829
3922
|
}
|
|
@@ -1847,7 +3940,7 @@ function checkNextVersion() {
|
|
|
1847
3940
|
}
|
|
1848
3941
|
var DEFAULT_INCLUDE = /\.[jt]sx?$/;
|
|
1849
3942
|
var DEFAULT_EXCLUDE = /node_modules/;
|
|
1850
|
-
var NEXT_RSC_ENTRIES = /(?:^|[
|
|
3943
|
+
var NEXT_RSC_ENTRIES = /(?:^|[\\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
|
|
1851
3944
|
var buildExcludePattern = (userExclude) => {
|
|
1852
3945
|
if (!userExclude) return new RegExp(`(?:${DEFAULT_EXCLUDE.source})|(?:${NEXT_RSC_ENTRIES.source})`);
|
|
1853
3946
|
return new RegExp(`(?:${userExclude.source})|(?:${NEXT_RSC_ENTRIES.source})`);
|
|
@@ -1861,7 +3954,7 @@ var createLoaderOptions = (options) => {
|
|
|
1861
3954
|
preserveImports: true
|
|
1862
3955
|
};
|
|
1863
3956
|
if (options.verbose !== void 0) opts.verbose = options.verbose;
|
|
1864
|
-
opts.safelistPath = options.safelistPath ??
|
|
3957
|
+
opts.safelistPath = options.safelistPath ?? path10__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
|
|
1865
3958
|
return Object.freeze(opts);
|
|
1866
3959
|
};
|
|
1867
3960
|
var buildTurbopackRules = (loaderPath, loaderOptions) => {
|
|
@@ -1874,7 +3967,7 @@ var buildTurbopackRules = (loaderPath, loaderOptions) => {
|
|
|
1874
3967
|
])
|
|
1875
3968
|
);
|
|
1876
3969
|
};
|
|
1877
|
-
var normalizeLoaderPath = (loaderPath) =>
|
|
3970
|
+
var normalizeLoaderPath = (loaderPath) => path10__default.resolve(loaderPath);
|
|
1878
3971
|
var applyWebpackRule = (config, options, loaderPath) => {
|
|
1879
3972
|
const loaderOptions = createLoaderOptions(options);
|
|
1880
3973
|
const rules = config.module?.rules ?? [];
|
|
@@ -1887,16 +3980,20 @@ var applyWebpackRule = (config, options, loaderPath) => {
|
|
|
1887
3980
|
if (alreadyRegistered) return config;
|
|
1888
3981
|
const tailwindStyledRule = {
|
|
1889
3982
|
test: options.include ?? DEFAULT_INCLUDE,
|
|
1890
|
-
// Selalu kecualikan Next.js RSC entry files (layout, page, dll) bahkan jika
|
|
1891
|
-
// user menyuplai exclude pattern sendiri — lihat buildExcludePattern.
|
|
1892
3983
|
exclude: buildExcludePattern(options.exclude),
|
|
1893
3984
|
enforce: "pre",
|
|
1894
3985
|
use: [{ loader: loaderPath, options: loaderOptions }]
|
|
1895
3986
|
};
|
|
3987
|
+
const safelistPath = loaderOptions.safelistPath ?? path10__default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
|
|
3988
|
+
const pluginAlreadyRegistered = (config.plugins ?? []).some(
|
|
3989
|
+
(p) => p?.constructor?.name === StaticCssWebpackPlugin.PLUGIN_NAME
|
|
3990
|
+
);
|
|
3991
|
+
const plugins = pluginAlreadyRegistered ? config.plugins ?? [] : [...config.plugins ?? [], new StaticCssWebpackPlugin(safelistPath)];
|
|
1896
3992
|
config.module = {
|
|
1897
3993
|
...config.module ?? {},
|
|
1898
3994
|
rules: [...rules, tailwindStyledRule]
|
|
1899
3995
|
};
|
|
3996
|
+
config.plugins = plugins;
|
|
1900
3997
|
const externalPackages = [
|
|
1901
3998
|
"tailwind-styled-v4",
|
|
1902
3999
|
"@tailwind-styled/shared",
|
|
@@ -1987,36 +4084,85 @@ function withTailwindStyled(options = {}) {
|
|
|
1987
4084
|
return fullCss.slice(startIdx, endIdx + 1);
|
|
1988
4085
|
};
|
|
1989
4086
|
var extractUtilitiesLayer = extractUtilitiesLayer2;
|
|
1990
|
-
const twClassesDir =
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
4087
|
+
const twClassesDir = path10__default.join(path10__default.dirname(safelistPath), "tw-classes");
|
|
4088
|
+
fs9__default.mkdirSync(twClassesDir, { recursive: true });
|
|
4089
|
+
setGlobalLogFile(path10__default.join(twClassesDir, "_tw-build.log"));
|
|
4090
|
+
fs9__default.writeFileSync(
|
|
4091
|
+
path10__default.join(twClassesDir, "_start.txt"),
|
|
1994
4092
|
String(Date.now()),
|
|
1995
4093
|
"utf-8"
|
|
1996
4094
|
);
|
|
4095
|
+
const stateStaticPath = path10__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
4096
|
+
if (!fs9__default.existsSync(stateStaticPath)) {
|
|
4097
|
+
fs9__default.writeFileSync(
|
|
4098
|
+
stateStaticPath,
|
|
4099
|
+
"/* tw-state-static.css \u2014 placeholder, akan di-generate setelah scan */\n",
|
|
4100
|
+
"utf-8"
|
|
4101
|
+
);
|
|
4102
|
+
}
|
|
4103
|
+
try {
|
|
4104
|
+
const CSS_CANDIDATES = [
|
|
4105
|
+
"src/app/globals.css",
|
|
4106
|
+
"src/globals.css",
|
|
4107
|
+
"src/styles/globals.css",
|
|
4108
|
+
"src/tailwind.css",
|
|
4109
|
+
"src/index.css",
|
|
4110
|
+
"styles/globals.css"
|
|
4111
|
+
];
|
|
4112
|
+
const safelistDir = path10__default.dirname(safelistPath);
|
|
4113
|
+
for (const candidate of CSS_CANDIDATES) {
|
|
4114
|
+
const candidatePath = path10__default.join(process.cwd(), candidate);
|
|
4115
|
+
if (!fs9__default.existsSync(candidatePath)) continue;
|
|
4116
|
+
const content = fs9__default.readFileSync(candidatePath, "utf-8");
|
|
4117
|
+
if (content.includes("_tw-state-static.css")) break;
|
|
4118
|
+
const globalsDir = path10__default.dirname(candidatePath);
|
|
4119
|
+
const rel = path10__default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
|
|
4120
|
+
const importLine = `@import "./${rel}";`;
|
|
4121
|
+
const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
|
|
4122
|
+
let updated;
|
|
4123
|
+
if (tailwindImportRe.test(content)) {
|
|
4124
|
+
updated = content.replace(
|
|
4125
|
+
tailwindImportRe,
|
|
4126
|
+
`$1${importLine}
|
|
4127
|
+
`
|
|
4128
|
+
);
|
|
4129
|
+
} else {
|
|
4130
|
+
updated = `${importLine}
|
|
4131
|
+
${content}`;
|
|
4132
|
+
}
|
|
4133
|
+
fs9__default.writeFileSync(candidatePath, updated, "utf-8");
|
|
4134
|
+
if (options.verbose) {
|
|
4135
|
+
console.log(
|
|
4136
|
+
`[tailwind-styled] Auto-injected "${importLine}" into ${candidate}`
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
4139
|
+
break;
|
|
4140
|
+
}
|
|
4141
|
+
} catch {
|
|
4142
|
+
}
|
|
1997
4143
|
if (!process.env.TW_NATIVE_PATH) {
|
|
1998
4144
|
const runtimeDir = resolveRuntimeDir2();
|
|
1999
|
-
const nativePath =
|
|
2000
|
-
if (
|
|
4145
|
+
const nativePath = path10__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
|
|
4146
|
+
if (fs9__default.existsSync(nativePath)) {
|
|
2001
4147
|
process.env.TW_NATIVE_PATH = nativePath;
|
|
2002
4148
|
}
|
|
2003
4149
|
}
|
|
2004
|
-
const srcDir =
|
|
2005
|
-
if (
|
|
4150
|
+
const srcDir = path10__default.join(process.cwd(), "src");
|
|
4151
|
+
if (fs9__default.existsSync(srcDir)) {
|
|
2006
4152
|
try {
|
|
2007
|
-
const result =
|
|
4153
|
+
const result = scanWorkspace2(srcDir);
|
|
2008
4154
|
if (result.uniqueClasses.length > 0) {
|
|
2009
4155
|
let atomicWriteFile2 = function(filePath, content) {
|
|
2010
4156
|
const tmpPath = `${filePath}.tmp`;
|
|
2011
4157
|
try {
|
|
2012
|
-
|
|
2013
|
-
|
|
4158
|
+
fs9__default.writeFileSync(tmpPath, content, "utf-8");
|
|
4159
|
+
fs9__default.renameSync(tmpPath, filePath);
|
|
2014
4160
|
} catch {
|
|
2015
4161
|
try {
|
|
2016
|
-
|
|
4162
|
+
fs9__default.unlinkSync(tmpPath);
|
|
2017
4163
|
} catch {
|
|
2018
4164
|
}
|
|
2019
|
-
|
|
4165
|
+
fs9__default.writeFileSync(filePath, content, "utf-8");
|
|
2020
4166
|
}
|
|
2021
4167
|
};
|
|
2022
4168
|
var atomicWriteFile = atomicWriteFile2;
|
|
@@ -2079,14 +4225,14 @@ function withTailwindStyled(options = {}) {
|
|
|
2079
4225
|
"styles/globals.css"
|
|
2080
4226
|
];
|
|
2081
4227
|
try {
|
|
2082
|
-
const twConfigPath =
|
|
2083
|
-
if (
|
|
2084
|
-
const twConfig = JSON.parse(
|
|
4228
|
+
const twConfigPath = path10__default.join(process.cwd(), "tailwind-styled.config.json");
|
|
4229
|
+
if (fs9__default.existsSync(twConfigPath)) {
|
|
4230
|
+
const twConfig = JSON.parse(fs9__default.readFileSync(twConfigPath, "utf-8"));
|
|
2085
4231
|
const cssEntry = twConfig.css?.entry;
|
|
2086
4232
|
if (cssEntry) {
|
|
2087
|
-
const cssEntryPath =
|
|
2088
|
-
if (
|
|
2089
|
-
cssEntryContent =
|
|
4233
|
+
const cssEntryPath = path10__default.join(process.cwd(), cssEntry);
|
|
4234
|
+
if (fs9__default.existsSync(cssEntryPath)) {
|
|
4235
|
+
cssEntryContent = fs9__default.readFileSync(cssEntryPath, "utf-8");
|
|
2090
4236
|
}
|
|
2091
4237
|
}
|
|
2092
4238
|
}
|
|
@@ -2094,9 +4240,9 @@ function withTailwindStyled(options = {}) {
|
|
|
2094
4240
|
}
|
|
2095
4241
|
if (!cssEntryContent) {
|
|
2096
4242
|
for (const candidate of CSS_CANDIDATES) {
|
|
2097
|
-
const candidatePath =
|
|
2098
|
-
if (
|
|
2099
|
-
cssEntryContent =
|
|
4243
|
+
const candidatePath = path10__default.join(process.cwd(), candidate);
|
|
4244
|
+
if (fs9__default.existsSync(candidatePath)) {
|
|
4245
|
+
cssEntryContent = fs9__default.readFileSync(candidatePath, "utf-8");
|
|
2100
4246
|
break;
|
|
2101
4247
|
}
|
|
2102
4248
|
}
|
|
@@ -2104,8 +4250,8 @@ function withTailwindStyled(options = {}) {
|
|
|
2104
4250
|
if (cssEntryContent) {
|
|
2105
4251
|
cssEntryContent = cssEntryContent.replace(/@source\s+["'][^"']+["']\s*;?\s*/g, "").replace(/←[^\n]*/g, "").trim();
|
|
2106
4252
|
}
|
|
2107
|
-
const initialScanPath =
|
|
2108
|
-
if (!
|
|
4253
|
+
const initialScanPath = path10__default.join(twClassesDir, "_initial-scan.css");
|
|
4254
|
+
if (!fs9__default.existsSync(initialScanPath)) {
|
|
2109
4255
|
atomicWriteFile2(
|
|
2110
4256
|
initialScanPath,
|
|
2111
4257
|
"/* tw-classes: initial scan \u2014 generating... */\n@layer utilities {}\n"
|
|
@@ -2113,7 +4259,7 @@ function withTailwindStyled(options = {}) {
|
|
|
2113
4259
|
}
|
|
2114
4260
|
void (async () => {
|
|
2115
4261
|
try {
|
|
2116
|
-
const compiler = await Promise.resolve().then(() => (
|
|
4262
|
+
const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
2117
4263
|
const generateCssForClasses2 = compiler.generateCssForClasses;
|
|
2118
4264
|
const css = await generateCssForClasses2(
|
|
2119
4265
|
filteredClasses,
|
|
@@ -2130,25 +4276,36 @@ function withTailwindStyled(options = {}) {
|
|
|
2130
4276
|
`/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
|
|
2131
4277
|
${utilitiesOnly}`
|
|
2132
4278
|
);
|
|
4279
|
+
const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
|
|
4280
|
+
verbose: options.verbose ?? false,
|
|
4281
|
+
resolvedCss: css
|
|
4282
|
+
});
|
|
4283
|
+
if (options.verbose) console.log(summary);
|
|
2133
4284
|
}
|
|
2134
4285
|
} catch (err) {
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
"}"
|
|
2141
|
-
].join("\n");
|
|
2142
|
-
atomicWriteFile2(initialScanPath, css);
|
|
4286
|
+
throw new Error(
|
|
4287
|
+
`[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
|
|
4288
|
+
${err.message}`,
|
|
4289
|
+
{ cause: err }
|
|
4290
|
+
);
|
|
2143
4291
|
}
|
|
2144
4292
|
})();
|
|
2145
4293
|
}
|
|
2146
4294
|
} catch (e) {
|
|
2147
|
-
|
|
4295
|
+
throw new Error(
|
|
4296
|
+
`[tailwind-styled] Scanner gagal \u2014 Rust native binary tidak tersedia. Build tidak bisa dilanjutkan.
|
|
4297
|
+
${e.message}`,
|
|
4298
|
+
{ cause: e }
|
|
4299
|
+
);
|
|
2148
4300
|
}
|
|
2149
4301
|
}
|
|
2150
4302
|
}
|
|
2151
|
-
} catch {
|
|
4303
|
+
} catch (err) {
|
|
4304
|
+
throw new Error(
|
|
4305
|
+
`[tailwind-styled] Build-time CSS generation gagal.
|
|
4306
|
+
${err.message}`,
|
|
4307
|
+
{ cause: err }
|
|
4308
|
+
);
|
|
2152
4309
|
}
|
|
2153
4310
|
return {
|
|
2154
4311
|
...nextConfig,
|
|
@@ -2215,6 +4372,6 @@ ${utilitiesOnly}`
|
|
|
2215
4372
|
};
|
|
2216
4373
|
}
|
|
2217
4374
|
|
|
2218
|
-
export { NextAdapterOptionsSchema, parseNextAdapterOptions, withTailwindStyled };
|
|
4375
|
+
export { NextAdapterOptionsSchema, StaticCssWebpackPlugin, parseNextAdapterOptions, setFileStaticCss, withTailwindStyled };
|
|
2219
4376
|
//# sourceMappingURL=next.mjs.map
|
|
2220
4377
|
//# sourceMappingURL=next.mjs.map
|