| import { |
| runOutsidePluginMetadataSnapshotScope, |
| withPluginMetadataSnapshotScope, |
| } from "../current-plugin-metadata-snapshot.js"; |
| import type { PluginMetadataSnapshot } from "../plugin-metadata-snapshot.types.js"; |
| import { createEmptyPluginRegistry } from "../registry-empty.js"; |
| import type { PluginRegistry } from "../registry-types.js"; |
| import { |
| runOutsidePluginRuntimeRegistryScope, |
| withPluginRuntimeRegistryScope, |
| } from "./gateway-request-scope.js"; |
| import { |
| withPluginRuntimeGenerationRegistryScope, |
| runOutsidePluginRuntimeGenerationRegistryScope, |
| } from "./generation-state.js"; |
|
|
| export { getPluginRuntimeGenerationRegistry } from "./generation-state.js"; |
|
|
| |
| export function withPluginRuntimeGenerationScope<T>( |
| generation: { |
| metadataSnapshot: PluginMetadataSnapshot; |
| pluginRegistry?: PluginRegistry; |
| }, |
| run: () => T, |
| ): T { |
| const pluginRegistry = generation.pluginRegistry ?? createEmptyPluginRegistry(); |
| return withPluginMetadataSnapshotScope( |
| generation.metadataSnapshot, |
| () => |
| withPluginRuntimeGenerationRegistryScope(pluginRegistry, () => |
| withPluginRuntimeRegistryScope( |
| pluginRegistry, |
| run, |
| generation.metadataSnapshot.declaredProviderOwners, |
| ), |
| ), |
| |
| { trustConfigIdentity: true }, |
| ); |
| } |
|
|
| |
| export function runOutsidePluginRuntimeGenerationScope<T>(run: () => T): T { |
| return runOutsidePluginRuntimeGenerationRegistryScope(() => |
| runOutsidePluginMetadataSnapshotScope(() => runOutsidePluginRuntimeRegistryScope(run)), |
| ); |
| } |
|
|