@ledgerhq/speculos-device-controller 0.0.0-speculos-transport-and-device-controller-20251016095459 → 0.0.0-wrong-error-when-in-experimental-provider-20251021161219

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 (157) hide show
  1. package/README.md +43 -48
  2. package/lib/cjs/package.json +3 -6
  3. package/lib/cjs/src/api/DeviceController.js +1 -1
  4. package/lib/cjs/src/api/DeviceController.js.map +3 -3
  5. package/lib/cjs/src/api/DeviceController.test.js +2 -0
  6. package/lib/cjs/src/api/DeviceController.test.js.map +7 -0
  7. package/lib/cjs/src/index.js +1 -1
  8. package/lib/cjs/src/index.js.map +3 -3
  9. package/lib/cjs/src/internal/adapters/DefaultButtonController.js +2 -0
  10. package/lib/cjs/src/internal/adapters/DefaultButtonController.js.map +7 -0
  11. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js +2 -0
  12. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js.map +7 -0
  13. package/lib/cjs/src/internal/adapters/DefaultTouchController.js +2 -0
  14. package/lib/cjs/src/internal/adapters/DefaultTouchController.js.map +7 -0
  15. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js +2 -0
  16. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js.map +7 -0
  17. package/lib/cjs/src/internal/config/defaultScreens.js +1 -1
  18. package/lib/cjs/src/internal/config/defaultScreens.js.map +3 -3
  19. package/lib/cjs/src/internal/core/{IButtonController.js → ButtonController.js} +1 -1
  20. package/lib/cjs/src/internal/core/ButtonController.js.map +7 -0
  21. package/lib/cjs/src/internal/core/TouchController.js +2 -0
  22. package/lib/cjs/src/internal/core/TouchController.js.map +7 -0
  23. package/lib/cjs/src/internal/core/types.js +1 -1
  24. package/lib/cjs/src/internal/core/types.js.map +3 -3
  25. package/lib/cjs/src/internal/di.js +1 -1
  26. package/lib/cjs/src/internal/di.js.map +3 -3
  27. package/lib/cjs/src/internal/di.test.js +2 -0
  28. package/lib/cjs/src/internal/di.test.js.map +7 -0
  29. package/lib/cjs/src/internal/use-cases/buttonUseCases.js +2 -0
  30. package/lib/cjs/src/internal/use-cases/buttonUseCases.js.map +7 -0
  31. package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js +2 -0
  32. package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js.map +7 -0
  33. package/lib/cjs/src/internal/use-cases/touchUseCases.js +2 -0
  34. package/lib/cjs/src/internal/use-cases/touchUseCases.js.map +7 -0
  35. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js +2 -0
  36. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js.map +7 -0
  37. package/lib/cjs/src/internal/utils/axisClamp.js +1 -1
  38. package/lib/cjs/src/internal/utils/axisClamp.js.map +3 -3
  39. package/lib/cjs/src/internal/utils/axisClamp.test.js +2 -0
  40. package/lib/cjs/src/internal/utils/axisClamp.test.js.map +7 -0
  41. package/lib/esm/package.json +3 -6
  42. package/lib/esm/src/api/DeviceController.js +1 -1
  43. package/lib/esm/src/api/DeviceController.js.map +3 -3
  44. package/lib/esm/src/api/DeviceController.test.js +2 -0
  45. package/lib/esm/src/api/DeviceController.test.js.map +7 -0
  46. package/lib/esm/src/index.js +1 -1
  47. package/lib/esm/src/index.js.map +2 -2
  48. package/lib/esm/src/internal/adapters/DefaultButtonController.js +2 -0
  49. package/lib/esm/src/internal/adapters/DefaultButtonController.js.map +7 -0
  50. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js +2 -0
  51. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js.map +7 -0
  52. package/lib/esm/src/internal/adapters/DefaultTouchController.js +2 -0
  53. package/lib/esm/src/internal/adapters/DefaultTouchController.js.map +7 -0
  54. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js +2 -0
  55. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js.map +7 -0
  56. package/lib/esm/src/internal/config/defaultScreens.js +1 -1
  57. package/lib/esm/src/internal/config/defaultScreens.js.map +3 -3
  58. package/lib/esm/src/internal/core/ButtonController.js +1 -0
  59. package/lib/esm/src/internal/core/TouchController.js +1 -0
  60. package/lib/esm/src/internal/core/types.js +1 -0
  61. package/lib/esm/src/internal/core/types.js.map +4 -4
  62. package/lib/esm/src/internal/di.js +1 -1
  63. package/lib/esm/src/internal/di.js.map +3 -3
  64. package/lib/esm/src/internal/di.test.js +2 -0
  65. package/lib/esm/src/internal/di.test.js.map +7 -0
  66. package/lib/esm/src/internal/use-cases/buttonUseCases.js +2 -0
  67. package/lib/esm/src/internal/use-cases/buttonUseCases.js.map +7 -0
  68. package/lib/esm/src/internal/use-cases/buttonUseCases.test.js +2 -0
  69. package/lib/esm/src/internal/use-cases/buttonUseCases.test.js.map +7 -0
  70. package/lib/esm/src/internal/use-cases/touchUseCases.js +2 -0
  71. package/lib/esm/src/internal/use-cases/touchUseCases.js.map +7 -0
  72. package/lib/esm/src/internal/use-cases/touchUseCases.test.js +2 -0
  73. package/lib/esm/src/internal/use-cases/touchUseCases.test.js.map +7 -0
  74. package/lib/esm/src/internal/utils/axisClamp.js +1 -1
  75. package/lib/esm/src/internal/utils/axisClamp.js.map +3 -3
  76. package/lib/esm/src/internal/utils/axisClamp.test.js +2 -0
  77. package/lib/esm/src/internal/utils/axisClamp.test.js.map +7 -0
  78. package/lib/types/src/api/DeviceController.d.ts +13 -15
  79. package/lib/types/src/api/DeviceController.d.ts.map +1 -1
  80. package/lib/types/src/api/DeviceController.test.d.ts +2 -0
  81. package/lib/types/src/api/DeviceController.test.d.ts.map +1 -0
  82. package/lib/types/src/index.d.ts +0 -1
  83. package/lib/types/src/index.d.ts.map +1 -1
  84. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts +9 -0
  85. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts.map +1 -0
  86. package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts +2 -0
  87. package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts.map +1 -0
  88. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts +15 -0
  89. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts.map +1 -0
  90. package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts +2 -0
  91. package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts.map +1 -0
  92. package/lib/types/src/internal/config/defaultScreens.d.ts +4 -4
  93. package/lib/types/src/internal/config/defaultScreens.d.ts.map +1 -1
  94. package/lib/types/src/internal/core/{IButtonController.d.ts → ButtonController.d.ts} +2 -2
  95. package/lib/types/src/internal/core/ButtonController.d.ts.map +1 -0
  96. package/lib/types/src/internal/core/TouchController.d.ts +7 -0
  97. package/lib/types/src/internal/core/TouchController.d.ts.map +1 -0
  98. package/lib/types/src/internal/core/types.d.ts +8 -3
  99. package/lib/types/src/internal/core/types.d.ts.map +1 -1
  100. package/lib/types/src/internal/di.d.ts +7 -2
  101. package/lib/types/src/internal/di.d.ts.map +1 -1
  102. package/lib/types/src/internal/di.test.d.ts +2 -0
  103. package/lib/types/src/internal/di.test.d.ts.map +1 -0
  104. package/lib/types/src/internal/use-cases/buttonUseCases.d.ts +9 -0
  105. package/lib/types/src/internal/use-cases/buttonUseCases.d.ts.map +1 -0
  106. package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts +2 -0
  107. package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts.map +1 -0
  108. package/lib/types/src/internal/use-cases/touchUseCases.d.ts +5 -0
  109. package/lib/types/src/internal/use-cases/touchUseCases.d.ts.map +1 -0
  110. package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts +2 -0
  111. package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts.map +1 -0
  112. package/lib/types/src/internal/utils/axisClamp.d.ts +1 -2
  113. package/lib/types/src/internal/utils/axisClamp.d.ts.map +1 -1
  114. package/lib/types/src/internal/utils/axisClamp.test.d.ts +2 -0
  115. package/lib/types/src/internal/utils/axisClamp.test.d.ts.map +1 -0
  116. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  117. package/package.json +5 -8
  118. package/lib/cjs/src/internal/adapters/AxiosButtonController.js +0 -2
  119. package/lib/cjs/src/internal/adapters/AxiosButtonController.js.map +0 -7
  120. package/lib/cjs/src/internal/adapters/AxiosTouchController.js +0 -2
  121. package/lib/cjs/src/internal/adapters/AxiosTouchController.js.map +0 -7
  122. package/lib/cjs/src/internal/core/IButtonController.js.map +0 -7
  123. package/lib/cjs/src/internal/core/ITouchController.js +0 -2
  124. package/lib/cjs/src/internal/core/ITouchController.js.map +0 -7
  125. package/lib/cjs/src/internal/core/speculosDeviceControllerTypes.js +0 -2
  126. package/lib/cjs/src/internal/core/speculosDeviceControllerTypes.js.map +0 -7
  127. package/lib/cjs/src/internal/usecases/buttonUsecases.js +0 -2
  128. package/lib/cjs/src/internal/usecases/buttonUsecases.js.map +0 -7
  129. package/lib/cjs/src/internal/usecases/touchUsecases.js +0 -2
  130. package/lib/cjs/src/internal/usecases/touchUsecases.js.map +0 -7
  131. package/lib/esm/src/internal/adapters/AxiosButtonController.js +0 -2
  132. package/lib/esm/src/internal/adapters/AxiosButtonController.js.map +0 -7
  133. package/lib/esm/src/internal/adapters/AxiosTouchController.js +0 -2
  134. package/lib/esm/src/internal/adapters/AxiosTouchController.js.map +0 -7
  135. package/lib/esm/src/internal/core/IButtonController.js +0 -1
  136. package/lib/esm/src/internal/core/ITouchController.js +0 -1
  137. package/lib/esm/src/internal/core/speculosDeviceControllerTypes.js +0 -2
  138. package/lib/esm/src/internal/core/speculosDeviceControllerTypes.js.map +0 -7
  139. package/lib/esm/src/internal/usecases/buttonUsecases.js +0 -2
  140. package/lib/esm/src/internal/usecases/buttonUsecases.js.map +0 -7
  141. package/lib/esm/src/internal/usecases/touchUsecases.js +0 -2
  142. package/lib/esm/src/internal/usecases/touchUsecases.js.map +0 -7
  143. package/lib/types/src/internal/adapters/AxiosButtonController.d.ts +0 -10
  144. package/lib/types/src/internal/adapters/AxiosButtonController.d.ts.map +0 -1
  145. package/lib/types/src/internal/adapters/AxiosTouchController.d.ts +0 -14
  146. package/lib/types/src/internal/adapters/AxiosTouchController.d.ts.map +0 -1
  147. package/lib/types/src/internal/core/IButtonController.d.ts.map +0 -1
  148. package/lib/types/src/internal/core/ITouchController.d.ts +0 -7
  149. package/lib/types/src/internal/core/ITouchController.d.ts.map +0 -1
  150. package/lib/types/src/internal/core/speculosDeviceControllerTypes.d.ts +0 -7
  151. package/lib/types/src/internal/core/speculosDeviceControllerTypes.d.ts.map +0 -1
  152. package/lib/types/src/internal/usecases/buttonUsecases.d.ts +0 -9
  153. package/lib/types/src/internal/usecases/buttonUsecases.d.ts.map +0 -1
  154. package/lib/types/src/internal/usecases/touchUsecases.d.ts +0 -5
  155. package/lib/types/src/internal/usecases/touchUsecases.d.ts.map +0 -1
  156. /package/lib/esm/src/internal/core/{IButtonController.js.map → ButtonController.js.map} +0 -0
  157. /package/lib/esm/src/internal/core/{ITouchController.js.map → TouchController.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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,kBAAkB,MAAS,EAC5C,cAAe,GAAG,GAAG,EAAE,kBAAkB,MAAS,CACpD,EACA,GAAG,gBAAgB,EACnB,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,iEAAkE,SAAY,CAE/E,QADc,YAASA,EAAYF,CAAS,EAChCC,CAAK,EAEjB,OAAOC,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBF,EAAWC,CAAK,EACtE,OAAOC,EAAW,GAAG,EAAE,IAAI,iBAAiB,EAC5C,OAAOA,EAAW,OAAO,EAAE,IAAI,iBAAiB,CAClD,CAAC,EAED,GAAG,qDAAsD,SAAY,CACnE,GAAG,cAAc,EACjB,MAAMC,EAAa,GAAG,MAAM,WAAY,YAAY,EAG9CC,KADU,WAAQF,EAAYF,CAAS,EACzBC,CAAK,EAEzB,MAAM,QAAQ,QAAQ,EAEtB,OAAOC,EAAW,GAAG,EAAE,sBAAsB,CAAC,EAC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AiB,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"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!y.call(e,n)&&n!==r&&c(e,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return e};var u=e=>f(c({},"__esModule",{value:!0}),e);var h={};M(h,{createAxes:()=>A,createAxis:()=>p,createVH:()=>x,createVW:()=>a});module.exports=u(h);const s=e=>Math.max(0,Math.min(100,e))/100,a=e=>t=>Math.floor(e*s(t)),x=e=>t=>Math.floor(e*s(t)),p=(e,t)=>({vw:a(e),vh:x(t),xy:(r,o)=>({x:Math.floor(e*s(r)),y:Math.floor(t*s(o))})}),A=e=>{const t={};for(const r of Object.keys(e)){const o=e[r];t[r]=p(o.width,o.height)}return t};0&&(module.exports={createAxes,createAxis,createVH,createVW});
1
+ "use strict";var o=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of a(t))!i.call(e,s)&&s!==r&&o(e,s,{get:()=>t[s],enumerable:!(n=x(t,s))||n.enumerable});return e};var A=e=>y(o({},"__esModule",{value:!0}),e);var M={};m(M,{clampValue:()=>c,createAxes:()=>K,createAxis:()=>p});module.exports=A(M);const u=e=>Math.max(0,Math.min(100,e))/100,c=e=>t=>Math.floor(e*u(t)),p=(e,t)=>({vw:c(e),vh:c(t),xy:(r,n)=>({x:c(e)(r),y:c(t)(n)})}),K=e=>{const t={};for(const r of Object.keys(e)){const n=e[r];t[r]=p(n.width,n.height)}return t};0&&(module.exports={clampValue,createAxes,createAxis});
2
2
  //# sourceMappingURL=axisClamp.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/utils/axisClamp.ts"],
