{"version":3,"file":"display-client-xvxWly5F.mjs","names":[],"sources":["../src/display/display-client.ts"],"sourcesContent":["/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  callServiceFunction,\n  closeService,\n  isServiceAvailable,\n  openService,\n  resolveHost,\n  type ServiceClientOptions,\n  type ServiceHandle,\n} from '../common/service-rpc.ts';\nimport type {\n  DisplayOutputInfo,\n  DisplaySourceInfo,\n  DisplayTouchGestureConfig,\n} from './display-types.ts';\n\n/** Registered name (`helper::Display::get_name()`). */\nexport const DISPLAY_SERVICE_NAME = 'Display';\n\n/** RPC function names (`helper::Display::FunctionId`). */\nexport const DISPLAY_FUNCTIONS = {\n  GetOutputs: 'GetOutputs',\n  GetSources: 'GetSources',\n  RegisterSource: 'RegisterSource',\n  UnregisterSource: 'UnregisterSource',\n  RequestOutput: 'RequestOutput',\n  ReleaseOutput: 'ReleaseOutput',\n  SetActiveSource: 'SetActiveSource',\n  GetActiveSource: 'GetActiveSource',\n  SetActiveSourceRole: 'SetActiveSourceRole',\n  GetActiveRole: 'GetActiveRole',\n  GetSourceRoles: 'GetSourceRoles',\n  SetTouchGestureConfig: 'SetTouchGestureConfig',\n  GetTouchGestureConfig: 'GetTouchGestureConfig',\n  SetBacklightBrightness: 'SetBacklightBrightness',\n  GetBacklightBrightness: 'GetBacklightBrightness',\n  SetBacklightOnOff: 'SetBacklightOnOff',\n  GetBacklightOnOff: 'GetBacklightOnOff',\n  LoadData: 'LoadData',\n  ResetData: 'ResetData',\n} as const;\n\nexport type DisplayClientOptions = ServiceClientOptions;\n\nexport { type ServiceHandle as DisplayHandle };\n\nexport function isDisplayAvailable(options?: DisplayClientOptions): boolean {\n  return isServiceAvailable(DISPLAY_SERVICE_NAME, options);\n}\n\nexport function openDisplay(options?: DisplayClientOptions): ServiceHandle {\n  return openService(DISPLAY_SERVICE_NAME, options);\n}\n\nexport function closeDisplay(handle: ServiceHandle, options?: DisplayClientOptions): void {\n  closeService(handle, options);\n}\n\nfunction callDisplay<T>(\n  handle: ServiceHandle,\n  functionName: string,\n  params: Record<string, unknown>,\n  options?: DisplayClientOptions,\n): T {\n  return callServiceFunction<T>(resolveHost(options), handle, functionName, params);\n}\n\nexport function getOutputs(\n  handle: ServiceHandle,\n  options?: DisplayClientOptions,\n): DisplayOutputInfo[] {\n  return callDisplay<DisplayOutputInfo[]>(handle, DISPLAY_FUNCTIONS.GetOutputs, {}, options);\n}\n\nexport function getSources(\n  handle: ServiceHandle,\n  options?: DisplayClientOptions,\n): DisplaySourceInfo[] {\n  return callDisplay<DisplaySourceInfo[]>(handle, DISPLAY_FUNCTIONS.GetSources, {}, options);\n}\n\nexport function registerSource(\n  handle: ServiceHandle,\n  source: DisplaySourceInfo,\n  options?: DisplayClientOptions,\n): number {\n  return callDisplay<number>(handle, DISPLAY_FUNCTIONS.RegisterSource, { Source: source }, options);\n}\n\nexport function unregisterSource(\n  handle: ServiceHandle,\n  sourceName: string,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.UnregisterSource,\n    { SourceName: sourceName },\n    options,\n  );\n}\n\nexport function requestOutput(\n  handle: ServiceHandle,\n  sourceName: string,\n  outputName: string,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.RequestOutput,\n    { SourceName: sourceName, OutputName: outputName },\n    options,\n  );\n}\n\nexport function releaseOutput(\n  handle: ServiceHandle,\n  sourceName: string,\n  outputName: string,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.ReleaseOutput,\n    { SourceName: sourceName, OutputName: outputName },\n    options,\n  );\n}\n\nexport function setActiveSource(\n  handle: ServiceHandle,\n  outputName: string,\n  sourceName: string,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.SetActiveSource,\n    { OutputName: outputName, SourceName: sourceName },\n    options,\n  );\n}\n\nexport function getActiveSource(\n  handle: ServiceHandle,\n  outputName: string,\n  options?: DisplayClientOptions,\n): string {\n  return callDisplay<string>(\n    handle,\n    DISPLAY_FUNCTIONS.GetActiveSource,\n    { OutputName: outputName },\n    options,\n  );\n}\n\nexport function setTouchGestureConfig(\n  handle: ServiceHandle,\n  outputId: number,\n  config: DisplayTouchGestureConfig,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.SetTouchGestureConfig,\n    { OutputId: outputId, Config: config },\n    options,\n  );\n}\n\nexport function getTouchGestureConfig(\n  handle: ServiceHandle,\n  outputId: number,\n  options?: DisplayClientOptions,\n): DisplayTouchGestureConfig {\n  return callDisplay<DisplayTouchGestureConfig>(\n    handle,\n    DISPLAY_FUNCTIONS.GetTouchGestureConfig,\n    { OutputId: outputId },\n    options,\n  );\n}\n\nexport function setBacklightBrightness(\n  handle: ServiceHandle,\n  outputId: number,\n  brightness: number,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.SetBacklightBrightness,\n    { OutputId: outputId, Brightness: brightness },\n    options,\n  );\n}\n\nexport function getBacklightBrightness(\n  handle: ServiceHandle,\n  outputId: number,\n  options?: DisplayClientOptions,\n): number {\n  return callDisplay<number>(\n    handle,\n    DISPLAY_FUNCTIONS.GetBacklightBrightness,\n    { OutputId: outputId },\n    options,\n  );\n}\n\nexport function setBacklightOnOff(\n  handle: ServiceHandle,\n  outputId: number,\n  on: boolean,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.SetBacklightOnOff,\n    { OutputId: outputId, On: on },\n    options,\n  );\n}\n\nexport function getBacklightOnOff(\n  handle: ServiceHandle,\n  outputId: number,\n  options?: DisplayClientOptions,\n): boolean {\n  return callDisplay<boolean>(\n    handle,\n    DISPLAY_FUNCTIONS.GetBacklightOnOff,\n    { OutputId: outputId },\n    options,\n  );\n}\n\nexport function setActiveSourceRole(\n  handle: ServiceHandle,\n  outputName: string,\n  role: string,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(\n    handle,\n    DISPLAY_FUNCTIONS.SetActiveSourceRole,\n    { OutputName: outputName, Role: role },\n    options,\n  );\n}\n\nexport function getActiveRole(\n  handle: ServiceHandle,\n  outputName: string,\n  options?: DisplayClientOptions,\n): string {\n  return callDisplay<string>(\n    handle,\n    DISPLAY_FUNCTIONS.GetActiveRole,\n    { OutputName: outputName },\n    options,\n  );\n}\n\nexport function getSourceRoles(handle: ServiceHandle, options?: DisplayClientOptions): string[] {\n  return callDisplay<string[]>(handle, DISPLAY_FUNCTIONS.GetSourceRoles, {}, options);\n}\n\nexport function loadDisplayData(\n  handle: ServiceHandle,\n  outputId: number,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(handle, DISPLAY_FUNCTIONS.LoadData, { OutputId: outputId }, options);\n}\n\nexport function resetDisplayData(\n  handle: ServiceHandle,\n  outputId: number,\n  options?: DisplayClientOptions,\n): void {\n  callDisplay<void>(handle, DISPLAY_FUNCTIONS.ResetData, { OutputId: outputId }, options);\n}\n"],"mappings":";;;AAmBA,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;CAC/B,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,kBAAkB;CAClB,eAAe;CACf,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,qBAAqB;CACrB,eAAe;CACf,gBAAgB;CAChB,uBAAuB;CACvB,uBAAuB;CACvB,wBAAwB;CACxB,wBAAwB;CACxB,mBAAmB;CACnB,mBAAmB;CACnB,UAAU;CACV,WAAW;AACb;AAMA,SAAgB,mBAAmB,SAAyC;CAC1E,OAAO,mBAAmB,sBAAsB,OAAO;AACzD;AAEA,SAAgB,YAAY,SAA+C;CACzE,OAAO,YAAY,sBAAsB,OAAO;AAClD;AAEA,SAAgB,aAAa,QAAuB,SAAsC;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