@flighthq/platform 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.
- package/LICENSE.md +9 -0
- package/README.md +10 -70
- 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,77 +1,17 @@
|
|
|
1
1
|
# @flighthq/platform
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Platform identification seam for the desktop/mobile integration suite: OS/kind/arch detection with a swappable host backend
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| Function | Purpose |
|
|
12
|
-
| --- | --- |
|
|
13
|
-
| `comparePlatformVersions(a, b)` | Compare two dotted version strings numerically, segment by segment. Returns `-1` / `0` / `1`; `''` sorts lowest. |
|
|
14
|
-
| `createPlatformInfo()` | Allocate a zeroed `PlatformInfo` (strings `''`, `kind`/`name`/`runtime`/`engine` `'unknown'`, `endianness` `'unknown'`, `pointerWidth` `-1`, `isTouch` `false`) to pass as `out`. |
|
|
15
|
-
| `createWebPlatformBackend()` | Build the default web backend. |
|
|
16
|
-
| `getPlatformBackend()` | Return the active backend, lazily creating the web default. There is always a backend. |
|
|
17
|
-
| `getPlatformEngine()` | Return the browser engine family. Convenience over `getPlatformInfo`. |
|
|
18
|
-
| `getPlatformInfo(out)` | Fill `out` with the running platform's identity snapshot and return it. |
|
|
19
|
-
| `getPlatformKind()` | Return the platform family (`desktop` / `mobile` / `web` / `unknown`). Convenience over `getPlatformInfo`. |
|
|
20
|
-
| `getPlatformName()` | Return the OS/runtime name. Convenience over `getPlatformInfo`. |
|
|
21
|
-
| `getPlatformRuntime()` | Return the host shell / runtime environment. Convenience over `getPlatformInfo`. |
|
|
22
|
-
| `isPlatformDesktop()` | `true` on a desktop host (Electron/Tauri/native window shell). |
|
|
23
|
-
| `isPlatformMobile()` | `true` on a mobile host (iOS/Android via Capacitor or a native shell). |
|
|
24
|
-
| `isPlatformNative()` | `true` when running inside a host shell, not a plain browser page. |
|
|
25
|
-
| `isPlatformTouch()` | `true` on a touch-primary device, independent of desktop/mobile classification. |
|
|
26
|
-
| `isPlatformVersionAtLeast(minimum)` | `true` when the live OS version is at or above `minimum`. `false` when the version is `''`. |
|
|
27
|
-
| `isPlatformWeb()` | `true` when running as a plain web page with no native host registered. |
|
|
28
|
-
| `setPlatformBackend(backend)` | Install a native host backend. Pass `null` to fall back to the web default. |
|
|
29
|
-
|
|
30
|
-
## `PlatformInfo` fields
|
|
31
|
-
|
|
32
|
-
`PlatformInfo` carries 14 fields. Every field is filled on the web from the user-agent string, `navigator`, and runtime probes; native hosts fill the same shape from OS APIs. Fields a web page cannot honestly report resolve to a sentinel rather than guessing.
|
|
33
|
-
|
|
34
|
-
| Field | Type | Value space | Sentinel | Web source | Native source |
|
|
35
|
-
| --- | --- | --- | --- | --- | --- |
|
|
36
|
-
| `name` | `PlatformName` | `'web'` `'windows'` `'macos'` `'linux'` `'ios'` `'android'` `'unknown'` | `'unknown'` | parsed from UA string | OS name |
|
|
37
|
-
| `kind` | `PlatformKind` | `'desktop'` `'mobile'` `'web'` `'unknown'` | `'unknown'` | derived from `name` | OS family |
|
|
38
|
-
| `version` | `string` | dotted OS version, e.g. `'10.15.7'` | `''` | parsed from UA string (best-effort) | OS version API |
|
|
39
|
-
| `arch` | `string` | `'x64'` `'arm64'` `'x86'` `'arm'` `'wasm'`, … | `''` | parsed from UA string | CPU arch |
|
|
40
|
-
| `locale` | `string` | BCP-47 tag, e.g. `'en-US'` | `''` | `navigator.language` | OS locale |
|
|
41
|
-
| `isTouch` | `boolean` | touch-primary input | `false` | `navigator.maxTouchPoints > 0` | input enumeration |
|
|
42
|
-
| `runtime` | `PlatformRuntime` | `'web'` `'electron'` `'tauri'` `'capacitor'` `'native'` `'unknown'` | `'unknown'` | probed from `window` globals | host shell identity |
|
|
43
|
-
| `engine` | `PlatformEngine` | `'gecko'` `'blink'` `'webkit'` `'unknown'` | `'unknown'` | parsed from UA string | `'unknown'` (no browser engine) |
|
|
44
|
-
| `engineVersion` | `string` | dotted engine version | `''` | parsed from UA string | `''` (no browser engine) |
|
|
45
|
-
| `endianness` | `PlatformEndianness` | `'big'` `'little'` `'unknown'` | `'unknown'` | `ArrayBuffer` byte-order probe | CPU byte order |
|
|
46
|
-
| `pointerWidth` | `32 \| 64 \| -1` | word width in bits | `-1` | inferred from `arch` | inferred from `arch` |
|
|
47
|
-
| `osBuild` | `string` | OS build identifier | `''` | **native-reserved** — always `''` | OS build string |
|
|
48
|
-
| `distro` | `string` | Linux distribution id, e.g. `'ubuntu'` | `''` | **native-reserved** — always `''` | `os-release` id |
|
|
49
|
-
| `distroVersion` | `string` | Linux distribution version | `''` | **native-reserved** — always `''` | `os-release` version |
|
|
50
|
-
|
|
51
|
-
`osBuild`, `distro`, and `distroVersion` exist in the shape so a native backend can fill them without a breaking type change. The web backend cannot honestly report them, so it returns `''`; they stay empty until a native host provides them. Treat `''` here as **native-reserved**, not an error.
|
|
52
|
-
|
|
53
|
-
## Cross-package delegation
|
|
54
|
-
|
|
55
|
-
`platform` reports only host **identity**. Richer or live concerns belong to their own cells; reach for these rather than expecting them on `PlatformInfo`:
|
|
56
|
-
|
|
57
|
-
| Concern | Owner | Why not here |
|
|
58
|
-
| --- | --- | --- |
|
|
59
|
-
| Device model, manufacturer, memory, safe-area insets | `@flighthq/device` | Hardware/device identity is a distinct, larger snapshot. |
|
|
60
|
-
| Battery, charging, low-power, keep-awake | `@flighthq/power` | Live, event-bearing state — not a static snapshot. |
|
|
61
|
-
| Display enumeration, work area, scale factor | `@flighthq/screen` | Multi-display geometry is its own live surface. |
|
|
62
|
-
| App name/version, quit/relaunch, single-instance lock | `@flighthq/app` | Application/process identity, not host identity. |
|
|
63
|
-
|
|
64
|
-
The UA-string parsing primitives (`parseUserAgent*`, `probeEndianness`) live in `@flighthq/useragent`, the shared value-leaf both `platform` and `device` build their web backends on.
|
|
65
|
-
|
|
66
|
-
## Usage
|
|
7
|
+
```sh
|
|
8
|
+
npm install @flighthq/platform
|
|
9
|
+
```
|
|
67
10
|
|
|
68
|
-
|
|
69
|
-
import { createPlatformInfo, getPlatformInfo, isPlatformVersionAtLeast } from '@flighthq/platform';
|
|
11
|
+
Import the supported application-facing API from `@flighthq/platform`. The `@flighthq/platform/contract` export is the wider package-to-package contract used to compose Flight itself.
|
|
70
12
|
|
|
71
|
-
|
|
72
|
-
console.log(info.name, info.kind, info.arch, info.runtime);
|
|
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.
|
|
73
14
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```
|
|
15
|
+
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
+
- [Source for @flighthq/platform@0.4.0-next.1932.1ef883a](https://github.com/flighthq/flight/tree/1ef883a866729a9bc6f461111970f6377de1499f/packages/platform)
|
|
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/platform",
|
|
3
|
-
"version": "0.4.0-next.
|
|
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.
|
|
42
|
-
"@flighthq/useragent": "0.4.0-next.
|
|
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"
|