Files
rea/src/domain/apple/applePlatforms.ts
T
Kaoru0822andClaude Opus 5.5 3b4969e3dc Merge branch 'feat/dylib-resolution' into feat/dyld-shared-cache
Carry #952's Apple ownership into the cache work: the cache reader and
fixture move to src/artifacts/apple/, the cache facts, platforms and
resolution schema to src/domain/apple/, the cache service to
src/application/apple/, and the lane to scripts/verify/apple/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:32:48 +00:00

36 lines
981 B
TypeScript

import { z } from "zod";
/** `PLATFORM_*` values from Apple's `mach-o/loader.h`. */
const APPLE_PLATFORM_NAMES: Readonly<Record<number, string>> = {
1: "macos",
2: "ios",
3: "tvos",
4: "watchos",
5: "bridgeos",
6: "maccatalyst",
7: "ios-simulator",
8: "tvos-simulator",
9: "watchos-simulator",
10: "driverkit",
11: "visionos",
12: "visionos-simulator",
};
/** A reported platform number and its `loader.h` name, when known. */
export const applePlatformSchema = z.strictObject({
id: z.number().int(),
name: z.string().nullable(),
});
export type ApplePlatform = z.infer<typeof applePlatformSchema>;
/** Name a reported platform number without discarding unknown values. */
export const applePlatform = (id: number): ApplePlatform => ({
id,
name: APPLE_PLATFORM_NAMES[id] ?? null,
});
/** Display one platform, falling back to its number. */
export const applePlatformLabel = ({ id, name }: ApplePlatform): string =>
name ?? `platform ${id}`;