@ledgerhq/speculos-device-controller 0.0.0-develop-20251022001229

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 (126) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +99 -0
  3. package/lib/cjs/index.js +2 -0
  4. package/lib/cjs/index.js.map +7 -0
  5. package/lib/cjs/package.json +53 -0
  6. package/lib/cjs/src/api/DeviceController.js +2 -0
  7. package/lib/cjs/src/api/DeviceController.js.map +7 -0
  8. package/lib/cjs/src/api/DeviceController.test.js +2 -0
  9. package/lib/cjs/src/api/DeviceController.test.js.map +7 -0
  10. package/lib/cjs/src/index.js +2 -0
  11. package/lib/cjs/src/index.js.map +7 -0
  12. package/lib/cjs/src/internal/adapters/DefaultButtonController.js +2 -0
  13. package/lib/cjs/src/internal/adapters/DefaultButtonController.js.map +7 -0
  14. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js +2 -0
  15. package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js.map +7 -0
  16. package/lib/cjs/src/internal/adapters/DefaultTouchController.js +2 -0
  17. package/lib/cjs/src/internal/adapters/DefaultTouchController.js.map +7 -0
  18. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js +2 -0
  19. package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js.map +7 -0
  20. package/lib/cjs/src/internal/config/defaultScreens.js +2 -0
  21. package/lib/cjs/src/internal/config/defaultScreens.js.map +7 -0
  22. package/lib/cjs/src/internal/core/ButtonController.js +2 -0
  23. package/lib/cjs/src/internal/core/ButtonController.js.map +7 -0
  24. package/lib/cjs/src/internal/core/TouchController.js +2 -0
  25. package/lib/cjs/src/internal/core/TouchController.js.map +7 -0
  26. package/lib/cjs/src/internal/core/types.js +2 -0
  27. package/lib/cjs/src/internal/core/types.js.map +7 -0
  28. package/lib/cjs/src/internal/di.js +2 -0
  29. package/lib/cjs/src/internal/di.js.map +7 -0
  30. package/lib/cjs/src/internal/di.test.js +2 -0
  31. package/lib/cjs/src/internal/di.test.js.map +7 -0
  32. package/lib/cjs/src/internal/use-cases/buttonUseCases.js +2 -0
  33. package/lib/cjs/src/internal/use-cases/buttonUseCases.js.map +7 -0
  34. package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js +2 -0
  35. package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js.map +7 -0
  36. package/lib/cjs/src/internal/use-cases/touchUseCases.js +2 -0
  37. package/lib/cjs/src/internal/use-cases/touchUseCases.js.map +7 -0
  38. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js +2 -0
  39. package/lib/cjs/src/internal/use-cases/touchUseCases.test.js.map +7 -0
  40. package/lib/cjs/src/internal/utils/axisClamp.js +2 -0
  41. package/lib/cjs/src/internal/utils/axisClamp.js.map +7 -0
  42. package/lib/cjs/src/internal/utils/axisClamp.test.js +2 -0
  43. package/lib/cjs/src/internal/utils/axisClamp.test.js.map +7 -0
  44. package/lib/esm/index.js +2 -0
  45. package/lib/esm/index.js.map +7 -0
  46. package/lib/esm/package.json +53 -0
  47. package/lib/esm/src/api/DeviceController.js +2 -0
  48. package/lib/esm/src/api/DeviceController.js.map +7 -0
  49. package/lib/esm/src/api/DeviceController.test.js +2 -0
  50. package/lib/esm/src/api/DeviceController.test.js.map +7 -0
  51. package/lib/esm/src/index.js +2 -0
  52. package/lib/esm/src/index.js.map +7 -0
  53. package/lib/esm/src/internal/adapters/DefaultButtonController.js +2 -0
  54. package/lib/esm/src/internal/adapters/DefaultButtonController.js.map +7 -0
  55. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js +2 -0
  56. package/lib/esm/src/internal/adapters/DefaultButtonController.test.js.map +7 -0
  57. package/lib/esm/src/internal/adapters/DefaultTouchController.js +2 -0
  58. package/lib/esm/src/internal/adapters/DefaultTouchController.js.map +7 -0
  59. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js +2 -0
  60. package/lib/esm/src/internal/adapters/DefaultTouchController.test.js.map +7 -0
  61. package/lib/esm/src/internal/config/defaultScreens.js +2 -0
  62. package/lib/esm/src/internal/config/defaultScreens.js.map +7 -0
  63. package/lib/esm/src/internal/core/ButtonController.js +1 -0
  64. package/lib/esm/src/internal/core/ButtonController.js.map +7 -0
  65. package/lib/esm/src/internal/core/TouchController.js +1 -0
  66. package/lib/esm/src/internal/core/TouchController.js.map +7 -0
  67. package/lib/esm/src/internal/core/types.js +2 -0
  68. package/lib/esm/src/internal/core/types.js.map +7 -0
  69. package/lib/esm/src/internal/di.js +2 -0
  70. package/lib/esm/src/internal/di.js.map +7 -0
  71. package/lib/esm/src/internal/di.test.js +2 -0
  72. package/lib/esm/src/internal/di.test.js.map +7 -0
  73. package/lib/esm/src/internal/use-cases/buttonUseCases.js +2 -0
  74. package/lib/esm/src/internal/use-cases/buttonUseCases.js.map +7 -0
  75. package/lib/esm/src/internal/use-cases/buttonUseCases.test.js +2 -0
  76. package/lib/esm/src/internal/use-cases/buttonUseCases.test.js.map +7 -0
  77. package/lib/esm/src/internal/use-cases/touchUseCases.js +2 -0
  78. package/lib/esm/src/internal/use-cases/touchUseCases.js.map +7 -0
  79. package/lib/esm/src/internal/use-cases/touchUseCases.test.js +2 -0
  80. package/lib/esm/src/internal/use-cases/touchUseCases.test.js.map +7 -0
  81. package/lib/esm/src/internal/utils/axisClamp.js +2 -0
  82. package/lib/esm/src/internal/utils/axisClamp.js.map +7 -0
  83. package/lib/esm/src/internal/utils/axisClamp.test.js +2 -0
  84. package/lib/esm/src/internal/utils/axisClamp.test.js.map +7 -0
  85. package/lib/types/index.d.ts +2 -0
  86. package/lib/types/index.d.ts.map +1 -0
  87. package/lib/types/src/api/DeviceController.d.ts +24 -0
  88. package/lib/types/src/api/DeviceController.d.ts.map +1 -0
  89. package/lib/types/src/api/DeviceController.test.d.ts +2 -0
  90. package/lib/types/src/api/DeviceController.test.d.ts.map +1 -0
  91. package/lib/types/src/index.d.ts +2 -0
  92. package/lib/types/src/index.d.ts.map +1 -0
  93. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts +9 -0
  94. package/lib/types/src/internal/adapters/DefaultButtonController.d.ts.map +1 -0
  95. package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts +2 -0
  96. package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts.map +1 -0
  97. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts +15 -0
  98. package/lib/types/src/internal/adapters/DefaultTouchController.d.ts.map +1 -0
  99. package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts +2 -0
  100. package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts.map +1 -0
  101. package/lib/types/src/internal/config/defaultScreens.d.ts +12 -0
  102. package/lib/types/src/internal/config/defaultScreens.d.ts.map +1 -0
  103. package/lib/types/src/internal/core/ButtonController.d.ts +5 -0
  104. package/lib/types/src/internal/core/ButtonController.d.ts.map +1 -0
  105. package/lib/types/src/internal/core/TouchController.d.ts +7 -0
  106. package/lib/types/src/internal/core/TouchController.d.ts.map +1 -0
  107. package/lib/types/src/internal/core/types.d.ts +23 -0
  108. package/lib/types/src/internal/core/types.d.ts.map +1 -0
  109. package/lib/types/src/internal/di.d.ts +9 -0
  110. package/lib/types/src/internal/di.d.ts.map +1 -0
  111. package/lib/types/src/internal/di.test.d.ts +2 -0
  112. package/lib/types/src/internal/di.test.d.ts.map +1 -0
  113. package/lib/types/src/internal/use-cases/buttonUseCases.d.ts +9 -0
  114. package/lib/types/src/internal/use-cases/buttonUseCases.d.ts.map +1 -0
  115. package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts +2 -0
  116. package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts.map +1 -0
  117. package/lib/types/src/internal/use-cases/touchUseCases.d.ts +5 -0
  118. package/lib/types/src/internal/use-cases/touchUseCases.d.ts.map +1 -0
  119. package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts +2 -0
  120. package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts.map +1 -0
  121. package/lib/types/src/internal/utils/axisClamp.d.ts +14 -0
  122. package/lib/types/src/internal/utils/axisClamp.d.ts.map +1 -0
  123. package/lib/types/src/internal/utils/axisClamp.test.d.ts +2 -0
  124. package/lib/types/src/internal/utils/axisClamp.test.d.ts.map +1 -0
  125. package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
  126. package/package.json +52 -0
