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N,IAAK,KACP,EAGN,Q","file":"/npm/@anov/hot-reload@1.0.3/dist/index.mjs","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@anov/hot-reload@1.0.3/dist/index.mjs\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * @Descripttion:\n * @version:\n * @Author: 周志国\n * @Date: 2025-05-14 09:32:39\n * @LastEditors: 周志国\n * @LastEditTime: 2025-05-16 11:25:11\n * @changeLog:\n * @FilePath: /anov/packages/dev/plugins/injectCode.ts\n */\nconst hotUpdateCode = (compName: string, method: string) => `\nif (import.meta.hot) {\n  import.meta.hot.on('vite:afterUpdate', payload => {\n    const currentFilePath = import.meta.url\n    payload.updates.forEach(update => {\n      try {\n      // ✅ 跳过包含 style、template、custom 等查询参数的更新路径\n        const isSubPartUpdate = update.path.includes('?vue&type=style') || update.path.includes('?vue&type=template')\n        if (update.type !== 'js-update' || isSubPartUpdate) return\n        // 获取当前文件路径（移除查询参数）\n        const currentUrl = new URL(currentFilePath)\n        const currentPathWithoutQuery = currentUrl.pathname\n        // 获取更新文件路径\n        const updatedUrl = new URL(update.path, import.meta.url)\n        const updatedPathWithoutQuery = updatedUrl.pathname\n        // 比较不带查询参数的路径\n        if (updatedPathWithoutQuery === currentPathWithoutQuery) {\n          const instance = window.__HMR_COMPONENTS__?.get(\"${compName}\")\n          console.log('✅ [HMR] update:', update.path)\n          if (typeof ${method} === 'function') {\n            ${method}()\n          } else if (instance && typeof instance.${method} === 'function') {\n            instance.${method}()\n          } else {\n            console.warn('[HMR] 找不到组件实例或 ${method} 方法')\n          }\n        }\n      } catch (error) {\n        console.error('处理热更新时出错:', error)\n      }\n    })\n  })\n}`\nconst registerCode = (compName: string, as: string) => `\nconst options = typeof ${as} === 'function' ? ${as}.options : ${as};\nif (typeof window !== 'undefined') {\n  window.__HMR_COMPONENTS__ = window.__HMR_COMPONENTS__ || new Map();\n  const oldMounted = options.mounted;\n  options.mounted = function () {\n    window.__HMR_COMPONENTS__.set('${compName}', this);\n    if (typeof oldMounted === 'function') {\n      return oldMounted.call(this);\n    }\n  }\n}\nconst oldUnmounted = options.unmounted;\noptions.unmounted = function () {\n  window.__HMR_COMPONENTS__.delete('${compName}');\n  if (typeof oldUnmounted === 'function') {\n    return oldUnmounted.call(this);\n  }\n}\nexport default ${as};\n`\nexport { hotUpdateCode, registerCode }\n","import { Plugin } from 'vite'\nimport { parse, rewriteDefault } from '@vue/compiler-sfc'\nimport { hotUpdateCode, registerCode } from './injectCode'\nexport default function autoHMRRegisterPlugin({ method }: { method: string }): Plugin {\n  return {\n    name: 'auto-hmr-register',\n    transform(code, id) {\n      if (!id.endsWith('.vue') || id.includes('?')) return null\n      const compName = id\n      let finalCode = ''\n      const { descriptor } = parse(code, { filename: id })\n      const scriptContent = descriptor.script?.content || ''\n      const scriptSetupContent = descriptor.scriptSetup?.content || ''\n      const templateContent = descriptor.template?.content || ''\n      const styleContent = descriptor.styles[0]?.content || ''\n      const styleScoped = descriptor.styles[0]?.scoped || false\n      const lang = descriptor.script?.lang || descriptor.scriptSetup?.lang || null\n      if (descriptor.script) {\n        const sfcRewritten = rewriteDefault(scriptContent, '__sfc__')\n        const registrationCode = registerCode(compName, '__sfc__')\n        finalCode = `\n        <template>${templateContent}</template>\n        <script ${!!lang ? `lang=\"${lang}\"` : ''} >\n          ${sfcRewritten}\n          ${hotUpdateCode(compName, method)}\n          ${registrationCode}\n        </script>\n        <style ${styleScoped ? 'scoped' : ''}>\n        ${styleContent}\n        </style>`\n      } else if (descriptor.scriptSetup) {\n        finalCode = `<template>${templateContent}</template>\n        <script setup ${!!lang ? `lang=\"${lang}\"` : ''} >${scriptSetupContent}${hotUpdateCode(compName, method)}</script>\n        <style ${styleScoped ? 'scoped' : ''}>${styleContent}</style>`\n      } else {\n        return null\n      }\n      return {\n        code: finalCode,\n        map: null\n      }\n    }\n  }\n}\n"]}