@flighthq/device 0.4.0-next.1920.b93ad0f → 0.4.0-next.1932.1ef883a

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.
Files changed (3) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +10 -97
  3. package/package.json +3 -3
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2013-2026 Joshua Granick and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,104 +1,17 @@
1
1
  # @flighthq/device
2
2
 
3
- Device identity, hardware, and safe-area insets over a swappable web/native backend.
3
+ Device identity, hardware, and safe-area insets over a swappable web/native backend
4
4
 
5
- `device` is a host-identity leaf in the platform-integration suite. Every public function is a free function that delegates to the active `DeviceBackend`. A web/DOM backend is lazily available, so every function works on the web; a native host (Electron, Tauri, Capacitor, a C/C++ shell) replaces it via `setDeviceBackend`. Snapshot reads fill an `out` value and return it. Unknown or unavailable fields resolve to sentinels (`''` / `-1` / `false`), never throwing.
5
+ ## Install
6
6
 
7
- Battery state is **not** here — it is a live, event-bearing concern owned by `@flighthq/power`. `DeviceInfo` is a static identity snapshot. Live multi-display enumeration and work-area geometry belong to `@flighthq/screen`; `DeviceDisplayMetrics` describes only the built-in display.
8
-
9
- ## Functions
10
-
11
- | Function | Purpose |
12
- | --- | --- |
13
- | `createDeviceCapabilities()` | Allocate a zeroed `DeviceCapabilities` (all `false`) to pass as `out`. |
14
- | `createDeviceDisplayMetrics()` | Allocate a zeroed `DeviceDisplayMetrics` (all `-1`) to pass as `out`. |
15
- | `createDeviceInfo()` | Allocate a zeroed `DeviceInfo` (strings `''`, booleans `false`, arrays `[]`, numbers `-1`) to pass as `out`. |
16
- | `createSafeAreaInsets()` | Allocate a zeroed `SafeAreaInsets` (all edges `0`) to pass as `out`. |
17
- | `createWebDeviceBackend()` | Build the default web backend. |
18
- | `enableWebSafeAreaInsets()` | Mount a CSS `env(safe-area-inset-*)` probe; returns a dispose function. Opt-in (touches the DOM). |
19
- | `getDeviceBackend()` | Return the active backend, lazily creating the web default. There is always a backend. |
20
- | `getDeviceCapabilities(out)` | Fill `out` with input/hardware capability flags. |
21
- | `getDeviceDisplayMetrics(out)` | Fill `out` with the built-in display metrics. |
22
- | `getDeviceId()` | Return a stable install identifier (resettable, not a hardware serial). |
23
- | `getDeviceInfo(out)` | Fill `out` with the device's identity snapshot. |
24
- | `getSafeAreaInsets(out)` | Fill `out` with safe-area insets, in CSS pixels. |
25
- | `refreshDeviceInfo()` | Invalidate a backend snapshot cache so the next read is fresh. No-op on the stateless web default. |
26
- | `setDeviceBackend(backend)` | Install a native host backend; pass `null` to fall back to the web default. |
27
-
28
- ## `DeviceInfo` fields
29
-
30
- | Field | Type | Unit | Sentinel | Web backend |
31
- | --- | --- | --- | --- | --- |
32
- | `arch` | `string` | CPU architecture token (e.g. `x86_64`, `arm64`) | `''` | Parsed from the UA / `userAgentData.platform`. Best-effort. |
33
- | `availableMemory` | `number` | bytes of currently-available RAM | `-1` | Not exposed by browsers — always `-1`. |
34
- | `boardName` | `string` | hardware board / mainboard name | `''` | Not exposed — always `''`. |
35
- | `colorGamut` | `string` | display color gamut token | `''` | Not exposed — always `''`. |
36
- | `cpuCores` | `number` | logical CPU core count | `-1` | `navigator.hardwareConcurrency` when present. |
37
- | `fontScale` | `number` | OS font-scale multiplier (`1.0` = default) | `-1` | Not exposed — always `-1`. |
38
- | `formFactor` | `DeviceFormFactor` | physical device class (open string-kind: `Desktop`, `Phone`, `Tablet`, `TV`, `Watch`, `Car`, `Unknown`, or vendor-prefixed) | `'Unknown'` | Parsed from the UA + `maxTouchPoints`. |
39
- | `gpuRenderer` | `string` | GPU renderer string | `''` | `WEBGL_debug_renderer_info`; may be masked/randomized by browser privacy budget. |
40
- | `gpuVendor` | `string` | GPU vendor string | `''` | `WEBGL_debug_renderer_info`; same caveat. |
41
- | `isHdr` | `boolean` | display is HDR-capable | `false` | Not exposed — always `false`. |
42
- | `isJailbroken` | `boolean` | iOS jailbreak detected | `false` | No web detection — always `false`. |
43
- | `isLowEndDevice` | `boolean` | heuristically a low-end device | `false` | Heuristic: `≤ 1 GiB` RAM or `≤ 2` cores. Unknown inputs → `false`. |
44
- | `isRooted` | `boolean` | Android root detected | `false` | No web detection — always `false`. |
45
- | `isVirtual` | `boolean` | running on an emulator / VM | `false` | No web detection — always `false`. |
46
- | `manufacturer` | `string` | hardware manufacturer | `''` | Not exposed — always `''`. |
47
- | `marketingName` | `string` | consumer marketing name | `''` | Not exposed — always `''`. |
48
- | `model` | `string` | hardware model identifier | `''` | Not exposed — always `''`. |
49
- | `osBuild` | `string` | OS build number | `''` | Not exposed — always `''`. |
50
- | `osName` | `string` | OS name | `''` | Parsed from the UA. |
51
- | `osVersion` | `string` | OS version string | `''` | Parsed from the UA. |
52
- | `platformString` | `string` | raw platform identifier | `''` | The full UA string. |
53
- | `productName` | `string` | product / device codename | `''` | Not exposed — always `''`. |
54
- | `supportedAbis` | `readonly string[]` | supported native ABIs | `[]` | Not exposed — always `[]`. |
55
- | `totalMemory` | `number` | bytes of total RAM | `-1` | `navigator.deviceMemory` (GiB) converted to bytes; coarse, privacy-clamped. |
56
- | `webViewVersion` | `string` | host WebView version | `''` | Not applicable (we are the browser) — always `''`. |
57
-
58
- ## `DeviceCapabilities` fields
59
-
60
- | Field | Type | Sentinel | Web backend |
61
- | --- | --- | --- | --- |
62
- | `hasKeyboard` | `boolean` | `false` | Heuristic: desktop UA likely has a physical keyboard. Cannot distinguish hybrid (Surface, iPad + keyboard). |
63
- | `hasMouse` | `boolean` | `false` | Heuristic: `maxTouchPoints === 0` is a strong pointer-device signal. Cannot confirm a physical mouse. |
64
- | `hasStylus` | `boolean` | `false` | No reliable browser signal — always `false`. |
65
-
66
- Richer pointer/keyboard event handling lives in `@flighthq/input` and `@flighthq/interaction`; `DeviceCapabilities` only surfaces capabilities with no dedicated package owner.
67
-
68
- ## `DeviceDisplayMetrics` fields
69
-
70
- | Field | Type | Unit | Sentinel | Web backend |
71
- | --- | --- | --- | --- | --- |
72
- | `colorDepth` | `number` | bits per pixel | `-1` | `screen.colorDepth`. |
73
- | `densityDpi` | `number` | dots per inch | `-1` | Not exposed by browsers — always `-1`. |
74
- | `logicalHeight` | `number` | CSS pixels | `-1` | `screen.height`. |
75
- | `logicalWidth` | `number` | CSS pixels | `-1` | `screen.width`. |
76
- | `physicalHeight` | `number` | device pixels | `-1` | `screen.height × devicePixelRatio` when the ratio is known. |
77
- | `physicalWidth` | `number` | device pixels | `-1` | `screen.width × devicePixelRatio` when the ratio is known. |
78
- | `pixelRatio` | `number` | device pixels per CSS pixel | `-1` | `window.devicePixelRatio`. |
79
-
80
- ## `SafeAreaInsets` fields
81
-
82
- | Field | Type | Unit | Sentinel | Web backend |
83
- | --- | --- | --- | --- | --- |
84
- | `top` | `number` | CSS pixels | `0` | `0` by default; real `env(safe-area-inset-top)` after `enableWebSafeAreaInsets()`. |
85
- | `right` | `number` | CSS pixels | `0` | `0` by default; real `env(safe-area-inset-right)` after `enableWebSafeAreaInsets()`. |
86
- | `bottom` | `number` | CSS pixels | `0` | `0` by default; real `env(safe-area-inset-bottom)` after `enableWebSafeAreaInsets()`. |
87
- | `left` | `number` | CSS pixels | `0` | `0` by default; real `env(safe-area-inset-left)` after `enableWebSafeAreaInsets()`. |
88
-
89
- Edge insets keep content clear of notches, rounded corners, and system bars. The web backend returns zeros until `enableWebSafeAreaInsets()` mounts a live CSS-var probe (one hidden element, no polling).
90
-
91
- ## `getDeviceId`
92
-
93
- The web default generates a `crypto.randomUUID()` and persists it to `localStorage` as a stable install id. It returns `''` when no stable id can be formed (SSR, blocked storage, privacy mode). This is an **install** id — it resets when storage is cleared — not a hardware serial.
94
-
95
- ## Usage
7
+ ```sh
8
+ npm install @flighthq/device
9
+ ```
96
10
 
