@ledgerhq/speculos-device-controller 0.0.0-speculos-transport-20251015135132 → 0.0.0-speculos-transport-and-device-controller-20251016095459

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 (83) hide show
  1. package/README.md +103 -0
  2. package/lib/cjs/package.json +3 -1
  3. package/lib/cjs/src/api/DeviceController.js +1 -1
  4. package/lib/cjs/src/api/DeviceController.js.map +3 -3
  5. package/lib/cjs/src/index.js +1 -1
  6. package/lib/cjs/src/index.js.map +3 -3
  7. package/lib/cjs/src/internal/adapters/AxiosButtonController.js +2 -0
  8. package/lib/cjs/src/internal/adapters/AxiosButtonController.js.map +7 -0
  9. package/lib/cjs/src/internal/adapters/AxiosTouchController.js +2 -0
  10. package/lib/cjs/src/internal/adapters/AxiosTouchController.js.map +7 -0
  11. package/lib/cjs/src/internal/config/defaultScreens.js +2 -0
  12. package/lib/cjs/src/internal/config/defaultScreens.js.map +7 -0
  13. package/lib/cjs/src/internal/core/IButtonController.js +2 -0
  14. package/lib/cjs/src/internal/core/IButtonController.js.map +7 -0
  15. package/lib/cjs/src/internal/core/ITouchController.js +2 -0
  16. package/lib/cjs/src/internal/core/ITouchController.js.map +7 -0
  17. package/lib/cjs/src/internal/core/speculosDeviceControllerTypes.js +2 -0
  18. package/lib/cjs/src/internal/core/speculosDeviceControllerTypes.js.map +7 -0
  19. package/lib/cjs/src/internal/core/types.js +2 -0
  20. package/lib/cjs/src/internal/core/types.js.map +7 -0
  21. package/lib/cjs/src/internal/di.js +2 -0
  22. package/lib/cjs/src/internal/di.js.map +7 -0
  23. package/lib/cjs/src/internal/usecases/buttonUsecases.js +2 -0
  24. package/lib/cjs/src/internal/usecases/buttonUsecases.js.map +7 -0
  25. package/lib/cjs/src/internal/usecases/touchUsecases.js +2 -0
  26. package/lib/cjs/src/internal/usecases/touchUsecases.js.map +7 -0
  27. package/lib/cjs/src/internal/utils/axisClamp.js +2 -0
  28. package/lib/cjs/src/internal/utils/axisClamp.js.map +7 -0
  29. package/lib/esm/package.json +3 -1
  30. package/lib/esm/src/api/DeviceController.js +1 -1
  31. package/lib/esm/src/api/DeviceController.js.map +3 -3
  32. package/lib/esm/src/index.js +1 -1
  33. package/lib/esm/src/index.js.map +2 -2
  34. package/lib/esm/src/internal/adapters/AxiosButtonController.js +2 -0
  35. package/lib/esm/src/internal/adapters/AxiosButtonController.js.map +7 -0
  36. package/lib/esm/src/internal/adapters/AxiosTouchController.js +2 -0
  37. package/lib/esm/src/internal/adapters/AxiosTouchController.js.map +7 -0
  38. package/lib/esm/src/internal/config/defaultScreens.js +2 -0
  39. package/lib/esm/src/internal/config/defaultScreens.js.map +7 -0
  40. package/lib/esm/src/internal/core/IButtonController.js +1 -0
  41. package/lib/esm/src/internal/core/IButtonController.js.map +7 -0
  42. package/lib/esm/src/internal/core/ITouchController.js +1 -0
  43. package/lib/esm/src/internal/core/ITouchController.js.map +7 -0
  44. package/lib/esm/src/internal/core/speculosDeviceControllerTypes.js +2 -0
  45. package/lib/esm/src/internal/core/speculosDeviceControllerTypes.js.map +7 -0
  46. package/lib/esm/src/internal/core/types.js +1 -0
  47. package/lib/esm/src/internal/core/types.js.map +7 -0
  48. package/lib/esm/src/internal/di.js +2 -0
  49. package/lib/esm/src/internal/di.js.map +7 -0
  50. package/lib/esm/src/internal/usecases/buttonUsecases.js +2 -0
  51. package/lib/esm/src/internal/usecases/buttonUsecases.js.map +7 -0
  52. package/lib/esm/src/internal/usecases/touchUsecases.js +2 -0
  53. package/lib/esm/src/internal/usecases/touchUsecases.js.map +7 -0
  54. package/lib/esm/src/internal/utils/axisClamp.js +2 -0
  55. package/lib/esm/src/internal/utils/axisClamp.js.map +7 -0
  56. package/lib/types/src/api/DeviceController.d.ts +22 -13
  57. package/lib/types/src/api/DeviceController.d.ts.map +1 -1
  58. package/lib/types/src/index.d.ts +1 -0
  59. package/lib/types/src/index.d.ts.map +1 -1
  60. package/lib/types/src/internal/adapters/AxiosButtonController.d.ts +10 -0
  61. package/lib/types/src/internal/adapters/AxiosButtonController.d.ts.map +1 -0
  62. package/lib/types/src/internal/adapters/AxiosTouchController.d.ts +14 -0
  63. package/lib/types/src/internal/adapters/AxiosTouchController.d.ts.map +1 -0
  64. package/lib/types/src/internal/config/defaultScreens.d.ts +12 -0
  65. package/lib/types/src/internal/config/defaultScreens.d.ts.map +1 -0
  66. package/lib/types/src/internal/core/IButtonController.d.ts +5 -0
  67. package/lib/types/src/internal/core/IButtonController.d.ts.map +1 -0
  68. package/lib/types/src/internal/core/ITouchController.d.ts +7 -0
  69. package/lib/types/src/internal/core/ITouchController.d.ts.map +1 -0
  70. package/lib/types/src/internal/core/speculosDeviceControllerTypes.d.ts +7 -0
  71. package/lib/types/src/internal/core/speculosDeviceControllerTypes.d.ts.map +1 -0
  72. package/lib/types/src/internal/core/types.d.ts +18 -0
  73. package/lib/types/src/internal/core/types.d.ts.map +1 -0
  74. package/lib/types/src/internal/di.d.ts +4 -0
  75. package/lib/types/src/internal/di.d.ts.map +1 -0
  76. package/lib/types/src/internal/usecases/buttonUsecases.d.ts +9 -0
  77. package/lib/types/src/internal/usecases/buttonUsecases.d.ts.map +1 -0
  78. package/lib/types/src/internal/usecases/touchUsecases.d.ts +5 -0
  79. package/lib/types/src/internal/usecases/touchUsecases.d.ts.map +1 -0
  80. package/lib/types/src/internal/utils/axisClamp.d.ts +15 -0
  81. package/lib/types/src/internal/utils/axisClamp.d.ts.map +1 -0
  82. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  83. package/package.json +6 -4
package/README.md CHANGED
@@ -1 +1,104 @@
1
1
  # speculos-device-controller
