@ikalogic/at1000 0.1.2 → 0.1.4

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 (125) hide show
  1. package/build/{at1000-BfFhFt1X.d.mts → at1000-BA_2J_cc.d.mts} +8 -7
  2. package/build/at1000-BA_2J_cc.d.mts.map +1 -0
  3. package/build/at1000-CYNSd3Yp.cjs +2 -0
  4. package/build/at1000-CYNSd3Yp.cjs.map +1 -0
  5. package/build/{at1000-CVUsyt17.d.cts → at1000-D-SOCmZr.d.cts} +8 -7
  6. package/build/at1000-D-SOCmZr.d.cts.map +1 -0
  7. package/build/at1000-Dm22ae18.mjs +2 -0
  8. package/build/at1000-Dm22ae18.mjs.map +1 -0
  9. package/build/browser.cjs +2 -1
  10. package/build/browser.cjs.map +1 -0
  11. package/build/browser.d.cts +14 -8
  12. package/build/browser.d.cts.map +1 -0
  13. package/build/browser.d.mts +14 -8
  14. package/build/browser.d.mts.map +1 -0
  15. package/build/browser.mjs +2 -1
  16. package/build/browser.mjs.map +1 -0
  17. package/build/{com-BdsqVRMC.mjs → com-9odKA1Fj.mjs} +1 -1
  18. package/build/com-9odKA1Fj.mjs.map +1 -0
  19. package/build/{com-BHaGVMz5.cjs → com-B1QZqhWz.cjs} +1 -1
  20. package/build/com-B1QZqhWz.cjs.map +1 -0
  21. package/build/{com-DkFgtUtq.d.cts → com-B7DWhc_c.d.cts} +32 -25
  22. package/build/com-B7DWhc_c.d.cts.map +1 -0
  23. package/build/{com-woRkoeGD.d.mts → com-CPlfIOz2.d.mts} +32 -25
  24. package/build/com-CPlfIOz2.d.mts.map +1 -0
  25. package/build/com.cjs +1 -1
  26. package/build/com.d.cts +1 -1
  27. package/build/com.d.mts +1 -1
  28. package/build/com.mjs +1 -1
  29. package/build/{gpio-DSTG-dmv.cjs → gpio-BRimmVQo.cjs} +1 -1
  30. package/build/gpio-BRimmVQo.cjs.map +1 -0
  31. package/build/{gpio-Dw8CAaDH.d.cts → gpio-Dvbd3MFr.d.cts} +14 -11
  32. package/build/{gpio-Dw8CAaDH.d.cts.map → gpio-Dvbd3MFr.d.cts.map} +1 -1
  33. package/build/{gpio-iqFA_xSb.d.mts → gpio-ahjdhywL.d.mts} +14 -11
  34. package/build/{gpio-iqFA_xSb.d.mts.map → gpio-ahjdhywL.d.mts.map} +1 -1
  35. package/build/{gpio-CxHnpe7Y.mjs → gpio-nD6e5nNZ.mjs} +1 -1
  36. package/build/gpio-nD6e5nNZ.mjs.map +1 -0
  37. package/build/gpio.cjs +1 -1
  38. package/build/gpio.d.cts +2 -2
  39. package/build/gpio.d.mts +2 -2
  40. package/build/gpio.mjs +1 -1
  41. package/build/{hmi-BMM-GMeM.d.mts → hmi-Bk74K2JX.d.cts} +40 -18
  42. package/build/hmi-Bk74K2JX.d.cts.map +1 -0
  43. package/build/hmi-DVUFmRMo.cjs +2 -0
  44. package/build/hmi-DVUFmRMo.cjs.map +1 -0
  45. package/build/{hmi-Cx7xLvkd.d.cts → hmi-FPTDoVfs.d.mts} +40 -18
  46. package/build/hmi-FPTDoVfs.d.mts.map +1 -0
  47. package/build/hmi-dJ8Y4DVD.mjs +2 -0
  48. package/build/hmi-dJ8Y4DVD.mjs.map +1 -0
  49. package/build/hmi.cjs +1 -1
  50. package/build/hmi.d.cts +1 -1
  51. package/build/hmi.d.mts +1 -1
  52. package/build/hmi.mjs +1 -1
  53. package/build/{management-BRYyWntE.mjs → management-CGmaS4-D.mjs} +1 -1
  54. package/build/management-CGmaS4-D.mjs.map +1 -0
  55. package/build/{management-DYOPvugC.d.mts → management-COw5z8sl.d.cts} +2 -1
  56. package/build/management-COw5z8sl.d.cts.map +1 -0
  57. package/build/{management-CecISx9d.d.cts → management-CinGOMF_.d.mts} +2 -1
  58. package/build/management-CinGOMF_.d.mts.map +1 -0
  59. package/build/{management-B758IJfF.cjs → management-PEkkZaQ3.cjs} +1 -1
  60. package/build/management-PEkkZaQ3.cjs.map +1 -0
  61. package/build/management.cjs +1 -1
  62. package/build/management.d.cts +1 -1
  63. package/build/management.d.mts +1 -1
  64. package/build/management.mjs +1 -1
  65. package/build/node.cjs +1 -1
  66. package/build/node.cjs.map +1 -1
  67. package/build/node.d.cts +10 -8
  68. package/build/node.d.cts.map +1 -1
  69. package/build/node.d.mts +9 -8
  70. package/build/node.d.mts.map +1 -1
  71. package/build/node.mjs +1 -1
  72. package/build/node.mjs.map +1 -1
  73. package/build/{power-kf9bMNDS.mjs → power-B1rs9Bqf.mjs} +1 -1
  74. package/build/power-B1rs9Bqf.mjs.map +1 -0
  75. package/build/{power-DtLWOEQI.cjs → power-BpI1_Yav.cjs} +1 -1
  76. package/build/power-BpI1_Yav.cjs.map +1 -0
  77. package/build/{power-OjShJGj_.d.mts → power-CopiAJXF.d.mts} +20 -16
  78. package/build/{power-CaK3L5t4.d.cts.map → power-CopiAJXF.d.mts.map} +1 -1
  79. package/build/{power-CaK3L5t4.d.cts → power-HNcZXI0F.d.cts} +20 -16
  80. package/build/{power-OjShJGj_.d.mts.map → power-HNcZXI0F.d.cts.map} +1 -1
  81. package/build/power.cjs +1 -1
  82. package/build/power.d.cts +2 -2
  83. package/build/power.d.mts +2 -2
  84. package/build/power.mjs +1 -1
  85. package/build/{relays-CGntlBiE.d.mts → relays-BR6408vm.d.mts} +3 -1
  86. package/build/relays-BR6408vm.d.mts.map +1 -0
  87. package/build/{relays-Dn_EI0HH.d.cts → relays-CoF1h8ZQ.d.cts} +3 -1
  88. package/build/relays-CoF1h8ZQ.d.cts.map +1 -0
  89. package/build/{relays-8a3YZaV7.cjs → relays-D_kWwwIR.cjs} +1 -1
  90. package/build/relays-D_kWwwIR.cjs.map +1 -0
  91. package/build/{relays-Cwtrx0B-.mjs → relays-I7rKvd13.mjs} +1 -1
  92. package/build/relays-I7rKvd13.mjs.map +1 -0
  93. package/build/relays.cjs +1 -1
  94. package/build/relays.d.cts +1 -1
  95. package/build/relays.d.mts +1 -1
  96. package/build/relays.mjs +1 -1
  97. package/package.json +12 -4
  98. package/build/at1000-BfFhFt1X.d.mts.map +0 -1
  99. package/build/at1000-CVUsyt17.d.cts.map +0 -1
  100. package/build/at1000-CnsQtUcX.mjs +0 -2
  101. package/build/at1000-CnsQtUcX.mjs.map +0 -1
  102. package/build/at1000-DvQtWopt.cjs +0 -2
  103. package/build/at1000-DvQtWopt.cjs.map +0 -1
  104. package/build/com-BHaGVMz5.cjs.map +0 -1
  105. package/build/com-BdsqVRMC.mjs.map +0 -1
  106. package/build/com-DkFgtUtq.d.cts.map +0 -1
  107. package/build/com-woRkoeGD.d.mts.map +0 -1
  108. package/build/gpio-CxHnpe7Y.mjs.map +0 -1
  109. package/build/gpio-DSTG-dmv.cjs.map +0 -1
  110. package/build/hmi-B04X0czX.mjs +0 -2
  111. package/build/hmi-B04X0czX.mjs.map +0 -1
  112. package/build/hmi-BMM-GMeM.d.mts.map +0 -1
  113. package/build/hmi-Cx7xLvkd.d.cts.map +0 -1
  114. package/build/hmi-DSFhbR-Y.cjs +0 -2
  115. package/build/hmi-DSFhbR-Y.cjs.map +0 -1
  116. package/build/management-B758IJfF.cjs.map +0 -1
  117. package/build/management-BRYyWntE.mjs.map +0 -1
  118. package/build/management-CecISx9d.d.cts.map +0 -1
  119. package/build/management-DYOPvugC.d.mts.map +0 -1
  120. package/build/power-DtLWOEQI.cjs.map +0 -1
  121. package/build/power-kf9bMNDS.mjs.map +0 -1
  122. package/build/relays-8a3YZaV7.cjs.map +0 -1
  123. package/build/relays-CGntlBiE.d.mts.map +0 -1
  124. package/build/relays-Cwtrx0B-.mjs.map +0 -1
  125. package/build/relays-Dn_EI0HH.d.cts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpio-nD6e5nNZ.mjs","names":["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\n/** @hideconstructor */\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\n/** @hideconstructor */\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\n/** @hideconstructor */\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> {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AKM,EAAb,KAAsB,CACpB,YAAY,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,KAAM,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/build/gpio.cjs CHANGED
@@ -1 +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;
1
+ require(`./common-ix04NEFn.cjs`);const e=require(`./gpio-BRimmVQo.cjs`);exports.AnalogIO=e.t,exports.DigitalIO=e.n,exports.GpioApi=e.r;
package/build/gpio.d.cts CHANGED
@@ -1,4 +1,4 @@
1
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-Dw8CAaDH.cjs";
2
+ import "./management-COw5z8sl.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-Dvbd3MFr.cjs";
4
4
  export { AnalogIO, AnalogInputConfiguration, AnalogOutputConfiguration, AnalogOutputLevel, DigitalIO, DigitalInputConfiguration, DigitalOutputConfiguration, GpioApi, PartialAnalogOutputConfiguration, PartialDigitalInputConfiguration, PartialDigitalOutputConfiguration, SyncConfiguration };
package/build/gpio.d.mts CHANGED
@@ -1,4 +1,4 @@
1
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-iqFA_xSb.mjs";
2
+ import "./management-CinGOMF_.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-ahjdhywL.mjs";
4
4
  export { AnalogIO, AnalogInputConfiguration, AnalogOutputConfiguration, AnalogOutputLevel, DigitalIO, DigitalInputConfiguration, DigitalOutputConfiguration, GpioApi, PartialAnalogOutputConfiguration, PartialDigitalInputConfiguration, PartialDigitalOutputConfiguration, SyncConfiguration };
package/build/gpio.mjs CHANGED
@@ -1 +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};
1
+ import"./common-DSzy5K03.mjs";import{n as e,r as t,t as n}from"./gpio-nD6e5nNZ.mjs";export{n as AnalogIO,e as DigitalIO,t as GpioApi};
@@ -21,14 +21,41 @@ declare const playbackConfiguration: v.ObjectSchema<{
21
21
  readonly volume: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
22
22
  }, undefined>;
