@ledgerhq/speculos-device-controller 0.0.0-develop-20260428002525 → 0.0.0-develop-20260430002707

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 (47) hide show
  1. package/README.md +2 -2
  2. package/lib/cjs/package.json +2 -3
  3. package/lib/cjs/src/internal/adapters/DefaultButtonController.js +1 -1
  4. package/lib/cjs/src/internal/adapters/DefaultButtonController.js.map +2 -2
  5. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js +1 -1
  6. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js.map +3 -3
  7. package/lib/cjs/src/internal/adapters/DefaultTouchController.js +1 -1
  8. package/lib/cjs/src/internal/adapters/DefaultTouchController.js.map +2 -2
  9. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js +1 -1
  10. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js.map +3 -3
  11. package/lib/cjs/src/internal/core/types.js +1 -1
  12. package/lib/cjs/src/internal/core/types.js.map +2 -2
  13. package/lib/cjs/src/internal/di.js +1 -1
  14. package/lib/cjs/src/internal/di.js.map +3 -3
  15. package/lib/cjs/src/internal/di.test.js +1 -1
  16. package/lib/cjs/src/internal/di.test.js.map +3 -3
  17. package/lib/cjs/src/internal/use-cases/touchUseCases.js +1 -1
  18. package/lib/cjs/src/internal/use-cases/touchUseCases.js.map +3 -3
  19. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js +1 -1
  20. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js.map +3 -3
  21. package/lib/esm/package.json +2 -3
  22. package/lib/esm/src/internal/adapters/DefaultButtonController.js.map +2 -2
  23. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js +1 -1
  24. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js.map +3 -3
  25. package/lib/esm/src/internal/adapters/DefaultTouchController.js +1 -1
  26. package/lib/esm/src/internal/adapters/DefaultTouchController.js.map +2 -2
  27. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js +1 -1
  28. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js.map +3 -3
  29. package/lib/esm/src/internal/core/types.js.map +2 -2
  30. package/lib/esm/src/internal/di.js +1 -1
  31. package/lib/esm/src/internal/di.js.map +3 -3
  32. package/lib/esm/src/internal/di.test.js +1 -1
  33. package/lib/esm/src/internal/di.test.js.map +3 -3
  34. package/lib/esm/src/internal/use-cases/touchUseCases.js +1 -1
  35. package/lib/esm/src/internal/use-cases/touchUseCases.js.map +3 -3
  36. package/lib/esm/src/internal/use-cases/touchUseCases.test.js +1 -1
  37. package/lib/esm/src/internal/use-cases/touchUseCases.test.js.map +3 -3
  38. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts +2 -3
  39. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts.map +1 -1
  40. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts +2 -3
  41. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts.map +1 -1
  42. package/lib/types/src/internal/core/types.d.ts +3 -0
  43. package/lib/types/src/internal/core/types.d.ts.map +1 -1
  44. package/lib/types/src/internal/di.d.ts.map +1 -1
  45. package/lib/types/src/internal/use-cases/touchUseCases.d.ts.map +1 -1
  46. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  47. package/package.json +6 -7
package/README.md CHANGED
@@ -40,7 +40,7 @@ Under the hood, percentages are clamped to [0, 100] and converted to pixels usin
40
40
 
41
41
  ```ts
42
42
  const deviceClient = deviceControllerClientFactory("http://localhost:4000", {
43
- timeoutMs: 2000, // optional axios timeout
43
+ timeoutMs: 2000, // optional fetch timeout
44
44
  clientHeader: "ldmk-transport-speculos", // optional header
45
45
  screens: {
46
46
  // override by default keys
@@ -91,7 +91,7 @@ type DeviceControllerClient = {
91
91
  type DeviceControllerClientFactory = (
92
92
  baseURL: string,
93
93
  opts?: {
94
- timeoutMs?: number; // axios timeout (ms)
94
+ timeoutMs?: number; // fetch timeout (ms)
95
95
  clientHeader?: string; // "X-Ledger-Client-Version" header
96
96
  screens?: DeviceScreens<string>;
97
97
  },
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@ledgerhq/device-management-kit": "workspace:*",
4
- "@sentry/minimal": "catalog:",
5
- "axios": "catalog:"
4
+ "@sentry/minimal": "catalog:"
6
5
  },
7
6
  "devDependencies": {
8
7
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
@@ -53,5 +52,5 @@
53
52
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
54
53
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
55
54
  },
56
- "version": "0.0.0-develop-20260428002525"
55
+ "version": "0.0.0-develop-20260430002707"
57
56
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(o,t)=>{for(var e in t)r(o,e,{get:t[e],enumerable:!0})},u=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!c.call(o,n)&&n!==e&&r(o,n,{get:()=>t[n],enumerable:!(i=l(t,n))||i.enumerable});return o};var m=o=>u(r({},"__esModule",{value:!0}),o);var B={};p(B,{DefaultButtonController:()=>y});module.exports=m(B);var s=require("../core/types");class y{constructor(t){this.client=t}async press(t){await this.client.post(`/button/${t}`,{action:s.SpeculosActions.PRESS_AND_RELEASE})}}0&&(module.exports={DefaultButtonController});
1
+ "use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var n in t)r(o,n,{get:t[n],enumerable:!0})},a=(o,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of s(t))!c.call(o,e)&&e!==n&&r(o,e,{get:()=>t[e],enumerable:!(l=p(t,e))||l.enumerable});return o};var m=o=>a(r({},"__esModule",{value:!0}),o);var B={};u(B,{DefaultButtonController:()=>y});module.exports=m(B);var i=require("../core/types");class y{constructor(t){this.client=t}async press(t){await this.client.post(`/button/${t}`,{action:i.SpeculosActions.PRESS_AND_RELEASE})}}0&&(module.exports={DefaultButtonController});
2
2
  //# sourceMappingURL=DefaultButtonController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultButtonController.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport { type ButtonKey, SpeculosActions } from \"@internal/core/types\";\n\nexport class DefaultButtonController implements ButtonController {\n constructor(private readonly client: AxiosInstance) {}\n\n async press(key: ButtonKey): Promise<void> {\n await this.client.post(`/button/${key}`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAAgD,gCAEzC,MAAMF,CAAoD,CAC/D,YAA6BG,EAAuB,CAAvB,YAAAA,CAAwB,CAErD,MAAM,MAAMC,EAA+B,CACzC,MAAM,KAAK,OAAO,KAAK,WAAWA,CAAG,GAAI,CACvC,OAAQ,kBAAgB,iBAC1B,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import type { ButtonController } from \"@internal/core/ButtonController\";\nimport {\n type ButtonKey,\n type HttpClient,\n SpeculosActions,\n} from \"@internal/core/types\";\n\nexport class DefaultButtonController implements ButtonController {\n constructor(private readonly client: HttpClient) {}\n\n async press(key: ButtonKey): Promise<void> {\n await this.client.post(`/button/${key}`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAIO,gCAEA,MAAMF,CAAoD,CAC/D,YAA6BG,EAAoB,CAApB,YAAAA,CAAqB,CAElD,MAAM,MAAMC,EAA+B,CACzC,MAAM,KAAK,OAAO,KAAK,WAAWA,CAAG,GAAI,CACvC,OAAQ,kBAAgB,iBAC1B,CAAC,CACH,CACF",
6
6
  "names": ["DefaultButtonController_exports", "__export", "DefaultButtonController", "__toCommonJS", "import_types", "client", "key"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("./DefaultButtonController");describe("DefaultButtonController",()=>{let e,s,o;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o=new n.DefaultButtonController(s)});const a=["left","right","both"];it.each(a)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
1
+ "use strict";var r=require("./DefaultButtonController");describe("DefaultButtonController",()=>{let e,n,o;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),n={post:e},o=new r.DefaultButtonController(n)});const l=["left","right","both"];it.each(l)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
2
2
  //# sourceMappingURL=DefaultButtonController.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport type { ButtonKey } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let axiosFake: AxiosInstance;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue({ status: 200, data: {} });\n axiosFake = { post: postMock } as unknown as AxiosInstance;\n controller = new DefaultButtonController(axiosFake);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
5
- "mappings": "aAIA,IAAAA,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,CAAE,OAAQ,IAAK,KAAM,CAAC,CAAE,CAAC,EAC9DC,EAAY,CAAE,KAAMD,CAAS,EAC7BE,EAAa,IAAI,0BAAwBD,CAAS,CACpD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
6
- "names": ["import_DefaultButtonController", "postMock", "axiosFake", "controller", "keys", "key", "error"]
4
+ "sourcesContent": ["import type { ButtonKey, HttpClient } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n controller = new DefaultButtonController(httpClient);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAC9BE,EAAa,IAAI,0BAAwBD,CAAU,CACrD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
6
+ "names": ["import_DefaultButtonController", "postMock", "httpClient", "controller", "keys", "key", "error"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(s,t)=>{for(var e in t)r(s,e,{get:t[e],enumerable:!0})},h=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!l.call(s,n)&&n!==e&&r(s,n,{get:()=>t[n],enumerable:!(o=a(t,n))||o.enumerable});return s};var m=s=>h(r({},"__esModule",{value:!0}),s);var u={};p(u,{DefaultTouchController:()=>d});module.exports=m(u);var i=require("../core/types");class d{constructor(t,e){this.client=t;this.axes=e}assertPercentPoint({x:t,y:e}){const o=n=>Number.isFinite(n)&&n>=0&&n<=100;if(!o(t)||!o(e))throw new Error(`[Touch] percent values must be within 0\u2013100. Received x=${t}, y=${e}`)}toAbs(t,e){const o=this.axes[t];if(!o){const n=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${String(t)}". Known keys: ${n.join(", ")||"<none>"}`)}return this.assertPercentPoint(e),o.xy(e.x,e.y)}async tapAndRelease(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.PRESS_AND_RELEASE,...o})}async tap(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.PRESS,...o})}async release(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.RELEASE,...o})}}0&&(module.exports={DefaultTouchController});
1
+ "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(i,t)=>{for(var e in t)s(i,e,{get:t[e],enumerable:!0})},h=(i,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!l.call(i,n)&&n!==e&&s(i,n,{get:()=>t[n],enumerable:!(o=a(t,n))||o.enumerable});return i};var d=i=>h(s({},"__esModule",{value:!0}),i);var m={};p(m,{DefaultTouchController:()=>u});module.exports=d(m);var r=require("../core/types");class u{constructor(t,e){this.client=t;this.axes=e}assertPercentPoint({x:t,y:e}){const o=n=>Number.isFinite(n)&&n>=0&&n<=100;if(!o(t)||!o(e))throw new Error(`[Touch] percent values must be within 0\u2013100. Received x=${t}, y=${e}`)}toAbs(t,e){const o=this.axes[t];if(!o){const n=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${String(t)}". Known keys: ${n.join(", ")||"<none>"}`)}return this.assertPercentPoint(e),o.xy(e.x,e.y)}async tapAndRelease(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:r.SpeculosActions.PRESS_AND_RELEASE,...o})}async tap(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:r.SpeculosActions.PRESS,...o})}async release(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:r.SpeculosActions.RELEASE,...o})}}0&&(module.exports={DefaultTouchController});
2
2
  //# sourceMappingURL=DefaultTouchController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultTouchController.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport { type PercentCoordinates, SpeculosActions } from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport class DefaultTouchController<K extends string>\n implements TouchController<K>\n{\n constructor(\n private readonly client: AxiosInstance,\n private readonly axes: AxisMap<K>,\n ) {}\n\n private assertPercentPoint({ x, y }: PercentCoordinates): void {\n const inRange = (v: number) => Number.isFinite(v) && v >= 0 && v <= 100;\n if (!inRange(x) || !inRange(y)) {\n throw new Error(\n `[Touch] percent values must be within 0\u2013100. Received x=${x}, y=${y}`,\n );\n }\n }\n\n private toAbs(deviceKey: K, p: PercentCoordinates) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes as Record<string, unknown>);\n throw new Error(\n `[Touch] Unknown device key \"${String(deviceKey)}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n this.assertPercentPoint(p);\n return axis.xy(p.x, p.y);\n }\n\n async tapAndRelease(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n ...abs,\n });\n }\n\n async tap(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS,\n ...abs,\n });\n }\n\n async release(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.RELEASE,\n ...abs,\n });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAyD,gCAIlD,MAAMF,CAEb,CACE,YACmBG,EACAC,EACjB,CAFiB,YAAAD,EACA,UAAAC,CAChB,CAEK,mBAAmB,CAAE,EAAAC,EAAG,EAAAC,CAAE,EAA6B,CAC7D,MAAMC,EAAWC,GAAc,OAAO,SAASA,CAAC,GAAKA,GAAK,GAAKA,GAAK,IACpE,GAAI,CAACD,EAAQF,CAAC,GAAK,CAACE,EAAQD,CAAC,EAC3B,MAAM,IAAI,MACR,gEAA2DD,CAAC,OAAOC,CAAC,EACtE,CAEJ,CAEQ,MAAMG,EAAcC,EAAuB,CACjD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAA+B,EAC9D,MAAM,IAAI,MACR,+BAA+B,OAAOH,CAAS,CAAC,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EAChG,CACF,CACA,YAAK,mBAAmBF,CAAC,EAClBC,EAAK,GAAGD,EAAE,EAAGA,EAAE,CAAC,CACzB,CAEA,MAAM,cAAcD,EAAcI,EAA0C,CAC1E,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,kBACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAcI,EAA0C,CAChE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,MACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAcI,EAA0C,CACpE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,QACxB,GAAGC,CACL,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import {\n type HttpClient,\n type PercentCoordinates,\n SpeculosActions,\n} from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport class DefaultTouchController<K extends string>\n implements TouchController<K>\n{\n constructor(\n private readonly client: HttpClient,\n private readonly axes: AxisMap<K>,\n ) {}\n\n private assertPercentPoint({ x, y }: PercentCoordinates): void {\n const inRange = (v: number) => Number.isFinite(v) && v >= 0 && v <= 100;\n if (!inRange(x) || !inRange(y)) {\n throw new Error(\n `[Touch] percent values must be within 0\u2013100. Received x=${x}, y=${y}`,\n );\n }\n }\n\n private toAbs(deviceKey: K, p: PercentCoordinates) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes as Record<string, unknown>);\n throw new Error(\n `[Touch] Unknown device key \"${String(deviceKey)}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n this.assertPercentPoint(p);\n return axis.xy(p.x, p.y);\n }\n\n async tapAndRelease(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n ...abs,\n });\n }\n\n async tap(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS,\n ...abs,\n });\n }\n\n async release(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.RELEASE,\n ...abs,\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,gCAIA,MAAMF,CAEb,CACE,YACmBG,EACAC,EACjB,CAFiB,YAAAD,EACA,UAAAC,CAChB,CAEK,mBAAmB,CAAE,EAAAC,EAAG,EAAAC,CAAE,EAA6B,CAC7D,MAAMC,EAAWC,GAAc,OAAO,SAASA,CAAC,GAAKA,GAAK,GAAKA,GAAK,IACpE,GAAI,CAACD,EAAQF,CAAC,GAAK,CAACE,EAAQD,CAAC,EAC3B,MAAM,IAAI,MACR,gEAA2DD,CAAC,OAAOC,CAAC,EACtE,CAEJ,CAEQ,MAAMG,EAAcC,EAAuB,CACjD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAA+B,EAC9D,MAAM,IAAI,MACR,+BAA+B,OAAOH,CAAS,CAAC,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EAChG,CACF,CACA,YAAK,mBAAmBF,CAAC,EAClBC,EAAK,GAAGD,EAAE,EAAGA,EAAE,CAAC,CACzB,CAEA,MAAM,cAAcD,EAAcI,EAA0C,CAC1E,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,kBACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAcI,EAA0C,CAChE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,MACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAcI,EAA0C,CACpE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,QACxB,GAAGC,CACL,CAAC,CACH,CACF",
