@ikalogic/at1000 0.1.29 → 0.1.33

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 (71) hide show
  1. package/build/{at1000-6jr4Cfl3.mjs → at1000-BjZ8P9Pl.mjs} +2 -2
  2. package/build/{at1000-6jr4Cfl3.mjs.map → at1000-BjZ8P9Pl.mjs.map} +1 -1
  3. package/build/{at1000-ARKCVfb6.cjs → at1000-COAmmgdX.cjs} +2 -2
  4. package/build/{at1000-ARKCVfb6.cjs.map → at1000-COAmmgdX.cjs.map} +1 -1
  5. package/build/{at1000-C4BduTvM.d.mts → at1000-Dj6VhvcC.d.mts} +6 -6
  6. package/build/{at1000-C4BduTvM.d.mts.map → at1000-Dj6VhvcC.d.mts.map} +1 -1
  7. package/build/{at1000-LlkehOWj.d.cts → at1000-jcW_736Y.d.cts} +6 -6
  8. package/build/{at1000-LlkehOWj.d.cts.map → at1000-jcW_736Y.d.cts.map} +1 -1
  9. package/build/browser.cjs +1 -1
  10. package/build/browser.cjs.map +1 -1
  11. package/build/browser.d.cts +1 -1
  12. package/build/browser.d.mts +1 -1
  13. package/build/browser.mjs +1 -1
  14. package/build/browser.mjs.map +1 -1
  15. package/build/{com-BKy7zoOg.d.mts → com-BlZKwbhV.d.mts} +107 -29
  16. package/build/com-BlZKwbhV.d.mts.map +1 -0
  17. package/build/{com-lqsVrnqO.d.cts → com-CMV0kKz-.d.cts} +107 -29
  18. package/build/com-CMV0kKz-.d.cts.map +1 -0
  19. package/build/com.cjs +1 -1
  20. package/build/com.cjs.map +1 -1
  21. package/build/com.d.cts +2 -2
  22. package/build/com.d.mts +2 -2
  23. package/build/com.mjs +1 -1
  24. package/build/com.mjs.map +1 -1
  25. package/build/{gpio-B2EhZKM8.d.mts → gpio-1KwDsZyZ.d.mts} +11 -11
  26. package/build/{gpio-B2EhZKM8.d.mts.map → gpio-1KwDsZyZ.d.mts.map} +1 -1
  27. package/build/{gpio-C4wCa4wG.d.cts → gpio-m44_p5b-.d.cts} +11 -11
  28. package/build/{gpio-C4wCa4wG.d.cts.map → gpio-m44_p5b-.d.cts.map} +1 -1
  29. package/build/gpio.cjs +1 -1
  30. package/build/gpio.cjs.map +1 -1
  31. package/build/gpio.d.cts +1 -1
  32. package/build/gpio.d.mts +1 -1
  33. package/build/gpio.mjs +1 -1
  34. package/build/gpio.mjs.map +1 -1
  35. package/build/{hmi-BdkiKYEE.d.mts → hmi-BAaIE12L.d.mts} +2 -2
  36. package/build/{hmi-BdkiKYEE.d.mts.map → hmi-BAaIE12L.d.mts.map} +1 -1
  37. package/build/{hmi-DkO4bd8B.d.cts → hmi-C5ga9KYh.d.cts} +2 -2
  38. package/build/{hmi-DkO4bd8B.d.cts.map → hmi-C5ga9KYh.d.cts.map} +1 -1
  39. package/build/hmi.cjs +1 -1
  40. package/build/hmi.cjs.map +1 -1
  41. package/build/hmi.d.cts +1 -1
  42. package/build/hmi.d.mts +1 -1
  43. package/build/hmi.mjs +1 -1
  44. package/build/hmi.mjs.map +1 -1
  45. package/build/{management-ra61-qUr.d.mts → management-Bm3yYjYD.d.cts} +37 -7
  46. package/build/management-Bm3yYjYD.d.cts.map +1 -0
  47. package/build/{management-wQgti8p7.d.cts → management-C3VCMRi6.d.mts} +37 -7
  48. package/build/management-C3VCMRi6.d.mts.map +1 -0
  49. package/build/management.cjs +1 -1
  50. package/build/management.cjs.map +1 -1
  51. package/build/management.d.cts +2 -2
  52. package/build/management.d.mts +2 -2
  53. package/build/management.mjs +1 -1
  54. package/build/management.mjs.map +1 -1
  55. package/build/node.cjs +1 -1
  56. package/build/node.cjs.map +1 -1
  57. package/build/node.d.cts +1 -1
  58. package/build/node.d.mts +1 -1
  59. package/build/node.mjs +1 -1
  60. package/build/node.mjs.map +1 -1
  61. package/build/{power-Dv21KxFx.d.cts → power-C174FazK.d.cts} +8 -8
  62. package/build/{power-Bi9cbP8g.d.mts.map → power-C174FazK.d.cts.map} +1 -1
  63. package/build/{power-Bi9cbP8g.d.mts → power-CQQWC6Fi.d.mts} +8 -8
  64. package/build/{power-Dv21KxFx.d.cts.map → power-CQQWC6Fi.d.mts.map} +1 -1
  65. package/build/power.d.cts +1 -1
  66. package/build/power.d.mts +1 -1
  67. package/package.json +7 -7
  68. package/build/com-BKy7zoOg.d.mts.map +0 -1
  69. package/build/com-lqsVrnqO.d.cts.map +0 -1
  70. package/build/management-ra61-qUr.d.mts.map +0 -1
  71. package/build/management-wQgti8p7.d.cts.map +0 -1
