mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
@@ -1,9 +1,10 @@
|
||||
name: Build and publish dev version
|
||||
name: Build and publish release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v1.*-beta.*
|
||||
- v1.*-rc.*
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pybricks/pybricks-code",
|
||||
"version": "1.0.0-beta.15",
|
||||
"version": "1.0.0-rc.1",
|
||||
"license": "MIT",
|
||||
"author": "The Pybricks Authors",
|
||||
"repository": {
|
||||
@@ -10,7 +10,7 @@
|
||||
"dependencies": {
|
||||
"@blueprintjs/core": "^3.41.0",
|
||||
"@craco/craco": "^6.1.1",
|
||||
"@pybricks/firmware": "4.10.0",
|
||||
"@pybricks/firmware": "4.11.0",
|
||||
"@pybricks/ide-docs": "1.3.2",
|
||||
"@pybricks/mpy-cross-v5": "^2.0.0",
|
||||
"@shopify/react-i18n": "^5.3.0",
|
||||
@@ -20,7 +20,6 @@
|
||||
"@testing-library/user-event": "^12.8.1",
|
||||
"@types/file-saver": "^2.0.1",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/jszip": "^3.4.1",
|
||||
"@types/node": "^12.20.4",
|
||||
"@types/react": "^16.14.5",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
|
||||
@@ -15,11 +15,11 @@ import { Store } from 'redux';
|
||||
import AboutDialog from './AboutDialog';
|
||||
|
||||
it('should close when the button is clicked', () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(() => ({ licenses: { list: null } })),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
const close = jest.fn();
|
||||
render(
|
||||
@@ -36,11 +36,11 @@ it('should close when the button is clicked', () => {
|
||||
});
|
||||
|
||||
it('should manage license dialog open/close', async () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(() => ({ licenses: { list: null } })),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
render(
|
||||
<Provider store={store}>
|
||||
|
||||
+4
-3
@@ -59,9 +59,10 @@ export function didCheckForUpdate(updateFound: boolean): AppDidCheckForUpdateAct
|
||||
}
|
||||
|
||||
/* Action that indicates the browser wants to prompt the use to install the app. */
|
||||
export type AppDidBeforeInstallPromptAction = Action<AppActionType.DidBeforeInstallPrompt> & {
|
||||
event: BeforeInstallPromptEvent;
|
||||
};
|
||||
export type AppDidBeforeInstallPromptAction =
|
||||
Action<AppActionType.DidBeforeInstallPrompt> & {
|
||||
event: BeforeInstallPromptEvent;
|
||||
};
|
||||
|
||||
/* Action that indicates the browser wants to prompt the use to install the app. */
|
||||
export function didBeforeInstallPrompt(
|
||||
|
||||
@@ -29,10 +29,11 @@ export enum BlePybricksServiceActionType {
|
||||
/**
|
||||
* Action that request to write a command to the Pybricks service control characteristic.
|
||||
*/
|
||||
export type BlePybricksServiceWriteCommandAction = Action<BlePybricksServiceActionType.WriteCommand> & {
|
||||
id: number;
|
||||
value: Uint8Array;
|
||||
};
|
||||
export type BlePybricksServiceWriteCommandAction =
|
||||
Action<BlePybricksServiceActionType.WriteCommand> & {
|
||||
id: number;
|
||||
value: Uint8Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that request to write a command to the Pybricks service control characteristic.
|
||||
@@ -51,9 +52,10 @@ export function writeCommand(
|
||||
/**
|
||||
* Action that indicates sending a command to the Pybricks service control characteristic was successful.
|
||||
*/
|
||||
export type BlePybricksServiceDidWriteCommandAction = Action<BlePybricksServiceActionType.DidWriteCommand> & {
|
||||
id: number;
|
||||
};
|
||||
export type BlePybricksServiceDidWriteCommandAction =
|
||||
Action<BlePybricksServiceActionType.DidWriteCommand> & {
|
||||
id: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that indicates sending a command to the Pybricks service control characteristic was successful.
|
||||
@@ -68,10 +70,11 @@ export function didWriteCommand(id: number): BlePybricksServiceDidWriteCommandAc
|
||||
/**
|
||||
* Action that indicates sending a command to the Pybricks service control characteristic failed.
|
||||
*/
|
||||
export type BlePybricksServiceDidFailToWriteCommandAction = Action<BlePybricksServiceActionType.DidFailToWriteCommand> & {
|
||||
id: number;
|
||||
err: Error;
|
||||
};
|
||||
export type BlePybricksServiceDidFailToWriteCommandAction =
|
||||
Action<BlePybricksServiceActionType.DidFailToWriteCommand> & {
|
||||
id: number;
|
||||
err: Error;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that indicates sending a command to the Pybricks service control characteristic failed.
|
||||
@@ -90,9 +93,10 @@ export function didFailToWriteCommand(
|
||||
/**
|
||||
* Action that indicates an event notification was received on the Pybricks service control characteristic.
|
||||
*/
|
||||
export type BlePybricksServiceDidNotifyEventAction = Action<BlePybricksServiceActionType.DidNotifyEvent> & {
|
||||
value: DataView;
|
||||
};
|
||||
export type BlePybricksServiceDidNotifyEventAction =
|
||||
Action<BlePybricksServiceActionType.DidNotifyEvent> & {
|
||||
value: DataView;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that indicates an event notification was received on the Pybricks service control characteristic.
|
||||
@@ -126,8 +130,8 @@ type TransactionId = {
|
||||
};
|
||||
|
||||
/** Action that requests a stop user program to be sent. */
|
||||
export type BlePybricksServiceCommandSendStopUserProgram = Action<BlePybricksServiceCommandActionType.SendStopUserProgram> &
|
||||
TransactionId;
|
||||
export type BlePybricksServiceCommandSendStopUserProgram =
|
||||
Action<BlePybricksServiceCommandActionType.SendStopUserProgram> & TransactionId;
|
||||
|
||||
/**
|
||||
* Action that requests a stop user program to be sent.
|
||||
@@ -142,8 +146,8 @@ export function sendStopUserProgramCommand(
|
||||
/**
|
||||
* Action that indicates that a command was successfully sent.
|
||||
*/
|
||||
export type BlePybricksServiceCommandDidSendAction = Action<BlePybricksServiceCommandActionType.DidSend> &
|
||||
TransactionId;
|
||||
export type BlePybricksServiceCommandDidSendAction =
|
||||
Action<BlePybricksServiceCommandActionType.DidSend> & TransactionId;
|
||||
|
||||
/**
|
||||
* Action that indicates that a command was successfully sent.
|
||||
@@ -156,11 +160,12 @@ export function didSendCommand(id: number): BlePybricksServiceCommandDidSendActi
|
||||
/**
|
||||
* Action that indicates that a command was not sent.
|
||||
*/
|
||||
export type BlePybricksServiceCommandDidFailToSendAction = Action<BlePybricksServiceCommandActionType.DidFailToSend> &
|
||||
TransactionId & {
|
||||
/** The error that was raised. */
|
||||
err: Error;
|
||||
};
|
||||
export type BlePybricksServiceCommandDidFailToSendAction =
|
||||
Action<BlePybricksServiceCommandActionType.DidFailToSend> &
|
||||
TransactionId & {
|
||||
/** The error that was raised. */
|
||||
err: Error;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that indicates that a command was not sent.
|
||||
@@ -191,9 +196,10 @@ export enum BlePybricksServiceEventActionType {
|
||||
/**
|
||||
* Action that represents a status report event received from the hub.
|
||||
*/
|
||||
export type BlePybricksServiceEventStatusReportAction = Action<BlePybricksServiceEventActionType.StatusReport> & {
|
||||
statusFlags: number;
|
||||
};
|
||||
export type BlePybricksServiceEventStatusReportAction =
|
||||
Action<BlePybricksServiceEventActionType.StatusReport> & {
|
||||
statusFlags: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that represents a status report event received from the hub.
|
||||
@@ -208,9 +214,10 @@ export function statusReportEvent(
|
||||
/**
|
||||
* Pseudo-event (not received from hub) indicating that there was a protocol error.
|
||||
*/
|
||||
export type BlePybricksServiceEventProtocolErrorAction = Action<BlePybricksServiceEventActionType.ProtocolError> & {
|
||||
err: Error;
|
||||
};
|
||||
export type BlePybricksServiceEventProtocolErrorAction =
|
||||
Action<BlePybricksServiceEventActionType.ProtocolError> & {
|
||||
err: Error;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pseudo-event (not received from hub) indicating that there was a protocol error.
|
||||
|
||||
+20
-12
@@ -67,21 +67,28 @@ type Reason<T extends BleDeviceFailToConnectReasonType> = {
|
||||
reason: T;
|
||||
};
|
||||
|
||||
export type BleDeviceFailToConnectNoWebBluetoothReason = Reason<BleDeviceFailToConnectReasonType.NoWebBluetooth>;
|
||||
export type BleDeviceFailToConnectNoWebBluetoothReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.NoWebBluetooth>;
|
||||
|
||||
export type BleDeviceFailToConnectNoBluetoothReason = Reason<BleDeviceFailToConnectReasonType.NoBluetooth>;
|
||||
export type BleDeviceFailToConnectNoBluetoothReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.NoBluetooth>;
|
||||
|
||||
export type BleDeviceFailToConnectCanceledReason = Reason<BleDeviceFailToConnectReasonType.Canceled>;
|
||||
export type BleDeviceFailToConnectCanceledReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.Canceled>;
|
||||
|
||||
export type BleDeviceFailToConnectNoGattReason = Reason<BleDeviceFailToConnectReasonType.NoGatt>;
|
||||
export type BleDeviceFailToConnectNoGattReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.NoGatt>;
|
||||
|
||||
export type BleDeviceFailToConnectNoDeviceInfoServiceReason = Reason<BleDeviceFailToConnectReasonType.NoDeviceInfoService>;
|
||||
export type BleDeviceFailToConnectNoDeviceInfoServiceReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.NoDeviceInfoService>;
|
||||
|
||||
export type BleDeviceFailToConnectNoPybricksServiceReason = Reason<BleDeviceFailToConnectReasonType.NoPybricksService>;
|
||||
export type BleDeviceFailToConnectNoPybricksServiceReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.NoPybricksService>;
|
||||
|
||||
export type BleDeviceFailToConnectUnknownReason = Reason<BleDeviceFailToConnectReasonType.Unknown> & {
|
||||
err: Error;
|
||||
};
|
||||
export type BleDeviceFailToConnectUnknownReason =
|
||||
Reason<BleDeviceFailToConnectReasonType.Unknown> & {
|
||||
err: Error;
|
||||
};
|
||||
|
||||
export type BleDeviceDidFailToConnectReason =
|
||||
| BleDeviceFailToConnectNoWebBluetoothReason
|
||||
@@ -92,8 +99,8 @@ export type BleDeviceDidFailToConnectReason =
|
||||
| BleDeviceFailToConnectNoPybricksServiceReason
|
||||
| BleDeviceFailToConnectUnknownReason;
|
||||
|
||||
export type BleDeviceDidFailToConnectAction = Action<BleDeviceActionType.DidFailToConnect> &
|
||||
BleDeviceDidFailToConnectReason;
|
||||
export type BleDeviceDidFailToConnectAction =
|
||||
Action<BleDeviceActionType.DidFailToConnect> & BleDeviceDidFailToConnectReason;
|
||||
|
||||
/**
|
||||
* Creates an action that indicates a device failed to connect.
|
||||
@@ -122,7 +129,8 @@ export function didDisconnect(): BleDeviceDidDisconnectAction {
|
||||
return { type: BleDeviceActionType.DidDisconnect };
|
||||
}
|
||||
|
||||
export type BleDeviceDidFailToDisconnectAction = Action<BleDeviceActionType.DidFailToDisconnect>;
|
||||
export type BleDeviceDidFailToDisconnectAction =
|
||||
Action<BleDeviceActionType.DidFailToDisconnect>;
|
||||
|
||||
/**
|
||||
* Creates an action that indicates a device failed to disconnect.
|
||||
|
||||
@@ -21,11 +21,11 @@ function getTextArea(): HTMLTextAreaElement {
|
||||
}
|
||||
|
||||
it('should focus the text area', () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(() => ({ settings: { darkMode: false, showDocs: false } })),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
render(
|
||||
<Provider store={store}>
|
||||
@@ -40,13 +40,13 @@ it('should focus the text area', () => {
|
||||
|
||||
describe('context menu', () => {
|
||||
it('should show the context menu', () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(() => ({
|
||||
settings: { darkMode: false, showDocs: false },
|
||||
})),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
|
||||
render(
|
||||
@@ -63,13 +63,13 @@ describe('context menu', () => {
|
||||
});
|
||||
|
||||
it('should hide the context menu when Escape is pressed', async () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(() => ({
|
||||
settings: { darkMode: false, showDocs: false },
|
||||
})),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
|
||||
render(
|
||||
|
||||
+28
-19
@@ -71,7 +71,8 @@ type Reason<T extends FailToFinishReasonType> = {
|
||||
reason: T;
|
||||
};
|
||||
|
||||
export type FailToFinishReasonFailedToConnect = Reason<FailToFinishReasonType.FailedToConnect>;
|
||||
export type FailToFinishReasonFailedToConnect =
|
||||
Reason<FailToFinishReasonType.FailedToConnect>;
|
||||
|
||||
export type FailToFinishReasonTimedOut = Reason<FailToFinishReasonType.TimedOut>;
|
||||
|
||||
@@ -79,7 +80,8 @@ export type FailToFinishReasonBleError = Reason<FailToFinishReasonType.BleError>
|
||||
err: Error;
|
||||
};
|
||||
|
||||
export type FailToFinishReasonDisconnected = Reason<FailToFinishReasonType.Disconnected>;
|
||||
export type FailToFinishReasonDisconnected =
|
||||
Reason<FailToFinishReasonType.Disconnected>;
|
||||
|
||||
export type FailToFinishReasonHubError = Reason<FailToFinishReasonType.HubError> & {
|
||||
hubError: HubError;
|
||||
@@ -87,24 +89,29 @@ export type FailToFinishReasonHubError = Reason<FailToFinishReasonType.HubError>
|
||||
|
||||
export type FailToFinishReasonNoFirmware = Reason<FailToFinishReasonType.NoFirmware>;
|
||||
|
||||
export type FailToFinishReasonDeviceMismatch = Reason<FailToFinishReasonType.DeviceMismatch>;
|
||||
export type FailToFinishReasonDeviceMismatch =
|
||||
Reason<FailToFinishReasonType.DeviceMismatch>;
|
||||
|
||||
export type FailToFinishReasonFailedToFetch = Reason<FailToFinishReasonType.FailedToFetch> & {
|
||||
response: Response;
|
||||
};
|
||||
export type FailToFinishReasonFailedToFetch =
|
||||
Reason<FailToFinishReasonType.FailedToFetch> & {
|
||||
response: Response;
|
||||
};
|
||||
|
||||
export type FailToFinishReasonZipError = Reason<FailToFinishReasonType.ZipError> & {
|
||||
err: FirmwareReaderError;
|
||||
};
|
||||
|
||||
export type FailToFinishReasonBadMetadata = Reason<FailToFinishReasonType.BadMetadata> & {
|
||||
property: keyof FirmwareMetadata;
|
||||
problem: MetadataProblem;
|
||||
};
|
||||
export type FailToFinishReasonBadMetadata =
|
||||
Reason<FailToFinishReasonType.BadMetadata> & {
|
||||
property: keyof FirmwareMetadata;
|
||||
problem: MetadataProblem;
|
||||
};
|
||||
|
||||
export type FailToFinishReasonFirmwareSize = Reason<FailToFinishReasonType.FirmwareSize>;
|
||||
export type FailToFinishReasonFirmwareSize =
|
||||
Reason<FailToFinishReasonType.FirmwareSize>;
|
||||
|
||||
export type FailToFinishReasonFailedToCompile = Reason<FailToFinishReasonType.FailedToCompile>;
|
||||
export type FailToFinishReasonFailedToCompile =
|
||||
Reason<FailToFinishReasonType.FailedToCompile>;
|
||||
|
||||
export type FailToFinishReasonUnknown = Reason<FailToFinishReasonType.Unknown> & {
|
||||
err: Error;
|
||||
@@ -153,10 +160,11 @@ export function didStart(): FlashFirmwareDidStartAction {
|
||||
}
|
||||
|
||||
/** Action that indicates current firmware flashing progress. */
|
||||
export type FlashFirmwareDidProgressAction = Action<FlashFirmwareActionType.DidProgress> & {
|
||||
/** The current progress (0 to 1). */
|
||||
value: number;
|
||||
};
|
||||
export type FlashFirmwareDidProgressAction =
|
||||
Action<FlashFirmwareActionType.DidProgress> & {
|
||||
/** The current progress (0 to 1). */
|
||||
value: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action that indicates current firmware flashing progress.
|
||||
@@ -176,9 +184,10 @@ export function didFinish(): FlashFirmwareDidFinishAction {
|
||||
}
|
||||
|
||||
/** Action that indicates that flashing failed. */
|
||||
export type FlashFirmwareDidFailToFinishAction = Action<FlashFirmwareActionType.DidFailToFinish> & {
|
||||
reason: FailToFinishReason;
|
||||
};
|
||||
export type FlashFirmwareDidFailToFinishAction =
|
||||
Action<FlashFirmwareActionType.DidFailToFinish> & {
|
||||
reason: FailToFinishReason;
|
||||
};
|
||||
|
||||
export function didFailToFinish(
|
||||
reason: FailToFinishReasonType.BleError,
|
||||
|
||||
+2
-1
@@ -65,7 +65,8 @@ export function didFinishDownload(): HubDidFinishDownloadAction {
|
||||
return { type: HubActionType.DidFinishDownload };
|
||||
}
|
||||
|
||||
export type HubDidFailToFinishDownloadAction = Action<HubActionType.DidFailToFinishDownload>;
|
||||
export type HubDidFailToFinishDownloadAction =
|
||||
Action<HubActionType.DidFailToFinishDownload>;
|
||||
|
||||
export function didFailToFinishDownload(): HubDidFailToFinishDownloadAction {
|
||||
return { type: HubActionType.DidFailToFinishDownload };
|
||||
|
||||
+1
-3
@@ -51,9 +51,7 @@ import {
|
||||
|
||||
const downloadChunkSize = 100;
|
||||
|
||||
function* waitForWrite(
|
||||
id: number,
|
||||
): SagaGenerator<{
|
||||
function* waitForWrite(id: number): SagaGenerator<{
|
||||
didWrite: BleUartDidWriteAction | undefined;
|
||||
didFailToWrite: BleUartDidFailToWriteAction | undefined;
|
||||
}> {
|
||||
|
||||
@@ -25,9 +25,10 @@ export function didFetchList(list: LicenseList): LicenseDidFetchListAction {
|
||||
return { type: LicenseActionType.DidFetchList, list };
|
||||
}
|
||||
|
||||
export type LicenseDidFailToFetchListAction = Action<LicenseActionType.DidFailToFetchList> & {
|
||||
reason: Response;
|
||||
};
|
||||
export type LicenseDidFailToFetchListAction =
|
||||
Action<LicenseActionType.DidFailToFetchList> & {
|
||||
reason: Response;
|
||||
};
|
||||
|
||||
export function didFailToFetchList(reason: Response): LicenseDidFailToFetchListAction {
|
||||
return { type: LicenseActionType.DidFailToFetchList, reason };
|
||||
|
||||
@@ -54,19 +54,22 @@ export enum BootloaderConnectionActionType {
|
||||
DidFailToDisconnect = 'bootloader.action.connection.did.failToDisconnect',
|
||||
}
|
||||
|
||||
export type BootloaderConnectionConnectAction = Action<BootloaderConnectionActionType.Connect>;
|
||||
export type BootloaderConnectionConnectAction =
|
||||
Action<BootloaderConnectionActionType.Connect>;
|
||||
|
||||
export function connect(): BootloaderConnectionConnectAction {
|
||||
return { type: BootloaderConnectionActionType.Connect };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidConnectAction = Action<BootloaderConnectionActionType.DidConnect>;
|
||||
export type BootloaderConnectionDidConnectAction =
|
||||
Action<BootloaderConnectionActionType.DidConnect>;
|
||||
|
||||
export function didConnect(): BootloaderConnectionDidConnectAction {
|
||||
return { type: BootloaderConnectionActionType.DidConnect };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDisconnectAction = Action<BootloaderConnectionActionType.Disconnect>;
|
||||
export type BootloaderConnectionDisconnectAction =
|
||||
Action<BootloaderConnectionActionType.Disconnect>;
|
||||
|
||||
export function disconnect(): BootloaderConnectionDisconnectAction {
|
||||
return { type: BootloaderConnectionActionType.Disconnect };
|
||||
@@ -92,17 +95,22 @@ type Reason<T extends BootloaderConnectionFailureReason> = {
|
||||
reason: T;
|
||||
};
|
||||
|
||||
export type BootloaderConnectionFailToConnectNoWebBluetoothReason = Reason<BootloaderConnectionFailureReason.NoWebBluetooth>;
|
||||
export type BootloaderConnectionFailToConnectNoWebBluetoothReason =
|
||||
Reason<BootloaderConnectionFailureReason.NoWebBluetooth>;
|
||||
|
||||
export type BootloaderConnectionFailToConnectNoBluetoothReason = Reason<BootloaderConnectionFailureReason.NoBluetooth>;
|
||||
export type BootloaderConnectionFailToConnectNoBluetoothReason =
|
||||
Reason<BootloaderConnectionFailureReason.NoBluetooth>;
|
||||
|
||||
export type BootloaderConnectionFailToConnectGattServiceNotFoundReason = Reason<BootloaderConnectionFailureReason.GattServiceNotFound>;
|
||||
export type BootloaderConnectionFailToConnectGattServiceNotFoundReason =
|
||||
Reason<BootloaderConnectionFailureReason.GattServiceNotFound>;
|
||||
|
||||
export type BootloaderConnectionFailToConnectCanceledReason = Reason<BootloaderConnectionFailureReason.Canceled>;
|
||||
export type BootloaderConnectionFailToConnectCanceledReason =
|
||||
Reason<BootloaderConnectionFailureReason.Canceled>;
|
||||
|
||||
export type BootloaderConnectionFailToConnectUnknownReason = Reason<BootloaderConnectionFailureReason.Unknown> & {
|
||||
err: Error;
|
||||
};
|
||||
export type BootloaderConnectionFailToConnectUnknownReason =
|
||||
Reason<BootloaderConnectionFailureReason.Unknown> & {
|
||||
err: Error;
|
||||
};
|
||||
|
||||
export type BootloaderConnectionDidFailToConnectReason =
|
||||
| BootloaderConnectionFailToConnectNoWebBluetoothReason
|
||||
@@ -111,8 +119,9 @@ export type BootloaderConnectionDidFailToConnectReason =
|
||||
| BootloaderConnectionFailToConnectCanceledReason
|
||||
| BootloaderConnectionFailToConnectUnknownReason;
|
||||
|
||||
export type BootloaderConnectionDidFailToConnectAction = Action<BootloaderConnectionActionType.DidFailToConnect> &
|
||||
BootloaderConnectionDidFailToConnectReason;
|
||||
export type BootloaderConnectionDidFailToConnectAction =
|
||||
Action<BootloaderConnectionActionType.DidFailToConnect> &
|
||||
BootloaderConnectionDidFailToConnectReason;
|
||||
|
||||
export function didFailToConnect(
|
||||
reason: Exclude<
|
||||
@@ -140,18 +149,20 @@ export function didFailToConnect(
|
||||
return { type: BootloaderConnectionActionType.DidFailToConnect, reason };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidErrorAction = Action<BootloaderConnectionActionType.DidError> & {
|
||||
err: Error;
|
||||
};
|
||||
export type BootloaderConnectionDidErrorAction =
|
||||
Action<BootloaderConnectionActionType.DidError> & {
|
||||
err: Error;
|
||||
};
|
||||
|
||||
export function didError(err: Error): BootloaderConnectionDidErrorAction {
|
||||
return { type: BootloaderConnectionActionType.DidError, err };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionSendAction = Action<BootloaderConnectionActionType.Send> & {
|
||||
readonly data: ArrayBuffer;
|
||||
readonly withResponse: boolean;
|
||||
};
|
||||
export type BootloaderConnectionSendAction =
|
||||
Action<BootloaderConnectionActionType.Send> & {
|
||||
readonly data: ArrayBuffer;
|
||||
readonly withResponse: boolean;
|
||||
};
|
||||
|
||||
export function send(
|
||||
data: ArrayBuffer,
|
||||
@@ -160,35 +171,40 @@ export function send(
|
||||
return { type: BootloaderConnectionActionType.Send, data, withResponse };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidSendAction = Action<BootloaderConnectionActionType.DidSend>;
|
||||
export type BootloaderConnectionDidSendAction =
|
||||
Action<BootloaderConnectionActionType.DidSend>;
|
||||
|
||||
export function didSend(): BootloaderConnectionDidSendAction {
|
||||
return { type: BootloaderConnectionActionType.DidSend };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidFailToSendAction = Action<BootloaderConnectionActionType.DidFailToSend> & {
|
||||
err: Error;
|
||||
};
|
||||
export type BootloaderConnectionDidFailToSendAction =
|
||||
Action<BootloaderConnectionActionType.DidFailToSend> & {
|
||||
err: Error;
|
||||
};
|
||||
|
||||
export function didFailToSend(err: Error): BootloaderConnectionDidFailToSendAction {
|
||||
return { type: BootloaderConnectionActionType.DidFailToSend, err };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidReceiveAction = Action<BootloaderConnectionActionType.DidReceive> & {
|
||||
data: DataView;
|
||||
};
|
||||
export type BootloaderConnectionDidReceiveAction =
|
||||
Action<BootloaderConnectionActionType.DidReceive> & {
|
||||
data: DataView;
|
||||
};
|
||||
|
||||
export function didReceive(data: DataView): BootloaderConnectionDidReceiveAction {
|
||||
return { type: BootloaderConnectionActionType.DidReceive, data };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidDisconnectAction = Action<BootloaderConnectionActionType.DidDisconnect>;
|
||||
export type BootloaderConnectionDidDisconnectAction =
|
||||
Action<BootloaderConnectionActionType.DidDisconnect>;
|
||||
|
||||
export function didDisconnect(): BootloaderConnectionDidDisconnectAction {
|
||||
return { type: BootloaderConnectionActionType.DidDisconnect };
|
||||
}
|
||||
|
||||
export type BootloaderConnectionDidFailToDisconnectAction = Action<BootloaderConnectionActionType.DidFailToDisconnect>;
|
||||
export type BootloaderConnectionDidFailToDisconnectAction =
|
||||
Action<BootloaderConnectionActionType.DidFailToDisconnect>;
|
||||
|
||||
export function didFailToDisconnect(): BootloaderConnectionDidFailToDisconnectAction {
|
||||
return { type: BootloaderConnectionActionType.DidFailToDisconnect };
|
||||
@@ -234,7 +250,8 @@ type BaseBootloaderRequestAction<T extends BootloaderRequestActionType> = Action
|
||||
/**
|
||||
* Action that requests to erase the flash memory.
|
||||
*/
|
||||
export type BootloaderEraseRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Erase>;
|
||||
export type BootloaderEraseRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Erase>;
|
||||
|
||||
/**
|
||||
* Creates a request to erase the flash memory.
|
||||
@@ -246,10 +263,11 @@ export function eraseRequest(id: number): BootloaderEraseRequestAction {
|
||||
/**
|
||||
* Action that requests to program the flash memory.
|
||||
*/
|
||||
export type BootloaderProgramRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Program> & {
|
||||
address: number;
|
||||
payload: ArrayBuffer;
|
||||
};
|
||||
export type BootloaderProgramRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Program> & {
|
||||
address: number;
|
||||
payload: ArrayBuffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a request to program the flash memory.
|
||||
@@ -272,7 +290,8 @@ export function programRequest(
|
||||
/**
|
||||
* Action that requests to reboot the hub.
|
||||
*/
|
||||
export type BootloaderRebootRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Reboot>;
|
||||
export type BootloaderRebootRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Reboot>;
|
||||
|
||||
/**
|
||||
* Creates a request to reboot the hub.
|
||||
@@ -284,9 +303,10 @@ export function rebootRequest(id: number): BootloaderRebootRequestAction {
|
||||
/**
|
||||
* Action that requests to initialize the firmware flashing process.
|
||||
*/
|
||||
export type BootloaderInitRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Init> & {
|
||||
firmwareSize: number;
|
||||
};
|
||||
export type BootloaderInitRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Init> & {
|
||||
firmwareSize: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a request to initialize the firmware flashing process.
|
||||
@@ -306,7 +326,8 @@ export function initRequest(
|
||||
/**
|
||||
* Action that requests information about the hub.
|
||||
*/
|
||||
export type BootloaderInfoRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Info>;
|
||||
export type BootloaderInfoRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Info>;
|
||||
|
||||
/**
|
||||
* Creates a request to get information about the hub.
|
||||
@@ -319,7 +340,8 @@ export function infoRequest(id: number): BootloaderInfoRequestAction {
|
||||
* Action to get the checksum of the bytes that have been written to flash
|
||||
* so far.
|
||||
*/
|
||||
export type BootloaderChecksumRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Checksum>;
|
||||
export type BootloaderChecksumRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Checksum>;
|
||||
|
||||
/**
|
||||
* Creates a request to get the checksum of the bytes that have been written
|
||||
@@ -332,7 +354,8 @@ export function checksumRequest(id: number): BootloaderChecksumRequestAction {
|
||||
/**
|
||||
* Action that requests the bootloader flash memory protection state.
|
||||
*/
|
||||
export type BootloaderStateRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.State>;
|
||||
export type BootloaderStateRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.State>;
|
||||
|
||||
/**
|
||||
* Creates a request to get the bootloader flash memory protection state.
|
||||
@@ -344,7 +367,8 @@ export function stateRequest(id: number): BootloaderStateRequestAction {
|
||||
/**
|
||||
* Action that requests to disconnect the hub.
|
||||
*/
|
||||
export type BootloaderDisconnectRequestAction = BaseBootloaderRequestAction<BootloaderRequestActionType.Disconnect>;
|
||||
export type BootloaderDisconnectRequestAction =
|
||||
BaseBootloaderRequestAction<BootloaderRequestActionType.Disconnect>;
|
||||
|
||||
/**
|
||||
* Creates a request to disconnect the hub.
|
||||
@@ -407,16 +431,17 @@ export const BootloaderDidFailToRequestType = 'bootloader.action.did.failToReque
|
||||
/**
|
||||
* Action that indicates a request failed to send.
|
||||
*/
|
||||
export type BootloaderDidFailToRequestAction = Action<BootloaderDidFailToRequestType> & {
|
||||
/**
|
||||
* The unique identifier of the action.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The error.
|
||||
*/
|
||||
err: Error;
|
||||
};
|
||||
export type BootloaderDidFailToRequestAction =
|
||||
Action<BootloaderDidFailToRequestType> & {
|
||||
/**
|
||||
* The unique identifier of the action.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The error.
|
||||
*/
|
||||
err: Error;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an action that indicates a request failed to send.
|
||||
@@ -443,18 +468,20 @@ export enum BootloaderResponseActionType {
|
||||
Error = 'bootloader.action.response.error',
|
||||
}
|
||||
|
||||
export type BootloaderEraseResponseAction = Action<BootloaderResponseActionType.Erase> & {
|
||||
result: Result;
|
||||
};
|
||||
export type BootloaderEraseResponseAction =
|
||||
Action<BootloaderResponseActionType.Erase> & {
|
||||
result: Result;
|
||||
};
|
||||
|
||||
export function eraseResponse(result: Result): BootloaderEraseResponseAction {
|
||||
return { type: BootloaderResponseActionType.Erase, result };
|
||||
}
|
||||
|
||||
export type BootloaderProgramResponseAction = Action<BootloaderResponseActionType.Program> & {
|
||||
checksum: number;
|
||||
count: number;
|
||||
};
|
||||
export type BootloaderProgramResponseAction =
|
||||
Action<BootloaderResponseActionType.Program> & {
|
||||
checksum: number;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export function programResponse(
|
||||
checksum: number,
|
||||
@@ -493,25 +520,28 @@ export function infoResponse(
|
||||
};
|
||||
}
|
||||
|
||||
export type BootloaderChecksumResponseAction = Action<BootloaderResponseActionType.Checksum> & {
|
||||
checksum: number;
|
||||
};
|
||||
export type BootloaderChecksumResponseAction =
|
||||
Action<BootloaderResponseActionType.Checksum> & {
|
||||
checksum: number;
|
||||
};
|
||||
|
||||
export function checksumResponse(checksum: number): BootloaderChecksumResponseAction {
|
||||
return { type: BootloaderResponseActionType.Checksum, checksum };
|
||||
}
|
||||
|
||||
export type BootloaderStateResponseAction = Action<BootloaderResponseActionType.State> & {
|
||||
level: ProtectionLevel;
|
||||
};
|
||||
export type BootloaderStateResponseAction =
|
||||
Action<BootloaderResponseActionType.State> & {
|
||||
level: ProtectionLevel;
|
||||
};
|
||||
|
||||
export function stateResponse(level: ProtectionLevel): BootloaderStateResponseAction {
|
||||
return { type: BootloaderResponseActionType.State, level };
|
||||
}
|
||||
|
||||
export type BootloaderErrorResponseAction = Action<BootloaderResponseActionType.Error> & {
|
||||
command: Command;
|
||||
};
|
||||
export type BootloaderErrorResponseAction =
|
||||
Action<BootloaderResponseActionType.Error> & {
|
||||
command: Command;
|
||||
};
|
||||
|
||||
export function errorResponse(command: Command): BootloaderErrorResponseAction {
|
||||
return { type: BootloaderResponseActionType.Error, command };
|
||||
|
||||
@@ -9,7 +9,7 @@ export enum ServiceWorkerActionType {
|
||||
}
|
||||
|
||||
export type ServiceWorkerAction<
|
||||
T extends ServiceWorkerActionType = ServiceWorkerActionType
|
||||
T extends ServiceWorkerActionType = ServiceWorkerActionType,
|
||||
> = Action<T> & {
|
||||
registration: ServiceWorkerRegistration;
|
||||
};
|
||||
|
||||
@@ -39,10 +39,11 @@ export function toggleBoolean(id: SettingId): SettingsToggleBooleanAction {
|
||||
}
|
||||
|
||||
/** Action that indicates setting/storing a setting failed. */
|
||||
export type SettingsDidFailToSetBooleanAction = Action<SettingsActionType.DidFailToSetBoolean> & {
|
||||
id: SettingId;
|
||||
err: Error;
|
||||
};
|
||||
export type SettingsDidFailToSetBooleanAction =
|
||||
Action<SettingsActionType.DidFailToSetBoolean> & {
|
||||
id: SettingId;
|
||||
err: Error;
|
||||
};
|
||||
|
||||
/** Creates an action indicating that setting/storing a setting failed. */
|
||||
export function didFailToSetBoolean(
|
||||
@@ -53,8 +54,8 @@ export function didFailToSetBoolean(
|
||||
}
|
||||
|
||||
/** Action that indicates a stored boolean setting value changed. */
|
||||
export type SettingsDidBooleanChangeAction = Action<SettingsActionType.DidBooleanChange> &
|
||||
SettingInfo<boolean>;
|
||||
export type SettingsDidBooleanChangeAction =
|
||||
Action<SettingsActionType.DidBooleanChange> & SettingInfo<boolean>;
|
||||
|
||||
/** Creates an action that indicates a stored boolean setting value changed. */
|
||||
export function didBooleanChange(
|
||||
|
||||
@@ -5,11 +5,11 @@ import { Store } from 'redux';
|
||||
import StatusBar from './StatusBar';
|
||||
|
||||
it('should prevent browser context menu', () => {
|
||||
const store = ({
|
||||
const store = {
|
||||
getState: jest.fn(),
|
||||
dispatch: jest.fn(),
|
||||
subscribe: jest.fn(),
|
||||
} as unknown) as Store;
|
||||
} as unknown as Store;
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<StatusBar />
|
||||
|
||||
Reference in New Issue
Block a user