{"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/utils-client.ts","../../src/utils/utils.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  DebugCapabilities,\n  DebugConfig,\n  DebugRuntimeState,\n  DebugSnapshot,\n  MemoryDebugSnapshot,\n} from './utils-types.ts';\n\nexport const UTILS_SERVICE_NAME = 'Utils';\n\nexport const UTILS_FUNCTIONS = {\n  GetDebugCapabilities: 'GetDebugCapabilities',\n  GetDebugConfig: 'GetDebugConfig',\n  SetDebugConfig: 'SetDebugConfig',\n  StartMemoryDebug: 'StartMemoryDebug',\n  StopMemoryDebug: 'StopMemoryDebug',\n  StartThreadDebug: 'StartThreadDebug',\n  StopThreadDebug: 'StopThreadDebug',\n  GetDebugState: 'GetDebugState',\n  GetDebugSnapshot: 'GetDebugSnapshot',\n  GetMemorySnapshot: 'GetMemorySnapshot',\n} as const;\n\nexport type UtilsClientOptions = ServiceClientOptions;\nexport { type ServiceHandle as UtilsHandle };\n\nexport function isUtilsAvailable(options?: UtilsClientOptions): boolean {\n  return isServiceAvailable(UTILS_SERVICE_NAME, options);\n}\n\nexport function openUtils(options?: UtilsClientOptions): ServiceHandle {\n  return openService(UTILS_SERVICE_NAME, options);\n}\n\nexport function closeUtils(handle: ServiceHandle, options?: UtilsClientOptions): void {\n  closeService(handle, options);\n}\n\nexport function getDebugCapabilities(\n  handle: ServiceHandle,\n  options?: UtilsClientOptions,\n): DebugCapabilities {\n  return callServiceFunction<DebugCapabilities>(\n    resolveHost(options),\n    handle,\n    UTILS_FUNCTIONS.GetDebugCapabilities,\n    {},\n  );\n}\n\nexport function getDebugConfig(handle: ServiceHandle, options?: UtilsClientOptions): DebugConfig {\n  return callServiceFunction<DebugConfig>(\n    resolveHost(options),\n    handle,\n    UTILS_FUNCTIONS.GetDebugConfig,\n    {},\n  );\n}\n\nexport function setDebugConfig(\n  handle: ServiceHandle,\n  config: DebugConfig,\n  options?: UtilsClientOptions,\n): void {\n  callServiceFunction<void>(resolveHost(options), handle, UTILS_FUNCTIONS.SetDebugConfig, {\n    Config: config,\n  });\n}\n\nexport function startMemoryDebug(handle: ServiceHandle, options?: UtilsClientOptions): void {\n  callServiceFunction<void>(resolveHost(options), handle, UTILS_FUNCTIONS.StartMemoryDebug, {});\n}\n\nexport function stopMemoryDebug(handle: ServiceHandle, options?: UtilsClientOptions): void {\n  callServiceFunction<void>(resolveHost(options), handle, UTILS_FUNCTIONS.StopMemoryDebug, {});\n}\n\nexport function startThreadDebug(handle: ServiceHandle, options?: UtilsClientOptions): void {\n  callServiceFunction<void>(resolveHost(options), handle, UTILS_FUNCTIONS.StartThreadDebug, {});\n}\n\nexport function stopThreadDebug(handle: ServiceHandle, options?: UtilsClientOptions): void {\n  callServiceFunction<void>(resolveHost(options), handle, UTILS_FUNCTIONS.StopThreadDebug, {});\n}\n\nexport function getDebugState(\n  handle: ServiceHandle,\n  options?: UtilsClientOptions,\n): DebugRuntimeState {\n  return callServiceFunction<DebugRuntimeState>(\n    resolveHost(options),\n    handle,\n    UTILS_FUNCTIONS.GetDebugState,\n    {},\n  );\n}\n\nexport function getDebugSnapshot(\n  handle: ServiceHandle,\n  options?: UtilsClientOptions,\n): DebugSnapshot {\n  return callServiceFunction<DebugSnapshot>(\n    resolveHost(options),\n    handle,\n    UTILS_FUNCTIONS.GetDebugSnapshot,\n    {},\n  );\n}\n\nexport function getMemorySnapshot(\n  handle: ServiceHandle,\n  options?: UtilsClientOptions,\n): MemoryDebugSnapshot {\n  return callServiceFunction<MemoryDebugSnapshot>(\n    resolveHost(options),\n    handle,\n    UTILS_FUNCTIONS.GetMemorySnapshot,\n    {},\n  );\n}\n","/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  closeUtils,\n  getDebugCapabilities,\n  getDebugConfig,\n  getDebugSnapshot,\n  getDebugState,\n  getMemorySnapshot,\n  isUtilsAvailable,\n  openUtils,\n  setDebugConfig,\n  startMemoryDebug,\n  startThreadDebug,\n  stopMemoryDebug,\n  stopThreadDebug,\n  type UtilsClientOptions,\n  type UtilsHandle,\n} from './utils-client.ts';\nimport type {\n  DebugCapabilities,\n  DebugConfig,\n  DebugRuntimeState,\n  DebugSnapshot,\n  MemoryDebugSnapshot,\n} from './utils-types.ts';\n\nexport type UtilsModuleOptions = UtilsClientOptions;\ntype State = { handle: UtilsHandle | null; options: UtilsModuleOptions };\nconst state: State = { handle: null, options: {} };\n\nfunction handle(): UtilsHandle {\n  if (state.handle !== null) return state.handle;\n  if (!isUtilsAvailable(state.options)) throw new Error('Utils service is not available');\n  state.handle = openUtils(state.options);\n  return state.handle;\n}\n\nexport function configure(options: UtilsModuleOptions): void {\n  if (state.handle !== null) closeUtils(state.handle, state.options);\n  state.handle = null;\n  state.options = options;\n}\n\nconst utils = {\n  available(): boolean {\n    return isUtilsAvailable(state.options);\n  },\n  close(): void {\n    if (state.handle === null) return;\n    closeUtils(state.handle, state.options);\n    state.handle = null;\n  },\n  getDebugCapabilities(): DebugCapabilities {\n    return getDebugCapabilities(handle(), state.options);\n  },\n  getDebugConfig(): DebugConfig {\n    return getDebugConfig(handle(), state.options);\n  },\n  setDebugConfig(config: DebugConfig): void {\n    setDebugConfig(handle(), config, state.options);\n  },\n  startMemoryDebug(): void {\n    startMemoryDebug(handle(), state.options);\n  },\n  stopMemoryDebug(): void {\n    stopMemoryDebug(handle(), state.options);\n  },\n  startThreadDebug(): void {\n    startThreadDebug(handle(), state.options);\n  },\n  stopThreadDebug(): void {\n    stopThreadDebug(handle(), state.options);\n  },\n  getDebugState(): DebugRuntimeState {\n    return getDebugState(handle(), state.options);\n  },\n  getDebugSnapshot(): DebugSnapshot {\n    return getDebugSnapshot(handle(), state.options);\n  },\n  getMemorySnapshot(): MemoryDebugSnapshot {\n    return getMemorySnapshot(handle(), state.options);\n  },\n};\n\nexport default utils;\n"],"mappings":";;AAoBA,MAAa,qBAAqB;AAElC,MAAa,kBAAkB;CAC7B,sBAAsB;CACtB,gBAAgB;CAChB,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;CAClB,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,mBAAmB;AACrB;AAKA,SAAgB,iBAAiB,SAAuC;CACtE,OAAO,mBAAmB,oBAAoB,OAAO;AACvD;AAEA,SAAgB,UAAU,SAA6C;CACrE,OAAO,YAAY,oBAAoB,OAAO;AAChD;AAEA,SAAgB,WAAW,QAAuB,SAAoC;CACpF,aAAa,QAAQ,OAAO;AAC9B;AAEA,SAAgB,qBACd,QACA,SACmB;CACnB,OAAO,oBACL,YAAY,OAAO,GACnB,QACA,gBAAgB,sBAChB,CAAC,CACH;AACF;AAEA,SAAgB,eAAe,QAAuB,SAA2C;CAC/F,OAAO,oBACL,YAAY,OAAO,GACnB,QACA,gBAAgB,gBAChB,CAAC,CACH;AACF;AAEA,SAAgB,eACd,QACA,QACA,SACM;CACN,oBAA0B,YAAY,OAAO,GAAG,QAAQ,gBAAgB,gBAAgB,EACtF,QAAQ,OACV,CAAC;AACH;AAEA,SAAgB,iBAAiB,QAAuB,SAAoC;CAC1F,oBAA0B,YAAY,OAAO,GAAG,QAAQ,gBAAgB,kBAAkB,CAAC,CAAC;AAC9F;AAEA,SAAgB,gBAAgB,QAAuB,SAAoC;CACzF,oBAA0B,YAAY,OAAO,GAAG,QAAQ,gBAAgB,iBAAiB,CAAC,CAAC;AAC7F;AAEA,SAAgB,iBAAiB,QAAuB,SAAoC;CAC1F,oBAA0B,YAAY,OAAO,GAAG,QAAQ,gBAAgB,kBAAkB,CAAC,CAAC;AAC9F;AAEA,SAAgB,gBAAgB,QAAuB,SAAoC;CACzF,oBAA0B,Y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