4
- "sourcesContent": ["import type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nconst clamp = (pct: number) => Math.max(0, Math.min(100, pct)) / 100;\n\nexport const createVW = (width: number) => (pct: Percent) =>\n Math.floor(width * clamp(pct));\nexport const createVH = (height: number) => (pct: Percent) =>\n Math.floor(height * clamp(pct));\n\nexport const createAxis = (width: number, height: number) => ({\n vw: createVW(width),\n vh: createVH(height),\n xy: (xPct: Percent, yPct: Percent) => ({\n x: Math.floor(width * clamp(xPct)),\n y: Math.floor(height * clamp(yPct)),\n }),\n});\n\nexport type Axis = ReturnType<typeof createAxis>;\nexport type AxisMap<K extends string = string> = Record<K, Axis>;\n\nexport const createAxes = <K extends string>(\n screens: DeviceScreens<K>,\n): AxisMap<K> => {\n const out = {} as AxisMap<K>;\n for (const key of Object.keys(screens) as K[]) {\n const s = screens[key];\n out[key] = createAxis(s.width, s.height);\n }\n return out;\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAN,GAEA,MAAMO,EAASC,GAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKA,CAAG,CAAC,EAAI,IAEpDH,EAAYI,GAAmBD,GAC1C,KAAK,MAAMC,EAAQF,EAAMC,CAAG,CAAC,EAClBJ,EAAYM,GAAoBF,GAC3C,KAAK,MAAME,EAASH,EAAMC,CAAG,CAAC,EAEnBL,EAAa,CAACM,EAAeC,KAAoB,CAC5D,GAAIL,EAASI,CAAK,EAClB,GAAIL,EAASM,CAAM,EACnB,GAAI,CAACC,EAAeC,KAAmB,CACrC,EAAG,KAAK,MAAMH,EAAQF,EAAMI,CAAI,CAAC,EACjC,EAAG,KAAK,MAAMD,EAASH,EAAMK,CAAI,CAAC,CACpC,EACF,GAKaV,EACXW,GACe,CACf,MAAMC,EAAM,CAAC,EACb,UAAWC,KAAO,OAAO,KAAKF,CAAO,EAAU,CAC7C,MAAMG,EAAIH,EAAQE,CAAG,EACrBD,EAAIC,CAAG,EAAIZ,EAAWa,EAAE,MAAOA,EAAE,MAAM,CACzC,CACA,OAAOF,CACT",
6
- "names": ["axisClamp_exports", "__export", "createAxes", "createAxis", "createVH", "createVW", "__toCommonJS", "clamp", "pct", "width", "height", "xPct", "yPct", "screens", "out", "key", "s"]
4
+ "sourcesContent": ["import type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nconst clamp = (pct: number) => Math.max(0, Math.min(100, pct)) / 100;\n\nexport const clampValue = (value: number) => (pct: Percent) =>\n Math.floor(value * clamp(pct));\n\nexport const createAxis = (width: number, height: number) => ({\n vw: clampValue(width),\n vh: clampValue(height),\n xy: (xPct: Percent, yPct: Percent) => ({\n x: clampValue(width)(xPct),\n y: clampValue(height)(yPct),\n }),\n});\n\nexport type Axis = ReturnType<typeof createAxis>;\nexport type AxisMap<K extends string = string> = Record<K, Axis>;\n\nexport const createAxes = <K extends string>(\n screens: DeviceScreens<K>,\n): AxisMap<K> => {\n const mappedAxes = {} as AxisMap<K>;\n for (const key of Object.keys(screens) as K[]) {\n const screen = screens[key];\n mappedAxes[key] = createAxis(screen.width, screen.height);\n }\n return mappedAxes;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,eAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAL,GAEA,MAAMM,EAASC,GAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKA,CAAG,CAAC,EAAI,IAEpDL,EAAcM,GAAmBD,GAC5C,KAAK,MAAMC,EAAQF,EAAMC,CAAG,CAAC,EAElBH,EAAa,CAACK,EAAeC,KAAoB,CAC5D,GAAIR,EAAWO,CAAK,EACpB,GAAIP,EAAWQ,CAAM,EACrB,GAAI,CAACC,EAAeC,KAAmB,CACrC,EAAGV,EAAWO,CAAK,EAAEE,CAAI,EACzB,EAAGT,EAAWQ,CAAM,EAAEE,CAAI,CAC5B,EACF,GAKaT,EACXU,GACe,CACf,MAAMC,EAAa,CAAC,EACpB,UAAWC,KAAO,OAAO,KAAKF,CAAO,EAAU,CAC7C,MAAMG,EAASH,EAAQE,CAAG,EAC1BD,EAAWC,CAAG,EAAIX,EAAWY,EAAO,MAAOA,EAAO,MAAM,CAC1D,CACA,OAAOF,CACT",
6
+ "names": ["axisClamp_exports", "__export", "clampValue", "createAxes", "createAxis", "__toCommonJS", "clamp", "pct", "value", "width", "height", "xPct", "yPct", "screens", "mappedAxes", "key", "screen"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("./axisClamp");const e=t=>t;describe("axisClamp helpers",()=>{describe("clampValue",()=>{it("floors and clamps to [0, width]",()=>{const t=(0,o.clampValue)(200);expect(t(e(0))).toBe(0),expect(t(e(50))).toBe(100),expect(t(e(50.4))).toBe(100),expect(t(e(50.5))).toBe(101),expect(t(e(100))).toBe(200),expect(t(e(150))).toBe(200),expect(t(e(-10))).toBe(0)})}),describe("createAxis",()=>{it("exposes vw, vh and xy with consistent flooring + clamping",()=>{const t=(0,o.createAxis)(300,200);expect(t.vw(e(25))).toBe(75),expect(t.vh(e(75))).toBe(150),expect(t.xy(e(10),e(90))).toEqual({x:30,y:180}),expect(t.xy(e(150),e(-20))).toEqual({x:300,y:0});const c=t.xy(e(33.4),e(66.6));expect(c.x).toBe(Math.floor(300*.334)),expect(c.y).toBe(Math.floor(200*.666))})}),describe("createAxes",()=>{it("creates an AxisMap for all device keys with matching dimensions",()=>{const c=(0,o.createAxes)({devA:{width:200,height:100},devB:{width:320,height:480}});expect(Object.keys(c).sort()).toEqual(["devA","devB"]),expect(c.devA.vw(e(100))).toBe(200),expect(c.devA.vh(e(100))).toBe(100),expect(c.devA.xy(e(120),e(-10))).toEqual({x:200,y:0}),expect(c.devB.vw(e(50))).toBe(160),expect(c.devB.vh(e(50))).toBe(240),expect(c.devB.xy(e(33.3),e(66.7))).toEqual({x:Math.floor(320*.333),y:Math.floor(480*.667)})})})});
2
+ //# sourceMappingURL=axisClamp.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/utils/axisClamp.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nimport { type AxisMap, clampValue, createAxes, createAxis } from \"./axisClamp\";\n\nconst p = (n: number) => n as unknown as Percent;\n\ndescribe(\"axisClamp helpers\", () => {\n describe(\"clampValue\", () => {\n it(\"floors and clamps to [0, width]\", () => {\n const clamp = clampValue(200);\n\n expect(clamp(p(0))).toBe(0);\n expect(clamp(p(50))).toBe(100); // 200 * 0.5 = 100\n expect(clamp(p(50.4))).toBe(100); // floor(200 * 0.504) = 100\n expect(clamp(p(50.5))).toBe(101); // floor(200 * 0.505) = 101\n expect(clamp(p(100))).toBe(200);\n expect(clamp(p(150))).toBe(200); // clamped\n expect(clamp(p(-10))).toBe(0); // clamped\n });\n });\n\n describe(\"createAxis\", () => {\n it(\"exposes vw, vh and xy with consistent flooring + clamping\", () => {\n const axis = createAxis(300, 200);\n\n // vw / vh\n expect(axis.vw(p(25))).toBe(75); // 300 * 0.25\n expect(axis.vh(p(75))).toBe(150); // 200 * 0.75\n\n // xy nominal\n expect(axis.xy(p(10), p(90))).toEqual({ x: 30, y: 180 });\n\n // xy clamps both axes\n expect(axis.xy(p(150), p(-20))).toEqual({ x: 300, y: 0 });\n\n // flooring behavior with fractional percent\n const xy = axis.xy(p(33.4), p(66.6));\n expect(xy.x).toBe(Math.floor(300 * 0.334));\n expect(xy.y).toBe(Math.floor(200 * 0.666));\n });\n });\n\n describe(\"createAxes\", () => {\n it(\"creates an AxisMap for all device keys with matching dimensions\", () => {\n const screens: DeviceScreens<\"devA\" | \"devB\"> = {\n devA: { width: 200, height: 100 } as any,\n devB: { width: 320, height: 480 } as any,\n };\n\n const axes: AxisMap<\"devA\" | \"devB\"> = createAxes(screens);\n\n // contains both keys\n expect(Object.keys(axes).sort()).toEqual([\"devA\", \"devB\"]);\n\n // devA\n expect(axes.devA.vw(p(100))).toBe(200);\n expect(axes.devA.vh(p(100))).toBe(100);\n expect(axes.devA.xy(p(120), p(-10))).toEqual({ x: 200, y: 0 });\n\n // devB\n expect(axes.devB.vw(p(50))).toBe(160);\n expect(axes.devB.vh(p(50))).toBe(240);\n expect(axes.devB.xy(p(33.3), p(66.7))).toEqual({\n x: Math.floor(320 * 0.333),\n y: Math.floor(480 * 0.667),\n });\n });\n });\n});\n"],
5
+ "mappings": "aAMA,IAAAA,EAAiE,uBAEjE,MAAMC,EAAKC,GAAcA,EAEzB,SAAS,oBAAqB,IAAM,CAClC,SAAS,aAAc,IAAM,CAC3B,GAAG,kCAAmC,IAAM,CAC1C,MAAMC,KAAQ,cAAW,GAAG,EAE5B,OAA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ALS,CAC9C,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,CAEyD,EAGzD,OAAO,OAAO,KAAKA,CAAI,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAQ,MAAM,CAAC,EAGzD,OAAOA,EAAK,KAAK,GAAGL,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EACrC,OAAOK,EAAK,KAAK,GAAGL,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EACrC,OAAOK,EAAK,KAAK,GAAGL,EAAE,GAAG,EAAGA,EAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAE,EAAG,IAAK,EAAG,CAAE,CAAC,EAG7D,OAAOK,EAAK,KAAK,GAAGL,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOK,EAAK,KAAK,GAAGL,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOK,EAAK,KAAK,GAAGL,EAAE,IAAI,EAAGA,EAAE,IAAI,CAAC,CAAC,EAAE,QAAQ,CAC7C,EAAG,KAAK,MAAM,IAAM,IAAK,EACzB,EAAG,KAAK,MAAM,IAAM,IAAK,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axisClamp", "p", "n", "clamp", "axis", "xy", "axes"]
7
+ }
@@ -35,11 +35,9 @@
35
35
  "test:coverage": "vitest run --coverage --passWithNoTests"
36
36
  },
