@ledgerhq/speculos-device-controller 0.0.0-develop-20261104000847 → 0.0.0-develop-20261107000805
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/lib/cjs/package.json +1 -1
- package/lib/esm/package.json +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/api/DeviceController.test.js +0 -2
- package/lib/cjs/src/api/DeviceController.test.js.map +0 -7
- package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js +0 -2
- package/lib/cjs/src/internal/adapters/DefaultButtonController.test.js.map +0 -7
- package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js +0 -2
- package/lib/cjs/src/internal/adapters/DefaultTouchController.test.js.map +0 -7
- package/lib/cjs/src/internal/di.test.js +0 -2
- package/lib/cjs/src/internal/di.test.js.map +0 -7
- package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js +0 -2
- package/lib/cjs/src/internal/use-cases/buttonUseCases.test.js.map +0 -7
- package/lib/cjs/src/internal/use-cases/touchUseCases.test.js +0 -2
- package/lib/cjs/src/internal/use-cases/touchUseCases.test.js.map +0 -7
- package/lib/cjs/src/internal/utils/axisClamp.test.js +0 -2
- package/lib/cjs/src/internal/utils/axisClamp.test.js.map +0 -7
- package/lib/esm/src/api/DeviceController.test.js +0 -2
- package/lib/esm/src/api/DeviceController.test.js.map +0 -7
- package/lib/esm/src/internal/adapters/DefaultButtonController.test.js +0 -2
- package/lib/esm/src/internal/adapters/DefaultButtonController.test.js.map +0 -7
- package/lib/esm/src/internal/adapters/DefaultTouchController.test.js +0 -2
- package/lib/esm/src/internal/adapters/DefaultTouchController.test.js.map +0 -7
- package/lib/esm/src/internal/di.test.js +0 -2
- package/lib/esm/src/internal/di.test.js.map +0 -7
- package/lib/esm/src/internal/use-cases/buttonUseCases.test.js +0 -2
- package/lib/esm/src/internal/use-cases/buttonUseCases.test.js.map +0 -7
- package/lib/esm/src/internal/use-cases/touchUseCases.test.js +0 -2
- package/lib/esm/src/internal/use-cases/touchUseCases.test.js.map +0 -7
- package/lib/esm/src/internal/utils/axisClamp.test.js +0 -2
- package/lib/esm/src/internal/utils/axisClamp.test.js.map +0 -7
- package/lib/types/src/api/DeviceController.test.d.ts +0 -2
- package/lib/types/src/api/DeviceController.test.d.ts.map +0 -1
- package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts +0 -2
- package/lib/types/src/internal/adapters/DefaultButtonController.test.d.ts.map +0 -1
- package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts +0 -2
- package/lib/types/src/internal/adapters/DefaultTouchController.test.d.ts.map +0 -1
- package/lib/types/src/internal/di.test.d.ts +0 -2
- package/lib/types/src/internal/di.test.d.ts.map +0 -1
- package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts +0 -2
- package/lib/types/src/internal/use-cases/buttonUseCases.test.d.ts.map +0 -1
- package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts +0 -2
- package/lib/types/src/internal/use-cases/touchUseCases.test.d.ts.map +0 -1
- package/lib/types/src/internal/utils/axisClamp.test.d.ts +0 -2
- package/lib/types/src/internal/utils/axisClamp.test.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@ledgerhq/device-management-kit": "0.0.0-develop-
|
|
3
|
+
"@ledgerhq/device-management-kit": "0.0.0-develop-20261107000805"
|
|
4
4
|
},
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"ts-node": "10.9.2",
|
|
7
|
+
"@ledgerhq/prettier-config-dsdk": "0.0.2",
|
|
7
8
|
"@ledgerhq/eslint-config-dsdk": "0.0.2",
|
|
8
9
|
"@ledgerhq/ldmk-tool": "0.0.1",
|
|
9
|
-
"@ledgerhq/prettier-config-dsdk": "0.0.2",
|
|
10
10
|
"@ledgerhq/tsconfig-dsdk": "1.0.1",
|
|
11
11
|
"@ledgerhq/vitest-config-dmk": "0.0.0"
|
|
12
12
|
},
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"name": "@ledgerhq/speculos-device-controller",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@ledgerhq/device-management-kit": "0.0.0-develop-
|
|
31
|
+
"@ledgerhq/device-management-kit": "0.0.0-develop-20261107000805"
|
|
32
32
|
},
|
|
33
33
|
"private": false,
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
37
37
|
},
|
|
38
|
-
"version": "0.0.0-develop-
|
|
38
|
+
"version": "0.0.0-develop-20261107000805",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
41
41
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
@@ -1,2 +0,0 @@
|
|
|
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)}),it("sends the bearer token with every request",async()=>{const e=vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}"));await(0,o.deviceControllerClientFactory)("http://localhost:0",{bearerToken:"session-token"}).buttonFactory().press("both"),expect(e).toHaveBeenCalledWith("http://localhost:0/button/both",expect.objectContaining({headers:expect.objectContaining({Authorization:"Bearer session-token"})})),e.mockRestore()})});
|
|
2
|
-
//# sourceMappingURL=DeviceController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/api/DeviceController.test.ts"],
|
|
4
|
-
"sourcesContent": ["import 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 it(\"sends the bearer token with every request\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n const deviceClient = deviceControllerClientFactory(\"http://localhost:0\", {\n bearerToken: \"session-token\",\n });\n\n await deviceClient.buttonFactory().press(\"both\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"http://localhost:0/button/both\",\n expect.objectContaining({\n headers: expect.objectContaining({\n Authorization: \"Bearer session-token\",\n }),\n }),\n );\n fetchSpy.mockRestore();\n });\n});\n"],
|
|
5
|
-
"mappings": "aAEA,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,EAED,GAAG,4CAA6C,SAAY,CAC1D,MAAMC,EAAW,GACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAKvC,QAJqB,iCAA8B,qBAAsB,CACvE,YAAa,eACf,CAAC,EAEkB,cAAc,EAAE,MAAM,MAAM,EAE/C,OAAOA,CAAQ,EAAE,qBACf,iCACA,OAAO,iBAAiB,CACtB,QAAS,OAAO,iBAAiB,CAC/B,cAAe,sBACjB,CAAC,CACH,CAAC,CACH,EACAA,EAAS,YAAY,CACvB,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_DeviceController", "deviceClient", "deviceButtons", "deviceTaps", "a", "b", "fetchSpy"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var r=require("./DefaultButtonController");describe("DefaultButtonController",()=>{let e,n,o;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),n={post:e},o=new r.DefaultButtonController(n)});const l=["left","right","both"];it.each(l)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
|
|
2
|
-
//# sourceMappingURL=DefaultButtonController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ButtonKey, HttpClient } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n controller = new DefaultButtonController(httpClient);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
|
|
5
|
-
"mappings": "aAEA,IAAAA,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAC9BE,EAAa,IAAI,0BAAwBD,CAAU,CACrD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_DefaultButtonController", "postMock", "httpClient", "controller", "keys", "key", "error"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var l=require("./DefaultTouchController");describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((a,i)=>({x:Math.round(a*10),y:Math.round(i*20)}))},r={xy:vi.fn((a,i)=>({x:Math.round(100+a),y:Math.round(200+i)}))};let c,n;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},n=new l.DefaultTouchController(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await n.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...a})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await n.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const a=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...a})}),it("release: converts via axes and POSTs action 'release'",async()=>{await n.release("devA",t);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...a})}),it("throws an error when device key is unknown",async()=>{await expect(n.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors",async()=>{const a=new Error("backend down");e.mockRejectedValueOnce(a),await expect(n.tapAndRelease("devA",t)).rejects.toBe(a)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((n,t)=>({x:n,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue(void 0),o={post:s},r.xy.mockClear(),e=new l.DefaultTouchController(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const n=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of n)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const n=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of n)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
|
|
2
|
-
//# sourceMappingURL=DefaultTouchController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/adapters/DefaultTouchController.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport type { HttpClient, PercentCoordinates } from \"../core/types\";\nimport { DefaultTouchController } from \"./DefaultTouchController\";\n\ndescribe(\"DefaultTouchController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axisA = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(xPct * 10),\n y: Math.round(yPct * 20),\n })),\n };\n const axisB = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(100 + xPct),\n y: Math.round(200 + yPct),\n })),\n };\n let axesFake: Record<\n string,\n { xy: (x: number, y: number) => { x: number; y: number } }\n >;\n\n let controller: DefaultTouchController<string>;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n\n axisA.xy.mockClear();\n axisB.xy.mockClear();\n\n axesFake = { devA: axisA, devB: axisB };\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n const point: PercentCoordinates = { x: 12, y: 45 };\n\n it(\"tapAndRelease: converts percent to absolute via axes and POSTs expected body\", async () => {\n await controller.tapAndRelease(\"devA\", point);\n\n expect(axisA.xy).toHaveBeenCalledTimes(1);\n expect(axisA.xy).toHaveBeenCalledWith(point.x, point.y);\n\n const expectedAbs = (axisA.xy.mock.results as any)[0].value;\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press-and-release\",\n ...expectedAbs,\n });\n });\n\n it(\"tap: converts via axes and POSTs action 'press'\", async () => {\n await controller.tap(\"devB\", point);\n\n expect(axisB.xy).toHaveBeenCalledWith(point.x, point.y);\n const expectedAbs = axisB.xy.mock.results[0]?.value;\n\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press\",\n ...expectedAbs,\n });\n });\n\n it(\"release: converts via axes and POSTs action 'release'\", async () => {\n await controller.release(\"devA\", point);\n\n const expectedAbs = axisA.xy.mock.results[0]!.value;\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"release\",\n ...expectedAbs,\n });\n });\n\n it(\"throws an error when device key is unknown\", async () => {\n await expect(controller.tap(\"unknownDevice\" as any, point)).rejects.toThrow(\n /\\[Touch] Unknown device key \"unknownDevice\".*Known keys: devA, devB/,\n );\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"propagates HTTP errors\", async () => {\n const boom = new Error(\"backend down\");\n postMock.mockRejectedValueOnce(boom);\n\n await expect(controller.tapAndRelease(\"devA\", point)).rejects.toBe(boom);\n });\n});\n\ndescribe(\"percent validation\", () => {\n let controller: DefaultTouchController<string>;\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axis = {\n xy: vi.fn((xPct: number, yPct: number) => ({ x: xPct, y: yPct })),\n };\n const axesFake = { devA: axis };\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n axis.xy.mockClear();\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n it(\"accepts boundary values 0 and 100\", async () => {\n await controller.tapAndRelease(\"devA\", { x: 0, y: 100 });\n await controller.tap(\"devA\", { x: 100, y: 0 });\n await controller.release(\"devA\", { x: 50, y: 99 });\n\n // should have sent 3 HTTP calls if all accepted\n expect(postMock).toHaveBeenCalledTimes(3);\n });\n\n it(\"rejects values outside [0, 100], non-finite, negative and non-integer\", async () => {\n const badPoints = [\n { x: 140, y: 50 },\n { x: -1, y: 50 },\n { x: 50, y: 120 },\n { x: 50, y: -0.01 },\n ];\n\n for (const p of badPoints) {\n await expect(\n controller.tapAndRelease(\"devA\", p as any),\n ).rejects.toThrow();\n }\n\n // no HTTP calls should be made for invalid input\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"rejects NaN or non-finite values\", async () => {\n const badPoints = [\n { x: Number.NaN, y: 50 },\n { x: 50, y: Number.NaN },\n { x: Number.POSITIVE_INFINITY, y: 10 },\n { x: 10, y: Number.NEGATIVE_INFINITY },\n ];\n\n for (const p of badPoints) {\n await expect(controller.tap(\"devA\", p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ACvD,MAAMA,EAAW,IAAI,OAAQ,CAAE,EAAG,IAAK,EAAG,CAAE,CAAC,EAC7C,MAAMA,EAAW,QAAQ,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EAGjD,OAAOP,CAAQ,EAAE,sBAAsB,CAAC,CAC1C,CAAC,EAED,GAAG,wEAAyE,SAAY,CACtF,MAAMY,EAAY,CAChB,CAAE,EAAG,IAAK,EAAG,EAAG,EAChB,CAAE,EAAG,GAAI,EAAG,EAAG,EACf,CAAE,EAAG,GAAI,EAAG,GAAI,EAChB,CAAE,EAAG,GAAI,EAAG,IAAM,CACpB,EAEA,UAAWC,KAAKD,EACd,MAAM,OACJL,EAAW,cAAc,OAAQM,CAAQ,CAC3C,EAAE,QAAQ,QAAQ,EAIpB,OAAOb,CAAQ,EAAE,IAAI,iBAAiB,CACxC,CAAC,EAED,GAAG,mCAAoC,SAAY,CACjD,MAAMY,EAAY,CAChB,CAAE,EAAG,OAAO,IAAK,EAAG,EAAG,EACvB,CAAE,EAAG,GAAI,EAAG,OAAO,GAAI,EACvB,CAAE,EAAG,OAAO,kBAAmB,EAAG,EAAG,EACrC,CAAE,EAAG,GAAI,EAAG,OAAO,iBAAkB,CACvC,EAEA,UAAWC,KAAKD,EACd,MAAM,OAAOL,EAAW,IAAI,OAAQM,CAAQ,CAAC,EAAE,QAAQ,QACrD,UACF,EAEF,OAAOb,CAAQ,EAAE,IAAI,iBAAiB,CACxC,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_DefaultTouchController", "postMock", "httpClient", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("vitest"),a=require("./adapters/DefaultButtonController"),c=require("./adapters/DefaultTouchController"),s=require("./di");const n={flex:{width:128,height:64},stax:{width:400,height:672}};(0,e.afterEach)(()=>{e.vi.restoreAllMocks()});(0,e.describe)("createDefaultControllers - fetch configuration",()=>{(0,e.it)("configures with custom timeout and header",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,s.createDefaultControllers)("https://example.com/api",{screens:n,timeoutMs:2345,clientHeader:"test-client"});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledTimes(1),(0,e.expect)(t).toHaveBeenCalledWith("https://example.com/api/button/left",e.expect.objectContaining({method:"POST",headers:e.expect.objectContaining({"X-Ledger-Client-Version":"test-client"})}))}),(0,e.it)("applies default timeout and client header when not provided",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,s.createDefaultControllers)("https://localhost:1234",{screens:n});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledWith("https://localhost:1234/button/left",e.expect.objectContaining({method:"POST",headers:e.expect.objectContaining({"X-Ledger-Client-Version":"ldmk-transport-speculos"})}))}),(0,e.it)("sends the bearer token alongside the client header",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{touch:o}=(0,s.createDefaultControllers)("https://localhost:1234",{screens:n,clientHeader:"test-client",bearerToken:"session-token"});await o.tap("stax",{x:50,y:50}),(0,e.expect)(t).toHaveBeenCalledWith("https://localhost:1234/finger",e.expect.objectContaining({headers:e.expect.objectContaining({Authorization:"Bearer session-token","X-Ledger-Client-Version":"test-client"})}))})});(0,e.describe)("createDefaultControllers - wiring",()=>{(0,e.it)("returns correct controller implementations",()=>{const{buttons:t,touch:o}=(0,s.createDefaultControllers)("https://x",{screens:n});(0,e.expect)(t).toBeInstanceOf(a.DefaultButtonController),(0,e.expect)(o).toBeInstanceOf(c.DefaultTouchController),(0,e.expect)(typeof t.press).toBe("function")}),(0,e.it)("creates fresh instances per invocation",()=>{const t=(0,s.createDefaultControllers)("https://x",{screens:n}),o=(0,s.createDefaultControllers)("https://x",{screens:n});(0,e.expect)(t.buttons).not.toBe(o.buttons),(0,e.expect)(t.touch).not.toBe(o.touch)}),(0,e.it)("button.press posts the correct payload",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=(0,s.createDefaultControllers)("https://x",{screens:n});await o.press("left"),(0,e.expect)(t).toHaveBeenCalledWith("https://x/button/left",e.expect.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release"})}))}),(0,e.it)("touch.tapAndRelease maps percent to absolute coords",async()=>{const t=e.vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{touch:o}=(0,s.createDefaultControllers)("https://x",{screens:n});await o.tapAndRelease("flex",{x:50,y:50}),(0,e.expect)(t).toHaveBeenCalledWith("https://x/finger",e.expect.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release",x:64,y:32})}))})});
|
|
2
|
-
//# sourceMappingURL=di.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/internal/di.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\n\nimport { createDefaultControllers } from \"./di\";\n\nconst SCREENS = {\n flex: { width: 128, height: 64 },\n stax: { width: 400, height: 672 },\n} as const;\n\nafterEach(() => {\n vi.restoreAllMocks();\n});\n\ndescribe(\"createDefaultControllers - fetch configuration\", () => {\n it(\"configures with custom timeout and header\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://example.com/api\", {\n screens: SCREENS,\n timeoutMs: 2345,\n clientHeader: \"test-client\",\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledTimes(1);\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://example.com/api/button/left\",\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"test-client\",\n }),\n }),\n );\n });\n\n it(\"applies default timeout and client header when not provided\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://localhost:1234\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://localhost:1234/button/left\",\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"ldmk-transport-speculos\",\n }),\n }),\n );\n });\n\n it(\"sends the bearer token alongside the client header\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { touch } = createDefaultControllers(\"https://localhost:1234\", {\n screens: SCREENS,\n clientHeader: \"test-client\",\n bearerToken: \"session-token\",\n });\n\n await touch.tap(\"stax\", { x: 50, y: 50 });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://localhost:1234/finger\",\n expect.objectContaining({\n headers: expect.objectContaining({\n Authorization: \"Bearer session-token\",\n \"X-Ledger-Client-Version\": \"test-client\",\n }),\n }),\n );\n });\n});\n\ndescribe(\"createDefaultControllers - wiring\", () => {\n it(\"returns correct controller implementations\", () => {\n const { buttons, touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n expect(buttons).toBeInstanceOf(DefaultButtonController);\n expect(touch).toBeInstanceOf(DefaultTouchController);\n expect(typeof buttons.press).toBe(\"function\");\n });\n\n it(\"creates fresh instances per invocation\", () => {\n const a = createDefaultControllers(\"https://x\", { screens: SCREENS });\n const b = createDefaultControllers(\"https://x\", { screens: SCREENS });\n\n expect(a.buttons).not.toBe(b.buttons);\n expect(a.touch).not.toBe(b.touch);\n });\n\n it(\"button.press posts the correct payload\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://x/button/left\",\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({ action: \"press-and-release\" }),\n }),\n );\n });\n\n it(\"touch.tapAndRelease maps percent to absolute coords\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n // 50% of 128x64 \u2192 (64, 32)\n await touch.tapAndRelease(\"flex\", { x: 50 as any, y: 50 as any });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://x/finger\",\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({\n action: \"press-and-release\",\n x: 64,\n y: 32,\n }),\n }),\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aACA,IAAAA,EAAoD,kBAEpDC,EAAwC,sDACxCC,EAAuC,qDAEvCC,EAAyC,gBAEzC,MAAMC,EAAU,CACd,KAAM,CAAE,MAAO,IAAK,OAAQ,EAAG,EAC/B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,KAEA,aAAU,IAAM,CACd,KAAG,gBAAgB,CACrB,CAAC,KAED,YAAS,iDAAkD,IAAM,IAC/D,MAAG,4CAA6C,SAAY,CAC1D,MAAMC,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,QAAAC,CAAQ,KAAI,4BAAyB,0BAA2B,CACtE,QAASF,EACT,UAAW,KACX,aAAc,aAChB,CAAC,EAED,MAAME,EAAQ,MAAM,MAAM,KAE1B,UAAOD,CAAQ,EAAE,sBAAsB,CAAC,KACxC,UAAOA,CAAQ,EAAE,qBACf,sCACA,SAAO,iBAAiB,CACtB,OAAQ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C,EAC9DK,KAAI,4BAAyB,YAAa,CAAE,QAASL,CAAQ,CAAC,KAEpE,UAAOI,EAAE,OAAO,EAAE,IAAI,KAAKC,EAAE,OAAO,KACpC,UAAOD,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,KAAK,CAClC,CAAC,KAED,MAAG,yCAA0C,SAAY,CACvD,MAAMJ,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,QAAAC,CAAQ,KAAI,4BAAyB,YAAa,CACxD,QAASF,CACX,CAAC,EAED,MAAME,EAAQ,MAAM,MAAM,KAE1B,UAAOD,CAAQ,EAAE,qBACf,wBACA,SAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CAAE,OAAQ,mBAAoB,CAAC,CACtD,CAAC,CACH,CACF,CAAC,KAED,MAAG,sDAAuD,SAAY,CACpE,MAAMA,EAAW,KACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,MAAAE,CAAM,KAAI,4BAAyB,YAAa,CACtD,QAASH,CACX,CAAC,EAGD,MAAMG,EAAM,cAAc,OAAQ,CAAE,EAAG,GAAW,EAAG,EAAU,CAAC,KAEhE,UAAOF,CAAQ,EAAE,qBACf,mBACA,SAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CACnB,OAAQ,oBACR,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_vitest", "import_DefaultButtonController", "import_DefaultTouchController", "import_di", "SCREENS", "fetchSpy", "buttons", "touch", "a", "b"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var s=require("./buttonUseCases");const i=()=>Promise.resolve();describe("buttonUsecases",()=>{let e;beforeEach(()=>{e={press:vi.fn(()=>Promise.resolve())}}),afterEach(()=>{vi.useRealTimers(),vi.restoreAllMocks()}),describe("pressButtons",()=>{it("returns functions that call controller.press with the correct keys",async()=>{const t=(0,s.pressButtons)(e);await t.left(),await t.right(),await t.both(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right"),expect(e.press).toHaveBeenNthCalledWith(3,"both")})}),describe("pressSequence",()=>{it("presses keys in order and waits the default 200ms after each key (including last)",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),a=(0,s.pressSequence)(e,["left","right","both"]);expect(e.press).toHaveBeenCalledTimes(1),expect(e.press).toHaveBeenNthCalledWith(1,"left"),await i(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),200),await vi.advanceTimersByTimeAsync(200),await i(),expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(2,"right"),await vi.advanceTimersByTimeAsync(200),await i(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(3,"both"),await vi.advanceTimersByTimeAsync(200),await expect(a).resolves.toBeUndefined()}),it("uses the provided custom delay",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),a=(0,s.pressSequence)(e,["left","right"],75);await i(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await i(),expect(t).toHaveBeenCalledTimes(2),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await expect(a).resolves.toBeUndefined()}),it("rejects if a press fails and stops processing subsequent keys",async()=>{vi.useFakeTimers();const t=new Error("oups");e.press.mockResolvedValueOnce(void 0).mockRejectedValueOnce(t);const a=(0,s.pressSequence)(e,["left","right","both"],50),n=expect(a).rejects.toThrow("oups");await Promise.resolve(),await vi.advanceTimersByTimeAsync(50),await Promise.resolve(),await n,expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right")})})});
|
|
2
|
-
//# sourceMappingURL=buttonUseCases.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/use-cases/buttonUseCases.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { pressButtons, pressSequence } from \"./buttonUseCases\";\n\ntype ButtonKey = \"left\" | \"right\" | \"both\";\ntype ButtonController = { press: (k: ButtonKey) => Promise<void> };\n\nconst tick = () => Promise.resolve();\n\ndescribe(\"buttonUsecases\", () => {\n let controller: ButtonController & { press: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n controller = {\n press: vi.fn(() => Promise.resolve()),\n };\n });\n\n afterEach(() => {\n vi.useRealTimers();\n vi.restoreAllMocks();\n });\n\n describe(\"pressButtons\", () => {\n it(\"returns functions that call controller.press with the correct keys\", async () => {\n const api = pressButtons(controller);\n\n await api.left();\n await api.right();\n await api.both();\n\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n });\n });\n\n describe(\"pressSequence\", () => {\n it(\"presses keys in order and waits the default 200ms after each key (including last)\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const promise = pressSequence(controller, keys); // delay = 200\n\n // first press happens immediately (sync call of controller.press)\n expect(controller.press).toHaveBeenCalledTimes(1);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n\n // timeout is scheduled after the awaited press resolves\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 200);\n\n // first delay elapse -> second press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n\n // next delay -> third press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n\n // final post-press delay\n await vi.advanceTimersByTimeAsync(200);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"uses the provided custom delay\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\"];\n\n const promise = pressSequence(controller, keys, 75);\n\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(2);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"rejects if a press fails and stops processing subsequent keys\", async () => {\n vi.useFakeTimers();\n\n const err = new Error(\"oups\");\n controller.press\n .mockResolvedValueOnce(undefined) // first ok\n .mockRejectedValueOnce(err); // second fails\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const p = pressSequence(controller, keys, 50);\n\n const assertion = expect(p).rejects.toThrow(\"oups\");\n\n await Promise.resolve(); // let first setTimeout schedule\n await vi.advanceTimersByTimeAsync(50);\n await Promise.resolve();\n\n await assertion;\n\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA4C,4BAK5C,MAAMC,EAAO,IAAM,QAAQ,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|
6
|
-
"names": ["import_buttonUseCases", "tick", "controller", "api", "timeoutSpy", "promise", "err", "p", "assertion"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("./touchUseCases");describe("touchUsecases",()=>{const s="devA",i={x:50,y:30};let e;beforeEach(()=>{e={tap:vi.fn().mockResolvedValue(void 0),release:vi.fn().mockResolvedValue(void 0),tapAndRelease:vi.fn().mockResolvedValue(void 0)},vi.restoreAllMocks(),vi.useRealTimers()}),it("tapQuick calls tapAndRelease with the same deviceKey and point",async()=>{await(0,t.tapQuick)(e,s)(i),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(s,i),expect(e.tap).not.toHaveBeenCalled(),expect(e.release).not.toHaveBeenCalled()}),it("tapLong taps, waits default timeout, then releases",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),o=(0,t.tapLong)(e,s)(i);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(s,i),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenLastCalledWith(expect.any(Function),5e3),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(5e3),await o,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(s,i)}),it("tapLong uses the provided delayMs value",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),n=1234,l=(0,t.tapLong)(e,s)(i,n);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(s,i),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenLastCalledWith(expect.any(Function),n),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(n),await l,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(s,i)}),it("tapLong propagates error if tap() rejects (no release)",async()=>{vi.useFakeTimers();const a=new Error("tap failed");e.tap.mockRejectedValueOnce(a);const o=(0,t.tapLong)(e,s)(i);await expect(o).rejects.toThrow("tap failed"),expect(e.release).not.toHaveBeenCalled()}),it("tapLong propagates error if release() rejects",async()=>{vi.useFakeTimers();const a=new Error("release failed");e.release.mockRejectedValueOnce(a);const n=(0,t.tapLong)(e,s)(i),o=expect(n).rejects.toThrow("release failed");await Promise.resolve(),await vi.advanceTimersByTimeAsync(5e3),await o,expect(e.tap).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledTimes(1)}),describe("enableBlindSigningSettings",()=>{it.each([["stax",{x:88,y:51}],["flex",{x:88,y:58}],["apex",{x:88,y:58}]])("taps the blind-signing toggle at the %s coordinates",async(a,n)=>{await(0,t.enableBlindSigningSettings)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,n)}),it("falls back to default coordinates for an unknown device key",async()=>{const a="unknown";await(0,t.enableBlindSigningSettings)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,{x:88,y:51})})}),describe("fixed-coordinate taps",()=>{it.each([["reject",t.reject,{x:20,y:90}],["navigateNext",t.navigateNext,{x:90,y:90}],["navigatePrevious",t.navigatePrevious,{x:45,y:90}],["mainButton",t.mainButton,{x:50,y:80}],["secondaryButton",t.secondaryButton,{x:50,y:90}],["enterMenu",t.enterMenu,{x:85,y:8}],["exitMenu",t.exitMenu,{x:10,y:4}],["continueToBlindSigning",t.continueToBlindSigning,{x:50,y:94}],["acceptBlindSigning",t.acceptBlindSigning,{x:50,y:94}]])("%s taps %o",async(a,n,o)=>{await n(e,s)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(s,o)})}),describe("sign",()=>{const a={x:85,y:80};it("holds the sign button for the default 5s",async()=>{vi.useFakeTimers();const n=vi.spyOn(globalThis,"setTimeout"),o=(0,t.sign)(e,s)();await Promise.resolve(),expect(e.tap).toHaveBeenCalledWith(s,a),expect(n).toHaveBeenLastCalledWith(expect.any(Function),5e3),await vi.advanceTimersByTimeAsync(5e3),await o,expect(e.release).toHaveBeenCalledWith(s,a)}),it("holds the sign button for the provided delay",async()=>{vi.useFakeTimers();const n=vi.spyOn(globalThis,"setTimeout"),o=250,l=(0,t.sign)(e,s)(o);await Promise.resolve(),expect(n).toHaveBeenLastCalledWith(expect.any(Function),o),await vi.advanceTimersByTimeAsync(o),await l,expect(e.release).toHaveBeenCalledTimes(1)})}),describe("confirmAddressBookReview",()=>{it.each([["stax",{x:50,y:77}],["flex",{x:50,y:72}]])("taps the Confirm button at the %s coordinates",async(a,n)=>{await(0,t.confirmAddressBookReview)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,n)}),it("falls back to Flex coordinates for an unmeasured device key",async()=>{const a="apex";await(0,t.confirmAddressBookReview)(e,a)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(a,{x:50,y:72})})})});
|
|
2
|
-
//# sourceMappingURL=touchUseCases.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/use-cases/touchUseCases.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nimport {\n acceptBlindSigning,\n confirmAddressBookReview,\n continueToBlindSigning,\n enableBlindSigningSettings,\n enterMenu,\n exitMenu,\n mainButton,\n navigateNext,\n navigatePrevious,\n reject,\n secondaryButton,\n sign,\n tapLong,\n tapQuick,\n} from \"./touchUseCases\";\n\ndescribe(\"touchUsecases\", () => {\n const deviceKey = \"devA\";\n const point = { x: 50, y: 30 } as any;\n\n let controller: TouchController;\n\n beforeEach(() => {\n controller = {\n tap: vi.fn().mockResolvedValue(undefined),\n release: vi.fn().mockResolvedValue(undefined),\n tapAndRelease: vi.fn().mockResolvedValue(undefined),\n } as unknown as TouchController;\n vi.restoreAllMocks();\n vi.useRealTimers();\n });\n\n it(\"tapQuick calls tapAndRelease with the same deviceKey and point\", async () => {\n const quick = tapQuick(controller, deviceKey);\n await quick(point);\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(deviceKey, point);\n expect(controller.tap).not.toHaveBeenCalled();\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong taps, waits default timeout, then releases\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n expect(controller.release).not.toHaveBeenCalled();\n\n // let the 5s timer elapse\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong uses the provided delayMs value\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 1234;\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point, customMs);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), customMs);\n expect(controller.release).not.toHaveBeenCalled();\n\n // advance exactly customMs and ensure release happens then\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong propagates error if tap() rejects (no release)\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"tap failed\");\n (controller.tap as any).mockRejectedValueOnce(boom);\n\n const longTap = tapLong(controller, deviceKey);\n const p = longTap(point);\n\n // attach rejection handler immediately\n await expect(p).rejects.toThrow(\"tap failed\");\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong propagates error if release() rejects\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"release failed\");\n (controller.release as any).mockRejectedValueOnce(boom);\n\n const p = tapLong(controller, deviceKey)(point);\n\n const assertion = expect(p).rejects.toThrow(\"release failed\");\n\n await Promise.resolve();\n await vi.advanceTimersByTimeAsync(5000);\n\n await assertion;\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n\n describe(\"enableBlindSigningSettings\", () => {\n it.each([\n [\"stax\", { x: 88, y: 51 }],\n [\"flex\", { x: 88, y: 58 }],\n [\"apex\", { x: 88, y: 58 }],\n ] as const)(\n \"taps the blind-signing toggle at the %s coordinates\",\n async (key, expected) => {\n await enableBlindSigningSettings(controller, key)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(key, expected);\n },\n );\n\n it(\"falls back to default coordinates for an unknown device key\", async () => {\n const unknownKey = \"unknown\";\n await enableBlindSigningSettings(controller, unknownKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(unknownKey, {\n x: 88,\n y: 51,\n });\n });\n });\n\n describe(\"fixed-coordinate taps\", () => {\n it.each([\n [\"reject\", reject, { x: 20, y: 90 }],\n [\"navigateNext\", navigateNext, { x: 90, y: 90 }],\n [\"navigatePrevious\", navigatePrevious, { x: 45, y: 90 }],\n [\"mainButton\", mainButton, { x: 50, y: 80 }],\n [\"secondaryButton\", secondaryButton, { x: 50, y: 90 }],\n [\"enterMenu\", enterMenu, { x: 85, y: 8 }],\n [\"exitMenu\", exitMenu, { x: 10, y: 4 }],\n [\"continueToBlindSigning\", continueToBlindSigning, { x: 50, y: 94 }],\n [\"acceptBlindSigning\", acceptBlindSigning, { x: 50, y: 94 }],\n ] as const)(\"%s taps %o\", async (_name, useCase, expected) => {\n await useCase(controller, deviceKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(\n deviceKey,\n expected,\n );\n });\n });\n\n describe(\"sign\", () => {\n const HOLD_TO_SIGN = { x: 85, y: 80 };\n\n it(\"holds the sign button for the default 5s\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const run = sign(controller, deviceKey)();\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, HOLD_TO_SIGN);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledWith(deviceKey, HOLD_TO_SIGN);\n });\n\n it(\"holds the sign button for the provided delay\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 250;\n const run = sign(controller, deviceKey)(customMs);\n await Promise.resolve();\n\n expect(timeoutSpy).toHaveBeenLastCalledWith(\n expect.any(Function),\n customMs,\n );\n\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n });\n\n describe(\"confirmAddressBookReview\", () => {\n // The Address Book review puts its Confirm button above the page footer,\n // so these coordinates are measured per model rather than shared with\n // mainButton/secondaryButton.\n it.each([\n [\"stax\", { x: 50, y: 77 }],\n [\"flex\", { x: 50, y: 72 }],\n ] as const)(\n \"taps the Confirm button at the %s coordinates\",\n async (key, expected) => {\n await confirmAddressBookReview(controller, key)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(key, expected);\n },\n );\n\n it(\"falls back to Flex coordinates for an unmeasured device key\", async () => {\n const unknownKey = \"apex\";\n await confirmAddressBookReview(controller, unknownKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(unknownKey, {\n x: 50,\n y: 72,\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAMA,IAAAA,EAeO,2BAEP,SAAS,gBAAiB,IAAM,CAC9B,MAAMC,EAAY,OACZC,EAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,EAE7B,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAa,CACX,IAAK,GAAG,GAAG,EAAE,kBAAkB,MAAS,EACxC,QAAS,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC5C,cAAe,GAAG,GAAG,EAAE,kBAAkB,MAAS,CACpD,EACA,GAAG,gBAAgB,EACnB,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,iEAAkE,SAAY,CAE/E,QADc,YAASA,EAAYF,CAAS,EAChCC,CAAK,EAEjB,OAAOC,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBF,EAAWC,CAAK,EACtE,OAAOC,EAAW,GAAG,EAAE,IAAI,iBAAiB,EAC5C,OAAOA,EAAW,OAAO,EAAE,IAAI,iBAAiB,CAClD,CAAC,EAED,GAAG,qDAAsD,SAAY,CACnE,GAAG,cAAc,EACjB,MAAMC,EAAa,GAAG,MAAM,WAAY,YAAY,EAG9CC,KADU,WAAQF,EAAYF,CAAS,EACzBC,C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C7D,GAAG,cAAc,EACjB,MAAMX,EAAa,GAAG,MAAM,WAAY,YAAY,EAE9CE,EAAW,IACXD,KAAM,QAAKF,EAAYF,CAAS,EAAEK,CAAQ,EAChD,MAAM,QAAQ,QAAQ,EAEtB,OAAOF,CAAU,EAAE,yBACjB,OAAO,IAAI,QAAQ,EACnBE,CACF,EAEA,MAAM,GAAG,yBAAyBA,CAAQ,EAC1C,MAAMD,EAEN,OAAOF,EAAW,OAAO,EAAE,sBAAsB,CAAC,CACpD,CAAC,CACH,CAAC,EAED,SAAS,2BAA4B,IAAM,CAIzC,GAAG,KAAK,CACN,CAAC,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,EACzB,CAAC,OAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,CAAC,CAC3B,CAAU,EACR,gDACA,MAAOO,EAAKC,IAAa,CACvB,QAAM,4BAAyBR,EAAYO,CAAG,EAAE,EAEhD,OAAOP,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBO,EAAKC,CAAQ,CACrE,CACF,EAEA,GAAG,8DAA+D,SAAY,CAC5E,MAAMC,EAAa,OACnB,QAAM,4BAAyBT,EAAYS,CAAU,EAAE,EAEvD,OAAOT,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAOA,EAAW,aAAa,EAAE,qBAAqBS,EAAY,CAChE,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_touchUseCases", "deviceKey", "point", "controller", "timeoutSpy", "run", "customMs", "boom", "p", "assertion", "key", "expected", "unknownKey", "_name", "useCase", "HOLD_TO_SIGN"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var o=require("./axisClamp");const e=t=>t;describe("axisClamp helpers",()=>{describe("clampValue",()=>{it("floors and clamps to [0, width]",()=>{const t=(0,o.clampValue)(200);expect(t(e(0))).toBe(0),expect(t(e(50))).toBe(100),expect(t(e(50.4))).toBe(100),expect(t(e(50.5))).toBe(101),expect(t(e(100))).toBe(200),expect(t(e(150))).toBe(200),expect(t(e(-10))).toBe(0)})}),describe("createAxis",()=>{it("exposes vw, vh and xy with consistent flooring + clamping",()=>{const t=(0,o.createAxis)(300,200);expect(t.vw(e(25))).toBe(75),expect(t.vh(e(75))).toBe(150),expect(t.xy(e(10),e(90))).toEqual({x:30,y:180}),expect(t.xy(e(150),e(-20))).toEqual({x:300,y:0});const c=t.xy(e(33.4),e(66.6));expect(c.x).toBe(Math.floor(300*.334)),expect(c.y).toBe(Math.floor(200*.666))})}),describe("createAxes",()=>{it("creates an AxisMap for all device keys with matching dimensions",()=>{const c=(0,o.createAxes)({devA:{width:200,height:100},devB:{width:320,height:480}});expect(Object.keys(c).sort()).toEqual(["devA","devB"]),expect(c.devA.vw(e(100))).toBe(200),expect(c.devA.vh(e(100))).toBe(100),expect(c.devA.xy(e(120),e(-10))).toEqual({x:200,y:0}),expect(c.devB.vw(e(50))).toBe(160),expect(c.devB.vh(e(50))).toBe(240),expect(c.devB.xy(e(33.3),e(66.7))).toEqual({x:Math.floor(320*.333),y:Math.floor(480*.667)})})})});
|
|
2
|
-
//# sourceMappingURL=axisClamp.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/utils/axisClamp.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nimport { type AxisMap, clampValue, createAxes, createAxis } from \"./axisClamp\";\n\nconst p = (n: number) => n as unknown as Percent;\n\ndescribe(\"axisClamp helpers\", () => {\n describe(\"clampValue\", () => {\n it(\"floors and clamps to [0, width]\", () => {\n const clamp = clampValue(200);\n\n expect(clamp(p(0))).toBe(0);\n expect(clamp(p(50))).toBe(100); // 200 * 0.5 = 100\n expect(clamp(p(50.4))).toBe(100); // floor(200 * 0.504) = 100\n expect(clamp(p(50.5))).toBe(101); // floor(200 * 0.505) = 101\n expect(clamp(p(100))).toBe(200);\n expect(clamp(p(150))).toBe(200); // clamped\n expect(clamp(p(-10))).toBe(0); // clamped\n });\n });\n\n describe(\"createAxis\", () => {\n it(\"exposes vw, vh and xy with consistent flooring + clamping\", () => {\n const axis = createAxis(300, 200);\n\n // vw / vh\n expect(axis.vw(p(25))).toBe(75); // 300 * 0.25\n expect(axis.vh(p(75))).toBe(150); // 200 * 0.75\n\n // xy nominal\n expect(axis.xy(p(10), p(90))).toEqual({ x: 30, y: 180 });\n\n // xy clamps both axes\n expect(axis.xy(p(150), p(-20))).toEqual({ x: 300, y: 0 });\n\n // flooring behavior with fractional percent\n const xy = axis.xy(p(33.4), p(66.6));\n expect(xy.x).toBe(Math.floor(300 * 0.334));\n expect(xy.y).toBe(Math.floor(200 * 0.666));\n });\n });\n\n describe(\"createAxes\", () => {\n it(\"creates an AxisMap for all device keys with matching dimensions\", () => {\n const screens: DeviceScreens<\"devA\" | \"devB\"> = {\n devA: { width: 200, height: 100 } as any,\n devB: { width: 320, height: 480 } as any,\n };\n\n const axes: AxisMap<\"devA\" | \"devB\"> = createAxes(screens);\n\n // contains both keys\n expect(Object.keys(axes).sort()).toEqual([\"devA\", \"devB\"]);\n\n // devA\n expect(axes.devA.vw(p(100))).toBe(200);\n expect(axes.devA.vh(p(100))).toBe(100);\n expect(axes.devA.xy(p(120), p(-10))).toEqual({ x: 200, y: 0 });\n\n // devB\n expect(axes.devB.vw(p(50))).toBe(160);\n expect(axes.devB.vh(p(50))).toBe(240);\n expect(axes.devB.xy(p(33.3), p(66.7))).toEqual({\n x: Math.floor(320 * 0.333),\n y: Math.floor(480 * 0.667),\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAKA,IAAAA,EAAiE,uBAEjE,MAAMC,EAAKC,GAAcA,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K,MAAM,IAAM,IAAK,CAAC,CAC3C,CAAC,CACH,CAAC,EAED,SAAS,aAAc,IAAM,CAC3B,GAAG,kEAAmE,IAAM,CAM1E,MAAMC,KAAiC,cALS,CAC9C,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,EAChC,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,CAEyD,EAGzD,OAAO,OAAO,KAAKA,CAAI,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAQ,MAAM,CAAC,EAGzD,OAAOA,EAAK,KAAK,GAAGL,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EACrC,OAAOK,EAAK,KAAK,GAAGL,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EACrC,OAAOK,EAAK,KAAK,GAAGL,EAAE,GAAG,EAAGA,EAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAE,EAAG,IAAK,EAAG,CAAE,CAAC,EAG7D,OAAOK,EAAK,KAAK,GAAGL,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOK,EAAK,KAAK,GAAGL,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOK,EAAK,KAAK,GAAGL,EAAE,IAAI,EAAGA,EAAE,IAAI,CAAC,CAAC,EAAE,QAAQ,CAC7C,EAAG,KAAK,MAAM,IAAM,IAAK,EACzB,EAAG,KAAK,MAAM,IAAM,IAAK,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_axisClamp", "p", "n", "clamp", "axis", "xy", "axes"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{deviceControllerClientFactory as o}from"./DeviceController";describe("deviceControllerClientFactory",()=>{it("returns a DeviceControllerdeviceClient with the expected shape",()=>{const e=o("http://localhost:0");expect(e).toBeDefined(),expect(e).toHaveProperty("buttonFactory"),expect(e).toHaveProperty("tapFactory");const t=e.buttonFactory();expect(typeof t.press).toBe("function"),expect(typeof t.left).toBe("function"),expect(typeof t.right).toBe("function"),expect(typeof t.both).toBe("function"),expect(typeof t.pressSequence).toBe("function");const c=e.tapFactory("flex");expect(typeof c.tapQuick).toBe("function"),expect(typeof c.tapLong).toBe("function")}),it("does not throw when created with custom options",()=>{const t=o("http://127.0.0.1:0",{clientHeader:"test-suite",timeoutMs:200,screens:{custom:{width:128,height:64},stax:{width:400,height:672}}});expect(t).toBeTruthy()}),it("creates independent instances (no accidental shared state)",()=>{const e=o("http://localhost:0"),t=o("http://localhost:0");expect(e).not.toBe(t),expect(e.buttonFactory().press).not.toBe(t.buttonFactory().press),expect(e.tapFactory("flex").tapQuick).not.toBe(t.tapFactory("flex").tapQuick)}),it("sends the bearer token with every request",async()=>{const e=vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}"));await o("http://localhost:0",{bearerToken:"session-token"}).buttonFactory().press("both"),expect(e).toHaveBeenCalledWith("http://localhost:0/button/both",expect.objectContaining({headers:expect.objectContaining({Authorization:"Bearer session-token"})})),e.mockRestore()})});
|
|
2
|
-
//# sourceMappingURL=DeviceController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/api/DeviceController.test.ts"],
|
|
4
|
-
"sourcesContent": ["import 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 it(\"sends the bearer token with every request\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n const deviceClient = deviceControllerClientFactory(\"http://localhost:0\", {\n bearerToken: \"session-token\",\n });\n\n await deviceClient.buttonFactory().press(\"both\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"http://localhost:0/button/both\",\n expect.objectContaining({\n headers: expect.objectContaining({\n Authorization: \"Bearer session-token\",\n }),\n }),\n );\n fetchSpy.mockRestore();\n });\n});\n"],
|
|
5
|
-
"mappings": "AAEA,OAAS,iCAAAA,MAAqC,qBAE9C,SAAS,gCAAiC,IAAM,CAC9C,GAAG,iEAAkE,IAAM,CACzE,MAAMC,EAAeD,EAA8B,oBAAoB,EAEvE,OAAOC,CAAY,EAAE,YAAY,EACjC,OAAOA,CAAY,EAAE,eAAe,eAAe,EACnD,OAAOA,CAAY,EAAE,eAAe,YAA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,iCACA,OAAO,iBAAiB,CACtB,QAAS,OAAO,iBAAiB,CAC/B,cAAe,sBACjB,CAAC,CACH,CAAC,CACH,EACAA,EAAS,YAAY,CACvB,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["deviceControllerClientFactory", "deviceClient", "deviceButtons", "deviceTaps", "a", "b", "fetchSpy"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{DefaultButtonController as l}from"./DefaultButtonController";describe("DefaultButtonController",()=>{let e,n,o;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),n={post:e},o=new l(n)});const r=["left","right","both"];it.each(r)("press(%s) posts expected payload",async t=>{await o.press(t),expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith(`/button/${t}`,{action:"press-and-release"})}),it("propagates HTTP errors",async()=>{const t=new Error("oups");e.mockRejectedValueOnce(t),await expect(o.press("left")).rejects.toBe(t)})});
|
|
2
|
-
//# sourceMappingURL=DefaultButtonController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ButtonKey, HttpClient } from \"@internal/core/types\";\n\nimport { DefaultButtonController } from \"./DefaultButtonController\";\n\ndescribe(\"DefaultButtonController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n let controller: DefaultButtonController;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n controller = new DefaultButtonController(httpClient);\n });\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n it.each<ButtonKey>(keys)(\n \"press(%s) posts expected payload\",\n async (key: ButtonKey) => {\n await controller.press(key);\n\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(`/button/${key}`, {\n action: \"press-and-release\",\n });\n },\n );\n\n it(\"propagates HTTP errors\", async () => {\n const error = new Error(\"oups\");\n postMock.mockRejectedValueOnce(error);\n\n await expect(controller.press(\"left\" as ButtonKey)).rejects.toBe(error);\n });\n});\n"],
|
|
5
|
-
"mappings": "AAEA,OAAS,2BAAAA,MAA+B,4BAExC,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACAC,EAEJ,WAAW,IAAM,CACfF,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAC9BE,EAAa,IAAIH,EAAwBE,CAAU,CACrD,CAAC,EAED,MAAME,EAAoB,CAAC,OAAQ,QAAS,MAAM,EAElD,GAAG,KAAgBA,CAAI,EACrB,mCACA,MAAOC,GAAmB,CACxB,MAAMF,EAAW,MAAME,CAAG,EAE1B,OAAOJ,CAAQ,EAAE,sBAAsB,CAAC,EACxC,OAAOA,CAAQ,EAAE,qBAAqB,WAAWI,CAAG,GAAI,CACtD,OAAQ,mBACV,CAAC,CACH,CACF,EAEA,GAAG,yBAA0B,SAAY,CACvC,MAAMC,EAAQ,IAAI,MAAM,MAAM,EAC9BL,EAAS,sBAAsBK,CAAK,EAEpC,MAAM,OAAOH,EAAW,MAAM,MAAmB,CAAC,EAAE,QAAQ,KAAKG,CAAK,CACxE,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["DefaultButtonController", "postMock", "httpClient", "controller", "keys", "key", "error"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{DefaultTouchController as l}from"./DefaultTouchController";describe("DefaultTouchController",()=>{let e,s;const o={xy:vi.fn((a,i)=>({x:Math.round(a*10),y:Math.round(i*20)}))},r={xy:vi.fn((a,i)=>({x:Math.round(100+a),y:Math.round(200+i)}))};let c,n;beforeEach(()=>{e=vi.fn().mockResolvedValue(void 0),s={post:e},o.xy.mockClear(),r.xy.mockClear(),c={devA:o,devB:r},n=new l(s,c)});const t={x:12,y:45};it("tapAndRelease: converts percent to absolute via axes and POSTs expected body",async()=>{await n.tapAndRelease("devA",t),expect(o.xy).toHaveBeenCalledTimes(1),expect(o.xy).toHaveBeenCalledWith(t.x,t.y);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledTimes(1),expect(e).toHaveBeenCalledWith("/finger",{action:"press-and-release",...a})}),it("tap: converts via axes and POSTs action 'press'",async()=>{await n.tap("devB",t),expect(r.xy).toHaveBeenCalledWith(t.x,t.y);const a=r.xy.mock.results[0]?.value;expect(e).toHaveBeenCalledWith("/finger",{action:"press",...a})}),it("release: converts via axes and POSTs action 'release'",async()=>{await n.release("devA",t);const a=o.xy.mock.results[0].value;expect(e).toHaveBeenCalledWith("/finger",{action:"release",...a})}),it("throws an error when device key is unknown",async()=>{await expect(n.tap("unknownDevice",t)).rejects.toThrow(/\[Touch] Unknown device key "unknownDevice".*Known keys: devA, devB/),expect(e).not.toHaveBeenCalled()}),it("propagates HTTP errors",async()=>{const a=new Error("backend down");e.mockRejectedValueOnce(a),await expect(n.tapAndRelease("devA",t)).rejects.toBe(a)})});describe("percent validation",()=>{let e,s,o;const r={xy:vi.fn((n,t)=>({x:n,y:t}))},c={devA:r};beforeEach(()=>{s=vi.fn().mockResolvedValue(void 0),o={post:s},r.xy.mockClear(),e=new l(o,c)}),it("accepts boundary values 0 and 100",async()=>{await e.tapAndRelease("devA",{x:0,y:100}),await e.tap("devA",{x:100,y:0}),await e.release("devA",{x:50,y:99}),expect(s).toHaveBeenCalledTimes(3)}),it("rejects values outside [0, 100], non-finite, negative and non-integer",async()=>{const n=[{x:140,y:50},{x:-1,y:50},{x:50,y:120},{x:50,y:-.01}];for(const t of n)await expect(e.tapAndRelease("devA",t)).rejects.toThrow();expect(s).not.toHaveBeenCalled()}),it("rejects NaN or non-finite values",async()=>{const n=[{x:Number.NaN,y:50},{x:50,y:Number.NaN},{x:Number.POSITIVE_INFINITY,y:10},{x:10,y:Number.NEGATIVE_INFINITY}];for(const t of n)await expect(e.tap("devA",t)).rejects.toThrow(/percent/i);expect(s).not.toHaveBeenCalled()})});
|
|
2
|
-
//# sourceMappingURL=DefaultTouchController.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/adapters/DefaultTouchController.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport type { HttpClient, PercentCoordinates } from \"../core/types\";\nimport { DefaultTouchController } from \"./DefaultTouchController\";\n\ndescribe(\"DefaultTouchController\", () => {\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axisA = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(xPct * 10),\n y: Math.round(yPct * 20),\n })),\n };\n const axisB = {\n xy: vi.fn((xPct: number, yPct: number) => ({\n x: Math.round(100 + xPct),\n y: Math.round(200 + yPct),\n })),\n };\n let axesFake: Record<\n string,\n { xy: (x: number, y: number) => { x: number; y: number } }\n >;\n\n let controller: DefaultTouchController<string>;\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n\n axisA.xy.mockClear();\n axisB.xy.mockClear();\n\n axesFake = { devA: axisA, devB: axisB };\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n const point: PercentCoordinates = { x: 12, y: 45 };\n\n it(\"tapAndRelease: converts percent to absolute via axes and POSTs expected body\", async () => {\n await controller.tapAndRelease(\"devA\", point);\n\n expect(axisA.xy).toHaveBeenCalledTimes(1);\n expect(axisA.xy).toHaveBeenCalledWith(point.x, point.y);\n\n const expectedAbs = (axisA.xy.mock.results as any)[0].value;\n expect(postMock).toHaveBeenCalledTimes(1);\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press-and-release\",\n ...expectedAbs,\n });\n });\n\n it(\"tap: converts via axes and POSTs action 'press'\", async () => {\n await controller.tap(\"devB\", point);\n\n expect(axisB.xy).toHaveBeenCalledWith(point.x, point.y);\n const expectedAbs = axisB.xy.mock.results[0]?.value;\n\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"press\",\n ...expectedAbs,\n });\n });\n\n it(\"release: converts via axes and POSTs action 'release'\", async () => {\n await controller.release(\"devA\", point);\n\n const expectedAbs = axisA.xy.mock.results[0]!.value;\n expect(postMock).toHaveBeenCalledWith(\"/finger\", {\n action: \"release\",\n ...expectedAbs,\n });\n });\n\n it(\"throws an error when device key is unknown\", async () => {\n await expect(controller.tap(\"unknownDevice\" as any, point)).rejects.toThrow(\n /\\[Touch] Unknown device key \"unknownDevice\".*Known keys: devA, devB/,\n );\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"propagates HTTP errors\", async () => {\n const boom = new Error(\"backend down\");\n postMock.mockRejectedValueOnce(boom);\n\n await expect(controller.tapAndRelease(\"devA\", point)).rejects.toBe(boom);\n });\n});\n\ndescribe(\"percent validation\", () => {\n let controller: DefaultTouchController<string>;\n let postMock: ReturnType<typeof vi.fn>;\n let httpClient: HttpClient;\n\n const axis = {\n xy: vi.fn((xPct: number, yPct: number) => ({ x: xPct, y: yPct })),\n };\n const axesFake = { devA: axis };\n\n beforeEach(() => {\n postMock = vi.fn().mockResolvedValue(undefined);\n httpClient = { post: postMock };\n axis.xy.mockClear();\n controller = new DefaultTouchController(httpClient, axesFake as any);\n });\n\n it(\"accepts boundary values 0 and 100\", async () => {\n await controller.tapAndRelease(\"devA\", { x: 0, y: 100 });\n await controller.tap(\"devA\", { x: 100, y: 0 });\n await controller.release(\"devA\", { x: 50, y: 99 });\n\n // should have sent 3 HTTP calls if all accepted\n expect(postMock).toHaveBeenCalledTimes(3);\n });\n\n it(\"rejects values outside [0, 100], non-finite, negative and non-integer\", async () => {\n const badPoints = [\n { x: 140, y: 50 },\n { x: -1, y: 50 },\n { x: 50, y: 120 },\n { x: 50, y: -0.01 },\n ];\n\n for (const p of badPoints) {\n await expect(\n controller.tapAndRelease(\"devA\", p as any),\n ).rejects.toThrow();\n }\n\n // no HTTP calls should be made for invalid input\n expect(postMock).not.toHaveBeenCalled();\n });\n\n it(\"rejects NaN or non-finite values\", async () => {\n const badPoints = [\n { x: Number.NaN, y: 50 },\n { x: 50, y: Number.NaN },\n { x: Number.POSITIVE_INFINITY, y: 10 },\n { x: 10, y: Number.NEGATIVE_INFINITY },\n ];\n\n for (const p of badPoints) {\n await expect(controller.tap(\"devA\", p as any)).rejects.toThrow(\n /percent/i,\n );\n }\n expect(postMock).not.toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
-
"mappings": "AAKA,OAAS,0BAAAA,MAA8B,2BAEvC,SAAS,yBAA0B,IAAM,CACvC,IAAIC,EACAC,EAEJ,MAAMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACC,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAMD,EAAO,EAAE,EACvB,EAAG,KAAK,MAAMC,EAAO,EAAE,CACzB,EAAE,CACJ,EACMC,EAAQ,CACZ,GAAI,GAAG,GAAG,CAACF,EAAcC,KAAkB,CACzC,EAAG,KAAK,MAAM,IAAMD,CAAI,EACxB,EAAG,KAAK,MAAM,IAAMC,CAAI,CAC1B,EAAE,CACJ,EACA,IAAIE,EAKAC,EAEJ,WAAW,IAAM,CACfP,EAAW,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC9CC,EAAa,CAAE,KAAMD,CAAS,EAE9BE,EAAM,GAAG,UAAU,EACnBG,EAAM,GAAG,UAAU,EAEnBC,EAAW,CAAE,KAAMJ,EAAO,KAAMG,CAAM,EACtCE,EAAa,IAAIR,EAAuBE,EAAYK,CAAe,CACrE,CAAC,EAED,MAAME,EAA4B,CAAE,EAAG,GAAI,EAAG,EAAG,EAEjD,GAAG,+EAAgF,SAAY,CAC7F,MAAMD,EAAW,cAAc,OAAQC,CAAK,EAE5C,OAAON,EAAM,EAAE,EAAE,sBAAsB,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C,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["DefaultTouchController", "postMock", "httpClient", "axisA", "xPct", "yPct", "axisB", "axesFake", "controller", "point", "expectedAbs", "boom", "axis", "badPoints", "p"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{afterEach as i,describe as l,expect as e,it as a,vi as c}from"vitest";import{DefaultButtonController as r}from"./adapters/DefaultButtonController";import{DefaultTouchController as h}from"./adapters/DefaultTouchController";import{createDefaultControllers as s}from"./di";const n={flex:{width:128,height:64},stax:{width:400,height:672}};i(()=>{c.restoreAllMocks()});l("createDefaultControllers - fetch configuration",()=>{a("configures with custom timeout and header",async()=>{const t=c.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=s("https://example.com/api",{screens:n,timeoutMs:2345,clientHeader:"test-client"});await o.press("left"),e(t).toHaveBeenCalledTimes(1),e(t).toHaveBeenCalledWith("https://example.com/api/button/left",e.objectContaining({method:"POST",headers:e.objectContaining({"X-Ledger-Client-Version":"test-client"})}))}),a("applies default timeout and client header when not provided",async()=>{const t=c.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=s("https://localhost:1234",{screens:n});await o.press("left"),e(t).toHaveBeenCalledWith("https://localhost:1234/button/left",e.objectContaining({method:"POST",headers:e.objectContaining({"X-Ledger-Client-Version":"ldmk-transport-speculos"})}))}),a("sends the bearer token alongside the client header",async()=>{const t=c.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{touch:o}=s("https://localhost:1234",{screens:n,clientHeader:"test-client",bearerToken:"session-token"});await o.tap("stax",{x:50,y:50}),e(t).toHaveBeenCalledWith("https://localhost:1234/finger",e.objectContaining({headers:e.objectContaining({Authorization:"Bearer session-token","X-Ledger-Client-Version":"test-client"})}))})});l("createDefaultControllers - wiring",()=>{a("returns correct controller implementations",()=>{const{buttons:t,touch:o}=s("https://x",{screens:n});e(t).toBeInstanceOf(r),e(o).toBeInstanceOf(h),e(typeof t.press).toBe("function")}),a("creates fresh instances per invocation",()=>{const t=s("https://x",{screens:n}),o=s("https://x",{screens:n});e(t.buttons).not.toBe(o.buttons),e(t.touch).not.toBe(o.touch)}),a("button.press posts the correct payload",async()=>{const t=c.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{buttons:o}=s("https://x",{screens:n});await o.press("left"),e(t).toHaveBeenCalledWith("https://x/button/left",e.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release"})}))}),a("touch.tapAndRelease maps percent to absolute coords",async()=>{const t=c.spyOn(globalThis,"fetch").mockResolvedValue(new Response("{}")),{touch:o}=s("https://x",{screens:n});await o.tapAndRelease("flex",{x:50,y:50}),e(t).toHaveBeenCalledWith("https://x/finger",e.objectContaining({method:"POST",body:JSON.stringify({action:"press-and-release",x:64,y:32})}))})});
|
|
2
|
-
//# sourceMappingURL=di.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/internal/di.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\n\nimport { DefaultButtonController } from \"@internal/adapters/DefaultButtonController\";\nimport { DefaultTouchController } from \"@internal/adapters/DefaultTouchController\";\n\nimport { createDefaultControllers } from \"./di\";\n\nconst SCREENS = {\n flex: { width: 128, height: 64 },\n stax: { width: 400, height: 672 },\n} as const;\n\nafterEach(() => {\n vi.restoreAllMocks();\n});\n\ndescribe(\"createDefaultControllers - fetch configuration\", () => {\n it(\"configures with custom timeout and header\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://example.com/api\", {\n screens: SCREENS,\n timeoutMs: 2345,\n clientHeader: \"test-client\",\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledTimes(1);\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://example.com/api/button/left\",\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"test-client\",\n }),\n }),\n );\n });\n\n it(\"applies default timeout and client header when not provided\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://localhost:1234\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://localhost:1234/button/left\",\n expect.objectContaining({\n method: \"POST\",\n headers: expect.objectContaining({\n \"X-Ledger-Client-Version\": \"ldmk-transport-speculos\",\n }),\n }),\n );\n });\n\n it(\"sends the bearer token alongside the client header\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { touch } = createDefaultControllers(\"https://localhost:1234\", {\n screens: SCREENS,\n clientHeader: \"test-client\",\n bearerToken: \"session-token\",\n });\n\n await touch.tap(\"stax\", { x: 50, y: 50 });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://localhost:1234/finger\",\n expect.objectContaining({\n headers: expect.objectContaining({\n Authorization: \"Bearer session-token\",\n \"X-Ledger-Client-Version\": \"test-client\",\n }),\n }),\n );\n });\n});\n\ndescribe(\"createDefaultControllers - wiring\", () => {\n it(\"returns correct controller implementations\", () => {\n const { buttons, touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n expect(buttons).toBeInstanceOf(DefaultButtonController);\n expect(touch).toBeInstanceOf(DefaultTouchController);\n expect(typeof buttons.press).toBe(\"function\");\n });\n\n it(\"creates fresh instances per invocation\", () => {\n const a = createDefaultControllers(\"https://x\", { screens: SCREENS });\n const b = createDefaultControllers(\"https://x\", { screens: SCREENS });\n\n expect(a.buttons).not.toBe(b.buttons);\n expect(a.touch).not.toBe(b.touch);\n });\n\n it(\"button.press posts the correct payload\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { buttons } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n await buttons.press(\"left\");\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://x/button/left\",\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({ action: \"press-and-release\" }),\n }),\n );\n });\n\n it(\"touch.tapAndRelease maps percent to absolute coords\", async () => {\n const fetchSpy = vi\n .spyOn(globalThis, \"fetch\")\n .mockResolvedValue(new Response(\"{}\"));\n\n const { touch } = createDefaultControllers(\"https://x\", {\n screens: SCREENS,\n });\n\n // 50% of 128x64 \u2192 (64, 32)\n await touch.tapAndRelease(\"flex\", { x: 50 as any, y: 50 as any });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n \"https://x/finger\",\n expect.objectContaining({\n method: \"POST\",\n body: JSON.stringify({\n action: \"press-and-release\",\n x: 64,\n y: 32,\n }),\n }),\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "AACA,OAAS,aAAAA,EAAW,YAAAC,EAAU,UAAAC,EAAQ,MAAAC,EAAI,MAAAC,MAAU,SAEpD,OAAS,2BAAAC,MAA+B,6CACxC,OAAS,0BAAAC,MAA8B,4CAEvC,OAAS,4BAAAC,MAAgC,OAEzC,MAAMC,EAAU,CACd,KAAM,CAAE,MAAO,IAAK,OAAQ,EAAG,EAC/B,KAAM,CAAE,MAAO,IAAK,OAAQ,GAAI,CAClC,EAEAR,EAAU,IAAM,CACdI,EAAG,gBAAgB,CACrB,CAAC,EAEDH,EAAS,iDAAkD,IAAM,CAC/DE,EAAG,4CAA6C,SAAY,CAC1D,MAAMM,EAAWL,EACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,QAAAM,CAAQ,EAAIH,EAAyB,0BAA2B,CACtE,QAASC,EACT,UAAW,KACX,aAAc,aAChB,CAAC,EAED,MA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L,CAAsB,EACnDJ,EAAO,OAAOQ,EAAQ,KAAK,EAAE,KAAK,UAAU,CAC9C,CAAC,EAEDP,EAAG,yCAA0C,IAAM,CACjD,MAAMS,EAAIL,EAAyB,YAAa,CAAE,QAASC,CAAQ,CAAC,EAC9DK,EAAIN,EAAyB,YAAa,CAAE,QAASC,CAAQ,CAAC,EAEpEN,EAAOU,EAAE,OAAO,EAAE,IAAI,KAAKC,EAAE,OAAO,EACpCX,EAAOU,EAAE,KAAK,EAAE,IAAI,KAAKC,EAAE,KAAK,CAClC,CAAC,EAEDV,EAAG,yCAA0C,SAAY,CACvD,MAAMM,EAAWL,EACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,QAAAM,CAAQ,EAAIH,EAAyB,YAAa,CACxD,QAASC,CACX,CAAC,EAED,MAAME,EAAQ,MAAM,MAAM,EAE1BR,EAAOO,CAAQ,EAAE,qBACf,wBACAP,EAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CAAE,OAAQ,mBAAoB,CAAC,CACtD,CAAC,CACH,CACF,CAAC,EAEDC,EAAG,sDAAuD,SAAY,CACpE,MAAMM,EAAWL,EACd,MAAM,WAAY,OAAO,EACzB,kBAAkB,IAAI,SAAS,IAAI,CAAC,EAEjC,CAAE,MAAAO,CAAM,EAAIJ,EAAyB,YAAa,CACtD,QAASC,CACX,CAAC,EAGD,MAAMG,EAAM,cAAc,OAAQ,CAAE,EAAG,GAAW,EAAG,EAAU,CAAC,EAEhET,EAAOO,CAAQ,EAAE,qBACf,mBACAP,EAAO,iBAAiB,CACtB,OAAQ,OACR,KAAM,KAAK,UAAU,CACnB,OAAQ,oBACR,EAAG,GACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["afterEach", "describe", "expect", "it", "vi", "DefaultButtonController", "DefaultTouchController", "createDefaultControllers", "SCREENS", "fetchSpy", "buttons", "touch", "a", "b"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{pressButtons as r,pressSequence as i}from"./buttonUseCases";const a=()=>Promise.resolve();describe("buttonUsecases",()=>{let e;beforeEach(()=>{e={press:vi.fn(()=>Promise.resolve())}}),afterEach(()=>{vi.useRealTimers(),vi.restoreAllMocks()}),describe("pressButtons",()=>{it("returns functions that call controller.press with the correct keys",async()=>{const t=r(e);await t.left(),await t.right(),await t.both(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right"),expect(e.press).toHaveBeenNthCalledWith(3,"both")})}),describe("pressSequence",()=>{it("presses keys in order and waits the default 200ms after each key (including last)",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),s=i(e,["left","right","both"]);expect(e.press).toHaveBeenCalledTimes(1),expect(e.press).toHaveBeenNthCalledWith(1,"left"),await a(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),200),await vi.advanceTimersByTimeAsync(200),await a(),expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(2,"right"),await vi.advanceTimersByTimeAsync(200),await a(),expect(e.press).toHaveBeenCalledTimes(3),expect(e.press).toHaveBeenNthCalledWith(3,"both"),await vi.advanceTimersByTimeAsync(200),await expect(s).resolves.toBeUndefined()}),it("uses the provided custom delay",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),s=i(e,["left","right"],75);await a(),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await a(),expect(t).toHaveBeenCalledTimes(2),expect(t).toHaveBeenLastCalledWith(expect.any(Function),75),await vi.advanceTimersByTimeAsync(75),await expect(s).resolves.toBeUndefined()}),it("rejects if a press fails and stops processing subsequent keys",async()=>{vi.useFakeTimers();const t=new Error("oups");e.press.mockResolvedValueOnce(void 0).mockRejectedValueOnce(t);const s=i(e,["left","right","both"],50),n=expect(s).rejects.toThrow("oups");await Promise.resolve(),await vi.advanceTimersByTimeAsync(50),await Promise.resolve(),await n,expect(e.press).toHaveBeenCalledTimes(2),expect(e.press).toHaveBeenNthCalledWith(1,"left"),expect(e.press).toHaveBeenNthCalledWith(2,"right")})})});
|
|
2
|
-
//# sourceMappingURL=buttonUseCases.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/use-cases/buttonUseCases.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { pressButtons, pressSequence } from \"./buttonUseCases\";\n\ntype ButtonKey = \"left\" | \"right\" | \"both\";\ntype ButtonController = { press: (k: ButtonKey) => Promise<void> };\n\nconst tick = () => Promise.resolve();\n\ndescribe(\"buttonUsecases\", () => {\n let controller: ButtonController & { press: ReturnType<typeof vi.fn> };\n\n beforeEach(() => {\n controller = {\n press: vi.fn(() => Promise.resolve()),\n };\n });\n\n afterEach(() => {\n vi.useRealTimers();\n vi.restoreAllMocks();\n });\n\n describe(\"pressButtons\", () => {\n it(\"returns functions that call controller.press with the correct keys\", async () => {\n const api = pressButtons(controller);\n\n await api.left();\n await api.right();\n await api.both();\n\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n });\n });\n\n describe(\"pressSequence\", () => {\n it(\"presses keys in order and waits the default 200ms after each key (including last)\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const promise = pressSequence(controller, keys); // delay = 200\n\n // first press happens immediately (sync call of controller.press)\n expect(controller.press).toHaveBeenCalledTimes(1);\n expect(controller.press).toHaveBeenNthCalledWith(1, \"left\");\n\n // timeout is scheduled after the awaited press resolves\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 200);\n\n // first delay elapse -> second press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).toHaveBeenNthCalledWith(2, \"right\");\n\n // next delay -> third press\n await vi.advanceTimersByTimeAsync(200);\n await tick();\n expect(controller.press).toHaveBeenCalledTimes(3);\n expect(controller.press).toHaveBeenNthCalledWith(3, \"both\");\n\n // final post-press delay\n await vi.advanceTimersByTimeAsync(200);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"uses the provided custom delay\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n const keys: ButtonKey[] = [\"left\", \"right\"];\n\n const promise = pressSequence(controller, keys, 75);\n\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await tick();\n expect(timeoutSpy).toHaveBeenCalledTimes(2);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 75);\n\n await vi.advanceTimersByTimeAsync(75);\n await expect(promise).resolves.toBeUndefined();\n });\n\n it(\"rejects if a press fails and stops processing subsequent keys\", async () => {\n vi.useFakeTimers();\n\n const err = new Error(\"oups\");\n controller.press\n .mockResolvedValueOnce(undefined) // first ok\n .mockRejectedValueOnce(err); // second fails\n\n const keys: ButtonKey[] = [\"left\", \"right\", \"both\"];\n\n const p = pressSequence(controller, keys, 50);\n\n const assertion = expect(p).rejects.toThrow(\"oups\");\n\n await Promise.resolve(); // let first setTimeout schedule\n await vi.advanceTimersByTimeAsync(50);\n await Promise.resolve();\n\n await assertion;\n\n expect(controller.press).toHaveBeenCalledTimes(2);\n expect(controller.press).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AON,EAAW,KAAK,EAAE,sBAAsB,CAAC,EAChD,OAAOA,EAAW,KAAK,EAAE,wBAAwB,EAAG,MAAM,EAC1D,OAAOA,EAAW,KAAK,EAAE,wBAAwB,EAAG,OAAO,CAC7D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["pressButtons", "pressSequence", "tick", "controller", "api", "timeoutSpy", "promise", "err", "p", "assertion"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{acceptBlindSigning as p,confirmAddressBookReview as c,continueToBlindSigning as v,enableBlindSigningSettings as r,enterMenu as x,exitMenu as u,mainButton as m,navigateNext as y,navigatePrevious as T,reject as B,secondaryButton as h,sign as d,tapLong as i,tapQuick as g}from"./touchUseCases";describe("touchUsecases",()=>{const n="devA",o={x:50,y:30};let e;beforeEach(()=>{e={tap:vi.fn().mockResolvedValue(void 0),release:vi.fn().mockResolvedValue(void 0),tapAndRelease:vi.fn().mockResolvedValue(void 0)},vi.restoreAllMocks(),vi.useRealTimers()}),it("tapQuick calls tapAndRelease with the same deviceKey and point",async()=>{await g(e,n)(o),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(n,o),expect(e.tap).not.toHaveBeenCalled(),expect(e.release).not.toHaveBeenCalled()}),it("tapLong taps, waits default timeout, then releases",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),s=i(e,n)(o);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(n,o),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),5e3),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(5e3),await s,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(n,o)}),it("tapLong uses the provided delayMs value",async()=>{vi.useFakeTimers();const t=vi.spyOn(globalThis,"setTimeout"),a=1234,l=i(e,n)(o,a);await Promise.resolve(),expect(e.tap).toHaveBeenCalledTimes(1),expect(e.tap).toHaveBeenCalledWith(n,o),expect(t).toHaveBeenCalledTimes(1),expect(t).toHaveBeenLastCalledWith(expect.any(Function),a),expect(e.release).not.toHaveBeenCalled(),await vi.advanceTimersByTimeAsync(a),await l,expect(e.release).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledWith(n,o)}),it("tapLong propagates error if tap() rejects (no release)",async()=>{vi.useFakeTimers();const t=new Error("tap failed");e.tap.mockRejectedValueOnce(t);const s=i(e,n)(o);await expect(s).rejects.toThrow("tap failed"),expect(e.release).not.toHaveBeenCalled()}),it("tapLong propagates error if release() rejects",async()=>{vi.useFakeTimers();const t=new Error("release failed");e.release.mockRejectedValueOnce(t);const a=i(e,n)(o),s=expect(a).rejects.toThrow("release failed");await Promise.resolve(),await vi.advanceTimersByTimeAsync(5e3),await s,expect(e.tap).toHaveBeenCalledTimes(1),expect(e.release).toHaveBeenCalledTimes(1)}),describe("enableBlindSigningSettings",()=>{it.each([["stax",{x:88,y:51}],["flex",{x:88,y:58}],["apex",{x:88,y:58}]])("taps the blind-signing toggle at the %s coordinates",async(t,a)=>{await r(e,t)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(t,a)}),it("falls back to default coordinates for an unknown device key",async()=>{const t="unknown";await r(e,t)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(t,{x:88,y:51})})}),describe("fixed-coordinate taps",()=>{it.each([["reject",B,{x:20,y:90}],["navigateNext",y,{x:90,y:90}],["navigatePrevious",T,{x:45,y:90}],["mainButton",m,{x:50,y:80}],["secondaryButton",h,{x:50,y:90}],["enterMenu",x,{x:85,y:8}],["exitMenu",u,{x:10,y:4}],["continueToBlindSigning",v,{x:50,y:94}],["acceptBlindSigning",p,{x:50,y:94}]])("%s taps %o",async(t,a,s)=>{await a(e,n)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(n,s)})}),describe("sign",()=>{const t={x:85,y:80};it("holds the sign button for the default 5s",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),s=d(e,n)();await Promise.resolve(),expect(e.tap).toHaveBeenCalledWith(n,t),expect(a).toHaveBeenLastCalledWith(expect.any(Function),5e3),await vi.advanceTimersByTimeAsync(5e3),await s,expect(e.release).toHaveBeenCalledWith(n,t)}),it("holds the sign button for the provided delay",async()=>{vi.useFakeTimers();const a=vi.spyOn(globalThis,"setTimeout"),s=250,l=d(e,n)(s);await Promise.resolve(),expect(a).toHaveBeenLastCalledWith(expect.any(Function),s),await vi.advanceTimersByTimeAsync(s),await l,expect(e.release).toHaveBeenCalledTimes(1)})}),describe("confirmAddressBookReview",()=>{it.each([["stax",{x:50,y:77}],["flex",{x:50,y:72}]])("taps the Confirm button at the %s coordinates",async(t,a)=>{await c(e,t)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(t,a)}),it("falls back to Flex coordinates for an unmeasured device key",async()=>{const t="apex";await c(e,t)(),expect(e.tapAndRelease).toHaveBeenCalledTimes(1),expect(e.tapAndRelease).toHaveBeenCalledWith(t,{x:50,y:72})})})});
|
|
2
|
-
//# sourceMappingURL=touchUseCases.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/use-cases/touchUseCases.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { TouchController } from \"@root/src/internal/core/TouchController\";\n\nimport {\n acceptBlindSigning,\n confirmAddressBookReview,\n continueToBlindSigning,\n enableBlindSigningSettings,\n enterMenu,\n exitMenu,\n mainButton,\n navigateNext,\n navigatePrevious,\n reject,\n secondaryButton,\n sign,\n tapLong,\n tapQuick,\n} from \"./touchUseCases\";\n\ndescribe(\"touchUsecases\", () => {\n const deviceKey = \"devA\";\n const point = { x: 50, y: 30 } as any;\n\n let controller: TouchController;\n\n beforeEach(() => {\n controller = {\n tap: vi.fn().mockResolvedValue(undefined),\n release: vi.fn().mockResolvedValue(undefined),\n tapAndRelease: vi.fn().mockResolvedValue(undefined),\n } as unknown as TouchController;\n vi.restoreAllMocks();\n vi.useRealTimers();\n });\n\n it(\"tapQuick calls tapAndRelease with the same deviceKey and point\", async () => {\n const quick = tapQuick(controller, deviceKey);\n await quick(point);\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(deviceKey, point);\n expect(controller.tap).not.toHaveBeenCalled();\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong taps, waits default timeout, then releases\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n expect(controller.release).not.toHaveBeenCalled();\n\n // let the 5s timer elapse\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong uses the provided delayMs value\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 1234;\n const longTap = tapLong(controller, deviceKey);\n const run = longTap(point, customMs);\n\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, point);\n expect(timeoutSpy).toHaveBeenCalledTimes(1);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), customMs);\n expect(controller.release).not.toHaveBeenCalled();\n\n // advance exactly customMs and ensure release happens then\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledWith(deviceKey, point);\n });\n\n it(\"tapLong propagates error if tap() rejects (no release)\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"tap failed\");\n (controller.tap as any).mockRejectedValueOnce(boom);\n\n const longTap = tapLong(controller, deviceKey);\n const p = longTap(point);\n\n // attach rejection handler immediately\n await expect(p).rejects.toThrow(\"tap failed\");\n expect(controller.release).not.toHaveBeenCalled();\n });\n\n it(\"tapLong propagates error if release() rejects\", async () => {\n vi.useFakeTimers();\n\n const boom = new Error(\"release failed\");\n (controller.release as any).mockRejectedValueOnce(boom);\n\n const p = tapLong(controller, deviceKey)(point);\n\n const assertion = expect(p).rejects.toThrow(\"release failed\");\n\n await Promise.resolve();\n await vi.advanceTimersByTimeAsync(5000);\n\n await assertion;\n\n expect(controller.tap).toHaveBeenCalledTimes(1);\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n\n describe(\"enableBlindSigningSettings\", () => {\n it.each([\n [\"stax\", { x: 88, y: 51 }],\n [\"flex\", { x: 88, y: 58 }],\n [\"apex\", { x: 88, y: 58 }],\n ] as const)(\n \"taps the blind-signing toggle at the %s coordinates\",\n async (key, expected) => {\n await enableBlindSigningSettings(controller, key)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(key, expected);\n },\n );\n\n it(\"falls back to default coordinates for an unknown device key\", async () => {\n const unknownKey = \"unknown\";\n await enableBlindSigningSettings(controller, unknownKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(unknownKey, {\n x: 88,\n y: 51,\n });\n });\n });\n\n describe(\"fixed-coordinate taps\", () => {\n it.each([\n [\"reject\", reject, { x: 20, y: 90 }],\n [\"navigateNext\", navigateNext, { x: 90, y: 90 }],\n [\"navigatePrevious\", navigatePrevious, { x: 45, y: 90 }],\n [\"mainButton\", mainButton, { x: 50, y: 80 }],\n [\"secondaryButton\", secondaryButton, { x: 50, y: 90 }],\n [\"enterMenu\", enterMenu, { x: 85, y: 8 }],\n [\"exitMenu\", exitMenu, { x: 10, y: 4 }],\n [\"continueToBlindSigning\", continueToBlindSigning, { x: 50, y: 94 }],\n [\"acceptBlindSigning\", acceptBlindSigning, { x: 50, y: 94 }],\n ] as const)(\"%s taps %o\", async (_name, useCase, expected) => {\n await useCase(controller, deviceKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(\n deviceKey,\n expected,\n );\n });\n });\n\n describe(\"sign\", () => {\n const HOLD_TO_SIGN = { x: 85, y: 80 };\n\n it(\"holds the sign button for the default 5s\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const run = sign(controller, deviceKey)();\n await Promise.resolve();\n\n expect(controller.tap).toHaveBeenCalledWith(deviceKey, HOLD_TO_SIGN);\n expect(timeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), 5000);\n\n await vi.advanceTimersByTimeAsync(5000);\n await run;\n\n expect(controller.release).toHaveBeenCalledWith(deviceKey, HOLD_TO_SIGN);\n });\n\n it(\"holds the sign button for the provided delay\", async () => {\n vi.useFakeTimers();\n const timeoutSpy = vi.spyOn(globalThis, \"setTimeout\");\n\n const customMs = 250;\n const run = sign(controller, deviceKey)(customMs);\n await Promise.resolve();\n\n expect(timeoutSpy).toHaveBeenLastCalledWith(\n expect.any(Function),\n customMs,\n );\n\n await vi.advanceTimersByTimeAsync(customMs);\n await run;\n\n expect(controller.release).toHaveBeenCalledTimes(1);\n });\n });\n\n describe(\"confirmAddressBookReview\", () => {\n // The Address Book review puts its Confirm button above the page footer,\n // so these coordinates are measured per model rather than shared with\n // mainButton/secondaryButton.\n it.each([\n [\"stax\", { x: 50, y: 77 }],\n [\"flex\", { x: 50, y: 72 }],\n ] as const)(\n \"taps the Confirm button at the %s coordinates\",\n async (key, expected) => {\n await confirmAddressBookReview(controller, key)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(key, expected);\n },\n );\n\n it(\"falls back to Flex coordinates for an unmeasured device key\", async () => {\n const unknownKey = \"apex\";\n await confirmAddressBookReview(controller, unknownKey)();\n\n expect(controller.tapAndRelease).toHaveBeenCalledTimes(1);\n expect(controller.tapAndRelease).toHaveBeenCalledWith(unknownKey, {\n x: 50,\n y: 72,\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAMA,OACE,sBAAAA,EACA,4BAAAC,EACA,0BAAAC,EACA,8BAAAC,EACA,aAAAC,EACA,YAAAC,EACA,cAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,UAAAC,EACA,mBAAAC,EACA,QAAAC,EACA,WAAAC,EACA,YAAAC,MACK,kBAEP,SAAS,gBAAiB,IAAM,CAC9B,MAAMC,EAAY,OACZC,EAAQ,CAAE,EAAG,GAAI,EAAG,EAAG,EAE7B,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAa,CACX,IAAK,GAAG,GAAG,EAAE,kBAAkB,MAAS,EACxC,QAAS,GAAG,GAAG,EAAE,kBAAkB,MAAS,EAC5C,cAAe,GAAG,GAAG,EAAE,kBAAkB,MAAS,CACpD,EACA,GAAG,gBAAgB,EACnB,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,iEAAkE,SAAY,CAE/E,MADcH,EAASG,EAAYF,CAAS,EAChCC,CAAK,EAEjB,OAAOC,EAAW,aAAa,EAAE,sBAAsB,CAAC,EACxD,OAAO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|
|
6
|
-
"names": ["acceptBlindSigning", "confirmAddressBookReview", "continueToBlindSigning", "enableBlindSigningSettings", "enterMenu", "exitMenu", "mainButton", "navigateNext", "navigatePrevious", "reject", "secondaryButton", "sign", "tapLong", "tapQuick", "deviceKey", "point", "controller", "timeoutSpy", "run", "customMs", "boom", "p", "assertion", "key", "expected", "unknownKey", "_name", "useCase", "HOLD_TO_SIGN"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{clampValue as o,createAxes as s,createAxis as x}from"./axisClamp";const e=t=>t;describe("axisClamp helpers",()=>{describe("clampValue",()=>{it("floors and clamps to [0, width]",()=>{const t=o(200);expect(t(e(0))).toBe(0),expect(t(e(50))).toBe(100),expect(t(e(50.4))).toBe(100),expect(t(e(50.5))).toBe(101),expect(t(e(100))).toBe(200),expect(t(e(150))).toBe(200),expect(t(e(-10))).toBe(0)})}),describe("createAxis",()=>{it("exposes vw, vh and xy with consistent flooring + clamping",()=>{const t=x(300,200);expect(t.vw(e(25))).toBe(75),expect(t.vh(e(75))).toBe(150),expect(t.xy(e(10),e(90))).toEqual({x:30,y:180}),expect(t.xy(e(150),e(-20))).toEqual({x:300,y:0});const c=t.xy(e(33.4),e(66.6));expect(c.x).toBe(Math.floor(300*.334)),expect(c.y).toBe(Math.floor(200*.666))})}),describe("createAxes",()=>{it("creates an AxisMap for all device keys with matching dimensions",()=>{const c=s({devA:{width:200,height:100},devB:{width:320,height:480}});expect(Object.keys(c).sort()).toEqual(["devA","devB"]),expect(c.devA.vw(e(100))).toBe(200),expect(c.devA.vh(e(100))).toBe(100),expect(c.devA.xy(e(120),e(-10))).toEqual({x:200,y:0}),expect(c.devB.vw(e(50))).toBe(160),expect(c.devB.vh(e(50))).toBe(240),expect(c.devB.xy(e(33.3),e(66.7))).toEqual({x:Math.floor(320*.333),y:Math.floor(480*.667)})})})});
|
|
2
|
-
//# sourceMappingURL=axisClamp.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/internal/utils/axisClamp.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { DeviceScreens, Percent } from \"@internal/core/types\";\n\nimport { type AxisMap, clampValue, createAxes, createAxis } from \"./axisClamp\";\n\nconst p = (n: number) => n as unknown as Percent;\n\ndescribe(\"axisClamp helpers\", () => {\n describe(\"clampValue\", () => {\n it(\"floors and clamps to [0, width]\", () => {\n const clamp = clampValue(200);\n\n expect(clamp(p(0))).toBe(0);\n expect(clamp(p(50))).toBe(100); // 200 * 0.5 = 100\n expect(clamp(p(50.4))).toBe(100); // floor(200 * 0.504) = 100\n expect(clamp(p(50.5))).toBe(101); // floor(200 * 0.505) = 101\n expect(clamp(p(100))).toBe(200);\n expect(clamp(p(150))).toBe(200); // clamped\n expect(clamp(p(-10))).toBe(0); // clamped\n });\n });\n\n describe(\"createAxis\", () => {\n it(\"exposes vw, vh and xy with consistent flooring + clamping\", () => {\n const axis = createAxis(300, 200);\n\n // vw / vh\n expect(axis.vw(p(25))).toBe(75); // 300 * 0.25\n expect(axis.vh(p(75))).toBe(150); // 200 * 0.75\n\n // xy nominal\n expect(axis.xy(p(10), p(90))).toEqual({ x: 30, y: 180 });\n\n // xy clamps both axes\n expect(axis.xy(p(150), p(-20))).toEqual({ x: 300, y: 0 });\n\n // flooring behavior with fractional percent\n const xy = axis.xy(p(33.4), p(66.6));\n expect(xy.x).toBe(Math.floor(300 * 0.334));\n expect(xy.y).toBe(Math.floor(200 * 0.666));\n });\n });\n\n describe(\"createAxes\", () => {\n it(\"creates an AxisMap for all device keys with matching dimensions\", () => {\n const screens: DeviceScreens<\"devA\" | \"devB\"> = {\n devA: { width: 200, height: 100 } as any,\n devB: { width: 320, height: 480 } as any,\n };\n\n const axes: AxisMap<\"devA\" | \"devB\"> = createAxes(screens);\n\n // contains both keys\n expect(Object.keys(axes).sort()).toEqual([\"devA\", \"devB\"]);\n\n // devA\n expect(axes.devA.vw(p(100))).toBe(200);\n expect(axes.devA.vh(p(100))).toBe(100);\n expect(axes.devA.xy(p(120), p(-10))).toEqual({ x: 200, y: 0 });\n\n // devB\n expect(axes.devB.vw(p(50))).toBe(160);\n expect(axes.devB.vh(p(50))).toBe(240);\n expect(axes.devB.xy(p(33.3), p(66.7))).toEqual({\n x: Math.floor(320 * 0.333),\n y: Math.floor(480 * 0.667),\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAKA,OAAuB,cAAAA,EAAY,cAAAC,EAAY,cAAAC,MAAkB,cAEjE,MAAMC,EAAKC,GAAcA,EAEzB,SAAS,oBAAqB,IAAM,CAClC,SAAS,aAAc,IAAM,CAC3B,GAAG,kCAAmC,IAAM,CAC1C,MAAMC,EAAQL,EAAW,GAAG,EAE5B,OAAOK,EAAMF,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAC1B,OAAOE,EAAMF,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,EAC7B,OAAOE,EAAMF,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,EAC/B,OAAOE,EAAMF,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,EAC/B,OAAOE,EAAMF,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EAC9B,OAAOE,EAAMF,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,EAC9B,OAAOE,EAAMF,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAC9B,CAAC,CACH,CAAC,EAED,SAAS,aAAc,IAAM,CAC3B,GAAG,4DAA6D,IAAM,CACpE,MAAMG,EAAOJ,EAAW,IAAK,GAAG,EAGhC,OAAOI,EAAK,GAAGH,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAC9B,OAAOG,EAAK,GAAGH,EAAE,EAAE,CAAC,CA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EAAGA,EAAE,IAAI,CAAC,CAAC,EAAE,QAAQ,CAC7C,EAAG,KAAK,MAAM,IAAM,IAAK,EACzB,EAAG,KAAK,MAAM,IAAM,IAAK,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["clampValue", "createAxes", "createAxis", "p", "n", "clamp", "axis", "xy", "axes"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceController.test.d.ts","sourceRoot":"","sources":["../../../../src/api/DeviceController.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultButtonController.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/adapters/DefaultButtonController.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultTouchController.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/adapters/DefaultTouchController.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"di.test.d.ts","sourceRoot":"","sources":["../../../../src/internal/di.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buttonUseCases.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/use-cases/buttonUseCases.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"touchUseCases.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/use-cases/touchUseCases.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axisClamp.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/utils/axisClamp.test.ts"],"names":[],"mappings":""}
|