{"version":3,"file":"rootInstrumentation.js","sources":["../../src/rootInstrumentation.ts"],"sourcesContent":["import type { Mixins, VueSentry } from './tracing';\nimport type { Vue } from './types';\n\nconst instrumentedApps = new WeakSet();\n\n/**\n * The mixin hooks only check `$root === this` to detect the root component, so a self-referential\n * stand-in works in place of the real instance, which does not exist yet at wrap time.\n */\nfunction createRootViewModel(): VueSentry {\n const vm: { $root?: unknown; $props: Record } = { $props: {} };\n vm.$root = vm;\n return vm as unknown as VueSentry;\n}\n\n/**\n * Records the `Application Render` and root component mount spans by wrapping `app.mount()`, for\n * builds where the Options API is compiled out and `app.mixin()` is a silent no-op (Nuxt 5 default).\n *\n * Vue runs all `mounted` hooks before `mount()` returns, so the wrap covers the same window as the\n * mixin's root hooks. Late mounts extend the span only when mixins are used: they record render activity\n * from every component, while the `app.mount()` wrap only observes the root component.\n */\nexport function instrumentAppMountWithoutMixin(app: Vue, mixins: Mixins): void {\n // A second wrap would duplicate the root spans (e.g. user and Nuxt SDK both add the integration).\n if (instrumentedApps.has(app)) {\n return;\n }\n\n const appWithMount = app as Vue & { mount?: (...args: unknown[]) => unknown };\n const originalMount = appWithMount.mount;\n // Guards odd app-like objects; Vue 2 constructors lack `mount` but never get here (their `app.mixin()` works).\n if (typeof originalMount !== 'function') {\n return;\n }\n\n const vm = createRootViewModel();\n instrumentedApps.add(app);\n\n // `createTracingMixins` always merges `DEFAULT_HOOKS`, so the `mount` pair exists.\n const mountHooks = mixins as Partial void>>;\n\n appWithMount.mount = function (...args: unknown[]): unknown {\n mountHooks.beforeMount?.call(vm);\n try {\n return originalMount.apply(this, args);\n } finally {\n // Also runs when mounting throws, so the started root component span always ends.\n mountHooks.mounted?.call(vm);\n }\n };\n}\n"],"names":[],"mappings":";;AAGA,MAAM,gBAAA,uBAAuB,OAAA,EAAa;AAM1C,SAAS,mBAAA,GAAiC;AACxC,EAAA,MAAM,EAAA,GAA2D,EAAE,MAAA,EAAQ,EAAC,EAAE;AAC9E,EAAA,EAAA,CAAG,KAAA,GAAQ,EAAA;AACX,EAAA,OAAO,EAAA;AACT;AAUO,SAAS,8BAAA,CAA+B,KAAU,MAAA,EAAsB;AAE7E,EAAA,IAAI,gBAAA,CAAiB,GAAA,CAAI,GAAG,CAAA,EAAG;AAC7B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,YAAA,GAAe,GAAA;AACrB,EAAA,MAAM,gBAAgB,YAAA,CAAa,KAAA;AAEnC,EAAA,IAAI,OAAO,kBAAkB,UAAA,EAAY;AACvC,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,KAAK,mBAAA,EAAoB;AAC/B,EAAA,gBAAA,CAAiB,IAAI,GAAG,CAAA;AAGxB,EAAA,MAAM,UAAA,GAAa,MAAA;AAEnB,EAAA,YAAA,CAAa,KAAA,GAAQ,YAAa,IAAA,EAA0B;AAC1D,IAAA,UAAA,CAAW,WAAA,EAAa,KAAK,EAAE,CAAA;AAC/B,IAAA,IAAI;AACF,MAAA,OAAO,aAAA,CAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAAA,IACvC,CAAA,SAAE;AAEA,MAAA,UAAA,CAAW,OAAA,EAAS,KAAK,EAAE,CAAA;AAAA,IAC7B;AAAA,EACF,CAAA;AACF;;;;"}