
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
@device-router/types
Advanced tools
Core types, device classification, and rendering hint derivation for DeviceRouter
Type definitions, device classification, and rendering hint derivation for DeviceRouter.
pnpm add @device-router/types
import { classify } from '@device-router/types';
const tiers = classify({
hardwareConcurrency: 8,
deviceMemory: 8,
connection: { effectiveType: '4g', downlink: 50 },
gpuRenderer: 'ANGLE (Apple, Apple M2 Pro, OpenGL 4.1)',
});
// { cpu: 'high', memory: 'high', connection: 'fast', gpu: 'high' }
import { classify, deriveHints } from '@device-router/types';
const tiers = classify(signals);
const hints = deriveHints(tiers, signals);
// {
// deferHeavyComponents: false,
// serveMinimalCSS: false,
// reduceAnimations: false,
// useImagePlaceholders: false,
// disableAutoplay: false,
// preferServerRendering: false,
// disable3dEffects: false,
// }
Rendering hints are derived from tiers and transient signals:
| Hint | When true |
|---|---|
deferHeavyComponents | Low-end device, slow connection, or low battery |
serveMinimalCSS | Low-end device |
reduceAnimations | Low-end device, prefers reduced motion, or low battery |
useImagePlaceholders | Slow connection (2G/3G) |
disableAutoplay | Low-end device, slow connection, or low battery |
preferServerRendering | Low-end device |
disable3dEffects | No GPU or software renderer |
The battery signal bypasses tier classification — it's transient state, not a capability. When unplugged and below 15% charge, power-sensitive hints are forced on.
Override default tier boundaries:
import { classify } from '@device-router/types';
const tiers = classify(signals, {
cpu: { lowUpperBound: 4, midUpperBound: 8 },
memory: { midUpperBound: 8 },
connection: { downlink4gUpperBound: 10 },
gpu: { highEndPattern: /\bRTX\b|\bGTX\b/i },
});
Thresholds are validated automatically by createDeviceRouter(). For standalone usage with classify(), call validateThresholds() explicitly:
import { validateThresholds } from '@device-router/types';
validateThresholds({
cpu: { lowUpperBound: 4, midUpperBound: 8 },
}); // OK
validateThresholds({
cpu: { lowUpperBound: 10, midUpperBound: 2 },
}); // throws Error
import { isValidSignals } from '@device-router/types';
if (isValidSignals(requestBody)) {
// requestBody is typed as RawSignals
}
| Dimension | Low | Mid | High/Fast |
|---|---|---|---|
| CPU | 1-2 cores | 3-4 cores | 5+ cores |
| Memory | <=2 GB | 2-4 GB | >4 GB |
| Connection | 2G | 3G / slow 4G | Fast 4G+ (>=5 Mbps) |
| GPU | Software renderer | Mid-range | RTX, RX 5000+, Apple M-series |
classify(signals, thresholds?) — Classify raw signals into DeviceTiersclassifyCpu(hardwareConcurrency?, thresholds?) — CPU tierclassifyMemory(deviceMemory?, thresholds?) — Memory tierclassifyConnection(effectiveType?, downlink?, thresholds?) — Connection tierclassifyGpu(renderer?, thresholds?) — GPU tierderiveHints(tiers, signals?) — Derive RenderingHints from tiers and signalsvalidateThresholds(thresholds) — Validate custom thresholds (called automatically by middleware)isValidSignals(body) — Type guard for RawSignalsisBotSignals(signals) — Detect bot/crawler/headless browser probe submissionsclassifyFromHeaders(headers) — Classify from UA/Client Hints headersresolveFallback(fallback) — Resolve a fallback profile preset or custom tiersCONSERVATIVE_TIERS — Low-end device tier presetOPTIMISTIC_TIERS — High-end device tier presetACCEPT_CH_VALUE — Accept-CH header value for requesting Client HintsRawSignals — Browser-collected device signalsDeviceTiers — Classified capability tiers (cpu, memory, connection, gpu)RenderingHints — Boolean rendering decisionsDeviceProfile — Full profile with schema version, session token, timestamps, and signalsClassifiedProfile — Profile + tiers + hints + sourceProfileSource — 'probe' | 'headers' | 'fallback'FallbackProfile — 'conservative' | 'optimistic' | DeviceTiersTierThresholds — Custom threshold configurationCpuTier, MemoryTier, ConnectionTier, GpuTier — Individual tier typesMIT
FAQs
Core types, device classification, and rendering hint derivation for DeviceRouter
The npm package @device-router/types receives a total of 1 weekly downloads. As such, @device-router/types popularity was classified as not popular.
We found that @device-router/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.