2
+
3
+ A tiny TypeScript SDK for driving **Speculos** devices:
4
+
5
+ - **Buttons**: `left`, `right`, `both`, and `pressSequence([...])`
6
+ - **Touch**: **percentage-based** coordinates (e.g. `{ x: 20, y: 45 }` = 20%/45% of the screen)
7
+ - **Flexible screens config**: use built-in `"flex"`/`"stax"` defaults or supply your own device keys
8
+
9
+ ---
10
+
11
+ ## Quick start
12
+
13
+ Out of the box, the API ships with default device screens ("flex" and "stax"). You can use them without passing any options.
14
+
15
+ ```ts
16
+ import { deviceControllerFactory } from "speculos-device-controller";
17
+
18
+ const device = deviceControllerFactory("http://localhost:4000");
19
+
20
+ // Buttons
21
+ await device.button.press("both");
22
+ await device.button.left();
23
+ await device.button.right();
24
+ await device.button.both();
25
+ await device.button.pressSequence(["left", "right", "both"], 150);
26
+
27
+ // Touch: percentages (0..100)
28
+ await device.touch.createTap("flex").tapQuick({ x: 20, y: 45 }); // 20% / 45% of the "flex" screen
29
+
30
+ // Touch returns a factory function so you can easily instanciate devices dynamically
31
+ const currentDevice = device.touch.createTap(currentDevice);
32
+ await currentDevice.tapLong({ x: 20, y: 45 });
33
+ ```
34
+
35
+ Under the hood, percentages are clamped to [0, 100] and converted to pixels using the screen spec for the selected device key.
36
+
37
+ ### Override default sizes (keep "flex"/"stax" keys)
38
+
39
+ ```ts
40
+ const device = deviceControllerFactory("http://localhost:4000", {
41
+ timeoutMs: 2000, // optional axios timeout
42
+ clientHeader: "ldmk-transport-speculos", // optional header
43
+ screens: {
44
+ // override by default keys
45
+ flex: { width: 256, height: 256 },
46
+ // stax: { width: 340, height: 340 }, // you can override one or both
47
+ },
48
+ });
49
+ ```
50
+
51
+ ### Provide custom screens
52
+
53
+ ```ts
54
+ const device = deviceControllerFactory("http://localhost:4000", {
55
+ screens: {
56
+ custom: { width: 128, height: 64 },
57
+ },
58
+ });
59
+
60
+ await device.touch.createTap("custom").tapQuick({ x: 50, y: 50 }); // ok
61
+ // await device.touch.createTap("unknown").tapQuick({ x: 10, y: 10 }); // throws: Unknown device key "unknown"
62
+ ```
63
+
64
+ ## API
65
+
66
+ ### Factory
67
+
68
+ ```ts
69
+ deviceControllerFactory(
70
+ baseURL: string,
71
+ opts?: {
72
+ timeoutMs?: number; // axios timeout (ms)
73
+ clientHeader?: string; // "X-Ledger-Client-Version" header
74
+ screens?: Record<string, { width: number; height: number }>;
75
+ }
76
+ ): DeviceAPI
77
+ ```
78
+
79
+ ### DeviceAPI
80
+
81
+ ```ts
82
+ type ButtonKey = "Ll" | "Rr" | "LRlr" | "left" | "right" | "both";
83
+ type PercentPoint = { x: number; y: number }; // interpreted as 0..100, clamped
84
+
85
+ type ButtonAPI = {
86
+ press(key: ButtonKey): Promise<void>;
87
+ left(): Promise<void>;
88
+ right(): Promise<void>;
89
+ both(): Promise<void>;
90
+ pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;
91
+ };
92
+
93
+ type TouchAPI = {
94
+ createTap: (deviceKey: string) => {
95
+ tapQuick: (point: PercentPoint) => Promise<void>;
96
+ tapLong: (point: PercentPoint) => Promise<void>;
97
+ };
98
+ };
99
+
100
+ type DeviceAPI = {
101
+ button: ButtonAPI;
102
+ touch: TouchAPI;
103
+ };
104
+ ```
@@ -36,8 +36,10 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@sentry/minimal": "catalog:",
39
+ "axios": "catalog:",
40
+ "inversify": "catalog:",
39
41
  "purify-ts": "catalog:",
40
- "axios": "catalog:"
42
+ "reflect-metadata": "catalog:"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.create;var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var b=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},n=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of p(t))!h.call(r,s)&&s!==e&&i(r,s,{get:()=>t[s],enumerable:!(o=c(t,s))||o.enumerable});return r};var m=(r,t,e)=>(e=r!=null?a(u(r)):{},n(t||!r||!r.__esModule?i(e,"default",{value:r,enumerable:!0}):e,r)),d=r=>n(i({},"__esModule",{value:!0}),r);var g={};b(g,{DeviceController:()=>f});module.exports=d(g);var l=m(require("axios"));class f{constructor(t,e={}){this.baseURL=t;const o=e.timeoutMs??1500,s=e.clientHeader??"ldmk-transport-speculos";this.buttonClient=l.default.create({baseURL:this.baseURL.replace(/\/+$/,""),timeout:o,headers:{"X-Ledger-Client-Version":s},transitional:{clarifyTimeoutError:!0}})}buttonClient;toEndpointKey(t){return{Ll:"left",Rr:"right",LRlr:"both",left:"left",right:"right",both:"both"}[t]??"right"}async press(t){const e=this.toEndpointKey(t);await this.buttonClient.post(`/button/${e}`,{action:"press-and-release"})}left(){return this.press("left")}right(){return this.press("right")}both(){return this.press("both")}async pressSequence(t,e=200){for(const o of t)await this.press(o),e>0&&await new Promise(s=>setTimeout(s,e))}}0&&(module.exports={DeviceController});
1
+ "use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},d=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!g.call(t,o)&&o!==r&&l(t,o,{get:()=>e[o],enumerable:!(i=y(e,o))||i.enumerable});return t};var B=t=>d(l({},"__esModule",{value:!0}),t);var f={};h(f,{deviceControllerFactory:()=>I});module.exports=B(f);var a=require("../internal/config/defaultScreens"),s=require("../internal/usecases/buttonUsecases"),c=require("../internal/usecases/touchUsecases"),u=require("../../src/internal/core/speculosDeviceControllerTypes"),P=require("../../src/internal/di");function I(t,e={}){const r={screens:e.screens??a.DEFAULT_SCREENS,timeoutMs:e.timeoutMs,clientHeader:e.clientHeader},i=(0,P.buildContainer)(t,r),o=i.get(u.speculosDeviceControllerTypes.ButtonController),p=(0,s.pressButtons)(o),m=i.get(u.speculosDeviceControllerTypes.TouchController);return{button:{press:n=>o.press(n),left:()=>p.left(),right:()=>p.right(),both:()=>p.both(),pressSequence:(n,v)=>(0,s.pressSequence)(o,n,v)},touch:{createTap:n=>({tapQuick:(0,c.tapQuick)(m,n),tapLong:(0,c.tapLong)(m,n)})}}}0&&(module.exports={deviceControllerFactory});
2
2
  //# sourceMappingURL=DeviceController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/DeviceController.ts"],