6
6
  "names": ["DefaultTouchController_exports", "__export", "DefaultTouchController", "__toCommonJS", "import_types", "client", "axes", "x", "y", "inRange", "v", "deviceKey", "p", "axis", "known", "point", "abs"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=require("./DefaultTouchController");describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((n,i)=>({x:Math.round(n*10),y:Math.round(i*20)}))},r={xy:vi.fn((n,i)=>({x:Math.round(100+n),y:Math.round(200+i)}))};let c,a;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},a=new l.DefaultTouchController(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await a.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...n})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await a.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const n=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...n})}),it("release: converts via axes and POSTs action 'release'",async()=>{await a.release("devA",t);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...n})}),it("throws an error when device key is unknown",async()=>{await expect(a.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors from axios client",async()=>{const n=new Error("backend down");e.mockRejectedValueOnce(n),await expect(a.tapAndRelease("devA",t)).rejects.toBe(n)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((a,t)=>({x:a,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue({status:200,data:{}}),o={post:s},r.xy.mockClear(),e=new l.DefaultTouchController(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const a=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of a)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const a=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of a)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
1
+ "use strict";var l=require("./DefaultTouchController");describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((a,i)=>({x:Math.round(a*10),y:Math.round(i*20)}))},r={xy:vi.fn((a,i)=>({x:Math.round(100+a),y:Math.round(200+i)}))};let c,n;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},n=new l.DefaultTouchController(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await n.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...a})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await n.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const a=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...a})}),it("release: converts via axes and POSTs action 'release'",async()=>{await n.release("devA",t);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...a})}),it("throws an error when device key is unknown",async()=>{await expect(n.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors",async()=>{const a=new Error("backend down");e.mockRejectedValueOnce(a),await expect(n.tapAndRelease("devA",t)).rejects.toBe(a)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((n,t)=>({x:n,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue(void 0),o={post:s},r.xy.mockClear(),e=new l.DefaultTouchController(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const n=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of n)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const n=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of n)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
2
2
  //# sourceMappingURL=DefaultTouchController.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultTouchController.test.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport type { AxiosInstance } from \"axios\";\n\nimport type { PercentCoordinates } from \"../core/types\";\nimport { DefaultTouchController } from \"./DefaultTouchController\";\n\ndescribe(\"DefaultTouchController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let axiosFake: AxiosInstance;\n\n const axisA = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(xPct * 10),\n y: Math.round(yPct * 20),\n })),\n };\n const axisB = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(100 + xPct),\n y: Math.round(200 + yPct),\n })),\n };\n let axesFake: Record<\n string,\n { xy: (x: number, y: number) => { x: number; y: number } }\n >;\n\n let controller: DefaultTouchController<string>;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue({ status: 200, data: {} });\n axiosFake = { post: postMock } as unknown as AxiosInstance;\n\n axisA.xy.mockClear();\n axisB.xy.mockClear();\n\n axesFake = { devA: axisA, devB: axisB };\n controller = new DefaultTouchController(axiosFake, axesFake as any);\n });\n\n const point: PercentCoordinates = { x: 12, y: 45 };\n\n it(\"tapAndRelease: converts percent to absolute via axes and POSTs expected body\", async () => {\n await controller.tapAndRelease(\"devA\", point);\n\n expect(axisA.xy).toHaveBeenCalledTimes(1);\n expect(axisA.xy).toHaveBeenCalledWith(point.x, point.y);\n\n const expectedAbs = (axisA.xy.mock.results as any)[0].value;\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press-and-release\",\n ...expectedAbs,\n });\n });\n\n it(\"tap: converts via axes and POSTs action 'press'\", async () => {\n await controller.tap(\"devB\", point);\n\n expect(axisB.xy).toHaveBeenCalledWith(point.x, point.y);\n const expectedAbs = axisB.xy.mock.results[0]?.value;\n\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press\",\n ...expectedAbs,\n });\n });\n\n it(\"release: converts via axes and POSTs action 'release'\", async () => {\n await controller.release(\"devA\", point);\n\n const expectedAbs = axisA.xy.mock.results[0]!.value;\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"release\",\n ...expectedAbs,\n });\n });\n\n it(\"throws an error when device key is unknown\", async () => {\n await expect(controller.tap(\"unknownDevice\" as any, point)).rejects.toThrow(\n /\\[Touch] Unknown device key \"unknownDevice\".*Known keys: devA, devB/,\n );\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"propagates HTTP errors from axios client\", async () => {\n const boom = new Error(\"backend down\");\n postMock.mockRejectedValueOnce(boom);\n\n await expect(controller.tapAndRelease(\"devA\", point)).rejects.toBe(boom);\n });\n});\n\ndescribe(\"percent validation\", () => {\n let controller: DefaultTouchController<string>;\n let postMock: ReturnType<typeof vi.fn>;\n let axiosFake: AxiosInstance;\n\n const axis = {\n xy: vi.fn((xPct: number, yPct: number) => ({ x: xPct, y: yPct })),\n };\n const axesFake = { devA: axis };\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue({ status: 200, data: {} });\n axiosFake = { post: postMock } as unknown as AxiosInstance;\n axis.xy.mockClear();\n controller = new DefaultTouchController(axiosFake, axesFake as any);\n });\n\n it(\"accepts boundary values 0 and 100\", async () => {\n await controller.tapAndRelease(\"devA\", { x: 0, y: 100 });\n await controller.tap(\"devA\", { x: 100, y: 0 });\n await controller.release(\"devA\", { x: 50, y: 99 });\n\n // should have sent 3 HTTP calls if all accepted\n expect(postMock).toHaveBeenCalledTimes(3);\n });\n\n it(\"rejects values outside [0, 100], non-finite, negative and non-integer\", async () => {\n const badPoints = [\n { x: 140, y: 50 },\n { x: -1, y: 50 },\n { x: 50, y: 120 },\n { x: 50, y: -0.01 },\n ];\n\n for (const p of badPoints) {\n await expect(\n controller.tapAndRelease(\"devA\", p as any),\n ).rejects.toThrow();\n }\n\n // no HTTP calls should be made for invalid input\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"rejects NaN or non-finite values\", async () => {\n const badPoints = [\n { x: Number.NaN, y: 50 },\n { x: 50, y: Number.NaN },\n { x: Number.POSITIVE_INFINITY, y: 10 },\n { x: 10, y: Number.NEGATIVE_INFINITY },\n ];\n\n for (const p of badPoints) {\n await expect(controller.tap(\"devA\", p as any)).rejects.toThrow(\n /percent/i,\n );\n }\n expect(postMock).not.toHaveBeenCalled();\n });\n});\n"],
5
- "mappings": "aAOA,IAAAA,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EAEJ,MAAMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACC,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAMD,EAAO,EAAE,EACvB,EAAG,KAAK,MAAMC,EAAO,EAAE,CACzB,EAAE,CACJ,EACMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACF,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAM,IAAMD,CAAI,EACxB,EAAG,KAAK,MAAM,IAAMC,CAAI,CAC1B,EAAE,CACJ,EACA,IAAIE,EAKAC,EAEJ,WAAW,IAAM,CACfP,EAAW,GAAG,GAAG,EAAE,kBAAkB,CAAE,OAAQ,IAAK,KAAM,CAAC,CAAE,CAAC,EAC9DC,EAAY,CAAE,KAAMD,CAAS,EAE7BE,EAAM,GAAG,UAAU,EACnBG,EAAM,GAAG,UAAU,EAEnBC,EAAW,CAAE,KAAMJ,EAAO,KAAMG,CAAM,EACtCE,EAAa,IAAI,yBAAuBN,EAAWK,CAAe,CACpE,CAAC,EAED,MAAME,EAA4B,CAAE,EAAG,GA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OAAO,iBAAkB,CACvC,EAEA,UAAWC,KAAKD,EACd,MAAM,OAAOL,EAAW,IAAI,OAAQM,CAAQ,CAAC,EAAE,QAAQ,QACrD,UACF,EAEF,OAAOb,CAAQ,EAAE,IAAI,iBAAiB,CACxC,CAAC,CACH,CAAC",
6
- "names": ["import_DefaultTouchController", "postMock", "axiosFake", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport type { HttpClient, PercentCoordinates } from \"../core/types\";\nimport { DefaultTouchController } from \"./DefaultTouchController\";\n\ndescribe(\"DefaultTouchController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axisA = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(xPct * 10),\n y: Math.round(yPct * 20),\n })),\n };\n const axisB = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(100 + xPct),\n y: Math.round(200 + yPct),\n })),\n };\n let axesFake: Record<\n string,\n { xy: (x: number, y: number) => { x: number; y: number } }\n >;\n\n let controller: DefaultTouchController<string>;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n\n axisA.xy.mockClear();\n axisB.xy.mockClear();\n\n axesFake = { devA: axisA, devB: axisB };\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n const point: PercentCoordinates = { x: 12, y: 45 };\n\n it(\"tapAndRelease: converts percent to absolute via axes and POSTs expected body\", async () => {\n await controller.tapAndRelease(\"devA\", point);\n\n expect(axisA.xy).toHaveBeenCalledTimes(1);\n expect(axisA.xy).toHaveBeenCalledWith(point.x, point.y);\n\n const expectedAbs = (axisA.xy.mock.results as any)[0].value;\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press-and-release\",\n ...expectedAbs,\n });\n });\n\n it(\"tap: converts via axes and POSTs action 'press'\", async () => {\n await controller.tap(\"devB\", point);\n\n expect(axisB.xy).toHaveBeenCalledWith(point.x, point.y);\n const expectedAbs = axisB.xy.mock.results[0]?.value;\n\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press\",\n ...expectedAbs,\n });\n });\n\n it(\"release: converts via axes and POSTs action 'release'\", async () => {\n await controller.release(\"devA\", point);\n\n const expectedAbs = axisA.xy.mock.results[0]!.value;\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"release\",\n ...expectedAbs,\n });\n });\n\n it(\"throws an error when device key is unknown\", async () => {\n await expect(controller.tap(\"unknownDevice\" as any, point)).rejects.toThrow(\n /\\[Touch] Unknown device key \"unknownDevice\".*Known keys: devA, devB/,\n );\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"propagates HTTP errors\", async () => {\n const boom = new Error(\"backend down\");\n postMock.mockRejectedValueOnce(boom);\n\n await expect(controller.tapAndRelease(\"devA\", point)).rejects.toBe(boom);\n });\n});\n\ndescribe(\"percent validation\", () => {\n let controller: DefaultTouchController<string>;\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axis = {\n xy: vi.fn((xPct: number, yPct: number) => ({ x: xPct, y: yPct })),\n };\n const axesFake = { devA: axis };\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n axis.xy.mockClear();\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n it(\"accepts boundary values 0 and 100\", async () => {\n await controller.tapAndRelease(\"devA\", { x: 0, y: 100 });\n await controller.tap(\"devA\", { x: 100, y: 0 });\n await controller.release(\"devA\", { x: 50, y: 99 });\n\n // should have sent 3 HTTP calls if all accepted\n expect(postMock).toHaveBeenCalledTimes(3);\n });\n\n it(\"rejects values outside [0, 100], non-finite, negative and non-integer\", async () => {\n const badPoints = [\n { x: 140, y: 50 },\n { x: -1, y: 50 },\n { x: 50, y: 120 },\n { x: 50, y: -0.01 },\n ];\n\n for (const p of badPoints) {\n await expect(\n controller.tapAndRelease(\"devA\", p as any),\n ).rejects.toThrow();\n }\n\n // no HTTP calls should be made for invalid input\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"rejects NaN or non-finite values\", async () => {\n const badPoints = [\n { x: Number.NaN, y: 50 },\n { x: 50, y: Number.NaN },\n { x: Number.POSITIVE_INFINITY, y: 10 },\n { x: 10, y: Number.NEGATIVE_INFINITY },\n ];\n\n for (const p of badPoints) {\n await expect(controller.tap(\"devA\", p as any)).rejects.toThrow(\n /percent/i,\n );\n }\n expect(postMock).not.toHaveBeenCalled();\n });\n});\n"],
5
+ "mappings": "aAKA,IAAAA,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EAEJ,MAAMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACC,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAMD,EAAO,EAAE,EACvB,EAAG,KAAK,MAAMC,EAAO,EAAE,CACzB,EAAE,CACJ,EACMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACF,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAM,IAAMD,CAAI,EACxB,EAAG,KAAK,MAAM,IAAMC,CAAI,CAC1B,EAAE,CACJ,EACA,IAAIE,EAKAC,EAEJ,WAAW,IAAM,CACfP,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAE9BE,EAAM,GAAG,UAAU,EACnBG,EAAM,GAAG,UAAU,EAEnBC,EAAW,CAAE,KAAMJ,EAAO,KAAMG,CAAM,EACtCE,EAAa,IAAI,yBAAuBN,EAAYK,CAAe,CACrE,CAAC,EAED,MAAME,EAA4B,CAAE,EAAG,GAAI,EAAG,EAAG,EAEjD,GAAG,+EAAgF,SAAY,CAC7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CAAC,EAAE,QAAQ,QACrD,UACF,EAEF,OAAOb,CAAQ,EAAE,IAAI,iBAAiB,CACxC,CAAC,CACH,CAAC",
6
+ "names": ["import_DefaultTouchController", "postMock", "httpClient", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var c in e)p(t,c,{get:e[c],enumerable:!0})},i=(t,e,c,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!d.call(t,n)&&n!==c&&p(t,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return t};var y=t=>i(p({},"__esModule",{value:!0}),t);var a={};g(a,{SpeculosActions:()=>s});module.exports=y(a);var s=(r=>(r.PRESS="press",r.RELEASE="release",r.PRESS_AND_RELEASE="press-and-release",r))(s||{});0&&(module.exports={SpeculosActions});
1
+ "use strict";var p=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var a=(t,e)=>{for(var c in e)p(t,c,{get:e[c],enumerable:!0})},d=(t,e,c,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of i(e))!x.call(t,r)&&r!==c&&p(t,r,{get:()=>e[r],enumerable:!(n=o(e,r))||n.enumerable});return t};var g=t=>d(p({},"__esModule",{value:!0}),t);var y={};a(y,{SpeculosActions:()=>s});module.exports=g(y);var s=(n=>(n.PRESS="press",n.RELEASE="release",n.PRESS_AND_RELEASE="press-and-release",n))(s||{});0&&(module.exports={SpeculosActions});
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/core/types.ts"],
4
- "sourcesContent": ["export type ButtonKey = \"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 PercentCoordinates = { x: Percent; y: Percent };\n\nexport type DeviceControllerOptions<K extends string = string> = {\n screens: DeviceScreens<K>;\n timeoutMs?: number;\n clientHeader?: string;\n};\n\nexport enum SpeculosActions {\n PRESS = \"press\",\n RELEASE = \"release\",\n PRESS_AND_RELEASE = \"press-and-release\",\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAsBO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBAHVA,OAAA",
4
+ "sourcesContent": ["export type ButtonKey = \"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 PercentCoordinates = { x: Percent; y: Percent };\n\nexport type DeviceControllerOptions<K extends string = string> = {\n screens: DeviceScreens<K>;\n timeoutMs?: number;\n clientHeader?: string;\n};\n\nexport interface HttpClient {\n post(url: string, data?: unknown): Promise<unknown>;\n}\n\nexport enum SpeculosActions {\n PRESS = \"press\",\n RELEASE = \"release\",\n PRESS_AND_RELEASE = \"press-and-release\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GA0BO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBAHVA,OAAA",
6
6
  "names": ["types_exports", "__export", "SpeculosActions", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var r in t)l(o,r,{get:t[r],enumerable:!0})},i=(o,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of f(t))!x.call(o,e)&&e!==r&&l(o,e,{get:()=>t[e],enumerable:!(n=C(t,e))||n.enumerable});return o};var T=(o,t,r)=>(r=o!=null?m(h(o)):{},i(t||!o||!o.__esModule?l(r,"default",{value:o,enumerable:!0}):r,o)),A=o=>i(l({},"__esModule",{value:!0}),o);var D={};y(D,{createDefaultControllers:()=>B});module.exports=A(D);var s=T(require("axios")),c=require("./adapters/DefaultButtonController"),a=require("./adapters/DefaultTouchController"),u=require("./utils/axisClamp");function B(o,t){const r=s.default.create({baseURL:o,timeout:t.timeoutMs??1500,headers:{"X-Ledger-Client-Version":t.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}}),n=(0,u.createAxes)(t.screens),e=new c.DefaultButtonController(r),p=new a.DefaultTouchController(r,n);return{buttons:e,touch:p}}0&&(module.exports={createDefaultControllers});
1
+ "use strict";var l=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var x=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},D=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!w.call(o,r)&&r!==e&&l(o,r,{get:()=>t[r],enumerable:!(n=h(t,r))||n.enumerable});return o};var k=o=>D(l({},"__esModule",{value:!0}),o);var T={};x(T,{createDefaultControllers:()=>B});module.exports=k(T);var s=require("@ledgerhq/device-management-kit"),i=require("./adapters/DefaultButtonController"),c=require("./adapters/DefaultTouchController"),u=require("./utils/axisClamp");function B(o,t){const e=t.timeoutMs??1500,n=new s.DmkNetworkClient({baseUrl:o,headers:{"X-Ledger-Client-Version":t.clientHeader??"ldmk-transport-speculos"}}),r={async post(a,f){return n.post(a,f,{timeoutMs:e})}},p=(0,u.createAxes)(t.screens),C=new i.DefaultButtonController(r),m=new c.DefaultTouchController(r,p);return{buttons:C,touch:m}}0&&(module.exports={createDefaultControllers});
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/di.ts"],
4
- "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport type { DeviceControllerOptions } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport type ControllersContainer = {\n buttons: ButtonController;\n touch: TouchController;\n};\n\nexport function createDefaultControllers(\n baseURL: string,\n opts: DeviceControllerOptions,\n): ControllersContainer {\n const http: AxiosInstance = axios.create({\n baseURL: baseURL,\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 const axes: AxisMap = createAxes(opts.screens);\n\n const buttons: ButtonController = new DefaultButtonController(http);\n const touch: TouchController = new DefaultTouchController(http, axes);\n\n return { buttons, touch };\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,oBAE1CC,EAAwC,sDACxCC,EAAuC,qDAGvCC,EAAyC,qCAQlC,SAASL,EACdM,EACAC,EACsB,CACtB,MAAMC,EAAsB,EAAAC,QAAM,OAAO,CACvC,QAASH,EACT,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAEKG,KAAgB,cAAWH,EAAK,OAAO,EAEvCI,EAA4B,IAAI,0BAAwBH,CAAI,EAC5DI,EAAyB,IAAI,yBAAuBJ,EAAME,CAAI,EAEpE,MAAO,CAAE,QAAAC,EAAS,MAAAC,CAAM,CAC1B",
6
- "names": ["di_exports", "__export", "createDefaultControllers", "__toCommonJS", "import_axios", "import_DefaultButtonController", "import_DefaultTouchController", "import_axisClamp", "baseURL", "opts", "http", "axios", "axes", "buttons", "touch"]
4
+ "sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport type { DeviceControllerOptions, HttpClient } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport type ControllersContainer = {\n buttons: ButtonController;\n touch: TouchController;\n};\n\nexport function createDefaultControllers(\n baseURL: string,\n opts: DeviceControllerOptions,\n): ControllersContainer {\n const timeoutMs = opts.timeoutMs ?? 1500;\n const client = new DmkNetworkClient({\n baseUrl: baseURL,\n headers: {\n \"X-Ledger-Client-Version\": opts.clientHeader ?? \"ldmk-transport-speculos\",\n },\n });\n\n const http: HttpClient = {\n async post(url: string, data?: unknown): Promise<unknown> {\n return client.post(url, data, { timeoutMs });\n },\n };\n\n const axes: AxisMap = createAxes(opts.screens);\n\n const buttons: ButtonController = new DefaultButtonController(http);\n const touch: TouchController = new DefaultTouchController(http, axes);\n\n return { buttons, touch };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiC,2CAEjCC,EAAwC,sDACxCC,EAAuC,qDAGvCC,EAAyC,qCAQlC,SAASL,EACdM,EACAC,EACsB,CACtB,MAAMC,EAAYD,EAAK,WAAa,KAC9BE,EAAS,IAAI,mBAAiB,CAClC,QAASH,EACT,QAAS,CACP,0BAA2BC,EAAK,cAAgB,yBAClD,CACF,CAAC,EAEKG,EAAmB,CACvB,MAAM,KAAKC,EAAaC,EAAkC,CACxD,OAAOH,EAAO,KAAKE,EAAKC,EAAM,CAAE,UAAAJ,CAAU,CAAC,CAC7C,CACF,EAEMK,KAAgB,cAAWN,EAAK,OAAO,EAEvCO,EAA4B,IAAI,0BAAwBJ,CAAI,EAC5DK,EAAyB,IAAI,yBAAuBL,EAAMG,CAAI,EAEpE,MAAO,CAAE,QAAAC,EAAS,MAAAC,CAAM,CAC1B",
6
+ "names": ["di_exports", "__export", "createDefaultControllers", "__toCommonJS", "import_device_management_kit", "import_DefaultButtonController", "import_DefaultTouchController", "import_axisClamp", "baseURL", "opts", "timeoutMs", "client", "http", "url", "data", "axes", "buttons", "touch"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var x=(o,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of h(t))!y.call(o,c)&&c!==n&&i(o,c,{get:()=>t[c],enumerable:!(l=f(t,c))||l.enumerable});return o};var B=(o,t,n)=>(n=o!=null?m(d(o)):{},x(t||!o||!o.__esModule?i(n,"default",{value:o,enumerable:!0}):n,o));var r=B(require("axios")),e=require("vitest"),p=require("./adapters/DefaultButtonController"),u=require("./adapters/DefaultTouchController"),s=require("./di");const a={flex:{width:128,height:64},stax:{width:400,height:672}};(0,e.afterEach)(()=>{e.vi.restoreAllMocks()});(0,e.describe)("createDefaultControllers - axios configuration",()=>{(0,e.it)("configures axios with normalised baseURL, custom timeout and header",()=>{const o=e.vi.spyOn(r.default,"create").mockImplementation(n=>({post:e.vi.fn(),defaults:{...n}}));(0,s.createDefaultControllers)("http://example.com/api",{screens:a,timeoutMs:2345,clientHeader:"test-client"}),(0,e.expect)(o).toHaveBeenCalledTimes(1);const t=o.mock.calls[0][0];(0,e.expect)(t.baseURL).toBe("http://example.com/api"),(0,e.expect)(t.timeout).toBe(2345),(0,e.expect)(t.headers?.["X-Ledger-Client-Version"]).toBe("test-client"),(0,e.expect)(t.transitional?.clarifyTimeoutError).toBe(!0)}),(0,e.it)("applies default timeout and client header when not provided",()=>{const o=e.vi.spyOn(r.default,"create").mockImplementation(n=>({post:e.vi.fn(),defaults:{...n}}));(0,s.createDefaultControllers)("http://localhost:1234",{screens:a});const t=o.mock.calls[0][0];(0,e.expect)(t.baseURL).toBe("http://localhost:1234"),(0,e.expect)(t.timeout).toBe(1500),(0,e.expect)(t.headers?.["X-Ledger-Client-Version"]).toBe("ldmk-transport-speculos")})});(0,e.describe)("createDefaultControllers - wiring",()=>{(0,e.it)("returns axios implementations wired by the factory",()=>{const o={post:e.vi.fn()};e.vi.spyOn(r.default,"create").mockReturnValue(o);const{buttons:t,touch:n}=(0,s.createDefaultControllers)("http://x",{screens:a});(0,e.expect)(t).toBeInstanceOf(p.DefaultButtonController),(0,e.expect)(n).toBeInstanceOf(u.DefaultTouchController),(0,e.expect)(typeof t.press).toBe("function")}),(0,e.it)("creates fresh instances per invocation",()=>{e.vi.spyOn(r.default,"create").mockReturnValueOnce({post:e.vi.fn()}).mockReturnValueOnce({post:e.vi.fn()});const o=(0,s.createDefaultControllers)("http://x",{screens:a}),t=(0,s.createDefaultControllers)("http://x",{screens:a});(0,e.expect)(o.buttons).not.toBe(t.buttons),(0,e.expect)(o.touch).not.toBe(t.touch)}),(0,e.it)("button.press posts the correct payload",async()=>{const o=e.vi.fn().mockResolvedValue(void 0);e.vi.spyOn(r.default,"create").mockReturnValue({post:o});const{buttons:t}=(0,s.createDefaultControllers)("http://x",{screens:a});await t.press("left"),(0,e.expect)(o).toHaveBeenCalledWith("/button/left",{action:"press-and-release"})}),(0,e.it)("touch.tapAndRelease maps percent to absolute coords",async()=>{const o=e.vi.fn().mockResolvedValue(void 0);e.vi.spyOn(r.default,"create").mockReturnValue({post:o});const{touch:t}=(0,s.createDefaultControllers)("http://x",{screens:a});await t.tapAndRelease("flex",{x:50,y:50}),(0,e.expect)(o).toHaveBeenCalledWith("/finger",{action:"press-and-release",x:64,y:32})})});
1
+ "use strict";var e=require("vitest"),a=require("./adapters/DefaultButtonController"),c=require("./adapters/DefaultTouchController"),n=require("./di");const s={flex:{width:128,height:64},stax:{width:400,height:672}};(0,e.afterEach)(()=>{e.vi.restoreAllMocks()});(0,e.describe)("createDefaultControllers - fetch configuration",()=>{(0,e.it)("configures with custom timeout and header",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,n.createDefaultControllers)("https://example.com/api",{screens:s,timeoutMs:2345,clientHeader:"test-client"});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledTimes(1),(0,e.expect)(t).toHaveBeenCalledWith(e.expect.objectContaining({href:"https://example.com/api/button/left"}),e.expect.objectContaining({method:"POST",headers:e.expect.objectContaining({"X-Ledger-Client-Version":"test-client"})}))}),(0,e.it)("applies default timeout and client header when not provided",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,n.createDefaultControllers)("https://localhost:1234",{screens:s});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledWith(e.expect.objectContaining({href:"https://localhost:1234/button/left"}),e.expect.objectContaining({method:"POST",headers:e.expect.objectContaining({"X-Ledger-Client-Version":"ldmk-transport-speculos"})}))})});(0,e.describe)("createDefaultControllers - wiring",()=>{(0,e.it)("returns correct controller implementations",()=>{const{buttons:t,touch:o}=(0,n.createDefaultControllers)("https://x",{screens:s});(0,e.expect)(t).toBeInstanceOf(a.DefaultButtonController),(0,e.expect)(o).toBeInstanceOf(c.DefaultTouchController),(0,e.expect)(typeof t.press).toBe("function")}),(0,e.it)("creates fresh instances per invocation",()=>{const t=(0,n.createDefaultControllers)("https://x",{screens:s}),o=(0,n.createDefaultControllers)("https://x",{screens:s});(0,e.expect)(t.buttons).not.toBe(o.buttons),(0,e.expect)(t.touch).not.toBe(o.touch)}),(0,e.it)("button.press posts the correct payload",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,n.createDefaultControllers)("https://x",{screens:s});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledWith(e.expect.objectContaining({href:"https://x/button/left"}),e.expect.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release"})}))}),(0,e.it)("touch.tapAndRelease maps percent to absolute coords",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{touch:o}=(0,n.createDefaultControllers)("https://x",{screens:s});await o.tapAndRelease("flex",{x:50,y:50}),(0,e.expect)(t).toHaveBeenCalledWith(e.expect.objectContaining({href:"https://x/finger"}),e.expect.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release",x:64,y:32})}))})});
2
2
  //# sourceMappingURL=di.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/di.test.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport axios from \"axios\";\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\n\nimport { createDefaultControllers } from \"./di\";\n\nconst SCREENS = {\n flex: { width: 128, height: 64 },\n stax: { width: 400, height: 672 },\n} as const;\n\nafterEach(() => {\n vi.restoreAllMocks();\n});\n\ndescribe(\"createDefaultControllers - axios configuration\", () => {\n it(\"configures axios with normalised baseURL, custom timeout and header\", () => {\n const createSpy = vi\n .spyOn(axios, \"create\")\n .mockImplementation((cfg: any) => {\n return { post: vi.fn(), defaults: { ...cfg } } as any;\n });\n\n createDefaultControllers(\"http://example.com/api\", {\n screens: SCREENS,\n timeoutMs: 2345,\n clientHeader: \"test-client\",\n });\n\n expect(createSpy).toHaveBeenCalledTimes(1);\n const cfg = createSpy.mock.calls[0]![0] as any;\n expect(cfg.baseURL).toBe(\"http://example.com/api\");\n expect(cfg.timeout).toBe(2345);\n expect(cfg.headers?.[\"X-Ledger-Client-Version\"]).toBe(\"test-client\");\n expect(cfg.transitional?.clarifyTimeoutError).toBe(true);\n });\n\n it(\"applies default timeout and client header when not provided\", () => {\n const createSpy = vi\n .spyOn(axios, \"create\")\n .mockImplementation((cfg: any) => {\n return { post: vi.fn(), defaults: { ...cfg } } as any;\n });\n\n createDefaultControllers(\"http://localhost:1234\", { screens: SCREENS });\n\n const cfg = createSpy.mock.calls[0]![0] as any;\n expect(cfg.baseURL).toBe(\"http://localhost:1234\");\n expect(cfg.timeout).toBe(1500);\n expect(cfg.headers?.[\"X-Ledger-Client-Version\"]).toBe(\n \"ldmk-transport-speculos\",\n );\n });\n});\n\ndescribe(\"createDefaultControllers - wiring\", () => {\n it(\"returns axios implementations wired by the factory\", () => {\n const http = { post: vi.fn() } as any;\n vi.spyOn(axios, \"create\").mockReturnValue(http);\n\n const { buttons, touch } = createDefaultControllers(\"http://x\", {\n screens: SCREENS,\n });\n\n expect(buttons).toBeInstanceOf(DefaultButtonController);\n expect(touch).toBeInstanceOf(DefaultTouchController);\n expect(typeof (buttons as any).press).toBe(\"function\");\n });\n\n it(\"creates fresh instances per invocation\", () => {\n vi.spyOn(axios, \"create\")\n .mockReturnValueOnce({ post: vi.fn() } as any)\n .mockReturnValueOnce({ post: vi.fn() } as any);\n\n const a = createDefaultControllers(\"http://x\", { screens: SCREENS });\n const b = createDefaultControllers(\"http://x\", { screens: SCREENS });\n\n expect(a.buttons).not.toBe(b.buttons);\n expect(a.touch).not.toBe(b.touch);\n });\n\n it(\"button.press posts the correct payload\", async () => {\n const post = vi.fn().mockResolvedValue(undefined);\n vi.spyOn(axios, \"create\").mockReturnValue({ post } as any);\n\n const { buttons } = createDefaultControllers(\"http://x\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n expect(post).toHaveBeenCalledWith(\"/button/left\", {\n action: \"press-and-release\",\n });\n });\n\n it(\"touch.tapAndRelease maps percent to absolute coords\", async () => {\n const post = vi.fn().mockResolvedValue(undefined);\n vi.spyOn(axios, \"create\").mockReturnValue({ post } as any);\n\n const { touch } = createDefaultControllers(\"http://x\", {\n screens: SCREENS,\n });\n\n // 50% of 128x64 \u2192 (64, 32)\n await touch.tapAndRelease(\"flex\", { x: 50 as any, y: 50 as any });\n\n expect(post).toHaveBeenCalledWith(\"/finger\", {\n action: \"press-and-release\",\n x: 64,\n y: 32,\n });\n });\n});\n"],
5
- "mappings": "wdAMA,IAAAA,EAAkB,oBAClBC,EAAoD,kBAEpDC,EAAwC,sDACxCC,EAAuC,qDAEvCC,EAAyC,gBAEzC,MAAMC,EAAU,CACd,KAAM,CAAE,MAAO,IAAK,OAAQ,EAAG,EAC/B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,KAEA,aAAU,IAAM,CACd,KAAG,gBAAgB,CACrB,CAAC,KAED,YAAS,iDAAkD,IAAM,IAC/D,MAAG,sEAAuE,IAAM,CAC9E,MAAMC,EAAY,KACf,MAAM,EAAAC,QAAO,QAAQ,EACrB,mBAAoBC,IACZ,CAAE,KAAM,KAAG,GAAG,EAAG,SAAU,CAAE,GAAGA,CAAI,CAAE,EAC9C,KAEH,4BAAyB,yBAA0B,CACjD,QAASH,EACT,UAAW,KACX,aAAc,aAChB,CAAC,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,KAAG,GAAG,CAAE,CAAQ,EAC5C,oBAAoB,CAAE,KAAM,KAAG,GAAG,CAAE,CAAQ,EAE/C,MAAMK,KAAI,4BAAyB,WAAY,CAAE,QAASP,CAAQ,CAAC,EAC7DQ,KAAI,4BAAyB,WAAY,CAAE,QAASR,CAAQ,CAAC,KAEnE,UAAOO,EAAE,OAAO,EAAE,IAAI,KAAKC,EAAE,OAAO,KACpC,UAAOD,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,KAAK,CAClC,CAAC,KAED,MAAG,yCAA0C,SAAY,CACvD,MAAMC,EAAO,KAAG,GAAG,EAAE,kBAAkB,MAAS,EAChD,KAAG,MAAM,EAAAP,QAAO,QAAQ,EAAE,gBAAgB,CAAE,KAAAO,CAAK,CAAQ,EAEzD,KAAM,CAAE,QAAAJ,CAAQ,KAAI,4BAAyB,WAAY,CACvD,QAASL,CACX,CAAC,EAED,MAAMK,EAAQ,MAAM,MAAM,KAC1B,UAAOI,CAAI,EAAE,qBAAqB,eAAgB,CAChD,OAAQ,mBACV,CAAC,CACH,CAAC,KAED,MAAG,sDAAuD,SAAY,CACpE,MAAMA,EAAO,KAAG,GAAG,EAAE,kBAAkB,MAAS,EAChD,KAAG,MAAM,EAAAP,QAAO,QAAQ,EAAE,gBAAgB,CAAE,KAAAO,CAAK,CAAQ,EAEzD,KAAM,CAAE,MAAAH,CAAM,KAAI,4BAAyB,WAAY,CACrD,QAASN,CACX,CAAC,EAGD,MAAMM,EAAM,cAAc,OAAQ,CAAE,EAAG,GAAW,EAAG,EAAU,CAAC,KAEhE,UAAOG,CAAI,EAAE,qBAAqB,UAAW,CAC3C,OAAQ,oBACR,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_axios", "import_vitest", "import_DefaultButtonController", "import_DefaultTouchController", "import_di", "SCREENS", "createSpy", "axios", "cfg", "http", "buttons", "touch", "a", "b", "post"]
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\n\nimport { createDefaultControllers } from \"./di\";\n\nconst SCREENS = {\n flex: { width: 128, height: 64 },\n stax: { width: 400, height: 672 },\n} as const;\n\nafterEach(() => {\n vi.restoreAllMocks();\n});\n\ndescribe(\"createDefaultControllers - fetch configuration\", () => {\n it(\"configures with custom timeout and header\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://example.com/api\", {\n screens: SCREENS,\n timeoutMs: 2345,\n clientHeader: \"test-client\",\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledTimes(1);\n expect(fetchSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n href: \"https://example.com/api/button/left\",\n }),\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"test-client\",\n }),\n }),\n );\n });\n\n it(\"applies default timeout and client header when not provided\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://localhost:1234\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n href: \"https://localhost:1234/button/left\",\n }),\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"ldmk-transport-speculos\",\n }),\n }),\n );\n });\n});\n\ndescribe(\"createDefaultControllers - wiring\", () => {\n it(\"returns correct controller implementations\", () => {\n const { buttons, touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n expect(buttons).toBeInstanceOf(DefaultButtonController);\n expect(touch).toBeInstanceOf(DefaultTouchController);\n expect(typeof buttons.press).toBe(\"function\");\n });\n\n it(\"creates fresh instances per invocation\", () => {\n const a = createDefaultControllers(\"https://x\", { screens: SCREENS });\n const b = createDefaultControllers(\"https://x\", { screens: SCREENS });\n\n expect(a.buttons).not.toBe(b.buttons);\n expect(a.touch).not.toBe(b.touch);\n });\n\n it(\"button.press posts the correct payload\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n expect.objectContaining({ href: \"https://x/button/left\" }),\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({ action: \"press-and-release\" }),\n }),\n );\n });\n\n it(\"touch.tapAndRelease maps percent to absolute coords\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n // 50% of 128x64 \u2192 (64, 32)\n await touch.tapAndRelease(\"flex\", { x: 50 as any, y: 50 as any });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n expect.objectContaining({ href: \"https://x/finger\" }),\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({\n action: \"press-and-release\",\n x: 64,\n y: 32,\n }),\n }),\n );\n });\n});\n"],
5
+ "mappings": "aACA,IAAAA,EAAoD,kBAEpDC,EAAwC,sDACxCC,EAAuC,qDAEvCC,EAAyC,gBAEzC,MAAMC,EAAU,CACd,KAAM,CAAE,MAAO,IAAK,OAAQ,EAAG,EAC/B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,KAEA,aAAU,IAAM,CACd,KAAG,gBAAgB,CACrB,CAAC,KAED,YAAS,iDAAkD,IAAM,IAC/D,MAAG,4CAA6C,SAAY,CAC1D,MAAMC,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,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IAAI,KAAKC,EAAE,OAAO,KACpC,UAAOD,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,KAAK,CAClC,CAAC,KAED,MAAG,yCAA0C,SAAY,CACvD,MAAMJ,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,QAAAC,CAAQ,KAAI,4BAAyB,YAAa,CACxD,QAASF,CACX,CAAC,EAED,MAAME,EAAQ,MAAM,MAAM,KAE1B,UAAOD,CAAQ,EAAE,qBACf,SAAO,iBAAiB,CAAE,KAAM,uBAAwB,CAAC,EACzD,SAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CAAE,OAAQ,mBAAoB,CAAC,CACtD,CAAC,CACH,CACF,CAAC,KAED,MAAG,sDAAuD,SAAY,CACpE,MAAMA,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,MAAAE,CAAM,KAAI,4BAAyB,YAAa,CACtD,QAASH,CACX,CAAC,EAGD,MAAMG,EAAM,cAAc,OAAQ,CAAE,EAAG,GAAW,EAAG,EAAU,CAAC,KAEhE,UAAOF,CAAQ,EAAE,qBACf,SAAO,iBAAiB,CAAE,KAAM,kBAAmB,CAAC,EACpD,SAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CACnB,OAAQ,oBACR,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_vitest", "import_DefaultButtonController", "import_DefaultTouchController", "import_di", "SCREENS", "fetchSpy", "buttons", "touch", "a", "b"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(n,t)=>{for(var e in t)a(n,e,{get:t[e],enumerable:!0})},g=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of K(t))!l.call(n,r)&&r!==e&&a(n,r,{get:()=>t[r],enumerable:!(s=x(t,r))||s.enumerable});return n};var u=n=>g(a({},"__esModule",{value:!0}),n);var b={};y(b,{acceptBlindSigning:()=>M,continueToBlindSigning:()=>S,enableBlindSigningSettings:()=>B,enterMenu:()=>m,exitMenu:()=>P,mainButton:()=>w,navigateNext:()=>T,navigatePrevious:()=>C,reject:()=>d,secondaryButton:()=>h,sign:()=>p,tapLong:()=>c,tapQuick:()=>o});module.exports=u(b);const i=5e3,c=(n,t)=>async(e,s=i)=>{await n.tap(t,e),await new Promise(r=>setTimeout(r,s)),await n.release(t,e)},o=(n,t)=>async e=>await n.tapAndRelease(t,e),p=(n,t)=>async(e=i)=>await c(n,t)({x:85,y:80},e),d=(n,t)=>async()=>await o(n,t)({x:20,y:90}),T=(n,t)=>async()=>await o(n,t)({x:90,y:90}),C=(n,t)=>async()=>await o(n,t)({x:45,y:90}),w=(n,t)=>async()=>await o(n,t)({x:50,y:80}),h=(n,t)=>async()=>await o(n,t)({x:50,y:90}),m=(n,t)=>async()=>await o(n,t)({x:85,y:8}),P=(n,t)=>async()=>await o(n,t)({x:10,y:4}),B=(n,t)=>async()=>await o(n,t)({x:88,y:51}),S=(n,t)=>async()=>await o(n,t)({x:50,y:94}),M=(n,t)=>async()=>await o(n,t)({x:50,y:94});0&&(module.exports={acceptBlindSigning,continueToBlindSigning,enableBlindSigningSettings,enterMenu,exitMenu,mainButton,navigateNext,navigatePrevious,reject,secondaryButton,sign,tapLong,tapQuick});
1
+ "use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(n,t)=>{for(var e in t)a(n,e,{get:t[e],enumerable:!0})},p=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!y.call(n,s)&&s!==e&&a(n,s,{get:()=>t[s],enumerable:!(r=l(t,s))||r.enumerable});return n};var u=n=>p(a({},"__esModule",{value:!0}),n);var L={};g(L,{acceptBlindSigning:()=>m,continueToBlindSigning:()=>I,enableBlindSigningSettings:()=>N,enterMenu:()=>G,exitMenu:()=>_,mainButton:()=>w,navigateNext:()=>C,navigatePrevious:()=>h,reject:()=>d,secondaryButton:()=>S,sign:()=>T,tapLong:()=>c,tapQuick:()=>o});module.exports=u(L);const i=5e3,c=(n,t)=>async(e,r=i)=>{await n.tap(t,e),await new Promise(s=>setTimeout(s,r)),await n.release(t,e)},o=(n,t)=>async e=>await n.tapAndRelease(t,e),T=(n,t)=>async(e=i)=>await c(n,t)({x:85,y:80},e),d=(n,t)=>async()=>await o(n,t)({x:20,y:90}),C=(n,t)=>async()=>await o(n,t)({x:90,y:90}),h=(n,t)=>async()=>await o(n,t)({x:45,y:90}),w=(n,t)=>async()=>await o(n,t)({x:50,y:80}),S=(n,t)=>async()=>await o(n,t)({x:50,y:90}),G=(n,t)=>async()=>await o(n,t)({x:85,y:8}),_=(n,t)=>async()=>await o(n,t)({x:10,y:4}),x={stax:{x:88,y:51},flex:{x:88,y:58},apex:{x:88,y:58}},O=n=>Object.hasOwn(x,n),B={x:88,y:51},N=(n,t)=>async()=>{const e=O(t)?x[t]:B;await o(n,t)(e)},I=(n,t)=>async()=>await o(n,t)({x:50,y:94}),m=(n,t)=>async()=>await o(n,t)({x:50,y:94});0&&(module.exports={acceptBlindSigning,continueToBlindSigning,enableBlindSigningSettings,enterMenu,exitMenu,mainButton,navigateNext,navigatePrevious,reject,secondaryButton,sign,tapLong,tapQuick});
2
2
  //# sourceMappingURL=touchUseCases.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/use-cases/touchUseCases.ts"],
