Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 70 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@codemirror/view": "^6.26.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@microbit/microbit-connection": "^0.0.0-alpha.36",
"@microbit/microbit-connection": "^0.9.0-apps.alpha.17",
"@microbit/microbit-fs": "^0.10.0",
"@sanity/block-content-to-react": "^3.0.0",
"@sanity/image-url": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "./App.css";
import { DialogProvider } from "./common/use-dialogs";
import VisualViewPortCSSVariables from "./common/VisualViewportCSSVariables";
import { deployment, useDeployment } from "./deployment";
import { createWebUSBConnection } from "@microbit/microbit-connection";
import { createUSBConnection } from "@microbit/microbit-connection/usb";
import { DeviceContextProvider } from "./device/device-hooks";
import { MockDeviceConnection } from "./device/mock";
import DocumentationProvider from "./documentation/documentation-hooks";
Expand Down Expand Up @@ -40,7 +40,7 @@ const isMockDeviceMode = () =>
const logging = deployment.logging;
const device = isMockDeviceMode()
? new MockDeviceConnection()
: createWebUSBConnection({ logging });
: createUSBConnection({ logging });

const host = createHost(logging);
const fs = new FileSystem(logging, host, fetchMicroPython);
Expand Down
13 changes: 9 additions & 4 deletions src/common/ProgressDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const doNothing = () => {};
export interface ProgressDialogParameters {
header: ReactNode;
body?: ReactNode;
progress: number | undefined;
progress?: number;
}

interface ProgressDialogProps extends ProgressDialogParameters {
Expand All @@ -29,10 +29,15 @@ interface ProgressDialogProps extends ProgressDialogParameters {
/**
* A progress dialog used for the flashing process.
*/
const ProgressDialog = ({ header, body, progress }: ProgressDialogProps) => {
const ProgressDialog = ({
isOpen,
header,
body,
progress,
}: ProgressDialogProps) => {
return (
<Modal
isOpen={progress !== undefined}
isOpen={isOpen}
onClose={doNothing}
isCentered
size={body ? "xl" : "md"}
Expand All @@ -53,7 +58,7 @@ const ProgressDialog = ({ header, body, progress }: ProgressDialogProps) => {
alignItems="flex-start"
>
{body}
<Progress value={progress! * 100} width="100%" />
<Progress value={(progress ?? 0) * 100} width="100%" />
</VStack>
</ModalBody>
</ModalContent>
Expand Down
10 changes: 5 additions & 5 deletions src/common/use-dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export class Dialogs {
}

progress(options: ProgressDialogParameters): void {
if (options.progress === undefined) {
this.progressDialogSetState(undefined);
} else {
this.progressDialogSetState(options);
}
this.progressDialogSetState(options);
}

closeProgress(): void {
this.progressDialogSetState(undefined);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/deployment/default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { ReactNode, createContext } from "react";
import { CookieConsent, DeploymentConfigFactory } from "..";
import { NullLogging } from "./logging";
import { ConsoleLogging } from "./logging";
import theme from "./theme";

const stubConsentValue: CookieConsent = {
Expand All @@ -20,7 +20,7 @@ const defaultDeploymentFactory: DeploymentConfigFactory = () => ({
chakraTheme: theme,
// This isn't ideal as it's the branded version. You can just remove the field to remove the welcome dialog.
welcomeVideoYouTubeId: "mREwMW69qKc",
logging: new NullLogging(),
logging: new ConsoleLogging(),
compliance: {
ConsentProvider: ({ children }: { children: ReactNode }) => (
<stubConsentContext.Provider value={stubConsentValue}>
Expand Down
14 changes: 10 additions & 4 deletions src/deployment/default/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
*/
import { Event, Logging } from "../../logging/logging";

export class NullLogging implements Logging {
event(_event: Event): void {}
error(_e: any): void {}
log(_e: any): void {}
export class ConsoleLogging implements Logging {
event(event: Event): void {
console.log(event);
}
error(e: any): void {
console.error(e);
}
log(e: any): void {
console.log(e);
}
}
16 changes: 9 additions & 7 deletions src/device/device-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { useFileSystem } from "../fs/fs-hooks";
import { useLogging } from "../logging/logging-hooks";
import {
ConnectionStatus,
MicrobitWebUSBConnection,
SerialDataEvent,
ConnectionStatusEvent,
ConnectionStatusChange,
} from "@microbit/microbit-connection";
import {
MicrobitUSBConnection,
SerialData,
} from "@microbit/microbit-connection/usb";
import { SimulatorDeviceConnection } from "./simulator";

const DeviceContext = React.createContext<undefined | MicrobitWebUSBConnection>(
const DeviceContext = React.createContext<undefined | MicrobitUSBConnection>(
undefined
);

Expand Down Expand Up @@ -56,7 +58,7 @@ export const useConnectionStatus = () => {
const device = useDevice();
const [status, setStatus] = useState<ConnectionStatus>(device.status);
useEffect(() => {
const statusListener = (event: ConnectionStatusEvent) => {
const statusListener = (event: ConnectionStatusChange) => {
setStatus(event.status);
};
device.addEventListener("status", statusListener);
Expand Down Expand Up @@ -185,7 +187,7 @@ export const useDeviceTraceback = () => {

useEffect(() => {
const buffer = new TracebackScrollback();
const dataListener = (event: SerialDataEvent) => {
const dataListener = (event: SerialData) => {
const latest = buffer.push(event.data);
setRuntimeError((current) => {
if (!current && latest) {
Expand Down Expand Up @@ -234,7 +236,7 @@ export const DeviceContextProvider = ({
value: device,
children,
}: {
value: MicrobitWebUSBConnection;
value: MicrobitUSBConnection;
children: ReactNode;
}) => {
const syncStatusState = useState<SyncStatus>(SyncStatus.OUT_OF_SYNC);
Expand Down
Loading