MockFrame is a pnpm workspace monorepo with two packages.
src/index.ts— re-exports the public API fromMockFrame.tsx.src/MockFrame.tsx—MockFrame(predefined devices) andCustomMockFrame(configurable bezel/radius/colors). Per-device "anatomy" (notch, dynamic island, antennas, shadows) is rendered via theDeviceAnatomy/DevicePostAnatomylookup maps.src/DeviceOptions.ts— the single source of truth: onedefineDevice(...)entry per device (CSS class, colors, landscape support, default size). TheMockFramePropsdiscriminated union is generated from this object.src/helper.ts— TypeScript utilities (KeysOfType,OmitFieldByType,OptionField,Compute) that turnDeviceOptionsinto type-safe props:coloris required only for devices that have colors;landscapeexists only for devices that support it.css/mockframe.css— nested source CSS (adapted from Marvel devices.css).scripts/—build-css.js(lightningcss → expanded + minified, with the nesting down-compiled for older browsers),build-css-modules.js(splits the CSS into per-family bundles; the build fails if a device inDeviceOptionshas no family or no CSS block),gen-readme.js(copies the root README into the package before publish).
Build: tsup emits CJS + ESM + .d.ts; lightningcss emits the stylesheets.
Vite + React + Tailwind v4 single-page app. Imports the library from source via
a Vite alias; imports the built CSS from ../package/dist/styles.
Vitest (jsdom) for render tests; expectTypeOf + @ts-expect-error JSX type
tests guard the discriminated-union API. Run with
pnpm --filter react-mockframe test (runtime + typecheck in one pass).