4
- "sourcesContent": ["import type { PercentCoordinates } from \"@internal/core/types\";\nimport { type TouchController } from \"@root/src/internal/core/TouchController\";\n\nconst TAP_LONG_TIME_MS = 5000;\n\nexport const tapLong =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (point: PercentCoordinates, delayMs: number = TAP_LONG_TIME_MS) => {\n await touch.tap(deviceKey, point);\n await new Promise((r) => setTimeout(r, delayMs));\n await touch.release(deviceKey, point);\n };\n\nexport const tapQuick =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (point: PercentCoordinates) =>\n await touch.tapAndRelease(deviceKey, point);\n\nexport const sign =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (delayMs: number = TAP_LONG_TIME_MS) =>\n await tapLong(touch, deviceKey)({ x: 85, y: 80 }, delayMs);\n\nexport const reject =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 20, y: 90 });\n\nexport const navigateNext =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 90, y: 90 });\n\nexport const navigatePrevious =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 45, y: 90 });\n\nexport const mainButton =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 80 });\n\nexport const secondaryButton =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 90 });\n\nexport const enterMenu =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 85, y: 8 });\n\nexport const exitMenu =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 10, y: 4 });\n\nexport const enableBlindSigningSettings =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 88, y: 51 });\n\nexport const continueToBlindSigning =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 94 });\n\nexport const acceptBlindSigning =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 94 });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,2BAAAC,EAAA,+BAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,iBAAAC,EAAA,qBAAAC,EAAA,WAAAC,EAAA,oBAAAC,EAAA,SAAAC,EAAA,YAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAf,GAGA,MAAMgB,EAAmB,IAEZH,EACX,CAAmBI,EAA2BC,IAC9C,MAAOC,EAA2BC,EAAkBJ,IAAqB,CACvE,MAAMC,EAAM,IAAIC,EAAWC,CAAK,EAChC,MAAM,IAAI,QAAS,GAAM,WAAW,EAAGC,CAAO,CAAC,EAC/C,MAAMH,EAAM,QAAQC,EAAWC,CAAK,CACtC,EAEWL,EACX,CAAmBG,EAA2BC,IAC9C,MAAOC,GACL,MAAMF,EAAM,cAAcC,EAAWC,CAAK,EAEjCP,EACX,CAAmBK,EAA2BC,IAC9C,MAAOE,EAAkBJ,IACvB,MAAMH,EAAQI,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,EAAGE,CAAO,EAEhDV,EACX,CAAmBO,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCV,EACX,CAAmBS,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCT,EACX,CAAmBQ,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCX,EACX,CAAmBU,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCP,EACX,CAAmBM,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCb,EACX,CAAmBY,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,CAAE,CAAC,EAEvCZ,EACX,CAAmBW,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,CAAE,CAAC,EAEvCd,EACX,CAAmBa,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCf,EACX,CAAmBc,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExChB,EACX,CAAmBe,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC",
6
- "names": ["touchUseCases_exports", "__export", "acceptBlindSigning", "continueToBlindSigning", "enableBlindSigningSettings", "enterMenu", "exitMenu", "mainButton", "navigateNext", "navigatePrevious", "reject", "secondaryButton", "sign", "tapLong", "tapQuick", "__toCommonJS", "TAP_LONG_TIME_MS", "touch", "deviceKey", "point", "delayMs"]
4
+ "sourcesContent": ["import type { PercentCoordinates } from \"@internal/core/types\";\nimport { type TouchController } from \"@root/src/internal/core/TouchController\";\n\nconst TAP_LONG_TIME_MS = 5000;\n\nexport const tapLong =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (point: PercentCoordinates, delayMs: number = TAP_LONG_TIME_MS) => {\n await touch.tap(deviceKey, point);\n await new Promise((r) => setTimeout(r, delayMs));\n await touch.release(deviceKey, point);\n };\n\nexport const tapQuick =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (point: PercentCoordinates) =>\n await touch.tapAndRelease(deviceKey, point);\n\nexport const sign =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async (delayMs: number = TAP_LONG_TIME_MS) =>\n await tapLong(touch, deviceKey)({ x: 85, y: 80 }, delayMs);\n\nexport const reject =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 20, y: 90 });\n\nexport const navigateNext =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 90, y: 90 });\n\nexport const navigatePrevious =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 45, y: 90 });\n\nexport const mainButton =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 80 });\n\nexport const secondaryButton =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 90 });\n\nexport const enterMenu =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 85, y: 8 });\n\nexport const exitMenu =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 10, y: 4 });\n\nconst BLIND_SIGNING_TOGGLE_COORDS = {\n stax: { x: 88, y: 51 },\n flex: { x: 88, y: 58 },\n apex: { x: 88, y: 58 },\n} as const satisfies Record<string, PercentCoordinates>;\n\ntype BlindSigningTouchKey = keyof typeof BLIND_SIGNING_TOGGLE_COORDS;\n\nconst isBlindSigningTouchKey = (key: string): key is BlindSigningTouchKey =>\n Object.hasOwn(BLIND_SIGNING_TOGGLE_COORDS, key);\n\nconst DEFAULT_BLIND_SIGNING_TOGGLE_COORDS: PercentCoordinates = {\n x: 88,\n y: 51,\n};\n\nexport const enableBlindSigningSettings =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () => {\n const point = isBlindSigningTouchKey(deviceKey)\n ? BLIND_SIGNING_TOGGLE_COORDS[deviceKey]\n : DEFAULT_BLIND_SIGNING_TOGGLE_COORDS;\n await tapQuick(touch, deviceKey)(point);\n };\n\nexport const continueToBlindSigning =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 94 });\n\nexport const acceptBlindSigning =\n <K extends string>(touch: TouchController<K>, deviceKey: K) =>\n async () =>\n await tapQuick(touch, deviceKey)({ x: 50, y: 94 });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,2BAAAC,EAAA,+BAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,iBAAAC,EAAA,qBAAAC,EAAA,WAAAC,EAAA,oBAAAC,EAAA,SAAAC,EAAA,YAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAf,GAGA,MAAMgB,EAAmB,IAEZH,EACX,CAAmBI,EAA2BC,IAC9C,MAAOC,EAA2BC,EAAkBJ,IAAqB,CACvE,MAAMC,EAAM,IAAIC,EAAWC,CAAK,EAChC,MAAM,IAAI,QAASE,GAAM,WAAWA,EAAGD,CAAO,CAAC,EAC/C,MAAMH,EAAM,QAAQC,EAAWC,CAAK,CACtC,EAEWL,EACX,CAAmBG,EAA2BC,IAC9C,MAAOC,GACL,MAAMF,EAAM,cAAcC,EAAWC,CAAK,EAEjCP,EACX,CAAmBK,EAA2BC,IAC9C,MAAOE,EAAkBJ,IACvB,MAAMH,EAAQI,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,EAAGE,CAAO,EAEhDV,EACX,CAAmBO,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,EAAOC,CAAS,EAAE,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAExCV,EACX,CAAmBS,EAA2BC,IAC9C,SACE,MAAMJ,EAASG,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AAC",
6
+ "names": ["touchUseCases_exports", "__export", "acceptBlindSigning", "continueToBlindSigning", "enableBlindSigningSettings", "enterMenu", "exitMenu", "mainButton", "navigateNext", "navigatePrevious", "reject", "secondaryButton", "sign", "tapLong", "tapQuick", "__toCommonJS", "TAP_LONG_TIME_MS", "touch", "deviceKey", "point", "delayMs", "r", "BLIND_SIGNING_TOGGLE_COORDS", "isBlindSigningTouchKey", "key", "DEFAULT_BLIND_SIGNING_TOGGLE_COORDS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("./touchUseCases");describe("touchUsecases",()=>{const a="devA",t={x:50,y:30};let e;beforeEach(()=>{e={tap:vi.fn().mockResolvedValue(void 0),release:vi.fn().mockResolvedValue(void 0),tapAndRelease:vi.fn().mockResolvedValue(void 0)},vi.restoreAllMocks(),vi.useRealTimers()}),it("tapQuick calls tapAndRelease with the same deviceKey and point",async()=>{await(0,n.tapQuick)(e,a)(t),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,t),expect(e.tap).not.toHaveBeenCalled(),expect(e.release).not.toHaveBeenCalled()}),it("tapLong taps, waits default timeout, then releases",async()=>{vi.useFakeTimers();const o=vi.spyOn(globalThis,"setTimeout"),l=(0,n.tapLong)(e,a)(t);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(a,t),expect(o).toHaveBeenCalledTimes(1),expect(o).toHaveBeenLastCalledWith(expect.any(Function),5e3),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(5e3),await l,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(a,t)}),it("tapLong uses the provided delayMs value",async()=>{vi.useFakeTimers();const o=vi.spyOn(globalThis,"setTimeout"),s=1234,i=(0,n.tapLong)(e,a)(t,s);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(a,t),expect(o).toHaveBeenCalledTimes(1),expect(o).toHaveBeenLastCalledWith(expect.any(Function),s),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(s),await i,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(a,t)}),it("tapLong propagates error if tap() rejects (no release)",async()=>{vi.useFakeTimers();const o=new Error("tap failed");e.tap.mockRejectedValueOnce(o);const l=(0,n.tapLong)(e,a)(t);await expect(l).rejects.toThrow("tap failed"),expect(e.release).not.toHaveBeenCalled()}),it("tapLong propagates error if release() rejects",async()=>{vi.useFakeTimers();const o=new Error("release failed");e.release.mockRejectedValueOnce(o);const s=(0,n.tapLong)(e,a)(t),l=expect(s).rejects.toThrow("release failed");await Promise.resolve(),await vi.advanceTimersByTimeAsync(5e3),await l,expect(e.tap).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledTimes(1)})});
1
+ "use strict";var o=require("./touchUseCases");describe("touchUsecases",()=>{const t="devA",n={x:50,y:30};let e;beforeEach(()=>{e={tap:vi.fn().mockResolvedValue(void 0),release:vi.fn().mockResolvedValue(void 0),tapAndRelease:vi.fn().mockResolvedValue(void 0)},vi.restoreAllMocks(),vi.useRealTimers()}),it("tapQuick calls tapAndRelease with the same deviceKey and point",async()=>{await(0,o.tapQuick)(e,t)(n),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(t,n),expect(e.tap).not.toHaveBeenCalled(),expect(e.release).not.toHaveBeenCalled()}),it("tapLong taps, waits default timeout, then releases",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),l=(0,o.tapLong)(e,t)(n);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(t,n),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenLastCalledWith(expect.any(Function),5e3),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(5e3),await l,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(t,n)}),it("tapLong uses the provided delayMs value",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),s=1234,i=(0,o.tapLong)(e,t)(n,s);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(t,n),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenLastCalledWith(expect.any(Function),s),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(s),await i,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(t,n)}),it("tapLong propagates error if tap() rejects (no release)",async()=>{vi.useFakeTimers();const a=new Error("tap failed");e.tap.mockRejectedValueOnce(a);const l=(0,o.tapLong)(e,t)(n);await expect(l).rejects.toThrow("tap failed"),expect(e.release).not.toHaveBeenCalled()}),it("tapLong propagates error if release() rejects",async()=>{vi.useFakeTimers();const a=new Error("release failed");e.release.mockRejectedValueOnce(a);const s=(0,o.tapLong)(e,t)(n),l=expect(s).rejects.toThrow("release failed");await Promise.resolve(),await vi.advanceTimersByTimeAsync(5e3),await l,expect(e.tap).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledTimes(1)}),describe("enableBlindSigningSettings",()=>{it.each([["stax",{x:88,y:51}],["flex",{x:88,y:58}],["apex",{x:88,y:58}]])("taps the blind-signing toggle at the %s coordinates",async(a,s)=>{await(0,o.enableBlindSigningSettings)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,s)}),it("falls back to default coordinates for an unknown device key",async()=>{const a="unknown";await(0,o.enableBlindSigningSettings)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,{x:88,y:51})})})});
2
2
  //# sourceMappingURL=touchUseCases.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/use-cases/touchUseCases.test.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nimport { tapLong, tapQuick } from \"./touchUseCases\";\n\ndescribe(\"touchUsecases\", () => {\n const deviceKey = \"devA\";\n const point = { x: 50, y: 30 } as any;\n\n let controller: TouchController;\n\n beforeEach(() => {\n controller = {\n tap: vi.fn().mockResolvedValue(undefined),\n release: vi.fn().mockResolvedValue(undefined),\n tapAndRelease: vi.fn().mockResolvedValue(undefined),\n } as unknown as TouchController;\n vi.restoreAllMocks();\n vi.useRealTimers();\n });\n\n it(\"tapQuick calls tapAndRelease with the same deviceKey and point\", async () => {\n const quick = tapQuick(controller, deviceKey);\n await quick(point);\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(deviceKey, point);\n expect(controller.tap).not.toHaveBeenCalled();\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong taps, waits default timeout, then releases\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n expect(controller.release).not.toHaveBeenCalled();\n\n // let the 5s timer elapse\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong uses the provided delayMs value\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 1234;\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point, customMs);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), customMs);\n expect(controller.release).not.toHaveBeenCalled();\n\n // advance exactly customMs and ensure release happens then\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong propagates error if tap() rejects (no release)\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"tap failed\");\n (controller.tap as any).mockRejectedValueOnce(boom);\n\n const longTap = tapLong(controller, deviceKey);\n const p = longTap(point);\n\n // attach rejection handler immediately\n await expect(p).rejects.toThrow(\"tap failed\");\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong propagates error if release() rejects\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"release failed\");\n (controller.release as any).mockRejectedValueOnce(boom);\n\n const p = tapLong(controller, deviceKey)(point);\n\n const assertion = expect(p).rejects.toThrow(\"release failed\");\n\n await Promise.resolve();\n await vi.advanceTimersByTimeAsync(5000);\n\n await assertion;\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n});\n"],
