{"version":3,"file":"PanelScreenshotService.cjs","sources":["../../../src/services/PanelScreenshotService.ts"],"sourcesContent":["/**\n * Options for the panel screenshot service.\n *\n * @alpha\n */\nexport interface PanelScreenshotOptions {\n  /**\n   * Output image format. Defaults to `'png'`.\n   */\n  format?: 'png' | 'jpeg' | 'webp';\n\n  /**\n   * Scene root used to resolve `panelPathId` to a `pluginId` for plugin\n   * overrides via `PanelPlugin.onScreenshot`. Pass `this` from a `SceneObject`,\n   * a scene reference held by your component, or omit to fall back to the\n   * global `window.__grafanaSceneContext`.\n   *\n   * Typed as `unknown` so `@grafana/runtime` does not depend on\n   * `@grafana/scenes`; scene-aware callers should pass a concrete `SceneObject`\n   * (the implementation duck-types it). A scenes-side typed wrapper can be\n   * layered on top without changing this surface.\n   *\n   * If the scene context cannot be resolved to a `pluginId`, capture falls\n   * through to the default html-to-image renderer.\n   *\n   * @alpha\n   */\n  sceneContext?: unknown;\n}\n\n/**\n * Captures a snapshot of a panel as the user currently sees it.\n *\n * The panel must currently be visible in the user's browser. Off-screen,\n * unmounted, or virtualised panels throw.\n *\n * Should be accessed via {@link getPanelScreenshotService}.\n *\n * @alpha\n */\nexport interface PanelScreenshotService {\n  /**\n   * Capture the panel identified by `panelPathId`.\n   *\n   * Obtain `panelPathId` from `PluginExtensionPanelContext.panelPathId` when\n   * consuming this service from a panel-menu extension. The value is opaque -\n   * pass it through unchanged. Unique per rendered panel instance, including\n   * across repeated panels.\n   *\n   * Override hooks registered via `PanelPlugin.setScreenshotImage()` are only\n   * consulted in scenes-based dashboards. In legacy dashboards, capture()\n   * always uses the default html-to-image path.\n   *\n   * @param panelPathId opaque panel identifier (see `PluginExtensionPanelContext.panelPathId`)\n   * @param options output format options\n   * @returns a Blob containing the rendered image bytes\n   * @throws if the panel is not currently visible, or if the capture fails\n   */\n  capture(panelPathId: string, options?: PanelScreenshotOptions): Promise<Blob>;\n}\n\nlet singletonInstance: PanelScreenshotService;\n\n/**\n * Used during startup by Grafana to set the PanelScreenshotService so it is available\n * via {@link getPanelScreenshotService} to the rest of the application.\n *\n * @internal\n */\nexport function setPanelScreenshotService(instance: PanelScreenshotService) {\n  singletonInstance = instance;\n}\n\n/**\n * Used to retrieve the {@link PanelScreenshotService}.\n *\n * @alpha\n */\nexport function getPanelScreenshotService(): PanelScreenshotService {\n  return singletonInstance;\n}\n"],"names":[],"mappings":";;;;;AA6DA,IAAI,iBAAA;AAQG,SAAS,0BAA0B,QAAA,EAAkC;AAC1E,EAAA,iBAAA,GAAoB,QAAA;AACtB;AAOO,SAAS,yBAAA,GAAoD;AAClE,EAAA,OAAO,iBAAA;AACT;;;;;"}