37
37
  "dependencies": {
38
+ "@ledgerhq/device-management-kit": "workspace:*",
38
39
  "@sentry/minimal": "catalog:",
39
- "axios": "catalog:",
40
- "inversify": "catalog:",
41
- "purify-ts": "catalog:",
42
- "reflect-metadata": "catalog:"
40
+ "axios": "catalog:"
43
41
  },
44
42
  "devDependencies": {
45
43
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
@@ -50,7 +48,6 @@
50
48
  "ts-node": "catalog:"
51
49
  },
52
50
  "peerDependencies": {
53
- "@ledgerhq/device-management-kit": "workspace:*",
54
- "rxjs": "catalog:"
51
+ "@ledgerhq/device-management-kit": "workspace:*"
55
52
  }
56
53
  }
@@ -1,2 +1,2 @@
1
- import{DEFAULT_SCREENS as u}from"../internal/config/defaultScreens";import{pressButtons as m,pressSequence as a}from"../internal/usecases/buttonUsecases";import{tapLong as P,tapQuick as v}from"../internal/usecases/touchUsecases";import{speculosDeviceControllerTypes as s}from"../../src/internal/core/speculosDeviceControllerTypes";import{buildContainer as y}from"../../src/internal/di";function I(c,t={}){const p={screens:t.screens??u,timeoutMs:t.timeoutMs,clientHeader:t.clientHeader},n=y(c,p),o=n.get(s.ButtonController),r=m(o),i=n.get(s.TouchController);return{button:{press:e=>o.press(e),left:()=>r.left(),right:()=>r.right(),both:()=>r.both(),pressSequence:(e,l)=>a(o,e,l)},touch:{createTap:e=>({tapQuick:v(i,e),tapLong:P(i,e)})}}}export{I as deviceControllerFactory};
1
+ import{DEFAULT_SCREENS as p}from"../internal/config/defaultScreens";import{createDefaultControllers as l}from"../../src/internal/di";import{pressButtons as a,pressSequence as u}from"../../src/internal/use-cases/buttonUseCases";import{tapLong as y,tapQuick as m}from"../../src/internal/use-cases/touchUseCases";const F=(i,t={})=>{const s={screens:t.screens??p,timeoutMs:t.timeoutMs,clientHeader:t.clientHeader},{buttons:o,touch:n}=l(i,s),r=a(o);return{buttonFactory:()=>({press:e=>o.press(e),left:()=>r.left(),right:()=>r.right(),both:()=>r.both(),pressSequence:(e,c)=>u(o,e,c)}),tapFactory:e=>({tapQuick:m(n,e),tapLong:y(n,e)})}};export{F as deviceControllerClientFactory};
2
2
  //# sourceMappingURL=DeviceController.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/DeviceController.ts"],