5
- "mappings": "aAMA,IAAAA,EAAkC,2BAElC,SAAS,gBAAiB,IAAM,CAC9B,MAAMC,EAAY,OACZC,EAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,EAE7B,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAa,CACX,IAAK,GAAG,GAAG,EAAE,kBAAkB,MAAS,EACxC,QAAS,GAAG,GAAG,EAAE,kBAA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AAWC,CAAK,EAC5D,OAAOE,CAAU,EAAE,sBAAsB,CAAC,EAC1C,OAAOA,CAAU,EAAE,yBAAyB,OAAO,IAAI,QAAQ,EAAGE,CAAQ,EAC1E,OAAOH,EAAW,OAAO,EAAE,IAAI,iBAAiB,EAGhD,MAAM,GAAG,yBAAyBG,CAAQ,EAC1C,MAAMD,EAEN,OAAOF,EAAW,OAAO,EAAE,sBAAsB,CAAC,EAClD,OAAOA,EAAW,OAAO,EAAE,qBAAqBF,EAAWC,CAAK,CAClE,CAAC,EAED,GAAG,yDAA0D,SAAY,CACvE,GAAG,cAAc,EAEjB,MAAMK,EAAO,IAAI,MAAM,YAAY,EAClCJ,EAAW,IAAY,sBAAsBI,CAAI,EAGlD,MAAMC,KADU,WAAQL,EAAYF,CAAS,EAC3BC,CAAK,EAGvB,MAAM,OAAOM,CAAC,EAAE,QAAQ,QAAQ,YAAY,EAC5C,OAAOL,EAAW,OAAO,EAAE,IAAI,iBAAiB,CAClD,CAAC,EAED,GAAG,gDAAiD,SAAY,CAC9D,GAAG,cAAc,EAEjB,MAAMI,EAAO,IAAI,MAAM,gBAAgB,EACtCJ,EAAW,QAAgB,sBAAsBI,CAAI,EAEtD,MAAMC,KAAI,WAAQL,EAAYF,CAAS,EAAEC,CAAK,EAExCO,EAAY,OAAOD,CAAC,EAAE,QAAQ,QAAQ,gBAAgB,EAE5D,MAAM,QAAQ,QAAQ,EACtB,MAAM,GAAG,yBAAyB,GAAI,EAEtC,MAAMC,EAEN,OAAON,EAAW,GAAG,EAAE,sBAAsB,CAAC,EAC9C,OAAOA,EAAW,OAAO,EAAE,sBAAsB,CAAC,CACpD,CAAC,CACH,CAAC",
6
- "names": ["import_touchUseCases", "deviceKey", "point", "controller", "timeoutSpy", "run", "customMs", "boom", "p", "assertion"]
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nimport { enableBlindSigningSettings, tapLong, tapQuick } from \"./touchUseCases\";\n\ndescribe(\"touchUsecases\", () => {\n const deviceKey = \"devA\";\n const point = { x: 50, y: 30 } as any;\n\n let controller: TouchController;\n\n beforeEach(() => {\n controller = {\n tap: vi.fn().mockResolvedValue(undefined),\n release: vi.fn().mockResolvedValue(undefined),\n tapAndRelease: vi.fn().mockResolvedValue(undefined),\n } as unknown as TouchController;\n vi.restoreAllMocks();\n vi.useRealTimers();\n });\n\n it(\"tapQuick calls tapAndRelease with the same deviceKey and point\", async () => {\n const quick = tapQuick(controller, deviceKey);\n await quick(point);\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(deviceKey, point);\n expect(controller.tap).not.toHaveBeenCalled();\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong taps, waits default timeout, then releases\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n expect(controller.release).not.toHaveBeenCalled();\n\n // let the 5s timer elapse\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong uses the provided delayMs value\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 1234;\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point, customMs);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), customMs);\n expect(controller.release).not.toHaveBeenCalled();\n\n // advance exactly customMs and ensure release happens then\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong propagates error if tap() rejects (no release)\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"tap failed\");\n (controller.tap as any).mockRejectedValueOnce(boom);\n\n const longTap = tapLong(controller, deviceKey);\n const p = longTap(point);\n\n // attach rejection handler immediately\n await expect(p).rejects.toThrow(\"tap failed\");\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong propagates error if release() rejects\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"release failed\");\n (controller.release as any).mockRejectedValueOnce(boom);\n\n const p = tapLong(controller, deviceKey)(point);\n\n const assertion = expect(p).rejects.toThrow(\"release failed\");\n\n await Promise.resolve();\n await vi.advanceTimersByTimeAsync(5000);\n\n await assertion;\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n\n describe(\"enableBlindSigningSettings\", () => {\n it.each([\n [\"stax\", { x: 88, y: 51 }],\n [\"flex\", { x: 88, y: 58 }],\n [\"apex\", { x: 88, y: 58 }],\n ] as const)(\n \"taps the blind-signing toggle at the %s coordinates\",\n async (key, expected) => {\n await enableBlindSigningSettings(controller, key)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(key, expected);\n },\n );\n\n it(\"falls back to default coordinates for an unknown device key\", async () => {\n const unknownKey = \"unknown\";\n await enableBlindSigningSettings(controller, unknownKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTim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yB,GAAI,EAEtC,MAAMC,EAEN,OAAON,EAAW,GAAG,EAAE,sBAAsB,CAAC,EAC9C,OAAOA,EAAW,OAAO,EAAE,sBAAsB,CAAC,CACpD,CAAC,EAED,SAAS,6BAA8B,IAAM,CAC3C,GAAG,KAAK,CACN,CAAC,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EACzB,CAAC,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EACzB,CAAC,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,CAC3B,CAAU,EACR,sDACA,MAAOO,EAAKC,IAAa,CACvB,QAAM,8BAA2BR,EAAYO,CAAG,EAAE,EAElD,OAAOP,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBO,EAAKC,CAAQ,CACrE,CACF,EAEA,GAAG,8DAA+D,SAAY,CAC5E,MAAMC,EAAa,UACnB,QAAM,8BAA2BT,EAAYS,CAAU,EAAE,EAEzD,OAAOT,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBS,EAAY,CAChE,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_touchUseCases", "deviceKey", "point", "controller", "timeoutSpy", "run", "customMs", "boom", "p", "assertion", "key", "expected", "unknownKey"]
7
7
  }
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@ledgerhq/device-management-kit": "workspace:*",
4
- "@sentry/minimal": "catalog:",
5
- "axios": "catalog:"
4
+ "@sentry/minimal": "catalog:"
6
5
  },
