diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /shared/apps-common/src/jet/dependencies/host.ts | |
init commit
Diffstat (limited to 'shared/apps-common/src/jet/dependencies/host.ts')
| -rw-r--r-- | shared/apps-common/src/jet/dependencies/host.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/shared/apps-common/src/jet/dependencies/host.ts b/shared/apps-common/src/jet/dependencies/host.ts new file mode 100644 index 0000000..85a03f0 --- /dev/null +++ b/shared/apps-common/src/jet/dependencies/host.ts @@ -0,0 +1,57 @@ +import type { + ClientIdentifier, + Host as NativeHost, + ProcessPlatform, +} from '@jet/environment'; +import type {} from '@jet/engine'; // For ClientIdentifier.Unknown + +export class Host implements NativeHost { + platform: ProcessPlatform = 'web'; + + get osBuild(): never { + throw makeWebDoesNotImplementException('osBuild'); + } + + get deviceModel(): string { + return 'web'; + } + + get devicePhysicalModel(): never { + throw makeWebDoesNotImplementException('devicePhysicalModel'); + } + + get deviceLocalizedModel() { + return ''; + } + + get deviceModelFamily(): never { + throw makeWebDoesNotImplementException('deviceModelFamily'); + } + + get clientIdentifier(): ClientIdentifier { + // We can't directly use the `ClientIdentifier.Unknown` enum member value + // because we cannot access "ambient const enums" with our TypeScript config. + // Enum handling is known to be tough in TypeScript and, for reasons like + // this, they are generally avoided. + // This returns a value defined on this enum by `@jet/engine`'s type definition + return 'unknown' as ClientIdentifier.Unknown; + } + + get clientVersion(): never { + throw makeWebDoesNotImplementException('clientVersion'); + } + + isOSAtLeast( + _majorVersion: number, + _minorVersion: number, + _patchVersion: number, + ): boolean { + return true; + } +} + +export function makeWebDoesNotImplementException(property: keyof NativeHost) { + return new Error( + `\`Host\` property \`${property}\` is not implemented for the "web" platform`, + ); +} |
