@ikalogic/at1000 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/chunk-DjWAcSYV.cjs +1 -0
  2. package/dist/com-BHaGVMz5.cjs +2 -0
  3. package/dist/com-BHaGVMz5.cjs.map +1 -0
  4. package/dist/com-BdsqVRMC.mjs +2 -0
  5. package/dist/com-BdsqVRMC.mjs.map +1 -0
  6. package/dist/com-DCoBgRma.d.mts +606 -0
  7. package/dist/com-DCoBgRma.d.mts.map +1 -0
  8. package/dist/com-J1K8y_90.d.cts +606 -0
  9. package/dist/com-J1K8y_90.d.cts.map +1 -0
  10. package/dist/com.cjs +1 -0
  11. package/dist/com.d.cts +2 -0
  12. package/dist/com.d.mts +2 -0
  13. package/dist/com.mjs +1 -0
  14. package/dist/common-ClinPNdn.d.mts +8 -0
  15. package/dist/common-ClinPNdn.d.mts.map +1 -0
  16. package/dist/common-CsBdb633.d.cts +8 -0
  17. package/dist/common-CsBdb633.d.cts.map +1 -0
  18. package/dist/common-DSzy5K03.mjs +2 -0
  19. package/dist/common-DSzy5K03.mjs.map +1 -0
  20. package/dist/common-ix04NEFn.cjs +2 -0
  21. package/dist/common-ix04NEFn.cjs.map +1 -0
  22. package/dist/discovery.cjs +2 -0
  23. package/dist/discovery.cjs.map +1 -0
  24. package/dist/discovery.d.cts +14 -0
  25. package/dist/discovery.d.cts.map +1 -0
  26. package/dist/discovery.d.mts +14 -0
  27. package/dist/discovery.d.mts.map +1 -0
  28. package/dist/discovery.mjs +2 -0
  29. package/dist/discovery.mjs.map +1 -0
  30. package/dist/gpio-BQXV_UtO.d.cts +253 -0
  31. package/dist/gpio-BQXV_UtO.d.cts.map +1 -0
  32. package/dist/gpio-CxHnpe7Y.mjs +2 -0
  33. package/dist/gpio-CxHnpe7Y.mjs.map +1 -0
  34. package/dist/gpio-D4KyCVtn.d.mts +253 -0
  35. package/dist/gpio-D4KyCVtn.d.mts.map +1 -0
  36. package/dist/gpio-DSTG-dmv.cjs +2 -0
  37. package/dist/gpio-DSTG-dmv.cjs.map +1 -0
  38. package/dist/gpio.cjs +1 -0
  39. package/dist/gpio.d.cts +4 -0
  40. package/dist/gpio.d.mts +4 -0
  41. package/dist/gpio.mjs +1 -0
  42. package/dist/hmi-B04X0czX.mjs +2 -0
  43. package/dist/hmi-B04X0czX.mjs.map +1 -0
  44. package/dist/hmi-BMM-GMeM.d.mts +113 -0
  45. package/dist/hmi-BMM-GMeM.d.mts.map +1 -0
  46. package/dist/hmi-Cx7xLvkd.d.cts +113 -0
  47. package/dist/hmi-Cx7xLvkd.d.cts.map +1 -0
  48. package/dist/hmi-DSFhbR-Y.cjs +2 -0
  49. package/dist/hmi-DSFhbR-Y.cjs.map +1 -0
  50. package/dist/hmi.cjs +1 -0
  51. package/dist/hmi.d.cts +2 -0
  52. package/dist/hmi.d.mts +2 -0
  53. package/dist/hmi.mjs +1 -0
  54. package/dist/index--f0Eile9.d.mts +49 -0
  55. package/dist/index--f0Eile9.d.mts.map +1 -0
  56. package/dist/index-CSex8Zr4.d.cts +49 -0
  57. package/dist/index-CSex8Zr4.d.cts.map +1 -0
  58. package/dist/index.cjs +1 -0
  59. package/dist/index.d.cts +9 -0
  60. package/dist/index.d.mts +9 -0
  61. package/dist/index.mjs +1 -0
  62. package/dist/management-B758IJfF.cjs +2 -0
  63. package/dist/management-B758IJfF.cjs.map +1 -0
  64. package/dist/management-BRYyWntE.mjs +2 -0
  65. package/dist/management-BRYyWntE.mjs.map +1 -0
  66. package/dist/management-CecISx9d.d.cts +243 -0
  67. package/dist/management-CecISx9d.d.cts.map +1 -0
  68. package/dist/management-DYOPvugC.d.mts +243 -0
  69. package/dist/management-DYOPvugC.d.mts.map +1 -0
  70. package/dist/management.cjs +1 -0
  71. package/dist/management.d.cts +2 -0
  72. package/dist/management.d.mts +2 -0
  73. package/dist/management.mjs +1 -0
  74. package/dist/power--6z_aXLw.d.mts +339 -0
  75. package/dist/power--6z_aXLw.d.mts.map +1 -0
  76. package/dist/power-AuGIL43h.d.cts +339 -0
  77. package/dist/power-AuGIL43h.d.cts.map +1 -0
  78. package/dist/power-DtLWOEQI.cjs +2 -0
  79. package/dist/power-DtLWOEQI.cjs.map +1 -0
  80. package/dist/power-kf9bMNDS.mjs +2 -0
  81. package/dist/power-kf9bMNDS.mjs.map +1 -0
  82. package/dist/power.cjs +1 -0
  83. package/dist/power.d.cts +4 -0
  84. package/dist/power.d.mts +4 -0
  85. package/dist/power.mjs +1 -0
  86. package/dist/relays-8a3YZaV7.cjs +2 -0
  87. package/dist/relays-8a3YZaV7.cjs.map +1 -0
  88. package/dist/relays-CGntlBiE.d.mts +77 -0
  89. package/dist/relays-CGntlBiE.d.mts.map +1 -0
  90. package/dist/relays-Cwtrx0B-.mjs +2 -0
  91. package/dist/relays-Cwtrx0B-.mjs.map +1 -0
  92. package/dist/relays-Dn_EI0HH.d.cts +77 -0
  93. package/dist/relays-Dn_EI0HH.d.cts.map +1 -0
  94. package/dist/relays.cjs +1 -0
  95. package/dist/relays.d.cts +2 -0
  96. package/dist/relays.d.mts +2 -0
  97. package/dist/relays.mjs +1 -0
  98. package/dist/src-3DKHMeTA.mjs +2 -0
  99. package/dist/src-3DKHMeTA.mjs.map +1 -0
  100. package/dist/src-CJhZ2EuZ.cjs +2 -0
  101. package/dist/src-CJhZ2EuZ.cjs.map +1 -0
  102. package/package.json +124 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-AuGIL43h.d.cts","names":[],"sources":["../src/api/power.ts"],"sourcesContent":[],"mappings":";;;;;;cAQM,UAAQ,CAAA,CAAA;EAAR,SAAA,OAKJ,iBAAA,CAAA,SAAA,CAAA;;;;;KACU,QAAA,GAAW,CAAA,CAAE,mBAAmB;cAEtC,kBAAgB,KAAA,KAAA,CAAA,CAAA;;;;;CARR,EAAA,SAAA,CAAA,EAAA,QAAA,GAAA,MAAA,GAAA,WAAA,GAAA,SAAA,CAAA,GAAA;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AsDoB,CAAA,IAAA,CAAA;EAKlB;;;;;EAe0B,SAAA,CAAA,MAAA,EAjEnB,gBAiEmB,CAAA,EAjEA,OAiEA,CAjEQ,QAiER,CAAA;EAYjB;;;;;EAgBZ,QAAA,CAAA,OAAA,EAhFgB,iBAgFhB,CAAA,EAhFoC,OAgFpC,CAhF4C,QAgF5C,CAAA;EAQc;;;AAaxB;EACsC,UAAA,CAAA,CAAA,EA9FhB,OA8FgB,CA9FR,QA8FQ,CAAA;EAMpB;;;;UA5FR,QAAQ;;;;;kBAQM;;;;;kBAQA;;cAKX,GAAA;;;qBACyB;;;;WAK3B;;;;;;oBASS,mBAAmB,QAAQ;;;;;cAYjC,QAAQ;;;;;gBAQN,QAAQ;;;;;UAQd,QAAQ;;;;;kBAQM;;;;;kBAQA;;cAKX,UAAA;;;qBACyB;;;;;UAM5B,QAAQ;;;;;kBAQM"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./chunk-DjWAcSYV.cjs`),t=require(`./common-ix04NEFn.cjs`);let n=require(`valibot`);n=e.t(n);const r=n.object({enabled:n.boolean(),target_voltage:t.t,voltage:t.t,current:n.number()}),i=n.partial(n.pick(r,[`enabled`,`target_voltage`])),a=n.pick(r,[`enabled`,`current`,`voltage`]),o=n.pick(a,[`enabled`]),s=n.pick(r,[`current`]);var c=class{usb_count;dut_count=1;constructor(e,t){this.fetch=e,this.usb_count=t.capabilities.usb_ports.length}reset(){return this.fetch(`/power/reset`,{method:`POST`,parseResponse:()=>{}})}dut(e){if(e<0||e>=this.dut_count)throw Error(`Invalid DUT id ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a DUT ID between 0 and ${this.dut_count-1}\n Path: /power/dut/${e}`);return new l(this.fetch,e)}usb(e){if(e<0||e>=this.usb_count)throw Error(`Invalid USB port ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a USB port ID between 0 and ${this.usb_count-1}\n Path: /power/usb/${e}`);return new u(this.fetch,e)}relay_4(){return new d(this.fetch,4)}},l=class{constructor(e,t){this.fetch=e,this.id=t}reset(){return this.fetch(`/power/dut/${this.id}/reset`,{method:`POST`,parseResponse:()=>{}})}configure(e){return this.fetch(`/power/dut/${this.id}`,{method:`PATCH`,body:n.parse(i,e),schema:r})}async power_up(e){return this.configure({enabled:!0,target_voltage:e})}async power_down(){return this.configure({enabled:!1})}read(){return this.fetch(`/power/dut/${this.id}`,{schema:r})}async read_current(){return(await this.read()).current}async read_voltage(){return(await this.read()).voltage}},u=class{constructor(e,t){this.fetch=e,this.id=t}reset(){return this.fetch(`/power/usb/${this.id}/reset`,{method:`POST`,parseResponse:()=>{}})}configure(e){return this.fetch(`/power/usb/${this.id}`,{method:`PATCH`,body:n.parse(o,e),schema:a})}power_up(){return this.configure({enabled:!0})}power_down(){return this.configure({enabled:!1})}read(){return this.fetch(`/power/usb/${this.id}`,{schema:a})}async read_current(){return(await this.read()).current}async read_voltage(){return(await this.read()).voltage}},d=class{constructor(e,t){this.fetch=e,this.id=t}read(){return this.fetch(`/power/relay/${this.id}`,{schema:s})}async read_current(){return(await this.read()).current}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