7
6
  "devDependencies": {
8
7
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
@@ -53,5 +52,5 @@
53
52
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
54
53
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
55
54
  },
56
- "version": "0.0.0-develop-20260428002525"
55
+ "version": "0.0.0-develop-20260430002707"
57
56
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultButtonController.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport { type ButtonKey, SpeculosActions } from \"@internal/core/types\";\n\nexport class DefaultButtonController implements ButtonController {\n constructor(private readonly client: AxiosInstance) {}\n\n async press(key: ButtonKey): Promise<void> {\n await this.client.post(`/button/${key}`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n });\n }\n}\n"],
5
- "mappings": "AAGA,OAAyB,mBAAAA,MAAuB,uBAEzC,MAAMC,CAAoD,CAC/D,YAA6BC,EAAuB,CAAvB,YAAAA,CAAwB,CAErD,MAAM,MAAMC,EAA+B,CACzC,MAAM,KAAK,OAAO,KAAK,WAAWA,CAAG,GAAI,CACvC,OAAQH,EAAgB,iBAC1B,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import type { ButtonController } from \"@internal/core/ButtonController\";\nimport {\n type ButtonKey,\n type HttpClient,\n SpeculosActions,\n} from \"@internal/core/types\";\n\nexport class DefaultButtonController implements ButtonController {\n constructor(private readonly client: HttpClient) {}\n\n async press(key: ButtonKey): Promise<void> {\n await this.client.post(`/button/${key}`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n });\n }\n}\n"],
5
+ "mappings": "AACA,OAGE,mBAAAA,MACK,uBAEA,MAAMC,CAAoD,CAC/D,YAA6BC,EAAoB,CAApB,YAAAA,CAAqB,CAElD,MAAM,MAAMC,EAA+B,CACzC,MAAM,KAAK,OAAO,KAAK,WAAWA,CAAG,GAAI,CACvC,OAAQH,EAAgB,iBAC1B,CAAC,CACH,CACF",
6
6
  "names": ["SpeculosActions", "DefaultButtonController", "client", "key"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DefaultButtonController as a}from"./DefaultButtonController";describe("DefaultButtonController",()=>{let e,s,o;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o=new a(s)});const n=["left","right","both"];it.each(n)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
