tailwind-styled-v4 5.0.7 → 5.0.9

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +184 -410
  2. package/README.md +45 -15
  3. package/dist/cli.js +62 -52
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cli.mjs +62 -52
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/compiler.d.mts +8 -3
  8. package/dist/compiler.d.ts +8 -3
  9. package/dist/compiler.js +214 -127
  10. package/dist/compiler.js.map +1 -1
  11. package/dist/compiler.mjs +195 -103
  12. package/dist/compiler.mjs.map +1 -1
  13. package/dist/engine.js +146 -66
  14. package/dist/engine.js.map +1 -1
  15. package/dist/engine.mjs +146 -66
  16. package/dist/engine.mjs.map +1 -1
  17. package/dist/index.d.mts +26 -8
  18. package/dist/index.d.ts +26 -8
  19. package/dist/index.js +72 -19
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +72 -19
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/next.d.mts +12 -40
  24. package/dist/next.d.ts +12 -40
  25. package/dist/next.js +27 -320
  26. package/dist/next.js.map +1 -1
  27. package/dist/next.mjs +27 -320
  28. package/dist/next.mjs.map +1 -1
  29. package/dist/turbopackLoader.js +137 -88
  30. package/dist/turbopackLoader.js.map +1 -1
  31. package/dist/turbopackLoader.mjs +137 -88
  32. package/dist/turbopackLoader.mjs.map +1 -1
  33. package/dist/tw.js +62 -52
  34. package/dist/tw.js.map +1 -1
  35. package/dist/tw.mjs +62 -52
  36. package/dist/tw.mjs.map +1 -1
  37. package/dist/vite.js +146 -66
  38. package/dist/vite.js.map +1 -1
  39. package/dist/vite.mjs +146 -66
  40. package/dist/vite.mjs.map +1 -1
  41. package/dist/webpackLoader.js +92 -83
  42. package/dist/webpackLoader.js.map +1 -1
  43. package/dist/webpackLoader.mjs +92 -83
  44. package/dist/webpackLoader.mjs.map +1 -1
  45. package/native/tailwind-styled-native.node +0 -0
  46. package/package.json +3 -3