2
+ //# sourceMappingURL=power-DtLWOEQI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-DtLWOEQI.cjs","names":["v","analogLevel","fetch: UpFetch","id: number"],"sources":["../src/api/power.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { analogLevel, type AnalogOutputLevel } from './common';\nimport type { Device } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst dutState = v.object({\n enabled: v.boolean(),\n target_voltage: analogLevel,\n voltage: analogLevel,\n current: v.number(),\n});\nexport type DutState = v.InferOutput<typeof dutState>;\n\nconst dutConfiguration = v.partial(v.pick(dutState, ['enabled', 'target_voltage']));\nexport type DutConfiguration = v.InferOutput<typeof dutConfiguration>;\n\nconst usbState = v.pick(dutState, ['enabled', 'current', 'voltage']);\nexport type UsbState = v.InferOutput<typeof usbState>;\n\nconst usbConfiguration = v.pick(usbState, ['enabled']);\nexport type UsbConfiguration = v.InferOutput<typeof usbConfiguration>;\n\nconst relayState = v.pick(dutState, ['current']);\nexport type RelayState = v.InferOutput<typeof relayState>;\n\nexport class PowerApi {\n private readonly usb_count: number;\n private readonly dut_count = 1;\n\n constructor(private readonly fetch: UpFetch, device: Device) {\n this.usb_count = device.capabilities.usb_ports.length;\n }\n\n /**\n * Resets the power API.\n */\n reset(): Promise<void> {\n return this.fetch('/power/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific DUT by id.\n * @param id The DUT id.\n * @returns The DUT instance.\n */\n dut(id: number): Dut {\n if (id < 0 || id >= this.dut_count) {\n throw new Error(\n `Invalid DUT id ${id} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a DUT ID between 0 and ${\n this.dut_count - 1\n }\\n Path: /power/dut/${id}`,\n );\n }\n\n return new Dut(this.fetch, id);\n }\n\n /**\n * Access a specific USB port by id.\n * @param id The USB port id.\n * @returns The USB port instance.\n */\n usb(id: number): Usb {\n if (id < 0 || id >= this.usb_count) {\n throw new Error(\n `Invalid USB port ${id} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a USB port ID between 0 and ${\n this.usb_count - 1\n }\\n Path: /power/usb/${id}`,\n );\n }\n\n return new Usb(this.fetch, id);\n }\n\n /**\n * Access the relay at index 4.\n * @returns The relay instance.\n */\n relay_4(): RelayPower {\n return new RelayPower(this.fetch, 4);\n }\n}\n\nexport class Dut {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Resets the DUT.\n */\n reset(): Promise<void> {\n return this.fetch(`/power/dut/${this.id}/reset`, { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Configures the DUT.\n * @param config The configuration to apply.\n * @returns The updated DUT state.\n */\n configure(config: DutConfiguration): Promise<DutState> {\n return this.fetch(`/power/dut/${this.id}`, {\n method: 'PATCH',\n body: v.parse(dutConfiguration, config),\n schema: dutState,\n });\n }\n\n /**\n * Powers up the DUT to the specified voltage.\n * @param voltage The target voltage to set.\n * @returns The updated DUT state.\n */\n async power_up(voltage: AnalogOutputLevel): Promise<DutState> {\n return this.configure({ enabled: true, target_voltage: voltage });\n }\n\n /**\n * Powers down the DUT.\n * @returns The updated DUT state.\n */\n async power_down(): Promise<DutState> {\n return this.configure({ enabled: false });\n }\n\n /**\n * Reads the current DUT state.\n * @returns The current DUT state.\n */\n read(): Promise<DutState> {\n return this.fetch(`/power/dut/${this.id}`, { schema: dutState });\n }\n\n /**\n * Reads the current drawn by the DUT.\n * @returns The current drawn by the DUT.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n\n /**\n * Reads the voltage supplied to the DUT.\n * @returns The voltage supplied to the DUT.\n */\n async read_voltage(): Promise<number> {\n return (await this.read()).voltage;\n }\n}\n\nexport class Usb {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Resets the USB port.\n */\n reset(): Promise<void> {\n return this.fetch(`/power/usb/${this.id}/reset`, { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Configures the USB port.\n * @param config The configuration to apply.\n * @returns The updated USB state.\n */\n configure(config: UsbConfiguration): Promise<UsbState> {\n return this.fetch(`/power/usb/${this.id}`, {\n method: 'PATCH',\n body: v.parse(usbConfiguration, config),\n schema: usbState,\n });\n }\n\n /**\n * Powers up the USB port.\n * @returns The updated USB state.\n */\n power_up(): Promise<UsbState> {\n return this.configure({ enabled: true });\n }\n\n /**\n * Powers down the USB port.\n * @returns The updated USB state.\n */\n power_down(): Promise<UsbState> {\n return this.configure({ enabled: false });\n }\n\n /**\n * Reads the current state of the USB port.\n * @returns The current USB state.\n */\n read(): Promise<UsbState> {\n return this.fetch(`/power/usb/${this.id}`, { schema: usbState });\n }\n\n /**\n * Reads the current drawn by the USB port.\n * @returns The current drawn by the USB port.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n\n /**\n * Reads the voltage at the USB port.\n * @returns The voltage at the USB port.\n */\n async read_voltage(): Promise<number> {\n return (await this.read()).voltage;\n }\n}\n\nexport class RelayPower {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Reads the current state of the relay.\n * @returns The current relay state.\n */\n read(): Promise<RelayState> {\n return this.fetch(`/power/relay/${this.id}`, { schema: relayState });\n }\n\n /**\n * Reads the current drawn through the relay.\n * @returns The current drawn through the relay.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n}\n"],"mappings":"6GAQA,MAAM,EAAWA,EAAE,OAAO,CACxB,QAASA,EAAE,SAAS,CACpB,eAAgBC,EAAAA,EAChB,QAASA,EAAAA,EACT,QAASD,EAAE,QAAQ,CACpB,CAAC,CAGI,EAAmBA,EAAE,QAAQA,EAAE,KAAK,EAAU,CAAC,UAAW,iBAAiB,CAAC,CAAC,CAG7E,EAAWA,EAAE,KAAK,EAAU,CAAC,UAAW,UAAW,UAAU,CAAC,CAG9D,EAAmBA,EAAE,KAAK,EAAU,CAAC,UAAU,CAAC,CAGhD,EAAaA,EAAE,KAAK,EAAU,CAAC,UAAU,CAAC,CAGhD,IAAa,EAAb,KAAsB,CACpB,UACA,UAA6B,EAE7B,YAAY,EAAiC,EAAgB,CAAhC,KAAA,MAAA,EAC3B,KAAK,UAAY,EAAO,aAAa,UAAU,OAMjD,OAAuB,CACrB,OAAO,KAAK,MAAM,eAAgB,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,CAQhF,IAAI,EAAiB,CACnB,GAAI,EAAK,GAAK,GAAM,KAAK,UACvB,MAAU,MACR,kBAAkB,EAAG,oEACnB,KAAK,UAAY,EAClB,yBAAyB,IAC3B,CAGH,OAAO,IAAI,EAAI,KAAK,MAAO,EAAG,CAQhC,IAAI,EAAiB,CACnB,GAAI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AAK,UAAU,CAAE,QAAS,GAAM,CAAC,CAO1C,YAAgC,CAC9B,OAAO,KAAK,UAAU,CAAE,QAAS,GAAO,CAAC,CAO3C,MAA0B,CACxB,OAAO,KAAK,MAAM,cAAc,KAAK,KAAM,CAAE,OAAQ,EAAU,CAAC,CAOlE,MAAM,cAAgC,CACpC,OAAQ,MAAM,KAAK,MAAM,EAAE,QAO7B,MAAM,cAAgC,CACpC,OAAQ,MAAM,KAAK,MAAM,EAAE,UAIlB,EAAb,KAAwB,CACtB,YAAY,EAAiC,EAA4B,CAA5C,KAAA,MAAA,EAAgC,KAAA,GAAA,EAM7D,MAA4B,CAC1B,OAAO,KAAK,MAAM,gBAAgB,KAAK,KAAM,CAAE,OAAQ,EAAY,CAAC,CAOtE,MAAM,cAAgC,CACpC,OAAQ,MAAM,KAAK,MAAM,EAAE"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./common-DSzy5K03.mjs";import*as t from"valibot";const n=t.object({enabled:t.boolean(),target_voltage:e,voltage:e,current:t.number()}),r=t.partial(t.pick(n,[`enabled`,`target_voltage`])),i=t.pick(n,[`enabled`,`current`,`voltage`]),a=t.pick(i,[`enabled`]),o=t.pick(n,[`current`]);var s=class{usb_count;dut_count=1;constructor(e,t){this.fetch=e,this.usb_count=t.capabilities.usb_ports.length}reset(){return this.fetch(`/power/reset`,{method:`POST`,parseResponse:()=>{}})}dut(e){if(e<0||e>=this.dut_count)throw Error(`Invalid DUT id ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a DUT ID between 0 and ${this.dut_count-1}\n Path: /power/dut/${e}`);return new c(this.fetch,e)}usb(e){if(e<0||e>=this.usb_count)throw Error(`Invalid USB port ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a USB port ID between 0 and ${this.usb_count-1}\n Path: /power/usb/${e}`);return new l(this.fetch,e)}relay_4(){return new u(this.fetch,4)}},c=class{constructor(e,t){this.fetch=e,this.id=t}reset(){return this.fetch(`/power/dut/${this.id}/reset`,{method:`POST`,parseResponse:()=>{}})}configure(e){return this.fetch(`/power/dut/${this.id}`,{method:`PATCH`,body:t.parse(r,e),schema:n})}async power_up(e){return this.configure({enabled:!0,target_voltage:e})}async power_down(){return this.configure({enabled:!1})}read(){return this.fetch(`/power/dut/${this.id}`,{schema:n})}async read_current(){return(await this.read()).current}async read_voltage(){return(await this.read()).voltage}},l=class{constructor(e,t){this.fetch=e,this.id=t}reset(){return this.fetch(`/power/usb/${this.id}/reset`,{method:`POST`,parseResponse:()=>{}})}configure(e){return this.fetch(`/power/usb/${this.id}`,{method:`PATCH`,body:t.parse(a,e),schema:i})}power_up(){return this.configure({enabled:!0})}power_down(){return this.configure({enabled:!1})}read(){return this.fetch(`/power/usb/${this.id}`,{schema:i})}async read_current(){return(await this.read()).current}async read_voltage(){return(await this.read()).voltage}},u=class{constructor(e,t){this.fetch=e,this.id=t}read(){return this.fetch(`/power/relay/${this.id}`,{schema:o})}async read_current(){return(await this.read()).current}};export{l as i,s as n,u as r,c as t};
2
+ //# sourceMappingURL=power-kf9bMNDS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-kf9bMNDS.mjs","names":["fetch: UpFetch","id: number"],"sources":["../src/api/power.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { analogLevel, type AnalogOutputLevel } from './common';\nimport type { Device } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst dutState = v.object({\n enabled: v.boolean(),\n target_voltage: analogLevel,\n voltage: analogLevel,\n current: v.number(),\n});\nexport type DutState = v.InferOutput<typeof dutState>;\n\nconst dutConfiguration = v.partial(v.pick(dutState, ['enabled', 'target_voltage']));\nexport type DutConfiguration = v.InferOutput<typeof dutConfiguration>;\n\nconst usbState = v.pick(dutState, ['enabled', 'current', 'voltage']);\nexport type UsbState = v.InferOutput<typeof usbState>;\n\nconst usbConfiguration = v.pick(usbState, ['enabled']);\nexport type UsbConfiguration = v.InferOutput<typeof usbConfiguration>;\n\nconst relayState = v.pick(dutState, ['current']);\nexport type RelayState = v.InferOutput<typeof relayState>;\n\nexport class PowerApi {\n private readonly usb_count: number;\n private readonly dut_count = 1;\n\n constructor(private readonly fetch: UpFetch, device: Device) {\n this.usb_count = device.capabilities.usb_ports.length;\n }\n\n /**\n * Resets the power API.\n */\n reset(): Promise<void> {\n return this.fetch('/power/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific DUT by id.\n * @param id The DUT id.\n * @returns The DUT instance.\n */\n dut(id: number): Dut {\n if (id < 0 || id >= this.dut_count) {\n throw new Error(\n `Invalid DUT id ${id} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a DUT ID between 0 and ${\n this.dut_count - 1\n }\\n Path: /power/dut/${id}`,\n );\n }\n\n return new Dut(this.fetch, id);\n }\n\n /**\n * Access a specific USB port by id.\n * @param id The USB port id.\n * @returns The USB port instance.\n */\n usb(id: number): Usb {\n if (id < 0 || id >= this.usb_count) {\n throw new Error(\n `Invalid USB port ${id} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a USB port ID between 0 and ${\n this.usb_count - 1\n }\\n Path: /power/usb/${id}`,\n );\n }\n\n return new Usb(this.fetch, id);\n }\n\n /**\n * Access the relay at index 4.\n * @returns The relay instance.\n */\n relay_4(): RelayPower {\n return new RelayPower(this.fetch, 4);\n }\n}\n\nexport class Dut {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Resets the DUT.\n */\n reset(): Promise<void> {\n return this.fetch(`/power/dut/${this.id}/reset`, { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Configures the DUT.\n * @param config The configuration to apply.\n * @returns The updated DUT state.\n */\n configure(config: DutConfiguration): Promise<DutState> {\n return this.fetch(`/power/dut/${this.id}`, {\n method: 'PATCH',\n body: v.parse(dutConfiguration, config),\n schema: dutState,\n });\n }\n\n /**\n * Powers up the DUT to the specified voltage.\n * @param voltage The target voltage to set.\n * @returns The updated DUT state.\n */\n async power_up(voltage: AnalogOutputLevel): Promise<DutState> {\n return this.configure({ enabled: true, target_voltage: voltage });\n }\n\n /**\n * Powers down the DUT.\n * @returns The updated DUT state.\n */\n async power_down(): Promise<DutState> {\n return this.configure({ enabled: false });\n }\n\n /**\n * Reads the current DUT state.\n * @returns The current DUT state.\n */\n read(): Promise<DutState> {\n return this.fetch(`/power/dut/${this.id}`, { schema: dutState });\n }\n\n /**\n * Reads the current drawn by the DUT.\n * @returns The current drawn by the DUT.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n\n /**\n * Reads the voltage supplied to the DUT.\n * @returns The voltage supplied to the DUT.\n */\n async read_voltage(): Promise<number> {\n return (await this.read()).voltage;\n }\n}\n\nexport class Usb {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Resets the USB port.\n */\n reset(): Promise<void> {\n return this.fetch(`/power/usb/${this.id}/reset`, { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Configures the USB port.\n * @param config The configuration to apply.\n * @returns The updated USB state.\n */\n configure(config: UsbConfiguration): Promise<UsbState> {\n return this.fetch(`/power/usb/${this.id}`, {\n method: 'PATCH',\n body: v.parse(usbConfiguration, config),\n schema: usbState,\n });\n }\n\n /**\n * Powers up the USB port.\n * @returns The updated USB state.\n */\n power_up(): Promise<UsbState> {\n return this.configure({ enabled: true });\n }\n\n /**\n * Powers down the USB port.\n * @returns The updated USB state.\n */\n power_down(): Promise<UsbState> {\n return this.configure({ enabled: false });\n }\n\n /**\n * Reads the current state of the USB port.\n * @returns The current USB state.\n */\n read(): Promise<UsbState> {\n return this.fetch(`/power/usb/${this.id}`, { schema: usbState });\n }\n\n /**\n * Reads the current drawn by the USB port.\n * @returns The current drawn by the USB port.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n\n /**\n * Reads the voltage at the USB port.\n * @returns The voltage at the USB port.\n */\n async read_voltage(): Promise<number> {\n return (await this.read()).voltage;\n }\n}\n\nexport class RelayPower {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Reads the current state of the relay.\n * @returns The current relay state.\n */\n read(): Promise<RelayState> {\n return this.fetch(`/power/relay/${this.id}`, { schema: relayState });\n }\n\n /**\n * Reads the current drawn through the relay.\n * @returns The current drawn through the relay.\n */\n async read_current(): Promise<number> {\n return (await this.read()).current;\n }\n}\n"],"mappings":"oEAQA,MAAM,EAAW,EAAE,OAAO,CACxB,QAAS,EAAE,SAAS,CACpB,eAAgB,EAChB,QAAS,EACT,QAAS,EAAE,QAAQ,CACpB,CAAC,CAGI,EAAmB,EAAE,QAAQ,EAAE,KAAK,EAAU,CAAC,UAAW,iBAAiB,CAAC,CAAC,CAG7E,EAAW,EAAE,KAAK,EAAU,CAAC,UAAW,UAAW,UAAU,CAAC,CAG9D,EAAmB,EAAE,KAAK,EAAU,CAAC,UAAU,CAAC,CAGhD,EAAa,EAAE,KAAK,EAAU,CAAC,UAAU,CAAC,CAGhD,IAAa,EAAb,KAAsB,CACpB,UACA,UAA6B,EAE7B,YAAY,EAAiC,EAAgB,CAAhC,KAAA,MAAA,EAC3B,KAAK,UAAY,EAAO,aAAa,UAAU,OAMjD,OAAuB,CACrB,OAAO,KAAK,MAAM,eAAgB,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,CAQhF,IAAI,EAAiB,CACnB,GAAI,EAAK,GAAK,GAAM,KAAK,UACvB,MAAU,MACR,kBAAkB,EAAG,oEACnB,KAAK,UAAY,EAClB,yBAAyB,IAC3B,CAGH,OAAO,IAAI,EAAI,KAAK,MAAO,EAAG,CAQhC,IAAI,EAAiB,CACnB,GAAI,EAAK,GAAK,GAAM,KAAK,UACvB,MAAU,MACR,oBAAoB,EAAG,yEACrB,KAAK,UAAY,EAClB,yBAAyB,IAC3B,CAGH,OAAO,IAAI,EAAI,KAAK,MAAO,EAAG,CAOhC,SAAsB,CACpB,OAAO,IAAI,EAAW,KAAK,MAAO,EAAE,GAI3B,EAAb,KAAiB,CACf,YAAY,EAAiC,EAA4B,C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MAAM,cAAgC,CACpC,OAAQ,MAAM,KAAK,MAAM,EAAE,UAIlB,EAAb,KAAwB,CACtB,YAAY,EAAiC,EAA4B,CAA5C,KAAA,MAAA,EAAgC,KAAA,GAAA,EAM7D,MAA4B,CAC1B,OAAO,KAAK,MAAM,gBAAgB,KAAK,KAAM,CAAE,OAAQ,EAAY,CAAC,CAOtE,MAAM,cAAgC,CACpC,OAAQ,MAAM,KAAK,MAAM,EAAE"}
package/dist/power.cjs ADDED
@@ -0,0 +1 @@
1
+ require(`./common-ix04NEFn.cjs`);const e=require(`./power-DtLWOEQI.cjs`);exports.Dut=e.t,exports.PowerApi=e.n,exports.RelayPower=e.r,exports.Usb=e.i;
@@ -0,0 +1,4 @@
1
+ import { t as AnalogOutputLevel } from "./common-CsBdb633.cjs";
2
+ import "./management-CecISx9d.cjs";
3
+ import { a as RelayPower, c as UsbConfiguration, i as PowerApi, l as UsbState, n as DutConfiguration, o as RelayState, r as DutState, s as Usb, t as Dut } from "./power-AuGIL43h.cjs";
4
+ export { AnalogOutputLevel, Dut, DutConfiguration, DutState, PowerApi, RelayPower, RelayState, Usb, UsbConfiguration, UsbState };
@@ -0,0 +1,4 @@
1
+ import { t as AnalogOutputLevel } from "./common-ClinPNdn.mjs";
2
+ import "./management-DYOPvugC.mjs";
3
+ import { a as RelayPower, c as UsbConfiguration, i as PowerApi, l as UsbState, n as DutConfiguration, o as RelayState, r as DutState, s as Usb, t as Dut } from "./power--6z_aXLw.mjs";
4
+ export { AnalogOutputLevel, Dut, DutConfiguration, DutState, PowerApi, RelayPower, RelayState, Usb, UsbConfiguration, UsbState };
package/dist/power.mjs ADDED
@@ -0,0 +1 @@
1
+ import"./common-DSzy5K03.mjs";import{i as e,n as t,r as n,t as r}from"./power-kf9bMNDS.mjs";export{r as Dut,t as PowerApi,n as RelayPower,e as Usb};
@@ -0,0 +1,2 @@
1
+ const e=require(`./chunk-DjWAcSYV.cjs`);let t=require(`valibot`);t=e.t(t);const n=t.picklist([`open`,`closed`]),r=t.array(n),i=t.object({state:n}),a=t.picklist([`open`,`close`]);t.object({action:a});var o=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/relays/reset`,{method:`POST`,parseResponse:()=>{}})}relay(e){return new s(this.fetch,e)}read(){return this.fetch(`/relays`,{schema:r})}open(){return this.fetch(`/relays`,{method:`POST`,body:{action:`open`},schema:r})}close(){return this.fetch(`/relays`,{method:`POST`,body:{action:`close`},schema:r})}},s=class{constructor(e,t){this.fetch=e,this.id=t}async read(){return(await this.fetch(`/relays/${this.id}`,{schema:i})).state}async is_open(){return await this.read()===`open`}async is_closed(){return await this.read()===`closed`}async open(){return(await this.fetch(`/relays/${this.id}`,{method:`POST`,body:{action:`open`},schema:i})).state}async close(){return(await this.fetch(`/relays/${this.id}`,{method:`POST`,body:{action:`close`},schema:i})).state}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
2
+ //# sourceMappingURL=relays-8a3YZaV7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relays-8a3YZaV7.cjs","names":["v","fetch: UpFetch","id: number"],"sources":["../src/api/relays.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst state = v.picklist(['open', 'closed']);\nexport type State = v.InferOutput<typeof state>;\nconst states = v.array(state);\nexport type States = v.InferOutput<typeof states>;\nconst relayState = v.object({ state: state });\n\nconst action = v.picklist(['open', 'close']);\nconst relayAction = v.object({ action: action });\ntype RelayAction = v.InferOutput<typeof relayAction>;\n\nexport class RelaysApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets all relays to their default state.\n */\n reset() {\n return this.fetch('/relays/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific relay by id.\n * @param id The relay id.\n * @returns The relay instance.\n */\n relay(id: number): Relay {\n return new Relay(this.fetch, id);\n }\n\n /**\n * Reads the state of all relays.\n * @returns The state of all relays.\n */\n read(): Promise<States> {\n return this.fetch(`/relays`, { schema: states });\n }\n\n /**\n * Opens all the relays.\n * @returns The new state of all relays.\n */\n open(): Promise<States> {\n return this.fetch(`/relays`, {\n method: 'POST',\n body: { action: 'open' } satisfies RelayAction,\n schema: states,\n });\n }\n\n /**\n * Closes all the relays.\n * @returns The new state of all relays.\n */\n close(): Promise<States> {\n return this.fetch(`/relays`, {\n method: 'POST',\n body: { action: 'close' } satisfies RelayAction,\n schema: states,\n });\n }\n}\n\nexport class Relay {\n constructor(\n private readonly fetch: UpFetch,\n /**\n * The relay id.\n */\n public readonly id: number,\n ) {}\n\n /**\n * Reads the state of the relay.\n * @returns The relay state.\n */\n async read(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, { schema: relayState })).state;\n }\n\n /**\n * Returns whether the relay is open.\n * @returns True if the relay is open, false otherwise.\n */\n async is_open(): Promise<boolean> {\n return (await this.read()) === 'open';\n }\n\n /**\n * Returns whether the relay is closed.\n * @returns True if the relay is closed, false otherwise.\n */\n async is_closed(): Promise<boolean> {\n return (await this.read()) === 'closed';\n }\n\n /**\n * Opens the relay.\n * @returns The new relay state.\n */\n async open(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, {\n method: 'POST',\n body: { action: 'open' } satisfies RelayAction,\n schema: relayState,\n }))\n .state;\n }\n\n /**\n * Closes the relay.\n * @returns The new relay state.\n */\n async close(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, {\n method: 'POST',\n body: { action: 'close' } satisfies RelayAction,\n schema: relayState,\n }))\n .state;\n }\n}\n"],"mappings":"0EAGA,MAAM,EAAQA,EAAE,SAAS,CAAC,OAAQ,SAAS,CAAC,CAEtC,EAASA,EAAE,MAAM,EAAM,CAEvB,EAAaA,EAAE,OAAO,CAAS,QAAO,CAAC,CAEvC,EAASA,EAAE,SAAS,CAAC,OAAQ,QAAQ,CAAC,CACxBA,EAAE,OAAO,CAAU,SAAQ,CAAC,CAGhD,IAAa,EAAb,KAAuB,CACrB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAK7B,OAAQ,CACN,OAAO,KAAK,MAAM,gBAAiB,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,CAQjF,MAAM,EAAmB,CACvB,OAAO,IAAI,EAAM,KAAK,MAAO,EAAG,CAOlC,MAAwB,CACtB,OAAO,KAAK,MAAM,UAAW,CAAE,OAAQ,EAAQ,CAAC,CAOlD,MAAwB,CACtB,OAAO,KAAK,MAAM,UAAW,CAC3B,OAAQ,OACR,KAAM,CAAE,OAAQ,OAAQ,CACxB,OAAQ,EACT,CAAC,CAOJ,OAAyB,CACvB,OAAO,KAAK,MAAM,UAAW,CAC3B,OAAQ,OACR,KAAM,CAAE,OAAQ,QAAS,CACzB,OAAQ,EACT,CAAC,GAIO,EAAb,KAAmB,CACjB,YACE,EAIA,EACA,CALiB,KAAA,MAAA,EAID,KAAA,GAAA,EAOlB,MAAM,MAAuB,CAC3B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAAE,OAAQ,EAAY,CAAC,EAAE,MAO1E,MAAM,SAA4B,CAChC,OAAQ,MAAM,KAAK,MAAM,GAAM,OAOjC,MAAM,WAA8B,CAClC,OAAQ,MAAM,KAAK,MAAM,GAAM,SAOjC,MAAM,MAAuB,CAC3B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAC7C,OAAQ,OACR,KAAM,CAAE,OAAQ,OAAQ,CACxB,OAAQ,EACT,CAAC,EACC,MAOL,MAAM,OAAwB,CAC5B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAC7C,OAAQ,OACR,KAAM,CAAE,OAAQ,QAAS,CACzB,OAAQ,EACT,CAAC,EACC"}
@@ -0,0 +1,77 @@
1
+ import { UpFetch } from "up-fetch";
2
+ import * as v from "valibot";
3
+
4
+ //#region src/api/relays.d.ts
5
+ declare const state: v.PicklistSchema<["open", "closed"], undefined>;
6
+ type State = v.InferOutput<typeof state>;
7
+ declare const states: v.ArraySchema<v.PicklistSchema<["open", "closed"], undefined>, undefined>;
8
+ type States = v.InferOutput<typeof states>;
9
+ declare class RelaysApi {
10
+ private readonly fetch;
11
+ constructor(fetch: UpFetch);
12
+ /**
13
+ * Resets all relays to their default state.
14
+ */
15
+ reset(): Promise<void>;
16
+ /**
17
+ * Access a specific relay by id.
18
+ * @param id The relay id.
19
+ * @returns The relay instance.
20
+ */
21
+ relay(id: number): Relay;
22
+ /**
23
+ * Reads the state of all relays.
24
+ * @returns The state of all relays.
25
+ */
26
+ read(): Promise<States>;
27
+ /**
28
+ * Opens all the relays.
29
+ * @returns The new state of all relays.
30
+ */
31
+ open(): Promise<States>;
32
+ /**
33
+ * Closes all the relays.
34
+ * @returns The new state of all relays.
35
+ */
36
+ close(): Promise<States>;
37
+ }
38
+ declare class Relay {
39
+ private readonly fetch;
40
+ /**
41
+ * The relay id.
42
+ */
43
+ readonly id: number;
44
+ constructor(fetch: UpFetch,
45
+ /**
46
+ * The relay id.
47
+ */
48
+ id: number);
49
+ /**
50
+ * Reads the state of the relay.
51
+ * @returns The relay state.
52
+ */
53
+ read(): Promise<State>;
54
+ /**
55
+ * Returns whether the relay is open.
56
+ * @returns True if the relay is open, false otherwise.
57
+ */
58
+ is_open(): Promise<boolean>;
59
+ /**
60
+ * Returns whether the relay is closed.
61
+ * @returns True if the relay is closed, false otherwise.
62
+ */
63
+ is_closed(): Promise<boolean>;
64
+ /**
65
+ * Opens the relay.
66
+ * @returns The new relay state.
67
+ */
68
+ open(): Promise<State>;
69
+ /**
70
+ * Closes the relay.
71
+ * @returns The new relay state.
72
+ */
73
+ close(): Promise<State>;
74
+ }
75
+ //#endregion
76
+ export { States as i, RelaysApi as n, State as r, Relay as t };
77
+ //# sourceMappingURL=relays-CGntlBiE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relays-CGntlBiE.d.mts","names":[],"sources":["../src/api/relays.ts"],"sourcesContent":[],"mappings":";;;;cAGM,OAAK,CAAA,CAAA;KACC,KAAA,GAAQ,CAAA,CAAE,mBAAmB;AAHZ,cAIvB,MAFsC,EAEhC,CAAA,CAAA,WAFD,CAEC,CAAA,CAAA,cAFD,CAAA,CAAA,MAAA,EAAA,QAAA,CAAA,EAAA,SAAA,CAAA,EAAA,SAAA,CAAA;AACC,KAEA,MAAA,GAAS,CAAA,CAAE,WAFD,CAAA,OAEoB,MAFT,CAAA;AAC3B,cAQO,SAAA,CARD;EACA,iBAAM,KAAwB;EAO7B,WAAA,CAAS,KAAA,EACgB,OADhB;EACgB;;;EAsBpB,KAAA,CAAA,CAAA,EAjBX,OAiBW,CAAA,IAAA,CAAA;EAAR;;;;;EAoBQ,KAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EA5BG,KA4BH;EASL;;;;EAqBM,IAAA,CAAA,CAAA,EAlDT,OAkDS,CAlDD,MAkDC,CAAA;EAQE;;;;EAqBJ,IAAA,CAAA,CAAA,EAvEP,OAuEO,CAvEC,MAuED,CAAA;EAAO;;;;WA3Db,QAAQ;;cASN,KAAA;;;;;;qBAEe;;;;;;;;;UAWZ,QAAQ;;;;;aAQL;;;;;eAQE;;;;;UAQL,QAAQ;;;;;WAaP,QAAQ"}
@@ -0,0 +1,2 @@
1
+ import*as e from"valibot";const t=e.picklist([`open`,`closed`]),n=e.array(t),r=e.object({state:t}),i=e.picklist([`open`,`close`]);e.object({action:i});var a=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/relays/reset`,{method:`POST`,parseResponse:()=>{}})}relay(e){return new o(this.fetch,e)}read(){return this.fetch(`/relays`,{schema:n})}open(){return this.fetch(`/relays`,{method:`POST`,body:{action:`open`},schema:n})}close(){return this.fetch(`/relays`,{method:`POST`,body:{action:`close`},schema:n})}},o=class{constructor(e,t){this.fetch=e,this.id=t}async read(){return(await this.fetch(`/relays/${this.id}`,{schema:r})).state}async is_open(){return await this.read()===`open`}async is_closed(){return await this.read()===`closed`}async open(){return(await this.fetch(`/relays/${this.id}`,{method:`POST`,body:{action:`open`},schema:r})).state}async close(){return(await this.fetch(`/relays/${this.id}`,{method:`POST`,body:{action:`close`},schema:r})).state}};export{a as n,o as t};
2
+ //# sourceMappingURL=relays-Cwtrx0B-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relays-Cwtrx0B-.mjs","names":["fetch: UpFetch","id: number"],"sources":["../src/api/relays.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst state = v.picklist(['open', 'closed']);\nexport type State = v.InferOutput<typeof state>;\nconst states = v.array(state);\nexport type States = v.InferOutput<typeof states>;\nconst relayState = v.object({ state: state });\n\nconst action = v.picklist(['open', 'close']);\nconst relayAction = v.object({ action: action });\ntype RelayAction = v.InferOutput<typeof relayAction>;\n\nexport class RelaysApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets all relays to their default state.\n */\n reset() {\n return this.fetch('/relays/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific relay by id.\n * @param id The relay id.\n * @returns The relay instance.\n */\n relay(id: number): Relay {\n return new Relay(this.fetch, id);\n }\n\n /**\n * Reads the state of all relays.\n * @returns The state of all relays.\n */\n read(): Promise<States> {\n return this.fetch(`/relays`, { schema: states });\n }\n\n /**\n * Opens all the relays.\n * @returns The new state of all relays.\n */\n open(): Promise<States> {\n return this.fetch(`/relays`, {\n method: 'POST',\n body: { action: 'open' } satisfies RelayAction,\n schema: states,\n });\n }\n\n /**\n * Closes all the relays.\n * @returns The new state of all relays.\n */\n close(): Promise<States> {\n return this.fetch(`/relays`, {\n method: 'POST',\n body: { action: 'close' } satisfies RelayAction,\n schema: states,\n });\n }\n}\n\nexport class Relay {\n constructor(\n private readonly fetch: UpFetch,\n /**\n * The relay id.\n */\n public readonly id: number,\n ) {}\n\n /**\n * Reads the state of the relay.\n * @returns The relay state.\n */\n async read(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, { schema: relayState })).state;\n }\n\n /**\n * Returns whether the relay is open.\n * @returns True if the relay is open, false otherwise.\n */\n async is_open(): Promise<boolean> {\n return (await this.read()) === 'open';\n }\n\n /**\n * Returns whether the relay is closed.\n * @returns True if the relay is closed, false otherwise.\n */\n async is_closed(): Promise<boolean> {\n return (await this.read()) === 'closed';\n }\n\n /**\n * Opens the relay.\n * @returns The new relay state.\n */\n async open(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, {\n method: 'POST',\n body: { action: 'open' } satisfies RelayAction,\n schema: relayState,\n }))\n .state;\n }\n\n /**\n * Closes the relay.\n * @returns The new relay state.\n */\n async close(): Promise<State> {\n return (await this.fetch(`/relays/${this.id}`, {\n method: 'POST',\n body: { action: 'close' } satisfies RelayAction,\n schema: relayState,\n }))\n .state;\n }\n}\n"],"mappings":"0BAGA,MAAM,EAAQ,EAAE,SAAS,CAAC,OAAQ,SAAS,CAAC,CAEtC,EAAS,EAAE,MAAM,EAAM,CAEvB,EAAa,EAAE,OAAO,CAAS,QAAO,CAAC,CAEvC,EAAS,EAAE,SAAS,CAAC,OAAQ,QAAQ,CAAC,CACxB,EAAE,OAAO,CAAU,SAAQ,CAAC,CAGhD,IAAa,EAAb,KAAuB,CACrB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAK7B,OAAQ,CACN,OAAO,KAAK,MAAM,gBAAiB,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,CAQjF,MAAM,EAAmB,CACvB,OAAO,IAAI,EAAM,KAAK,MAAO,EAAG,CAOlC,MAAwB,CACtB,OAAO,KAAK,MAAM,UAAW,CAAE,OAAQ,EAAQ,CAAC,CAOlD,MAAwB,CACtB,OAAO,KAAK,MAAM,UAAW,CAC3B,OAAQ,OACR,KAAM,CAAE,OAAQ,OAAQ,CACxB,OAAQ,EACT,CAAC,CAOJ,OAAyB,CACvB,OAAO,KAAK,MAAM,UAAW,CAC3B,OAAQ,OACR,KAAM,CAAE,OAAQ,QAAS,CACzB,OAAQ,EACT,CAAC,GAIO,EAAb,KAAmB,CACjB,YACE,EAIA,EACA,CALiB,KAAA,MAAA,EAID,KAAA,GAAA,EAOlB,MAAM,MAAuB,CAC3B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAAE,OAAQ,EAAY,CAAC,EAAE,MAO1E,MAAM,SAA4B,CAChC,OAAQ,MAAM,KAAK,MAAM,GAAM,OAOjC,MAAM,WAA8B,CAClC,OAAQ,MAAM,KAAK,MAAM,GAAM,SAOjC,MAAM,MAAuB,CAC3B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAC7C,OAAQ,OACR,KAAM,CAAE,OAAQ,OAAQ,CACxB,OAAQ,EACT,CAAC,EACC,MAOL,MAAM,OAAwB,CAC5B,OAAQ,MAAM,KAAK,MAAM,WAAW,KAAK,KAAM,CAC7C,OAAQ,OACR,KAAM,CAAE,OAAQ,QAAS,CACzB,OAAQ,EACT,CAAC,EACC"}
@@ -0,0 +1,77 @@
1
+ import { UpFetch } from "up-fetch";
2
+ import * as v from "valibot";
3
+
4
+ //#region src/api/relays.d.ts
5
+ declare const state: v.PicklistSchema<["open", "closed"], undefined>;
6
+ type State = v.InferOutput<typeof state>;
7
+ declare const states: v.ArraySchema<v.PicklistSchema<["open", "closed"], undefined>, undefined>;
8
+ type States = v.InferOutput<typeof states>;
9
+ declare class RelaysApi {
10
+ private readonly fetch;
11
+ constructor(fetch: UpFetch);
12
+ /**
13
+ * Resets all relays to their default state.
14
+ */
15
+ reset(): Promise<void>;
16
+ /**
17
+ * Access a specific relay by id.
18
+ * @param id The relay id.
19
+ * @returns The relay instance.
20
+ */
21
+ relay(id: number): Relay;
22
+ /**
23
+ * Reads the state of all relays.
24
+ * @returns The state of all relays.
25
+ */
26
+ read(): Promise<States>;
27
+ /**
28
+ * Opens all the relays.
29
+ * @returns The new state of all relays.
30
+ */
31
+ open(): Promise<States>;
32
+ /**
33
+ * Closes all the relays.
34
+ * @returns The new state of all relays.
35
+ */
36
+ close(): Promise<States>;
37
+ }
38
+ declare class Relay {
39
+ private readonly fetch;
40
+ /**
41
+ * The relay id.
42
+ */
43
+ readonly id: number;
44
+ constructor(fetch: UpFetch,
45
+ /**
46
+ * The relay id.
47
+ */
48
+ id: number);
49
+ /**
50
+ * Reads the state of the relay.
51
+ * @returns The relay state.
52
+ */
53
+ read(): Promise<State>;
54
+ /**
55
+ * Returns whether the relay is open.
56
+ * @returns True if the relay is open, false otherwise.
57
+ */
58
+ is_open(): Promise<boolean>;
59
+ /**
60
+ * Returns whether the relay is closed.
61
+ * @returns True if the relay is closed, false otherwise.
62
+ */
63
+ is_closed(): Promise<boolean>;
64
+ /**
65
+ * Opens the relay.
66
+ * @returns The new relay state.
67
+ */
68
+ open(): Promise<State>;
69
+ /**
70
+ * Closes the relay.
71
+ * @returns The new relay state.
72
+ */
73
+ close(): Promise<State>;
74
+ }
75
+ //#endregion
76
+ export { States as i, RelaysApi as n, State as r, Relay as t };
77
+ //# sourceMappingURL=relays-Dn_EI0HH.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relays-Dn_EI0HH.d.cts","names":[],"sources":["../src/api/relays.ts"],"sourcesContent":[],"mappings":";;;;cAGM,OAAK,CAAA,CAAA;KACC,KAAA,GAAQ,CAAA,CAAE,mBAAmB;AAHZ,cAIvB,MAFsC,EAEhC,CAAA,CAAA,WAFD,CAEC,CAAA,CAAA,cAFD,CAAA,CAAA,MAAA,EAAA,QAAA,CAAA,EAAA,SAAA,CAAA,EAAA,SAAA,CAAA;AACC,KAEA,MAAA,GAAS,CAAA,CAAE,WAFD,CAAA,OAEoB,MAFT,CAAA;AAC3B,cAQO,SAAA,CARD;EACA,iBAAM,KAAwB;EAO7B,WAAA,CAAS,KAAA,EACgB,OADhB;EACgB;;;EAsBpB,KAAA,CAAA,CAAA,EAjBX,OAiBW,CAAA,IAAA,CAAA;EAAR;;;;;EAoBQ,KAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EA5BG,KA4BH;EASL;;;;EAqBM,IAAA,CAAA,CAAA,EAlDT,OAkDS,CAlDD,MAkDC,CAAA;EAQE;;;;EAqBJ,IAAA,CAAA,CAAA,EAvEP,OAuEO,CAvEC,MAuED,CAAA;EAAO;;;;WA3Db,QAAQ;;cASN,KAAA;;;;;;qBAEe;;;;;;;;;UAWZ,QAAQ;;;;;aAQL;;;;;eAQE;;;;;UAQL,QAAQ;;;;;WAaP,QAAQ"}
@@ -0,0 +1 @@
1
+ const e=require(`./relays-8a3YZaV7.cjs`);exports.Relay=e.t,exports.RelaysApi=e.n;
@@ -0,0 +1,2 @@
1
+ import { i as States, n as RelaysApi, r as State, t as Relay } from "./relays-Dn_EI0HH.cjs";
2
+ export { Relay, RelaysApi, State, States };
@@ -0,0 +1,2 @@
1
+ import { i as States, n as RelaysApi, r as State, t as Relay } from "./relays-CGntlBiE.mjs";
2
+ export { Relay, RelaysApi, State, States };
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./relays-Cwtrx0B-.mjs";export{t as Relay,e as RelaysApi};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./com-BdsqVRMC.mjs";import{r as t}from"./gpio-CxHnpe7Y.mjs";import{n}from"./hmi-B04X0czX.mjs";import{n as r}from"./management-BRYyWntE.mjs";import{n as i}from"./power-kf9bMNDS.mjs";import{n as a}from"./relays-Cwtrx0B-.mjs";import{up as o}from"up-fetch";var s=class s{host;device;fetch;com;hmi;gpio;management;power;relays;constructor(s,c){this.host=s,this.device=c,this.fetch=o(fetch,()=>({baseUrl:`http://${this.host}/v0`,timeout:1e3,parseRejected:async e=>{let t,n=e.headers.get(`content-type`);try{t=n?.includes(`application/json`)?await e.json():await e.text()}catch{t=`Failed to parse response body`}throw typeof t==`object`&&[`code`,`message`,`suggestion`,`path`].every(e=>e in t)?Error(`${t.message} (${t.code})\n Suggestion: ${t.suggestion}\n Path: ${t.path}`):Error(`API request to ${e.url} failed with status ${e.status}: ${typeof t==`string`?t:JSON.stringify(t)}`)}})),this.com=new e(this.fetch),this.hmi=new n(this.fetch),this.gpio=new t(this.fetch,this.device),this.management=new r(this.fetch),this.power=new i(this.fetch,this.device),this.relays=new a(this.fetch)}async reset(){await this.com.reset(),await this.hmi.reset(),await this.gpio.reset(),await this.power.reset(),await this.relays.reset()}static create=async e=>new s(e,await new r(o(fetch,()=>({baseUrl:`http://${e}/v0`,timeout:1e3}))).device())};export{s as t};
2
+ //# sourceMappingURL=src-3DKHMeTA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-3DKHMeTA.mjs","names":["errorData: any"],"sources":["../src/index.ts"],"sourcesContent":["// Browser compatible package\n\nimport { up, type UpFetch } from 'up-fetch';\n\nimport { ComApi } from './api/com';\nimport { GpioApi } from './api/gpio';\nimport { HmiApi } from './api/hmi';\nimport { type Device, ManagementApi } from './api/management';\nimport { PowerApi } from './api/power';\nimport { RelaysApi } from './api/relays';\n\nexport class AT1000 {\n /**\n * IP address or hostname of the AT1000 device\n */\n public readonly host: string;\n /**\n * Device information\n */\n public readonly device: Device;\n\n private fetch: UpFetch;\n /**\n * COM API\n */\n public readonly com: ComApi;\n /**\n * HMI API\n */\n public readonly hmi: HmiApi;\n /**\n * GPIO API\n */\n public readonly gpio: GpioApi;\n /**\n * Management API\n */\n public readonly management: ManagementApi;\n /**\n * Power management API\n */\n public readonly power: PowerApi;\n /**\n * Relays API\n */\n public readonly relays: RelaysApi;\n\n constructor(host: string, device: Device) {\n this.host = host;\n this.device = device;\n\n this.fetch = up(\n fetch,\n () => ({\n baseUrl: `http://${this.host}/v0`,\n timeout: 1000,\n parseRejected: async (response) => {\n let errorData: any;\n const contentType = response.headers.get('content-type');\n try {\n if (contentType?.includes('application/json')) {\n errorData = await response.json();\n } else {\n errorData = await response.text();\n }\n } catch {\n errorData = 'Failed to parse response body';\n }\n\n if (\n typeof errorData === 'object'\n && ['code', 'message', 'suggestion', 'path'].every((key) => key in errorData)\n ) {\n throw new Error(\n `${errorData.message} (${errorData.code})\\n Suggestion: ${errorData.suggestion}\\n Path: ${errorData.path}`,\n );\n }\n\n throw new Error(\n `API request to ${response.url} failed with status ${response.status}: ${\n typeof errorData === 'string' ? errorData : JSON.stringify(errorData)\n }`,\n );\n },\n }),\n );\n\n this.com = new ComApi(this.fetch);\n this.hmi = new HmiApi(this.fetch);\n this.gpio = new GpioApi(this.fetch, this.device);\n this.management = new ManagementApi(this.fetch);\n this.power = new PowerApi(this.fetch, this.device);\n this.relays = new RelaysApi(this.fetch);\n }\n\n async reset() {\n await this.com.reset();\n await this.hmi.reset();\n await this.gpio.reset();\n await this.power.reset();\n await this.relays.reset();\n }\n\n public static create = async (host: string): Promise<AT1000> => {\n // Create a temporary client to fetch device info\n const management = new ManagementApi(\n up(fetch, () => ({ baseUrl: `http://${host}/v0`, timeout: 1000 })),\n );\n const device = await management.device();\n\n return new AT1000(host, device);\n };\n}\n"],"mappings":"gRAWA,IAAa,EAAb,MAAa,CAAO,CAIlB,KAIA,OAEA,MAIA,IAIA,IAIA,KAIA,WAIA,MAIA,OAEA,YAAY,EAAc,EAAgB,CACxC,KAAK,KAAO,EACZ,KAAK,OAAS,EAEd,KAAK,MAAQ,EACX,WACO,CACL,QAAS,UAAU,KAAK,KAAK,KAC7B,QAAS,IACT,cAAe,KAAO,IAAa,CACjC,IAAIA,EACE,EAAc,EAAS,QAAQ,IAAI,eAAe,CACxD,GAAI,CACF,AAGE,EAHE,GAAa,SAAS,mBAAmB,CAC/B,MAAM,EAAS,MAAM,CAErB,MAAM,EAAS,MAAM,MAE7B,CACN,EAAY,gCAYd,MARE,OAAO,GAAc,UAClB,CAAC,OAAQ,UAAW,aAAc,OAAO,CAAC,MAAO,GAAQ,KAAO,EAAU,CAEnE,MACR,GAAG,EAAU,QAAQ,IAAI,EAAU,KAAK,qBAAqB,EAAU,WAAW,cAAc,EAAU,OAC3G,CAGO,MACR,kBAAkB,EAAS,IAAI,sBAAsB,EAAS,OAAO,IACnE,OAAO,GAAc,SAAW,EAAY,KAAK,UAAU,EAAU,GAExE,EAEJ,EACF,CAED,KAAK,IAAM,IAAI,EAAO,KAAK,MAAM,CACjC,KAAK,IAAM,IAAI,EAAO,KAAK,MAAM,CACjC,KAAK,KAAO,IAAI,EAAQ,KAAK,MAAO,KAAK,OAAO,CAChD,KAAK,WAAa,IAAI,EAAc,KAAK,MAAM,CAC/C,KAAK,MAAQ,IAAI,EAAS,KAAK,MAAO,KAAK,OAAO,CAClD,KAAK,OAAS,IAAI,EAAU,KAAK,MAAM,CAGzC,MAAM,OAAQ,CACZ,MAAM,KAAK,IAAI,OAAO,CACtB,MAAM,KAAK,IAAI,OAAO,CACtB,MAAM,KAAK,KAAK,OAAO,CACvB,MAAM,KAAK,MAAM,OAAO,CACxB,MAAM,KAAK,OAAO,OAAO,CAG3B,OAAc,OAAS,KAAO,IAOrB,IAAI,EAAO,EAFH,MAHI,IAAI,EACrB,EAAG,WAAc,CAAE,QAAS,UAAU,EAAK,KAAM,QAAS,IAAM,EAAE,CACnE,CAC+B,QAAQ,CAET"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./chunk-DjWAcSYV.cjs`),t=require(`./com-BHaGVMz5.cjs`),n=require(`./gpio-DSTG-dmv.cjs`),r=require(`./hmi-DSFhbR-Y.cjs`),i=require(`./management-B758IJfF.cjs`),a=require(`./power-DtLWOEQI.cjs`),o=require(`./relays-8a3YZaV7.cjs`);let s=require(`up-fetch`);s=e.t(s);var c=class e{host;device;fetch;com;hmi;gpio;management;power;relays;constructor(e,c){this.host=e,this.device=c,this.fetch=(0,s.up)(fetch,()=>({baseUrl:`http://${this.host}/v0`,timeout:1e3,parseRejected:async e=>{let t,n=e.headers.get(`content-type`);try{t=n?.includes(`application/json`)?await e.json():await e.text()}catch{t=`Failed to parse response body`}throw typeof t==`object`&&[`code`,`message`,`suggestion`,`path`].every(e=>e in t)?Error(`${t.message} (${t.code})\n Suggestion: ${t.suggestion}\n Path: ${t.path}`):Error(`API request to ${e.url} failed with status ${e.status}: ${typeof t==`string`?t:JSON.stringify(t)}`)}})),this.com=new t.n(this.fetch),this.hmi=new r.n(this.fetch),this.gpio=new n.r(this.fetch,this.device),this.management=new i.n(this.fetch),this.power=new a.n(this.fetch,this.device),this.relays=new o.n(this.fetch)}async reset(){await this.com.reset(),await this.hmi.reset(),await this.gpio.reset(),await this.power.reset(),await this.relays.reset()}static create=async t=>new e(t,await new i.n((0,s.up)(fetch,()=>({baseUrl:`http://${t}/v0`,timeout:1e3}))).device())};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
2
+ //# sourceMappingURL=src-CJhZ2EuZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-CJhZ2EuZ.cjs","names":["errorData: any","ComApi","HmiApi","GpioApi","ManagementApi","PowerApi","RelaysApi"],"sources":["../src/index.ts"],"sourcesContent":["// Browser compatible package\n\nimport { up, type UpFetch } from 'up-fetch';\n\nimport { ComApi } from './api/com';\nimport { GpioApi } from './api/gpio';\nimport { HmiApi } from './api/hmi';\nimport { type Device, ManagementApi } from './api/management';\nimport { PowerApi } from './api/power';\nimport { RelaysApi } from './api/relays';\n\nexport class AT1000 {\n /**\n * IP address or hostname of the AT1000 device\n */\n public readonly host: string;\n /**\n * Device information\n */\n public readonly device: Device;\n\n private fetch: UpFetch;\n /**\n * COM API\n */\n public readonly com: ComApi;\n /**\n * HMI API\n */\n public readonly hmi: HmiApi;\n /**\n * GPIO API\n */\n public readonly gpio: GpioApi;\n /**\n * Management API\n */\n public readonly management: ManagementApi;\n /**\n * Power management API\n */\n public readonly power: PowerApi;\n /**\n * Relays API\n */\n public readonly relays: RelaysApi;\n\n constructor(host: string, device: Device) {\n this.host = host;\n this.device = device;\n\n this.fetch = up(\n fetch,\n () => ({\n baseUrl: `http://${this.host}/v0`,\n timeout: 1000,\n parseRejected: async (response) => {\n let errorData: any;\n const contentType = response.headers.get('content-type');\n try {\n if (contentType?.includes('application/json')) {\n errorData = await response.json();\n } else {\n errorData = await response.text();\n }\n } catch {\n errorData = 'Failed to parse response body';\n }\n\n if (\n typeof errorData === 'object'\n && ['code', 'message', 'suggestion', 'path'].every((key) => key in errorData)\n ) {\n throw new Error(\n `${errorData.message} (${errorData.code})\\n Suggestion: ${errorData.suggestion}\\n Path: ${errorData.path}`,\n );\n }\n\n throw new Error(\n `API request to ${response.url} failed with status ${response.status}: ${\n typeof errorData === 'string' ? errorData : JSON.stringify(errorData)\n }`,\n );\n },\n }),\n );\n\n this.com = new ComApi(this.fetch);\n this.hmi = new HmiApi(this.fetch);\n this.gpio = new GpioApi(this.fetch, this.device);\n this.management = new ManagementApi(this.fetch);\n this.power = new PowerApi(this.fetch, this.device);\n this.relays = new RelaysApi(this.fetch);\n }\n\n async reset() {\n await this.com.reset();\n await this.hmi.reset();\n await this.gpio.reset();\n await this.power.reset();\n await this.relays.reset();\n }\n\n public static create = async (host: string): Promise<AT1000> => {\n // Create a temporary client to fetch device info\n const management = new ManagementApi(\n up(fetch, () => ({ baseUrl: `http://${host}/v0`, timeout: 1000 })),\n );\n const device = await management.device();\n\n return new AT1000(host, device);\n };\n}\n"],"mappings":"wRAWA,IAAa,EAAb,MAAa,CAAO,CAIlB,KAIA,OAEA,MAIA,IAIA,IAIA,KAIA,WAIA,MAIA,OAEA,YAAY,EAAc,EAAgB,CACxC,KAAK,KAAO,EACZ,KAAK,OAAS,EAEd,KAAK,OAAA,EAAA,EAAA,IACH,WACO,CACL,QAAS,UAAU,KAAK,KAAK,KAC7B,QAAS,IACT,cAAe,KAAO,IAAa,CACjC,IAAIA,EACE,EAAc,EAAS,QAAQ,IAAI,eAAe,CACxD,GAAI,CACF,AAGE,EAHE,GAAa,SAAS,mBAAmB,CAC/B,MAAM,EAAS,MAAM,CAErB,MAAM,EAAS,MAAM,MAE7B,CACN,EAAY,gCAYd,MARE,OAAO,GAAc,UAClB,CAAC,OAAQ,UAAW,aAAc,OAAO,CAAC,MAAO,GAAQ,KAAO,EAAU,CAEnE,MACR,GAAG,EAAU,QAAQ,IAAI,EAAU,KAAK,qBAAqB,EAAU,WAAW,cAAc,EAAU,OAC3G,CAGO,MACR,kBAAkB,EAAS,IAAI,sBAAsB,EAAS,OAAO,IACnE,OAAO,GAAc,SAAW,EAAY,KAAK,UAAU,EAAU,GAExE,EAEJ,EACF,CAED,KAAK,IAAM,IAAIC,EAAAA,EAAO,KAAK,MAAM,CACjC,KAAK,IAAM,IAAIC,EAAAA,EAAO,KAAK,MAAM,CACjC,KAAK,KAAO,IAAIC,EAAAA,EAAQ,KAAK,MAAO,KAAK,OAAO,CAChD,KAAK,WAAa,IAAIC,EAAAA,EAAc,KAAK,MAAM,CAC/C,KAAK,MAAQ,IAAIC,EAAAA,EAAS,KAAK,MAAO,KAAK,OAAO,CAClD,KAAK,OAAS,IAAIC,EAAAA,EAAU,KAAK,MAAM,CAGzC,MAAM,OAAQ,CACZ,MAAM,KAAK,IAAI,OAAO,CACtB,MAAM,KAAK,IAAI,OAAO,CACtB,MAAM,KAAK,KAAK,OAAO,CACvB,MAAM,KAAK,MAAM,OAAO,CACxB,MAAM,KAAK,OAAO,OAAO,CAG3B,OAAc,OAAS,KAAO,IAOrB,IAAI,EAAO,EAFH,MAHI,IAAIF,EAAAA,GAAAA,EAAAA,EAAAA,IAClB,WAAc,CAAE,QAAS,UAAU,EAAK,KAAM,QAAS,IAAM,EAAE,CACnE,CAC+B,QAAQ,CAET"}
package/package.json ADDED
@@ -0,0 +1,124 @@
1
+ {
2
+ "name": "@ikalogic/at1000",
3
+ "version": "0.1.0",
4
+ "description": "Ikalogic AT1000 SDK for browsers",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.mts",
9
+ "license": "MIT",
10
+ "homepage": "https://ikalogic.com/test-sequencers/at1000/intro/",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.mts",
21
+ "default": "./dist/index.mjs"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.cts",
25
+ "default": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "./discovery": {
29
+ "import": {
30
+ "types": "./dist/discovery.d.mts",
31
+ "default": "./dist/discovery.mjs"
32
+ },
33
+ "require": {
34
+ "types": "./dist/discovery.d.cts",
35
+ "default": "./dist/discovery.cjs"
36
+ }
37
+ },
38
+ "./com": {
39
+ "import": {
40
+ "types": "./dist/com.d.mts",
41
+ "default": "./dist/com.mjs"
42
+ },
43
+ "require": {
44
+ "types": "./dist/com.d.cts",
45
+ "default": "./dist/com.cjs"
46
+ }
47
+ },
48
+ "./gpio": {
49
+ "import": {
50
+ "types": "./dist/gpio.d.mts",
51
+ "default": "./dist/gpio.mjs"
52
+ },
53
+ "require": {
54
+ "types": "./dist/gpio.d.cts",
55
+ "default": "./dist/gpio.cjs"
56
+ }
57
+ },
58
+ "./hmi": {
59
+ "import": {
60
+ "types": "./dist/hmi.d.mts",
61
+ "default": "./dist/hmi.mjs"
62
+ },
63
+ "require": {
64
+ "types": "./dist/hmi.d.cts",
65
+ "default": "./dist/hmi.cjs"
66
+ }
67
+ },
68
+ "./management": {
69
+ "import": {
70
+ "types": "./dist/management.d.mts",
71
+ "default": "./dist/management.mjs"
72
+ },
73
+ "require": {
74
+ "types": "./dist/management.d.cts",
75
+ "default": "./dist/management.cjs"
76
+ }
77
+ },
78
+ "./power": {
79
+ "import": {
80
+ "types": "./dist/power.d.mts",
81
+ "default": "./dist/power.mjs"
82
+ },
83
+ "require": {
84
+ "types": "./dist/power.d.cts",
85
+ "default": "./dist/power.cjs"
86
+ }
87
+ },
88
+ "./relays": {
89
+ "import": {
90
+ "types": "./dist/relays.d.mts",
91
+ "default": "./dist/relays.mjs"
92
+ },
93
+ "require": {
94
+ "types": "./dist/relays.d.cts",
95
+ "default": "./dist/relays.cjs"
96
+ }
97
+ },
98
+ "./package.json": "./package.json"
99
+ },
100
+ "scripts": {
101
+ "build": "tsdown",
102
+ "dev": "tsdown --watch",
103
+ "typecheck": "tsc --noEmit",
104
+ "release": "npm publish",
105
+ "test": "bun test --coverage",
106
+ "docs": "typedoc-pkg -o dist/docs",
107
+ "lint:package": "bun run build && publint"
108
+ },
109
+ "dependencies": {
110
+ "mdns-scanner": "^1.2.3",
111
+ "up-fetch": "^2.5.0",
112
+ "valibot": "^1.1.0"
113
+ },
114
+ "devDependencies": {
115
+ "@arethetypeswrong/core": "^0.18.2",
116
+ "@types/bun": "^1.3.1",
117
+ "@types/node": "^24.10.0",
118
+ "@typhonjs-typedoc/typedoc-pkg": "^0.4.0",
119
+ "publint": "^0.3.15",
120
+ "tsdown": "^0.15.12",
121
+ "typedoc": "^0.28.14",
122
+ "typescript": "^5.9.3"
123
+ }
124
+ }