@onekeyfe/hardware-cli 1.2.0-alpha.105 → 1.2.0-alpha.107
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/dist/cli.js +9 -3
- package/package.json +6 -6
- package/src/__tests__/wallpaper-upload-command.test.ts +0 -1
- package/src/cli.ts +11 -3
package/dist/cli.js
CHANGED
|
@@ -62,11 +62,15 @@ program
|
|
|
62
62
|
program
|
|
63
63
|
.command('upload-wallpaper')
|
|
64
64
|
.description('Upload and activate a Pro2 wallpaper')
|
|
65
|
-
.requiredOption('--
|
|
65
|
+
.requiredOption('--rgba <path>', '604x1024 raw RGBA file')
|
|
66
66
|
.option('--file-name <name>', 'Device wallpaper file name', 'wallpaper-cli')
|
|
67
67
|
.option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
|
|
68
68
|
.action(opts => runCommand({}, async ({ sdk, globalOpts, params }) => {
|
|
69
|
-
const
|
|
69
|
+
const rgba = readBinaryParam(opts.rgba);
|
|
70
|
+
const expectedBytes = 604 * 1024 * 4;
|
|
71
|
+
if (rgba.byteLength !== expectedBytes) {
|
|
72
|
+
throw new Error(`Invalid RGBA size: expected ${expectedBytes} bytes, received ${rgba.byteLength}`);
|
|
73
|
+
}
|
|
70
74
|
let transferStartedAt;
|
|
71
75
|
let transferEndedAt;
|
|
72
76
|
let lastProgress = -1;
|
|
@@ -107,7 +111,9 @@ program
|
|
|
107
111
|
try {
|
|
108
112
|
result = await sdk.deviceUploadWallpaper(globalOpts.connectId, {
|
|
109
113
|
...params,
|
|
110
|
-
|
|
114
|
+
width: 604,
|
|
115
|
+
height: 1024,
|
|
116
|
+
rgba,
|
|
111
117
|
fileName: opts.fileName,
|
|
112
118
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
113
119
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.107",
|
|
4
4
|
"description": "OneKey hardware wallet CLI for testing device communication",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"test": "jest"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.
|
|
35
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
36
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
37
|
-
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.
|
|
34
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.107",
|
|
35
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.107",
|
|
36
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.107",
|
|
37
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.107",
|
|
38
38
|
"@stoprocent/noble": "2.3.16",
|
|
39
39
|
"commander": "^12.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "23fe3be6f7b41066a704b4149b49bbc64d883c55"
|
|
42
42
|
}
|
|
@@ -6,7 +6,6 @@ describe('upload-wallpaper CLI command', () => {
|
|
|
6
6
|
|
|
7
7
|
expect(command).toBeDefined();
|
|
8
8
|
expect(command?.description()).toBe('Upload and activate a Pro2 wallpaper');
|
|
9
|
-
expect(command?.options.some(option => option.long === '--jpeg' && option.required)).toBe(true);
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
test('reports effective transfer speed from encoded bytes and elapsed time', () => {
|
package/src/cli.ts
CHANGED
|
@@ -99,12 +99,18 @@ program
|
|
|
99
99
|
program
|
|
100
100
|
.command('upload-wallpaper')
|
|
101
101
|
.description('Upload and activate a Pro2 wallpaper')
|
|
102
|
-
.requiredOption('--
|
|
102
|
+
.requiredOption('--rgba <path>', '604x1024 raw RGBA file')
|
|
103
103
|
.option('--file-name <name>', 'Device wallpaper file name', 'wallpaper-cli')
|
|
104
104
|
.option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
|
|
105
105
|
.action(opts =>
|
|
106
106
|
runCommand({}, async ({ sdk, globalOpts, params }) => {
|
|
107
|
-
const
|
|
107
|
+
const rgba = readBinaryParam(opts.rgba);
|
|
108
|
+
const expectedBytes = 604 * 1024 * 4;
|
|
109
|
+
if (rgba.byteLength !== expectedBytes) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Invalid RGBA size: expected ${expectedBytes} bytes, received ${rgba.byteLength}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
108
114
|
|
|
109
115
|
let transferStartedAt: number | undefined;
|
|
110
116
|
let transferEndedAt: number | undefined;
|
|
@@ -153,7 +159,9 @@ program
|
|
|
153
159
|
try {
|
|
154
160
|
result = await sdk.deviceUploadWallpaper(globalOpts.connectId, {
|
|
155
161
|
...params,
|
|
156
|
-
|
|
162
|
+
width: 604,
|
|
163
|
+
height: 1024,
|
|
164
|
+
rgba,
|
|
157
165
|
fileName: opts.fileName,
|
|
158
166
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
159
167
|
});
|