tailwind-styled-v4 5.0.13 → 5.0.14

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 (58) hide show
  1. package/dist/atomic.js +14 -14
  2. package/dist/atomic.js.map +1 -1
  3. package/dist/atomic.mjs +14 -14
  4. package/dist/atomic.mjs.map +1 -1
  5. package/dist/cli.js +14 -14
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cli.mjs +14 -14
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/compiler.js +14 -14
  10. package/dist/compiler.js.map +1 -1
  11. package/dist/compiler.mjs +14 -14
  12. package/dist/compiler.mjs.map +1 -1
  13. package/dist/engine.js +14 -14
  14. package/dist/engine.js.map +1 -1
  15. package/dist/engine.mjs +14 -14
  16. package/dist/engine.mjs.map +1 -1
  17. package/dist/index.browser.mjs +3 -1
  18. package/dist/index.browser.mjs.map +1 -1
  19. package/dist/index.js +45 -25
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +45 -25
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/next.js +14 -14
  24. package/dist/next.js.map +1 -1
  25. package/dist/next.mjs +14 -14
  26. package/dist/next.mjs.map +1 -1
  27. package/dist/shared.d.mts +3 -2
  28. package/dist/shared.d.ts +3 -2
  29. package/dist/shared.js +14 -14
  30. package/dist/shared.js.map +1 -1
  31. package/dist/shared.mjs +14 -14
  32. package/dist/shared.mjs.map +1 -1
  33. package/dist/svelte.js +42 -24
  34. package/dist/svelte.js.map +1 -1
  35. package/dist/svelte.mjs +42 -24
  36. package/dist/svelte.mjs.map +1 -1
  37. package/dist/turbopackLoader.js +14 -14
  38. package/dist/turbopackLoader.js.map +1 -1
  39. package/dist/turbopackLoader.mjs +14 -14
  40. package/dist/turbopackLoader.mjs.map +1 -1
  41. package/dist/tw.js +14 -14
  42. package/dist/tw.js.map +1 -1
  43. package/dist/tw.mjs +14 -14
  44. package/dist/tw.mjs.map +1 -1
  45. package/dist/vite.js +14 -14
  46. package/dist/vite.js.map +1 -1
  47. package/dist/vite.mjs +14 -14
  48. package/dist/vite.mjs.map +1 -1
  49. package/dist/vue.js +42 -24
  50. package/dist/vue.js.map +1 -1
  51. package/dist/vue.mjs +42 -24
  52. package/dist/vue.mjs.map +1 -1
  53. package/dist/webpackLoader.js +14 -14
  54. package/dist/webpackLoader.js.map +1 -1
  55. package/dist/webpackLoader.mjs +14 -14
  56. package/dist/webpackLoader.mjs.map +1 -1
  57. package/package.json +3 -2
  58. package/native/index.node +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../packages/domain/shared/src/native-resolution.ts","../packages/domain/shared/src/index.ts","../packages/domain/core/src/native.ts","../packages/domain/core/src/merge.ts","../packages/presentation/svelte/src/index.ts"],"names":["createRequire","isBrowser","path","fileURLToPath","twMerge"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI,WAAW,OAAO,SAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAAI,QAAQ,IAAI,CAAA,CAAA;AAC5C;AAaO,SAAS,oBAAoB,UAAA,EAA6C;AAC/E,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,CAAC,0BAA0B,CAAA,EAAE;AAAA,EAC1F;AAIA,EAAA,IAAI,QAAQ,GAAA,CAAI,aAAA,KAAkB,OAAO,OAAA,CAAQ,GAAA,CAAI,uBAAuB,GAAA,EAAK;AAC/E,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,EAAC,EAAE;AAAA,EAChE;AAGA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,GAAA,CAAI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IAAA,MAAM,eAAA,GAAkB,eAAA,CAAgB,gBAAA,EAAkB,MAAM,CAAA;AAEhE,IAAA,OAAO,QAAQ,IAAA,EAAM,cAAA,EAAgB,iBAAiB,WAAA,CAAY,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,EAChF,CAAA;AACF;AAeO,SAAS,MAAM,OAAA,EAA6D;AACjF,EAAA,OAAO,OAAA,CAAQ,GAAI,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAc,CAAA;AACzD;AAmBO,SAAS,OACd,IAAA,EACA,EAAE,QAAQ,KAAA,GAAQ,IAAG,EACrB;AAGA,EAAA,SAAS,MAAA,CAAO;AAAA,IACd,MAAA,EAAQ,GAAA;AAAA,IACR,KAAA,EAAO,IAAI;AAAC,GACd,EAGG;AACD,IAAA,MAAM,OAAA,GAAU,EAAA,CAAG,GAAG,CAAA,CAAE,CAAC,CAAA;AAEzB,IAAA,IAAA,CAAK,SAAA,GAAY,OAAA;AAAA,EACnB;AAGA,EAAA,MAAA,CAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,CAAA;AAExB,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA,GAAU;AAAA,IAEV;AAAA,GACF;AACF;AAmBO,SAAS,cAAA,CAAe,QAA+B,QAAA,EAAuB;AACnF,EAAA,MAAM,QAAA,GAAW,GAAG,MAAM,CAAA;AAE1B,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,MAAM,QAAA,CAAS,QAAA,EAAU,CAAA;AAAA,IACpC;AAAA,GACF;AACF","file":"svelte.mjs","sourcesContent":["/**\r\n * Prebuilt binary resolution untuk native NAPI bindings.\r\n * QA #1: Resolve native binary dari prebuilt packages atau local build.\r\n *\r\n * Prioritas:\r\n * 1. TW_NATIVE_PATH env var (explicit override)\r\n * 2. Prebuilt binary dari platform-specific npm package\r\n * 3. Local build dari source (developer mode)\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport * as fs from \"node:fs\"\r\nimport * as path from \"node:path\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require — works in both ESM and CJS contexts\r\nconst _require = typeof require !== \"undefined\" ? require : createRequire(import.meta.url)\r\n\r\nexport interface NativeResolutionResult {\r\n path: string | null\r\n source: \"env\" | \"prebuilt\" | \"local\" | \"not-found\"\r\n platform: string\r\n tried: string[]\r\n}\r\n\r\n/** Platform key → prebuilt npm package name */\r\nconst PLATFORM_MAP: Record<string, string[]> = {\r\n \"linux-x64\": [\"@tailwind-styled/native-linux-x64-gnu\", \"@tailwind-styled/native-linux-x64\"],\r\n \"linux-arm64\": [\"@tailwind-styled/native-linux-arm64-gnu\", \"@tailwind-styled/native-linux-arm64\"],\r\n \"darwin-x64\": [\"@tailwind-styled/native-darwin-x64\"],\r\n \"darwin-arm64\": [\"@tailwind-styled/native-darwin-arm64\"],\r\n \"win32-x64\": [\"@tailwind-styled/native-win32-x64-msvc\", \"@tailwind-styled/native-win32-x64\"],\r\n \"win32-arm64\": [\"@tailwind-styled/native-win32-arm64-msvc\", \"@tailwind-styled/native-win32-arm64\"],\r\n}\r\n\r\nfunction platformKey(): string {\r\n if (isBrowser) return \"browser\"\r\n return `${process.platform}-${process.arch}`\r\n}\r\n\r\n/**\r\n * Resolve native binary path dari semua sumber yang tersedia.\r\n *\r\n * @example\r\n * const result = resolveNativeBinary()\r\n * if (result.path) {\r\n * const binding = require(result.path)\r\n * } else {\r\n * throw new Error(\"Native binding not found — run npm run build:rust\")\r\n * }\r\n */\r\nexport function resolveNativeBinary(runtimeDir?: string): NativeResolutionResult {\r\n const platform = platformKey()\r\n const tried: string[] = []\r\n\r\n if (isBrowser) {\r\n return { path: null, source: \"not-found\", platform, tried: [\"not available in browser\"] }\r\n }\r\n\r\n // 0. Disabled flag — always short-circuit before any I/O\r\n // TWS_NO_NATIVE adalah nama canonical; TWS_DISABLE_NATIVE diterima untuk backward compat\r\n if (process.env.TWS_NO_NATIVE === \"1\" || process.env.TWS_DISABLE_NATIVE === \"1\") {\r\n return { path: null, source: \"not-found\", platform, tried: [] }\r\n }\r\n\r\n // 1. Env var override\r\n const envPath = process.env.TW_NATIVE_PATH?.trim()\r\n if (envPath) {\r\n if (fs.existsSync(envPath)) {\r\n return { path: envPath, source: \"env\", platform, tried }\r\n }\r\n tried.push(`env:${envPath} (not found)`)\r\n }\r\n\r\n // 2. Prebuilt binary dari platform-specific npm package\r\n const prebuiltPkgs = PLATFORM_MAP[platform] ?? []\r\n for (const pkg of prebuiltPkgs) {\r\n try {\r\n const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n tried.push(`prebuilt:${pkg} (resolved but missing)`)\r\n } catch {\r\n tried.push(`prebuilt:${pkg} (not installed)`)\r\n }\r\n }\r\n\r\n // 2b. .node file bundled inside this package itself (via \"files\": [\"native/*.node\"])\r\n // Covers the case where user installs tailwind-styled-v4 directly from npm\r\n // and the .node file lands at node_modules/tailwind-styled-v4/native/*.node\r\n const napiPlatform = platform === \"linux-x64\" ? \"linux-x64-gnu\"\r\n : platform === \"linux-arm64\" ? \"linux-arm64-gnu\"\r\n : platform\r\n const BINARY_NAMES_SELF = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n if (runtimeDir) {\r\n // runtimeDir is typically dist/ — go up to package root, then into native/\r\n for (const depth of [\"..\", path.join(\"..\", \"..\"), path.join(\"..\", \"..\", \"..\")]) {\r\n const pkgRoot = path.resolve(runtimeDir, depth)\r\n for (const bin of BINARY_NAMES_SELF) {\r\n for (const suffix of [\"\", `.${platform}`, `.${napiPlatform}`]) {\r\n const candidate = path.resolve(pkgRoot, \"native\", `${bin}${suffix}.node`)\r\n tried.push(`self-bundled:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // 3. Local build candidates\r\n const cwd = process.cwd()\r\n const base = runtimeDir ?? cwd\r\n // napi-rs naming: platform key may have -gnu suffix on Linux (already computed above)\r\n\r\n // Both possible binary names:\r\n // - \"tailwind_styled_parser\" (old hardcoded name in resolvers)\r\n // - \"tailwind-styled-native\" (actual binaryName in native/package.json)\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n\r\n const localCandidates: string[] = []\r\n\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(base, `${bin}.node`))\r\n localCandidates.push(path.resolve(base, \"..\", `${bin}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`))\r\n }\r\n\r\n // Walk up from cwd AND base to find repo root native/ dir\r\n // Needed when npm workspaces sets cwd to the package subdir\r\n for (const startDir of [cwd, base]) {\r\n let dir = startDir\r\n for (let i = 0; i < 6; i++) {\r\n const nativeDir = path.resolve(dir, \"native\")\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, \"target\", \"release\", `${bin}.node`))\r\n }\r\n const parent = path.resolve(dir, \"..\")\r\n if (parent === dir) break\r\n dir = parent\r\n }\r\n }\r\n\r\n for (const candidate of localCandidates) {\r\n tried.push(`local:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"local\", platform, tried }\r\n }\r\n }\r\n\r\n return { path: null, source: \"not-found\", platform, tried }\r\n}\r\n\r\n/**\r\n * Format human-readable error untuk \"binary not found\".\r\n */\r\nexport function formatNativeNotFoundError(result: NativeResolutionResult): string {\r\n const lines = [\r\n `[tailwind-styled] Native binding not found for ${result.platform}`,\r\n ``,\r\n `Tried:`,\r\n ...result.tried.map(t => ` - ${t}`),\r\n ``,\r\n `Solutions:`,\r\n ` 1. Build locally: npm run build:rust`,\r\n ` 2. Install prebuilt: npm install @tailwind-styled/native-${result.platform}`,\r\n ` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node`,\r\n ]\r\n return lines.join(\"\\n\")\r\n}","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"\r\n\r\nexport {\r\n TW_STATE_STATIC_FILENAME,\r\n extractStaticStateCss,\r\n appendStaticStateCssToSafelist,\r\n type TwStateConfigEntry,\r\n type StaticStateCssInput,\r\n type GeneratedStateRule,\r\n type StaticStateExtractionResult,\r\n} from \"./staticStateExtractor\"\r\nexport { setGlobalLogFile } from \"./logger\"","/**\r\n * tailwind-styled-v5 — Native Rust Bindings\r\n *\r\n * All functions require native Rust bindings.\r\n * Uses @tailwind-styled/shared for native resolution.\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport { dirname } from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { resolveNativeBinary } from \"@tailwind-styled/shared\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\nconst NATIVE_UNAVAILABLE_MESSAGE =\r\n \"[tailwind-styled/core] Native binding is required but not available.\\n\" +\r\n \"Please ensure you have run: npm run build:rust\"\r\n\r\nconst _nodeRequire = createRequire(import.meta.url)\r\nconst _loadNative = (path: string): unknown => _nodeRequire(path)\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Type Definitions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface ParsedClassModifier {\r\n type: \"opacity\" | \"arbitrary\"\r\n value: string\r\n}\r\n\r\nexport interface ParsedClass {\r\n raw: string\r\n base: string\r\n variants: string[]\r\n modifier?: ParsedClassModifier\r\n}\r\n\r\nexport interface ThemeConfig {\r\n colors: Record<string, string>\r\n spacing: Record<string, string>\r\n fonts: Record<string, string>\r\n breakpoints: Record<string, string>\r\n animations: Record<string, string>\r\n raw: Record<string, string>\r\n}\r\n\r\ninterface NativeBinding {\r\n batchSplitClasses?: (input: string[]) => Array<{\r\n variantKey: string\r\n base: string\r\n variants: string[]\r\n isArbitrary: boolean\r\n hasModifier: boolean\r\n }>\r\n \r\n twMergeRaw?: (classLists: string[]) => string\r\n flattenAndResolve?: (nestedJson: string) => string\r\n resolveConflictGroup?: (base: string) => string\r\n\r\n compileTheme?: (themeConfig: string) => { css: string; variables: Record<string, string> }\r\n extractCssVars?: (css: string) => Record<string, string>\r\n extractThemeFromCss?: (css: string) => Array<{ key: string; value: string }>\r\n parseCssRules?: (css: string) => Array<{\r\n className: string\r\n property: string\r\n value: string\r\n isImportant: boolean\r\n variants: string[]\r\n specificity: number\r\n }>\r\n parseCssToRules?: (css: string) => string\r\n detectDeadCode?: (css: string, usedClasses: string[]) => string[]\r\n classifyKnownClasses?: (classes: string[]) => Array<{ className: string; category: string }>\r\n detectClassConflicts?: (classes: string) => { conflicts: Array<{ class1: string; class2: string; reason: string }>; conflictedClassNames: string[] }\r\n resolveVariants?: (configJson: string, propsJson: string) => { classes: string; resolvedCount: number }\r\n resolveSimpleVariants?: (base: string | null, variants: Record<string, Record<string, string>>, defaults: Record<string, string>, props: Record<string, string>) => string\r\n /** Parse template literal yang sudah di-join. Menggantikan parseTemplate() di twProxy.ts */\r\n parseTemplate?: (raw: string) => {\r\n base: string\r\n subsJson: string\r\n hasSubs: boolean\r\n }\r\n /** Validate ComponentConfig — menggantikan validateVariantConfig() di cv.ts */\r\n validateVariantConfig?: (configJson: string) => {\r\n valid: boolean\r\n errors: Array<{ errorType: string; key: string; value?: string; message: string }>\r\n warnings: string[]\r\n }\r\n /** Build lookup key untuk generated registry — menggantikan key builder di lookupGenerated() */\r\n buildVariantLookupKey?: (defaultVariantsJson: string, propsJson: string) => string\r\n /** Menggantikan cn() — filter+join class names dalam satu Rust pass. (class_utils.rs) */\r\n resolveClassNames?: (inputs: string[]) => string\r\n /** tw_merge dengan custom separator dan optional debug */\r\n twMergeWithSeparator?: (classString: string, opts: { separator?: string; debug?: boolean }) => string\r\n /** tw_merge_many dengan custom separator */\r\n twMergeManyWithSeparator?: (classStrings: string[], opts: { separator?: string; debug?: boolean }) => string\r\n /** conflict-aware Tailwind class merger — port of tailwind-merge. (tw_merge.rs) */\r\n twMerge?: (classString: string) => string\r\n /** variadic convenience wrapper untuk twMerge. (tw_merge.rs) */\r\n twMergeMany?: (classStrings: string[]) => string\r\n /** Tailwind classes → semicolon-separated inline CSS declarations. (state_css.rs) */\r\n twClassesToCss?: (classes: string) => string\r\n /**\r\n * Generate semua CSS rules untuk satu component dari state config — satu Rust call.\r\n *\r\n * Menggantikan JS loop di `injectStateStyles()` dan `generateStateCss()` yang\r\n * memanggil `twClassesToCss()` per state entry (N × NAPI calls → 1 call).\r\n *\r\n * @param id Component state class, e.g. `\"tw-s-abc123\"`\r\n * @param stateMapJson JSON object `{\"loading\":\"opacity-60 cursor-wait\",\"selected\":\"ring-2\"}`\r\n * @param resolvedCss Opsional Tailwind pipeline CSS untuk resolve named classes\r\n * @returns Array of `{ cssRule, stateName, declarations }` — satu per state entry\r\n */\r\n generateRuntimeStateCss?: (\r\n id: string,\r\n stateMapJson: string,\r\n resolvedCss: string | null\r\n ) => Array<{ cssRule: string; stateName: string; declarations: string }>\r\n /**\r\n * Hash a content string — menggantikan JS djb2 loop di hashState() dan hashContainer().\r\n * algorithm: \"md5\" | \"sha256\" | \"fnv\" | \"ahash\" (default: \"md5\")\r\n * length: potong output hex ke N karakter (mis. 6 untuk short ID)\r\n */\r\n hashContent?: (content: string, algorithm?: \"md5\" | \"sha256\" | \"fnv\" | \"ahash\", length?: number) => string\r\n /** Iterative CSS var() chain resolver. (theme.rs) */\r\n resolveThemeValue?: (key: string, rawMapJson: string) => string\r\n /**\r\n * Parse @theme CSS blocks, classify tokens ke buckets, resolve semua var() —\r\n * satu Rust call menggantikan extractThemeFromCss() + N × resolveThemeValue().\r\n * Return ClassifiedThemeConfig: { colors, spacing, fonts, breakpoints, animations, raw }\r\n */\r\n extractThemeFromCssClassified?: (css: string) => {\r\n colors: Record<string, string>\r\n spacing: Record<string, string>\r\n fonts: Record<string, string>\r\n breakpoints: Record<string, string>\r\n animations: Record<string, string>\r\n raw: Record<string, string>\r\n }\r\n /**\r\n * Generate TypeScript interface TailwindStyledThemeTokens dari theme JSON.\r\n * Build-time CLI only (tw generate-types). Menggantikan generateTypeDefinitions() JS.\r\n */\r\n generateTypeDefinitions?: (themeJson: string) => string\r\n /**\r\n * Generate `:root { --prefix-group-name: value; ... }` CSS block dari SystemTokenMap.\r\n *\r\n * Menggantikan nested JS loop di `injectTokensToRoot()` dan `setTokens()` di `styledSystem.ts`.\r\n *\r\n * `tokensJson`: JSON dari `SystemTokenMap` — `{\"colors\":{\"primary\":\"#6366f1\"},\"radius\":{\"base\":\"0.5rem\"}}`\r\n * `prefix`: CSS variable prefix, e.g. `\"sys\"` → `--sys-colors-primary`\r\n */\r\n generateSystemTokenCss?: (tokensJson: string, prefix: string) => string\r\n /** Parse sub-component block syntax from tw`` template. (tw_merge.rs) */\r\n parseSubcomponentBlocksNapi?: (template: string, componentName: string) => {\r\n baseClasses: string\r\n subMapJson: string\r\n }\r\n /** Menggantikan layoutClassesToCss() — static lookup + split dalam satu Rust pass. (container_query.rs) */\r\n layoutClassesToCss?: (classes: string) => string\r\n /** Menggantikan buildContainerRules() — generate @container CSS rules. (container_query.rs) */\r\n buildContainerRules?: (\r\n id: string,\r\n breakpoints: Array<{ key: string; classes: string }>,\r\n containerName: string | null\r\n ) => string\r\n /** Pre-generate semua kombinasi boolean states via bitmask (tw_merge.rs) */\r\n pregenerateStatesNapi?: (states: Record<string, string>) => {\r\n lookupJson: string\r\n stateKeys: string[]\r\n combinations: number\r\n }\r\n\r\n // ── Theme Parsing (napi_bridge_theme_parsing.rs) ───────────────────────────\r\n parseColorsNapi?: (colorsJson: string) => string | Record<string, string>\r\n parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>\r\n parseTransformNapi?: (transformJson: string) => string | Record<string, string>\r\n normalizeColorNapi?: (color: string, opacity: string) => string\r\n sanitizeColorNapi?: (color: string) => string\r\n splitRgbaNapi?: (color: string) => string | { r: number; g: number; b: number; a: number }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Binding Loader\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nlet nativeBinding: NativeBinding | null = null\r\nlet bindingLoadAttempted = false\r\n\r\nconst getBinding = (): NativeBinding => {\r\n if (isBrowser) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE + \"\\n\\nNative bindings are not available in browser. Use the compiled CSS output instead.\")\r\n }\r\n \r\n if (nativeBinding) return nativeBinding\r\n\r\n if (bindingLoadAttempted) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n\r\n bindingLoadAttempted = true\r\n\r\n try {\r\n const runtimeDir = isBrowser ? \"\" : dirname(fileURLToPath(import.meta.url))\r\n const result = isBrowser\r\n ? { path: null, source: \"not-found\", platform: \"browser\", tried: [] }\r\n : resolveNativeBinary(runtimeDir)\r\n\r\n if (result.path && result.path.endsWith(\".node\")) {\r\n const mod = _loadNative(result.path) as NativeBinding\r\n if (mod?.batchSplitClasses) {\r\n nativeBinding = mod\r\n return nativeBinding\r\n }\r\n }\r\n\r\n throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}\\n\\nTried: ${result.tried.join(\"\\n\")}`)\r\n } catch (err) {\r\n throw err instanceof Error ? err : new Error(String(err))\r\n }\r\n}\r\n\r\nexport const resetNativeBinding = (): void => {\r\n nativeBinding = null\r\n bindingLoadAttempted = false\r\n}\r\n\r\nexport const getNativeBinding = getBinding\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Parser Functions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nfunction splitClassListNative(input: string): string[] {\r\n const binding = getBinding()\r\n if (!binding?.batchSplitClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n const result = binding.batchSplitClasses([input])\r\n if (result.length === 0) return []\r\n return result[0].base.split(\" \").filter(Boolean)\r\n}\r\n\r\nfunction parseClassTokenNative(rawToken: string): ParsedClass {\r\n const binding = getBinding()\r\n if (!binding?.batchSplitClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n const result = binding.batchSplitClasses([rawToken])\r\n if (result.length === 0) {\r\n return { raw: rawToken, base: rawToken, variants: [] }\r\n }\r\n const r = result[0]\r\n const parsed: ParsedClass = {\r\n raw: r.base,\r\n base: r.base,\r\n variants: r.variants,\r\n }\r\n if (r.hasModifier) {\r\n const opacityMatch = r.base.match(/^(.*)\\/(\\d{1,3})$/)\r\n if (opacityMatch && opacityMatch[1].length > 0) {\r\n parsed.base = opacityMatch[1]\r\n parsed.modifier = { type: \"opacity\", value: opacityMatch[2] }\r\n } else {\r\n const arbitraryMatch = r.base.match(/\\((--[a-zA-Z0-9_-]+)\\)/)\r\n if (arbitraryMatch) {\r\n parsed.modifier = { type: \"arbitrary\", value: arbitraryMatch[1] }\r\n }\r\n }\r\n }\r\n return parsed\r\n}\r\n\r\nexport function splitClassList(input: string): string[] {\r\n return splitClassListNative(input)\r\n}\r\n\r\nexport function parseClassToken(rawToken: string): ParsedClass {\r\n return parseClassTokenNative(rawToken)\r\n}\r\n\r\nexport function parseTailwindClasses(input: string): ParsedClass[] {\r\n const classes = splitClassListNative(input)\r\n return classes.map((c) => parseClassTokenNative(c))\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// CSS/Theme Functions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function compileTheme(themeConfig: Record<string, unknown>) {\r\n const binding = getBinding()\r\n if (!binding?.compileTheme) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.compileTheme(JSON.stringify(themeConfig))\r\n}\r\n\r\nexport function extractCssVars(css: string): Record<string, string> {\r\n const binding = getBinding()\r\n if (!binding?.extractCssVars) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.extractCssVars(css)\r\n}\r\n\r\nexport function parseCssRules(css: string) {\r\n const binding = getBinding()\r\n if (!binding?.parseCssRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.parseCssRules(css)\r\n}\r\n\r\nexport function parseCssToRules(css: string): string {\r\n const binding = getBinding()\r\n if (!binding?.parseCssToRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.parseCssToRules(css)\r\n}\r\n\r\nexport function detectDeadCode(css: string, usedClasses: string[]): string[] {\r\n const binding = getBinding()\r\n if (!binding?.detectDeadCode) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.detectDeadCode(css, usedClasses)\r\n}\r\n\r\nexport function classifyKnownClasses(classes: string[]) {\r\n const binding = getBinding()\r\n if (!binding?.classifyKnownClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.classifyKnownClasses(classes)\r\n}\r\n\r\nexport function detectClassConflicts(classes: string[]) {\r\n const binding = getBinding()\r\n if (!binding?.detectClassConflicts) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.detectClassConflicts(classes.join(\" \"))\r\n}\r\n\r\nexport function extractThemeFromCSS(cssContent: string): ThemeConfig {\r\n const binding = getBinding()\r\n if (!binding?.parseCssRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n \r\n const properties = binding.parseCssRules(cssContent)\r\n const theme: ThemeConfig = {\r\n colors: {},\r\n spacing: {},\r\n fonts: {},\r\n breakpoints: {},\r\n animations: {},\r\n raw: {},\r\n }\r\n \r\n const prefixMap: Record<string, keyof ThemeConfig> = {\r\n \"color-\": \"colors\",\r\n \"spacing-\": \"spacing\",\r\n \"font-\": \"fonts\",\r\n \"breakpoint-\": \"breakpoints\",\r\n \"animate-\": \"animations\",\r\n }\r\n \r\n for (const prop of properties) {\r\n const cssVar = prop.property.replace(/^--/, \"\")\r\n theme.raw[cssVar] = prop.value\r\n \r\n for (const [prefix, category] of Object.entries(prefixMap)) {\r\n if (cssVar.startsWith(prefix)) {\r\n const name = cssVar.slice(prefix.length)\r\n if (name) theme[category][name] = prop.value\r\n break\r\n }\r\n }\r\n }\r\n \r\n return theme\r\n}","/**\r\n * tailwind-styled-v4 — createTwMerge()\r\n * Pure Node.js — requires native Rust binding.\r\n */\r\n\r\nimport { getNativeBinding } from \"./native\"\r\nimport type { ThemeConfig } from \"./themeReader\"\r\n\r\nexport interface MergeOptions {\r\n prefix?: string\r\n separator?: string\r\n theme?: ThemeConfig\r\n}\r\n\r\nexport function createTwMerge(_options: MergeOptions = {}) {\r\n return function twMerge(...classLists: Array<string | undefined | null | false>): string {\r\n const inputs: string[] = []\r\n for (let i = 0; i < classLists.length; i++) {\r\n const v = classLists[i]\r\n if (v) inputs.push(String(v))\r\n }\r\n if (inputs.length === 0) return \"\"\r\n\r\n const native = getNativeBinding()\r\n if (!native?.twMergeRaw) {\r\n throw new Error(\"Native binding 'twMergeRaw' is required but not available.\")\r\n }\r\n return native.twMergeRaw(inputs)\r\n }\r\n}\r\n\r\nexport const twMerge = createTwMerge()\r\n\r\nexport function mergeWithRules(\r\n rules: Record<string, (classes: string[]) => string>,\r\n ...classLists: string[]\r\n): string {\r\n const base = twMerge(...classLists)\r\n const classes = Object.values(rules).reduce(\r\n (acc, rule) => twMerge(rule(acc)).split(/\\s+/).filter(Boolean),\r\n base.split(/\\s+/).filter(Boolean)\r\n )\r\n return classes.join(\" \")\r\n}","/**\r\n * tailwind-styled-v4 — Svelte Adapter\r\n *\r\n * Svelte 4+ adapter menggunakan action dan store pattern.\r\n * Kompatibel dengan Svelte 5 runes mode.\r\n *\r\n * Dua pola yang didukung:\r\n * 1. `tw()` — buat class string resolver untuk dipakai di template\r\n * 2. `createSvelteComponent()` — buat Svelte component via Svelte API\r\n *\r\n * @example\r\n * <!-- Pola 1: tw() sebagai class resolver -->\r\n * <script>\r\n * import { cv } from '@tailwind-styled/svelte'\r\n *\r\n * const buttonClass = cv({\r\n * base: 'px-4 py-2 rounded font-medium',\r\n * variants: {\r\n * intent: { primary: 'bg-blue-500 text-white', danger: 'bg-red-500 text-white' },\r\n * size: { sm: 'h-8 text-sm', lg: 'h-12 text-lg' },\r\n * },\r\n * defaultVariants: { intent: 'primary', size: 'sm' },\r\n * })\r\n *\r\n * export let intent = 'primary'\r\n * export let size = 'sm'\r\n * </script>\r\n *\r\n * <button class={buttonClass({ intent, size })}>\r\n * <slot />\r\n * </button>\r\n */\r\n\r\nimport { twMerge } from \"@tailwind-styled/core\"\r\n\r\nimport type { VariantValue, VariantProps as Props } from '@tailwind-styled/shared'\r\n\r\n\r\nconst toClassName = (value: VariantValue): string | undefined => {\r\n if (typeof value === \"string\") return value\r\n if (typeof value === \"number\") return String(value)\r\n return undefined\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface SvelteComponentConfig {\r\n base?: string\r\n variants?: Record<string, Record<string, string>>\r\n compoundVariants?: Array<{ class: string; [key: string]: VariantValue }>\r\n defaultVariants?: Record<string, string>\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Variant resolvers (framework-agnostic core)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nfunction resolveVariants(\r\n variants: Record<string, Record<string, string>>,\r\n props: Props,\r\n defaults: Record<string, string> = {}\r\n): string {\r\n const classes: string[] = []\r\n for (const key in variants) {\r\n const val = props[key] ?? defaults[key]\r\n if (val !== undefined && variants[key]?.[String(val)]) {\r\n classes.push(variants[key][String(val)])\r\n }\r\n }\r\n return classes.join(\" \")\r\n}\r\n\r\nfunction resolveCompound(\r\n compounds: Array<{ class: string; [key: string]: VariantValue }>,\r\n props: Props\r\n): string {\r\n return compounds\r\n .filter((c) => {\r\n const { class: _cls, ...conditions } = c\r\n return Object.entries(conditions).every(([k, v]) => props[k] === v)\r\n })\r\n .map((c) => c.class)\r\n .join(\" \")\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// cv() — Class Variant (utama untuk Svelte)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Class variant resolver — pola utama untuk Svelte.\r\n * Returns fungsi yang menerima props dan mengembalikan class string.\r\n *\r\n * Gunakan ini di `<script>` block, lalu panggil di template.\r\n *\r\n * @example\r\n * const button = cv({\r\n * base: 'px-4 py-2 rounded',\r\n * variants: { size: { sm: 'h-8', lg: 'h-12' } },\r\n * })\r\n *\r\n * // Di template: class={button({ size: 'lg' })}\r\n */\r\nexport function cv(config: SvelteComponentConfig) {\r\n return (props: Props = {}) => {\r\n const { base = \"\", variants = {}, compoundVariants = [], defaultVariants = {} } = config\r\n\r\n const merged = { ...defaultVariants, ...props }\r\n const variantClasses = resolveVariants(variants, merged, defaultVariants)\r\n const compoundClasses = resolveCompound(compoundVariants, merged)\r\n\r\n return twMerge(base, variantClasses, compoundClasses, toClassName(props.class))\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// tw() — Simple class merger dengan template literal support\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Simple class merger — berguna untuk merge class dinamis.\r\n *\r\n * @example\r\n * import { tw } from '@tailwind-styled/svelte'\r\n *\r\n * // Merge class string\r\n * const cls = tw('px-4 py-2', isActive && 'bg-blue-500', className)\r\n */\r\nexport function tw(...classes: Array<string | boolean | null | undefined>): string {\r\n return twMerge(...(classes.filter(Boolean) as string[]))\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Svelte action — use:styled\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Svelte action untuk menerapkan class dinamis.\r\n *\r\n * @example\r\n * <script>\r\n * import { styled } from '@tailwind-styled/svelte'\r\n * const buttonConfig = { base: 'px-4 py-2', variants: { size: { sm: 'h-8', lg: 'h-12' } } }\r\n * </script>\r\n *\r\n * <button use:styled={{ config: buttonConfig, props: { size: 'lg' } }}>\r\n * Click me\r\n * </button>\r\n */\r\nexport function styled(\r\n node: HTMLElement,\r\n { config, props = {} }: { config: SvelteComponentConfig; props?: Props }\r\n) {\r\n const _resolver = cv(config)\r\n\r\n function update({\r\n config: cfg,\r\n props: p = {},\r\n }: {\r\n config: SvelteComponentConfig\r\n props?: Props\r\n }) {\r\n const classes = cv(cfg)(p)\r\n // Hapus class lama yang dikelola action, tambah yang baru\r\n node.className = classes\r\n }\r\n\r\n // Apply initial classes\r\n update({ config, props })\r\n\r\n return {\r\n update,\r\n destroy() {\r\n // Cleanup tidak diperlukan\r\n },\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// createVariants() — Svelte 5 runes compatible\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Svelte 5 runes-compatible variant factory.\r\n * Mengembalikan reactive class string menggunakan $derived pattern.\r\n *\r\n * @example\r\n * // Dalam Svelte 5 component:\r\n * const { className, variantProps } = createVariants({\r\n * base: 'px-4 py-2',\r\n * variants: { size: { sm: 'h-8', lg: 'h-12' } },\r\n * }, () => ({ size: currentSize }))\r\n *\r\n * // className adalah fungsi yang return class string terkini\r\n */\r\nexport function createVariants(config: SvelteComponentConfig, getProps: () => Props) {\r\n const resolver = cv(config)\r\n\r\n return {\r\n className: () => resolver(getProps()),\r\n config,\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../packages/domain/shared/src/native-resolution.ts","../packages/domain/shared/src/index.ts","../packages/domain/core/src/native.ts","../packages/domain/core/src/merge.ts","../packages/presentation/svelte/src/index.ts"],"names":["createRequire","isBrowser","path","fileURLToPath","twMerge"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI,WAAW,OAAO,SAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAAI,QAAQ,IAAI,CAAA,CAAA;AAC5C;AAaO,SAAS,oBAAoB,UAAA,EAA6C;AAC/E,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,CAAC,0BAA0B,CAAA,EAAE;AAAA,EAC1F;AAIA,EAAA,IAAI,QAAQ,GAAA,CAAI,aAAA,KAAkB,OAAO,OAAA,CAAQ,GAAA,CAAI,uBAAuB,GAAA,EAAK;AAC/E,IAAA,OAAO,EAAE,MAAM,IAAA,EAAM,MAAA,EAAQ,aAAa,QAAA,EAAU,KAAA,EAAO,EAAC,EAAE;AAAA,EAChE;AAGA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,GAAA,CAAI,cAAA,EAAgB,IAAA,EAAK;AACjD,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,IAAO,EAAA,CAAA,UAAA,CAAW,OAAO,CAAA,EAAG;AAC1B,MAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,KAAA,EAAO,UAAU,KAAA,EAAM;AAAA,IACzD;AACA,IAAA,K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gBAAA,EAAkB,MAAM,CAAA;AAEhE,IAAA,OAAO,QAAQ,IAAA,EAAM,cAAA,EAAgB,iBAAiB,WAAA,CAAY,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,EAChF,CAAA;AACF;AAeO,SAAS,MAAM,OAAA,EAA6D;AACjF,EAAA,OAAO,OAAA,CAAQ,GAAI,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAc,CAAA;AACzD;AAmBO,SAAS,OACd,IAAA,EACA,EAAE,QAAQ,KAAA,GAAQ,IAAG,EACrB;AAGA,EAAA,SAAS,MAAA,CAAO;AAAA,IACd,MAAA,EAAQ,GAAA;AAAA,IACR,KAAA,EAAO,IAAI;AAAC,GACd,EAGG;AACD,IAAA,MAAM,OAAA,GAAU,EAAA,CAAG,GAAG,CAAA,CAAE,CAAC,CAAA;AAEzB,IAAA,IAAA,CAAK,SAAA,GAAY,OAAA;AAAA,EACnB;AAGA,EAAA,MAAA,CAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,CAAA;AAExB,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA,GAAU;AAAA,IAEV;AAAA,GACF;AACF;AAmBO,SAAS,cAAA,CAAe,QAA+B,QAAA,EAAuB;AACnF,EAAA,MAAM,QAAA,GAAW,GAAG,MAAM,CAAA;AAE1B,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,MAAM,QAAA,CAAS,QAAA,EAAU,CAAA;AAAA,IACpC;AAAA,GACF;AACF","file":"svelte.mjs","sourcesContent":["/**\r\n * Prebuilt binary resolution untuk native NAPI bindings.\r\n * QA #1: Resolve native binary dari prebuilt packages atau local build.\r\n *\r\n * Prioritas:\r\n * 1. TW_NATIVE_PATH env var (explicit override)\r\n * 2. Local native/ folder in npm package (via \"files\": [\"native/*.node\"])\r\n * 3. Prebuilt binary dari platform-specific npm package\r\n * 4. Local build dari source (developer mode)\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport * as fs from \"node:fs\"\r\nimport * as path from \"node:path\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// ESM-safe require — works in both ESM and CJS contexts\r\nconst _require = typeof require !== \"undefined\" ? require : createRequire(import.meta.url)\r\n\r\nexport interface NativeResolutionResult {\r\n path: string | null\r\n source: \"env\" | \"prebuilt\" | \"local\" | \"not-found\"\r\n platform: string\r\n tried: string[]\r\n}\r\n\r\n/** Platform key → prebuilt npm package name */\r\nconst PLATFORM_MAP: Record<string, string[]> = {\r\n \"linux-x64\": [\"@tailwind-styled/native-linux-x64-gnu\", \"@tailwind-styled/native-linux-x64\"],\r\n \"linux-arm64\": [\"@tailwind-styled/native-linux-arm64-gnu\", \"@tailwind-styled/native-linux-arm64\"],\r\n \"darwin-x64\": [\"@tailwind-styled/native-darwin-x64\"],\r\n \"darwin-arm64\": [\"@tailwind-styled/native-darwin-arm64\"],\r\n \"win32-x64\": [\"@tailwind-styled/native-win32-x64-msvc\", \"@tailwind-styled/native-win32-x64\"],\r\n \"win32-arm64\": [\"@tailwind-styled/native-win32-arm64-msvc\", \"@tailwind-styled/native-win32-arm64\"],\r\n}\r\n\r\nfunction platformKey(): string {\r\n if (isBrowser) return \"browser\"\r\n return `${process.platform}-${process.arch}`\r\n}\r\n\r\n/**\r\n * Resolve native binary path dari semua sumber yang tersedia.\r\n *\r\n * @example\r\n * const result = resolveNativeBinary()\r\n * if (result.path) {\r\n * const binding = require(result.path)\r\n * } else {\r\n * throw new Error(\"Native binding not found — run npm run build:rust\")\r\n * }\r\n */\r\nexport function resolveNativeBinary(runtimeDir?: string): NativeResolutionResult {\r\n const platform = platformKey()\r\n const tried: string[] = []\r\n\r\n if (isBrowser) {\r\n return { path: null, source: \"not-found\", platform, tried: [\"not available in browser\"] }\r\n }\r\n\r\n // 0. Disabled flag — always short-circuit before any I/O\r\n // TWS_NO_NATIVE adalah nama canonical; TWS_DISABLE_NATIVE diterima untuk backward compat\r\n if (process.env.TWS_NO_NATIVE === \"1\" || process.env.TWS_DISABLE_NATIVE === \"1\") {\r\n return { path: null, source: \"not-found\", platform, tried: [] }\r\n }\r\n\r\n // 1. Env var override\r\n const envPath = process.env.TW_NATIVE_PATH?.trim()\r\n if (envPath) {\r\n if (fs.existsSync(envPath)) {\r\n return { path: envPath, source: \"env\", platform, tried }\r\n }\r\n tried.push(`env:${envPath} (not found)`)\r\n }\r\n\r\n // 2. Local build candidates FIRST (native/ folder in node_modules package)\r\n // When installed via npm, \"files\": [\"native/*.node\"] includes them\r\n // Priority: node_modules/tailwind-styled-v4/native/*.node\r\n const napiPlatform = platform === \"linux-x64\" ? \"linux-x64-gnu\"\r\n : platform === \"linux-arm64\" ? \"linux-arm64-gnu\"\r\n : platform\r\n const BINARY_NAMES_SELF = [\"tailwind-styled-native\", \"tailwind_styled_parser\", \"index\"]\r\n if (runtimeDir) {\r\n // runtimeDir is typically dist/ — go up to package root, then into native/\r\n for (const depth of [\"..\", path.join(\"..\", \"..\"), path.join(\"..\", \"..\", \"..\")]) {\r\n const pkgRoot = path.resolve(runtimeDir, depth)\r\n for (const bin of BINARY_NAMES_SELF) {\r\n for (const suffix of [\"\", `.${platform}`, `.${napiPlatform}`]) {\r\n const candidate = path.resolve(pkgRoot, \"native\", `${bin}${suffix}.node`)\r\n tried.push(`native:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // 2b. Prebuilt binary dari platform-specific npm package\r\n const prebuiltPkgs = PLATFORM_MAP[platform] ?? []\r\n for (const pkg of prebuiltPkgs) {\r\n try {\r\n const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"prebuilt\", platform, tried }\r\n }\r\n tried.push(`prebuilt:${pkg} (resolved but missing)`)\r\n } catch {\r\n tried.push(`prebuilt:${pkg} (not installed)`)\r\n }\r\n }\r\n\r\n // 3. Local build candidates\r\n const cwd = process.cwd()\r\n const base = runtimeDir ?? cwd\r\n // napi-rs naming: platform key may have -gnu suffix on Linux (already computed above)\r\n\r\n // Both possible binary names:\r\n // - \"tailwind_styled_parser\" (old hardcoded name in resolvers)\r\n // - \"tailwind-styled-native\" (actual binaryName in native/package.json)\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n\r\n const localCandidates: string[] = []\r\n\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(base, `${bin}.node`))\r\n localCandidates.push(path.resolve(base, \"..\", `${bin}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`))\r\n }\r\n\r\n // Walk up from cwd AND base to find repo root native/ dir\r\n // Needed when npm workspaces sets cwd to the package subdir\r\n for (const startDir of [cwd, base]) {\r\n let dir = startDir\r\n for (let i = 0; i < 6; i++) {\r\n const nativeDir = path.resolve(dir, \"native\")\r\n for (const bin of BINARY_NAMES) {\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`))\r\n localCandidates.push(path.resolve(nativeDir, \"target\", \"release\", `${bin}.node`))\r\n }\r\n const parent = path.resolve(dir, \"..\")\r\n if (parent === dir) break\r\n dir = parent\r\n }\r\n }\r\n\r\n for (const candidate of localCandidates) {\r\n tried.push(`local:${candidate}`)\r\n if (fs.existsSync(candidate)) {\r\n return { path: candidate, source: \"local\", platform, tried }\r\n }\r\n }\r\n\r\n return { path: null, source: \"not-found\", platform, tried }\r\n}\r\n\r\n/**\r\n * Format human-readable error untuk \"binary not found\".\r\n */\r\nexport function formatNativeNotFoundError(result: NativeResolutionResult): string {\r\n const lines = [\r\n `[tailwind-styled] Native binding not found for ${result.platform}`,\r\n ``,\r\n `Tried:`,\r\n ...result.tried.map(t => ` - ${t}`),\r\n ``,\r\n `Solutions:`,\r\n ` 1. Build locally: npm run build:rust`,\r\n ` 2. Install prebuilt: npm install @tailwind-styled/native-${result.platform}`,\r\n ` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node`,\r\n ]\r\n return lines.join(\"\\n\")\r\n}","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"\r\n\r\nexport {\r\n TW_STATE_STATIC_FILENAME,\r\n extractStaticStateCss,\r\n appendStaticStateCssToSafelist,\r\n type TwStateConfigEntry,\r\n type StaticStateCssInput,\r\n type GeneratedStateRule,\r\n type StaticStateExtractionResult,\r\n} from \"./staticStateExtractor\"\r\nexport { setGlobalLogFile } from \"./logger\"","/**\r\n * tailwind-styled-v5 — Native Rust Bindings\r\n *\r\n * All functions require native Rust bindings.\r\n * Uses @tailwind-styled/shared for native resolution.\r\n */\r\n\r\nimport { createRequire } from \"node:module\"\r\nimport { dirname } from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { resolveNativeBinary } from \"@tailwind-styled/shared\"\r\n\r\nconst isBrowser = typeof window !== \"undefined\" && typeof document !== \"undefined\"\r\nconst NATIVE_UNAVAILABLE_MESSAGE =\r\n \"[tailwind-styled/core] Native binding is required but not available.\\n\" +\r\n \"Make sure:\\n\" +\r\n \" 1. .node files were copied to dist/ during build\\n\" +\r\n \" 2. You installed the correct native package for your platform\\n\" +\r\n \" 3. npm run build:rust was executed successfully\"\r\n\r\nconst _nodeRequire = createRequire(import.meta.url)\r\nconst _loadNative = (path: string): unknown => _nodeRequire(path)\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Type Definitions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface ParsedClassModifier {\r\n type: \"opacity\" | \"arbitrary\"\r\n value: string\r\n}\r\n\r\nexport interface ParsedClass {\r\n raw: string\r\n base: string\r\n variants: string[]\r\n modifier?: ParsedClassModifier\r\n}\r\n\r\nexport interface ThemeConfig {\r\n colors: Record<string, string>\r\n spacing: Record<string, string>\r\n fonts: Record<string, string>\r\n breakpoints: Record<string, string>\r\n animations: Record<string, string>\r\n raw: Record<string, string>\r\n}\r\n\r\ninterface NativeBinding {\r\n batchSplitClasses?: (input: string[]) => Array<{\r\n variantKey: string\r\n base: string\r\n variants: string[]\r\n isArbitrary: boolean\r\n hasModifier: boolean\r\n }>\r\n \r\n twMergeRaw?: (classLists: string[]) => string\r\n flattenAndResolve?: (nestedJson: string) => string\r\n resolveConflictGroup?: (base: string) => string\r\n\r\n compileTheme?: (themeConfig: string) => { css: string; variables: Record<string, string> }\r\n extractCssVars?: (css: string) => Record<string, string>\r\n extractThemeFromCss?: (css: string) => Array<{ key: string; value: string }>\r\n parseCssRules?: (css: string) => Array<{\r\n className: string\r\n property: string\r\n value: string\r\n isImportant: boolean\r\n variants: string[]\r\n specificity: number\r\n }>\r\n parseCssToRules?: (css: string) => string\r\n detectDeadCode?: (css: string, usedClasses: string[]) => string[]\r\n classifyKnownClasses?: (classes: string[]) => Array<{ className: string; category: string }>\r\n detectClassConflicts?: (classes: string) => { conflicts: Array<{ class1: string; class2: string; reason: string }>; conflictedClassNames: string[] }\r\n resolveVariants?: (configJson: string, propsJson: string) => { classes: string; resolvedCount: number }\r\n resolveSimpleVariants?: (base: string | null, variants: Record<string, Record<string, string>>, defaults: Record<string, string>, props: Record<string, string>) => string\r\n /** Parse template literal yang sudah di-join. Menggantikan parseTemplate() di twProxy.ts */\r\n parseTemplate?: (raw: string) => {\r\n base: string\r\n subsJson: string\r\n hasSubs: boolean\r\n }\r\n /** Validate ComponentConfig — menggantikan validateVariantConfig() di cv.ts */\r\n validateVariantConfig?: (configJson: string) => {\r\n valid: boolean\r\n errors: Array<{ errorType: string; key: string; value?: string; message: string }>\r\n warnings: string[]\r\n }\r\n /** Build lookup key untuk generated registry — menggantikan key builder di lookupGenerated() */\r\n buildVariantLookupKey?: (defaultVariantsJson: string, propsJson: string) => string\r\n /** Menggantikan cn() — filter+join class names dalam satu Rust pass. (class_utils.rs) */\r\n resolveClassNames?: (inputs: string[]) => string\r\n /** tw_merge dengan custom separator dan optional debug */\r\n twMergeWithSeparator?: (classString: string, opts: { separator?: string; debug?: boolean }) => string\r\n /** tw_merge_many dengan custom separator */\r\n twMergeManyWithSeparator?: (classStrings: string[], opts: { separator?: string; debug?: boolean }) => string\r\n /** conflict-aware Tailwind class merger — port of tailwind-merge. (tw_merge.rs) */\r\n twMerge?: (classString: string) => string\r\n /** variadic convenience wrapper untuk twMerge. (tw_merge.rs) */\r\n twMergeMany?: (classStrings: string[]) => string\r\n /** Tailwind classes → semicolon-separated inline CSS declarations. (state_css.rs) */\r\n twClassesToCss?: (classes: string) => string\r\n /**\r\n * Generate semua CSS rules untuk satu component dari state config — satu Rust call.\r\n *\r\n * Menggantikan JS loop di `injectStateStyles()` dan `generateStateCss()` yang\r\n * memanggil `twClassesToCss()` per state entry (N × NAPI calls → 1 call).\r\n *\r\n * @param id Component state class, e.g. `\"tw-s-abc123\"`\r\n * @param stateMapJson JSON object `{\"loading\":\"opacity-60 cursor-wait\",\"selected\":\"ring-2\"}`\r\n * @param resolvedCss Opsional Tailwind pipeline CSS untuk resolve named classes\r\n * @returns Array of `{ cssRule, stateName, declarations }` — satu per state entry\r\n */\r\n generateRuntimeStateCss?: (\r\n id: string,\r\n stateMapJson: string,\r\n resolvedCss: string | null\r\n ) => Array<{ cssRule: string; stateName: string; declarations: string }>\r\n /**\r\n * Hash a content string — menggantikan JS djb2 loop di hashState() dan hashContainer().\r\n * algorithm: \"md5\" | \"sha256\" | \"fnv\" | \"ahash\" (default: \"md5\")\r\n * length: potong output hex ke N karakter (mis. 6 untuk short ID)\r\n */\r\n hashContent?: (content: string, algorithm?: \"md5\" | \"sha256\" | \"fnv\" | \"ahash\", length?: number) => string\r\n /** Iterative CSS var() chain resolver. (theme.rs) */\r\n resolveThemeValue?: (key: string, rawMapJson: string) => string\r\n /**\r\n * Parse @theme CSS blocks, classify tokens ke buckets, resolve semua var() —\r\n * satu Rust call menggantikan extractThemeFromCss() + N × resolveThemeValue().\r\n * Return ClassifiedThemeConfig: { colors, spacing, fonts, breakpoints, animations, raw }\r\n */\r\n extractThemeFromCssClassified?: (css: string) => {\r\n colors: Record<string, string>\r\n spacing: Record<string, string>\r\n fonts: Record<string, string>\r\n breakpoints: Record<string, string>\r\n animations: Record<string, string>\r\n raw: Record<string, string>\r\n }\r\n /**\r\n * Generate TypeScript interface TailwindStyledThemeTokens dari theme JSON.\r\n * Build-time CLI only (tw generate-types). Menggantikan generateTypeDefinitions() JS.\r\n */\r\n generateTypeDefinitions?: (themeJson: string) => string\r\n /**\r\n * Generate `:root { --prefix-group-name: value; ... }` CSS block dari SystemTokenMap.\r\n *\r\n * Menggantikan nested JS loop di `injectTokensToRoot()` dan `setTokens()` di `styledSystem.ts`.\r\n *\r\n * `tokensJson`: JSON dari `SystemTokenMap` — `{\"colors\":{\"primary\":\"#6366f1\"},\"radius\":{\"base\":\"0.5rem\"}}`\r\n * `prefix`: CSS variable prefix, e.g. `\"sys\"` → `--sys-colors-primary`\r\n */\r\n generateSystemTokenCss?: (tokensJson: string, prefix: string) => string\r\n /** Parse sub-component block syntax from tw`` template. (tw_merge.rs) */\r\n parseSubcomponentBlocksNapi?: (template: string, componentName: string) => {\r\n baseClasses: string\r\n subMapJson: string\r\n }\r\n /** Menggantikan layoutClassesToCss() — static lookup + split dalam satu Rust pass. (container_query.rs) */\r\n layoutClassesToCss?: (classes: string) => string\r\n /** Menggantikan buildContainerRules() — generate @container CSS rules. (container_query.rs) */\r\n buildContainerRules?: (\r\n id: string,\r\n breakpoints: Array<{ key: string; classes: string }>,\r\n containerName: string | null\r\n ) => string\r\n /** Pre-generate semua kombinasi boolean states via bitmask (tw_merge.rs) */\r\n pregenerateStatesNapi?: (states: Record<string, string>) => {\r\n lookupJson: string\r\n stateKeys: string[]\r\n combinations: number\r\n }\r\n\r\n // ── Theme Parsing (napi_bridge_theme_parsing.rs) ───────────────────────────\r\n parseColorsNapi?: (colorsJson: string) => string | Record<string, string>\r\n parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>\r\n parseTransformNapi?: (transformJson: string) => string | Record<string, string>\r\n normalizeColorNapi?: (color: string, opacity: string) => string\r\n sanitizeColorNapi?: (color: string) => string\r\n splitRgbaNapi?: (color: string) => string | { r: number; g: number; b: number; a: number }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Binding Loader\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nlet nativeBinding: NativeBinding | null = null\r\nlet bindingLoadAttempted = false\r\nlet bindingError: Error | null = null\r\n\r\nconst getBinding = (): NativeBinding => {\r\n // If already loaded, return\r\n if (nativeBinding) return nativeBinding\r\n \r\n // If attempted and failed, re-throw cached error\r\n if (bindingError) {\r\n throw bindingError\r\n }\r\n \r\n // If already attempted without error and still no binding, throw\r\n if (bindingLoadAttempted) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n\r\n bindingLoadAttempted = true\r\n\r\n try {\r\n // Browser environment — template literals not supported at all\r\n if (isBrowser) {\r\n bindingError = new Error(\r\n \"[tailwind-styled/core] Cannot use template literals (tw`...`) in browser environment.\\n\\n\" +\r\n \"Template literal parsing requires native Rust bindings compiled to WebAssembly,\\n\" +\r\n \"which is not currently supported.\\n\\n\" +\r\n \"Solutions:\\n\" +\r\n \"1. Use object config only: tw.button({ base: '...', variants: {...} })\\n\" +\r\n \"2. Pre-compile components on the server (Next.js Server Components)\\n\" +\r\n \"3. Use @tailwind-styled browser-safe packages if available\\n\\n\" +\r\n \"For more info: https://github.com/Dictionar32/css-in-rust/discussions\"\r\n )\r\n throw bindingError\r\n }\r\n\r\n const runtimeDir = dirname(fileURLToPath(import.meta.url))\r\n const result = resolveNativeBinary(runtimeDir)\r\n\r\n if (result.path && result.path.endsWith(\".node\")) {\r\n const mod = _loadNative(result.path) as NativeBinding\r\n if (mod?.batchSplitClasses) {\r\n nativeBinding = mod\r\n return nativeBinding\r\n }\r\n }\r\n\r\n bindingError = new Error(\r\n `${NATIVE_UNAVAILABLE_MESSAGE}\\n\\n` +\r\n `Resolution Attempts:\\n${result.tried.map(t => ` - ${t}`).join(\"\\n\")}\\n\\n` +\r\n \"Quick fixes:\\n\" +\r\n \" 1. npm run build:rust # Build native binaries\\n\" +\r\n \" 2. npm install # Reinstall with pre-built binaries\\n\" +\r\n \" 3. TW_NATIVE_PATH=/path/to/index.node npm run dev # Specify binary path\"\r\n )\r\n throw bindingError\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err))\r\n bindingError = error\r\n throw error\r\n }\r\n}\r\n\r\nexport const resetNativeBinding = (): void => {\r\n nativeBinding = null\r\n bindingLoadAttempted = false\r\n}\r\n\r\nexport const getNativeBinding = getBinding\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Parser Functions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nfunction splitClassListNative(input: string): string[] {\r\n const binding = getBinding()\r\n if (!binding?.batchSplitClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n const result = binding.batchSplitClasses([input])\r\n if (result.length === 0) return []\r\n return result[0].base.split(\" \").filter(Boolean)\r\n}\r\n\r\nfunction parseClassTokenNative(rawToken: string): ParsedClass {\r\n const binding = getBinding()\r\n if (!binding?.batchSplitClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n const result = binding.batchSplitClasses([rawToken])\r\n if (result.length === 0) {\r\n return { raw: rawToken, base: rawToken, variants: [] }\r\n }\r\n const r = result[0]\r\n const parsed: ParsedClass = {\r\n raw: r.base,\r\n base: r.base,\r\n variants: r.variants,\r\n }\r\n if (r.hasModifier) {\r\n const opacityMatch = r.base.match(/^(.*)\\/(\\d{1,3})$/)\r\n if (opacityMatch && opacityMatch[1].length > 0) {\r\n parsed.base = opacityMatch[1]\r\n parsed.modifier = { type: \"opacity\", value: opacityMatch[2] }\r\n } else {\r\n const arbitraryMatch = r.base.match(/\\((--[a-zA-Z0-9_-]+)\\)/)\r\n if (arbitraryMatch) {\r\n parsed.modifier = { type: \"arbitrary\", value: arbitraryMatch[1] }\r\n }\r\n }\r\n }\r\n return parsed\r\n}\r\n\r\nexport function splitClassList(input: string): string[] {\r\n return splitClassListNative(input)\r\n}\r\n\r\nexport function parseClassToken(rawToken: string): ParsedClass {\r\n return parseClassTokenNative(rawToken)\r\n}\r\n\r\nexport function parseTailwindClasses(input: string): ParsedClass[] {\r\n const classes = splitClassListNative(input)\r\n return classes.map((c) => parseClassTokenNative(c))\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// CSS/Theme Functions\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function compileTheme(themeConfig: Record<string, unknown>) {\r\n const binding = getBinding()\r\n if (!binding?.compileTheme) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.compileTheme(JSON.stringify(themeConfig))\r\n}\r\n\r\nexport function extractCssVars(css: string): Record<string, string> {\r\n const binding = getBinding()\r\n if (!binding?.extractCssVars) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.extractCssVars(css)\r\n}\r\n\r\nexport function parseCssRules(css: string) {\r\n const binding = getBinding()\r\n if (!binding?.parseCssRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.parseCssRules(css)\r\n}\r\n\r\nexport function parseCssToRules(css: string): string {\r\n const binding = getBinding()\r\n if (!binding?.parseCssToRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.parseCssToRules(css)\r\n}\r\n\r\nexport function detectDeadCode(css: string, usedClasses: string[]): string[] {\r\n const binding = getBinding()\r\n if (!binding?.detectDeadCode) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.detectDeadCode(css, usedClasses)\r\n}\r\n\r\nexport function classifyKnownClasses(classes: string[]) {\r\n const binding = getBinding()\r\n if (!binding?.classifyKnownClasses) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.classifyKnownClasses(classes)\r\n}\r\n\r\nexport function detectClassConflicts(classes: string[]) {\r\n const binding = getBinding()\r\n if (!binding?.detectClassConflicts) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n return binding.detectClassConflicts(classes.join(\" \"))\r\n}\r\n\r\nexport function extractThemeFromCSS(cssContent: string): ThemeConfig {\r\n const binding = getBinding()\r\n if (!binding?.parseCssRules) {\r\n throw new Error(NATIVE_UNAVAILABLE_MESSAGE)\r\n }\r\n \r\n const properties = binding.parseCssRules(cssContent)\r\n const theme: ThemeConfig = {\r\n colors: {},\r\n spacing: {},\r\n fonts: {},\r\n breakpoints: {},\r\n animations: {},\r\n raw: {},\r\n }\r\n \r\n const prefixMap: Record<string, keyof ThemeConfig> = {\r\n \"color-\": \"colors\",\r\n \"spacing-\": \"spacing\",\r\n \"font-\": \"fonts\",\r\n \"breakpoint-\": \"breakpoints\",\r\n \"animate-\": \"animations\",\r\n }\r\n \r\n for (const prop of properties) {\r\n const cssVar = prop.property.replace(/^--/, \"\")\r\n theme.raw[cssVar] = prop.value\r\n \r\n for (const [prefix, category] of Object.entries(prefixMap)) {\r\n if (cssVar.startsWith(prefix)) {\r\n const name = cssVar.slice(prefix.length)\r\n if (name) theme[category][name] = prop.value\r\n break\r\n }\r\n }\r\n }\r\n \r\n return theme\r\n}","/**\r\n * tailwind-styled-v4 — createTwMerge()\r\n * Pure Node.js — requires native Rust binding.\r\n */\r\n\r\nimport { getNativeBinding } from \"./native\"\r\nimport type { ThemeConfig } from \"./themeReader\"\r\n\r\nexport interface MergeOptions {\r\n prefix?: string\r\n separator?: string\r\n theme?: ThemeConfig\r\n}\r\n\r\nexport function createTwMerge(_options: MergeOptions = {}) {\r\n return function twMerge(...classLists: Array<string | undefined | null | false>): string {\r\n const inputs: string[] = []\r\n for (let i = 0; i < classLists.length; i++) {\r\n const v = classLists[i]\r\n if (v) inputs.push(String(v))\r\n }\r\n if (inputs.length === 0) return \"\"\r\n\r\n const native = getNativeBinding()\r\n if (!native?.twMergeRaw) {\r\n throw new Error(\"Native binding 'twMergeRaw' is required but not available.\")\r\n }\r\n return native.twMergeRaw(inputs)\r\n }\r\n}\r\n\r\nexport const twMerge = createTwMerge()\r\n\r\nexport function mergeWithRules(\r\n rules: Record<string, (classes: string[]) => string>,\r\n ...classLists: string[]\r\n): string {\r\n const base = twMerge(...classLists)\r\n const classes = Object.values(rules).reduce(\r\n (acc, rule) => twMerge(rule(acc)).split(/\\s+/).filter(Boolean),\r\n base.split(/\\s+/).filter(Boolean)\r\n )\r\n return classes.join(\" \")\r\n}","/**\r\n * tailwind-styled-v4 — Svelte Adapter\r\n *\r\n * Svelte 4+ adapter menggunakan action dan store pattern.\r\n * Kompatibel dengan Svelte 5 runes mode.\r\n *\r\n * Dua pola yang didukung:\r\n * 1. `tw()` — buat class string resolver untuk dipakai di template\r\n * 2. `createSvelteComponent()` — buat Svelte component via Svelte API\r\n *\r\n * @example\r\n * <!-- Pola 1: tw() sebagai class resolver -->\r\n * <script>\r\n * import { cv } from '@tailwind-styled/svelte'\r\n *\r\n * const buttonClass = cv({\r\n * base: 'px-4 py-2 rounded font-medium',\r\n * variants: {\r\n * intent: { primary: 'bg-blue-500 text-white', danger: 'bg-red-500 text-white' },\r\n * size: { sm: 'h-8 text-sm', lg: 'h-12 text-lg' },\r\n * },\r\n * defaultVariants: { intent: 'primary', size: 'sm' },\r\n * })\r\n *\r\n * export let intent = 'primary'\r\n * export let size = 'sm'\r\n * </script>\r\n *\r\n * <button class={buttonClass({ intent, size })}>\r\n * <slot />\r\n * </button>\r\n */\r\n\r\nimport { twMerge } from \"@tailwind-styled/core\"\r\n\r\nimport type { VariantValue, VariantProps as Props } from '@tailwind-styled/shared'\r\n\r\n\r\nconst toClassName = (value: VariantValue): string | undefined => {\r\n if (typeof value === \"string\") return value\r\n if (typeof value === \"number\") return String(value)\r\n return undefined\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface SvelteComponentConfig {\r\n base?: string\r\n variants?: Record<string, Record<string, string>>\r\n compoundVariants?: Array<{ class: string; [key: string]: VariantValue }>\r\n defaultVariants?: Record<string, string>\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Variant resolvers (framework-agnostic core)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nfunction resolveVariants(\r\n variants: Record<string, Record<string, string>>,\r\n props: Props,\r\n defaults: Record<string, string> = {}\r\n): string {\r\n const classes: string[] = []\r\n for (const key in variants) {\r\n const val = props[key] ?? defaults[key]\r\n if (val !== undefined && variants[key]?.[String(val)]) {\r\n classes.push(variants[key][String(val)])\r\n }\r\n }\r\n return classes.join(\" \")\r\n}\r\n\r\nfunction resolveCompound(\r\n compounds: Array<{ class: string; [key: string]: VariantValue }>,\r\n props: Props\r\n): string {\r\n return compounds\r\n .filter((c) => {\r\n const { class: _cls, ...conditions } = c\r\n return Object.entries(conditions).every(([k, v]) => props[k] === v)\r\n })\r\n .map((c) => c.class)\r\n .join(\" \")\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// cv() — Class Variant (utama untuk Svelte)\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Class variant resolver — pola utama untuk Svelte.\r\n * Returns fungsi yang menerima props dan mengembalikan class string.\r\n *\r\n * Gunakan ini di `<script>` block, lalu panggil di template.\r\n *\r\n * @example\r\n * const button = cv({\r\n * base: 'px-4 py-2 rounded',\r\n * variants: { size: { sm: 'h-8', lg: 'h-12' } },\r\n * })\r\n *\r\n * // Di template: class={button({ size: 'lg' })}\r\n */\r\nexport function cv(config: SvelteComponentConfig) {\r\n return (props: Props = {}) => {\r\n const { base = \"\", variants = {}, compoundVariants = [], defaultVariants = {} } = config\r\n\r\n const merged = { ...defaultVariants, ...props }\r\n const variantClasses = resolveVariants(variants, merged, defaultVariants)\r\n const compoundClasses = resolveCompound(compoundVariants, merged)\r\n\r\n return twMerge(base, variantClasses, compoundClasses, toClassName(props.class))\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// tw() — Simple class merger dengan template literal support\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Simple class merger — berguna untuk merge class dinamis.\r\n *\r\n * @example\r\n * import { tw } from '@tailwind-styled/svelte'\r\n *\r\n * // Merge class string\r\n * const cls = tw('px-4 py-2', isActive && 'bg-blue-500', className)\r\n */\r\nexport function tw(...classes: Array<string | boolean | null | undefined>): string {\r\n return twMerge(...(classes.filter(Boolean) as string[]))\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Svelte action — use:styled\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Svelte action untuk menerapkan class dinamis.\r\n *\r\n * @example\r\n * <script>\r\n * import { styled } from '@tailwind-styled/svelte'\r\n * const buttonConfig = { base: 'px-4 py-2', variants: { size: { sm: 'h-8', lg: 'h-12' } } }\r\n * </script>\r\n *\r\n * <button use:styled={{ config: buttonConfig, props: { size: 'lg' } }}>\r\n * Click me\r\n * </button>\r\n */\r\nexport function styled(\r\n node: HTMLElement,\r\n { config, props = {} }: { config: SvelteComponentConfig; props?: Props }\r\n) {\r\n const _resolver = cv(config)\r\n\r\n function update({\r\n config: cfg,\r\n props: p = {},\r\n }: {\r\n config: SvelteComponentConfig\r\n props?: Props\r\n }) {\r\n const classes = cv(cfg)(p)\r\n // Hapus class lama yang dikelola action, tambah yang baru\r\n node.className = classes\r\n }\r\n\r\n // Apply initial classes\r\n update({ config, props })\r\n\r\n return {\r\n update,\r\n destroy() {\r\n // Cleanup tidak diperlukan\r\n },\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// createVariants() — Svelte 5 runes compatible\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Svelte 5 runes-compatible variant factory.\r\n * Mengembalikan reactive class string menggunakan $derived pattern.\r\n *\r\n * @example\r\n * // Dalam Svelte 5 component:\r\n * const { className, variantProps } = createVariants({\r\n * base: 'px-4 py-2',\r\n * variants: { size: { sm: 'h-8', lg: 'h-12' } },\r\n * }, () => ({ size: currentSize }))\r\n *\r\n * // className adalah fungsi yang return class string terkini\r\n */\r\nexport function createVariants(config: SvelteComponentConfig, getProps: () => Props) {\r\n const resolver = cv(config)\r\n\r\n return {\r\n className: () => resolver(getProps()),\r\n config,\r\n }\r\n}\r\n"]}
@@ -75,27 +75,15 @@ function resolveNativeBinary(runtimeDir) {
75
75
  }
76
76
  tried.push(`env:${envPath} (not found)`);
77
77
  }
78
- const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
79
- for (const pkg of prebuiltPkgs) {
80
- try {
81
- const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
82
- if (fs4__namespace.existsSync(candidate)) {
83
- return { path: candidate, source: "prebuilt", platform, tried };
84
- }
85
- tried.push(`prebuilt:${pkg} (resolved but missing)`);
86
- } catch {
87
- tried.push(`prebuilt:${pkg} (not installed)`);
88
- }
89
- }
90
78
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
91
- const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
79
+ const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser", "index"];
92
80
  if (runtimeDir) {
93
81
  for (const depth of ["..", path4__namespace.join("..", ".."), path4__namespace.join("..", "..", "..")]) {
94
82
  const pkgRoot = path4__namespace.resolve(runtimeDir, depth);
95
83
  for (const bin of BINARY_NAMES_SELF) {
96
84
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
97
85
  const candidate = path4__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
98
- tried.push(`self-bundled:${candidate}`);
86
+ tried.push(`native:${candidate}`);
99
87
  if (fs4__namespace.existsSync(candidate)) {
100
88
  return { path: candidate, source: "prebuilt", platform, tried };
101
89
  }
@@ -103,6 +91,18 @@ function resolveNativeBinary(runtimeDir) {
103
91
  }
104
92
  }
105
93
  }
94
+ const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
95
+ for (const pkg of prebuiltPkgs) {
96
+ try {
97
+ const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
98
+ if (fs4__namespace.existsSync(candidate)) {
99
+ return { path: candidate, source: "prebuilt", platform, tried };
100
+ }
101
+ tried.push(`prebuilt:${pkg} (resolved but missing)`);
102
+ } catch {
103
+ tried.push(`prebuilt:${pkg} (not installed)`);
104
+ }
105
+ }
106
106
  const cwd = process.cwd();
107
107
  const base = runtimeDir ?? cwd;
108
108
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];