@onekeyfe/hd-core 1.2.8-alpha.118 → 1.2.8-alpha.119
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/__tests__/protocol-v2.test.ts +0 -425
- package/dist/api/FirmwareUpdateV4.d.ts +0 -4
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/index.js +39 -214
- package/dist/utils/logger.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +54 -301
- package/src/utils/logger.ts +0 -4
- package/__tests__/logger.test.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -40784,9 +40784,6 @@ class Log$n {
|
|
|
40784
40784
|
}
|
|
40785
40785
|
const _logs = {};
|
|
40786
40786
|
const initLog = (prefix, enabled) => {
|
|
40787
|
-
const existing = _logs[prefix];
|
|
40788
|
-
if (existing)
|
|
40789
|
-
return existing;
|
|
40790
40787
|
const instance = new Log$n(prefix, !!enabled);
|
|
40791
40788
|
_logs[prefix] = instance;
|
|
40792
40789
|
return instance;
|
|
@@ -52634,8 +52631,6 @@ const PROTOCOL_V2_CONNECT_POLL_INTERVAL = 500;
|
|
|
52634
52631
|
const PROTOCOL_V2_CONNECT_SINGLE_TIMEOUT = 75 * 1000;
|
|
52635
52632
|
const PROTOCOL_V2_DEVICE_INFO_READY_TIMEOUT = 30 * 1000;
|
|
52636
52633
|
const PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT = 3;
|
|
52637
|
-
const PROTOCOL_V2_RESOURCE_HEADER_RECOVERY_LIMIT = 2;
|
|
52638
|
-
const PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION = '1.0.2';
|
|
52639
52634
|
const PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS = 1000;
|
|
52640
52635
|
const PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE = 'FirmwareInstallStatusConflict';
|
|
52641
52636
|
const PROTOCOL_V2_INSTALL_FAILED_CODE = 'FirmwareInstallFailed';
|
|
@@ -52683,11 +52678,6 @@ function assertProtocolV2FirmwareTargetsSupported(deviceType, params, hasExplici
|
|
|
52683
52678
|
: `Cannot safely update ${targetList} without a confirmed Pro2 device type`;
|
|
52684
52679
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, message);
|
|
52685
52680
|
}
|
|
52686
|
-
function supportsProtocolV2BleFileWriteWindow(bootloaderVersion, minBootloaderVersion = PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION) {
|
|
52687
|
-
return (!!minBootloaderVersion &&
|
|
52688
|
-
!!semver__default["default"].valid(bootloaderVersion) &&
|
|
52689
|
-
semver__default["default"].gte(bootloaderVersion, minBootloaderVersion));
|
|
52690
|
-
}
|
|
52691
52681
|
const getProtocolV2DeviceTransferProgress = (bytesBeforeChunk, bytesAfterChunk, totalBytes) => {
|
|
52692
52682
|
if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
|
|
52693
52683
|
return 0;
|
|
@@ -52697,8 +52687,6 @@ const getProtocolV2DeviceTransferProgress = (bytesBeforeChunk, bytesAfterChunk,
|
|
|
52697
52687
|
}
|
|
52698
52688
|
return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
|
|
52699
52689
|
};
|
|
52700
|
-
const getProtocolV2TransferRate = (bytes, elapsedMs) => elapsedMs > 0 ? Math.round((bytes / elapsedMs) * 1000) : undefined;
|
|
52701
|
-
const getProtocolV2ElapsedMs = (startedAt, now = Date.now()) => Math.max(now - startedAt, 0);
|
|
52702
52690
|
const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
|
|
52703
52691
|
BOOTLOADER: {
|
|
52704
52692
|
fileName: 'bootloader.bin',
|
|
@@ -52799,21 +52787,6 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52799
52787
|
const causeCode = errorCode !== null && errorCode !== void 0 ? errorCode : code;
|
|
52800
52788
|
return typeof causeCode === 'number' || typeof causeCode === 'string' ? causeCode : undefined;
|
|
52801
52789
|
};
|
|
52802
|
-
const isProtocolV2ResourceHeaderLinkError = (error) => {
|
|
52803
|
-
if (isProtocolV2DeviceDisconnectedError(error))
|
|
52804
|
-
return true;
|
|
52805
|
-
const errorCode = getProtocolV2ErrorCode(error);
|
|
52806
|
-
if (errorCode === hdShared.HardwareErrorCode.BleTimeoutError)
|
|
52807
|
-
return true;
|
|
52808
|
-
const message = getProtocolV2UnknownErrorText(error);
|
|
52809
|
-
if (errorCode === hdShared.HardwareErrorCode.TransportNotFound && /not connected/i.test(message)) {
|
|
52810
|
-
return true;
|
|
52811
|
-
}
|
|
52812
|
-
return (message.includes('ProtocolV2LinkError') ||
|
|
52813
|
-
message.includes('Device protocol has not been detected') ||
|
|
52814
|
-
message.includes('Electron BLE device state cleaned') ||
|
|
52815
|
-
message.includes('Electron BLE transport released'));
|
|
52816
|
-
};
|
|
52817
52790
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52818
52791
|
var _a;
|
|
52819
52792
|
return error instanceof hdShared.HardwareError &&
|
|
@@ -52929,7 +52902,6 @@ const assertProtocolV2ReconnectIdentity = (expectedSerialNumber, actualSerialNum
|
|
|
52929
52902
|
}
|
|
52930
52903
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, `Protocol V2 reconnect physical identity unavailable: expected path ${expectedPath !== null && expectedPath !== void 0 ? expectedPath : 'unknown'}, received ${actualPath !== null && actualPath !== void 0 ? actualPath : 'unknown'}`);
|
|
52931
52904
|
};
|
|
52932
|
-
const isProtocolV2ReconnectIdentityUnverified = (error) => getProtocolV2UnknownErrorText(error).includes('Protocol V2 reconnect physical identity');
|
|
52933
52905
|
class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
52934
52906
|
constructor() {
|
|
52935
52907
|
super(...arguments);
|
|
@@ -53091,7 +53063,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53091
53063
|
componentArtifacts: preparedPlan ? undefined : payload.componentArtifacts,
|
|
53092
53064
|
};
|
|
53093
53065
|
}
|
|
53094
|
-
getProtocolV2FirmwareChunkSize(direction, filePath
|
|
53066
|
+
getProtocolV2FirmwareChunkSize(direction, filePath) {
|
|
53095
53067
|
var _a, _b;
|
|
53096
53068
|
const payloadChunkSize = Number((_a = this.params) === null || _a === void 0 ? void 0 : _a.chunkSize);
|
|
53097
53069
|
const env = DataManager.getSettings('env');
|
|
@@ -53101,9 +53073,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53101
53073
|
if (direction === 'read') {
|
|
53102
53074
|
maxChunkSize = hdTransport.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
53103
53075
|
}
|
|
53104
|
-
else if (fileWriteWindow) {
|
|
53105
|
-
maxChunkSize = hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
53106
|
-
}
|
|
53107
53076
|
else {
|
|
53108
53077
|
maxChunkSize = PROTOCOL_V2_FIRMWARE_STAGING_PATHS.has(filePath !== null && filePath !== void 0 ? filePath : '')
|
|
53109
53078
|
? hdTransport.PROTOCOL_V2_BLE_FIRMWARE_FILE_CHUNK_SIZE
|
|
@@ -53918,43 +53887,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53918
53887
|
return true;
|
|
53919
53888
|
}
|
|
53920
53889
|
catch (error) {
|
|
53921
|
-
if (isProtocolV2ResourceHeaderLinkError(error))
|
|
53922
|
-
throw error;
|
|
53923
53890
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53924
53891
|
return false;
|
|
53925
53892
|
}
|
|
53926
53893
|
});
|
|
53927
53894
|
}
|
|
53928
|
-
isProtocolV2ResourceBundleUpToDateWithRecovery(bundle, recovery) {
|
|
53929
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53930
|
-
for (;;) {
|
|
53931
|
-
try {
|
|
53932
|
-
return yield this.isProtocolV2ResourceBundleUpToDate(bundle);
|
|
53933
|
-
}
|
|
53934
|
-
catch (error) {
|
|
53935
|
-
this.throwIfAborted();
|
|
53936
|
-
if (recovery.remaining <= 0) {
|
|
53937
|
-
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check lost the link; reconnect budget used up: `, getProtocolV2UnknownErrorText(error));
|
|
53938
|
-
return false;
|
|
53939
|
-
}
|
|
53940
|
-
recovery.remaining -= 1;
|
|
53941
|
-
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check lost the link; reconnecting: `, getProtocolV2UnknownErrorText(error));
|
|
53942
|
-
}
|
|
53943
|
-
try {
|
|
53944
|
-
yield this.recoverProtocolV2FileTransfer();
|
|
53945
|
-
}
|
|
53946
|
-
catch (recoverError) {
|
|
53947
|
-
this.throwIfAborted();
|
|
53948
|
-
if (isProtocolV2ReconnectIdentityUnverified(recoverError))
|
|
53949
|
-
throw recoverError;
|
|
53950
|
-
recovery.remaining = 0;
|
|
53951
|
-
Log$6.log('[FirmwareUpdateV4] RESC header check reconnect failed: ', getProtocolV2UnknownErrorText(recoverError));
|
|
53952
|
-
return false;
|
|
53953
|
-
}
|
|
53954
|
-
this.throwIfAborted();
|
|
53955
|
-
}
|
|
53956
|
-
});
|
|
53957
|
-
}
|
|
53958
53895
|
isProtocolV2BootloaderMode() {
|
|
53959
53896
|
var _a, _b, _c;
|
|
53960
53897
|
if (typeof this.device.isBootloader === 'function') {
|
|
@@ -54133,9 +54070,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54133
54070
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54134
54071
|
let totalSize = installSources.reduce((total, item) => total + item.source.size, 0);
|
|
54135
54072
|
const resourcesToSync = [];
|
|
54136
|
-
const headerRecovery = { remaining: PROTOCOL_V2_RESOURCE_HEADER_RECOVERY_LIMIT };
|
|
54137
54073
|
for (const resource of resourceSources) {
|
|
54138
|
-
if (yield this.
|
|
54074
|
+
if (yield this.isProtocolV2ResourceBundleUpToDate(resource)) {
|
|
54139
54075
|
Log$6.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
54140
54076
|
}
|
|
54141
54077
|
else {
|
|
@@ -54180,20 +54116,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54180
54116
|
});
|
|
54181
54117
|
}
|
|
54182
54118
|
if (totalSize > 0) {
|
|
54183
|
-
const elapsedMs =
|
|
54184
|
-
const rateBytesPerSecond = getProtocolV2TransferRate(totalSize, elapsedMs);
|
|
54119
|
+
const elapsedMs = Math.max(Date.now() - transferStartedAt, 0);
|
|
54185
54120
|
this.postProgressMessage(100, 'transferData', {
|
|
54186
54121
|
transferredBytes: totalSize,
|
|
54187
54122
|
totalBytes: totalSize,
|
|
54188
|
-
rateBytesPerSecond,
|
|
54123
|
+
rateBytesPerSecond: elapsedMs > 0 ? Math.round((totalSize / elapsedMs) * 1000) : undefined,
|
|
54189
54124
|
elapsedMs,
|
|
54190
54125
|
});
|
|
54191
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 transfer completed', {
|
|
54192
|
-
files: resourcesToSync.length + installSources.length,
|
|
54193
|
-
totalBytes: totalSize,
|
|
54194
|
-
elapsedMs,
|
|
54195
|
-
rateBytesPerSecond,
|
|
54196
|
-
});
|
|
54197
54126
|
}
|
|
54198
54127
|
if (stagedInstallTargets.length === 0) {
|
|
54199
54128
|
return;
|
|
@@ -54203,15 +54132,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54203
54132
|
target_id: item.targetId,
|
|
54204
54133
|
path: item.path,
|
|
54205
54134
|
}));
|
|
54206
|
-
const installStartedAt = Date.now();
|
|
54207
54135
|
try {
|
|
54208
54136
|
yield this.protocolV2StartFirmwareUpdate({ targets });
|
|
54209
54137
|
yield hdShared.wait(PROTOCOL_V2_INSTALL_STATUS_INITIAL_DELAY);
|
|
54210
54138
|
yield this.waitForProtocolV2FirmwareUpdateComplete(targets, true);
|
|
54211
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 install completed', {
|
|
54212
|
-
targets: targets.length,
|
|
54213
|
-
elapsedMs: getProtocolV2ElapsedMs(installStartedAt),
|
|
54214
|
-
});
|
|
54215
54139
|
}
|
|
54216
54140
|
finally {
|
|
54217
54141
|
(_a = this.device) === null || _a === void 0 ? void 0 : _a.clearCancelableAction();
|
|
@@ -54220,81 +54144,51 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54220
54144
|
}
|
|
54221
54145
|
protocolV2SourceUpdateProcess({ source, filePath, processedSize, totalSize, transferStartedAt = Date.now(), }) {
|
|
54222
54146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54223
|
-
const reportConfirmedChunk = (chunkEnd) => {
|
|
54224
|
-
const transferredBytes = processedSize + chunkEnd;
|
|
54225
|
-
const now = Date.now();
|
|
54226
|
-
const elapsedMs = getProtocolV2ElapsedMs(transferStartedAt, now);
|
|
54227
|
-
const progress = Math.min(Math.ceil((transferredBytes / totalSize) * 100), 99);
|
|
54228
|
-
const shouldPostProgress = transferredBytes >= this.protocolV2LastTransferredBytes &&
|
|
54229
|
-
(progress !== this.protocolV2LastTransferProgress ||
|
|
54230
|
-
now - this.protocolV2LastTransferProgressAt >=
|
|
54231
|
-
PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS ||
|
|
54232
|
-
chunkEnd === source.size);
|
|
54233
|
-
if (shouldPostProgress) {
|
|
54234
|
-
this.protocolV2LastTransferProgress = progress;
|
|
54235
|
-
this.protocolV2LastTransferProgressAt = now;
|
|
54236
|
-
this.protocolV2LastTransferredBytes = transferredBytes;
|
|
54237
|
-
this.postProgressMessage(progress, 'transferData', {
|
|
54238
|
-
transferredBytes,
|
|
54239
|
-
totalBytes: totalSize,
|
|
54240
|
-
rateBytesPerSecond: getProtocolV2TransferRate(transferredBytes, elapsedMs),
|
|
54241
|
-
elapsedMs,
|
|
54242
|
-
});
|
|
54243
|
-
}
|
|
54244
|
-
};
|
|
54245
54147
|
let lastError;
|
|
54246
54148
|
for (let attempt = 1; attempt <= PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT; attempt += 1) {
|
|
54247
54149
|
this.throwIfAborted();
|
|
54248
|
-
const attemptStartedAt = Date.now();
|
|
54249
54150
|
try {
|
|
54250
|
-
|
|
54251
|
-
|
|
54252
|
-
|
|
54253
|
-
|
|
54254
|
-
|
|
54255
|
-
|
|
54256
|
-
|
|
54257
|
-
|
|
54258
|
-
|
|
54259
|
-
|
|
54260
|
-
|
|
54261
|
-
|
|
54262
|
-
|
|
54263
|
-
|
|
54264
|
-
|
|
54265
|
-
|
|
54266
|
-
|
|
54267
|
-
|
|
54268
|
-
|
|
54269
|
-
|
|
54270
|
-
|
|
54271
|
-
|
|
54272
|
-
|
|
54273
|
-
|
|
54274
|
-
|
|
54275
|
-
|
|
54276
|
-
|
|
54277
|
-
|
|
54278
|
-
|
|
54279
|
-
|
|
54280
|
-
|
|
54281
|
-
|
|
54282
|
-
|
|
54283
|
-
|
|
54284
|
-
|
|
54285
|
-
attempt,
|
|
54286
|
-
fileWriteWindow: windowed ? hdTransport.PROTOCOL_V2_FILE_WRITE_PIPELINE_WINDOW : 1,
|
|
54151
|
+
yield writeFirmwareByteSource({
|
|
54152
|
+
source,
|
|
54153
|
+
chunkSize: this.getProtocolV2FirmwareChunkSize('write', filePath),
|
|
54154
|
+
write: ({ data, sourceOffset, length, first }) => __awaiter(this, void 0, void 0, function* () {
|
|
54155
|
+
this.throwIfAborted();
|
|
54156
|
+
const chunkEnd = sourceOffset + length;
|
|
54157
|
+
const deviceProgress = getProtocolV2DeviceTransferProgress(processedSize + sourceOffset, processedSize + chunkEnd, totalSize);
|
|
54158
|
+
const response = yield this.fileWriteChunk(filePath, source.size, sourceOffset, data, first, deviceProgress);
|
|
54159
|
+
const rawProcessedByte = response.message.processed_byte;
|
|
54160
|
+
const nextOffset = rawProcessedByte === undefined ? chunkEnd : Number(rawProcessedByte);
|
|
54161
|
+
if (!Number.isFinite(nextOffset) || nextOffset !== chunkEnd) {
|
|
54162
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${rawProcessedByte} for offset ${sourceOffset}`);
|
|
54163
|
+
}
|
|
54164
|
+
const transferredBytes = processedSize + chunkEnd;
|
|
54165
|
+
const now = Date.now();
|
|
54166
|
+
const elapsedMs = Math.max(now - transferStartedAt, 0);
|
|
54167
|
+
const progress = Math.min(Math.ceil((transferredBytes / totalSize) * 100), 99);
|
|
54168
|
+
const shouldPostProgress = transferredBytes >= this.protocolV2LastTransferredBytes &&
|
|
54169
|
+
(progress !== this.protocolV2LastTransferProgress ||
|
|
54170
|
+
now - this.protocolV2LastTransferProgressAt >=
|
|
54171
|
+
PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS ||
|
|
54172
|
+
chunkEnd === source.size);
|
|
54173
|
+
if (shouldPostProgress) {
|
|
54174
|
+
this.protocolV2LastTransferProgress = progress;
|
|
54175
|
+
this.protocolV2LastTransferProgressAt = now;
|
|
54176
|
+
this.protocolV2LastTransferredBytes = transferredBytes;
|
|
54177
|
+
this.postProgressMessage(progress, 'transferData', {
|
|
54178
|
+
transferredBytes,
|
|
54179
|
+
totalBytes: totalSize,
|
|
54180
|
+
rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
|
|
54181
|
+
elapsedMs,
|
|
54182
|
+
});
|
|
54183
|
+
}
|
|
54184
|
+
return length;
|
|
54185
|
+
}),
|
|
54287
54186
|
});
|
|
54288
54187
|
return processedSize + source.size;
|
|
54289
54188
|
}
|
|
54290
54189
|
catch (error) {
|
|
54291
54190
|
this.throwIfAborted();
|
|
54292
54191
|
lastError = error;
|
|
54293
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 file transfer attempt failed', {
|
|
54294
|
-
path: filePath,
|
|
54295
|
-
attempt,
|
|
54296
|
-
error: getProtocolV2UnknownErrorText(error),
|
|
54297
|
-
});
|
|
54298
54192
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54299
54193
|
yield this.recoverProtocolV2FileTransfer();
|
|
54300
54194
|
this.throwIfAborted();
|
|
@@ -54977,75 +54871,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54977
54871
|
return writeRes;
|
|
54978
54872
|
});
|
|
54979
54873
|
}
|
|
54980
|
-
shouldUseProtocolV2BleFileWriteWindow(minBootloaderVersion = PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION) {
|
|
54981
|
-
var _a, _b;
|
|
54982
|
-
const env = DataManager.getSettings('env');
|
|
54983
|
-
if ((env !== 'react-native' && env !== 'desktop-web-ble') ||
|
|
54984
|
-
!this.isProtocolV2BootloaderMode()) {
|
|
54985
|
-
return false;
|
|
54986
|
-
}
|
|
54987
|
-
const bootloaderVersion = getDeviceBootloaderVersion(this.device.features).join('.');
|
|
54988
|
-
const enabled = supportsProtocolV2BleFileWriteWindow(bootloaderVersion, minBootloaderVersion);
|
|
54989
|
-
Log$6.debug('[FirmwareUpdateV4] BLE FileWrite window', {
|
|
54990
|
-
enabled,
|
|
54991
|
-
bootloaderVersion,
|
|
54992
|
-
bootloaderBuildId: (_b = (_a = this.device.features) === null || _a === void 0 ? void 0 : _a.verify) === null || _b === void 0 ? void 0 : _b.bootloaderBuildId,
|
|
54993
|
-
});
|
|
54994
|
-
return enabled;
|
|
54995
|
-
}
|
|
54996
|
-
writeProtocolV2SourceWindowed({ source, filePath, chunkSize, processedSize, totalSize, onChunkConfirmed, }) {
|
|
54997
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54998
|
-
let sendOffset = 0;
|
|
54999
|
-
let sourceError;
|
|
55000
|
-
const readRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
55001
|
-
const offset = sendOffset;
|
|
55002
|
-
const length = Math.min(chunkSize, source.size - offset);
|
|
55003
|
-
const data = yield source.readAt(offset, length);
|
|
55004
|
-
sendOffset += length;
|
|
55005
|
-
return {
|
|
55006
|
-
file: { path: filePath, offset, total_size: source.size, data },
|
|
55007
|
-
overwrite: offset === 0,
|
|
55008
|
-
append: false,
|
|
55009
|
-
ui_percentage: getProtocolV2DeviceTransferProgress(processedSize + offset, processedSize + sendOffset, totalSize),
|
|
55010
|
-
};
|
|
55011
|
-
});
|
|
55012
|
-
const nextRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
55013
|
-
var _a;
|
|
55014
|
-
if (((_a = this.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) || sendOffset >= source.size)
|
|
55015
|
-
return undefined;
|
|
55016
|
-
try {
|
|
55017
|
-
return yield readRequest();
|
|
55018
|
-
}
|
|
55019
|
-
catch (error) {
|
|
55020
|
-
sourceError = error;
|
|
55021
|
-
return undefined;
|
|
55022
|
-
}
|
|
55023
|
-
});
|
|
55024
|
-
this.throwIfAborted();
|
|
55025
|
-
if (source.size === 0)
|
|
55026
|
-
return;
|
|
55027
|
-
const firstRequest = yield readRequest();
|
|
55028
|
-
const response = yield this.device
|
|
55029
|
-
.getCommands()
|
|
55030
|
-
.typedCall('FilesystemFileWrite', 'FilesystemFile', firstRequest, {
|
|
55031
|
-
timeoutMs: PROTOCOL_V2_FILE_WRITE_RESPONSE_TIMEOUT,
|
|
55032
|
-
writeWithResponse: false,
|
|
55033
|
-
fileWritePipeline: {
|
|
55034
|
-
next: nextRequest,
|
|
55035
|
-
onResponse: confirmed => {
|
|
55036
|
-
onChunkConfirmed(Number(confirmed.message.processed_byte));
|
|
55037
|
-
},
|
|
55038
|
-
},
|
|
55039
|
-
});
|
|
55040
|
-
this.throwIfAborted();
|
|
55041
|
-
if (sourceError)
|
|
55042
|
-
throw sourceError;
|
|
55043
|
-
const rawProcessedByte = response.message.processed_byte;
|
|
55044
|
-
if (Number(rawProcessedByte) !== source.size) {
|
|
55045
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${rawProcessedByte} for file size ${source.size}`);
|
|
55046
|
-
}
|
|
55047
|
-
});
|
|
55048
|
-
}
|
|
55049
54874
|
recoverProtocolV2FileTransfer() {
|
|
55050
54875
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55051
54876
|
const env = DataManager.getSettings('env');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,YAAY,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,YAAY,OAAO,QAIxD,CAAC;AAEF,eAAO,MAAM,SAAS,aAAc,OAAO,SAI1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,OAAO,SAIjE,CAAC;AAEF,eAAO,MAAM,MAAM,oBAOlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,4BAA6B,WAAW,KAAK,IAAI,SAEjF,CAAC;AAuCF,oBAAY,WAAW;IACrB,IAAI,oBAAoB;IACxB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,kBAAkB,+BAA+B;IACjD,QAAQ,uBAAuB;IAC/B,eAAe,8BAA8B;IAC7C,mBAAmB,kCAAkC;IACrD,cAAc,6BAA6B;IAC3C,iBAAiB,iCAAiC;IAClD,iBAAiB,gCAAgC;IACjD,kBAAkB,kCAAkC;IACpD,OAAO,oBAAoB;IAC3B,MAAM,WAAW;IACjB,WAAW,kBAAkB;IAC7B,MAAM,aAAa;CACpB;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,WAAW,QAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.119",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.8-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.8-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.119",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.119",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "26953c0d533e9a05980abc8ea43e7bbd45ead861"
|
|
50
50
|
}
|