{"version":3,"file":"index.cjs","names":[],"sources":["../src/dependency-graph.ts","../src/detect-vm-classes.ts","../src/detect-vm-usage.ts","../src/detect-observer.ts","../src/hmr-runtime.ts","../src/store-access.ts","../src/index.ts"],"sourcesContent":["import type { VMClassInfo, VMUsageInfo } from './types.js';\n\nexport class DependencyGraph {\n  /** Map from absolute file path to the ViewModel classes it exports */\n  private vmExports = new Map<string, VMClassInfo[]>();\n\n  /** Map from absolute file path to the ViewModel usage sites it contains */\n  private vmUsage = new Map<string, VMUsageInfo[]>();\n\n  /** Reverse map: from VM class name to set of files that use it */\n  private vmConsumers = new Map<string, Set<string>>();\n\n  /** Map from VM class name to the file that exports it */\n  private vmSourceFile = new Map<string, string>();\n\n  addFile(\n    filePath: string,\n    classes: VMClassInfo[],\n    usages: VMUsageInfo[],\n  ): void {\n    // Clean up old entries for this file\n    this.removeFile(filePath);\n\n    // Store VM exports\n    if (classes.length > 0) {\n      this.vmExports.set(filePath, classes);\n      for (const cls of classes) {\n        this.vmSourceFile.set(cls.name, filePath);\n      }\n    }\n\n    // Store VM usages and update reverse map\n    if (usages.length > 0) {\n      this.vmUsage.set(filePath, usages);\n      for (const usage of usages) {\n        let consumers = this.vmConsumers.get(usage.vmClassName);\n        if (!consumers) {\n          consumers = new Set();\n          this.vmConsumers.set(usage.vmClassName, consumers);\n        }\n        consumers.add(filePath);\n      }\n    }\n  }\n\n  removeFile(filePath: string): void {\n    // Remove old VM exports\n    const oldClasses = this.vmExports.get(filePath);\n    if (oldClasses) {\n      for (const cls of oldClasses) {\n        // Only delete source file mapping if it still points to this file\n        if (this.vmSourceFile.get(cls.name) === filePath) {\n          this.vmSourceFile.delete(cls.name);\n        }\n      }\n      this.vmExports.delete(filePath);\n    }\n\n    // Remove old VM usages from reverse map\n    const oldUsages = this.vmUsage.get(filePath);\n    if (oldUsages) {\n      for (const usage of oldUsages) {\n        const consumers = this.vmConsumers.get(usage.vmClassName);\n        if (consumers) {\n          consumers.delete(filePath);\n          if (consumers.size === 0) {\n            this.vmConsumers.delete(usage.vmClassName);\n          }\n        }\n      }\n      this.vmUsage.delete(filePath);\n    }\n  }\n\n  getVmExports(filePath: string): VMClassInfo[] {\n    return this.vmExports.get(filePath) ?? [];\n  }\n\n  getVmSourceFile(className: string): string | undefined {\n    return this.vmSourceFile.get(className);\n  }\n\n  getVmType(className: string): VMClassInfo['type'] | undefined {\n    const filePath = this.vmSourceFile.get(className);\n    if (!filePath) return undefined;\n    const classes = this.vmExports.get(filePath);\n    return classes?.find((c) => c.name === className)?.type;\n  }\n\n  getVmConsumers(className: string): Set<string> {\n    return this.vmConsumers.get(className) ?? new Set();\n  }\n\n  isVmFile(filePath: string): boolean {\n    return this.vmExports.has(filePath);\n  }\n}\n","import type { VMClassInfo } from './types.js';\n\n/**\n * Checks if a file imports from mobx-view-model or mobx-view-model-react.\n */\nconst MOBX_VM_IMPORT_RE = /from\\s+['\"]mobx-view-model(?:\\/react|\\/core)?['\"]/;\n\n/**\n * Collapses generic type parameters (<...>) into a single line so that\n * class declarations spanning multiple lines can be matched by regex.\n * e.g. \"class VM<\\n  Payload,\\n> extends ViewModelBase\" →\n *      \"class VM<Payload,> extends ViewModelBase\"\n */\nfunction collapseGenerics(code: string): string {\n  let result = '';\n  let i = 0;\n  while (i < code.length) {\n    if (code[i] !== '<') {\n      result += code[i];\n      i++;\n      continue;\n    }\n\n    // Try to find the matching '>' for this '<', handling nested <> and\n    // skipping balanced {} / () / [] blocks and string literals inside.\n    let depth = 0;\n    let j = i;\n    let found = false;\n\n    while (j < code.length) {\n      const ch = code[j];\n      if (ch === '<') {\n        depth++;\n        j++;\n      } else if (ch === '>') {\n        depth--;\n        if (depth === 0) {\n          found = true;\n          break;\n        }\n        j++;\n      } else if (ch === '{' || ch === '(' || ch === '[') {\n        const close = ch === '{' ? '}' : ch === '(' ? ')' : ']';\n        let innerDepth = 1;\n        j++;\n        while (j < code.length && innerDepth > 0) {\n          if (code[j] === ch) innerDepth++;\n          else if (code[j] === close) innerDepth--;\n          j++;\n        }\n      } else if (ch === '\"' || ch === \"'\" || ch === '`') {\n        const quote = ch;\n        j++;\n        while (j < code.length) {\n          if (code[j] === '\\\\') {\n            j += 2;\n            continue;\n          }\n          if (code[j] === quote) {\n            j++;\n            break;\n          }\n          j++;\n        }\n      } else {\n        j++;\n      }\n    }\n\n    if (found) {\n      const generic = code.slice(i, j + 1);\n      result += generic.replace(/\\s+/g, ' ');\n      i = j + 1;\n    } else {\n      // No matching '>' — treat '<' as a comparison operator\n      result += code[i];\n      i++;\n    }\n  }\n  return result;\n}\n\n/**\n * Imported VM class from another file — local name and its type.\n */\nexport type ImportedVmClass = { localName: string; type: VMClassInfo['type'] };\n\n/**\n * Detects ViewModel classes exported from the given source code.\n * Returns an array of VMClassInfo for each detected class.\n *\n * @param code - Source code to analyze\n * @param importedVmClasses - VM classes imported from other files\n *   (local identifier in this file + their VM type), used for cross-file\n *   indirect inheritance detection (e.g. `class X extends ImportedVM`).\n */\nexport function detectViewModelClasses(\n  code: string,\n  importedVmClasses: ImportedVmClass[] = [],\n): VMClassInfo[] {\n  if (!MOBX_VM_IMPORT_RE.test(code) && importedVmClasses.length === 0) {\n    return [];\n  }\n\n  // Collapse generic type parameters to single lines so that multi-line\n  // class declarations like `class VM<\\n  Payload,\\n> extends ViewModelBase`\n  // can be matched by the line-oriented regexes below.\n  const flatCode = collapseGenerics(code);\n\n  const classes: VMClassInfo[] = [];\n\n  // class X extends ViewModelBase\n  const extendsBaseRe = /class\\s+(\\w+)(?:\\s*<[^>]*?>)?\\s+extends\\s+\\w*ViewModelBase\\b/g;\n  let match: RegExpExecArray | null;\n  while ((match = extendsBaseRe.exec(flatCode)) !== null) {\n    classes.push({\n      name: match[1],\n      type: 'ViewModelBase',\n      exportType: getExportType(code, match[1]),\n    });\n  }\n\n  // class X extends ViewModelSimple\n  const extendsSimpleRe = /class\\s+(\\w+)(?:\\s*<[^>]*?>)?\\s+extends\\s+\\w*ViewModelSimple\\b/g;\n  while ((match = extendsSimpleRe.exec(flatCode)) !== null) {\n    if (!classes.some((c) => c.name === match![1])) {\n      classes.push({\n        name: match[1],\n        type: 'ViewModelSimple',\n        exportType: getExportType(code, match[1]),\n      });\n    }\n  }\n\n  // class X implements ... ViewModel ...\n  const implementsVMRe =\n    /class\\s+(\\w+)(?:\\s*<[^>]*?>)?[^;{]*?\\bimplements\\b[^{]*?\\bViewModel\\b(?!Simple|Base)/g;\n  while ((match = implementsVMRe.exec(flatCode)) !== null) {\n    // Avoid duplicating if already found via extends ViewModelBase\n    if (!classes.some((c) => c.name === match![1])) {\n      classes.push({\n        name: match[1],\n        type: 'ViewModel',\n        exportType: getExportType(code, match[1]),\n      });\n    }\n  }\n\n  // class X implements ... ViewModelSimple ...\n  const implementsSimpleRe =\n    /class\\s+(\\w+)(?:\\s*<[^>]*?>)?[^;{]*?\\bimplements\\b[^{]*?\\bViewModelSimple\\b/g;\n  while ((match = implementsSimpleRe.exec(flatCode)) !== null) {\n    if (!classes.some((c) => c.name === match![1])) {\n      classes.push({\n        name: match[1],\n        type: 'ViewModelSimple',\n        exportType: getExportType(code, match[1]),\n      });\n    }\n  }\n\n  // class X extends SomeBase (where SomeBase was already detected as VM in this file\n  // or is an imported VM class from another file)\n  const extendsAnyRe = /class\\s+(\\w+)(?:\\s*<[^>]*?>)?\\s+extends\\s+(\\w+)/g;\n  const knownNames = new Set(classes.map((c) => c.name));\n  const importedByName = new Map(\n    importedVmClasses.map((v) => [v.localName, v.type]),\n  );\n  while ((match = extendsAnyRe.exec(flatCode)) !== null) {\n    const [, className, baseName] = match;\n    if (knownNames.has(className)) continue;\n\n    // Same-file indirect inheritance\n    const localBase = classes.find((c) => c.name === baseName);\n    if (localBase) {\n      classes.push({\n        name: className,\n        type: localBase.type,\n        exportType: getExportType(code, className),\n      });\n      knownNames.add(className);\n      continue;\n    }\n\n    // Cross-file indirect inheritance via import\n    const importedType = importedByName.get(baseName);\n    if (importedType) {\n      classes.push({\n        name: className,\n        type: importedType,\n        exportType: getExportType(code, className),\n      });\n      knownNames.add(className);\n    }\n  }\n\n  return classes;\n}\n\n/**\n * Extracts import bindings from source code.\n * Returns a list of { localName, importedName, source } for each imported identifier.\n * Handles named imports (including aliases) and default imports.\n */\nexport function extractImportBindings(\n  code: string,\n): { localName: string; importedName: string; source: string }[] {\n  const bindings: {\n    localName: string;\n    importedName: string;\n    source: string;\n  }[] = [];\n\n  // import { X, Y as Z } from 'source'\n  const namedImportRe = /import[ \\t]*\\{([^}]+)\\}[ \\t]*from[ \\t]*['\"]([^'\"]+)['\"]/g;\n  let match: RegExpExecArray | null;\n  while ((match = namedImportRe.exec(code)) !== null) {\n    const specifiers = match[1];\n    const source = match[2];\n    for (const spec of specifiers.split(',')) {\n      const trimmed = spec.trim();\n      if (!trimmed) continue;\n      const asIndex = trimmed.lastIndexOf(' as ');\n      const importedName = asIndex === -1 ? trimmed : trimmed.slice(0, asIndex);\n      const localName = asIndex === -1 ? trimmed : trimmed.slice(asIndex + 4);\n      bindings.push({ localName, importedName, source });\n    }\n  }\n\n  // import X from 'source'\n  const defaultImportRe = /import\\s+(\\w+)\\s+from\\s*['\"]([^'\"]+)['\"]/g;\n  while ((match = defaultImportRe.exec(code)) !== null) {\n    // Avoid duplicating if this was already captured as a named import\n    if (!bindings.some((b) => b.localName === match![1])) {\n      bindings.push({\n        localName: match[1],\n        importedName: 'default',\n        source: match[2],\n      });\n    }\n  }\n\n  return bindings;\n}\n\n/**\n * Determines how a class is exported from the file.\n */\nfunction getExportType(code: string, className: string): 'named' | 'default' {\n  // export default class X\n  if (new RegExp(`export\\\\s+default\\\\s+class\\\\s+${className}\\\\b`).test(code)) {\n    return 'default';\n  }\n  // export class X or export { X }\n  if (\n    new RegExp(`export\\\\s+class\\\\s+${className}\\\\b`).test(code) ||\n    new RegExp(`export\\\\s+\\\\{[^}]*\\\\b${className}\\\\b[^}]*\\\\}`).test(code)\n  ) {\n    return 'named';\n  }\n  return 'named';\n}\n","import type { VMUsageInfo } from './types.js';\n\n/**\n * Detects useViewModel/withViewModel/useCreateViewModel usage sites in the code.\n * Only matches calls where the first argument is a plain identifier (class reference),\n * not a string literal or expression.\n */\nexport function detectViewModelUsage(code: string): VMUsageInfo[] {\n  const usages: VMUsageInfo[] = [];\n\n  // useViewModel(SomeVM)\n  const useViewModelRe = /useViewModel\\s*\\(\\s*(\\w+)\\s*\\)/g;\n  let match: RegExpExecArray | null;\n  while ((match = useViewModelRe.exec(code)) !== null) {\n    usages.push({\n      vmClassName: match[1],\n      usageType: 'useViewModel',\n    });\n  }\n\n  // withViewModel(SomeVM, ...) or withViewModel(SomeVM)(...)\n  const withViewModelRe = /withViewModel\\s*\\(\\s*(\\w+)\\s*[,)]/g;\n  while ((match = withViewModelRe.exec(code)) !== null) {\n    usages.push({\n      vmClassName: match[1],\n      usageType: 'withViewModel',\n    });\n  }\n\n  // useCreateViewModel(SomeVM, ...)\n  const useCreateVMRe = /useCreateViewModel\\s*\\(\\s*(\\w+)\\s*[,)]/g;\n  while ((match = useCreateVMRe.exec(code)) !== null) {\n    usages.push({\n      vmClassName: match[1],\n      usageType: 'useCreateViewModel',\n    });\n  }\n\n  return usages;\n}\n","import type { ObserverCallInfo } from './types.js';\n\nconst DEFAULT_OBSERVER_SOURCES = ['mobx-react-lite', 'mobx-react'];\n\n/**\n * Detects observer() calls that assign to a named variable.\n * Returns info needed to inject displayName assignments.\n */\nexport function detectObserverCalls(\n  code: string,\n  observerSources: string[] = DEFAULT_OBSERVER_SOURCES,\n): ObserverCallInfo[] {\n  const results: ObserverCallInfo[] = [];\n\n  // Only process files that import observer from one of the configured sources\n  const hasObserverImport = observerSources.some((source) => {\n    const re = new RegExp(`from\\\\s+['\"]${escapeRegExp(source)}['\"]`);\n    return re.test(code);\n  });\n  if (!hasObserverImport) {\n    return results;\n  }\n\n  // Match: [export] (const|let|var) Name = observer(\n  const pattern = /(export\\s+)?(?:const|let|var)\\s+(\\w+)\\s*=\\s*observer\\s*\\(/g;\n\n  let match: RegExpExecArray | null;\n  while ((match = pattern.exec(code)) !== null) {\n    const isExported = !!match[1];\n    const varName = match[2];\n    const matchStart = match.index;\n    const observerCallStart = match.index + match[0].length - 1; // position of '('\n\n    // Find the matching closing ')'\n    const statementEnd = findMatchingParenAndSemicolon(code, observerCallStart);\n    if (statementEnd === -1) continue;\n\n    results.push({\n      start: matchStart,\n      statementEnd,\n      varName,\n      isExported,\n    });\n  }\n\n  return results;\n}\n\n/**\n * Given the position of an opening '(' in code, find the matching ')' and\n * any trailing semicolon. Returns the index after the full statement.\n */\nfunction findMatchingParenAndSemicolon(\n  code: string,\n  openParenIndex: number,\n): number {\n  let depth = 0;\n  let i = openParenIndex;\n  let inString: string | null = null;\n  let inTemplate = 0;\n  let escaped = false;\n\n  while (i < code.length) {\n    const ch = code[i];\n\n    if (escaped) {\n      escaped = false;\n      i++;\n      continue;\n    }\n\n    if (ch === '\\\\') {\n      escaped = true;\n      i++;\n      continue;\n    }\n\n    // Track string literals\n    if (inString) {\n      if (ch === inString) inString = null;\n      i++;\n      continue;\n    }\n    if (ch === '\"' || ch === \"'\") {\n      inString = ch;\n      i++;\n      continue;\n    }\n\n    // Track template literals\n    if (ch === '`') {\n      inTemplate++;\n      i++;\n      continue;\n    }\n    if (inTemplate > 0 && ch === '`') {\n      inTemplate--;\n      i++;\n      continue;\n    }\n    if (inTemplate > 0) {\n      i++;\n      continue;\n    }\n\n    if (ch === '(') depth++;\n    else if (ch === ')') {\n      depth--;\n      if (depth === 0) {\n        // Found matching ')', skip trailing whitespace and optional ';'\n        i++;\n        while (i < code.length && (code[i] === ' ' || code[i] === '\\t')) i++;\n        if (i < code.length && code[i] === ';') i++;\n        return i;\n      }\n    }\n\n    i++;\n  }\n\n  return -1;\n}\n\nfunction escapeRegExp(str: string): string {\n  return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","/**\n * Generates the HMR dispose + class-remapping code to inject at the end\n * of a ViewModel class file.\n *\n * On first load: saves current class references via import.meta.hot.dispose().\n * On HMR re-evaluation: reads old refs from hot.data, compares with new refs,\n * remaps viewModelIdsByClasses and linkedAnchorVMClasses, patches instance prototypes.\n */\nexport function generateHmrCode(vmClassNames: string[]): string {\n  if (vmClassNames.length === 0) return '';\n\n  const classRefsObj = vmClassNames.map((name) => `  ${name}`).join(',\\n');\n\n  return `\nif (import.meta.hot) {\n  const __vm_classes__ = {\n${classRefsObj}\n  };\n  if (import.meta.hot.data.__vm_classes__) {\n    const __old_classes__ = import.meta.hot.data.__vm_classes__;\n    const __stores__ = globalThis.__MOBX_VM_PLUGIN_STORES__ || [];\n    for (const __store__ of __stores__) {\n      const __ids_by_classes__ = __store__.viewModelIdsByClasses;\n      const __anchor_classes__ = __store__.linkedAnchorVMClasses;\n      for (const [__name__, __NewClass__] of Object.entries(__vm_classes__)) {\n        const __OldClass__ = __old_classes__[__name__];\n        if (__OldClass__ && __OldClass__ !== __NewClass__) {\n          const __ids__ = __ids_by_classes__.get(__OldClass__);\n          if (__ids__) {\n            __ids_by_classes__.set(__NewClass__, __ids__);\n            __ids_by_classes__.delete(__OldClass__);\n          }\n          for (const [__anchor__, __vmClass__] of __anchor_classes__.entries()) {\n            if (__vmClass__ === __OldClass__) {\n              __anchor_classes__.set(__anchor__, __NewClass__);\n            }\n          }\n          if (__ids__) {\n            const __viewModels__ = __store__.viewModels;\n            for (const __id__ of __ids__) {\n              const __instance__ = __viewModels__.get(__id__);\n              if (__instance__ && __instance__.constructor !== __NewClass__) {\n                Object.setPrototypeOf(__instance__, __NewClass__.prototype);\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n  import.meta.hot.dispose(() => {\n    import.meta.hot.data.__vm_classes__ = __vm_classes__;\n  });\n}`;\n}\n","import type { DevtoolsConfig } from './types.js';\n\nexport const RUNTIME_MODULE_ID = '\\0mobx-view-model-vite-plugin/runtime';\nexport const RUNTIME_MODULE_RESOLVED = '\\0mobx-view-model-vite-plugin/runtime';\n\n/**\n * The virtual module source that subscribes to ViewModelStore creation\n * via the official viewModelsConfig.hooks.storeCreate PubSub hook.\n * Exposes globalThis.__MOBX_VM_PLUGIN_STORES__ for HMR callbacks.\n * When devtools is enabled, also auto-connects mobx-view-model-devtools.\n *\n * ## Bridge pattern for MobX reactivity\n *\n * The devtools bundles its own copy of MobX, so its computed properties\n * cannot observe the host app's ObservableMap (e.g. store.viewModels).\n * To bridge the two MobX instances, the runtime module imports `autorun`\n * from the HOST's `mobx` and sets up a reaction that watches the store's\n * `viewModels` map. When the map changes, the reaction calls\n * `devtools.notifyVmChange()`, which signals a MobX atom inside\n * the devtools' own MobX — forcing `allVms` to re-read the map.\n */\nexport function getRuntimeModuleSource(\n  devtools?: boolean | DevtoolsConfig,\n): string {\n  const devtoolsEnabled = !!devtools;\n  const devtoolsConfig: DevtoolsConfig =\n    typeof devtools === 'object' ? devtools : {};\n\n  const devtoolsImport = devtoolsEnabled\n    ? `import { ViewModelDevtools } from 'mobx-view-model-devtools';`\n    : '';\n\n  const mobxBridgeImport = devtoolsEnabled\n    ? `import { autorun } from 'mobx';`\n    : '';\n\n  const devtoolsSetup = devtoolsEnabled\n    ? `\n// Capture lastPub BEFORE define() — define() creates an internal\n// ViewModelStoreImpl that overwrites lastPub with its own store\nconst __lastStoreBeforeDefine__ = __orig_storeCreate__.lastPub?.[0];\n\nconst __devtools__ = ViewModelDevtools.define({\n  position: ${JSON.stringify(devtoolsConfig.position ?? 'top-right')},\n  defaultIsOpened: ${JSON.stringify(devtoolsConfig.defaultIsOpened ?? false)},\n});\n\nViewModelDevtools.connectExtras({ globalThis });\n\n// The devtools' internal ViewModelStoreImpl — filter it out so only\n// the project's store is connected\nconst __devtoolsInternalCtor__ = __devtools__.vmStore.constructor;\n\nconst __connectDevtools__ = (store) => {\n  if (store.constructor !== __devtoolsInternalCtor__) {\n    ViewModelDevtools.connectViewModels(store);\n    // Bridge: use the HOST's autorun to watch the store's viewModels map.\n    // When the map changes, notify the devtools so its own MobX\n    // computed (allVms) re-reads the latest values.\n    autorun(() => {\n      // Reading .size tracks additions/removals in the HOST's MobX.\n      // Iterating keys tracks key-level changes too.\n      void (store).viewModels?.size;\n      for (const _key of (store).viewModels?.keys() ?? []) { void _key; }\n      __devtools__.notifyVmChange();\n    });\n  }\n};\n\n// Connect the project store that existed before define()\nif (__lastStoreBeforeDefine__) {\n  __stores__.push(__lastStoreBeforeDefine__);\n  __connectDevtools__(__lastStoreBeforeDefine__);\n}`\n    : '';\n\n  const devtoolsConnect = devtoolsEnabled\n    ? `\n  __connectDevtools__(store);`\n    : '';\n\n  return `import { viewModelsConfig } from 'mobx-view-model';\n${devtoolsImport}\n${mobxBridgeImport}\n\nconst __stores__ = [];\n\nconst __orig_storeCreate__ = viewModelsConfig.hooks.storeCreate;\n${devtoolsSetup}\n\n__orig_storeCreate__.sub((store) => {\n  __stores__.push(store);${devtoolsConnect}\n});\n\n${\n  !devtoolsEnabled\n    ? `if (__orig_storeCreate__.lastPub?.[0]) {\n  __stores__.push(__orig_storeCreate__.lastPub[0]);\n}`\n    : ''\n}\n\nglobalThis.__MOBX_VM_PLUGIN_STORES__ = __stores__;\n`;\n}\n","import { createRequire } from 'node:module';\nimport fs from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { Plugin } from 'vite';\nimport MagicString from 'magic-string';\nimport { DependencyGraph } from './dependency-graph.js';\nimport {\n  detectViewModelClasses,\n  extractImportBindings,\n} from './detect-vm-classes.js';\nimport type { ImportedVmClass } from './detect-vm-classes.js';\nimport { detectViewModelUsage } from './detect-vm-usage.js';\nimport { detectObserverCalls } from './detect-observer.js';\nimport { generateHmrCode } from './hmr-runtime.js';\nimport {\n  RUNTIME_MODULE_ID,\n  RUNTIME_MODULE_RESOLVED,\n  getRuntimeModuleSource,\n} from './store-access.js';\nimport type { MobxVmVitePluginOptions } from './types.js';\n\nconst PLUGIN_NAME = 'mobx-view-model-vite-plugin';\n\nconst _require = createRequire(import.meta.url);\n\nconst MOBX_VM_IMPORT_RE = /from\\s+['\"]mobx-view-model(?:\\/react|\\/core)?['\"]/;\n\nconst DEFAULT_OBSERVER_SOURCES = ['mobx-react-lite', 'mobx-react'];\n\n/**\n * Resolves a package to its ESM entry point using the plugin's own\n * node_modules context. This is needed because the virtual runtime module\n * has no resolution context — Vite can't follow bare imports from it.\n */\nfunction resolveEsmEntry(bareImport: string): string | undefined {\n  try {\n    const cjsPath = _require.resolve(bareImport);\n    const pkgDir = dirname(cjsPath);\n    const pkgJson = JSON.parse(\n      fs.readFileSync(join(pkgDir, 'package.json'), 'utf8'),\n    );\n    const esmEntry =\n      pkgJson.exports?.['.']?.import ?? pkgJson.module ?? 'index.js';\n    return join(pkgDir, esmEntry);\n  } catch {\n    return undefined;\n  }\n}\n\nexport function mobxVmVitePlugin(options?: MobxVmVitePluginOptions): Plugin {\n  const hmr = options?.hmr ?? true;\n  const autoDisplayName = options?.autoDisplayName ?? true;\n  const devtools = options?.devtools;\n  const observerSources = options?.observerSources ?? DEFAULT_OBSERVER_SOURCES;\n  const debug = options?.debug ?? false;\n\n  const log = debug\n    ? (...args: unknown[]) => console.log(`[${PLUGIN_NAME}]`, ...args)\n    : () => {};\n\n  const graph = new DependencyGraph();\n\n  let isProduction = false;\n  let _root = '';\n\n  return {\n    name: PLUGIN_NAME,\n\n    config() {\n      // Force Vite to always resolve these packages from the project root,\n      // preventing pnpm's nested node_modules from creating duplicate\n      // instances. A single MobX instance is critical — two separate copies\n      // break reactivity (the devtools' computed properties can't observe\n      // observables created by the app's MobX).\n      return {\n        resolve: {\n          dedupe: [\n            'mobx',\n            'mobx-view-model',\n            'mobx-view-model-react',\n            'react',\n            'react-dom',\n            'mobx-react-lite',\n          ],\n        },\n      };\n    },\n\n    configResolved(config) {\n      isProduction = config.command === 'build';\n      _root = config.root;\n    },\n\n    resolveId(id, importer) {\n      if (id === RUNTIME_MODULE_ID) {\n        return RUNTIME_MODULE_RESOLVED;\n      }\n      // Resolve devtools and its external deps when imported from the virtual\n      // runtime module (which has no resolution context). We must resolve the\n      // ESM entry (not CJS) because the virtual module uses named imports.\n      // pnpm isolates deps, so this.resolve(id, root) fails — the package\n      // is only accessible from the plugin's own node_modules context.\n      // We use createRequire (which resolves from the plugin's location)\n      // to find the CJS path, then read the adjacent package.json to\n      // determine the correct ESM entry point.\n      if (importer === RUNTIME_MODULE_RESOLVED) {\n        // mobx-view-model-devtools\n        if (id === 'mobx-view-model-devtools') {\n          return resolveEsmEntry(id);\n        }\n        // mobx-view-model (imported by the runtime module)\n        if (id === 'mobx-view-model') {\n          return resolveEsmEntry(id);\n        }\n        // mobx — needed by the bridge autorun to observe the host's store\n        if (id === 'mobx') {\n          return resolveEsmEntry(id);\n        }\n      }\n    },\n\n    load(id) {\n      if (id === RUNTIME_MODULE_RESOLVED) {\n        return getRuntimeModuleSource(devtools);\n      }\n    },\n\n    transform(code, id) {\n      if (isProduction) return;\n      if (!id.endsWith('.ts') && !id.endsWith('.tsx')) return;\n      if (id.includes('node_modules')) return;\n      if (id === RUNTIME_MODULE_RESOLVED) return;\n\n      const isMobxVmFile = MOBX_VM_IMPORT_RE.test(code);\n      const isObserverFile = observerSources.some((source) => {\n        const re = new RegExp(\n          `from\\\\s+['\"]${source.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}['\"]`,\n        );\n        return re.test(code);\n      });\n\n      // Resolve imported VM classes from the dependency graph for cross-file inheritance\n      const importedVmClasses: ImportedVmClass[] = [];\n      const importBindings = extractImportBindings(code);\n      for (const binding of importBindings) {\n        const vmType = graph.getVmType(binding.importedName);\n        if (vmType) {\n          importedVmClasses.push({\n            localName: binding.localName,\n            type: vmType,\n          });\n        }\n      }\n\n      // Skip files that have no mobx-view-model imports, no observer imports,\n      // and don't import any known VM classes from other files\n      if (!isMobxVmFile && !isObserverFile && importedVmClasses.length === 0)\n        return;\n\n      const s = new MagicString(code);\n      let hasEdits = false;\n\n      const classes = detectViewModelClasses(code, importedVmClasses);\n      const usages = detectViewModelUsage(code);\n\n      if (classes.length > 0) {\n        log(\n          `detected VM classes in ${id}:`,\n          classes.map((c) => `${c.name} (${c.type})`),\n        );\n      }\n      if (usages.length > 0) {\n        log(\n          `detected VM usages in ${id}:`,\n          usages.map((u) => `${u.usageType}(${u.vmClassName})`),\n        );\n      }\n\n      graph.addFile(id, classes, usages);\n\n      // Inject runtime module import into files with ViewModel classes\n      // ESM deduplicates imports, so multiple imports are safe\n      // Also inject when devtools is enabled (even without HMR)\n      const needsRuntime = (hmr || devtools) && classes.length > 0;\n      if (needsRuntime) {\n        log(`injecting runtime import into ${id}`);\n        s.prepend(`import '${RUNTIME_MODULE_ID}';\\n`);\n        hasEdits = true;\n      }\n\n      // Feature 1: Inject HMR code into ViewModel class files\n      if (hmr && classes.length > 0) {\n        const vmClassNames = classes.map((c) => c.name);\n        const hmrCode = generateHmrCode(vmClassNames);\n        if (hmrCode) {\n          log(`injecting HMR code into ${id} for:`, vmClassNames);\n          s.append(hmrCode);\n          hasEdits = true;\n        }\n      }\n\n      // Feature 2: Inject displayName for observer() components\n      if (autoDisplayName) {\n        const observerCalls = detectObserverCalls(code, observerSources);\n        if (observerCalls.length > 0) {\n          log(\n            `detected observer calls in ${id}:`,\n            observerCalls.map((c) => c.varName),\n          );\n        }\n        // Process in reverse order to avoid offset shifts\n        for (let i = observerCalls.length - 1; i >= 0; i--) {\n          const call = observerCalls[i];\n          const displayNameCode = `\\n${call.varName}.displayName = \"${call.varName}\";`;\n          s.appendRight(call.statementEnd, displayNameCode);\n          hasEdits = true;\n        }\n      }\n\n      if (!hasEdits) return;\n\n      return {\n        code: s.toString(),\n        map: s.generateMap({ hires: true }),\n      };\n    },\n\n    async handleHotUpdate(ctx) {\n      if (isProduction) return;\n      const { file } = ctx;\n      if (!file.endsWith('.ts') && !file.endsWith('.tsx')) return;\n      if (file.includes('node_modules')) return;\n\n      // Re-analyze the changed file from disk\n      let content: string;\n      try {\n        content = fs.readFileSync(file, 'utf8');\n      } catch {\n        return;\n      }\n\n      const importedVmClasses: ImportedVmClass[] = [];\n      const importBindings = extractImportBindings(content);\n      for (const binding of importBindings) {\n        const vmType = graph.getVmType(binding.importedName);\n        if (vmType) {\n          importedVmClasses.push({\n            localName: binding.localName,\n            type: vmType,\n          });\n        }\n      }\n      const classes = detectViewModelClasses(content, importedVmClasses);\n      const usages = detectViewModelUsage(content);\n      graph.addFile(file, classes, usages);\n\n      // If this file doesn't export ViewModel classes, no special handling needed\n      if (classes.length === 0) return;\n\n      log(\n        `HMR update in ${file}, VM classes:`,\n        classes.map((c) => c.name),\n      );\n\n      // Find all consumer modules and ensure they're included in the HMR update\n      const affectedModules = new Set(ctx.modules);\n\n      for (const cls of classes) {\n        const consumers = graph.getVmConsumers(cls.name);\n        if (consumers.size > 0) {\n          log(`  ${cls.name} consumers:`, [...consumers]);\n        }\n        for (const consumerPath of consumers) {\n          const mods = ctx.server.moduleGraph.getModulesByFile(consumerPath);\n          if (mods) {\n            for (const mod of mods) {\n              affectedModules.add(mod);\n            }\n          }\n        }\n      }\n\n      return [...affectedModules];\n    },\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAa,kBAAb,MAA6B;;CAE3B,4BAAoB,IAAI,IAA2B;;CAGnD,0BAAkB,IAAI,IAA2B;;CAGjD,8BAAsB,IAAI,IAAyB;;CAGnD,+BAAuB,IAAI,IAAoB;CAE/C,QACE,UACA,SACA,QACM;EAEN,KAAK,WAAW,QAAQ;EAGxB,IAAI,QAAQ,SAAS,GAAG;GACtB,KAAK,UAAU,IAAI,UAAU,OAAO;GACpC,KAAK,MAAM,OAAO,SAChB,KAAK,aAAa,IAAI,IAAI,MAAM,QAAQ;EAE5C;EAGA,IAAI,OAAO,SAAS,GAAG;GACrB,KAAK,QAAQ,IAAI,UAAU,MAAM;GACjC,KAAK,MAAM,SAAS,QAAQ;IAC1B,IAAI,YAAY,KAAK,YAAY,IAAI,MAAM,WAAW;IACtD,IAAI,CAAC,WAAW;KACd,4BAAY,IAAI,IAAI;KACpB,KAAK,YAAY,IAAI,MAAM,aAAa,SAAS;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