This file contains hidden or 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
| /** | |
| * Async generator that yields the MacBook lid tilt angle, | |
| * but only when the angle changes (debounced). | |
| * If the device is unavailable, it yields 0 once and stops. | |
| * | |
| * @returns {AsyncGenerator<number, void, unknown>} | |
| */ | |
| async function* getMacBookTilt() { | |
| /** @type {HIDDevice | undefined} */ | |
| let device; |
This file contains hidden or 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
| { | |
| "deno.enable": true, | |
| "deno.lint": true, | |
| "editor.formatOnSave": true, | |
| "[typescript]": { | |
| "editor.defaultFormatter": "denoland.vscode-deno" | |
| }, | |
| "typescript.tsserver.experimental.enableProjectDiagnostics": false | |
| } |
This file contains hidden or 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
| export async function open_file({ accept }: { accept?: string }): Promise<File> { | |
| const input = document.createElement('input'); | |
| input.type = 'file'; | |
| if (accept) input.accept = accept; | |
| input.click(); | |
| return new Promise((resolve, reject) => { | |
| input.onchange = () => { | |
| const file_handle = input.files?.[0]; |