From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- shared/apps-common/src/jet/dependencies/host.ts | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 shared/apps-common/src/jet/dependencies/host.ts (limited to 'shared/apps-common/src/jet/dependencies/host.ts') 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`, + ); +} -- cgit v1.2.3