package/dist/next.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../packages/presentation/next/src/schemas.ts","../packages/domain/shared/src/workerResolver.ts","../packages/domain/shared/src/native-resolution.ts","../packages/domain/shared/src/index.ts","../packages/domain/compiler/src/nativeBridge.ts","../packages/domain/compiler/src/index.ts","../packages/presentation/next/src/withTailwindStyled.ts"],"names":["path","isBrowser","fs","nodeModuleRef","getNodeModuleRef","getRequire","require","getDirnameFromUrl","lastSlash","createRequire","resolveRuntimeDir","resolveLoaderPath"],"mappings":";;;;;;;;;;;;AAEA,IAAM,eAAe,CAAC,KAAA,KACpB,MAAM,MAAA,CACH,GAAA,CAAI,CAAC,KAAA,KAAU;AACd,EAAA,MAAM,CAAA,GAAI,MAAM,IAAA,CAAK,MAAA,GAAS,IAAI,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,GAAI,QAAA;AACzD,EAAA,OAAO,CAAA,EAAG,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,OAAO,CAAA,CAAA;AAC/B,CAAC,CAAA,CACA,KAAK,IAAI,CAAA;AAEd,IAAM,eAAA,GAAkB,CAAI,MAAA,EAAsB,IAAA,EAAe,KAAA,KAAqB;AACpF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,IAAI,CAAA;AACpC,EAAA,IAAI,MAAA,CAAO,OAAA,EAAS,OAAO,MAAA,CAAO,IAAA;AAClC,EAAA,MAAM,IAAI,UAAU,CAAA,EAAG,KAAK,KAAK,YAAA,CAAa,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAC/D,CAAA;AAEO,IAAM,wBAAA,GAA2B,EAAE,MAAA,CAAO;AAAA,EAC/C,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,cAAc,EAAE,QAAA,EAAS;AAAA,EACzC,kBAAA,EAAoB,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;A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,CAAK,IAAI,mBAAA,EAAqB,CAAA;AACtC,YAAA,IAAI,eAAe,GAAA,EAAK;AACtB,cAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,mBAAA,CAAoB,cAAA,CAAe,GAAG,CAAC,CAAA;AAAA,YAC1D;AACC,YAAC,YAAoB,OAAA,GAAU,OAAA;AAC/B,YAAC,YAAoB,iBAAA,GAAoB,IAAA;AAAA,UAC5C;AACA,UAAA,OAAO,WAAA;AAAA,QACT,CAAA;AAEA,QAAA,IAAI,OAAO,oBAAoB,UAAA,EAAY;AACzC,UAAA,OAAO,MAAM,MAAM,CAAA;AAAA,QACrB;AAEA,QAAA,IAAI;AACF,UAAA,MAAM,MAAA,GAAS,eAAA,CAAgB,MAAA,EAAQ,cAAc,CAAA;AACrD,UAAA,OAAO,kBAAkB,OAAA,GAAU,MAAA,CAAO,KAAK,KAAK,CAAA,GAAI,MAAM,MAAM,CAAA;AAAA,QACtE,SAAS,KAAA,EAAO;AACd,UAAA,MAAM,IAAI,MAAM,wEAAA,EAA0E;AAAA,YACxF,KAAA,EAAO;AAAA,WACR,CAAA;AAAA,QACH;AAAA,MACF,CAAA;AAAA,MACA,SAAA,EAAW;AAAA,QACT,GAAI,UAAA,CAAW,SAAA,IAAa,EAAC;AAAA,QAC7B,KAAA,EAAO,mBAAA;AAAA,UACJ,UAAA,CAAW,SAAA,EAAW,KAAA,IAAqC,EAAC;AAAA,UAC7D,oBAAoB,mBAAA,EAAqB,EAAE,GAAG,aAAA,EAAe,cAAc;AAAA;AAC7E;AACF,KACF;AAAA,EACF,CAAA;AACF","file":"next.mjs","sourcesContent":["import { z } from \"zod\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = issue.path.length > 0 ? issue.path.join(\".\") : \"<root>\"\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n throw new TypeError(`${label}: ${formatIssues(parsed.error)}`)\r\n}\r\n\r\nexport const NextAdapterOptionsSchema = 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 include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n})\r\n\r\nexport type NextAdapterOptionsInput = z.infer<typeof NextAdapterOptionsSchema>\r\n\r\nexport const parseNextAdapterOptions = (options: unknown) =>\r\n parseWithSchema(NextAdapterOptionsSchema, options ?? {}, \"next adapter options are invalid\")\r\n","/**\r\n * Worker/bootstrap path resolution untuk artifact release safety.\r\n * Dari monorepo checklist: \"Perkuat worker/bootstrap path agar artifact release aman\"\r\n *\r\n * Masalah: path ke worker/loader script bisa berbeda antara:\r\n * - Development (src/*.ts)\r\n * - Built dist (dist/*.js / dist/*.cjs)\r\n * - Packed npm artifact (dist/ saja, tanpa src/)\r\n *\r\n * Solusi: resolve path secara hierarchical dengan fallback yang eksplisit.\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\nconst NODE_URL = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:url\" : null\r\nconst NODE_FS = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:fs\" : null\r\nconst NODE_PATH = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:path\" : null\r\n\r\nfunction getDirnameFromUrl(importMetaUrl: string): string {\r\n if (!importMetaUrl) return \"\"\r\n if (isBrowser) return \"\"\r\n\r\n try {\r\n const nodeUrl = require(NODE_URL!)\r\n return nodeUrl.fileURLToPath(importMetaUrl)\r\n } catch {\r\n if (importMetaUrl.startsWith(\"file://\")) {\r\n return importMetaUrl.slice(7)\r\n }\r\n return \"\"\r\n }\r\n}\r\n\r\nfunction resolvePath(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\").replace(/\\/+/g, \"/\")\r\n try {\r\n const nodePath = require(NODE_PATH!)\r\n return nodePath.resolve(...segments)\r\n } catch {\r\n return segments.join(\"/\").replace(/\\/+/g, \"/\")\r\n }\r\n}\r\n\r\nfunction existsSync(path: string): boolean {\r\n if (isBrowser) return false\r\n try {\r\n const nodeFs = require(NODE_FS!)\r\n return nodeFs.existsSync(path)\r\n } catch {\r\n return false\r\n }\r\n}\r\n\r\nexport interface WorkerPathOptions {\r\n /** Nama file worker tanpa extension */\r\n basename: string\r\n /** Import meta URL dari caller module */\r\n importMetaUrl: string\r\n /** Extensions yang dicoba secara urutan (default: [\".cjs\", \".js\", \".mjs\"]) */\r\n extensions?: string[]\r\n /** Sub-directories relatif dari runtimeDir yang dicoba */\r\n subdirs?: string[]\r\n /** Throw jika tidak ditemukan (default: true) */\r\n required?: boolean\r\n}\r\n\r\nexport interface WorkerPathResult {\r\n /** Absolute path ke worker file */\r\n path: string\r\n /** Extension yang ditemukan */\r\n extension: string\r\n /** Apakah ini dari CJS atau ESM artifact */\r\n format: \"cjs\" | \"esm\"\r\n}\r\n\r\n/**\r\n * Resolve worker/loader script path yang aman untuk release artifacts.\r\n *\r\n * Prioritas:\r\n * 1. CJS (.cjs) — untuk Node.js workers yang butuh require()\r\n * 2. JS (.js) — bundled output\r\n * 3. MJS (.mjs) — explicit ESM\r\n *\r\n * @example\r\n * const workerPath = resolveWorkerPath({\r\n * basename: \"scanner-worker\",\r\n * importMetaUrl: import.meta.url,\r\n * })\r\n * // → \"/path/to/dist/scanner-worker.cjs\"\r\n */\r\nexport function resolveWorkerPath(opts: WorkerPathOptions): WorkerPathResult {\r\n if (isBrowser) {\r\n throw new Error(\"Worker resolution not available in browser\")\r\n }\r\n\r\n const {\r\n basename,\r\n importMetaUrl,\r\n extensions = [\".cjs\", \".js\", \".mjs\"],\r\n subdirs = [\".\", \"workers\", \"lib\"],\r\n required = true,\r\n } = opts\r\n\r\n const runtimeDir = getDirnameFromUrl(importMetaUrl)\r\n\r\n // Try each subdir + extension combination\r\n for (const subdir of subdirs) {\r\n for (const ext of extensions) {\r\n const candidate = resolvePath(runtimeDir, subdir, `${basename}${ext}`)\r\n if (existsSync(candidate)) {\r\n return {\r\n path: candidate,\r\n extension: ext,\r\n format: ext === \".cjs\" ? \"cjs\" : \"esm\",\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (required) {\r\n const tried = subdirs.flatMap(d =>\r\n extensions.map(e => resolvePath(runtimeDir, d, `${basename}${e}`))\r\n )\r\n throw new Error(\r\n `[worker-resolver] Could not find worker script \"${basename}\".\\n` +\r\n `Tried:\\n${tried.map(p => ` - ${p}`).join(\"\\n\")}\\n` +\r\n `Ensure the package is built: npm run build`\r\n )\r\n }\r\n\r\n return { path: \"\", extension: \"\", format: \"cjs\" }\r\n}\r\n\r\n/**\r\n * Resolve loader path (untuk webpack/rspack/vite loaders).\r\n * Same as resolveWorkerPath but dengan nama yang lebih eksplisit.\r\n */\r\nexport function resolveLoaderPath(\r\n loaderBasename: string,\r\n importMetaUrl: string\r\n): string {\r\n return resolveWorkerPath({\r\n basename: loaderBasename,\r\n importMetaUrl,\r\n extensions: [\".cjs\", \".js\", \".mjs\"],\r\n subdirs: [\".\", \"loaders\", \"lib\"],\r\n }).path\r\n}","/**\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\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require detection\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodeFs: any = null\r\nlet _nodePath: any = null\r\nlet _nodeModule: any = null\r\nlet _require: any = null\r\n\r\nfunction getNodeFs() {\r\n if (isBrowser) return { existsSync: () => false }\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return { existsSync: () => false }\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs\r\n}\r\nfunction getNodePath() {\r\n if (isBrowser) return { resolve: () => \"\", dirname: \"\" }\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return { resolve: () => \"\", dirname: \"\" }\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeModule() {\r\n if (isBrowser) return { createRequire: () => { throw new Error(\"node:module not available\") } }\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return { createRequire: () => { throw new Error(\"require not available\") } }\r\n if (!_nodeModule) _nodeModule = nodeRequire\r\n return _nodeModule\r\n}\r\nfunction getRequire(_importMetaUrl: string) {\r\n if (isBrowser) return () => { throw new Error(\"node:module not available\") }\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return () => { throw new Error(\"require not available\") }\r\n if (!_require) _require = nodeRequire.createRequire(_importMetaUrl)\r\n return _require\r\n}\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\"],\r\n \"linux-arm64\": [\"@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\"],\r\n \"win32-arm64\": [\"@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 const fs = getNodeFs()\r\n const path = getNodePath()\r\n const _req = getRequire(import.meta.url)\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. Skip jika disabled\r\n if (\r\n process.env.TWS_NO_NATIVE === \"1\" ||\r\n process.env.TWS_NO_RUST === \"1\" ||\r\n process.env.TWS_DISABLE_NATIVE === \"1\"\r\n ) {\r\n return { path: null, source: \"not-found\", platform, tried: [\"disabled by env\"] }\r\n }\r\n\r\n // 3. 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 = _req.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 // 4. Local build candidates\r\n const cwd = process.cwd()\r\n const base = runtimeDir ?? cwd\r\n const localCandidates = [\r\n path.resolve(base, \"tailwind_styled_parser.node\"),\r\n path.resolve(base, \"..\", \"tailwind_styled_parser.node\"),\r\n path.resolve(cwd, \"native\", \"tailwind_styled_parser.node\"),\r\n path.resolve(cwd, \"native\", \"target\", \"release\", \"tailwind_styled_parser.node\"),\r\n // napi-rs conventional output\r\n path.resolve(base, `tailwind_styled_parser.${platform}.node`),\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 ` 4. Disable native: TWS_DISABLE_NATIVE=1 (slower, JS fallback)`,\r\n ]\r\n return lines.join(\"\\n\")\r\n}\r\n","const isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require detection\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodeCrypto: any = null\r\nlet _nodeFs: any = null\r\nlet _nodeModule: any = null\r\nlet _nodePath: any = null\r\nlet _nodeUrl: any = null\r\n\r\nfunction getNodeCrypto() {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeFs() {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeModule() {\r\n if (isBrowser) throw new Error(\"node:module not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeModule) _nodeModule = nodeRequire\r\n return _nodeModule!\r\n}\r\nfunction getNodePath() {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl() {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\")\r\n return _nodeUrl!\r\n}\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 if (isBrowser) {\r\n return { binding: null, loadErrors: [{ path: \"\", message: \"Native bindings not available in browser\" }] }\r\n }\r\n \r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n const path = getNodePath()\r\n const fs = getNodeFs()\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\nfunction getRequire(): NodeRequire {\r\n if (isBrowser) return (() => { throw new Error(\"require not available in browser\") }) as unknown as NodeRequire\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return (() => { throw new Error(\"require not available\") }) as unknown as NodeRequire\r\n return nodeRequire.createRequire(import.meta.url)\r\n}\r\n\r\nconst _require = getRequire()\r\n\r\nfunction requireNativeModule(path: string): unknown {\r\n return _require(path)\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}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n if (isBrowser) return []\r\n \r\n const { runtimeDir, envVarNames = [], includeDefaultCandidates = true, enforceNodeExtensionForEnvPath = false } = options\r\n const candidates: string[] = []\r\n const path = getNodePath()\r\n const fs = getNodeFs()\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n if (enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\")) {\r\n candidates.push(envPath + \".node\")\r\n } else {\r\n candidates.push(envPath)\r\n }\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 const entries = fs.readdirSync(runtimeDir)\r\n for (const entry of entries) {\r\n if (entry.endsWith(\".node\")) {\r\n candidates.push(entry)\r\n }\r\n }\r\n } catch {\r\n // ignore read errors\r\n }\r\n }\r\n\r\n const platform = typeof process !== \"undefined\" ? process.platform : \"\"\r\n const ext = platform === \"win32\" ? \".dll\" : platform === \"darwin\" ? \".dylib\" : \".so\"\r\n const defaultBindingName = `tailwind_styled_parser${ext}`\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", defaultBindingName))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", defaultBindingName))\r\n candidates.push(path.resolve(process.cwd(), \"native\", defaultBindingName))\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 (isBrowser) return \"\"\r\n \r\n if (dir) return getNodePath().resolve(dir)\r\n try {\r\n return getNodeUrl().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 if (isBrowser) {\r\n // Simple hash fallback for browser\r\n let hash = 0\r\n for (let i = 0; i < content.length; i++) {\r\n const char = content.charCodeAt(i)\r\n hash = ((hash << 5) - hash) + char\r\n hash = hash & hash\r\n }\r\n return Math.abs(hash).toString(16).slice(0, length ?? 8)\r\n }\r\n const hash = getNodeCrypto().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\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\nimport { createRequire } from \"node:module\"\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// ── Type Exports ────────────────────────────────────────────────────────────────\r\n\r\nexport interface NativeBridge {\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 // 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) => { code: string; hoisted: string[]; warnings: string[] }\r\n compileVariantTable?: (configJson: string) => { id: string; tableJson: string; keys: string[]; defaultKey: string; combinations: number }\r\n classifyAndSortClasses?: (classes: string[]) => Array<{ className: string; bucket: string; sortOrder: number }>\r\n mergeCssDeclarations?: (cssChunks: string[]) => { declarationsJson: string; declarationString: string; count: number }\r\n analyzeClassUsage?: (classes: string[], scanResultJson: string, css: string) => Array<{ className: string; usageCount: number; filesJson: string; bundleSizeBytes: number; isDeadCode: boolean }>\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}\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 const require = createRequire(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 = require(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 * tailwind-styled-v5 — Compiler Index\r\n * \r\n * All functions are backed by native Rust bindings.\r\n * No JavaScript fallback - native is required.\r\n */\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\nexport type LoaderOutput = {\r\n code: string\r\n changed: boolean\r\n classes: string[]\r\n}\r\n\r\n// =============================================================================\r\n// CORE TRANSFORM 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// CSS COMPILATION\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 compileCssNative = (classes: string[], prefix: string | null = null) => {\r\n return compileCssFromClasses(classes, prefix)\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): Promise<string> => {\r\n const result = await compileCssFromClasses(classes)\r\n return result?.code || \"\"\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\nexport const parseClasses = (raw: string): Array<{ raw: string; type: string }> => {\r\n const native = getNativeBridge()\r\n if (!native?.parseClasses) {\r\n // Fallback to JS implementation\r\n return parseClassesJs(raw)\r\n }\r\n return native.parseClasses(raw) || []\r\n}\r\n\r\nfunction parseClassesJs(raw: string): Array<{ raw: string; type: string }> {\r\n if (!raw || typeof raw !== \"string\") return []\r\n \r\n const classes = raw.split(/\\s+/).filter(Boolean)\r\n return classes.map((cls) => ({\r\n raw: cls,\r\n type: cls.includes(\":\") ? \"variant\" : cls.includes(\"/\") ? \"arbitrary\" : \"utility\",\r\n }))\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\nfunction normalizeAndDedupClassesJs(raw: string): { normalized: string; duplicatesRemoved: number; uniqueCount: number } {\r\n const seen = new Set<string>()\r\n const result: string[] = []\r\n let duplicatesRemoved = 0\r\n\r\n for (const token of raw.split(/\\s+/)) {\r\n if (token.length === 0) continue\r\n if (seen.has(token)) {\r\n duplicatesRemoved++\r\n } else {\r\n seen.add(token)\r\n result.push(token)\r\n }\r\n }\r\n\r\n return {\r\n normalized: result.join(\" \"),\r\n duplicatesRemoved,\r\n uniqueCount: result.length,\r\n }\r\n}\r\n\r\nexport const normalizeAndDedupClasses = (raw: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.normalizeAndDedupClasses) {\r\n // Fallback to JS implementation\r\n return normalizeAndDedupClassesJs(raw)\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// DEAD STYLE ELIMINATOR\r\n// =============================================================================\r\n\r\nexport const eliminateDeadCss = (css: string, deadClasses: Set<string>): string => {\r\n let result = css\r\n for (const dead of deadClasses) {\r\n result = result.replace(new RegExp(`\\\\.${dead.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}[^{]*\\\\{[^}]*\\\\}`, 'g'), '')\r\n }\r\n return result\r\n}\r\n\r\nexport const findDeadVariants = (variantConfig: Record<string, unknown>, usage: Record<string, Set<string>>) => {\r\n const unused: string[] = []\r\n const variants = variantConfig 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 const keyValue = `${key}:${value}`\r\n if (!usage[key]?.has(value)) {\r\n unused.push(keyValue)\r\n }\r\n }\r\n }\r\n return unused\r\n}\r\n\r\nexport const runElimination = (css: string, scanResult: unknown) => {\r\n const scanJson = JSON.stringify(scanResult)\r\n const classes = extractAllClasses(css)\r\n const usage = analyzeClassUsage(classes, scanJson, css) || []\r\n const deadClasses = new Set((usage as Array<{ isDeadCode: boolean; className: string }>).filter(u => u.isDeadCode).map(u => u.className))\r\n return eliminateDeadCss(css, deadClasses)\r\n}\r\n\r\nexport const optimizeCss = (css: string): string => {\r\n const classes = extractAllClasses(css)\r\n const usage = analyzeClassUsage(classes, \"[]\", css) || []\r\n const usedClasses = new Set((usage as Array<{ isDeadCode: boolean; className: string }>).filter(u => !u.isDeadCode).map(u => u.className))\r\n \r\n let result = css\r\n const classRegex = /\\.([a-zA-Z0-9_-]+)/g\r\n result = result.replace(classRegex, (match, className) => {\r\n return usedClasses.has(className) ? match : ''\r\n })\r\n \r\n result = result.replace(/[^{}]*\\{\\s*\\}/g, '')\r\n return result.trim()\r\n}\r\n\r\nexport const scanProjectUsage = (dirs: string[], cwd: string) => {\r\n const path = require('node:path')\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// 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// DIFF & BATCH OPERATIONS\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\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// HOISTING\r\n// =============================================================================\r\n\r\nexport const hoistComponents = (source: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.hoistComponents) {\r\n throw new Error(\"FATAL: Native binding 'hoistComponents' is required but not available.\")\r\n }\r\n return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] }\r\n}\r\n\r\n// =============================================================================\r\n// VARIANT COMPILATION\r\n// =============================================================================\r\n\r\nexport const compileVariantTable = (configJson: string) => {\r\n const native = getNativeBridge()\r\n if (!native?.compileVariantTable) {\r\n throw new Error(\"FATAL: Native binding 'compileVariantTable' is required but not available.\")\r\n }\r\n return native.compileVariantTable(configJson) || { id: \"\", tableJson: \"{}\", keys: [], defaultKey: \"\", combinations: 0 }\r\n}\r\n\r\nexport const compileVariants = (componentId: string, config: Record<string, unknown>) => {\r\n return compileVariantTable(JSON.stringify({ componentId, ...config }))\r\n}\r\n\r\n// =============================================================================\r\n// CSS ANALYSIS\r\n// =============================================================================\r\n\r\nexport const classifyAndSortClasses = (classes: 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 native.classifyAndSortClasses(classes) || []\r\n}\r\n\r\nexport const mergeCssDeclarations = (cssChunks: string[]) => {\r\n const native = getNativeBridge()\r\n if (!native?.mergeCssDeclarations) {\r\n throw new Error(\"FATAL: Native binding 'mergeCssDeclarations' is required but not available.\")\r\n }\r\n return native.mergeCssDeclarations(cssChunks) || { declarationsJson: \"{}\", declarationString: \"\", count: 0 }\r\n}\r\n\r\nexport const analyzeClassUsage = (classes: string[], scanResultJson: string, css: 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 native.analyzeClassUsage(classes, scanResultJson, css) || []\r\n}\r\n\r\n// =============================================================================\r\n// RSC ANALYSIS\r\n// =============================================================================\r\n\r\nexport const analyzeRsc = (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 return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] }\r\n}\r\n\r\nexport const analyzeFile = (source: string, filename: string) => {\r\n const rsc = 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 const rsc = analyzeRsc(source, componentName)\r\n return { \r\n resolved: {} as Record<string, string>, \r\n dynamic: [] as string[] \r\n }\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// SAFELIST\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 \r\n if (outputPath) {\r\n const fs = require('node:fs')\r\n fs.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2))\r\n }\r\n \r\n return allClasses\r\n}\r\n\r\nexport const loadSafelist = (safelistPath: string): string[] => {\r\n const fs = require('node:fs')\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\n// =============================================================================\r\n// CONFIG LOADING\r\n// =============================================================================\r\n\r\nexport const loadTailwindConfig = (cwd: string = process.cwd()) => {\r\n const fs = require('node:fs')\r\n const path = require('node:path')\r\n \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 \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)\r\n return mod.default || mod\r\n }\r\n }\r\n \r\n return {}\r\n}\r\n\r\nexport const getContentPaths = (cwd: string = process.cwd()) => {\r\n const path = require('node:path')\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// LOADER\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 return {\r\n code: result?.code || \"\",\r\n changed: result?.changed || false,\r\n classes: result?.classes || [],\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 \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 CSS COLLECTOR\r\n// =============================================================================\r\n\r\nexport const fileToRoute = (filepath: string): string | null => {\r\n const normalized = filepath.replace(/\\\\/g, '/')\r\n\r\n // Layout / loading / error — shared across all routes\r\n if (\r\n normalized.includes('/layout.') ||\r\n normalized.includes('/loading.') ||\r\n normalized.includes('/error.')\r\n ) {\r\n return '__global'\r\n }\r\n\r\n // App Router — /app/[...]/page.[tj]sx?\r\n const appPageMatch = normalized.match(/\\/app\\/(.+?)\\/page\\.[tj]sx?$/)\r\n if (appPageMatch) return `/${appPageMatch[1]}`\r\n\r\n const appRootPage = normalized.match(/\\/app\\/page\\.[tj]sx?$/)\r\n if (appRootPage) return '/'\r\n\r\n // Pages Router — /pages/[...].tsx (exclude _app, _document, _error, api/)\r\n const pagesMatch = normalized.match(/\\/pages\\/(.+?)\\.[tj]sx?$/)\r\n if (pagesMatch) {\r\n const pagePath = pagesMatch[1]\r\n if (pagePath.startsWith('_') || pagePath.startsWith('api/')) return '__global'\r\n // /pages/index → /, /pages/about → /about, /pages/blog/[slug] → /blog/[slug]\r\n return pagePath === 'index' ? '/' : `/${pagePath}`\r\n }\r\n\r\n return null\r\n}\r\n\r\nexport const getAllRoutes = (): string[] => {\r\n return Array.from(_routeClassMap.keys())\r\n}\r\n\r\n// In-memory route → classes map (populated by webpack/turbopack loader per file)\r\nconst _routeClassMap = new Map<string, Set<string>>()\r\n\r\nexport const getRouteClasses = (route: string): Set<string> => {\r\n return _routeClassMap.get(route) ?? new Set()\r\n}\r\n\r\nexport const getAllRouteClasses = (): Map<string, Set<string>> => {\r\n return new Map(_routeClassMap)\r\n}\r\n\r\nexport const registerFileClasses = (filepath: string, classes: string[]): void => {\r\n if (!classes.length) return\r\n const route = fileToRoute(filepath) ?? '__global'\r\n const existing = _routeClassMap.get(route) ?? new Set<string>()\r\n for (const cls of classes) existing.add(cls)\r\n _routeClassMap.set(route, existing)\r\n}\r\n\r\nexport const registerGlobalClasses = (classes: string[]): void => {\r\n if (!classes.length) return\r\n const existing = _routeClassMap.get('__global') ?? new Set<string>()\r\n for (const cls of classes) existing.add(cls)\r\n _routeClassMap.set('__global', existing)\r\n}\r\n\r\nexport const clearRouteClasses = (): void => {\r\n _routeClassMap.clear()\r\n}\r\n\r\n// =============================================================================\r\n// INCREMENTAL ENGINE\r\n// =============================================================================\r\n\r\nlet incrementalEngineInstance: unknown = null\r\n\r\nexport const getIncrementalEngine = () => {\r\n if (!incrementalEngineInstance) {\r\n incrementalEngineInstance = {\r\n compile: (source: string) => transformSource(source),\r\n }\r\n }\r\n return incrementalEngineInstance\r\n}\r\n\r\nexport const resetIncrementalEngine = () => {\r\n incrementalEngineInstance = null\r\n}\r\n\r\nexport const IncrementalEngine = class {\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\nlet bucketEngineInstance: unknown = null\r\n\r\nexport const getBucketEngine = () => {\r\n if (!bucketEngineInstance) {\r\n bucketEngineInstance = {\r\n add: (className: string) => className,\r\n get: (bucket: string) => [],\r\n }\r\n }\r\n return bucketEngineInstance\r\n}\r\n\r\nexport const resetBucketEngine = () => {\r\n bucketEngineInstance = null\r\n}\r\n\r\nexport const BucketEngine = class {\r\n add(className: string) {\r\n return className\r\n }\r\n}\r\n\r\nexport const classifyNode = (node: unknown): string => {\r\n return 'unknown'\r\n}\r\n\r\nexport const detectConflicts = (classes: string[]): string[] => {\r\n return []\r\n}\r\n\r\nexport const bucketSort = (classes: string[]): string[] => {\r\n return classes\r\n}","import fs from \"node:fs\"\r\nimport { createRequire } from \"node:module\"\r\nimport path from \"node:path\"\r\n\r\nfunction getDirnameFromUrl(importMetaUrl: string): string {\r\n if (typeof importMetaUrl !== 'string') return ''\r\n // Simple URL parsing without Node.js modules\r\n if (importMetaUrl.startsWith('file://')) {\r\n let withoutFile = importMetaUrl.slice(7)\r\n // On Windows, file URLs can be like file:///C:/path\r\n if (withoutFile[0] === '/' && withoutFile[2] === ':') {\r\n withoutFile = withoutFile.slice(1) // Remove leading / from C:/\r\n }\r\n const lastSlash = Math.max(withoutFile.lastIndexOf('/'), withoutFile.lastIndexOf('\\\\'))\r\n return lastSlash > 0 ? withoutFile.slice(0, lastSlash) : '/'\r\n }\r\n // Fallback for other URL types\r\n const lastSlash = Math.max(importMetaUrl.lastIndexOf('/'), importMetaUrl.lastIndexOf('\\\\'))\r\n return lastSlash > 0 ? importMetaUrl.slice(0, lastSlash) : ''\r\n}\r\n\r\nimport { resolveLoaderPath as sharedResolveLoaderPath } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseNextAdapterOptions } from \"./schemas\"\r\nimport { getAllRouteClasses, buildStyleTag, clearRouteClasses } from \"@tailwind-styled/compiler/internal\"\r\n\r\nconst require = createRequire(import.meta.url)\r\n\r\ninterface TailwindStyledLoaderOptions {\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 dev file — di-inject oleh TwSafelistDevPlugin (dev only) */\r\n safelistPath?: string\r\n}\r\n\r\nexport interface TailwindStyledNextOptions\r\n extends Pick<\r\n TailwindStyledLoaderOptions,\r\n \"mode\" | \"autoClientBoundary\" | \"addDataAttr\" | \"hoist\" | \"routeCss\" | \"incremental\" | \"verbose\"\r\n > {\r\n include?: RegExp\r\n exclude?: RegExp\r\n}\r\n\r\ninterface NextWebpackUseEntry {\r\n loader: string\r\n options?: TailwindStyledLoaderOptions\r\n}\r\n\r\ninterface NextWebpackRule {\r\n test?: RegExp\r\n exclude?: RegExp\r\n enforce?: \"pre\" | \"post\"\r\n use?: NextWebpackUseEntry[]\r\n}\r\n\r\ninterface NextWebpackConfig {\r\n module?: {\r\n rules?: NextWebpackRule[]\r\n }\r\n [key: string]: unknown\r\n}\r\n\r\ninterface NextWebpackOptions {\r\n buildId: string\r\n dev: boolean\r\n isServer: boolean\r\n nextRuntime?: \"nodejs\" | \"edge\"\r\n defaultLoaders: { babel: unknown }\r\n webpack: unknown\r\n dir: string\r\n config: Record<string, unknown>\r\n totalPages: number\r\n}\r\n\r\ninterface NextConfigWithTurbopack {\r\n webpack?:\r\n | ((\r\n config: NextWebpackConfig,\r\n options: NextWebpackOptions\r\n ) => NextWebpackConfig | Promise<NextWebpackConfig>)\r\n | null\r\n | undefined\r\n turbopack?: Record<string, unknown>\r\n [key: string]: unknown\r\n}\r\n\r\ninterface TurbopackLoaderRule {\r\n loaders: Array<{ loader: string; options: TailwindStyledLoaderOptions }>\r\n}\r\n\r\nconst resolveRuntimeDir = (): string => getDirnameFromUrl(import.meta.url)\r\n\r\nconst resolveLoaderPath = (basename: string): string => {\r\n try {\r\n return sharedResolveLoaderPath(basename, import.meta.url)\r\n } catch {\r\n const runtimeDir = resolveRuntimeDir()\r\n const candidates = [\r\n path.resolve(runtimeDir, `${basename}.mjs`),\r\n path.resolve(runtimeDir, `${basename}.js`),\r\n path.resolve(runtimeDir, `${basename}.cjs`),\r\n ]\r\n\r\n for (const candidate of candidates) {\r\n if (fs.existsSync(candidate)) {\r\n return candidate\r\n }\r\n }\r\n\r\n throw new Error(\r\n `[tailwind-styled] Loader not found for '${basename}'. Checked: ${candidates.join(\", \")}`\r\n )\r\n }\r\n}\r\n\r\nfunction checkNextVersion(): void {\r\n try {\r\n const pkgPath = require.resolve(\"next/package.json\")\r\n const { version } = require(pkgPath)\r\n const major = Number.parseInt(version.split(\".\")[0], 10)\r\n if (major < 15) {\r\n console.warn(\r\n `[tailwind-styled] Next.js ${version} detected. Recommended: 15+ for full Turbopack support.`\r\n )\r\n }\r\n } catch {\r\n // next not resolvable — skip check\r\n }\r\n}\r\n\r\nconst DEFAULT_INCLUDE = /\\.[jt]sx?$/\r\nconst DEFAULT_EXCLUDE = /node_modules/\r\n\r\nconst createLoaderOptions = (options: TailwindStyledNextOptions): Readonly<TailwindStyledLoaderOptions> => {\r\n const opts: TailwindStyledLoaderOptions = {\r\n mode: options.mode ?? \"zero-runtime\",\r\n autoClientBoundary: options.autoClientBoundary ?? true,\r\n preserveImports: true,\r\n }\r\n if (options.addDataAttr !== undefined) opts.addDataAttr = options.addDataAttr\r\n if (options.hoist !== undefined) opts.hoist = options.hoist\r\n if (options.routeCss !== undefined) opts.routeCss = options.routeCss\r\n if (options.incremental !== undefined) opts.incremental = options.incremental\r\n if (options.verbose !== undefined) opts.verbose = options.verbose\r\n return Object.freeze(opts)\r\n}\r\n\r\nconst buildTurbopackRules = (\r\n loaderPath: string,\r\n loaderOptions: TailwindStyledLoaderOptions\r\n): Record<string, TurbopackLoaderRule> => {\r\n const extensions = [\"js\", \"jsx\", \"ts\", \"tsx\", \"mjs\", \"cjs\"]\r\n return Object.fromEntries(\r\n extensions.map((ext) => [\r\n `*.${ext}`,\r\n { loaders: [{ loader: loaderPath, options: loaderOptions }] },\r\n ])\r\n ) as Record<string, TurbopackLoaderRule>\r\n}\r\n\r\nconst normalizeLoaderPath = (loaderPath: string): string => path.resolve(loaderPath)\r\n\r\nconst applyWebpackRule = (\r\n config: NextWebpackConfig,\r\n options: TailwindStyledNextOptions,\r\n loaderPath: string\r\n): NextWebpackConfig => {\r\n const loaderOptions = createLoaderOptions(options)\r\n const rules = config.module?.rules ?? []\r\n const normalizedLoaderPath = normalizeLoaderPath(loaderPath)\r\n\r\n const alreadyRegistered = rules.some(\r\n (rule) =>\r\n Array.isArray(rule?.use) &&\r\n rule.use.some(\r\n (entry) =>\r\n typeof entry.loader === \"string\" &&\r\n normalizeLoaderPath(entry.loader) === normalizedLoaderPath\r\n )\r\n )\r\n\r\n if (alreadyRegistered) return config\r\n\r\n const tailwindStyledRule: NextWebpackRule = {\r\n test: options.include ?? DEFAULT_INCLUDE,\r\n exclude: options.exclude ?? DEFAULT_EXCLUDE,\r\n enforce: \"pre\",\r\n use: [{ loader: loaderPath, options: loaderOptions }],\r\n }\r\n\r\n config.module = {\r\n ...(config.module ?? {}),\r\n rules: [...rules, tailwindStyledRule],\r\n }\r\n\r\n const externalPackages = [\r\n \"@tailwind-styled/shared\",\r\n \"@tailwind-styled/compiler\", \r\n \"@tailwind-styled/engine\",\r\n \"@tailwind-styled/plugin\",\r\n \"@tailwind-styled/core\",\r\n \"@tailwind-styled/runtime-css\",\r\n \"@tailwind-styled/runtime\",\r\n \"@tailwind-styled/scanner\",\r\n \"@tailwind-styled/analyzer\",\r\n \"@tailwind-styled/theme\",\r\n \"@tailwind-styled/preset\",\r\n ]\r\n\r\n const configAny = config as any\r\n\r\n if (!configAny.externals) {\r\n configAny.externals = []\r\n }\r\n\r\nconst ext = configAny.externals\r\n if (Array.isArray(ext)) {\r\n externalPackages.forEach((pkg) => {\r\n const found = ext.find((e: any) => \r\n (typeof e === \"string\" && e.includes(pkg)) ||\r\n (typeof e === \"object\" && e !== null && Object.keys(e).some((k) => k.includes(pkg)))\r\n )\r\n if (!found) {\r\n ext.push(pkg)\r\n }\r\n })\r\n }\r\n\r\n return config\r\n}\r\n\r\nconst mergeTurbopackRules = (\r\n existingRules: Record<string, unknown>,\r\n nextRules: Record<string, TurbopackLoaderRule>\r\n): Record<string, unknown> => {\r\n const merged = { ...existingRules }\r\n\r\n for (const [pattern, incomingRule] of Object.entries(nextRules)) {\r\n const current = merged[pattern]\r\n if (current == null) {\r\n merged[pattern] = incomingRule\r\n continue\r\n }\r\n\r\n if (typeof current === \"object\" && current !== null && \"loaders\" in current) {\r\n const typedCurrent = current as { loaders?: unknown }\r\n if (Array.isArray(typedCurrent.loaders)) {\r\n merged[pattern] = {\r\n ...(current as Record<string, unknown>),\r\n loaders: [...typedCurrent.loaders, ...incomingRule.loaders],\r\n }\r\n console.warn(\r\n `[tailwind-styled] Turbopack rule '${pattern}' already exists. Appending tailwind-styled loader.`\r\n )\r\n continue\r\n }\r\n }\r\n\r\n merged[pattern] = incomingRule\r\n console.warn(\r\n `[tailwind-styled] Turbopack rule '${pattern}' has incompatible shape. Replacing with tailwind-styled rule.`\r\n )\r\n }\r\n\r\n return merged\r\n}\r\n\r\n/**\r\n * Webpack plugin yang emit CSS manifest per-route setelah build selesai.\r\n * Output ke .next/static/css/tw/ — dibaca oleh TwCssInjector.\r\n */\r\n/**\r\n * Plugin untuk dev mode — tulis safelist.css setiap kali webpack selesai compile.\r\n * Tailwind CSS scanner akan pick up file ini sehingga semua class yang di-extract\r\n * dari tw`...` template literals ter-include di output CSS.\r\n *\r\n * File ditulis ke: <cwd>/.next/tailwind-styled-safelist.css\r\n * Format: satu class per baris, dibungkus selector dummy agar Tailwind scan-nya\r\n */\r\n/**\r\n * Escape CSS class name untuk dipakai sebagai selector.\r\n * CSS.escape hanya tersedia di browser — Node tidak punya.\r\n */\r\nfunction escapeClassName(cls: string): string {\r\n return cls.replace(/([^a-zA-Z0-9_-])/g, \"\\\\$1\")\r\n}\r\n\r\nclass TwSafelistDevPlugin {\r\n private readonly outputPath: string\r\n private lastHash = \"\"\r\n\r\n constructor(cwd: string) {\r\n this.outputPath = path.resolve(cwd, \".next\", \"tw-classes\", \"_webpack-merged.css\")\r\n }\r\n\r\n apply(compiler: any): void {\r\n // Reset classes setiap kali webpack mulai compile baru —\r\n // tanpa ini, file yang dihapus tetap ada classnya di safelist selamanya\r\n const resetClasses = () => {\r\n try { clearRouteClasses() } catch { /* non-fatal */ }\r\n }\r\n compiler.hooks.watchRun.tap(\"TwSafelistDevPlugin\", resetClasses) // HMR cycle\r\n compiler.hooks.beforeRun.tap(\"TwSafelistDevPlugin\", resetClasses) // fresh build\r\n\r\n // afterCompile — jalan di setiap HMR cycle, bukan hanya emit\r\n compiler.hooks.afterCompile.tap(\"TwSafelistDevPlugin\", () => {\r\n try {\r\n const routeMap = getAllRouteClasses()\r\n const allClasses = new Set<string>()\r\n for (const classes of routeMap.values()) {\r\n for (const cls of classes) allClasses.add(cls)\r\n }\r\n\r\n if (allClasses.size === 0) return\r\n\r\n // Hash check — skip write jika tidak ada perubahan\r\n const sorted = [...allClasses].sort()\r\n const hash = sorted.join(\",\")\r\n if (hash === this.lastHash) return\r\n this.lastHash = hash\r\n\r\n // Format: dummy selector agar Tailwind CSS v4 scanner mengenali class-nya\r\n const css = [\r\n \"/* tailwind-styled-v4 safelist — auto-generated, do not edit */\",\r\n \"/* @tw-safelist */\",\r\n \".tw-safelist {\",\r\n sorted.map((cls) => ` /* ${cls} */`).join(\"\\n\"),\r\n \"}\",\r\n // Juga emit sebagai @layer utilities agar v4 langsung generate\r\n \"@layer utilities {\",\r\n sorted.map((cls) => `.${escapeClassName(cls)} {}`).join(\"\\n\"),\r\n \"}\",\r\n ].join(\"\\n\")\r\n\r\n // Pastikan .next/ dir ada\r\n const dir = path.dirname(this.outputPath)\r\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })\r\n\r\n fs.writeFileSync(this.outputPath, css, \"utf-8\")\r\n } catch {\r\n // Non-fatal\r\n }\r\n })\r\n }\r\n}\r\n\r\nclass TwCssManifestPlugin {\r\n apply(compiler: any): void {\r\n compiler.hooks.emit.tapAsync(\"TwCssManifestPlugin\", async (compilation: any, callback: () => void) => {\r\n // Skip di dev mode — TwSafelistDevPlugin sudah handle safelist via afterCompile\r\n if ((compiler as any).options?.mode === \"development\") { callback(); return }\r\n try {\r\n const routeMap = getAllRouteClasses()\r\n if (routeMap.size === 0) {\r\n callback()\r\n return\r\n }\r\n\r\n const manifest: Record<string, string> = {}\r\n\r\n for (const [route, classes] of routeMap.entries()) {\r\n if (classes.size === 0) continue\r\n\r\n // Compile classes → CSS via Rust\r\n let css = \"\"\r\n try {\r\n css = buildStyleTag(Array.from(classes))\r\n .replace(/<style[^>]*>/, \"\")\r\n .replace(/<\\/style>/, \"\")\r\n .trim()\r\n } catch {\r\n // Native binding not available — skip\r\n }\r\n\r\n if (!css) continue\r\n\r\n const filename = route === \"/\" ? \"index.css\"\r\n : route === \"__global\" ? \"_global.css\"\r\n : `${route.replace(/^\\//, \"\").replace(/\\//g, \"_\")}.css`\r\n\r\n const outputPath = `static/css/tw/${filename}`\r\n compilation.assets[outputPath] = {\r\n source: () => css,\r\n size: () => css.length,\r\n }\r\n manifest[route] = filename\r\n }\r\n\r\n // Emit manifest\r\n const manifestJson = JSON.stringify({ routes: manifest }, null, 2)\r\n compilation.assets[\"static/css/tw/css-manifest.json\"] = {\r\n source: () => manifestJson,\r\n size: () => manifestJson.length,\r\n }\r\n } catch {\r\n // Non-fatal — app still works without route CSS\r\n }\r\n callback()\r\n })\r\n }\r\n}\r\n\r\nexport function withTailwindStyled(options: TailwindStyledNextOptions = {}) {\r\n checkNextVersion()\r\n const normalizedOptions = parseNextAdapterOptions(options)\r\n const webpackLoaderPath = resolveLoaderPath(\"webpackLoader\")\r\n const turbopackLoaderPath = resolveLoaderPath(\"turbopackLoader\")\r\n\r\nreturn function wrap(nextConfig: NextConfigWithTurbopack = {}): NextConfigWithTurbopack {\r\n const previousWebpack = nextConfig.webpack\r\n const loaderOptions = createLoaderOptions(normalizedOptions)\r\n\r\n // safelistPath = path to the tw-classes dir (Turbopack per-file approach)\r\n // turbopackLoader uses this as base dir for per-file safelist CSS files\r\n const safelistPath = path.resolve(\r\n typeof process !== \"undefined\" ? process.cwd() : \"\",\r\n \".next\",\r\n \"tailwind-styled-safelist.css\" // used as anchor; loader derives tw-classes/ from dirname\r\n )\r\n\r\n return {\r\n ...nextConfig,\r\n webpack(\r\n config: NextWebpackConfig,\r\n webpackOptions: NextWebpackOptions\r\n ): NextConfigWithTurbopack | Promise<NextConfigWithTurbopack> {\r\n const apply = (resolvedConfig: NextConfigWithTurbopack) => {\r\n const finalConfig = applyWebpackRule(resolvedConfig, normalizedOptions, webpackLoaderPath)\r\n if (!finalConfig.externals) {\r\n finalConfig.externals = []\r\n }\r\n const externals = finalConfig.externals\r\n if (Array.isArray(externals)) {\r\n externals.push({\r\n \"@tailwind-styled/shared\": \"commonjs2 @tailwind-styled/shared\",\r\n \"@tailwind-styled/compiler\": \"commonjs2 @tailwind-styled/compiler\",\r\n \"@tailwind-styled/engine\": \"commonjs2 @tailwind-styled/engine\",\r\n \"@tailwind-styled/plugin\": \"commonjs2 @tailwind-styled/plugin\",\r\n })\r\n }\r\n // Tambah CSS manifest plugin (build) + safelist dev plugin (dev/HMR)\r\n if (!(finalConfig as any)._twCssPluginAdded) {\r\n const plugins = (finalConfig as any).plugins as unknown[] ?? []\r\n plugins.push(new TwCssManifestPlugin())\r\n if (webpackOptions.dev) {\r\n plugins.push(new TwSafelistDevPlugin(webpackOptions.dir))\r\n }\r\n ;(finalConfig as any).plugins = plugins\r\n ;(finalConfig as any)._twCssPluginAdded = true\r\n }\r\n return finalConfig\r\n }\r\n\r\n if (typeof previousWebpack !== \"function\") {\r\n return apply(config)\r\n }\r\n\r\n try {\r\n const result = previousWebpack(config, webpackOptions)\r\n return result instanceof Promise ? result.then(apply) : apply(result)\r\n } catch (error) {\r\n throw new Error(\"[tailwind-styled] Failed while executing existing Next webpack config.\", {\r\n cause: error,\r\n })\r\n }\r\n },\r\n turbopack: {\r\n ...(nextConfig.turbopack ?? {}),\r\n rules: mergeTurbopackRules(\r\n (nextConfig.turbopack?.rules as Record<string, unknown>) ?? {},\r\n buildTurbopackRules(turbopackLoaderPath, { ...loaderOptions, safelistPath })\r\n ),\r\n },\r\n }\r\n }\r\n}"]}
1
+ {"version":3,"sources":["../packages/presentation/next/src/schemas.ts","../packages/domain/shared/src/workerResolver.ts","../packages/domain/shared/src/index.ts","../packages/presentation/next/src/withTailwindStyled.ts"],"names":["path","isBrowser","getDirnameFromUrl","lastSlash","require","resolveLoaderPath"],"mappings":";;;;;;;;;;;;AAEA,IAAM,eAAe,CAAC,KAAA,KACpB,MAAM,MAAA,CACH,GAAA,CAAI,CAAC,KAAA,KAAU;AACd,EAAA,MAAM,CAAA,GAAI,MAAM,IAAA,CAAK,MAAA,GAAS,IAAI,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,GAAI,QAAA;AACzD,EAAA,OAAO,CAAA,EAAG,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,OAAO,CAAA,CAAA;AAC/B,CAAC,CAAA,CACA,KAAK,IAAI,CAAA;AAEd,IAAM,eAAA,GAAkB,CAAI,MAAA,EAAsB,IAAA,EAAe,KAAA,KAAqB;AACpF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,IAAI,CAAA;AACpC,EAAA,IAAI,MAAA,CAAO,OAAA,EAAS,OAAO,MAAA,CAAO,IAAA;AAClC,EAAA,MAAM,IAAI,UAAU,CAAA,EAAG,KAAK,KAAK,YAAA,CAAa,MAAA,CA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M,YAAY,WAAA,CAAY,SAAA;AAC9B,UAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC5B,YAAA,SAAA,CAAU,IAAA,CAAK;AAAA,cACb,yBAAA,EAA2B,mCAAA;AAAA,cAC3B,2BAAA,EAA6B,qCAAA;AAAA,cAC7B,yBAAA,EAA2B,mCAAA;AAAA,cAC3B,yBAAA,EAA2B;AAAA,aAC5B,CAAA;AAAA,UACH;AACA,UAAA,OAAO,WAAA;AAAA,QACT,CAAA;AAEA,QAAA,IAAI,OAAO,oBAAoB,UAAA,EAAY;AACzC,UAAA,OAAO,MAAM,MAAM,CAAA;AAAA,QACrB;AAEA,QAAA,IAAI;AACF,UAAA,MAAM,MAAA,GAAS,eAAA,CAAgB,MAAA,EAAQ,cAAc,CAAA;AACrD,UAAA,OAAO,kBAAkB,OAAA,GAAU,MAAA,CAAO,KAAK,KAAK,CAAA,GAAI,MAAM,MAAM,CAAA;AAAA,QACtE,SAAS,KAAA,EAAO;AACd,UAAA,MAAM,IAAI,MAAM,wEAAA,EAA0E;AAAA,YACxF,KAAA,EAAO;AAAA,WACR,CAAA;AAAA,QACH;AAAA,MACF,CAAA;AAAA,MACA,SAAA,EAAW;AAAA,QACT,GAAI,UAAA,CAAW,SAAA,IAAa,EAAC;AAAA,QAC7B,KAAA,EAAO,mBAAA;AAAA,UACJ,UAAA,CAAW,SAAA,EAAW,KAAA,IAAS,EAAC;AAAA,UACjC,mBAAA,CAAoB,qBAAqB,aAAa;AAAA;AACxD;AACF,KACF;AAAA,EACF,CAAA;AACF","file":"next.mjs","sourcesContent":["import { z } from \"zod\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = issue.path.length > 0 ? issue.path.join(\".\") : \"<root>\"\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n throw new TypeError(`${label}: ${formatIssues(parsed.error)}`)\r\n}\r\n\r\nexport const NextAdapterOptionsSchema = 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 include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n})\r\n\r\nexport type NextAdapterOptionsInput = z.infer<typeof NextAdapterOptionsSchema>\r\n\r\nexport const parseNextAdapterOptions = (options: unknown) =>\r\n parseWithSchema(NextAdapterOptionsSchema, options ?? {}, \"next adapter options are invalid\")\r\n","/**\r\n * Worker/bootstrap path resolution untuk artifact release safety.\r\n * Dari monorepo checklist: \"Perkuat worker/bootstrap path agar artifact release aman\"\r\n *\r\n * Masalah: path ke worker/loader script bisa berbeda antara:\r\n * - Development (src/*.ts)\r\n * - Built dist (dist/*.js / dist/*.cjs)\r\n * - Packed npm artifact (dist/ saja, tanpa src/)\r\n *\r\n * Solusi: resolve path secara hierarchical dengan fallback yang eksplisit.\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\nconst NODE_URL = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:url\" : null\r\nconst NODE_FS = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:fs\" : null\r\nconst NODE_PATH = typeof window === \"undefined\" || typeof document === \"undefined\" ? \"node:path\" : null\r\n\r\nfunction getDirnameFromUrl(importMetaUrl: string): string {\r\n if (!importMetaUrl) return \"\"\r\n if (isBrowser) return \"\"\r\n\r\n try {\r\n const nodeUrl = require(NODE_URL!)\r\n return nodeUrl.fileURLToPath(importMetaUrl)\r\n } catch {\r\n if (importMetaUrl.startsWith(\"file://\")) {\r\n return importMetaUrl.slice(7)\r\n }\r\n return \"\"\r\n }\r\n}\r\n\r\nfunction resolvePath(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\").replace(/\\/+/g, \"/\")\r\n try {\r\n const nodePath = require(NODE_PATH!)\r\n return nodePath.resolve(...segments)\r\n } catch {\r\n return segments.join(\"/\").replace(/\\/+/g, \"/\")\r\n }\r\n}\r\n\r\nfunction existsSync(path: string): boolean {\r\n if (isBrowser) return false\r\n try {\r\n const nodeFs = require(NODE_FS!)\r\n return nodeFs.existsSync(path)\r\n } catch {\r\n return false\r\n }\r\n}\r\n\r\nexport interface WorkerPathOptions {\r\n /** Nama file worker tanpa extension */\r\n basename: string\r\n /** Import meta URL dari caller module */\r\n importMetaUrl: string\r\n /** Extensions yang dicoba secara urutan (default: [\".cjs\", \".js\", \".mjs\"]) */\r\n extensions?: string[]\r\n /** Sub-directories relatif dari runtimeDir yang dicoba */\r\n subdirs?: string[]\r\n /** Throw jika tidak ditemukan (default: true) */\r\n required?: boolean\r\n}\r\n\r\nexport interface WorkerPathResult {\r\n /** Absolute path ke worker file */\r\n path: string\r\n /** Extension yang ditemukan */\r\n extension: string\r\n /** Apakah ini dari CJS atau ESM artifact */\r\n format: \"cjs\" | \"esm\"\r\n}\r\n\r\n/**\r\n * Resolve worker/loader script path yang aman untuk release artifacts.\r\n *\r\n * Prioritas:\r\n * 1. CJS (.cjs) — untuk Node.js workers yang butuh require()\r\n * 2. JS (.js) — bundled output\r\n * 3. MJS (.mjs) — explicit ESM\r\n *\r\n * @example\r\n * const workerPath = resolveWorkerPath({\r\n * basename: \"scanner-worker\",\r\n * importMetaUrl: import.meta.url,\r\n * })\r\n * // → \"/path/to/dist/scanner-worker.cjs\"\r\n */\r\nexport function resolveWorkerPath(opts: WorkerPathOptions): WorkerPathResult {\r\n if (isBrowser) {\r\n throw new Error(\"Worker resolution not available in browser\")\r\n }\r\n\r\n const {\r\n basename,\r\n importMetaUrl,\r\n extensions = [\".cjs\", \".js\", \".mjs\"],\r\n subdirs = [\".\", \"workers\", \"lib\"],\r\n required = true,\r\n } = opts\r\n\r\n const runtimeDir = getDirnameFromUrl(importMetaUrl)\r\n\r\n // Try each subdir + extension combination\r\n for (const subdir of subdirs) {\r\n for (const ext of extensions) {\r\n const candidate = resolvePath(runtimeDir, subdir, `${basename}${ext}`)\r\n if (existsSync(candidate)) {\r\n return {\r\n path: candidate,\r\n extension: ext,\r\n format: ext === \".cjs\" ? \"cjs\" : \"esm\",\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (required) {\r\n const tried = subdirs.flatMap(d =>\r\n extensions.map(e => resolvePath(runtimeDir, d, `${basename}${e}`))\r\n )\r\n throw new Error(\r\n `[worker-resolver] Could not find worker script \"${basename}\".\\n` +\r\n `Tried:\\n${tried.map(p => ` - ${p}`).join(\"\\n\")}\\n` +\r\n `Ensure the package is built: npm run build`\r\n )\r\n }\r\n\r\n return { path: \"\", extension: \"\", format: \"cjs\" }\r\n}\r\n\r\n/**\r\n * Resolve loader path (untuk webpack/rspack/vite loaders).\r\n * Same as resolveWorkerPath but dengan nama yang lebih eksplisit.\r\n */\r\nexport function resolveLoaderPath(\r\n loaderBasename: string,\r\n importMetaUrl: string\r\n): string {\r\n return resolveWorkerPath({\r\n basename: loaderBasename,\r\n importMetaUrl,\r\n extensions: [\".cjs\", \".js\", \".mjs\"],\r\n subdirs: [\".\", \"loaders\", \"lib\"],\r\n }).path\r\n}","const isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require detection\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodeCrypto: any = null\r\nlet _nodeFs: any = null\r\nlet _nodeModule: any = null\r\nlet _nodePath: any = null\r\nlet _nodeUrl: any = null\r\n\r\nfunction getNodeCrypto() {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeFs() {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeModule() {\r\n if (isBrowser) throw new Error(\"node:module not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeModule) _nodeModule = nodeRequire\r\n return _nodeModule!\r\n}\r\nfunction getNodePath() {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl() {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\")\r\n return _nodeUrl!\r\n}\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 if (isBrowser) {\r\n return { binding: null, loadErrors: [{ path: \"\", message: \"Native bindings not available in browser\" }] }\r\n }\r\n \r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n const path = getNodePath()\r\n const fs = getNodeFs()\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\nfunction getRequire(): NodeRequire {\r\n if (isBrowser) return (() => { throw new Error(\"require not available in browser\") }) as unknown as NodeRequire\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) return (() => { throw new Error(\"require not available\") }) as unknown as NodeRequire\r\n return nodeRequire.createRequire(import.meta.url)\r\n}\r\n\r\nconst _require = getRequire()\r\n\r\nfunction requireNativeModule(path: string): unknown {\r\n return _require(path)\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}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n if (isBrowser) return []\r\n \r\n const { runtimeDir, envVarNames = [], includeDefaultCandidates = true, enforceNodeExtensionForEnvPath = false } = options\r\n const candidates: string[] = []\r\n const path = getNodePath()\r\n const fs = getNodeFs()\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n if (enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\")) {\r\n candidates.push(envPath + \".node\")\r\n } else {\r\n candidates.push(envPath)\r\n }\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 const entries = fs.readdirSync(runtimeDir)\r\n for (const entry of entries) {\r\n if (entry.endsWith(\".node\")) {\r\n candidates.push(entry)\r\n }\r\n }\r\n } catch {\r\n // ignore read errors\r\n }\r\n }\r\n\r\n const platform = typeof process !== \"undefined\" ? process.platform : \"\"\r\n const ext = platform === \"win32\" ? \".dll\" : platform === \"darwin\" ? \".dylib\" : \".so\"\r\n const defaultBindingName = `tailwind_styled_parser${ext}`\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", defaultBindingName))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", defaultBindingName))\r\n candidates.push(path.resolve(process.cwd(), \"native\", defaultBindingName))\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 (isBrowser) return \"\"\r\n \r\n if (dir) return getNodePath().resolve(dir)\r\n try {\r\n return getNodeUrl().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 if (isBrowser) {\r\n // Simple hash fallback for browser\r\n let hash = 0\r\n for (let i = 0; i < content.length; i++) {\r\n const char = content.charCodeAt(i)\r\n hash = ((hash << 5) - hash) + char\r\n hash = hash & hash\r\n }\r\n return Math.abs(hash).toString(16).slice(0, length ?? 8)\r\n }\r\n const hash = getNodeCrypto().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","import fs from \"node:fs\"\r\nimport { createRequire } from \"node:module\"\r\nimport path from \"node:path\"\r\n\r\nfunction getDirnameFromUrl(importMetaUrl: string): string {\r\n if (typeof importMetaUrl !== 'string') return ''\r\n // Simple URL parsing without Node.js modules\r\n if (importMetaUrl.startsWith('file://')) {\r\n let withoutFile = importMetaUrl.slice(7)\r\n // On Windows, file URLs can be like file:///C:/path\r\n if (withoutFile[0] === '/' && withoutFile[2] === ':') {\r\n withoutFile = withoutFile.slice(1) // Remove leading / from C:/\r\n }\r\n const lastSlash = Math.max(withoutFile.lastIndexOf('/'), withoutFile.lastIndexOf('\\\\'))\r\n return lastSlash > 0 ? withoutFile.slice(0, lastSlash) : '/'\r\n }\r\n // Fallback for other URL types\r\n const lastSlash = Math.max(importMetaUrl.lastIndexOf('/'), importMetaUrl.lastIndexOf('\\\\'))\r\n return lastSlash > 0 ? importMetaUrl.slice(0, lastSlash) : ''\r\n}\r\n\r\nimport { resolveLoaderPath as sharedResolveLoaderPath } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseNextAdapterOptions } from \"./schemas\"\r\n\r\nconst require = createRequire(import.meta.url)\r\n\r\ninterface TailwindStyledLoaderOptions {\r\n /** @deprecated — handled by engine internally */\r\n mode?: \"zero-runtime\"\r\n /** @deprecated — handled by engine internally */\r\n autoClientBoundary?: boolean\r\n /** @deprecated — handled by engine internally */\r\n addDataAttr?: boolean\r\n /** @deprecated — handled by engine internally */\r\n hoist?: boolean\r\n /** @deprecated — handled by engine internally */\r\n routeCss?: boolean\r\n /** @deprecated — handled by engine internally */\r\n incremental?: boolean\r\n verbose?: boolean\r\n preserveImports?: boolean\r\n safelistPath?: string\r\n}\r\n\r\nexport interface TailwindStyledNextOptions {\r\n /** @deprecated — handled by engine internally */\r\n mode?: \"zero-runtime\"\r\n /** @deprecated — handled by engine internally */\r\n autoClientBoundary?: boolean\r\n /** @deprecated — handled by engine internally */\r\n addDataAttr?: boolean\r\n /** @deprecated — handled by engine internally */\r\n hoist?: boolean\r\n /** @deprecated — handled by engine internally */\r\n routeCss?: boolean\r\n /** @deprecated — handled by engine internally */\r\n incremental?: boolean\r\n /** Show detailed loader output */\r\n verbose?: boolean\r\n /** Path to generated safelist CSS file. Default: <cwd>/__tw_safelist.css */\r\n safelistPath?: string\r\n include?: RegExp\r\n exclude?: RegExp\r\n}\r\n\r\nimport type { NextConfig } from \"next\"\r\n\r\n// Derive webpack types directly from Next.js — always in sync with installed version\r\ntype NextWebpackFn = NonNullable<NextConfig[\"webpack\"]>\r\ntype NextWebpackConfig = Parameters<NextWebpackFn>[0]\r\ntype NextWebpackOptions = Parameters<NextWebpackFn>[1]\r\n\r\n// Derive turbopack rule types from NextConfig\r\ntype TurboRules = NonNullable<NonNullable<NextConfig[\"turbopack\"]>[\"rules\"]>\r\ntype TurbopackLoaderRule = TurboRules[string]\r\n\r\n// Derive webpack module rule type for safe iteration\r\ntype ModuleRule = NonNullable<NonNullable<NextWebpackConfig[\"module\"]>[\"rules\"]>[number]\r\ntype RuleUseEntry = { loader?: string; options?: unknown }\r\n\r\ninterface NextWebpackUseEntry {\r\n loader: string\r\n options?: TailwindStyledLoaderOptions\r\n}\r\n\r\ninterface NextWebpackRule {\r\n test?: RegExp\r\n exclude?: RegExp\r\n enforce?: \"pre\" | \"post\"\r\n use?: NextWebpackUseEntry[]\r\n}\r\n\r\n\r\nconst resolveRuntimeDir = (): string => getDirnameFromUrl(import.meta.url)\r\n\r\nconst resolveLoaderPath = (basename: string): string => {\r\n try {\r\n return sharedResolveLoaderPath(basename, import.meta.url)\r\n } catch {\r\n const runtimeDir = resolveRuntimeDir()\r\n const candidates = [\r\n path.resolve(runtimeDir, `${basename}.mjs`),\r\n path.resolve(runtimeDir, `${basename}.js`),\r\n path.resolve(runtimeDir, `${basename}.cjs`),\r\n ]\r\n\r\n for (const candidate of candidates) {\r\n if (fs.existsSync(candidate)) {\r\n return candidate\r\n }\r\n }\r\n\r\n throw new Error(\r\n `[tailwind-styled] Loader not found for '${basename}'. Checked: ${candidates.join(\", \")}`\r\n )\r\n }\r\n}\r\n\r\nfunction checkNextVersion(): void {\r\n try {\r\n const pkgPath = require.resolve(\"next/package.json\")\r\n const { version } = require(pkgPath)\r\n const major = Number.parseInt(version.split(\".\")[0], 10)\r\n if (major < 15) {\r\n console.warn(\r\n `[tailwind-styled] Next.js ${version} detected. Recommended: 15+ for full Turbopack support.`\r\n )\r\n }\r\n } catch {\r\n // next not resolvable — skip check\r\n }\r\n}\r\n\r\nconst DEFAULT_INCLUDE = /\\.[jt]sx?$/\r\nconst DEFAULT_EXCLUDE = /node_modules/\r\n\r\n/**\r\n * Next.js App Router entry-point files yang TIDAK boleh diproses oleh TW loader.\r\n *\r\n * Mengapa: file-file ini adalah RSC boundary points yang dikelola Next.js secara khusus.\r\n * Jika loader menginjeksi TRANSFORM_MARKER atau memodifikasi source-nya—bahkan ketika\r\n * `changed: false`—Next.js/React Compiler kehilangan sinyal bahwa file adalah pure RSC,\r\n * sehingga locale injection dari Accept-Language header (Next.js 16+) tidak konsisten\r\n * antara SSR pass (server: lang=\"id\") dan hydration pass (client: lang=\"en\").\r\n *\r\n * File yang dikecualikan: layout, page, loading, error, not-found, template, default\r\n * semuanya adalah Next.js segment conventions yang tidak boleh disentuh loader pihak ketiga.\r\n */\r\nconst NEXT_RSC_ENTRIES =\r\n /(?:^|[\\\\/])(?:layout|page|loading|error|not-found|template|default)\\.[jt]sx?$/\r\n\r\n/**\r\n * Gabungkan user-supplied exclude dengan NEXT_RSC_ENTRIES.\r\n * Menggunakan non-capturing group agar tidak interferensi dengan capture group lain.\r\n */\r\nconst buildExcludePattern = (userExclude?: RegExp): RegExp => {\r\n if (!userExclude) return new RegExp(`(?:${DEFAULT_EXCLUDE.source})|(?:${NEXT_RSC_ENTRIES.source})`)\r\n return new RegExp(`(?:${userExclude.source})|(?:${NEXT_RSC_ENTRIES.source})`)\r\n}\r\n\r\nconst createLoaderOptions = (options: TailwindStyledNextOptions): Readonly<TailwindStyledLoaderOptions> => {\r\n // Deprecated options — still passed for loader backward compat but engine ignores them\r\n const opts: TailwindStyledLoaderOptions = {\r\n mode: \"zero-runtime\", // only supported mode\r\n autoClientBoundary: true, // always on (engine handles it)\r\n preserveImports: true,\r\n }\r\n if (options.verbose !== undefined) opts.verbose = options.verbose\r\n opts.safelistPath = options.safelistPath ?? path.join(process.cwd(), \"__tw_safelist.css\")\r\n return Object.freeze(opts)\r\n}\r\n\r\nconst buildTurbopackRules = (\r\n loaderPath: string,\r\n loaderOptions: TailwindStyledLoaderOptions\r\n): TurboRules => {\r\n const extensions = [\"js\", \"jsx\", \"ts\", \"tsx\", \"mjs\", \"cjs\"]\r\n return Object.fromEntries(\r\n extensions.map((ext) => [\r\n `*.${ext}`,\r\n { loaders: [{ loader: loaderPath, options: loaderOptions }] },\r\n ])\r\n ) as TurboRules\r\n}\r\n\r\nconst normalizeLoaderPath = (loaderPath: string): string => path.resolve(loaderPath)\r\n\r\nconst applyWebpackRule = (\r\n config: NextWebpackConfig,\r\n options: TailwindStyledNextOptions,\r\n loaderPath: string\r\n): NextWebpackConfig => {\r\n const loaderOptions = createLoaderOptions(options)\r\n const rules = config.module?.rules ?? []\r\n const normalizedLoaderPath = normalizeLoaderPath(loaderPath)\r\n\r\n const alreadyRegistered = rules.some(\r\n (rule: ModuleRule) =>\r\n Array.isArray(rule?.use) &&\r\n (rule.use as RuleUseEntry[]).some(\r\n (entry: RuleUseEntry) =>\r\n typeof entry.loader === \"string\" &&\r\n normalizeLoaderPath(entry.loader) === normalizedLoaderPath\r\n )\r\n )\r\n\r\n if (alreadyRegistered) return config\r\n\r\n const tailwindStyledRule: NextWebpackRule = {\r\n test: options.include ?? DEFAULT_INCLUDE,\r\n // Selalu kecualikan Next.js RSC entry files (layout, page, dll) bahkan jika\r\n // user menyuplai exclude pattern sendiri — lihat buildExcludePattern.\r\n exclude: buildExcludePattern(options.exclude),\r\n enforce: \"pre\",\r\n use: [{ loader: loaderPath, options: loaderOptions }],\r\n }\r\n\r\n config.module = {\r\n ...(config.module ?? {}),\r\n rules: [...rules, tailwindStyledRule],\r\n }\r\n\r\n const externalPackages = [\r\n \"@tailwind-styled/shared\",\r\n \"@tailwind-styled/compiler\", \r\n \"@tailwind-styled/engine\",\r\n \"@tailwind-styled/plugin\",\r\n \"@tailwind-styled/core\",\r\n \"@tailwind-styled/runtime-css\",\r\n \"@tailwind-styled/runtime\",\r\n \"@tailwind-styled/scanner\",\r\n \"@tailwind-styled/analyzer\",\r\n \"@tailwind-styled/theme\",\r\n \"@tailwind-styled/preset\",\r\n ]\r\n\r\n type ExternalsArray = Extract<NonNullable<NextWebpackConfig[\"externals\"]>, readonly unknown[]>\r\n type ExternalItem = ExternalsArray[number]\r\n\r\n if (!config.externals) {\r\n config.externals = []\r\n }\r\n\r\n const ext = config.externals\r\n if (Array.isArray(ext)) {\r\n externalPackages.forEach((pkg) => {\r\n const found = (ext as ExternalItem[]).find((e: ExternalItem) =>\r\n (typeof e === \"string\" && e.includes(pkg)) ||\r\n (typeof e === \"object\" && e !== null && !Array.isArray(e) &&\r\n Object.keys(e as object).some((k) => k.includes(pkg)))\r\n )\r\n if (!found) {\r\n (ext as string[]).push(pkg)\r\n }\r\n })\r\n }\r\n\r\n return config\r\n}\r\n\r\nconst mergeTurbopackRules = (\r\n existingRules: TurboRules,\r\n nextRules: TurboRules\r\n): TurboRules => {\r\n const merged: TurboRules = { ...existingRules }\r\n\r\n for (const [pattern, incomingRule] of Object.entries(nextRules)) {\r\n const current = merged[pattern]\r\n if (current == null) {\r\n merged[pattern] = incomingRule\r\n continue\r\n }\r\n\r\n if (typeof current === \"object\" && current !== null && \"loaders\" in current) {\r\n const typedCurrent = current as { loaders?: unknown }\r\n if (Array.isArray(typedCurrent.loaders)) {\r\n const incomingLoaders = (incomingRule as { loaders?: unknown[] }).loaders ?? []\r\n merged[pattern] = {\r\n ...(current as TurbopackLoaderRule),\r\n loaders: [...typedCurrent.loaders, ...incomingLoaders],\r\n } as TurbopackLoaderRule\r\n console.warn(\r\n `[tailwind-styled] Turbopack rule '${pattern}' already exists. Appending tailwind-styled loader.`\r\n )\r\n continue\r\n }\r\n }\r\n\r\n merged[pattern] = incomingRule\r\n console.warn(\r\n `[tailwind-styled] Turbopack rule '${pattern}' has incompatible shape. Replacing with tailwind-styled rule.`\r\n )\r\n }\r\n\r\n return merged\r\n}\r\n\r\nexport function withTailwindStyled(options: TailwindStyledNextOptions = {}) {\r\n checkNextVersion()\r\n const normalizedOptions = parseNextAdapterOptions(options)\r\n const webpackLoaderPath = resolveLoaderPath(\"webpackLoader\")\r\n const turbopackLoaderPath = resolveLoaderPath(\"turbopackLoader\")\r\n\r\nreturn function wrap(nextConfig: NextConfig = {}): NextConfig {\r\n const previousWebpack = nextConfig.webpack\r\n const loaderOptions = createLoaderOptions(normalizedOptions)\r\n\r\n return {\r\n ...nextConfig,\r\n webpack(\r\n config: NextWebpackConfig,\r\n webpackOptions: NextWebpackOptions\r\n ): ReturnType<NextWebpackFn> {\r\n const apply = (resolvedConfig: NextWebpackConfig) => {\r\n const finalConfig = applyWebpackRule(resolvedConfig, normalizedOptions, webpackLoaderPath)\r\n if (!finalConfig.externals) {\r\n finalConfig.externals = []\r\n }\r\n const externals = finalConfig.externals\r\n if (Array.isArray(externals)) {\r\n externals.push({\r\n \"@tailwind-styled/shared\": \"commonjs2 @tailwind-styled/shared\",\r\n \"@tailwind-styled/compiler\": \"commonjs2 @tailwind-styled/compiler\",\r\n \"@tailwind-styled/engine\": \"commonjs2 @tailwind-styled/engine\",\r\n \"@tailwind-styled/plugin\": \"commonjs2 @tailwind-styled/plugin\",\r\n })\r\n }\r\n return finalConfig\r\n }\r\n\r\n if (typeof previousWebpack !== \"function\") {\r\n return apply(config)\r\n }\r\n\r\n try {\r\n const result = previousWebpack(config, webpackOptions)\r\n return result instanceof Promise ? result.then(apply) : apply(result)\r\n } catch (error) {\r\n throw new Error(\"[tailwind-styled] Failed while executing existing Next webpack config.\", {\r\n cause: error,\r\n })\r\n }\r\n },\r\n turbopack: {\r\n ...(nextConfig.turbopack ?? {}),\r\n rules: mergeTurbopackRules(\r\n (nextConfig.turbopack?.rules ?? {}) as TurboRules,\r\n buildTurbopackRules(turbopackLoaderPath, loaderOptions)\r\n ),\r\n },\r\n }\r\n }\r\n}"]}