4
- "sourcesContent": ["import { DEFAULT_SCREENS } from \"@internal/config/defaultScreens\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type {\n ButtonKey,\n DeviceControllerOptions,\n DeviceScreens,\n PercentPoint,\n} from \"@internal/core/types\";\nimport { pressButtons, pressSequence } from \"@internal/usecases/buttonUsecases\";\nimport { tapLong, tapQuick } from \"@internal/usecases/touchUsecases\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\nimport { buildContainer } from \"@root/src/internal/di\";\n\nexport type ButtonAPI = IButtonController & {\n left(): Promise<void>;\n right(): Promise<void>;\n both(): Promise<void>;\n pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;\n};\n\nexport type TouchAPI = {\n createTap: (deviceKey: string) => {\n tapQuick: (point: PercentPoint) => Promise<void>;\n tapLong: (point: PercentPoint) => Promise<void>;\n };\n};\n\nexport type DeviceAPI = {\n button: ButtonAPI;\n touch: TouchAPI;\n};\n\ntype BaseOpts = {\n timeoutMs?: number;\n clientHeader?: string;\n screens?: DeviceScreens<string>;\n};\n\nexport function deviceControllerFactory(\n baseURL: string,\n opts: BaseOpts = {},\n): DeviceAPI {\n const resolved: DeviceControllerOptions<string> = {\n screens: opts.screens ?? DEFAULT_SCREENS,\n timeoutMs: opts.timeoutMs,\n clientHeader: opts.clientHeader,\n };\n\n const container = buildContainer<string>(baseURL, resolved);\n\n const buttons = container.get<IButtonController>(\n speculosDeviceControllerTypes.ButtonController,\n );\n const press = pressButtons(buttons);\n const touch = container.get<ITouchController<string>>(\n speculosDeviceControllerTypes.TouchController,\n );\n\n return {\n button: {\n press: (k) => buttons.press(k),\n left: () => press.left(),\n right: () => press.right(),\n both: () => press.both(),\n pressSequence: (keys, delayMs) => pressSequence(buttons, keys, delayMs),\n },\n touch: {\n createTap: (key) => ({\n tapQuick: tapQuick(touch, key),\n tapLong: tapLong(touch, key),\n }),\n },\n };\n}\n\nexport type { ButtonKey, DeviceControllerOptions, DeviceScreens, PercentPoint };\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAShC,OAAS,gBAAAC,EAAc,iBAAAC,MAAqB,oCAC5C,OAAS,WAAAC,EAAS,YAAAC,MAAgB,mCAClC,OAAS,iCAAAC,MAAqC,wDAC9C,OAAS,kBAAAC,MAAsB,wBA2BxB,SAASC,EACdC,EACAC,EAAiB,CAAC,EACP,CACX,MAAMC,EAA4C,CAChD,QAASD,EAAK,SAAWT,EACzB,UAAWS,EAAK,UAChB,aAAcA,EAAK,YACrB,EAEME,EAAYL,EAAuBE,EAASE,CAAQ,EAEpDE,EAAUD,EAAU,IACxBN,EAA8B,gBAChC,EACMQ,EAAQZ,EAAaW,CAAO,EAC5BE,EAAQH,EAAU,IACtBN,EAA8B,eAChC,EAEA,MAAO,CACL,OAAQ,CACN,MAAQU,GAAMH,EAAQ,MAAMG,CAAC,EAC7B,KAAM,IAAMF,EAAM,KAAK,EACvB,MAAO,IAAMA,EAAM,MAAM,EACzB,KAAM,IAAMA,EAAM,KAAK,EACvB,cAAe,CAACG,EAAMC,IAAYf,EAAcU,EAASI,EAAMC,CAAO,CACxE,EACA,MAAO,CACL,UAAYC,IAAS,CACnB,SAAUd,EAASU,EAAOI,CAAG,EAC7B,QAASf,EAAQW,EAAOI,CAAG,CAC7B,EACF,CACF,CACF",
6
- "names": ["DEFAULT_SCREENS", "pressButtons", "pressSequence", "tapLong", "tapQuick", "speculosDeviceControllerTypes", "buildContainer", "deviceControllerFactory", "baseURL", "opts", "resolved", "container", "buttons", "press", "touch", "k", "keys", "delayMs", "key"]
4
+ "sourcesContent": ["import { DEFAULT_SCREENS } from \"@internal/config/defaultScreens\";\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport type {\n ButtonKey,\n DeviceControllerOptions,\n DeviceScreens,\n PercentCoordinates,\n} from \"@internal/core/types\";\nimport { createDefaultControllers } from \"@root/src/internal/di\";\nimport {\n pressButtons,\n pressSequence,\n} from \"@root/src/internal/use-cases/buttonUseCases\";\nimport { tapLong, tapQuick } from \"@root/src/internal/use-cases/touchUseCases\";\n\nexport type ButtonFactory = () => ButtonController & {\n left(): Promise<void>;\n right(): Promise<void>;\n both(): Promise<void>;\n pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;\n};\n\nexport type TapFactory = (deviceKey: string) => {\n tapQuick: (point: PercentCoordinates) => Promise<void>;\n tapLong: (point: PercentCoordinates) => Promise<void>;\n};\n\nexport type DeviceControllerClientFactory = (\n baseURL: string,\n opts?: {\n timeoutMs?: number;\n clientHeader?: string;\n screens?: DeviceScreens<string>;\n },\n) => DeviceControllerClient;\n\nexport type DeviceControllerClient = {\n buttonFactory: ButtonFactory;\n tapFactory: TapFactory;\n};\n\nexport const deviceControllerClientFactory: DeviceControllerClientFactory = (\n baseURL,\n opts = {},\n) => {\n const resolved: DeviceControllerOptions = {\n screens: opts.screens ?? DEFAULT_SCREENS,\n timeoutMs: opts.timeoutMs,\n clientHeader: opts.clientHeader,\n };\n\n const { buttons, touch } = createDefaultControllers(baseURL, resolved);\n const press = pressButtons(buttons);\n\n return {\n buttonFactory: () => ({\n press: (key) => buttons.press(key),\n left: () => press.left(),\n right: () => press.right(),\n both: () => press.both(),\n pressSequence: (keys, delayMs) => pressSequence(buttons, keys, delayMs),\n }),\n tapFactory: (key) => ({\n tapQuick: tapQuick(touch, key),\n tapLong: tapLong(touch, key),\n }),\n };\n};\n\nexport type {\n ButtonKey,\n DeviceControllerOptions,\n DeviceScreens,\n PercentCoordinates,\n};\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAQhC,OAAS,4BAAAC,MAAgC,wBACzC,OACE,gBAAAC,EACA,iBAAAC,MACK,8CACP,OAAS,WAAAC,EAAS,YAAAC,MAAgB,6CA4B3B,MAAMC,EAA+D,CAC1EC,EACAC,EAAO,CAAC,IACL,CACH,MAAMC,EAAoC,CACxC,QAASD,EAAK,SAAWR,EACzB,UAAWQ,EAAK,UAChB,aAAcA,EAAK,YACrB,EAEM,CAAE,QAAAE,EAAS,MAAAC,CAAM,EAAIV,EAAyBM,EAASE,CAAQ,EAC/DG,EAAQV,EAAaQ,CAAO,EAElC,MAAO,CACL,cAAe,KAAO,CACpB,MAAQG,GAAQH,EAAQ,MAAMG,CAAG,EACjC,KAAM,IAAMD,EAAM,KAAK,EACvB,MAAO,IAAMA,EAAM,MAAM,EACzB,KAAM,IAAMA,EAAM,KAAK,EACvB,cAAe,CAACE,EAAMC,IAAYZ,EAAcO,EAASI,EAAMC,CAAO,CACxE,GACA,WAAaF,IAAS,CACpB,SAAUR,EAASM,EAAOE,CAAG,EAC7B,QAAST,EAAQO,EAAOE,CAAG,CAC7B,EACF,CACF",
6
+ "names": ["DEFAULT_SCREENS", "createDefaultControllers", "pressButtons", "pressSequence", "tapLong", "tapQuick", "deviceControllerClientFactory", "baseURL", "opts", "resolved", "buttons", "touch", "press", "key", "keys", "delayMs"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{deviceControllerClientFactory as o}from"./DeviceController";describe("deviceControllerClientFactory",()=>{it("returns a DeviceControllerdeviceClient with the expected shape",()=>{const e=o("http://localhost:0");expect(e).toBeDefined(),expect(e).toHaveProperty("buttonFactory"),expect(e).toHaveProperty("tapFactory");const t=e.buttonFactory();expect(typeof t.press).toBe("function"),expect(typeof t.left).toBe("function"),expect(typeof t.right).toBe("function"),expect(typeof t.both).toBe("function"),expect(typeof t.pressSequence).toBe("function");const c=e.tapFactory("flex");expect(typeof c.tapQuick).toBe("function"),expect(typeof c.tapLong).toBe("function")}),it("does not throw when created with custom options",()=>{const t=o("http://127.0.0.1:0",{clientHeader:"test-suite",timeoutMs:200,screens:{custom:{width:128,height:64},stax:{width:400,height:672}}});expect(t).toBeTruthy()}),it("creates independent instances (no accidental shared state)",()=>{const e=o("http://localhost:0"),t=o("http://localhost:0");expect(e).not.toBe(t),expect(e.buttonFactory().press).not.toBe(t.buttonFactory().press),expect(e.tapFactory("flex").tapQuick).not.toBe(t.tapFactory("flex").tapQuick)})});
2
+ //# sourceMappingURL=DeviceController.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/api/DeviceController.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport type { DeviceScreens } from \"@internal/core/types\";\n\nimport { deviceControllerClientFactory } from \"./DeviceController\";\n\ndescribe(\"deviceControllerClientFactory\", () => {\n it(\"returns a DeviceControllerdeviceClient with the expected shape\", () => {\n const deviceClient = deviceControllerClientFactory(\"http://localhost:0\");\n\n expect(deviceClient).toBeDefined();\n expect(deviceClient).toHaveProperty(\"buttonFactory\");\n expect(deviceClient).toHaveProperty(\"tapFactory\");\n\n const deviceButtons = deviceClient.buttonFactory();\n\n // button surfaces\n expect(typeof deviceButtons.press).toBe(\"function\");\n expect(typeof deviceButtons.left).toBe(\"function\");\n expect(typeof deviceButtons.right).toBe(\"function\");\n expect(typeof deviceButtons.both).toBe(\"function\");\n expect(typeof deviceButtons.pressSequence).toBe(\"function\");\n\n const deviceTaps = deviceClient.tapFactory(\"flex\");\n\n // tap surfaces\n expect(typeof deviceTaps.tapQuick).toBe(\"function\");\n expect(typeof deviceTaps.tapLong).toBe(\"function\");\n });\n\n it(\"does not throw when created with custom options\", () => {\n const screens: DeviceScreens<string> = {\n custom: { width: 128, height: 64 },\n stax: { width: 400, height: 672 },\n };\n const deviceClient = deviceControllerClientFactory(\"http://127.0.0.1:0\", {\n clientHeader: \"test-suite\",\n timeoutMs: 200,\n screens,\n });\n expect(deviceClient).toBeTruthy();\n });\n\n it(\"creates independent instances (no accidental shared state)\", () => {\n const a = deviceControllerClientFactory(\"http://localhost:0\");\n const b = deviceControllerClientFactory(\"http://localhost:0\");\n\n expect(a).not.toBe(b);\n expect(a.buttonFactory().press).not.toBe(b.buttonFactory().press);\n expect(a.tapFactory(\"flex\").tapQuick).not.toBe(\n b.tapFactory(\"flex\").tapQuick,\n );\n });\n});\n"],
5
+ "mappings": "AAIA,OAAS,iCAAAA,MAAq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ceControllerClientFactory", "deviceClient", "deviceButtons", "deviceTaps", "a", "b"]
7
+ }
@@ -1,2 +1,2 @@
1
- import"reflect-metadata";export*from"./api/DeviceController";
1
+ export*from"./api/DeviceController";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["import \"reflect-metadata\";\n\nexport * from \"./api/DeviceController\";\n"],
5
- "mappings": "AAAA,MAAO,mBAEP,WAAc",
4
+ "sourcesContent": ["export * from \"./api/DeviceController\";\n"],
5
+ "mappings": "AAAA,WAAc",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{SpeculosActions as o}from"../core/types";class r{constructor(t){this.client=t}async press(t){await this.client.post(`/button/${t}`,{action:o.PRESS_AND_RELEASE})}}export{r as DefaultButtonController};
2
+ //# sourceMappingURL=DefaultButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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",
6
+ "names": ["SpeculosActions", "DefaultButtonController", "client", "key"]
7
+ }
@@ -0,0 +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)})});
2
+ //# sourceMappingURL=DefaultButtonController.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-call */\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 { 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": "AAOA,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"]
7
+ }
@@ -0,0 +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};
2
+ //# sourceMappingURL=DefaultTouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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}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axes", "x", "y", "inRange", "v", "deviceKey", "p", "axis", "known", "point", "abs"]
7
+ }
@@ -0,0 +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()})});
2
+ //# sourceMappingURL=DefaultTouchController.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/adapters/DefaultTouchController.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\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,OAAS,0BAAAA,MAA8B,2BAEvC,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,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EAAG,GAAI,EAAG,IAAM,CACpB,EAEA,UAAWC,KAAKD,EACd,MAAM,OACJL,EAAW,cAAc,OAAQM,CAAQ,CAC3C,EAAE,QAAQ,QAAQ,EAIpB,OAAOb,CAAQ,EAAE,IAAI,iBAAiB,CACxC,CAAC,EAED,GAAG,mCAAoC,SAAY,CACjD,MAAMY,EAAY,CAChB,CAAE,EAAG,OAAO,IAAK,EAAG,EAAG,EACvB,CAAE,EAAG,GAAI,EAAG,OAAO,GAAI,EACvB,CAAE,EAAG,OAAO,kBAAmB,EAAG,EAAG,EACrC,CAAE,EAAG,GAAI,EAAG,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": ["DefaultTouchController", "postMock", "axiosFake", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
7
+ }
@@ -1,2 +1,2 @@
1
- const t={flex:{width:240,height:240},stax:{width:340,height:340}};export{t as DEFAULT_SCREENS};
1
+ import{DeviceModelId as e}from"@ledgerhq/device-management-kit";const o={[e.FLEX]:{width:480,height:600},[e.STAX]:{width:400,height:672}};export{o as DEFAULT_SCREENS};
2
2
  //# sourceMappingURL=defaultScreens.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/config/defaultScreens.ts"],
