-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
253 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { AppItem } from "../../api/banglejs/interface"; | ||
|
||
export const EspruinoComms: typeof Comms = { | ||
// write: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// showMessage: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// showUploadFinished: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// getProgressCmd: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// reset: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// uploadCommandList: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
uploadApp: (...args) => { | ||
return Comms.uploadApp(...args) | ||
}, | ||
getDeviceInfo: (...args) => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
console.log(Comms); | ||
return Comms.getDeviceInfo(...args) | ||
}, | ||
// getAppInfo: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// removeApp: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// removeAllApps: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// setTime: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// resetDevice: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
isConnected: () => { | ||
return Comms.isConnected() | ||
}, | ||
// disconnectDevice: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// watchConnectionChange: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// listFiles: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// readTextBlock: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// readFile: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// readStorageFile: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// writeFile: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// handlers: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
// on: () => { | ||
// throw new Error("not implemented"); | ||
// }, | ||
}; | ||
|
||
|
||
declare const Comms: { | ||
uploadApp: (app: AppItem, options: { | ||
/** | ||
* object of translations, eg 'lang/de_DE.json' | ||
*/ | ||
language?: { | ||
/** | ||
* Translations that apply for all apps | ||
*/ | ||
GLOBAL: undefined | { | ||
[key: string]: string | ||
} | ||
/** | ||
* App-specific overrides | ||
*/ | ||
[appId: string]: undefined | { | ||
[key: string]: string | ||
} | ||
}; | ||
/** | ||
* { id : ..., version : ... } info about the currently connected device | ||
*/ | ||
device: { | ||
id: string; | ||
appsInstalled: InstalledApp[]; | ||
version: string; | ||
exptr: number; | ||
}; | ||
/** | ||
* if true, showUploadFinished isn't called (displaying the reboot message) | ||
* @default false | ||
*/ | ||
noFinish?: boolean; | ||
/** | ||
* if true, don't reset the device before | ||
* | ||
* @default false | ||
* | ||
* reset to ensure we have enough memory to upload what we need to | ||
*/ | ||
noReset?: boolean; | ||
}) => Promise<void | unknown>; | ||
getDeviceInfo: (noReset?: boolean) => Promise<{ | ||
apps: InstalledApp[]; | ||
/** | ||
* @example 1708008913000 | ||
*/ | ||
currentTime: number; | ||
/** | ||
* @example 495324 | ||
*/ | ||
exptr: number; | ||
/** | ||
* @example "BANGLEJS2" | ||
*/ | ||
id: string; | ||
/** | ||
* @example 3533326687 | ||
*/ | ||
uid: number; | ||
/** | ||
* @example "2v21" | ||
*/ | ||
version: string; | ||
}> | ||
isConnected: () => boolean; | ||
}; | ||
|
||
interface InstalledApp { | ||
/** | ||
* @example "synthwave.info,synthwave.app.js,synthwave.img" | ||
*/ | ||
files: string; | ||
/** | ||
* @example "synthwave" | ||
*/ | ||
id: string; | ||
/** | ||
* @example "clock" | ||
*/ | ||
type: string; | ||
/** | ||
* @example "0.01" | ||
*/ | ||
version: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import toast, { Toaster } from 'react-hot-toast'; | ||
|
||
interface Progress { | ||
show: ( | ||
options: { | ||
title: string; | ||
domElement?: never; | ||
sticky?: boolean; | ||
interval?: number; | ||
percent?: number; | ||
min?: number; | ||
max?: number; | ||
} | ||
) => void; | ||
hide: ( | ||
options: { | ||
sticky?: boolean, | ||
} | ||
) => void; | ||
} | ||
|
||
const augmentedWindow = window as unknown as { Progress: Progress }; | ||
const GLOBAL_PROGRESS_ID = "GLOBAL_PROGRESS_ID"; | ||
|
||
augmentedWindow.Progress = Object.defineProperties(Object.create(null), { | ||
show: { | ||
get: (): Progress["show"] => (options) => { | ||
console.log("showing toast"); | ||
toast(options.title, { | ||
id: GLOBAL_PROGRESS_ID, | ||
position: "bottom-left", | ||
}) | ||
}, | ||
configurable: false, | ||
}, | ||
hide: { | ||
get: (): Progress["hide"] => (options) => { | ||
console.log("hiding toast"); | ||
if (options.sticky) { | ||
toast.dismiss(GLOBAL_PROGRESS_ID); | ||
} | ||
}, | ||
configurable: false, | ||
}, | ||
}); | ||
|
||
export const GlobalProgressToaster = () => { | ||
return <Toaster /> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters