tailwind-styled-v4 5.0.10 → 5.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -373
- package/dist/analyzer.js +75 -22
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +74 -21
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.js +4 -2
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +4 -2
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +20 -5
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +20 -5
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +174 -67
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +171 -64
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +7 -1
- package/dist/compiler.d.ts +7 -1
- package/dist/compiler.js +53 -27
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +53 -27
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.js +159 -61
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +159 -61
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +1512 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.d.mts +94 -12
- package/dist/index.d.ts +94 -12
- package/dist/index.js +436 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +436 -106
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +1946 -47
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +1929 -44
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +23 -10
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +23 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs.map +1 -1
- package/dist/scanner.js +72 -19
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +71 -18
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.js +32 -15
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +32 -15
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +38 -12
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -12
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +17 -5
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +17 -5
- package/dist/syntax.mjs.map +1 -1
- package/dist/theme.js +4 -2
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +4 -2
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +87 -33
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +87 -33
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +174 -67
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +171 -64
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +145 -63
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +145 -63
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +38 -12
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -12
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +20 -5
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +20 -5
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +29 -24
package/dist/rspack.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/domain/shared/src/esmHelpers.ts","../packages/domain/shared/src/index.ts","../packages/presentation/rspack/src/schemas.ts","../packages/presentation/rspack/src/index.ts"],"names":["path","formatIssuePath","getDirname","fs","rule"],"mappings":";;;;;;;;;;;;;;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AS,EAAC;AACpD,IAAA,MAAM,oBAAoB,QAAA,CAAS,IAAA;AAAA,MACjC,CAACI,UACC,OAAOA,KAAAA,KAAS,YAAYA,KAAAA,KAAS,IAAA,IAAQA,MAAK,2BAAA,KAAgC;AAAA,KACtF;AAEA,IAAA,IAAI,iBAAA,EAAmB;AAEvB,IAAA,MAAM,IAAA,GAAmB;AAAA,MACvB,2BAAA,EAA6B,IAAA;AAAA,MAC7B,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,OAAA,IAAW,YAAA;AAAA,MAC3B,OAAA,EAAS,IAAA,CAAK,IAAA,CAAK,OAAA,IAAW,cAAA;AAAA,MAC9B,GAAA,EAAK;AAAA,QACH;AAAA,UACE,MAAA,EAAQ,UAAA;AAAA,UACR,OAAA,EAAS;AAAA,YACP,IAAA,EAAM,cAAA;AAAA,YACN,WAAA,EAAa,IAAA,CAAK,IAAA,CAAK,WAAA,IAAe,KAAA;AAAA,YACtC,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACF;AAEA,IAAA,QAAA,CAAS,QAAQ,MAAA,GAAS;AAAA,MACxB,GAAI,QAAA,CAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAAA,MAChC,KAAA,EAAO,CAAC,IAAA,EAAM,GAAG,QAAQ;AAAA,KAC3B;AAAA,EACF;AACF;AAEO,SAAS,0BAAA,CACd,IAAA,GAA4B,EAAC,EACD;AAC5B,EAAA,OAAO,IAAI,2BAA2B,IAAI,CAAA;AAC5C","file":"rspack.mjs","sourcesContent":["/**\r\n * ESM-safe runtime helpers untuk monorepo.\r\n *\r\n * Menggantikan pola fragile seperti:\r\n * - `createRequire(import.meta.url)` → gunakan `createEsmRequire()`\r\n * - `__dirname` → gunakan `getDirname(import.meta.url)`\r\n * - `__filename` → gunakan `getFilename(import.meta.url)`\r\n *\r\n * Semua helper ini bekerja di ESM dan CJS.\r\n *\r\n * @module @tailwind-styled/shared/esmHelpers\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// Safe check for require availability - works in both CJS and ESM\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n // Test if require actually works\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodePath: any = null\r\nlet _nodeUrl: any = null\r\nlet _nodeFs: any = null\r\nlet _nodeCrypto: any = null\r\nlet _nodeOs: any = null\r\n\r\nfunction getNodePath() {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl() {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\")\r\n return _nodeUrl!\r\n}\r\nfunction getNodeFs() {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeCrypto() {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeOs() {\r\n if (isBrowser) throw new Error(\"node:os not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeOs) _nodeOs = nodeRequire.createRequire(import.meta.url)(\"node:os\")\r\n return _nodeOs!\r\n}\r\n\r\n/**\r\n * Buat `require()` function yang relative terhadap sebuah ESM module.\r\n *\r\n * @example\r\n * // Ganti: createRequire(import.meta.url)(\"some-pkg\")\r\n * const req = createEsmRequire(import.meta.url)\r\n * const mod = req(\"some-pkg\")\r\n */\r\nexport function createEsmRequire(importMetaUrl: string): NodeRequire {\r\n if (isBrowser) throw new Error(\"require not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n return nodeRequire.createRequire(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Dapat `__dirname` dari `import.meta.url`.\r\n *\r\n * @example\r\n * // Ganti: const __dirname = ...\r\n * const dir = getDirname(import.meta.url)\r\n */\r\nexport function getDirname(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n const nodePath = getNodePath()\r\n const nodeUrl = getNodeUrl()\r\n return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl))\r\n}\r\n\r\n/**\r\n * Dapat `__filename` dari `import.meta.url`.\r\n */\r\nexport function getFilename(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n return getNodeUrl().fileURLToPath(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Resolve path dari root monorepo (bukan CWD).\r\n * Berguna untuk scripts dan tools yang dipanggil dari lokasi berbeda.\r\n *\r\n * @example\r\n * const root = resolveFromRoot(\"packages/domain/shared/src\")\r\n */\r\nexport function resolveFromRoot(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\")\r\n\r\n const nodePath = getNodePath()\r\n const nodeFs = getNodeFs()\r\n \r\n let dir = getDirname(import.meta.url)\r\n for (let i = 0; i < 10; i++) {\r\n const pkgPath = nodePath.join(dir, \"package.json\")\r\n try {\r\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf-8\"))\r\n if (pkg.workspaces) {\r\n return nodePath.resolve(dir, ...segments)\r\n }\r\n } catch { /* intentionally silent */ }\r\n dir = nodePath.dirname(dir)\r\n }\r\n return nodePath.resolve(process.cwd(), ...segments)\r\n}\r\n\r\n/**\r\n * Require sebuah module dengan fallback ke null jika tidak tersedia.\r\n * Berguna untuk optional dependencies.\r\n *\r\n * @example\r\n * const oxc = tryRequire(\"oxc-parser\", import.meta.url)\r\n * if (!oxc) console.warn(\"oxc-parser not installed\")\r\n */\r\nexport function tryRequire<T = unknown>(\r\n moduleName: string,\r\n importMetaUrl: string\r\n): T | null {\r\n if (isBrowser) return null\r\n try {\r\n return createEsmRequire(importMetaUrl)(moduleName) as T\r\n } catch { /* intentionally silent — optional dep */ }\r\n return null\r\n}\r\n\r\n/**\r\n * Resolve .node binary path yang cross-platform dan ESM-safe.\r\n * Menggantikan pola `path.resolve(__dirname, \"../native.node\")`.\r\n */\r\nexport function resolveNativeNodePath(\r\n importMetaUrl: string,\r\n ...relativeSegments: string[]\r\n): string {\r\n if (isBrowser) return relativeSegments.join(\"/\")\r\n return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments)\r\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 // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/\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 candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.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\"","import { z } from \"zod\"\r\nimport { TwError } from \"@tailwind-styled/shared\"\r\n\r\nconst formatIssuePath = (path: readonly PropertyKey[]): string =>\r\n path.length > 0\r\n ? path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n : \"<root>\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = formatIssuePath(issue.path)\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n const details = formatIssues(parsed.error)\r\n throw new TwError(\r\n \"validation\",\r\n \"SCHEMA_VALIDATION_FAILED\",\r\n details ? `${label}: ${details}` : label,\r\n parsed.error\r\n )\r\n}\r\n\r\nexport const RspackPluginOptionsSchema = z.object({\r\n include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n addDataAttr: z.boolean().optional(),\r\n analyze: z.boolean().optional(),\r\n cssEntry: z.string().optional(),\r\n})\r\n\r\nexport type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>\r\n\r\nexport const parseRspackPluginOptions = (options: unknown) =>\r\n parseWithSchema(RspackPluginOptionsSchema, options ?? {}, \"rspack plugin options are invalid\")\r\n","/**\r\n * tailwind-styled-v4 - Rspack Plugin v5 (stable)\r\n *\r\n * Usage:\r\n * import { tailwindStyledRspackPlugin } from \"@tailwind-styled/rspack\"\r\n *\r\n * export default defineConfig({\r\n * plugins: [tailwindStyledRspackPlugin()],\r\n * })\r\n *\r\n * v5:\r\n * - Simplified API\r\n * - Mode always zero-runtime\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { getDirname as getEsmDirname } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseRspackPluginOptions } from \"./schemas\"\r\n\r\nfunction getDirname(): string {\r\n if (typeof __dirname !== \"undefined\") {\r\n return __dirname\r\n }\r\n if (typeof import.meta !== \"undefined\" && import.meta.url) {\r\n return getEsmDirname(import.meta.url)\r\n }\r\n return process.cwd()\r\n}\r\n\r\nfunction resolveLoaderPath(basename: string): string {\r\n const runtimeDir = getDirname()\r\n const preferredExtensions =\r\n typeof __dirname !== \"undefined\" && __dirname.length > 0 ? [\".cjs\", \".js\"] : [\".js\", \".cjs\"]\r\n\r\n for (const ext of preferredExtensions) {\r\n const candidate = path.resolve(runtimeDir, `${basename}${ext}`)\r\n if (fs.existsSync(candidate)) return candidate\r\n }\r\n\r\n return path.resolve(runtimeDir, `${basename}.js`)\r\n}\r\n\r\ninterface RspackRule {\r\n _tailwindStyledRspackMarker?: boolean\r\n test?: RegExp\r\n exclude?: RegExp\r\n use?: Array<{\r\n loader: string\r\n options: {\r\n mode: \"zero-runtime\"\r\n addDataAttr: boolean\r\n preserveImports: boolean\r\n }\r\n }>\r\n}\r\n\r\ninterface RspackCompiler {\r\n options: {\r\n mode?: string\r\n module?: {\r\n rules?: RspackRule[]\r\n }\r\n }\r\n}\r\n\r\nexport interface RspackPluginOptions {\r\n /** File patterns to include. Default: /\\.[jt]sx?$/ */\r\n include?: RegExp\r\n /** File patterns to exclude. Default: /node_modules/ */\r\n exclude?: RegExp\r\n /** Add data-tw debug attributes in dev. Default: true in dev */\r\n addDataAttr?: boolean\r\n /** Enable analyzer. Default: false */\r\n analyze?: boolean\r\n}\r\n\r\nexport class TailwindStyledRspackPlugin {\r\n private opts: RspackPluginOptions\r\n\r\n constructor(opts: RspackPluginOptions = {}) {\r\n this.opts = parseRspackPluginOptions(opts)\r\n }\r\n\r\n apply(compiler: RspackCompiler): void {\r\n const isDev = compiler.options.mode !== \"production\"\r\n const loaderPath = resolveLoaderPath(\"loader\")\r\n const existing = compiler.options.module?.rules ?? []\r\n const alreadyRegistered = existing.some(\r\n (rule) =>\r\n typeof rule === \"object\" && rule !== null && rule._tailwindStyledRspackMarker === true\r\n )\r\n\r\n if (alreadyRegistered) return\r\n\r\n const rule: RspackRule = {\r\n _tailwindStyledRspackMarker: true,\r\n test: this.opts.include ?? /\\.[jt]sx?$/,\r\n exclude: this.opts.exclude ?? /node_modules/,\r\n use: [\r\n {\r\n loader: loaderPath,\r\n options: {\r\n mode: \"zero-runtime\",\r\n addDataAttr: this.opts.addDataAttr ?? isDev,\r\n preserveImports: true,\r\n },\r\n },\r\n ],\r\n }\r\n\r\n compiler.options.module = {\r\n ...(compiler.options.module ?? {}),\r\n rules: [rule, ...existing],\r\n }\r\n }\r\n}\r\n\r\nexport function tailwindStyledRspackPlugin(\r\n opts: RspackPluginOptions = {}\r\n): TailwindStyledRspackPlugin {\r\n return new TailwindStyledRspackPlugin(opts)\r\n}\r\n\r\nexport default tailwindStyledRspackPlugin\r\n\r\nexport {\r\n parseRspackPluginOptions,\r\n type RspackPluginOptionsInput,\r\n RspackPluginOptionsSchema,\r\n} from \"./schemas\"\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../packages/domain/shared/src/esmHelpers.ts","../packages/domain/shared/src/index.ts","../packages/presentation/rspack/src/schemas.ts","../packages/presentation/rspack/src/index.ts"],"names":["path","formatIssuePath","getDirname","fs","rule"],"mappings":";;;;;;;;;;;;;;;;AAaA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,QAAA,KAAa,WAAA;AAGvE,IAAI,aAAA,GAAqB,IAAA;AACzB,SAAS,gBAAA,GAAmB;AAC1B,EAAA,IAAI,WAAW,OAAO,IAAA;AACtB,EAAA,IAAI,aAAA,KAAkB,MAAM,OAAO,aAAA;AACnC,EAAA,IAAI;AAEF,IAAA,MAAM,OAAO,OAAO,SAAA,KAAY,UAAA,GAAa,SAAA,CAAQ,QAAa,CAAA,GAAI,IAAA;AACtE,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAI,SAAA,GAAiB,IAAA;AACrB,IAAI,QAAA,GAAgB,IAAA;AAKpB,SAAS,WAAA,GAAc;AACrB,EAAA,IAAI,SAAA,EAAW,MAAM,IAAI,KAAA,CAAM,oCAAoC,CAAA;AACnE,EAAA,MAAM,cAAc,gBAAA,EAAiB;AACrC,EAAA,IAAI,CAAC,W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AAQ,MAAA,IAAU,EAAC;AAAA,MAChC,KAAA,EAAO,CAAC,IAAA,EAAM,GAAG,QAAQ;AAAA,KAC3B;AAAA,EACF;AACF;AAEO,SAAS,0BAAA,CACd,IAAA,GAA4B,EAAC,EACD;AAC5B,EAAA,OAAO,IAAI,2BAA2B,IAAI,CAAA;AAC5C","file":"rspack.mjs","sourcesContent":["/**\r\n * ESM-safe runtime helpers untuk monorepo.\r\n *\r\n * Menggantikan pola fragile seperti:\r\n * - `createRequire(import.meta.url)` → gunakan `createEsmRequire()`\r\n * - `__dirname` → gunakan `getDirname(import.meta.url)`\r\n * - `__filename` → gunakan `getFilename(import.meta.url)`\r\n *\r\n * Semua helper ini bekerja di ESM dan CJS.\r\n *\r\n * @module @tailwind-styled/shared/esmHelpers\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// Safe check for require availability - works in both CJS and ESM\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n // Test if require actually works\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodePath: any = null\r\nlet _nodeUrl: any = null\r\nlet _nodeFs: any = null\r\nlet _nodeCrypto: any = null\r\nlet _nodeOs: any = null\r\n\r\nfunction getNodePath() {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl() {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\")\r\n return _nodeUrl!\r\n}\r\nfunction getNodeFs() {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeCrypto() {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeOs() {\r\n if (isBrowser) throw new Error(\"node:os not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeOs) _nodeOs = nodeRequire.createRequire(import.meta.url)(\"node:os\")\r\n return _nodeOs!\r\n}\r\n\r\n/**\r\n * Buat `require()` function yang relative terhadap sebuah ESM module.\r\n *\r\n * @example\r\n * // Ganti: createRequire(import.meta.url)(\"some-pkg\")\r\n * const req = createEsmRequire(import.meta.url)\r\n * const mod = req(\"some-pkg\")\r\n */\r\nexport function createEsmRequire(importMetaUrl: string): NodeRequire {\r\n if (isBrowser) throw new Error(\"require not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n return nodeRequire.createRequire(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Dapat `__dirname` dari `import.meta.url`.\r\n *\r\n * @example\r\n * // Ganti: const __dirname = ...\r\n * const dir = getDirname(import.meta.url)\r\n */\r\nexport function getDirname(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n const nodePath = getNodePath()\r\n const nodeUrl = getNodeUrl()\r\n return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl))\r\n}\r\n\r\n/**\r\n * Dapat `__filename` dari `import.meta.url`.\r\n */\r\nexport function getFilename(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n return getNodeUrl().fileURLToPath(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Resolve path dari root monorepo (bukan CWD).\r\n * Berguna untuk scripts dan tools yang dipanggil dari lokasi berbeda.\r\n *\r\n * @example\r\n * const root = resolveFromRoot(\"packages/domain/shared/src\")\r\n */\r\nexport function resolveFromRoot(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\")\r\n\r\n const nodePath = getNodePath()\r\n const nodeFs = getNodeFs()\r\n \r\n let dir = getDirname(import.meta.url)\r\n for (let i = 0; i < 10; i++) {\r\n const pkgPath = nodePath.join(dir, \"package.json\")\r\n try {\r\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf-8\"))\r\n if (pkg.workspaces) {\r\n return nodePath.resolve(dir, ...segments)\r\n }\r\n } catch { /* intentionally silent */ }\r\n dir = nodePath.dirname(dir)\r\n }\r\n return nodePath.resolve(process.cwd(), ...segments)\r\n}\r\n\r\n/**\r\n * Require sebuah module dengan fallback ke null jika tidak tersedia.\r\n * Berguna untuk optional dependencies.\r\n *\r\n * @example\r\n * const oxc = tryRequire(\"oxc-parser\", import.meta.url)\r\n * if (!oxc) console.warn(\"oxc-parser not installed\")\r\n */\r\nexport function tryRequire<T = unknown>(\r\n moduleName: string,\r\n importMetaUrl: string\r\n): T | null {\r\n if (isBrowser) return null\r\n try {\r\n return createEsmRequire(importMetaUrl)(moduleName) as T\r\n } catch { /* intentionally silent — optional dep */ }\r\n return null\r\n}\r\n\r\n/**\r\n * Resolve .node binary path yang cross-platform dan ESM-safe.\r\n * Menggantikan pola `path.resolve(__dirname, \"../native.node\")`.\r\n */\r\nexport function resolveNativeNodePath(\r\n importMetaUrl: string,\r\n ...relativeSegments: string[]\r\n): string {\r\n if (isBrowser) return relativeSegments.join(\"/\")\r\n return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments)\r\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\"","import { z } from \"zod\"\r\nimport { TwError } from \"@tailwind-styled/shared\"\r\n\r\nconst formatIssuePath = (path: readonly PropertyKey[]): string =>\r\n path.length > 0\r\n ? path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n : \"<root>\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = formatIssuePath(issue.path)\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n const details = formatIssues(parsed.error)\r\n throw new TwError(\r\n \"validation\",\r\n \"SCHEMA_VALIDATION_FAILED\",\r\n details ? `${label}: ${details}` : label,\r\n parsed.error\r\n )\r\n}\r\n\r\nexport const RspackPluginOptionsSchema = z.object({\r\n include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n addDataAttr: z.boolean().optional(),\r\n analyze: z.boolean().optional(),\r\n cssEntry: z.string().optional(),\r\n})\r\n\r\nexport type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>\r\n\r\nexport const parseRspackPluginOptions = (options: unknown) =>\r\n parseWithSchema(RspackPluginOptionsSchema, options ?? {}, \"rspack plugin options are invalid\")\r\n","/**\r\n * tailwind-styled-v4 - Rspack Plugin v5 (stable)\r\n *\r\n * Usage:\r\n * import { tailwindStyledRspackPlugin } from \"@tailwind-styled/rspack\"\r\n *\r\n * export default defineConfig({\r\n * plugins: [tailwindStyledRspackPlugin()],\r\n * })\r\n *\r\n * v5:\r\n * - Simplified API\r\n * - Mode always zero-runtime\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { getDirname as getEsmDirname } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseRspackPluginOptions } from \"./schemas\"\r\n\r\nfunction getDirname(): string {\r\n if (typeof __dirname !== \"undefined\") {\r\n return __dirname\r\n }\r\n if (typeof import.meta !== \"undefined\" && import.meta.url) {\r\n return getEsmDirname(import.meta.url)\r\n }\r\n return process.cwd()\r\n}\r\n\r\nfunction resolveLoaderPath(basename: string): string {\r\n const runtimeDir = getDirname()\r\n const preferredExtensions =\r\n typeof __dirname !== \"undefined\" && __dirname.length > 0 ? [\".cjs\", \".js\"] : [\".js\", \".cjs\"]\r\n\r\n for (const ext of preferredExtensions) {\r\n const candidate = path.resolve(runtimeDir, `${basename}${ext}`)\r\n if (fs.existsSync(candidate)) return candidate\r\n }\r\n\r\n return path.resolve(runtimeDir, `${basename}.js`)\r\n}\r\n\r\ninterface RspackRule {\r\n _tailwindStyledRspackMarker?: boolean\r\n test?: RegExp\r\n exclude?: RegExp\r\n use?: Array<{\r\n loader: string\r\n options: {\r\n mode: \"zero-runtime\"\r\n addDataAttr: boolean\r\n preserveImports: boolean\r\n }\r\n }>\r\n}\r\n\r\ninterface RspackCompiler {\r\n options: {\r\n mode?: string\r\n module?: {\r\n rules?: RspackRule[]\r\n }\r\n }\r\n}\r\n\r\nexport interface RspackPluginOptions {\r\n /** File patterns to include. Default: /\\.[jt]sx?$/ */\r\n include?: RegExp\r\n /** File patterns to exclude. Default: /node_modules/ */\r\n exclude?: RegExp\r\n /** Add data-tw debug attributes in dev. Default: true in dev */\r\n addDataAttr?: boolean\r\n /** Enable analyzer. Default: false */\r\n analyze?: boolean\r\n}\r\n\r\nexport class TailwindStyledRspackPlugin {\r\n private opts: RspackPluginOptions\r\n\r\n constructor(opts: RspackPluginOptions = {}) {\r\n this.opts = parseRspackPluginOptions(opts)\r\n }\r\n\r\n apply(compiler: RspackCompiler): void {\r\n const isDev = compiler.options.mode !== \"production\"\r\n const loaderPath = resolveLoaderPath(\"loader\")\r\n const existing = compiler.options.module?.rules ?? []\r\n const alreadyRegistered = existing.some(\r\n (rule) =>\r\n typeof rule === \"object\" && rule !== null && rule._tailwindStyledRspackMarker === true\r\n )\r\n\r\n if (alreadyRegistered) return\r\n\r\n const rule: RspackRule = {\r\n _tailwindStyledRspackMarker: true,\r\n test: this.opts.include ?? /\\.[jt]sx?$/,\r\n exclude: this.opts.exclude ?? /node_modules/,\r\n use: [\r\n {\r\n loader: loaderPath,\r\n options: {\r\n mode: \"zero-runtime\",\r\n addDataAttr: this.opts.addDataAttr ?? isDev,\r\n preserveImports: true,\r\n },\r\n },\r\n ],\r\n }\r\n\r\n compiler.options.module = {\r\n ...(compiler.options.module ?? {}),\r\n rules: [rule, ...existing],\r\n }\r\n }\r\n}\r\n\r\nexport function tailwindStyledRspackPlugin(\r\n opts: RspackPluginOptions = {}\r\n): TailwindStyledRspackPlugin {\r\n return new TailwindStyledRspackPlugin(opts)\r\n}\r\n\r\nexport default tailwindStyledRspackPlugin\r\n\r\nexport {\r\n parseRspackPluginOptions,\r\n type RspackPluginOptionsInput,\r\n RspackPluginOptionsSchema,\r\n} from \"./schemas\"\r\n"]}
|
package/dist/scanner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('crypto');
|
|
4
|
-
var
|
|
4
|
+
var fs4 = require('fs');
|
|
5
5
|
var path5 = require('path');
|
|
6
6
|
var url = require('url');
|
|
7
7
|
var module$1 = require('module');
|
|
@@ -12,7 +12,7 @@ var zod = require('zod');
|
|
|
12
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var fs4__default = /*#__PURE__*/_interopDefault(fs4);
|
|
16
16
|
var path5__default = /*#__PURE__*/_interopDefault(path5);
|
|
17
17
|
|
|
18
18
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
@@ -77,7 +77,7 @@ function loadNativeBinding(options) {
|
|
|
77
77
|
for (const candidate of candidates) {
|
|
78
78
|
const candidatePath = path5__default.default.resolve(runtimeDir, candidate);
|
|
79
79
|
try {
|
|
80
|
-
if (!
|
|
80
|
+
if (!fs4__default.default.existsSync(candidatePath) && !fs4__default.default.existsSync(candidatePath + ".node")) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -109,9 +109,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
if (!includeDefaultCandidates) return candidates;
|
|
112
|
-
if (
|
|
112
|
+
if (fs4__default.default.existsSync(runtimeDir)) {
|
|
113
113
|
try {
|
|
114
|
-
for (const entry of
|
|
114
|
+
for (const entry of fs4__default.default.readdirSync(runtimeDir)) {
|
|
115
115
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
116
116
|
}
|
|
117
117
|
} catch {
|
|
@@ -122,11 +122,13 @@ function resolveNativeBindingCandidates(options) {
|
|
|
122
122
|
for (const bin of BINARY_NAMES) {
|
|
123
123
|
candidates.push(path5__default.default.resolve(runtimeDir, `${bin}.node`));
|
|
124
124
|
candidates.push(path5__default.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
125
|
+
candidates.push(path5__default.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
126
|
+
candidates.push(path5__default.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
127
|
+
candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
128
|
+
candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
125
129
|
candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
126
130
|
candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
127
131
|
candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
128
|
-
candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
129
|
-
candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
130
132
|
}
|
|
131
133
|
return Array.from(new Set(candidates));
|
|
132
134
|
}
|
|
@@ -201,8 +203,10 @@ __export(native_bridge_exports, {
|
|
|
201
203
|
extractClassesNative: () => extractClassesNative,
|
|
202
204
|
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
203
205
|
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
206
|
+
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
204
207
|
hashContentNative: () => hashContentNative,
|
|
205
208
|
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
209
|
+
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
206
210
|
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
207
211
|
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
208
212
|
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
@@ -212,7 +216,9 @@ __export(native_bridge_exports, {
|
|
|
212
216
|
scanCacheStats: () => scanCacheStats,
|
|
213
217
|
scanFileNative: () => scanFileNative,
|
|
214
218
|
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
215
|
-
scanWorkspaceNative: () => scanWorkspaceNative
|
|
219
|
+
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
220
|
+
startWatchNative: () => startWatchNative,
|
|
221
|
+
stopWatchNative: () => stopWatchNative
|
|
216
222
|
});
|
|
217
223
|
function getDirname() {
|
|
218
224
|
if (typeof __dirname !== "undefined") {
|
|
@@ -389,6 +395,41 @@ function computeCacheStatsNative(filesClasses, sizes, top) {
|
|
|
389
395
|
if (!binding.computeCacheStats) return null;
|
|
390
396
|
return binding.computeCacheStats(filesClasses, sizes, top ?? null);
|
|
391
397
|
}
|
|
398
|
+
function startWatchNative(rootDir) {
|
|
399
|
+
try {
|
|
400
|
+
const binding = scannerGetBinding();
|
|
401
|
+
if (!binding.startWatch) return null;
|
|
402
|
+
return binding.startWatch(rootDir);
|
|
403
|
+
} catch {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function pollWatchEventsNative(handleId) {
|
|
408
|
+
try {
|
|
409
|
+
const binding = scannerGetBinding();
|
|
410
|
+
if (!binding.pollWatchEvents) return [];
|
|
411
|
+
return binding.pollWatchEvents(handleId);
|
|
412
|
+
} catch {
|
|
413
|
+
return [];
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function stopWatchNative(handleId) {
|
|
417
|
+
try {
|
|
418
|
+
const binding = scannerGetBinding();
|
|
419
|
+
if (!binding.stopWatch) return false;
|
|
420
|
+
return binding.stopWatch(handleId);
|
|
421
|
+
} catch {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function hasNativeWatchBinding() {
|
|
426
|
+
try {
|
|
427
|
+
const binding = scannerGetBinding();
|
|
428
|
+
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
429
|
+
} catch {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
392
433
|
var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
393
434
|
var init_native_bridge = __esm({
|
|
394
435
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
@@ -484,6 +525,7 @@ function defaultCachePath(rootDir, cacheDir) {
|
|
|
484
525
|
}
|
|
485
526
|
function readCache(rootDir, cacheDir) {
|
|
486
527
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
528
|
+
fs4__default.default.mkdirSync(path5__default.default.dirname(cachePath), { recursive: true });
|
|
487
529
|
const result = cacheReadNative(cachePath);
|
|
488
530
|
if (!result) return [];
|
|
489
531
|
return result.entries.map((e) => ({
|
|
@@ -498,6 +540,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
498
540
|
}
|
|
499
541
|
function writeCache(rootDir, entries, cacheDir) {
|
|
500
542
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
543
|
+
fs4__default.default.mkdirSync(path5__default.default.dirname(cachePath), { recursive: true });
|
|
501
544
|
const success = cacheWriteNative(cachePath, entries);
|
|
502
545
|
if (!success) {
|
|
503
546
|
throw new Error(
|
|
@@ -529,7 +572,7 @@ function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
|
529
572
|
function walk(dir) {
|
|
530
573
|
let entries;
|
|
531
574
|
try {
|
|
532
|
-
entries =
|
|
575
|
+
entries = fs4__default.default.readdirSync(dir, { withFileTypes: true });
|
|
533
576
|
} catch {
|
|
534
577
|
return;
|
|
535
578
|
}
|
|
@@ -701,21 +744,31 @@ var createNativeParserLoader = () => {
|
|
|
701
744
|
if (_state.binding !== void 0) return _state.binding;
|
|
702
745
|
const runtimeDir = getRuntimeDir();
|
|
703
746
|
const req = module$1.createRequire(path5__default.default.join(runtimeDir, "noop.cjs"));
|
|
747
|
+
const _platform = process.platform;
|
|
748
|
+
const _arch = process.arch;
|
|
749
|
+
const _platformArch = `${_platform}-${_arch}`;
|
|
750
|
+
const _platformArchGnu = _platformArch === "linux-x64" ? "linux-x64-gnu" : _platformArch === "linux-arm64" ? "linux-arm64-gnu" : _platformArch;
|
|
704
751
|
const candidates = [
|
|
705
752
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
706
753
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
707
754
|
path5__default.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
708
|
-
path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
709
|
-
path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
710
|
-
// runtimeDir = dist/ → naik
|
|
755
|
+
path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
756
|
+
path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
757
|
+
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
758
|
+
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
759
|
+
path5__default.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
760
|
+
path5__default.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
761
|
+
path5__default.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
762
|
+
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
711
763
|
path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
712
|
-
path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${
|
|
764
|
+
path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
713
765
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
714
766
|
path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
715
|
-
path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${
|
|
767
|
+
path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
716
768
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
717
769
|
path5__default.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
718
770
|
path5__default.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
771
|
+
path5__default.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
719
772
|
path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
720
773
|
path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
721
774
|
path5__default.default.resolve(
|
|
@@ -730,7 +783,7 @@ var createNativeParserLoader = () => {
|
|
|
730
783
|
)
|
|
731
784
|
];
|
|
732
785
|
for (const fullPath of candidates) {
|
|
733
|
-
if (!
|
|
786
|
+
if (!fs4__default.default.existsSync(fullPath)) continue;
|
|
734
787
|
try {
|
|
735
788
|
const required = req(fullPath);
|
|
736
789
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -776,7 +829,7 @@ function resolveScannerWorkerModulePath() {
|
|
|
776
829
|
path5__default.default.resolve(runtimeDir, "worker.ts")
|
|
777
830
|
];
|
|
778
831
|
for (const candidate of candidates) {
|
|
779
|
-
if (
|
|
832
|
+
if (fs4__default.default.existsSync(candidate)) return candidate;
|
|
780
833
|
}
|
|
781
834
|
return null;
|
|
782
835
|
}
|
|
@@ -833,7 +886,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
833
886
|
if (!currentDir) continue;
|
|
834
887
|
const entries = (() => {
|
|
835
888
|
try {
|
|
836
|
-
return
|
|
889
|
+
return fs4__default.default.readdirSync(currentDir, { withFileTypes: true });
|
|
837
890
|
} catch {
|
|
838
891
|
return [];
|
|
839
892
|
}
|
|
@@ -932,7 +985,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
932
985
|
for (const filePath of candidates) {
|
|
933
986
|
const stat = (() => {
|
|
934
987
|
try {
|
|
935
|
-
return
|
|
988
|
+
return fs4__default.default.statSync(filePath);
|
|
936
989
|
} catch {
|
|
937
990
|
return null;
|
|
938
991
|
}
|
|
@@ -958,7 +1011,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
958
1011
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
959
1012
|
const content = (() => {
|
|
960
1013
|
try {
|
|
961
|
-
return
|
|
1014
|
+
return fs4__default.default.readFileSync(filePath, "utf8");
|
|
962
1015
|
} catch {
|
|
963
1016
|
return null;
|
|
964
1017
|
}
|