4
- "sourcesContent": ["export const DEFAULT_SCREENS = {\n flex: { width: 240, height: 240 },\n stax: { width: 340, height: 340 },\n} as const;\n\nexport type DefaultDeviceKey = keyof typeof DEFAULT_SCREENS & string;\n"],
5
- "mappings": "AAAO,MAAMA,EAAkB,CAC7B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC",
6
- "names": ["DEFAULT_SCREENS"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nexport const DEFAULT_SCREENS = {\n [DeviceModelId.FLEX]: { width: 480, height: 600 },\n [DeviceModelId.STAX]: { width: 400, height: 672 },\n} as const;\n\nexport type DefaultDeviceKey = keyof typeof DEFAULT_SCREENS & string;\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAEvB,MAAMC,EAAkB,CAC7B,CAACD,EAAc,IAAI,EAAG,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChD,CAACA,EAAc,IAAI,EAAG,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClD",
6
+ "names": ["DeviceModelId", "DEFAULT_SCREENS"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ButtonController.js.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=TouchController.js.map
@@ -1 +1,2 @@
1
+ var t=(e=>(e.PRESS="press",e.RELEASE="release",e.PRESS_AND_RELEASE="press-and-release",e))(t||{});export{t as SpeculosActions};
1
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
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": "AAsBO,IAAKA,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBAHVA,OAAA",
6
+ "names": ["SpeculosActions"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import i from"axios";import{Container as l}from"inversify";import{AxiosButtonController as s}from"./adapters/AxiosButtonController";import{AxiosTouchController as a}from"./adapters/AxiosTouchController";import{createAxes as c}from"./utils/axisClamp";import{speculosDeviceControllerTypes as t}from"../../src/internal/core/speculosDeviceControllerTypes";function x(r,e){const o=new l({defaultScope:"Singleton"}),n=i.create({baseURL:r.replace(/\/+$/,""),timeout:e.timeoutMs??1500,headers:{"X-Ledger-Client-Version":e.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}});return o.bind(t.HttpClient).toConstantValue(n),o.bind(t.Axes).toConstantValue(c(e.screens)),o.bind(t.ButtonController).to(s),o.bind(t.TouchController).to(a),o}export{x as buildContainer};
1
+ import i from"axios";import{DefaultButtonController as s}from"./adapters/DefaultButtonController";import{DefaultTouchController as c}from"./adapters/DefaultTouchController";import{createAxes as a}from"./utils/axisClamp";function f(r,o){const t=i.create({baseURL:r,timeout:o.timeoutMs??1500,headers:{"X-Ledger-Client-Version":o.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}}),e=a(o.screens),n=new s(t),l=new c(t,e);return{buttons:n,touch:l}}export{f as 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\";\nimport { Container } from \"inversify\";\n\nimport { AxiosButtonController } from \"@internal/adapters/AxiosButtonController\";\nimport { AxiosTouchController } from \"@internal/adapters/AxiosTouchController\";\nimport type { IButtonController } from \"@internal/core/IButtonController\";\nimport type { ITouchController } from \"@internal/core/ITouchController\";\nimport type { DeviceControllerOptions } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport { speculosDeviceControllerTypes } from \"@root/src/internal/core/speculosDeviceControllerTypes\";\n\nexport function buildContainer<K extends string>(\n baseURL: string,\n opts: DeviceControllerOptions<K>,\n) {\n const container = new Container({ defaultScope: \"Singleton\" });\n\n const http = axios.create({\n baseURL: baseURL.replace(/\\/+$/, \"\"),\n timeout: opts.timeoutMs ?? 1500,\n headers: {\n \"X-Ledger-Client-Version\": opts.clientHeader ?? \"ldmk-transport-speculos\",\n },\n transitional: { clarifyTimeoutError: true },\n });\n\n container\n .bind<AxiosInstance>(speculosDeviceControllerTypes.HttpClient)\n .toConstantValue(http);\n container\n .bind<AxisMap<K>>(speculosDeviceControllerTypes.Axes)\n .toConstantValue(createAxes(opts.screens));\n\n container\n .bind<IButtonController>(speculosDeviceControllerTypes.ButtonController)\n .to(AxiosButtonController);\n container\n .bind<ITouchController<K>>(speculosDeviceControllerTypes.TouchController)\n .to(AxiosTouchController);\n\n return container;\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAAmC,QAC1C,OAAS,aAAAC,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,2CACtC,OAAS,wBAAAC,MAA4B,0CAIrC,OAAuB,cAAAC,MAAkB,4BACzC,OAAS,iCAAAC,MAAqC,wDAEvC,SAASC,EACdC,EACAC,EACA,CACA,MAAMC,EAAY,IAAIR,EAAU,CAAE,aAAc,WAAY,CAAC,EAEvDS,EAAOV,EAAM,OAAO,CACxB,QAASO,EAAQ,QAAQ,OAAQ,EAAE,EACnC,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAED,OAAAC,EACG,KAAoBJ,EAA8B,UAAU,EAC5D,gBAAgBK,CAAI,EACvBD,EACG,KAAiBJ,EAA8B,IAAI,EACnD,gBAAgBD,EAAWI,EAAK,OAAO,CAAC,EAE3CC,EACG,KAAwBJ,EAA8B,gBAAgB,EACtE,GAAGH,CAAqB,EAC3BO,EACG,KAA0BJ,EAA8B,eAAe,EACvE,GAAGF,CAAoB,EAEnBM,CACT",
6
- "names": ["axios", "Container", "AxiosButtonController", "AxiosTouchController", "createAxes", "speculosDeviceControllerTypes", "buildContainer", "baseURL", "opts", "container", "http"]
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": "AAAA,OAAOA,MAAmC,QAE1C,OAAS,2BAAAC,MAA+B,6CACxC,OAAS,0BAAAC,MAA8B,4CAGvC,OAAuB,cAAAC,MAAkB,4BAQlC,SAASC,EACdC,EACAC,EACsB,CACtB,MAAMC,EAAsBP,EAAM,OAAO,CACvC,QAASK,EACT,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAEKE,EAAgBL,EAAWG,EAAK,OAAO,EAEvCG,EAA4B,IAAIR,EAAwBM,CAAI,EAC5DG,EAAyB,IAAIR,EAAuBK,EAAMC,CAAI,EAEpE,MAAO,CAAE,QAAAC,EAAS,MAAAC,CAAM,CAC1B",
6
+ "names": ["axios", "DefaultButtonController", "DefaultTouchController", "createAxes", "createDefaultControllers", "baseURL", "opts", "http", "axes", "buttons", "touch"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import r from"axios";import{afterEach as p,describe as i,expect as o,it as c,vi as n}from"vitest";import{DefaultButtonController as u}from"./adapters/DefaultButtonController";import{DefaultTouchController as m}from"./adapters/DefaultTouchController";import{createDefaultControllers as s}from"./di";const a={flex:{width:128,height:64},stax:{width:400,height:672}};p(()=>{n.restoreAllMocks()});i("createDefaultControllers - axios configuration",()=>{c("configures axios with normalised baseURL, custom timeout and header",()=>{const t=n.spyOn(r,"create").mockImplementation(l=>({post:n.fn(),defaults:{...l}}));s("http://example.com/api",{screens:a,timeoutMs:2345,clientHeader:"test-client"}),o(t).toHaveBeenCalledTimes(1);const e=t.mock.calls[0][0];o(e.baseURL).toBe("http://example.com/api"),o(e.timeout).toBe(2345),o(e.headers?.["X-Ledger-Client-Version"]).toBe("test-client"),o(e.transitional?.clarifyTimeoutError).toBe(!0)}),c("applies default timeout and client header when not provided",()=>{const t=n.spyOn(r,"create").mockImplementation(l=>({post:n.fn(),defaults:{...l}}));s("http://localhost:1234",{screens:a});const e=t.mock.calls[0][0];o(e.baseURL).toBe("http://localhost:1234"),o(e.timeout).toBe(1500),o(e.headers?.["X-Ledger-Client-Version"]).toBe("ldmk-transport-speculos")})});i("createDefaultControllers - wiring",()=>{c("returns axios implementations wired by the factory",()=>{const t={post:n.fn()};n.spyOn(r,"create").mockReturnValue(t);const{buttons:e,touch:l}=s("http://x",{screens:a});o(e).toBeInstanceOf(u),o(l).toBeInstanceOf(m),o(typeof e.press).toBe("function")}),c("creates fresh instances per invocation",()=>{n.spyOn(r,"create").mockReturnValueOnce({post:n.fn()}).mockReturnValueOnce({post:n.fn()});const t=s("http://x",{screens:a}),e=s("http://x",{screens:a});o(t.buttons).not.toBe(e.buttons),o(t.touch).not.toBe(e.touch)}),c("button.press posts the correct payload",async()=>{const t=n.fn().mockResolvedValue(void 0);n.spyOn(r,"create").mockReturnValue({post:t});const{buttons:e}=s("http://x",{screens:a});await e.press("left"),o(t).toHaveBeenCalledWith("/button/left",{action:"press-and-release"})}),c("touch.tapAndRelease maps percent to absolute coords",async()=>{const t=n.fn().mockResolvedValue(void 0);n.spyOn(r,"create").mockReturnValue({post:t});const{touch:e}=s("http://x",{screens:a});await e.tapAndRelease("flex",{x:50,y:50}),o(t).toHaveBeenCalledWith("/finger",{action:"press-and-release",x:64,y:32})})});
2
+ //# sourceMappingURL=di.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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": "AAMA,OAAOA,MAAW,QAClB,OAAS,aAAAC,EAAW,YAAAC,EAAU,UAAAC,EAAQ,MAAAC,EAAI,MAAAC,MAAU,SAEpD,OAAS,2BAAAC,MAA+B,6CACxC,OAAS,0BAAAC,MAA8B,4CAEvC,OAAS,4BAAAC,MAAgC,OAEzC,MAAMC,EAAU,CACd,KAAM,CAAE,MAAO,IAAK,OAAQ,EAAG,EAC/B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,EAEAR,EAAU,IAAM,CACdI,EAAG,gBAAgB,CACrB,CAAC,EAEDH,EAAS,iDAAkD,IAAM,CAC/DE,EAAG,sEAAuE,IAAM,CAC9E,MAAMM,EAAYL,EACf,MAAML,EAAO,QAAQ,EACrB,mBAAoBW,IACZ,CAAE,KAAMN,EAAG,GAAG,EAAG,SAAU,CAAE,GAAGM,CAAI,CAAE,EAC9C,EAEHH,EAAyB,yBAA0B,CACjD,QAASC,EACT,UAAW,KACX,aAAc,aAChB,CAAC,EAEDN,EAAOO,CAAS,EAAE,sBAAsB,CAAC,EACzC,MAAMC,EAAMD,EAAU,KAAK,MAAM,CAAC,EAAG,CAAC,EACtCP,EAAOQ,EAAI,OAAO,EAAE,KAAK,wBAAwB,EACjDR,EAAOQ,EAAI,OAAO,EAAE,KAAK,IA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,CAAE,QAASC,CAAQ,CAAC,EAEnEN,EAAOY,EAAE,OAAO,EAAE,IAAI,KAAKC,EAAE,OAAO,EACpCb,EAAOY,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,KAAK,CAClC,CAAC,EAEDZ,EAAG,yCAA0C,SAAY,CACvD,MAAMa,EAAOZ,EAAG,GAAG,EAAE,kBAAkB,MAAS,EAChDA,EAAG,MAAML,EAAO,QAAQ,EAAE,gBAAgB,CAAE,KAAAiB,CAAK,CAAQ,EAEzD,KAAM,CAAE,QAAAJ,CAAQ,EAAIL,EAAyB,WAAY,CACvD,QAASC,CACX,CAAC,EAED,MAAMI,EAAQ,MAAM,MAAM,EAC1BV,EAAOc,CAAI,EAAE,qBAAqB,eAAgB,CAChD,OAAQ,mBACV,CAAC,CACH,CAAC,EAEDb,EAAG,sDAAuD,SAAY,CACpE,MAAMa,EAAOZ,EAAG,GAAG,EAAE,kBAAkB,MAAS,EAChDA,EAAG,MAAML,EAAO,QAAQ,EAAE,gBAAgB,CAAE,KAAAiB,CAAK,CAAQ,EAEzD,KAAM,CAAE,MAAAH,CAAM,EAAIN,EAAyB,WAAY,CACrD,QAASC,CACX,CAAC,EAGD,MAAMK,EAAM,cAAc,OAAQ,CAAE,EAAG,GAAW,EAAG,EAAU,CAAC,EAEhEX,EAAOc,CAAI,EAAE,qBAAqB,UAAW,CAC3C,OAAQ,oBACR,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "afterEach", "describe", "expect", "it", "vi", "DefaultButtonController", "DefaultTouchController", "createDefaultControllers", "SCREENS", "createSpy", "cfg", "http", "buttons", "touch", "a", "b", "post"]
7
+ }
@@ -0,0 +1,2 @@
1
+ async function i(t,e,o=200){for(const r of e)await t.press(r),o>0&&await new Promise(n=>setTimeout(n,o))}function s(t){return{left:async()=>await t.press("left"),right:async()=>await t.press("right"),both:async()=>await t.press("both")}}export{s as pressButtons,i as pressSequence};
2
+ //# sourceMappingURL=buttonUseCases.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/use-cases/buttonUseCases.ts"],
4
+ "sourcesContent": ["import type { ButtonController } from \"@internal/core/ButtonController\";\nimport type { ButtonKey } from \"@internal/core/types\";\n\nconst DEFAULT_DELAY_MS = 200;\n\nexport async function pressSequence(\n buttons: ButtonController,\n keys: ButtonKey[],\n delayMs = DEFAULT_DELAY_MS,\n): Promise<void> {\n for (const k of keys) {\n await buttons.press(k);\n if (delayMs > 0) {\n await new Promise((r) => setTimeout(r, delayMs));\n }\n }\n}\n\nexport function pressButtons(buttons: ButtonController): {\n left: () => Promise<void>;\n right: () => Promise<void>;\n both: () => Promise<void>;\n} {\n return {\n left: async () => await buttons.press(\"left\"),\n right: async () => await buttons.press(\"right\"),\n both: async () => await buttons.press(\"both\"),\n };\n}\n"],
5
+ "mappings": "AAKA,eAAsBA,EACpBC,EACAC,EACAC,EAAU,IACK,CACf,UAAWC,KAAKF,EACd,MAAMD,EAAQ,MAAMG,CAAC,EACjBD,EAAU,GACZ,MAAM,IAAI,QAASE,GAAM,WAAWA,EAAGF,CAAO,CAAC,CAGrD,CAEO,SAASG,EAAaL,EAI3B,CACA,MAAO,CACL,KAAM,SAAY,MAAMA,EAAQ,MAAM,MAAM,EAC5C,MAAO,SAAY,MAAMA,EAAQ,MAAM,OAAO,EAC9C,KAAM,SAAY,MAAMA,EAAQ,MAAM,MAAM,CAC9C,CACF",
6
+ "names": ["pressSequence", "buttons", "keys", "delayMs", "k", "r", "pressButtons"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{pressButtons as r,pressSequence as i}from"./buttonUseCases";const a=()=>Promise.resolve();describe("buttonUsecases",()=>{let e;beforeEach(()=>{e={press:vi.fn(()=>Promise.resolve())}}),afterEach(()=>{vi.useRealTimers(),vi.restoreAllMocks()}),describe("pressButtons",()=>{it("returns functions that call controller.press with the correct keys",async()=>{const t=r(e);await t.left(),await t.right(),await t.both(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right"),expect(e.press).toHaveBeenNthCalledWith(3,"both")})}),describe("pressSequence",()=>{it("presses keys in order and waits the default 200ms after each key (including last)",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),s=i(e,["left","right","both"]);expect(e.press).toHaveBeenCalledTimes(1),expect(e.press).toHaveBeenNthCalledWith(1,"left"),await a(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),200),await vi.advanceTimersByTimeAsync(200),await a(),expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(2,"right"),await vi.advanceTimersByTimeAsync(200),await a(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(3,"both"),await vi.advanceTimersByTimeAsync(200),await expect(s).resolves.toBeUndefined()}),it("uses the provided custom delay",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),s=i(e,["left","right"],75);await a(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await a(),expect(t).toHaveBeenCalledTimes(2),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await expect(s).resolves.toBeUndefined()}),it("rejects if a press fails and stops processing subsequent keys",async()=>{vi.useFakeTimers();const t=new Error("oups");e.press.mockResolvedValueOnce(void 0).mockRejectedValueOnce(t);const s=i(e,["left","right","both"],50),n=expect(s).rejects.toThrow("oups");await Promise.resolve(),await vi.advanceTimersByTimeAsync(50),await Promise.resolve(),await n,expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right")})})});
2
+ //# sourceMappingURL=buttonUseCases.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/use-cases/buttonUseCases.test.ts"],
4
+ "sourcesContent": ["/* 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 { pressButtons, pressSequence } from \"./buttonUseCases\";\n\ntype ButtonKey = \"left\" | \"right\" | \"both\";\ntype ButtonController = { press: (k: ButtonKey) => Promise<void> };\n\nconst tick = () => Promise.resolve();\n\ndescribe(\"buttonUsecases\", () => {\n let controller: ButtonController & { press: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n controller = {\n press: vi.fn(() => Promise.resolve()),\n };\n });\n\n afterEach(() => {\n vi.useRealTimers();\n vi.restoreAllMocks();\n });\n\n describe(\"pressButtons\", () => {\n it(\"returns functions that call controller.press with the correct keys\", async () => {\n const api = pressButtons(controller);\n\n await api.left();\n await api.right();\n await api.both();\n\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n });\n });\n\n describe(\"pressSequence\", () => {\n it(\"presses keys in order and waits the default 200ms after each key (including last)\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const promise = pressSequence(controller, keys); // delay = 200\n\n // first press happens immediately (sync call of controller.press)\n expect(controller.press).toHaveBeenCalledTimes(1);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n\n // timeout is scheduled after the awaited press resolves\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 200);\n\n // first delay elapse -> second press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n\n // next delay -> third press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n\n // final post-press delay\n await vi.advanceTimersByTimeAsync(200);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"uses the provided custom delay\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\"];\n\n const promise = pressSequence(controller, keys, 75);\n\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(2);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"rejects if a press fails and stops processing subsequent keys\", async () => {\n vi.useFakeTimers();\n\n const err = new Error(\"oups\");\n controller.press\n .mockResolvedValueOnce(undefined) // first ok\n .mockRejectedValueOnce(err); // second fails\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const p = pressSequence(controller, keys, 50);\n\n const assertion = expect(p).rejects.toThrow(\"oups\");\n\n await Promise.resolve(); // let first setTimeout schedule\n await vi.advanceTimersByTimeAsync(50);\n await Promise.resolve();\n\n await assertion;\n\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n });\n });\n});\n"],
5
+ "mappings": "AAGA,OAAS,gBAAAA,EAAc,iBAAAC,MAAqB,mBAK5C,MAAMC,EAAO,IAAM,QAAQ,QAAQ,EAEnC,SAAS,iBAAkB,IAAM,CAC/B,IAAIC,EAEJ,WAAW,I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ertion"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const a=5e3,s=(t,e)=>async(o,r=a)=>{await t.tap(e,o),await new Promise(n=>setTimeout(n,r)),await t.release(e,o)},i=(t,e)=>async o=>await t.tapAndRelease(e,o);export{s as tapLong,i as tapQuick};
2
+ //# sourceMappingURL=touchUseCases.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"],
5
+ "mappings": "AAGA,MAAMA,EAAmB,IAEZC,EACX,CAAmBC,EAA2BC,IAC9C,MAAOC,EAA2BC,EAAkBL,IAAqB,CACvE,MAAME,EAAM,IAAIC,EAAWC,CAAK,EAChC,MAAM,IAAI,QAASE,GAAM,WAAWA,EAAGD,CAAO,CAAC,EAC/C,MAAMH,EAAM,QAAQC,EAAWC,CAAK,CACtC,EAEWG,EACX,CAAmBL,EAA2BC,IAC9C,MAAOC,GACL,MAAMF,EAAM,cAAcC,EAAWC,CAAK",
6
+ "names": ["TAP_LONG_TIME_MS", "tapLong", "touch", "deviceKey", "point", "delayMs", "r", "tapQuick"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{tapLong as l,tapQuick as c}from"./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 c(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"),n=l(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 n,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=l(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 n=l(e,a)(t);await expect(n).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=l(e,a)(t),n=expect(s).rejects.toThrow("release failed");await Promise.resolve(),await vi.advanceTimersByTimeAsync(5e3),await n,expect(e.tap).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledTimes(1)})});
2
+ //# sourceMappingURL=touchUseCases.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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,OAAS,WAAAA,EAAS,YAAAC,MAAgB,kBAElC,SAAS,gBAAiB,IAAM,CAC9B,MAAMC,EAAY,OACZC,EAAQ,CAAE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ller", "timeoutSpy", "run", "customMs", "boom", "p", "assertion"]
7
+ }
@@ -1,2 +1,2 @@
1
- const n=e=>Math.max(0,Math.min(100,e))/100,s=e=>t=>Math.floor(e*n(t)),c=e=>t=>Math.floor(e*n(t)),a=(e,t)=>({vw:s(e),vh:c(t),xy:(r,o)=>({x:Math.floor(e*n(r)),y:Math.floor(t*n(o))})}),x=e=>{const t={};for(const r of Object.keys(e)){const o=e[r];t[r]=a(o.width,o.height)}return t};export{x as createAxes,a as createAxis,c as createVH,s as createVW};
1
+ const c=e=>Math.max(0,Math.min(100,e))/100,s=e=>t=>Math.floor(e*c(t)),o=(e,t)=>({vw:s(e),vh:s(t),xy:(r,n)=>({x:s(e)(r),y:s(t)(n)})}),p=e=>{const t={};for(const r of Object.keys(e)){const n=e[r];t[r]=o(n.width,n.height)}return t};export{s as clampValue,p as createAxes,o as createAxis};
2
2
  //# sourceMappingURL=axisClamp.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/utils/axisClamp.ts"],
4
- "sourcesContent": ["import type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nconst clamp = (pct: number) => Math.max(0, Math.min(100, pct)) / 100;\n\nexport const createVW = (width: number) => (pct: Percent) =>\n Math.floor(width * clamp(pct));\nexport const createVH = (height: number) => (pct: Percent) =>\n Math.floor(height * clamp(pct));\n\nexport const createAxis = (width: number, height: number) => ({\n vw: createVW(width),\n vh: createVH(height),\n xy: (xPct: Percent, yPct: Percent) => ({\n x: Math.floor(width * clamp(xPct)),\n y: Math.floor(height * clamp(yPct)),\n }),\n});\n\nexport type Axis = ReturnType<typeof createAxis>;\nexport type AxisMap<K extends string = string> = Record<K, Axis>;\n\nexport const createAxes = <K extends string>(\n screens: DeviceScreens<K>,\n): AxisMap<K> => {\n const out = {} as AxisMap<K>;\n for (const key of Object.keys(screens) as K[]) {\n const s = screens[key];\n out[key] = createAxis(s.width, s.height);\n }\n return out;\n};\n"],
5
- "mappings": "AAEA,MAAMA,EAASC,GAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKA,CAAG,CAAC,EAAI,IAEpDC,EAAYC,GAAmBF,GAC1C,KAAK,MAAME,EAAQH,EAAMC,CAAG,CAAC,EAClBG,EAAYC,GAAoBJ,GAC3C,KAAK,MAAMI,EAASL,EAAMC,CAAG,CAAC,EAEnBK,EAAa,CAACH,EAAeE,KAAoB,CAC5D,GAAIH,EAASC,CAAK,EAClB,GAAIC,EAASC,CAAM,EACnB,GAAI,CAACE,EAAeC,KAAmB,CACrC,EAAG,KAAK,MAAML,EAAQH,EAAMO,CAAI,CAAC,EACjC,EAAG,KAAK,MAAMF,EAASL,EAAMQ,CAAI,CAAC,CACpC,EACF,GAKaC,EACXC,GACe,CACf,MAAMC,EAAM,CAAC,EACb,UAAWC,KAAO,OAAO,KAAKF,CAAO,EAAU,CAC7C,MAAMG,EAAIH,EAAQE,CAAG,EACrBD,EAAIC,CAAG,EAAIN,EAAWO,EAAE,MAAOA,EAAE,MAAM,CACzC,CACA,OAAOF,CACT",
6
- "names": ["clamp", "pct", "createVW", "width", "createVH", "height", "createAxis", "xPct", "yPct", "createAxes", "screens", "out", "key", "s"]
4
+ "sourcesContent": ["import type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nconst clamp = (pct: number) => Math.max(0, Math.min(100, pct)) / 100;\n\nexport const clampValue = (value: number) => (pct: Percent) =>\n Math.floor(value * clamp(pct));\n\nexport const createAxis = (width: number, height: number) => ({\n vw: clampValue(width),\n vh: clampValue(height),\n xy: (xPct: Percent, yPct: Percent) => ({\n x: clampValue(width)(xPct),\n y: clampValue(height)(yPct),\n }),\n});\n\nexport type Axis = ReturnType<typeof createAxis>;\nexport type AxisMap<K extends string = string> = Record<K, Axis>;\n\nexport const createAxes = <K extends string>(\n screens: DeviceScreens<K>,\n): AxisMap<K> => {\n const mappedAxes = {} as AxisMap<K>;\n for (const key of Object.keys(screens) as K[]) {\n const screen = screens[key];\n mappedAxes[key] = createAxis(screen.width, screen.height);\n }\n return mappedAxes;\n};\n"],
5
+ "mappings": "AAEA,MAAMA,EAASC,GAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,IAAKA,CAAG,CAAC,EAAI,IAEpDC,EAAcC,GAAmBF,GAC5C,KAAK,MAAME,EAAQH,EAAMC,CAAG,CAAC,EAElBG,EAAa,CAACC,EAAeC,KAAoB,CAC5D,GAAIJ,EAAWG,CAAK,EACpB,GAAIH,EAAWI,CAAM,EACrB,GAAI,CAACC,EAAeC,KAAmB,CACrC,EAAGN,EAAWG,CAAK,EAAEE,CAAI,EACzB,EAAGL,EAAWI,CAAM,EAAEE,CAAI,CAC5B,EACF,GAKaC,EACXC,GACe,CACf,MAAMC,EAAa,CAAC,EACpB,UAAWC,KAAO,OAAO,KAAKF,CAAO,EAAU,CAC7C,MAAMG,EAASH,EAAQE,CAAG,EAC1BD,EAAWC,CAAG,EAAIR,EAAWS,EAAO,MAAOA,EAAO,MAAM,CAC1D,CACA,OAAOF,CACT",
6
+ "names": ["clamp", "pct", "clampValue", "value", "createAxis", "width", "height", "xPct", "yPct", "createAxes", "screens", "mappedAxes", "key", "screen"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{clampValue as o,createAxes as s,createAxis as x}from"./axisClamp";const e=t=>t;describe("axisClamp helpers",()=>{describe("clampValue",()=>{it("floors and clamps to [0, width]",()=>{const t=o(200);expect(t(e(0))).toBe(0),expect(t(e(50))).toBe(100),expect(t(e(50.4))).toBe(100),expect(t(e(50.5))).toBe(101),expect(t(e(100))).toBe(200),expect(t(e(150))).toBe(200),expect(t(e(-10))).toBe(0)})}),describe("createAxis",()=>{it("exposes vw, vh and xy with consistent flooring + clamping",()=>{const t=x(300,200);expect(t.vw(e(25))).toBe(75),expect(t.vh(e(75))).toBe(150),expect(t.xy(e(10),e(90))).toEqual({x:30,y:180}),expect(t.xy(e(150),e(-20))).toEqual({x:300,y:0});const c=t.xy(e(33.4),e(66.6));expect(c.x).toBe(Math.floor(300*.334)),expect(c.y).toBe(Math.floor(200*.666))})}),describe("createAxes",()=>{it("creates an AxisMap for all device keys with matching dimensions",()=>{const c=s({devA:{width:200,height:100},devB:{width:320,height:480}});expect(Object.keys(c).sort()).toEqual(["devA","devB"]),expect(c.devA.vw(e(100))).toBe(200),expect(c.devA.vh(e(100))).toBe(100),expect(c.devA.xy(e(120),e(-10))).toEqual({x:200,y:0}),expect(c.devB.vw(e(50))).toBe(160),expect(c.devB.vh(e(50))).toBe(240),expect(c.devB.xy(e(33.3),e(66.7))).toEqual({x:Math.floor(320*.333),y:Math.floor(480*.667)})})})});
2
+ //# sourceMappingURL=axisClamp.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/utils/axisClamp.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nimport { type AxisMap, clampValue, createAxes, createAxis } from \"./axisClamp\";\n\nconst p = (n: number) => n as unknown as Percent;\n\ndescribe(\"axisClamp helpers\", () => {\n describe(\"clampValue\", () => {\n it(\"floors and clamps to [0, width]\", () => {\n const clamp = clampValue(200);\n\n expect(clamp(p(0))).toBe(0);\n expect(clamp(p(50))).toBe(100); // 200 * 0.5 = 100\n expect(clamp(p(50.4))).toBe(100); // floor(200 * 0.504) = 100\n expect(clamp(p(50.5))).toBe(101); // floor(200 * 0.505) = 101\n expect(clamp(p(100))).toBe(200);\n expect(clamp(p(150))).toBe(200); // clamped\n expect(clamp(p(-10))).toBe(0); // clamped\n });\n });\n\n describe(\"createAxis\", () => {\n it(\"exposes vw, vh and xy with consistent flooring + clamping\", () => {\n const axis = createAxis(300, 200);\n\n // vw / vh\n expect(axis.vw(p(25))).toBe(75); // 300 * 0.25\n expect(axis.vh(p(75))).toBe(150); // 200 * 0.75\n\n // xy nominal\n expect(axis.xy(p(10), p(90))).toEqual({ x: 30, y: 180 });\n\n // xy clamps both axes\n expect(axis.xy(p(150), p(-20))).toEqual({ x: 300, y: 0 });\n\n // flooring behavior with fractional percent\n const xy = axis.xy(p(33.4), p(66.6));\n expect(xy.x).toBe(Math.floor(300 * 0.334));\n expect(xy.y).toBe(Math.floor(200 * 0.666));\n });\n });\n\n describe(\"createAxes\", () => {\n it(\"creates an AxisMap for all device keys with matching dimensions\", () => {\n const screens: DeviceScreens<\"devA\" | \"devB\"> = {\n devA: { width: 200, height: 100 } as any,\n devB: { width: 320, height: 480 } as any,\n };\n\n const axes: AxisMap<\"devA\" | \"devB\"> = createAxes(screens);\n\n // contains both keys\n expect(Object.keys(axes).sort()).toEqual([\"devA\", \"devB\"]);\n\n // devA\n expect(axes.devA.vw(p(100))).toBe(200);\n expect(axes.devA.vh(p(100))).toBe(100);\n expect(axes.devA.xy(p(120), p(-10))).toEqual({ x: 200, y: 0 });\n\n // devB\n expect(axes.devB.vw(p(50))).toBe(160);\n expect(axes.devB.vh(p(50))).toBe(240);\n expect(axes.devB.xy(p(33.3), p(66.7))).toEqual({\n x: Math.floor(320 * 0.333),\n y: Math.floor(480 * 0.667),\n });\n });\n });\n});\n"],
5
+ "mappings": "AAMA,OAAuB,cAAAA,EAAY,cAAAC,EAAY,cAAAC,MAAkB,cAEjE,MAAMC,EAAKC,GAAcA,EAEzB,SAAS,oBAAqB,IAAM,CAClC,SAAS,aAAc,IAAM,CAC3B,GAAG,kCAAmC,IAAM,CAC1C,MAAMC,EAAQL,EAAW,GAAG,EAE5B,OAAOK,EAAMF,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAC1B,OAAOE,EAAMF,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EAC7B,OAAOE,EAAMF,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,EAC/B,OAAOE,EAAM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