@ledgerhq/device-mockserver-react-core 0.0.0-delayed-signing-20261113142655
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.
- package/LICENSE.MD +202 -0
- package/README.md +29 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +7 -0
- package/lib/cjs/package.json +61 -0
- package/lib/cjs/src/deviceModels.js +2 -0
- package/lib/cjs/src/deviceModels.js.map +7 -0
- package/lib/cjs/src/index.js +2 -0
- package/lib/cjs/src/index.js.map +7 -0
- package/lib/cjs/src/mockServerScreenApi.js +2 -0
- package/lib/cjs/src/mockServerScreenApi.js.map +7 -0
- package/lib/cjs/src/types.js +2 -0
- package/lib/cjs/src/types.js.map +7 -0
- package/lib/cjs/src/useButtonHold.js +2 -0
- package/lib/cjs/src/useButtonHold.js.map +7 -0
- package/lib/cjs/src/useHold.js +2 -0
- package/lib/cjs/src/useHold.js.map +7 -0
- package/lib/cjs/src/useMockServerDevice.js +2 -0
- package/lib/cjs/src/useMockServerDevice.js.map +7 -0
- package/lib/cjs/src/useOpenApp.js +2 -0
- package/lib/cjs/src/useOpenApp.js.map +7 -0
- package/lib/cjs/src/useScreenPolling.js +2 -0
- package/lib/cjs/src/useScreenPolling.js.map +7 -0
- package/lib/cjs/src/useTouchHold.js +2 -0
- package/lib/cjs/src/useTouchHold.js.map +7 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +7 -0
- package/lib/esm/package.json +61 -0
- package/lib/esm/src/deviceModels.js +2 -0
- package/lib/esm/src/deviceModels.js.map +7 -0
- package/lib/esm/src/index.js +2 -0
- package/lib/esm/src/index.js.map +7 -0
- package/lib/esm/src/mockServerScreenApi.js +2 -0
- package/lib/esm/src/mockServerScreenApi.js.map +7 -0
- package/lib/esm/src/types.js +1 -0
- package/lib/esm/src/types.js.map +7 -0
- package/lib/esm/src/useButtonHold.js +2 -0
- package/lib/esm/src/useButtonHold.js.map +7 -0
- package/lib/esm/src/useHold.js +2 -0
- package/lib/esm/src/useHold.js.map +7 -0
- package/lib/esm/src/useMockServerDevice.js +2 -0
- package/lib/esm/src/useMockServerDevice.js.map +7 -0
- package/lib/esm/src/useOpenApp.js +2 -0
- package/lib/esm/src/useOpenApp.js.map +7 -0
- package/lib/esm/src/useScreenPolling.js +2 -0
- package/lib/esm/src/useScreenPolling.js.map +7 -0
- package/lib/esm/src/useTouchHold.js +2 -0
- package/lib/esm/src/useTouchHold.js.map +7 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/src/deviceModels.d.ts +12 -0
- package/lib/types/src/deviceModels.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +10 -0
- package/lib/types/src/index.d.ts.map +1 -0
- package/lib/types/src/mockServerScreenApi.d.ts +3 -0
- package/lib/types/src/mockServerScreenApi.d.ts.map +1 -0
- package/lib/types/src/types.d.ts +60 -0
- package/lib/types/src/types.d.ts.map +1 -0
- package/lib/types/src/useButtonHold.d.ts +6 -0
- package/lib/types/src/useButtonHold.d.ts.map +1 -0
- package/lib/types/src/useHold.d.ts +23 -0
- package/lib/types/src/useHold.d.ts.map +1 -0
- package/lib/types/src/useMockServerDevice.d.ts +9 -0
- package/lib/types/src/useMockServerDevice.d.ts.map +1 -0
- package/lib/types/src/useOpenApp.d.ts +19 -0
- package/lib/types/src/useOpenApp.d.ts.map +1 -0
- package/lib/types/src/useScreenPolling.d.ts +3 -0
- package/lib/types/src/useScreenPolling.d.ts.map +1 -0
- package/lib/types/src/useTouchHold.d.ts +23 -0
- package/lib/types/src/useTouchHold.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
- package/package.json +61 -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,29 @@
|
|
|
1
|
+
# @ledgerhq/device-mockserver-react-core
|
|
2
|
+
|
|
3
|
+
The platform-free part of the [device mock server](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/apps/device-mock-server)
|
|
4
|
+
screens: React hooks and helpers with no DOM, React Native or design system
|
|
5
|
+
import. Two packages draw it:
|
|
6
|
+
|
|
7
|
+
- [`@ledgerhq/device-mockserver-react`](../mockserver-device-react) for the web.
|
|
8
|
+
- [`@ledgerhq/device-mockserver-react-native`](../mockserver-device-react-native)
|
|
9
|
+
for React Native.
|
|
10
|
+
|
|
11
|
+
Use one of those to show a device screen. Use this package directly only to
|
|
12
|
+
build a screen for another platform.
|
|
13
|
+
|
|
14
|
+
## Contents
|
|
15
|
+
|
|
16
|
+
| Export | Role |
|
|
17
|
+
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `useScreenPolling(api, polling, platform)` | Polls the screen: a live frame, the device record while no app runs, or an error. |
|
|
19
|
+
| `ScreenPlatform` | What the platform supplies: how a frame becomes an image source, and when the app is hidden. |
|
|
20
|
+
| `mockServerScreenApi(client, deviceId)` | A `ScreenApi` that reaches a device through the mock server. |
|
|
21
|
+
| `useMockServerDevice(client, deviceId)` | The mock server's record of a device. |
|
|
22
|
+
| `findDeviceScreenModel(deviceType)` | Touch or buttons, screen size and colour of a device model. |
|
|
23
|
+
| `useHold(onAction)` | Sends a quick click or tap as one press-and-release, and a longer hold as a press, then a release. |
|
|
24
|
+
| `useButtonHold(onPress)`, `useTouchHold(onTouch)` | `useHold` for the Nano buttons, and for touches in device pixels. |
|
|
25
|
+
| `toScreenPoint` | Maps a point on the drawn screen to device pixels. |
|
|
26
|
+
| `useOpenApp(onOpenApp)`, `openableApps`, `appIconUrl` | Opens an app from the device's list and waits for its screen. |
|
|
27
|
+
|
|
28
|
+
Pass `useScreenPolling` a `ScreenPlatform` defined at module level. Polling
|
|
29
|
+
restarts whenever the object changes.
|
package/lib/cjs/index.js
ADDED
|
@@ -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"),module.exports);0&&(module.exports={...require("./src")});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@ledgerhq/device-mockserver-client": "workspace:*"
|
|
4
|
+
},
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
7
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
8
|
+
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
9
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
10
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
11
|
+
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
12
|
+
"@types/react": "catalog:",
|
|
13
|
+
"@types/react-dom": "catalog:",
|
|
14
|
+
"react": "catalog:",
|
|
15
|
+
"react-dom": "catalog:"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./lib/esm/index.js",
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"types": "./lib/types/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./*": {
|
|
24
|
+
"import": "./lib/esm/*",
|
|
25
|
+
"require": "./lib/cjs/*",
|
|
26
|
+
"types": "./lib/types/*"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"./lib"
|
|
31
|
+
],
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"main": "lib/cjs/index.js",
|
|
34
|
+
"name": "@ledgerhq/device-mockserver-react-core",
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
37
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"private": false,
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/*.tsx,src/*.ts --tsconfig tsconfig.prod.json",
|
|
46
|
+
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
47
|
+
"lint": "eslint",
|
|
48
|
+
"lint:fix": "pnpm lint --fix",
|
|
49
|
+
"prebuild": "rimraf lib",
|
|
50
|
+
"prettier": "prettier . --check",
|
|
51
|
+
"prettier:fix": "prettier . --write",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:coverage": "vitest run --coverage",
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/*.tsx,src/*.ts --tsconfig tsconfig.prod.json",
|
|
57
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
58
|
+
},
|
|
59
|
+
"types": "lib/types/index.d.ts",
|
|
60
|
+
"version": "0.0.0-delayed-signing-20261113142655"
|
|
61
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var u=(e,n)=>{for(var c in n)t(e,c,{get:n[c],enumerable:!0})},d=(e,n,c,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of a(n))!i.call(e,r)&&r!==c&&t(e,r,{get:()=>n[r],enumerable:!(l=s(n,r))||l.enumerable});return e};var h=e=>d(t({},"__esModule",{value:!0}),e);var b={};u(b,{findDeviceScreenModel:()=>p});module.exports=h(b);const o=(e,n)=>({label:e,touch:!1,speculos:!0,screenWidth:128,screenHeight:n,lightScreen:!1}),S={nanoS:{...o("Nano S",32),speculos:!1},nanoSP:o("Nano S Plus",64),nanoX:o("Nano X",64),stax:{label:"Stax",touch:!0,speculos:!0,screenWidth:400,screenHeight:672,lightScreen:!0},flex:{label:"Flex",touch:!0,speculos:!0,screenWidth:480,screenHeight:600,lightScreen:!0},apexp:{label:"Apex",touch:!0,speculos:!0,screenWidth:300,screenHeight:400,lightScreen:!0}},g=o("Device",64),p=e=>S[e]??g;0&&(module.exports={findDeviceScreenModel});
|
|
2
|
+
//# sourceMappingURL=deviceModels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/deviceModels.ts"],
|
|
4
|
+
"sourcesContent": ["export interface DeviceScreenModel {\n readonly label: string;\n readonly touch: boolean;\n /** Whether Speculos has an emulator for it, so it can have a screen. */\n readonly speculos: boolean;\n /** In device pixels. */\n readonly screenWidth: number;\n readonly screenHeight: number;\n readonly lightScreen: boolean;\n}\n\nconst nano = (label: string, screenHeight: number): DeviceScreenModel => ({\n label,\n touch: false,\n speculos: true,\n screenWidth: 128,\n screenHeight,\n lightScreen: false,\n});\n\n/** Keyed by the mock server's `device_type`, a DMK `DeviceModelId`. */\nconst MODELS: Record<string, DeviceScreenModel> = {\n nanoS: { ...nano(\"Nano S\", 32), speculos: false },\n nanoSP: nano(\"Nano S Plus\", 64),\n nanoX: nano(\"Nano X\", 64),\n stax: {\n label: \"Stax\",\n touch: true,\n speculos: true,\n screenWidth: 400,\n screenHeight: 672,\n lightScreen: true,\n },\n flex: {\n label: \"Flex\",\n touch: true,\n speculos: true,\n screenWidth: 480,\n screenHeight: 600,\n lightScreen: true,\n },\n apexp: {\n label: \"Apex\",\n touch: true,\n speculos: true,\n screenWidth: 300,\n screenHeight: 400,\n lightScreen: true,\n },\n};\n\nconst UNKNOWN: DeviceScreenModel = nano(\"Device\", 64);\n\nexport const findDeviceScreenModel = (deviceType: string): DeviceScreenModel =>\n MODELS[deviceType] ?? UNKNOWN;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAWA,MAAMI,EAAO,CAACC,EAAeC,KAA6C,CACxE,MAAAD,EACA,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAAC,EACA,YAAa,EACf,GAGMC,EAA4C,CAChD,MAAO,CAAE,GAAGH,EAAK,SAAU,EAAE,EAAG,SAAU,EAAM,EAChD,OAAQA,EAAK,cAAe,EAAE,EAC9B,MAAOA,EAAK,SAAU,EAAE,EACxB,KAAM,CACJ,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,EACA,MAAO,CACL,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,CACF,EAEMI,EAA6BJ,EAAK,SAAU,EAAE,EAEvCF,EAAyBO,GACpCF,EAAOE,CAAU,GAAKD",
|
|
6
|
+
"names": ["deviceModels_exports", "__export", "findDeviceScreenModel", "__toCommonJS", "nano", "label", "screenHeight", "MODELS", "UNKNOWN", "deviceType"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var S=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var s=(r,e)=>{for(var t in e)S(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of y(e))!H.call(r,p)&&p!==t&&S(r,p,{get:()=>e[p],enumerable:!(l=x(e,p))||l.enumerable});return r};var D=r=>v(S({},"__esModule",{value:!0}),r);var M={};s(M,{HOLD_THRESHOLD_MS:()=>n.HOLD_THRESHOLD_MS,OPEN_APP_TIMEOUT_MS:()=>o.OPEN_APP_TIMEOUT_MS,appIconUrl:()=>o.appIconUrl,findDeviceScreenModel:()=>i.findDeviceScreenModel,mockServerScreenApi:()=>f.mockServerScreenApi,openableApps:()=>o.openableApps,toScreenPoint:()=>c.toScreenPoint,useButtonHold:()=>m.useButtonHold,useHold:()=>n.useHold,useMockServerDevice:()=>u.useMockServerDevice,useOpenApp:()=>o.useOpenApp,useScreenPolling:()=>d.useScreenPolling,useTouchHold:()=>c.useTouchHold});module.exports=D(M);var i=require("./deviceModels"),f=require("./mockServerScreenApi"),m=require("./useButtonHold"),n=require("./useHold"),u=require("./useMockServerDevice"),o=require("./useOpenApp"),d=require("./useScreenPolling"),c=require("./useTouchHold");0&&(module.exports={HOLD_THRESHOLD_MS,OPEN_APP_TIMEOUT_MS,appIconUrl,findDeviceScreenModel,mockServerScreenApi,openableApps,toScreenPoint,useButtonHold,useHold,useMockServerDevice,useOpenApp,useScreenPolling,useTouchHold});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { type DeviceScreenModel, findDeviceScreenModel } from \"./deviceModels\";\nexport { mockServerScreenApi } from \"./mockServerScreenApi\";\nexport type {\n DeviceScreenInput,\n DeviceScreenState,\n MockServerClient,\n ScreenApi,\n ScreenPlatform,\n} from \"./types\";\nexport { type ButtonHold, useButtonHold } from \"./useButtonHold\";\nexport { type Hold, HOLD_THRESHOLD_MS, useHold } from \"./useHold\";\nexport { useMockServerDevice } from \"./useMockServerDevice\";\nexport {\n appIconUrl,\n OPEN_APP_TIMEOUT_MS,\n openableApps,\n type OpenApp,\n useOpenApp,\n} from \"./useOpenApp\";\nexport { useScreenPolling } from \"./useScreenPolling\";\nexport {\n type ScreenPoint,\n type Size,\n toScreenPoint,\n type TouchHold,\n useTouchHold,\n} from \"./useTouchHold\";\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kfAAAE,EAAAF,GAAA,IAAAG,EAA8D,0BAC9DC,EAAoC,iCAQpCC,EAA+C,2BAC/CC,EAAsD,qBACtDC,EAAoC,iCACpCC,EAMO,wBACPC,EAAiC,8BACjCC,EAMO",
|
|
6
|
+
"names": ["src_exports", "__export", "__toCommonJS", "import_deviceModels", "import_mockServerScreenApi", "import_useButtonHold", "import_useHold", "import_useMockServerDevice", "import_useOpenApp", "import_useScreenPolling", "import_useTouchHold"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var i=(n,o)=>{for(var e in o)s(n,e,{get:o[e],enumerable:!0})},w=(n,o,e,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of u(o))!p.call(n,r)&&r!==e&&s(n,r,{get:()=>o[r],enumerable:!(t=a(o,r))||t.enumerable});return n};var h=n=>w(s({},"__esModule",{value:!0}),n);var S={};i(S,{mockServerScreenApi:()=>f});module.exports=h(S);const l=n=>n?.status===409,f=(n,o)=>({screenshot:async()=>{try{return await n.getScreenshot(o)}catch(e){if(l(e))return null;throw e}},idle:async()=>({kind:"os-info",device:await n.getDevice(o)}),pressButton:(e,t)=>n.pressButton(o,e,t),touch:(e,t,r)=>n.touchScreen(o,e,t,r),openApp:async e=>{const t=new TextEncoder().encode(e);if(t.length>255)throw new Error(`App name too long to open: ${e}`);const{response:r}=await n.sendApdu(o,Uint8Array.from([224,216,0,0,t.length,...t])),c=r.slice(-4);if(c!=="9000")throw new Error(`Could not open ${e} (${c})`)}});0&&(module.exports={mockServerScreenApi});
|
|
2
|
+
//# sourceMappingURL=mockServerScreenApi.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mockServerScreenApi.ts"],
|
|
4
|
+
"sourcesContent": ["import { type MockServerClient, type ScreenApi } from \"./types\";\n\n/** The proxy answers 409 when the device has no Speculos instance. */\nconst isNoInstance = (error: unknown): boolean =>\n (error as { status?: unknown } | null)?.status === 409;\n\nexport const mockServerScreenApi = (\n client: MockServerClient,\n deviceId: string,\n): ScreenApi => ({\n screenshot: async () => {\n try {\n return await client.getScreenshot(deviceId);\n } catch (error) {\n if (isNoInstance(error)) return null;\n throw error;\n }\n },\n idle: async () => ({\n kind: \"os-info\",\n device: await client.getDevice(deviceId),\n }),\n pressButton: (button, action) => client.pressButton(deviceId, button, action),\n touch: (x, y, action) => client.touchScreen(deviceId, x, y, action),\n openApp: async (appName) => {\n const name = new TextEncoder().encode(appName);\n // Lc is a single byte.\n if (name.length > 0xff) {\n throw new Error(`App name too long to open: ${appName}`);\n }\n const { response } = await client.sendApdu(\n deviceId,\n Uint8Array.from([0xe0, 0xd8, 0x00, 0x00, name.length, ...name]),\n );\n const statusWord = response.slice(-4);\n if (statusWord !== \"9000\") {\n throw new Error(`Could not open ${appName} (${statusWord})`);\n }\n },\n});\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAGA,MAAMI,EAAgBC,GACnBA,GAAuC,SAAW,IAExCH,EAAsB,CACjCI,EACAC,KACe,CACf,WAAY,SAAY,CACtB,GAAI,CACF,OAAO,MAAMD,EAAO,cAAcC,CAAQ,CAC5C,OAASF,EAAO,CACd,GAAID,EAAaC,CAAK,EAAG,OAAO,KAChC,MAAMA,CACR,CACF,EACA,KAAM,UAAa,CACjB,KAAM,UACN,OAAQ,MAAMC,EAAO,UAAUC,CAAQ,CACzC,GACA,YAAa,CAACC,EAAQC,IAAWH,EAAO,YAAYC,EAAUC,EAAQC,CAAM,EAC5E,MAAO,CAACC,EAAGC,EAAGF,IAAWH,EAAO,YAAYC,EAAUG,EAAGC,EAAGF,CAAM,EAClE,QAAS,MAAOG,GAAY,CAC1B,MAAMC,EAAO,IAAI,YAAY,EAAE,OAAOD,CAAO,EAE7C,GAAIC,EAAK,OAAS,IAChB,MAAM,IAAI,MAAM,8BAA8BD,CAAO,EAAE,EAEzD,KAAM,CAAE,SAAAE,CAAS,EAAI,MAAMR,EAAO,SAChCC,EACA,WAAW,KAAK,CAAC,IAAM,IAAM,EAAM,EAAMM,EAAK,OAAQ,GAAGA,CAAI,CAAC,CAChE,EACME,EAAaD,EAAS,MAAM,EAAE,EACpC,GAAIC,IAAe,OACjB,MAAM,IAAI,MAAM,kBAAkBH,CAAO,KAAKG,CAAU,GAAG,CAE/D,CACF",
|
|
6
|
+
"names": ["mockServerScreenApi_exports", "__export", "mockServerScreenApi", "__toCommonJS", "isNoInstance", "error", "client", "deviceId", "button", "action", "x", "y", "appName", "name", "response", "statusWord"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(o,e,c,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!p.call(o,t)&&t!==c&&i(o,t,{get:()=>e[t],enumerable:!(n=r(e,t))||n.enumerable});return o};var S=o=>u(i({},"__esModule",{value:!0}),o);var l={};module.exports=S(l);
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type Device,\n type MockClient,\n type SpeculosAction,\n type SpeculosButton,\n} from \"@ledgerhq/device-mockserver-client\";\n\n/**\n * The MockClient calls this library makes. Picking them drops the class's\n * private fields, so a client from another copy of the package still fits.\n */\nexport type MockServerClient = Pick<\n MockClient,\n \"getDevice\" | \"getScreenshot\" | \"pressButton\" | \"touchScreen\" | \"sendApdu\"\n>;\n\n/**\n * How the screen is reached. The mock server proxies to the Speculos instance\n * backing a device and a Speculos transport talks to one directly, but both\n * answer the same calls.\n */\nexport interface ScreenApi {\n /** Resolves null when there is no screen to capture right now. */\n screenshot(): Promise<Blob | null>;\n /** What to show while `screenshot` keeps resolving null. */\n idle?(): Promise<DeviceScreenState>;\n pressButton(button: SpeculosButton, action: SpeculosAction): Promise<void>;\n /** Coordinates in device screen pixels. */\n touch(x: number, y: number, action: SpeculosAction): Promise<void>;\n /** Omitted by apis whose device always runs an app. */\n openApp?(appName: string): Promise<void>;\n}\n\n/**\n * Press and release are separate so a hold reaches the device as a hold: Stax\n * and Flex gate their confirmations behind one.\n */\nexport interface DeviceScreenInput {\n pressButton(button: SpeculosButton, action: SpeculosAction): void;\n touch(x: number, y: number, action: SpeculosAction): void;\n}\n\nexport type DeviceScreenState =\n | { kind: \"loading\" }\n /** No app runs, so no Speculos instance: the device record stands in. */\n | { kind: \"os-info\"; device: Device }\n /** `src` is whatever the platform's `toImageSource` made of the frame. */\n | { kind: \"image\"; src: string; input: DeviceScreenInput }\n | { kind: \"error\"; message: string };\n\n/**\n * What a screen needs from the platform drawing it. Polling restarts whenever\n * this object changes, so hosts pass a module-level constant.\n */\nexport interface ScreenPlatform {\n /** Turns a screenshot into a source the platform's image element shows. */\n toImageSource(screenshot: Blob): Promise<string>;\n /** Frees a source once a newer frame or no frame replaces it. */\n releaseImageSource?(source: string): void;\n /** Polling skips its turn while the screen is out of sight. */\n isHidden(): boolean;\n}\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var i=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})},r=(o,t,e,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of s(t))!d.call(o,u)&&u!==e&&p(o,u,{get:()=>t[u],enumerable:!(l=c(t,u))||l.enumerable});return o};var B=o=>r(p({},"__esModule",{value:!0}),o);var S={};i(S,{useButtonHold:()=>H});module.exports=B(S);var n=require("./useHold");const H=o=>(0,n.useHold)(o);0&&(module.exports={useButtonHold});
|
|
2
|
+
//# sourceMappingURL=useButtonHold.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useButtonHold.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type SpeculosAction,\n type SpeculosButton,\n} from \"@ledgerhq/device-mockserver-client\";\n\nimport { type Hold, useHold } from \"./useHold\";\n\nexport type ButtonHold = Hold<SpeculosButton>;\n\n/** A physical button's down and up, as the actions the device gets. */\nexport const useButtonHold = (\n onPress: (button: SpeculosButton, action: SpeculosAction) => void,\n): ButtonHold => useHold(onPress);\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAmC,qBAK5B,MAAMF,EACXG,MACe,WAAQA,CAAO",
|
|
6
|
+
"names": ["useButtonHold_exports", "__export", "useButtonHold", "__toCommonJS", "import_useHold", "onPress"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var u in e)s(t,u,{get:e[u],enumerable:!0})},H=(t,e,u,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!T.call(t,n)&&n!==u&&s(t,n,{get:()=>e[n],enumerable:!(o=f(e,n))||o.enumerable});return t};var y=t=>H(s({},"__esModule",{value:!0}),t);var g={};m(g,{HOLD_THRESHOLD_MS:()=>i,useHold:()=>b});module.exports=y(g);var r=require("react");const i=150;function b(t){const e=(0,r.useRef)(null),u=(0,r.useRef)(null),o=(0,r.useRef)(t);o.current=t;const n=(0,r.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),c=(0,r.useCallback)(l=>{if(!o.current||e.current)return!1;const d={target:l,pressed:!1};return e.current=d,u.current=setTimeout(()=>{d.pressed=!0,o.current?.(l,"press")},i),!0},[]),a=(0,r.useCallback)(()=>{const l=e.current;return l?(e.current=null,n(),o.current?.(l.target,l.pressed?"release":"press-and-release"),!0):!1},[n]);return(0,r.useEffect)(()=>()=>{const l=e.current;e.current=null,n(),l?.pressed&&o.current?.(l.target,"release")},[n]),(0,r.useMemo)(()=>({hold:c,release:a}),[c,a])}0&&(module.exports={HOLD_THRESHOLD_MS,useHold});
|
|
2
|
+
//# sourceMappingURL=useHold.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useHold.ts"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { type SpeculosAction } from \"@ledgerhq/device-mockserver-client\";\n\n/**\n * How long a button or finger stays down before the interaction counts as a\n * hold. A click sent as a separate press and release is two requests the\n * device can receive in either order, and the emulator only sees what is down\n * when its event loop samples it, so a click that beats the loop is dropped:\n * a quick tap, or a chord of both buttons. One press-and-release leaves the\n * timing to the emulator.\n */\nexport const HOLD_THRESHOLD_MS = 150;\n\ninterface Held<T> {\n target: T;\n pressed: boolean;\n}\n\nexport interface Hold<T> {\n /** Went down. False when ignored: no handler, or something is held. */\n hold(target: T): boolean;\n /** Went up. False when nothing was held. */\n release(): boolean;\n}\n\n/**\n * Turns a button's or a finger's down and up into the actions the device\n * gets: a quick click as one press-and-release, a longer hold as a press then\n * a release. Whatever is still pressed on unmount is released.\n */\nexport function useHold<T>(\n onAction: ((target: T, action: SpeculosAction) => void) | undefined,\n): Hold<T> {\n const held = useRef<Held<T> | null>(null);\n const holdTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const actionRef = useRef(onAction);\n actionRef.current = onAction;\n\n const clearHoldTimer = useCallback(() => {\n if (!holdTimer.current) return;\n clearTimeout(holdTimer.current);\n holdTimer.current = null;\n }, []);\n\n const hold = useCallback((target: T) => {\n if (!actionRef.current || held.current) return false;\n const entry: Held<T> = { target, pressed: false };\n held.current = entry;\n holdTimer.current = setTimeout(() => {\n entry.pressed = true;\n actionRef.current?.(target, \"press\");\n }, HOLD_THRESHOLD_MS);\n return true;\n }, []);\n\n const release = useCallback(() => {\n const entry = held.current;\n if (!entry) return false;\n held.current = null;\n clearHoldTimer();\n actionRef.current?.(\n entry.target,\n entry.pressed ? \"release\" : \"press-and-release\",\n );\n return true;\n }, [clearHoldTimer]);\n\n useEffect(\n () => () => {\n const entry = held.current;\n held.current = null;\n clearHoldTimer();\n if (entry?.pressed) actionRef.current?.(entry.target, \"release\");\n },\n [clearHoldTimer],\n );\n\n return useMemo(() => ({ hold, release }), [hold, release]);\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAwD,iBAWjD,MAAMH,EAAoB,IAmB1B,SAASC,EACdG,EACS,CACT,MAAMC,KAAO,UAAuB,IAAI,EAClCC,KAAY,UAA6C,IAAI,EAC7DC,KAAY,UAAOH,CAAQ,EACjCG,EAAU,QAAUH,EAEpB,MAAMI,KAAiB,eAAY,IAAM,CAClCF,EAAU,UACf,aAAaA,EAAU,OAAO,EAC9BA,EAAU,QAAU,KACtB,EAAG,CAAC,CAAC,EAECG,KAAO,eAAaC,GAAc,CACtC,GAAI,CAACH,EAAU,SAAWF,EAAK,QAAS,MAAO,GAC/C,MAAMM,EAAiB,CAAE,OAAAD,EAAQ,QAAS,EAAM,EAChD,OAAAL,EAAK,QAAUM,EACfL,EAAU,QAAU,WAAW,IAAM,CACnCK,EAAM,QAAU,GAChBJ,EAAU,UAAUG,EAAQ,OAAO,CACrC,EAAGV,CAAiB,EACb,EACT,EAAG,CAAC,CAAC,EAECY,KAAU,eAAY,IAAM,CAChC,MAAMD,EAAQN,EAAK,QACnB,OAAKM,GACLN,EAAK,QAAU,KACfG,EAAe,EACfD,EAAU,UACRI,EAAM,OACNA,EAAM,QAAU,UAAY,mBAC9B,EACO,IAPY,EAQrB,EAAG,CAACH,CAAc,CAAC,EAEnB,sBACE,IAAM,IAAM,CACV,MAAMG,EAAQN,EAAK,QACnBA,EAAK,QAAU,KACfG,EAAe,EACXG,GAAO,SAASJ,EAAU,UAAUI,EAAM,OAAQ,SAAS,CACjE,EACA,CAACH,CAAc,CACjB,KAEO,WAAQ,KAAO,CAAE,KAAAC,EAAM,QAAAG,CAAQ,GAAI,CAACH,EAAMG,CAAO,CAAC,CAC3D",
|
|
6
|
+
"names": ["useHold_exports", "__export", "HOLD_THRESHOLD_MS", "useHold", "__toCommonJS", "import_react", "onAction", "held", "holdTimer", "actionRef", "clearHoldTimer", "hold", "target", "entry", "release"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},D=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!p.call(t,r)&&r!==n&&u(t,r,{get:()=>e[r],enumerable:!(i=s(e,r))||i.enumerable});return t};var a=t=>D(u({},"__esModule",{value:!0}),t);var S={};v(S,{useMockServerDevice:()=>y});module.exports=a(S);var o=require("react");const d=2e3;function y(t,e){const[n,i]=(0,o.useState)();return(0,o.useEffect)(()=>{let r=!1,c;if(i(void 0),!e)return;const f=()=>{t.getDevice(e).then(l=>{r||i(l)},()=>{r||(i(null),c=setTimeout(f,d))})};return f(),()=>{r=!0,clearTimeout(c)}},[t,e]),n}0&&(module.exports={useMockServerDevice});
|
|
2
|
+
//# sourceMappingURL=useMockServerDevice.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useMockServerDevice.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState } from \"react\";\nimport { type Device } from \"@ledgerhq/device-mockserver-client\";\n\nimport { type MockServerClient } from \"./types\";\n\nconst RETRY_MS = 2000;\n\n/**\n * The mock server's record of a device: undefined while it loads, or while no\n * device id is given, and null while it cannot be read. A failed read is\n * retried, so a transient error does not leave the device without its model.\n */\nexport function useMockServerDevice(\n client: MockServerClient,\n deviceId: string,\n): Device | null | undefined {\n const [device, setDevice] = useState<Device | null>();\n\n useEffect(() => {\n let cancelled = false;\n let retry: ReturnType<typeof setTimeout> | undefined;\n setDevice(undefined);\n if (!deviceId) return;\n\n const load = () => {\n client.getDevice(deviceId).then(\n (record) => {\n if (!cancelled) setDevice(record);\n },\n () => {\n if (cancelled) return;\n setDevice(null);\n retry = setTimeout(load, RETRY_MS);\n },\n );\n };\n load();\n\n return () => {\n cancelled = true;\n clearTimeout(retry);\n };\n }, [client, deviceId]);\n\n return device;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAKpC,MAAMC,EAAW,IAOV,SAASH,EACdI,EACAC,EAC2B,CAC3B,KAAM,CAACC,EAAQC,CAAS,KAAI,YAAwB,EAEpD,sBAAU,IAAM,CACd,IAAIC,EAAY,GACZC,EAEJ,GADAF,EAAU,MAAS,EACf,CAACF,EAAU,OAEf,MAAMK,EAAO,IAAM,CACjBN,EAAO,UAAUC,CAAQ,EAAE,KACxBM,GAAW,CACLH,GAAWD,EAAUI,CAAM,CAClC,EACA,IAAM,CACAH,IACJD,EAAU,IAAI,EACdE,EAAQ,WAAWC,EAAMP,CAAQ,EACnC,CACF,CACF,EACA,OAAAO,EAAK,EAEE,IAAM,CACXF,EAAY,GACZ,aAAaC,CAAK,CACpB,CACF,EAAG,CAACL,EAAQC,CAAQ,CAAC,EAEdC,CACT",
|
|
6
|
+
"names": ["useMockServerDevice_exports", "__export", "useMockServerDevice", "__toCommonJS", "import_react", "RETRY_MS", "client", "deviceId", "device", "setDevice", "cancelled", "retry", "load", "record"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(e,n)=>{for(var o in n)u(e,o,{get:n[o],enumerable:!0})},v=(e,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of l(n))!a.call(e,t)&&t!==o&&u(e,t,{get:()=>n[t],enumerable:!(i=g(n,t))||i.enumerable});return e};var O=e=>v(u({},"__esModule",{value:!0}),e);var P={};m(P,{OPEN_APP_TIMEOUT_MS:()=>d,appIconUrl:()=>A,openableApps:()=>_,useOpenApp:()=>E});module.exports=O(P);var r=require("react");const T="BOLOS",d=1e4,_=e=>(e.apps??[]).filter(({name:n})=>n!==T),A=e=>`https://cdn.live.ledger.com/icons/${e.toLowerCase().replaceAll(" ","_")}.png`;function E(e){const[n,o]=(0,r.useState)(),[i,t]=(0,r.useState)(),c=(0,r.useRef)(void 0);(0,r.useEffect)(()=>()=>clearTimeout(c.current),[]);const f=(0,r.useCallback)(s=>{!e||n||(o(s),t(void 0),e(s).then(()=>{c.current=setTimeout(()=>{o(void 0),t(`${s} opened but its screen never showed up`)},d)},p=>{o(void 0),t(p instanceof Error?p.message:String(p))}))},[e,n]);return{opening:n,error:i,open:f}}0&&(module.exports={OPEN_APP_TIMEOUT_MS,appIconUrl,openableApps,useOpenApp});
|
|
2
|
+
//# sourceMappingURL=useOpenApp.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useOpenApp.ts"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { type Device } from \"@ledgerhq/device-mockserver-client\";\n\n/** The OS reports itself as an app; it is not one the user can open. */\nconst OS_APP_NAME = \"BOLOS\";\n\nexport const OPEN_APP_TIMEOUT_MS = 10_000;\n\n/** The apps a device lists that the user can open. */\nexport const openableApps = (device: Device): NonNullable<Device[\"apps\"]> =>\n (device.apps ?? []).filter(({ name }) => name !== OS_APP_NAME);\n\n/** Ledger Live's app icons, keyed by the app's Manager API icon name. */\nexport const appIconUrl = (appName: string): string =>\n `https://cdn.live.ledger.com/icons/${appName.toLowerCase().replaceAll(\" \", \"_\")}.png`;\n\nexport interface OpenApp {\n /**\n * The app being opened. Kept on success, until the live screen replaces the\n * app list or the wait times out.\n */\n opening: string | undefined;\n error: string | undefined;\n /** Ignored without a handler, or while another app is opening. */\n open(appName: string): void;\n}\n\n/** Omitted, the apps are listed but cannot be opened. */\nexport function useOpenApp(\n onOpenApp: ((appName: string) => Promise<void>) | undefined,\n): OpenApp {\n const [opening, setOpening] = useState<string>();\n const [error, setError] = useState<string>();\n\n const openTimer = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n useEffect(() => () => clearTimeout(openTimer.current), []);\n\n const open = useCallback(\n (appName: string) => {\n if (!onOpenApp || opening) return;\n setOpening(appName);\n setError(undefined);\n onOpenApp(appName).then(\n () => {\n openTimer.current = setTimeout(() => {\n setOpening(undefined);\n setError(`${appName} opened but its screen never showed up`);\n }, OPEN_APP_TIMEOUT_MS);\n },\n (cause: unknown) => {\n setOpening(undefined);\n setError(cause instanceof Error ? cause.message : String(cause));\n },\n );\n },\n [onOpenApp, opening],\n );\n\n return { opening, error, open };\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAyD,iBAIzD,MAAMC,EAAc,QAEPN,EAAsB,IAGtBE,EAAgBK,IAC1BA,EAAO,MAAQ,CAAC,GAAG,OAAO,CAAC,CAAE,KAAAC,CAAK,IAAMA,IAASF,CAAW,EAGlDL,EAAcQ,GACzB,qCAAqCA,EAAQ,YAAY,EAAE,WAAW,IAAK,GAAG,CAAC,OAc1E,SAASN,EACdO,EACS,CACT,KAAM,CAACC,EAASC,CAAU,KAAI,YAAiB,EACzC,CAACC,EAAOC,CAAQ,KAAI,YAAiB,EAErCC,KAAY,UAChB,MACF,KACA,aAAU,IAAM,IAAM,aAAaA,EAAU,OAAO,EAAG,CAAC,CAAC,EAEzD,MAAMC,KAAO,eACVP,GAAoB,CACf,CAACC,GAAaC,IAClBC,EAAWH,CAAO,EAClBK,EAAS,MAAS,EAClBJ,EAAUD,CAAO,EAAE,KACjB,IAAM,CACJM,EAAU,QAAU,WAAW,IAAM,CACnCH,EAAW,MAAS,EACpBE,EAAS,GAAGL,CAAO,wCAAwC,CAC7D,EAAGT,CAAmB,CACxB,EACCiB,GAAmB,CAClBL,EAAW,MAAS,EACpBE,EAASG,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,CACjE,CACF,EACF,EACA,CAACP,EAAWC,CAAO,CACrB,EAEA,MAAO,CAAE,QAAAA,EAAS,MAAAE,EAAO,KAAAG,CAAK,CAChC",
|
|
6
|
+
"names": ["useOpenApp_exports", "__export", "OPEN_APP_TIMEOUT_MS", "appIconUrl", "openableApps", "useOpenApp", "__toCommonJS", "import_react", "OS_APP_NAME", "device", "name", "appName", "onOpenApp", "opening", "setOpening", "error", "setError", "openTimer", "open", "cause"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var w=(e,r)=>{for(var c in r)h(e,c,{get:r[c],enumerable:!0})},P=(e,r,c,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of D(r))!p.call(e,i)&&i!==c&&h(e,i,{get:()=>r[i],enumerable:!(l=L(r,i))||l.enumerable});return e};var R=e=>P(h({},"__esModule",{value:!0}),e);var M={};w(M,{useScreenPolling:()=>F});module.exports=R(M);var t=require("react");const T=500,_=2e3,b=3,A=e=>e instanceof Error?e.message:String(e);function F(e,r,c){const[l,i]=(0,t.useState)({kind:"loading"}),f=(0,t.useRef)(null),g=(0,t.useRef)(!1),m=(0,t.useRef)(!1);m.current=l.kind==="image";const E=(0,t.useRef)(0),v=(0,t.useRef)(0),S=(0,t.useCallback)(o=>{m.current&&++E.current<=b||i({kind:"error",message:A(o)})},[]),a=(0,t.useCallback)(()=>{f.current&&(c.releaseImageSource?.(f.current),f.current=null)},[c]),I=(0,t.useRef)(()=>{}),k=(0,t.useMemo)(()=>{const o=n=>void n.then(()=>I.current()).catch(S);return{pressButton:(n,s)=>o(e.pressButton(n,s)),touch:(n,s,u)=>o(e.touch(n,s,u))}},[e,S]),y=(0,t.useCallback)(async()=>{if(g.current)return;g.current=!0;const o=v.current,n=()=>o!==v.current;try{const s=await e.screenshot();if(n())return;if(E.current=0,s){const u=await c.toImageSource(s);if(n()){c.releaseImageSource?.(u);return}u!==f.current&&(a(),f.current=u),i(d=>d.kind==="image"&&d.src===u&&d.input===k?d:{kind:"image",src:u,input:k})}else{const u=await e.idle?.();if(n())return;a(),i(u??{kind:"error",message:"No screen to capture"})}}catch(s){n()||S(s)}finally{g.current=!1}},[e,c,k,S,a]);return I.current=()=>void y(),(0,t.useEffect)(()=>{if(!r){a(),i({kind:"loading"});return}let o,n=!1;const s=async()=>{c.isHidden()||await y(),!n&&(o=setTimeout(()=>void s(),m.current?T:_))};return s(),()=>{n=!0,clearTimeout(o),v.current++}},[r,c,y,a]),(0,t.useEffect)(()=>a,[a]),l}0&&(module.exports={useScreenPolling});
|
|
2
|
+
//# sourceMappingURL=useScreenPolling.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useScreenPolling.ts"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport {\n type DeviceScreenInput,\n type DeviceScreenState,\n type ScreenApi,\n type ScreenPlatform,\n} from \"./types\";\n\nconst SCREEN_POLL_MS = 500;\nconst IDLE_POLL_MS = 2000;\n/**\n * An app quitting fails a few calls while Speculos shuts down; the last frame\n * stays up through them rather than flashing an error before the dashboard.\n */\nconst LIVE_FAILURES_TOLERATED = 3;\n\nconst describe = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nexport function useScreenPolling(\n api: ScreenApi,\n polling: boolean,\n platform: ScreenPlatform,\n): DeviceScreenState {\n const [state, setState] = useState<DeviceScreenState>({ kind: \"loading\" });\n\n const imageSource = useRef<string | null>(null);\n const inFlight = useRef(false);\n const isLive = useRef(false);\n isLive.current = state.kind === \"image\";\n const liveFailures = useRef(0);\n /** Bumped when polling stops, so a response still in flight is dropped. */\n const generation = useRef(0);\n\n const fail = useCallback((error: unknown) => {\n if (isLive.current && ++liveFailures.current <= LIVE_FAILURES_TOLERATED) {\n return;\n }\n setState({ kind: \"error\", message: describe(error) });\n }, []);\n\n const releaseImageSource = useCallback(() => {\n if (imageSource.current) {\n platform.releaseImageSource?.(imageSource.current);\n imageSource.current = null;\n }\n }, [platform]);\n\n /**\n * Input handlers refresh straight after acting. Going through a ref keeps\n * them stable, so the <img> is not remounted on every poll.\n */\n const refreshRef = useRef<() => void>(() => {});\n\n const input = useMemo<DeviceScreenInput>(() => {\n const send = (call: Promise<void>) =>\n void call.then(() => refreshRef.current()).catch(fail);\n\n return {\n pressButton: (button, action) => send(api.pressButton(button, action)),\n touch: (x, y, action) => send(api.touch(x, y, action)),\n };\n }, [api, fail]);\n\n const refresh = useCallback(async () => {\n if (inFlight.current) return;\n inFlight.current = true;\n const started = generation.current;\n const stale = () => started !== generation.current;\n try {\n const blob = await api.screenshot();\n if (stale()) return;\n liveFailures.current = 0;\n if (blob) {\n const source = await platform.toImageSource(blob);\n if (stale()) {\n platform.releaseImageSource?.(source);\n return;\n }\n if (source !== imageSource.current) {\n releaseImageSource();\n imageSource.current = source;\n }\n // A source made from the bytes, like a data URI, repeats while the\n // screen holds still; keeping the state then skips a re-render.\n setState((current) =>\n current.kind === \"image\" &&\n current.src === source &&\n current.input === input\n ? current\n : { kind: \"image\", src: source, input },\n );\n } else {\n const idle = await api.idle?.();\n if (stale()) return;\n releaseImageSource();\n setState(idle ?? { kind: \"error\", message: \"No screen to capture\" });\n }\n } catch (error) {\n if (!stale()) fail(error);\n } finally {\n inFlight.current = false;\n }\n }, [api, platform, input, fail, releaseImageSource]);\n refreshRef.current = () => void refresh();\n\n useEffect(() => {\n if (!polling) {\n // Drop the frame rather than keep a released source around, which\n // would flash a broken image when the panel reopens.\n releaseImageSource();\n setState({ kind: \"loading\" });\n return;\n }\n\n let timer: ReturnType<typeof setTimeout>;\n let cancelled = false;\n\n const tick = async () => {\n if (!platform.isHidden()) await refresh();\n if (cancelled) return;\n timer = setTimeout(\n () => void tick(),\n isLive.current ? SCREEN_POLL_MS : IDLE_POLL_MS,\n );\n };\n void tick();\n\n return () => {\n cancelled = true;\n clearTimeout(timer);\n generation.current++;\n };\n }, [polling, platform, refresh, releaseImageSource]);\n\n useEffect(() => releaseImageSource, [releaseImageSource]);\n\n return state;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkE,iBASlE,MAAMC,EAAiB,IACjBC,EAAe,IAKfC,EAA0B,EAE1BC,EAAYC,GAChBA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EAEhD,SAASP,EACdQ,EACAC,EACAC,EACmB,CACnB,KAAM,CAACC,EAAOC,CAAQ,KAAI,YAA4B,CAAE,KAAM,SAAU,CAAC,EAEnEC,KAAc,UAAsB,IAAI,EACxCC,KAAW,UAAO,EAAK,EACvBC,KAAS,UAAO,EAAK,EAC3BA,EAAO,QAAUJ,EAAM,OAAS,QAChC,MAAMK,KAAe,UAAO,CAAC,EAEvBC,KAAa,UAAO,CAAC,EAErBC,KAAO,eAAaX,GAAmB,CACvCQ,EAAO,SAAW,EAAEC,EAAa,SAAWX,GAGhDO,EAAS,CAAE,KAAM,QAAS,QAASN,EAASC,CAAK,CAAE,CAAC,CACtD,EAAG,CAAC,CAAC,EAECY,KAAqB,eAAY,IAAM,CACvCN,EAAY,UACdH,EAAS,qBAAqBG,EAAY,OAAO,EACjDA,EAAY,QAAU,KAE1B,EAAG,CAACH,CAAQ,CAAC,EAMPU,KAAa,UAAmB,IAAM,CAAC,CAAC,EAExCC,KAAQ,WAA2B,IAAM,CAC7C,MAAMC,EAAQC,GACZ,KAAKA,EAAK,KAAK,IAAMH,EAAW,QAAQ,CAAC,EAAE,MAAMF,CAAI,EAEvD,MAAO,CACL,YAAa,CAACM,EAAQC,IAAWH,EAAKd,EAAI,YAAYgB,EAAQC,CAAM,CAAC,EACrE,MAAO,CAACC,EAAGC,EAAGF,IAAWH,EAAKd,EAAI,MAAMkB,EAAGC,EAAGF,CAAM,CAAC,CACvD,CACF,EAAG,CAACjB,EAAKU,CAAI,CAAC,EAERU,KAAU,eAAY,SAAY,CACtC,GAAId,EAAS,QAAS,OACtBA,EAAS,QAAU,GACnB,MAAMe,EAAUZ,EAAW,QACrBa,EAAQ,IAAMD,IAAYZ,EAAW,QAC3C,GAAI,CACF,MAAMc,EAAO,MAAMvB,EAAI,WAAW,EAClC,GAAIsB,EAAM,EAAG,OAEb,GADAd,EAAa,QAAU,EACnBe,EAAM,CACR,MAAMC,EAAS,MAAMtB,EAAS,cAAcqB,CAAI,EAChD,GAAID,EAAM,EAAG,CACXpB,EAAS,qBAAqBsB,CAAM,EACpC,MACF,CACIA,IAAWnB,EAAY,UACzBM,EAAmB,EACnBN,EAAY,QAAUmB,GAIxBpB,EAAUqB,GACRA,EAAQ,OAAS,SACjBA,EAAQ,MAAQD,GAChBC,EAAQ,QAAUZ,EACdY,EACA,CAAE,KAAM,QAAS,IAAKD,EAAQ,MAAAX,CAAM,CAC1C,CACF,KAAO,CACL,MAAMa,EAAO,MAAM1B,EAAI,OAAO,EAC9B,GAAIsB,EAAM,EAAG,OACbX,EAAmB,EACnBP,EAASsB,GAAQ,CAAE,KAAM,QAAS,QAAS,sBAAuB,CAAC,CACrE,CACF,OAAS3B,EAAO,CACTuB,EAAM,GAAGZ,EAAKX,CAAK,CAC1B,QAAE,CACAO,EAAS,QAAU,EACrB,CACF,EAAG,CAACN,EAAKE,EAAUW,EAAOH,EAAMC,CAAkB,CAAC,EACnD,OAAAC,EAAW,QAAU,IAAM,KAAKQ,EAAQ,KAExC,aAAU,IAAM,CACd,GAAI,CAACnB,EAAS,CAGZU,EAAmB,EACnBP,EAAS,CAAE,KAAM,SAAU,CAAC,EAC5B,MACF,CAEA,IAAIuB,EACAC,EAAY,GAEhB,MAAMC,EAAO,SAAY,CAClB3B,EAAS,SAAS,GAAG,MAAMkB,EAAQ,EACpC,CAAAQ,IACJD,EAAQ,WACN,IAAM,KAAKE,EAAK,EAChBtB,EAAO,QAAUZ,EAAiBC,CACpC,EACF,EACA,OAAKiC,EAAK,EAEH,IAAM,CACXD,EAAY,GACZ,aAAaD,CAAK,EAClBlB,EAAW,SACb,CACF,EAAG,CAACR,EAASC,EAAUkB,EAAST,CAAkB,CAAC,KAEnD,aAAU,IAAMA,EAAoB,CAACA,CAAkB,CAAC,EAEjDR,CACT",
|
|
6
|
+
"names": ["useScreenPolling_exports", "__export", "useScreenPolling", "__toCommonJS", "import_react", "SCREEN_POLL_MS", "IDLE_POLL_MS", "LIVE_FAILURES_TOLERATED", "describe", "error", "api", "polling", "platform", "state", "setState", "imageSource", "inFlight", "isLive", "liveFailures", "generation", "fail", "releaseImageSource", "refreshRef", "input", "send", "call", "button", "action", "x", "y", "refresh", "started", "stale", "blob", "source", "current", "idle", "timer", "cancelled", "tick"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},S=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of c(t))!p.call(e,i)&&i!==o&&r(e,i,{get:()=>t[i],enumerable:!(n=d(t,i))||n.enumerable});return e};var b=e=>S(r({},"__esModule",{value:!0}),e);var f={};y(f,{toScreenPoint:()=>x,useTouchHold:()=>a});module.exports=b(f);var u=require("react"),h=require("./useHold");const x=(e,t,o,n)=>{if(!o.width||!o.height||!n.width||!n.height)return null;const i=(m,l)=>Math.min(Math.max(Math.round(m),0),l-1);return{x:i(e/o.width*n.width,n.width),y:i(t/o.height*n.height,n.height)}};function a(e){const t=(0,u.useMemo)(()=>e&&((o,n)=>e(o.x,o.y,n)),[e]);return(0,h.useHold)(t)}0&&(module.exports={toScreenPoint,useTouchHold});
|
|
2
|
+
//# sourceMappingURL=useTouchHold.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useTouchHold.ts"],
|
|
4
|
+
"sourcesContent": ["import { useMemo } from \"react\";\nimport { type SpeculosAction } from \"@ledgerhq/device-mockserver-client\";\n\nimport { type Hold, useHold } from \"./useHold\";\n\nexport interface Size {\n readonly width: number;\n readonly height: number;\n}\n\nexport interface ScreenPoint {\n readonly x: number;\n readonly y: number;\n}\n\n/**\n * Where an offset into the screen as drawn lands in device pixels, or null\n * while either size is unknown.\n */\nexport const toScreenPoint = (\n offsetX: number,\n offsetY: number,\n drawn: Size,\n screen: Size,\n): ScreenPoint | null => {\n if (!drawn.width || !drawn.height || !screen.width || !screen.height) {\n return null;\n }\n // The far edge maps to the pixel count itself, one past the last pixel.\n const clamp = (value: number, size: number) =>\n Math.min(Math.max(Math.round(value), 0), size - 1);\n return {\n x: clamp((offsetX / drawn.width) * screen.width, screen.width),\n y: clamp((offsetY / drawn.height) * screen.height, screen.height),\n };\n};\n\nexport type TouchHold = Hold<ScreenPoint>;\n\n/**\n * A finger's down and up on the screen, as the actions the device gets: a\n * quick tap as one press-and-release, a hold as a press then a release on the\n * spot where it went down.\n */\nexport function useTouchHold(\n onTouch: ((x: number, y: number, action: SpeculosAction) => void) | undefined,\n): TouchHold {\n const onAction = useMemo(\n () =>\n onTouch &&\n ((point: ScreenPoint, action: SpeculosAction) =>\n onTouch(point.x, point.y, action)),\n [onTouch],\n );\n return useHold(onAction);\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,iBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAwB,iBAGxBC,EAAmC,qBAgB5B,MAAMJ,EAAgB,CAC3BK,EACAC,EACAC,EACAC,IACuB,CACvB,GAAI,CAACD,EAAM,OAAS,CAACA,EAAM,QAAU,CAACC,EAAO,OAAS,CAACA,EAAO,OAC5D,OAAO,KAGT,MAAMC,EAAQ,CAACC,EAAeC,IAC5B,KAAK,IAAI,KAAK,IAAI,KAAK,MAAMD,CAAK,EAAG,CAAC,EAAGC,EAAO,CAAC,EACnD,MAAO,CACL,EAAGF,EAAOJ,EAAUE,EAAM,MAASC,EAAO,MAAOA,EAAO,KAAK,EAC7D,EAAGC,EAAOH,EAAUC,EAAM,OAAUC,EAAO,OAAQA,EAAO,MAAM,CAClE,CACF,EASO,SAASP,EACdW,EACW,CACX,MAAMC,KAAW,WACf,IACED,IACC,CAACE,EAAoBC,IACpBH,EAAQE,EAAM,EAAGA,EAAM,EAAGC,CAAM,GACpC,CAACH,CAAO,CACV,EACA,SAAO,WAAQC,CAAQ,CACzB",
|
|
6
|
+
"names": ["useTouchHold_exports", "__export", "toScreenPoint", "useTouchHold", "__toCommonJS", "import_react", "import_useHold", "offsetX", "offsetY", "drawn", "screen", "clamp", "value", "size", "onTouch", "onAction", "point", "action"]
|
|
7
|
+
}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@ledgerhq/device-mockserver-client": "workspace:*"
|
|
4
|
+
},
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
7
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
8
|
+
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
9
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
10
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
11
|
+
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
12
|
+
"@types/react": "catalog:",
|
|
13
|
+
"@types/react-dom": "catalog:",
|
|
14
|
+
"react": "catalog:",
|
|
15
|
+
"react-dom": "catalog:"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./lib/esm/index.js",
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"types": "./lib/types/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./*": {
|
|
24
|
+
"import": "./lib/esm/*",
|
|
25
|
+
"require": "./lib/cjs/*",
|
|
26
|
+
"types": "./lib/types/*"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"./lib"
|
|
31
|
+
],
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"main": "lib/cjs/index.js",
|
|
34
|
+
"name": "@ledgerhq/device-mockserver-react-core",
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
37
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"private": false,
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/*.tsx,src/*.ts --tsconfig tsconfig.prod.json",
|
|
46
|
+
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
47
|
+
"lint": "eslint",
|
|
48
|
+
"lint:fix": "pnpm lint --fix",
|
|
49
|
+
"prebuild": "rimraf lib",
|
|
50
|
+
"prettier": "prettier . --check",
|
|
51
|
+
"prettier:fix": "prettier . --write",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:coverage": "vitest run --coverage",
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/*.tsx,src/*.ts --tsconfig tsconfig.prod.json",
|
|
57
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
58
|
+
},
|
|
59
|
+
"types": "lib/types/index.d.ts",
|
|
60
|
+
"version": "0.0.0-delayed-signing-20261113142655"
|
|
61
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(n,r)=>({label:n,touch:!1,speculos:!0,screenWidth:128,screenHeight:r,lightScreen:!1}),c={nanoS:{...e("Nano S",32),speculos:!1},nanoSP:e("Nano S Plus",64),nanoX:e("Nano X",64),stax:{label:"Stax",touch:!0,speculos:!0,screenWidth:400,screenHeight:672,lightScreen:!0},flex:{label:"Flex",touch:!0,speculos:!0,screenWidth:480,screenHeight:600,lightScreen:!0},apexp:{label:"Apex",touch:!0,speculos:!0,screenWidth:300,screenHeight:400,lightScreen:!0}},o=e("Device",64),t=n=>c[n]??o;export{t as findDeviceScreenModel};
|
|
2
|
+
//# sourceMappingURL=deviceModels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/deviceModels.ts"],
|
|
4
|
+
"sourcesContent": ["export interface DeviceScreenModel {\n readonly label: string;\n readonly touch: boolean;\n /** Whether Speculos has an emulator for it, so it can have a screen. */\n readonly speculos: boolean;\n /** In device pixels. */\n readonly screenWidth: number;\n readonly screenHeight: number;\n readonly lightScreen: boolean;\n}\n\nconst nano = (label: string, screenHeight: number): DeviceScreenModel => ({\n label,\n touch: false,\n speculos: true,\n screenWidth: 128,\n screenHeight,\n lightScreen: false,\n});\n\n/** Keyed by the mock server's `device_type`, a DMK `DeviceModelId`. */\nconst MODELS: Record<string, DeviceScreenModel> = {\n nanoS: { ...nano(\"Nano S\", 32), speculos: false },\n nanoSP: nano(\"Nano S Plus\", 64),\n nanoX: nano(\"Nano X\", 64),\n stax: {\n label: \"Stax\",\n touch: true,\n speculos: true,\n screenWidth: 400,\n screenHeight: 672,\n lightScreen: true,\n },\n flex: {\n label: \"Flex\",\n touch: true,\n speculos: true,\n screenWidth: 480,\n screenHeight: 600,\n lightScreen: true,\n },\n apexp: {\n label: \"Apex\",\n touch: true,\n speculos: true,\n screenWidth: 300,\n screenHeight: 400,\n lightScreen: true,\n },\n};\n\nconst UNKNOWN: DeviceScreenModel = nano(\"Device\", 64);\n\nexport const findDeviceScreenModel = (deviceType: string): DeviceScreenModel =>\n MODELS[deviceType] ?? UNKNOWN;\n"],
|
|
5
|
+
"mappings": "AAWA,MAAMA,EAAO,CAACC,EAAeC,KAA6C,CACxE,MAAAD,EACA,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAAC,EACA,YAAa,EACf,GAGMC,EAA4C,CAChD,MAAO,CAAE,GAAGH,EAAK,SAAU,EAAE,EAAG,SAAU,EAAM,EAChD,OAAQA,EAAK,cAAe,EAAE,EAC9B,MAAOA,EAAK,SAAU,EAAE,EACxB,KAAM,CACJ,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,EACA,MAAO,CACL,MAAO,OACP,MAAO,GACP,SAAU,GACV,YAAa,IACb,aAAc,IACd,YAAa,EACf,CACF,EAEMI,EAA6BJ,EAAK,SAAU,EAAE,EAEvCK,EAAyBC,GACpCH,EAAOG,CAAU,GAAKF",
|
|
6
|
+
"names": ["nano", "label", "screenHeight", "MODELS", "UNKNOWN", "findDeviceScreenModel", "deviceType"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{findDeviceScreenModel as r}from"./deviceModels";import{mockServerScreenApi as t}from"./mockServerScreenApi";import{useButtonHold as c}from"./useButtonHold";import{HOLD_THRESHOLD_MS as l,useHold as i}from"./useHold";import{useMockServerDevice as m}from"./useMockServerDevice";import{appIconUrl as d,OPEN_APP_TIMEOUT_MS as x,openableApps as y,useOpenApp as H}from"./useOpenApp";import{useScreenPolling as v}from"./useScreenPolling";import{toScreenPoint as M,useTouchHold as P}from"./useTouchHold";export{l as HOLD_THRESHOLD_MS,x as OPEN_APP_TIMEOUT_MS,d as appIconUrl,r as findDeviceScreenModel,t as mockServerScreenApi,y as openableApps,M as toScreenPoint,c as useButtonHold,i as useHold,m as useMockServerDevice,H as useOpenApp,v as useScreenPolling,P as useTouchHold};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|