package/LICENSE.MD ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024-present Ledger
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # speculos-device-controller
2
+
3
+ A tiny TypeScript SDK for driving **Speculos** devices:
4
+
5
+ - **Buttons**: `press(...)`, `left`, `right`, `both`, and `pressSequence([...])`
6
+ - **Tap**: **percentage-based** `tapQuick(...)`, `tapLong(...)`
7
+ - **Flexible screens config**: use built-in `"flex"`/`"stax"` defaults or supply your own device screen size
8
+
9
+ ---
10
+
11
+ ## Quick start
12
+
13
+ Out of the box, the API ships with default device screens sizes ("flex" and "stax"). You can use them without passing any options.
14
+
15
+ ```ts
16
+ import { deviceControllerClientFactory } from "speculos-device-controller";
17
+
18
+ const deviceClient = deviceControllerClientFactory("http://localhost:4000");
19
+
20
+ // Buttons
21
+ const deviceButtons = deviceClient.buttonFactory();
22
+
23
+ await deviceButtons.press("both");
24
+ await deviceButtons.left();
25
+ await deviceButtons.right();
26
+ await deviceButtons.both();
27
+ await deviceButtons.pressSequence(["left", "right", "both"], 150);
28
+
29
+ // Tap: percentages (0..100)
30
+ await deviceClient.tapFactory("flex").tapQuick({ x: 20, y: 45 }); // 20% / 45% of the "flex" screen
31
+
32
+ // You can easily instantiate tap devices dynamically
33
+ const currentDeviceTap = deviceClient.tapFactory(currentDevice);
34
+ await currentDeviceTap.tapLong({ x: 20, y: 45 });
35
+ ```
36
+
37
+ Under the hood, percentages are clamped to [0, 100] and converted to pixels using the screen spec for the selected device key.
38
+
39
+ ### Override default sizes (keep "flex"/"stax" keys)
40
+
41
+ ```ts
42
+ const deviceClient = deviceControllerClientFactory("http://localhost:4000", {
43
+ timeoutMs: 2000, // optional axios timeout
44
+ clientHeader: "ldmk-transport-speculos", // optional header
45
+ screens: {
46
+ // override by default keys
47
+ flex: { width: 256, height: 256 },
48
+ // stax: { width: 340, height: 340 }, // you can override one or both
49
+ },
50
+ });
51
+ ```
52
+
53
+ ### Provide custom screens
54
+
55
+ ```ts
56
+ const deviceClient = deviceControllerClientFactory("http://localhost:4000", {
57
+ screens: {
58
+ custom: { width: 128, height: 64 },
59
+ },
60
+ });
61
+
62
+ await deviceClient.tapFactory("custom").tapQuick({ x: 50, y: 50 }); // ok
63
+ // await deviceClient.tapFactory("unknown").tapQuick({ x: 10, y: 10 }); // throws: Unknown device key "unknown"
64
+ ```
65
+
66
+ ## API
67
+
68
+ ```ts
69
+ type ButtonKey = "left" | "right" | "both";
70
+ type Percent = Range<101>; // 0 to 100
71
+ type PercentCoordinates = { x: Percent; y: Percent };
72
+
73
+ type ButtonFactory = () => {
74
+ press(key: ButtonKey): Promise<void>;
75
+ left(): Promise<void>;
76
+ right(): Promise<void>;
77
+ both(): Promise<void>;
78
+ pressSequence(keys: ButtonKey[], delayMs?: number): Promise<void>;
79
+ };
80
+
81
+ type TapFactory = (deviceKey: string) => {
82
+ tapQuick: (point: PercentCoordinates) => Promise<void>;
83
+ tapLong: (point: PercentCoordinates) => Promise<void>;
84
+ };
85
+
86
+ type DeviceControllerClient = {
87
+ buttonFactory: ButtonFactory;
88
+ tapFactory: TapFactory;
89
+ };
90
+
91
+ type DeviceControllerClientFactory = (
92
+ baseURL: string,
93
+ opts?: {
94
+ timeoutMs?: number; // axios timeout (ms)
95
+ clientHeader?: string; // "X-Ledger-Client-Version" header
96
+ screens?: DeviceScreens<string>;
97
+ },
98
+ ) => DeviceControllerClient;
99
+ ```
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./src/index"),module.exports);0&&(module.exports={...require("./src/index")});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../index.ts"],
4
+ "sourcesContent": ["export * from \"./src/index\";\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,uBAAd",
6
+ "names": ["index_exports", "__toCommonJS", "__reExport"]
7
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@ledgerhq/speculos-device-controller",
3
+ "version": "0.0.1",
4
+ "license": "Apache-2.0",
5
+ "private": false,
6
+ "exports": {
7
+ ".": {
8
+ "types": "./lib/types/index.d.ts",
9
+ "import": "./lib/esm/index.js",
10
+ "require": "./lib/cjs/index.js"
11
+ },
12
+ "./*": {
13
+ "types": "./lib/types/*",
14
+ "import": "./lib/esm/*",
15
+ "require": "./lib/cjs/*"
16
+ }
17
+ },
18
+ "files": [
19
+ "./lib"
20
+ ],
21
+ "scripts": {
22
+ "prebuild": "rimraf lib",
23
+ "build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
24
+ "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
25
+ "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
26
+ "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
27
+ "lint": "eslint",
28
+ "lint:fix": "pnpm lint --fix",
29
+ "postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
30
+ "prettier": "prettier . --check",
31
+ "prettier:fix": "prettier . --write",
32
+ "typecheck": "tsc --noEmit",
33
+ "test": "vitest run --passWithNoTests",
34
+ "test:watch": "vitest --passWithNoTests",
35
+ "test:coverage": "vitest run --coverage --passWithNoTests"
36
+ },
37
+ "dependencies": {
38
+ "@ledgerhq/device-management-kit": "workspace:*",
39
+ "@sentry/minimal": "catalog:",
40
+ "axios": "catalog:"
41
+ },
42
+ "devDependencies": {
43
+ "@ledgerhq/eslint-config-dsdk": "workspace:*",
44
+ "@ledgerhq/ldmk-tool": "workspace:*",
45
+ "@ledgerhq/prettier-config-dsdk": "workspace:*",
46
+ "@ledgerhq/tsconfig-dsdk": "workspace:*",
47
+ "@ledgerhq/vitest-config-dmk": "workspace:*",
48
+ "ts-node": "catalog:"
49
+ },
50
+ "peerDependencies": {
51
+ "@ledgerhq/device-management-kit": "workspace:*"
52
+ }
53
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},D=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!v.call(t,o)&&o!==r&&l(t,o,{get:()=>e[o],enumerable:!(n=m(e,o))||n.enumerable});return t};var F=t=>D(l({},"__esModule",{value:!0}),t);var g={};d(g,{deviceControllerClientFactory:()=>f});module.exports=F(g);var a=require("../internal/config/defaultScreens"),u=require("../../src/internal/di"),s=require("../../src/internal/use-cases/buttonUseCases"),c=require("../../src/internal/use-cases/touchUseCases");const f=(t,e={})=>{const r={screens:e.screens??a.DEFAULT_SCREENS,timeoutMs:e.timeoutMs,clientHeader:e.clientHeader},{buttons:n,touch:o}=(0,u.createDefaultControllers)(t,r),p=(0,s.pressButtons)(n);return{buttonFactory:()=>({press:i=>n.press(i),left:()=>p.left(),right:()=>p.right(),both:()=>p.both(),pressSequence:(i,y)=>(0,s.pressSequence)(n,i,y)}),tapFactory:i=>({tapQuick:(0,c.tapQuick)(o,i),tapLong:(0,c.tapLong)(o,i)})}};0&&(module.exports={deviceControllerClientFactory});
2
+ //# sourceMappingURL=DeviceController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/api/DeviceController.ts"],
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,2CAQhCC,EAAyC,iCACzCC,EAGO,uDACPC,EAAkC,sDA4B3B,MAAML,EAA+D,CAC1EM,EACAC,EAAO,CAAC,IACL,CACH,MAAMC,EAAoC,CACxC,QAASD,EAAK,SAAW,kBACzB,UAAWA,EAAK,UAChB,aAAcA,EAAK,YACrB,EAEM,CAAE,QAAAE,EAAS,MAAAC,CAAM,KAAI,4BAAyBJ,EAASE,CAAQ,EAC/DG,KAAQ,gBAAaF,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,OAAY,iBAAcL,EAASI,EAAMC,CAAO,CACxE,GACA,WAAaF,IAAS,CACpB,YAAU,YAASF,EAAOE,CAAG,EAC7B,WAAS,WAAQF,EAAOE,CAAG,CAC7B,EACF,CACF",
6
+ "names": ["DeviceController_exports", "__export", "deviceControllerClientFactory", "__toCommonJS", "import_defaultScreens", "import_di", "import_buttonUseCases", "import_touchUseCases", "baseURL", "opts", "resolved", "buttons", "touch", "press", "key", "keys", "delayMs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("./DeviceController");describe("deviceControllerClientFactory",()=>{it("returns a DeviceControllerdeviceClient with the expected shape",()=>{const e=(0,o.deviceControllerClientFactory)("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=(0,o.deviceControllerClientFactory)("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=(0,o.deviceControllerClientFactory)("http://localhost:0"),t=(0,o.deviceControllerClientFactory)("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,IAAAA,EAA8C,8BAE9C,SAAS,gCAAiC,IAAM,CAC9C,GAAG,iEAAkE,IAAM,CACzE,MAAMC,KAAe,iCAA8B,oBAAoB,EAEvE,OAAOA,CAAY,EAAE,YAAY,EACjC,OAAOA,CAAY,EAAE,eAAe,eAAe,EACnD,OAAOA,CAAY,EAAE,eAAe,YAAY,EAEhD,MAAMC,EAAgBD,EAAa,cAAc,EAGjD,OAAO,OAAOC,EAAc,KAAK,EAAE,KAAK,UAAU,EAClD,OAAO,OAAOA,EAAc,IAAI,EAAE,KAAK,UAAU,EACjD,OAAO,OAAOA,EAAc,KAAK,EAAE,KAAK,UAAU,EAClD,OAAO,OAAOA,EAAc,IAAI,EAAE,KAAK,UAAU,EACjD,OAAO,OAAOA,EAAc,aAAa,EAAE,KAAK,UAAU,EAE1D,MAAMC,EAAaF,EAAa,WAAW,MAAM,EAGjD,OAAO,OAAOE,EAAW,QAAQ,EAAE,KAAK,UAAU,EAClD,OAAO,OAAOA,EAAW,OAAO,EAAE,KAAK,UAAU,CACnD,CAAC,EAED,GAAG,kDAAmD,IAAM,CAK1D,MAAMF,KAAe,iCAA8B,qBAAsB,CACvE,aAAc,aACd,UAAW,IACX,QAPqC,CACrC,OAAQ,CAAE,MAAO,IAAK,OAAQ,EAAG,EACjC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,CAKA,CAAC,EACD,OAAOA,CAAY,EAAE,WAAW,CAClC,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,MAAMG,KAAI,iCAA8B,oBAAoB,EACtDC,KAAI,iCAA8B,oBAAoB,EAE5D,OAAOD,CAAC,EAAE,IAAI,KAAKC,CAAC,EACpB,OAAOD,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,cAAc,EAAE,KAAK,EAChE,OAAOD,EAAE,WAAW,MAAM,EAAE,QAAQ,EAAE,IAAI,KACxCC,EAAE,WAAW,MAAM,EAAE,QACvB,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_DeviceController", "deviceClient", "deviceButtons", "deviceTaps", "a", "b"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./api/DeviceController"),module.exports);0&&(module.exports={...require("./api/DeviceController")});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts"],
4
+ "sourcesContent": ["export * from \"./api/DeviceController\";\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,kCAAd",
6
+ "names": ["src_exports", "__toCommonJS", "__reExport"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(o,t)=>{for(var e in t)r(o,e,{get:t[e],enumerable:!0})},u=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!c.call(o,n)&&n!==e&&r(o,n,{get:()=>t[n],enumerable:!(i=l(t,n))||i.enumerable});return o};var m=o=>u(r({},"__esModule",{value:!0}),o);var B={};p(B,{DefaultButtonController:()=>y});module.exports=m(B);var s=require("../core/types");class y{constructor(t){this.client=t}async press(t){await this.client.post(`/button/${t}`,{action:s.SpeculosActions.PRESS_AND_RELEASE})}}0&&(module.exports={DefaultButtonController});
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAAgD,gCAEzC,MAAMF,CAAoD,CAC/D,YAA6BG,EAAuB,CAAvB,YAAAA,CAAwB,CAErD,MAAM,MAAMC,EAA+B,CACzC,MAAM,KAAK,OAAO,KAAK,WAAWA,CAAG,GAAI,CACvC,OAAQ,kBAAgB,iBAC1B,CAAC,CACH,CACF",
6
+ "names": ["DefaultButtonController_exports", "__export", "DefaultButtonController", "__toCommonJS", "import_types", "client", "key"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=require("./DefaultButtonController");describe("DefaultButtonController",()=>{let e,s,o;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o=new n.DefaultButtonController(s)});const a=["left","right","both"];it.each(a)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
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,IAAAA,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,CAAE,OAAQ,IAAK,KAAM,CAAC,CAAE,CAAC,EAC9DC,EAAY,CAAE,KAAMD,CAAS,EAC7BE,EAAa,IAAI,0BAAwBD,CAAS,CACpD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
6
+ "names": ["import_DefaultButtonController", "postMock", "axiosFake", "controller", "keys", "key", "error"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(s,t)=>{for(var e in t)r(s,e,{get:t[e],enumerable:!0})},h=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!l.call(s,n)&&n!==e&&r(s,n,{get:()=>t[n],enumerable:!(o=a(t,n))||o.enumerable});return s};var m=s=>h(r({},"__esModule",{value:!0}),s);var u={};p(u,{DefaultTouchController:()=>d});module.exports=m(u);var i=require("../core/types");class d{constructor(t,e){this.client=t;this.axes=e}assertPercentPoint({x:t,y:e}){const o=n=>Number.isFinite(n)&&n>=0&&n<=100;if(!o(t)||!o(e))throw new Error(`[Touch] percent values must be within 0\u2013100. Received x=${t}, y=${e}`)}toAbs(t,e){const o=this.axes[t];if(!o){const n=Object.keys(this.axes);throw new Error(`[Touch] Unknown device key "${String(t)}". Known keys: ${n.join(", ")||"<none>"}`)}return this.assertPercentPoint(e),o.xy(e.x,e.y)}async tapAndRelease(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.PRESS_AND_RELEASE,...o})}async tap(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.PRESS,...o})}async release(t,e){const o=this.toAbs(t,e);await this.client.post("/finger",{action:i.SpeculosActions.RELEASE,...o})}}0&&(module.exports={DefaultTouchController});
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}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAyD,gCAIlD,MAAMF,CAEb,CACE,YACmBG,EACAC,EACjB,CAFiB,YAAAD,EACA,UAAAC,CAChB,CAEK,mBAAmB,CAAE,EAAAC,EAAG,EAAAC,CAAE,EAA6B,CAC7D,MAAMC,EAAWC,GAAc,OAAO,SAASA,CAAC,GAAKA,GAAK,GAAKA,GAAK,IACpE,GAAI,CAACD,EAAQF,CAAC,GAAK,CAACE,EAAQD,CAAC,EAC3B,MAAM,IAAI,MACR,gEAA2DD,CAAC,OAAOC,CAAC,EACtE,CAEJ,CAEQ,MAAMG,EAAcC,EAAuB,CACjD,MAAMC,EAAO,KAAK,KAAKF,CAAS,EAChC,GAAI,CAACE,EAAM,CACT,MAAMC,EAAQ,OAAO,KAAK,KAAK,IAA+B,EAC9D,MAAM,IAAI,MACR,+BAA+B,OAAOH,CAAS,CAAC,kBAAkBG,EAAM,KAAK,IAAI,GAAK,QAAQ,EAChG,CACF,CACA,YAAK,mBAAmBF,CAAC,EAClBC,EAAK,GAAGD,EAAE,EAAGA,EAAE,CAAC,CACzB,CAEA,MAAM,cAAcD,EAAcI,EAA0C,CAC1E,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,kBACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,IAAIL,EAAcI,EAA0C,CAChE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,MACxB,GAAGC,CACL,CAAC,CACH,CAEA,MAAM,QAAQL,EAAcI,EAA0C,CACpE,MAAMC,EAAM,KAAK,MAAML,EAAWI,CAAK,EACvC,MAAM,KAAK,OAAO,KAAK,UAAW,CAChC,OAAQ,kBAAgB,QACxB,GAAGC,CACL,CAAC,CACH,CACF",
6
+ "names": ["DefaultTouchController_exports", "__export", "DefaultTouchController", "__toCommonJS", "import_types", "client", "axes", "x", "y", "inRange", "v", "deviceKey", "p", "axis", "known", "point", "abs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=require("./DefaultTouchController");describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((n,i)=>({x:Math.round(n*10),y:Math.round(i*20)}))},r={xy:vi.fn((n,i)=>({x:Math.round(100+n),y:Math.round(200+i)}))};let c,a;beforeEach(()=>{e=vi.fn().mockResolvedValue({status:200,data:{}}),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},a=new l.DefaultTouchController(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await a.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...n})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await a.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const n=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...n})}),it("release: converts via axes and POSTs action 'release'",async()=>{await a.release("devA",t);const n=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...n})}),it("throws an error when device key is unknown",async()=>{await expect(a.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors from axios client",async()=>{const n=new Error("backend down");e.mockRejectedValueOnce(n),await expect(a.tapAndRelease("devA",t)).rejects.toBe(n)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((a,t)=>({x:a,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue({status:200,data:{}}),o={post:s},r.xy.mockClear(),e=new l.DefaultTouchController(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const a=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of a)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const a=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of a)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
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": "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",
6
+ "names": ["import_DefaultTouchController", "postMock", "axiosFake", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var E=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var i in e)E(t,i,{get:e[i],enumerable:!0})},d=(t,e,i,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!S.call(t,o)&&o!==i&&E(t,o,{get:()=>e[o],enumerable:!(p=r(e,o))||p.enumerable});return t};var f=t=>d(E({},"__esModule",{value:!0}),t);var y={};c(y,{DEFAULT_SCREENS:()=>s});module.exports=f(y);var h=require("@ledgerhq/device-management-kit");const s={[h.DeviceModelId.FLEX]:{width:480,height:600},[h.DeviceModelId.STAX]:{width:400,height:672}};0&&(module.exports={DEFAULT_SCREENS});
2
+ //# sourceMappingURL=defaultScreens.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/config/defaultScreens.ts"],
4
+ "sourcesContent": ["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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,2CAEvB,MAAMF,EAAkB,CAC7B,CAAC,gBAAc,IAAI,EAAG,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChD,CAAC,gBAAc,IAAI,EAAG,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClD",
6
+ "names": ["defaultScreens_exports", "__export", "DEFAULT_SCREENS", "__toCommonJS", "import_device_management_kit"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(e,t,p,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of i(t))!s.call(e,o)&&o!==p&&n(e,o,{get:()=>t[o],enumerable:!(r=y(t,o))||r.enumerable});return e};var u=e=>m(n({},"__esModule",{value:!0}),e);var B={};module.exports=u(B);
2
+ //# sourceMappingURL=ButtonController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/ButtonController.ts"],
4
+ "sourcesContent": ["import type { ButtonKey } from \"./types\";\n\nexport interface ButtonController {\n press(key: ButtonKey): Promise<void>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ButtonController_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!a.call(o,t)&&t!==n&&r(o,t,{get:()=>e[t],enumerable:!(i=s(e,t))||i.enumerable});return o};var p=o=>c(r({},"__esModule",{value:!0}),o);var K={};module.exports=p(K);
2
+ //# sourceMappingURL=TouchController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/TouchController.ts"],
4
+ "sourcesContent": ["import type { PercentCoordinates } from \"./types\";\n\nexport interface TouchController<K extends string = string> {\n tapAndRelease: (deviceKey: K, point: PercentCoordinates) => Promise<void>;\n tap: (deviceKey: K, point: PercentCoordinates) => Promise<void>;\n release: (deviceKey: K, point: PercentCoordinates) => Promise<void>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TouchController_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var c in e)p(t,c,{get:e[c],enumerable:!0})},i=(t,e,c,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!d.call(t,n)&&n!==c&&p(t,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return t};var y=t=>i(p({},"__esModule",{value:!0}),t);var a={};g(a,{SpeculosActions:()=>s});module.exports=y(a);var s=(r=>(r.PRESS="press",r.RELEASE="release",r.PRESS_AND_RELEASE="press-and-release",r))(s||{});0&&(module.exports={SpeculosActions});
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/core/types.ts"],
4
+ "sourcesContent": ["export type ButtonKey = \"left\" | \"right\" | \"both\";\n\nexport type ScreenSpec = Readonly<{ width: number; height: number }>;\n\nexport type DeviceScreens<K extends string = string> = Readonly<\n Record<K, ScreenSpec>\n>;\n\nexport type Range<\n N extends number,\n Acc extends number[] = [],\n> = Acc[\"length\"] extends N ? Acc[number] : Range<N, [...Acc, Acc[\"length\"]]>;\nexport type Percent = Range<101>;\n\nexport type PercentCoordinates = { x: Percent; y: Percent };\n\nexport type DeviceControllerOptions<K extends string = string> = {\n screens: DeviceScreens<K>;\n timeoutMs?: number;\n clientHeader?: string;\n};\n\nexport enum SpeculosActions {\n PRESS = \"press\",\n RELEASE = \"release\",\n PRESS_AND_RELEASE = \"press-and-release\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAsBO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBAHVA,OAAA",
6
+ "names": ["types_exports", "__export", "SpeculosActions", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.create;var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var r in t)l(o,r,{get:t[r],enumerable:!0})},i=(o,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of f(t))!x.call(o,e)&&e!==r&&l(o,e,{get:()=>t[e],enumerable:!(n=C(t,e))||n.enumerable});return o};var T=(o,t,r)=>(r=o!=null?m(h(o)):{},i(t||!o||!o.__esModule?l(r,"default",{value:o,enumerable:!0}):r,o)),A=o=>i(l({},"__esModule",{value:!0}),o);var D={};y(D,{createDefaultControllers:()=>B});module.exports=A(D);var s=T(require("axios")),c=require("./adapters/DefaultButtonController"),a=require("./adapters/DefaultTouchController"),u=require("./utils/axisClamp");function B(o,t){const r=s.default.create({baseURL:o,timeout:t.timeoutMs??1500,headers:{"X-Ledger-Client-Version":t.clientHeader??"ldmk-transport-speculos"},transitional:{clarifyTimeoutError:!0}}),n=(0,u.createAxes)(t.screens),e=new c.DefaultButtonController(r),p=new a.DefaultTouchController(r,n);return{buttons:e,touch:p}}0&&(module.exports={createDefaultControllers});
2
+ //# sourceMappingURL=di.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/di.ts"],
4
+ "sourcesContent": ["import axios, { type AxiosInstance } from \"axios\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\nimport type { ButtonController } from \"@internal/core/ButtonController\";\nimport type { DeviceControllerOptions } from \"@internal/core/types\";\nimport { type AxisMap, createAxes } from \"@internal/utils/axisClamp\";\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nexport type ControllersContainer = {\n buttons: ButtonController;\n touch: TouchController;\n};\n\nexport function createDefaultControllers(\n baseURL: string,\n opts: DeviceControllerOptions,\n): ControllersContainer {\n const http: AxiosInstance = axios.create({\n baseURL: baseURL,\n timeout: opts.timeoutMs ?? 1500,\n headers: {\n \"X-Ledger-Client-Version\": opts.clientHeader ?? \"ldmk-transport-speculos\",\n },\n transitional: { clarifyTimeoutError: true },\n });\n\n const axes: AxisMap = createAxes(opts.screens);\n\n const buttons: ButtonController = new DefaultButtonController(http);\n const touch: TouchController = new DefaultTouchController(http, axes);\n\n return { buttons, touch };\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,oBAE1CC,EAAwC,sDACxCC,EAAuC,qDAGvCC,EAAyC,qCAQlC,SAASL,EACdM,EACAC,EACsB,CACtB,MAAMC,EAAsB,EAAAC,QAAM,OAAO,CACvC,QAASH,EACT,QAASC,EAAK,WAAa,KAC3B,QAAS,CACP,0BAA2BA,EAAK,cAAgB,yBAClD,EACA,aAAc,CAAE,oBAAqB,EAAK,CAC5C,CAAC,EAEKG,KAAgB,cAAWH,EAAK,OAAO,EAEvCI,EAA4B,IAAI,0BAAwBH,CAAI,EAC5DI,EAAyB,IAAI,yBAAuBJ,EAAME,CAAI,EAEpE,MAAO,CAAE,QAAAC,EAAS,MAAAC,CAAM,CAC1B",
6
+ "names": ["di_exports", "__export", "createDefaultControllers", "__toCommonJS", "import_axios", "import_DefaultButtonController", "import_DefaultTouchController", "import_axisClamp", "baseURL", "opts", "http", "axios", "axes", "buttons", "touch"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.create;var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var x=(o,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of h(t))!y.call(o,c)&&c!==n&&i(o,c,{get:()=>t[c],enumerable:!(l=f(t,c))||l.enumerable});return o};var B=(o,t,n)=>(n=o!=null?m(d(o)):{},x(t||!o||!o.__esModule?i(n,"default",{value:o,enumerable:!0}):n,o));var r=B(require("axios")),e=require("vitest"),p=require("./adapters/DefaultButtonController"),u=require("./adapters/DefaultTouchController"),s=require("./di");const a={flex:{width:128,height:64},stax:{width:400,height:672}};(0,e.afterEach)(()=>{e.vi.restoreAllMocks()});(0,e.describe)("createDefaultControllers - axios configuration",()=>{(0,e.it)("configures axios with normalised baseURL, custom timeout and header",()=>{const o=e.vi.spyOn(r.default,"create").mockImplementation(n=>({post:e.vi.fn(),defaults:{...n}}));(0,s.createDefaultControllers)("http://example.com/api",{screens:a,timeoutMs:2345,clientHeader:"test-client"}),(0,e.expect)(o).toHaveBeenCalledTimes(1);const t=o.mock.calls[0][0];(0,e.expect)(t.baseURL).toBe("http://example.com/api"),(0,e.expect)(t.timeout).toBe(2345),(0,e.expect)(t.headers?.["X-Ledger-Client-Version"]).toBe("test-client"),(0,e.expect)(t.transitional?.clarifyTimeoutError).toBe(!0)}),(0,e.it)("applies default timeout and client header when not provided",()=>{const o=e.vi.spyOn(r.default,"create").mockImplementation(n=>({post:e.vi.fn(),defaults:{...n}}));(0,s.createDefaultControllers)("http://localhost:1234",{screens:a});const t=o.mock.calls[0][0];(0,e.expect)(t.baseURL).toBe("http://localhost:1234"),(0,e.expect)(t.timeout).toBe(1500),(0,e.expect)(t.headers?.["X-Ledger-Client-Version"]).toBe("ldmk-transport-speculos")})});(0,e.describe)("createDefaultControllers - wiring",()=>{(0,e.it)("returns axios implementations wired by the factory",()=>{const o={post:e.vi.fn()};e.vi.spyOn(r.default,"create").mockReturnValue(o);const{buttons:t,touch:n}=(0,s.createDefaultControllers)("http://x",{screens:a});(0,e.expect)(t).toBeInstanceOf(p.DefaultButtonController),(0,e.expect)(n).toBeInstanceOf(u.DefaultTouchController),(0,e.expect)(typeof t.press).toBe("function")}),(0,e.it)("creates fresh instances per invocation",()=>{e.vi.spyOn(r.default,"create").mockReturnValueOnce({post:e.vi.fn()}).mockReturnValueOnce({post:e.vi.fn()});const o=(0,s.createDefaultControllers)("http://x",{screens:a}),t=(0,s.createDefaultControllers)("http://x",{screens:a});(0,e.expect)(o.buttons).not.toBe(t.buttons),(0,e.expect)(o.touch).not.toBe(t.touch)}),(0,e.it)("button.press posts the correct payload",async()=>{const o=e.vi.fn().mockResolvedValue(void 0);e.vi.spyOn(r.default,"create").mockReturnValue({post:o});const{buttons:t}=(0,s.createDefaultControllers)("http://x",{screens:a});await t.press("left"),(0,e.expect)(o).toHaveBeenCalledWith("/button/left",{action:"press-and-release"})}),(0,e.it)("touch.tapAndRelease maps percent to absolute coords",async()=>{const o=e.vi.fn().mockResolvedValue(void 0);e.vi.spyOn(r.default,"create").mockReturnValue({post:o});const{touch:t}=(0,s.createDefaultControllers)("http://x",{screens:a});await t.tapAndRelease("flex",{x:50,y:50}),(0,e.expect)(o).toHaveBeenCalledWith("/finger",{action:"press-and-release",x:64,y:32})})});
2
+ //# sourceMappingURL=di.test.js.map