4
- "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\n\nexport type DeviceControllerOptions = {\n timeoutMs?: number;\n clientHeader?: string;\n};\n\nexport type SpeculosDeviceButtonsKeys =\n | \"Ll\"\n | \"Rr\"\n | \"LRlr\"\n | \"left\"\n | \"right\"\n | \"both\";\n\nexport class DeviceController {\n private readonly buttonClient: AxiosInstance;\n\n constructor(\n private readonly baseURL: string,\n opts: DeviceControllerOptions = {},\n ) {\n const timeoutMs = opts.timeoutMs ?? 1500;\n const clientHeader = opts.clientHeader ?? \"ldmk-transport-speculos\";\n\n this.buttonClient = axios.create({\n baseURL: this.baseURL.replace(/\\/+$/, \"\"),\n timeout: timeoutMs,\n headers: {\n \"X-Ledger-Client-Version\": clientHeader,\n },\n transitional: { clarifyTimeoutError: true },\n });\n }\n\n private toEndpointKey(\n but: SpeculosDeviceButtonsKeys,\n ): \"left\" | \"right\" | \"both\" {\n const map: Record<string, \"left\" | \"right\" | \"both\"> = {\n Ll: \"left\",\n Rr: \"right\",\n LRlr: \"both\",\n left: \"left\",\n right: \"right\",\n both: \"both\",\n };\n return map[but] ?? \"right\";\n }\n\n async press(but: SpeculosDeviceButtonsKeys): Promise<void> {\n const input = this.toEndpointKey(but);\n await this.buttonClient.post(`/button/${input}`, {\n action: \"press-and-release\",\n });\n }\n\n left() {\n return this.press(\"left\");\n }\n right() {\n return this.press(\"right\");\n }\n both() {\n return this.press(\"both\");\n }\n\n async pressSequence(\n keys: SpeculosDeviceButtonsKeys[],\n delayMs = 200,\n ): Promise<void> {\n for (const k of keys) {\n await this.press(k);\n if (delayMs > 0) {\n await new Promise((r) => setTimeout(r, delayMs));\n }\n }\n }\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,oBAenC,MAAMF,CAAiB,CAG5B,YACmBG,EACjBC,EAAgC,CAAC,EACjC,CAFiB,aAAAD,EAGjB,MAAME,EAAYD,EAAK,WAAa,KAC9BE,EAAeF,EAAK,cAAgB,0BAE1C,KAAK,aAAe,EAAAG,QAAM,OAAO,CAC/B,QAAS,KAAK,QAAQ,QAAQ,OAAQ,EAAE,EACxC,QAASF,EACT,QAAS,CACP,0BAA2BC,CAC7B,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,CACH,CAjBiB,aAmBT,cACNE,EAC2B,CAS3B,MARuD,CACrD,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,OACN,MAAO,QACP,KAAM,MACR,EACWA,CAAG,GAAK,OACrB,CAEA,MAAM,MAAMA,EAA+C,CACzD,MAAMC,EAAQ,KAAK,cAAcD,CAAG,EACpC,MAAM,KAAK,aAAa,KAAK,WAAWC,CAAK,GAAI,CAC/C,OAAQ,mBACV,CAAC,CACH,CAEA,MAAO,CACL,OAAO,KAAK,MAAM,MAAM,CAC1B,CACA,OAAQ,CACN,OAAO,KAAK,MAAM,OAAO,CAC3B,CACA,MAAO,CACL,OAAO,KAAK,MAAM,MAAM,CAC1B,CAEA,MAAM,cACJC,EACAC,EAAU,IACK,CACf,UAAWC,KAAKF,EACd,MAAM,KAAK,MAAME,CAAC,EACdD,EAAU,GACZ,MAAM,IAAI,QAASE,GAAM,WAAWA,EAAGF,CAAO,CAAC,CAGrD,CACF",
6
- "names": ["DeviceController_exports", "__export", "DeviceController", "__toCommonJS", "import_axios", "baseURL", "opts", "timeoutMs", "clientHeader", "axios", "but", "input", "keys", "delayMs", "k", "r"]
4
+ "sourcesContent": ["import { DEFAULT_SCREENS } from \"@internal/config/defaultScreens\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type {\n ButtonKey,\n DeviceControllerOptions,\n DeviceScreens,\n PercentPoint,\n} from \"@internal/core/types\";\nimport { pressButtons, pressSequence } from \"@internal/usecases/buttonUsecases\";\nimport { tapLong, tapQuick } from \"@internal/usecases/touchUsecases\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\nimport { buildContainer } from \"@root/src/internal/di\";\n\nexport type ButtonAPI = IButtonController & {\n left(): Promise<void>;\n right(): Promise<void>;\n both(): Promise<void>;\n pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;\n};\n\nexport type TouchAPI = {\n createTap: (deviceKey: string) => {\n tapQuick: (point: PercentPoint) => Promise<void>;\n tapLong: (point: PercentPoint) => Promise<void>;\n };\n};\n\nexport type DeviceAPI = {\n button: ButtonAPI;\n touch: TouchAPI;\n};\n\ntype BaseOpts = {\n timeoutMs?: number;\n clientHeader?: string;\n screens?: DeviceScreens<string>;\n};\n\nexport function deviceControllerFactory(\n baseURL: string,\n opts: BaseOpts = {},\n): DeviceAPI {\n const resolved: DeviceControllerOptions<string> = {\n screens: opts.screens ?? DEFAULT_SCREENS,\n timeoutMs: opts.timeoutMs,\n clientHeader: opts.clientHeader,\n };\n\n const container = buildContainer<string>(baseURL, resolved);\n\n const buttons = container.get<IButtonController>(\n speculosDeviceControllerTypes.ButtonController,\n );\n const press = pressButtons(buttons);\n const touch = container.get<ITouchController<string>>(\n speculosDeviceControllerTypes.TouchController,\n );\n\n return {\n button: {\n press: (k) => buttons.press(k),\n left: () => press.left(),\n right: () => press.right(),\n both: () => press.both(),\n pressSequence: (keys, delayMs) => pressSequence(buttons, keys, delayMs),\n },\n touch: {\n createTap: (key) => ({\n tapQuick: tapQuick(touch, key),\n tapLong: tapLong(touch, key),\n }),\n },\n };\n}\n\nexport type { ButtonKey, DeviceControllerOptions, DeviceScreens, PercentPoint };\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,2CAShCC,EAA4C,6CAC5CC,EAAkC,4CAClCC,EAA8C,iEAC9CC,EAA+B,iCA2BxB,SAASN,EACdO,EACAC,EAAiB,CAAC,EACP,CACX,MAAMC,EAA4C,CAChD,QAASD,EAAK,SAAW,kBACzB,UAAWA,EAAK,UAChB,aAAcA,EAAK,YACrB,EAEME,KAAY,kBAAuBH,EAASE,CAAQ,EAEpDE,EAAUD,EAAU,IACxB,gCAA8B,gBAChC,EACME,KAAQ,gBAAaD,CAAO,EAC5BE,EAAQH,EAAU,IACtB,gCAA8B,eAChC,EAEA,MAAO,CACL,OAAQ,CACN,MAAQI,GAAMH,EAAQ,MAAMG,CAAC,EAC7B,KAAM,IAAMF,EAAM,KAAK,EACvB,MAAO,IAAMA,EAAM,MAAM,EACzB,KAAM,IAAMA,EAAM,KAAK,EACvB,cAAe,CAACG,EAAMC,OAAY,iBAAcL,EAASI,EAAMC,CAAO,CACxE,EACA,MAAO,CACL,UAAYC,IAAS,CACnB,YAAU,YAASJ,EAAOI,CAAG,EAC7B,WAAS,WAAQJ,EAAOI,CAAG,CAC7B,EACF,CACF,CACF",
6
+ "names": ["DeviceController_exports", "__export", "deviceControllerFactory", "__toCommonJS", "import_defaultScreens", "import_buttonUsecases", "import_touchUsecases", "import_speculosDeviceControllerTypes", "import_di", "baseURL", "opts", "resolved", "container", "buttons", "press", "touch", "k", "keys", "delayMs", "key"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./api/DeviceController"),module.exports);0&&(module.exports={...require("./api/DeviceController")});
1
+ "use strict";var x=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(r,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of b(o))!c.call(r,m)&&m!==t&&x(r,m,{get:()=>o[m],enumerable:!(i=a(o,m))||i.enumerable});return r},e=(r,o,t)=>(f(r,o,"default"),t&&f(t,o,"default"));var d=r=>f(x({},"__esModule",{value:!0}),r);var p={};module.exports=d(p);var h=require("reflect-metadata");e(p,require("./api/DeviceController"),module.exports);0&&(module.exports={...require("./api/DeviceController")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export * from \"./api/DeviceController\";\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,kCAAd",
6
- "names": ["src_exports", "__toCommonJS", "__reExport"]
4
+ "sourcesContent": ["import \"reflect-metadata\";\n\nexport * from \"./api/DeviceController\";\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAA,IAAAE,EAAO,4BAEPC,EAAAH,EAAc,kCAFd",
6
+ "names": ["src_exports", "__toCommonJS", "import_reflect_metadata", "__reExport"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!u.call(e,r)&&r!==o&&p(e,r,{get:()=>t[r],enumerable:!(n=c(t,r))||n.enumerable});return e};var K=e=>d(p({},"__esModule",{value:!0}),e),m=(e,t,o,n)=>{for(var r=n>1?void 0:n?c(t,o):t,l=e.length-1,a;l>=0;l--)(a=e[l])&&(r=(n?a(t,o,r):a(r))||r);return n&&r&&p(t,o,r),r},y=(e,t)=>(o,n)=>t(o,n,e);var g={};b(g,{AxiosButtonController:()=>i});module.exports=K(g);var s=require("inversify"),h=require("../../../src/internal/core/speculosDeviceControllerTypes");let i=class{constructor(t){this.client=t}toEndpointKey(t){return{Ll:"left",Rr:"right",LRlr:"both",left:"left",right:"right",both:"both"}[t]}async press(t){const o=this.toEndpointKey(t);await this.client.post(`/button/${o}`,{action:"press-and-release"})}};i=m([(0,s.injectable)(),y(0,(0,s.inject)(h.speculosDeviceControllerTypes.HttpClient))],i);0&&(module.exports={AxiosButtonController});
2
+ //# sourceMappingURL=AxiosButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/AxiosButtonController.ts"],
4
+ "sourcesContent": ["import type { AxiosInstance } from \"axios\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ButtonKey } from \"@internal/core/types\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\n@injectable()\nexport class AxiosButtonController implements IButtonController {\n constructor(\n @inject(speculosDeviceControllerTypes.HttpClient)\n private readonly client: AxiosInstance,\n ) {}\n\n private toEndpointKey(but: ButtonKey): \"left\" | \"right\" | \"both\" {\n const map: Record<ButtonKey, \"left\" | \"right\" | \"both\"> = {\n Ll: \"left\",\n Rr: \"right\",\n LRlr: \"both\",\n left: \"left\",\n right: \"right\",\n both: \"both\",\n };\n return map[but];\n }\n\n async press(but: ButtonKey): Promise<void> {\n const input = this.toEndpointKey(but);\n await this.client.post(`/button/${input}`, { action: \"press-and-release\" });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBAInCC,EAA8C,iEAGvC,IAAMC,EAAN,KAAyD,CAC9D,YAEmBC,EACjB,CADiB,YAAAA,CAChB,CAEK,cAAcC,EAA2C,CAS/D,MAR0D,CACxD,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,OACN,MAAO,QACP,KAAM,MACR,EACWA,CAAG,CAChB,CAEA,MAAM,MAAMA,EAA+B,CACzC,MAAMC,EAAQ,KAAK,cAAcD,CAAG,EACpC,MAAM,KAAK,OAAO,KAAK,WAAWC,CAAK,GAAI,CAAE,OAAQ,mBAAoB,CAAC,CAC5E,CACF,EAtBaH,EAANI,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gCAA8B,UAAU,IAFvCL",
6
+ "names": ["AxiosButtonController_exports", "__export", "AxiosButtonController", "__toCommonJS", "import_inversify", "import_speculosDeviceControllerTypes", "AxiosButtonController", "client", "but", "input", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(i,t)=>{for(var e in t)a(i,e,{get:t[e],enumerable:!0})},b=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of x(t))!f.call(i,s)&&s!==e&&a(i,s,{get:()=>t[s],enumerable:!(n=P(t,s))||n.enumerable});return i};var g=i=>b(a({},"__esModule",{value:!0}),i),y=(i,t,e,n)=>{for(var s=n>1?void 0:n?P(t,e):t,c=i.length-1,p;c>=0;c--)(p=i[c])&&(s=(n?p(t,e,s):p(s))||s);return n&&s&&a(t,e,s),s},l=(i,t)=>(e,n)=>t(e,n,i);var w={};h(w,{AxiosTouchController:()=>r});module.exports=g(w);var o=require("inversify"),m=require("../../../src/internal/core/speculosDeviceControllerTypes");let r=class{constructor(t,e){this.client=t;this.axes=e}toAbs(t,e){const n=this.axes[t];if(!n){const s=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${t}". Known keys: ${s.join(", ")||"<none>"}`)}return n.xy(e.x,e.y)}async tapAndRelease(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"press-and-release",...n})}async tap(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"press",...n})}async release(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"release",...n})}};r=y([(0,o.injectable)(),l(0,(0,o.inject)(m.speculosDeviceControllerTypes.HttpClient)),l(1,(0,o.inject)(m.speculosDeviceControllerTypes.Axes))],r);0&&(module.exports={AxiosTouchController});
2
+ //# sourceMappingURL=AxiosTouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/AxiosTouchController.ts"],
4
+ "sourcesContent": ["import type { AxiosInstance } from \"axios\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type { Percent, PercentPoint } from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\n@injectable()\nexport class AxiosTouchController implements ITouchController<string> {\n constructor(\n @inject(speculosDeviceControllerTypes.HttpClient)\n private readonly client: AxiosInstance,\n @inject(speculosDeviceControllerTypes.Axes)\n private readonly axes: AxisMap<string>,\n ) {}\n\n private toAbs(deviceKey: string, p: PercentPoint) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes);\n throw new Error(\n `[Touch] Unknown device key \"${deviceKey}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n return axis.xy(p.x as Percent, p.y as Percent);\n }\n\n async tapAndRelease(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"press-and-release\",\n ...abs,\n });\n }\n\n async tap(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"press\",\n ...abs,\n });\n }\n\n async release(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"release\",\n ...abs,\n });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBAKnCC,EAA8C,iEAGvC,IAAMC,EAAN,KAA+D,CACpE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEK,MAAMC,EAAmBC,EAAiB,CAChD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAAI,EACnC,MAAM,IAAI,MACR,+BAA+BH,CAAS,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EACxF,CACF,CACA,OAAOD,EAAK,GAAGD,EAAE,EAAcA,EAAE,CAAY,CAC/C,CAEA,MAAM,cAAcD,EAAmBI,EAAoC,CACzE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,oBACR,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAmBI,EAAoC,CAC/D,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,QACR,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAmBI,EAAoC,CACnE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,UACR,GAAGC,CACL,CAAC,CACH,CACF,EA1CaR,EAANS,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gCAA8B,UAAU,GAE/CA,EAAA,eAAO,gCAA8B,IAAI,IAJjCV",
6
+ "names": ["AxiosTouchController_exports", "__export", "AxiosTouchController", "__toCommonJS", "import_inversify", "import_speculosDeviceControllerTypes", "AxiosTouchController", "client", "axes", "deviceKey", "p", "axis", "known", "point", "abs", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var i in t)o(e,i,{get:t[i],enumerable:!0})},y=(e,t,i,E)=>{if(t&&typeof t=="object"||typeof t=="function")for(let h of f(t))!p.call(e,h)&&h!==i&&o(e,h,{get:()=>t[h],enumerable:!(E=s(t,h))||E.enumerable});return e};var D=e=>y(o({},"__esModule",{value:!0}),e);var a={};x(a,{DEFAULT_SCREENS:()=>S});module.exports=D(a);const S={flex:{width:240,height:240},stax:{width:340,height:340}};0&&(module.exports={DEFAULT_SCREENS});
2
+ //# sourceMappingURL=defaultScreens.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/config/defaultScreens.ts"],
4
+ "sourcesContent": ["export const DEFAULT_SCREENS = {\n flex: { width: 240, height: 240 },\n stax: { width: 340, height: 340 },\n} as const;\n\nexport type DefaultDeviceKey = keyof typeof DEFAULT_SCREENS & string;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAkB,CAC7B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC",
6
+ "names": ["defaultScreens_exports", "__export", "DEFAULT_SCREENS", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(e,t,p,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of i(t))!s.call(e,o)&&o!==p&&n(e,o,{get:()=>t[o],enumerable:!(r=y(t,o))||r.enumerable});return e};var u=e=>m(n({},"__esModule",{value:!0}),e);var B={};module.exports=u(B);
2
+ //# sourceMappingURL=IButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/IButtonController.ts"],
4
+ "sourcesContent": ["import type { ButtonKey } from \"./types\";\n\nexport interface IButtonController {\n press(key: ButtonKey): Promise<void>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["IButtonController_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var s=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!p.call(t,i)&&i!==r&&n(t,i,{get:()=>e[i],enumerable:!(o=P(e,i))||o.enumerable});return t};var d=t=>s(n({},"__esModule",{value:!0}),t);var K={};module.exports=d(K);
2
+ //# sourceMappingURL=ITouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/ITouchController.ts"],
4
+ "sourcesContent": ["import type { PercentPoint } from \"./types\";\n\nexport interface ITouchController<K extends string = string> {\n tapAndRelease: (deviceKey: K, point: PercentPoint) => Promise<void>;\n tap: (deviceKey: K, point: PercentPoint) => Promise<void>;\n release: (deviceKey: K, point: PercentPoint) => Promise<void>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ITouchController_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var e=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(l,o)=>{for(var r in o)e(l,r,{get:o[r],enumerable:!0})},u=(l,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!c.call(l,t)&&t!==r&&e(l,t,{get:()=>o[t],enumerable:!(n=C(o,t))||n.enumerable});return l};var y=l=>u(e({},"__esModule",{value:!0}),l);var f={};p(f,{speculosDeviceControllerTypes:()=>b});module.exports=y(f);const b={HttpClient:Symbol.for("HttpClient"),ButtonController:Symbol.for("ButtonController"),TouchController:Symbol.for("TouchController"),Axes:Symbol.for("Axes")};0&&(module.exports={speculosDeviceControllerTypes});
2
+ //# sourceMappingURL=speculosDeviceControllerTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/speculosDeviceControllerTypes.ts"],
4
+ "sourcesContent": ["export const speculosDeviceControllerTypes = {\n HttpClient: Symbol.for(\"HttpClient\"),\n ButtonController: Symbol.for(\"ButtonController\"),\n TouchController: Symbol.for(\"TouchController\"),\n Axes: Symbol.for(\"Axes\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAgC,CAC3C,WAAY,OAAO,IAAI,YAAY,EACnC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,KAAM,OAAO,IAAI,MAAM,CACzB",
6
+ "names": ["speculosDeviceControllerTypes_exports", "__export", "speculosDeviceControllerTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var x=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!i.call(t,n)&&n!==o&&c(t,n,{get:()=>e[n],enumerable:!(r=p(e,n))||r.enumerable});return t};var g=t=>x(c({},"__esModule",{value:!0}),t);var y={};module.exports=g(y);
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/types.ts"],
4
+ "sourcesContent": ["export type ButtonKey = \"Ll\" | \"Rr\" | \"LRlr\" | \"left\" | \"right\" | \"both\";\n\nexport type ScreenSpec = Readonly<{ width: number; height: number }>;\n\nexport type DeviceScreens<K extends string = string> = Readonly<\n Record<K, ScreenSpec>\n>;\n\nexport type Range<\n N extends number,\n Acc extends number[] = [],\n> = Acc[\"length\"] extends N ? Acc[number] : Range<N, [...Acc, Acc[\"length\"]]>;\nexport type Percent = Range<101>;\n\nexport type PercentPoint = { x: Percent; y: Percent };\n\nexport type DeviceControllerOptions<K extends string = string> = {\n timeoutMs?: number;\n clientHeader?: string;\n screens: DeviceScreens<K>;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["types_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var C=Object.create;var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var A=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},s=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!y.call(o,r)&&r!==e&&l(o,r,{get:()=>t[r],enumerable:!(i=f(t,r))||i.enumerable});return o};var I=(o,t,e)=>(e=o!=null?C(x(o)):{},s(t||!o||!o.__esModule?l(e,"default",{value:o,enumerable:!0}):e,o)),h=o=>s(l({},"__esModule",{value:!0}),o);var b={};A(b,{buildContainer:()=>T});module.exports=h(b);var a=I(require("axios")),c=require("inversify"),p=require("./adapters/AxiosButtonController"),m=require("./adapters/AxiosTouchController"),u=require("./utils/axisClamp"),n=require("../../src/internal/core/speculosDeviceControllerTypes");function T(o,t){const e=new c.Container({defaultScope:"Singleton"}),i=a.default.create({baseURL:o.replace(/\/+$/,""),timeout:t.timeoutMs??1500,headers:{"X-Ledger-Client-Version":t.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}});return e.bind(n.speculosDeviceControllerTypes.HttpClient).toConstantValue(i),e.bind(n.speculosDeviceControllerTypes.Axes).toConstantValue((0,u.createAxes)(t.screens)),e.bind(n.speculosDeviceControllerTypes.ButtonController).to(p.AxiosButtonController),e.bind(n.speculosDeviceControllerTypes.TouchController).to(m.AxiosTouchController),e}0&&(module.exports={buildContainer});
2
+ //# sourceMappingURL=di.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/di.ts"],
4
+ "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\nimport { Container } from \"inversify\";\n\nimport { AxiosButtonController } from \"@internal/adapters/AxiosButtonController\";\nimport { AxiosTouchController } from \"@internal/adapters/AxiosTouchController\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type { DeviceControllerOptions } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\nexport function buildContainer<K extends string>(\n baseURL: string,\n opts: DeviceControllerOptions<K>,\n) {\n const container = new Container({ defaultScope: \"Singleton\" });\n\n const http = axios.create({\n baseURL: baseURL.replace(/\\/+$/, \"\"),\n timeout: opts.timeoutMs ?? 1500,\n headers: {\n \"X-Ledger-Client-Version\": opts.clientHeader ?? \"ldmk-transport-speculos\",\n },\n transitional: { clarifyTimeoutError: true },\n });\n\n container\n .bind<AxiosInstance>(speculosDeviceControllerTypes.HttpClient)\n .toConstantValue(http);\n container\n .bind<AxisMap<K>>(speculosDeviceControllerTypes.Axes)\n .toConstantValue(createAxes(opts.screens));\n\n container\n .bind<IButtonController>(speculosDeviceControllerTypes.ButtonController)\n .to(AxiosButtonController);\n container\n .bind<ITouchController<K>>(speculosDeviceControllerTypes.TouchController)\n .to(AxiosTouchController);\n\n return container;\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,oBAC1CC,EAA0B,qBAE1BC,EAAsC,oDACtCC,EAAqC,mDAIrCC,EAAyC,qCACzCC,EAA8C,iEAEvC,SAASP,EACdQ,EACAC,EACA,CACA,MAAMC,EAAY,IAAI,YAAU,CAAE,aAAc,WAAY,CAAC,EAEvDC,EAAO,EAAAC,QAAM,OAAO,CACxB,QAASJ,EAAQ,QAAQ,OAAQ,EAAE,EACnC,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAED,OAAAC,EACG,KAAoB,gCAA8B,UAAU,EAC5D,gBAAgBC,CAAI,EACvBD,EACG,KAAiB,gCAA8B,IAAI,EACnD,mBAAgB,cAAWD,EAAK,OAAO,CAAC,EAE3CC,EACG,KAAwB,gCAA8B,gBAAgB,EACtE,GAAG,uBAAqB,EAC3BA,EACG,KAA0B,gCAA8B,eAAe,EACvE,GAAG,sBAAoB,EAEnBA,CACT",
6
+ "names": ["di_exports", "__export", "buildContainer", "__toCommonJS", "import_axios", "import_inversify", "import_AxiosButtonController", "import_AxiosTouchController", "import_axisClamp", "import_speculosDeviceControllerTypes", "baseURL", "opts", "container", "http", "axios"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,o)=>{for(var e in o)n(t,e,{get:o[e],enumerable:!0})},c=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of a(o))!p.call(t,r)&&r!==e&&n(t,r,{get:()=>o[r],enumerable:!(i=s(o,r))||i.enumerable});return t};var f=t=>c(n({},"__esModule",{value:!0}),t);var y={};l(y,{pressButtons:()=>u,pressSequence:()=>m});module.exports=f(y);async function m(t,o,e=200){for(const i of o)await t.press(i),e>0&&await new Promise(r=>setTimeout(r,e))}function u(t){return{left:async()=>await t.press("left"),right:async()=>await t.press("right"),both:async()=>await t.press("both")}}0&&(module.exports={pressButtons,pressSequence});
2
+ //# sourceMappingURL=buttonUsecases.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/usecases/buttonUsecases.ts"],
4
+ "sourcesContent": ["import type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ButtonKey } from \"@internal/core/types\";\n\nexport async function pressSequence(\n buttons: IButtonController,\n keys: ButtonKey[],\n delayMs = 200,\n): Promise<void> {\n for (const k of keys) {\n await buttons.press(k);\n if (delayMs > 0) {\n await new Promise((r) => setTimeout(r, delayMs));\n }\n }\n}\n\nexport function pressButtons(buttons: IButtonController): {\n left: () => Promise<void>;\n right: () => Promise<void>;\n both: () => Promise<void>;\n} {\n return {\n left: async () => await buttons.press(\"left\"),\n right: async () => await buttons.press(\"right\"),\n both: async () => await buttons.press(\"both\"),\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GAGA,eAAsBG,EACpBE,EACAC,EACAC,EAAU,IACK,CACf,UAAWC,KAAKF,EACd,MAAMD,EAAQ,MAAMG,CAAC,EACjBD,EAAU,GACZ,MAAM,IAAI,QAAS,GAAM,WAAW,EAAGA,CAAO,CAAC,CAGrD,CAEO,SAASL,EAAaG,EAI3B,CACA,MAAO,CACL,KAAM,SAAY,MAAMA,EAAQ,MAAM,MAAM,EAC5C,MAAO,SAAY,MAAMA,EAAQ,MAAM,OAAO,EAC9C,KAAM,SAAY,MAAMA,EAAQ,MAAM,MAAM,CAC9C,CACF",
6
+ "names": ["buttonUsecases_exports", "__export", "pressButtons", "pressSequence", "__toCommonJS", "buttons", "keys", "delayMs", "k"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var o in t)a(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!c.call(e,r)&&r!==o&&a(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e};var P=e=>l(a({},"__esModule",{value:!0}),e);var u={};p(u,{tapLong:()=>m,tapQuick:()=>w});module.exports=P(u);const m=(e,t)=>async o=>{await e.tap(t,o),await new Promise(n=>setTimeout(n,5e3)),await e.release(t,o)},w=(e,t)=>async o=>await e.tapAndRelease(t,o);0&&(module.exports={tapLong,tapQuick});
2
+ //# sourceMappingURL=touchUsecases.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/usecases/touchUsecases.ts"],
4
+ "sourcesContent": ["import { type ITouchController } from \"@internal/core/ITouchController\";\nimport type { PercentPoint } from \"@internal/core/types\";\n\nexport const tapLong =\n (touch: ITouchController, deviceKey: string) =>\n async (point: PercentPoint) => {\n await touch.tap(deviceKey, point);\n await new Promise((r) => setTimeout(r, 5000));\n await touch.release(deviceKey, point);\n };\n\nexport const tapQuick =\n (touch: ITouchController, deviceKey: string) => async (point: PercentPoint) =>\n await touch.tapAndRelease(deviceKey, point);\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,aAAAC,IAAA,eAAAC,EAAAJ,GAGO,MAAME,EACX,CAACG,EAAyBC,IAC1B,MAAOC,GAAwB,CAC7B,MAAMF,EAAM,IAAIC,EAAWC,CAAK,EAChC,MAAM,IAAI,QAASC,GAAM,WAAWA,EAAG,GAAI,CAAC,EAC5C,MAAMH,EAAM,QAAQC,EAAWC,CAAK,CACtC,EAEWJ,EACX,CAACE,EAAyBC,IAAsB,MAAOC,GACrD,MAAMF,EAAM,cAAcC,EAAWC,CAAK",
6
+ "names": ["touchUsecases_exports", "__export", "tapLong", "tapQuick", "__toCommonJS", "touch", "deviceKey", "point", "r"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!y.call(e,n)&&n!==r&&c(e,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return e};var u=e=>f(c({},"__esModule",{value:!0}),e);var h={};M(h,{createAxes:()=>A,createAxis:()=>p,createVH:()=>x,createVW:()=>a});module.exports=u(h);const s=e=>Math.max(0,Math.min(100,e))/100,a=e=>t=>Math.floor(e*s(t)),x=e=>t=>Math.floor(e*s(t)),p=(e,t)=>({vw:a(e),vh:x(t),xy:(r,o)=>({x:Math.floor(e*s(r)),y:Math.floor(t*s(o))})}),A=e=>{const t={};for(const r of Object.keys(e)){const o=e[r];t[r]=p(o.width,o.height)}return t};0&&(module.exports={createAxes,createAxis,createVH,createVW});
2
+ //# sourceMappingURL=axisClamp.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/utils/axisClamp.ts"],
4
+ "sourcesContent": ["import type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nconst clamp = (pct: number) => Math.max(0, Math.min(100, pct)) / 100;\n\nexport const createVW = (width: number) => (pct: Percent) =>\n Math.floor(width * clamp(pct));\nexport const createVH = (height: number) => (pct: Percent) =>\n Math.floor(height * clamp(pct));\n\nexport const createAxis = (width: number, height: number) => ({\n vw: createVW(width),\n vh: createVH(height),\n xy: (xPct: Percent, yPct: Percent) => ({\n x: Math.floor(width * clamp(xPct)),\n y: Math.floor(height * clamp(yPct)),\n }),\n});\n\nexport type Axis = ReturnType<typeof createAxis>;\nexport type AxisMap<K extends string = string> = Record<K, Axis>;\n\nexport const createAxes = <K extends string>(\n screens: DeviceScreens<K>,\n): AxisMap<K> => {\n const out = {} as AxisMap<K>;\n for (const key of Object.keys(screens) as K[]) {\n const s = screens[key];\n out[key] = createAxis(s.width, s.height);\n }\n return out;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAN,GAEA,MAAMO,EAASC,GAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKA,CAAG,CAAC,EAAI,IAEpDH,EAAYI,GAAmBD,GAC1C,KAAK,MAAMC,EAAQF,EAAMC,CAAG,CAAC,EAClBJ,EAAYM,GAAoBF,GAC3C,KAAK,MAAME,EAASH,EAAMC,CAAG,CAAC,EAEnBL,EAAa,CAACM,EAAeC,KAAoB,CAC5D,GAAIL,EAASI,CAAK,EAClB,GAAIL,EAASM,CAAM,EACnB,GAAI,CAACC,EAAeC,KAAmB,CACrC,EAAG,KAAK,MAAMH,EAAQF,EAAMI,CAAI,CAAC,EACjC,EAAG,KAAK,MAAMD,EAASH,EAAMK,CAAI,CAAC,CACpC,EACF,GAKaV,EACXW,GACe,CACf,MAAMC,EAAM,CAAC,EACb,UAAWC,KAAO,OAAO,KAAKF,CAAO,EAAU,CAC7C,MAAMG,EAAIH,EAAQE,CAAG,EACrBD,EAAIC,CAAG,EAAIZ,EAAWa,EAAE,MAAOA,EAAE,MAAM,CACzC,CACA,OAAOF,CACT",
6
+ "names": ["axisClamp_exports", "__export", "createAxes", "createAxis", "createVH", "createVW", "__toCommonJS", "clamp", "pct", "width", "height", "xPct", "yPct", "screens", "out", "key", "s"]
7
+ }
@@ -36,8 +36,10 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@sentry/minimal": "catalog:",
39
+ "axios": "catalog:",
40
+ "inversify": "catalog:",
39
41
  "purify-ts": "catalog:",
40
- "axios": "catalog:"
42
+ "reflect-metadata": "catalog:"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
@@ -1,2 +1,2 @@
1
- import o from"axios";class l{constructor(e,t={}){this.baseURL=e;const r=t.timeoutMs??1500,s=t.clientHeader??"ldmk-transport-speculos";this.buttonClient=o.create({baseURL:this.baseURL.replace(/\/+$/,""),timeout:r,headers:{"X-Ledger-Client-Version":s},transitional:{clarifyTimeoutError:!0}})}buttonClient;toEndpointKey(e){return{Ll:"left",Rr:"right",LRlr:"both",left:"left",right:"right",both:"both"}[e]??"right"}async press(e){const t=this.toEndpointKey(e);await this.buttonClient.post(`/button/${t}`,{action:"press-and-release"})}left(){return this.press("left")}right(){return this.press("right")}both(){return this.press("both")}async pressSequence(e,t=200){for(const r of e)await this.press(r),t>0&&await new Promise(s=>setTimeout(s,t))}}export{l as DeviceController};
1
+ import{DEFAULT_SCREENS as u}from"../internal/config/defaultScreens";import{pressButtons as m,pressSequence as a}from"../internal/usecases/buttonUsecases";import{tapLong as P,tapQuick as v}from"../internal/usecases/touchUsecases";import{speculosDeviceControllerTypes as s}from"../../src/internal/core/speculosDeviceControllerTypes";import{buildContainer as y}from"../../src/internal/di";function I(c,t={}){const p={screens:t.screens??u,timeoutMs:t.timeoutMs,clientHeader:t.clientHeader},n=y(c,p),o=n.get(s.ButtonController),r=m(o),i=n.get(s.TouchController);return{button:{press:e=>o.press(e),left:()=>r.left(),right:()=>r.right(),both:()=>r.both(),pressSequence:(e,l)=>a(o,e,l)},touch:{createTap:e=>({tapQuick:v(i,e),tapLong:P(i,e)})}}}export{I as deviceControllerFactory};
2
2
  //# sourceMappingURL=DeviceController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/DeviceController.ts"],
4
- "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\n\nexport type DeviceControllerOptions = {\n timeoutMs?: number;\n clientHeader?: string;\n};\n\nexport type SpeculosDeviceButtonsKeys =\n | \"Ll\"\n | \"Rr\"\n | \"LRlr\"\n | \"left\"\n | \"right\"\n | \"both\";\n\nexport class DeviceController {\n private readonly buttonClient: AxiosInstance;\n\n constructor(\n private readonly baseURL: string,\n opts: DeviceControllerOptions = {},\n ) {\n const timeoutMs = opts.timeoutMs ?? 1500;\n const clientHeader = opts.clientHeader ?? \"ldmk-transport-speculos\";\n\n this.buttonClient = axios.create({\n baseURL: this.baseURL.replace(/\\/+$/, \"\"),\n timeout: timeoutMs,\n headers: {\n \"X-Ledger-Client-Version\": clientHeader,\n },\n transitional: { clarifyTimeoutError: true },\n });\n }\n\n private toEndpointKey(\n but: SpeculosDeviceButtonsKeys,\n ): \"left\" | \"right\" | \"both\" {\n const map: Record<string, \"left\" | \"right\" | \"both\"> = {\n Ll: \"left\",\n Rr: \"right\",\n LRlr: \"both\",\n left: \"left\",\n right: \"right\",\n both: \"both\",\n };\n return map[but] ?? \"right\";\n }\n\n async press(but: SpeculosDeviceButtonsKeys): Promise<void> {\n const input = this.toEndpointKey(but);\n await this.buttonClient.post(`/button/${input}`, {\n action: \"press-and-release\",\n });\n }\n\n left() {\n return this.press(\"left\");\n }\n right() {\n return this.press(\"right\");\n }\n both() {\n return this.press(\"both\");\n }\n\n async pressSequence(\n keys: SpeculosDeviceButtonsKeys[],\n delayMs = 200,\n ): Promise<void> {\n for (const k of keys) {\n await this.press(k);\n if (delayMs > 0) {\n await new Promise((r) => setTimeout(r, delayMs));\n }\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAAmC,QAenC,MAAMC,CAAiB,CAG5B,YACmBC,EACjBC,EAAgC,CAAC,EACjC,CAFiB,aAAAD,EAGjB,MAAME,EAAYD,EAAK,WAAa,KAC9BE,EAAeF,EAAK,cAAgB,0BAE1C,KAAK,aAAeH,EAAM,OAAO,CAC/B,QAAS,KAAK,QAAQ,QAAQ,OAAQ,EAAE,EACxC,QAASI,EACT,QAAS,CACP,0BAA2BC,CAC7B,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,CACH,CAjBiB,aAmBT,cACNC,EAC2B,CAS3B,MARuD,CACrD,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,OACN,MAAO,QACP,KAAM,MACR,EACWA,CAAG,GAAK,OACrB,CAEA,MAAM,MAAMA,EAA+C,CACzD,MAAMC,EAAQ,KAAK,cAAcD,CAAG,EACpC,MAAM,KAAK,aAAa,KAAK,WAAWC,CAAK,GAAI,CAC/C,OAAQ,mBACV,CAAC,CACH,CAEA,MAAO,CACL,OAAO,KAAK,MAAM,MAAM,CAC1B,CACA,OAAQ,CACN,OAAO,KAAK,MAAM,OAAO,CAC3B,CACA,MAAO,CACL,OAAO,KAAK,MAAM,MAAM,CAC1B,CAEA,MAAM,cACJC,EACAC,EAAU,IACK,CACf,UAAWC,KAAKF,EACd,MAAM,KAAK,MAAME,CAAC,EACdD,EAAU,GACZ,MAAM,IAAI,QAASE,GAAM,WAAWA,EAAGF,CAAO,CAAC,CAGrD,CACF",
6
- "names": ["axios", "DeviceController", "baseURL", "opts", "timeoutMs", "clientHeader", "but", "input", "keys", "delayMs", "k", "r"]
4
+ "sourcesContent": ["import { DEFAULT_SCREENS } from \"@internal/config/defaultScreens\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type {\n ButtonKey,\n DeviceControllerOptions,\n DeviceScreens,\n PercentPoint,\n} from \"@internal/core/types\";\nimport { pressButtons, pressSequence } from \"@internal/usecases/buttonUsecases\";\nimport { tapLong, tapQuick } from \"@internal/usecases/touchUsecases\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\nimport { buildContainer } from \"@root/src/internal/di\";\n\nexport type ButtonAPI = IButtonController & {\n left(): Promise<void>;\n right(): Promise<void>;\n both(): Promise<void>;\n pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;\n};\n\nexport type TouchAPI = {\n createTap: (deviceKey: string) => {\n tapQuick: (point: PercentPoint) => Promise<void>;\n tapLong: (point: PercentPoint) => Promise<void>;\n };\n};\n\nexport type DeviceAPI = {\n button: ButtonAPI;\n touch: TouchAPI;\n};\n\ntype BaseOpts = {\n timeoutMs?: number;\n clientHeader?: string;\n screens?: DeviceScreens<string>;\n};\n\nexport function deviceControllerFactory(\n baseURL: string,\n opts: BaseOpts = {},\n): DeviceAPI {\n const resolved: DeviceControllerOptions<string> = {\n screens: opts.screens ?? DEFAULT_SCREENS,\n timeoutMs: opts.timeoutMs,\n clientHeader: opts.clientHeader,\n };\n\n const container = buildContainer<string>(baseURL, resolved);\n\n const buttons = container.get<IButtonController>(\n speculosDeviceControllerTypes.ButtonController,\n );\n const press = pressButtons(buttons);\n const touch = container.get<ITouchController<string>>(\n speculosDeviceControllerTypes.TouchController,\n );\n\n return {\n button: {\n press: (k) => buttons.press(k),\n left: () => press.left(),\n right: () => press.right(),\n both: () => press.both(),\n pressSequence: (keys, delayMs) => pressSequence(buttons, keys, delayMs),\n },\n touch: {\n createTap: (key) => ({\n tapQuick: tapQuick(touch, key),\n tapLong: tapLong(touch, key),\n }),\n },\n };\n}\n\nexport type { ButtonKey, DeviceControllerOptions, DeviceScreens, PercentPoint };\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAShC,OAAS,gBAAAC,EAAc,iBAAAC,MAAqB,oCAC5C,OAAS,WAAAC,EAAS,YAAAC,MAAgB,mCAClC,OAAS,iCAAAC,MAAqC,wDAC9C,OAAS,kBAAAC,MAAsB,wBA2BxB,SAASC,EACdC,EACAC,EAAiB,CAAC,EACP,CACX,MAAMC,EAA4C,CAChD,QAASD,EAAK,SAAWT,EACzB,UAAWS,EAAK,UAChB,aAAcA,EAAK,YACrB,EAEME,EAAYL,EAAuBE,EAASE,CAAQ,EAEpDE,EAAUD,EAAU,IACxBN,EAA8B,gBAChC,EACMQ,EAAQZ,EAAaW,CAAO,EAC5BE,EAAQH,EAAU,IACtBN,EAA8B,eAChC,EAEA,MAAO,CACL,OAAQ,CACN,MAAQU,GAAMH,EAAQ,MAAMG,CAAC,EAC7B,KAAM,IAAMF,EAAM,KAAK,EACvB,MAAO,IAAMA,EAAM,MAAM,EACzB,KAAM,IAAMA,EAAM,KAAK,EACvB,cAAe,CAACG,EAAMC,IAAYf,EAAcU,EAASI,EAAMC,CAAO,CACxE,EACA,MAAO,CACL,UAAYC,IAAS,CACnB,SAAUd,EAASU,EAAOI,CAAG,EAC7B,QAASf,EAAQW,EAAOI,CAAG,CAC7B,EACF,CACF,CACF",
6
+ "names": ["DEFAULT_SCREENS", "pressButtons", "pressSequence", "tapLong", "tapQuick", "speculosDeviceControllerTypes", "buildContainer", "deviceControllerFactory", "baseURL", "opts", "resolved", "container", "buttons", "press", "touch", "k", "keys", "delayMs", "key"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export*from"./api/DeviceController";
1
+ import"reflect-metadata";export*from"./api/DeviceController";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export * from \"./api/DeviceController\";\n"],
5
- "mappings": "AAAA,WAAc",
4
+ "sourcesContent": ["import \"reflect-metadata\";\n\nexport * from \"./api/DeviceController\";\n"],
5
+ "mappings": "AAAA,MAAO,mBAEP,WAAc",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=(n,t,e,r)=>{for(var o=r>1?void 0:r?m(t,e):t,p=n.length-1,s;p>=0;p--)(s=n[p])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&c(t,e,o),o},a=(n,t)=>(e,r)=>t(e,r,n);import{inject as y,injectable as h}from"inversify";import{speculosDeviceControllerTypes as f}from"../../../src/internal/core/speculosDeviceControllerTypes";let i=class{constructor(t){this.client=t}toEndpointKey(t){return{Ll:"left",Rr:"right",LRlr:"both",left:"left",right:"right",both:"both"}[t]}async press(t){const e=this.toEndpointKey(t);await this.client.post(`/button/${e}`,{action:"press-and-release"})}};i=l([h(),a(0,y(f.HttpClient))],i);export{i as AxiosButtonController};
2
+ //# sourceMappingURL=AxiosButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/AxiosButtonController.ts"],
4
+ "sourcesContent": ["import type { AxiosInstance } from \"axios\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ButtonKey } from \"@internal/core/types\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\n@injectable()\nexport class AxiosButtonController implements IButtonController {\n constructor(\n @inject(speculosDeviceControllerTypes.HttpClient)\n private readonly client: AxiosInstance,\n ) {}\n\n private toEndpointKey(but: ButtonKey): \"left\" | \"right\" | \"both\" {\n const map: Record<ButtonKey, \"left\" | \"right\" | \"both\"> = {\n Ll: \"left\",\n Rr: \"right\",\n LRlr: \"both\",\n left: \"left\",\n right: \"right\",\n both: \"both\",\n };\n return map[but];\n }\n\n async press(but: ButtonKey): Promise<void> {\n const input = this.toEndpointKey(but);\n await this.client.post(`/button/${input}`, { action: \"press-and-release\" });\n }\n}\n"],
5
+ "mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAInC,OAAS,iCAAAC,MAAqC,wDAGvC,IAAMC,EAAN,KAAyD,CAC9D,YAEmBC,EACjB,CADiB,YAAAA,CAChB,CAEK,cAAcC,EAA2C,CAS/D,MAR0D,CACxD,GAAI,OACJ,GAAI,QACJ,KAAM,OACN,KAAM,OACN,MAAO,QACP,KAAM,MACR,EACWA,CAAG,CAChB,CAEA,MAAM,MAAMA,EAA+B,CACzC,MAAMC,EAAQ,KAAK,cAAcD,CAAG,EACpC,MAAM,KAAK,OAAO,KAAK,WAAWC,CAAK,GAAI,CAAE,OAAQ,mBAAoB,CAAC,CAC5E,CACF,EAtBaH,EAANI,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAA8B,UAAU,IAFvCR",
6
+ "names": ["inject", "injectable", "speculosDeviceControllerTypes", "AxiosButtonController", "client", "but", "input", "__decorateClass", "injectable", "__decorateParam", "inject", "speculosDeviceControllerTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var P=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var p=(i,t,e,n)=>{for(var s=n>1?void 0:n?y(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(s=(n?a(t,e,s):a(s))||s);return n&&s&&P(t,e,s),s},c=(i,t)=>(e,n)=>t(e,n,i);import{inject as l,injectable as x}from"inversify";import{speculosDeviceControllerTypes as m}from"../../../src/internal/core/speculosDeviceControllerTypes";let r=class{constructor(t,e){this.client=t;this.axes=e}toAbs(t,e){const n=this.axes[t];if(!n){const s=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${t}". Known keys: ${s.join(", ")||"<none>"}`)}return n.xy(e.x,e.y)}async tapAndRelease(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"press-and-release",...n})}async tap(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"press",...n})}async release(t,e){const n=this.toAbs(t,e);await this.client.post("/finger",{action:"release",...n})}};r=p([x(),c(0,l(m.HttpClient)),c(1,l(m.Axes))],r);export{r as AxiosTouchController};
2
+ //# sourceMappingURL=AxiosTouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/AxiosTouchController.ts"],
4
+ "sourcesContent": ["import type { AxiosInstance } from \"axios\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type { Percent, PercentPoint } from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\n@injectable()\nexport class AxiosTouchController implements ITouchController<string> {\n constructor(\n @inject(speculosDeviceControllerTypes.HttpClient)\n private readonly client: AxiosInstance,\n @inject(speculosDeviceControllerTypes.Axes)\n private readonly axes: AxisMap<string>,\n ) {}\n\n private toAbs(deviceKey: string, p: PercentPoint) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes);\n throw new Error(\n `[Touch] Unknown device key \"${deviceKey}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n return axis.xy(p.x as Percent, p.y as Percent);\n }\n\n async tapAndRelease(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"press-and-release\",\n ...abs,\n });\n }\n\n async tap(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"press\",\n ...abs,\n });\n }\n\n async release(deviceKey: string, point: PercentPoint): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: \"release\",\n ...abs,\n });\n }\n}\n"],
5
+ "mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAKnC,OAAS,iCAAAC,MAAqC,wDAGvC,IAAMC,EAAN,KAA+D,CACpE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEK,MAAMC,EAAmBC,EAAiB,CAChD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAAI,EACnC,MAAM,IAAI,MACR,+BAA+BH,CAAS,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EACxF,CACF,CACA,OAAOD,EAAK,GAAGD,EAAE,EAAcA,EAAE,CAAY,CAC/C,CAEA,MAAM,cAAcD,EAAmBI,EAAoC,CACzE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,oBACR,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAmBI,EAAoC,CAC/D,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,QACR,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAmBI,EAAoC,CACnE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,UACR,GAAGC,CACL,CAAC,CACH,CACF,EA1CaR,EAANS,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAA8B,UAAU,GAE/CF,EAAA,EAAAC,EAAOC,EAA8B,IAAI,IAJjCb",
6
+ "names": ["inject", "injectable", "speculosDeviceControllerTypes", "AxiosTouchController", "client", "axes", "deviceKey", "p", "axis", "known", "point", "abs", "__decorateClass", "injectable", "__decorateParam", "inject", "speculosDeviceControllerTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const t={flex:{width:240,height:240},stax:{width:340,height:340}};export{t as DEFAULT_SCREENS};
2
+ //# sourceMappingURL=defaultScreens.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/config/defaultScreens.ts"],
4
+ "sourcesContent": ["export const DEFAULT_SCREENS = {\n flex: { width: 240, height: 240 },\n stax: { width: 340, height: 340 },\n} as const;\n\nexport type DefaultDeviceKey = keyof typeof DEFAULT_SCREENS & string;\n"],
5
+ "mappings": "AAAO,MAAMA,EAAkB,CAC7B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC",
6
+ "names": ["DEFAULT_SCREENS"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=IButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ITouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={HttpClient:Symbol.for("HttpClient"),ButtonController:Symbol.for("ButtonController"),TouchController:Symbol.for("TouchController"),Axes:Symbol.for("Axes")};export{o as speculosDeviceControllerTypes};
2
+ //# sourceMappingURL=speculosDeviceControllerTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/speculosDeviceControllerTypes.ts"],
4
+ "sourcesContent": ["export const speculosDeviceControllerTypes = {\n HttpClient: Symbol.for(\"HttpClient\"),\n ButtonController: Symbol.for(\"ButtonController\"),\n TouchController: Symbol.for(\"TouchController\"),\n Axes: Symbol.for(\"Axes\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAgC,CAC3C,WAAY,OAAO,IAAI,YAAY,EACnC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,KAAM,OAAO,IAAI,MAAM,CACzB",
6
+ "names": ["speculosDeviceControllerTypes"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import i from"axios";import{Container as l}from"inversify";import{AxiosButtonController as s}from"./adapters/AxiosButtonController";import{AxiosTouchController as a}from"./adapters/AxiosTouchController";import{createAxes as c}from"./utils/axisClamp";import{speculosDeviceControllerTypes as t}from"../../src/internal/core/speculosDeviceControllerTypes";function x(r,e){const o=new l({defaultScope:"Singleton"}),n=i.create({baseURL:r.replace(/\/+$/,""),timeout:e.timeoutMs??1500,headers:{"X-Ledger-Client-Version":e.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}});return o.bind(t.HttpClient).toConstantValue(n),o.bind(t.Axes).toConstantValue(c(e.screens)),o.bind(t.ButtonController).to(s),o.bind(t.TouchController).to(a),o}export{x as buildContainer};
2
+ //# sourceMappingURL=di.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/di.ts"],
4
+ "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\nimport { Container } from \"inversify\";\n\nimport { AxiosButtonController } from \"@internal/adapters/AxiosButtonController\";\nimport { AxiosTouchController } from \"@internal/adapters/AxiosTouchController\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type { DeviceControllerOptions } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\nexport function buildContainer<K extends string>(\n baseURL: string,\n opts: DeviceControllerOptions<K>,\n) {\n const container = new Container({ defaultScope: \"Singleton\" });\n\n const http = axios.create({\n baseURL: baseURL.replace(/\\/+$/, \"\"),\n timeout: opts.timeoutMs ?? 1500,\n headers: {\n \"X-Ledger-Client-Version\": opts.clientHeader ?? \"ldmk-transport-speculos\",\n },\n transitional: { clarifyTimeoutError: true },\n });\n\n container\n .bind<AxiosInstance>(speculosDeviceControllerTypes.HttpClient)\n .toConstantValue(http);\n container\n .bind<AxisMap<K>>(speculosDeviceControllerTypes.Axes)\n .toConstantValue(createAxes(opts.screens));\n\n container\n .bind<IButtonController>(speculosDeviceControllerTypes.ButtonController)\n .to(AxiosButtonController);\n container\n .bind<ITouchController<K>>(speculosDeviceControllerTypes.TouchController)\n .to(AxiosTouchController);\n\n return container;\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAmC,QAC1C,OAAS,aAAAC,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,2CACtC,OAAS,wBAAAC,MAA4B,0CAIrC,OAAuB,cAAAC,MAAkB,4BACzC,OAAS,iCAAAC,MAAqC,wDAEvC,SAASC,EACdC,EACAC,EACA,CACA,MAAMC,EAAY,IAAIR,EAAU,CAAE,aAAc,WAAY,CAAC,EAEvDS,EAAOV,EAAM,OAAO,CACxB,QAASO,EAAQ,QAAQ,OAAQ,EAAE,EACnC,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAED,OAAAC,EACG,KAAoBJ,EAA8B,UAAU,EAC5D,gBAAgBK,CAAI,EACvBD,EACG,KAAiBJ,EAA8B,IAAI,EACnD,gBAAgBD,EAAWI,EAAK,OAAO,CAAC,EAE3CC,EACG,KAAwBJ,EAA8B,gBAAgB,EACtE,GAAGH,CAAqB,EAC3BO,EACG,KAA0BJ,EAA8B,eAAe,EACvE,GAAGF,CAAoB,EAEnBM,CACT",
6
+ "names": ["axios", "Container", "AxiosButtonController", "AxiosTouchController", "createAxes", "speculosDeviceControllerTypes", "buildContainer", "baseURL", "opts", "container", "http"]
7
+ }
@@ -0,0 +1,2 @@
1
+ async function n(t,e,o=200){for(const r of e)await t.press(r),o>0&&await new Promise(i=>setTimeout(i,o))}function s(t){return{left:async()=>await t.press("left"),right:async()=>await t.press("right"),both:async()=>await t.press("both")}}export{s as pressButtons,n as pressSequence};
2
+ //# sourceMappingURL=buttonUsecases.js.map