@ledgerhq/device-mockserver-react 0.0.0-mockserver-react-20260929114136
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 +45 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +7 -0
- package/lib/cjs/package.json +67 -0
- package/lib/cjs/src/DeviceOsInfo.js +2 -0
- package/lib/cjs/src/DeviceOsInfo.js.map +7 -0
- package/lib/cjs/src/DeviceScreen.js +2 -0
- package/lib/cjs/src/DeviceScreen.js.map +7 -0
- package/lib/cjs/src/DeviceScreenButtons.js +2 -0
- package/lib/cjs/src/DeviceScreenButtons.js.map +7 -0
- package/lib/cjs/src/DeviceScreenImage.js +2 -0
- package/lib/cjs/src/DeviceScreenImage.js.map +7 -0
- package/lib/cjs/src/MockServerDevice.js +2 -0
- package/lib/cjs/src/MockServerDevice.js.map +7 -0
- package/lib/cjs/src/ScreenFrame.js +2 -0
- package/lib/cjs/src/ScreenFrame.js.map +7 -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/mockServerScreenApi.test.js +2 -0
- package/lib/cjs/src/mockServerScreenApi.test.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/useMockServerDevice.js +2 -0
- package/lib/cjs/src/useMockServerDevice.js.map +7 -0
- package/lib/cjs/src/useScreenPolling.js +2 -0
- package/lib/cjs/src/useScreenPolling.js.map +7 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +7 -0
- package/lib/esm/package.json +67 -0
- package/lib/esm/src/DeviceOsInfo.js +2 -0
- package/lib/esm/src/DeviceOsInfo.js.map +7 -0
- package/lib/esm/src/DeviceScreen.js +2 -0
- package/lib/esm/src/DeviceScreen.js.map +7 -0
- package/lib/esm/src/DeviceScreenButtons.js +2 -0
- package/lib/esm/src/DeviceScreenButtons.js.map +7 -0
- package/lib/esm/src/DeviceScreenImage.js +2 -0
- package/lib/esm/src/DeviceScreenImage.js.map +7 -0
- package/lib/esm/src/MockServerDevice.js +2 -0
- package/lib/esm/src/MockServerDevice.js.map +7 -0
- package/lib/esm/src/ScreenFrame.js +2 -0
- package/lib/esm/src/ScreenFrame.js.map +7 -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/mockServerScreenApi.test.js +2 -0
- package/lib/esm/src/mockServerScreenApi.test.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/useMockServerDevice.js +2 -0
- package/lib/esm/src/useMockServerDevice.js.map +7 -0
- package/lib/esm/src/useScreenPolling.js +2 -0
- package/lib/esm/src/useScreenPolling.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/DeviceOsInfo.d.ts +12 -0
- package/lib/types/src/DeviceOsInfo.d.ts.map +1 -0
- package/lib/types/src/DeviceScreen.d.ts +17 -0
- package/lib/types/src/DeviceScreen.d.ts.map +1 -0
- package/lib/types/src/DeviceScreenButtons.d.ts +8 -0
- package/lib/types/src/DeviceScreenButtons.d.ts.map +1 -0
- package/lib/types/src/DeviceScreenImage.d.ts +10 -0
- package/lib/types/src/DeviceScreenImage.d.ts.map +1 -0
- package/lib/types/src/MockServerDevice.d.ts +10 -0
- package/lib/types/src/MockServerDevice.d.ts.map +1 -0
- package/lib/types/src/ScreenFrame.d.ts +12 -0
- package/lib/types/src/ScreenFrame.d.ts.map +1 -0
- package/lib/types/src/deviceModels.d.ts +14 -0
- package/lib/types/src/deviceModels.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +7 -0
- package/lib/types/src/index.d.ts.map +1 -0
- package/lib/types/src/mockServerScreenApi.d.ts +4 -0
- package/lib/types/src/mockServerScreenApi.d.ts.map +1 -0
- package/lib/types/src/mockServerScreenApi.test.d.ts +2 -0
- package/lib/types/src/mockServerScreenApi.test.d.ts.map +1 -0
- package/lib/types/src/types.d.ts +41 -0
- package/lib/types/src/types.d.ts.map +1 -0
- package/lib/types/src/useMockServerDevice.d.ts +7 -0
- package/lib/types/src/useMockServerDevice.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/tsconfig.prod.tsbuildinfo +1 -0
- package/package.json +67 -0
- package/tailwind.css +2 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Nano } from "@ledgerhq/lumen-ui-react/symbols";
|
|
2
|
+
export interface DeviceScreenModel {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly icon: typeof Nano;
|
|
5
|
+
readonly touch: boolean;
|
|
6
|
+
/** Whether Speculos has an emulator for it, so it can have a screen. */
|
|
7
|
+
readonly speculos: boolean;
|
|
8
|
+
/** In device pixels. */
|
|
9
|
+
readonly screenWidth: number;
|
|
10
|
+
readonly screenHeight: number;
|
|
11
|
+
readonly lightScreen: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const findDeviceScreenModel: (deviceType: string) => DeviceScreenModel;
|
|
14
|
+
//# sourceMappingURL=deviceModels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceModels.d.ts","sourceRoot":"","sources":["../../../src/deviceModels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAQ,MAAM,kCAAkC,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,wBAAwB;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAgDD,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,KAAG,iBAC5B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { type DeviceScreenModel, findDeviceScreenModel } from "./deviceModels";
|
|
2
|
+
export { DeviceScreen, type DeviceScreenProps } from "./DeviceScreen";
|
|
3
|
+
export { MockServerDevice, type MockServerDeviceProps, } from "./MockServerDevice";
|
|
4
|
+
export { mockServerScreenApi } from "./mockServerScreenApi";
|
|
5
|
+
export type { DeviceScreenState, ScreenApi } from "./types";
|
|
6
|
+
export { useMockServerDevice } from "./useMockServerDevice";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockServerScreenApi.d.ts","sourceRoot":"","sources":["../../../src/mockServerScreenApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzC,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,UAAU,EAClB,UAAU,MAAM,KACf,SA8BD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockServerScreenApi.test.d.ts","sourceRoot":"","sources":["../../../src/mockServerScreenApi.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Device, type SpeculosAction, type SpeculosButton } from "@ledgerhq/device-mockserver-client";
|
|
2
|
+
/**
|
|
3
|
+
* How the screen is reached. The mock server proxies to the Speculos instance
|
|
4
|
+
* backing a device and a Speculos transport talks to one directly, but both
|
|
5
|
+
* answer the same calls.
|
|
6
|
+
*/
|
|
7
|
+
export interface ScreenApi {
|
|
8
|
+
/** Resolves null when there is no screen to capture right now. */
|
|
9
|
+
screenshot(): Promise<Blob | null>;
|
|
10
|
+
/** What to show while `screenshot` keeps resolving null. */
|
|
11
|
+
idle?(): Promise<DeviceScreenState>;
|
|
12
|
+
pressButton(button: SpeculosButton, action: SpeculosAction): Promise<void>;
|
|
13
|
+
/** Coordinates in device screen pixels. */
|
|
14
|
+
touch(x: number, y: number, action: SpeculosAction): Promise<void>;
|
|
15
|
+
/** Omitted by apis whose device always runs an app. */
|
|
16
|
+
openApp?(appName: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Press and release are separate so a hold reaches the device as a hold: Stax
|
|
20
|
+
* and Flex gate their confirmations behind one.
|
|
21
|
+
*/
|
|
22
|
+
export interface DeviceScreenInput {
|
|
23
|
+
pressButton(button: SpeculosButton, action: SpeculosAction): void;
|
|
24
|
+
touch(x: number, y: number, action: SpeculosAction): void;
|
|
25
|
+
}
|
|
26
|
+
export type DeviceScreenState = {
|
|
27
|
+
kind: "loading";
|
|
28
|
+
}
|
|
29
|
+
/** No app runs, so no Speculos instance: the device record stands in. */
|
|
30
|
+
| {
|
|
31
|
+
kind: "os-info";
|
|
32
|
+
device: Device;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "image";
|
|
35
|
+
src: string;
|
|
36
|
+
input: DeviceScreenInput;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "error";
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,kEAAkE;IAClE,UAAU,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACnC,4DAA4D;IAC5D,IAAI,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpC,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,2CAA2C;IAC3C,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,uDAAuD;IACvD,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAClE,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,yEAAyE;GACvE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Device, type MockClient } from "@ledgerhq/device-mockserver-client";
|
|
2
|
+
/**
|
|
3
|
+
* The mock server's record of a device: undefined while it loads, or while no
|
|
4
|
+
* device id is given, and null when it could not be read.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useMockServerDevice(client: MockClient, deviceId: string): Device | null | undefined;
|
|
7
|
+
//# sourceMappingURL=useMockServerDevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMockServerDevice.d.ts","sourceRoot":"","sources":["../../../src/useMockServerDevice.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,oCAAoC,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,GAAG,SAAS,CAqB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreenPolling.d.ts","sourceRoot":"","sources":["../../../src/useScreenPolling.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AAajB,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,OAAO,GACf,iBAAiB,CAoGnB"}
|