{"version":3,"file":"subscribe-injection.js","sources":["../../../../src/orchestrion/config/subscribe-injection.ts"],"sourcesContent":["import type { InstrumentationConfig } from '../apmTypes';\n\n/**\n * Name shared by the `Program` injection configs (their `transform` field) and\n * the custom transform registered on the bundler plugin (its `customTransforms`\n * key). Any unique string works — it only has to match on both sides.\n *\n * Lives in this dependency-free leaf so the per-library config files can build\n * their injection configs without importing the transform implementation (which\n * pulls in `meriyah` and must never reach the runtime `--import` path).\n */\nexport const SUBSCRIBE_TRANSFORM_NAME = 'sentrySubscribeOrchestrionChannel';\n\n/**\n * Turn a library's channel-publishing configs into the `Program`-matching\n * injection configs that make each instrumented file self-register its channel\n * subscriber (via the {@link SUBSCRIBE_TRANSFORM_NAME} custom transform).\n *\n * Emits one injection per distinct instrumented file (deduped by module\n * matcher), so the subscribe snippet lands in exactly the files that receive\n * channels and inherits their precise version ranges. `channelName` carries the\n * package name (not a real channel — nothing is wrapped here) so the transform\n * can look up which subscriber to import.\n *\n * Co-located with each library's config (e.g. `mysqlSubscribeInjection`) but\n * kept OUT of `SENTRY_INSTRUMENTATIONS`: the runtime `--import` hook consumes\n * that list and can't register the custom transform, and an unregistered\n * `transform` makes the code-transformer drop the whole file. They are\n * aggregated separately into `SUBSCRIBE_INJECTIONS` and only handed to a bundler\n * plugin that opts in (and registers the transform).\n */\nexport function toSubscribeInjections(configs: InstrumentationConfig[]): InstrumentationConfig[] {\n const seen = new Set();\n const injections: InstrumentationConfig[] = [];\n\n for (const { module } of configs) {\n const key = `${module.name}\\0${module.versionRange}\\0${String(module.filePath)}`;\n\n if (seen.has(key)) {\n continue;\n }\n\n seen.add(key);\n\n injections.push({\n channelName: module.name,\n module,\n astQuery: 'Program',\n transform: SUBSCRIBE_TRANSFORM_NAME,\n });\n }\n\n return injections;\n}\n"],"names":[],"mappings":"AAWO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,wBAAA,CAAA,CAAA,CAA2B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA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