package/build/hmi.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hmi.cjs","names":["v"],"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(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\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),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\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.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\n }\n}\n"],"mappings":"6IAGA,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,SACV,CAAC,UAAW,UAAW,UAAW,iBAAkB,iBAClD,iBAAiB,CACpB,CACD,OA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AAQ,kBAAqB,GAAI,CAAC,GAK1E,EAAb,KAAmB,CACjB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAO7B,MAAM,KAAK,EAA+D,CACxE,OAAO,KAAK,MAAM,oBAAqB,CACrC,OAAQ,OACR,KAAMA,EAAE,MAAM,EAAuB,EAAO,CAC5C,OAAQ,EACT,CAAC,GAKO,EAAb,KAAkB,CAChB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAE7B,eAAmB,KAAK,MAAM,2BAA4B,CAAE,OAAQ,EAAmB,CAAC,CAExF,eAAiB,UAAa,MAAM,KAAK,YAAY,EAAE,YACvD,eAAiB,SAAY,KAAK,KAAK,MAAM,KAAK,YAAY,EAAE,eAAe,EAAI,EAOnF,MAAM,WAAW,EAAgD,CAC/D,MAAM,KAAK,YAAY,CACvB,IAAI,EAAQ,EAEN,EAAW,KAAK,IAAI,IAAK,GAAc,KAAO,GAAG,CAEjD,EAAY,KAAK,KAAK,CAC5B,KAAO,IAAa,KAAK,KAAK,CAAG,EAAY,GAAmB,CAC9D,IAAM,EAAY,MAAM,KAAK,YAAY,CAGzC,GAFA,GAAS,EAAU,eAEf,EAAU,gBAAkB,KAAK,IAAI,EAAM,EAAI,EACjD,MAAO,CAAE,eAAgB,EAAU,eAAgB,eAAgB,KAAK,KAAK,EAAM,CAAE,CAEvF,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,EAAS,CAAC,CAG/D,OAAO"}
1
+ {"version":3,"file":"hmi.cjs","names":["v"],"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(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\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),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\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.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms !== undefined ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\n }\n}\n"],"mappings":"6IAGA,MAAM,EAA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AM,KAAK,YAAY,CAGzC,GAFA,GAAS,EAAU,eAEf,EAAU,gBAAkB,KAAK,IAAI,EAAM,EAAI,EACjD,MAAO,CAAE,eAAgB,EAAU,eAAgB,eAAgB,KAAK,KAAK,EAAM,CAAE,CAEvF,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,EAAS,CAAC,CAG/D,OAAO"}
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-DkO4bd8B.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-C5ga9KYh.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-BdkiKYEE.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-BAaIE12L.mjs";
2
2
  export { Audio, Color, HmiApi, Knob, KnobEvent, PlaybackConfiguration, Progress, ProgressValue, Screen, ScreenText };
package/build/hmi.mjs CHANGED
@@ -1,2 +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([`success`,`warning`,`failure`,`notification_1`,`notification_2`,`imperial_march`]),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}read_event=()=>this.fetch(`/hmi/knob/get_knob_event`,{schema:c});is_button_held=async()=>(await this.read_event()).button_held;is_knob_turned=async()=>Math.abs((await this.read_event()).rotation_delta)>=4;async wait_event(e){await this.read_event();let t=0,n=Math.min(50,(e??500)/10),r=Date.now();for(;!e||Date.now()-r<e;){let e=await this.read_event();if(t+=e.rotation_delta,e.button_pressed||Math.abs(t)>=4)return{button_pressed:e.button_pressed,rotation_delta:Math.sign(t)};await new Promise(e=>setTimeout(e,n))}return null}};export{d as Audio,l as HmiApi,f as Knob,u as Screen};
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([`success`,`warning`,`failure`,`notification_1`,`notification_2`,`imperial_march`]),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}read_event=()=>this.fetch(`/hmi/knob/get_knob_event`,{schema:c});is_button_held=async()=>(await this.read_event()).button_held;is_knob_turned=async()=>Math.abs((await this.read_event()).rotation_delta)>=4;async wait_event(e){await this.read_event();let t=0,n=Math.min(50,(e??500)/10),r=Date.now();for(;e===void 0||Date.now()-r<e;){let e=await this.read_event();if(t+=e.rotation_delta,e.button_pressed||Math.abs(t)>=4)return{button_pressed:e.button_pressed,rotation_delta:Math.sign(t)};await new Promise(e=>setTimeout(e,n))}return null}};export{d as Audio,l as HmiApi,f as Knob,u as Screen};
2
2
  //# sourceMappingURL=hmi.mjs.map
