{"version":3,"file":"index.cjs","names":["runtimeCore"],"sources":["../src/index.ts"],"sourcesContent":["import * as runtimeCore from '@module-federation/runtime-tools/runtime-core';\n\nimport type { ModuleFederationRuntimePlugin } from '@module-federation/runtime-tools/runtime-core';\ndeclare global {\n var __VERSION__: string;\n var _FEDERATION_RUNTIME_CORE: typeof runtimeCore;\n var _FEDERATION_RUNTIME_CORE_FROM: {\n version: string;\n name: string;\n };\n}\n\nfunction injectExternalRuntimeCorePlugin(): ModuleFederationRuntimePlugin {\n return {\n name: 'inject-external-runtime-core-plugin',\n version: __VERSION__,\n beforeInit(args) {\n const globalRef = (\n runtimeCore as typeof runtimeCore & {\n Global?: typeof runtimeCore.Global;\n }\n ).Global;\n if (!globalRef || typeof globalRef !== 'object') {\n return args;\n }\n const name = args.options.name;\n const version = __VERSION__;\n if (\n globalRef._FEDERATION_RUNTIME_CORE &&\n globalRef._FEDERATION_RUNTIME_CORE_FROM &&\n (globalRef._FEDERATION_RUNTIME_CORE_FROM.name !== name ||\n globalRef._FEDERATION_RUNTIME_CORE_FROM.version !== version)\n ) {\n console.warn(\n `Detect multiple module federation runtime! Injected runtime from ${globalRef._FEDERATION_RUNTIME_CORE_FROM.name}@${globalRef._FEDERATION_RUNTIME_CORE_FROM.version} and current is ${name}@${version}, pleasure ensure there is only one consumer to provider runtime!`,\n );\n return args;\n }\n globalRef._FEDERATION_RUNTIME_CORE = runtimeCore;\n globalRef._FEDERATION_RUNTIME_CORE_FROM = {\n version,\n name,\n };\n return args;\n },\n };\n}\n\nexport default injectExternalRuntimeCorePlugin;\n"],"mappings":";;;;;AAYA,SAAS,kCAAiE;AACxE,QAAO;EACL,MAAM;EACN;EACA,WAAW,MAAM;GACf,MAAM,YACJA,8CAGA;AACF,OAAI,CAAC,aAAa,OAAO,cAAc,SACrC,QAAO;GAET,MAAM,OAAO,KAAK,QAAQ;GAC1B,MAAM;AACN,OACE,UAAU,4BACV,UAAU,kCACT,UAAU,8BAA8B,SAAS,QAChD,UAAU,8BAA8B,YAAY,UACtD;AACA,YAAQ,KACN,oEAAoE,UAAU,8BAA8B,KAAK,GAAG,UAAU,8BAA8B,QAAQ,kBAAkB,KAAK,GAAG,QAAQ,mEACvM;AACD,WAAO;;AAET,aAAU,2BAA2BA;AACrC,aAAU,gCAAgC;IACxC;IACA;IACD;AACD,UAAO;;EAEV"}