this repo has no description
at main 57 lines 1.7 kB view raw
1import type { 2 ClientIdentifier, 3 Host as NativeHost, 4 ProcessPlatform, 5} from '@jet/environment'; 6import type {} from '@jet/engine'; // For ClientIdentifier.Unknown 7 8export class Host implements NativeHost { 9 platform: ProcessPlatform = 'web'; 10 11 get osBuild(): never { 12 throw makeWebDoesNotImplementException('osBuild'); 13 } 14 15 get deviceModel(): string { 16 return 'web'; 17 } 18 19 get devicePhysicalModel(): never { 20 throw makeWebDoesNotImplementException('devicePhysicalModel'); 21 } 22 23 get deviceLocalizedModel() { 24 return ''; 25 } 26 27 get deviceModelFamily(): never { 28 throw makeWebDoesNotImplementException('deviceModelFamily'); 29 } 30 31 get clientIdentifier(): ClientIdentifier { 32 // We can't directly use the `ClientIdentifier.Unknown` enum member value 33 // because we cannot access "ambient const enums" with our TypeScript config. 34 // Enum handling is known to be tough in TypeScript and, for reasons like 35 // this, they are generally avoided. 36 // This returns a value defined on this enum by `@jet/engine`'s type definition 37 return 'unknown' as ClientIdentifier.Unknown; 38 } 39 40 get clientVersion(): never { 41 throw makeWebDoesNotImplementException('clientVersion'); 42 } 43 44 isOSAtLeast( 45 _majorVersion: number, 46 _minorVersion: number, 47 _patchVersion: number, 48 ): boolean { 49 return true; 50 } 51} 52 53export function makeWebDoesNotImplementException(property: keyof NativeHost) { 54 return new Error( 55 `\`Host\` property \`${property}\` is not implemented for the "web" platform`, 56 ); 57}