tailwind-styled-v4 5.0.13 → 5.0.15
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/atomic.js +14 -14
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +14 -14
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +14 -14
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +14 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.js +14 -14
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +14 -14
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +14 -14
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +14 -14
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +3 -1
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +45 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -25
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +14 -14
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +14 -14
- package/dist/next.mjs.map +1 -1
- package/dist/shared.d.mts +3 -2
- package/dist/shared.d.ts +3 -2
- package/dist/shared.js +14 -14
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +14 -14
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +42 -24
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +42 -24
- package/dist/svelte.mjs.map +1 -1
- package/dist/turbopackLoader.js +14 -14
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +14 -14
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +14 -14
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +14 -14
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +14 -14
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +14 -14
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +42 -24
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +42 -24
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +14 -14
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +14 -14
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +5 -2
- package/native/index.node +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/domain/shared/src/native-resolution.ts","../packages/domain/shared/src/index.ts","../packages/domain/compiler/src/nativeBridge.ts","../packages/domain/compiler/src/compiler/index.ts","../packages/domain/compiler/src/parser/index.ts","../packages/domain/compiler/src/analyzer/index.ts","../packages/domain/compiler/src/cache/index.ts","../packages/domain/compiler/src/redis/index.ts","../packages/domain/compiler/src/watch/index.ts","../packages/domain/compiler/src/index.ts","../packages/domain/compiler/src/internal.ts","../packages/presentation/next/src/webpackLoader.ts","../packages/presentation/next/src/staticCssWebpackPlugin.ts"],"names":["fs","path","createRequire","fileURLToPath","init_src","z"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI,WAAW,OAAO,SAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAAI,QAAQ,IAAI,CAAA,CAAA;AAC5C;AAaO,SAAS,oBAAoB,UAAA,EAA6C;AAC/E,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,CAAC,0BAA0B,CAAA,EAAE;AAAA,EAC1F;AAIA,EAAA,IAAI,QAAQ,GAAA,CAAI,aAAA,KAAkB,OAAO,OAAA,CAAQ,GAAA,CAAI,uBAAuB,GAAA,EAAK;AAC/E,IAAA,OAAO,EAAE,M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YAAA,EAAc;AACzC,MAAA,QAAA,CAAS,GAAA,YAAe,QAAQ,GAAA,GAAM,IAAI,MAAM,MAAA,CAAO,GAAG,CAAC,CAAC,CAAA;AAC5D,MAAA;AAAA,IACF;AAEA,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,kDAAA,EAAqD,QAAQ,CAAA,CAAA,CAAA,EAAK,GAAG,CAAA;AAClF,IAAA,QAAA,CAAS,MAAM,MAAM,CAAA;AAAA,EACvB;AACF","file":"webpackLoader.js","sourcesContent":["/**\r\n * Prebuilt binary resolution untuk native NAPI bindings.\r\n * QA #1: Resolve native binary dari prebuilt packages atau local build.\r\n *\r\n * Prioritas:\r\n * 1. TW_NATIVE_PATH env var (explicit override)\r\n * 2. Prebuilt binary dari platform-specific npm package\r\n * 3. Local build dari source (developer mode)\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport * as fs from \"node:fs\"\r\nimport * as path from \"node:path\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require — works in both ESM and CJS contexts\r\nconst _require = typeof require !== \"undefined\" ? require : createRequire(import.meta.url)\r\n\r\nexport interface NativeResolutionResult {\r\n path: string | null\r\n source: \"env\" | \"prebuilt\" | \"local\" | \"not-found\"\r\n platform: string\r\n tried: string[]\r\n}\r\n\r\n/** Platform key → prebuilt npm package name */\r\nconst PLATFORM_MAP: Record<string, string[]> = {\r\n \"linux-x64\": [\"@tailwind-styled/native-linux-x64-gnu\", \"@tailwind-styled/native-linux-x64\"],\r\n \"linux-arm64\": [\"@tailwind-styled/native-linux-arm64-gnu\", \"@tailwind-styled/native-linux-arm64\"],\r\n \"darwin-x64\": [\"@tailwind-styled/native-darwin-x64\"],\r\n \"darwin-arm64\": [\"@tailwind-styled/native-darwin-arm64\"],\r\n \"win32-x64\": [\"@tailwind-styled/native-win32-x64-msvc\", \"@tailwind-styled/native-win32-x64\"],\r\n \"win32-arm64\": [\"@tailwind-styled/native-win32-arm64-msvc\", \"@tailwind-styled/native-win32-arm64\"],\r\n}\r\n\r\nfunction platformKey(): string {\r\n if (isBrowser) return \"browser\"\r\n return `${process.platform}-${process.arch}`\r\n}\r\n\r\n/**\r\n * Resolve native binary path dari semua sumber yang tersedia.\r\n *\r\n * @example\r\n * const result = resolveNativeBinary()\r\n * if (result.path) {\r\n * const binding = require(result.path)\r\n * } else {\r\n * throw new Error(\"Native binding not found — run npm run build:rust\")\r\n * }\r\n */\r\nexport function resolveNativeBinary(runtimeDir?: string): NativeResolutionResult {\r\n const platform = platformKey()\r\n const tried: string[] = []\r\n\r\n if (isBrowser) {\r\n return { path: null, source: \"not-found\", platform, tried: [\"not available in browser\"] }\r\n }\r\n\r\n // 0. Disabled flag — always short-circuit before any I/O\r\n // TWS_NO_NATIVE adalah nama canonical; TWS_DISABLE_NATIVE diterima untuk backward compat\r\n if (process.env.TWS_NO_NATIVE === \"1\" || process.env.TWS_DISABLE_NATIVE === \"1\") {\r\n return { path: null, source: \"not-found\", platform, tried: [] }\r\n }\r\n\r\n // 1. Env var override\r\n const envPath = process.env.TW_NATIVE_PATH?.trim()\r\n if (envPath) {\r\n if (fs.existsSync(envPath)) {\r\n return { path: envPath, source: \"env\", platform, tried }\r\n }\r\n tried.push(`env:${envPath} (not found)`)\r\n }\r\n\r\n // 2. Prebuilt binary dari platform-specific npm package\r\n const prebuiltPkgs = PLATFORM_MAP[platform] ?? []\r\n for (const pkg of prebuiltPkgs) {\r\n try {\r\n const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n tried.push(`prebuilt:${pkg} (resolved but missing)`)\r\n } catch {\r\n tried.push(`prebuilt:${pkg} (not installed)`)\r\n }\r\n }\r\n\r\n // 2b. .node file bundled inside this package itself (via \"files\": [\"native/*.node\"])\r\n // Covers the case where user installs tailwind-styled-v4 directly from npm\r\n // and the .node file lands at node_modules/tailwind-styled-v4/native/*.node\r\n const napiPlatform = platform === \"linux-x64\" ? \"linux-x64-gnu\"\r\n : platform === \"linux-arm64\" ? \"linux-arm64-gnu\"\r\n : platform\r\n const BINARY_NAMES_SELF = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n if (runtimeDir) {\r\n // runtimeDir is typically dist/ — go up to package root, then into native/\r\n for (const depth of [\"..\", path.join(\"..\", \"..\"), path.join(\"..\", \"..\", \"..\")]) {\r\n const pkgRoot = path.resolve(runtimeDir, depth)\r\n for (const bin of BINARY_NAMES_SELF) {\r\n for (const suffix of [\"\", `.${platform}`, `.${napiPlatform}`]) {\r\n const candidate = path.resolve(pkgRoot, \"native\", `${bin}${suffix}.node`)\r\n tried.push(`self-bundled:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // 3. Local build candidates\r\n const cwd = process.cwd()\r\n const base = runtimeDir ?? cwd\r\n // napi-rs naming: platform key may have -gnu suffix on Linux (already computed above)\r\n\r\n // Both possible binary names:\r\n // - \"tailwind_styled_parser\" (old hardcoded name in resolvers)\r\n // - \"tailwind-styled-native\" (actual binaryName in native/package.json)\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n\r\n const localCandidates: string[] = []\r\n\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(base, `${bin}.node`))\r\n localCandidates.push(path.resolve(base, \"..\", `${bin}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`))\r\n }\r\n\r\n // Walk up from cwd AND base to find repo root native/ dir\r\n // Needed when npm workspaces sets cwd to the package subdir\r\n for (const startDir of [cwd, base]) {\r\n let dir = startDir\r\n for (let i = 0; i < 6; i++) {\r\n const nativeDir = path.resolve(dir, \"native\")\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, \"target\", \"release\", `${bin}.node`))\r\n }\r\n const parent = path.resolve(dir, \"..\")\r\n if (parent === dir) break\r\n dir = parent\r\n }\r\n }\r\n\r\n for (const candidate of localCandidates) {\r\n tried.push(`local:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"local\", platform, tried }\r\n }\r\n }\r\n\r\n return { path: null, source: \"not-found\", platform, tried }\r\n}\r\n\r\n/**\r\n * Format human-readable error untuk \"binary not found\".\r\n */\r\nexport function formatNativeNotFoundError(result: NativeResolutionResult): string {\r\n const lines = [\r\n `[tailwind-styled] Native binding not found for ${result.platform}`,\r\n ``,\r\n `Tried:`,\r\n ...result.tried.map(t => ` - ${t}`),\r\n ``,\r\n `Solutions:`,\r\n ` 1. Build locally: npm run build:rust`,\r\n ` 2. Install prebuilt: npm install @tailwind-styled/native-${result.platform}`,\r\n ` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node`,\r\n ]\r\n return lines.join(\"\\n\")\r\n}","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"\r\n\r\nexport {\r\n TW_STATE_STATIC_FILENAME,\r\n extractStaticStateCss,\r\n appendStaticStateCssToSafelist,\r\n type TwStateConfigEntry,\r\n type StaticStateCssInput,\r\n type GeneratedStateRule,\r\n type StaticStateExtractionResult,\r\n} from \"./staticStateExtractor\"\r\nexport { setGlobalLogFile } from \"./logger\"","/**\r\n * tailwind-styled-v5 — Native Bridge Loader\r\n *\r\n * Uses @tailwind-styled/shared for native binding resolution.\r\n * All functions require native Rust binding - no JS fallback.\r\n */\r\n\r\nimport { resolveNativeBinary, resolveRuntimeDir } from \"@tailwind-styled/shared\"\r\n\r\n// require() is safe here — tsup banner injects CJS-compatible require into ESM output.\r\n// See tsup.config.ts esbuildOptions banner for how this is set up.\r\nconst _loadNative = (path: string): unknown => require(path)\r\n\r\nexport interface ComponentMetadata {\r\n component: string\r\n tag: string\r\n baseClass: string\r\n subComponents: Record<string, { tag?: string; class: string }>\r\n}\r\n\r\nexport interface NativeRscResult {\r\n isServer: boolean\r\n needsClientDirective: boolean\r\n clientReasons: string[]\r\n}\r\n\r\nconst log = (...args: unknown[]) => {\r\n if (process.env.DEBUG?.includes(\"compiler:native\")) {\r\n console.log(\"[compiler:native]\", ...args)\r\n }\r\n}\r\n\r\n// ── Structured Type Definitions ─────────────────────────────────────────────\r\n\r\nexport interface ScanWorkspaceResult {\r\n files: string[]\r\n total_files: number\r\n classes: string[]\r\n unique_classes: number\r\n duration_ms: number\r\n errors: string[]\r\n}\r\n\r\nexport interface ScanFileResult {\r\n file: string\r\n classes: string[]\r\n class_count: number\r\n has_tw_usage: boolean\r\n size_bytes: number\r\n duration_ms: number\r\n}\r\n\r\nexport interface BatchExtractResult {\r\n file: string\r\n classes: string[]\r\n contentHash: string\r\n ok: boolean\r\n error?: string\r\n}\r\n\r\nexport interface SafelistCheckResult {\r\n matched: string[]\r\n unmatched: string[]\r\n safelistSize: number\r\n}\r\n\r\nexport interface PrefilterFileResult {\r\n file: string\r\n has_tw_usage: boolean\r\n duration_ms: number\r\n size_bytes: number\r\n status: \"processed\" | \"skipped\" | \"error\"\r\n error?: string\r\n}\r\n\r\nexport interface DeadCodeResult {\r\n deadInCss: string[]\r\n deadInSource: string[]\r\n liveClasses: string[]\r\n totalCssClasses: number\r\n totalSourceClasses: number\r\n}\r\n\r\nexport interface ProcessedCssResult {\r\n css: string\r\n size_bytes: number\r\n resolved_classes: string[]\r\n unknown_classes: string[]\r\n}\r\n\r\nexport interface ContainerConfig {\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n}\r\n\r\nexport interface HoistResult {\r\n code: string\r\n hoisted: string[]\r\n warnings: string[]\r\n}\r\n\r\nexport interface VariantTableResult {\r\n id: string\r\n tableJson: string\r\n keys: string[]\r\n defaultKey: string\r\n combinations: number\r\n}\r\n\r\nexport interface ClassifyResult {\r\n className: string\r\n bucket: string\r\n sortOrder: number\r\n}\r\n\r\nexport interface MergeResult {\r\n declarationsJson: string\r\n declarationString: string\r\n count: number\r\n}\r\n\r\nexport interface ClassUsageItem {\r\n className: string\r\n usageCount: number\r\n filesJson: string\r\n bundleSizeBytes: number\r\n isDeadCode: boolean\r\n}\r\n\r\nexport interface StateCssConfig {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n sourceFile: string\r\n}\r\n\r\nexport interface GeneratedStateCss {\r\n selector: string\r\n declarations: string\r\n cssRule: string\r\n componentName: string\r\n stateName: string\r\n}\r\n\r\n// ── Type Exports ────────────────────────────────────────────────────────────────\r\n\r\nexport interface NativeBridge {\r\n // CSS Compiler - New Rust implementation\r\n generateCssNative?: (classes: string[], theme_json: string) => string\r\n getCacheStats?: () => [number, number]\r\n clearThemeCache?: () => void\r\n // Core transform\r\n transformSource?: (source: string, opts?: Record<string, string>) => NativeTransformResult | null\r\n extractClassesFromSource?: (source: string) => string[]\r\n hasTwUsage?: (source: string) => boolean\r\n isAlreadyTransformed?: (source: string) => boolean\r\n // Phase 5: Scanner functions (snake_case from Rust)\r\n scan_workspace?: (root: string, extensions?: string[]) => ScanWorkspaceResult\r\n extract_classes_from_source?: (source: string) => string[]\r\n batch_extract_classes?: (filePaths: string[]) => BatchExtractResult[]\r\n check_against_safelist?: (classes: string[], safelist: string[]) => SafelistCheckResult\r\n scan_file?: (filePath: string) => ScanFileResult\r\n collect_files?: (root: string, extensions?: string[]) => string[]\r\n walk_and_prefilter_source_files?: (root: string, extensions?: string[]) => PrefilterFileResult[]\r\n generate_sub_component_types?: (root: string, outputPath?: string) => string\r\n // Class Extractor\r\n extractAllClasses?: (source: string) => string[]\r\n parseClasses?: (raw: string) => Array<{ raw: string; type: string }>\r\n // Application functions\r\n extractComponentUsage?: (source: string) => Array<{ component: string; propsJson: string }>\r\n normalizeAndDedupClasses?: (raw: string) => { normalized: string; duplicatesRemoved: number; uniqueCount: number }\r\n diffClassLists?: (previous: string[], current: string[]) => { added: string[]; removed: string[]; unchanged: string[]; hasChanges: boolean }\r\n batchExtractClasses?: (filePaths: string[]) => Array<{ file: string; classes: string[]; contentHash: string; ok: boolean; error?: string }>\r\n checkAgainstSafelist?: (classes: string[], safelist: string[]) => { matched: string[]; unmatched: string[]; safelistSize: number }\r\n // Batch 2\r\n hoistComponents?: (source: string) => HoistResult\r\n compileVariantTable?: (configJson: string) => VariantTableResult\r\n classifyAndSortClasses?: (classes: string[]) => ClassifyResult[]\r\n mergeCssDeclarations?: (cssChunks: string[]) => MergeResult\r\n analyzeClassUsage?: (classes: string[], scanResultJson: string, css: string) => ClassUsageItem[]\r\n analyzeRsc?: (source: string, filename: string) => {\r\n isServer: boolean\r\n needsClientDirective: boolean\r\n clientReasons: string[]\r\n }\r\n analyzeClasses?: (\r\n filesJson: string,\r\n cwd: string,\r\n flags: number\r\n ) => {\r\n css?: string\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rscJson?: string\r\n metadataJson?: string\r\n safelist?: string[]\r\n } | null\r\n // CSS compilation\r\n compileCss?: (classes: string[], prefix?: string | null) => { css: string; classes: string[] }\r\n compileCssLightning?: (classes: string[]) => string\r\n /** Post-process raw Tailwind-generated CSS dengan LightningCSS di Rust */\r\n detectDeadCode?: (scanResultJson: string, css: string) => DeadCodeResult\r\n processTailwindCssLightning?: (css: string) => ProcessedCssResult\r\n processTailwindCssWithTargets?: (css: string, targets: string | null) => { css: string; size_bytes: number }\r\n // Atomic CSS (atomic.rs)\r\n parseAtomicClass?: (twClass: string) => string | null\r\n generateAtomicCss?: (rulesJson: string) => string\r\n toAtomicClasses?: (twClasses: string) => string\r\n clearAtomicRegistry?: () => void\r\n atomicRegistrySize?: () => number\r\n // Impact analysis (impact_analysis.rs)\r\n calculateImpact?: (impactJson: string) => string\r\n calculateRisk?: (className: string, totalComponents: number) => string\r\n calculateSavings?: (bundleSizeBytes: number, componentCount: number) => number\r\n // Static state CSS pre-generation (state_css.rs)\r\n extractTwStateConfigs?: (source: string, filename: string) => StateCssConfig[]\r\n generateStaticStateCss?: (inputs: Array<{\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n }>, resolvedCss: string | null) => GeneratedStateCss[]\r\n extractAndGenerateStateCss?: (source: string, filename: string) => GeneratedStateCss[]\r\n /**\r\n * Convert layout/utility class string ke CSS declarations.\r\n * Dipakai oleh extractContainerCssFromSource sebagai Rust-accelerated fallback.\r\n */\r\n layoutClassesToCss?: (classes: string) => string\r\n /**\r\n * Hash string dengan algoritma tertentu, return n karakter pertama.\r\n * Dipakai untuk generate deterministic container CSS IDs.\r\n */\r\n hashContent?: (input: string, algo: string, length: number) => string\r\n /** Hapus dead CSS selectors + minify via Lightning CSS. */\r\n eliminateDeadCss?: (css: string, deadClasses: string[]) => string\r\n /** Dead code detection + strip + Lightning CSS minify dalam satu call. */\r\n optimizeCss?: (css: string) => string\r\n /** Extract tw container configs dari source untuk static @container CSS generation. */\r\n extractTwContainerConfigs?: (source: string) => Array<{\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n }>\r\n \r\n // Phase 5.1: Cache Management (9 functions)\r\n get_cache_statistics?: () => string // Returns JSON\r\n clear_all_caches?: () => void\r\n clear_parse_cache?: () => void\r\n clear_resolve_cache?: () => void\r\n clear_compile_cache?: () => void\r\n clear_css_gen_cache?: () => void\r\n get_cache_optimization_hints?: (hit_rate_percent: number, memory_used_mb: number) => string // Returns JSON\r\n estimate_optimal_cache_config_native?: (total_budget_mb: number, workload_type: string) => string // Returns JSON\r\n cache_read?: (cache_path: string) => { entries_json: string }\r\n cache_write?: (cache_path: string, entries: Array<{ file: string; content_hash: string; classes: string[]; mtime_ms: number; size_bytes: number }>) => boolean\r\n cache_priority?: (mtime_ms: number, size_bytes: number, hit_count: number) => number\r\n \r\n // Phase 5.1: Theme Resolution Extended (7 functions)\r\n resolve_variants?: (configJson: string) => string // Returns JSON\r\n validate_variant_config?: (configJson: string) => string // Returns JSON\r\n resolve_cascade?: (baseThemeJson: string, overridesJson: string) => string // Returns JSON\r\n resolve_class_names?: (classNames: string[], themeJson: string) => string // Returns JSON\r\n resolve_conflict_group?: (groupName: string, themeJson: string) => string // Returns JSON\r\n resolve_theme_value?: (keyPath: string, themeJson: string) => string | null\r\n resolve_simple_variants?: (configJson: string) => string // Returns JSON\r\n \r\n // Phase 5.1: Streaming & Incremental Processing (8 functions)\r\n process_file_change?: (fileChangeJson: string) => string // Returns JSON\r\n compute_incremental_diff?: (oldScanJson: string, newScanJson: string) => string // Returns JSON\r\n create_fingerprint?: (filePath: string, fileContent: string) => string // Returns JSON\r\n inject_state_hash?: (css: string, stateHash: string) => string // Returns JSON\r\n prune_stale_entries?: (maxAgeSeconds: number, maxEntries: number) => string // Returns JSON\r\n rebuild_workspace_result?: (rootDir: string, extensions?: string[]) => string // Returns JSON\r\n scan_file_native?: (filePath: string, fileContent: string) => string // Returns JSON\r\n scan_files_batch_native?: (filesJson: string) => string // Returns JSON\r\n \r\n // Phase 5.2: CSS Compilation (12 functions)\r\n compile_class?: (input: string) => string // Returns JSON\r\n compile_classes?: (inputs: string[]) => string // Returns JSON\r\n compile_to_css?: (input: string, minify: boolean) => string\r\n compile_to_css_batch?: (inputs: string[], minify: boolean) => string\r\n minify_css?: (css: string) => string\r\n compile_animation?: (animationName: string, from: string, to: string) => string // Returns JSON\r\n compile_keyframes?: (name: string, stopsJson: string) => string // Returns JSON\r\n compile_theme?: (tokensJson: string, themeName: string, prefix: string) => string // Returns JSON\r\n tw_merge?: (classString: string) => string\r\n tw_merge_many?: (classStrings: string[]) => string\r\n tw_merge_with_separator?: (classString: string, options: Record<string, unknown>) => string\r\n tw_merge_many_with_separator?: (classStrings: string[], options: Record<string, unknown>) => string\r\n tw_merge_raw?: (classLists: string[]) => string\r\n \r\n // Phase 5.2: ID Registry (16 functions)\r\n id_registry_create?: () => number\r\n id_registry_generate?: (handle: number, name: string) => number\r\n id_registry_lookup?: (handle: number, name: string) => number\r\n id_registry_next?: (handle: number) => number\r\n id_registry_destroy?: (handle: number) => void\r\n id_registry_reset?: (handle: number) => void\r\n id_registry_snapshot?: (handle: number) => string // Returns JSON\r\n id_registry_active_count?: () => number\r\n register_property_name?: (propertyName: string) => number\r\n register_value_name?: (valueName: string) => number\r\n property_id_to_string?: (propertyId: number) => string\r\n value_id_to_string?: (valueId: number) => string\r\n reverse_lookup_property?: (propertyId: number) => string\r\n reverse_lookup_value?: (valueId: number) => string\r\n id_registry_export?: (handle: number) => string\r\n id_registry_import?: (importedData: string) => number\r\n \r\n // Phase 5.3: Redis Integration (40 functions)\r\n redis_ping?: () => string\r\n redis_get?: (key: string) => string\r\n redis_set?: (key: string, value: string, ttl_seconds?: number) => string\r\n redis_delete?: (key: string) => number\r\n redis_exists?: (key: string) => number\r\n redis_mget?: (keys: string[]) => string // Returns JSON\r\n redis_mset?: (pairs: Array<[string, string]>) => string\r\n redis_flush_db?: () => number\r\n redis_flush_all?: () => number\r\n redis_pool_connect?: (host: string, port: number, pool_size?: number) => string\r\n redis_pool_stats?: () => string // Returns JSON\r\n redis_pool_reconnect?: () => string\r\n redis_enable_cluster?: (initial_nodes: string[]) => string // Returns JSON\r\n redis_disable_cluster?: () => string\r\n redis_cluster_status?: () => string // Returns JSON\r\n redis_subscribe?: (channel: string) => string\r\n redis_publish?: (channel: string, message: string) => number\r\n redis_expiration_set?: (key: string, ttl_seconds: number) => number\r\n redis_expiration_get?: (key: string) => string // Returns JSON\r\n redis_info?: () => string\r\n redis_monitor?: () => string\r\n redis_cache_size?: () => number\r\n redis_cache_key_count?: () => number\r\n redis_cache_clear?: () => number\r\n redis_cache_hit_rate?: () => number\r\n redis_enable_persistence?: (mode: string) => string\r\n redis_disable_persistence?: () => string\r\n redis_snapshot?: () => string\r\n redis_memory_stats?: () => string\r\n redis_optimize_memory?: () => number\r\n redis_set_eviction_policy?: (policy: string) => string\r\n redis_get_eviction_policy?: () => string\r\n redis_replicate?: (target_host: string, target_port: number) => number\r\n redis_replication_status?: () => string\r\n redis_cache_sync?: (peers: string[]) => number\r\n redis_enable_cache_warming?: (key_pattern: string) => string\r\n redis_disable_cache_warming?: () => string\r\n redis_diagnose?: () => string\r\n \r\n // Phase 5.4: Watch System & File Monitoring (20 functions)\r\n start_watch?: (root_path: string, patterns?: string[]) => number\r\n poll_watch_events?: (handle: number, timeout_ms?: number) => string // Returns JSON\r\n stop_watch?: (handle: number) => number\r\n watch_add_pattern?: (handle: number, pattern: string) => string\r\n watch_remove_pattern?: (handle: number, pattern: string) => string\r\n watch_get_active_handles?: () => string // Returns JSON\r\n watch_clear_all?: () => number\r\n watch_event_type_to_string?: (event_type_code: number) => string\r\n is_watch_running?: (handle: number) => boolean\r\n get_watch_stats?: () => string // Returns JSON\r\n watch_pause?: (handle: number) => string\r\n watch_resume?: (handle: number) => string\r\n scan_cache_optimizations?: () => string // Returns JSON\r\n get_plugin_hooks?: () => string // Returns JSON\r\n register_plugin_hook?: (hook_name: string, handler_id: string) => string\r\n unregister_plugin_hook?: (hook_name: string, handler_id: string) => string\r\n emit_plugin_hook?: (hook_name: string, data_json: string) => string\r\n get_compilation_metrics?: () => string // Returns JSON\r\n reset_compilation_metrics?: () => string\r\n validate_css_output?: (css: string) => string // Returns JSON\r\n get_compiler_diagnostics?: () => string // Returns JSON\r\n\r\n // ── Cache Management (napi_bridge_cache.rs) ────────────────────────────────\r\n configureCacheBackend?: (configJson: string) => string\r\n getRecommendedCacheConfig?: (workloadType: string) => string\r\n clearAllCachesNapi?: () => void\r\n clearResolveCacheNapi?: () => void\r\n clearCompileCacheNapi?: () => void\r\n clearCssGenCacheNapi?: () => void\r\n getResolverPoolStats?: () => string\r\n clearResolverPool?: () => string\r\n getCacheOptimizationHints?: () => string\r\n estimateStreamingBatchSize?: (targetMemoryMb: number) => string\r\n\r\n // ── Parsing (napi_bridge_parsing.rs) ──────────────────────────────────────\r\n parseClass?: (input: string) => string\r\n compileClassNapi?: (input: string) => string\r\n getParseStats?: () => string\r\n clearParseCacheNapi?: () => void\r\n\r\n // ── Theme Parsing (napi_bridge_theme_parsing.rs) ───────────────────────────\r\n parseColorsNapi?: (colorsJson: string) => string | Record<string, string>\r\n parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>\r\n parseTransformNapi?: (transformJson: string) => string | Record<string, string>\r\n normalizeColorNapi?: (color: string, opacity: string) => string\r\n sanitizeColorNapi?: (color: string) => string\r\n splitRgbaNapi?: (color: string) => string | { r: number; g: number; b: number; a: number }\r\n validateColorsNapi?: (colorsJson: string) => boolean\r\n validateBreakpointsNapi?: (breakpointsJson: string) => boolean\r\n runHealthCheck?: () => void\r\n\r\n // ── Watch (napi_bridge_watch.rs) ───────────────────────────────────────────\r\n watchFiles?: (rootDir: string, optionsJson?: string | null) => string\r\n stopWatching?: (handleId: number) => string\r\n getWatchEvents?: (handleId: number, maxEvents?: number | null) => string\r\n getWatchPerformance?: () => string\r\n clearWatchStats?: () => string\r\n getActiveWatches?: () => number\r\n setWatchMetrics?: (metricName: string, value: string) => string\r\n setWatchAggregation?: (aggregationType: string) => string\r\n\r\n // ── Week 6 Optimization (week6_api.rs) ────────────────────────────────────\r\n getOptimizationRecommendations?: (hitRate: number, memoryMb: number, classCount: number) => string\r\n estimateOptimalBatchSize?: (totalClasses: number, memoryAvailableMb: number) => number\r\n predictMemoryUsage?: (uniqueClasses: number, avgClassSizeBytes: number) => number\r\n recommendCachingStrategy?: (isSsr: boolean, memoryConstraintMb: number) => string\r\n benchmarkStreamingVsBuffered?: (classCount: number) => string\r\n getWeek6OptimizationStatus?: () => string\r\n\r\n // ── Scan Cache (scan_cache_api.rs) ────────────────────────────────────────\r\n scanCacheGet?: (filePath: string, contentHash: string) => string[] | null\r\n scanCachePut?: (filePath: string, contentHash: string, classes: string[], mtimeMs: number, size: number) => void\r\n scanCacheInvalidate?: (filePath: string) => void\r\n scanCacheStats?: () => { size: number }\r\n}\r\n\r\nexport interface NativeTransformResult {\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rscJson?: string\r\n metadataJson?: string\r\n}\r\n\r\nexport interface ClassExtractResult {\r\n classes: string[]\r\n component_names: string[]\r\n has_tw_usage: boolean\r\n has_use_client: boolean\r\n imports: string[]\r\n}\r\n\r\nconst NATIVE_UNAVAILABLE_MESSAGE =\r\n \"[tailwind-styled/compiler v5] Native binding is required but not available.\\n\" +\r\n \"This package requires native Rust bindings. There is no JavaScript fallback.\\n\" +\r\n \"Please ensure:\\n\" +\r\n \" 1. The native module is properly installed\\n\" +\r\n \" 2. You have run: npm run build:rust (or use prebuilt binary)\\n\" +\r\n \"\\n\" +\r\n \"For help, see: https://tailwind-styled.dev/docs/install\"\r\n\r\n// ── Native Bridge - Factory Pattern\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nlet nativeBridge: NativeBridge | null = null\r\nlet bridgeLoadAttempted = false\r\nlet bridgeLoadError: Error | null = null\r\n\r\nconst isValidNativeBridge = (mod: unknown): mod is NativeBridge => {\r\n const m = mod as Partial<NativeBridge>\r\n return !!(\r\n typeof m.transformSource === \"function\" ||\r\n typeof m.extractAllClasses === \"function\" ||\r\n typeof m.hasTwUsage === \"function\"\r\n )\r\n}\r\n\r\nexport const getNativeBridge = (): NativeBridge => {\r\n if (nativeBridge) {\r\n return nativeBridge\r\n }\r\n\r\n if (bridgeLoadAttempted) {\r\n if (bridgeLoadError) {\r\n throw bridgeLoadError\r\n }\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n\r\n bridgeLoadAttempted = true\r\n\r\n try {\r\n const runtimeDir = resolveRuntimeDir(undefined, import.meta.url)\r\n \r\n // Use shared's native resolution\r\n const result = resolveNativeBinary(runtimeDir)\r\n\r\n if (result.path && result.path.endsWith(\".node\")) {\r\n try {\r\n const binding = _loadNative(result.path) as NativeBridge\r\n if (isValidNativeBridge(binding)) {\r\n nativeBridge = binding\r\n log(\"Native bridge loaded successfully from:\", result.path)\r\n return nativeBridge\r\n }\r\n } catch (e) {\r\n log(\"Failed to require native binding:\", e)\r\n }\r\n }\r\n\r\n throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}\\n\\nTried paths: ${result.tried.join(\"\\n\")}`)\r\n } catch (err) {\r\n bridgeLoadError = err instanceof Error ? err : new Error(String(err))\r\n log(\"Failed to load native bridge:\", bridgeLoadError.message)\r\n throw bridgeLoadError\r\n }\r\n}\r\n\r\nexport const resetNativeBridgeCache = (): void => {\r\n nativeBridge = null\r\n bridgeLoadAttempted = false\r\n bridgeLoadError = null\r\n log(\"Native bridge cache reset\")\r\n}\r\n\r\n// ── Adaptor for native results\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport const adaptNativeResult = (\r\n raw: NativeTransformResult\r\n): {\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rsc?: NativeRscResult\r\n metadata?: ComponentMetadata[]\r\n} => {\r\n return {\r\n code: raw.code ?? \"\",\r\n classes: raw.classes ?? [],\r\n changed: raw.changed ?? false,\r\n rsc: raw.rscJson ? JSON.parse(raw.rscJson) : undefined,\r\n metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : undefined,\r\n }\r\n}\r\n\r\n// ── Eager init — load native bridge saat module dimuat, bukan saat request pertama\r\n// Mencegah crash di Turbopack dev mode karena lazy init mid-request\r\n// ─────────────────────────────────────────────────────────────────────────────\r\nif (typeof process !== \"undefined\" && !bridgeLoadAttempted) {\r\n try {\r\n getNativeBridge()\r\n } catch {\r\n // Sudah di-capture di bridgeLoadError — akan di-throw saat dipanggil pertama kali\r\n }\r\n}\r\n\r\n// ── Re-export all 63 wrapper functions from nativeBridgeWrappers\r\n// These provide complete type safety, error handling, and JSDoc documentation\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport {\r\n // Redis Cache Functions (40)\r\n redis_pool_connect,\r\n redis_pool_stats,\r\n redis_pool_reconnect,\r\n redis_ping,\r\n redis_get,\r\n redis_set,\r\n redis_delete,\r\n redis_exists,\r\n redis_mget,\r\n redis_mset,\r\n redis_flush_db,\r\n redis_flush_all,\r\n redis_cache_size,\r\n redis_cache_key_count,\r\n redis_cache_clear,\r\n redis_cache_hit_rate,\r\n redis_info,\r\n redis_monitor,\r\n redis_enable_cluster,\r\n redis_disable_cluster,\r\n redis_cluster_status,\r\n redis_expiration_set,\r\n redis_expiration_get,\r\n redis_subscribe,\r\n redis_publish,\r\n redis_enable_persistence,\r\n redis_disable_persistence,\r\n redis_snapshot,\r\n redis_replicate,\r\n redis_replication_status,\r\n redis_enable_cache_warming,\r\n redis_disable_cache_warming,\r\n redis_cache_sync,\r\n redis_set_eviction_policy,\r\n redis_get_eviction_policy,\r\n redis_memory_stats,\r\n redis_optimize_memory,\r\n redis_diagnose,\r\n // Watch System Functions (20)\r\n start_watch,\r\n poll_watch_events,\r\n stop_watch,\r\n watch_add_pattern,\r\n watch_remove_pattern,\r\n watch_pause,\r\n watch_resume,\r\n is_watch_running,\r\n get_watch_stats,\r\n watch_get_active_handles,\r\n watch_clear_all,\r\n register_plugin_hook,\r\n unregister_plugin_hook,\r\n emit_plugin_hook,\r\n get_plugin_hooks,\r\n // ID Registry Functions (16)\r\n id_registry_create,\r\n id_registry_generate,\r\n id_registry_lookup,\r\n id_registry_next,\r\n id_registry_destroy,\r\n id_registry_reset,\r\n id_registry_snapshot,\r\n id_registry_active_count,\r\n register_property_name,\r\n register_value_name,\r\n property_id_to_string,\r\n value_id_to_string,\r\n reverse_lookup_property,\r\n reverse_lookup_value,\r\n id_registry_export,\r\n id_registry_import,\r\n // Incremental Compilation Functions (8)\r\n process_file_change,\r\n compute_incremental_diff,\r\n create_fingerprint,\r\n inject_state_hash,\r\n prune_stale_entries,\r\n rebuild_workspace_result,\r\n scan_files_batch_native,\r\n // Theme Resolution Functions (7)\r\n resolve_variants,\r\n validate_variant_config,\r\n resolve_cascade,\r\n resolve_class_names,\r\n resolve_conflict_group,\r\n resolve_theme_value,\r\n resolve_simple_variants,\r\n} from \"./nativeBridgeWrappers\"","/**\r\n * Compiler Sub-entry Point\r\n * \r\n * Exports CSS generation and compilation functionality.\r\n * - CSS generation with caching\r\n * - Compilation of classes to CSS\r\n * - ID registry management\r\n * - Streaming and incremental processing\r\n */\r\n\r\nexport {\r\n generateCssNative,\r\n getCacheStats,\r\n clearThemeCache,\r\n} from './cssGeneratorNative'\r\n\r\nexport {\r\n compileCssNative2,\r\n compileCssLightning,\r\n extractTwStateConfigsNative,\r\n generateStaticStateCssNative,\r\n extractAndGenerateStateCssNative,\r\n layoutClassesToCss,\r\n hashContent,\r\n extractTwContainerConfigs,\r\n parseAtomicClass,\r\n generateAtomicCss,\r\n toAtomicClasses,\r\n clearAtomicRegistry,\r\n atomicRegistrySize,\r\n type ContainerConfig,\r\n type StateCssConfig,\r\n type GeneratedStateCss,\r\n} from './compilationNative'\r\n\r\nexport {\r\n compileClass,\r\n compileClasses,\r\n compileToCss,\r\n compileToCssBatch,\r\n minifyCss,\r\n compileAnimation,\r\n compileKeyframes,\r\n compileTheme,\r\n twMerge,\r\n twMergeMany,\r\n twMergeWithSeparator,\r\n twMergeManyWithSeparator,\r\n twMergeRaw,\r\n type CompiledCssRule,\r\n type CompiledAnimation,\r\n type CompiledTheme,\r\n type CssCompileResult,\r\n type TwMergeOptions,\r\n} from './cssCompilationNative'\r\n\r\nexport {\r\n idRegistryCreate,\r\n idRegistryGenerate,\r\n idRegistryLookup,\r\n idRegistryNext,\r\n idRegistryDestroy,\r\n idRegistryReset,\r\n idRegistrySnapshot,\r\n idRegistryActiveCount,\r\n registerPropertyName,\r\n registerValueName,\r\n propertyIdToString,\r\n valueIdToString,\r\n reverseLookupProperty,\r\n reverseLookupValue,\r\n idRegistryExport,\r\n idRegistryImport,\r\n type RegistrySnapshot,\r\n} from './idRegistryNative'\r\n\r\nexport {\r\n processFileChange,\r\n computeIncrementalDiff,\r\n createFingerprint,\r\n injectStateHash,\r\n pruneStaleCacheEntries,\r\n rebuildWorkspaceResult,\r\n scanFileNative,\r\n scanFilesBatchNative,\r\n type FileChangeEvent,\r\n type ProcessedFileChange,\r\n type FileDiff,\r\n type FileFingerprint,\r\n type IncrementalDiffResult,\r\n type StateInjectionResult,\r\n type PruneResult,\r\n type RebuildWorkspaceResult,\r\n} from './streamingNative'\r\n\r\nexport { runCssPipeline } from './tailwindEngine'\r\n","/**\r\n * Parser Sub-entry Point\r\n * \r\n * Exports class parsing and extraction functionality.\r\n * - Tailwind class parsing\r\n * - Class extraction from source\r\n * - Class normalization and deduplication\r\n * - Component analysis\r\n */\r\n\r\nimport { getNativeBridge } from '../nativeBridge'\r\n\r\n// ============================================================================\r\n// PARSING FUNCTIONS\r\n// ============================================================================\r\n\r\nexport const parseClasses = (raw: string): Array<{ raw: string; type: string }> => {\r\n const native = getNativeBridge()\r\n if (!native?.parseClasses) {\r\n throw new Error('FATAL: Native binding \\'parseClasses\\' is required but not available.')\r\n }\r\n return native.parseClasses(raw) || []\r\n}\r\n\r\n// ============================================================================\r\n// CLASS EXTRACTION\r\n// ============================================================================\r\n\r\nexport const extractAllClasses = (source: string): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.extractAllClasses) {\r\n throw new Error('FATAL: Native binding \\'extractAllClasses\\' is required but not available.')\r\n }\r\n return native.extractAllClasses(source) || []\r\n}\r\n\r\nexport const extractClassesFromSource = (source: string): string => {\r\n const native = getNativeBridge()\r\n if (!native?.extractClassesFromSource) {\r\n throw new Error('FATAL: Native binding \\'extractClassesFromSource\\' is required but not available.')\r\n }\r\n const result = native.extractClassesFromSource(source)\r\n return Array.isArray(result) ? result.join(' ') : String(result || '')\r\n}\r\n\r\nexport const astExtractClasses = (source: string, _filename: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.extractClassesFromSource) {\r\n throw new Error('FATAL: Native binding \\'extractClassesFromSource\\' is required but not available.')\r\n }\r\n return native.extractClassesFromSource(source) || []\r\n}\r\n\r\n// ============================================================================\r\n// CLASS NORMALIZATION & MERGING\r\n// ============================================================================\r\n\r\nexport const normalizeClasses = (raw: string): string => {\r\n const result = normalizeAndDedupClasses(raw)\r\n return result?.normalized || ''\r\n}\r\n\r\nexport const mergeClassesStatic = (classes: string): string => {\r\n const result = normalizeAndDedupClasses(classes)\r\n return result?.normalized || ''\r\n}\r\n\r\nexport const normalizeAndDedupClasses = (raw: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.normalizeAndDedupClasses) {\r\n throw new Error('FATAL: Native binding \\'normalizeAndDedupClasses\\' is required but not available.')\r\n }\r\n const result = native.normalizeAndDedupClasses(raw)\r\n return result || { normalized: '', duplicatesRemoved: 0, uniqueCount: 0 }\r\n}\r\n\r\n// ============================================================================\r\n// COMPONENT ANALYSIS\r\n// ============================================================================\r\n\r\nexport const extractComponentUsage = (source: string): Array<{ component: string; propsJson: string }> => {\r\n const native = getNativeBridge()\r\n if (!native?.extractComponentUsage) {\r\n throw new Error('FATAL: Native binding \\'extractComponentUsage\\' is required but not available.')\r\n }\r\n return native.extractComponentUsage(source) || []\r\n}\r\n\r\n// ============================================================================\r\n// BATCH OPERATIONS\r\n// ============================================================================\r\n\r\nexport const batchExtractClasses = (filePaths: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.batchExtractClasses) {\r\n throw new Error('FATAL: Native binding \\'batchExtractClasses\\' is required but not available.')\r\n }\r\n return native.batchExtractClasses(filePaths) || []\r\n}\r\n\r\nexport const checkAgainstSafelist = (classes: string[], safelist: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.checkAgainstSafelist) {\r\n throw new Error('FATAL: Native binding \\'checkAgainstSafelist\\' is required but not available.')\r\n }\r\n return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 }\r\n}\r\n\r\n// ============================================================================\r\n// DIFF & MERGING\r\n// ============================================================================\r\n\r\nexport const diffClassLists = (previous: string[], current: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.diffClassLists) {\r\n throw new Error('FATAL: Native binding \\'diffClassLists\\' is required but not available.')\r\n }\r\n return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false }\r\n}\r\n\r\n// Re-export types if any\r\nexport type { ClassExtractResult, ComponentMetadata } from '../nativeBridge'\r\n","/**\r\n * Analyzer Sub-entry Point\r\n * \r\n * Exports analysis and optimization functionality.\r\n * - CSS and class analysis\r\n * - Dead code detection\r\n * - Theme resolution and validation\r\n * - Code classification and optimization\r\n */\r\n\r\nexport {\r\n detectDeadCode,\r\n analyzeClassUsageNative,\r\n analyzeClassesNative,\r\n analyzeRscNative,\r\n optimizeCssNative,\r\n processTailwindCssLightning,\r\n eliminateDeadCssNative,\r\n hoistComponentsNative,\r\n compileVariantTableNative,\r\n classifyAndSortClassesNative,\r\n mergeCssDeclarationsNative,\r\n type DeadCodeResult,\r\n type ClassUsageItem,\r\n type ProcessedCssResult,\r\n type HoistResult,\r\n type VariantTableResult,\r\n type ClassifyResult,\r\n type MergeResult,\r\n} from './analyzerNative'\r\n\r\nexport {\r\n resolveVariants,\r\n validateThemeConfig,\r\n resolveCascade,\r\n resolveClassNames,\r\n resolveConflictGroup,\r\n resolveThemeValue,\r\n resolveSimpleVariants,\r\n type ThemeValidationResult,\r\n type ResolvedVariantConfig,\r\n type ThemeCascadeResult,\r\n type ResolvedClassName,\r\n type ConflictGroupInfo,\r\n} from './themeResolutionNative'\r\n\r\nexport {\r\n scanWorkspace,\r\n extractClassesFromSourceNative,\r\n batchExtractClassesNative,\r\n checkAgainstSafelistNative,\r\n scanFile,\r\n collectFiles,\r\n walkAndPrefilterSourceFiles,\r\n generateSubComponentTypes,\r\n type ScanWorkspaceResult,\r\n type ScanFileResult,\r\n type BatchExtractResult,\r\n type SafelistCheckResult,\r\n type PrefilterFileResult,\r\n} from './scannerNative'\r\n","/**\r\n * Cache Sub-entry Point\r\n * \r\n * Exports cache management functionality.\r\n * - Cache statistics retrieval\r\n * - Cache clearing operations\r\n * - Cache optimization\r\n * - Cache configuration\r\n */\r\n\r\nexport {\r\n getCacheStatistics,\r\n clearAllCaches,\r\n clearParseCache,\r\n clearResolveCache,\r\n clearCompileCache,\r\n clearCssGenCache,\r\n getCacheOptimizationHints,\r\n estimateOptimalCacheConfig,\r\n cacheRead,\r\n cacheWrite,\r\n cachePriority,\r\n type CacheOptimizationHints,\r\n type OptimalCacheConfig,\r\n type CacheStatistics,\r\n} from './cacheNative'\r\n","/**\r\n * Redis Sub-entry Point\r\n * \r\n * Exports Redis and distributed cache functionality.\r\n * - Redis operations (get, set, delete, etc.)\r\n * - Redis pool management\r\n * - Cluster management\r\n * - Cache synchronization\r\n * - Persistence management\r\n */\r\n\r\nexport {\r\n redisPing,\r\n redisGet,\r\n redisSet,\r\n redisDelete,\r\n redisExists,\r\n redisMget,\r\n redisMset,\r\n redisFlushDb,\r\n redisFlushAll,\r\n redisPoolConnect,\r\n redisPoolStats,\r\n redisPoolReconnect,\r\n redisEnableCluster,\r\n redisDisableCluster,\r\n redisClusterStatus,\r\n redisSubscribe,\r\n redisPublish,\r\n redisExpirationSet,\r\n redisExpirationGet,\r\n redisInfo,\r\n redisMonitor,\r\n redisCacheSize,\r\n redisCacheKeyCount,\r\n redisCacheClear,\r\n redisCacheHitRate,\r\n redisEnablePersistence,\r\n redisDisablePersistence,\r\n redisSnapshot,\r\n redisMemoryStats,\r\n redisOptimizeMemory,\r\n redisSetEvictionPolicy,\r\n redisGetEvictionPolicy,\r\n redisReplicate,\r\n redisReplicationStatus,\r\n redisCacheSync,\r\n redisEnableCacheWarming,\r\n redisDisableCacheWarming,\r\n redisDiagnose,\r\n type RedisCacheConfig,\r\n type RedisPoolStats,\r\n type RedisClusterNode,\r\n type RedisClusterStatus,\r\n type KeyExpiration,\r\n type PubSubMessage,\r\n type PoolInfo,\r\n} from './redisNative'\r\n","/**\r\n * Watch Sub-entry Point\r\n * \r\n * Exports file watching and compilation monitoring functionality.\r\n * - File system watching\r\n * - Watch event polling and management\r\n * - Watch statistics\r\n * - Plugin hooks\r\n * - Compilation metrics\r\n */\r\n\r\nexport {\r\n startWatch,\r\n pollWatchEvents,\r\n stopWatch,\r\n watchAddPattern,\r\n watchRemovePattern,\r\n watchGetActiveHandles,\r\n watchClearAll,\r\n watchEventTypeToString,\r\n isWatchRunning,\r\n getWatchStats,\r\n watchPause,\r\n watchResume,\r\n scanCacheOptimizations,\r\n getPluginHooks,\r\n registerPluginHook,\r\n unregisterPluginHook,\r\n emitPluginHook,\r\n getCompilationMetrics,\r\n resetCompilationMetrics,\r\n validateCssOutput,\r\n getCompilerDiagnostics,\r\n type WatchEvent,\r\n type WatchHandle,\r\n type WatchStats,\r\n} from './watchSystemNative'\r\n","/**\r\n * tailwind-styled-v5 — Compiler Main Entry Point\r\n * \r\n * Re-exports all sub-entry points for backward compatibility.\r\n * For better tree-shaking, import from specific sub-entries:\r\n * - '@tailwind-styled/compiler/compiler' - CSS generation and compilation\r\n * - '@tailwind-styled/compiler/parser' - Class parsing and extraction\r\n * - '@tailwind-styled/compiler/analyzer' - Analysis and optimization\r\n * - '@tailwind-styled/compiler/cache' - Cache management\r\n * - '@tailwind-styled/compiler/redis' - Redis and distributed cache\r\n * - '@tailwind-styled/compiler/watch' - File watching and monitoring\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\n\r\nimport { getNativeBridge, resetNativeBridgeCache, adaptNativeResult, type NativeBridge, type NativeTransformResult, type ClassExtractResult, type ComponentMetadata, type NativeRscResult } from \"./nativeBridge\"\r\n\r\nexport { getNativeBridge, resetNativeBridgeCache, adaptNativeResult }\r\nexport type { NativeBridge, NativeTransformResult, ClassExtractResult, ComponentMetadata, NativeRscResult }\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// RE-EXPORT ALL SUB-ENTRIES FOR BACKWARD COMPATIBILITY\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\n// Compiler sub-entry - CSS generation, compilation, ID registry, streaming\r\nexport * from './compiler'\r\n\r\n// Parser sub-entry - Class parsing and extraction\r\nexport * from './parser'\r\n\r\n// Analyzer sub-entry - Analysis, optimization, theme resolution\r\nexport * from './analyzer'\r\n\r\n// Cache sub-entry - Cache management\r\nexport * from './cache'\r\n\r\n// Redis sub-entry - Redis and distributed cache\r\nexport * from './redis'\r\n\r\n// Watch sub-entry - File watching and monitoring\r\nexport * from './watch'\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// TRANSFORM & CORE FUNCTIONS\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const transformSource = (source: string, opts?: Record<string, unknown>) => {\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(source, opts as Record<string, string>)\r\n if (!result) {\r\n throw new Error(\"FATAL: transformSource returned null\")\r\n }\r\n return result\r\n}\r\n\r\nexport const hasTwUsage = (source: string): boolean => {\r\n const native = getNativeBridge()\r\n if (!native?.hasTwUsage) {\r\n throw new Error(\"FATAL: Native binding 'hasTwUsage' is required but not available.\")\r\n }\r\n return native.hasTwUsage(source)\r\n}\r\n\r\nexport const isAlreadyTransformed = (source: string): boolean => {\r\n const native = getNativeBridge()\r\n if (!native?.isAlreadyTransformed) {\r\n throw new Error(\"FATAL: Native binding 'isAlreadyTransformed' is required but not available.\")\r\n }\r\n return native.isAlreadyTransformed(source)\r\n}\r\n\r\nexport const shouldProcess = (source: string): boolean => {\r\n return hasTwUsage(source) && !isAlreadyTransformed(source)\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// ADDITIONAL UTILITIES\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const compileCssFromClasses = (classes: string[], prefix?: string | null) => {\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(classes.join(\" \"), { prefix: prefix ?? \"\" })\r\n if (!result) {\r\n throw new Error(\"FATAL: transformSource returned null\")\r\n }\r\n return result\r\n}\r\n\r\nexport const buildStyleTag = (classes: string[]): string => {\r\n const result = compileCssFromClasses(classes)\r\n return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : \"\"\r\n}\r\n\r\nexport const generateCssForClasses = async (\r\n classes: string[],\r\n _tailwindConfig?: Record<string, unknown>,\r\n root?: string,\r\n cssEntryContent?: string,\r\n minify = false\r\n): Promise<string> => {\r\n try {\r\n const { runCssPipeline } = await import(\"./compiler/tailwindEngine\")\r\n const result = await runCssPipeline(classes, cssEntryContent, root, minify)\r\n return result.css\r\n } catch {\r\n // Fallback if import fails\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(classes.join(\" \"), {})\r\n return result?.code || \"\"\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// DEAD STYLE ELIMINATION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const eliminateDeadCss = (css: string, deadClasses: Set<string>): string => {\r\n const native = getNativeBridge()\r\n if (!native?.eliminateDeadCss) {\r\n throw new Error(\"FATAL: Native binding 'eliminateDeadCss' is required but not available.\")\r\n }\r\n return native.eliminateDeadCss(css, Array.from(deadClasses)) as string\r\n}\r\n\r\nexport const findDeadVariants = (\r\n variantConfig: Record<string, unknown> | Array<{ name: string; variants: Record<string, Record<string, string>>; defaultVariants?: Record<string, string> }>,\r\n usage: Record<string, Set<string>>\r\n) => {\r\n const unused: string[] = []\r\n\r\n const configs = Array.isArray(variantConfig)\r\n ? variantConfig\r\n : [{ name: \"__root__\", variants: variantConfig as Record<string, Record<string, string>> }]\r\n\r\n for (const component of configs) {\r\n const componentUsage = usage[component.name] ?? new Set<string>()\r\n const variants = component.variants as Record<string, Record<string, string>>\r\n for (const [key, values] of Object.entries(variants)) {\r\n for (const [value] of Object.entries(values)) {\r\n if (!componentUsage.has(`${key}:${value}`)) {\r\n unused.push(`${component.name !== \"__root__\" ? `${component.name}/` : \"\"}${key}:${value}`)\r\n }\r\n }\r\n }\r\n }\r\n\r\n return { unusedCount: unused.length, unused }\r\n}\r\n\r\nexport const runElimination = (css: string, scanResult: unknown): string => {\r\n const native = getNativeBridge()\r\n if (!native?.detectDeadCode) {\r\n throw new Error(\"FATAL: Native binding 'detectDeadCode' is required but not available.\")\r\n }\r\n const dead = native.detectDeadCode(JSON.stringify(scanResult), css) as { deadInCss: string[] }\r\n return eliminateDeadCss(css, new Set(dead.deadInCss ?? []))\r\n}\r\n\r\nexport const scanProjectUsage = (dirs: string[], cwd: string) => {\r\n // Import locally to avoid circular dependency\r\n const { batchExtractClasses } = require('./parser')\r\n const files = dirs.map(dir => path.resolve(cwd, dir))\r\n const results = batchExtractClasses(files) || []\r\n\r\n const combined: Record<string, Record<string, Set<string>>> = {}\r\n for (const result of results) {\r\n if (result.ok && result.classes) {\r\n for (const cls of result.classes) {\r\n if (!combined[cls]) combined[cls] = {}\r\n combined[cls][result.file] = new Set([cls])\r\n }\r\n }\r\n }\r\n return combined\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// CONFIG & UTILITIES\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const generateSafelist = (scanDirs: string[], outputPath?: string, cwd?: string) => {\r\n const classes = scanProjectUsage(scanDirs, cwd || process.cwd())\r\n const allClasses = Object.keys(classes).sort()\r\n if (outputPath) {\r\n fs.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2))\r\n }\r\n return allClasses\r\n}\r\n\r\nexport const loadSafelist = (safelistPath: string): string[] => {\r\n try {\r\n const content = fs.readFileSync(safelistPath, \"utf-8\")\r\n return JSON.parse(content)\r\n } catch {\r\n return []\r\n }\r\n}\r\n\r\nexport const loadTailwindConfig = (cwd: string = process.cwd()) => {\r\n const configFiles = [\r\n \"tailwind.config.ts\",\r\n \"tailwind.config.js\",\r\n \"tailwind.config.mjs\",\r\n \"tailwind.config.cjs\",\r\n ]\r\n for (const file of configFiles) {\r\n const fullPath = path.join(cwd, file)\r\n if (fs.existsSync(fullPath)) {\r\n const mod = require(fullPath) as { default?: unknown }\r\n return mod.default || mod\r\n }\r\n }\r\n return {}\r\n}\r\n\r\nexport const getContentPaths = (cwd: string = process.cwd()) => {\r\n return {\r\n content: [\r\n path.join(cwd, \"src/**/*.{js,ts,jsx,tsx}\"),\r\n path.join(cwd, \"app/**/*.{js,ts,jsx,tsx}\"),\r\n path.join(cwd, \"pages/**/*.{js,ts,jsx,tsx}\"),\r\n ],\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// CONTAINER CSS EXTRACTION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nfunction _layoutClassesToCss(classes: string): string {\r\n const native = getNativeBridge()\r\n if (!native?.layoutClassesToCss) {\r\n throw new Error(\"FATAL: Native binding 'layoutClassesToCss' is required but not available.\")\r\n }\r\n return native.layoutClassesToCss(classes)\r\n}\r\n\r\nfunction _hashContainer(tag: string, containerJson: string, name?: string): string {\r\n const sortedKey = tag + (name ?? \"\") + containerJson\r\n const native = getNativeBridge()\r\n if (!native?.hashContent) {\r\n throw new Error(\"FATAL: Native binding 'hashContent' is required but not available.\")\r\n }\r\n return `tw-cq-${native.hashContent(sortedKey, \"fnv\", 6)}`\r\n}\r\n\r\nconst _CONTAINER_BREAKPOINTS: Record<string, string> = {\r\n xs: \"240px\",\r\n sm: \"320px\",\r\n md: \"640px\",\r\n lg: \"1024px\",\r\n xl: \"1280px\",\r\n \"2xl\": \"1536px\",\r\n}\r\n\r\nexport function extractContainerCssFromSource(source: string): string {\r\n const native = getNativeBridge()\r\n if (!native?.extractTwContainerConfigs) {\r\n throw new Error(\"FATAL: Native binding 'extractTwContainerConfigs' is required but not available.\")\r\n }\r\n\r\n const configs = native.extractTwContainerConfigs(source) as Array<{\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n }>\r\n\r\n const rules: string[] = []\r\n for (const cfg of configs) {\r\n const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName)\r\n for (const { key, classes } of cfg.breakpoints) {\r\n const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key\r\n const css = _layoutClassesToCss(classes)\r\n if (!css) continue\r\n const query = cfg.containerName\r\n ? `@container ${cfg.containerName} (min-width: ${minWidth})`\r\n : `@container (min-width: ${minWidth})`\r\n rules.push(`${query}{.${id}{${css}}}`)\r\n }\r\n }\r\n return rules.join(\"\\n\")\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// LOADER INTERFACE\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport type LoaderOutput = {\r\n code: string\r\n changed: boolean\r\n classes: string[]\r\n staticCss?: string\r\n rsc?: { isServer?: boolean; needsClientDirective?: boolean; clientReasons?: string[] }\r\n engine?: string\r\n}\r\n\r\nexport const runLoaderTransform = (ctx: { filepath: string; source: string; options?: Record<string, unknown> }) => {\r\n const { filepath, source, options } = ctx\r\n const result = transformSource(source, { filename: filepath, ...options })\r\n\r\n let staticCss: string | undefined\r\n try {\r\n const cssChunks: string[] = []\r\n\r\n const stateRules = extractAndGenerateStateCss(source, filepath)\r\n if (stateRules.length > 0) {\r\n cssChunks.push(stateRules.map((r) => r.cssRule).join(\"\\n\"))\r\n }\r\n\r\n const containerCss = extractContainerCssFromSource(source)\r\n if (containerCss) cssChunks.push(containerCss)\r\n\r\n const combined = cssChunks.join(\"\\n\").trim()\r\n if (combined) staticCss = combined\r\n } catch (err) {\r\n // Non-fatal — static CSS extraction failure should not break transform pipeline.\r\n console.debug(\"Static CSS extraction warning:\", err)\r\n }\r\n\r\n return {\r\n code: result?.code || \"\",\r\n changed: result?.changed || false,\r\n classes: result?.classes || [],\r\n staticCss,\r\n } as LoaderOutput\r\n}\r\n\r\nexport const shouldSkipFile = (filepath: string): boolean => {\r\n const SKIP_PATHS = [\"node_modules\", \".next\", \".rspack-dist\", \".turbo\", \"dist/\", \"out/\"]\r\n const skipExtensions = [\".css\", \".json\", \".md\", \".txt\", \".yaml\", \".yml\"]\r\n for (const p of SKIP_PATHS) {\r\n if (filepath.includes(p)) return true\r\n }\r\n for (const ext of skipExtensions) {\r\n if (filepath.endsWith(ext)) return true\r\n }\r\n return false\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// ROUTE MANAGEMENT\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const fileToRoute = (filepath: string): string | null => {\r\n const normalized = filepath.replace(/\\\\/g, \"/\")\r\n if (normalized.includes(\"/layout.\") || normalized.includes(\"/loading.\") || normalized.includes(\"/error.\")) {\r\n return \"__global\"\r\n }\r\n const pageMatch = normalized.match(/\\/app\\/(.+?)\\/page\\.[tj]sx?$/)\r\n if (pageMatch) return `/${pageMatch[1]}`\r\n const rootPage = normalized.match(/\\/app\\/page\\.[tj]sx?$/)\r\n if (rootPage) return \"/\"\r\n return null\r\n}\r\n\r\nexport const getAllRoutes = (): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClasses) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClasses' is required but not available.\")\r\n }\r\n return [\"/\", \"__global\"]\r\n}\r\n\r\nexport const getRouteClasses = (_route: string): Set<string> => new Set()\r\nexport const registerFileClasses = (_filepath: string, _classes: string[]): void => {}\r\nexport const registerGlobalClasses = (_classes: string[]): void => {}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// INCREMENTAL ENGINE\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nlet _incrementalEngineInstance: InstanceType<typeof IncrementalEngine> | null = null\r\n\r\nexport const getIncrementalEngine = () => {\r\n if (!_incrementalEngineInstance) {\r\n _incrementalEngineInstance = new IncrementalEngine()\r\n }\r\n return _incrementalEngineInstance\r\n}\r\n\r\nexport const resetIncrementalEngine = (): void => {\r\n _incrementalEngineInstance = null\r\n}\r\n\r\nexport class IncrementalEngine {\r\n compile(source: string) {\r\n return transformSource(source)\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// STYLE BUCKET SYSTEM\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const getBucketEngine = () => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n return {\r\n add: (className: string) => className,\r\n get: (_bucket: string): string[] => [],\r\n }\r\n}\r\n\r\nexport const resetBucketEngine = (): void => {}\r\n\r\nexport class BucketEngine {\r\n add(className: string) { return className }\r\n}\r\n\r\nexport const classifyNode = (_node: unknown): string => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n return \"unknown\"\r\n}\r\n\r\nexport const detectConflicts = (_classes: string[]): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClassUsage) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClassUsage' is required but not available.\")\r\n }\r\n return []\r\n}\r\n\r\nexport const bucketSort = (classes: string[]): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n const sorted = native.classifyAndSortClasses(classes)\r\n return sorted.map((c) => (c as { raw?: string }).raw ?? (c as unknown as string))\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// RSC & FILE ANALYSIS CONTINUED\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const analyzeFile = (source: string, filename: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeRsc) {\r\n throw new Error(\"FATAL: Native binding 'analyzeRsc' is required but not available.\")\r\n }\r\n const rsc = native.analyzeRsc(source, filename)\r\n return {\r\n isServer: rsc?.isServer ?? true,\r\n needsClientDirective: rsc?.needsClientDirective ?? false,\r\n clientReasons: rsc?.clientReasons ?? [],\r\n interactiveClasses: [],\r\n canStaticResolveVariants: true,\r\n }\r\n}\r\n\r\nexport const analyzeVariantUsage = (_source: string, _componentName: string, _variantKeys: string[]) => {\r\n return { resolved: {} as Record<string, string>, dynamic: [] as string[] }\r\n}\r\n\r\nexport const injectClientDirective = (source: string): string => {\r\n if (!source.includes('\"use client\"') && !source.includes(\"'use client'\")) {\r\n return '\"use client\";\\n' + source\r\n }\r\n return source\r\n}\r\n\r\nexport const injectServerOnlyComment = (source: string): string => {\r\n return `/* @server-only */\\n${source}`\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// FULL ANALYSIS\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const analyzeClasses = (filesJson: string, cwd: string, flags: number) => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClasses) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClasses' is required but not available.\")\r\n }\r\n return native.analyzeClasses(filesJson, cwd, flags)\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// STATE CSS PRE-GENERATION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport interface TwStateConfigEntry {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n sourceFile: string\r\n}\r\n\r\nexport interface StaticStateCssInput {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n}\r\n\r\nexport interface GeneratedStateRule {\r\n selector: string\r\n declarations: string\r\n cssRule: string\r\n componentName: string\r\n stateName: string\r\n}\r\n\r\nexport const extractTwStateConfigs = (source: string, filename: string): TwStateConfigEntry[] => {\r\n const native = getNativeBridge()\r\n if (!native?.extractTwStateConfigs) {\r\n throw new Error(\"FATAL: Native binding 'extractTwStateConfigs' is required but not available.\")\r\n }\r\n return native.extractTwStateConfigs(source, filename)\r\n}\r\n\r\nexport const generateStaticStateCss = (\r\n entries: TwStateConfigEntry[],\r\n _themeConfig?: Record<string, unknown>\r\n): GeneratedStateRule[] => {\r\n const rules: GeneratedStateRule[] = []\r\n for (const entry of entries) {\r\n const stateConfig = JSON.parse(entry.statesJson) as Record<string, string>\r\n for (const [stateName, classes] of Object.entries(stateConfig)) {\r\n rules.push({\r\n selector: `.${entry.componentName}[data-state=\"${stateName}\"]`,\r\n declarations: classes,\r\n cssRule: `.${entry.componentName}[data-state=\"${stateName}\"]{${classes}}`,\r\n componentName: entry.componentName,\r\n stateName,\r\n })\r\n }\r\n }\r\n return rules\r\n}\r\n\r\nexport const extractAndGenerateStateCss = (source: string, filename: string): GeneratedStateRule[] => {\r\n const entries = extractTwStateConfigs(source, filename)\r\n return generateStaticStateCss(entries)\r\n}\r\n","/**\r\n * tailwind-styled-v5 — Internal API\r\n * \r\n * Re-exports functions needed by other package consumers.\r\n * All functions require native Rust bindings.\r\n */\r\n\r\nimport {\r\n type NativeBridge,\r\n type NativeTransformResult,\r\n type ComponentMetadata,\r\n type NativeRscResult,\r\n type LoaderOutput,\r\n getNativeBridge,\r\n adaptNativeResult,\r\n transformSource,\r\n hasTwUsage,\r\n isAlreadyTransformed,\r\n shouldProcess,\r\n compileCssFromClasses,\r\n buildStyleTag,\r\n extractAllClasses,\r\n extractClassesFromSource,\r\n astExtractClasses,\r\n parseClasses,\r\n normalizeClasses,\r\n mergeClassesStatic,\r\n normalizeAndDedupClasses,\r\n eliminateDeadCss,\r\n findDeadVariants,\r\n runElimination,\r\n scanProjectUsage,\r\n extractComponentUsage,\r\n diffClassLists,\r\n batchExtractClasses,\r\n checkAgainstSafelist,\r\n generateSafelist,\r\n loadSafelist,\r\n loadTailwindConfig,\r\n getContentPaths,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n fileToRoute,\r\n getAllRoutes,\r\n getRouteClasses,\r\n registerFileClasses,\r\n registerGlobalClasses,\r\n getIncrementalEngine,\r\n resetIncrementalEngine,\r\n getBucketEngine,\r\n resetBucketEngine,\r\n classifyNode,\r\n detectConflicts,\r\n bucketSort,\r\n generateCssForClasses,\r\n analyzeFile,\r\n analyzeVariantUsage,\r\n injectClientDirective,\r\n injectServerOnlyComment,\r\n analyzeClasses,\r\n // Static state CSS pre-generation\r\n extractTwStateConfigs,\r\n generateStaticStateCss,\r\n extractAndGenerateStateCss,\r\n extractContainerCssFromSource,\r\n} from \"./index\"\r\n\r\nexport {\r\n getNativeBridge,\r\n adaptNativeResult,\r\n transformSource,\r\n hasTwUsage,\r\n isAlreadyTransformed,\r\n shouldProcess,\r\n compileCssFromClasses,\r\n buildStyleTag,\r\n extractAllClasses,\r\n extractClassesFromSource,\r\n astExtractClasses,\r\n parseClasses,\r\n normalizeClasses,\r\n mergeClassesStatic,\r\n normalizeAndDedupClasses,\r\n eliminateDeadCss,\r\n findDeadVariants,\r\n runElimination,\r\n scanProjectUsage,\r\n extractComponentUsage,\r\n diffClassLists,\r\n batchExtractClasses,\r\n checkAgainstSafelist,\r\n generateSafelist,\r\n loadSafelist,\r\n loadTailwindConfig,\r\n getContentPaths,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n fileToRoute,\r\n getAllRoutes,\r\n getRouteClasses,\r\n registerFileClasses,\r\n registerGlobalClasses,\r\n getIncrementalEngine,\r\n resetIncrementalEngine,\r\n getBucketEngine,\r\n resetBucketEngine,\r\n classifyNode,\r\n detectConflicts,\r\n bucketSort,\r\n generateCssForClasses,\r\n analyzeFile,\r\n analyzeVariantUsage,\r\n injectClientDirective,\r\n injectServerOnlyComment,\r\n analyzeClasses,\r\n // Static state + container CSS pre-generation\r\n extractTwStateConfigs,\r\n generateStaticStateCss,\r\n extractAndGenerateStateCss,\r\n extractContainerCssFromSource,\r\n}\r\n\r\nexport { type NativeBridge, type NativeTransformResult, type ComponentMetadata, type NativeRscResult, type LoaderOutput }\r\n\r\nexport type CssCompileResult = NativeTransformResult\r\n\r\n// CSS pipeline — Tailwind → LightningCSS\r\n// PHASE 0: Includes LRU caching for 30-40% performance improvement\r\nexport { runCssPipeline, runCssPipelineSync, getCacheStats, clearCache, type CssPipelineResult } from \"./compiler/tailwindEngine\"\r\n\r\n// Re-export all sub-entries directly for convenience\r\nexport * from \"./compiler\"\r\nexport * from \"./parser\"\r\nexport * from \"./analyzer\"\r\nexport * from \"./cache\"\r\nexport * from \"./redis\"\r\nexport * from \"./watch\"\r\n\r\n","import {\r\n type LoaderOutput,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n registerFileClasses,\r\n} from \"@tailwind-styled/compiler/internal\"\r\nimport path from \"node:path\"\r\nimport { z } from \"zod\"\r\nimport { setFileStaticCss } from \"./staticCssWebpackPlugin\"\r\n\r\ninterface WebpackLoaderOptions {\r\n mode?: \"zero-runtime\"\r\n autoClientBoundary?: boolean\r\n addDataAttr?: boolean\r\n hoist?: boolean\r\n routeCss?: boolean\r\n incremental?: boolean\r\n verbose?: boolean\r\n preserveImports?: boolean\r\n /** Path ke safelist CSS file — untuk menentukan lokasi _tw-state-static.css */\r\n safelistPath?: string\r\n}\r\n\r\ninterface WebpackContext {\r\n resourcePath: string\r\n getOptions(): WebpackLoaderOptions\r\n async?(): ((err: Error | null, result?: string) => void) | undefined\r\n cacheable?(flag?: boolean): void\r\n}\r\n\r\nconst WebpackLoaderOptionsSchema = z.object({\r\n mode: z.literal(\"zero-runtime\").optional(),\r\n autoClientBoundary: z.boolean().optional(),\r\n addDataAttr: z.boolean().optional(),\r\n hoist: z.boolean().optional(),\r\n routeCss: z.boolean().optional(),\r\n incremental: z.boolean().optional(),\r\n verbose: z.boolean().optional(),\r\n preserveImports: z.boolean().optional(),\r\n safelistPath: z.string().optional(),\r\n})\r\n\r\nconst isNextBuildArtifact = (filepath: string): boolean =>\r\n filepath.includes(`${path.sep}.next${path.sep}`)\r\n\r\nexport default function webpackLoader(this: WebpackContext, source: string): void {\r\n const callback = this.async?.()\r\n if (!callback) {\r\n throw new Error(\"[tailwind-styled] Async loader callback is not available.\")\r\n }\r\n\r\n this.cacheable?.(true)\r\n const filepath = this.resourcePath\r\n\r\n if (shouldSkipFile(filepath) || isNextBuildArtifact(filepath)) {\r\n callback(null, source)\r\n return\r\n }\r\n\r\n try {\r\n const options = WebpackLoaderOptionsSchema.parse(this.getOptions())\r\n\r\n const output: LoaderOutput = runLoaderTransform({\r\n filepath,\r\n source,\r\n options: {\r\n mode: options.mode,\r\n autoClientBoundary: options.autoClientBoundary ?? true,\r\n addDataAttr: options.addDataAttr,\r\n hoist: options.hoist,\r\n filename: filepath,\r\n routeCss: options.routeCss,\r\n incremental: options.incremental,\r\n verbose: options.verbose,\r\n preserveImports: options.preserveImports ?? true,\r\n },\r\n })\r\n\r\n if (typeof output.code !== \"string\") {\r\n throw new TypeError(`[tailwind-styled] Invalid transform output for ${filepath}: code is not a string`)\r\n }\r\n\r\n // ── Update static CSS Map (state + container) ──────────────────────────\r\n // StaticCssWebpackPlugin akan rebuild _tw-state-static.css di done hook.\r\n // Pass undefined untuk hapus entry kalau file tidak punya static CSS lagi.\r\n setFileStaticCss(filepath, output.staticCss)\r\n\r\n // Tidak ada perubahan — Rust kembalikan source asli, bukan string kosong.\r\n // Return source asli via callback agar webpack pipeline tidak memperlakukan\r\n // file sebagai \"modified\" dan RSC boundary Next.js tetap utuh.\r\n if (!output.changed) {\r\n callback(null, source)\r\n return\r\n }\r\n\r\n if (options.verbose && output.changed) {\r\n const rsc = output.rsc\r\n const engine = output.engine ?? \"js\"\r\n const env = rsc?.isServer ? \"server\" : \"client\"\r\n const name = path.basename(filepath)\r\n process.stdout.write(\r\n `[tailwind-styled/webpack] ${name} -> ${output.classes.length} classes (${env}) [${engine}]\\n`\r\n )\r\n }\r\n\r\n // Register classes ke route map untuk TwCssInjector\r\n if (output.classes.length > 0) {\r\n registerFileClasses(filepath, output.classes)\r\n }\r\n\r\n callback(null, output.code)\r\n } catch (err) {\r\n if (process.env.NODE_ENV === \"production\") {\r\n callback(err instanceof Error ? err : new Error(String(err)))\r\n return\r\n }\r\n\r\n console.warn(`[tailwind-styled-v4] Webpack transform failed for ${filepath}:`, err)\r\n callback(null, source)\r\n }\r\n}","/**\r\n * StaticCssWebpackPlugin\r\n *\r\n * Webpack plugin companion untuk tailwind-styled-v4 build-time migration.\r\n *\r\n * Masalah yang diselesaikan:\r\n * - `webpackLoader.ts` di-invoke per-file saat transform. Kalau pakai append-to-file\r\n * langsung, ada dua bug: (1) rules lama tidak dibersihkan saat file di-edit/hapus\r\n * statenya, (2) duplicate rules kalau file di-transform ulang.\r\n *\r\n * Solusi: plugin ini maintain `_fileStaticCssMap: Map<filepath, css>` yang hidup\r\n * selama proses webpack. Setiap kali loader transform file, ia update Map.\r\n * Di `compiler.hooks.done`, plugin rebuild `_tw-state-static.css` dari scratch\r\n * menggunakan seluruh isi Map → selalu fresh, tidak ada stale rules.\r\n *\r\n * HMR flow:\r\n * File berubah → webpack incremental compilation → loader transform file baru\r\n * → `setFileStaticCss(filepath, newCss)` update Map → `done` hook flush Map\r\n * → `_tw-state-static.css` berisi state terbaru dari semua file.\r\n *\r\n * File dihapus / state dihapus:\r\n * Webpack invalidate → loader transform ulang → `setFileStaticCss(filepath, undefined)`\r\n * hapus entry dari Map → `done` hook flush → file tidak ada stale rules.\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Shared singleton Map — persists selama Node.js process hidup (webpack watch)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\nconst _fileStaticCssMap = new Map<string, string>()\r\n\r\n/**\r\n * Dipanggil oleh `webpackLoader.ts` setiap kali file di-transform.\r\n * Pass `undefined` / empty string untuk hapus entry (file tidak punya state CSS).\r\n */\r\nexport function setFileStaticCss(filepath: string, css: string | undefined): void {\r\n if (css && css.trim()) {\r\n _fileStaticCssMap.set(filepath, css.trim())\r\n } else {\r\n _fileStaticCssMap.delete(filepath)\r\n }\r\n}\r\n\r\n/** Deduplicate + concat semua CSS dari Map */\r\nfunction buildContent(map: Map<string, string>): string {\r\n const seen = new Set<string>()\r\n const rules: string[] = []\r\n for (const css of map.values()) {\r\n for (const chunk of css.split(/(?<=\\})\\s*/)) {\r\n const rule = chunk.trim()\r\n if (rule && !seen.has(rule)) {\r\n seen.add(rule)\r\n rules.push(rule)\r\n }\r\n }\r\n }\r\n return rules.join(\"\\n\")\r\n}\r\n\r\nconst HEADER =\r\n `/* _tw-state-static.css — Auto-generated by tailwind-styled-v4. DO NOT EDIT.\\n` +\r\n ` * Import di globals.css: @import \"./_tw-state-static.css\";\\n` +\r\n ` * Berisi: state CSS (.tw-s-*[data-*=\"true\"]) + container queries (@container .tw-cq-*).\\n` +\r\n ` * Di-rebuild penuh setiap webpack compilation selesai — tidak ada stale rules.\\n` +\r\n ` */\\n\\n`\r\n\r\ninterface WebpackCompiler {\r\n hooks: {\r\n done: {\r\n tap(pluginName: string, callback: () => void): void\r\n }\r\n }\r\n}\r\n\r\nexport class StaticCssWebpackPlugin {\r\n static readonly PLUGIN_NAME = \"TailwindStyledStaticCss\"\r\n\r\n private readonly outPath: string\r\n\r\n constructor(safelistPath: string) {\r\n this.outPath = path.join(path.dirname(safelistPath), \"_tw-state-static.css\")\r\n }\r\n\r\n apply(compiler: WebpackCompiler): void {\r\n compiler.hooks.done.tap(StaticCssWebpackPlugin.PLUGIN_NAME, () => {\r\n try {\r\n const content = buildContent(_fileStaticCssMap)\r\n fs.mkdirSync(path.dirname(this.outPath), { recursive: true })\r\n fs.writeFileSync(\r\n this.outPath,\r\n HEADER + (content || \"/* no static rules yet */\") + \"\\n\",\r\n \"utf-8\"\r\n )\r\n } catch (e) {\r\n console.warn(\"[tailwind-styled] Could not write _tw-state-static.css:\", e)\r\n }\r\n })\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../packages/domain/shared/src/native-resolution.ts","../packages/domain/shared/src/index.ts","../packages/domain/compiler/src/nativeBridge.ts","../packages/domain/compiler/src/compiler/index.ts","../packages/domain/compiler/src/parser/index.ts","../packages/domain/compiler/src/analyzer/index.ts","../packages/domain/compiler/src/cache/index.ts","../packages/domain/compiler/src/redis/index.ts","../packages/domain/compiler/src/watch/index.ts","../packages/domain/compiler/src/index.ts","../packages/domain/compiler/src/internal.ts","../packages/presentation/next/src/webpackLoader.ts","../packages/presentation/next/src/staticCssWebpackPlugin.ts"],"names":["fs","path","createRequire","fileURLToPath","init_src","z"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI,WAAW,OAAO,SAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAAI,QAAQ,IAAI,CAAA,CAAA;AAC5C;AAaO,SAAS,oBAAoB,UAAA,EAA6C;AAC/E,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,CAAC,0BAA0B,CAAA,EAAE;AAAA,EAC1F;AAIA,EAAA,IAAI,QAAQ,GAAA,CAAI,aAAA,KAAkB,OAAO,OAAA,CAAQ,GAAA,CAAI,uBAAuB,GAAA,EAAK;AAC/E,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAA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QAAQ,GAAA,GAAM,IAAI,MAAM,MAAA,CAAO,GAAG,CAAC,CAAC,CAAA;AAC5D,MAAA;AAAA,IACF;AAEA,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,kDAAA,EAAqD,QAAQ,CAAA,CAAA,CAAA,EAAK,GAAG,CAAA;AAClF,IAAA,QAAA,CAAS,MAAM,MAAM,CAAA;AAAA,EACvB;AACF","file":"webpackLoader.js","sourcesContent":["/**\r\n * Prebuilt binary resolution untuk native NAPI bindings.\r\n * QA #1: Resolve native binary dari prebuilt packages atau local build.\r\n *\r\n * Prioritas:\r\n * 1. TW_NATIVE_PATH env var (explicit override)\r\n * 2. Local native/ folder in npm package (via \"files\": [\"native/*.node\"])\r\n * 3. Prebuilt binary dari platform-specific npm package\r\n * 4. Local build dari source (developer mode)\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport * as fs from \"node:fs\"\r\nimport * as path from \"node:path\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require — works in both ESM and CJS contexts\r\nconst _require = typeof require !== \"undefined\" ? require : createRequire(import.meta.url)\r\n\r\nexport interface NativeResolutionResult {\r\n path: string | null\r\n source: \"env\" | \"prebuilt\" | \"local\" | \"not-found\"\r\n platform: string\r\n tried: string[]\r\n}\r\n\r\n/** Platform key → prebuilt npm package name */\r\nconst PLATFORM_MAP: Record<string, string[]> = {\r\n \"linux-x64\": [\"@tailwind-styled/native-linux-x64-gnu\", \"@tailwind-styled/native-linux-x64\"],\r\n \"linux-arm64\": [\"@tailwind-styled/native-linux-arm64-gnu\", \"@tailwind-styled/native-linux-arm64\"],\r\n \"darwin-x64\": [\"@tailwind-styled/native-darwin-x64\"],\r\n \"darwin-arm64\": [\"@tailwind-styled/native-darwin-arm64\"],\r\n \"win32-x64\": [\"@tailwind-styled/native-win32-x64-msvc\", \"@tailwind-styled/native-win32-x64\"],\r\n \"win32-arm64\": [\"@tailwind-styled/native-win32-arm64-msvc\", \"@tailwind-styled/native-win32-arm64\"],\r\n}\r\n\r\nfunction platformKey(): string {\r\n if (isBrowser) return \"browser\"\r\n return `${process.platform}-${process.arch}`\r\n}\r\n\r\n/**\r\n * Resolve native binary path dari semua sumber yang tersedia.\r\n *\r\n * @example\r\n * const result = resolveNativeBinary()\r\n * if (result.path) {\r\n * const binding = require(result.path)\r\n * } else {\r\n * throw new Error(\"Native binding not found — run npm run build:rust\")\r\n * }\r\n */\r\nexport function resolveNativeBinary(runtimeDir?: string): NativeResolutionResult {\r\n const platform = platformKey()\r\n const tried: string[] = []\r\n\r\n if (isBrowser) {\r\n return { path: null, source: \"not-found\", platform, tried: [\"not available in browser\"] }\r\n }\r\n\r\n // 0. Disabled flag — always short-circuit before any I/O\r\n // TWS_NO_NATIVE adalah nama canonical; TWS_DISABLE_NATIVE diterima untuk backward compat\r\n if (process.env.TWS_NO_NATIVE === \"1\" || process.env.TWS_DISABLE_NATIVE === \"1\") {\r\n return { path: null, source: \"not-found\", platform, tried: [] }\r\n }\r\n\r\n // 1. Env var override\r\n const envPath = process.env.TW_NATIVE_PATH?.trim()\r\n if (envPath) {\r\n if (fs.existsSync(envPath)) {\r\n return { path: envPath, source: \"env\", platform, tried }\r\n }\r\n tried.push(`env:${envPath} (not found)`)\r\n }\r\n\r\n // 2. Local build candidates FIRST (native/ folder in node_modules package)\r\n // When installed via npm, \"files\": [\"native/*.node\"] includes them\r\n // Priority: node_modules/tailwind-styled-v4/native/*.node\r\n const napiPlatform = platform === \"linux-x64\" ? \"linux-x64-gnu\"\r\n : platform === \"linux-arm64\" ? \"linux-arm64-gnu\"\r\n : platform\r\n const BINARY_NAMES_SELF = [\"tailwind-styled-native\", \"tailwind_styled_parser\", \"index\"]\r\n if (runtimeDir) {\r\n // runtimeDir is typically dist/ — go up to package root, then into native/\r\n for (const depth of [\"..\", path.join(\"..\", \"..\"), path.join(\"..\", \"..\", \"..\")]) {\r\n const pkgRoot = path.resolve(runtimeDir, depth)\r\n for (const bin of BINARY_NAMES_SELF) {\r\n for (const suffix of [\"\", `.${platform}`, `.${napiPlatform}`]) {\r\n const candidate = path.resolve(pkgRoot, \"native\", `${bin}${suffix}.node`)\r\n tried.push(`native:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // 2b. Prebuilt binary dari platform-specific npm package\r\n const prebuiltPkgs = PLATFORM_MAP[platform] ?? []\r\n for (const pkg of prebuiltPkgs) {\r\n try {\r\n const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n tried.push(`prebuilt:${pkg} (resolved but missing)`)\r\n } catch {\r\n tried.push(`prebuilt:${pkg} (not installed)`)\r\n }\r\n }\r\n\r\n // 3. Local build candidates\r\n const cwd = process.cwd()\r\n const base = runtimeDir ?? cwd\r\n // napi-rs naming: platform key may have -gnu suffix on Linux (already computed above)\r\n\r\n // Both possible binary names:\r\n // - \"tailwind_styled_parser\" (old hardcoded name in resolvers)\r\n // - \"tailwind-styled-native\" (actual binaryName in native/package.json)\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n\r\n const localCandidates: string[] = []\r\n\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(base, `${bin}.node`))\r\n localCandidates.push(path.resolve(base, \"..\", `${bin}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`))\r\n }\r\n\r\n // Walk up from cwd AND base to find repo root native/ dir\r\n // Needed when npm workspaces sets cwd to the package subdir\r\n for (const startDir of [cwd, base]) {\r\n let dir = startDir\r\n for (let i = 0; i < 6; i++) {\r\n const nativeDir = path.resolve(dir, \"native\")\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, \"target\", \"release\", `${bin}.node`))\r\n }\r\n const parent = path.resolve(dir, \"..\")\r\n if (parent === dir) break\r\n dir = parent\r\n }\r\n }\r\n\r\n for (const candidate of localCandidates) {\r\n tried.push(`local:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"local\", platform, tried }\r\n }\r\n }\r\n\r\n return { path: null, source: \"not-found\", platform, tried }\r\n}\r\n\r\n/**\r\n * Format human-readable error untuk \"binary not found\".\r\n */\r\nexport function formatNativeNotFoundError(result: NativeResolutionResult): string {\r\n const lines = [\r\n `[tailwind-styled] Native binding not found for ${result.platform}`,\r\n ``,\r\n `Tried:`,\r\n ...result.tried.map(t => ` - ${t}`),\r\n ``,\r\n `Solutions:`,\r\n ` 1. Build locally: npm run build:rust`,\r\n ` 2. Install prebuilt: npm install @tailwind-styled/native-${result.platform}`,\r\n ` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node`,\r\n ]\r\n return lines.join(\"\\n\")\r\n}","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"\r\n\r\nexport {\r\n TW_STATE_STATIC_FILENAME,\r\n extractStaticStateCss,\r\n appendStaticStateCssToSafelist,\r\n type TwStateConfigEntry,\r\n type StaticStateCssInput,\r\n type GeneratedStateRule,\r\n type StaticStateExtractionResult,\r\n} from \"./staticStateExtractor\"\r\nexport { setGlobalLogFile } from \"./logger\"","/**\r\n * tailwind-styled-v5 — Native Bridge Loader\r\n *\r\n * Uses @tailwind-styled/shared for native binding resolution.\r\n * All functions require native Rust binding - no JS fallback.\r\n */\r\n\r\nimport { resolveNativeBinary, resolveRuntimeDir } from \"@tailwind-styled/shared\"\r\n\r\n// require() is safe here — tsup banner injects CJS-compatible require into ESM output.\r\n// See tsup.config.ts esbuildOptions banner for how this is set up.\r\nconst _loadNative = (path: string): unknown => require(path)\r\n\r\nexport interface ComponentMetadata {\r\n component: string\r\n tag: string\r\n baseClass: string\r\n subComponents: Record<string, { tag?: string; class: string }>\r\n}\r\n\r\nexport interface NativeRscResult {\r\n isServer: boolean\r\n needsClientDirective: boolean\r\n clientReasons: string[]\r\n}\r\n\r\nconst log = (...args: unknown[]) => {\r\n if (process.env.DEBUG?.includes(\"compiler:native\")) {\r\n console.log(\"[compiler:native]\", ...args)\r\n }\r\n}\r\n\r\n// ── Structured Type Definitions ─────────────────────────────────────────────\r\n\r\nexport interface ScanWorkspaceResult {\r\n files: string[]\r\n total_files: number\r\n classes: string[]\r\n unique_classes: number\r\n duration_ms: number\r\n errors: string[]\r\n}\r\n\r\nexport interface ScanFileResult {\r\n file: string\r\n classes: string[]\r\n class_count: number\r\n has_tw_usage: boolean\r\n size_bytes: number\r\n duration_ms: number\r\n}\r\n\r\nexport interface BatchExtractResult {\r\n file: string\r\n classes: string[]\r\n contentHash: string\r\n ok: boolean\r\n error?: string\r\n}\r\n\r\nexport interface SafelistCheckResult {\r\n matched: string[]\r\n unmatched: string[]\r\n safelistSize: number\r\n}\r\n\r\nexport interface PrefilterFileResult {\r\n file: string\r\n has_tw_usage: boolean\r\n duration_ms: number\r\n size_bytes: number\r\n status: \"processed\" | \"skipped\" | \"error\"\r\n error?: string\r\n}\r\n\r\nexport interface DeadCodeResult {\r\n deadInCss: string[]\r\n deadInSource: string[]\r\n liveClasses: string[]\r\n totalCssClasses: number\r\n totalSourceClasses: number\r\n}\r\n\r\nexport interface ProcessedCssResult {\r\n css: string\r\n size_bytes: number\r\n resolved_classes: string[]\r\n unknown_classes: string[]\r\n}\r\n\r\nexport interface ContainerConfig {\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n}\r\n\r\nexport interface HoistResult {\r\n code: string\r\n hoisted: string[]\r\n warnings: string[]\r\n}\r\n\r\nexport interface VariantTableResult {\r\n id: string\r\n tableJson: string\r\n keys: string[]\r\n defaultKey: string\r\n combinations: number\r\n}\r\n\r\nexport interface ClassifyResult {\r\n className: string\r\n bucket: string\r\n sortOrder: number\r\n}\r\n\r\nexport interface MergeResult {\r\n declarationsJson: string\r\n declarationString: string\r\n count: number\r\n}\r\n\r\nexport interface ClassUsageItem {\r\n className: string\r\n usageCount: number\r\n filesJson: string\r\n bundleSizeBytes: number\r\n isDeadCode: boolean\r\n}\r\n\r\nexport interface StateCssConfig {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n sourceFile: string\r\n}\r\n\r\nexport interface GeneratedStateCss {\r\n selector: string\r\n declarations: string\r\n cssRule: string\r\n componentName: string\r\n stateName: string\r\n}\r\n\r\n// ── Type Exports ────────────────────────────────────────────────────────────────\r\n\r\nexport interface NativeBridge {\r\n // CSS Compiler - New Rust implementation\r\n generateCssNative?: (classes: string[], theme_json: string) => string\r\n getCacheStats?: () => [number, number]\r\n clearThemeCache?: () => void\r\n // Core transform\r\n transformSource?: (source: string, opts?: Record<string, string>) => NativeTransformResult | null\r\n extractClassesFromSource?: (source: string) => string[]\r\n hasTwUsage?: (source: string) => boolean\r\n isAlreadyTransformed?: (source: string) => boolean\r\n // Phase 5: Scanner functions (snake_case from Rust)\r\n scan_workspace?: (root: string, extensions?: string[]) => ScanWorkspaceResult\r\n extract_classes_from_source?: (source: string) => string[]\r\n batch_extract_classes?: (filePaths: string[]) => BatchExtractResult[]\r\n check_against_safelist?: (classes: string[], safelist: string[]) => SafelistCheckResult\r\n scan_file?: (filePath: string) => ScanFileResult\r\n collect_files?: (root: string, extensions?: string[]) => string[]\r\n walk_and_prefilter_source_files?: (root: string, extensions?: string[]) => PrefilterFileResult[]\r\n generate_sub_component_types?: (root: string, outputPath?: string) => string\r\n // Class Extractor\r\n extractAllClasses?: (source: string) => string[]\r\n parseClasses?: (raw: string) => Array<{ raw: string; type: string }>\r\n // Application functions\r\n extractComponentUsage?: (source: string) => Array<{ component: string; propsJson: string }>\r\n normalizeAndDedupClasses?: (raw: string) => { normalized: string; duplicatesRemoved: number; uniqueCount: number }\r\n diffClassLists?: (previous: string[], current: string[]) => { added: string[]; removed: string[]; unchanged: string[]; hasChanges: boolean }\r\n batchExtractClasses?: (filePaths: string[]) => Array<{ file: string; classes: string[]; contentHash: string; ok: boolean; error?: string }>\r\n checkAgainstSafelist?: (classes: string[], safelist: string[]) => { matched: string[]; unmatched: string[]; safelistSize: number }\r\n // Batch 2\r\n hoistComponents?: (source: string) => HoistResult\r\n compileVariantTable?: (configJson: string) => VariantTableResult\r\n classifyAndSortClasses?: (classes: string[]) => ClassifyResult[]\r\n mergeCssDeclarations?: (cssChunks: string[]) => MergeResult\r\n analyzeClassUsage?: (classes: string[], scanResultJson: string, css: string) => ClassUsageItem[]\r\n analyzeRsc?: (source: string, filename: string) => {\r\n isServer: boolean\r\n needsClientDirective: boolean\r\n clientReasons: string[]\r\n }\r\n analyzeClasses?: (\r\n filesJson: string,\r\n cwd: string,\r\n flags: number\r\n ) => {\r\n css?: string\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rscJson?: string\r\n metadataJson?: string\r\n safelist?: string[]\r\n } | null\r\n // CSS compilation\r\n compileCss?: (classes: string[], prefix?: string | null) => { css: string; classes: string[] }\r\n compileCssLightning?: (classes: string[]) => string\r\n /** Post-process raw Tailwind-generated CSS dengan LightningCSS di Rust */\r\n detectDeadCode?: (scanResultJson: string, css: string) => DeadCodeResult\r\n processTailwindCssLightning?: (css: string) => ProcessedCssResult\r\n processTailwindCssWithTargets?: (css: string, targets: string | null) => { css: string; size_bytes: number }\r\n // Atomic CSS (atomic.rs)\r\n parseAtomicClass?: (twClass: string) => string | null\r\n generateAtomicCss?: (rulesJson: string) => string\r\n toAtomicClasses?: (twClasses: string) => string\r\n clearAtomicRegistry?: () => void\r\n atomicRegistrySize?: () => number\r\n // Impact analysis (impact_analysis.rs)\r\n calculateImpact?: (impactJson: string) => string\r\n calculateRisk?: (className: string, totalComponents: number) => string\r\n calculateSavings?: (bundleSizeBytes: number, componentCount: number) => number\r\n // Static state CSS pre-generation (state_css.rs)\r\n extractTwStateConfigs?: (source: string, filename: string) => StateCssConfig[]\r\n generateStaticStateCss?: (inputs: Array<{\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n }>, resolvedCss: string | null) => GeneratedStateCss[]\r\n extractAndGenerateStateCss?: (source: string, filename: string) => GeneratedStateCss[]\r\n /**\r\n * Convert layout/utility class string ke CSS declarations.\r\n * Dipakai oleh extractContainerCssFromSource sebagai Rust-accelerated fallback.\r\n */\r\n layoutClassesToCss?: (classes: string) => string\r\n /**\r\n * Hash string dengan algoritma tertentu, return n karakter pertama.\r\n * Dipakai untuk generate deterministic container CSS IDs.\r\n */\r\n hashContent?: (input: string, algo: string, length: number) => string\r\n /** Hapus dead CSS selectors + minify via Lightning CSS. */\r\n eliminateDeadCss?: (css: string, deadClasses: string[]) => string\r\n /** Dead code detection + strip + Lightning CSS minify dalam satu call. */\r\n optimizeCss?: (css: string) => string\r\n /** Extract tw container configs dari source untuk static @container CSS generation. */\r\n extractTwContainerConfigs?: (source: string) => Array<{\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n }>\r\n \r\n // Phase 5.1: Cache Management (9 functions)\r\n get_cache_statistics?: () => string // Returns JSON\r\n clear_all_caches?: () => void\r\n clear_parse_cache?: () => void\r\n clear_resolve_cache?: () => void\r\n clear_compile_cache?: () => void\r\n clear_css_gen_cache?: () => void\r\n get_cache_optimization_hints?: (hit_rate_percent: number, memory_used_mb: number) => string // Returns JSON\r\n estimate_optimal_cache_config_native?: (total_budget_mb: number, workload_type: string) => string // Returns JSON\r\n cache_read?: (cache_path: string) => { entries_json: string }\r\n cache_write?: (cache_path: string, entries: Array<{ file: string; content_hash: string; classes: string[]; mtime_ms: number; size_bytes: number }>) => boolean\r\n cache_priority?: (mtime_ms: number, size_bytes: number, hit_count: number) => number\r\n \r\n // Phase 5.1: Theme Resolution Extended (7 functions)\r\n resolve_variants?: (configJson: string) => string // Returns JSON\r\n validate_variant_config?: (configJson: string) => string // Returns JSON\r\n resolve_cascade?: (baseThemeJson: string, overridesJson: string) => string // Returns JSON\r\n resolve_class_names?: (classNames: string[], themeJson: string) => string // Returns JSON\r\n resolve_conflict_group?: (groupName: string, themeJson: string) => string // Returns JSON\r\n resolve_theme_value?: (keyPath: string, themeJson: string) => string | null\r\n resolve_simple_variants?: (configJson: string) => string // Returns JSON\r\n \r\n // Phase 5.1: Streaming & Incremental Processing (8 functions)\r\n process_file_change?: (fileChangeJson: string) => string // Returns JSON\r\n compute_incremental_diff?: (oldScanJson: string, newScanJson: string) => string // Returns JSON\r\n create_fingerprint?: (filePath: string, fileContent: string) => string // Returns JSON\r\n inject_state_hash?: (css: string, stateHash: string) => string // Returns JSON\r\n prune_stale_entries?: (maxAgeSeconds: number, maxEntries: number) => string // Returns JSON\r\n rebuild_workspace_result?: (rootDir: string, extensions?: string[]) => string // Returns JSON\r\n scan_file_native?: (filePath: string, fileContent: string) => string // Returns JSON\r\n scan_files_batch_native?: (filesJson: string) => string // Returns JSON\r\n \r\n // Phase 5.2: CSS Compilation (12 functions)\r\n compile_class?: (input: string) => string // Returns JSON\r\n compile_classes?: (inputs: string[]) => string // Returns JSON\r\n compile_to_css?: (input: string, minify: boolean) => string\r\n compile_to_css_batch?: (inputs: string[], minify: boolean) => string\r\n minify_css?: (css: string) => string\r\n compile_animation?: (animationName: string, from: string, to: string) => string // Returns JSON\r\n compile_keyframes?: (name: string, stopsJson: string) => string // Returns JSON\r\n compile_theme?: (tokensJson: string, themeName: string, prefix: string) => string // Returns JSON\r\n tw_merge?: (classString: string) => string\r\n tw_merge_many?: (classStrings: string[]) => string\r\n tw_merge_with_separator?: (classString: string, options: Record<string, unknown>) => string\r\n tw_merge_many_with_separator?: (classStrings: string[], options: Record<string, unknown>) => string\r\n tw_merge_raw?: (classLists: string[]) => string\r\n \r\n // Phase 5.2: ID Registry (16 functions)\r\n id_registry_create?: () => number\r\n id_registry_generate?: (handle: number, name: string) => number\r\n id_registry_lookup?: (handle: number, name: string) => number\r\n id_registry_next?: (handle: number) => number\r\n id_registry_destroy?: (handle: number) => void\r\n id_registry_reset?: (handle: number) => void\r\n id_registry_snapshot?: (handle: number) => string // Returns JSON\r\n id_registry_active_count?: () => number\r\n register_property_name?: (propertyName: string) => number\r\n register_value_name?: (valueName: string) => number\r\n property_id_to_string?: (propertyId: number) => string\r\n value_id_to_string?: (valueId: number) => string\r\n reverse_lookup_property?: (propertyId: number) => string\r\n reverse_lookup_value?: (valueId: number) => string\r\n id_registry_export?: (handle: number) => string\r\n id_registry_import?: (importedData: string) => number\r\n \r\n // Phase 5.3: Redis Integration (40 functions)\r\n redis_ping?: () => string\r\n redis_get?: (key: string) => string\r\n redis_set?: (key: string, value: string, ttl_seconds?: number) => string\r\n redis_delete?: (key: string) => number\r\n redis_exists?: (key: string) => number\r\n redis_mget?: (keys: string[]) => string // Returns JSON\r\n redis_mset?: (pairs: Array<[string, string]>) => string\r\n redis_flush_db?: () => number\r\n redis_flush_all?: () => number\r\n redis_pool_connect?: (host: string, port: number, pool_size?: number) => string\r\n redis_pool_stats?: () => string // Returns JSON\r\n redis_pool_reconnect?: () => string\r\n redis_enable_cluster?: (initial_nodes: string[]) => string // Returns JSON\r\n redis_disable_cluster?: () => string\r\n redis_cluster_status?: () => string // Returns JSON\r\n redis_subscribe?: (channel: string) => string\r\n redis_publish?: (channel: string, message: string) => number\r\n redis_expiration_set?: (key: string, ttl_seconds: number) => number\r\n redis_expiration_get?: (key: string) => string // Returns JSON\r\n redis_info?: () => string\r\n redis_monitor?: () => string\r\n redis_cache_size?: () => number\r\n redis_cache_key_count?: () => number\r\n redis_cache_clear?: () => number\r\n redis_cache_hit_rate?: () => number\r\n redis_enable_persistence?: (mode: string) => string\r\n redis_disable_persistence?: () => string\r\n redis_snapshot?: () => string\r\n redis_memory_stats?: () => string\r\n redis_optimize_memory?: () => number\r\n redis_set_eviction_policy?: (policy: string) => string\r\n redis_get_eviction_policy?: () => string\r\n redis_replicate?: (target_host: string, target_port: number) => number\r\n redis_replication_status?: () => string\r\n redis_cache_sync?: (peers: string[]) => number\r\n redis_enable_cache_warming?: (key_pattern: string) => string\r\n redis_disable_cache_warming?: () => string\r\n redis_diagnose?: () => string\r\n \r\n // Phase 5.4: Watch System & File Monitoring (20 functions)\r\n start_watch?: (root_path: string, patterns?: string[]) => number\r\n poll_watch_events?: (handle: number, timeout_ms?: number) => string // Returns JSON\r\n stop_watch?: (handle: number) => number\r\n watch_add_pattern?: (handle: number, pattern: string) => string\r\n watch_remove_pattern?: (handle: number, pattern: string) => string\r\n watch_get_active_handles?: () => string // Returns JSON\r\n watch_clear_all?: () => number\r\n watch_event_type_to_string?: (event_type_code: number) => string\r\n is_watch_running?: (handle: number) => boolean\r\n get_watch_stats?: () => string // Returns JSON\r\n watch_pause?: (handle: number) => string\r\n watch_resume?: (handle: number) => string\r\n scan_cache_optimizations?: () => string // Returns JSON\r\n get_plugin_hooks?: () => string // Returns JSON\r\n register_plugin_hook?: (hook_name: string, handler_id: string) => string\r\n unregister_plugin_hook?: (hook_name: string, handler_id: string) => string\r\n emit_plugin_hook?: (hook_name: string, data_json: string) => string\r\n get_compilation_metrics?: () => string // Returns JSON\r\n reset_compilation_metrics?: () => string\r\n validate_css_output?: (css: string) => string // Returns JSON\r\n get_compiler_diagnostics?: () => string // Returns JSON\r\n\r\n // ── Cache Management (napi_bridge_cache.rs) ────────────────────────────────\r\n configureCacheBackend?: (configJson: string) => string\r\n getRecommendedCacheConfig?: (workloadType: string) => string\r\n clearAllCachesNapi?: () => void\r\n clearResolveCacheNapi?: () => void\r\n clearCompileCacheNapi?: () => void\r\n clearCssGenCacheNapi?: () => void\r\n getResolverPoolStats?: () => string\r\n clearResolverPool?: () => string\r\n getCacheOptimizationHints?: () => string\r\n estimateStreamingBatchSize?: (targetMemoryMb: number) => string\r\n\r\n // ── Parsing (napi_bridge_parsing.rs) ──────────────────────────────────────\r\n parseClass?: (input: string) => string\r\n compileClassNapi?: (input: string) => string\r\n getParseStats?: () => string\r\n clearParseCacheNapi?: () => void\r\n\r\n // ── Theme Parsing (napi_bridge_theme_parsing.rs) ───────────────────────────\r\n parseColorsNapi?: (colorsJson: string) => string | Record<string, string>\r\n parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>\r\n parseTransformNapi?: (transformJson: string) => string | Record<string, string>\r\n normalizeColorNapi?: (color: string, opacity: string) => string\r\n sanitizeColorNapi?: (color: string) => string\r\n splitRgbaNapi?: (color: string) => string | { r: number; g: number; b: number; a: number }\r\n validateColorsNapi?: (colorsJson: string) => boolean\r\n validateBreakpointsNapi?: (breakpointsJson: string) => boolean\r\n runHealthCheck?: () => void\r\n\r\n // ── Watch (napi_bridge_watch.rs) ───────────────────────────────────────────\r\n watchFiles?: (rootDir: string, optionsJson?: string | null) => string\r\n stopWatching?: (handleId: number) => string\r\n getWatchEvents?: (handleId: number, maxEvents?: number | null) => string\r\n getWatchPerformance?: () => string\r\n clearWatchStats?: () => string\r\n getActiveWatches?: () => number\r\n setWatchMetrics?: (metricName: string, value: string) => string\r\n setWatchAggregation?: (aggregationType: string) => string\r\n\r\n // ── Week 6 Optimization (week6_api.rs) ────────────────────────────────────\r\n getOptimizationRecommendations?: (hitRate: number, memoryMb: number, classCount: number) => string\r\n estimateOptimalBatchSize?: (totalClasses: number, memoryAvailableMb: number) => number\r\n predictMemoryUsage?: (uniqueClasses: number, avgClassSizeBytes: number) => number\r\n recommendCachingStrategy?: (isSsr: boolean, memoryConstraintMb: number) => string\r\n benchmarkStreamingVsBuffered?: (classCount: number) => string\r\n getWeek6OptimizationStatus?: () => string\r\n\r\n // ── Scan Cache (scan_cache_api.rs) ────────────────────────────────────────\r\n scanCacheGet?: (filePath: string, contentHash: string) => string[] | null\r\n scanCachePut?: (filePath: string, contentHash: string, classes: string[], mtimeMs: number, size: number) => void\r\n scanCacheInvalidate?: (filePath: string) => void\r\n scanCacheStats?: () => { size: number }\r\n}\r\n\r\nexport interface NativeTransformResult {\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rscJson?: string\r\n metadataJson?: string\r\n}\r\n\r\nexport interface ClassExtractResult {\r\n classes: string[]\r\n component_names: string[]\r\n has_tw_usage: boolean\r\n has_use_client: boolean\r\n imports: string[]\r\n}\r\n\r\nconst NATIVE_UNAVAILABLE_MESSAGE =\r\n \"[tailwind-styled/compiler v5] Native binding is required but not available.\\n\" +\r\n \"This package requires native Rust bindings. There is no JavaScript fallback.\\n\" +\r\n \"Please ensure:\\n\" +\r\n \" 1. The native module is properly installed\\n\" +\r\n \" 2. You have run: npm run build:rust (or use prebuilt binary)\\n\" +\r\n \"\\n\" +\r\n \"For help, see: https://tailwind-styled.dev/docs/install\"\r\n\r\n// ── Native Bridge - Factory Pattern\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nlet nativeBridge: NativeBridge | null = null\r\nlet bridgeLoadAttempted = false\r\nlet bridgeLoadError: Error | null = null\r\n\r\nconst isValidNativeBridge = (mod: unknown): mod is NativeBridge => {\r\n const m = mod as Partial<NativeBridge>\r\n return !!(\r\n typeof m.transformSource === \"function\" ||\r\n typeof m.extractAllClasses === \"function\" ||\r\n typeof m.hasTwUsage === \"function\"\r\n )\r\n}\r\n\r\nexport const getNativeBridge = (): NativeBridge => {\r\n if (nativeBridge) {\r\n return nativeBridge\r\n }\r\n\r\n if (bridgeLoadAttempted) {\r\n if (bridgeLoadError) {\r\n throw bridgeLoadError\r\n }\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n\r\n bridgeLoadAttempted = true\r\n\r\n try {\r\n const runtimeDir = resolveRuntimeDir(undefined, import.meta.url)\r\n \r\n // Use shared's native resolution\r\n const result = resolveNativeBinary(runtimeDir)\r\n\r\n if (result.path && result.path.endsWith(\".node\")) {\r\n try {\r\n const binding = _loadNative(result.path) as NativeBridge\r\n if (isValidNativeBridge(binding)) {\r\n nativeBridge = binding\r\n log(\"Native bridge loaded successfully from:\", result.path)\r\n return nativeBridge\r\n }\r\n } catch (e) {\r\n log(\"Failed to require native binding:\", e)\r\n }\r\n }\r\n\r\n throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}\\n\\nTried paths: ${result.tried.join(\"\\n\")}`)\r\n } catch (err) {\r\n bridgeLoadError = err instanceof Error ? err : new Error(String(err))\r\n log(\"Failed to load native bridge:\", bridgeLoadError.message)\r\n throw bridgeLoadError\r\n }\r\n}\r\n\r\nexport const resetNativeBridgeCache = (): void => {\r\n nativeBridge = null\r\n bridgeLoadAttempted = false\r\n bridgeLoadError = null\r\n log(\"Native bridge cache reset\")\r\n}\r\n\r\n// ── Adaptor for native results\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport const adaptNativeResult = (\r\n raw: NativeTransformResult\r\n): {\r\n code: string\r\n classes: string[]\r\n changed: boolean\r\n rsc?: NativeRscResult\r\n metadata?: ComponentMetadata[]\r\n} => {\r\n return {\r\n code: raw.code ?? \"\",\r\n classes: raw.classes ?? [],\r\n changed: raw.changed ?? false,\r\n rsc: raw.rscJson ? JSON.parse(raw.rscJson) : undefined,\r\n metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : undefined,\r\n }\r\n}\r\n\r\n// ── Eager init — load native bridge saat module dimuat, bukan saat request pertama\r\n// Mencegah crash di Turbopack dev mode karena lazy init mid-request\r\n// ─────────────────────────────────────────────────────────────────────────────\r\nif (typeof process !== \"undefined\" && !bridgeLoadAttempted) {\r\n try {\r\n getNativeBridge()\r\n } catch {\r\n // Sudah di-capture di bridgeLoadError — akan di-throw saat dipanggil pertama kali\r\n }\r\n}\r\n\r\n// ── Re-export all 63 wrapper functions from nativeBridgeWrappers\r\n// These provide complete type safety, error handling, and JSDoc documentation\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport {\r\n // Redis Cache Functions (40)\r\n redis_pool_connect,\r\n redis_pool_stats,\r\n redis_pool_reconnect,\r\n redis_ping,\r\n redis_get,\r\n redis_set,\r\n redis_delete,\r\n redis_exists,\r\n redis_mget,\r\n redis_mset,\r\n redis_flush_db,\r\n redis_flush_all,\r\n redis_cache_size,\r\n redis_cache_key_count,\r\n redis_cache_clear,\r\n redis_cache_hit_rate,\r\n redis_info,\r\n redis_monitor,\r\n redis_enable_cluster,\r\n redis_disable_cluster,\r\n redis_cluster_status,\r\n redis_expiration_set,\r\n redis_expiration_get,\r\n redis_subscribe,\r\n redis_publish,\r\n redis_enable_persistence,\r\n redis_disable_persistence,\r\n redis_snapshot,\r\n redis_replicate,\r\n redis_replication_status,\r\n redis_enable_cache_warming,\r\n redis_disable_cache_warming,\r\n redis_cache_sync,\r\n redis_set_eviction_policy,\r\n redis_get_eviction_policy,\r\n redis_memory_stats,\r\n redis_optimize_memory,\r\n redis_diagnose,\r\n // Watch System Functions (20)\r\n start_watch,\r\n poll_watch_events,\r\n stop_watch,\r\n watch_add_pattern,\r\n watch_remove_pattern,\r\n watch_pause,\r\n watch_resume,\r\n is_watch_running,\r\n get_watch_stats,\r\n watch_get_active_handles,\r\n watch_clear_all,\r\n register_plugin_hook,\r\n unregister_plugin_hook,\r\n emit_plugin_hook,\r\n get_plugin_hooks,\r\n // ID Registry Functions (16)\r\n id_registry_create,\r\n id_registry_generate,\r\n id_registry_lookup,\r\n id_registry_next,\r\n id_registry_destroy,\r\n id_registry_reset,\r\n id_registry_snapshot,\r\n id_registry_active_count,\r\n register_property_name,\r\n register_value_name,\r\n property_id_to_string,\r\n value_id_to_string,\r\n reverse_lookup_property,\r\n reverse_lookup_value,\r\n id_registry_export,\r\n id_registry_import,\r\n // Incremental Compilation Functions (8)\r\n process_file_change,\r\n compute_incremental_diff,\r\n create_fingerprint,\r\n inject_state_hash,\r\n prune_stale_entries,\r\n rebuild_workspace_result,\r\n scan_files_batch_native,\r\n // Theme Resolution Functions (7)\r\n resolve_variants,\r\n validate_variant_config,\r\n resolve_cascade,\r\n resolve_class_names,\r\n resolve_conflict_group,\r\n resolve_theme_value,\r\n resolve_simple_variants,\r\n} from \"./nativeBridgeWrappers\"","/**\r\n * Compiler Sub-entry Point\r\n * \r\n * Exports CSS generation and compilation functionality.\r\n * - CSS generation with caching\r\n * - Compilation of classes to CSS\r\n * - ID registry management\r\n * - Streaming and incremental processing\r\n */\r\n\r\nexport {\r\n generateCssNative,\r\n getCacheStats,\r\n clearThemeCache,\r\n} from './cssGeneratorNative'\r\n\r\nexport {\r\n compileCssNative2,\r\n compileCssLightning,\r\n extractTwStateConfigsNative,\r\n generateStaticStateCssNative,\r\n extractAndGenerateStateCssNative,\r\n layoutClassesToCss,\r\n hashContent,\r\n extractTwContainerConfigs,\r\n parseAtomicClass,\r\n generateAtomicCss,\r\n toAtomicClasses,\r\n clearAtomicRegistry,\r\n atomicRegistrySize,\r\n type ContainerConfig,\r\n type StateCssConfig,\r\n type GeneratedStateCss,\r\n} from './compilationNative'\r\n\r\nexport {\r\n compileClass,\r\n compileClasses,\r\n compileToCss,\r\n compileToCssBatch,\r\n minifyCss,\r\n compileAnimation,\r\n compileKeyframes,\r\n compileTheme,\r\n twMerge,\r\n twMergeMany,\r\n twMergeWithSeparator,\r\n twMergeManyWithSeparator,\r\n twMergeRaw,\r\n type CompiledCssRule,\r\n type CompiledAnimation,\r\n type CompiledTheme,\r\n type CssCompileResult,\r\n type TwMergeOptions,\r\n} from './cssCompilationNative'\r\n\r\nexport {\r\n idRegistryCreate,\r\n idRegistryGenerate,\r\n idRegistryLookup,\r\n idRegistryNext,\r\n idRegistryDestroy,\r\n idRegistryReset,\r\n idRegistrySnapshot,\r\n idRegistryActiveCount,\r\n registerPropertyName,\r\n registerValueName,\r\n propertyIdToString,\r\n valueIdToString,\r\n reverseLookupProperty,\r\n reverseLookupValue,\r\n idRegistryExport,\r\n idRegistryImport,\r\n type RegistrySnapshot,\r\n} from './idRegistryNative'\r\n\r\nexport {\r\n processFileChange,\r\n computeIncrementalDiff,\r\n createFingerprint,\r\n injectStateHash,\r\n pruneStaleCacheEntries,\r\n rebuildWorkspaceResult,\r\n scanFileNative,\r\n scanFilesBatchNative,\r\n type FileChangeEvent,\r\n type ProcessedFileChange,\r\n type FileDiff,\r\n type FileFingerprint,\r\n type IncrementalDiffResult,\r\n type StateInjectionResult,\r\n type PruneResult,\r\n type RebuildWorkspaceResult,\r\n} from './streamingNative'\r\n\r\nexport { runCssPipeline } from './tailwindEngine'\r\n","/**\r\n * Parser Sub-entry Point\r\n * \r\n * Exports class parsing and extraction functionality.\r\n * - Tailwind class parsing\r\n * - Class extraction from source\r\n * - Class normalization and deduplication\r\n * - Component analysis\r\n */\r\n\r\nimport { getNativeBridge } from '../nativeBridge'\r\n\r\n// ============================================================================\r\n// PARSING FUNCTIONS\r\n// ============================================================================\r\n\r\nexport const parseClasses = (raw: string): Array<{ raw: string; type: string }> => {\r\n const native = getNativeBridge()\r\n if (!native?.parseClasses) {\r\n throw new Error('FATAL: Native binding \\'parseClasses\\' is required but not available.')\r\n }\r\n return native.parseClasses(raw) || []\r\n}\r\n\r\n// ============================================================================\r\n// CLASS EXTRACTION\r\n// ============================================================================\r\n\r\nexport const extractAllClasses = (source: string): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.extractAllClasses) {\r\n throw new Error('FATAL: Native binding \\'extractAllClasses\\' is required but not available.')\r\n }\r\n return native.extractAllClasses(source) || []\r\n}\r\n\r\nexport const extractClassesFromSource = (source: string): string => {\r\n const native = getNativeBridge()\r\n if (!native?.extractClassesFromSource) {\r\n throw new Error('FATAL: Native binding \\'extractClassesFromSource\\' is required but not available.')\r\n }\r\n const result = native.extractClassesFromSource(source)\r\n return Array.isArray(result) ? result.join(' ') : String(result || '')\r\n}\r\n\r\nexport const astExtractClasses = (source: string, _filename: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.extractClassesFromSource) {\r\n throw new Error('FATAL: Native binding \\'extractClassesFromSource\\' is required but not available.')\r\n }\r\n return native.extractClassesFromSource(source) || []\r\n}\r\n\r\n// ============================================================================\r\n// CLASS NORMALIZATION & MERGING\r\n// ============================================================================\r\n\r\nexport const normalizeClasses = (raw: string): string => {\r\n const result = normalizeAndDedupClasses(raw)\r\n return result?.normalized || ''\r\n}\r\n\r\nexport const mergeClassesStatic = (classes: string): string => {\r\n const result = normalizeAndDedupClasses(classes)\r\n return result?.normalized || ''\r\n}\r\n\r\nexport const normalizeAndDedupClasses = (raw: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.normalizeAndDedupClasses) {\r\n throw new Error('FATAL: Native binding \\'normalizeAndDedupClasses\\' is required but not available.')\r\n }\r\n const result = native.normalizeAndDedupClasses(raw)\r\n return result || { normalized: '', duplicatesRemoved: 0, uniqueCount: 0 }\r\n}\r\n\r\n// ============================================================================\r\n// COMPONENT ANALYSIS\r\n// ============================================================================\r\n\r\nexport const extractComponentUsage = (source: string): Array<{ component: string; propsJson: string }> => {\r\n const native = getNativeBridge()\r\n if (!native?.extractComponentUsage) {\r\n throw new Error('FATAL: Native binding \\'extractComponentUsage\\' is required but not available.')\r\n }\r\n return native.extractComponentUsage(source) || []\r\n}\r\n\r\n// ============================================================================\r\n// BATCH OPERATIONS\r\n// ============================================================================\r\n\r\nexport const batchExtractClasses = (filePaths: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.batchExtractClasses) {\r\n throw new Error('FATAL: Native binding \\'batchExtractClasses\\' is required but not available.')\r\n }\r\n return native.batchExtractClasses(filePaths) || []\r\n}\r\n\r\nexport const checkAgainstSafelist = (classes: string[], safelist: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.checkAgainstSafelist) {\r\n throw new Error('FATAL: Native binding \\'checkAgainstSafelist\\' is required but not available.')\r\n }\r\n return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 }\r\n}\r\n\r\n// ============================================================================\r\n// DIFF & MERGING\r\n// ============================================================================\r\n\r\nexport const diffClassLists = (previous: string[], current: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.diffClassLists) {\r\n throw new Error('FATAL: Native binding \\'diffClassLists\\' is required but not available.')\r\n }\r\n return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false }\r\n}\r\n\r\n// Re-export types if any\r\nexport type { ClassExtractResult, ComponentMetadata } from '../nativeBridge'\r\n","/**\r\n * Analyzer Sub-entry Point\r\n * \r\n * Exports analysis and optimization functionality.\r\n * - CSS and class analysis\r\n * - Dead code detection\r\n * - Theme resolution and validation\r\n * - Code classification and optimization\r\n */\r\n\r\nexport {\r\n detectDeadCode,\r\n analyzeClassUsageNative,\r\n analyzeClassesNative,\r\n analyzeRscNative,\r\n optimizeCssNative,\r\n processTailwindCssLightning,\r\n eliminateDeadCssNative,\r\n hoistComponentsNative,\r\n compileVariantTableNative,\r\n classifyAndSortClassesNative,\r\n mergeCssDeclarationsNative,\r\n type DeadCodeResult,\r\n type ClassUsageItem,\r\n type ProcessedCssResult,\r\n type HoistResult,\r\n type VariantTableResult,\r\n type ClassifyResult,\r\n type MergeResult,\r\n} from './analyzerNative'\r\n\r\nexport {\r\n resolveVariants,\r\n validateThemeConfig,\r\n resolveCascade,\r\n resolveClassNames,\r\n resolveConflictGroup,\r\n resolveThemeValue,\r\n resolveSimpleVariants,\r\n type ThemeValidationResult,\r\n type ResolvedVariantConfig,\r\n type ThemeCascadeResult,\r\n type ResolvedClassName,\r\n type ConflictGroupInfo,\r\n} from './themeResolutionNative'\r\n\r\nexport {\r\n scanWorkspace,\r\n extractClassesFromSourceNative,\r\n batchExtractClassesNative,\r\n checkAgainstSafelistNative,\r\n scanFile,\r\n collectFiles,\r\n walkAndPrefilterSourceFiles,\r\n generateSubComponentTypes,\r\n type ScanWorkspaceResult,\r\n type ScanFileResult,\r\n type BatchExtractResult,\r\n type SafelistCheckResult,\r\n type PrefilterFileResult,\r\n} from './scannerNative'\r\n","/**\r\n * Cache Sub-entry Point\r\n * \r\n * Exports cache management functionality.\r\n * - Cache statistics retrieval\r\n * - Cache clearing operations\r\n * - Cache optimization\r\n * - Cache configuration\r\n */\r\n\r\nexport {\r\n getCacheStatistics,\r\n clearAllCaches,\r\n clearParseCache,\r\n clearResolveCache,\r\n clearCompileCache,\r\n clearCssGenCache,\r\n getCacheOptimizationHints,\r\n estimateOptimalCacheConfig,\r\n cacheRead,\r\n cacheWrite,\r\n cachePriority,\r\n type CacheOptimizationHints,\r\n type OptimalCacheConfig,\r\n type CacheStatistics,\r\n} from './cacheNative'\r\n","/**\r\n * Redis Sub-entry Point\r\n * \r\n * Exports Redis and distributed cache functionality.\r\n * - Redis operations (get, set, delete, etc.)\r\n * - Redis pool management\r\n * - Cluster management\r\n * - Cache synchronization\r\n * - Persistence management\r\n */\r\n\r\nexport {\r\n redisPing,\r\n redisGet,\r\n redisSet,\r\n redisDelete,\r\n redisExists,\r\n redisMget,\r\n redisMset,\r\n redisFlushDb,\r\n redisFlushAll,\r\n redisPoolConnect,\r\n redisPoolStats,\r\n redisPoolReconnect,\r\n redisEnableCluster,\r\n redisDisableCluster,\r\n redisClusterStatus,\r\n redisSubscribe,\r\n redisPublish,\r\n redisExpirationSet,\r\n redisExpirationGet,\r\n redisInfo,\r\n redisMonitor,\r\n redisCacheSize,\r\n redisCacheKeyCount,\r\n redisCacheClear,\r\n redisCacheHitRate,\r\n redisEnablePersistence,\r\n redisDisablePersistence,\r\n redisSnapshot,\r\n redisMemoryStats,\r\n redisOptimizeMemory,\r\n redisSetEvictionPolicy,\r\n redisGetEvictionPolicy,\r\n redisReplicate,\r\n redisReplicationStatus,\r\n redisCacheSync,\r\n redisEnableCacheWarming,\r\n redisDisableCacheWarming,\r\n redisDiagnose,\r\n type RedisCacheConfig,\r\n type RedisPoolStats,\r\n type RedisClusterNode,\r\n type RedisClusterStatus,\r\n type KeyExpiration,\r\n type PubSubMessage,\r\n type PoolInfo,\r\n} from './redisNative'\r\n","/**\r\n * Watch Sub-entry Point\r\n * \r\n * Exports file watching and compilation monitoring functionality.\r\n * - File system watching\r\n * - Watch event polling and management\r\n * - Watch statistics\r\n * - Plugin hooks\r\n * - Compilation metrics\r\n */\r\n\r\nexport {\r\n startWatch,\r\n pollWatchEvents,\r\n stopWatch,\r\n watchAddPattern,\r\n watchRemovePattern,\r\n watchGetActiveHandles,\r\n watchClearAll,\r\n watchEventTypeToString,\r\n isWatchRunning,\r\n getWatchStats,\r\n watchPause,\r\n watchResume,\r\n scanCacheOptimizations,\r\n getPluginHooks,\r\n registerPluginHook,\r\n unregisterPluginHook,\r\n emitPluginHook,\r\n getCompilationMetrics,\r\n resetCompilationMetrics,\r\n validateCssOutput,\r\n getCompilerDiagnostics,\r\n type WatchEvent,\r\n type WatchHandle,\r\n type WatchStats,\r\n} from './watchSystemNative'\r\n","/**\r\n * tailwind-styled-v5 — Compiler Main Entry Point\r\n * \r\n * Re-exports all sub-entry points for backward compatibility.\r\n * For better tree-shaking, import from specific sub-entries:\r\n * - '@tailwind-styled/compiler/compiler' - CSS generation and compilation\r\n * - '@tailwind-styled/compiler/parser' - Class parsing and extraction\r\n * - '@tailwind-styled/compiler/analyzer' - Analysis and optimization\r\n * - '@tailwind-styled/compiler/cache' - Cache management\r\n * - '@tailwind-styled/compiler/redis' - Redis and distributed cache\r\n * - '@tailwind-styled/compiler/watch' - File watching and monitoring\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\n\r\nimport { getNativeBridge, resetNativeBridgeCache, adaptNativeResult, type NativeBridge, type NativeTransformResult, type ClassExtractResult, type ComponentMetadata, type NativeRscResult } from \"./nativeBridge\"\r\n\r\nexport { getNativeBridge, resetNativeBridgeCache, adaptNativeResult }\r\nexport type { NativeBridge, NativeTransformResult, ClassExtractResult, ComponentMetadata, NativeRscResult }\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// RE-EXPORT ALL SUB-ENTRIES FOR BACKWARD COMPATIBILITY\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\n// Compiler sub-entry - CSS generation, compilation, ID registry, streaming\r\nexport * from './compiler'\r\n\r\n// Parser sub-entry - Class parsing and extraction\r\nexport * from './parser'\r\n\r\n// Analyzer sub-entry - Analysis, optimization, theme resolution\r\nexport * from './analyzer'\r\n\r\n// Cache sub-entry - Cache management\r\nexport * from './cache'\r\n\r\n// Redis sub-entry - Redis and distributed cache\r\nexport * from './redis'\r\n\r\n// Watch sub-entry - File watching and monitoring\r\nexport * from './watch'\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// TRANSFORM & CORE FUNCTIONS\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const transformSource = (source: string, opts?: Record<string, unknown>) => {\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(source, opts as Record<string, string>)\r\n if (!result) {\r\n throw new Error(\"FATAL: transformSource returned null\")\r\n }\r\n return result\r\n}\r\n\r\nexport const hasTwUsage = (source: string): boolean => {\r\n const native = getNativeBridge()\r\n if (!native?.hasTwUsage) {\r\n throw new Error(\"FATAL: Native binding 'hasTwUsage' is required but not available.\")\r\n }\r\n return native.hasTwUsage(source)\r\n}\r\n\r\nexport const isAlreadyTransformed = (source: string): boolean => {\r\n const native = getNativeBridge()\r\n if (!native?.isAlreadyTransformed) {\r\n throw new Error(\"FATAL: Native binding 'isAlreadyTransformed' is required but not available.\")\r\n }\r\n return native.isAlreadyTransformed(source)\r\n}\r\n\r\nexport const shouldProcess = (source: string): boolean => {\r\n return hasTwUsage(source) && !isAlreadyTransformed(source)\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// ADDITIONAL UTILITIES\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const compileCssFromClasses = (classes: string[], prefix?: string | null) => {\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(classes.join(\" \"), { prefix: prefix ?? \"\" })\r\n if (!result) {\r\n throw new Error(\"FATAL: transformSource returned null\")\r\n }\r\n return result\r\n}\r\n\r\nexport const buildStyleTag = (classes: string[]): string => {\r\n const result = compileCssFromClasses(classes)\r\n return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : \"\"\r\n}\r\n\r\nexport const generateCssForClasses = async (\r\n classes: string[],\r\n _tailwindConfig?: Record<string, unknown>,\r\n root?: string,\r\n cssEntryContent?: string,\r\n minify = false\r\n): Promise<string> => {\r\n try {\r\n const { runCssPipeline } = await import(\"./compiler/tailwindEngine\")\r\n const result = await runCssPipeline(classes, cssEntryContent, root, minify)\r\n return result.css\r\n } catch {\r\n // Fallback if import fails\r\n const native = getNativeBridge()\r\n if (!native?.transformSource) {\r\n throw new Error(\"FATAL: Native binding 'transformSource' is required but not available.\")\r\n }\r\n const result = native.transformSource(classes.join(\" \"), {})\r\n return result?.code || \"\"\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// DEAD STYLE ELIMINATION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const eliminateDeadCss = (css: string, deadClasses: Set<string>): string => {\r\n const native = getNativeBridge()\r\n if (!native?.eliminateDeadCss) {\r\n throw new Error(\"FATAL: Native binding 'eliminateDeadCss' is required but not available.\")\r\n }\r\n return native.eliminateDeadCss(css, Array.from(deadClasses)) as string\r\n}\r\n\r\nexport const findDeadVariants = (\r\n variantConfig: Record<string, unknown> | Array<{ name: string; variants: Record<string, Record<string, string>>; defaultVariants?: Record<string, string> }>,\r\n usage: Record<string, Set<string>>\r\n) => {\r\n const unused: string[] = []\r\n\r\n const configs = Array.isArray(variantConfig)\r\n ? variantConfig\r\n : [{ name: \"__root__\", variants: variantConfig as Record<string, Record<string, string>> }]\r\n\r\n for (const component of configs) {\r\n const componentUsage = usage[component.name] ?? new Set<string>()\r\n const variants = component.variants as Record<string, Record<string, string>>\r\n for (const [key, values] of Object.entries(variants)) {\r\n for (const [value] of Object.entries(values)) {\r\n if (!componentUsage.has(`${key}:${value}`)) {\r\n unused.push(`${component.name !== \"__root__\" ? `${component.name}/` : \"\"}${key}:${value}`)\r\n }\r\n }\r\n }\r\n }\r\n\r\n return { unusedCount: unused.length, unused }\r\n}\r\n\r\nexport const runElimination = (css: string, scanResult: unknown): string => {\r\n const native = getNativeBridge()\r\n if (!native?.detectDeadCode) {\r\n throw new Error(\"FATAL: Native binding 'detectDeadCode' is required but not available.\")\r\n }\r\n const dead = native.detectDeadCode(JSON.stringify(scanResult), css) as { deadInCss: string[] }\r\n return eliminateDeadCss(css, new Set(dead.deadInCss ?? []))\r\n}\r\n\r\nexport const scanProjectUsage = (dirs: string[], cwd: string) => {\r\n // Import locally to avoid circular dependency\r\n const { batchExtractClasses } = require('./parser')\r\n const files = dirs.map(dir => path.resolve(cwd, dir))\r\n const results = batchExtractClasses(files) || []\r\n\r\n const combined: Record<string, Record<string, Set<string>>> = {}\r\n for (const result of results) {\r\n if (result.ok && result.classes) {\r\n for (const cls of result.classes) {\r\n if (!combined[cls]) combined[cls] = {}\r\n combined[cls][result.file] = new Set([cls])\r\n }\r\n }\r\n }\r\n return combined\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// CONFIG & UTILITIES\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const generateSafelist = (scanDirs: string[], outputPath?: string, cwd?: string) => {\r\n const classes = scanProjectUsage(scanDirs, cwd || process.cwd())\r\n const allClasses = Object.keys(classes).sort()\r\n if (outputPath) {\r\n fs.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2))\r\n }\r\n return allClasses\r\n}\r\n\r\nexport const loadSafelist = (safelistPath: string): string[] => {\r\n try {\r\n const content = fs.readFileSync(safelistPath, \"utf-8\")\r\n return JSON.parse(content)\r\n } catch {\r\n return []\r\n }\r\n}\r\n\r\nexport const loadTailwindConfig = (cwd: string = process.cwd()) => {\r\n const configFiles = [\r\n \"tailwind.config.ts\",\r\n \"tailwind.config.js\",\r\n \"tailwind.config.mjs\",\r\n \"tailwind.config.cjs\",\r\n ]\r\n for (const file of configFiles) {\r\n const fullPath = path.join(cwd, file)\r\n if (fs.existsSync(fullPath)) {\r\n const mod = require(fullPath) as { default?: unknown }\r\n return mod.default || mod\r\n }\r\n }\r\n return {}\r\n}\r\n\r\nexport const getContentPaths = (cwd: string = process.cwd()) => {\r\n return {\r\n content: [\r\n path.join(cwd, \"src/**/*.{js,ts,jsx,tsx}\"),\r\n path.join(cwd, \"app/**/*.{js,ts,jsx,tsx}\"),\r\n path.join(cwd, \"pages/**/*.{js,ts,jsx,tsx}\"),\r\n ],\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// CONTAINER CSS EXTRACTION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nfunction _layoutClassesToCss(classes: string): string {\r\n const native = getNativeBridge()\r\n if (!native?.layoutClassesToCss) {\r\n throw new Error(\"FATAL: Native binding 'layoutClassesToCss' is required but not available.\")\r\n }\r\n return native.layoutClassesToCss(classes)\r\n}\r\n\r\nfunction _hashContainer(tag: string, containerJson: string, name?: string): string {\r\n const sortedKey = tag + (name ?? \"\") + containerJson\r\n const native = getNativeBridge()\r\n if (!native?.hashContent) {\r\n throw new Error(\"FATAL: Native binding 'hashContent' is required but not available.\")\r\n }\r\n return `tw-cq-${native.hashContent(sortedKey, \"fnv\", 6)}`\r\n}\r\n\r\nconst _CONTAINER_BREAKPOINTS: Record<string, string> = {\r\n xs: \"240px\",\r\n sm: \"320px\",\r\n md: \"640px\",\r\n lg: \"1024px\",\r\n xl: \"1280px\",\r\n \"2xl\": \"1536px\",\r\n}\r\n\r\nexport function extractContainerCssFromSource(source: string): string {\r\n const native = getNativeBridge()\r\n if (!native?.extractTwContainerConfigs) {\r\n throw new Error(\"FATAL: Native binding 'extractTwContainerConfigs' is required but not available.\")\r\n }\r\n\r\n const configs = native.extractTwContainerConfigs(source) as Array<{\r\n tag: string\r\n containerJson: string\r\n containerName?: string\r\n breakpoints: Array<{ key: string; classes: string }>\r\n }>\r\n\r\n const rules: string[] = []\r\n for (const cfg of configs) {\r\n const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName)\r\n for (const { key, classes } of cfg.breakpoints) {\r\n const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key\r\n const css = _layoutClassesToCss(classes)\r\n if (!css) continue\r\n const query = cfg.containerName\r\n ? `@container ${cfg.containerName} (min-width: ${minWidth})`\r\n : `@container (min-width: ${minWidth})`\r\n rules.push(`${query}{.${id}{${css}}}`)\r\n }\r\n }\r\n return rules.join(\"\\n\")\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// LOADER INTERFACE\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport type LoaderOutput = {\r\n code: string\r\n changed: boolean\r\n classes: string[]\r\n staticCss?: string\r\n rsc?: { isServer?: boolean; needsClientDirective?: boolean; clientReasons?: string[] }\r\n engine?: string\r\n}\r\n\r\nexport const runLoaderTransform = (ctx: { filepath: string; source: string; options?: Record<string, unknown> }) => {\r\n const { filepath, source, options } = ctx\r\n const result = transformSource(source, { filename: filepath, ...options })\r\n\r\n let staticCss: string | undefined\r\n try {\r\n const cssChunks: string[] = []\r\n\r\n const stateRules = extractAndGenerateStateCss(source, filepath)\r\n if (stateRules.length > 0) {\r\n cssChunks.push(stateRules.map((r) => r.cssRule).join(\"\\n\"))\r\n }\r\n\r\n const containerCss = extractContainerCssFromSource(source)\r\n if (containerCss) cssChunks.push(containerCss)\r\n\r\n const combined = cssChunks.join(\"\\n\").trim()\r\n if (combined) staticCss = combined\r\n } catch (err) {\r\n // Non-fatal — static CSS extraction failure should not break transform pipeline.\r\n console.debug(\"Static CSS extraction warning:\", err)\r\n }\r\n\r\n return {\r\n code: result?.code || \"\",\r\n changed: result?.changed || false,\r\n classes: result?.classes || [],\r\n staticCss,\r\n } as LoaderOutput\r\n}\r\n\r\nexport const shouldSkipFile = (filepath: string): boolean => {\r\n const SKIP_PATHS = [\"node_modules\", \".next\", \".rspack-dist\", \".turbo\", \"dist/\", \"out/\"]\r\n const skipExtensions = [\".css\", \".json\", \".md\", \".txt\", \".yaml\", \".yml\"]\r\n for (const p of SKIP_PATHS) {\r\n if (filepath.includes(p)) return true\r\n }\r\n for (const ext of skipExtensions) {\r\n if (filepath.endsWith(ext)) return true\r\n }\r\n return false\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// ROUTE MANAGEMENT\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const fileToRoute = (filepath: string): string | null => {\r\n const normalized = filepath.replace(/\\\\/g, \"/\")\r\n if (normalized.includes(\"/layout.\") || normalized.includes(\"/loading.\") || normalized.includes(\"/error.\")) {\r\n return \"__global\"\r\n }\r\n const pageMatch = normalized.match(/\\/app\\/(.+?)\\/page\\.[tj]sx?$/)\r\n if (pageMatch) return `/${pageMatch[1]}`\r\n const rootPage = normalized.match(/\\/app\\/page\\.[tj]sx?$/)\r\n if (rootPage) return \"/\"\r\n return null\r\n}\r\n\r\nexport const getAllRoutes = (): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClasses) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClasses' is required but not available.\")\r\n }\r\n return [\"/\", \"__global\"]\r\n}\r\n\r\nexport const getRouteClasses = (_route: string): Set<string> => new Set()\r\nexport const registerFileClasses = (_filepath: string, _classes: string[]): void => {}\r\nexport const registerGlobalClasses = (_classes: string[]): void => {}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// INCREMENTAL ENGINE\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nlet _incrementalEngineInstance: InstanceType<typeof IncrementalEngine> | null = null\r\n\r\nexport const getIncrementalEngine = () => {\r\n if (!_incrementalEngineInstance) {\r\n _incrementalEngineInstance = new IncrementalEngine()\r\n }\r\n return _incrementalEngineInstance\r\n}\r\n\r\nexport const resetIncrementalEngine = (): void => {\r\n _incrementalEngineInstance = null\r\n}\r\n\r\nexport class IncrementalEngine {\r\n compile(source: string) {\r\n return transformSource(source)\r\n }\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// STYLE BUCKET SYSTEM\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const getBucketEngine = () => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n return {\r\n add: (className: string) => className,\r\n get: (_bucket: string): string[] => [],\r\n }\r\n}\r\n\r\nexport const resetBucketEngine = (): void => {}\r\n\r\nexport class BucketEngine {\r\n add(className: string) { return className }\r\n}\r\n\r\nexport const classifyNode = (_node: unknown): string => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n return \"unknown\"\r\n}\r\n\r\nexport const detectConflicts = (_classes: string[]): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClassUsage) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClassUsage' is required but not available.\")\r\n }\r\n return []\r\n}\r\n\r\nexport const bucketSort = (classes: string[]): string[] => {\r\n const native = getNativeBridge()\r\n if (!native?.classifyAndSortClasses) {\r\n throw new Error(\"FATAL: Native binding 'classifyAndSortClasses' is required but not available.\")\r\n }\r\n const sorted = native.classifyAndSortClasses(classes)\r\n return sorted.map((c) => (c as { raw?: string }).raw ?? (c as unknown as string))\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// RSC & FILE ANALYSIS CONTINUED\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const analyzeFile = (source: string, filename: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeRsc) {\r\n throw new Error(\"FATAL: Native binding 'analyzeRsc' is required but not available.\")\r\n }\r\n const rsc = native.analyzeRsc(source, filename)\r\n return {\r\n isServer: rsc?.isServer ?? true,\r\n needsClientDirective: rsc?.needsClientDirective ?? false,\r\n clientReasons: rsc?.clientReasons ?? [],\r\n interactiveClasses: [],\r\n canStaticResolveVariants: true,\r\n }\r\n}\r\n\r\nexport const analyzeVariantUsage = (_source: string, _componentName: string, _variantKeys: string[]) => {\r\n return { resolved: {} as Record<string, string>, dynamic: [] as string[] }\r\n}\r\n\r\nexport const injectClientDirective = (source: string): string => {\r\n if (!source.includes('\"use client\"') && !source.includes(\"'use client'\")) {\r\n return '\"use client\";\\n' + source\r\n }\r\n return source\r\n}\r\n\r\nexport const injectServerOnlyComment = (source: string): string => {\r\n return `/* @server-only */\\n${source}`\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// FULL ANALYSIS\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport const analyzeClasses = (filesJson: string, cwd: string, flags: number) => {\r\n const native = getNativeBridge()\r\n if (!native?.analyzeClasses) {\r\n throw new Error(\"FATAL: Native binding 'analyzeClasses' is required but not available.\")\r\n }\r\n return native.analyzeClasses(filesJson, cwd, flags)\r\n}\r\n\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n// STATE CSS PRE-GENERATION\r\n// ═══════════════════════════════════════════════════════════════════════════\r\n\r\nexport interface TwStateConfigEntry {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n sourceFile: string\r\n}\r\n\r\nexport interface StaticStateCssInput {\r\n tag: string\r\n componentName: string\r\n statesJson: string\r\n}\r\n\r\nexport interface GeneratedStateRule {\r\n selector: string\r\n declarations: string\r\n cssRule: string\r\n componentName: string\r\n stateName: string\r\n}\r\n\r\nexport const extractTwStateConfigs = (source: string, filename: string): TwStateConfigEntry[] => {\r\n const native = getNativeBridge()\r\n if (!native?.extractTwStateConfigs) {\r\n throw new Error(\"FATAL: Native binding 'extractTwStateConfigs' is required but not available.\")\r\n }\r\n return native.extractTwStateConfigs(source, filename)\r\n}\r\n\r\nexport const generateStaticStateCss = (\r\n entries: TwStateConfigEntry[],\r\n _themeConfig?: Record<string, unknown>\r\n): GeneratedStateRule[] => {\r\n const rules: GeneratedStateRule[] = []\r\n for (const entry of entries) {\r\n const stateConfig = JSON.parse(entry.statesJson) as Record<string, string>\r\n for (const [stateName, classes] of Object.entries(stateConfig)) {\r\n rules.push({\r\n selector: `.${entry.componentName}[data-state=\"${stateName}\"]`,\r\n declarations: classes,\r\n cssRule: `.${entry.componentName}[data-state=\"${stateName}\"]{${classes}}`,\r\n componentName: entry.componentName,\r\n stateName,\r\n })\r\n }\r\n }\r\n return rules\r\n}\r\n\r\nexport const extractAndGenerateStateCss = (source: string, filename: string): GeneratedStateRule[] => {\r\n const entries = extractTwStateConfigs(source, filename)\r\n return generateStaticStateCss(entries)\r\n}\r\n","/**\r\n * tailwind-styled-v5 — Internal API\r\n * \r\n * Re-exports functions needed by other package consumers.\r\n * All functions require native Rust bindings.\r\n */\r\n\r\nimport {\r\n type NativeBridge,\r\n type NativeTransformResult,\r\n type ComponentMetadata,\r\n type NativeRscResult,\r\n type LoaderOutput,\r\n getNativeBridge,\r\n adaptNativeResult,\r\n transformSource,\r\n hasTwUsage,\r\n isAlreadyTransformed,\r\n shouldProcess,\r\n compileCssFromClasses,\r\n buildStyleTag,\r\n extractAllClasses,\r\n extractClassesFromSource,\r\n astExtractClasses,\r\n parseClasses,\r\n normalizeClasses,\r\n mergeClassesStatic,\r\n normalizeAndDedupClasses,\r\n eliminateDeadCss,\r\n findDeadVariants,\r\n runElimination,\r\n scanProjectUsage,\r\n extractComponentUsage,\r\n diffClassLists,\r\n batchExtractClasses,\r\n checkAgainstSafelist,\r\n generateSafelist,\r\n loadSafelist,\r\n loadTailwindConfig,\r\n getContentPaths,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n fileToRoute,\r\n getAllRoutes,\r\n getRouteClasses,\r\n registerFileClasses,\r\n registerGlobalClasses,\r\n getIncrementalEngine,\r\n resetIncrementalEngine,\r\n getBucketEngine,\r\n resetBucketEngine,\r\n classifyNode,\r\n detectConflicts,\r\n bucketSort,\r\n generateCssForClasses,\r\n analyzeFile,\r\n analyzeVariantUsage,\r\n injectClientDirective,\r\n injectServerOnlyComment,\r\n analyzeClasses,\r\n // Static state CSS pre-generation\r\n extractTwStateConfigs,\r\n generateStaticStateCss,\r\n extractAndGenerateStateCss,\r\n extractContainerCssFromSource,\r\n} from \"./index\"\r\n\r\nexport {\r\n getNativeBridge,\r\n adaptNativeResult,\r\n transformSource,\r\n hasTwUsage,\r\n isAlreadyTransformed,\r\n shouldProcess,\r\n compileCssFromClasses,\r\n buildStyleTag,\r\n extractAllClasses,\r\n extractClassesFromSource,\r\n astExtractClasses,\r\n parseClasses,\r\n normalizeClasses,\r\n mergeClassesStatic,\r\n normalizeAndDedupClasses,\r\n eliminateDeadCss,\r\n findDeadVariants,\r\n runElimination,\r\n scanProjectUsage,\r\n extractComponentUsage,\r\n diffClassLists,\r\n batchExtractClasses,\r\n checkAgainstSafelist,\r\n generateSafelist,\r\n loadSafelist,\r\n loadTailwindConfig,\r\n getContentPaths,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n fileToRoute,\r\n getAllRoutes,\r\n getRouteClasses,\r\n registerFileClasses,\r\n registerGlobalClasses,\r\n getIncrementalEngine,\r\n resetIncrementalEngine,\r\n getBucketEngine,\r\n resetBucketEngine,\r\n classifyNode,\r\n detectConflicts,\r\n bucketSort,\r\n generateCssForClasses,\r\n analyzeFile,\r\n analyzeVariantUsage,\r\n injectClientDirective,\r\n injectServerOnlyComment,\r\n analyzeClasses,\r\n // Static state + container CSS pre-generation\r\n extractTwStateConfigs,\r\n generateStaticStateCss,\r\n extractAndGenerateStateCss,\r\n extractContainerCssFromSource,\r\n}\r\n\r\nexport { type NativeBridge, type NativeTransformResult, type ComponentMetadata, type NativeRscResult, type LoaderOutput }\r\n\r\nexport type CssCompileResult = NativeTransformResult\r\n\r\n// CSS pipeline — Tailwind → LightningCSS\r\n// PHASE 0: Includes LRU caching for 30-40% performance improvement\r\nexport { runCssPipeline, runCssPipelineSync, getCacheStats, clearCache, type CssPipelineResult } from \"./compiler/tailwindEngine\"\r\n\r\n// Re-export all sub-entries directly for convenience\r\nexport * from \"./compiler\"\r\nexport * from \"./parser\"\r\nexport * from \"./analyzer\"\r\nexport * from \"./cache\"\r\nexport * from \"./redis\"\r\nexport * from \"./watch\"\r\n\r\n","import {\r\n type LoaderOutput,\r\n runLoaderTransform,\r\n shouldSkipFile,\r\n registerFileClasses,\r\n} from \"@tailwind-styled/compiler/internal\"\r\nimport path from \"node:path\"\r\nimport { z } from \"zod\"\r\nimport { setFileStaticCss } from \"./staticCssWebpackPlugin\"\r\n\r\ninterface WebpackLoaderOptions {\r\n mode?: \"zero-runtime\"\r\n autoClientBoundary?: boolean\r\n addDataAttr?: boolean\r\n hoist?: boolean\r\n routeCss?: boolean\r\n incremental?: boolean\r\n verbose?: boolean\r\n preserveImports?: boolean\r\n /** Path ke safelist CSS file — untuk menentukan lokasi _tw-state-static.css */\r\n safelistPath?: string\r\n}\r\n\r\ninterface WebpackContext {\r\n resourcePath: string\r\n getOptions(): WebpackLoaderOptions\r\n async?(): ((err: Error | null, result?: string) => void) | undefined\r\n cacheable?(flag?: boolean): void\r\n}\r\n\r\nconst WebpackLoaderOptionsSchema = z.object({\r\n mode: z.literal(\"zero-runtime\").optional(),\r\n autoClientBoundary: z.boolean().optional(),\r\n addDataAttr: z.boolean().optional(),\r\n hoist: z.boolean().optional(),\r\n routeCss: z.boolean().optional(),\r\n incremental: z.boolean().optional(),\r\n verbose: z.boolean().optional(),\r\n preserveImports: z.boolean().optional(),\r\n safelistPath: z.string().optional(),\r\n})\r\n\r\nconst isNextBuildArtifact = (filepath: string): boolean =>\r\n filepath.includes(`${path.sep}.next${path.sep}`)\r\n\r\nexport default function webpackLoader(this: WebpackContext, source: string): void {\r\n const callback = this.async?.()\r\n if (!callback) {\r\n throw new Error(\"[tailwind-styled] Async loader callback is not available.\")\r\n }\r\n\r\n this.cacheable?.(true)\r\n const filepath = this.resourcePath\r\n\r\n if (shouldSkipFile(filepath) || isNextBuildArtifact(filepath)) {\r\n callback(null, source)\r\n return\r\n }\r\n\r\n try {\r\n const options = WebpackLoaderOptionsSchema.parse(this.getOptions())\r\n\r\n const output: LoaderOutput = runLoaderTransform({\r\n filepath,\r\n source,\r\n options: {\r\n mode: options.mode,\r\n autoClientBoundary: options.autoClientBoundary ?? true,\r\n addDataAttr: options.addDataAttr,\r\n hoist: options.hoist,\r\n filename: filepath,\r\n routeCss: options.routeCss,\r\n incremental: options.incremental,\r\n verbose: options.verbose,\r\n preserveImports: options.preserveImports ?? true,\r\n },\r\n })\r\n\r\n if (typeof output.code !== \"string\") {\r\n throw new TypeError(`[tailwind-styled] Invalid transform output for ${filepath}: code is not a string`)\r\n }\r\n\r\n // ── Update static CSS Map (state + container) ──────────────────────────\r\n // StaticCssWebpackPlugin akan rebuild _tw-state-static.css di done hook.\r\n // Pass undefined untuk hapus entry kalau file tidak punya static CSS lagi.\r\n setFileStaticCss(filepath, output.staticCss)\r\n\r\n // Tidak ada perubahan — Rust kembalikan source asli, bukan string kosong.\r\n // Return source asli via callback agar webpack pipeline tidak memperlakukan\r\n // file sebagai \"modified\" dan RSC boundary Next.js tetap utuh.\r\n if (!output.changed) {\r\n callback(null, source)\r\n return\r\n }\r\n\r\n if (options.verbose && output.changed) {\r\n const rsc = output.rsc\r\n const engine = output.engine ?? \"js\"\r\n const env = rsc?.isServer ? \"server\" : \"client\"\r\n const name = path.basename(filepath)\r\n process.stdout.write(\r\n `[tailwind-styled/webpack] ${name} -> ${output.classes.length} classes (${env}) [${engine}]\\n`\r\n )\r\n }\r\n\r\n // Register classes ke route map untuk TwCssInjector\r\n if (output.classes.length > 0) {\r\n registerFileClasses(filepath, output.classes)\r\n }\r\n\r\n callback(null, output.code)\r\n } catch (err) {\r\n if (process.env.NODE_ENV === \"production\") {\r\n callback(err instanceof Error ? err : new Error(String(err)))\r\n return\r\n }\r\n\r\n console.warn(`[tailwind-styled-v4] Webpack transform failed for ${filepath}:`, err)\r\n callback(null, source)\r\n }\r\n}","/**\r\n * StaticCssWebpackPlugin\r\n *\r\n * Webpack plugin companion untuk tailwind-styled-v4 build-time migration.\r\n *\r\n * Masalah yang diselesaikan:\r\n * - `webpackLoader.ts` di-invoke per-file saat transform. Kalau pakai append-to-file\r\n * langsung, ada dua bug: (1) rules lama tidak dibersihkan saat file di-edit/hapus\r\n * statenya, (2) duplicate rules kalau file di-transform ulang.\r\n *\r\n * Solusi: plugin ini maintain `_fileStaticCssMap: Map<filepath, css>` yang hidup\r\n * selama proses webpack. Setiap kali loader transform file, ia update Map.\r\n * Di `compiler.hooks.done`, plugin rebuild `_tw-state-static.css` dari scratch\r\n * menggunakan seluruh isi Map → selalu fresh, tidak ada stale rules.\r\n *\r\n * HMR flow:\r\n * File berubah → webpack incremental compilation → loader transform file baru\r\n * → `setFileStaticCss(filepath, newCss)` update Map → `done` hook flush Map\r\n * → `_tw-state-static.css` berisi state terbaru dari semua file.\r\n *\r\n * File dihapus / state dihapus:\r\n * Webpack invalidate → loader transform ulang → `setFileStaticCss(filepath, undefined)`\r\n * hapus entry dari Map → `done` hook flush → file tidak ada stale rules.\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Shared singleton Map — persists selama Node.js process hidup (webpack watch)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\nconst _fileStaticCssMap = new Map<string, string>()\r\n\r\n/**\r\n * Dipanggil oleh `webpackLoader.ts` setiap kali file di-transform.\r\n * Pass `undefined` / empty string untuk hapus entry (file tidak punya state CSS).\r\n */\r\nexport function setFileStaticCss(filepath: string, css: string | undefined): void {\r\n if (css && css.trim()) {\r\n _fileStaticCssMap.set(filepath, css.trim())\r\n } else {\r\n _fileStaticCssMap.delete(filepath)\r\n }\r\n}\r\n\r\n/** Deduplicate + concat semua CSS dari Map */\r\nfunction buildContent(map: Map<string, string>): string {\r\n const seen = new Set<string>()\r\n const rules: string[] = []\r\n for (const css of map.values()) {\r\n for (const chunk of css.split(/(?<=\\})\\s*/)) {\r\n const rule = chunk.trim()\r\n if (rule && !seen.has(rule)) {\r\n seen.add(rule)\r\n rules.push(rule)\r\n }\r\n }\r\n }\r\n return rules.join(\"\\n\")\r\n}\r\n\r\nconst HEADER =\r\n `/* _tw-state-static.css — Auto-generated by tailwind-styled-v4. DO NOT EDIT.\\n` +\r\n ` * Import di globals.css: @import \"./_tw-state-static.css\";\\n` +\r\n ` * Berisi: state CSS (.tw-s-*[data-*=\"true\"]) + container queries (@container .tw-cq-*).\\n` +\r\n ` * Di-rebuild penuh setiap webpack compilation selesai — tidak ada stale rules.\\n` +\r\n ` */\\n\\n`\r\n\r\ninterface WebpackCompiler {\r\n hooks: {\r\n done: {\r\n tap(pluginName: string, callback: () => void): void\r\n }\r\n }\r\n}\r\n\r\nexport class StaticCssWebpackPlugin {\r\n static readonly PLUGIN_NAME = \"TailwindStyledStaticCss\"\r\n\r\n private readonly outPath: string\r\n\r\n constructor(safelistPath: string) {\r\n this.outPath = path.join(path.dirname(safelistPath), \"_tw-state-static.css\")\r\n }\r\n\r\n apply(compiler: WebpackCompiler): void {\r\n compiler.hooks.done.tap(StaticCssWebpackPlugin.PLUGIN_NAME, () => {\r\n try {\r\n const content = buildContent(_fileStaticCssMap)\r\n fs.mkdirSync(path.dirname(this.outPath), { recursive: true })\r\n fs.writeFileSync(\r\n this.outPath,\r\n HEADER + (content || \"/* no static rules yet */\") + \"\\n\",\r\n \"utf-8\"\r\n )\r\n } catch (e) {\r\n console.warn(\"[tailwind-styled] Could not write _tw-state-static.css:\", e)\r\n }\r\n })\r\n }\r\n}"]}
|