23
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>;
24
+ declare const knobEvent: Omit<v.ObjectSchema<{
25
+ readonly button_pressed: v.BooleanSchema<undefined>;
26
+ readonly button_held: v.BooleanSchema<undefined>;
27
+ readonly rotation_delta: v.NumberSchema<undefined>;
28
+ }, undefined>, "~standard" | "~run" | "~types" | "entries"> & {
29
+ readonly entries: Omit<{
30
+ readonly button_pressed: v.BooleanSchema<undefined>;
31
+ readonly button_held: v.BooleanSchema<undefined>;
32
+ readonly rotation_delta: v.NumberSchema<undefined>;
33
+ }, "button_held">;
34
+ readonly '~standard': v.StandardProps<{
35
+ button_pressed: boolean;
36
+ rotation_delta: number;
37
+ }, {
38
+ button_pressed: boolean;
39
+ rotation_delta: number;
40
+ }>;
41
+ readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
42
+ button_pressed: boolean;
43
+ rotation_delta: number;
44
+ }, v.NumberIssue | v.BooleanIssue | v.ObjectIssue>;
45
+ readonly '~types'?: {
46
+ readonly input: {
47
+ button_pressed: boolean;
48
+ rotation_delta: number;
49
+ };
50
+ readonly output: {
51
+ button_pressed: boolean;
52
+ rotation_delta: number;
53
+ };
54
+ readonly issue: v.NumberIssue | v.BooleanIssue | v.ObjectIssue;
55
+ } | undefined;
56
+ };
31
57
  type KnobEvent = v.InferOutput<typeof knobEvent>;
58
+ /** @hideconstructor */
32
59
  declare class HmiApi {
33
60
  private readonly fetch;
34
61
  constructor(fetch: UpFetch);
@@ -52,6 +79,7 @@ declare class HmiApi {
52
79
  */
53
80
  knob(): Knob;
54
81
  }
82
+ /** @hideconstructor */
55
83
  declare class Screen {
56
84
  private readonly fetch;
57
85
  constructor(fetch: UpFetch);
@@ -78,6 +106,7 @@ declare class Screen {
78
106
  */
79
107
  clear(): Promise<void>;
80
108
  }
109
+ /** @hideconstructor */
81
110
  declare class Audio {
82
111
  private readonly fetch;
83
112
  constructor(fetch: UpFetch);
@@ -88,19 +117,12 @@ declare class Audio {
88
117
  */
89
118
  play(config: PlaybackConfiguration): Promise<PlaybackConfiguration>;
90
119
  }
120
+ /** @hideconstructor */
91
121
  declare class Knob {
92
122
  private readonly fetch;
93
123
  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>;
124
+ private get_knob_event;
125
+ is_button_pressed: () => Promise<boolean>;
104
126
  /**
105
127
  * Waits for a knob event and returns it.
106
128
  * @param timeout_ms The timeout in milliseconds.
@@ -110,4 +132,4 @@ declare class Knob {
110
132
  }
111
133
  //#endregion
112
134
  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
135
+ //# sourceMappingURL=hmi-Bk74K2JX.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-Bk74K2JX.d.cts","names":[],"sources":["../src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OAqCqC,CAAA,IAAA,CAAA;;;cA/BnC,KAAA;;qBACyB;;;;;;eAOjB,wBAAwB,QAAQ;;;cAUxC,IAAA;;qBACyB;;2BAKnB;;;;;;kCAOqB,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({button_pressed:t.boolean(),button_held:t.boolean(),rotation_delta:t.number()});t.omit(l,[`button_held`]);var u=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/hmi/reset`,{method:`POST`,parseResponse:()=>{}})}screen(){return new d(this.fetch)}audio(){return new f(this.fetch)}knob(){return new p(this.fetch)}},d=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:()=>{}})}},f=class{constructor(e){this.fetch=e}async play(e){return this.fetch(`/hmi/speaker/play`,{method:`POST`,body:t.parse(c,e),schema:c})}},p=class{constructor(e){this.fetch=e}get_knob_event=()=>this.fetch(`/hmi/knob/get_knob_event`,{method:`POST`,schema:l});is_button_pressed=async()=>(await this.get_knob_event()).button_held;async wait_event(e){await this.get_knob_event();let t=Math.min(50,e/10),n=Date.now();for(;Date.now()-n<e;){let e=await this.get_knob_event();if(e.button_pressed||e.rotation_delta!==0)return{button_pressed:e.button_pressed,rotation_delta:e.rotation_delta};await new Promise(e=>setTimeout(e,t))}return null}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
2
+ //# sourceMappingURL=hmi-DVUFmRMo.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-DVUFmRMo.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 internalKnobEvent = v.object({\n button_pressed: v.boolean(),\n button_held: v.boolean(),\n rotation_delta: v.number(),\n});\nconst knobEvent = v.omit(internalKnobEvent, ['button_held']);\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\n\n/** @hideconstructor */\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\n/** @hideconstructor */\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\n/** @hideconstructor */\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\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n private get_knob_event = () =>\n this.fetch('/hmi/knob/get_knob_event', { method: 'POST', schema: internalKnobEvent });\n\n is_button_pressed = async () => (await this.get_knob_event()).button_held;\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 await this.get_knob_event(); // Discard any previous events\n\n const interval = Math.min(50, timeout_ms / 10);\n\n const startTime = Date.now();\n while (Date.now() - startTime < timeout_ms) {\n const knobEvent = await this.get_knob_event();\n if (knobEvent.button_pressed || knobEvent.rotation_delta !== 0) {\n return {\n button_pressed: knobEvent.button_pressed,\n rotation_delta: knobEvent.rotation_delta,\n };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\n }\n}\n"],"mappings":"0EAGA,MAAM,EAAaA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,UAAU,KAAK,CAAC,CAGlD,EAAOA,EAAE,OAAO,CAAE,KAAM,EAAY,CAAC,CAGrC,EAAmBA,EAAE,SAASA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,OAAO,EAAE,CAAEA,EAAE,UAAU,CAAC,CAAC,CAC5E,EAAQA,EAAE,OAAO,CACrB,KAAM,EACN,SAAU,EACV,WAAY,EACb,CAAC,CAGI,EAAgBA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAEA,EAAE,SAAS,IAAI,CAAC,CAElE,EAAWA,EAAE,OAAO,CAAE,SAAU,EAAe,CAAC,CAGhD,EAAwBA,EAAE,OAAO,CACrC,SAAUA,EAAE,SAAS,CAAC,SAAU,SAAU,SAAS,CAAC,CACpD,OAAQA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAEA,EAAE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AhB,KAAA,MAAA,EAO7B,MAAM,KAAK,EAA+D,CACxE,OAAO,KAAK,MAAM,oBAAqB,CACrC,OAAQ,OACR,KAAMA,EAAE,MAAM,EAAuB,EAAuC,CAC5E,OAAQ,EACT,CAAC,GAKO,EAAb,KAAkB,CAChB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAE7B,mBACE,KAAK,MAAM,2BAA4B,CAAE,OAAQ,OAAQ,OAAQ,EAAmB,CAAC,CAEvF,kBAAoB,UAAa,MAAM,KAAK,gBAAgB,EAAE,YAO9D,MAAM,WAAW,EAA+C,CAC9D,MAAM,KAAK,gBAAgB,CAE3B,IAAM,EAAW,KAAK,IAAI,GAAI,EAAa,GAAG,CAExC,EAAY,KAAK,KAAK,CAC5B,KAAO,KAAK,KAAK,CAAG,EAAY,GAAY,CAC1C,IAAM,EAAY,MAAM,KAAK,gBAAgB,CAC7C,GAAI,EAAU,gBAAkB,EAAU,iBAAmB,EAC3D,MAAO,CACL,eAAgB,EAAU,eAC1B,eAAgB,EAAU,eAC3B,CAEH,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,EAAS,CAAC,CAG/D,OAAO"}
@@ -21,14 +21,41 @@ declare const playbackConfiguration: v.ObjectSchema<{
21
21
  readonly volume: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>;
22
22
  }, undefined>;
23
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>;
24
+ declare const knobEvent: Omit<v.ObjectSchema<{
25
+ readonly button_pressed: v.BooleanSchema<undefined>;
26
+ readonly button_held: v.BooleanSchema<undefined>;
27
+ readonly rotation_delta: v.NumberSchema<undefined>;
28
+ }, undefined>, "~standard" | "~run" | "~types" | "entries"> & {
29
+ readonly entries: Omit<{
30
+ readonly button_pressed: v.BooleanSchema<undefined>;
31
+ readonly button_held: v.BooleanSchema<undefined>;
32
+ readonly rotation_delta: v.NumberSchema<undefined>;
33
+ }, "button_held">;
34
+ readonly '~standard': v.StandardProps<{
35
+ button_pressed: boolean;
36
+ rotation_delta: number;
37
+ }, {
38
+ button_pressed: boolean;
39
+ rotation_delta: number;
40
+ }>;
41
+ readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
42
+ button_pressed: boolean;
43
+ rotation_delta: number;
44
+ }, v.NumberIssue | v.BooleanIssue | v.ObjectIssue>;
45
+ readonly '~types'?: {
46
+ readonly input: {
47
+ button_pressed: boolean;
48
+ rotation_delta: number;
49
+ };
50
+ readonly output: {
51
+ button_pressed: boolean;
52
+ rotation_delta: number;
53
+ };
54
+ readonly issue: v.NumberIssue | v.BooleanIssue | v.ObjectIssue;
55
+ } | undefined;
56
+ };
31
57
  type KnobEvent = v.InferOutput<typeof knobEvent>;
58
+ /** @hideconstructor */
32
59
  declare class HmiApi {
33
60
  private readonly fetch;
34
61
  constructor(fetch: UpFetch);
@@ -52,6 +79,7 @@ declare class HmiApi {
52
79
  */
53
80
  knob(): Knob;
54
81
  }
82
+ /** @hideconstructor */
55
83
  declare class Screen {
56
84
  private readonly fetch;
57
85
  constructor(fetch: UpFetch);
@@ -78,6 +106,7 @@ declare class Screen {
78
106
  */
79
107
  clear(): Promise<void>;
80
108
  }
109
+ /** @hideconstructor */
81
110
  declare class Audio {
82
111
  private readonly fetch;
83
112
  constructor(fetch: UpFetch);
@@ -88,19 +117,12 @@ declare class Audio {
88
117
  */
89
118
  play(config: PlaybackConfiguration): Promise<PlaybackConfiguration>;
90
119
  }
120
+ /** @hideconstructor */
91
121
  declare class Knob {
92
122
  private readonly fetch;
93
123
  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>;
124
+ private get_knob_event;
125
+ is_button_pressed: () => Promise<boolean>;
104
126
  /**
105
127
  * Waits for a knob event and returns it.
106
128
  * @param timeout_ms The timeout in milliseconds.
@@ -110,4 +132,4 @@ declare class Knob {
110
132
  }
111
133
  //#endregion
112
134
  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
135
+ //# sourceMappingURL=hmi-FPTDoVfs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-FPTDoVfs.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,S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AAmB;;cAGhC,MAAA;EAJE,iBAAA,KAAA;EAAA,WAAA,CAAA,KAAA,EAKuB,OALvB;;;;WAUJ;;;;;YAQC;;;;;WAQD;;;AAzBX;AAGA;EACsC,IAAA,CAAA,CAAA,EA6B5B,IA7B4B;;;AAqB3B,cAcE,MAAA,CAdF;EAQD,iBAAA,KAAA;EAAI,WAAA,CAAA,KAAA,EAOwB,OAPxB;EAMD;;;;;EAsBoB,KAAA,CAAA,IAAA,EAdb,UAca,CAAA,EAdA,OAcA,CAAA,MAAA,CAAA;EAAR;;;;;EA+BP,MAAA,CAAA,MAAA,EA/BD,KA+BC,CAAA,EA/BO,OA+BP,CA/Be,KA+Bf,CAAA;EAML;;;;;EAQuC,QAAA,CAAA,IAAA,EAhC7B,aAgC6B,CAAA,EAhCb,OAgCa,CAhCL,QAgCK,CAAA;EAUvC;;;EAamC,KAAA,CAAA,CAAA,EArCrC,OAqCqC,CAAA,IAAA,CAAA;;;cA/BnC,KAAA;;qBACyB;;;;;;eAOjB,wBAAwB,QAAQ;;;cAUxC,IAAA;;qBACyB;;2BAKnB;;;;;;kCAOqB,QAAQ"}
@@ -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({button_pressed:e.boolean(),button_held:e.boolean(),rotation_delta:e.number()});e.omit(c,[`button_held`]);var l=class{constructor(e){this.fetch=e}reset(){return this.fetch(`/hmi/reset`,{method:`POST`,parseResponse:()=>{}})}screen(){return new u(this.fetch)}audio(){return new d(this.fetch)}knob(){return new f(this.fetch)}},u=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:()=>{}})}},d=class{constructor(e){this.fetch=e}async play(t){return this.fetch(`/hmi/speaker/play`,{method:`POST`,body:e.parse(s,t),schema:s})}},f=class{constructor(e){this.fetch=e}get_knob_event=()=>this.fetch(`/hmi/knob/get_knob_event`,{method:`POST`,schema:c});is_button_pressed=async()=>(await this.get_knob_event()).button_held;async wait_event(e){await this.get_knob_event();let t=Math.min(50,e/10),n=Date.now();for(;Date.now()-n<e;){let e=await this.get_knob_event();if(e.button_pressed||e.rotation_delta!==0)return{button_pressed:e.button_pressed,rotation_delta:e.rotation_delta};await new Promise(e=>setTimeout(e,t))}return null}};export{u as i,l as n,f as r,d as t};
2
+ //# sourceMappingURL=hmi-dJ8Y4DVD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmi-dJ8Y4DVD.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 internalKnobEvent = v.object({\n button_pressed: v.boolean(),\n button_held: v.boolean(),\n rotation_delta: v.number(),\n});\nconst knobEvent = v.omit(internalKnobEvent, ['button_held']);\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\n\n/** @hideconstructor */\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\n/** @hideconstructor */\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\n/** @hideconstructor */\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\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n private get_knob_event = () =>\n this.fetch('/hmi/knob/get_knob_event', { method: 'POST', schema: internalKnobEvent });\n\n is_button_pressed = async () => (await this.get_knob_event()).button_held;\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 await this.get_knob_event(); // Discard any previous events\n\n const interval = Math.min(50, timeout_ms / 10);\n\n const startTime = Date.now();\n while (Date.now() - startTime < timeout_ms) {\n const knobEvent = await this.get_knob_event();\n if (knobEvent.button_pressed || knobEvent.rotation_delta !== 0) {\n return {\n button_pressed: knobEvent.button_pressed,\n rotation_delta: knobEvent.rotation_delta,\n };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\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,CAAC,CAAC,CAC5E,E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.t,exports.HmiApi=e.n,exports.Knob=e.r,exports.Screen=e.i;
package/build/hmi.d.cts CHANGED
@@ -1,2 +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";
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-Bk74K2JX.cjs";
2
2
  export { Audio, Color, HmiApi, Knob, KnobEvent, PlaybackConfiguration, Progress, ProgressValue, Screen, ScreenText };
package/build/hmi.d.mts CHANGED
@@ -1,2 +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";
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-FPTDoVfs.mjs";
2
2
  export { Audio, Color, HmiApi, Knob, KnobEvent, PlaybackConfiguration, Progress, ProgressValue, Screen, ScreenText };
package/build/hmi.mjs CHANGED
@@ -1 +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};
1
+ import{i as e,n as t,r as n,t as r}from"./hmi-dJ8Y4DVD.mjs";export{r as Audio,t as HmiApi,n as Knob,e as Screen};
@@ -1,2 +1,2 @@
1
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
2
+ //# sourceMappingURL=management-CGmaS4-D.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-CGmaS4-D.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\n/** @hideconstructor */\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,E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EAAU,OAAQ,CAAE,OAAQ,OAAQ,CAAC,CAOjF,cAAc,EAAmB,CAC/B,OAAO,KAAK,MAAM,wBAAwB,IAAa,CAAE,OAAQ,SAAU,CAAC"}
@@ -97,6 +97,7 @@ declare const createProject: v.ObjectSchema<{
97
97
  readonly image: v.StringSchema<undefined>;
98
98
  }, undefined>;
99
99
  type CreateProject = v.InferOutput<typeof createProject>;
100
+ /** @hideconstructor */
100
101
  declare class ManagementApi {
101
102
  private readonly fetch;
102
103
  constructor(fetch: UpFetch);
@@ -240,4 +241,4 @@ declare class ManagementApi {
240
241
  }
241
242
  //#endregion
242
243
  export { Device as n, ManagementApi as r, CommunicationInterfaceType as t };
243
- //# sourceMappingURL=management-DYOPvugC.d.mts.map
244
+ //# sourceMappingURL=management-COw5z8sl.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-COw5z8sl.d.cts","names":[],"sources":["../src/api/management.ts"],"sourcesContent":[],"mappings":";;;;aAGY,0BAAA;;EAAA,KAAA,GAAA,OAAA;EAuFN,KAAA,GAAA,OASJ;;;;;cATI,QAAM,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAUA,MAAA,GAAS,CAAA,CAAE,mBAAmB;cAEpC,SAAO,CAAA,CAAA;;;;;;KAMR,OAAA,GAAU,CAAA,CAAE,mBAAmB;cAE9B,eAAa,CAAA,CAAA;;;;KACd,aAAA,GAAgB,CAAA,CAAE,mBAAmB;;cAG7B,aAAA;;qBACyB;;;;;YAM9B;;;IA/BI,gBAAA,EAAA,MAAA;IAAA,eAAA,EAAA,MAAA;IAUA,SAAM,EAAA,MAAwB;IAEpC,UAKJ,EAAA,MAAA;;;;;MALW,EAAA,EAAA;QAAA,KAAA,EAAA,MAAA;QAMD,aAAwB,EAAA;UAEmC,GAAA,EAAA,MAAA;;;QAApD,cAAA,EAAA;UAAA,GAAA,EAAA,MAAA;UACD,GAAA,EAAA,MAAA;QAGL,CAAA;MACyB,CAAA;;QAM9B,KAAA,EAAA,MAAA;QAQoB,WAAA,EAAA,MAAA;QAAR,WAAA,EAAA,MAAA;QAcI,aAAA,EAAA,MAAA;MAAO,CAAA;MAYlB,SAAA,EAAA;QAQe,IAAA,EAAA,KAAA,GAAA,KAAA;QAAa,KAAA,EAAA,MAAA;MAaA,CAAA,EAAA;MAAO,QAAA,EAAA;QAYlB,IAAA,EAAA,YAAA,GAAA,WAAA,GAAA,UAAA;QAQC,KAAA,EAAA,MAAA;MAQE,CAAA,EAAA;MAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA3Eb,QAAQ;;;;;;;;wBAcJ,OAAO;;;;;iBAYlB;;;;;;;;;;4BAQe,gBAAa;;;;;;;;;;;yCAaA,UAAO;;;;;;;;;;iCAYlB;;;;;kCAQC;;;;;oCAQE"}
@@ -97,6 +97,7 @@ declare const createProject: v.ObjectSchema<{
97
97
  readonly image: v.StringSchema<undefined>;
98
98
  }, undefined>;
99
99
  type CreateProject = v.InferOutput<typeof createProject>;
100
+ /** @hideconstructor */
100
101
  declare class ManagementApi {
101
102
  private readonly fetch;
102
103
  constructor(fetch: UpFetch);
@@ -240,4 +241,4 @@ declare class ManagementApi {
240
241
  }
241
242
  //#endregion
242
243
  export { Device as n, ManagementApi as r, CommunicationInterfaceType as t };
243
- //# sourceMappingURL=management-CecISx9d.d.cts.map
244
+ //# sourceMappingURL=management-CinGOMF_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-CinGOMF_.d.mts","names":[],"sources":["../src/api/management.ts"],"sourcesContent":[],"mappings":";;;;aAGY,0BAAA;;EAAA,KAAA,GAAA,OAAA;EAuFN,KAAA,GAAA,OASJ;;;;;cATI,QAAM,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAUA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.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
2
+ //# sourceMappingURL=management-PEkkZaQ3.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-PEkkZaQ3.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\n/** @hideconstructor */\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,SAAS,GAAG,CAAC,CACxD,IAAKA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,IAAI,CAAEA,EAAE,SAAS,GAAG,CAAC,CACzD,CAAC,CAEI,EAAeA,EAAE,OAAO,CAAE,IAAKA,EAAE,QAAQ,CAAE,CAAC,CAE5C,EAAiBA,EAAE,OAAO,CAC9B,MAAOA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAC,CACxC,cAAe,EACf,eAAgB,EACjB,CAAC,CAEI,EAAqBA,EAAE,OAAO,CAClC,MAAOA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAC,CACxC,YAAaA,EAAE,QAAQ,CACvB,YAAaA,EAAE,QAAQ,CACvB,cAAeA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAC,CACjD,CAAC,CAEI,EAAgBA,EAAE,OAAO,CAC7B,KAAMA,EAAE,SAAS,CAAC,MAAO,MAAM,CAAC,CAChC,MAAOA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAC,CACzC,CAAC,CAEI,EAAqBA,EAAE,OAAO,CAClC,KAAMA,EAAE,SAAS,CAAC,aAAc,YAAa,WAAW,CAAC,CACzD,MAAOA,EAAE,KAAKA,EAAE,QAAQ,CAAEA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AM,EACN,OAAQ,EACT,CAAC,CAQJ,cAAc,EAAmB,EAAe,CAC9C,OAAO,KAAK,MAAM,wBAAwB,IAAa,CACrD,OAAQ,QACR,KAAM,EACN,OAAQ,EACT,CAAC,CAOJ,WAAW,EAAmB,CAC5B,OAAO,KAAK,MAAM,wBAAwB,EAAU,MAAO,CAAE,OAAQ,OAAQ,CAAC,CAOhF,YAAY,EAAmB,CAC7B,OAAO,KAAK,MAAM,wBAAwB,EAAU,OAAQ,CAAE,OAAQ,OAAQ,CAAC,CAOjF,cAAc,EAAmB,CAC/B,OAAO,KAAK,MAAM,wBAAwB,IAAa,CAAE,OAAQ,SAAU,CAAC"}
@@ -1 +1 @@
1
- const e=require(`./management-B758IJfF.cjs`);exports.CommunicationInterfaceType=e.t,exports.ManagementApi=e.n;
1
+ const e=require(`./management-PEkkZaQ3.cjs`);exports.CommunicationInterfaceType=e.t,exports.ManagementApi=e.n;
@@ -1,2 +1,2 @@
1
- import { n as Device, r as ManagementApi, t as CommunicationInterfaceType } from "./management-CecISx9d.cjs";
1
+ import { n as Device, r as ManagementApi, t as CommunicationInterfaceType } from "./management-COw5z8sl.cjs";
2
2
  export { CommunicationInterfaceType, Device, ManagementApi };
@@ -1,2 +1,2 @@
1
- import { n as Device, r as ManagementApi, t as CommunicationInterfaceType } from "./management-DYOPvugC.mjs";
1
+ import { n as Device, r as ManagementApi, t as CommunicationInterfaceType } from "./management-CinGOMF_.mjs";
2
2
  export { CommunicationInterfaceType, Device, ManagementApi };
@@ -1 +1 @@
1
- import{n as e,t}from"./management-BRYyWntE.mjs";export{t as CommunicationInterfaceType,e as ManagementApi};
1
+ import{n as e,t}from"./management-CGmaS4-D.mjs";export{t as CommunicationInterfaceType,e as ManagementApi};
package/build/node.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require(`./chunk-DjWAcSYV.cjs`);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 t=require(`./at1000-DvQtWopt.cjs`);let n=require(`dns-packet`);n=e.t(n);let r=require(`node:events`);r=e.t(r);let i=require(`node:util`);i=e.t(i);let a=require(`ip-address`);a=e.t(a);let o=require(`node:os`);o=e.t(o);let s=require(`node:dgram`);s=e.t(s);const c=`224.0.0.251`,l=`FF02::FB`,u=5353,d=`IPv4`,f=4,p=`IPv6`,m=6,h=[d,4,p,6];var g=class e{static getInterfaces(t){return t?e.getInterfacesFromStrings(t):e.getAllInterfaces()}static getAllInterfaces(){let e=[],t=[],n=o.default.networkInterfaces();for(let[r,i]of Object.entries(n))t.includes(r)||(t.push(r),i?.forEach(t=>{t.internal||!h.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family})}));if(!e.length)throw Error(`No usable network interfaces returned by OS.`);return e}static getInterfacesFromStrings(t){let n=Array.isArray(t)?t:[t],r=this.getAllInterfaces().filter(t=>n.reduce((n,r)=>n||!!(e.stringMatchesAddress(r,t.address)||t.name===r),!1));if(!r||!r.length)throw Error(`No usable network interfaces returned by OS.`);return r}static stringMatchesAddress(e,t){let n,r;try{n=new a.default.Address4(e),r=new a.default.Address4(t)}catch{try{n=new a.default.Address6(e),r=new a.default.Address6(t)}catch{return!1}}return n.bigInt()===r.bigInt()}},_=g;const v={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var y=class e{static validateSettings(e){if(!e.multicastAddress)throw Error(`Socket settings require multicastAddress`);if(!e.multicastPort)throw Error(`Socket settings require multicastPort`)}static createMulticastSocket(t){return new Promise((n,r)=>{let i=Object.assign({},v,t);e.validateSettings(i);let o=s.default.createSocket({type:a.default.Address4.isValid(i.multicastAddress)?`udp4`:`udp6`,reuseAddr:i.reuseAddr}),c=!1;o.on(`error`,e=>{c?i.socketError(e):(o.close(),n({success:!1,error:e}))}).on(`listening`,()=>{c=!0,o.setMulticastTTL(i.ttl??255),o.setMulticastLoopback(i.loopback??!0);let t=e.addMulticastMemberships(o,i);if(!t.memberships.length){c=!1,o.close(),n({success:!1,error:Error(`No interface memberships for multicast address `+i.multicastAddress)});return}n(Object.assign({success:!0},t,{socket:o}))}).on(`message`,(e,t)=>{i.onMessage(e,t)}),o.bind({port:i.multicastPort,exclusive:!1})})}static addMulticastMemberships(t,n){let r=[],i=[],o=a.default.Address4.isValid(n.multicastAddress)?[d,4]:[p,6];return n.interfaces.forEach(a=>{if(o.includes(a.family))try{t.addMembership(n.multicastAddress,e.interfaceAddress(a)),r.push(a)}catch{i.push(a)}}),{memberships:r,failedMemberships:i}}static async createSendSocket(t,n,r,i){return new Promise((a,o)=>{let c=s.default.createSocket({type:[d,4].includes(t.family)?`udp4`:`udp6`,reuseAddr:!!n.reuseAddr});c.once(`error`,e=>{c.close(),a({success:!1,error:Error(e.message)})}).on(`error`,i).on(`listening`,()=>{a({success:!0,iface:t,socket:c,send:c.send.bind(c)})}).on(`message`,(e,n)=>{n.interface=t.name,r(e,n)}).bind(n.srcPort||0,e.interfaceAddress(t))})}static interfaceAddress(e){return`${e.address}${[d,4].includes(e.family)?``:`%`+e.name}`}},b=y;const x={reuseAddr:!0,srcPort:0,interfaces:null,ttl:255,loopback:!0,debug:!1};var S=class extends r.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},x,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=_.getInterfaces(this.Config.interfaces||void 0)}catch(e){throw this.emitError(e),e}return this.emitDebug(`Scanner interfaces: ${i.default.inspect(this.interfaces)}`),await this.createReceiveSockets(),await this.createSendSockets(),this.receiveSockets.length&&this.sendSockets.length&&(this.ready=!0),this.ready}async createReceiveSockets(){if(!this.interfaces)return[];let e=this.interfaces.filter(e=>[d,4].includes(e.family)),t=this.interfaces.filter(e=>[p,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` `+d:``}${e.length&&t.length?` and`:``}${t.length?` `+p:``}`),e.length){let t=await b.createMulticastSocket({multicastAddress:c,multicastPort:u,interfaces:e,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});t.success?this.receiveSockets.push(t):t.error&&this.emitError(t.error.message)}if(t.length){let e=await b.createMulticastSocket({multicastAddress:l,multicastPort:u,interfaces:t,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});e.success?this.receiveSockets.push(e):e.error&&this.emitError(e.error.message)}return this.receiveSockets}async createSendSockets(){if(this.interfaces){this.emitDebug(`Create send sockets on ${this.interfaces.length} interfaces/addresses.`);for(let e=0;e<this.interfaces.length;e++){let t=await b.createSendSocket(this.interfaces[e],this.Config,this.onMessage.bind(this),this.socketError.bind(this));t.success?this.sendSockets.push(t):t.error&&this.emitError(t.error.message)}}}onMessage(e,t){let r;try{r=n.default.decode(e)}catch(e){return this.emitWarn(e)}this.emit(`packet`,r,t)}socketError(e){e.code===`EACCES`||e.code===`EADDRINUSE`||e.code===`EADDRNOTAVAIL`?this.emitError(e):this.emitWarn(e)}query(e,t){let n;if(typeof e==`string`)n=[{name:e,type:t||`ANY`}];else if(Array.isArray(e))n=e;else throw Error(`Query questions must be an array of mDNS query questions.`);let r={type:`query`,questions:n};this.emitDebug(`Send mDNS query: ${i.default.inspect(r)}`),this.send(r)}send(e){if(this.destroyed)return;let t=n.default.encode(e);for(let e=0;e<this.sendSockets.length;e++){let n=this.sendSockets[e];n.send&&n.iface&&(n.send(t,0,t.length,u,[d,4].includes(n.iface.family)?c:l+`%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`))}}destroy(){this.ready=!1,this.sendSockets.forEach(e=>e.socket?.close()),this.sendSockets=[],this.receiveSockets.forEach(e=>e.socket?.close()),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}},C=S;const w={debug:!1};var T=class extends r.EventEmitter{Config;scanner;types;namedServices;packetListener;constructor(e,t){super(),this.packetListener=this.onPacket.bind(this),this.scanner=e,this.Config=Object.assign({},w,t),this.types=[],this.namedServices={},this.forwardEvents(this.scanner),this.reset()}reset(){this.removeMDNSListener(this.scanner),this.types=[],this.namedServices={},this.listenMDNSEvents(this.scanner)}forwardEvents(e){e.on(`error`,e=>{this.emitError(e)}).on(`warn`,e=>{this.emitWarn(e)}).on(`debug`,e=>{this.emitDebug(e)})}listenMDNSEvents(e){e.on(`packet`,this.packetListener)}removeMDNSListener(e){e.removeListener(`packet`,this.packetListener)}onPacket(e,t){switch(this.emitDebug(`Received packet type ${e.type} from ${t.address}.`),e.type){case`query`:this.emit(`query`,e,t);break;case`response`:this.emitDebug(`Received response packet from ${t.address} with ${e.answers?e.answers.length:0} answers and ${e.additionals?e.additionals.length:0} additionals.`),e.answers&&this.processAnswers(e.answers,t),e.additionals&&this.processAnswers(e.additionals,t);break}}processAnswers(e,t){this.emitDebug(`Processing answers or additionals...`);let n=this.processSRVAnswers(e);this.processTXTAnswers(e),this.processAAnswers(e),this.processAAAAAnswers(e),this.processPTRAnswers(e,t),n.forEach(e=>{this.emit(`discovered`,{type:`service`,data:this.namedServices[e]})})}processSRVAnswers(e){let t=[];return e.forEach(e=>{if(e.type!==`SRV`)return;this.emitDebug(`Processing SRV answer.`);let n=e.name.toString();t.includes(n)||t.push(n),this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].service=e,this.namedServices[n].host=e.data.target.toString(),this.namedServices[n].port=e.data.port}),t}processTXTAnswers(e){e.forEach(e=>{if(e.type!==`TXT`)return;this.emitDebug(`Processing TXT answer.`);let t=e.data;if(Array.isArray(t)&&t.length>1){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(Buffer.concat(t))}else if(Buffer.isBuffer(t)){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(t)}})}processAAnswers(e){e.forEach(e=>{if(e.type!==`A`)return;this.emitDebug(`Processing A answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:d,address:n}))})}processAAAAAnswers(e){e.forEach(e=>{if(e.type!==`AAAA`)return;this.emitDebug(`Processing AAAA answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:p,address:n}))})}processPTRAnswers(e,t){e.forEach(e=>{if(e.type!==`PTR`)return;this.emitDebug(`Processing PTR answer.`);let n=this.serviceTypeFromPTR(e),r=e.data.toString();n!==r&&(this.namedServices[r]=this.namedServices[r]||{},this.namedServices[r].name=r.replace(`.`+n,``),this.namedServices[r].rinfo=t)})}serviceTypeFromPTR(e){let t=e.data,n=/(?:^|^.+?(?:\.))(_.*)$/gm.exec(t.toString()),r=n?n[1]:t.toString();return this.types.includes(r)||(this.types.push(r),this.emit(`discovered`,{type:`type`,data:r}),this.emitDebug(`Scanning service type ${r}.`),this.scanner.query(r,`ANY`)),r}answerDataToKeyValues(e){let t=[],n={},r=0,i=e[r];for(;i;){let a=e.slice(r+1,r+1+i);t.push(a.toString());let o=/^([^=]+)=([^=]*)$/.exec(a.toString());o&&(n[o[1]]=o[2]),r=r+1+i,i=e[r]}return{strings:t,keyValuePairs:n}}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}},E=T;const D=async(e=500)=>{e<10&&(e=10);let n=new C({debug:!0}),r=new E(n);if(r.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await n.init())throw Error(`Failed to initialize mDNS scanner`);n.query(`_at1000_server._tcp.local`),await new Promise(t=>setTimeout(t,e));let i=[...new Set(Object.values(r.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).map(e=>e.addresses.filter(e=>e.family==`IPv4`).pop()?.address).filter(e=>e!==void 0))].map(e=>t.t.create(e));return n.destroy(),await Promise.all(i)};var O=class extends t.t{static findDevices(e=500){return D(e)}};module.exports=O;
1
+ const e=require(`./chunk-DjWAcSYV.cjs`);require(`./com-B1QZqhWz.cjs`),require(`./common-ix04NEFn.cjs`),require(`./gpio-BRimmVQo.cjs`),require(`./hmi-DVUFmRMo.cjs`),require(`./management-PEkkZaQ3.cjs`),require(`./power-BpI1_Yav.cjs`),require(`./relays-D_kWwwIR.cjs`);const t=require(`./at1000-CYNSd3Yp.cjs`);let n=require(`dns-packet`);n=e.t(n);let r=require(`node:events`);r=e.t(r);let i=require(`node:util`);i=e.t(i);let a=require(`ip-address`);a=e.t(a);let o=require(`node:os`);o=e.t(o);let s=require(`node:dgram`);s=e.t(s);const c=`224.0.0.251`,l=`FF02::FB`,u=5353,d=`IPv4`,f=4,p=`IPv6`,m=6,h=[d,4,p,6];var g=class e{static getInterfaces(t){return t?e.getInterfacesFromStrings(t):e.getAllInterfaces()}static getAllInterfaces(){let e=[],t=[],n=o.default.networkInterfaces();for(let[r,i]of Object.entries(n))t.includes(r)||(t.push(r),i?.forEach(t=>{t.internal||!h.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family})}));if(!e.length)throw Error(`No usable network interfaces returned by OS.`);return e}static getInterfacesFromStrings(t){let n=Array.isArray(t)?t:[t],r=this.getAllInterfaces().filter(t=>n.reduce((n,r)=>n||!!(e.stringMatchesAddress(r,t.address)||t.name===r),!1));if(!r||!r.length)throw Error(`No usable network interfaces returned by OS.`);return r}static stringMatchesAddress(e,t){let n,r;try{n=new a.default.Address4(e),r=new a.default.Address4(t)}catch{try{n=new a.default.Address6(e),r=new a.default.Address6(t)}catch{return!1}}return n.bigInt()===r.bigInt()}},_=g;const v={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var y=class e{static validateSettings(e){if(!e.multicastAddress)throw Error(`Socket settings require multicastAddress`);if(!e.multicastPort)throw Error(`Socket settings require multicastPort`)}static createMulticastSocket(t){return new Promise((n,r)=>{let i=Object.assign({},v,t);e.validateSettings(i);let o=s.default.createSocket({type:a.default.Address4.isValid(i.multicastAddress)?`udp4`:`udp6`,reuseAddr:i.reuseAddr}),c=!1;o.on(`error`,e=>{c?i.socketError(e):(o.close(),n({success:!1,error:e}))}).on(`listening`,()=>{c=!0,o.setMulticastTTL(i.ttl??255),o.setMulticastLoopback(i.loopback??!0);let t=e.addMulticastMemberships(o,i);if(!t.memberships.length){c=!1,o.close(),n({success:!1,error:Error(`No interface memberships for multicast address `+i.multicastAddress)});return}n(Object.assign({success:!0},t,{socket:o}))}).on(`message`,(e,t)=>{i.onMessage(e,t)}),o.bind({port:i.multicastPort,exclusive:!1})})}static addMulticastMemberships(t,n){let r=[],i=[],o=a.default.Address4.isValid(n.multicastAddress)?[d,4]:[p,6];return n.interfaces.forEach(a=>{if(o.includes(a.family))try{t.addMembership(n.multicastAddress,e.interfaceAddress(a)),r.push(a)}catch{i.push(a)}}),{memberships:r,failedMemberships:i}}static async createSendSocket(t,n,r,i){return new Promise((a,o)=>{let c=s.default.createSocket({type:[d,4].includes(t.family)?`udp4`:`udp6`,reuseAddr:!!n.reuseAddr});c.once(`error`,e=>{c.close(),a({success:!1,error:Error(e.message)})}).on(`error`,i).on(`listening`,()=>{a({success:!0,iface:t,socket:c,send:c.send.bind(c)})}).on(`message`,(e,n)=>{n.interface=t.name,r(e,n)}).bind(n.srcPort||0,e.interfaceAddress(t))})}static interfaceAddress(e){return`${e.address}${[d,4].includes(e.family)?``:`%`+e.name}`}},b=y;const x={reuseAddr:!0,srcPort:0,interfaces:null,ttl:255,loopback:!0,debug:!1};var S=class extends r.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},x,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=_.getInterfaces(this.Config.interfaces||void 0)}catch(e){throw this.emitError(e),e}return this.emitDebug(`Scanner interfaces: ${i.default.inspect(this.interfaces)}`),await this.createReceiveSockets(),await this.createSendSockets(),this.receiveSockets.length&&this.sendSockets.length&&(this.ready=!0),this.ready}async createReceiveSockets(){if(!this.interfaces)return[];let e=this.interfaces.filter(e=>[d,4].includes(e.family)),t=this.interfaces.filter(e=>[p,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` `+d:``}${e.length&&t.length?` and`:``}${t.length?` `+p:``}`),e.length){let t=await b.createMulticastSocket({multicastAddress:c,multicastPort:u,interfaces:e,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});t.success?this.receiveSockets.push(t):t.error&&this.emitError(t.error.message)}if(t.length){let e=await b.createMulticastSocket({multicastAddress:l,multicastPort:u,interfaces:t,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});e.success?this.receiveSockets.push(e):e.error&&this.emitError(e.error.message)}return this.receiveSockets}async createSendSockets(){if(this.interfaces){this.emitDebug(`Create send sockets on ${this.interfaces.length} interfaces/addresses.`);for(let e=0;e<this.interfaces.length;e++){let t=await b.createSendSocket(this.interfaces[e],this.Config,this.onMessage.bind(this),this.socketError.bind(this));t.success?this.sendSockets.push(t):t.error&&this.emitError(t.error.message)}}}onMessage(e,t){let r;try{r=n.default.decode(e)}catch(e){return this.emitWarn(e)}this.emit(`packet`,r,t)}socketError(e){e.code===`EACCES`||e.code===`EADDRINUSE`||e.code===`EADDRNOTAVAIL`?this.emitError(e):this.emitWarn(e)}query(e,t){let n;if(typeof e==`string`)n=[{name:e,type:t||`ANY`}];else if(Array.isArray(e))n=e;else throw Error(`Query questions must be an array of mDNS query questions.`);let r={type:`query`,questions:n};this.emitDebug(`Send mDNS query: ${i.default.inspect(r)}`),this.send(r)}send(e){if(this.destroyed)return;let t=n.default.encode(e);for(let e=0;e<this.sendSockets.length;e++){let n=this.sendSockets[e];n.send&&n.iface&&(n.send(t,0,t.length,u,[d,4].includes(n.iface.family)?c:l+`%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`))}}destroy(){this.ready=!1,this.sendSockets.forEach(e=>e.socket?.close()),this.sendSockets=[],this.receiveSockets.forEach(e=>e.socket?.close()),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}},C=S;const w={debug:!1};var T=class extends r.EventEmitter{Config;scanner;types;namedServices;packetListener;constructor(e,t){super(),this.packetListener=this.onPacket.bind(this),this.scanner=e,this.Config=Object.assign({},w,t),this.types=[],this.namedServices={},this.forwardEvents(this.scanner),this.reset()}reset(){this.removeMDNSListener(this.scanner),this.types=[],this.namedServices={},this.listenMDNSEvents(this.scanner)}forwardEvents(e){e.on(`error`,e=>{this.emitError(e)}).on(`warn`,e=>{this.emitWarn(e)}).on(`debug`,e=>{this.emitDebug(e)})}listenMDNSEvents(e){e.on(`packet`,this.packetListener)}removeMDNSListener(e){e.removeListener(`packet`,this.packetListener)}onPacket(e,t){switch(this.emitDebug(`Received packet type ${e.type} from ${t.address}.`),e.type){case`query`:this.emit(`query`,e,t);break;case`response`:this.emitDebug(`Received response packet from ${t.address} with ${e.answers?e.answers.length:0} answers and ${e.additionals?e.additionals.length:0} additionals.`),e.answers&&this.processAnswers(e.answers,t),e.additionals&&this.processAnswers(e.additionals,t);break}}processAnswers(e,t){this.emitDebug(`Processing answers or additionals...`);let n=this.processSRVAnswers(e);this.processTXTAnswers(e),this.processAAnswers(e),this.processAAAAAnswers(e),this.processPTRAnswers(e,t),n.forEach(e=>{this.emit(`discovered`,{type:`service`,data:this.namedServices[e]})})}processSRVAnswers(e){let t=[];return e.forEach(e=>{if(e.type!==`SRV`)return;this.emitDebug(`Processing SRV answer.`);let n=e.name.toString();t.includes(n)||t.push(n),this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].service=e,this.namedServices[n].host=e.data.target.toString(),this.namedServices[n].port=e.data.port}),t}processTXTAnswers(e){e.forEach(e=>{if(e.type!==`TXT`)return;this.emitDebug(`Processing TXT answer.`);let t=e.data;if(Array.isArray(t)&&t.length>1){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(Buffer.concat(t))}else if(Buffer.isBuffer(t)){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(t)}})}processAAnswers(e){e.forEach(e=>{if(e.type!==`A`)return;this.emitDebug(`Processing A answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:d,address:n}))})}processAAAAAnswers(e){e.forEach(e=>{if(e.type!==`AAAA`)return;this.emitDebug(`Processing AAAA answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:p,address:n}))})}processPTRAnswers(e,t){e.forEach(e=>{if(e.type!==`PTR`)return;this.emitDebug(`Processing PTR answer.`);let n=this.serviceTypeFromPTR(e),r=e.data.toString();n!==r&&(this.namedServices[r]=this.namedServices[r]||{},this.namedServices[r].name=r.replace(`.`+n,``),this.namedServices[r].rinfo=t)})}serviceTypeFromPTR(e){let t=e.data,n=/(?:^|^.+?(?:\.))(_.*)$/gm.exec(t.toString()),r=n?n[1]:t.toString();return this.types.includes(r)||(this.types.push(r),this.emit(`discovered`,{type:`type`,data:r}),this.emitDebug(`Scanning service type ${r}.`),this.scanner.query(r,`ANY`)),r}answerDataToKeyValues(e){let t=[],n={},r=0,i=e[r];for(;i;){let a=e.slice(r+1,r+1+i);t.push(a.toString());let o=/^([^=]+)=([^=]*)$/.exec(a.toString());o&&(n[o[1]]=o[2]),r=r+1+i,i=e[r]}return{strings:t,keyValuePairs:n}}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}},E=T;const D=async(e=500)=>{e<10&&(e=10);let n=new C({debug:!0}),r=new E(n);if(r.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await n.init())throw Error(`Failed to initialize mDNS scanner`);n.query(`_at1000_server._tcp.local`),await new Promise(t=>setTimeout(t,e));let i=[...new Set(Object.values(r.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).map(e=>e.addresses.filter(e=>e.family==`IPv4`).pop()?.address).filter(e=>e!==void 0))].map(e=>t.t.create(e));return n.destroy(),await Promise.all(i)};var O=class extends t.t{static findDevices(e=500){return D(e)}};exports.AT1000=O;
2
2
  //# sourceMappingURL=node.cjs.map