tailwind-styled-v4 5.0.11 → 5.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{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.js +11 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +11 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +16 -7
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +16 -7
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +262 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +259 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2543 -109
- package/dist/compiler.d.ts +2543 -109
- package/dist/compiler.js +1962 -435
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1816 -382
- 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 +1442 -417
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +1442 -417
- 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 +6000 -1463
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5995 -1458
- 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 +3197 -1128
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3196 -1129
- 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 +1627 -376
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +1620 -354
- 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 +943 -76
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +943 -76
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +262 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +259 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1336 -296
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1336 -296
- 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 +140 -34
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +140 -34
- 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/compiler.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
+
import fs__default from 'fs';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
import path__default from 'path';
|
|
5
6
|
import 'crypto';
|
|
@@ -31,7 +32,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
31
32
|
if (isBrowser) {
|
|
32
33
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
33
34
|
}
|
|
34
|
-
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
35
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
35
36
|
return { path: null, source: "not-found", platform, tried: [] };
|
|
36
37
|
}
|
|
37
38
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
@@ -136,7 +137,7 @@ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttemp
|
|
|
136
137
|
var init_nativeBridge = __esm({
|
|
137
138
|
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
138
139
|
init_src();
|
|
139
|
-
_loadNative = (
|
|
140
|
+
_loadNative = (path4) => __require(path4);
|
|
140
141
|
log = (...args) => {
|
|
141
142
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
142
143
|
console.log("[compiler:native]", ...args);
|
|
@@ -212,11 +213,41 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
212
213
|
// packages/domain/compiler/src/tailwindEngine.ts
|
|
213
214
|
var tailwindEngine_exports = {};
|
|
214
215
|
__export(tailwindEngine_exports, {
|
|
216
|
+
clearCache: () => clearCache,
|
|
215
217
|
generateRawCss: () => generateRawCss,
|
|
218
|
+
getCacheStats: () => getCacheStats,
|
|
216
219
|
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
217
220
|
runCssPipeline: () => runCssPipeline,
|
|
218
221
|
runCssPipelineSync: () => runCssPipelineSync
|
|
219
222
|
});
|
|
223
|
+
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
224
|
+
const sorted = [...classes].sort().join(",");
|
|
225
|
+
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
226
|
+
return `${sorted}|${flags}`;
|
|
227
|
+
}
|
|
228
|
+
function _evictOldestIfNeeded() {
|
|
229
|
+
if (_cssCache.size >= MAX_CACHE_SIZE) {
|
|
230
|
+
const firstKey = _cssCache.keys().next().value;
|
|
231
|
+
if (firstKey !== void 0) {
|
|
232
|
+
_cssCache.delete(firstKey);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function getCacheStats() {
|
|
237
|
+
const total = _cacheHits + _cacheMisses;
|
|
238
|
+
return {
|
|
239
|
+
hits: _cacheHits,
|
|
240
|
+
misses: _cacheMisses,
|
|
241
|
+
hitRate: total > 0 ? _cacheHits / total : 0,
|
|
242
|
+
size: _cssCache.size,
|
|
243
|
+
maxSize: MAX_CACHE_SIZE
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function clearCache() {
|
|
247
|
+
_cssCache.clear();
|
|
248
|
+
_cacheHits = 0;
|
|
249
|
+
_cacheMisses = 0;
|
|
250
|
+
}
|
|
220
251
|
function loadTailwindEngine() {
|
|
221
252
|
if (_twEngine) return _twEngine;
|
|
222
253
|
if (_twEngineError) throw _twEngineError;
|
|
@@ -244,10 +275,7 @@ async function generateRawCss(classes, cssEntryContent, root) {
|
|
|
244
275
|
try {
|
|
245
276
|
const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
|
|
246
277
|
const pkgPath = req.resolve(cssId);
|
|
247
|
-
return {
|
|
248
|
-
content: readFileSync(pkgPath, "utf-8"),
|
|
249
|
-
base: dirname(pkgPath)
|
|
250
|
-
};
|
|
278
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
|
|
251
279
|
} catch {
|
|
252
280
|
try {
|
|
253
281
|
const absPath = resolve2(base, id);
|
|
@@ -262,30 +290,132 @@ async function generateRawCss(classes, cssEntryContent, root) {
|
|
|
262
290
|
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
263
291
|
return compiler.build(classes);
|
|
264
292
|
}
|
|
293
|
+
function getThemeConfig() {
|
|
294
|
+
return {
|
|
295
|
+
colors: {
|
|
296
|
+
slate: {
|
|
297
|
+
"50": "#f8fafc",
|
|
298
|
+
"100": "#f1f5f9",
|
|
299
|
+
"200": "#e2e8f0",
|
|
300
|
+
"300": "#cbd5e1",
|
|
301
|
+
"400": "#94a3b8",
|
|
302
|
+
"500": "#64748b",
|
|
303
|
+
"600": "#475569",
|
|
304
|
+
"700": "#334155",
|
|
305
|
+
"800": "#1e293b",
|
|
306
|
+
"900": "#0f172a"
|
|
307
|
+
},
|
|
308
|
+
gray: {
|
|
309
|
+
"50": "#f9fafb",
|
|
310
|
+
"100": "#f3f4f6",
|
|
311
|
+
"200": "#e5e7eb",
|
|
312
|
+
"300": "#d1d5db",
|
|
313
|
+
"400": "#9ca3af",
|
|
314
|
+
"500": "#6b7280",
|
|
315
|
+
"600": "#4b5563",
|
|
316
|
+
"700": "#374151",
|
|
317
|
+
"800": "#1f2937",
|
|
318
|
+
"900": "#111827"
|
|
319
|
+
},
|
|
320
|
+
white: "#ffffff",
|
|
321
|
+
black: "#000000",
|
|
322
|
+
red: {
|
|
323
|
+
"500": "#ef4444",
|
|
324
|
+
"600": "#dc2626"
|
|
325
|
+
},
|
|
326
|
+
blue: {
|
|
327
|
+
"500": "#3b82f6",
|
|
328
|
+
"600": "#1e40af"
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
spacing: {
|
|
332
|
+
"0": "0px",
|
|
333
|
+
"1": "0.25rem",
|
|
334
|
+
"2": "0.5rem",
|
|
335
|
+
"3": "0.75rem",
|
|
336
|
+
"4": "1rem",
|
|
337
|
+
"5": "1.25rem",
|
|
338
|
+
"6": "1.5rem",
|
|
339
|
+
"8": "2rem",
|
|
340
|
+
"10": "2.5rem",
|
|
341
|
+
"12": "3rem",
|
|
342
|
+
"16": "4rem",
|
|
343
|
+
"20": "5rem",
|
|
344
|
+
"24": "6rem"
|
|
345
|
+
},
|
|
346
|
+
breakpoints: {
|
|
347
|
+
"sm": "640px",
|
|
348
|
+
"md": "768px",
|
|
349
|
+
"lg": "1024px",
|
|
350
|
+
"xl": "1280px",
|
|
351
|
+
"2xl": "1536px"
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
265
355
|
function postProcessWithLightning(rawCss) {
|
|
266
356
|
if (!rawCss) return "";
|
|
267
357
|
const native = getNativeBridge();
|
|
268
|
-
if (
|
|
358
|
+
if (!native?.processTailwindCssLightning) {
|
|
269
359
|
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
270
360
|
}
|
|
271
361
|
const result = native.processTailwindCssLightning(rawCss);
|
|
272
|
-
|
|
362
|
+
if (!result?.css) {
|
|
363
|
+
throw new Error("FATAL: processTailwindCssLightning returned null");
|
|
364
|
+
}
|
|
365
|
+
return result.css;
|
|
273
366
|
}
|
|
274
367
|
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
275
|
-
const
|
|
368
|
+
const filtered = classes.filter(Boolean);
|
|
369
|
+
const uniqueMap = /* @__PURE__ */ new Map();
|
|
370
|
+
filtered.forEach((cls) => uniqueMap.set(cls, cls));
|
|
371
|
+
const unique = Array.from(uniqueMap.values());
|
|
276
372
|
if (unique.length === 0) {
|
|
277
373
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
278
374
|
}
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
375
|
+
const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
|
|
376
|
+
const cached = _cssCache.get(cacheKey);
|
|
377
|
+
if (cached) {
|
|
378
|
+
_cacheHits++;
|
|
379
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
380
|
+
console.log(
|
|
381
|
+
`[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
return cached;
|
|
385
|
+
}
|
|
386
|
+
_cacheMisses++;
|
|
387
|
+
let rawCss;
|
|
388
|
+
let usedRustCompiler = false;
|
|
389
|
+
try {
|
|
390
|
+
const theme = getThemeConfig();
|
|
391
|
+
rawCss = await generateCssNative(unique, {
|
|
392
|
+
theme,
|
|
393
|
+
fallbackToJs: true,
|
|
394
|
+
logFallback: process.env.DEBUG?.includes("compiler") === true
|
|
395
|
+
});
|
|
396
|
+
usedRustCompiler = true;
|
|
397
|
+
} catch (error) {
|
|
398
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
399
|
+
console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
|
|
400
|
+
}
|
|
401
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
402
|
+
}
|
|
403
|
+
const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
|
|
404
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
405
|
+
console.log(
|
|
406
|
+
`[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
|
|
407
|
+
`Size: ${finalCss.length} bytes`
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
const result = {
|
|
284
411
|
css: finalCss,
|
|
285
412
|
classes: unique,
|
|
286
413
|
sizeBytes: finalCss.length,
|
|
287
|
-
optimized:
|
|
414
|
+
optimized: minify
|
|
288
415
|
};
|
|
416
|
+
_evictOldestIfNeeded();
|
|
417
|
+
_cssCache.set(cacheKey, result);
|
|
418
|
+
return result;
|
|
289
419
|
}
|
|
290
420
|
function runCssPipelineSync(_classes) {
|
|
291
421
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
@@ -296,443 +426,1747 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
296
426
|
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
297
427
|
}
|
|
298
428
|
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
299
|
-
|
|
429
|
+
if (!result?.css) {
|
|
430
|
+
throw new Error("FATAL: processTailwindCssWithTargets returned null");
|
|
431
|
+
}
|
|
432
|
+
return result.css;
|
|
300
433
|
}
|
|
301
|
-
var require2, _twEngine, _twEngineError;
|
|
434
|
+
var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
|
|
302
435
|
var init_tailwindEngine = __esm({
|
|
303
436
|
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
304
437
|
init_nativeBridge();
|
|
438
|
+
init_cssGeneratorNative();
|
|
305
439
|
require2 = createRequire(import.meta.url);
|
|
440
|
+
_cssCache = /* @__PURE__ */ new Map();
|
|
441
|
+
_cacheHits = 0;
|
|
442
|
+
_cacheMisses = 0;
|
|
443
|
+
MAX_CACHE_SIZE = 100;
|
|
306
444
|
_twEngine = null;
|
|
307
445
|
_twEngineError = null;
|
|
308
446
|
}
|
|
309
447
|
});
|
|
310
448
|
|
|
311
|
-
// packages/domain/compiler/src/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
449
|
+
// packages/domain/compiler/src/cssGeneratorNative.ts
|
|
450
|
+
async function generateCssNative(classes, options) {
|
|
451
|
+
const {
|
|
452
|
+
theme,
|
|
453
|
+
fallbackToJs = true,
|
|
454
|
+
logFallback = false
|
|
455
|
+
} = options;
|
|
456
|
+
try {
|
|
457
|
+
const native = getNativeBridge();
|
|
458
|
+
if (!native?.generateCssNative) {
|
|
459
|
+
throw new Error("generateCssNative not available in native binding");
|
|
460
|
+
}
|
|
461
|
+
const themeJson = JSON.stringify(theme);
|
|
462
|
+
const css = native.generateCssNative(classes, themeJson);
|
|
463
|
+
return css;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
if (!fallbackToJs) {
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
if (logFallback) {
|
|
469
|
+
console.warn(
|
|
470
|
+
"[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
|
|
471
|
+
error instanceof Error ? error.message : String(error)
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
return generateRawCss(classes);
|
|
317
475
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
476
|
+
}
|
|
477
|
+
function getCacheStats2() {
|
|
478
|
+
try {
|
|
479
|
+
const native = getNativeBridge();
|
|
480
|
+
if (!native?.getCacheStats) {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
const [hits, misses] = native.getCacheStats();
|
|
484
|
+
return { hits, misses };
|
|
485
|
+
} catch {
|
|
486
|
+
return null;
|
|
321
487
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
488
|
+
}
|
|
489
|
+
function clearThemeCache() {
|
|
490
|
+
try {
|
|
491
|
+
const native = getNativeBridge();
|
|
492
|
+
if (!native?.clearThemeCache) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
native.clearThemeCache();
|
|
496
|
+
} catch {
|
|
328
497
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
498
|
+
}
|
|
499
|
+
var init_cssGeneratorNative = __esm({
|
|
500
|
+
"packages/domain/compiler/src/cssGeneratorNative.ts"() {
|
|
501
|
+
init_nativeBridge();
|
|
502
|
+
init_tailwindEngine();
|
|
335
503
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
};
|
|
341
|
-
var compileCssFromClasses = (classes, prefix) => {
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
// packages/domain/compiler/src/scannerNative.ts
|
|
507
|
+
function scanWorkspace(root, extensions) {
|
|
342
508
|
const native = getNativeBridge();
|
|
343
|
-
if (!native?.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (!result) {
|
|
348
|
-
throw new Error("FATAL: transformSource returned null");
|
|
349
|
-
}
|
|
350
|
-
return result;
|
|
351
|
-
};
|
|
352
|
-
var buildStyleTag = (classes) => {
|
|
353
|
-
const result = compileCssFromClasses(classes);
|
|
354
|
-
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
355
|
-
};
|
|
356
|
-
var compileCssNative = (classes, prefix = null) => {
|
|
357
|
-
return compileCssFromClasses(classes, prefix);
|
|
358
|
-
};
|
|
359
|
-
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
360
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
361
|
-
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
362
|
-
return result.css;
|
|
363
|
-
};
|
|
364
|
-
var extractAllClasses = (source) => {
|
|
509
|
+
if (!native?.scan_workspace) throw new Error("scan_workspace not available");
|
|
510
|
+
return native.scan_workspace(root, extensions);
|
|
511
|
+
}
|
|
512
|
+
function extractClassesFromSourceNative(source) {
|
|
365
513
|
const native = getNativeBridge();
|
|
366
|
-
if (!native?.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
};
|
|
371
|
-
var extractClassesFromSource = (source) => {
|
|
514
|
+
if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
|
|
515
|
+
return native.extract_classes_from_source(source);
|
|
516
|
+
}
|
|
517
|
+
function batchExtractClassesNative(filePaths) {
|
|
372
518
|
const native = getNativeBridge();
|
|
373
|
-
if (!native?.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
378
|
-
};
|
|
379
|
-
var astExtractClasses = (source, filename) => {
|
|
519
|
+
if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
|
|
520
|
+
return native.batch_extract_classes(filePaths);
|
|
521
|
+
}
|
|
522
|
+
function checkAgainstSafelistNative(classes, safelist) {
|
|
380
523
|
const native = getNativeBridge();
|
|
381
|
-
if (!native?.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
};
|
|
386
|
-
var parseClasses = (raw) => {
|
|
524
|
+
if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
|
|
525
|
+
return native.check_against_safelist(classes, safelist);
|
|
526
|
+
}
|
|
527
|
+
function scanFile(filePath) {
|
|
387
528
|
const native = getNativeBridge();
|
|
388
|
-
if (!native?.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
};
|
|
393
|
-
var normalizeClasses = (raw) => {
|
|
394
|
-
const result = normalizeAndDedupClasses(raw);
|
|
395
|
-
return result?.normalized || "";
|
|
396
|
-
};
|
|
397
|
-
var mergeClassesStatic = (classes) => {
|
|
398
|
-
const result = normalizeAndDedupClasses(classes);
|
|
399
|
-
return result?.normalized || "";
|
|
400
|
-
};
|
|
401
|
-
var normalizeAndDedupClasses = (raw) => {
|
|
529
|
+
if (!native?.scan_file) throw new Error("scan_file not available");
|
|
530
|
+
return native.scan_file(filePath);
|
|
531
|
+
}
|
|
532
|
+
function collectFiles(root, extensions) {
|
|
402
533
|
const native = getNativeBridge();
|
|
403
|
-
if (!native?.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
408
|
-
};
|
|
409
|
-
var eliminateDeadCss = (css, deadClasses) => {
|
|
534
|
+
if (!native?.collect_files) throw new Error("collect_files not available");
|
|
535
|
+
return native.collect_files(root, extensions);
|
|
536
|
+
}
|
|
537
|
+
function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
|
|
410
538
|
const native = getNativeBridge();
|
|
411
|
-
if (!native?.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
var findDeadVariants = (variantConfig, usage) => {
|
|
423
|
-
const unused = [];
|
|
424
|
-
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
425
|
-
for (const component of configs) {
|
|
426
|
-
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
427
|
-
const variants = component.variants;
|
|
428
|
-
for (const [key, values] of Object.entries(variants)) {
|
|
429
|
-
for (const [value] of Object.entries(values)) {
|
|
430
|
-
if (!componentUsage.has(`${key}:${value}`)) {
|
|
431
|
-
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
539
|
+
if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
|
|
540
|
+
return native.walk_and_prefilter_source_files(root, extensions);
|
|
541
|
+
}
|
|
542
|
+
function generateSubComponentTypes(root, outputPath) {
|
|
543
|
+
const native = getNativeBridge();
|
|
544
|
+
if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
|
|
545
|
+
return native.generate_sub_component_types(root, outputPath);
|
|
546
|
+
}
|
|
547
|
+
var init_scannerNative = __esm({
|
|
548
|
+
"packages/domain/compiler/src/scannerNative.ts"() {
|
|
549
|
+
init_nativeBridge();
|
|
435
550
|
}
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
// packages/domain/compiler/src/analyzerNative.ts
|
|
554
|
+
function detectDeadCode(scanResultJson, css) {
|
|
555
|
+
const native = getNativeBridge();
|
|
556
|
+
if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
|
|
557
|
+
return native.detectDeadCode(scanResultJson, css);
|
|
558
|
+
}
|
|
559
|
+
function analyzeClassUsageNative(classes, scanResultJson, css) {
|
|
560
|
+
const native = getNativeBridge();
|
|
561
|
+
if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
|
|
562
|
+
return native.analyzeClassUsage(classes, scanResultJson, css);
|
|
563
|
+
}
|
|
564
|
+
function analyzeClassesNative(filesJson, cwd, flags) {
|
|
565
|
+
const native = getNativeBridge();
|
|
566
|
+
if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
|
|
567
|
+
return native.analyzeClasses(filesJson, cwd, flags ?? 0);
|
|
568
|
+
}
|
|
569
|
+
function analyzeRscNative(source, filename) {
|
|
570
|
+
const native = getNativeBridge();
|
|
571
|
+
if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
|
|
572
|
+
return native.analyzeRsc(source, filename);
|
|
573
|
+
}
|
|
574
|
+
function optimizeCssNative(css) {
|
|
575
|
+
const native = getNativeBridge();
|
|
576
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
577
|
+
const result = native.processTailwindCssLightning(css);
|
|
436
578
|
return {
|
|
437
|
-
|
|
438
|
-
|
|
579
|
+
css: result.css,
|
|
580
|
+
originalSize: css.length,
|
|
581
|
+
optimizedSize: result.size_bytes,
|
|
582
|
+
reductionPercentage: (css.length - result.size_bytes) / css.length * 100
|
|
439
583
|
};
|
|
440
|
-
}
|
|
441
|
-
|
|
584
|
+
}
|
|
585
|
+
function processTailwindCssLightning(css) {
|
|
586
|
+
const native = getNativeBridge();
|
|
587
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
588
|
+
return native.processTailwindCssLightning(css);
|
|
589
|
+
}
|
|
590
|
+
function eliminateDeadCssNative(css, deadClasses) {
|
|
591
|
+
const native = getNativeBridge();
|
|
592
|
+
if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
|
|
593
|
+
return native.eliminateDeadCss(css, deadClasses);
|
|
594
|
+
}
|
|
595
|
+
function hoistComponentsNative(source) {
|
|
596
|
+
const native = getNativeBridge();
|
|
597
|
+
if (!native?.hoistComponents) throw new Error("hoistComponents not available");
|
|
598
|
+
return native.hoistComponents(source);
|
|
599
|
+
}
|
|
600
|
+
function compileVariantTableNative(configJson) {
|
|
601
|
+
const native = getNativeBridge();
|
|
602
|
+
if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
|
|
603
|
+
return native.compileVariantTable(configJson);
|
|
604
|
+
}
|
|
605
|
+
function classifyAndSortClassesNative(classes) {
|
|
606
|
+
const native = getNativeBridge();
|
|
607
|
+
if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
|
|
608
|
+
return native.classifyAndSortClasses(classes);
|
|
609
|
+
}
|
|
610
|
+
function mergeCssDeclarationsNative(cssChunks) {
|
|
442
611
|
const native = getNativeBridge();
|
|
443
|
-
if (!native?.
|
|
444
|
-
|
|
612
|
+
if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
|
|
613
|
+
return native.mergeCssDeclarations(cssChunks);
|
|
614
|
+
}
|
|
615
|
+
var init_analyzerNative = __esm({
|
|
616
|
+
"packages/domain/compiler/src/analyzerNative.ts"() {
|
|
617
|
+
init_nativeBridge();
|
|
445
618
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// packages/domain/compiler/src/compilationNative.ts
|
|
622
|
+
function compileCssNative2(classes, prefix) {
|
|
623
|
+
const native = getNativeBridge();
|
|
624
|
+
if (!native?.compileCss) throw new Error("compileCss not available");
|
|
625
|
+
return native.compileCss(classes, prefix);
|
|
626
|
+
}
|
|
627
|
+
function compileCssLightning(classes) {
|
|
628
|
+
const native = getNativeBridge();
|
|
629
|
+
if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
|
|
630
|
+
return native.compileCssLightning(classes);
|
|
631
|
+
}
|
|
632
|
+
function extractTwStateConfigsNative(source, filename) {
|
|
633
|
+
const native = getNativeBridge();
|
|
634
|
+
if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
|
|
635
|
+
return native.extractTwStateConfigs(source, filename);
|
|
636
|
+
}
|
|
637
|
+
function generateStaticStateCssNative(inputs, resolvedCss) {
|
|
638
|
+
const native = getNativeBridge();
|
|
639
|
+
if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
|
|
640
|
+
return native.generateStaticStateCss(inputs, resolvedCss ?? null);
|
|
641
|
+
}
|
|
642
|
+
function extractAndGenerateStateCssNative(source, filename) {
|
|
643
|
+
const native = getNativeBridge();
|
|
644
|
+
if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
|
|
645
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
646
|
+
}
|
|
647
|
+
function layoutClassesToCss(classes) {
|
|
648
|
+
const native = getNativeBridge();
|
|
649
|
+
if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
|
|
650
|
+
return native.layoutClassesToCss(classes);
|
|
651
|
+
}
|
|
652
|
+
function hashContent(input, algorithm = "sha256", length = 8) {
|
|
653
|
+
const native = getNativeBridge();
|
|
654
|
+
if (!native?.hashContent) throw new Error("hashContent not available");
|
|
655
|
+
return native.hashContent(input, algorithm, length);
|
|
656
|
+
}
|
|
657
|
+
function extractTwContainerConfigs(source) {
|
|
658
|
+
const native = getNativeBridge();
|
|
659
|
+
if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
|
|
660
|
+
return native.extractTwContainerConfigs(source);
|
|
661
|
+
}
|
|
662
|
+
function parseAtomicClass(twClass) {
|
|
663
|
+
const native = getNativeBridge();
|
|
664
|
+
if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
|
|
665
|
+
return native.parseAtomicClass(twClass);
|
|
666
|
+
}
|
|
667
|
+
function generateAtomicCss(rulesJson) {
|
|
668
|
+
const native = getNativeBridge();
|
|
669
|
+
if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
|
|
670
|
+
return native.generateAtomicCss(rulesJson);
|
|
671
|
+
}
|
|
672
|
+
function toAtomicClasses(twClasses) {
|
|
673
|
+
const native = getNativeBridge();
|
|
674
|
+
if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
|
|
675
|
+
return native.toAtomicClasses(twClasses);
|
|
676
|
+
}
|
|
677
|
+
function clearAtomicRegistry() {
|
|
678
|
+
const native = getNativeBridge();
|
|
679
|
+
if (!native?.clearAtomicRegistry) return;
|
|
680
|
+
native.clearAtomicRegistry();
|
|
681
|
+
}
|
|
682
|
+
function atomicRegistrySize() {
|
|
453
683
|
const native = getNativeBridge();
|
|
454
|
-
if (!native?.
|
|
455
|
-
|
|
684
|
+
if (!native?.atomicRegistrySize) return 0;
|
|
685
|
+
return native.atomicRegistrySize();
|
|
686
|
+
}
|
|
687
|
+
var init_compilationNative = __esm({
|
|
688
|
+
"packages/domain/compiler/src/compilationNative.ts"() {
|
|
689
|
+
init_nativeBridge();
|
|
456
690
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
// packages/domain/compiler/src/cacheNative.ts
|
|
694
|
+
function getCacheStatistics() {
|
|
695
|
+
const native = getNativeBridge();
|
|
696
|
+
if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
|
|
697
|
+
const statsJson = native.get_cache_statistics();
|
|
698
|
+
try {
|
|
699
|
+
return JSON.parse(statsJson);
|
|
700
|
+
} catch {
|
|
701
|
+
return {
|
|
702
|
+
parse_cache: { hits: 0, misses: 0, size: 0 },
|
|
703
|
+
resolve_cache: { hits: 0, misses: 0, size: 0 },
|
|
704
|
+
compile_cache: { hits: 0, misses: 0, size: 0 },
|
|
705
|
+
css_gen_cache: { hits: 0, misses: 0, size: 0 },
|
|
706
|
+
overall_hit_rate: 0,
|
|
707
|
+
total_memory_bytes: 0
|
|
708
|
+
};
|
|
463
709
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
return (compiled?.css ?? pruned).trim();
|
|
472
|
-
};
|
|
473
|
-
var scanProjectUsage = (dirs, cwd) => {
|
|
474
|
-
const path3 = __require("path");
|
|
475
|
-
const files = dirs.map((dir) => path3.resolve(cwd, dir));
|
|
476
|
-
const results = batchExtractClasses(files) || [];
|
|
477
|
-
const combined = {};
|
|
478
|
-
for (const result of results) {
|
|
479
|
-
if (result.ok && result.classes) {
|
|
480
|
-
for (const cls of result.classes) {
|
|
481
|
-
if (!combined[cls]) combined[cls] = {};
|
|
482
|
-
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
710
|
+
}
|
|
711
|
+
function clearAllCaches() {
|
|
712
|
+
const native = getNativeBridge();
|
|
713
|
+
if (!native?.clear_all_caches) return;
|
|
714
|
+
try {
|
|
715
|
+
native.clear_all_caches();
|
|
716
|
+
} catch {
|
|
485
717
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
var extractComponentUsage = (source) => {
|
|
718
|
+
}
|
|
719
|
+
function clearParseCache() {
|
|
489
720
|
const native = getNativeBridge();
|
|
490
|
-
if (!native?.
|
|
491
|
-
|
|
721
|
+
if (!native?.clear_parse_cache) return;
|
|
722
|
+
try {
|
|
723
|
+
native.clear_parse_cache();
|
|
724
|
+
} catch {
|
|
492
725
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var diffClassLists = (previous, current) => {
|
|
726
|
+
}
|
|
727
|
+
function clearResolveCache() {
|
|
496
728
|
const native = getNativeBridge();
|
|
497
|
-
if (!native?.
|
|
498
|
-
|
|
729
|
+
if (!native?.clear_resolve_cache) return;
|
|
730
|
+
try {
|
|
731
|
+
native.clear_resolve_cache();
|
|
732
|
+
} catch {
|
|
499
733
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
var batchExtractClasses = (filePaths) => {
|
|
734
|
+
}
|
|
735
|
+
function clearCompileCache() {
|
|
503
736
|
const native = getNativeBridge();
|
|
504
|
-
if (!native?.
|
|
505
|
-
|
|
737
|
+
if (!native?.clear_compile_cache) return;
|
|
738
|
+
try {
|
|
739
|
+
native.clear_compile_cache();
|
|
740
|
+
} catch {
|
|
506
741
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
var checkAgainstSafelist = (classes, safelist) => {
|
|
742
|
+
}
|
|
743
|
+
function clearCssGenCache() {
|
|
510
744
|
const native = getNativeBridge();
|
|
511
|
-
if (!native?.
|
|
512
|
-
|
|
745
|
+
if (!native?.clear_css_gen_cache) return;
|
|
746
|
+
try {
|
|
747
|
+
native.clear_css_gen_cache();
|
|
748
|
+
} catch {
|
|
513
749
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
var hoistComponents = (source) => {
|
|
750
|
+
}
|
|
751
|
+
function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
|
|
517
752
|
const native = getNativeBridge();
|
|
518
|
-
if (!native?.
|
|
519
|
-
throw new Error("
|
|
753
|
+
if (!native?.get_cache_optimization_hints)
|
|
754
|
+
throw new Error("get_cache_optimization_hints not available");
|
|
755
|
+
const hintsJson = native.get_cache_optimization_hints(
|
|
756
|
+
Math.min(100, Math.max(0, hitRatePercent)),
|
|
757
|
+
Math.max(1, memoryUsedMb)
|
|
758
|
+
);
|
|
759
|
+
try {
|
|
760
|
+
return JSON.parse(hintsJson);
|
|
761
|
+
} catch {
|
|
762
|
+
return {
|
|
763
|
+
current_strategy: "unknown",
|
|
764
|
+
recommended_strategy: "increase_size",
|
|
765
|
+
estimated_improvement_percent: 0,
|
|
766
|
+
suggested_memory_mb: 256,
|
|
767
|
+
notes: ["Unable to analyze cache statistics"]
|
|
768
|
+
};
|
|
520
769
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
var compileVariantTable = (configJson) => {
|
|
770
|
+
}
|
|
771
|
+
function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
|
|
524
772
|
const native = getNativeBridge();
|
|
525
|
-
if (!native?.
|
|
526
|
-
throw new Error("
|
|
773
|
+
if (!native?.estimate_optimal_cache_config_native)
|
|
774
|
+
throw new Error("estimate_optimal_cache_config_native not available");
|
|
775
|
+
const configJson = native.estimate_optimal_cache_config_native(
|
|
776
|
+
Math.max(64, totalBudgetMb),
|
|
777
|
+
workloadType
|
|
778
|
+
);
|
|
779
|
+
try {
|
|
780
|
+
return JSON.parse(configJson);
|
|
781
|
+
} catch {
|
|
782
|
+
return {
|
|
783
|
+
parse_cache_size: 128,
|
|
784
|
+
resolve_cache_size: 64,
|
|
785
|
+
compile_cache_size: 256,
|
|
786
|
+
css_gen_cache_size: 128,
|
|
787
|
+
recommended_eviction_policy: "lru",
|
|
788
|
+
ttl_seconds: 3600,
|
|
789
|
+
expected_hit_rate_percent: 75
|
|
790
|
+
};
|
|
527
791
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
var compileVariants = (componentId, config) => {
|
|
531
|
-
return compileVariantTable(JSON.stringify({ componentId, ...config }));
|
|
532
|
-
};
|
|
533
|
-
var classifyAndSortClasses = (classes) => {
|
|
792
|
+
}
|
|
793
|
+
function cacheRead(cachePath) {
|
|
534
794
|
const native = getNativeBridge();
|
|
535
|
-
if (!native?.
|
|
536
|
-
|
|
795
|
+
if (!native?.cache_read) throw new Error("cache_read not available");
|
|
796
|
+
const result = native.cache_read(cachePath);
|
|
797
|
+
try {
|
|
798
|
+
return JSON.parse(result.entries_json || "[]");
|
|
799
|
+
} catch {
|
|
800
|
+
return [];
|
|
537
801
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
var mergeCssDeclarations = (cssChunks) => {
|
|
802
|
+
}
|
|
803
|
+
function cacheWrite(cachePath, entries) {
|
|
541
804
|
const native = getNativeBridge();
|
|
542
|
-
if (!native?.
|
|
543
|
-
|
|
805
|
+
if (!native?.cache_write) throw new Error("cache_write not available");
|
|
806
|
+
try {
|
|
807
|
+
const result = native.cache_write(
|
|
808
|
+
cachePath,
|
|
809
|
+
entries.map((e) => ({
|
|
810
|
+
file: e.file,
|
|
811
|
+
content_hash: e.contentHash,
|
|
812
|
+
classes: e.classes,
|
|
813
|
+
mtime_ms: e.mtimeMs,
|
|
814
|
+
size_bytes: e.sizeBytes
|
|
815
|
+
}))
|
|
816
|
+
);
|
|
817
|
+
return typeof result === "boolean" ? result : result === true;
|
|
818
|
+
} catch {
|
|
819
|
+
return false;
|
|
544
820
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
var analyzeClassUsage = (classes, scanResultJson, css) => {
|
|
821
|
+
}
|
|
822
|
+
function cachePriority(mtimeMs, sizeBytes, hitCount) {
|
|
548
823
|
const native = getNativeBridge();
|
|
549
|
-
if (!native?.
|
|
550
|
-
|
|
824
|
+
if (!native?.cache_priority) throw new Error("cache_priority not available");
|
|
825
|
+
return native.cache_priority(mtimeMs, sizeBytes, hitCount);
|
|
826
|
+
}
|
|
827
|
+
var init_cacheNative = __esm({
|
|
828
|
+
"packages/domain/compiler/src/cacheNative.ts"() {
|
|
829
|
+
init_nativeBridge();
|
|
551
830
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
// packages/domain/compiler/src/themeResolutionNative.ts
|
|
834
|
+
function resolveVariants(configJson) {
|
|
555
835
|
const native = getNativeBridge();
|
|
556
|
-
if (!native?.
|
|
557
|
-
|
|
836
|
+
if (!native?.resolve_variants) throw new Error("resolve_variants not available");
|
|
837
|
+
const resultJson = native.resolve_variants(configJson);
|
|
838
|
+
try {
|
|
839
|
+
return JSON.parse(resultJson);
|
|
840
|
+
} catch {
|
|
841
|
+
return {
|
|
842
|
+
variants: [],
|
|
843
|
+
supported: [],
|
|
844
|
+
deprecated: [],
|
|
845
|
+
conflicting: []
|
|
846
|
+
};
|
|
558
847
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
return {
|
|
574
|
-
resolved: {},
|
|
575
|
-
dynamic: []
|
|
576
|
-
};
|
|
577
|
-
};
|
|
578
|
-
var injectClientDirective = (source) => {
|
|
579
|
-
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
580
|
-
return '"use client";\n' + source;
|
|
848
|
+
}
|
|
849
|
+
function validateThemeConfig(configJson) {
|
|
850
|
+
const native = getNativeBridge();
|
|
851
|
+
if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
|
|
852
|
+
const resultJson = native.validate_variant_config(configJson);
|
|
853
|
+
try {
|
|
854
|
+
return JSON.parse(resultJson);
|
|
855
|
+
} catch {
|
|
856
|
+
return {
|
|
857
|
+
is_valid: false,
|
|
858
|
+
errors: ["Unable to parse configuration"],
|
|
859
|
+
warnings: [],
|
|
860
|
+
suggestions: []
|
|
861
|
+
};
|
|
581
862
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
var injectServerOnlyComment = (source) => {
|
|
585
|
-
return `/* @server-only */
|
|
586
|
-
${source}`;
|
|
587
|
-
};
|
|
588
|
-
var analyzeClasses = (filesJson, cwd, flags) => {
|
|
863
|
+
}
|
|
864
|
+
function resolveCascade(baseThemeJson, overridesJson) {
|
|
589
865
|
const native = getNativeBridge();
|
|
590
|
-
if (!native?.
|
|
591
|
-
|
|
866
|
+
if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
|
|
867
|
+
const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
|
|
868
|
+
try {
|
|
869
|
+
return JSON.parse(resultJson);
|
|
870
|
+
} catch {
|
|
871
|
+
return {
|
|
872
|
+
base_theme: {},
|
|
873
|
+
user_overrides: {},
|
|
874
|
+
merged_theme: {},
|
|
875
|
+
conflict_resolutions: []
|
|
876
|
+
};
|
|
592
877
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
if (outputPath) {
|
|
599
|
-
const fs3 = __require("fs");
|
|
600
|
-
fs3.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
601
|
-
}
|
|
602
|
-
return allClasses;
|
|
603
|
-
};
|
|
604
|
-
var loadSafelist = (safelistPath) => {
|
|
605
|
-
const fs3 = __require("fs");
|
|
878
|
+
}
|
|
879
|
+
function resolveClassNames(classNames, themeJson) {
|
|
880
|
+
const native = getNativeBridge();
|
|
881
|
+
if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
|
|
882
|
+
const resultJson = native.resolve_class_names(classNames, themeJson);
|
|
606
883
|
try {
|
|
607
|
-
|
|
608
|
-
return JSON.parse(content);
|
|
884
|
+
return JSON.parse(resultJson);
|
|
609
885
|
} catch {
|
|
610
886
|
return [];
|
|
611
887
|
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
return {};
|
|
630
|
-
};
|
|
631
|
-
var getContentPaths = (cwd = process.cwd()) => {
|
|
632
|
-
const path3 = __require("path");
|
|
633
|
-
return {
|
|
634
|
-
content: [
|
|
635
|
-
path3.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
636
|
-
path3.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
637
|
-
path3.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
638
|
-
]
|
|
639
|
-
};
|
|
640
|
-
};
|
|
641
|
-
var runLoaderTransform = (ctx) => {
|
|
642
|
-
const { filepath, source, options } = ctx;
|
|
643
|
-
const result = transformSource(source, { filename: filepath, ...options });
|
|
644
|
-
return {
|
|
645
|
-
code: result?.code || "",
|
|
646
|
-
changed: result?.changed || false,
|
|
647
|
-
classes: result?.classes || []
|
|
648
|
-
};
|
|
649
|
-
};
|
|
650
|
-
var shouldSkipFile = (filepath) => {
|
|
651
|
-
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
652
|
-
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
653
|
-
for (const p of SKIP_PATHS) {
|
|
654
|
-
if (filepath.includes(p)) return true;
|
|
655
|
-
}
|
|
656
|
-
for (const ext of skipExtensions) {
|
|
657
|
-
if (filepath.endsWith(ext)) return true;
|
|
888
|
+
}
|
|
889
|
+
function resolveConflictGroup(groupName, themeJson) {
|
|
890
|
+
const native = getNativeBridge();
|
|
891
|
+
if (!native?.resolve_conflict_group)
|
|
892
|
+
throw new Error("resolve_conflict_group not available");
|
|
893
|
+
const resultJson = native.resolve_conflict_group(groupName, themeJson);
|
|
894
|
+
try {
|
|
895
|
+
return JSON.parse(resultJson);
|
|
896
|
+
} catch {
|
|
897
|
+
return {
|
|
898
|
+
group_name: groupName,
|
|
899
|
+
conflicting_classes: [],
|
|
900
|
+
description: "",
|
|
901
|
+
resolution_strategy: "last-wins"
|
|
902
|
+
};
|
|
658
903
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
667
|
-
if (pageMatch) return `/${pageMatch[1]}`;
|
|
668
|
-
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
669
|
-
if (rootPage) return "/";
|
|
670
|
-
return null;
|
|
671
|
-
};
|
|
672
|
-
var getAllRoutes = () => {
|
|
904
|
+
}
|
|
905
|
+
function resolveThemeValue(keyPath, themeJson) {
|
|
906
|
+
const native = getNativeBridge();
|
|
907
|
+
if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
|
|
908
|
+
return native.resolve_theme_value(keyPath, themeJson);
|
|
909
|
+
}
|
|
910
|
+
function resolveSimpleVariants(configJson) {
|
|
673
911
|
const native = getNativeBridge();
|
|
674
|
-
if (!native?.
|
|
675
|
-
|
|
912
|
+
if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
|
|
913
|
+
const resultJson = native.resolve_simple_variants(configJson);
|
|
914
|
+
try {
|
|
915
|
+
return JSON.parse(resultJson);
|
|
916
|
+
} catch {
|
|
917
|
+
return [];
|
|
676
918
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
};
|
|
682
|
-
var registerFileClasses = (_filepath, _classes) => {
|
|
683
|
-
};
|
|
684
|
-
var registerGlobalClasses = (_classes) => {
|
|
685
|
-
};
|
|
686
|
-
var _incrementalEngineInstance = null;
|
|
687
|
-
var getIncrementalEngine = () => {
|
|
688
|
-
if (!_incrementalEngineInstance) {
|
|
689
|
-
_incrementalEngineInstance = new IncrementalEngine();
|
|
919
|
+
}
|
|
920
|
+
var init_themeResolutionNative = __esm({
|
|
921
|
+
"packages/domain/compiler/src/themeResolutionNative.ts"() {
|
|
922
|
+
init_nativeBridge();
|
|
690
923
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
// packages/domain/compiler/src/streamingNative.ts
|
|
927
|
+
function processFileChange(fileChangeJson) {
|
|
928
|
+
const native = getNativeBridge();
|
|
929
|
+
if (!native?.process_file_change) throw new Error("process_file_change not available");
|
|
930
|
+
const resultJson = native.process_file_change(fileChangeJson);
|
|
931
|
+
try {
|
|
932
|
+
return JSON.parse(resultJson);
|
|
933
|
+
} catch {
|
|
934
|
+
return {
|
|
935
|
+
file_path: "",
|
|
936
|
+
status: "error",
|
|
937
|
+
old_classes: [],
|
|
938
|
+
new_classes: [],
|
|
939
|
+
added_classes: [],
|
|
940
|
+
removed_classes: [],
|
|
941
|
+
changed: false,
|
|
942
|
+
fingerprint: "",
|
|
943
|
+
error: "Failed to parse result"
|
|
944
|
+
};
|
|
699
945
|
}
|
|
700
|
-
}
|
|
701
|
-
|
|
946
|
+
}
|
|
947
|
+
function computeIncrementalDiff(oldScanJson, newScanJson) {
|
|
702
948
|
const native = getNativeBridge();
|
|
703
|
-
if (!native?.
|
|
704
|
-
throw new Error("
|
|
949
|
+
if (!native?.compute_incremental_diff)
|
|
950
|
+
throw new Error("compute_incremental_diff not available");
|
|
951
|
+
const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
|
|
952
|
+
try {
|
|
953
|
+
return JSON.parse(resultJson);
|
|
954
|
+
} catch {
|
|
955
|
+
return {
|
|
956
|
+
is_changed: false,
|
|
957
|
+
changes_count: 0,
|
|
958
|
+
diff: {
|
|
959
|
+
added_files: [],
|
|
960
|
+
removed_files: [],
|
|
961
|
+
modified_files: [],
|
|
962
|
+
added_classes: [],
|
|
963
|
+
removed_classes: [],
|
|
964
|
+
total_changes: 0
|
|
965
|
+
},
|
|
966
|
+
processing_time_ms: 0
|
|
967
|
+
};
|
|
705
968
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
969
|
+
}
|
|
970
|
+
function createFingerprint(filePath, fileContent) {
|
|
971
|
+
const native = getNativeBridge();
|
|
972
|
+
if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
|
|
973
|
+
const fingerprintJson = native.create_fingerprint(filePath, fileContent);
|
|
974
|
+
try {
|
|
975
|
+
return JSON.parse(fingerprintJson);
|
|
976
|
+
} catch {
|
|
977
|
+
return {
|
|
978
|
+
file_path: filePath,
|
|
979
|
+
content_hash: "",
|
|
980
|
+
size_bytes: fileContent.length,
|
|
981
|
+
mtime_ms: Date.now(),
|
|
982
|
+
class_hash: "",
|
|
983
|
+
signature: ""
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
function injectStateHash(css, stateHash) {
|
|
988
|
+
const native = getNativeBridge();
|
|
989
|
+
if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
|
|
990
|
+
const resultJson = native.inject_state_hash(css, stateHash);
|
|
991
|
+
try {
|
|
992
|
+
return JSON.parse(resultJson);
|
|
993
|
+
} catch {
|
|
994
|
+
return {
|
|
995
|
+
injected: false,
|
|
996
|
+
state_hash: stateHash,
|
|
997
|
+
affected_files: 0,
|
|
998
|
+
total_injected_bytes: 0
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
|
|
1003
|
+
const native = getNativeBridge();
|
|
1004
|
+
if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
|
|
1005
|
+
const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
|
|
1006
|
+
try {
|
|
1007
|
+
return JSON.parse(resultJson);
|
|
1008
|
+
} catch {
|
|
1009
|
+
return {
|
|
1010
|
+
entries_before: 0,
|
|
1011
|
+
entries_after: 0,
|
|
1012
|
+
entries_removed: 0,
|
|
1013
|
+
freed_bytes: 0
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
function rebuildWorkspaceResult(rootDir, extensions) {
|
|
1018
|
+
const native = getNativeBridge();
|
|
1019
|
+
if (!native?.rebuild_workspace_result)
|
|
1020
|
+
throw new Error("rebuild_workspace_result not available");
|
|
1021
|
+
const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
|
|
1022
|
+
try {
|
|
1023
|
+
return JSON.parse(resultJson);
|
|
1024
|
+
} catch {
|
|
1025
|
+
return {
|
|
1026
|
+
total_files_scanned: 0,
|
|
1027
|
+
total_classes_found: 0,
|
|
1028
|
+
unique_classes: 0,
|
|
1029
|
+
build_time_ms: 0,
|
|
1030
|
+
files_with_changes: 0
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
function scanFileNative(filePath, fileContent) {
|
|
1035
|
+
const native = getNativeBridge();
|
|
1036
|
+
if (!native?.scan_file_native) throw new Error("scan_file_native not available");
|
|
1037
|
+
const resultJson = native.scan_file_native(filePath, fileContent);
|
|
1038
|
+
try {
|
|
1039
|
+
return JSON.parse(resultJson);
|
|
1040
|
+
} catch {
|
|
1041
|
+
return {
|
|
1042
|
+
file: filePath,
|
|
1043
|
+
classes: [],
|
|
1044
|
+
added_classes: [],
|
|
1045
|
+
removed_classes: [],
|
|
1046
|
+
changed: false
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
function scanFilesBatchNative(filesJson) {
|
|
1051
|
+
const native = getNativeBridge();
|
|
1052
|
+
if (!native?.scan_files_batch_native)
|
|
1053
|
+
throw new Error("scan_files_batch_native not available");
|
|
1054
|
+
const resultJson = native.scan_files_batch_native(filesJson);
|
|
1055
|
+
try {
|
|
1056
|
+
return JSON.parse(resultJson);
|
|
1057
|
+
} catch {
|
|
1058
|
+
return [];
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
var init_streamingNative = __esm({
|
|
1062
|
+
"packages/domain/compiler/src/streamingNative.ts"() {
|
|
1063
|
+
init_nativeBridge();
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
// packages/domain/compiler/src/cssCompilationNative.ts
|
|
1068
|
+
function compileClass(input) {
|
|
1069
|
+
const native = getNativeBridge();
|
|
1070
|
+
if (!native?.compile_class) throw new Error("compile_class not available");
|
|
1071
|
+
const resultJson = native.compile_class(input);
|
|
1072
|
+
try {
|
|
1073
|
+
return JSON.parse(resultJson);
|
|
1074
|
+
} catch {
|
|
1075
|
+
return {
|
|
1076
|
+
selector: "",
|
|
1077
|
+
declarations: "",
|
|
1078
|
+
properties: [],
|
|
1079
|
+
specificity: 0
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function compileClasses(inputs) {
|
|
1084
|
+
const native = getNativeBridge();
|
|
1085
|
+
if (!native?.compile_classes) throw new Error("compile_classes not available");
|
|
1086
|
+
const resultJson = native.compile_classes(inputs);
|
|
1087
|
+
try {
|
|
1088
|
+
return JSON.parse(resultJson);
|
|
1089
|
+
} catch {
|
|
1090
|
+
return {
|
|
1091
|
+
css: "",
|
|
1092
|
+
resolved_classes: [],
|
|
1093
|
+
unknown_classes: [],
|
|
1094
|
+
size_bytes: 0,
|
|
1095
|
+
duration_ms: 0
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function compileToCss(input, minify) {
|
|
1100
|
+
const native = getNativeBridge();
|
|
1101
|
+
if (!native?.compile_to_css) throw new Error("compile_to_css not available");
|
|
1102
|
+
return native.compile_to_css(input, minify ?? false);
|
|
1103
|
+
}
|
|
1104
|
+
function compileToCssBatch(inputs, minify) {
|
|
1105
|
+
const native = getNativeBridge();
|
|
1106
|
+
if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
|
|
1107
|
+
return native.compile_to_css_batch(inputs, minify ?? false);
|
|
1108
|
+
}
|
|
1109
|
+
function minifyCss(css) {
|
|
1110
|
+
const native = getNativeBridge();
|
|
1111
|
+
if (!native?.minify_css) throw new Error("minify_css not available");
|
|
1112
|
+
return native.minify_css(css);
|
|
1113
|
+
}
|
|
1114
|
+
function compileAnimation(animationName, from, to) {
|
|
1115
|
+
const native = getNativeBridge();
|
|
1116
|
+
if (!native?.compile_animation) throw new Error("compile_animation not available");
|
|
1117
|
+
const resultJson = native.compile_animation(animationName, from, to);
|
|
1118
|
+
try {
|
|
1119
|
+
return JSON.parse(resultJson);
|
|
1120
|
+
} catch {
|
|
1121
|
+
return {
|
|
1122
|
+
animation_id: "",
|
|
1123
|
+
keyframes_css: "",
|
|
1124
|
+
animation_rule: "",
|
|
1125
|
+
duration_ms: 0
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function compileKeyframes(name, stopsJson) {
|
|
1130
|
+
const native = getNativeBridge();
|
|
1131
|
+
if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
|
|
1132
|
+
const resultJson = native.compile_keyframes(name, stopsJson);
|
|
1133
|
+
try {
|
|
1134
|
+
return JSON.parse(resultJson);
|
|
1135
|
+
} catch {
|
|
1136
|
+
return {
|
|
1137
|
+
animation_id: "",
|
|
1138
|
+
keyframes_css: "",
|
|
1139
|
+
animation_rule: "",
|
|
1140
|
+
duration_ms: 0
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function compileTheme(tokensJson, themeName, prefix) {
|
|
1145
|
+
const native = getNativeBridge();
|
|
1146
|
+
if (!native?.compile_theme) throw new Error("compile_theme not available");
|
|
1147
|
+
const resultJson = native.compile_theme(tokensJson, themeName, prefix);
|
|
1148
|
+
try {
|
|
1149
|
+
return JSON.parse(resultJson);
|
|
1150
|
+
} catch {
|
|
1151
|
+
return {
|
|
1152
|
+
selector: ":root",
|
|
1153
|
+
variables: [],
|
|
1154
|
+
variables_css: "",
|
|
1155
|
+
theme_name: themeName
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
function twMerge(classString) {
|
|
1160
|
+
const native = getNativeBridge();
|
|
1161
|
+
if (!native?.tw_merge) throw new Error("tw_merge not available");
|
|
1162
|
+
return native.tw_merge(classString);
|
|
1163
|
+
}
|
|
1164
|
+
function twMergeMany(classStrings) {
|
|
1165
|
+
const native = getNativeBridge();
|
|
1166
|
+
if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
|
|
1167
|
+
return native.tw_merge_many(classStrings);
|
|
1168
|
+
}
|
|
1169
|
+
function twMergeWithSeparator(classString, options) {
|
|
1170
|
+
const native = getNativeBridge();
|
|
1171
|
+
if (!native?.tw_merge_with_separator)
|
|
1172
|
+
throw new Error("tw_merge_with_separator not available");
|
|
1173
|
+
const opts = {
|
|
1174
|
+
separator: options.separator,
|
|
1175
|
+
debug: options.debug
|
|
709
1176
|
};
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
1177
|
+
return native.tw_merge_with_separator(classString, opts);
|
|
1178
|
+
}
|
|
1179
|
+
function twMergeManyWithSeparator(classStrings, options) {
|
|
1180
|
+
const native = getNativeBridge();
|
|
1181
|
+
if (!native?.tw_merge_many_with_separator)
|
|
1182
|
+
throw new Error("tw_merge_many_with_separator not available");
|
|
1183
|
+
const opts = {
|
|
1184
|
+
separator: options.separator,
|
|
1185
|
+
debug: options.debug
|
|
1186
|
+
};
|
|
1187
|
+
return native.tw_merge_many_with_separator(classStrings, opts);
|
|
1188
|
+
}
|
|
1189
|
+
function twMergeRaw(classLists) {
|
|
1190
|
+
const native = getNativeBridge();
|
|
1191
|
+
if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
|
|
1192
|
+
return native.tw_merge_raw(classLists);
|
|
1193
|
+
}
|
|
1194
|
+
var init_cssCompilationNative = __esm({
|
|
1195
|
+
"packages/domain/compiler/src/cssCompilationNative.ts"() {
|
|
1196
|
+
init_nativeBridge();
|
|
716
1197
|
}
|
|
717
|
-
};
|
|
718
|
-
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
// packages/domain/compiler/src/idRegistryNative.ts
|
|
1201
|
+
function idRegistryCreate() {
|
|
1202
|
+
const native = getNativeBridge();
|
|
1203
|
+
if (!native?.id_registry_create) throw new Error("id_registry_create not available");
|
|
1204
|
+
return native.id_registry_create();
|
|
1205
|
+
}
|
|
1206
|
+
function idRegistryGenerate(handle, name) {
|
|
1207
|
+
const native = getNativeBridge();
|
|
1208
|
+
if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
|
|
1209
|
+
return native.id_registry_generate(handle, name);
|
|
1210
|
+
}
|
|
1211
|
+
function idRegistryLookup(handle, name) {
|
|
1212
|
+
const native = getNativeBridge();
|
|
1213
|
+
if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
|
|
1214
|
+
return native.id_registry_lookup(handle, name);
|
|
1215
|
+
}
|
|
1216
|
+
function idRegistryNext(handle) {
|
|
719
1217
|
const native = getNativeBridge();
|
|
720
|
-
if (!native?.
|
|
721
|
-
|
|
1218
|
+
if (!native?.id_registry_next) throw new Error("id_registry_next not available");
|
|
1219
|
+
return native.id_registry_next(handle);
|
|
1220
|
+
}
|
|
1221
|
+
function idRegistryDestroy(handle) {
|
|
1222
|
+
const native = getNativeBridge();
|
|
1223
|
+
if (!native?.id_registry_destroy) return;
|
|
1224
|
+
native.id_registry_destroy(handle);
|
|
1225
|
+
}
|
|
1226
|
+
function idRegistryReset(handle) {
|
|
1227
|
+
const native = getNativeBridge();
|
|
1228
|
+
if (!native?.id_registry_reset) return;
|
|
1229
|
+
native.id_registry_reset(handle);
|
|
1230
|
+
}
|
|
1231
|
+
function idRegistrySnapshot(handle) {
|
|
1232
|
+
const native = getNativeBridge();
|
|
1233
|
+
if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
|
|
1234
|
+
const snapshotJson = native.id_registry_snapshot(handle);
|
|
1235
|
+
try {
|
|
1236
|
+
return JSON.parse(snapshotJson);
|
|
1237
|
+
} catch {
|
|
1238
|
+
return {
|
|
1239
|
+
handle,
|
|
1240
|
+
next_id: 0,
|
|
1241
|
+
entries: [],
|
|
1242
|
+
total_entries: 0
|
|
1243
|
+
};
|
|
722
1244
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
1245
|
+
}
|
|
1246
|
+
function idRegistryActiveCount() {
|
|
1247
|
+
const native = getNativeBridge();
|
|
1248
|
+
if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
|
|
1249
|
+
return native.id_registry_active_count();
|
|
1250
|
+
}
|
|
1251
|
+
function registerPropertyName(propertyName) {
|
|
1252
|
+
const native = getNativeBridge();
|
|
1253
|
+
if (!native?.register_property_name)
|
|
1254
|
+
throw new Error("register_property_name not available");
|
|
1255
|
+
return native.register_property_name(propertyName);
|
|
1256
|
+
}
|
|
1257
|
+
function registerValueName(valueName) {
|
|
726
1258
|
const native = getNativeBridge();
|
|
727
|
-
if (!native?.
|
|
728
|
-
|
|
1259
|
+
if (!native?.register_value_name) throw new Error("register_value_name not available");
|
|
1260
|
+
return native.register_value_name(valueName);
|
|
1261
|
+
}
|
|
1262
|
+
function propertyIdToString(propertyId) {
|
|
1263
|
+
const native = getNativeBridge();
|
|
1264
|
+
if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
|
|
1265
|
+
return native.property_id_to_string(propertyId);
|
|
1266
|
+
}
|
|
1267
|
+
function valueIdToString(valueId) {
|
|
1268
|
+
const native = getNativeBridge();
|
|
1269
|
+
if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
|
|
1270
|
+
return native.value_id_to_string(valueId);
|
|
1271
|
+
}
|
|
1272
|
+
function reverseLookupProperty(propertyId) {
|
|
1273
|
+
const native = getNativeBridge();
|
|
1274
|
+
if (!native?.reverse_lookup_property)
|
|
1275
|
+
throw new Error("reverse_lookup_property not available");
|
|
1276
|
+
return native.reverse_lookup_property(propertyId);
|
|
1277
|
+
}
|
|
1278
|
+
function reverseLookupValue(valueId) {
|
|
1279
|
+
const native = getNativeBridge();
|
|
1280
|
+
if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
|
|
1281
|
+
return native.reverse_lookup_value(valueId);
|
|
1282
|
+
}
|
|
1283
|
+
function idRegistryExport(handle) {
|
|
1284
|
+
const native = getNativeBridge();
|
|
1285
|
+
if (!native?.id_registry_export) throw new Error("id_registry_export not available");
|
|
1286
|
+
return native.id_registry_export(handle);
|
|
1287
|
+
}
|
|
1288
|
+
function idRegistryImport(importedData) {
|
|
1289
|
+
const native = getNativeBridge();
|
|
1290
|
+
if (!native?.id_registry_import) throw new Error("id_registry_import not available");
|
|
1291
|
+
return native.id_registry_import(importedData);
|
|
1292
|
+
}
|
|
1293
|
+
var init_idRegistryNative = __esm({
|
|
1294
|
+
"packages/domain/compiler/src/idRegistryNative.ts"() {
|
|
1295
|
+
init_nativeBridge();
|
|
729
1296
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
// packages/domain/compiler/src/redisNative.ts
|
|
1300
|
+
function redisPing() {
|
|
1301
|
+
const native = getNativeBridge();
|
|
1302
|
+
if (!native?.redis_ping) throw new Error("redis_ping not available");
|
|
1303
|
+
return native.redis_ping();
|
|
1304
|
+
}
|
|
1305
|
+
function redisGet(key) {
|
|
1306
|
+
const native = getNativeBridge();
|
|
1307
|
+
if (!native?.redis_get) throw new Error("redis_get not available");
|
|
1308
|
+
const result = native.redis_get(key);
|
|
1309
|
+
return result === "nil" ? null : result;
|
|
1310
|
+
}
|
|
1311
|
+
function redisSet(key, value, ttl_seconds) {
|
|
1312
|
+
const native = getNativeBridge();
|
|
1313
|
+
if (!native?.redis_set) throw new Error("redis_set not available");
|
|
1314
|
+
return native.redis_set(key, value, ttl_seconds);
|
|
1315
|
+
}
|
|
1316
|
+
function redisDelete(key) {
|
|
1317
|
+
const native = getNativeBridge();
|
|
1318
|
+
if (!native?.redis_delete) throw new Error("redis_delete not available");
|
|
1319
|
+
return native.redis_delete(key);
|
|
1320
|
+
}
|
|
1321
|
+
function redisExists(key) {
|
|
1322
|
+
const native = getNativeBridge();
|
|
1323
|
+
if (!native?.redis_exists) throw new Error("redis_exists not available");
|
|
1324
|
+
return native.redis_exists(key);
|
|
1325
|
+
}
|
|
1326
|
+
function redisMget(keys) {
|
|
1327
|
+
const native = getNativeBridge();
|
|
1328
|
+
if (!native?.redis_mget) throw new Error("redis_mget not available");
|
|
1329
|
+
const result = native.redis_mget(keys);
|
|
1330
|
+
try {
|
|
1331
|
+
return JSON.parse(result);
|
|
1332
|
+
} catch {
|
|
1333
|
+
return keys.map(() => null);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function redisMset(pairs) {
|
|
1337
|
+
const native = getNativeBridge();
|
|
1338
|
+
if (!native?.redis_mset) throw new Error("redis_mset not available");
|
|
1339
|
+
return native.redis_mset(pairs);
|
|
1340
|
+
}
|
|
1341
|
+
function redisFlushDb() {
|
|
1342
|
+
const native = getNativeBridge();
|
|
1343
|
+
if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
|
|
1344
|
+
return native.redis_flush_db();
|
|
1345
|
+
}
|
|
1346
|
+
function redisFlushAll() {
|
|
1347
|
+
const native = getNativeBridge();
|
|
1348
|
+
if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
|
|
1349
|
+
return native.redis_flush_all();
|
|
1350
|
+
}
|
|
1351
|
+
function redisPoolConnect(host, port, pool_size) {
|
|
1352
|
+
const native = getNativeBridge();
|
|
1353
|
+
if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
|
|
1354
|
+
return native.redis_pool_connect(host, port, pool_size);
|
|
1355
|
+
}
|
|
1356
|
+
function redisPoolStats() {
|
|
1357
|
+
const native = getNativeBridge();
|
|
1358
|
+
if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
|
|
1359
|
+
const result = native.redis_pool_stats();
|
|
1360
|
+
try {
|
|
1361
|
+
return JSON.parse(result);
|
|
1362
|
+
} catch {
|
|
1363
|
+
return {
|
|
1364
|
+
connected_count: 0,
|
|
1365
|
+
idle_count: 0,
|
|
1366
|
+
waiting_count: 0,
|
|
1367
|
+
total_requests: 0,
|
|
1368
|
+
total_errors: 0
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function redisPoolReconnect() {
|
|
1373
|
+
const native = getNativeBridge();
|
|
1374
|
+
if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
|
|
1375
|
+
return native.redis_pool_reconnect();
|
|
1376
|
+
}
|
|
1377
|
+
function redisEnableCluster(initial_nodes) {
|
|
1378
|
+
const native = getNativeBridge();
|
|
1379
|
+
if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
|
|
1380
|
+
const result = native.redis_enable_cluster(initial_nodes);
|
|
1381
|
+
try {
|
|
1382
|
+
return JSON.parse(result);
|
|
1383
|
+
} catch {
|
|
1384
|
+
return {
|
|
1385
|
+
enabled: false,
|
|
1386
|
+
cluster_state: "error",
|
|
1387
|
+
nodes: [],
|
|
1388
|
+
slots_assigned: 0,
|
|
1389
|
+
slots_ok: 0,
|
|
1390
|
+
slots_fail: 0
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function redisDisableCluster() {
|
|
1395
|
+
const native = getNativeBridge();
|
|
1396
|
+
if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
|
|
1397
|
+
return native.redis_disable_cluster();
|
|
1398
|
+
}
|
|
1399
|
+
function redisClusterStatus() {
|
|
1400
|
+
const native = getNativeBridge();
|
|
1401
|
+
if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
|
|
1402
|
+
const result = native.redis_cluster_status();
|
|
1403
|
+
try {
|
|
1404
|
+
return JSON.parse(result);
|
|
1405
|
+
} catch {
|
|
1406
|
+
return {
|
|
1407
|
+
enabled: false,
|
|
1408
|
+
cluster_state: "unknown",
|
|
1409
|
+
nodes: [],
|
|
1410
|
+
slots_assigned: 0,
|
|
1411
|
+
slots_ok: 0,
|
|
1412
|
+
slots_fail: 0
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
function redisSubscribe(channel) {
|
|
1417
|
+
const native = getNativeBridge();
|
|
1418
|
+
if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
|
|
1419
|
+
return native.redis_subscribe(channel);
|
|
1420
|
+
}
|
|
1421
|
+
function redisPublish(channel, message) {
|
|
1422
|
+
const native = getNativeBridge();
|
|
1423
|
+
if (!native?.redis_publish) throw new Error("redis_publish not available");
|
|
1424
|
+
return native.redis_publish(channel, message);
|
|
1425
|
+
}
|
|
1426
|
+
function redisExpirationSet(key, ttl_seconds) {
|
|
1427
|
+
const native = getNativeBridge();
|
|
1428
|
+
if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
|
|
1429
|
+
return native.redis_expiration_set(key, ttl_seconds);
|
|
1430
|
+
}
|
|
1431
|
+
function redisExpirationGet(key) {
|
|
1432
|
+
const native = getNativeBridge();
|
|
1433
|
+
if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
|
|
1434
|
+
const result = native.redis_expiration_get(key);
|
|
1435
|
+
try {
|
|
1436
|
+
return JSON.parse(result);
|
|
1437
|
+
} catch {
|
|
1438
|
+
return {
|
|
1439
|
+
key,
|
|
1440
|
+
ttl_seconds: -1,
|
|
1441
|
+
expiration_timestamp: 0,
|
|
1442
|
+
is_persistent: true
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function redisInfo() {
|
|
1447
|
+
const native = getNativeBridge();
|
|
1448
|
+
if (!native?.redis_info) throw new Error("redis_info not available");
|
|
1449
|
+
return native.redis_info();
|
|
1450
|
+
}
|
|
1451
|
+
function redisMonitor() {
|
|
1452
|
+
const native = getNativeBridge();
|
|
1453
|
+
if (!native?.redis_monitor) throw new Error("redis_monitor not available");
|
|
1454
|
+
return native.redis_monitor();
|
|
1455
|
+
}
|
|
1456
|
+
function redisCacheSize() {
|
|
1457
|
+
const native = getNativeBridge();
|
|
1458
|
+
if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
|
|
1459
|
+
return native.redis_cache_size();
|
|
1460
|
+
}
|
|
1461
|
+
function redisCacheKeyCount() {
|
|
1462
|
+
const native = getNativeBridge();
|
|
1463
|
+
if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
|
|
1464
|
+
return native.redis_cache_key_count();
|
|
1465
|
+
}
|
|
1466
|
+
function redisCacheClear() {
|
|
1467
|
+
const native = getNativeBridge();
|
|
1468
|
+
if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
|
|
1469
|
+
return native.redis_cache_clear();
|
|
1470
|
+
}
|
|
1471
|
+
function redisCacheHitRate() {
|
|
1472
|
+
const native = getNativeBridge();
|
|
1473
|
+
if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
|
|
1474
|
+
return native.redis_cache_hit_rate();
|
|
1475
|
+
}
|
|
1476
|
+
function redisEnablePersistence(mode) {
|
|
1477
|
+
const native = getNativeBridge();
|
|
1478
|
+
if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
|
|
1479
|
+
return native.redis_enable_persistence(mode);
|
|
1480
|
+
}
|
|
1481
|
+
function redisDisablePersistence() {
|
|
1482
|
+
const native = getNativeBridge();
|
|
1483
|
+
if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
|
|
1484
|
+
return native.redis_disable_persistence();
|
|
1485
|
+
}
|
|
1486
|
+
function redisSnapshot() {
|
|
1487
|
+
const native = getNativeBridge();
|
|
1488
|
+
if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
|
|
1489
|
+
return native.redis_snapshot();
|
|
1490
|
+
}
|
|
1491
|
+
function redisMemoryStats() {
|
|
1492
|
+
const native = getNativeBridge();
|
|
1493
|
+
if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
|
|
1494
|
+
return native.redis_memory_stats();
|
|
1495
|
+
}
|
|
1496
|
+
function redisOptimizeMemory() {
|
|
1497
|
+
const native = getNativeBridge();
|
|
1498
|
+
if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
|
|
1499
|
+
return native.redis_optimize_memory();
|
|
1500
|
+
}
|
|
1501
|
+
function redisSetEvictionPolicy(policy) {
|
|
1502
|
+
const native = getNativeBridge();
|
|
1503
|
+
if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
|
|
1504
|
+
return native.redis_set_eviction_policy(policy);
|
|
1505
|
+
}
|
|
1506
|
+
function redisGetEvictionPolicy() {
|
|
1507
|
+
const native = getNativeBridge();
|
|
1508
|
+
if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
|
|
1509
|
+
return native.redis_get_eviction_policy();
|
|
1510
|
+
}
|
|
1511
|
+
function redisReplicate(target_host, target_port) {
|
|
1512
|
+
const native = getNativeBridge();
|
|
1513
|
+
if (!native?.redis_replicate) throw new Error("redis_replicate not available");
|
|
1514
|
+
return native.redis_replicate(target_host, target_port);
|
|
1515
|
+
}
|
|
1516
|
+
function redisReplicationStatus() {
|
|
1517
|
+
const native = getNativeBridge();
|
|
1518
|
+
if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
|
|
1519
|
+
return native.redis_replication_status();
|
|
1520
|
+
}
|
|
1521
|
+
function redisCacheSync(peers) {
|
|
1522
|
+
const native = getNativeBridge();
|
|
1523
|
+
if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
|
|
1524
|
+
return native.redis_cache_sync(peers);
|
|
1525
|
+
}
|
|
1526
|
+
function redisEnableCacheWarming(key_pattern) {
|
|
1527
|
+
const native = getNativeBridge();
|
|
1528
|
+
if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
|
|
1529
|
+
return native.redis_enable_cache_warming(key_pattern);
|
|
1530
|
+
}
|
|
1531
|
+
function redisDisableCacheWarming() {
|
|
1532
|
+
const native = getNativeBridge();
|
|
1533
|
+
if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
|
|
1534
|
+
return native.redis_disable_cache_warming();
|
|
1535
|
+
}
|
|
1536
|
+
function redisDiagnose() {
|
|
1537
|
+
const native = getNativeBridge();
|
|
1538
|
+
if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
|
|
1539
|
+
return native.redis_diagnose();
|
|
1540
|
+
}
|
|
1541
|
+
var init_redisNative = __esm({
|
|
1542
|
+
"packages/domain/compiler/src/redisNative.ts"() {
|
|
1543
|
+
init_nativeBridge();
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
// packages/domain/compiler/src/watchSystemNative.ts
|
|
1548
|
+
function startWatch(root_path, patterns) {
|
|
1549
|
+
const native = getNativeBridge();
|
|
1550
|
+
if (!native?.start_watch) throw new Error("start_watch not available");
|
|
1551
|
+
return native.start_watch(root_path, patterns);
|
|
1552
|
+
}
|
|
1553
|
+
function pollWatchEvents(handle, timeout_ms) {
|
|
1554
|
+
const native = getNativeBridge();
|
|
1555
|
+
if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
|
|
1556
|
+
const result = native.poll_watch_events(handle, timeout_ms);
|
|
1557
|
+
try {
|
|
1558
|
+
return JSON.parse(result);
|
|
1559
|
+
} catch {
|
|
1560
|
+
return [];
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
function stopWatch(handle) {
|
|
1564
|
+
const native = getNativeBridge();
|
|
1565
|
+
if (!native?.stop_watch) throw new Error("stop_watch not available");
|
|
1566
|
+
return native.stop_watch(handle);
|
|
1567
|
+
}
|
|
1568
|
+
function watchAddPattern(handle, pattern) {
|
|
1569
|
+
const native = getNativeBridge();
|
|
1570
|
+
if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
|
|
1571
|
+
return native.watch_add_pattern(handle, pattern);
|
|
1572
|
+
}
|
|
1573
|
+
function watchRemovePattern(handle, pattern) {
|
|
1574
|
+
const native = getNativeBridge();
|
|
1575
|
+
if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
|
|
1576
|
+
return native.watch_remove_pattern(handle, pattern);
|
|
1577
|
+
}
|
|
1578
|
+
function watchGetActiveHandles() {
|
|
1579
|
+
const native = getNativeBridge();
|
|
1580
|
+
if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
|
|
1581
|
+
const result = native.watch_get_active_handles();
|
|
1582
|
+
try {
|
|
1583
|
+
return JSON.parse(result);
|
|
1584
|
+
} catch {
|
|
1585
|
+
return [];
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function watchClearAll() {
|
|
1589
|
+
const native = getNativeBridge();
|
|
1590
|
+
if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
|
|
1591
|
+
return native.watch_clear_all();
|
|
1592
|
+
}
|
|
1593
|
+
function watchEventTypeToString(event_type_code) {
|
|
1594
|
+
const native = getNativeBridge();
|
|
1595
|
+
if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
|
|
1596
|
+
return native.watch_event_type_to_string(event_type_code);
|
|
1597
|
+
}
|
|
1598
|
+
function isWatchRunning(handle) {
|
|
1599
|
+
const native = getNativeBridge();
|
|
1600
|
+
if (!native?.is_watch_running) throw new Error("is_watch_running not available");
|
|
1601
|
+
return native.is_watch_running(handle);
|
|
1602
|
+
}
|
|
1603
|
+
function getWatchStats() {
|
|
1604
|
+
const native = getNativeBridge();
|
|
1605
|
+
if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
|
|
1606
|
+
const result = native.get_watch_stats();
|
|
1607
|
+
try {
|
|
1608
|
+
return JSON.parse(result);
|
|
1609
|
+
} catch {
|
|
1610
|
+
return {
|
|
1611
|
+
active_watchers: 0,
|
|
1612
|
+
total_events: 0,
|
|
1613
|
+
events_this_second: 0,
|
|
1614
|
+
average_latency_ms: 0,
|
|
1615
|
+
largest_batch_size: 0
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
function watchPause(handle) {
|
|
1620
|
+
const native = getNativeBridge();
|
|
1621
|
+
if (!native?.watch_pause) throw new Error("watch_pause not available");
|
|
1622
|
+
return native.watch_pause(handle);
|
|
1623
|
+
}
|
|
1624
|
+
function watchResume(handle) {
|
|
1625
|
+
const native = getNativeBridge();
|
|
1626
|
+
if (!native?.watch_resume) throw new Error("watch_resume not available");
|
|
1627
|
+
return native.watch_resume(handle);
|
|
1628
|
+
}
|
|
1629
|
+
function scanCacheOptimizations() {
|
|
1630
|
+
const native = getNativeBridge();
|
|
1631
|
+
if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
|
|
1632
|
+
return native.scan_cache_optimizations();
|
|
1633
|
+
}
|
|
1634
|
+
function getPluginHooks() {
|
|
1635
|
+
const native = getNativeBridge();
|
|
1636
|
+
if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
|
|
1637
|
+
const result = native.get_plugin_hooks();
|
|
1638
|
+
try {
|
|
1639
|
+
return JSON.parse(result);
|
|
1640
|
+
} catch {
|
|
1641
|
+
return [];
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
function registerPluginHook(hook_name, handler_id) {
|
|
1645
|
+
const native = getNativeBridge();
|
|
1646
|
+
if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
|
|
1647
|
+
return native.register_plugin_hook(hook_name, handler_id);
|
|
1648
|
+
}
|
|
1649
|
+
function unregisterPluginHook(hook_name, handler_id) {
|
|
1650
|
+
const native = getNativeBridge();
|
|
1651
|
+
if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
|
|
1652
|
+
return native.unregister_plugin_hook(hook_name, handler_id);
|
|
1653
|
+
}
|
|
1654
|
+
function emitPluginHook(hook_name, data_json) {
|
|
1655
|
+
const native = getNativeBridge();
|
|
1656
|
+
if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
|
|
1657
|
+
return native.emit_plugin_hook(hook_name, data_json);
|
|
1658
|
+
}
|
|
1659
|
+
function getCompilationMetrics() {
|
|
1660
|
+
const native = getNativeBridge();
|
|
1661
|
+
if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
|
|
1662
|
+
return native.get_compilation_metrics();
|
|
1663
|
+
}
|
|
1664
|
+
function resetCompilationMetrics() {
|
|
1665
|
+
const native = getNativeBridge();
|
|
1666
|
+
if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
|
|
1667
|
+
return native.reset_compilation_metrics();
|
|
1668
|
+
}
|
|
1669
|
+
function validateCssOutput(css) {
|
|
1670
|
+
const native = getNativeBridge();
|
|
1671
|
+
if (!native?.validate_css_output) throw new Error("validate_css_output not available");
|
|
1672
|
+
return native.validate_css_output(css);
|
|
1673
|
+
}
|
|
1674
|
+
function getCompilerDiagnostics() {
|
|
1675
|
+
const native = getNativeBridge();
|
|
1676
|
+
if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
|
|
1677
|
+
return native.get_compiler_diagnostics();
|
|
1678
|
+
}
|
|
1679
|
+
var init_watchSystemNative = __esm({
|
|
1680
|
+
"packages/domain/compiler/src/watchSystemNative.ts"() {
|
|
1681
|
+
init_nativeBridge();
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
function _layoutClassesToCss(classes) {
|
|
1685
|
+
const native = getNativeBridge();
|
|
1686
|
+
if (!native?.layoutClassesToCss) {
|
|
1687
|
+
throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
|
|
1688
|
+
}
|
|
1689
|
+
return native.layoutClassesToCss(classes);
|
|
1690
|
+
}
|
|
1691
|
+
function _hashContainer(tag, containerJson, name) {
|
|
1692
|
+
const sortedKey = tag + (name ?? "") + containerJson;
|
|
1693
|
+
const native = getNativeBridge();
|
|
1694
|
+
if (!native?.hashContent) {
|
|
1695
|
+
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
1696
|
+
}
|
|
1697
|
+
return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
1698
|
+
}
|
|
1699
|
+
function extractContainerCssFromSource(source) {
|
|
1700
|
+
const native = getNativeBridge();
|
|
1701
|
+
if (!native?.extractTwContainerConfigs) {
|
|
1702
|
+
throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
|
|
1703
|
+
}
|
|
1704
|
+
const configs = native.extractTwContainerConfigs(source);
|
|
1705
|
+
const rules = [];
|
|
1706
|
+
for (const cfg of configs) {
|
|
1707
|
+
const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
|
|
1708
|
+
for (const { key, classes } of cfg.breakpoints) {
|
|
1709
|
+
const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
|
|
1710
|
+
const css = _layoutClassesToCss(classes);
|
|
1711
|
+
if (!css) continue;
|
|
1712
|
+
const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
1713
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
return rules.join("\n");
|
|
1717
|
+
}
|
|
1718
|
+
var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
1719
|
+
var init_src2 = __esm({
|
|
1720
|
+
"packages/domain/compiler/src/index.ts"() {
|
|
1721
|
+
init_nativeBridge();
|
|
1722
|
+
init_cssGeneratorNative();
|
|
1723
|
+
init_scannerNative();
|
|
1724
|
+
init_analyzerNative();
|
|
1725
|
+
init_compilationNative();
|
|
1726
|
+
init_cacheNative();
|
|
1727
|
+
init_themeResolutionNative();
|
|
1728
|
+
init_streamingNative();
|
|
1729
|
+
init_cssCompilationNative();
|
|
1730
|
+
init_idRegistryNative();
|
|
1731
|
+
init_redisNative();
|
|
1732
|
+
init_watchSystemNative();
|
|
1733
|
+
transformSource = (source, opts) => {
|
|
1734
|
+
const native = getNativeBridge();
|
|
1735
|
+
if (!native?.transformSource) {
|
|
1736
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
1737
|
+
}
|
|
1738
|
+
const result = native.transformSource(source, opts);
|
|
1739
|
+
if (!result) {
|
|
1740
|
+
throw new Error("FATAL: transformSource returned null");
|
|
1741
|
+
}
|
|
1742
|
+
return result;
|
|
1743
|
+
};
|
|
1744
|
+
hasTwUsage = (source) => {
|
|
1745
|
+
const native = getNativeBridge();
|
|
1746
|
+
if (!native?.hasTwUsage) {
|
|
1747
|
+
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
1748
|
+
}
|
|
1749
|
+
return native.hasTwUsage(source);
|
|
1750
|
+
};
|
|
1751
|
+
isAlreadyTransformed = (source) => {
|
|
1752
|
+
const native = getNativeBridge();
|
|
1753
|
+
if (!native?.isAlreadyTransformed) {
|
|
1754
|
+
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
1755
|
+
}
|
|
1756
|
+
return native.isAlreadyTransformed(source);
|
|
1757
|
+
};
|
|
1758
|
+
shouldProcess = (source) => {
|
|
1759
|
+
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
1760
|
+
};
|
|
1761
|
+
compileCssFromClasses = (classes, prefix) => {
|
|
1762
|
+
const native = getNativeBridge();
|
|
1763
|
+
if (!native?.transformSource) {
|
|
1764
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
1765
|
+
}
|
|
1766
|
+
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
1767
|
+
if (!result) {
|
|
1768
|
+
throw new Error("FATAL: transformSource returned null");
|
|
1769
|
+
}
|
|
1770
|
+
return result;
|
|
1771
|
+
};
|
|
1772
|
+
buildStyleTag = (classes) => {
|
|
1773
|
+
const result = compileCssFromClasses(classes);
|
|
1774
|
+
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
1775
|
+
};
|
|
1776
|
+
compileCssNative = (classes, prefix = null) => {
|
|
1777
|
+
return compileCssFromClasses(classes, prefix);
|
|
1778
|
+
};
|
|
1779
|
+
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
1780
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
1781
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
1782
|
+
return result.css;
|
|
1783
|
+
};
|
|
1784
|
+
extractAllClasses = (source) => {
|
|
1785
|
+
const native = getNativeBridge();
|
|
1786
|
+
if (!native?.extractAllClasses) {
|
|
1787
|
+
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
1788
|
+
}
|
|
1789
|
+
return native.extractAllClasses(source) || [];
|
|
1790
|
+
};
|
|
1791
|
+
extractClassesFromSource = (source) => {
|
|
1792
|
+
const native = getNativeBridge();
|
|
1793
|
+
if (!native?.extractClassesFromSource) {
|
|
1794
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1795
|
+
}
|
|
1796
|
+
const result = native.extractClassesFromSource(source);
|
|
1797
|
+
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
1798
|
+
};
|
|
1799
|
+
astExtractClasses = (source, _filename) => {
|
|
1800
|
+
const native = getNativeBridge();
|
|
1801
|
+
if (!native?.extractClassesFromSource) {
|
|
1802
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1803
|
+
}
|
|
1804
|
+
return native.extractClassesFromSource(source) || [];
|
|
1805
|
+
};
|
|
1806
|
+
parseClasses = (raw) => {
|
|
1807
|
+
const native = getNativeBridge();
|
|
1808
|
+
if (!native?.parseClasses) {
|
|
1809
|
+
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
1810
|
+
}
|
|
1811
|
+
return native.parseClasses(raw) || [];
|
|
1812
|
+
};
|
|
1813
|
+
normalizeClasses = (raw) => {
|
|
1814
|
+
const result = normalizeAndDedupClasses(raw);
|
|
1815
|
+
return result?.normalized || "";
|
|
1816
|
+
};
|
|
1817
|
+
mergeClassesStatic = (classes) => {
|
|
1818
|
+
const result = normalizeAndDedupClasses(classes);
|
|
1819
|
+
return result?.normalized || "";
|
|
1820
|
+
};
|
|
1821
|
+
normalizeAndDedupClasses = (raw) => {
|
|
1822
|
+
const native = getNativeBridge();
|
|
1823
|
+
if (!native?.normalizeAndDedupClasses) {
|
|
1824
|
+
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
1825
|
+
}
|
|
1826
|
+
const result = native.normalizeAndDedupClasses(raw);
|
|
1827
|
+
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
1828
|
+
};
|
|
1829
|
+
eliminateDeadCss = (css, deadClasses) => {
|
|
1830
|
+
const native = getNativeBridge();
|
|
1831
|
+
if (!native?.eliminateDeadCss) {
|
|
1832
|
+
throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
|
|
1833
|
+
}
|
|
1834
|
+
return native.eliminateDeadCss(css, Array.from(deadClasses));
|
|
1835
|
+
};
|
|
1836
|
+
findDeadVariants = (variantConfig, usage) => {
|
|
1837
|
+
const unused = [];
|
|
1838
|
+
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
1839
|
+
for (const component of configs) {
|
|
1840
|
+
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
1841
|
+
const variants = component.variants;
|
|
1842
|
+
for (const [key, values] of Object.entries(variants)) {
|
|
1843
|
+
for (const [value] of Object.entries(values)) {
|
|
1844
|
+
if (!componentUsage.has(`${key}:${value}`)) {
|
|
1845
|
+
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
return { unusedCount: unused.length, unused };
|
|
1851
|
+
};
|
|
1852
|
+
runElimination = (css, scanResult) => {
|
|
1853
|
+
const native = getNativeBridge();
|
|
1854
|
+
if (!native?.detectDeadCode) {
|
|
1855
|
+
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
1856
|
+
}
|
|
1857
|
+
const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
|
|
1858
|
+
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
1859
|
+
};
|
|
1860
|
+
optimizeCss = (css) => {
|
|
1861
|
+
const native = getNativeBridge();
|
|
1862
|
+
if (!native?.optimizeCss) {
|
|
1863
|
+
throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
|
|
1864
|
+
}
|
|
1865
|
+
return native.optimizeCss(css);
|
|
1866
|
+
};
|
|
1867
|
+
scanProjectUsage = (dirs, cwd) => {
|
|
1868
|
+
const files = dirs.map((dir) => path__default.resolve(cwd, dir));
|
|
1869
|
+
const results = batchExtractClasses(files) || [];
|
|
1870
|
+
const combined = {};
|
|
1871
|
+
for (const result of results) {
|
|
1872
|
+
if (result.ok && result.classes) {
|
|
1873
|
+
for (const cls of result.classes) {
|
|
1874
|
+
if (!combined[cls]) combined[cls] = {};
|
|
1875
|
+
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return combined;
|
|
1880
|
+
};
|
|
1881
|
+
extractComponentUsage = (source) => {
|
|
1882
|
+
const native = getNativeBridge();
|
|
1883
|
+
if (!native?.extractComponentUsage) {
|
|
1884
|
+
throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
|
|
1885
|
+
}
|
|
1886
|
+
return native.extractComponentUsage(source) || [];
|
|
1887
|
+
};
|
|
1888
|
+
diffClassLists = (previous, current) => {
|
|
1889
|
+
const native = getNativeBridge();
|
|
1890
|
+
if (!native?.diffClassLists) {
|
|
1891
|
+
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
1892
|
+
}
|
|
1893
|
+
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
1894
|
+
};
|
|
1895
|
+
batchExtractClasses = (filePaths) => {
|
|
1896
|
+
const native = getNativeBridge();
|
|
1897
|
+
if (!native?.batchExtractClasses) {
|
|
1898
|
+
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
1899
|
+
}
|
|
1900
|
+
return native.batchExtractClasses(filePaths) || [];
|
|
1901
|
+
};
|
|
1902
|
+
checkAgainstSafelist = (classes, safelist) => {
|
|
1903
|
+
const native = getNativeBridge();
|
|
1904
|
+
if (!native?.checkAgainstSafelist) {
|
|
1905
|
+
throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
|
|
1906
|
+
}
|
|
1907
|
+
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
1908
|
+
};
|
|
1909
|
+
hoistComponents = (source) => {
|
|
1910
|
+
const native = getNativeBridge();
|
|
1911
|
+
if (!native?.hoistComponents) {
|
|
1912
|
+
throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
|
|
1913
|
+
}
|
|
1914
|
+
return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
|
|
1915
|
+
};
|
|
1916
|
+
compileVariantTable = (configJson) => {
|
|
1917
|
+
const native = getNativeBridge();
|
|
1918
|
+
if (!native?.compileVariantTable) {
|
|
1919
|
+
throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
|
|
1920
|
+
}
|
|
1921
|
+
return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
|
|
1922
|
+
};
|
|
1923
|
+
compileVariants = (componentId, config) => {
|
|
1924
|
+
return compileVariantTable(JSON.stringify({ componentId, ...config }));
|
|
1925
|
+
};
|
|
1926
|
+
classifyAndSortClasses = (classes) => {
|
|
1927
|
+
const native = getNativeBridge();
|
|
1928
|
+
if (!native?.classifyAndSortClasses) {
|
|
1929
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1930
|
+
}
|
|
1931
|
+
return native.classifyAndSortClasses(classes) || [];
|
|
1932
|
+
};
|
|
1933
|
+
mergeCssDeclarations = (cssChunks) => {
|
|
1934
|
+
const native = getNativeBridge();
|
|
1935
|
+
if (!native?.mergeCssDeclarations) {
|
|
1936
|
+
throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
|
|
1937
|
+
}
|
|
1938
|
+
return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
|
|
1939
|
+
};
|
|
1940
|
+
analyzeClassUsage = (classes, scanResultJson, css) => {
|
|
1941
|
+
const native = getNativeBridge();
|
|
1942
|
+
if (!native?.analyzeClassUsage) {
|
|
1943
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
1944
|
+
}
|
|
1945
|
+
return native.analyzeClassUsage(classes, scanResultJson, css) || [];
|
|
1946
|
+
};
|
|
1947
|
+
analyzeRsc = (source, filename) => {
|
|
1948
|
+
const native = getNativeBridge();
|
|
1949
|
+
if (!native?.analyzeRsc) {
|
|
1950
|
+
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
1951
|
+
}
|
|
1952
|
+
return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
|
|
1953
|
+
};
|
|
1954
|
+
analyzeFile = (source, filename) => {
|
|
1955
|
+
const rsc = analyzeRsc(source, filename);
|
|
1956
|
+
return {
|
|
1957
|
+
isServer: rsc?.isServer ?? true,
|
|
1958
|
+
needsClientDirective: rsc?.needsClientDirective ?? false,
|
|
1959
|
+
clientReasons: rsc?.clientReasons ?? [],
|
|
1960
|
+
interactiveClasses: [],
|
|
1961
|
+
canStaticResolveVariants: true
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1964
|
+
analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
|
|
1965
|
+
return { resolved: {}, dynamic: [] };
|
|
1966
|
+
};
|
|
1967
|
+
injectClientDirective = (source) => {
|
|
1968
|
+
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
1969
|
+
return '"use client";\n' + source;
|
|
1970
|
+
}
|
|
1971
|
+
return source;
|
|
1972
|
+
};
|
|
1973
|
+
injectServerOnlyComment = (source) => {
|
|
1974
|
+
return `/* @server-only */
|
|
1975
|
+
${source}`;
|
|
1976
|
+
};
|
|
1977
|
+
analyzeClasses = (filesJson, cwd, flags) => {
|
|
1978
|
+
const native = getNativeBridge();
|
|
1979
|
+
if (!native?.analyzeClasses) {
|
|
1980
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
1981
|
+
}
|
|
1982
|
+
return native.analyzeClasses(filesJson, cwd, flags);
|
|
1983
|
+
};
|
|
1984
|
+
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
1985
|
+
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
1986
|
+
const allClasses = Object.keys(classes).sort();
|
|
1987
|
+
if (outputPath) {
|
|
1988
|
+
fs__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
1989
|
+
}
|
|
1990
|
+
return allClasses;
|
|
1991
|
+
};
|
|
1992
|
+
loadSafelist = (safelistPath) => {
|
|
1993
|
+
try {
|
|
1994
|
+
const content = fs__default.readFileSync(safelistPath, "utf-8");
|
|
1995
|
+
return JSON.parse(content);
|
|
1996
|
+
} catch {
|
|
1997
|
+
return [];
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
2001
|
+
const configFiles = [
|
|
2002
|
+
"tailwind.config.ts",
|
|
2003
|
+
"tailwind.config.js",
|
|
2004
|
+
"tailwind.config.mjs",
|
|
2005
|
+
"tailwind.config.cjs"
|
|
2006
|
+
];
|
|
2007
|
+
for (const file of configFiles) {
|
|
2008
|
+
const fullPath = path__default.join(cwd, file);
|
|
2009
|
+
if (fs__default.existsSync(fullPath)) {
|
|
2010
|
+
const mod = __require(fullPath);
|
|
2011
|
+
return mod.default || mod;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
return {};
|
|
2015
|
+
};
|
|
2016
|
+
getContentPaths = (cwd = process.cwd()) => {
|
|
2017
|
+
return {
|
|
2018
|
+
content: [
|
|
2019
|
+
path__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
2020
|
+
path__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
2021
|
+
path__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
2022
|
+
]
|
|
2023
|
+
};
|
|
2024
|
+
};
|
|
2025
|
+
_CONTAINER_BREAKPOINTS = {
|
|
2026
|
+
xs: "240px",
|
|
2027
|
+
sm: "320px",
|
|
2028
|
+
md: "640px",
|
|
2029
|
+
lg: "1024px",
|
|
2030
|
+
xl: "1280px",
|
|
2031
|
+
"2xl": "1536px"
|
|
2032
|
+
};
|
|
2033
|
+
runLoaderTransform = (ctx) => {
|
|
2034
|
+
const { filepath, source, options } = ctx;
|
|
2035
|
+
const result = transformSource(source, { filename: filepath, ...options });
|
|
2036
|
+
let staticCss;
|
|
2037
|
+
try {
|
|
2038
|
+
const cssChunks = [];
|
|
2039
|
+
const stateRules = extractAndGenerateStateCss(source, filepath);
|
|
2040
|
+
if (stateRules.length > 0) {
|
|
2041
|
+
cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
|
|
2042
|
+
}
|
|
2043
|
+
const containerCss = extractContainerCssFromSource(source);
|
|
2044
|
+
if (containerCss) cssChunks.push(containerCss);
|
|
2045
|
+
const combined = cssChunks.join("\n").trim();
|
|
2046
|
+
if (combined) staticCss = combined;
|
|
2047
|
+
} catch {
|
|
2048
|
+
}
|
|
2049
|
+
return {
|
|
2050
|
+
code: result?.code || "",
|
|
2051
|
+
changed: result?.changed || false,
|
|
2052
|
+
classes: result?.classes || [],
|
|
2053
|
+
staticCss
|
|
2054
|
+
};
|
|
2055
|
+
};
|
|
2056
|
+
shouldSkipFile = (filepath) => {
|
|
2057
|
+
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
2058
|
+
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
2059
|
+
for (const p of SKIP_PATHS) {
|
|
2060
|
+
if (filepath.includes(p)) return true;
|
|
2061
|
+
}
|
|
2062
|
+
for (const ext of skipExtensions) {
|
|
2063
|
+
if (filepath.endsWith(ext)) return true;
|
|
2064
|
+
}
|
|
2065
|
+
return false;
|
|
2066
|
+
};
|
|
2067
|
+
fileToRoute = (filepath) => {
|
|
2068
|
+
const normalized = filepath.replace(/\\/g, "/");
|
|
2069
|
+
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
2070
|
+
return "__global";
|
|
2071
|
+
}
|
|
2072
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
2073
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
2074
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
2075
|
+
if (rootPage) return "/";
|
|
2076
|
+
return null;
|
|
2077
|
+
};
|
|
2078
|
+
getAllRoutes = () => {
|
|
2079
|
+
const native = getNativeBridge();
|
|
2080
|
+
if (!native?.analyzeClasses) {
|
|
2081
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
2082
|
+
}
|
|
2083
|
+
return ["/", "__global"];
|
|
2084
|
+
};
|
|
2085
|
+
getRouteClasses = (_route) => /* @__PURE__ */ new Set();
|
|
2086
|
+
registerFileClasses = (_filepath, _classes) => {
|
|
2087
|
+
};
|
|
2088
|
+
registerGlobalClasses = (_classes) => {
|
|
2089
|
+
};
|
|
2090
|
+
_incrementalEngineInstance = null;
|
|
2091
|
+
getIncrementalEngine = () => {
|
|
2092
|
+
if (!_incrementalEngineInstance) {
|
|
2093
|
+
_incrementalEngineInstance = new IncrementalEngine();
|
|
2094
|
+
}
|
|
2095
|
+
return _incrementalEngineInstance;
|
|
2096
|
+
};
|
|
2097
|
+
resetIncrementalEngine = () => {
|
|
2098
|
+
_incrementalEngineInstance = null;
|
|
2099
|
+
};
|
|
2100
|
+
IncrementalEngine = class {
|
|
2101
|
+
compile(source) {
|
|
2102
|
+
return transformSource(source);
|
|
2103
|
+
}
|
|
2104
|
+
};
|
|
2105
|
+
getBucketEngine = () => {
|
|
2106
|
+
const native = getNativeBridge();
|
|
2107
|
+
if (!native?.classifyAndSortClasses) {
|
|
2108
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2109
|
+
}
|
|
2110
|
+
return {
|
|
2111
|
+
add: (className) => className,
|
|
2112
|
+
get: (_bucket) => []
|
|
2113
|
+
};
|
|
2114
|
+
};
|
|
2115
|
+
resetBucketEngine = () => {
|
|
2116
|
+
};
|
|
2117
|
+
BucketEngine = class {
|
|
2118
|
+
add(className) {
|
|
2119
|
+
return className;
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
classifyNode = (_node) => {
|
|
2123
|
+
const native = getNativeBridge();
|
|
2124
|
+
if (!native?.classifyAndSortClasses) {
|
|
2125
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2126
|
+
}
|
|
2127
|
+
return "unknown";
|
|
2128
|
+
};
|
|
2129
|
+
detectConflicts = (_classes) => {
|
|
2130
|
+
const native = getNativeBridge();
|
|
2131
|
+
if (!native?.analyzeClassUsage) {
|
|
2132
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
2133
|
+
}
|
|
2134
|
+
return [];
|
|
2135
|
+
};
|
|
2136
|
+
bucketSort = (classes) => {
|
|
2137
|
+
return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
|
|
2138
|
+
};
|
|
2139
|
+
extractTwStateConfigs = (source, filename) => {
|
|
2140
|
+
const native = getNativeBridge();
|
|
2141
|
+
if (!native?.extractTwStateConfigs) {
|
|
2142
|
+
throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
|
|
2143
|
+
}
|
|
2144
|
+
return native.extractTwStateConfigs(source, filename);
|
|
2145
|
+
};
|
|
2146
|
+
generateStaticStateCss = (inputs, resolvedCss = null) => {
|
|
2147
|
+
const native = getNativeBridge();
|
|
2148
|
+
if (!native?.generateStaticStateCss) {
|
|
2149
|
+
throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
|
|
2150
|
+
}
|
|
2151
|
+
return native.generateStaticStateCss(inputs, resolvedCss);
|
|
2152
|
+
};
|
|
2153
|
+
extractAndGenerateStateCss = (source, filename) => {
|
|
2154
|
+
const native = getNativeBridge();
|
|
2155
|
+
if (!native?.extractAndGenerateStateCss) {
|
|
2156
|
+
const configs = extractTwStateConfigs(source, filename);
|
|
2157
|
+
if (configs.length === 0) return [];
|
|
2158
|
+
return generateStaticStateCss(
|
|
2159
|
+
configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
|
|
2160
|
+
);
|
|
2161
|
+
}
|
|
2162
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
|
|
2167
|
+
// src/umbrella/compiler.ts
|
|
2168
|
+
init_src2();
|
|
735
2169
|
|
|
736
|
-
export { BucketEngine, IncrementalEngine, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode, compileCssFromClasses, compileCssNative, compileVariantTable, compileVariants, detectConflicts, diffClassLists, eliminateDeadCss, extractAllClasses, extractClassesFromSource, extractComponentUsage, fileToRoute, findDeadVariants, generateCssForClasses, generateSafelist, getAllRoutes, getBucketEngine, getContentPaths, getIncrementalEngine, getNativeBridge, getRouteClasses, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, isAlreadyTransformed, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, normalizeAndDedupClasses, normalizeClasses, optimizeCss, parseClasses, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetIncrementalEngine, resetNativeBridgeCache, runElimination, runLoaderTransform, scanProjectUsage, shouldProcess, shouldSkipFile, transformSource };
|
|
2170
|
+
export { BucketEngine, IncrementalEngine, adaptNativeResult, analyzeClassUsage, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRsc, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClasses, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTable, compileVariantTableNative, compileVariants, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats2 as getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getNativeBridge, getPluginHooks, getRouteClasses, getWatchStats, hasTwUsage, hashContent, hoistComponents, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCss, optimizeCssNative, parseAtomicClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCompilationMetrics, resetIncrementalEngine, resetNativeBridgeCache, resolveCascade, resolveClassNames, resolveConflictGroup, resolveSimpleVariants, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|
|
737
2171
|
//# sourceMappingURL=compiler.mjs.map
|
|
738
2172
|
//# sourceMappingURL=compiler.mjs.map
|