package/build/hmi.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hmi.mjs","names":[],"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(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\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),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\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.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\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,EAAQ,EAAE,OAAO,CACrB,KAAM,EACN,SAAU,EACV,WAAY,EACb,CAAC,CAGI,EAAgB,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAE,EAAE,SAAS,IAAI,CAAC,CAElE,EAAW,EAAE,OAAO,CAAE,SAAU,EAAe,CAAC,CAGhD,EAAwB,EAAE,OAAO,CACrC,SAAU,EAAE,SACV,CAAC,UAAW,UAAW,UAAW,iBAAkB,iBAClD,iBAAiB,CACpB,CACD,OAAQ,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAE,EAAE,SAAS,IAAI,CAAC,CAC3D,CAAC,CAGI,EAAoB,EAAE,OAAO,CACjC,eAAgB,EAAE,SAAS,CAC3B,YAAa,EAAE,SAAS,CACxB,eAAgB,EAAE,QAAQ,CAC3B,CAAC,CACgB,EAAE,KAAK,EAAmB,CAAC,cAAc,CAAC,CAI5D,IAAa,EAAb,KAAoB,CAClB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAK7B,OAAuB,CACrB,OAAO,KAAK,MAAM,aAAc,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,CAO9E,QAAiB,CACf,OAAO,IAAI,EAAO,KAAK,MAAM,CAO/B,OAAe,CAC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AM,KAAK,YAAY,CACvB,IAAI,EAAQ,EAEN,EAAW,KAAK,IAAI,IAAK,GAAc,KAAO,GAAG,CAEjD,EAAY,KAAK,KAAK,CAC5B,KAAO,IAAa,KAAK,KAAK,CAAG,EAAY,GAAmB,CAC9D,IAAM,EAAY,MAAM,KAAK,YAAY,CAGzC,GAFA,GAAS,EAAU,eAEf,EAAU,gBAAkB,KAAK,IAAI,EAAM,EAAI,EACjD,MAAO,CAAE,eAAgB,EAAU,eAAgB,eAAgB,KAAK,KAAK,EAAM,CAAE,CAEvF,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,EAAS,CAAC,CAG/D,OAAO"}
1
+ {"version":3,"file":"hmi.mjs","names":[],"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(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\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),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\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.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms !== undefined ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\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,EAAQ,EAAE,OAAO,CACrB,KAAM,EACN,SAAU,EACV,WAAY,EACb,CAAC,CAGI,EAAgB,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAE,EAAE,SAAS,IAAI,CAAC,CAElE,EAAW,EAAE,OAAO,CAAE,SAAU,EAAe,CAAC,CAGhD,EAAwB,EAAE,OAAO,CACrC,SAAU,EAAE,SACV,CAAC,UAAW,UA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AAK,MAAM,oBAAqB,CAAE,OAAQ,OAAQ,kBAAqB,GAAI,CAAC,GAK1E,EAAb,KAAmB,CACjB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAO7B,MAAM,KAAK,EAA+D,CACxE,OAAO,KAAK,MAAM,oBAAqB,CACrC,OAAQ,OACR,KAAM,EAAE,MAAM,EAAuB,EAAO,CAC5C,OAAQ,EACT,CAAC,GAKO,EAAb,KAAkB,CAChB,YAAY,EAAiC,CAAhB,KAAA,MAAA,EAE7B,eAAmB,KAAK,MAAM,2BAA4B,CAAE,OAAQ,EAAmB,CAAC,CAExF,eAAiB,UAAa,MAAM,KAAK,YAAY,EAAE,YACvD,eAAiB,SAAY,KAAK,KAAK,MAAM,KAAK,YAAY,EAAE,eAAe,EAAI,EAOnF,MAAM,WAAW,EAAgD,CAC/D,MAAM,KAAK,YAAY,CACvB,IAAI,EAAQ,EAEN,EAAW,KAAK,IAAI,IAAK,GAAc,KAAO,GAAG,CAEjD,EAAY,KAAK,KAAK,CAC5B,KAAO,IAAe,IAAA,IAAY,KAAK,KAAK,CAAG,EAAY,GAAmB,CAC5E,IAAM,EAAY,MAAM,KAAK,YAAY,CAGzC,GAFA,GAAS,EAAU,eAEf,EAAU,gBAAkB,KAAK,IAAI,EAAM,EAAI,EACjD,MAAO,CAAE,eAAgB,EAAU,eAAgB,eAAgB,KAAK,KAAK,EAAM,CAAE,CAEvF,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,EAAS,CAAC,CAG/D,OAAO"}
@@ -12,6 +12,7 @@ declare enum CommunicationInterfaceType {
12
12
  }
