|
| 1 | +/** |
| 2 | + * @fileoverview |
| 3 | + * Defines extra APIs that exist in real web browsers but that are missing from TypeScript's default types. |
| 4 | + */ |
| 5 | + |
| 6 | +interface Element { |
| 7 | + /** |
| 8 | + * requestFullscreen() but available in Safari. |
| 9 | + */ |
| 10 | + webkitRequestFullscreen?(): unknown; |
| 11 | +} |
| 12 | + |
| 13 | +interface Document { |
| 14 | + /** |
| 15 | + * exitFullscreen() but available in Safari. |
| 16 | + */ |
| 17 | + webkitExitFullscreen?(): unknown; |
| 18 | + /** |
| 19 | + * fullscreenElement but available in Safari. |
| 20 | + */ |
| 21 | + webkitFullscreenElement?: Element; |
| 22 | +} |
| 23 | + |
| 24 | +/** |
| 25 | + * https://developer.mozilla.org/en-US/docs/Web/API/NDEFReader |
| 26 | + */ |
| 27 | +declare class NDEFReader extends EventTarget { |
| 28 | + constructor(); |
| 29 | + scan(options?: { signal?: AbortSignal }): Promise<void>; |
| 30 | + onreading?(event: Event & { message: NDEFMessage }): void; |
| 31 | + onreadingerror?(event: Event): void; |
| 32 | +} |
| 33 | + |
| 34 | +type TypedArray = |
| 35 | + | Uint8Array |
| 36 | + | Int8Array |
| 37 | + | Uint16Array |
| 38 | + | Int16Array |
| 39 | + | Uint32Array |
| 40 | + | Int32Array |
| 41 | + | BigUint64Array |
| 42 | + | BigInt64Array; |
| 43 | + |
| 44 | +/** |
| 45 | + * https://developer.mozilla.org/en-US/docs/Web/API/NDEFMessage/NDEFMessage |
| 46 | + */ |
| 47 | +declare class NDEFMessage { |
| 48 | + constructor( |
| 49 | + records: Array<{ |
| 50 | + data?: string | ArrayBuffer | TypedArray | DataView | NDEFRecord[]; |
| 51 | + encoding?: string; |
| 52 | + id?: string; |
| 53 | + lang?: string; |
| 54 | + mediaType?: string; |
| 55 | + recordType?: string; |
| 56 | + }> |
| 57 | + ); |
| 58 | + readonly records: NDEFRecord[]; |
| 59 | +} |
| 60 | + |
| 61 | +/** |
| 62 | + * https://developer.mozilla.org/en-US/docs/Web/API/NDEFRecord |
| 63 | + */ |
| 64 | +declare class NDEFRecord { |
| 65 | + constructor(); |
| 66 | + readonly recordType: string; |
| 67 | + readonly mediaType: string; |
| 68 | + readonly id: string; |
| 69 | + readonly data: DataView; |
| 70 | + readonly encoding: string | null; |
| 71 | + readonly lang: string | null; |
| 72 | + toRecords(): NDEFRecord[]; |
| 73 | +} |
| 74 | + |
| 75 | +interface NetworkInformation { |
| 76 | + downlink: number; |
| 77 | + downlinkMax: number; |
| 78 | + effectiveType: string; |
| 79 | + rtt: number; |
| 80 | + saveData: boolean; |
| 81 | + type: |
| 82 | + | "bluetooth" |
| 83 | + | "cellular" |
| 84 | + | "ethernet" |
| 85 | + | "none" |
| 86 | + | "wifi" |
| 87 | + | "wimax" |
| 88 | + | "other" |
| 89 | + | "unknown"; |
| 90 | +} |
| 91 | + |
| 92 | +interface Navigator { |
| 93 | + connection?: NetworkInformation; |
| 94 | +} |
| 95 | + |
| 96 | +declare namespace Scratch.extensions { |
| 97 | + /** |
| 98 | + * Most extensions fail the type checking of @turbowarp/types-tw's default register(). |
| 99 | + * That error generally isn't very useful - so for now we'll just add this overload so |
| 100 | + * that those errors don't appear. |
| 101 | + */ |
| 102 | + function register(extensionObj: any): void; |
| 103 | +} |
0 commit comments