tailwind-styled-v4 5.0.37 → 5.0.38
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/analyzer.js +213 -161
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +118 -82
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.js +131 -87
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +28 -14
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +105 -68
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +40 -13
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +577 -426
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +466 -304
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.js +826 -508
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +287 -29
- package/dist/compiler.mjs.map +1 -1
- package/dist/dashboard.js +71 -41
- package/dist/dashboard.js.map +1 -1
- package/dist/dashboard.mjs +12 -6
- package/dist/dashboard.mjs.map +1 -1
- package/dist/devtools.js +333 -289
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +26 -11
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.js +679 -502
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +467 -307
- package/dist/engine.mjs.map +1 -1
- package/dist/index.d.mts +145 -319
- package/dist/index.d.ts +145 -319
- package/dist/index.js +1329 -7441
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1266 -7385
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +318 -243
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +256 -181
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.js +93 -49
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +26 -6
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +67 -40
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +14 -10
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.js +101 -53
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +30 -6
- package/dist/plugin.mjs.map +1 -1
- package/dist/preset.js +47 -15
- package/dist/preset.js.map +1 -1
- package/dist/preset.mjs +13 -5
- package/dist/preset.mjs.map +1 -1
- package/dist/rspack.js +82 -50
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +20 -12
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime-css.js +62 -24
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +15 -7
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/runtime.js +97 -44
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +31 -8
- package/dist/runtime.mjs.map +1 -1
- package/dist/scanner.js +163 -120
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +67 -39
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.js +441 -295
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +253 -122
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.js +39 -10
- package/dist/storybook-addon.js.map +1 -1
- package/dist/storybook-addon.mjs +8 -3
- package/dist/storybook-addon.mjs.map +1 -1
- package/dist/svelte.js +88 -64
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +28 -13
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +68 -37
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +8 -7
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +55 -18
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +16 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.js +131 -74
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +42 -13
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +150 -116
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +124 -81
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +560 -421
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +460 -302
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +561 -446
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +433 -321
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +95 -70
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +30 -14
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +110 -78
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +45 -17
- package/dist/webpackLoader.mjs.map +1 -1
- package/package.json +3 -1
package/dist/vite.mjs
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
|
-
import * as fs13 from 'fs';
|
|
4
|
-
import fs13__default from 'fs';
|
|
5
|
-
import * as path9 from 'path';
|
|
6
|
-
import path9__default from 'path';
|
|
7
|
-
import { createHash } from 'crypto';
|
|
8
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
9
|
-
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
|
|
10
|
-
import { availableParallelism } from 'os';
|
|
11
|
-
import 'perf_hooks';
|
|
12
|
-
|
|
13
1
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
14
2
|
var __defProp = Object.defineProperty;
|
|
15
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -130,6 +118,7 @@ function getPipelinePercentages(metrics) {
|
|
|
130
118
|
}
|
|
131
119
|
var init_trace = __esm({
|
|
132
120
|
"packages/domain/shared/src/trace.ts"() {
|
|
121
|
+
"use strict";
|
|
133
122
|
}
|
|
134
123
|
});
|
|
135
124
|
|
|
@@ -144,6 +133,7 @@ function formatErrorCode(code) {
|
|
|
144
133
|
var ERROR_CODES, ERROR_SUGGESTIONS;
|
|
145
134
|
var init_error_codes = __esm({
|
|
146
135
|
"packages/domain/shared/src/error-codes.ts"() {
|
|
136
|
+
"use strict";
|
|
147
137
|
ERROR_CODES = {
|
|
148
138
|
// E0xx — Native binding
|
|
149
139
|
NATIVE_NOT_FOUND: "E001",
|
|
@@ -210,8 +200,12 @@ function isTailwindV4() {
|
|
|
210
200
|
}
|
|
211
201
|
var init_compatibility = __esm({
|
|
212
202
|
"packages/domain/shared/src/compatibility.ts"() {
|
|
203
|
+
"use strict";
|
|
213
204
|
}
|
|
214
205
|
});
|
|
206
|
+
|
|
207
|
+
// packages/domain/shared/src/native-schemas.ts
|
|
208
|
+
import { z } from "zod";
|
|
215
209
|
function safeParseNative(schema, data, fallback) {
|
|
216
210
|
const result = schema.safeParse(data);
|
|
217
211
|
return result.success ? result.data : fallback;
|
|
@@ -227,9 +221,10 @@ function parseNative(schema, data, context) {
|
|
|
227
221
|
}
|
|
228
222
|
return result.data;
|
|
229
223
|
}
|
|
230
|
-
var NativeScanFileSchema, NativeScanResultSchema, NativeClassUsageSchema, NativeAnalyzerReportSchema, NativeTransformResultSchema, NativeCssCompileResultSchema, NativeWatchResultSchema, NativeCacheEntrySchema, NativeCacheReadResultSchema;
|
|
224
|
+
var NativeScanFileSchema, NativeScanResultSchema, NativeClassUsageSchema, NativeAnalyzerReportSchema, NativeTransformResultSchema, NativeCssCompileResultSchema, NativeWatchEventSchema, NativeWatchResultSchema, NativeCacheEntrySchema, NativeCacheReadResultSchema;
|
|
231
225
|
var init_native_schemas = __esm({
|
|
232
226
|
"packages/domain/shared/src/native-schemas.ts"() {
|
|
227
|
+
"use strict";
|
|
233
228
|
NativeScanFileSchema = z.object({
|
|
234
229
|
file: z.string().min(1, "file path cannot be empty"),
|
|
235
230
|
classes: z.array(z.string()),
|
|
@@ -269,7 +264,7 @@ var init_native_schemas = __esm({
|
|
|
269
264
|
resolvedClasses: z.array(z.string()),
|
|
270
265
|
unresolvedClasses: z.array(z.string()).optional()
|
|
271
266
|
});
|
|
272
|
-
z.object({
|
|
267
|
+
NativeWatchEventSchema = z.object({
|
|
273
268
|
type: z.enum(["change", "unlink", "create"]),
|
|
274
269
|
path: z.string()
|
|
275
270
|
});
|
|
@@ -375,6 +370,7 @@ function resolveNativeNodePath(importMetaUrl, ...relativeSegments) {
|
|
|
375
370
|
var isBrowser, nodeModuleRef, _nodePath, _nodeUrl, _nodeFs;
|
|
376
371
|
var init_esmHelpers = __esm({
|
|
377
372
|
"packages/domain/shared/src/esmHelpers.ts"() {
|
|
373
|
+
"use strict";
|
|
378
374
|
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
379
375
|
nodeModuleRef = null;
|
|
380
376
|
_nodePath = null;
|
|
@@ -425,6 +421,7 @@ function createBuildTimer() {
|
|
|
425
421
|
var RING_BUFFER_SIZE, TelemetryCollector, _globalCollector;
|
|
426
422
|
var init_telemetry = __esm({
|
|
427
423
|
"packages/domain/shared/src/telemetry.ts"() {
|
|
424
|
+
"use strict";
|
|
428
425
|
RING_BUFFER_SIZE = 100;
|
|
429
426
|
TelemetryCollector = class {
|
|
430
427
|
data = [];
|
|
@@ -491,6 +488,9 @@ var init_telemetry = __esm({
|
|
|
491
488
|
_globalCollector = null;
|
|
492
489
|
}
|
|
493
490
|
});
|
|
491
|
+
|
|
492
|
+
// packages/domain/shared/src/configSchemas.ts
|
|
493
|
+
import { z as z2 } from "zod";
|
|
494
494
|
function parseJsonWithSchema(jsonString, schema, sourceName) {
|
|
495
495
|
let parsed;
|
|
496
496
|
try {
|
|
@@ -524,67 +524,68 @@ function parseJsonFileWithSchema(filePath, schema) {
|
|
|
524
524
|
var ScanCacheClassEntrySchema, ScanCacheSchema, TailwindContentItemSchema, TailwindConfigSchema, RegistryPluginEntrySchema, RegistryFileSchema, PackageJsonSchema;
|
|
525
525
|
var init_configSchemas = __esm({
|
|
526
526
|
"packages/domain/shared/src/configSchemas.ts"() {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
527
|
+
"use strict";
|
|
528
|
+
ScanCacheClassEntrySchema = z2.object({
|
|
529
|
+
name: z2.string().min(1),
|
|
530
|
+
usedIn: z2.array(z2.string()),
|
|
531
|
+
risk: z2.enum(["low", "medium", "high"]).default("low"),
|
|
532
|
+
bundleContribution: z2.number().nonnegative().default(0),
|
|
533
|
+
variants: z2.array(z2.string()).default([])
|
|
533
534
|
});
|
|
534
|
-
ScanCacheSchema =
|
|
535
|
-
version:
|
|
536
|
-
generatedAt:
|
|
537
|
-
root:
|
|
538
|
-
classNames:
|
|
539
|
-
totalFiles:
|
|
540
|
-
uniqueCount:
|
|
535
|
+
ScanCacheSchema = z2.object({
|
|
536
|
+
version: z2.string().default("1"),
|
|
537
|
+
generatedAt: z2.string(),
|
|
538
|
+
root: z2.string(),
|
|
539
|
+
classNames: z2.array(ScanCacheClassEntrySchema),
|
|
540
|
+
totalFiles: z2.number().int().nonnegative(),
|
|
541
|
+
uniqueCount: z2.number().int().nonnegative()
|
|
541
542
|
});
|
|
542
|
-
TailwindContentItemSchema =
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
raw:
|
|
546
|
-
extension:
|
|
543
|
+
TailwindContentItemSchema = z2.union([
|
|
544
|
+
z2.string(),
|
|
545
|
+
z2.object({
|
|
546
|
+
raw: z2.string(),
|
|
547
|
+
extension: z2.string().optional()
|
|
547
548
|
}),
|
|
548
|
-
|
|
549
|
-
files:
|
|
550
|
-
transform:
|
|
549
|
+
z2.object({
|
|
550
|
+
files: z2.array(z2.string()),
|
|
551
|
+
transform: z2.record(z2.string(), z2.unknown()).optional()
|
|
551
552
|
})
|
|
552
553
|
]);
|
|
553
|
-
TailwindConfigSchema =
|
|
554
|
-
content:
|
|
555
|
-
theme:
|
|
556
|
-
plugins:
|
|
557
|
-
darkMode:
|
|
558
|
-
prefix:
|
|
559
|
-
safelist:
|
|
560
|
-
blocklist:
|
|
554
|
+
TailwindConfigSchema = z2.object({
|
|
555
|
+
content: z2.array(TailwindContentItemSchema).optional(),
|
|
556
|
+
theme: z2.record(z2.string(), z2.unknown()).optional(),
|
|
557
|
+
plugins: z2.array(z2.unknown()).optional(),
|
|
558
|
+
darkMode: z2.union([z2.literal("class"), z2.literal("media"), z2.literal(false)]).optional(),
|
|
559
|
+
prefix: z2.string().optional(),
|
|
560
|
+
safelist: z2.array(z2.union([z2.string(), z2.object({ pattern: z2.instanceof(RegExp) })])).optional(),
|
|
561
|
+
blocklist: z2.array(z2.string()).optional()
|
|
561
562
|
}).passthrough();
|
|
562
|
-
RegistryPluginEntrySchema =
|
|
563
|
-
name:
|
|
564
|
-
description:
|
|
565
|
-
version:
|
|
566
|
-
tags:
|
|
567
|
-
official:
|
|
568
|
-
docs:
|
|
569
|
-
install:
|
|
570
|
-
integrity:
|
|
563
|
+
RegistryPluginEntrySchema = z2.object({
|
|
564
|
+
name: z2.string().min(1),
|
|
565
|
+
description: z2.string(),
|
|
566
|
+
version: z2.string(),
|
|
567
|
+
tags: z2.array(z2.string()).default([]),
|
|
568
|
+
official: z2.boolean().default(false),
|
|
569
|
+
docs: z2.string().url().optional(),
|
|
570
|
+
install: z2.string().optional(),
|
|
571
|
+
integrity: z2.string().optional()
|
|
571
572
|
});
|
|
572
|
-
RegistryFileSchema =
|
|
573
|
-
version:
|
|
574
|
-
official:
|
|
575
|
-
community:
|
|
573
|
+
RegistryFileSchema = z2.object({
|
|
574
|
+
version: z2.string(),
|
|
575
|
+
official: z2.array(RegistryPluginEntrySchema).default([]),
|
|
576
|
+
community: z2.array(RegistryPluginEntrySchema).default([])
|
|
576
577
|
});
|
|
577
|
-
PackageJsonSchema =
|
|
578
|
-
name:
|
|
579
|
-
version:
|
|
580
|
-
scripts:
|
|
581
|
-
dependencies:
|
|
582
|
-
devDependencies:
|
|
583
|
-
peerDependencies:
|
|
584
|
-
main:
|
|
585
|
-
module:
|
|
586
|
-
exports:
|
|
587
|
-
type:
|
|
578
|
+
PackageJsonSchema = z2.object({
|
|
579
|
+
name: z2.string(),
|
|
580
|
+
version: z2.string(),
|
|
581
|
+
scripts: z2.record(z2.string(), z2.string()).optional(),
|
|
582
|
+
dependencies: z2.record(z2.string(), z2.string()).optional(),
|
|
583
|
+
devDependencies: z2.record(z2.string(), z2.string()).optional(),
|
|
584
|
+
peerDependencies: z2.record(z2.string(), z2.string()).optional(),
|
|
585
|
+
main: z2.string().optional(),
|
|
586
|
+
module: z2.string().optional(),
|
|
587
|
+
exports: z2.unknown().optional(),
|
|
588
|
+
type: z2.enum(["module", "commonjs"]).optional()
|
|
588
589
|
}).passthrough();
|
|
589
590
|
}
|
|
590
591
|
});
|
|
@@ -672,6 +673,7 @@ function resolveLoaderPath(loaderBasename, importMetaUrl) {
|
|
|
672
673
|
var isBrowser2, NODE_URL, NODE_FS, NODE_PATH;
|
|
673
674
|
var init_workerResolver = __esm({
|
|
674
675
|
"packages/domain/shared/src/workerResolver.ts"() {
|
|
676
|
+
"use strict";
|
|
675
677
|
isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
676
678
|
NODE_URL = typeof window === "undefined" || typeof document === "undefined" ? "node:url" : null;
|
|
677
679
|
NODE_FS = typeof window === "undefined" || typeof document === "undefined" ? "node:fs" : null;
|
|
@@ -821,13 +823,13 @@ function generateClassRenameCodemod(renames, opts = {}) {
|
|
|
821
823
|
}
|
|
822
824
|
return lines.join("\n");
|
|
823
825
|
}
|
|
824
|
-
function generateBarrelFile(exports
|
|
826
|
+
function generateBarrelFile(exports, dir, opts = {}) {
|
|
825
827
|
const { includeTypes = true } = opts;
|
|
826
828
|
const lines = [];
|
|
827
829
|
lines.push(`// Auto-generated barrel file for ${dir}`);
|
|
828
830
|
lines.push(`// Run: npx tsx scripts/generate-barrel.ts to regenerate`);
|
|
829
831
|
lines.push(``);
|
|
830
|
-
for (const name of exports
|
|
832
|
+
for (const name of exports) {
|
|
831
833
|
lines.push(`export { default as ${name}, type ${name}Props } from "./${name}"`);
|
|
832
834
|
if (includeTypes) {
|
|
833
835
|
lines.push(`export type * from "./${name}"`);
|
|
@@ -837,8 +839,14 @@ function generateBarrelFile(exports$1, dir, opts = {}) {
|
|
|
837
839
|
}
|
|
838
840
|
var init_codegen = __esm({
|
|
839
841
|
"packages/domain/shared/src/codegen.ts"() {
|
|
842
|
+
"use strict";
|
|
840
843
|
}
|
|
841
844
|
});
|
|
845
|
+
|
|
846
|
+
// packages/domain/shared/src/native-resolution.ts
|
|
847
|
+
import { createRequire } from "module";
|
|
848
|
+
import * as fs from "fs";
|
|
849
|
+
import * as path from "path";
|
|
842
850
|
function platformKey() {
|
|
843
851
|
if (isBrowser3) return "browser";
|
|
844
852
|
return `${process.platform}-${process.arch}`;
|
|
@@ -854,7 +862,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
854
862
|
}
|
|
855
863
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
856
864
|
if (envPath) {
|
|
857
|
-
if (
|
|
865
|
+
if (fs.existsSync(envPath)) {
|
|
858
866
|
return { path: envPath, source: "env", platform, tried };
|
|
859
867
|
}
|
|
860
868
|
tried.push(`env:${envPath} (not found)`);
|
|
@@ -863,7 +871,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
863
871
|
for (const pkg of prebuiltPkgs) {
|
|
864
872
|
try {
|
|
865
873
|
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
866
|
-
if (
|
|
874
|
+
if (fs.existsSync(candidate)) {
|
|
867
875
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
868
876
|
}
|
|
869
877
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -874,13 +882,13 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
874
882
|
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
875
883
|
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
876
884
|
if (runtimeDir) {
|
|
877
|
-
for (const depth of ["..",
|
|
878
|
-
const pkgRoot =
|
|
885
|
+
for (const depth of ["..", path.join("..", ".."), path.join("..", "..", "..")]) {
|
|
886
|
+
const pkgRoot = path.resolve(runtimeDir, depth);
|
|
879
887
|
for (const bin of BINARY_NAMES_SELF) {
|
|
880
888
|
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
881
|
-
const candidate =
|
|
889
|
+
const candidate = path.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
882
890
|
tried.push(`self-bundled:${candidate}`);
|
|
883
|
-
if (
|
|
891
|
+
if (fs.existsSync(candidate)) {
|
|
884
892
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
885
893
|
}
|
|
886
894
|
}
|
|
@@ -892,29 +900,29 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
892
900
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
893
901
|
const localCandidates = [];
|
|
894
902
|
for (const bin of BINARY_NAMES) {
|
|
895
|
-
localCandidates.push(
|
|
896
|
-
localCandidates.push(
|
|
897
|
-
localCandidates.push(
|
|
898
|
-
localCandidates.push(
|
|
903
|
+
localCandidates.push(path.resolve(base, `${bin}.node`));
|
|
904
|
+
localCandidates.push(path.resolve(base, "..", `${bin}.node`));
|
|
905
|
+
localCandidates.push(path.resolve(base, `${bin}.${platform}.node`));
|
|
906
|
+
localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
899
907
|
}
|
|
900
908
|
for (const startDir of [cwd, base]) {
|
|
901
909
|
let dir = startDir;
|
|
902
910
|
for (let i = 0; i < 6; i++) {
|
|
903
|
-
const nativeDir =
|
|
911
|
+
const nativeDir = path.resolve(dir, "native");
|
|
904
912
|
for (const bin of BINARY_NAMES) {
|
|
905
|
-
localCandidates.push(
|
|
906
|
-
localCandidates.push(
|
|
907
|
-
localCandidates.push(
|
|
908
|
-
localCandidates.push(
|
|
913
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.node`));
|
|
914
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
915
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
916
|
+
localCandidates.push(path.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
909
917
|
}
|
|
910
|
-
const parent =
|
|
918
|
+
const parent = path.resolve(dir, "..");
|
|
911
919
|
if (parent === dir) break;
|
|
912
920
|
dir = parent;
|
|
913
921
|
}
|
|
914
922
|
}
|
|
915
923
|
for (const candidate of localCandidates) {
|
|
916
924
|
tried.push(`local:${candidate}`);
|
|
917
|
-
if (
|
|
925
|
+
if (fs.existsSync(candidate)) {
|
|
918
926
|
return { path: candidate, source: "local", platform, tried };
|
|
919
927
|
}
|
|
920
928
|
}
|
|
@@ -937,6 +945,7 @@ function formatNativeNotFoundError(result) {
|
|
|
937
945
|
var isBrowser3, _require, PLATFORM_MAP;
|
|
938
946
|
var init_native_resolution = __esm({
|
|
939
947
|
"packages/domain/shared/src/native-resolution.ts"() {
|
|
948
|
+
"use strict";
|
|
940
949
|
isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
941
950
|
_require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
942
951
|
PLATFORM_MAP = {
|
|
@@ -984,6 +993,7 @@ function createObservabilityClient(opts = {}) {
|
|
|
984
993
|
}
|
|
985
994
|
var init_observability = __esm({
|
|
986
995
|
"packages/domain/shared/src/observability.ts"() {
|
|
996
|
+
"use strict";
|
|
987
997
|
}
|
|
988
998
|
});
|
|
989
999
|
|
|
@@ -1022,6 +1032,7 @@ function resetCacheStats() {
|
|
|
1022
1032
|
}
|
|
1023
1033
|
var init_cssGeneratorNative = __esm({
|
|
1024
1034
|
"packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
|
|
1035
|
+
"use strict";
|
|
1025
1036
|
init_nativeBridge();
|
|
1026
1037
|
}
|
|
1027
1038
|
});
|
|
@@ -1165,9 +1176,13 @@ function twMergeRaw(classLists) {
|
|
|
1165
1176
|
}
|
|
1166
1177
|
var init_cssCompilationNative = __esm({
|
|
1167
1178
|
"packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
|
|
1179
|
+
"use strict";
|
|
1168
1180
|
init_nativeBridge();
|
|
1169
1181
|
}
|
|
1170
1182
|
});
|
|
1183
|
+
|
|
1184
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
1185
|
+
import { createRequire as createRequire2 } from "module";
|
|
1171
1186
|
function loadTailwindEngine() {
|
|
1172
1187
|
if (_twEngine) return _twEngine;
|
|
1173
1188
|
if (_twEngineError) throw _twEngineError;
|
|
@@ -1187,10 +1202,10 @@ async function generateRawCss(classes, cssEntryContent, root) {
|
|
|
1187
1202
|
if (classes.length === 0) return "";
|
|
1188
1203
|
const tw = loadTailwindEngine();
|
|
1189
1204
|
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1190
|
-
const { readFileSync, existsSync: existsSync3 } = await import(
|
|
1191
|
-
const { dirname, resolve: resolve2 } = await import(
|
|
1205
|
+
const { readFileSync, existsSync: existsSync3 } = await import("fs");
|
|
1206
|
+
const { dirname, resolve: resolve2 } = await import("path");
|
|
1192
1207
|
const projectRoot = root ?? process.cwd();
|
|
1193
|
-
const req =
|
|
1208
|
+
const req = createRequire2(resolve2(projectRoot, "package.json"));
|
|
1194
1209
|
const loadStylesheet = async (id, base) => {
|
|
1195
1210
|
try {
|
|
1196
1211
|
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;
|
|
@@ -1210,10 +1225,12 @@ async function generateRawCss(classes, cssEntryContent, root) {
|
|
|
1210
1225
|
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1211
1226
|
return compiler.build(classes);
|
|
1212
1227
|
}
|
|
1213
|
-
var require2, _twEngine, _twEngineError;
|
|
1228
|
+
var require2, MAX_CACHE_MEMORY, _twEngine, _twEngineError;
|
|
1214
1229
|
var init_tailwindEngine = __esm({
|
|
1215
1230
|
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
1216
|
-
|
|
1231
|
+
"use strict";
|
|
1232
|
+
require2 = createRequire2(import.meta.url);
|
|
1233
|
+
MAX_CACHE_MEMORY = 256 * 1024;
|
|
1217
1234
|
_twEngine = null;
|
|
1218
1235
|
_twEngineError = null;
|
|
1219
1236
|
}
|
|
@@ -1228,6 +1245,7 @@ __export(tailwindEngine_exports, {
|
|
|
1228
1245
|
runCssPipeline: () => runCssPipeline,
|
|
1229
1246
|
runCssPipelineSync: () => runCssPipelineSync
|
|
1230
1247
|
});
|
|
1248
|
+
import { createRequire as createRequire3 } from "module";
|
|
1231
1249
|
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
1232
1250
|
const sorted = [...classes].sort().join(",");
|
|
1233
1251
|
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
@@ -1394,18 +1412,20 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
1394
1412
|
}
|
|
1395
1413
|
return result.css;
|
|
1396
1414
|
}
|
|
1397
|
-
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
1415
|
+
var require3, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, MAX_CACHE_MEMORY2;
|
|
1398
1416
|
var init_tailwindEngine2 = __esm({
|
|
1399
1417
|
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
1418
|
+
"use strict";
|
|
1400
1419
|
init_nativeBridge();
|
|
1401
1420
|
init_cssGeneratorNative();
|
|
1402
1421
|
init_cssCompilationNative();
|
|
1403
1422
|
init_tailwindEngine();
|
|
1404
|
-
|
|
1423
|
+
require3 = createRequire3(import.meta.url);
|
|
1405
1424
|
_cssCache = /* @__PURE__ */ new Map();
|
|
1406
1425
|
_cacheHits = 0;
|
|
1407
1426
|
_cacheMisses = 0;
|
|
1408
1427
|
MAX_CACHE_SIZE = 100;
|
|
1428
|
+
MAX_CACHE_MEMORY2 = 256 * 1024;
|
|
1409
1429
|
}
|
|
1410
1430
|
});
|
|
1411
1431
|
|
|
@@ -1477,6 +1497,7 @@ function atomicRegistrySize() {
|
|
|
1477
1497
|
}
|
|
1478
1498
|
var init_compilationNative = __esm({
|
|
1479
1499
|
"packages/domain/compiler/src/compiler/compilationNative.ts"() {
|
|
1500
|
+
"use strict";
|
|
1480
1501
|
init_nativeBridge();
|
|
1481
1502
|
}
|
|
1482
1503
|
});
|
|
@@ -1576,6 +1597,7 @@ function idRegistryImport(importedData) {
|
|
|
1576
1597
|
}
|
|
1577
1598
|
var init_idRegistryNative = __esm({
|
|
1578
1599
|
"packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
|
|
1600
|
+
"use strict";
|
|
1579
1601
|
init_nativeBridge();
|
|
1580
1602
|
}
|
|
1581
1603
|
});
|
|
@@ -1717,6 +1739,7 @@ function scanFilesBatchNative(filesJson) {
|
|
|
1717
1739
|
}
|
|
1718
1740
|
var init_streamingNative = __esm({
|
|
1719
1741
|
"packages/domain/compiler/src/compiler/streamingNative.ts"() {
|
|
1742
|
+
"use strict";
|
|
1720
1743
|
init_nativeBridge();
|
|
1721
1744
|
}
|
|
1722
1745
|
});
|
|
@@ -1724,6 +1747,7 @@ var init_streamingNative = __esm({
|
|
|
1724
1747
|
// packages/domain/compiler/src/compiler/index.ts
|
|
1725
1748
|
var init_compiler = __esm({
|
|
1726
1749
|
"packages/domain/compiler/src/compiler/index.ts"() {
|
|
1750
|
+
"use strict";
|
|
1727
1751
|
init_cssGeneratorNative();
|
|
1728
1752
|
init_compilationNative();
|
|
1729
1753
|
init_cssCompilationNative();
|
|
@@ -1736,6 +1760,7 @@ var init_compiler = __esm({
|
|
|
1736
1760
|
var parseClasses, parseClass, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
|
|
1737
1761
|
var init_parser = __esm({
|
|
1738
1762
|
"packages/domain/compiler/src/parser/index.ts"() {
|
|
1763
|
+
"use strict";
|
|
1739
1764
|
init_nativeBridge();
|
|
1740
1765
|
parseClasses = (raw) => {
|
|
1741
1766
|
const native = getNativeBridge();
|
|
@@ -1914,6 +1939,7 @@ function resetMemoryStats() {
|
|
|
1914
1939
|
}
|
|
1915
1940
|
var init_analyzerNative = __esm({
|
|
1916
1941
|
"packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
|
|
1942
|
+
"use strict";
|
|
1917
1943
|
init_nativeBridge();
|
|
1918
1944
|
}
|
|
1919
1945
|
});
|
|
@@ -2007,6 +2033,7 @@ function resolveSimpleVariants(configJson) {
|
|
|
2007
2033
|
}
|
|
2008
2034
|
var init_themeResolutionNative = __esm({
|
|
2009
2035
|
"packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
|
|
2036
|
+
"use strict";
|
|
2010
2037
|
init_nativeBridge();
|
|
2011
2038
|
}
|
|
2012
2039
|
});
|
|
@@ -2054,6 +2081,7 @@ function generateSubComponentTypes(root, outputPath) {
|
|
|
2054
2081
|
}
|
|
2055
2082
|
var init_scannerNative = __esm({
|
|
2056
2083
|
"packages/domain/compiler/src/analyzer/scannerNative.ts"() {
|
|
2084
|
+
"use strict";
|
|
2057
2085
|
init_nativeBridge();
|
|
2058
2086
|
}
|
|
2059
2087
|
});
|
|
@@ -2061,6 +2089,7 @@ var init_scannerNative = __esm({
|
|
|
2061
2089
|
// packages/domain/compiler/src/analyzer/index.ts
|
|
2062
2090
|
var init_analyzer = __esm({
|
|
2063
2091
|
"packages/domain/compiler/src/analyzer/index.ts"() {
|
|
2092
|
+
"use strict";
|
|
2064
2093
|
init_analyzerNative();
|
|
2065
2094
|
init_themeResolutionNative();
|
|
2066
2095
|
init_scannerNative();
|
|
@@ -2249,6 +2278,7 @@ function resetResolverPoolStats() {
|
|
|
2249
2278
|
}
|
|
2250
2279
|
var init_cacheNative = __esm({
|
|
2251
2280
|
"packages/domain/compiler/src/cache/cacheNative.ts"() {
|
|
2281
|
+
"use strict";
|
|
2252
2282
|
init_nativeBridge();
|
|
2253
2283
|
}
|
|
2254
2284
|
});
|
|
@@ -2256,6 +2286,7 @@ var init_cacheNative = __esm({
|
|
|
2256
2286
|
// packages/domain/compiler/src/cache/index.ts
|
|
2257
2287
|
var init_cache = __esm({
|
|
2258
2288
|
"packages/domain/compiler/src/cache/index.ts"() {
|
|
2289
|
+
"use strict";
|
|
2259
2290
|
init_cacheNative();
|
|
2260
2291
|
}
|
|
2261
2292
|
});
|
|
@@ -2504,6 +2535,7 @@ function redisDiagnose() {
|
|
|
2504
2535
|
}
|
|
2505
2536
|
var init_redisNative = __esm({
|
|
2506
2537
|
"packages/domain/compiler/src/redis/redisNative.ts"() {
|
|
2538
|
+
"use strict";
|
|
2507
2539
|
init_nativeBridge();
|
|
2508
2540
|
}
|
|
2509
2541
|
});
|
|
@@ -2511,6 +2543,7 @@ var init_redisNative = __esm({
|
|
|
2511
2543
|
// packages/domain/compiler/src/redis/index.ts
|
|
2512
2544
|
var init_redis = __esm({
|
|
2513
2545
|
"packages/domain/compiler/src/redis/index.ts"() {
|
|
2546
|
+
"use strict";
|
|
2514
2547
|
init_redisNative();
|
|
2515
2548
|
}
|
|
2516
2549
|
});
|
|
@@ -2649,6 +2682,7 @@ function getCompilerDiagnostics() {
|
|
|
2649
2682
|
}
|
|
2650
2683
|
var init_watchSystemNative = __esm({
|
|
2651
2684
|
"packages/domain/compiler/src/watch/watchSystemNative.ts"() {
|
|
2685
|
+
"use strict";
|
|
2652
2686
|
init_nativeBridge();
|
|
2653
2687
|
}
|
|
2654
2688
|
});
|
|
@@ -2656,6 +2690,7 @@ var init_watchSystemNative = __esm({
|
|
|
2656
2690
|
// packages/domain/compiler/src/watch/index.ts
|
|
2657
2691
|
var init_watch = __esm({
|
|
2658
2692
|
"packages/domain/compiler/src/watch/index.ts"() {
|
|
2693
|
+
"use strict";
|
|
2659
2694
|
init_watchSystemNative();
|
|
2660
2695
|
}
|
|
2661
2696
|
});
|
|
@@ -2884,6 +2919,7 @@ __export(internal_exports, {
|
|
|
2884
2919
|
});
|
|
2885
2920
|
var init_internal = __esm({
|
|
2886
2921
|
"packages/domain/compiler/src/internal.ts"() {
|
|
2922
|
+
"use strict";
|
|
2887
2923
|
init_src2();
|
|
2888
2924
|
init_tailwindEngine2();
|
|
2889
2925
|
init_compiler();
|
|
@@ -2894,6 +2930,10 @@ var init_internal = __esm({
|
|
|
2894
2930
|
init_watch();
|
|
2895
2931
|
}
|
|
2896
2932
|
});
|
|
2933
|
+
|
|
2934
|
+
// packages/domain/shared/src/staticStateExtractor.ts
|
|
2935
|
+
import fs2 from "fs";
|
|
2936
|
+
import path2 from "path";
|
|
2897
2937
|
function getNative() {
|
|
2898
2938
|
if (_native) return _native;
|
|
2899
2939
|
try {
|
|
@@ -2923,17 +2963,17 @@ function getNative() {
|
|
|
2923
2963
|
function* walkSourceFiles(dir) {
|
|
2924
2964
|
let entries;
|
|
2925
2965
|
try {
|
|
2926
|
-
entries =
|
|
2966
|
+
entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
2927
2967
|
} catch {
|
|
2928
2968
|
return;
|
|
2929
2969
|
}
|
|
2930
2970
|
for (const entry of entries) {
|
|
2931
|
-
const fullPath =
|
|
2971
|
+
const fullPath = path2.join(dir, entry.name);
|
|
2932
2972
|
if (entry.isDirectory()) {
|
|
2933
2973
|
if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
|
|
2934
2974
|
yield* walkSourceFiles(fullPath);
|
|
2935
2975
|
} else if (entry.isFile()) {
|
|
2936
|
-
const ext =
|
|
2976
|
+
const ext = path2.extname(entry.name);
|
|
2937
2977
|
if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
|
|
2938
2978
|
}
|
|
2939
2979
|
}
|
|
@@ -2997,7 +3037,7 @@ function extractStaticStateCss(srcDir, options = {}) {
|
|
|
2997
3037
|
allConfigs.push(...configs);
|
|
2998
3038
|
if (verbose) {
|
|
2999
3039
|
process.stderr.write(
|
|
3000
|
-
`[tw:static-state] ${
|
|
3040
|
+
`[tw:static-state] ${path2.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
3001
3041
|
`
|
|
3002
3042
|
);
|
|
3003
3043
|
}
|
|
@@ -3008,7 +3048,7 @@ function extractStaticStateCss(srcDir, options = {}) {
|
|
|
3008
3048
|
if (filesScanned >= maxFiles) break;
|
|
3009
3049
|
let source;
|
|
3010
3050
|
try {
|
|
3011
|
-
source =
|
|
3051
|
+
source = fs2.readFileSync(filePath, "utf-8");
|
|
3012
3052
|
} catch {
|
|
3013
3053
|
continue;
|
|
3014
3054
|
}
|
|
@@ -3021,7 +3061,7 @@ function extractStaticStateCss(srcDir, options = {}) {
|
|
|
3021
3061
|
allConfigs.push(...configs);
|
|
3022
3062
|
if (verbose) {
|
|
3023
3063
|
process.stderr.write(
|
|
3024
|
-
`[tw:static-state] ${
|
|
3064
|
+
`[tw:static-state] ${path2.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
3025
3065
|
`
|
|
3026
3066
|
);
|
|
3027
3067
|
}
|
|
@@ -3115,12 +3155,12 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
|
3115
3155
|
resolvedCss: options.resolvedCss || ""
|
|
3116
3156
|
// ← ensure always passed
|
|
3117
3157
|
});
|
|
3118
|
-
const twClassesDir =
|
|
3119
|
-
|
|
3120
|
-
const stateFilePath =
|
|
3158
|
+
const twClassesDir = path2.join(path2.dirname(safelistPath), "tw-classes");
|
|
3159
|
+
fs2.mkdirSync(twClassesDir, { recursive: true });
|
|
3160
|
+
const stateFilePath = path2.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
3121
3161
|
if (result.rulesGenerated === 0) {
|
|
3122
3162
|
try {
|
|
3123
|
-
|
|
3163
|
+
fs2.writeFileSync(
|
|
3124
3164
|
stateFilePath,
|
|
3125
3165
|
"/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
|
|
3126
3166
|
"utf-8"
|
|
@@ -3130,7 +3170,7 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
|
3130
3170
|
return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
|
|
3131
3171
|
}
|
|
3132
3172
|
try {
|
|
3133
|
-
|
|
3173
|
+
fs2.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
|
|
3134
3174
|
return [
|
|
3135
3175
|
`[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
|
|
3136
3176
|
` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
|
|
@@ -3145,12 +3185,17 @@ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
|
3145
3185
|
var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
|
|
3146
3186
|
var init_staticStateExtractor = __esm({
|
|
3147
3187
|
"packages/domain/shared/src/staticStateExtractor.ts"() {
|
|
3188
|
+
"use strict";
|
|
3148
3189
|
SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
|
|
3149
3190
|
IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
|
|
3150
3191
|
_native = null;
|
|
3151
3192
|
TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
|
|
3152
3193
|
}
|
|
3153
3194
|
});
|
|
3195
|
+
|
|
3196
|
+
// packages/domain/shared/src/logger.ts
|
|
3197
|
+
import fs3 from "fs";
|
|
3198
|
+
import path3 from "path";
|
|
3154
3199
|
function getEnvLevel() {
|
|
3155
3200
|
const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
|
|
3156
3201
|
if (env && env in LEVELS) return env;
|
|
@@ -3160,8 +3205,8 @@ function setGlobalLogFile(filePath) {
|
|
|
3160
3205
|
_globalLogFile = filePath;
|
|
3161
3206
|
_logFileInitialized = false;
|
|
3162
3207
|
try {
|
|
3163
|
-
|
|
3164
|
-
|
|
3208
|
+
fs3.mkdirSync(path3.dirname(filePath), { recursive: true });
|
|
3209
|
+
fs3.writeFileSync(
|
|
3165
3210
|
filePath,
|
|
3166
3211
|
`# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
3167
3212
|
`,
|
|
@@ -3174,13 +3219,13 @@ function setGlobalLogFile(filePath) {
|
|
|
3174
3219
|
function writeToFile(line) {
|
|
3175
3220
|
if (!_globalLogFile || !_logFileInitialized) return;
|
|
3176
3221
|
try {
|
|
3177
|
-
|
|
3222
|
+
fs3.appendFileSync(_globalLogFile, line);
|
|
3178
3223
|
} catch {
|
|
3179
3224
|
}
|
|
3180
3225
|
}
|
|
3181
3226
|
function createLogger(prefix, level) {
|
|
3182
3227
|
const loggerState = {
|
|
3183
|
-
currentLevel: getEnvLevel(),
|
|
3228
|
+
currentLevel: level ?? getEnvLevel(),
|
|
3184
3229
|
setLevel(l) {
|
|
3185
3230
|
this.currentLevel = l;
|
|
3186
3231
|
}
|
|
@@ -3201,13 +3246,14 @@ function createLogger(prefix, level) {
|
|
|
3201
3246
|
setLogFile: (filePath) => setGlobalLogFile(filePath)
|
|
3202
3247
|
};
|
|
3203
3248
|
}
|
|
3204
|
-
var LEVELS, _globalLogFile, _logFileInitialized;
|
|
3249
|
+
var LEVELS, _globalLogFile, _logFileInitialized, logger;
|
|
3205
3250
|
var init_logger = __esm({
|
|
3206
3251
|
"packages/domain/shared/src/logger.ts"() {
|
|
3252
|
+
"use strict";
|
|
3207
3253
|
LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
3208
3254
|
_globalLogFile = null;
|
|
3209
3255
|
_logFileInitialized = false;
|
|
3210
|
-
createLogger("tailwind-styled");
|
|
3256
|
+
logger = createLogger("tailwind-styled");
|
|
3211
3257
|
}
|
|
3212
3258
|
});
|
|
3213
3259
|
|
|
@@ -3283,6 +3329,11 @@ __export(src_exports, {
|
|
|
3283
3329
|
tryRequire: () => tryRequire,
|
|
3284
3330
|
wrapUnknownError: () => wrapUnknownError
|
|
3285
3331
|
});
|
|
3332
|
+
import { createHash } from "crypto";
|
|
3333
|
+
import fs4 from "fs";
|
|
3334
|
+
import path4 from "path";
|
|
3335
|
+
import { fileURLToPath } from "url";
|
|
3336
|
+
import { createRequire as createRequire4 } from "module";
|
|
3286
3337
|
function createLogger2(namespace) {
|
|
3287
3338
|
const prefix = `[${namespace}]`;
|
|
3288
3339
|
return {
|
|
@@ -3328,9 +3379,9 @@ function loadNativeBinding(options) {
|
|
|
3328
3379
|
const { runtimeDir, candidates, isValid } = options;
|
|
3329
3380
|
const loadErrors = [];
|
|
3330
3381
|
for (const candidate of candidates) {
|
|
3331
|
-
const candidatePath =
|
|
3382
|
+
const candidatePath = path4.resolve(runtimeDir, candidate);
|
|
3332
3383
|
try {
|
|
3333
|
-
if (!
|
|
3384
|
+
if (!fs4.existsSync(candidatePath) && !fs4.existsSync(candidatePath + ".node")) {
|
|
3334
3385
|
continue;
|
|
3335
3386
|
}
|
|
3336
3387
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -3362,9 +3413,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
3362
3413
|
}
|
|
3363
3414
|
}
|
|
3364
3415
|
if (!includeDefaultCandidates) return candidates;
|
|
3365
|
-
if (
|
|
3416
|
+
if (fs4.existsSync(runtimeDir)) {
|
|
3366
3417
|
try {
|
|
3367
|
-
for (const entry of
|
|
3418
|
+
for (const entry of fs4.readdirSync(runtimeDir)) {
|
|
3368
3419
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
3369
3420
|
}
|
|
3370
3421
|
} catch {
|
|
@@ -3373,22 +3424,22 @@ function resolveNativeBindingCandidates(options) {
|
|
|
3373
3424
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
3374
3425
|
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
3375
3426
|
for (const bin of BINARY_NAMES) {
|
|
3376
|
-
candidates.push(
|
|
3377
|
-
candidates.push(
|
|
3378
|
-
candidates.push(
|
|
3379
|
-
candidates.push(
|
|
3380
|
-
candidates.push(
|
|
3381
|
-
candidates.push(
|
|
3382
|
-
candidates.push(
|
|
3383
|
-
candidates.push(
|
|
3384
|
-
candidates.push(
|
|
3427
|
+
candidates.push(path4.resolve(runtimeDir, `${bin}.node`));
|
|
3428
|
+
candidates.push(path4.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
3429
|
+
candidates.push(path4.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
3430
|
+
candidates.push(path4.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3431
|
+
candidates.push(path4.resolve(process.cwd(), "native", `${bin}.node`));
|
|
3432
|
+
candidates.push(path4.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
3433
|
+
candidates.push(path4.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
3434
|
+
candidates.push(path4.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3435
|
+
candidates.push(path4.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
3385
3436
|
}
|
|
3386
3437
|
return Array.from(new Set(candidates));
|
|
3387
3438
|
}
|
|
3388
3439
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
3389
|
-
if (dir) return
|
|
3440
|
+
if (dir) return path4.resolve(dir);
|
|
3390
3441
|
try {
|
|
3391
|
-
return
|
|
3442
|
+
return path4.dirname(fileURLToPath(importMetaUrl));
|
|
3392
3443
|
} catch {
|
|
3393
3444
|
return process.cwd();
|
|
3394
3445
|
}
|
|
@@ -3405,6 +3456,7 @@ function formatErrorMessage(error) {
|
|
|
3405
3456
|
var TwError, _require2, LRUCache;
|
|
3406
3457
|
var init_src = __esm({
|
|
3407
3458
|
"packages/domain/shared/src/index.ts"() {
|
|
3459
|
+
"use strict";
|
|
3408
3460
|
init_trace();
|
|
3409
3461
|
init_error_codes();
|
|
3410
3462
|
init_compatibility();
|
|
@@ -3470,7 +3522,7 @@ var init_src = __esm({
|
|
|
3470
3522
|
return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
|
|
3471
3523
|
}
|
|
3472
3524
|
};
|
|
3473
|
-
_require2 =
|
|
3525
|
+
_require2 = createRequire4(import.meta.url);
|
|
3474
3526
|
LRUCache = class {
|
|
3475
3527
|
capacity;
|
|
3476
3528
|
cache;
|
|
@@ -3519,6 +3571,7 @@ var init_src = __esm({
|
|
|
3519
3571
|
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
|
|
3520
3572
|
var init_nativeBridge = __esm({
|
|
3521
3573
|
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
3574
|
+
"use strict";
|
|
3522
3575
|
init_src();
|
|
3523
3576
|
_loadNative = (path16) => __require(path16);
|
|
3524
3577
|
log = (...args) => {
|
|
@@ -3622,6 +3675,11 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
3622
3675
|
}
|
|
3623
3676
|
}
|
|
3624
3677
|
});
|
|
3678
|
+
|
|
3679
|
+
// packages/domain/compiler/src/index.ts
|
|
3680
|
+
import fs5 from "fs";
|
|
3681
|
+
import path5 from "path";
|
|
3682
|
+
import { createRequire as createRequire5 } from "module";
|
|
3625
3683
|
function _layoutClassesToCss(classes) {
|
|
3626
3684
|
const native = getNativeBridge();
|
|
3627
3685
|
if (!native?.layoutClassesToCss) {
|
|
@@ -3659,6 +3717,7 @@ function extractContainerCssFromSource(source) {
|
|
|
3659
3717
|
var _require3, transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
3660
3718
|
var init_src2 = __esm({
|
|
3661
3719
|
"packages/domain/compiler/src/index.ts"() {
|
|
3720
|
+
"use strict";
|
|
3662
3721
|
init_nativeBridge();
|
|
3663
3722
|
init_compiler();
|
|
3664
3723
|
init_parser();
|
|
@@ -3666,7 +3725,7 @@ var init_src2 = __esm({
|
|
|
3666
3725
|
init_cache();
|
|
3667
3726
|
init_redis();
|
|
3668
3727
|
init_watch();
|
|
3669
|
-
_require3 =
|
|
3728
|
+
_require3 = createRequire5(import.meta.url);
|
|
3670
3729
|
transformSource = (source, opts) => {
|
|
3671
3730
|
const native = getNativeBridge();
|
|
3672
3731
|
if (!native?.transformSource) {
|
|
@@ -3758,7 +3817,7 @@ var init_src2 = __esm({
|
|
|
3758
3817
|
};
|
|
3759
3818
|
scanProjectUsage = (dirs, cwd) => {
|
|
3760
3819
|
const { batchExtractClasses: batchExtractClasses2 } = _require3("./parser");
|
|
3761
|
-
const files = dirs.map((dir) =>
|
|
3820
|
+
const files = dirs.map((dir) => path5.resolve(cwd, dir));
|
|
3762
3821
|
const results = batchExtractClasses2(files) || [];
|
|
3763
3822
|
const combined = {};
|
|
3764
3823
|
for (const result of results) {
|
|
@@ -3775,13 +3834,13 @@ var init_src2 = __esm({
|
|
|
3775
3834
|
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
3776
3835
|
const allClasses = Object.keys(classes).sort();
|
|
3777
3836
|
if (outputPath) {
|
|
3778
|
-
|
|
3837
|
+
fs5.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
3779
3838
|
}
|
|
3780
3839
|
return allClasses;
|
|
3781
3840
|
};
|
|
3782
3841
|
loadSafelist = (safelistPath) => {
|
|
3783
3842
|
try {
|
|
3784
|
-
const content =
|
|
3843
|
+
const content = fs5.readFileSync(safelistPath, "utf-8");
|
|
3785
3844
|
return JSON.parse(content);
|
|
3786
3845
|
} catch {
|
|
3787
3846
|
return [];
|
|
@@ -3795,8 +3854,8 @@ var init_src2 = __esm({
|
|
|
3795
3854
|
"tailwind.config.cjs"
|
|
3796
3855
|
];
|
|
3797
3856
|
for (const file of configFiles) {
|
|
3798
|
-
const fullPath =
|
|
3799
|
-
if (
|
|
3857
|
+
const fullPath = path5.join(cwd, file);
|
|
3858
|
+
if (fs5.existsSync(fullPath)) {
|
|
3800
3859
|
const mod = __require(fullPath);
|
|
3801
3860
|
return mod.default || mod;
|
|
3802
3861
|
}
|
|
@@ -3806,9 +3865,9 @@ var init_src2 = __esm({
|
|
|
3806
3865
|
getContentPaths = (cwd = process.cwd()) => {
|
|
3807
3866
|
return {
|
|
3808
3867
|
content: [
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3868
|
+
path5.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
3869
|
+
path5.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
3870
|
+
path5.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
3812
3871
|
]
|
|
3813
3872
|
};
|
|
3814
3873
|
};
|
|
@@ -4027,12 +4086,14 @@ __export(native_bridge_exports, {
|
|
|
4027
4086
|
startWatchNative: () => startWatchNative,
|
|
4028
4087
|
stopWatchNative: () => stopWatchNative
|
|
4029
4088
|
});
|
|
4089
|
+
import path6 from "path";
|
|
4090
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4030
4091
|
function getDirname2() {
|
|
4031
4092
|
if (typeof __dirname !== "undefined") {
|
|
4032
4093
|
return __dirname;
|
|
4033
4094
|
}
|
|
4034
4095
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
4035
|
-
return
|
|
4096
|
+
return path6.dirname(fileURLToPath2(import.meta.url));
|
|
4036
4097
|
}
|
|
4037
4098
|
return process.cwd();
|
|
4038
4099
|
}
|
|
@@ -4240,6 +4301,7 @@ function hasNativeWatchBinding() {
|
|
|
4240
4301
|
var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
4241
4302
|
var init_native_bridge = __esm({
|
|
4242
4303
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
4304
|
+
"use strict";
|
|
4243
4305
|
init_src();
|
|
4244
4306
|
log2 = createDebugLogger("scanner:native");
|
|
4245
4307
|
isValidScannerBinding = (module) => {
|
|
@@ -4320,13 +4382,17 @@ var init_native_bridge = __esm({
|
|
|
4320
4382
|
resetScannerBridgeCache = scannerBridgeLoader.reset;
|
|
4321
4383
|
}
|
|
4322
4384
|
});
|
|
4385
|
+
|
|
4386
|
+
// packages/domain/scanner/src/cache-native.ts
|
|
4387
|
+
import fs6 from "fs";
|
|
4388
|
+
import path7 from "path";
|
|
4323
4389
|
function defaultCachePath(rootDir, cacheDir) {
|
|
4324
|
-
const dir = cacheDir ?
|
|
4325
|
-
return
|
|
4390
|
+
const dir = cacheDir ? path7.resolve(rootDir, cacheDir) : path7.join(process.cwd(), ".cache", "tailwind-styled");
|
|
4391
|
+
return path7.join(dir, "scanner-cache.json");
|
|
4326
4392
|
}
|
|
4327
4393
|
function readCache(rootDir, cacheDir) {
|
|
4328
4394
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
4329
|
-
|
|
4395
|
+
fs6.mkdirSync(path7.dirname(cachePath), { recursive: true });
|
|
4330
4396
|
const result = cacheReadNative(cachePath);
|
|
4331
4397
|
if (!result) return [];
|
|
4332
4398
|
return result.entries.map((e) => ({
|
|
@@ -4341,7 +4407,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
4341
4407
|
}
|
|
4342
4408
|
function writeCache(rootDir, entries, cacheDir) {
|
|
4343
4409
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
4344
|
-
|
|
4410
|
+
fs6.mkdirSync(path7.dirname(cachePath), { recursive: true });
|
|
4345
4411
|
const success = cacheWriteNative(cachePath, entries);
|
|
4346
4412
|
if (!success) {
|
|
4347
4413
|
throw new Error(
|
|
@@ -4360,11 +4426,20 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
|
|
|
4360
4426
|
nowMs
|
|
4361
4427
|
);
|
|
4362
4428
|
}
|
|
4429
|
+
var STALE_THRESHOLD_MS;
|
|
4363
4430
|
var init_cache_native = __esm({
|
|
4364
4431
|
"packages/domain/scanner/src/cache-native.ts"() {
|
|
4432
|
+
"use strict";
|
|
4365
4433
|
init_native_bridge();
|
|
4434
|
+
STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
4366
4435
|
}
|
|
4367
4436
|
});
|
|
4437
|
+
|
|
4438
|
+
// packages/domain/scanner/src/parallel-scanner.ts
|
|
4439
|
+
import { Worker, isMainThread, parentPort, workerData } from "worker_threads";
|
|
4440
|
+
import path8 from "path";
|
|
4441
|
+
import { availableParallelism } from "os";
|
|
4442
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
4368
4443
|
function collectFiles2(rootDir, extensions, ignoreDirs) {
|
|
4369
4444
|
const native = collectFilesNative(rootDir, extensions, ignoreDirs);
|
|
4370
4445
|
if (native !== null) return native;
|
|
@@ -4405,7 +4480,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
4405
4480
|
maxWorkers = Math.max(1, availableParallelism() - 1),
|
|
4406
4481
|
chunkSize = DEFAULT_CHUNK_SIZE
|
|
4407
4482
|
} = options;
|
|
4408
|
-
const files = collectFiles2(
|
|
4483
|
+
const files = collectFiles2(path8.resolve(rootDir), extensions, ignoreDirs);
|
|
4409
4484
|
if (files.length < PARALLEL_THRESHOLD) {
|
|
4410
4485
|
return mergeResults(batchExtractClassesNative2(files));
|
|
4411
4486
|
}
|
|
@@ -4424,6 +4499,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
4424
4499
|
var PARALLEL_THRESHOLD, DEFAULT_CHUNK_SIZE, _workerFilename;
|
|
4425
4500
|
var init_parallel_scanner = __esm({
|
|
4426
4501
|
"packages/domain/scanner/src/parallel-scanner.ts"() {
|
|
4502
|
+
"use strict";
|
|
4427
4503
|
init_src3();
|
|
4428
4504
|
init_native_bridge();
|
|
4429
4505
|
PARALLEL_THRESHOLD = 50;
|
|
@@ -4442,12 +4518,16 @@ var init_parallel_scanner = __esm({
|
|
|
4442
4518
|
parentPort.postMessage(msg);
|
|
4443
4519
|
}
|
|
4444
4520
|
}
|
|
4445
|
-
_workerFilename = typeof __filename !== "undefined" ? __filename :
|
|
4521
|
+
_workerFilename = typeof __filename !== "undefined" ? __filename : fileURLToPath3(import.meta.url);
|
|
4446
4522
|
}
|
|
4447
4523
|
});
|
|
4448
|
-
|
|
4524
|
+
|
|
4525
|
+
// packages/domain/scanner/src/schemas.ts
|
|
4526
|
+
import { z as z3 } from "zod";
|
|
4527
|
+
var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, ScanWorkspaceOptionsSchema, ScanFileResultSchema, ScanWorkspaceResultSchema, ScannerWorkerRequestSchema, ScannerWorkerSuccessMessageSchema, ScannerWorkerErrorMessageSchema, ScannerWorkerMessageSchema, parseScanWorkspaceOptions, parseScanWorkspaceResult, parseScannerWorkerMessage;
|
|
4449
4528
|
var init_schemas = __esm({
|
|
4450
4529
|
"packages/domain/scanner/src/schemas.ts"() {
|
|
4530
|
+
"use strict";
|
|
4451
4531
|
init_src();
|
|
4452
4532
|
formatIssuePath2 = (path16) => path16.length > 0 ? path16.map(
|
|
4453
4533
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
@@ -4467,40 +4547,40 @@ var init_schemas = __esm({
|
|
|
4467
4547
|
parsed.error
|
|
4468
4548
|
);
|
|
4469
4549
|
};
|
|
4470
|
-
NonNegativeIntegerSchema =
|
|
4471
|
-
ScanWorkspaceOptionsSchema =
|
|
4472
|
-
includeExtensions:
|
|
4473
|
-
ignoreDirectories:
|
|
4474
|
-
useCache:
|
|
4475
|
-
cacheDir:
|
|
4476
|
-
smartInvalidation:
|
|
4550
|
+
NonNegativeIntegerSchema = z3.number().int().min(0);
|
|
4551
|
+
ScanWorkspaceOptionsSchema = z3.object({
|
|
4552
|
+
includeExtensions: z3.array(z3.string()).optional(),
|
|
4553
|
+
ignoreDirectories: z3.array(z3.string()).optional(),
|
|
4554
|
+
useCache: z3.boolean().optional(),
|
|
4555
|
+
cacheDir: z3.string().min(1).optional(),
|
|
4556
|
+
smartInvalidation: z3.boolean().optional()
|
|
4477
4557
|
});
|
|
4478
|
-
ScanFileResultSchema =
|
|
4479
|
-
file:
|
|
4480
|
-
classes:
|
|
4481
|
-
hash:
|
|
4558
|
+
ScanFileResultSchema = z3.object({
|
|
4559
|
+
file: z3.string(),
|
|
4560
|
+
classes: z3.array(z3.string()),
|
|
4561
|
+
hash: z3.string().optional()
|
|
4482
4562
|
});
|
|
4483
|
-
ScanWorkspaceResultSchema =
|
|
4484
|
-
files:
|
|
4563
|
+
ScanWorkspaceResultSchema = z3.object({
|
|
4564
|
+
files: z3.array(ScanFileResultSchema),
|
|
4485
4565
|
totalFiles: NonNegativeIntegerSchema,
|
|
4486
|
-
uniqueClasses:
|
|
4566
|
+
uniqueClasses: z3.array(z3.string())
|
|
4487
4567
|
}).refine((value) => value.totalFiles === value.files.length, {
|
|
4488
4568
|
message: "scan result totalFiles must match files.length",
|
|
4489
4569
|
path: ["totalFiles"]
|
|
4490
4570
|
});
|
|
4491
|
-
|
|
4492
|
-
rootDir:
|
|
4571
|
+
ScannerWorkerRequestSchema = z3.object({
|
|
4572
|
+
rootDir: z3.string().min(1),
|
|
4493
4573
|
options: ScanWorkspaceOptionsSchema.optional()
|
|
4494
4574
|
});
|
|
4495
|
-
ScannerWorkerSuccessMessageSchema =
|
|
4496
|
-
ok:
|
|
4575
|
+
ScannerWorkerSuccessMessageSchema = z3.object({
|
|
4576
|
+
ok: z3.literal(true),
|
|
4497
4577
|
result: ScanWorkspaceResultSchema
|
|
4498
4578
|
});
|
|
4499
|
-
ScannerWorkerErrorMessageSchema =
|
|
4500
|
-
ok:
|
|
4501
|
-
error:
|
|
4579
|
+
ScannerWorkerErrorMessageSchema = z3.object({
|
|
4580
|
+
ok: z3.literal(false),
|
|
4581
|
+
error: z3.string().optional()
|
|
4502
4582
|
});
|
|
4503
|
-
ScannerWorkerMessageSchema =
|
|
4583
|
+
ScannerWorkerMessageSchema = z3.union([
|
|
4504
4584
|
ScannerWorkerSuccessMessageSchema,
|
|
4505
4585
|
ScannerWorkerErrorMessageSchema
|
|
4506
4586
|
]);
|
|
@@ -4526,12 +4606,17 @@ __export(src_exports2, {
|
|
|
4526
4606
|
scanWorkspace: () => scanWorkspace2,
|
|
4527
4607
|
scanWorkspaceAsync: () => scanWorkspaceAsync
|
|
4528
4608
|
});
|
|
4609
|
+
import fs7 from "fs";
|
|
4610
|
+
import { createRequire as createRequire6 } from "module";
|
|
4611
|
+
import path9 from "path";
|
|
4612
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
4613
|
+
import { Worker as Worker2 } from "worker_threads";
|
|
4529
4614
|
function getRuntimeDir() {
|
|
4530
4615
|
if (typeof __dirname !== "undefined" && __dirname.length > 0) {
|
|
4531
4616
|
return __dirname;
|
|
4532
4617
|
}
|
|
4533
4618
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
4534
|
-
return
|
|
4619
|
+
return path9.dirname(fileURLToPath4(import.meta.url));
|
|
4535
4620
|
}
|
|
4536
4621
|
return process.cwd();
|
|
4537
4622
|
}
|
|
@@ -4541,17 +4626,17 @@ function resolveScannerWorkerModulePath() {
|
|
|
4541
4626
|
return __dirname;
|
|
4542
4627
|
}
|
|
4543
4628
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
4544
|
-
return
|
|
4629
|
+
return path9.dirname(fileURLToPath4(import.meta.url));
|
|
4545
4630
|
}
|
|
4546
4631
|
return process.cwd();
|
|
4547
4632
|
})();
|
|
4548
4633
|
const candidates = [
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4634
|
+
path9.resolve(runtimeDir, "worker.cjs"),
|
|
4635
|
+
path9.resolve(runtimeDir, "worker.js"),
|
|
4636
|
+
path9.resolve(runtimeDir, "worker.ts")
|
|
4552
4637
|
];
|
|
4553
4638
|
for (const candidate of candidates) {
|
|
4554
|
-
if (
|
|
4639
|
+
if (fs7.existsSync(candidate)) return candidate;
|
|
4555
4640
|
}
|
|
4556
4641
|
return null;
|
|
4557
4642
|
}
|
|
@@ -4563,7 +4648,7 @@ function scanWorkspaceInWorker(rootDir, options) {
|
|
|
4563
4648
|
}
|
|
4564
4649
|
return new Promise((resolve2, reject) => {
|
|
4565
4650
|
const settleState = { settled: false };
|
|
4566
|
-
const worker = new
|
|
4651
|
+
const worker = new Worker2(modulePath, { workerData: { rootDir, options: normalizedOptions } });
|
|
4567
4652
|
const timeout = setTimeout(() => {
|
|
4568
4653
|
if (!settleState.settled) {
|
|
4569
4654
|
settleState.settled = true;
|
|
@@ -4608,19 +4693,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
4608
4693
|
if (!currentDir) continue;
|
|
4609
4694
|
const entries = (() => {
|
|
4610
4695
|
try {
|
|
4611
|
-
return
|
|
4696
|
+
return fs7.readdirSync(currentDir, { withFileTypes: true });
|
|
4612
4697
|
} catch {
|
|
4613
4698
|
return [];
|
|
4614
4699
|
}
|
|
4615
4700
|
})();
|
|
4616
4701
|
for (const entry of entries) {
|
|
4617
|
-
const fullPath =
|
|
4702
|
+
const fullPath = path9.join(currentDir, entry.name);
|
|
4618
4703
|
if (entry.isDirectory()) {
|
|
4619
4704
|
if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
|
|
4620
4705
|
continue;
|
|
4621
4706
|
}
|
|
4622
4707
|
if (!entry.isFile()) continue;
|
|
4623
|
-
if (!extensionSet.has(
|
|
4708
|
+
if (!extensionSet.has(path9.extname(entry.name))) continue;
|
|
4624
4709
|
candidates.push(fullPath);
|
|
4625
4710
|
}
|
|
4626
4711
|
}
|
|
@@ -4647,7 +4732,7 @@ function scanSource(source) {
|
|
|
4647
4732
|
);
|
|
4648
4733
|
}
|
|
4649
4734
|
function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
|
|
4650
|
-
return includeExtensions.includes(
|
|
4735
|
+
return includeExtensions.includes(path9.extname(filePath));
|
|
4651
4736
|
}
|
|
4652
4737
|
function scanFile2(filePath) {
|
|
4653
4738
|
const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
|
|
@@ -4667,7 +4752,7 @@ function scanWorkspace2(rootDir, options = {}) {
|
|
|
4667
4752
|
const extensionSet = buildExtensionSet(includeExtensions);
|
|
4668
4753
|
const ignoreDirectories = new Set(normalizedOptions.ignoreDirectories ?? DEFAULT_IGNORES);
|
|
4669
4754
|
const useCache = normalizedOptions.useCache ?? true;
|
|
4670
|
-
normalizedOptions.smartInvalidation ?? true;
|
|
4755
|
+
const _smartInvalidation = normalizedOptions.smartInvalidation ?? true;
|
|
4671
4756
|
const files = [];
|
|
4672
4757
|
const unique = /* @__PURE__ */ new Set();
|
|
4673
4758
|
const candidates = collectCandidates(rootDir, ignoreDirectories, extensionSet);
|
|
@@ -4707,7 +4792,7 @@ function scanWorkspace2(rootDir, options = {}) {
|
|
|
4707
4792
|
for (const filePath of candidates) {
|
|
4708
4793
|
const stat = (() => {
|
|
4709
4794
|
try {
|
|
4710
|
-
return
|
|
4795
|
+
return fs7.statSync(filePath);
|
|
4711
4796
|
} catch {
|
|
4712
4797
|
return null;
|
|
4713
4798
|
}
|
|
@@ -4733,7 +4818,7 @@ function scanWorkspace2(rootDir, options = {}) {
|
|
|
4733
4818
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
4734
4819
|
const content = (() => {
|
|
4735
4820
|
try {
|
|
4736
|
-
return
|
|
4821
|
+
return fs7.readFileSync(filePath, "utf8");
|
|
4737
4822
|
} catch {
|
|
4738
4823
|
return null;
|
|
4739
4824
|
}
|
|
@@ -4817,6 +4902,7 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
|
|
|
4817
4902
|
var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
|
|
4818
4903
|
var init_src3 = __esm({
|
|
4819
4904
|
"packages/domain/scanner/src/index.ts"() {
|
|
4905
|
+
"use strict";
|
|
4820
4906
|
init_src();
|
|
4821
4907
|
init_cache_native();
|
|
4822
4908
|
init_native_bridge();
|
|
@@ -4837,7 +4923,7 @@ var init_src3 = __esm({
|
|
|
4837
4923
|
const loadNativeParserBinding = () => {
|
|
4838
4924
|
if (_state.binding !== void 0) return _state.binding;
|
|
4839
4925
|
const runtimeDir = getRuntimeDir();
|
|
4840
|
-
const req =
|
|
4926
|
+
const req = createRequire6(path9.join(runtimeDir, "noop.cjs"));
|
|
4841
4927
|
const _platform = process.platform;
|
|
4842
4928
|
const _arch = process.arch;
|
|
4843
4929
|
const _platformArch = `${_platform}-${_arch}`;
|
|
@@ -4845,27 +4931,27 @@ var init_src3 = __esm({
|
|
|
4845
4931
|
const candidates = [
|
|
4846
4932
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
4847
4933
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4934
|
+
path9.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
4935
|
+
path9.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
4936
|
+
path9.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
4851
4937
|
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
4852
4938
|
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4939
|
+
path9.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
4940
|
+
path9.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
4941
|
+
path9.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
4856
4942
|
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
4857
|
-
|
|
4858
|
-
|
|
4943
|
+
path9.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4944
|
+
path9.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
4859
4945
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
4860
|
-
|
|
4861
|
-
|
|
4946
|
+
path9.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4947
|
+
path9.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
4862
4948
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4949
|
+
path9.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
4950
|
+
path9.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
4951
|
+
path9.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
4952
|
+
path9.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
4953
|
+
path9.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
4954
|
+
path9.resolve(
|
|
4869
4955
|
runtimeDir,
|
|
4870
4956
|
"..",
|
|
4871
4957
|
"..",
|
|
@@ -4877,7 +4963,7 @@ var init_src3 = __esm({
|
|
|
4877
4963
|
)
|
|
4878
4964
|
];
|
|
4879
4965
|
for (const fullPath of candidates) {
|
|
4880
|
-
if (!
|
|
4966
|
+
if (!fs7.existsSync(fullPath)) continue;
|
|
4881
4967
|
try {
|
|
4882
4968
|
const required = req(fullPath);
|
|
4883
4969
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -4924,6 +5010,7 @@ function getNativeEngineBinding() {
|
|
|
4924
5010
|
var log4, isValidEngineBinding, createEngineBindingLoader, engineBindingLoader;
|
|
4925
5011
|
var init_native_bridge2 = __esm({
|
|
4926
5012
|
"packages/domain/engine/src/native-bridge.ts"() {
|
|
5013
|
+
"use strict";
|
|
4927
5014
|
init_src();
|
|
4928
5015
|
log4 = createDebugLogger("engine:native");
|
|
4929
5016
|
isValidEngineBinding = (module) => {
|
|
@@ -5004,15 +5091,24 @@ var init_native_bridge2 = __esm({
|
|
|
5004
5091
|
|
|
5005
5092
|
// packages/presentation/vite/src/plugin.ts
|
|
5006
5093
|
init_src2();
|
|
5094
|
+
import fs13 from "fs";
|
|
5095
|
+
import path15 from "path";
|
|
5096
|
+
|
|
5097
|
+
// packages/domain/engine/src/index.ts
|
|
5098
|
+
import fs12 from "fs";
|
|
5099
|
+
import path14 from "path";
|
|
5100
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
5007
5101
|
|
|
5008
5102
|
// packages/domain/analyzer/src/analyzeWorkspace.ts
|
|
5009
5103
|
init_src3();
|
|
5104
|
+
import path11 from "path";
|
|
5010
5105
|
|
|
5011
5106
|
// packages/domain/analyzer/src/binding.ts
|
|
5012
5107
|
init_src();
|
|
5013
5108
|
|
|
5014
5109
|
// packages/domain/analyzer/src/utils.ts
|
|
5015
5110
|
init_src();
|
|
5111
|
+
import fs8 from "fs";
|
|
5016
5112
|
var DEFAULT_TOP_LIMIT = 10;
|
|
5017
5113
|
var DEFAULT_FREQUENT_THRESHOLD = 2;
|
|
5018
5114
|
var DEBUG_NAMESPACE = "tailwind-styled:analyzer";
|
|
@@ -5026,7 +5122,7 @@ function isRecord(value) {
|
|
|
5026
5122
|
}
|
|
5027
5123
|
async function pathExists(filePath) {
|
|
5028
5124
|
try {
|
|
5029
|
-
await
|
|
5125
|
+
await fs8.promises.access(filePath, fs8.constants.F_OK);
|
|
5030
5126
|
return true;
|
|
5031
5127
|
} catch {
|
|
5032
5128
|
return false;
|
|
@@ -5125,6 +5221,7 @@ async function requireNativeBinding() {
|
|
|
5125
5221
|
|
|
5126
5222
|
// packages/domain/analyzer/src/schemas.ts
|
|
5127
5223
|
init_src();
|
|
5224
|
+
import { z as z4 } from "zod";
|
|
5128
5225
|
var formatIssuePath3 = (path16) => path16.length > 0 ? path16.map(
|
|
5129
5226
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
5130
5227
|
).join(".") : "<root>";
|
|
@@ -5148,81 +5245,86 @@ var parseWithSchema2 = (schema, data, label) => {
|
|
|
5148
5245
|
parsed.error
|
|
5149
5246
|
);
|
|
5150
5247
|
};
|
|
5151
|
-
var CountSchema =
|
|
5152
|
-
|
|
5153
|
-
name:
|
|
5248
|
+
var CountSchema = z4.number().int().min(0);
|
|
5249
|
+
var ClassUsageSchema = z4.object({
|
|
5250
|
+
name: z4.string(),
|
|
5154
5251
|
count: CountSchema,
|
|
5155
|
-
isUnused:
|
|
5156
|
-
isConflict:
|
|
5252
|
+
isUnused: z4.boolean().optional(),
|
|
5253
|
+
isConflict: z4.boolean().optional()
|
|
5157
5254
|
});
|
|
5158
|
-
|
|
5159
|
-
className:
|
|
5160
|
-
variants:
|
|
5161
|
-
classes:
|
|
5162
|
-
message:
|
|
5255
|
+
var ClassConflictSchema = z4.object({
|
|
5256
|
+
className: z4.string(),
|
|
5257
|
+
variants: z4.array(z4.string()),
|
|
5258
|
+
classes: z4.array(z4.string()),
|
|
5259
|
+
message: z4.string()
|
|
5163
5260
|
});
|
|
5164
|
-
var ClassCountSchema =
|
|
5165
|
-
name:
|
|
5261
|
+
var ClassCountSchema = z4.object({
|
|
5262
|
+
name: z4.string(),
|
|
5166
5263
|
count: CountSchema
|
|
5167
5264
|
});
|
|
5168
|
-
var NativeReportSchema =
|
|
5169
|
-
root:
|
|
5265
|
+
var NativeReportSchema = z4.object({
|
|
5266
|
+
root: z4.string(),
|
|
5170
5267
|
totalFiles: CountSchema,
|
|
5171
5268
|
uniqueClassCount: CountSchema,
|
|
5172
5269
|
totalClassOccurrences: CountSchema,
|
|
5173
|
-
topClasses:
|
|
5174
|
-
duplicateCandidates:
|
|
5175
|
-
safelist:
|
|
5270
|
+
topClasses: z4.array(ClassCountSchema),
|
|
5271
|
+
duplicateCandidates: z4.array(ClassCountSchema),
|
|
5272
|
+
safelist: z4.array(z4.string())
|
|
5176
5273
|
});
|
|
5177
|
-
|
|
5178
|
-
css:
|
|
5179
|
-
resolvedClasses:
|
|
5180
|
-
unknownClasses:
|
|
5274
|
+
var NativeCssCompileResultSchema2 = z4.object({
|
|
5275
|
+
css: z4.string(),
|
|
5276
|
+
resolvedClasses: z4.array(z4.string()),
|
|
5277
|
+
unknownClasses: z4.array(z4.string()),
|
|
5181
5278
|
sizeBytes: CountSchema
|
|
5182
5279
|
});
|
|
5183
|
-
var AnalyzerClassStatsSchema =
|
|
5184
|
-
top:
|
|
5280
|
+
var AnalyzerClassStatsSchema = z4.object({
|
|
5281
|
+
top: z4.number({
|
|
5185
5282
|
error: "analyzeWorkspace options.classStats.top must be a number when provided."
|
|
5186
5283
|
}).finite().optional(),
|
|
5187
|
-
frequentThreshold:
|
|
5284
|
+
frequentThreshold: z4.number({
|
|
5188
5285
|
error: "analyzeWorkspace options.classStats.frequentThreshold must be a number when provided."
|
|
5189
5286
|
}).finite().optional()
|
|
5190
5287
|
});
|
|
5191
|
-
var AnalyzerSemanticOptionsSchema =
|
|
5192
|
-
tailwindConfigPath:
|
|
5288
|
+
var AnalyzerSemanticOptionsSchema = z4.object({
|
|
5289
|
+
tailwindConfigPath: z4.string({
|
|
5193
5290
|
error: "analyzeWorkspace options.semantic.tailwindConfigPath must be a non-empty string when provided."
|
|
5194
5291
|
}).min(
|
|
5195
5292
|
1,
|
|
5196
5293
|
"analyzeWorkspace options.semantic.tailwindConfigPath must be a non-empty string when provided."
|
|
5197
5294
|
).optional()
|
|
5198
5295
|
});
|
|
5199
|
-
var AnalyzerOptionsSchema =
|
|
5200
|
-
scanner:
|
|
5296
|
+
var AnalyzerOptionsSchema = z4.object({
|
|
5297
|
+
scanner: z4.custom(
|
|
5201
5298
|
(value) => isPlainObject(value),
|
|
5202
5299
|
"analyzeWorkspace options.scanner must be an object when provided."
|
|
5203
5300
|
).optional(),
|
|
5204
5301
|
classStats: AnalyzerClassStatsSchema.optional(),
|
|
5205
|
-
semantic:
|
|
5206
|
-
|
|
5302
|
+
semantic: z4.union([
|
|
5303
|
+
z4.boolean({
|
|
5207
5304
|
error: "analyzeWorkspace options.semantic must be a boolean or an object when provided."
|
|
5208
5305
|
}),
|
|
5209
5306
|
AnalyzerSemanticOptionsSchema
|
|
5210
5307
|
]).optional(),
|
|
5211
|
-
includeClass:
|
|
5308
|
+
includeClass: z4.custom(
|
|
5212
5309
|
(value) => typeof value === "function",
|
|
5213
5310
|
"analyzeWorkspace options.includeClass must be a function when provided."
|
|
5214
5311
|
).optional()
|
|
5215
5312
|
});
|
|
5216
|
-
|
|
5217
|
-
prefix:
|
|
5313
|
+
var ClassToCssOptionsSchema = z4.object({
|
|
5314
|
+
prefix: z4.union([z4.string(), z4.null()], {
|
|
5218
5315
|
error: "classToCss options.prefix must be a string or null when provided."
|
|
5219
5316
|
}).optional(),
|
|
5220
|
-
strict:
|
|
5317
|
+
strict: z4.boolean({
|
|
5221
5318
|
error: "classToCss options.strict must be a boolean when provided."
|
|
5222
5319
|
}).optional()
|
|
5223
5320
|
});
|
|
5224
5321
|
var parseAnalyzerOptions = (options) => parseWithSchema2(AnalyzerOptionsSchema, options ?? {}, "analyzeWorkspace options are invalid");
|
|
5225
5322
|
var parseNativeReport = (report) => parseWithSchema2(NativeReportSchema, report, "Native analyzer report is invalid");
|
|
5323
|
+
|
|
5324
|
+
// packages/domain/analyzer/src/semantic.ts
|
|
5325
|
+
import fs9 from "fs";
|
|
5326
|
+
import path10 from "path";
|
|
5327
|
+
import { pathToFileURL } from "url";
|
|
5226
5328
|
var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
|
|
5227
5329
|
var tailwindConfigCache = /* @__PURE__ */ new Map();
|
|
5228
5330
|
var detectConflicts2 = async (usages) => {
|
|
@@ -5242,11 +5344,11 @@ var detectConflicts2 = async (usages) => {
|
|
|
5242
5344
|
};
|
|
5243
5345
|
};
|
|
5244
5346
|
var isSupportedTailwindConfigPath = (configPath) => {
|
|
5245
|
-
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(
|
|
5347
|
+
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path10.extname(configPath).toLowerCase());
|
|
5246
5348
|
};
|
|
5247
5349
|
var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
5248
5350
|
if (explicitPath) {
|
|
5249
|
-
const resolved =
|
|
5351
|
+
const resolved = path10.resolve(root, explicitPath);
|
|
5250
5352
|
if (!await pathExists(resolved)) return null;
|
|
5251
5353
|
return resolved;
|
|
5252
5354
|
}
|
|
@@ -5257,7 +5359,7 @@ var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
|
5257
5359
|
"tailwind.config.mjs"
|
|
5258
5360
|
];
|
|
5259
5361
|
for (const candidate of candidates) {
|
|
5260
|
-
const fullPath =
|
|
5362
|
+
const fullPath = path10.resolve(root, candidate);
|
|
5261
5363
|
if (await pathExists(fullPath)) return fullPath;
|
|
5262
5364
|
}
|
|
5263
5365
|
return null;
|
|
@@ -5311,7 +5413,7 @@ var collectCustomUtilities = (config) => {
|
|
|
5311
5413
|
return out;
|
|
5312
5414
|
};
|
|
5313
5415
|
var collectSafelistFromSource = async (configPath) => {
|
|
5314
|
-
const source = await
|
|
5416
|
+
const source = await fs9.promises.readFile(configPath, "utf8");
|
|
5315
5417
|
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src3(), src_exports2));
|
|
5316
5418
|
const allTokens = extractClassesNative2(source);
|
|
5317
5419
|
const hasSafelist = source.includes("safelist");
|
|
@@ -5338,7 +5440,7 @@ var loadTailwindConfig2 = async (root, semanticOption) => {
|
|
|
5338
5440
|
customUtilities: /* @__PURE__ */ new Set()
|
|
5339
5441
|
};
|
|
5340
5442
|
}
|
|
5341
|
-
const configStat = await
|
|
5443
|
+
const configStat = await fs9.promises.stat(configPath).catch(() => null);
|
|
5342
5444
|
if (configStat) {
|
|
5343
5445
|
const cached = tailwindConfigCache.get(configPath);
|
|
5344
5446
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -5497,7 +5599,7 @@ async function buildDistribution(usages, native) {
|
|
|
5497
5599
|
}
|
|
5498
5600
|
async function analyzeWorkspace(root, options = {}) {
|
|
5499
5601
|
const startedAtMs = Date.now();
|
|
5500
|
-
const resolvedRoot =
|
|
5602
|
+
const resolvedRoot = path11.resolve(root);
|
|
5501
5603
|
const normalizedOptions = parseAnalyzerOptions(options);
|
|
5502
5604
|
const scan = await (async () => {
|
|
5503
5605
|
const scanStartedAtMs = Date.now();
|
|
@@ -5609,6 +5711,8 @@ init_src();
|
|
|
5609
5711
|
init_src3();
|
|
5610
5712
|
init_src();
|
|
5611
5713
|
init_native_bridge2();
|
|
5714
|
+
import fs10 from "fs";
|
|
5715
|
+
import path12 from "path";
|
|
5612
5716
|
var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
5613
5717
|
var log5 = createLogger2("engine:incremental");
|
|
5614
5718
|
function rebuildWorkspaceResult2(byFile) {
|
|
@@ -5641,8 +5745,8 @@ function areClassSetsEqual(a, b) {
|
|
|
5641
5745
|
function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
5642
5746
|
const includeExtensions = scanner?.includeExtensions ?? DEFAULT_EXTENSIONS2;
|
|
5643
5747
|
if (!isScannableFile2(filePath, includeExtensions)) return previous;
|
|
5644
|
-
const byFile = new Map(previous.files.map((f) => [
|
|
5645
|
-
const normalizedPath =
|
|
5748
|
+
const byFile = new Map(previous.files.map((f) => [path12.resolve(f.file), f]));
|
|
5749
|
+
const normalizedPath = path12.resolve(filePath);
|
|
5646
5750
|
const native = getNativeEngineBinding();
|
|
5647
5751
|
if (!native?.processFileChange) {
|
|
5648
5752
|
throw new Error(
|
|
@@ -5658,7 +5762,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
5658
5762
|
}
|
|
5659
5763
|
log5.debug(`native change ${normalizedPath}`);
|
|
5660
5764
|
const scanned = scanFile2(normalizedPath);
|
|
5661
|
-
const content =
|
|
5765
|
+
const content = fs10.readFileSync(normalizedPath, "utf8");
|
|
5662
5766
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
5663
5767
|
const existing = byFile.get(normalizedPath);
|
|
5664
5768
|
if (diff && existing) {
|
|
@@ -5723,12 +5827,16 @@ var EngineMetricsCollector = class {
|
|
|
5723
5827
|
|
|
5724
5828
|
// packages/domain/engine/src/metricsWriter.ts
|
|
5725
5829
|
init_src();
|
|
5830
|
+
import fs11 from "fs";
|
|
5831
|
+
import path13 from "path";
|
|
5832
|
+
import { performance } from "perf_hooks";
|
|
5833
|
+
var _log = createLogger2("tw:metrics");
|
|
5726
5834
|
var METRICS_FILE_NAME = "metrics.json";
|
|
5727
5835
|
var CACHE_DIR = ".tw-cache";
|
|
5728
5836
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
5729
5837
|
try {
|
|
5730
|
-
const cacheDir =
|
|
5731
|
-
|
|
5838
|
+
const cacheDir = path13.join(cwd, CACHE_DIR);
|
|
5839
|
+
fs11.mkdirSync(cacheDir, { recursive: true });
|
|
5732
5840
|
const mem = process.memoryUsage();
|
|
5733
5841
|
const data = {
|
|
5734
5842
|
...metrics,
|
|
@@ -5739,7 +5847,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
5739
5847
|
},
|
|
5740
5848
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5741
5849
|
};
|
|
5742
|
-
|
|
5850
|
+
fs11.writeFileSync(path13.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
5743
5851
|
} catch {
|
|
5744
5852
|
}
|
|
5745
5853
|
}
|
|
@@ -5791,6 +5899,9 @@ async function runAfterWatch(plugins, context) {
|
|
|
5791
5899
|
await plugin.afterWatch?.(context);
|
|
5792
5900
|
}
|
|
5793
5901
|
}
|
|
5902
|
+
|
|
5903
|
+
// packages/domain/engine/src/schemas.ts
|
|
5904
|
+
import { z as z5 } from "zod";
|
|
5794
5905
|
var formatIssues3 = (error) => error.issues.map((issue) => {
|
|
5795
5906
|
const p = issue.path.length > 0 ? issue.path.join(".") : "<root>";
|
|
5796
5907
|
return `${p}: ${issue.message}`;
|
|
@@ -5800,46 +5911,46 @@ var parseWithSchema3 = (schema, data, label) => {
|
|
|
5800
5911
|
if (parsed.success) return parsed.data;
|
|
5801
5912
|
throw new TypeError(`${label}: ${formatIssues3(parsed.error)}`);
|
|
5802
5913
|
};
|
|
5803
|
-
var EngineOptionsSchema =
|
|
5804
|
-
root:
|
|
5805
|
-
scanner:
|
|
5806
|
-
includeExtensions:
|
|
5807
|
-
ignoreDirectories:
|
|
5808
|
-
useCache:
|
|
5809
|
-
cacheDir:
|
|
5810
|
-
smartInvalidation:
|
|
5914
|
+
var EngineOptionsSchema = z5.object({
|
|
5915
|
+
root: z5.string().optional(),
|
|
5916
|
+
scanner: z5.object({
|
|
5917
|
+
includeExtensions: z5.array(z5.string()).optional(),
|
|
5918
|
+
ignoreDirectories: z5.array(z5.string()).optional(),
|
|
5919
|
+
useCache: z5.boolean().optional(),
|
|
5920
|
+
cacheDir: z5.string().min(1).optional(),
|
|
5921
|
+
smartInvalidation: z5.boolean().optional()
|
|
5811
5922
|
}).optional(),
|
|
5812
|
-
compileCss:
|
|
5813
|
-
tailwindConfigPath:
|
|
5814
|
-
analyze:
|
|
5815
|
-
plugins:
|
|
5923
|
+
compileCss: z5.boolean().optional(),
|
|
5924
|
+
tailwindConfigPath: z5.string().optional(),
|
|
5925
|
+
analyze: z5.boolean().optional(),
|
|
5926
|
+
plugins: z5.array(z5.custom()).optional()
|
|
5816
5927
|
});
|
|
5817
|
-
var EngineWatchOptionsSchema =
|
|
5818
|
-
debounceMs:
|
|
5819
|
-
maxEventsPerFlush:
|
|
5820
|
-
largeFileThreshold:
|
|
5928
|
+
var EngineWatchOptionsSchema = z5.object({
|
|
5929
|
+
debounceMs: z5.number().int().min(0).optional(),
|
|
5930
|
+
maxEventsPerFlush: z5.number().int().min(1).optional(),
|
|
5931
|
+
largeFileThreshold: z5.number().int().min(0).optional()
|
|
5821
5932
|
});
|
|
5822
|
-
|
|
5823
|
-
scan:
|
|
5824
|
-
files:
|
|
5825
|
-
|
|
5933
|
+
var BuildResultSchema = z5.object({
|
|
5934
|
+
scan: z5.object({
|
|
5935
|
+
files: z5.array(
|
|
5936
|
+
z5.object({ file: z5.string(), classes: z5.array(z5.string()), hash: z5.string().optional() })
|
|
5826
5937
|
),
|
|
5827
|
-
totalFiles:
|
|
5828
|
-
uniqueClasses:
|
|
5938
|
+
totalFiles: z5.number().int().min(0),
|
|
5939
|
+
uniqueClasses: z5.array(z5.string())
|
|
5829
5940
|
}),
|
|
5830
|
-
mergedClassList:
|
|
5831
|
-
css:
|
|
5832
|
-
analysis:
|
|
5833
|
-
unusedClasses:
|
|
5834
|
-
classConflicts:
|
|
5835
|
-
|
|
5836
|
-
className:
|
|
5837
|
-
files:
|
|
5838
|
-
classes:
|
|
5839
|
-
message:
|
|
5941
|
+
mergedClassList: z5.string(),
|
|
5942
|
+
css: z5.string(),
|
|
5943
|
+
analysis: z5.object({
|
|
5944
|
+
unusedClasses: z5.array(z5.string()),
|
|
5945
|
+
classConflicts: z5.array(
|
|
5946
|
+
z5.object({
|
|
5947
|
+
className: z5.string(),
|
|
5948
|
+
files: z5.array(z5.string()),
|
|
5949
|
+
classes: z5.array(z5.string()).optional(),
|
|
5950
|
+
message: z5.string().optional()
|
|
5840
5951
|
})
|
|
5841
5952
|
),
|
|
5842
|
-
classUsage:
|
|
5953
|
+
classUsage: z5.record(z5.string(), z5.number())
|
|
5843
5954
|
}).optional()
|
|
5844
5955
|
});
|
|
5845
5956
|
var parseEngineOptions = (options) => parseWithSchema3(EngineOptionsSchema, options ?? {}, "engine options are invalid");
|
|
@@ -5938,11 +6049,11 @@ var configState = {
|
|
|
5938
6049
|
var log6 = createLogger2("engine");
|
|
5939
6050
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
5940
6051
|
if (!tailwindConfigPath) return void 0;
|
|
5941
|
-
const configPath =
|
|
5942
|
-
if (!
|
|
6052
|
+
const configPath = path14.resolve(root, tailwindConfigPath);
|
|
6053
|
+
if (!fs12.existsSync(configPath)) {
|
|
5943
6054
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
5944
6055
|
}
|
|
5945
|
-
const imported = await import(
|
|
6056
|
+
const imported = await import(pathToFileURL2(configPath).href);
|
|
5946
6057
|
const config = imported.default ?? imported;
|
|
5947
6058
|
return config;
|
|
5948
6059
|
}
|
|
@@ -6005,11 +6116,11 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
6005
6116
|
};
|
|
6006
6117
|
}
|
|
6007
6118
|
function countWorkspacePackages(root) {
|
|
6008
|
-
const packagesDir =
|
|
6009
|
-
if (!
|
|
6119
|
+
const packagesDir = path14.join(root, "packages");
|
|
6120
|
+
if (!fs12.existsSync(packagesDir)) return 0;
|
|
6010
6121
|
try {
|
|
6011
|
-
return
|
|
6012
|
-
(entry) => entry.isDirectory() &&
|
|
6122
|
+
return fs12.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
6123
|
+
(entry) => entry.isDirectory() && fs12.existsSync(path14.join(packagesDir, entry.name, "package.json"))
|
|
6013
6124
|
).length;
|
|
6014
6125
|
} catch (err) {
|
|
6015
6126
|
log6.debug(`countWorkspacePackages: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -6046,7 +6157,7 @@ function writeDashboardMetrics(root, mode, result, metrics) {
|
|
|
6046
6157
|
async function createEngine(rawOptions = {}) {
|
|
6047
6158
|
const options = parseEngineOptions(rawOptions);
|
|
6048
6159
|
const root = options.root ?? process.cwd();
|
|
6049
|
-
const resolvedRoot =
|
|
6160
|
+
const resolvedRoot = path14.resolve(root);
|
|
6050
6161
|
const plugins = rawOptions.plugins ?? [];
|
|
6051
6162
|
const getTailwindConfig = async () => {
|
|
6052
6163
|
if (configState.isLoaded()) return configState.getConfig();
|
|
@@ -6193,7 +6304,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
6193
6304
|
const shouldForceFullRescan = (event) => {
|
|
6194
6305
|
if (event.type === "unlink") return false;
|
|
6195
6306
|
try {
|
|
6196
|
-
const stat =
|
|
6307
|
+
const stat = fs12.statSync(event.filePath);
|
|
6197
6308
|
if (stat.size > largeFileThreshold) {
|
|
6198
6309
|
metrics.markSkippedLargeFile();
|
|
6199
6310
|
return true;
|
|
@@ -6313,6 +6424,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
6313
6424
|
|
|
6314
6425
|
// packages/presentation/vite/src/schemas.ts
|
|
6315
6426
|
init_src();
|
|
6427
|
+
import { z as z6 } from "zod";
|
|
6316
6428
|
var formatIssuePath4 = (path16) => path16.length > 0 ? path16.map(
|
|
6317
6429
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
6318
6430
|
).join(".") : "<root>";
|
|
@@ -6331,23 +6443,23 @@ var parseWithSchema4 = (schema, data, label) => {
|
|
|
6331
6443
|
parsed.error
|
|
6332
6444
|
);
|
|
6333
6445
|
};
|
|
6334
|
-
var VitePluginOptionsSchema =
|
|
6335
|
-
include:
|
|
6336
|
-
exclude:
|
|
6337
|
-
scanDirs:
|
|
6338
|
-
safelistOutput:
|
|
6339
|
-
generateSafelist:
|
|
6340
|
-
scanReportOutput:
|
|
6341
|
-
useEngineBuild:
|
|
6342
|
-
analyze:
|
|
6343
|
-
strict:
|
|
6344
|
-
mode:
|
|
6345
|
-
routeCss:
|
|
6346
|
-
deadStyleElimination:
|
|
6347
|
-
addDataAttr:
|
|
6348
|
-
autoClientBoundary:
|
|
6349
|
-
hoist:
|
|
6350
|
-
incremental:
|
|
6446
|
+
var VitePluginOptionsSchema = z6.object({
|
|
6447
|
+
include: z6.instanceof(RegExp).optional(),
|
|
6448
|
+
exclude: z6.instanceof(RegExp).optional(),
|
|
6449
|
+
scanDirs: z6.array(z6.string()).optional(),
|
|
6450
|
+
safelistOutput: z6.string().optional(),
|
|
6451
|
+
generateSafelist: z6.boolean().optional(),
|
|
6452
|
+
scanReportOutput: z6.string().optional(),
|
|
6453
|
+
useEngineBuild: z6.boolean().optional(),
|
|
6454
|
+
analyze: z6.boolean().optional(),
|
|
6455
|
+
strict: z6.boolean().optional(),
|
|
6456
|
+
mode: z6.enum(["zero-runtime", "runtime"]).optional(),
|
|
6457
|
+
routeCss: z6.boolean().optional(),
|
|
6458
|
+
deadStyleElimination: z6.boolean().optional(),
|
|
6459
|
+
addDataAttr: z6.boolean().optional(),
|
|
6460
|
+
autoClientBoundary: z6.boolean().optional(),
|
|
6461
|
+
hoist: z6.boolean().optional(),
|
|
6462
|
+
incremental: z6.boolean().optional()
|
|
6351
6463
|
});
|
|
6352
6464
|
var parseVitePluginOptions = (options) => parseWithSchema4(VitePluginOptionsSchema, options ?? {}, "vite plugin options are invalid");
|
|
6353
6465
|
|
|
@@ -6359,14 +6471,14 @@ function warnDeprecated(options, key, message) {
|
|
|
6359
6471
|
}
|
|
6360
6472
|
}
|
|
6361
6473
|
function isInsideDirectory(filePath, directory) {
|
|
6362
|
-
const relative =
|
|
6363
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
6474
|
+
const relative = path15.relative(directory, filePath);
|
|
6475
|
+
return relative === "" || !relative.startsWith("..") && !path15.isAbsolute(relative);
|
|
6364
6476
|
}
|
|
6365
6477
|
function filterScanToDirs(scan, root, scanDirs) {
|
|
6366
|
-
const resolvedDirs = scanDirs.map((dir) =>
|
|
6478
|
+
const resolvedDirs = scanDirs.map((dir) => path15.resolve(root, dir));
|
|
6367
6479
|
if (resolvedDirs.length === 0) return scan;
|
|
6368
6480
|
const files = scan.files.filter((file) => {
|
|
6369
|
-
const absoluteFile =
|
|
6481
|
+
const absoluteFile = path15.resolve(file.file);
|
|
6370
6482
|
return resolvedDirs.some((directory) => isInsideDirectory(absoluteFile, directory));
|
|
6371
6483
|
});
|
|
6372
6484
|
const uniqueClasses = Array.from(new Set(files.flatMap((file) => file.classes))).sort();
|
|
@@ -6377,9 +6489,9 @@ function filterScanToDirs(scan, root, scanDirs) {
|
|
|
6377
6489
|
};
|
|
6378
6490
|
}
|
|
6379
6491
|
function writeJsonArtifact(root, relativePath, value) {
|
|
6380
|
-
const outputPath =
|
|
6381
|
-
|
|
6382
|
-
|
|
6492
|
+
const outputPath = path15.resolve(root, relativePath);
|
|
6493
|
+
fs13.mkdirSync(path15.dirname(outputPath), { recursive: true });
|
|
6494
|
+
fs13.writeFileSync(outputPath, `${JSON.stringify(value, null, 2)}
|
|
6383
6495
|
`);
|
|
6384
6496
|
}
|
|
6385
6497
|
function tailwindStyledPlugin(opts = {}) {
|
|
@@ -6420,7 +6532,7 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
6420
6532
|
return rules.join("\n");
|
|
6421
6533
|
}
|
|
6422
6534
|
function getStaticCssOutputPath(root, safelistOutputPath) {
|
|
6423
|
-
return
|
|
6535
|
+
return path15.resolve(root, path15.dirname(safelistOutputPath), "_tw-state-static.css");
|
|
6424
6536
|
}
|
|
6425
6537
|
function flushStaticCss(root) {
|
|
6426
6538
|
if (staticCssPerFile.size === 0) return;
|
|
@@ -6429,8 +6541,8 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
6429
6541
|
if (!deduped.trim()) return;
|
|
6430
6542
|
const outPath = getStaticCssOutputPath(root, safelistOutput);
|
|
6431
6543
|
try {
|
|
6432
|
-
|
|
6433
|
-
|
|
6544
|
+
fs13.mkdirSync(path15.dirname(outPath), { recursive: true });
|
|
6545
|
+
fs13.writeFileSync(
|
|
6434
6546
|
outPath,
|
|
6435
6547
|
`/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
|
|
6436
6548
|
* Import this in globals.css: @import "./_tw-state-static.css";
|
|
@@ -6462,17 +6574,17 @@ ${deduped}
|
|
|
6462
6574
|
"src/style.css"
|
|
6463
6575
|
];
|
|
6464
6576
|
for (const candidate of CSS_CANDIDATES) {
|
|
6465
|
-
const candidatePath =
|
|
6466
|
-
if (!
|
|
6467
|
-
const content =
|
|
6577
|
+
const candidatePath = path15.resolve(config.root, candidate);
|
|
6578
|
+
if (!fs13.existsSync(candidatePath)) continue;
|
|
6579
|
+
const content = fs13.readFileSync(candidatePath, "utf-8");
|
|
6468
6580
|
if (content.includes("_tw-state-static.css")) break;
|
|
6469
|
-
const rel =
|
|
6581
|
+
const rel = path15.relative(path15.dirname(candidatePath), outPath).replace(/\\/g, "/");
|
|
6470
6582
|
const importLine = `@import "./${rel}";`;
|
|
6471
6583
|
const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
|
|
6472
6584
|
const updated = tailwindImportRe.test(content) ? content.replace(tailwindImportRe, `$1${importLine}
|
|
6473
6585
|
`) : `${importLine}
|
|
6474
6586
|
${content}`;
|
|
6475
|
-
|
|
6587
|
+
fs13.writeFileSync(candidatePath, updated, "utf-8");
|
|
6476
6588
|
break;
|
|
6477
6589
|
}
|
|
6478
6590
|
} catch {
|
|
@@ -6556,7 +6668,7 @@ ${content}`;
|
|
|
6556
6668
|
}
|
|
6557
6669
|
};
|
|
6558
6670
|
}
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6671
|
+
export {
|
|
6672
|
+
tailwindStyledPlugin
|
|
6673
|
+
};
|
|
6562
6674
|
//# sourceMappingURL=vite.mjs.map
|