13
13
  declare const info: v.ObjectSchema<{
14
14
  readonly model: v.StringSchema<undefined>;
15
+ readonly hostname: v.StringSchema<undefined>;
15
16
  readonly serial_number: v.StringSchema<undefined>;
16
17
  readonly firmware_version: v.StringSchema<undefined>;
17
18
  readonly firmware_commit: v.StringSchema<undefined>;
@@ -95,11 +96,18 @@ declare const createProject: v.ObjectSchema<{
95
96
  readonly image: v.StringSchema<undefined>;
96
97
  }, undefined>;
97
98
  type CreateProject = v.InferOutput<typeof createProject>;
98
- declare const updateResponse: v.ObjectSchema<{
99
+ declare const bundleInfo: v.ObjectSchema<{
100
+ readonly bundle: v.StringSchema<undefined>;
101
+ readonly version: v.StringSchema<undefined>;
102
+ readonly compatible: v.StringSchema<undefined>;
103
+ readonly description: v.StringSchema<undefined>;
104
+ }, undefined>;
105
+ type BundleInfo = v.InferOutput<typeof bundleInfo>;
106
+ declare const installResponse: v.ObjectSchema<{
99
107
  readonly message: v.StringSchema<undefined>;
100
108
  readonly bundle: v.StringSchema<undefined>;
101
109
  }, undefined>;
102
- type UpdateResponse = v.InferOutput<typeof updateResponse>;
110
+ type InstallResponse = v.InferOutput<typeof installResponse>;
103
111
  declare const updateStatus: v.ObjectSchema<{
104
112
  readonly state: v.PicklistSchema<["idle", "installing", "failed"], undefined>;
105
113
  readonly progress: v.NumberSchema<undefined>;
@@ -121,6 +129,7 @@ declare class ManagementApi {
121
129
  */
122
130
  info(): Promise<{
123
131
  model: string;
132
+ hostname: string;
124
133
  serial_number: string;
125
134
  firmware_version: string;
126
135
  firmware_commit: string;
@@ -251,12 +260,33 @@ declare class ManagementApi {
251
260
  */
252
261
  deleteProject(projectId: string): Promise<any>;
253
262
  /**
254
- * Uploads a firmware bundle to the device and starts installation.
263
+ * Uploads a firmware bundle to the device and inspects it.
264
+ * The bundle is staged for installation but not installed yet.
255
265
  * @param file The firmware bundle file (.raucb).
256
266
  * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.
257
- * @returns The upload response with message and bundle name.
267
+ * @returns Bundle metadata including version information.
268
+ */
269
+ upload_bundle(file: Blob, filename?: string): Promise<{
270
+ bundle: string;
271
+ version: string;
272
+ compatible: string;
273
+ description: string;
274
+ }>;
275
+ /**
276
+ * Gets metadata for the currently staged firmware bundle.
277
+ * @returns Bundle metadata including version information.
278
+ */
279
+ bundle_info(): Promise<{
280
+ bundle: string;
281
+ version: string;
282
+ compatible: string;
283
+ description: string;
284
+ }>;
285
+ /**
286
+ * Installs a previously uploaded firmware bundle.
287
+ * @returns The install response with message and bundle name.
258
288
  */
259
- upload_update(file: Blob, filename?: string): Promise<{
289
+ install_update(): Promise<{
260
290
  message: string;
261
291
  bundle: string;
262
292
  }>;
@@ -279,5 +309,5 @@ declare class ManagementApi {
279
309
  }>;
280
310
  }
281
311
  //#endregion
282
- export { UpdateResponse as a, RebootResponse as i, Information as n, UpdateStatus as o, ManagementApi as r, CommunicationInterfaceType as t };
283
- //# sourceMappingURL=management-ra61-qUr.d.mts.map
312
+ export { ManagementApi as a, InstallResponse as i, CommunicationInterfaceType as n, RebootResponse as o, Information as r, UpdateStatus as s, BundleInfo as t };
313
+ //# sourceMappingURL=management-Bm3yYjYD.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-Bm3yYjYD.d.cts","names":[],"sources":["../src/api/management.ts"],"mappings":";;;;aAGY,0BAAA;EACV,GAAA;EACA,KAAA;EACA,KAAA;EACA,GAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,cA+EI,IAAA,EAAI,CAAA,CAAA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAWE,WAAA,GAAc,CAAA,CAAE,WAAA,QAAmB,IAAA;AAAA,cAEzC,OAAA,EAAO,CAAA,CAAA,YAAA;EAAA;;;;;KAMR,OAAA,GAAU,CAAA,CAAE,WAAA,QAAmB,OAAA;AAAA,cAE9B,aAAA,EAAa,CAAA,CAAA,YAAA;EAAA;;;KACd,aAAA,GAAgB,CAAA,CAAE,WAAA,QAAmB,aAAA;AAAA,cAEpC,UAAA,EAAU,CAAA,CAAA,YAAA;EAAA;;;;;KAMJ,UAAA,GAAa,CAAA,CAAE,WAAA,QAAmB,UAAA;AAAA,cAExC,eAAA,EAAe,CAAA,CAAA,YAAA;EAAA;;;KACT,eAAA,GAAkB,CAAA,CAAE,WAAA,QAAmB,eAAA;AAAA,cAE7C,YAAA,EAAY,CAAA,CAAA,YAAA;EAAA;;;;;KAMN,YAAA,GAAe,CAAA,CAAE,WAAA,QAAmB,YAAA;AAAA,cAE1C,cAAA,EAAc,CAAA,CAAA,YAAA;EAAA,kBAAoC,CAAA,CAAA,YAAA;AAAA;AAAA,KAC5C,cAAA,GAAiB,CAAA,CAAE,WAAA,QAAmB,cAAA;;cAGrC,aAAA;EAAA,iBACkB,KAAA;cAAA,KAAA,EAAO,OAAA;EAhD5B;;;;EAsDR,IAAA,CAAA,GAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQE,QAAA,CAAA,GAAY,OAAA,CAAQ,IAAA;;;;;;;;EAc1B,WAAA,CAAY,QAAA,EAAU,IAAA,GAAO,OAAA;;;;;EAY7B,WAAA,CAAA,GAAW,OAAA;;;;;;;;;;EAQX,aAAA,CAAc,UAAA,EAAY,aAAA,GAAa,OAAA;;;;;;;;;;;EAavC,aAAA,CAAc,SAAA,UAAmB,IAAA,EAAM,OAAA,GAAO,OAAA;;;;;;;;;;EAY9C,UAAA,CAAW,SAAA,WAAiB,OAAA;;;;;EAQ5B,WAAA,CAAY,SAAA,WAAiB,OAAA;;;;;EAQ7B,aAAA,CAAc,SAAA,WAAiB,OAAA;;;;;;;;EAW/B,aAAA,CAAc,IAAA,EAAM,IAAA,EAAM,QAAA,YAAyB,OAAA;;;;;;;;;;EAenD,WAAA,CAAA,GAAW,OAAA;;;;;;;;;;EAQX,cAAA,CAAA,GAAc,OAAA;;;;;;;;EAQd,aAAA,CAAA,GAAa,OAAA;;;;;;;;;;EAQb,MAAA,CAAA,GAAM,OAAA"}
@@ -12,6 +12,7 @@ declare enum CommunicationInterfaceType {
12
12
  }
13
13
  declare const info: v.ObjectSchema<{
14
14
  readonly model: v.StringSchema<undefined>;
15
+ readonly hostname: v.StringSchema<undefined>;
15
16
  readonly serial_number: v.StringSchema<undefined>;
16
17
  readonly firmware_version: v.StringSchema<undefined>;
17
18
  readonly firmware_commit: v.StringSchema<undefined>;
@@ -95,11 +96,18 @@ declare const createProject: v.ObjectSchema<{
95
96
  readonly image: v.StringSchema<undefined>;
96
97
  }, undefined>;
97
98
  type CreateProject = v.InferOutput<typeof createProject>;
98
- declare const updateResponse: v.ObjectSchema<{
99
+ declare const bundleInfo: v.ObjectSchema<{
100
+ readonly bundle: v.StringSchema<undefined>;
101
+ readonly version: v.StringSchema<undefined>;
102
+ readonly compatible: v.StringSchema<undefined>;
103
+ readonly description: v.StringSchema<undefined>;
104
+ }, undefined>;
105
+ type BundleInfo = v.InferOutput<typeof bundleInfo>;
106
+ declare const installResponse: v.ObjectSchema<{
99
107
  readonly message: v.StringSchema<undefined>;
100
108
  readonly bundle: v.StringSchema<undefined>;
101
109
  }, undefined>;
102
- type UpdateResponse = v.InferOutput<typeof updateResponse>;
110
+ type InstallResponse = v.InferOutput<typeof installResponse>;
103
111
  declare const updateStatus: v.ObjectSchema<{
104
112
  readonly state: v.PicklistSchema<["idle", "installing", "failed"], undefined>;
105
113
  readonly progress: v.NumberSchema<undefined>;
@@ -121,6 +129,7 @@ declare class ManagementApi {
121
129
  */
122
130
  info(): Promise<{
123
131
  model: string;
132
+ hostname: string;
124
133
  serial_number: string;
125
134
  firmware_version: string;
126
135
  firmware_commit: string;
@@ -251,12 +260,33 @@ declare class ManagementApi {
251
260
  */
252
261
  deleteProject(projectId: string): Promise<any>;
253
262
  /**
254
- * Uploads a firmware bundle to the device and starts installation.
263
+ * Uploads a firmware bundle to the device and inspects it.
264
+ * The bundle is staged for installation but not installed yet.
255
265
  * @param file The firmware bundle file (.raucb).
256
266
  * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.
257
- * @returns The upload response with message and bundle name.
267
+ * @returns Bundle metadata including version information.
268
+ */
269
+ upload_bundle(file: Blob, filename?: string): Promise<{
270
+ bundle: string;
271
+ version: string;
272
+ compatible: string;
273
+ description: string;
274
+ }>;
275
+ /**
276
+ * Gets metadata for the currently staged firmware bundle.
277
+ * @returns Bundle metadata including version information.
278
+ */
279
+ bundle_info(): Promise<{
280
+ bundle: string;
281
+ version: string;
282
+ compatible: string;
283
+ description: string;
284
+ }>;
285
+ /**
286
+ * Installs a previously uploaded firmware bundle.
287
+ * @returns The install response with message and bundle name.
258
288
  */
259
- upload_update(file: Blob, filename?: string): Promise<{
289
+ install_update(): Promise<{
260
290
  message: string;
261
291
  bundle: string;
262
292
  }>;
@@ -279,5 +309,5 @@ declare class ManagementApi {
279
309
  }>;
280
310
  }
281
311
  //#endregion
282
- export { UpdateResponse as a, RebootResponse as i, Information as n, UpdateStatus as o, ManagementApi as r, CommunicationInterfaceType as t };
283
- //# sourceMappingURL=management-wQgti8p7.d.cts.map
312
+ export { ManagementApi as a, InstallResponse as i, CommunicationInterfaceType as n, RebootResponse as o, Information as r, UpdateStatus as s, BundleInfo as t };
313
+ //# sourceMappingURL=management-C3VCMRi6.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-C3VCMRi6.d.mts","names":[],"sources":["../src/api/management.ts"],"mappings":";;;;aAGY,0BAAA;EACV,GAAA;EACA,KAAA;EACA,KAAA;EACA,GAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,cA+EI,IAAA,EAAI,CAAA,CAAA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAWE,WAAA,GAAc,CAAA,CAAE,WAAA,QAAmB,IAAA;AAAA,cAEzC,OAAA,EAAO,CAAA,CAAA,YAAA;EAAA;;;;;KAMR,OAAA,GAAU,CAAA,CAAE,WAAA,QAAmB,OAAA;AAAA,cAE9B,aAAA,EAAa,CAAA,CAAA,YAAA;EAAA;;;KACd,aAAA,GAAgB,CAAA,CAAE,WAAA,QAAmB,aAAA;AAAA,cAEpC,UAAA,EAAU,CAAA,CAAA,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AAM,OAAA"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`);require(`up-fetch`);let t=require(`valibot`);t=e.t(t);let n=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const r=t.enum(n),i=t.object({min:t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),max:t.pipe(t.number(),t.minValue(-24),t.maxValue(24))}),a=t.object({max:t.number()}),o=t.object({count:t.pipe(t.number(),t.minValue(1)),input_voltage:i,output_voltage:i}),s=t.object({count:t.pipe(t.number(),t.minValue(0)),max_current:t.number(),max_voltage:t.number(),on_resistance:t.pipe(t.number(),t.minValue(0))}),c=t.object({type:t.picklist([`3.0`,`2.0`]),count:t.pipe(t.number(),t.minValue(1))}),l=t.object({type:t.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:t.pipe(t.number(),t.minValue(1))}),u=t.object({type:r,count:t.pipe(t.number(),t.minValue(1))}),d=t.object({count:t.pipe(t.number(),t.minValue(1)),output_voltage:i,current:a}),f=t.object({type:t.picklist([`low_precision`,`high_precision`]),source:t.string(),resolution:t.pipe(t.number(),t.minValue(0))}),p=t.object({width:t.pipe(t.number(),t.minValue(1)),height:t.pipe(t.number(),t.minValue(1))}),m=t.object({type:t.string(),size:p}),h=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),g=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),_=t.object({display:m,input:h,speaker:g}),v=t.object({io:o,relays:s,usb_ports:t.array(c),ethernet:t.array(l),communication:t.array(u),power_supply:d,current_measurement:t.array(f),hmi:_}),y=t.object({model:t.string(),serial_number:t.string(),firmware_version:t.string(),firmware_commit:t.string(),disk_used:t.number(),disk_total:t.number(),docker_used:t.number(),capabilities:v}),b=t.object({name:t.string(),path:t.string(),container_id:t.string(),image:t.string()});t.object({name:t.string(),image:t.string()});const x=t.object({message:t.string(),bundle:t.string()}),S=t.object({state:t.picklist([`idle`,`installing`,`failed`]),progress:t.number(),message:t.string(),error:t.string()}),C=t.object({message:t.string()});var w=class{constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:y})}async datetime(){let e=await this.fetch(`/management/time`,{schema:t.object({epoch_seconds:t.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:t.array(b)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:b})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:b})}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`})}upload_update(e,t=`bundle.raucb`){return this.fetch(`/management/update`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:x})}update_status(){return this.fetch(`/management/update/status`,{schema:S})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:C})}};exports.CommunicationInterfaceType=n,exports.ManagementApi=w;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`);require(`up-fetch`);let t=require(`valibot`);t=e.t(t);let n=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const r=t.enum(n),i=t.object({min:t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),max:t.pipe(t.number(),t.minValue(-24),t.maxValue(24))}),a=t.object({max:t.number()}),o=t.object({count:t.pipe(t.number(),t.minValue(1)),input_voltage:i,output_voltage:i}),s=t.object({count:t.pipe(t.number(),t.minValue(0)),max_current:t.number(),max_voltage:t.number(),on_resistance:t.pipe(t.number(),t.minValue(0))}),c=t.object({type:t.picklist([`3.0`,`2.0`]),count:t.pipe(t.number(),t.minValue(1))}),l=t.object({type:t.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:t.pipe(t.number(),t.minValue(1))}),u=t.object({type:r,count:t.pipe(t.number(),t.minValue(1))}),d=t.object({count:t.pipe(t.number(),t.minValue(1)),output_voltage:i,current:a}),f=t.object({type:t.picklist([`low_precision`,`high_precision`]),source:t.string(),resolution:t.pipe(t.number(),t.minValue(0))}),p=t.object({width:t.pipe(t.number(),t.minValue(1)),height:t.pipe(t.number(),t.minValue(1))}),m=t.object({type:t.string(),size:p}),h=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),g=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),_=t.object({display:m,input:h,speaker:g}),v=t.object({io:o,relays:s,usb_ports:t.array(c),ethernet:t.array(l),communication:t.array(u),power_supply:d,current_measurement:t.array(f),hmi:_}),y=t.object({model:t.string(),hostname:t.string(),serial_number:t.string(),firmware_version:t.string(),firmware_commit:t.string(),disk_used:t.number(),disk_total:t.number(),docker_used:t.number(),capabilities:v}),b=t.object({name:t.string(),path:t.string(),container_id:t.string(),image:t.string()});t.object({name:t.string(),image:t.string()});const x=t.object({bundle:t.string(),version:t.string(),compatible:t.string(),description:t.string()}),S=t.object({message:t.string(),bundle:t.string()}),C=t.object({state:t.picklist([`idle`,`installing`,`failed`]),progress:t.number(),message:t.string(),error:t.string()}),w=t.object({message:t.string()});var T=class{constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:y})}async datetime(){let e=await this.fetch(`/management/time`,{schema:t.object({epoch_seconds:t.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:t.array(b)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:b})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:b})}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`})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:x})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:x})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:S})}update_status(){return this.fetch(`/management/update/status`,{schema:C})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:w})}};exports.CommunicationInterfaceType=n,exports.ManagementApi=T;
2
2
  //# sourceMappingURL=management.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"management.cjs","names":["v"],"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 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 info = 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 Information = v.InferOutput<typeof info>;\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\nconst updateResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type UpdateResponse = v.InferOutput<typeof updateResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\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 info() {\n return this.fetch('/management/info', { schema: info });\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 * Uploads a firmware bundle to the device and starts installation.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns The upload response with message and bundle name.\n */\n upload_update(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: updateResponse,\n });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"iKAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,aACD,CACD,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,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AAwB,IAAa,CAAE,OAAQ,SAAU,CAAC,CAS9E,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,qBAAsB,CACtC,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,EAAU,CACtF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,EACT,CAAC,CAOJ,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
1
+ {"version":3,"file":"management.cjs","names":["v"],"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 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 info = v.object({\n model: v.string(),\n hostname: 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 Information = v.InferOutput<typeof info>;\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\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\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 info() {\n return this.fetch('/management/info', { schema: info });\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 * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"iKAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,aACD,CACD,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,IAAK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rD,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,CAU9E,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,4BAA6B,CAC7C,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,EAAU,CACtF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,EACT,CAAC,CAOJ,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,EAAY,CAAC,CAO7E,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,EAAiB,CAAC,CAO9F,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
@@ -1,2 +1,2 @@
1
- import { a as UpdateResponse, i as RebootResponse, n as Information, o as UpdateStatus, r as ManagementApi, t as CommunicationInterfaceType } from "./management-wQgti8p7.cjs";
2
- export { CommunicationInterfaceType, Information, ManagementApi, RebootResponse, UpdateResponse, UpdateStatus };
1
+ import { a as ManagementApi, i as InstallResponse, n as CommunicationInterfaceType, o as RebootResponse, r as Information, s as UpdateStatus, t as BundleInfo } from "./management-Bm3yYjYD.cjs";
2
+ export { BundleInfo, CommunicationInterfaceType, Information, InstallResponse, ManagementApi, RebootResponse, UpdateStatus };
@@ -1,2 +1,2 @@
1
- import { a as UpdateResponse, i as RebootResponse, n as Information, o as UpdateStatus, r as ManagementApi, t as CommunicationInterfaceType } from "./management-ra61-qUr.mjs";
2
- export { CommunicationInterfaceType, Information, ManagementApi, RebootResponse, UpdateResponse, UpdateStatus };
1
+ import { a as ManagementApi, i as InstallResponse, n as CommunicationInterfaceType, o as RebootResponse, r as Information, s as UpdateStatus, t as BundleInfo } from "./management-C3VCMRi6.mjs";
2
+ export { BundleInfo, CommunicationInterfaceType, Information, InstallResponse, ManagementApi, RebootResponse, UpdateStatus };
@@ -1,2 +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({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()});const b=e.object({message:e.string(),bundle:e.string()}),x=e.object({state:e.picklist([`idle`,`installing`,`failed`]),progress:e.number(),message:e.string(),error:e.string()}),S=e.object({message:e.string()});var C=class{constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{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`})}upload_update(e,t=`bundle.raucb`){return this.fetch(`/management/update`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:b})}update_status(){return this.fetch(`/management/update/status`,{schema:x})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:S})}};export{t as CommunicationInterfaceType,C as ManagementApi};
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({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(),hostname: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()});const b=e.object({bundle:e.string(),version:e.string(),compatible:e.string(),description:e.string()}),x=e.object({message:e.string(),bundle:e.string()}),S=e.object({state:e.picklist([`idle`,`installing`,`failed`]),progress:e.number(),message:e.string(),error:e.string()}),C=e.object({message:e.string()});var w=class{constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{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`})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:b})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:b})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:x})}update_status(){return this.fetch(`/management/update/status`,{schema:S})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:C})}};export{t as CommunicationInterfaceType,w as ManagementApi};
2
2
  //# sourceMappingURL=management.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"management.mjs","names":[],"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 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 info = 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 Information = v.InferOutput<typeof info>;\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\nconst updateResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type UpdateResponse = v.InferOutput<typeof updateResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\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 info() {\n return this.fetch('/management/info', { schema: info });\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 * Uploads a firmware bundle to the device and starts installation.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns The upload response with message and bundle name.\n */\n upload_update(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: updateResponse,\n });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"2CAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,aACD,CACD,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,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BAAwB,IAAa,CAAE,OAAQ,SAAU,CAAC,CAS9E,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,qBAAsB,CACtC,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,EAAU,CACtF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,EACT,CAAC,CAOJ,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
1
+ {"version":3,"file":"management.mjs","names":[],"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 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 info = v.object({\n model: v.string(),\n hostname: 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 Information = v.InferOutput<typeof info>;\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\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\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 info() {\n return this.fetch('/management/info', { schema: info });\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 * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"2CAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,aACD,CACD,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,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Q,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,CAU9E,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,4BAA6B,CAC7C,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,EAAU,CACtF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,EACT,CAAC,CAOJ,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,EAAY,CAAC,CAO7E,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,EAAiB,CAAC,CAO9F,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
package/build/node.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./at1000-ARKCVfb6.cjs`);require(`./common-PXzrB8CC.cjs`);let n=require(`dns-packet`);n=e.t(n);let r=require(`node:events`),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=`IPv6`,p=[d,4,f,6];var m=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||!p.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family,scopeid:t.scopeid})}));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()}};const h={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var g=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({},h,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]:[f,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:[`IPv4`,4].includes(t.family)?`udp4`:`udp6`,reuseAddr:!!n.reuseAddr}),l=!1;c.on(`error`,e=>{l?i(e):(c.close(),a({success:!1,error:Error(e.message)}))}).on(`listening`,()=>{l=!0,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[`IPv4`,4].includes(e.family)?e.address:e.scopeid?`${e.address}%${e.scopeid}`:e.address}};const _={reuseAddr:!0,srcPort:0,interfaces:null,ttl:255,loopback:!0,debug:!1};var v=class extends r.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},_,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=m.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=>[f,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` `+d:``}${e.length&&t.length?` and`:``}${t.length?` `+f:``}`),e.length){let t=await g.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 g.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 g.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];if(n.send&&n.iface)try{n.send(t,0,t.length,u,[`IPv4`,4].includes(n.iface.family)?c:l+`%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`)}catch{}}}destroy(){this.destroyed=!0,this.ready=!1,this.removeAllListeners(),this.sendSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.sendSockets=[],this.receiveSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};const y={debug:!1};var b=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({},y,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:f,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)}};const x=async(e=500)=>{e<10&&(e=10);let n=new v({debug:!0}),r=new b(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`)).flatMap(e=>{let t=e.addresses??[],n=t.filter(e=>e.family===`IPv4`).map(e=>e.address),r=t.filter(e=>e.family===`IPv6`).map(e=>e.address);return[...n,...r]}))];n.destroy();let a=(await Promise.allSettled(i.map(e=>t.t.create(e)))).filter(e=>e.status===`fulfilled`).map(e=>e.value),o=new Set;return a.filter(e=>o.has(e.info.serial_number)?!1:(o.add(e.info.serial_number),!0))};var S=class extends t.t{static apiVersion=t.n;static findDevices(e=500){return x(e)}};exports.AT1000=S;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./at1000-COAmmgdX.cjs`);let n=require(`dns-packet`);n=e.t(n);let r=require(`node:events`),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=`IPv6`,p=[d,4,f,6];var m=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||!p.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family,scopeid:t.scopeid})}));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()}};const h={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var g=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({},h,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]:[f,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:[`IPv4`,4].includes(t.family)?`udp4`:`udp6`,reuseAddr:!!n.reuseAddr}),l=!1;c.on(`error`,e=>{l?i(e):(c.close(),a({success:!1,error:Error(e.message)}))}).on(`listening`,()=>{l=!0,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[`IPv4`,4].includes(e.family)?e.address:e.scopeid?`${e.address}%${e.scopeid}`:e.address}};const _={reuseAddr:!0,srcPort:0,interfaces:null,ttl:255,loopback:!0,debug:!1};var v=class extends r.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},_,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=m.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=>[f,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` `+d:``}${e.length&&t.length?` and`:``}${t.length?` `+f:``}`),e.length){let t=await g.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 g.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 g.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];if(n.send&&n.iface)try{n.send(t,0,t.length,u,[`IPv4`,4].includes(n.iface.family)?c:l+`%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`)}catch{}}}destroy(){this.destroyed=!0,this.ready=!1,this.removeAllListeners(),this.sendSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.sendSockets=[],this.receiveSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};const y={debug:!1};var b=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({},y,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:f,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)}};function x(e){return e.startsWith(`192.168.`)?0:e.startsWith(`169.254.`)?1:2}const S=async(e=500)=>{e<10&&(e=10);let n=new v({debug:!0}),r=new b(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`)).flatMap(e=>{let t=e.addresses??[],n=t.filter(e=>e.family===`IPv4`).map(e=>e.address),r=t.filter(e=>e.family===`IPv6`).map(e=>e.address);return[...n,...r]}))];n.destroy();let a=(await Promise.allSettled(i.map(e=>t.t.create(e)))).filter(e=>e.status===`fulfilled`).map(e=>e.value),o=new Map;for(let e of a){let t=o.get(e.info.hostname);t?x(e.host)<x(t.host)&&o.set(e.info.hostname,e):o.set(e.info.hostname,e)}return[...o.values()]};var C=class extends t.t{static apiVersion=t.n;static findDevices(e=500){return S(e)}};exports.AT1000=C;
2
2
  //# sourceMappingURL=node.cjs.map