97
- ```ts
98
- import { createDeviceInfo, getDeviceInfo, getDeviceId } from '@flighthq/device';
11
+ Import the supported application-facing API from `@flighthq/device`. The `@flighthq/device/contract` export is the wider package-to-package contract used to compose Flight itself.
99
12
 
100
- const info = getDeviceInfo(createDeviceInfo());
101
- console.log(info.formFactor, info.osName, info.cpuCores);
13
+ This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
102
14
 
103
- const installId = getDeviceId();
104
- ```
15
+ - [Flight project](https://github.com/flighthq/flight)
16
+ - [Source for @flighthq/device@0.4.0-next.1932.1ef883a](https://github.com/flighthq/flight/tree/1ef883a866729a9bc6f461111970f6377de1499f/packages/device)
17
+ - [License](https://github.com/flighthq/flight/blob/1ef883a866729a9bc6f461111970f6377de1499f/LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/device",
3
- "version": "0.4.0-next.1920.b93ad0f",
3
+ "version": "0.4.0-next.1932.1ef883a",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/types": "0.4.0-next.1920.b93ad0f",
42
- "@flighthq/useragent": "0.4.0-next.1920.b93ad0f"
41
+ "@flighthq/types": "0.4.0-next.1932.1ef883a",
42
+ "@flighthq/useragent": "0.4.0-next.1932.1ef883a"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.3.0"