1
+ import{DefaultButtonController as l}from"./DefaultButtonController";describe("DefaultButtonController",()=>{let e,n,o;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),n={post:e},o=new l(n)});const r=["left","right","both"];it.each(r)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
2
2
  //# sourceMappingURL=DefaultButtonController.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport type { ButtonKey } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let axiosFake: AxiosInstance;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue({ status: 200, data: {} });\n axiosFake = { post: postMock } as unknown as AxiosInstance;\n controller = new DefaultButtonController(axiosFake);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
5
- "mappings": "AAIA,OAAS,2BAAAA,MAA+B,4BAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,CAAE,OAAQ,IAAK,KAAM,CAAC,CAAE,CAAC,EAC9DC,EAAY,CAAE,KAAMD,CAAS,EAC7BE,EAAa,IAAIH,EAAwBE,CAAS,CACpD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
6
- "names": ["DefaultButtonController", "postMock", "axiosFake", "controller", "keys", "key", "error"]
4
+ "sourcesContent": ["import type { ButtonKey, HttpClient } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n controller = new DefaultButtonController(httpClient);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
5
+ "mappings": "AAEA,OAAS,2BAAAA,MAA+B,4BAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAC9BE,EAAa,IAAIH,EAAwBE,CAAU,CACrD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
6
+ "names": ["DefaultButtonController", "postMock", "httpClient", "controller", "keys", "key", "error"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{SpeculosActions as s}from"../core/types";class a{constructor(e,t){this.client=e;this.axes=t}assertPercentPoint({x:e,y:t}){const o=n=>Number.isFinite(n)&&n>=0&&n<=100;if(!o(e)||!o(t))throw new Error(`[Touch] percent values must be within 0\u2013100. Received x=${e}, y=${t}`)}toAbs(e,t){const o=this.axes[e];if(!o){const n=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${String(e)}". Known keys: ${n.join(", ")||"<none>"}`)}return this.assertPercentPoint(t),o.xy(t.x,t.y)}async tapAndRelease(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:s.PRESS_AND_RELEASE,...o})}async tap(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:s.PRESS,...o})}async release(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:s.RELEASE,...o})}}export{a as DefaultTouchController};
1
+ import{SpeculosActions as i}from"../core/types";class a{constructor(e,t){this.client=e;this.axes=t}assertPercentPoint({x:e,y:t}){const o=n=>Number.isFinite(n)&&n>=0&&n<=100;if(!o(e)||!o(t))throw new Error(`[Touch] percent values must be within 0\u2013100. Received x=${e}, y=${t}`)}toAbs(e,t){const o=this.axes[e];if(!o){const n=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${String(e)}". Known keys: ${n.join(", ")||"<none>"}`)}return this.assertPercentPoint(t),o.xy(t.x,t.y)}async tapAndRelease(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:i.PRESS_AND_RELEASE,...o})}async tap(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:i.PRESS,...o})}async release(e,t){const o=this.toAbs(e,t);await this.client.post("/finger",{action:i.RELEASE,...o})}}export{a as DefaultTouchController};
2
2
  //# sourceMappingURL=DefaultTouchController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/adapters/DefaultTouchController.ts"],
4
- "sourcesContent": ["import type { AxiosInstance } from \"axios\";\n\nimport { type PercentCoordinates, SpeculosActions } from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport class DefaultTouchController<K extends string>\n implements TouchController<K>\n{\n constructor(\n private readonly client: AxiosInstance,\n private readonly axes: AxisMap<K>,\n ) {}\n\n private assertPercentPoint({ x, y }: PercentCoordinates): void {\n const inRange = (v: number) => Number.isFinite(v) && v >= 0 && v <= 100;\n if (!inRange(x) || !inRange(y)) {\n throw new Error(\n `[Touch] percent values must be within 0\u2013100. Received x=${x}, y=${y}`,\n );\n }\n }\n\n private toAbs(deviceKey: K, p: PercentCoordinates) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes as Record<string, unknown>);\n throw new Error(\n `[Touch] Unknown device key \"${String(deviceKey)}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n this.assertPercentPoint(p);\n return axis.xy(p.x, p.y);\n }\n\n async tapAndRelease(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n ...abs,\n });\n }\n\n async tap(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS,\n ...abs,\n });\n }\n\n async release(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.RELEASE,\n ...abs,\n });\n }\n}\n"],
5
- "mappings": "AAEA,OAAkC,mBAAAA,MAAuB,uBAIlD,MAAMC,CAEb,CACE,YACmBC,EACAC,EACjB,CAFiB,YAAAD,EACA,UAAAC,CAChB,CAEK,mBAAmB,CAAE,EAAAC,EAAG,EAAAC,CAAE,EAA6B,CAC7D,MAAMC,EAAWC,GAAc,OAAO,SAASA,CAAC,GAAKA,GAAK,GAAKA,GAAK,IACpE,GAAI,CAACD,EAAQF,CAAC,GAAK,CAACE,EAAQD,CAAC,EAC3B,MAAM,IAAI,MACR,gEAA2DD,CAAC,OAAOC,CAAC,EACtE,CAEJ,CAEQ,MAAMG,EAAcC,EAAuB,CACjD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAA+B,EAC9D,MAAM,IAAI,MACR,+BAA+B,OAAOH,CAAS,CAAC,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EAChG,CACF,CACA,YAAK,mBAAmBF,CAAC,EAClBC,EAAK,GAAGD,EAAE,EAAGA,EAAE,CAAC,CACzB,CAEA,MAAM,cAAcD,EAAcI,EAA0C,CAC1E,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,kBACxB,GAAGa,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAcI,EAA0C,CAChE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,MACxB,GAAGa,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAcI,EAA0C,CACpE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,QACxB,GAAGa,CACL,CAAC,CACH,CACF",
4
+ "sourcesContent": ["import {\n type HttpClient,\n type PercentCoordinates,\n SpeculosActions,\n} from \"@internal/core/types\";\nimport type { AxisMap } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport class DefaultTouchController<K extends string>\n implements TouchController<K>\n{\n constructor(\n private readonly client: HttpClient,\n private readonly axes: AxisMap<K>,\n ) {}\n\n private assertPercentPoint({ x, y }: PercentCoordinates): void {\n const inRange = (v: number) => Number.isFinite(v) && v >= 0 && v <= 100;\n if (!inRange(x) || !inRange(y)) {\n throw new Error(\n `[Touch] percent values must be within 0\u2013100. Received x=${x}, y=${y}`,\n );\n }\n }\n\n private toAbs(deviceKey: K, p: PercentCoordinates) {\n const axis = this.axes[deviceKey];\n if (!axis) {\n const known = Object.keys(this.axes as Record<string, unknown>);\n throw new Error(\n `[Touch] Unknown device key \"${String(deviceKey)}\". Known keys: ${known.join(\", \") || \"<none>\"}`,\n );\n }\n this.assertPercentPoint(p);\n return axis.xy(p.x, p.y);\n }\n\n async tapAndRelease(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS_AND_RELEASE,\n ...abs,\n });\n }\n\n async tap(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.PRESS,\n ...abs,\n });\n }\n\n async release(deviceKey: K, point: PercentCoordinates): Promise<void> {\n const abs = this.toAbs(deviceKey, point);\n await this.client.post(`/finger`, {\n action: SpeculosActions.RELEASE,\n ...abs,\n });\n }\n}\n"],
5
+ "mappings": "AAAA,OAGE,mBAAAA,MACK,uBAIA,MAAMC,CAEb,CACE,YACmBC,EACAC,EACjB,CAFiB,YAAAD,EACA,UAAAC,CAChB,CAEK,mBAAmB,CAAE,EAAAC,EAAG,EAAAC,CAAE,EAA6B,CAC7D,MAAMC,EAAWC,GAAc,OAAO,SAASA,CAAC,GAAKA,GAAK,GAAKA,GAAK,IACpE,GAAI,CAACD,EAAQF,CAAC,GAAK,CAACE,EAAQD,CAAC,EAC3B,MAAM,IAAI,MACR,gEAA2DD,CAAC,OAAOC,CAAC,EACtE,CAEJ,CAEQ,MAAMG,EAAcC,EAAuB,CACjD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAA+B,EAC9D,MAAM,IAAI,MACR,+BAA+B,OAAOH,CAAS,CAAC,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EAChG,CACF,CACA,YAAK,mBAAmBF,CAAC,EAClBC,EAAK,GAAGD,EAAE,EAAGA,EAAE,CAAC,CACzB,CAEA,MAAM,cAAcD,EAAcI,EAA0C,CAC1E,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,kBACxB,GAAGa,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAcI,EAA0C,CAChE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,MACxB,GAAGa,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAcI,EAA0C,CACpE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQZ,EAAgB,QACxB,GAAGa,CACL,CAAC,CACH,CACF",
6
6
  "names": ["SpeculosActions", "DefaultTouchController", "client", "axes", "x", "y", "inRange", "v", "deviceKey", "p", "axis", "known", "point", "abs"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DefaultTouchController as l}from"./DefaultTouchController";describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((n,i)=>({x:Math.round(n*10),y:Math.round(i*20)}))},r={xy:vi.fn((n,i)=>({x:Math.round(100+n),y:Math.round(200+i)}))};let c,a;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},a=new l(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await a.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...n})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await a.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const n=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...n})}),it("release: converts via axes and POSTs action 'release'",async()=>{await a.release("devA",t);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...n})}),it("throws an error when device key is unknown",async()=>{await expect(a.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors from axios client",async()=>{const n=new Error("backend down");e.mockRejectedValueOnce(n),await expect(a.tapAndRelease("devA",t)).rejects.toBe(n)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((a,t)=>({x:a,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue({status:200,data:{}}),o={post:s},r.xy.mockClear(),e=new l(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const a=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of a)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const a=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of a)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
1
+ import{DefaultTouchController as l}from"./DefaultTouchController";describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((a,i)=>({x:Math.round(a*10),y:Math.round(i*20)}))},r={xy:vi.fn((a,i)=>({x:Math.round(100+a),y:Math.round(200+i)}))};let c,n;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},n=new l(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await n.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...a})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await n.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const a=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...a})}),it("release: converts via axes and POSTs action 'release'",async()=>{await n.release("devA",t);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...a})}),it("throws an error when device key is unknown",async()=>{await expect(n.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors",async()=>{const a=new Error("backend down");e.mockRejectedValueOnce(a),await expect(n.tapAndRelease("devA",t)).rejects.toBe(a)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((n,t)=>({x:n,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue(void 0),o={post:s},r.xy.mockClear(),e=new l(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const n=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of n)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const n=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of n)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
2
2
  //# sourceMappingURL=DefaultTouchController.test.js.map