@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":"gpio-DSTG-dmv.cjs","names":["v","analogOutputLevel","analogLevel","digitalLevel","fetch: UpFetch","id: number"],"sources":["../src/api/gpio.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { analogLevel, type AnalogOutputLevel, analogOutputLevel, digitalLevel } from './common';\nimport type { Device } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst syncAction = v.picklist(['release', 'hold'], 'Invalid sync action');\nconst analogInputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('input'),\n});\nconst analogOutputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('output'),\n value: v.optional(analogOutputLevel),\n});\nconst digitalInputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('input'),\n vil: analogLevel,\n vih: analogLevel,\n});\nconst digitalOutputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('output'),\n value: digitalLevel,\n vol: analogOutputLevel,\n voh: analogOutputLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\nexport type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;\nexport type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;\nexport type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;\nexport type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;\n\nconst partialAnalogOutputConfiguration = v.omit(analogOutputConfiguration, ['direction', 'mode']);\nexport type PartialAnalogOutputConfiguration = v.InferOutput<\n typeof partialAnalogOutputConfiguration\n>;\nconst partialDigitalInputConfiguration = v.omit(digitalInputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalInputConfiguration = v.InferOutput<\n typeof partialDigitalInputConfiguration\n>;\nconst partialDigitalOutputConfiguration = v.omit(digitalOutputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalOutputConfiguration = v.InferOutput<\n typeof partialDigitalOutputConfiguration\n>;\n\nconst digitalState = v.object({ value: digitalLevel });\nconst analogState = v.object({ value: analogLevel });\n\nconst syncConfiguration = v.object({ action: syncAction });\nexport type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;\n\nexport class GpioApi {\n private count: number;\n\n constructor(private readonly fetch: UpFetch, device: Device) {\n this.count = device.capabilities.io.count;\n }\n\n /**\n * Resets all IO configurations to default.\n */\n reset(): Promise<void> {\n return this.fetch('/gpio/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific digital IO pin by id.\n * @param io The IO pin id.\n * @returns The digital IO instance.\n */\n digital(io: number): DigitalIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new DigitalIO(this.fetch, io);\n }\n\n /**\n * Access a specific analog IO pin by id.\n * @param io The IO pin id.\n * @returns The analog IO instance.\n */\n analog(io: number): AnalogIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new AnalogIO(this.fetch, io);\n }\n\n /**\n * Holds the current state of all GPIO pins.\n * @returns The applied sync state.\n */\n hold(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'hold' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Releases control of the IO pins, allowing external control.\n *\n * This also sets the device as a slave.\n *\n * @returns The applied sync state.\n */\n release(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'release' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n}\n\nexport class DigitalIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configure the pin as a digital input.\n * @param config The digital input configuration.\n * @returns The applied configuration.\n */\n configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalInputConfiguration,\n { ...config, mode: 'digital', direction: 'input' } satisfies DigitalInputConfiguration,\n ),\n schema: digitalInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as a digital output.\n * @param config The digital output configuration.\n * @returns The applied configuration.\n */\n configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalOutputConfiguration,\n { ...config, mode: 'digital', direction: 'output' } satisfies DigitalOutputConfiguration,\n ),\n schema: digitalOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: digitalState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: boolean): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: { value },\n schema: digitalState,\n }))\n .value;\n }\n}\n\nexport class AnalogIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configures the pin as an analog input.\n * @returns The applied configuration.\n * @returns The applied configuration.\n */\n configure_input(): Promise<AnalogInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: { mode: 'analog', direction: 'input' } satisfies AnalogInputConfiguration,\n schema: analogInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as an analog output.\n * @param config The analog output configuration.\n * @returns The applied configuration.\n */\n configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n analogOutputConfiguration,\n { value, mode: 'analog', direction: 'output' } satisfies AnalogOutputConfiguration,\n ),\n schema: analogOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: analogState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: number): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: { value },\n schema: analogState,\n }))\n .value;\n }\n}\n"],"mappings":"6GAQA,MAAM,EAAaA,EAAE,SAAS,CAAC,UAA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AY,EAAiC,EAA4B,CAA5C,KAAA,MAAA,EAAgC,KAAA,GAAA,EAO7D,iBAAqD,CACnD,OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAM,CAAE,KAAM,SAAU,UAAW,QAAS,CAC5C,OAAQ,EACT,CAAC,CAQJ,iBAAiB,EAA8D,CAC7E,OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAMA,EAAE,MACN,EACA,CAAE,QAAO,KAAM,SAAU,UAAW,SAAU,CAC/C,CACD,OAAQ,EACT,CAAC,CAOJ,MAAM,MAAwB,CAC5B,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CAAE,OAAQ,EAAa,CAAC,EAAE,MAQ/E,MAAM,MAAM,EAAgC,CAC1C,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CACjD,OAAQ,MACR,KAAM,CAAE,QAAO,CACf,OAAQ,EACT,CAAC,EACC"}
package/dist/gpio.cjs ADDED
@@ -0,0 +1 @@
1
+ require(`./common-ix04NEFn.cjs`);const e=require(`./gpio-DSTG-dmv.cjs`);exports.AnalogIO=e.t,exports.DigitalIO=e.n,exports.GpioApi=e.r;
@@ -0,0 +1,4 @@
1
+ import { t as AnalogOutputLevel } from "./common-CsBdb633.cjs";
2
+ import "./management-CecISx9d.cjs";
3
+ import { a as DigitalInputConfiguration, c as PartialAnalogOutputConfiguration, d as SyncConfiguration, i as DigitalIO, l as PartialDigitalInputConfiguration, n as AnalogInputConfiguration, o as DigitalOutputConfiguration, r as AnalogOutputConfiguration, s as GpioApi, t as AnalogIO, u as PartialDigitalOutputConfiguration } from "./gpio-BQXV_UtO.cjs";
4
+ export { AnalogIO, AnalogInputConfiguration, AnalogOutputConfiguration, AnalogOutputLevel, DigitalIO, DigitalInputConfiguration, DigitalOutputConfiguration, GpioApi, PartialAnalogOutputConfiguration, PartialDigitalInputConfiguration, PartialDigitalOutputConfiguration, SyncConfiguration };
@@ -0,0 +1,4 @@
1
+ import { t as AnalogOutputLevel } from "./common-ClinPNdn.mjs";
2
+ import "./management-DYOPvugC.mjs";
3
+ import { a as DigitalInputConfiguration, c as PartialAnalogOutputConfiguration, d as SyncConfiguration, i as DigitalIO, l as PartialDigitalInputConfiguration, n as AnalogInputConfiguration, o as DigitalOutputConfiguration, r as AnalogOutputConfiguration, s as GpioApi, t as AnalogIO, u as PartialDigitalOutputConfiguration } from "./gpio-D4KyCVtn.mjs";
4
+ export { AnalogIO, AnalogInputConfiguration, AnalogOutputConfiguration, AnalogOutputLevel, DigitalIO, DigitalInputConfiguration, DigitalOutputConfiguration, GpioApi, PartialAnalogOutputConfiguration, PartialDigitalInputConfiguration, PartialDigitalOutputConfiguration, SyncConfiguration };
package/dist/gpio.mjs ADDED
@@ -0,0 +1 @@
1
+ import"./common-DSzy5K03.mjs";import{n as e,r as t,t as n}from"./gpio-CxHnpe7Y.mjs";export{n as AnalogIO,e as DigitalIO,t as GpioApi};
@@ -0,0 +1,2 @@
1
+ import*as e from"valibot";const t=e.pipe(e.string(),e.maxLength(1024)),n=e.object({text:t}),r=e.optional(e.pipe(e.string(),e.length(7),e.hexColor())),i=e.object({text:r,progress:r,background:r}),a=e.pipe(e.number(),e.minValue(0),e.maxValue(100)),o=e.object({progress:a}),s=e.object({sound_id:e.picklist([`sound1`,`sound2`,`sound3`]),volume:e.pipe(e.number(),e.minValue(0),e.maxValue(100))}),c=e.object({rotation:e.number(),button_pushed:e.boolean()}),l=e.object({type:e.picklist([`rotation`,`button`]),state:c}),u=e.union([l,e.null()]),d=e.object({timeout_ms:e.pipe(e.number(),e.minValue(0),e.maxValue(3e4))});var f=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/hmi/reset`,{method:`POST`,parseResponse:()=>{}})}screen(){return new p(this.fetch)}audio(){return new m(this.fetch)}knob(){return new h(this.fetch)}},p=class{constructor(e){this.fetch=e}async print(t){return(await this.fetch(`/hmi/screen/text`,{method:`POST`,body:e.parse(n,{text:t}),schema:n})).text}colors(t){return this.fetch(`/hmi/screen/colors`,{method:`PATCH`,body:e.parse(i,t),schema:i})}async progress(t){return t==0?await this.fetch(`/hmi/screen/progress`,{method:`DELETE`,parseResponse:()=>({progress:0})}):this.fetch(`/hmi/screen/progress`,{method:`PUT`,body:e.parse(o,{progress:t}),schema:o})}clear(){return this.fetch(`/hmi/screen/clear`,{method:`POST`,parseResponse:()=>{}})}},m=class{constructor(e){this.fetch=e}async play(t){return this.fetch(`/hmi/speaker/play`,{method:`POST`,body:e.parse(s,t),schema:s})}},h=class{constructor(e){this.fetch=e}async rotation(){return(await this.fetch(`/hmi/knob`,{method:`GET`,schema:c})).rotation}async button_pushed(){return(await this.fetch(`/hmi/knob`,{method:`GET`,schema:c})).button_pushed}async wait_event(t){return this.fetch(`/hmi/knob/wait_event`,{method:`POST`,body:e.parse(d,{timeout_ms:t}),schema:u,parseResponse:t=>t.status===204?null:e.parse(l,t.json())})}};export{p as i,f as n,h as r,m as t};
2
+ //# sourceMappingURL=hmi-B04X0czX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-B04X0czX.mjs","names":["fetch: UpFetch"],"sources":["../src/api/hmi.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst screenText = v.pipe(v.string(), v.maxLength(1024));\nexport type ScreenText = v.InferOutput<typeof screenText>;\n\nconst text = v.object({ text: screenText });\ntype Text = v.InferOutput<typeof text>;\n\nconst optionalHexColor = v.optional(v.pipe(v.string(), v.length(7), v.hexColor()));\nconst color = v.object({\n text: optionalHexColor,\n progress: optionalHexColor,\n background: optionalHexColor,\n});\nexport type Color = v.InferOutput<typeof color>;\n\nconst progressValue = v.pipe(v.number(), v.minValue(0), v.maxValue(100));\nexport type ProgressValue = v.InferOutput<typeof progressValue>;\nconst progress = v.object({ progress: progressValue });\nexport type Progress = v.InferOutput<typeof progress>;\n\nconst playbackConfiguration = v.object({\n sound_id: v.picklist(['sound1', 'sound2', 'sound3']),\n volume: v.pipe(v.number(), v.minValue(0), v.maxValue(100)),\n});\nexport type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;\n\nconst knobState = v.object({ rotation: v.number(), button_pushed: v.boolean() });\nconst knobEvent = v.object({ type: v.picklist(['rotation', 'button']), state: knobState });\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\nconst optionalKnobEvent = v.union([knobEvent, v.null()]);\nconst knobWaitEvent = v.object({\n timeout_ms: v.pipe(v.number(), v.minValue(0), v.maxValue(30000)),\n});\n\nexport class HmiApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets the HMI.\n */\n reset(): Promise<void> {\n return this.fetch('/hmi/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access the screen API.\n * @returns The screen instance.\n */\n screen(): Screen {\n return new Screen(this.fetch);\n }\n\n /**\n * Access the audio API.\n * @returns The audio instance.\n */\n audio(): Audio {\n return new Audio(this.fetch);\n }\n\n /**\n * Access the knob API.\n * @returns The knob instance.\n */\n knob(): Knob {\n return new Knob(this.fetch);\n }\n}\n\nexport class Screen {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Prints text to the screen.\n * @param data The text to print.\n * @returns The printed text.\n */\n async print(data: ScreenText): Promise<string> {\n return (await this.fetch('/hmi/screen/text', {\n method: 'POST',\n body: v.parse(text, { text: data } satisfies Text),\n schema: text,\n }))\n .text;\n }\n\n /**\n * Sets the screen colors.\n * @param colors The colors to set.\n * @returns The updated colors.\n */\n colors(colors: Color): Promise<Color> {\n return this.fetch('/hmi/screen/colors', {\n method: 'PATCH',\n body: v.parse(color, colors satisfies Color),\n schema: color,\n });\n }\n\n /**\n * Sets the screen progress.\n * @param data The progress value to set.\n * @returns The updated progress.\n */\n async progress(data: ProgressValue): Promise<Progress> {\n if (data == 0) {\n return await this.fetch('/hmi/screen/progress', {\n method: 'DELETE',\n parseResponse: () => ({ progress: 0 }),\n });\n }\n\n return this.fetch('/hmi/screen/progress', {\n method: 'PUT',\n body: v.parse(progress, { progress: data } satisfies Progress),\n schema: progress,\n });\n }\n\n /**\n * Clears the screen.\n */\n clear(): Promise<void> {\n return this.fetch('/hmi/screen/clear', { method: 'POST', parseResponse: () => {} });\n }\n}\n\nexport class Audio {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Plays a sound.\n * @param config The configuration (sound_id, volume).\n * @returns The play configuration.\n */\n async play(config: PlaybackConfiguration): Promise<PlaybackConfiguration> {\n return this.fetch('/hmi/speaker/play', {\n method: 'POST',\n body: v.parse(playbackConfiguration, config satisfies PlaybackConfiguration),\n schema: playbackConfiguration,\n });\n }\n}\n\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets the current rotation of the knob in increments.\n * @returns The current number of increments.\n */\n async rotation(): Promise<number> {\n return (await this.fetch('/hmi/knob', { method: 'GET', schema: knobState })).rotation;\n }\n\n /**\n * Returns whether the button is currently pushed.\n * @returns True if the button is pushed, false otherwise.\n */\n async button_pushed(): Promise<boolean> {\n return (await this.fetch('/hmi/knob', { method: 'GET', schema: knobState })).button_pushed;\n }\n\n /**\n * Waits for a knob event and returns it.\n * @param timeout_ms The timeout in milliseconds.\n * @returns The knob event or null if the timeout was reached.\n */\n async wait_event(timeout_ms: number): Promise<KnobEvent | null> {\n return this.fetch('/hmi/knob/wait_event', {\n method: 'POST',\n body: v.parse(knobWaitEvent, { timeout_ms }),\n schema: optionalKnobEvent,\n parseResponse: (response) => {\n if (response.status === 204) {\n return null;\n }\n\n return v.parse(knobEvent, response.json());\n },\n });\n }\n}\n"],"mappings":"0BAGA,MAAM,EAAa,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,UAAU,KAAK,CAAC,CAGlD,EAAO,EAAE,OAAO,CAAE,KAAM,EAAY,CAAC,CAGrC,EAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,OAAO,EAAE,CAAE,EAAE,UAAU,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0 +1,113 @@
1
+ import { UpFetch } from "up-fetch";
2
+ import * as v from "valibot";
3
+
4
+ //#region src/api/hmi.d.ts
5
+ declare const screenText: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1024, undefined>]>;
6
+ type ScreenText = v.InferOutput<typeof screenText>;
7
+ declare const color: v.ObjectSchema<{
8
+ readonly text: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
9
+ readonly progress: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
10
+ readonly background: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
11
+ }, undefined>;
12
+ type Color = v.InferOutput<typeof color>;
13
+ declare const progressValue: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
14
+ type ProgressValue = v.InferOutput<typeof progressValue>;
15
+ declare const progress: v.ObjectSchema<{
16
+ readonly progress: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
17
+ }, undefined>;
18
+ type Progress = v.InferOutput<typeof progress>;
19
+ declare const playbackConfiguration: v.ObjectSchema<{
20
+ readonly sound_id: v.PicklistSchema<["sound1", "sound2", "sound3"], undefined>;
21
+ readonly volume: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
22
+ }, undefined>;
23
+ type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;
24
+ declare const knobEvent: v.ObjectSchema<{
25
+ readonly type: v.PicklistSchema<["rotation", "button"], undefined>;
26
+ readonly state: v.ObjectSchema<{
27
+ readonly rotation: v.NumberSchema<undefined>;
28
+ readonly button_pushed: v.BooleanSchema<undefined>;
29
+ }, undefined>;
30
+ }, undefined>;
31
+ type KnobEvent = v.InferOutput<typeof knobEvent>;
32
+ declare class HmiApi {
33
+ private readonly fetch;
34
+ constructor(fetch: UpFetch);
35
+ /**
36
+ * Resets the HMI.
37
+ */
38
+ reset(): Promise<void>;
39
+ /**
40
+ * Access the screen API.
41
+ * @returns The screen instance.
42
+ */
43
+ screen(): Screen;
44
+ /**
45
+ * Access the audio API.
46
+ * @returns The audio instance.
47
+ */
48
+ audio(): Audio;
49
+ /**
50
+ * Access the knob API.
51
+ * @returns The knob instance.
52
+ */
53
+ knob(): Knob;
54
+ }
55
+ declare class Screen {
56
+ private readonly fetch;
57
+ constructor(fetch: UpFetch);
58
+ /**
59
+ * Prints text to the screen.
60
+ * @param data The text to print.
61
+ * @returns The printed text.
62
+ */
63
+ print(data: ScreenText): Promise<string>;
64
+ /**
65
+ * Sets the screen colors.
66
+ * @param colors The colors to set.
67
+ * @returns The updated colors.
68
+ */
69
+ colors(colors: Color): Promise<Color>;
70
+ /**
71
+ * Sets the screen progress.
72
+ * @param data The progress value to set.
73
+ * @returns The updated progress.
74
+ */
75
+ progress(data: ProgressValue): Promise<Progress>;
76
+ /**
77
+ * Clears the screen.
78
+ */
79
+ clear(): Promise<void>;
80
+ }
81
+ declare class Audio {
82
+ private readonly fetch;
83
+ constructor(fetch: UpFetch);
84
+ /**
85
+ * Plays a sound.
86
+ * @param config The configuration (sound_id, volume).
87
+ * @returns The play configuration.
88
+ */
89
+ play(config: PlaybackConfiguration): Promise<PlaybackConfiguration>;
90
+ }
91
+ declare class Knob {
92
+ private readonly fetch;
93
+ constructor(fetch: UpFetch);
94
+ /**
95
+ * Gets the current rotation of the knob in increments.
96
+ * @returns The current number of increments.
97
+ */
98
+ rotation(): Promise<number>;
99
+ /**
100
+ * Returns whether the button is currently pushed.
101
+ * @returns True if the button is pushed, false otherwise.
102
+ */
103
+ button_pushed(): Promise<boolean>;
104
+ /**
105
+ * Waits for a knob event and returns it.
106
+ * @param timeout_ms The timeout in milliseconds.
107
+ * @returns The knob event or null if the timeout was reached.
108
+ */
109
+ wait_event(timeout_ms: number): Promise<KnobEvent | null>;
110
+ }
111
+ //#endregion
112
+ export { KnobEvent as a, ProgressValue as c, Knob as i, Screen as l, Color as n, PlaybackConfiguration as o, HmiApi as r, Progress as s, Audio as t, ScreenText as u };
113
+ //# sourceMappingURL=hmi-BMM-GMeM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-BMM-GMeM.d.mts","names":[],"sources":["../src/api/hmi.ts"],"sourcesContent":[],"mappings":";;;;cAGM,YAAU,CAAA,CAAA,yBAAA,CAAA,CAAA,yBAAA,CAAA,CAAA;KACJ,UAAA,GAAa,CAAA,CAAE,mBAAmB;AAHjB,cASvB,KAPkD,EAO7C,CAAA,CAAA,YAP6C,CAAA;EAAxC,SAAA,IAAA,kBAAA,iBAAA,CAAA,SAAA,eAAA,CAAA,SAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA,kBAAA,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA;EAAA,SAAA,QAAA,kBAAA,iBAAA,CAAA,SAAA,eAAA,CAAA,SAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA,kBAAA,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA;EAAA,SAAA,UAAA,kBAAA,iBAAA,CAAA,SAAA,eAAA,CAAA,SAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA,kBAAA,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA;CAAA,EAAA,SAAA,CAAA;AACJ,KAWA,KAAA,GAAQ,CAAA,CAAE,WAXwB,CAAA,OAWL,KAXd,CAA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CAAA;;AAkBpC,cAKE,KAAA,CALF;EAAO,iBAAA,KAAA;EAKL,WAAK,CAAA,KAAA,EACoB,OADpB;EACoB;;;;;EAgBzB,IAAA,CAAA,MAAI,EATI,qBASJ,CAAA,EAT4B,OAS5B,CAToC,qBASpC,CAAA;;AAOG,cAPP,IAAA,CAOO;EAQK,iBAAA,KAAA;EASuB,WAAA,CAAA,KAAA,EAvBV,OAuBU;EAAR;;;;cAjBpB;;;;;mBAQK;;;;;;kCASe,QAAQ"}
@@ -0,0 +1,113 @@
1
+ import { UpFetch } from "up-fetch";
2
+ import * as v from "valibot";
3
+
4
+ //#region src/api/hmi.d.ts
5
+ declare const screenText: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1024, undefined>]>;
6
+ type ScreenText = v.InferOutput<typeof screenText>;
7
+ declare const color: v.ObjectSchema<{
8
+ readonly text: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
9
+ readonly progress: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
10
+ readonly background: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 7, undefined>, v.HexColorAction<string, undefined>]>, undefined>;
11
+ }, undefined>;
12
+ type Color = v.InferOutput<typeof color>;
13
+ declare const progressValue: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
14
+ type ProgressValue = v.InferOutput<typeof progressValue>;
15
+ declare const progress: v.ObjectSchema<{
16
+ readonly progress: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
17
+ }, undefined>;
18
+ type Progress = v.InferOutput<typeof progress>;
19
+ declare const playbackConfiguration: v.ObjectSchema<{
20
+ readonly sound_id: v.PicklistSchema<["sound1", "sound2", "sound3"], undefined>;
21
+ readonly volume: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
22
+ }, undefined>;
23
+ type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;
24
+ declare const knobEvent: v.ObjectSchema<{
25
+ readonly type: v.PicklistSchema<["rotation", "button"], undefined>;
26
+ readonly state: v.ObjectSchema<{
27
+ readonly rotation: v.NumberSchema<undefined>;
28
+ readonly button_pushed: v.BooleanSchema<undefined>;
29
+ }, undefined>;
30
+ }, undefined>;
31
+ type KnobEvent = v.InferOutput<typeof knobEvent>;
32
+ declare class HmiApi {
33
+ private readonly fetch;
34
+ constructor(fetch: UpFetch);
35
+ /**
36
+ * Resets the HMI.
37
+ */
38
+ reset(): Promise<void>;
39
+ /**
40
+ * Access the screen API.
41
+ * @returns The screen instance.
42
+ */
43
+ screen(): Screen;
44
+ /**
45
+ * Access the audio API.
46
+ * @returns The audio instance.
47
+ */
48
+ audio(): Audio;
49
+ /**
50
+ * Access the knob API.
51
+ * @returns The knob instance.
52
+ */
53
+ knob(): Knob;
54
+ }
55
+ declare class Screen {
56
+ private readonly fetch;
57
+ constructor(fetch: UpFetch);
58
+ /**
59
+ * Prints text to the screen.
60
+ * @param data The text to print.
61
+ * @returns The printed text.
62
+ */
63
+ print(data: ScreenText): Promise<string>;
64
+ /**
65
+ * Sets the screen colors.
66
+ * @param colors The colors to set.
67
+ * @returns The updated colors.
68
+ */
69
+ colors(colors: Color): Promise<Color>;
70
+ /**
71
+ * Sets the screen progress.
72
+ * @param data The progress value to set.
73
+ * @returns The updated progress.
74
+ */
75
+ progress(data: ProgressValue): Promise<Progress>;
76
+ /**
77
+ * Clears the screen.
78
+ */
79
+ clear(): Promise<void>;
80
+ }
81
+ declare class Audio {
82
+ private readonly fetch;
83
+ constructor(fetch: UpFetch);
84
+ /**
85
+ * Plays a sound.
86
+ * @param config The configuration (sound_id, volume).
87
+ * @returns The play configuration.
88
+ */
89
+ play(config: PlaybackConfiguration): Promise<PlaybackConfiguration>;
90
+ }
91
+ declare class Knob {
92
+ private readonly fetch;
93
+ constructor(fetch: UpFetch);
94
+ /**
95
+ * Gets the current rotation of the knob in increments.
96
+ * @returns The current number of increments.
97
+ */
98
+ rotation(): Promise<number>;
99
+ /**
100
+ * Returns whether the button is currently pushed.
101
+ * @returns True if the button is pushed, false otherwise.
102
+ */
103
+ button_pushed(): Promise<boolean>;
104
+ /**
105
+ * Waits for a knob event and returns it.
106
+ * @param timeout_ms The timeout in milliseconds.
107
+ * @returns The knob event or null if the timeout was reached.
108
+ */
109
+ wait_event(timeout_ms: number): Promise<KnobEvent | null>;
110
+ }
111
+ //#endregion
112
+ export { KnobEvent as a, ProgressValue as c, Knob as i, Screen as l, Color as n, PlaybackConfiguration as o, HmiApi as r, Progress as s, Audio as t, ScreenText as u };
113
+ //# sourceMappingURL=hmi-Cx7xLvkd.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-Cx7xLvkd.d.cts","names":[],"sources":["../src/api/hmi.ts"],"sourcesContent":[],"mappings":";;;;cAGM,YAAU,CAAA,CAAA,yBAAA,CAAA,CAAA,yBAAA,CAAA,CAAA;KACJ,UAAA,GAAa,CAAA,CAAE,mBAAmB;AAHjB,cASvB,KAPkD,EAO7C,CAAA,CAAA,YAP6C,CAAA;EAAxC,SAAA,IAAA,kBAAA,iBAAA,CAAA,SAAA,eAAA,CAAA,SAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA,kBAAA,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,CAAA,EAAA,SAAA,CAAA;EAAA,SAAA,QAAA,kBAAA,iBAAA,CAAA,SAAA,eAAA,CAAA,SAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA,kBAAA,CAAA,MAAA,EA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AA,CAAA,IAAA,EAiDQ,UAjDC,CAAA,EAiDY,OAjDY,CAAA,MAAnB,CAAA;EAMb;;;;;EA8BH,MAAA,CAAA,MAAA,EA2BO,KA3BP,CAAA,EA2Be,OA3Bf,CA2BuB,KA3BvB,CAAA;EAAI;AAKd;;;;EAsBiB,QAAA,CAAA,IAAA,EAaM,aAbN,CAAA,EAasB,OAbtB,CAa8B,QAb9B,CAAA;EAAgB;;;EAac,KAAA,CAAA,CAAA,EAkBpC,OAlBoC,CAAA,IAAA,CAAA;;AAkBpC,cAKE,KAAA,CALF;EAAO,iBAAA,KAAA;EAKL,WAAK,CAAA,KAAA,EACoB,OADpB;EACoB;;;;;EAgBzB,IAAA,CAAA,MAAI,EATI,qBASJ,CAAA,EAT4B,OAS5B,CAToC,qBASpC,CAAA;;AAOG,cAPP,IAAA,CAOO;EAQK,iBAAA,KAAA;EASuB,WAAA,CAAA,KAAA,EAvBV,OAuBU;EAAR;;;;cAjBpB;;;;;mBAQK;;;;;;kCASe,QAAQ"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./chunk-DjWAcSYV.cjs`);let t=require(`valibot`);t=e.t(t);const n=t.pipe(t.string(),t.maxLength(1024)),r=t.object({text:n}),i=t.optional(t.pipe(t.string(),t.length(7),t.hexColor())),a=t.object({text:i,progress:i,background:i}),o=t.pipe(t.number(),t.minValue(0),t.maxValue(100)),s=t.object({progress:o}),c=t.object({sound_id:t.picklist([`sound1`,`sound2`,`sound3`]),volume:t.pipe(t.number(),t.minValue(0),t.maxValue(100))}),l=t.object({rotation:t.number(),button_pushed:t.boolean()}),u=t.object({type:t.picklist([`rotation`,`button`]),state:l}),d=t.union([u,t.null()]),f=t.object({timeout_ms:t.pipe(t.number(),t.minValue(0),t.maxValue(3e4))});var p=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/hmi/reset`,{method:`POST`,parseResponse:()=>{}})}screen(){return new m(this.fetch)}audio(){return new h(this.fetch)}knob(){return new g(this.fetch)}},m=class{constructor(e){this.fetch=e}async print(e){return(await this.fetch(`/hmi/screen/text`,{method:`POST`,body:t.parse(r,{text:e}),schema:r})).text}colors(e){return this.fetch(`/hmi/screen/colors`,{method:`PATCH`,body:t.parse(a,e),schema:a})}async progress(e){return e==0?await this.fetch(`/hmi/screen/progress`,{method:`DELETE`,parseResponse:()=>({progress:0})}):this.fetch(`/hmi/screen/progress`,{method:`PUT`,body:t.parse(s,{progress:e}),schema:s})}clear(){return this.fetch(`/hmi/screen/clear`,{method:`POST`,parseResponse:()=>{}})}},h=class{constructor(e){this.fetch=e}async play(e){return this.fetch(`/hmi/speaker/play`,{method:`POST`,body:t.parse(c,e),schema:c})}},g=class{constructor(e){this.fetch=e}async rotation(){return(await this.fetch(`/hmi/knob`,{method:`GET`,schema:l})).rotation}async button_pushed(){return(await this.fetch(`/hmi/knob`,{method:`GET`,schema:l})).button_pushed}async wait_event(e){return this.fetch(`/hmi/knob/wait_event`,{method:`POST`,body:t.parse(f,{timeout_ms:e}),schema:d,parseResponse:e=>e.status===204?null:t.parse(u,e.json())})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return h}});
2
+ //# sourceMappingURL=hmi-DSFhbR-Y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-DSFhbR-Y.cjs","names":["v","fetch: UpFetch"],"sources":["../src/api/hmi.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst screenText = v.pipe(v.string(), v.maxLength(1024));\nexport type ScreenText = v.InferOutput<typeof screenText>;\n\nconst text = v.object({ text: screenText });\ntype Text = v.InferOutput<typeof text>;\n\nconst optionalHexColor = v.optional(v.pipe(v.string(), v.length(7), v.hexColor()));\nconst color = v.object({\n text: optionalHexColor,\n progress: optionalHexColor,\n background: optionalHexColor,\n});\nexport type Color = v.InferOutput<typeof color>;\n\nconst progressValue = v.pipe(v.number(), v.minValue(0), v.maxValue(100));\nexport type ProgressValue = v.InferOutput<typeof progressValue>;\nconst progress = v.object({ progress: progressValue });\nexport type Progress = v.InferOutput<typeof progress>;\n\nconst playbackConfiguration = v.object({\n sound_id: v.picklist(['sound1', 'sound2', 'sound3']),\n volume: v.pipe(v.number(), v.minValue(0), v.maxValue(100)),\n});\nexport type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;\n\nconst knobState = v.object({ rotation: v.number(), button_pushed: v.boolean() });\nconst knobEvent = v.object({ type: v.picklist(['rotation', 'button']), state: knobState });\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\nconst optionalKnobEvent = v.union([knobEvent, v.null()]);\nconst knobWaitEvent = v.object({\n timeout_ms: v.pipe(v.number(), v.minValue(0), v.maxValue(30000)),\n});\n\nexport class HmiApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets the HMI.\n */\n reset(): Promise<void> {\n return this.fetch('/hmi/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access the screen API.\n * @returns The screen instance.\n */\n screen(): Screen {\n return new Screen(this.fetch);\n }\n\n /**\n * Access the audio API.\n * @returns The audio instance.\n */\n audio(): Audio {\n return new Audio(this.fetch);\n }\n\n /**\n * Access the knob API.\n * @returns The knob instance.\n */\n knob(): Knob {\n return new Knob(this.fetch);\n }\n}\n\nexport class Screen {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Prints text to the screen.\n * @param data The text to print.\n * @returns The printed text.\n */\n async print(data: ScreenText): Promise<string> {\n return (await this.fetch('/hmi/screen/text', {\n method: 'POST',\n body: v.parse(text, { text: data } satisfies Text),\n schema: text,\n }))\n .text;\n }\n\n /**\n * Sets the screen colors.\n * @param colors The colors to set.\n * @returns The updated colors.\n */\n colors(colors: Color): Promise<Color> {\n return this.fetch('/hmi/screen/colors', {\n method: 'PATCH',\n body: v.parse(color, colors satisfies Color),\n schema: color,\n });\n }\n\n /**\n * Sets the screen progress.\n * @param data The progress value to set.\n * @returns The updated progress.\n */\n async progress(data: ProgressValue): Promise<Progress> {\n if (data == 0) {\n return await this.fetch('/hmi/screen/progress', {\n method: 'DELETE',\n parseResponse: () => ({ progress: 0 }),\n });\n }\n\n return this.fetch('/hmi/screen/progress', {\n method: 'PUT',\n body: v.parse(progress, { progress: data } satisfies Progress),\n schema: progress,\n });\n }\n\n /**\n * Clears the screen.\n */\n clear(): Promise<void> {\n return this.fetch('/hmi/screen/clear', { method: 'POST', parseResponse: () => {} });\n }\n}\n\nexport class Audio {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Plays a sound.\n * @param config The configuration (sound_id, volume).\n * @returns The play configuration.\n */\n async play(config: PlaybackConfiguration): Promise<PlaybackConfiguration> {\n return this.fetch('/hmi/speaker/play', {\n method: 'POST',\n body: v.parse(playbackConfiguration, config satisfies PlaybackConfiguration),\n schema: playbackConfiguration,\n });\n }\n}\n\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets the current rotation of the knob in increments.\n * @returns The current number of increments.\n */\n async rotation(): Promise<number> {\n return (await this.fetch('/hmi/knob', { method: 'GET', schema: knobState })).rotation;\n }\n\n /**\n * Returns whether the button is currently pushed.\n * @returns True if the button is pushed, false otherwise.\n */\n async button_pushed(): Promise<boolean> {\n return (await this.fetch('/hmi/knob', { method: 'GET', schema: knobState })).button_pushed;\n }\n\n /**\n * Waits for a knob event and returns it.\n * @param timeout_ms The timeout in milliseconds.\n * @returns The knob event or null if the timeout was reached.\n */\n async wait_event(timeout_ms: number): Promise<KnobEvent | null> {\n return this.fetch('/hmi/knob/wait_event', {\n method: 'POST',\n body: v.parse(knobWaitEvent, { timeout_ms }),\n schema: optionalKnobEvent,\n parseResponse: (response) => {\n if (response.status === 204) {\n return null;\n }\n\n return v.parse(knobEvent, response.json());\n },\n });\n }\n}\n"],"mappings":"0EAGA,MAAM,EAAaA,EAAE,K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/E,MAAM,WAAW,EAA+C,CAC9D,OAAO,KAAK,MAAM,uBAAwB,CACxC,OAAQ,OACR,KAAMA,EAAE,MAAM,EAAe,CAAE,aAAY,CAAC,CAC5C,OAAQ,EACR,cAAgB,GACV,EAAS,SAAW,IACf,KAGFA,EAAE,MAAM,EAAW,EAAS,MAAM,CAAC,CAE7C,CAAC"}
package/dist/hmi.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require(`./hmi-DSFhbR-Y.cjs`);exports.Audio=e.t,exports.HmiApi=e.n,exports.Knob=e.r,exports.Screen=e.i;
package/dist/hmi.d.cts ADDED
@@ -0,0 +1,2 @@
1
+ import { a as KnobEvent, c as ProgressValue, i as Knob, l as Screen, n as Color, o as PlaybackConfiguration, r as HmiApi, s as Progress, t as Audio, u as ScreenText } from "./hmi-Cx7xLvkd.cjs";
2
+ export { Audio, Color, HmiApi, Knob, KnobEvent, PlaybackConfiguration, Progress, ProgressValue, Screen, ScreenText };
package/dist/hmi.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { a as KnobEvent, c as ProgressValue, i as Knob, l as Screen, n as Color, o as PlaybackConfiguration, r as HmiApi, s as Progress, t as Audio, u as ScreenText } from "./hmi-BMM-GMeM.mjs";
2
+ export { Audio, Color, HmiApi, Knob, KnobEvent, PlaybackConfiguration, Progress, ProgressValue, Screen, ScreenText };
package/dist/hmi.mjs ADDED
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,t as r}from"./hmi-B04X0czX.mjs";export{r as Audio,t as HmiApi,n as Knob,e as Screen};
@@ -0,0 +1,49 @@
1
+ import { a as ComApi } from "./com-DCoBgRma.mjs";
2
+ import { n as Device, r as ManagementApi } from "./management-DYOPvugC.mjs";
3
+ import { s as GpioApi } from "./gpio-D4KyCVtn.mjs";
4
+ import { r as HmiApi } from "./hmi-BMM-GMeM.mjs";
5
+ import { i as PowerApi } from "./power--6z_aXLw.mjs";
6
+ import { n as RelaysApi } from "./relays-CGntlBiE.mjs";
7
+
8
+ //#region src/index.d.ts
9
+ declare class AT1000 {
10
+ /**
11
+ * IP address or hostname of the AT1000 device
12
+ */
13
+ readonly host: string;
14
+ /**
15
+ * Device information
16
+ */
17
+ readonly device: Device;
18
+ private fetch;
19
+ /**
20
+ * COM API
21
+ */
22
+ readonly com: ComApi;
23
+ /**
24
+ * HMI API
25
+ */
26
+ readonly hmi: HmiApi;
27
+ /**
28
+ * GPIO API
29
+ */
30
+ readonly gpio: GpioApi;
31
+ /**
32
+ * Management API
33
+ */
34
+ readonly management: ManagementApi;
35
+ /**
36
+ * Power management API
37
+ */
38
+ readonly power: PowerApi;
39
+ /**
40
+ * Relays API
41
+ */
42
+ readonly relays: RelaysApi;
43
+ constructor(host: string, device: Device);
44
+ reset(): Promise<void>;
45
+ static create: (host: string) => Promise<AT1000>;
46
+ }
47
+ //#endregion
48
+ export { AT1000 as t };
49
+ //# sourceMappingURL=index--f0Eile9.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index--f0Eile9.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAWa,MAAA;;AAAb;;EAcuB,SAAA,IAAA,EAAA,MAAA;EAIA;;;EAYE,SAAA,MAAA,EAtBC,MAsBD;EAIC,QAAA,KAAA;EAEU;;;EAwDW,SAAA,GAAA,EA9ExB,MA8EwB;EAAO;;;gBA1E/B;;;;iBAIC;;;;uBAIM;;;;kBAIL;;;;mBAIC;oCAEU;WAgDvB;mCAQkC,QAAQ"}
@@ -0,0 +1,49 @@
1
+ import { a as ComApi } from "./com-J1K8y_90.cjs";
2
+ import { n as Device, r as ManagementApi } from "./management-CecISx9d.cjs";
3
+ import { s as GpioApi } from "./gpio-BQXV_UtO.cjs";
4
+ import { r as HmiApi } from "./hmi-Cx7xLvkd.cjs";
5
+ import { i as PowerApi } from "./power-AuGIL43h.cjs";
6
+ import { n as RelaysApi } from "./relays-Dn_EI0HH.cjs";
7
+
8
+ //#region src/index.d.ts
9
+ declare class AT1000 {
10
+ /**
11
+ * IP address or hostname of the AT1000 device
12
+ */
13
+ readonly host: string;
14
+ /**
15
+ * Device information
16
+ */
17
+ readonly device: Device;
18
+ private fetch;
19
+ /**
20
+ * COM API
21
+ */
22
+ readonly com: ComApi;
23
+ /**
24
+ * HMI API
25
+ */
26
+ readonly hmi: HmiApi;
27
+ /**
28
+ * GPIO API
29
+ */
30
+ readonly gpio: GpioApi;
31
+ /**
32
+ * Management API
33
+ */
34
+ readonly management: ManagementApi;
35
+ /**
36
+ * Power management API
37
+ */
38
+ readonly power: PowerApi;
39
+ /**
40
+ * Relays API
41
+ */
42
+ readonly relays: RelaysApi;
43
+ constructor(host: string, device: Device);
44
+ reset(): Promise<void>;
45
+ static create: (host: string) => Promise<AT1000>;
46
+ }
47
+ //#endregion
48
+ export { AT1000 as t };
49
+ //# sourceMappingURL=index-CSex8Zr4.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CSex8Zr4.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAWa,MAAA;;AAAb;;EAcuB,SAAA,IAAA,EAAA,MAAA;EAIA;;;EAYE,SAAA,MAAA,EAtBC,MAsBD;EAIC,QAAA,KAAA;EAEU;;;EAwDW,SAAA,GAAA,EA9ExB,MA8EwB;EAAO;;;gBA1E/B;;;;iBAIC;;;;uBAIM;;;;kBAIL;;;;mBAIC;oCAEU;WAgDvB;mCAQkC,QAAQ"}
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ require(`./com-BHaGVMz5.cjs`),require(`./common-ix04NEFn.cjs`),require(`./gpio-DSTG-dmv.cjs`),require(`./hmi-DSFhbR-Y.cjs`),require(`./management-B758IJfF.cjs`),require(`./power-DtLWOEQI.cjs`),require(`./relays-8a3YZaV7.cjs`);const e=require(`./src-CJhZ2EuZ.cjs`);exports.AT1000=e.t;
@@ -0,0 +1,9 @@
1
+ import "./com-J1K8y_90.cjs";
2
+ import "./common-CsBdb633.cjs";
3
+ import "./management-CecISx9d.cjs";
4
+ import "./gpio-BQXV_UtO.cjs";
5
+ import "./hmi-Cx7xLvkd.cjs";
6
+ import "./power-AuGIL43h.cjs";
7
+ import "./relays-Dn_EI0HH.cjs";
8
+ import { t as AT1000 } from "./index-CSex8Zr4.cjs";
9
+ export { AT1000 };
@@ -0,0 +1,9 @@
1
+ import "./com-DCoBgRma.mjs";
2
+ import "./common-ClinPNdn.mjs";
3
+ import "./management-DYOPvugC.mjs";
4
+ import "./gpio-D4KyCVtn.mjs";
5
+ import "./hmi-BMM-GMeM.mjs";
6
+ import "./power--6z_aXLw.mjs";
7
+ import "./relays-CGntlBiE.mjs";
8
+ import { t as AT1000 } from "./index--f0Eile9.mjs";
9
+ export { AT1000 };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import"./com-BdsqVRMC.mjs";import"./common-DSzy5K03.mjs";import"./gpio-CxHnpe7Y.mjs";import"./hmi-B04X0czX.mjs";import"./management-BRYyWntE.mjs";import"./power-kf9bMNDS.mjs";import"./relays-Cwtrx0B-.mjs";import{t as e}from"./src-3DKHMeTA.mjs";export{e as AT1000};
@@ -0,0 +1,2 @@
1
+ const e=require(`./chunk-DjWAcSYV.cjs`);let t=require(`up-fetch`);t=e.t(t);let n=require(`valibot`);n=e.t(n);let r=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const i=n.enum(r),a=n.object({min:n.pipe(n.number(),n.minValue(-24),n.maxValue(24)),max:n.pipe(n.number(),n.minValue(-24),n.maxValue(24))}),o=n.object({max:n.number()}),s=n.object({count:n.pipe(n.number(),n.minValue(1)),input_voltage:a,output_voltage:a}),c=n.object({count:n.pipe(n.number(),n.minValue(0)),max_current:n.number(),max_voltage:n.number(),on_resistance:n.pipe(n.number(),n.minValue(0))}),l=n.object({type:n.picklist([`3.0`,`2.0`]),count:n.pipe(n.number(),n.minValue(1))}),u=n.object({type:n.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:n.pipe(n.number(),n.minValue(1))}),d=n.object({type:i,count:n.pipe(n.number(),n.minValue(1))}),f=n.object({count:n.pipe(n.number(),n.minValue(1)),output_voltage:a,current:o}),p=n.object({type:n.picklist([`low_precision`,`high_precision`]),source:n.string(),resolution:n.pipe(n.number(),n.minValue(0))}),m=n.object({width:n.pipe(n.number(),n.minValue(1)),height:n.pipe(n.number(),n.minValue(1))}),h=n.object({type:n.string(),size:m}),g=n.object({count:n.pipe(n.number(),n.minValue(0)),type:n.string()}),_=n.object({count:n.pipe(n.number(),n.minValue(0)),type:n.string()}),v=n.object({display:h,input:g,speaker:_}),y=n.object({name:n.string(),serial_number:n.string(),io:s,relays:c,usb_ports:n.array(l),ethernet:n.array(u),communication:n.array(d),power_supply:f,current_measurement:n.array(p),hmi:v}),b=n.object({model:n.string(),serial_number:n.string(),firmware_version:n.string(),firmware_commit:n.string(),disk_used:n.number(),disk_total:n.number(),docker_used:n.number(),capabilities:y}),x=n.object({name:n.string(),path:n.string(),container_id:n.string(),image:n.string()});n.object({name:n.string(),image:n.string()});var S=class{constructor(e){this.fetch=e}device(){return this.fetch(`/management/device`,{schema:b})}async datetime(){let e=await this.fetch(`/management/time`,{schema:n.object({epoch_seconds:n.number()})});return new Date(e.epoch_seconds*1e3)}setDatetime(e){return this.fetch(`/management/time`,{method:`POST`,body:{epoch_seconds:Math.floor(e.getTime()/1e3)},parseResponse:()=>{}})}getProjects(){return this.fetch(`/management/projects`,{schema:n.array(x)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:x})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:x})}runProject(e){return this.fetch(`/management/projects/${e}/run`,{method:`POST`})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`})}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=management-B758IJfF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-B758IJfF.cjs","names":["v","fetch: UpFetch"],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n name: v.string(),\n serial_number: v.string(),\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst device = v.object({\n model: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Device = v.InferOutput<typeof device>;\n\nconst project = v.object({\n name: v.string(),\n path: v.string(),\n container_id: v.string(),\n image: v.string(),\n});\ntype Project = v.InferOutput<typeof project>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\ntype CreateProject = v.InferOutput<typeof createProject>;\n\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n device() {\n return this.fetch('/management/device', { schema: device });\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/time', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/time', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The ID or name of the project to patch.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: Project) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: data,\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The ID or name of the project to run.\n */\n runProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/run`, { method: 'POST' });\n }\n\n /**\n * Stops a running project.\n * @param projectId The ID or name of the project to stop.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, { method: 'POST' });\n }\n\n /**\n * Deletes a project.\n * @param projectId The ID or name of the project to delete.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE' });\n }\n\n /**\n * Imports a project. The data should be FormData containing the project file.\n * @param\n */\n /*\n async importProject(: data): Promise<void> {\n return this.client.requestVoid(\"POST\", \"/management/projects/import\", data);\n }\n */\n\n /**\n * Exports a project.\n * @param projectId The ID or name of the project to export.\n * @returns An ArrayBuffer containing the project export data.\n */\n /*\n async exportProject(projectId: string): Promise<ArrayBuffer> {\n return this.client.request<ArrayBuffer>(\"GET\", `/management/projects/${projectId}/export`, undefined, { responseType: 'arraybuffer' });\n }\n */\n}\n"],"mappings":"6GAGA,IAAY,EAAA,SAAA,EAAL,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,cAEF,MAAM,EAAyBA,EAAE,KAAK,EAA2B,CAE3D,EAAeA,EAAE,OAAO,CAC5B,IAAKA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,IAAI,CAAEA,EAAE,SAA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AE,OAAQ,SAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ import"up-fetch";import*as e from"valibot";let t=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const n=e.enum(t),r=e.object({min:e.pipe(e.number(),e.minValue(-24),e.maxValue(24)),max:e.pipe(e.number(),e.minValue(-24),e.maxValue(24))}),i=e.object({max:e.number()}),a=e.object({count:e.pipe(e.number(),e.minValue(1)),input_voltage:r,output_voltage:r}),o=e.object({count:e.pipe(e.number(),e.minValue(0)),max_current:e.number(),max_voltage:e.number(),on_resistance:e.pipe(e.number(),e.minValue(0))}),s=e.object({type:e.picklist([`3.0`,`2.0`]),count:e.pipe(e.number(),e.minValue(1))}),c=e.object({type:e.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:e.pipe(e.number(),e.minValue(1))}),l=e.object({type:n,count:e.pipe(e.number(),e.minValue(1))}),u=e.object({count:e.pipe(e.number(),e.minValue(1)),output_voltage:r,current:i}),d=e.object({type:e.picklist([`low_precision`,`high_precision`]),source:e.string(),resolution:e.pipe(e.number(),e.minValue(0))}),f=e.object({width:e.pipe(e.number(),e.minValue(1)),height:e.pipe(e.number(),e.minValue(1))}),p=e.object({type:e.string(),size:f}),m=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),h=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),g=e.object({display:p,input:m,speaker:h}),_=e.object({name:e.string(),serial_number:e.string(),io:a,relays:o,usb_ports:e.array(s),ethernet:e.array(c),communication:e.array(l),power_supply:u,current_measurement:e.array(d),hmi:g}),v=e.object({model:e.string(),serial_number:e.string(),firmware_version:e.string(),firmware_commit:e.string(),disk_used:e.number(),disk_total:e.number(),docker_used:e.number(),capabilities:_}),y=e.object({name:e.string(),path:e.string(),container_id:e.string(),image:e.string()});e.object({name:e.string(),image:e.string()});var b=class{constructor(e){this.fetch=e}device(){return this.fetch(`/management/device`,{schema:v})}async datetime(){let t=await this.fetch(`/management/time`,{schema:e.object({epoch_seconds:e.number()})});return new Date(t.epoch_seconds*1e3)}setDatetime(e){return this.fetch(`/management/time`,{method:`POST`,body:{epoch_seconds:Math.floor(e.getTime()/1e3)},parseResponse:()=>{}})}getProjects(){return this.fetch(`/management/projects`,{schema:e.array(y)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:y})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:y})}runProject(e){return this.fetch(`/management/projects/${e}/run`,{method:`POST`})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`})}};export{b as n,t};
2
+ //# sourceMappingURL=management-BRYyWntE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-BRYyWntE.mjs","names":["fetch: UpFetch"],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n name: v.string(),\n serial_number: v.string(),\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst device = v.object({\n model: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Device = v.InferOutput<typeof device>;\n\nconst project = v.object({\n name: v.string(),\n path: v.string(),\n container_id: v.string(),\n image: v.string(),\n});\ntype Project = v.InferOutput<typeof project>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\ntype CreateProject = v.InferOutput<typeof createProject>;\n\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n device() {\n return this.fetch('/management/device', { schema: device });\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/time', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/time', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The ID or name of the project to patch.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: Project) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: data,\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The ID or name of the project to run.\n */\n runProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/run`, { method: 'POST' });\n }\n\n /**\n * Stops a running project.\n * @param projectId The ID or name of the project to stop.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, { method: 'POST' });\n }\n\n /**\n * Deletes a project.\n * @param projectId The ID or name of the project to delete.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE' });\n }\n\n /**\n * Imports a project. The data should be FormData containing the project file.\n * @param\n */\n /*\n async importProject(: data): Promise<void> {\n return this.client.requestVoid(\"POST\", \"/management/projects/import\", data);\n }\n */\n\n /**\n * Exports a project.\n * @param projectId The ID or name of the project to export.\n * @returns An ArrayBuffer containing the project export data.\n */\n /*\n async exportProject(projectId: string): Promise<ArrayBuffer> {\n return this.client.request<ArrayBuffer>(\"GET\", `/management/projects/${projectId}/export`, undefined, { responseType: 'arraybuffer' });\n }\n */\n}\n"],"mappings":"2CAGA,IAAY,EAAA,SAAA,EAAL,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,cAEF,MAAM,EAAyB,EAAE,KAAK,EAA2B,CAE3D,EAAe,EAAE,OAAO,CAC5B,IAAK,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,IAAI,CAAE,EAAE,SAAS,GAAG,CAAC,CACxD,IAAK,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,IAAI,CAAE,EAAE,SAAS,GAAG,CAAC,CACzD,CAAC,CAEI,EAAe,EAAE,OAAO,CAAE,IAAK,EAAE,QAAQ,CAAE,CAAC,CAE5C,EAAiB,EAAE,OAAO,CAC9B,MAAO,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACxC,cAAe,EACf,eAAgB,EACjB,CAAC,CAEI,EAAqB,EAAE,OAAO,CAClC,MAAO,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACxC,YAAa,EAAE,QAAQ,CACvB,YAAa,EAAE,QAAQ,CACvB,cAAe,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACjD,CAAC,CAEI,EAAgB,EAAE,OAAO,CAC7B,KAAM,EAAE,SAAS,CAAC,MAAO,MAAM,CAAC,CAChC,MAAO,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACzC,CAAC,CAEI,EAAqB,EAAE,OAAO,CAClC,KAAM,EAAE,SAAS,CAAC,aAAc,YAAa,WAAW,CAAC,CACzD,MAAO,EAAE,KAAK,EAAE,QAAQ,CAA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