{"version":3,"sources":["../src/index.ts","../src/middleware.ts","../src/mockFileUtils.ts","../src/utils.ts","../src/inspector.ts","../src/mockBundler.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\n\nimport { automock as createAutomockPlugin } from './middleware'\nimport { bundleMockFiles, writeMockBundle } from './mockBundler'\nimport { buildMockIndex } from './mockFileUtils'\nimport type { Plugin } from 'vite'\nimport type { AutomockPluginOptions } from './types'\nimport type { MockBundle } from './mockBundler'\n\nexport type { AutomockPluginOptions, InspectorOptions } from './types'\nexport { saveMockData, buildMockIndex, parseMockModule, writeMockFile } from './mockFileUtils'\nexport type { MockBundle, MockBundleData } from './mockBundler'\nexport { bundleMockFiles, writeMockBundle } from './mockBundler'\n\n// Client interceptor exports\nexport {\n  createMockInterceptor,\n  initMockInterceptor,\n  initMockInterceptorForPureHttp,\n  setMockEnabled,\n  isMockEnabled,\n  loadMockData,\n  registerHttpInstance\n} from './client'\nexport type { MockInterceptorOptions, MockBundleData as ClientMockBundleData } from './client/interceptor'\n\nexport interface AutomockWithBundleOptions extends AutomockPluginOptions {\n  bundleMockData?: boolean\n  bundleOutputPath?: string\n}\n\nfunction resolveProductionMockEnabled(\n  productionMock: AutomockPluginOptions['productionMock'],\n  mode = process.env.NODE_ENV\n): boolean {\n  if (productionMock === true) return true\n  if (productionMock === 'auto') return mode !== 'production'\n  return false\n}\n\nexport function automock(options: AutomockWithBundleOptions = {}): Plugin {\n  const {\n    bundleMockData = true,\n    bundleOutputPath = 'public/mock-data.json',\n    ...pluginOptions\n  } = options\n\n  const basePlugin = createAutomockPlugin(pluginOptions)\n\n  let cachedBundle: MockBundle | null = null\n  let productionMockEnabled = resolveProductionMockEnabled(pluginOptions.productionMock)\n\n  const resolveBundleOutputPath = () =>\n    path.isAbsolute(bundleOutputPath)\n      ? bundleOutputPath\n      : path.join(process.cwd(), bundleOutputPath)\n\n  const ensureBundleExists = () => {\n    const outputPath = resolveBundleOutputPath()\n    if (!fs.existsSync(outputPath) && cachedBundle) {\n      console.log('[automock] Re-writing mock bundle...')\n      writeMockBundle(cachedBundle, outputPath)\n    }\n  }\n\n  return {\n    ...basePlugin,\n    name: 'vite-plugin-automock-with-bundle',\n    config(userConfig, env) {\n      if (typeof basePlugin.config === 'function') {\n        basePlugin.config.call(this, userConfig, env)\n      }\n      // Inject compile-time constant for client interceptor\n      productionMockEnabled = resolveProductionMockEnabled(\n        pluginOptions.productionMock,\n        env.mode\n      )\n      return {\n        define: {\n          __AUTOMOCK_ENABLED__: JSON.stringify(productionMockEnabled),\n        },\n      }\n    },\n    buildEnd: async () => {\n      if (bundleMockData && productionMockEnabled) {\n        try {\n          const mockDir = pluginOptions.mockDir || path.join(process.cwd(), 'mock')\n\n          if (!fs.existsSync(mockDir)) {\n            console.log('[automock] Mock directory not found, skipping bundle generation')\n            console.log('[automock] Using existing mock-data.json if present')\n            return\n          }\n\n          const mockFileMap = await buildMockIndex(mockDir)\n          if (mockFileMap.size === 0) {\n            console.log('[automock] No mock files found, skipping bundle generation')\n            return\n          }\n\n          cachedBundle = await bundleMockFiles({ mockDir })\n\n          const outputPath = resolveBundleOutputPath()\n          writeMockBundle(cachedBundle, outputPath)\n          console.log(`[automock] Mock bundle written to: ${outputPath}`)\n        } catch (error) {\n          console.error('[automock] Failed to bundle mock data:', error)\n        }\n      }\n    },\n    writeBundle: ensureBundleExists,\n    closeBundle: ensureBundleExists,\n  }\n}\n","import chokidar from \"chokidar\";\nimport debounce from \"lodash.debounce\";\nimport path from \"path\";\nimport fs from \"fs-extra\";\nimport http from \"http\";\nimport https from \"https\";\nimport type { AddressInfo } from \"net\";\n\nimport { buildMockIndex, saveMockData } from \"./mockFileUtils\";\nimport { createInspectorHandler, normalizeInspectorConfig } from \"./inspector\";\nimport {\n  resolveAbsolutePath,\n  getServerAddress,\n  sendError,\n} from \"./utils\";\n\nimport type { Plugin } from \"vite\";\nimport type { IncomingMessage, ServerResponse } from \"http\";\nimport type { FSWatcher } from \"chokidar\";\nimport type { AutomockPluginOptions } from \"./types\";\n\nfunction serveMockResponse(\n  res: ServerResponse,\n  mockFilePath: string,\n  mockResult: { data?: unknown; delay?: number; status?: number },\n): void {\n  const { data, delay = 0, status = 200 } = mockResult;\n\n  setTimeout(() => {\n    const isBinaryMock = data && typeof data === \"object\" && (data as Record<string, unknown>).__binaryFile;\n\n    if (isBinaryMock) {\n      const binaryData = data as Record<string, unknown>;\n      const binaryFilePath = mockFilePath.replace(\n        /\\.js$/,\n        \".\" + binaryData.__binaryFile,\n      );\n\n      if (!fs.existsSync(binaryFilePath)) {\n        console.error(\n          `[automock] Binary mock file not found: ${binaryFilePath}`,\n        );\n        sendError(res, \"Binary mock file not found\", 404);\n        return;\n      }\n\n      try {\n        const fileData = fs.readFileSync(binaryFilePath);\n        const contentType =\n          (binaryData.__contentType as string) || \"application/octet-stream\";\n        res.setHeader(\"Content-Type\", contentType);\n        res.setHeader(\"Content-Length\", fileData.length);\n        res.setHeader(\"X-Mock-Response\", \"true\");\n        res.setHeader(\"X-Mock-Source\", \"vite-plugin-automock\");\n        res.setHeader(\"X-Mock-Binary-File\", \"true\");\n        res.statusCode = status;\n        res.end(fileData);\n      } catch (error) {\n        console.error(\"[automock] Failed to read binary mock file:\", error);\n        sendError(res, \"Failed to read binary mock file\");\n      }\n    } else {\n      res.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n      res.setHeader(\"X-Mock-Response\", \"true\");\n      res.setHeader(\"X-Mock-Source\", \"vite-plugin-automock\");\n      res.statusCode = status;\n      res.end(typeof data === \"string\" ? data : JSON.stringify(data));\n    }\n  }, delay);\n}\n\nfunction matchesApiPrefix(pathname: string, apiPrefix: string): boolean {\n  if (!apiPrefix || apiPrefix === \"/\") return true;\n  const normalizedPrefix =\n    apiPrefix.endsWith(\"/\") && apiPrefix !== \"/\"\n      ? apiPrefix.slice(0, -1)\n      : apiPrefix;\n\n  return pathname === normalizedPrefix || pathname.startsWith(`${normalizedPrefix}/`);\n}\n\nfunction proxyAndCapture(\n  req: IncomingMessage,\n  res: ServerResponse,\n  options: {\n    proxyBaseUrl: string;\n    pathRewrite: (p: string) => string;\n    shouldSave: boolean;\n    method: string;\n    pathname: string;\n    mockDir: string;\n    onMockSaved: () => void;\n  },\n): void {\n  const { proxyBaseUrl, pathRewrite, shouldSave, method, pathname, mockDir, onMockSaved } = options;\n  const targetUrl = proxyBaseUrl + pathRewrite(req.url || \"\");\n  const client = targetUrl.startsWith(\"https\") ? https : http;\n\n  function sendProxyRequest(body?: string) {\n    const targetUrlObj = new URL(proxyBaseUrl);\n    const proxyOptions = {\n      method: req.method,\n      headers: {\n        ...req.headers,\n        host: targetUrlObj.host,\n      },\n      rejectUnauthorized: false,\n    };\n\n    const proxyReq = client.request(targetUrl, proxyOptions, (proxyRes) => {\n      const contentType = proxyRes.headers[\"content-type\"] || \"\";\n      const isJson = contentType.includes(\"application/json\");\n\n      // Non-JSON response (file download, stream, etc.) → pipe directly\n      if (!isJson) {\n        res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);\n        proxyRes.pipe(res);\n        return;\n      }\n\n      // JSON response → buffer, save mock, then respond\n      const chunks: Buffer[] = [];\n\n      proxyRes.on(\"data\", (chunk) => chunks.push(chunk));\n      proxyRes.on(\"end\", async () => {\n        try {\n          const responseData = Buffer.concat(chunks);\n\n          if (shouldSave) {\n            try {\n              console.log(\n                `[automock] Capturing mock: ${req.url!} -> ${pathname}`,\n              );\n              const savedFilePath = await saveMockData(\n                req.url!,\n                method,\n                responseData,\n                mockDir,\n                proxyRes.statusCode,\n                contentType,\n              );\n              if (savedFilePath) {\n                console.log(`[automock] Mock saved: ${pathname}`);\n                onMockSaved();\n              } else {\n                console.log(\n                  `[automock] Mock file already exists, skipped: ${pathname}`,\n                );\n              }\n            } catch (saveError) {\n              console.error(\"[automock] Failed to save mock:\", saveError);\n            }\n          }\n\n          res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);\n          res.end(responseData);\n        } catch (error) {\n          console.error(\"[automock] Failed to process response:\", error);\n          res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);\n          res.end(Buffer.concat(chunks));\n        }\n      });\n    });\n\n    proxyReq.on(\"error\", (err) => {\n      console.error(\"[automock] Proxy request failed:\", err);\n      sendError(res, err.message);\n    });\n\n    if (\n      body &&\n      (req.method === \"POST\" || req.method === \"PUT\" || req.method === \"PATCH\")\n    ) {\n      proxyReq.write(body);\n    }\n\n    proxyReq.end();\n  }\n\n  if (\n    req.method === \"POST\" ||\n    req.method === \"PUT\" ||\n    req.method === \"PATCH\"\n  ) {\n    let bodyStr = \"\";\n    req.on(\"data\", (chunk) => (bodyStr += chunk.toString()));\n    req.on(\"end\", () => sendProxyRequest(bodyStr));\n  } else {\n    sendProxyRequest();\n  }\n}\n\nfunction printServerUrls(\n  server: { httpServer?: { address(): AddressInfo | string | null; once(event: string, cb: () => void): void } | null; config: { server: { https?: unknown } } },\n  urls: Array<{ path: string; label: string; color: string; delay: number }>,\n): void {\n  server.httpServer?.once(\"listening\", () => {\n    const address = server.httpServer?.address();\n    if (!address || typeof address !== \"object\") return;\n\n    const { protocol, host, port } = getServerAddress(\n      address,\n      !!server.config.server.https,\n    );\n\n    for (const { path: urlPath, label, color, delay } of urls) {\n      setTimeout(() => {\n        const fullUrl = `${protocol}://${host}:${port}${urlPath}`;\n        console.log(`  ➜  ${color}${label}\\x1b[0m: \\x1b[1m${fullUrl}\\x1b[0m`);\n      }, delay);\n    }\n  });\n}\n\nexport function automock(options: AutomockPluginOptions): Plugin {\n  const {\n    mockDir: configMockDir = path.join(process.cwd(), \"mock\"),\n    apiPrefix = \"/api\",\n    pathRewrite = (p) => p,\n    proxyBaseUrl,\n    inspector = false,\n    enabled = true,\n    proxy: proxyEnabled = true,\n    capture: captureEnabled = true,\n  } = options;\n\n  const mockDir = resolveAbsolutePath(configMockDir);\n\n  if (!fs.existsSync(mockDir)) {\n    try {\n      fs.ensureDirSync(mockDir);\n      console.log(`[automock] Mock directory created: ${mockDir}`);\n    } catch (error) {\n      console.error(`[automock] Failed to create mock directory: ${mockDir}`, error);\n    }\n  }\n\n  let watcher: FSWatcher | undefined;\n\n  return {\n    name: \"vite-plugin-automock\",\n    config(userConfig) {\n      if (proxyBaseUrl && userConfig.server?.proxy) {\n        const proxyConfig = userConfig.server.proxy;\n        const hasConflictingPrefix =\n          typeof proxyConfig === \"object\" && apiPrefix in proxyConfig;\n\n        if (hasConflictingPrefix) {\n          console.warn(\n            `\\n⚠️  [automock] WARNING: You have both Vite's server.proxy[\"${apiPrefix}\"] and automock's proxyBaseUrl configured.`,\n          );\n          console.warn(\n            `   This may cause request conflicts. Remove the \"${apiPrefix}\" entry from vite.config.ts server.proxy to avoid issues.`,\n          );\n          console.warn(\n            `   Automock will handle all ${apiPrefix} requests when proxyBaseUrl is set.\\n`,\n          );\n        }\n      }\n    },\n    async configureServer(server) {\n      let mockFileMap = await buildMockIndex(mockDir);\n      console.log(`[automock] Loaded ${mockFileMap.size} mock files`);\n\n      const rebuildMockFileMap = debounce(async () => {\n        mockFileMap = await buildMockIndex(mockDir);\n      }, 200);\n\n      watcher = chokidar.watch(mockDir, {\n        ignoreInitial: true,\n        persistent: true,\n        depth: 30,\n      });\n      watcher.on(\"add\", () => rebuildMockFileMap());\n      watcher.on(\"unlink\", () => rebuildMockFileMap());\n\n      server.httpServer?.on(\"close\", () => watcher?.close());\n\n      const inspectorHandler = createInspectorHandler({\n        inspector,\n        apiPrefix,\n        mockDir,\n        getMockFileMap: () => mockFileMap,\n      });\n\n      const urlsToPrint: Array<{ path: string; label: string; color: string; delay: number }> = [\n        { path: apiPrefix, label: \"Mock API\", color: \"\\x1b[32m\", delay: 100 },\n      ];\n\n      if (inspector) {\n        const inspectorConfig = normalizeInspectorConfig(inspector);\n        urlsToPrint.push({\n          path: inspectorConfig.route,\n          label: \"Mock Inspector\",\n          color: \"\\x1b[95m\",\n          delay: 150,\n        });\n      }\n\n      printServerUrls(server, urlsToPrint);\n\n      async function tryLoadMock(key: string): Promise<{ absolutePath: string; mockResult: Record<string, unknown> } | null> {\n        const mockFilePath = mockFileMap.get(key);\n        if (!mockFilePath) return null;\n\n        const absolutePath = resolveAbsolutePath(mockFilePath);\n        if (!fs.existsSync(absolutePath)) return null;\n\n        const { default: mockModule } = await import(\n          `${absolutePath}?t=${Date.now()}`\n        );\n        const exportedConfig =\n          typeof mockModule === \"function\" ? await mockModule() : mockModule;\n        const mockResult =\n          typeof exportedConfig?.data === \"function\"\n            ? { ...exportedConfig, data: await exportedConfig.data() }\n            : exportedConfig;\n\n        const { enable = true } = mockResult || {};\n        return enable ? { absolutePath, mockResult } : null;\n      }\n\n      server.middlewares.use(\n        async (\n          req: IncomingMessage,\n          res: ServerResponse,\n          next: (err?: Error | unknown) => void,\n        ): Promise<void> => {\n          // Global switch: skip all mock handling\n          if (!enabled) return next();\n\n          if (inspectorHandler && req.url) {\n            const handled = await inspectorHandler(req, res);\n            if (handled) return;\n          }\n\n          if (!req.url) {\n            return next();\n          }\n\n          const pathname = new URL(req.url, \"http://localhost\").pathname;\n          if (!matchesApiPrefix(pathname, apiPrefix)) {\n            return next();\n          }\n\n          // Skip non-standard requests (SSE, WebSocket, file streams)\n          const accept = req.headers.accept || \"\";\n          const upgrade = req.headers.upgrade || \"\";\n          if (accept.includes(\"text/event-stream\") || upgrade.toLowerCase() === \"websocket\") {\n            return next();\n          }\n\n          const method = (req.method || \"GET\").toLowerCase();\n          const key = `${pathname}/${method}.js`.toLowerCase();\n\n          // 1. Try mock\n          try {\n            const mock = await tryLoadMock(key);\n            if (mock) {\n              serveMockResponse(res, mock.absolutePath, mock.mockResult);\n              return;\n            }\n          } catch (error) {\n            console.error(\"[automock] Failed to load mock file:\", error);\n          }\n\n          // 2. Try proxy\n          if (!proxyBaseUrl || !proxyEnabled) return next();\n\n          try {\n            proxyAndCapture(req, res, {\n              proxyBaseUrl,\n              pathRewrite,\n              shouldSave: captureEnabled && !mockFileMap.has(key),\n              method,\n              pathname,\n              mockDir,\n              onMockSaved: async () => {\n                mockFileMap = await buildMockIndex(mockDir);\n              },\n            });\n          } catch (error) {\n            console.error(\"[automock] Proxy request error:\", error);\n            sendError(res, \"Internal server error\");\n          }\n        },\n      );\n    },\n    closeBundle() {\n      watcher?.close();\n    },\n    transform() {\n      return null;\n    },\n  };\n}\n","import path from \"path\";\nimport fs from \"fs-extra\";\nimport prettier from \"prettier\";\n\nimport { resolveAbsolutePath, toPosixPath } from \"./utils\";\n\nexport interface MockFileConfig {\n  enable: boolean;\n  data: unknown;\n  delay: number;\n  status: number;\n  [key: string]: unknown;\n}\n\nexport interface MockFileInfo {\n  config: MockFileConfig;\n  serializable: boolean;\n  hasDynamicData: boolean;\n  headerComment?: string;\n  description?: string;\n  dataText: string;\n  isBinary?: boolean;\n}\n\nexport const DEFAULT_CONFIG: MockFileConfig = {\n  enable: true,\n  data: null,\n  delay: 0,\n  status: 200,\n};\n\nconst isBufferTextLike = (buffer: Buffer): boolean => {\n  try {\n    const sample = buffer.slice(0, 100);\n    const nullBytes = [...sample].filter((b) => b === 0).length;\n    const controlChars = [...sample].filter(\n      (b) => b < 32 && b !== 9 && b !== 10 && b !== 13,\n    ).length;\n    return nullBytes === 0 && controlChars < 5;\n  } catch {\n    return false;\n  }\n};\n\nconst isBinaryResponse = (\n  contentType: string | undefined,\n  data: Buffer,\n): boolean => {\n  if (!contentType) return false;\n\n  const binaryTypes = [\n    \"application/octet-stream\",\n    \"application/pdf\",\n    \"application/zip\",\n    \"application/x-zip-compressed\",\n    \"application/vnd.ms-excel\",\n    \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n    \"application/msword\",\n    \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n    \"application/vnd.ms-powerpoint\",\n    \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n    \"image/\",\n    \"video/\",\n    \"audio/\",\n  ];\n\n  return (\n    binaryTypes.some((type) => contentType.toLowerCase().includes(type)) ||\n    !isBufferTextLike(data)\n  );\n};\n\nconst getFileExtension = (\n  contentType: string | undefined,\n  url: string,\n): string => {\n  const mimeMap: Record<string, string> = {\n    \"application/json\": \"json\",\n    \"application/pdf\": \"pdf\",\n    \"application/zip\": \"zip\",\n    \"application/vnd.ms-excel\": \"xls\",\n    \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"xlsx\",\n    \"application/msword\": \"doc\",\n    \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\":\n      \"docx\",\n    \"application/vnd.ms-powerpoint\": \"ppt\",\n    \"application/vnd.openxmlformats-officedocument.presentationml.presentation\":\n      \"pptx\",\n    \"image/jpeg\": \"jpg\",\n    \"image/png\": \"png\",\n    \"image/gif\": \"gif\",\n    \"text/plain\": \"txt\",\n    \"text/html\": \"html\",\n    \"text/css\": \"css\",\n    \"application/javascript\": \"js\",\n    \"text/xml\": \"xml\",\n  };\n\n  if (contentType && mimeMap[contentType.toLowerCase()]) {\n    return mimeMap[contentType.toLowerCase()];\n  }\n\n  try {\n    const urlObj = new URL(url, \"http://localhost\");\n    const fileName = urlObj.searchParams.get(\"file_name\");\n    if (fileName) {\n      const extensionMatch = fileName.match(/\\.([a-zA-Z0-9]+)$/);\n      if (extensionMatch) {\n        return extensionMatch[1];\n      }\n    }\n  } catch {\n    // Ignore URL parse errors\n  }\n\n  return \"bin\";\n};\n\nasync function formatWithPrettier(content: string): Promise<string> {\n  try {\n    return await prettier.format(content, { parser: \"babel\" });\n  } catch {\n    return content;\n  }\n}\n\nfunction buildMockFileHeader(\n  pathname: string,\n  method: string,\n  search: string,\n  extra?: string,\n): string {\n  return `/**\n * Mock data for ${pathname} (${method.toUpperCase()})${search || \"\"}\n * @description ${pathname}${search || \"\"}${extra ? ` - ${extra}` : \"\"}\n * Generated at ${new Date().toISOString()}\n */`;\n}\n\nasync function saveBinaryMock(\n  filePath: string,\n  binaryData: Buffer,\n  pathname: string,\n  method: string,\n  search: string,\n  contentType: string | undefined,\n  url: string,\n  statusCode: number | undefined,\n): Promise<string | null> {\n  const extension = getFileExtension(contentType, url);\n  const binaryFilePath = filePath.replace(/\\.js$/, \".\" + extension);\n\n  if (fs.existsSync(binaryFilePath)) return null;\n\n  fs.writeFileSync(binaryFilePath, binaryData);\n\n  const header = buildMockFileHeader(pathname, method, search, `Binary file (${extension})`);\n  const configContent = `${header}\nexport default {\n  enable: false,\n  data: {\n    __binaryFile: '${extension}',\n    __originalPath: '${pathname}',\n    __originalQuery: '${search}',\n    __originalUrl: '${pathname}${search || \"\"}',\n    __contentType: '${contentType}',\n    __fileSize: ${binaryData.length}\n  },\n  delay: 0,\n  status: ${statusCode || 200}\n}`;\n\n  const formatted = await formatWithPrettier(configContent);\n  fs.writeFileSync(filePath, formatted, \"utf-8\");\n  return filePath;\n}\n\nasync function saveJsonMock(\n  filePath: string,\n  dataStr: string,\n  pathname: string,\n  method: string,\n  search: string,\n  statusCode: number | undefined,\n): Promise<string | null> {\n  if (fs.existsSync(filePath)) return null;\n\n  let jsonData;\n  if (!dataStr || dataStr.trim() === \"\") {\n    jsonData = {\n      error: true,\n      message: `Empty response (${statusCode || \"unknown status\"})`,\n      status: statusCode || 404,\n      data: null,\n    };\n  } else {\n    try {\n      jsonData = JSON.parse(dataStr);\n      if (statusCode && statusCode >= 400) {\n        const errorMeta = { __mockStatusCode: statusCode, __isErrorResponse: true };\n        jsonData =\n          typeof jsonData === \"object\" && jsonData !== null\n            ? { ...jsonData, ...errorMeta }\n            : { originalData: jsonData, ...errorMeta };\n      }\n    } catch {\n      jsonData = {\n        error: true,\n        message: `Non-JSON response (${statusCode || \"unknown status\"})`,\n        status: statusCode || 404,\n        data: dataStr,\n        __mockStatusCode: statusCode,\n        __isErrorResponse: true,\n      };\n    }\n  }\n\n  const header = buildMockFileHeader(pathname, method, search);\n  const content = `${header}\nexport default {\n  enable: false,\n  data: ${JSON.stringify(jsonData)},\n  delay: 0,\n  status: ${statusCode || 200}\n}`;\n\n  const formatted = await formatWithPrettier(content);\n  fs.writeFileSync(filePath, formatted, \"utf-8\");\n  return filePath;\n}\n\nexport async function saveMockData(\n  url: string,\n  method: string,\n  data: Buffer | string,\n  rootDir: string,\n  statusCode?: number,\n  contentType?: string,\n): Promise<string | null> {\n  try {\n    const absoluteRootDir = resolveAbsolutePath(rootDir);\n    const urlObj = new URL(url, \"http://localhost\");\n    const pathname = urlObj.pathname;\n    const search = urlObj.search;\n\n    const filePath = path.join(\n      absoluteRootDir,\n      pathname.replace(/^\\//, \"\"),\n      method.toLowerCase() + \".js\",\n    );\n\n    await fs.ensureDir(path.dirname(filePath));\n\n    const isBuffer = Buffer.isBuffer(data);\n    const binaryData = isBuffer ? data : Buffer.from(data || \"\");\n    const isBinary = isBinaryResponse(contentType, binaryData);\n\n    if (isBinary) {\n      return saveBinaryMock(\n        filePath, binaryData, pathname, method, search,\n        contentType, url, statusCode,\n      );\n    }\n\n    const dataStr = isBuffer ? data.toString(\"utf8\") : data || \"\";\n    return saveJsonMock(filePath, dataStr, pathname, method, search, statusCode);\n  } catch (error) {\n    console.error(`Failed to save mock data for ${url}:`, error);\n    console.error(\n      `URL details: url=${url}, method=${method}, statusCode=${statusCode}, contentType=${contentType}`,\n    );\n    throw error;\n  }\n}\n\nconst recursiveReadAllFiles = async (dir: string): Promise<string[]> => {\n  if (!(await fs.pathExists(dir))) return [];\n\n  const files: string[] = [];\n  try {\n    const list = await fs.readdir(dir);\n    for (const file of list) {\n      const filePath = path.join(dir, file);\n      const stat = await fs.stat(filePath);\n      if (stat.isDirectory()) {\n        files.push(...(await recursiveReadAllFiles(filePath)));\n      } else {\n        files.push(filePath);\n      }\n    }\n  } catch (error) {\n    console.error(`Error reading directory ${dir}:`, error);\n  }\n  return files;\n};\n\nexport async function buildMockIndex(mockDir: string): Promise<Map<string, string>> {\n  const mockFileMap = new Map<string, string>();\n\n  if (!(await fs.pathExists(mockDir))) {\n    await fs.ensureDir(mockDir);\n    return mockFileMap;\n  }\n\n  const files = await recursiveReadAllFiles(mockDir);\n\n  files.forEach((filePath) => {\n    if (!filePath.endsWith(\".js\")) return;\n\n    try {\n      const relativePath = path.relative(mockDir, filePath);\n      const method = path.basename(filePath, \".js\");\n      const dirPath = path.dirname(relativePath);\n      const urlPath = \"/\" + toPosixPath(dirPath);\n      const absolutePath = resolveAbsolutePath(filePath);\n      const key = `${urlPath}/${method}.js`.toLowerCase();\n\n      mockFileMap.set(key, absolutePath);\n    } catch (error) {\n      console.error(`[automock] Failed to process file ${filePath}:`, error);\n    }\n  });\n\n  return mockFileMap;\n}\n\nexport async function parseMockModule(filePath: string): Promise<MockFileInfo> {\n  const absolutePath = resolveAbsolutePath(filePath);\n\n  if (!fs.existsSync(absolutePath)) {\n    throw new Error(`Mock file does not exist: ${absolutePath}`);\n  }\n\n  const content = fs.readFileSync(absolutePath, \"utf-8\");\n  const headerCommentMatch = content.match(/^(\\/\\*\\*[\\s\\S]*?\\*\\/)/);\n  const headerComment = headerCommentMatch ? headerCommentMatch[1] : undefined;\n\n  let description: string | undefined;\n  if (headerComment) {\n    const descMatch = headerComment.match(/@description\\s+(.+?)(?:\\n|\\*\\/)/s);\n    if (descMatch) {\n      description = descMatch[1].trim();\n    }\n  }\n\n  const { default: mockModule } = await import(\n    `${absolutePath}?t=${Date.now()}`\n  );\n\n  const exportedConfig =\n    typeof mockModule === \"function\" ? mockModule() : mockModule;\n  const hasDynamicData = typeof exportedConfig?.data === \"function\";\n  const config: MockFileConfig = {\n    ...DEFAULT_CONFIG,\n    ...(exportedConfig ?? {}),\n  };\n\n  const serializable = !hasDynamicData;\n  const dataObj =\n    typeof config.data === \"object\" && config.data !== null\n      ? (config.data as Record<string, unknown>)\n      : null;\n  const isBinary = dataObj !== null && \"__binaryFile\" in dataObj;\n\n  return {\n    config,\n    serializable,\n    hasDynamicData,\n    headerComment,\n    description,\n    dataText: isBinary\n      ? `/* Binary file: ${dataObj?.__binaryFile} */`\n      : serializable\n        ? JSON.stringify(config.data ?? null, null, 2)\n        : \"/* data is generated dynamically and cannot be edited here */\",\n    isBinary,\n  };\n}\n\nexport async function writeMockFile(\n  filePath: string,\n  mockInfo: Pick<MockFileInfo, \"config\" | \"headerComment\" | \"description\">,\n): Promise<void> {\n  const absolutePath = resolveAbsolutePath(filePath);\n\n  let header = mockInfo.headerComment || \"\";\n\n  if (mockInfo.description !== undefined) {\n    if (header) {\n      if (/@description/.test(header)) {\n        header = header.replace(\n          /@description\\s+.+?(?=\\n|\\*\\/)/s,\n          `@description ${mockInfo.description}`,\n        );\n      } else {\n        header = header.replace(\n          /\\*\\//,\n          ` * @description ${mockInfo.description}\\n */`,\n        );\n      }\n    }\n  }\n\n  const content = header ? `${header}\\n` : \"\";\n  const finalContent = `${content}export default ${JSON.stringify(mockInfo.config, null, 2)}\\n`;\n\n  try {\n    const formatted = await formatWithPrettier(finalContent);\n    fs.writeFileSync(absolutePath, formatted, \"utf-8\");\n  } catch {\n    console.error(\"Error formatting code with prettier, writing raw content\");\n    fs.writeFileSync(absolutePath, finalContent, \"utf-8\");\n  }\n}\n","import path from \"path\";\n\nimport type { IncomingMessage, ServerResponse } from \"http\";\nimport type { AddressInfo } from \"net\";\n\nexport function resolveAbsolutePath(p: string): string {\n  return path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);\n}\n\nexport function toPosixPath(p: string): string {\n  return p.replace(/\\\\/g, \"/\");\n}\n\nexport interface ServerAddress {\n  protocol: string;\n  host: string;\n  port: number;\n}\n\nexport function getServerAddress(\n  address: AddressInfo,\n  isHttps: boolean,\n): ServerAddress {\n  return {\n    protocol: isHttps ? \"https\" : \"http\",\n    host:\n      address.address === \"::\" || address.address === \"0.0.0.0\"\n        ? \"localhost\"\n        : address.address,\n    port: address.port,\n  };\n}\n\nexport function sendJson(\n  res: ServerResponse,\n  data: unknown,\n  status = 200,\n): void {\n  res.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n  res.statusCode = status;\n  res.end(typeof data === \"string\" ? data : JSON.stringify(data));\n}\n\nexport function sendError(\n  res: ServerResponse,\n  message: string,\n  status = 500,\n): void {\n  sendJson(res, { error: message }, status);\n}\n\nconst MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB\n\nexport function readBody(req: IncomingMessage): Promise<string> {\n  return new Promise((resolve, reject) => {\n    const chunks: Buffer[] = [];\n    let totalSize = 0;\n    req.on(\"data\", (chunk: Buffer) => {\n      totalSize += chunk.length;\n      if (totalSize > MAX_BODY_SIZE) {\n        reject(new Error(\"Request body too large\"));\n        req.destroy();\n        return;\n      }\n      chunks.push(chunk);\n    });\n    req.on(\"end\", () => resolve(Buffer.concat(chunks).toString(\"utf-8\")));\n    req.on(\"error\", reject);\n  });\n}\n","import path from \"path\";\nimport fs from \"fs-extra\";\nimport { fileURLToPath } from \"url\";\n\n// ESM/CJS compatible __dirname\nconst _dirName = typeof __dirname !== \"undefined\"\n  ? __dirname\n  : path.dirname(fileURLToPath(import.meta.url));\nimport { parseMockModule, writeMockFile, saveMockData, buildMockIndex, type MockFileConfig } from \"./mockFileUtils\";\nimport { toPosixPath, sendJson, readBody } from \"./utils\";\nimport type { IncomingMessage, ServerResponse } from \"http\";\nimport type { AutomockPluginOptions, InspectorOptions } from \"./types\";\n\ninterface InspectorContext {\n  req: IncomingMessage;\n  res: ServerResponse;\n  mockDir: string;\n  inspectorRoute: string;\n  apiPrefix: string;\n  inspectorConfig: Required<InspectorOptions>;\n  getMockFileMap: () => Map<string, string>;\n}\n\ninterface InspectorHandlerOptions {\n  inspector: AutomockPluginOptions[\"inspector\"];\n  apiPrefix: string;\n  mockDir: string;\n  getMockFileMap: () => Map<string, string>;\n}\n\ninterface InspectorApiContext extends InspectorContext {\n  pathname: string;\n}\n\ninterface InspectorPayload {\n  key: string;\n  config?: Partial<MockFileConfig>;\n  description?: string;\n}\n\ninterface MockItem {\n  key: string;\n  file: string;\n  method: string;\n  path: string;\n  config: MockFileConfig;\n  editable: boolean;\n  description?: string;\n  dataText: string;\n}\n\nfunction buildMockItem(\n  key: string,\n  filePath: string,\n  mockDir: string,\n  info: Awaited<ReturnType<typeof parseMockModule>>,\n): MockItem {\n  return {\n    key,\n    file: path.relative(mockDir, filePath),\n    method: key.split(\"/\").pop()?.replace(/\\.js$/, \"\") ?? \"get\",\n    path: key.replace(/\\/[^/]+\\.js$/, \"\"),\n    config: info.config,\n    editable: info.serializable,\n    description: info.description,\n    dataText: info.dataText,\n  };\n}\n\nexport const DEFAULT_ROUTE = \"/__mock/\";\n\nfunction ensureTrailingSlash(route: string): string {\n  return route.endsWith(\"/\") ? route : `${route}/`;\n}\n\nfunction escapeHtml(value: string): string {\n  return value\n    .replace(/&/g, \"&amp;\")\n    .replace(/</g, \"&lt;\")\n    .replace(/>/g, \"&gt;\")\n    .replace(/\"/g, \"&quot;\")\n    .replace(/'/g, \"&#39;\");\n}\n\nexport function normalizeInspectorConfig(\n  input: AutomockPluginOptions[\"inspector\"],\n): Required<InspectorOptions> {\n  if (input === false || input === undefined) {\n    return { route: DEFAULT_ROUTE, enableToggle: true };\n  }\n  if (input === true) {\n    return { route: DEFAULT_ROUTE, enableToggle: true };\n  }\n  return {\n    route: ensureTrailingSlash(input.route ?? DEFAULT_ROUTE),\n    enableToggle: input.enableToggle ?? true,\n  };\n}\n\nexport type InspectorRequestHandler = (\n  req: IncomingMessage,\n  res: ServerResponse,\n) => Promise<boolean>;\n\nexport function createInspectorHandler(\n  options: InspectorHandlerOptions,\n): InspectorRequestHandler | null {\n  if (!options.inspector) {\n    return null;\n  }\n\n  const inspectorConfig = normalizeInspectorConfig(options.inspector);\n  const inspectorRoute = ensureTrailingSlash(inspectorConfig.route);\n\n  return async (req, res) => {\n    if (!req.url) {\n      return false;\n    }\n    const url = new URL(req.url, \"http://localhost\");\n    if (!url.pathname.startsWith(inspectorRoute)) {\n      return false;\n    }\n\n    await handleInspectorRequest({\n      req,\n      res,\n      mockDir: options.mockDir,\n      inspectorRoute,\n      apiPrefix: options.apiPrefix,\n      inspectorConfig,\n      getMockFileMap: options.getMockFileMap,\n    });\n\n    return true;\n  };\n}\n\nasync function handleInspectorRequest(\n  context: InspectorContext,\n): Promise<void> {\n  const { req, res, inspectorRoute } = context;\n  const url = new URL(req.url || inspectorRoute, \"http://localhost\");\n  const normalizedRoute = ensureTrailingSlash(inspectorRoute);\n\n  if (\n    url.pathname === normalizedRoute.slice(0, -1) ||\n    url.pathname === normalizedRoute\n  ) {\n    await serveInspectorHtml(context);\n    return;\n  }\n\n  const relativePath = url.pathname.startsWith(normalizedRoute)\n    ? url.pathname.slice(normalizedRoute.length)\n    : null;\n\n  if (relativePath && relativePath.startsWith(\"api/\")) {\n    await handleInspectorApi({ ...context, pathname: relativePath.slice(4) });\n    return;\n  }\n\n  res.statusCode = 404;\n  res.end(\"Not Found\");\n}\n\nasync function serveInspectorHtml({\n  res,\n  inspectorRoute,\n  apiPrefix,\n  inspectorConfig,\n}: InspectorContext): Promise<void> {\n  const routeJson = JSON.stringify(ensureTrailingSlash(inspectorRoute));\n  const allowToggleJson = JSON.stringify(inspectorConfig.enableToggle);\n  const apiPrefixEscaped = escapeHtml(apiPrefix);\n\n  const templatePath = path.join(_dirName, \"inspector-template.html\");\n  const template = fs.readFileSync(templatePath, \"utf-8\");\n  const html = template\n    .replace(\"__API_PREFIX__\", apiPrefixEscaped)\n    .replace(\"__ROUTE_JSON__\", routeJson)\n    .replace(\"__ALLOW_TOGGLE_JSON__\", allowToggleJson);\n\n  res.setHeader(\"Content-Type\", \"text/html; charset=utf-8\");\n  res.end(html);\n}\n\nasync function handleList(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { res, mockDir } = ctx;\n  const list = await Promise.all(\n    Array.from(mockFileMap.entries()).map(async ([key, filePath]) => {\n      const info = await parseMockModule(filePath);\n      return buildMockItem(key, filePath, mockDir, info);\n    }),\n  );\n  sendJson(res, { mocks: list });\n  return true;\n}\n\nasync function handleDetail(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { req, res, mockDir } = ctx;\n  const url = new URL(req.url || \"\", \"http://localhost\");\n  const key = url.searchParams.get(\"key\");\n  if (!key) {\n    sendJson(res, { error: \"Missing key\" }, 400);\n    return true;\n  }\n  const filePath = mockFileMap.get(key);\n  if (!filePath) {\n    sendJson(res, { error: \"Mock not found\" }, 404);\n    return true;\n  }\n  const info = await parseMockModule(filePath);\n  sendJson(res, { mock: buildMockItem(key, filePath, mockDir, info) });\n  return true;\n}\n\nasync function handleUpdate(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { req, res, mockDir, inspectorConfig } = ctx;\n  if (req.method !== \"POST\") {\n    sendJson(res, { error: \"Method not allowed\" }, 405);\n    return true;\n  }\n  const body = await readBody(req);\n  let payload: InspectorPayload;\n  try {\n    payload = JSON.parse(body);\n  } catch {\n    sendJson(res, { error: \"Invalid JSON body\" }, 400);\n    return true;\n  }\n\n  const { key, config, description } = payload || {};\n  if (!key) {\n    sendJson(res, { error: \"Invalid payload: missing key\" }, 400);\n    return true;\n  }\n\n  const filePath = mockFileMap.get(key);\n  if (!filePath) {\n    sendJson(res, { error: \"Mock not found\" }, 404);\n    return true;\n  }\n\n  const info = await parseMockModule(filePath);\n\n  let nextConfig = info.config;\n  if (config && typeof config === \"object\") {\n    if (!inspectorConfig.enableToggle && config.enable !== undefined) {\n      delete config.enable;\n    }\n    nextConfig = { ...info.config, ...config };\n  }\n\n  const nextDescription =\n    description !== undefined ? description : info.description;\n\n  await writeMockFile(filePath, {\n    headerComment: info.headerComment,\n    config: nextConfig,\n    description: nextDescription,\n  });\n\n  const updatedInfo = await parseMockModule(filePath);\n  sendJson(res, { mock: buildMockItem(key, filePath, mockDir, updatedInfo) });\n  return true;\n}\n\nasync function handleCreate(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { req, res, mockDir, apiPrefix } = ctx;\n  if (req.method !== \"POST\") {\n    sendJson(res, { error: \"Method not allowed\" }, 405);\n    return true;\n  }\n  const body = await readBody(req);\n  let payload: { method: string; path: string; description?: string; data?: unknown };\n  try {\n    payload = JSON.parse(body);\n  } catch {\n    sendJson(res, { error: \"Invalid JSON body\" }, 400);\n    return true;\n  }\n\n  const { method, path: apiPath, data } = payload || {};\n  if (!method || !apiPath) {\n    sendJson(res, { error: \"Invalid payload: missing method or path\" }, 400);\n    return true;\n  }\n\n  const fullUrl = apiPrefix + apiPath;\n\n  try {\n    let dataToSave: Buffer | string;\n    if (typeof data === \"object\" && data !== null) {\n      dataToSave = JSON.stringify(data, null, 2);\n    } else {\n      dataToSave = typeof data === \"string\" ? data : \"\";\n    }\n\n    await saveMockData(fullUrl, method.toLowerCase(), dataToSave, mockDir, 200);\n\n    const newMockFileMap = await buildMockIndex(mockDir);\n    for (const [key, value] of newMockFileMap.entries()) {\n      mockFileMap.set(key, value);\n    }\n\n    const normalizedPath = toPosixPath(apiPath);\n    const key = (normalizedPath.startsWith(\"/\") ? \"\" : \"/\") +\n      normalizedPath.toLowerCase() + \"/\" + method.toLowerCase() + \".js\";\n    const filePath = mockFileMap.get(key);\n\n    if (!filePath) {\n      sendJson(res, { error: \"Mock file created but not found in map\" }, 500);\n      return true;\n    }\n\n    const info = await parseMockModule(filePath);\n    sendJson(res, {\n      success: true,\n      mock: buildMockItem(key, filePath, mockDir, info),\n    });\n    return true;\n  } catch (error: unknown) {\n    const errorMessage = error instanceof Error ? error.message : String(error);\n    sendJson(res, { error: \"Failed to create mock: \" + errorMessage }, 500);\n    return true;\n  }\n}\n\nasync function handleDelete(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { req, res } = ctx;\n  const url = new URL(req.url || \"\", \"http://localhost\");\n  const key = url.searchParams.get(\"key\");\n  if (!key) {\n    sendJson(res, { error: \"Missing key\" }, 400);\n    return true;\n  }\n\n  const filePath = mockFileMap.get(key);\n  if (!filePath) {\n    sendJson(res, { error: \"Mock not found\" }, 404);\n    return true;\n  }\n\n  try {\n    const stats = await fs.stat(filePath);\n    if (stats.isDirectory()) {\n      await fs.remove(filePath);\n      for (const [mapKey, mapPath] of mockFileMap.entries()) {\n        if (mapPath.startsWith(filePath + path.sep) || mapPath === filePath) {\n          mockFileMap.delete(mapKey);\n        }\n      }\n    } else {\n      await fs.unlink(filePath);\n      mockFileMap.delete(key);\n    }\n    sendJson(res, { success: true });\n  } catch (error: unknown) {\n    const errorMessage = error instanceof Error ? error.message : String(error);\n    sendJson(res, { error: \"Failed to delete: \" + errorMessage }, 500);\n  }\n  return true;\n}\n\ntype ApiHandler = (ctx: InspectorApiContext, mockFileMap: Map<string, string>) => Promise<boolean>;\n\nasync function handleBatchUpdate(\n  ctx: InspectorApiContext,\n  mockFileMap: Map<string, string>,\n): Promise<boolean> {\n  const { req, res } = ctx;\n  if (req.method !== \"POST\") {\n    sendJson(res, { error: \"Method not allowed\" }, 405);\n    return true;\n  }\n  const body = await readBody(req);\n  let payload: { updates?: Array<{ key: string; config?: Record<string, unknown> }> };\n  try {\n    payload = JSON.parse(body);\n  } catch {\n    sendJson(res, { error: \"Invalid JSON body\" }, 400);\n    return true;\n  }\n\n  const updates = payload?.updates;\n  if (!Array.isArray(updates) || updates.length === 0) {\n    sendJson(res, { error: \"Invalid payload: updates must be a non-empty array\" }, 400);\n    return true;\n  }\n\n  let updated = 0;\n  const errors: string[] = [];\n\n  for (const item of updates) {\n    const { key, config } = item;\n    if (!key) continue;\n\n    const filePath = mockFileMap.get(key);\n    if (!filePath) {\n      errors.push(`Mock not found: ${key}`);\n      continue;\n    }\n\n    try {\n      const info = await parseMockModule(filePath);\n      const nextConfig = config ? { ...info.config, ...config } : info.config;\n\n      await writeMockFile(filePath, {\n        headerComment: info.headerComment,\n        config: nextConfig,\n        description: info.description,\n      });\n      updated++;\n    } catch (err) {\n      errors.push(`Failed to update ${key}: ${err instanceof Error ? err.message : String(err)}`);\n    }\n  }\n\n  sendJson(res, { success: true, updated, errors: errors.length > 0 ? errors : undefined });\n  return true;\n}\n\nconst API_ROUTES: Record<string, ApiHandler> = {\n  list: handleList,\n  detail: handleDetail,\n  update: handleUpdate,\n  \"batch-update\": handleBatchUpdate,\n  create: handleCreate,\n  delete: handleDelete,\n};\n\nasync function handleInspectorApi(ctx: InspectorApiContext): Promise<void> {\n  try {\n    const mockFileMap = ctx.getMockFileMap();\n    const handler = API_ROUTES[ctx.pathname];\n    if (handler) {\n      await handler(ctx, mockFileMap);\n      return;\n    }\n    sendJson(ctx.res, { error: \"Unknown inspector endpoint\" }, 404);\n  } catch (error) {\n    console.error(\"[automock] Inspector request failed:\", error);\n    sendJson(ctx.res, { error: \"Inspector failed\" }, 500);\n  }\n}\n","import path from 'path'\nimport fs from 'fs-extra'\n\nimport { buildMockIndex, parseMockModule } from './mockFileUtils'\n\nexport interface MockBundleData {\n  enable: boolean\n  data: unknown\n  delay: number\n  status: number\n  isBinary?: boolean\n}\n\nexport interface MockBundle {\n  [key: string]: MockBundleData\n}\n\nexport interface BundleOptions {\n  mockDir: string\n  includeDisabled?: boolean\n  log?: boolean\n}\n\nconst DEFAULT_BUNDLE_OPTIONS: Partial<BundleOptions> = {\n  includeDisabled: true,\n  log: true\n}\n\nasync function bundleMockFiles(options: BundleOptions): Promise<MockBundle> {\n  const opts = { ...DEFAULT_BUNDLE_OPTIONS, ...options }\n  const { mockDir, log } = opts\n\n  if (!fs.existsSync(mockDir)) {\n    if (log) {\n      console.log(`[mock-bundler] Mock directory does not exist: ${mockDir}`)\n    }\n    return {}\n  }\n\n  const mockFileMap = await buildMockIndex(mockDir)\n  const bundle: MockBundle = {}\n  let bundledCount = 0\n  let skippedCount = 0\n\n  for (const [key, filePath] of mockFileMap) {\n    try {\n      const mockInfo = await parseMockModule(filePath)\n\n      if (!mockInfo.serializable) {\n        skippedCount++\n        if (log) {\n          console.log(`[mock-bundler] Skipping non-serializable mock: ${key}`)\n        }\n        continue\n      }\n\n      bundle[key] = {\n        enable: mockInfo.config.enable,\n        data: mockInfo.config.data,\n        delay: mockInfo.config.delay,\n        status: mockInfo.config.status,\n        isBinary: mockInfo.isBinary\n      }\n\n      bundledCount++\n    } catch (error) {\n      if (log) {\n        console.error(`[mock-bundler] Failed to bundle mock ${key}:`, error)\n      }\n    }\n  }\n\n  if (log) {\n    console.log(`[mock-bundler] Bundled ${bundledCount} mocks, skipped ${skippedCount} non-serializable mocks`)\n  }\n\n  return bundle\n}\n\nfunction writeMockBundle(bundle: MockBundle, outputPath: string): void {\n  const outputDir = path.dirname(outputPath)\n\n  if (!fs.existsSync(outputDir)) {\n    fs.ensureDirSync(outputDir)\n  }\n\n  fs.writeFileSync(\n    outputPath,\n    JSON.stringify(bundle, null, 2),\n    'utf-8'\n  )\n}\n\nexport { bundleMockFiles, writeMockBundle }\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,OAAOC,SAAQ;;;ACDf,OAAO,cAAc;AACrB,OAAO,cAAc;AACrB,OAAOC,WAAU;AACjB,OAAOC,SAAQ;AACf,OAAO,UAAU;AACjB,OAAO,WAAW;;;ACLlB,OAAOC,WAAU;AACjB,OAAO,QAAQ;AACf,OAAO,cAAc;;;ACFrB,OAAO,UAAU;AAKV,SAAS,oBAAoB,GAAmB;AACrD,SAAO,KAAK,WAAW,CAAC,IAAI,IAAI,KAAK,QAAQ,QAAQ,IAAI,GAAG,CAAC;AAC/D;AAEO,SAAS,YAAY,GAAmB;AAC7C,SAAO,EAAE,QAAQ,OAAO,GAAG;AAC7B;AAQO,SAAS,iBACd,SACA,SACe;AACf,SAAO;AAAA,IACL,UAAU,UAAU,UAAU;AAAA,IAC9B,MACE,QAAQ,YAAY,QAAQ,QAAQ,YAAY,YAC5C,cACA,QAAQ;AAAA,IACd,MAAM,QAAQ;AAAA,EAChB;AACF;AAEO,SAAS,SACd,KACA,MACA,SAAS,KACH;AACN,MAAI,UAAU,gBAAgB,iCAAiC;AAC/D,MAAI,aAAa;AACjB,MAAI,IAAI,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,IAAI,CAAC;AAChE;AAEO,SAAS,UACd,KACA,SACA,SAAS,KACH;AACN,WAAS,KAAK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AChD,cAAI,YAAY,SAAS,GAAG;AAC1B,oBAAQ,IAAI,4DAA4D;AACxE;AAAA,UACF;AAEA,yBAAe,MAAM,gBAAgB,EAAE,QAAQ,CAAC;AAEhD,gBAAM,aAAa,wBAAwB;AAC3C,0BAAgB,cAAc,UAAU;AACxC,kBAAQ,IAAI,sCAAsC,UAAU,EAAE;AAAA,QAChE,SAAS,OAAO;AACd,kBAAQ,MAAM,0CAA0C,KAAK;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AACF;","names":["path","fs","path","fs","path","path","path","fs","path","fs","key","fs","path","path","fs","fs","path","automock","path","fs"]}