@idle-screens/capabilities 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shawn Partridge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @idle-screens/capabilities
2
+
3
+ Device and capability detection plus saver eligibility tiering for idle-screens. Pure decision logic (Node-testable) plus a thin browser detector.
4
+
5
+ See the [idle-screens repository](https://github.com/shaaaaawn/idle-screens) for full documentation.
@@ -0,0 +1,88 @@
1
+ /** Render backends a saver can require, cheapest -> most capable. */
2
+ type Backend = 'css' | 'canvas2d' | 'webgl2' | 'webgpu';
3
+ /** Perf/cost budget class (mirrors a saver manifest's costTier). */
4
+ type CostTier = 'idle' | 'low' | 'medium' | 'high';
5
+ type MotionIntensity = 'calm' | 'moderate' | 'energetic';
6
+ type ReducedMotionFallback = 'static' | 'slow' | 'hide';
7
+ /** Which backends the current device actually provides. */
8
+ interface BackendSupport {
9
+ css: boolean;
10
+ canvas2d: boolean;
11
+ webgl2: boolean;
12
+ webgpu: boolean;
13
+ }
14
+ /**
15
+ * A snapshot of device capabilities. `backends` is always probed; EVERYTHING ELSE is
16
+ * OPTIONAL — deviceMemory / connection.saveData / effectiveType are Chromium-only and
17
+ * absent in Safari/Firefox, so consumers must have a defined "unknown" behavior and
18
+ * these may only ever *lower* a tier, never gate on their absence.
19
+ */
20
+ interface Capabilities {
21
+ backends: BackendSupport;
22
+ reducedMotion?: boolean;
23
+ dpr?: number;
24
+ coarsePointer?: boolean;
25
+ screen?: {
26
+ w: number;
27
+ h: number;
28
+ };
29
+ hardwareConcurrency?: number;
30
+ /** Chromium-only, privacy-capped ladder (0.25..8). Optional refinement. */
31
+ deviceMemoryGb?: number;
32
+ /** Chromium-only. Optional refinement. */
33
+ saveData?: boolean;
34
+ /** Chromium-only (navigator.connection.effectiveType). */
35
+ effectiveType?: string;
36
+ colorScheme?: 'light' | 'dark' | 'no-preference';
37
+ }
38
+ /** Compute-capability tier, independent of the backend availability axis. */
39
+ type CapabilityTier = 'minimal' | 'basic' | 'standard' | 'high';
40
+ /** The subset of a saver manifest the tiering needs (structurally SaverManifest). */
41
+ interface SaverInfo {
42
+ id: string;
43
+ minBackend?: Backend;
44
+ costTier?: CostTier;
45
+ motionIntensity?: MotionIntensity;
46
+ reducedMotionFallback?: ReducedMotionFallback;
47
+ }
48
+ type EligibilityStatus = 'ok' | 'degraded' | 'blocked';
49
+ interface SaverEligibility {
50
+ id: string;
51
+ status: EligibilityStatus;
52
+ /** Human-readable reasons (why blocked / degraded). */
53
+ reasons: string[];
54
+ }
55
+
56
+ /** Does the device provide `min` (or any higher backend, which implies the lower ones)? */
57
+ declare function backendSupported(caps: Capabilities, min?: Backend): boolean;
58
+ /**
59
+ * Compute a compute-capability tier. The BASE comes from the best available backend
60
+ * (the reliable, cross-browser signal). Optional refinements (save-data, low memory,
61
+ * few cores, a small coarse-pointer screen) can only LOWER it — never raise it, and
62
+ * their ABSENCE never lowers it. This keeps non-Chromium devices from being mis-tiered.
63
+ */
64
+ declare function computeTier(caps: Capabilities): CapabilityTier;
65
+ /** Max cost tier a device of this capability tier should run. */
66
+ declare function costBudget(tier: CapabilityTier): CostTier;
67
+ /**
68
+ * Evaluate one saver against a device:
69
+ * - blocked: the device lacks the required backend, the cost exceeds the budget, or
70
+ * reduced-motion is on AND the saver's fallback is 'hide'.
71
+ * - degraded: reduced-motion is on and the saver has a non-hide fallback (it still
72
+ * runs, but statically/slowly) — this RESPECTS the manifest's declared a11y intent
73
+ * rather than blanket-blocking energetic savers.
74
+ * - ok: runs at full fidelity.
75
+ */
76
+ declare function evaluateSaver(saver: SaverInfo, caps: Capabilities): SaverEligibility;
77
+ declare function eligibleSavers(savers: SaverInfo[], caps: Capabilities): SaverEligibility[];
78
+ /** The savers that are not blocked (ok or degraded). */
79
+ declare function playableSavers(savers: SaverInfo[], caps: Capabilities): SaverInfo[];
80
+
81
+ /**
82
+ * Probe real device capabilities. Async so it can `await` the WebGPU adapter (the only
83
+ * honest webgpu check). SSR-safe: with no DOM it returns a minimal css-only snapshot.
84
+ * Every optional field is left `undefined` when the platform doesn't expose it.
85
+ */
86
+ declare function detectCapabilities(): Promise<Capabilities>;
87
+
88
+ export { type Backend, type BackendSupport, type Capabilities, type CapabilityTier, type CostTier, type EligibilityStatus, type MotionIntensity, type ReducedMotionFallback, type SaverEligibility, type SaverInfo, backendSupported, computeTier, costBudget, detectCapabilities, eligibleSavers, evaluateSaver, playableSavers };
package/dist/index.js ADDED
@@ -0,0 +1,151 @@
1
+ // src/tier.ts
2
+ var BACKEND_RANK = { css: 0, canvas2d: 1, webgl2: 2, webgpu: 3 };
3
+ var COST_RANK = { idle: 0, low: 1, medium: 2, high: 3 };
4
+ var TIER_ORDER = ["minimal", "basic", "standard", "high"];
5
+ function backendSupported(caps, min = "css") {
6
+ const need = BACKEND_RANK[min];
7
+ return Object.keys(caps.backends).some(
8
+ (b) => caps.backends[b] && BACKEND_RANK[b] >= need
9
+ );
10
+ }
11
+ function topBackend(caps) {
12
+ let best = "css";
13
+ for (const b of Object.keys(caps.backends)) {
14
+ if (caps.backends[b] && BACKEND_RANK[b] > BACKEND_RANK[best]) best = b;
15
+ }
16
+ return best;
17
+ }
18
+ function step(tier, by) {
19
+ const i = Math.max(0, Math.min(TIER_ORDER.length - 1, TIER_ORDER.indexOf(tier) + by));
20
+ return TIER_ORDER[i];
21
+ }
22
+ function computeTier(caps) {
23
+ const base = topBackend(caps) === "webgpu" ? "high" : topBackend(caps) === "webgl2" ? "standard" : topBackend(caps) === "canvas2d" ? "basic" : "minimal";
24
+ let tier = base;
25
+ if (caps.saveData === true) tier = step(tier, -1);
26
+ if (caps.deviceMemoryGb !== void 0 && caps.deviceMemoryGb < 4) tier = step(tier, -1);
27
+ if (caps.hardwareConcurrency !== void 0 && caps.hardwareConcurrency <= 2) tier = step(tier, -1);
28
+ if (caps.coarsePointer === true && caps.screen && caps.screen.w * caps.screen.h <= 640 * 960) {
29
+ tier = step(tier, -1);
30
+ }
31
+ if (TIER_ORDER.indexOf(tier) > TIER_ORDER.indexOf(base)) tier = base;
32
+ return tier;
33
+ }
34
+ function costBudget(tier) {
35
+ switch (tier) {
36
+ case "high":
37
+ return "high";
38
+ case "standard":
39
+ return "medium";
40
+ case "basic":
41
+ return "low";
42
+ case "minimal":
43
+ default:
44
+ return "idle";
45
+ }
46
+ }
47
+ function affordable(cost, budget) {
48
+ return COST_RANK[cost] <= COST_RANK[budget];
49
+ }
50
+ function evaluateSaver(saver, caps) {
51
+ const reasons = [];
52
+ let status = "ok";
53
+ const block = (r) => {
54
+ status = "blocked";
55
+ reasons.push(r);
56
+ };
57
+ const degrade = (r) => {
58
+ if (status !== "blocked") status = "degraded";
59
+ reasons.push(r);
60
+ };
61
+ const min = saver.minBackend ?? "css";
62
+ if (!backendSupported(caps, min)) block(`needs ${min}, which this device lacks`);
63
+ if (saver.costTier) {
64
+ const budget = costBudget(computeTier(caps));
65
+ if (!affordable(saver.costTier, budget)) {
66
+ block(`cost "${saver.costTier}" exceeds the device budget "${budget}"`);
67
+ }
68
+ }
69
+ if (caps.reducedMotion) {
70
+ const fallback = saver.reducedMotionFallback;
71
+ const movesALot = saver.motionIntensity === "moderate" || saver.motionIntensity === "energetic";
72
+ if (fallback === "hide") {
73
+ block("reduced-motion: this saver hides");
74
+ } else if (movesALot) {
75
+ degrade(`reduced-motion: uses "${fallback ?? "static"}" fallback`);
76
+ }
77
+ }
78
+ return { id: saver.id, status, reasons };
79
+ }
80
+ function eligibleSavers(savers, caps) {
81
+ return savers.map((s) => evaluateSaver(s, caps));
82
+ }
83
+ function playableSavers(savers, caps) {
84
+ return savers.filter((s) => evaluateSaver(s, caps).status !== "blocked");
85
+ }
86
+
87
+ // src/detect.ts
88
+ var hasDoc = typeof document !== "undefined";
89
+ var hasNav = typeof navigator !== "undefined";
90
+ function mm(query) {
91
+ return typeof matchMedia === "function" ? matchMedia(query).matches : false;
92
+ }
93
+ function probeContext(type) {
94
+ if (!hasDoc) return false;
95
+ try {
96
+ const canvas = document.createElement("canvas");
97
+ return canvas.getContext(type) != null;
98
+ } catch {
99
+ return false;
100
+ }
101
+ }
102
+ async function probeWebGpu() {
103
+ const gpu = hasNav ? navigator.gpu : void 0;
104
+ if (!gpu?.requestAdapter) return false;
105
+ try {
106
+ return await gpu.requestAdapter() != null;
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+ function detectBackendsSync() {
112
+ return {
113
+ css: true,
114
+ // if a DOM exists at all, CSS is available
115
+ canvas2d: probeContext("2d"),
116
+ webgl2: probeContext("webgl2"),
117
+ webgpu: false
118
+ // resolved asynchronously by detectCapabilities()
119
+ };
120
+ }
121
+ async function detectCapabilities() {
122
+ if (!hasDoc) {
123
+ return { backends: { css: true, canvas2d: false, webgl2: false, webgpu: false } };
124
+ }
125
+ const backends = detectBackendsSync();
126
+ backends.webgpu = await probeWebGpu();
127
+ const nav = hasNav ? navigator : void 0;
128
+ const colorScheme = mm("(prefers-color-scheme: dark)") ? "dark" : mm("(prefers-color-scheme: light)") ? "light" : "no-preference";
129
+ return {
130
+ backends,
131
+ reducedMotion: mm("(prefers-reduced-motion: reduce)"),
132
+ dpr: typeof devicePixelRatio === "number" ? devicePixelRatio : void 0,
133
+ coarsePointer: mm("(pointer: coarse)"),
134
+ screen: typeof screen !== "undefined" ? { w: screen.width, h: screen.height } : void 0,
135
+ hardwareConcurrency: nav?.hardwareConcurrency,
136
+ deviceMemoryGb: nav?.deviceMemory,
137
+ saveData: nav?.connection?.saveData,
138
+ effectiveType: nav?.connection?.effectiveType,
139
+ colorScheme
140
+ };
141
+ }
142
+ export {
143
+ backendSupported,
144
+ computeTier,
145
+ costBudget,
146
+ detectCapabilities,
147
+ eligibleSavers,
148
+ evaluateSaver,
149
+ playableSavers
150
+ };
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tier.ts","../src/detect.ts"],"sourcesContent":["import type {\n Backend,\n Capabilities,\n CapabilityTier,\n CostTier,\n SaverEligibility,\n SaverInfo,\n} from './types';\n\nconst BACKEND_RANK: Record<Backend, number> = { css: 0, canvas2d: 1, webgl2: 2, webgpu: 3 };\nconst COST_RANK: Record<CostTier, number> = { idle: 0, low: 1, medium: 2, high: 3 };\nconst TIER_ORDER: CapabilityTier[] = ['minimal', 'basic', 'standard', 'high'];\n\n/** Does the device provide `min` (or any higher backend, which implies the lower ones)? */\nexport function backendSupported(caps: Capabilities, min: Backend = 'css'): boolean {\n const need = BACKEND_RANK[min];\n return (Object.keys(caps.backends) as Backend[]).some(\n (b) => caps.backends[b] && BACKEND_RANK[b] >= need,\n );\n}\n\n/** The best backend the device has. */\nfunction topBackend(caps: Capabilities): Backend {\n let best: Backend = 'css';\n for (const b of Object.keys(caps.backends) as Backend[]) {\n if (caps.backends[b] && BACKEND_RANK[b] > BACKEND_RANK[best]) best = b;\n }\n return best;\n}\n\nfunction step(tier: CapabilityTier, by: number): CapabilityTier {\n const i = Math.max(0, Math.min(TIER_ORDER.length - 1, TIER_ORDER.indexOf(tier) + by));\n return TIER_ORDER[i];\n}\n\n/**\n * Compute a compute-capability tier. The BASE comes from the best available backend\n * (the reliable, cross-browser signal). Optional refinements (save-data, low memory,\n * few cores, a small coarse-pointer screen) can only LOWER it — never raise it, and\n * their ABSENCE never lowers it. This keeps non-Chromium devices from being mis-tiered.\n */\nexport function computeTier(caps: Capabilities): CapabilityTier {\n const base: CapabilityTier =\n topBackend(caps) === 'webgpu'\n ? 'high'\n : topBackend(caps) === 'webgl2'\n ? 'standard'\n : topBackend(caps) === 'canvas2d'\n ? 'basic'\n : 'minimal';\n\n let tier = base;\n if (caps.saveData === true) tier = step(tier, -1);\n if (caps.deviceMemoryGb !== undefined && caps.deviceMemoryGb < 4) tier = step(tier, -1);\n if (caps.hardwareConcurrency !== undefined && caps.hardwareConcurrency <= 2) tier = step(tier, -1);\n // Small mobile screens (coarse pointer + little area) tend to have weaker GPUs.\n if (caps.coarsePointer === true && caps.screen && caps.screen.w * caps.screen.h <= 640 * 960) {\n tier = step(tier, -1);\n }\n // Never exceed what the backend can actually do.\n if (TIER_ORDER.indexOf(tier) > TIER_ORDER.indexOf(base)) tier = base;\n return tier;\n}\n\n/** Max cost tier a device of this capability tier should run. */\nexport function costBudget(tier: CapabilityTier): CostTier {\n switch (tier) {\n case 'high':\n return 'high';\n case 'standard':\n return 'medium';\n case 'basic':\n return 'low';\n case 'minimal':\n default:\n return 'idle';\n }\n}\n\nfunction affordable(cost: CostTier, budget: CostTier): boolean {\n return COST_RANK[cost] <= COST_RANK[budget];\n}\n\n/**\n * Evaluate one saver against a device:\n * - blocked: the device lacks the required backend, the cost exceeds the budget, or\n * reduced-motion is on AND the saver's fallback is 'hide'.\n * - degraded: reduced-motion is on and the saver has a non-hide fallback (it still\n * runs, but statically/slowly) — this RESPECTS the manifest's declared a11y intent\n * rather than blanket-blocking energetic savers.\n * - ok: runs at full fidelity.\n */\nexport function evaluateSaver(saver: SaverInfo, caps: Capabilities): SaverEligibility {\n const reasons: string[] = [];\n let status: SaverEligibility['status'] = 'ok';\n const block = (r: string): void => {\n status = 'blocked';\n reasons.push(r);\n };\n const degrade = (r: string): void => {\n if (status !== 'blocked') status = 'degraded';\n reasons.push(r);\n };\n\n const min = saver.minBackend ?? 'css';\n if (!backendSupported(caps, min)) block(`needs ${min}, which this device lacks`);\n\n if (saver.costTier) {\n const budget = costBudget(computeTier(caps));\n if (!affordable(saver.costTier, budget)) {\n block(`cost \"${saver.costTier}\" exceeds the device budget \"${budget}\"`);\n }\n }\n\n if (caps.reducedMotion) {\n const fallback = saver.reducedMotionFallback;\n const movesALot = saver.motionIntensity === 'moderate' || saver.motionIntensity === 'energetic';\n if (fallback === 'hide') {\n block('reduced-motion: this saver hides');\n } else if (movesALot) {\n // moderate/energetic savers run, but in their reduced form — calm savers are\n // left fully eligible even if they declare a (no-op) fallback.\n degrade(`reduced-motion: uses \"${fallback ?? 'static'}\" fallback`);\n }\n }\n\n return { id: saver.id, status, reasons };\n}\n\nexport function eligibleSavers(savers: SaverInfo[], caps: Capabilities): SaverEligibility[] {\n return savers.map((s) => evaluateSaver(s, caps));\n}\n\n/** The savers that are not blocked (ok or degraded). */\nexport function playableSavers(savers: SaverInfo[], caps: Capabilities): SaverInfo[] {\n return savers.filter((s) => evaluateSaver(s, caps).status !== 'blocked');\n}\n","import type { BackendSupport, Capabilities } from './types';\n\nconst hasDoc = typeof document !== 'undefined';\nconst hasNav = typeof navigator !== 'undefined';\n\nfunction mm(query: string): boolean {\n return typeof matchMedia === 'function' ? matchMedia(query).matches : false;\n}\n\nfunction probeContext(type: '2d' | 'webgl2'): boolean {\n if (!hasDoc) return false;\n try {\n // A canvas can only ever hold ONE context type, so probe each on a FRESH canvas.\n const canvas = document.createElement('canvas');\n return canvas.getContext(type) != null;\n } catch {\n return false;\n }\n}\n\nasync function probeWebGpu(): Promise<boolean> {\n // `'gpu' in navigator` is a false positive — an adapter can still be null/blocklisted.\n const gpu = (hasNav ? (navigator as unknown as { gpu?: { requestAdapter?: () => Promise<unknown> } }).gpu : undefined);\n if (!gpu?.requestAdapter) return false;\n try {\n return (await gpu.requestAdapter()) != null;\n } catch {\n return false;\n }\n}\n\nfunction detectBackendsSync(): BackendSupport {\n return {\n css: true, // if a DOM exists at all, CSS is available\n canvas2d: probeContext('2d'),\n webgl2: probeContext('webgl2'),\n webgpu: false, // resolved asynchronously by detectCapabilities()\n };\n}\n\n/**\n * Probe real device capabilities. Async so it can `await` the WebGPU adapter (the only\n * honest webgpu check). SSR-safe: with no DOM it returns a minimal css-only snapshot.\n * Every optional field is left `undefined` when the platform doesn't expose it.\n */\nexport async function detectCapabilities(): Promise<Capabilities> {\n if (!hasDoc) {\n return { backends: { css: true, canvas2d: false, webgl2: false, webgpu: false } };\n }\n const backends = detectBackendsSync();\n backends.webgpu = await probeWebGpu();\n\n const nav = hasNav ? (navigator as unknown as {\n hardwareConcurrency?: number;\n deviceMemory?: number;\n connection?: { saveData?: boolean; effectiveType?: string };\n }) : undefined;\n\n const colorScheme = mm('(prefers-color-scheme: dark)')\n ? 'dark'\n : mm('(prefers-color-scheme: light)')\n ? 'light'\n : 'no-preference';\n\n return {\n backends,\n reducedMotion: mm('(prefers-reduced-motion: reduce)'),\n dpr: typeof devicePixelRatio === 'number' ? devicePixelRatio : undefined,\n coarsePointer: mm('(pointer: coarse)'),\n screen: typeof screen !== 'undefined' ? { w: screen.width, h: screen.height } : undefined,\n hardwareConcurrency: nav?.hardwareConcurrency,\n deviceMemoryGb: nav?.deviceMemory,\n saveData: nav?.connection?.saveData,\n effectiveType: nav?.connection?.effectiveType,\n colorScheme,\n };\n}\n"],"mappings":";AASA,IAAM,eAAwC,EAAE,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,EAAE;AAC1F,IAAM,YAAsC,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AAmB;AAAA,IACrC,QAAQ,OAAO,WAAW,cAAc,EAAE,GAAG,OAAO,OAAO,GAAG,OAAO,OAAO,IAAI;AAAA,IAChF,qBAAqB,KAAK;AAAA,IAC1B,gBAAgB,KAAK;AAAA,IACrB,UAAU,KAAK,YAAY;AAAA,IAC3B,eAAe,KAAK,YAAY;AAAA,IAChC;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@idle-screens/capabilities",
3
+ "version": "0.1.0",
4
+ "description": "Device & capability detection + saver eligibility tiering for idle-screens. Pure decide (Node-testable) + a thin browser detector.",
5
+ "license": "MIT",
6
+ "author": "Shawn Partridge",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/shaaaaawn/idle-screens",
10
+ "directory": "packages/capabilities"
11
+ },
12
+ "homepage": "https://github.com/shaaaaawn/idle-screens#readme",
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "keywords": [
28
+ "screensaver",
29
+ "idle",
30
+ "capabilities",
31
+ "device-detection",
32
+ "webgl",
33
+ "webgpu"
34
+ ],
35
+ "bugs": {
36
+ "url": "https://github.com/shaaaaawn/idle-screens/issues"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "scripts": {
42
+ "build": "tsup",
43
+ "dev": "tsup --watch",
44
+ "typecheck": "tsc --noEmit",
45
+ "lint": "eslint src"
46
+ }
47
+ }