@flighthq/platform 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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/README.md +2 -2
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +24 -24
- package/dist/platform.js.map +1 -1
- package/package.json +4 -4
- package/src/platform.test.ts +33 -33
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/platform`. The `@fli
|
|
|
13
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.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/platform@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/platform@0.5.1-next.1201.9b49dee](https://github.com/flighthq/flight/tree/9b49dee3f22f6b2838c3d237edcc77bca65734f2/packages/platform)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/9b49dee3f22f6b2838c3d237edcc77bca65734f2/LICENSE.md)
|
package/dist/platform.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { EntityConstruction,
|
|
1
|
+
import type { EntityConstruction, HostPlatformProvider, PlatformEngine, PlatformInfo, PlatformKind, PlatformName, PlatformRuntime } from '@flighthq/types/contract';
|
|
2
2
|
export declare function comparePlatformVersions(a: string, b: string): -1 | 0 | 1;
|
|
3
3
|
export declare function createPlatformInfo(): PlatformInfo;
|
|
4
|
-
export declare function getPlatformEngine(
|
|
5
|
-
export declare function getPlatformInfo(
|
|
6
|
-
export declare function getPlatformKind(
|
|
7
|
-
export declare function getPlatformName(
|
|
8
|
-
export declare function getPlatformRuntime(
|
|
4
|
+
export declare function getPlatformEngine(hostPlatform: Readonly<HostPlatformProvider>): PlatformEngine;
|
|
5
|
+
export declare function getPlatformInfo(hostPlatform: Readonly<HostPlatformProvider>, out: PlatformInfo): PlatformInfo;
|
|
6
|
+
export declare function getPlatformKind(hostPlatform: Readonly<HostPlatformProvider>): PlatformKind;
|
|
7
|
+
export declare function getPlatformName(hostPlatform: Readonly<HostPlatformProvider>): PlatformName;
|
|
8
|
+
export declare function getPlatformRuntime(hostPlatform: Readonly<HostPlatformProvider>): PlatformRuntime;
|
|
9
9
|
export declare function initializePlatformInfo(out: EntityConstruction<PlatformInfo>): void;
|
|
10
|
-
export declare function isPlatformDesktop(
|
|
11
|
-
export declare function isPlatformMobile(
|
|
12
|
-
export declare function isPlatformNative(
|
|
13
|
-
export declare function isPlatformTouch(
|
|
14
|
-
export declare function isPlatformVersionAtLeast(
|
|
15
|
-
export declare function isPlatformWeb(
|
|
10
|
+
export declare function isPlatformDesktop(hostPlatform: Readonly<HostPlatformProvider>): boolean;
|
|
11
|
+
export declare function isPlatformMobile(hostPlatform: Readonly<HostPlatformProvider>): boolean;
|
|
12
|
+
export declare function isPlatformNative(hostPlatform: Readonly<HostPlatformProvider>): boolean;
|
|
13
|
+
export declare function isPlatformTouch(hostPlatform: Readonly<HostPlatformProvider>): boolean;
|
|
14
|
+
export declare function isPlatformVersionAtLeast(hostPlatform: Readonly<HostPlatformProvider>, minimum: string): boolean;
|
|
15
|
+
export declare function isPlatformWeb(hostPlatform: Readonly<HostPlatformProvider>): boolean;
|
|
16
16
|
//# sourceMappingURL=platform.d.ts.map
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,YAAY,E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AC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAEnF"}
|
package/dist/platform.js
CHANGED
|
@@ -27,27 +27,27 @@ export function createPlatformInfo() {
|
|
|
27
27
|
}
|
|
28
28
|
// The browser rendering engine — 'blink' | 'gecko' | 'webkit' | 'unknown'. Convenience over
|
|
29
29
|
// getPlatformInfo. 'unknown' on native hosts where no browser engine is present.
|
|
30
|
-
export function getPlatformEngine(
|
|
31
|
-
return getPlatformInfo(
|
|
30
|
+
export function getPlatformEngine(hostPlatform) {
|
|
31
|
+
return getPlatformInfo(hostPlatform, _scratch).engine;
|
|
32
32
|
}
|
|
33
|
-
// Fills `out` with the running platform's identity
|
|
34
|
-
export function getPlatformInfo(
|
|
35
|
-
return
|
|
33
|
+
// Fills `out` with the running platform's identity through the supplied provider and returns it.
|
|
34
|
+
export function getPlatformInfo(hostPlatform, out) {
|
|
35
|
+
return hostPlatform.getInfo(out);
|
|
36
36
|
}
|
|
37
37
|
// The platform family — 'desktop' | 'mobile' | 'web' | 'unknown'. Convenience over getPlatformInfo.
|
|
38
|
-
export function getPlatformKind(
|
|
39
|
-
return getPlatformInfo(
|
|
38
|
+
export function getPlatformKind(hostPlatform) {
|
|
39
|
+
return getPlatformInfo(hostPlatform, _scratch).kind;
|
|
40
40
|
}
|
|
41
41
|
// The specific OS/runtime name — 'windows' | 'macos' | 'ios' | 'android' | 'linux' | 'web' | 'unknown'.
|
|
42
|
-
export function getPlatformName(
|
|
43
|
-
return getPlatformInfo(
|
|
42
|
+
export function getPlatformName(hostPlatform) {
|
|
43
|
+
return getPlatformInfo(hostPlatform, _scratch).name;
|
|
44
44
|
}
|
|
45
45
|
// The host shell / runtime environment — 'web' | 'electron' | 'tauri' | 'capacitor' | 'native' |
|
|
46
46
|
// 'unknown'. Convenience over getPlatformInfo. Distinguishes plain web from a host shell.
|
|
47
|
-
export function getPlatformRuntime(
|
|
48
|
-
return getPlatformInfo(
|
|
47
|
+
export function getPlatformRuntime(hostPlatform) {
|
|
48
|
+
return getPlatformInfo(hostPlatform, _scratch).runtime;
|
|
49
49
|
}
|
|
50
|
-
// Allocates a zeroed PlatformInfo; use as the `out` for getPlatformInfo or when building a
|
|
50
|
+
// Allocates a zeroed PlatformInfo; use as the `out` for getPlatformInfo or when building a provider.
|
|
51
51
|
export function initializePlatformInfo(out) {
|
|
52
52
|
out.arch = '';
|
|
53
53
|
out.distro = '';
|
|
@@ -65,35 +65,35 @@ export function initializePlatformInfo(out) {
|
|
|
65
65
|
out.version = '';
|
|
66
66
|
}
|
|
67
67
|
// True on a desktop host (Electron/Tauri/native window shell). False on mobile and plain web.
|
|
68
|
-
export function isPlatformDesktop(
|
|
69
|
-
return getPlatformKind(
|
|
68
|
+
export function isPlatformDesktop(hostPlatform) {
|
|
69
|
+
return getPlatformKind(hostPlatform) === 'desktop';
|
|
70
70
|
}
|
|
71
71
|
// True on a mobile host (iOS/Android via Capacitor or a native shell).
|
|
72
|
-
export function isPlatformMobile(
|
|
73
|
-
return getPlatformKind(
|
|
72
|
+
export function isPlatformMobile(hostPlatform) {
|
|
73
|
+
return getPlatformKind(hostPlatform) === 'mobile';
|
|
74
74
|
}
|
|
75
75
|
// True when the app is running inside a host shell (Electron/Tauri/Capacitor/native), not a plain
|
|
76
76
|
// browser page. Convenience over `getPlatformRuntime() !== 'web' && !== 'unknown'`.
|
|
77
|
-
export function isPlatformNative(
|
|
78
|
-
const runtime = getPlatformRuntime(
|
|
77
|
+
export function isPlatformNative(hostPlatform) {
|
|
78
|
+
const runtime = getPlatformRuntime(hostPlatform);
|
|
79
79
|
return runtime !== 'web' && runtime !== 'unknown';
|
|
80
80
|
}
|
|
81
81
|
// True on a touch-primary device, independent of desktop/mobile classification.
|
|
82
|
-
export function isPlatformTouch(
|
|
83
|
-
return getPlatformInfo(
|
|
82
|
+
export function isPlatformTouch(hostPlatform) {
|
|
83
|
+
return getPlatformInfo(hostPlatform, _scratch).isTouch;
|
|
84
84
|
}
|
|
85
85
|
// True when the running platform's OS version is at or above `minimum`. Reads the live version via
|
|
86
86
|
// getPlatformInfo. Returns false when the version is '' (unknown). The comparison is numeric and
|
|
87
87
|
// segment-wise (see comparePlatformVersions).
|
|
88
|
-
export function isPlatformVersionAtLeast(
|
|
89
|
-
const version = getPlatformInfo(
|
|
88
|
+
export function isPlatformVersionAtLeast(hostPlatform, minimum) {
|
|
89
|
+
const version = getPlatformInfo(hostPlatform, _scratch).version;
|
|
90
90
|
if (version === '')
|
|
91
91
|
return false;
|
|
92
92
|
return comparePlatformVersions(version, minimum) >= 0;
|
|
93
93
|
}
|
|
94
94
|
// True when running as a plain web page with no native host registered.
|
|
95
|
-
export function isPlatformWeb(
|
|
96
|
-
return getPlatformKind(
|
|
95
|
+
export function isPlatformWeb(hostPlatform) {
|
|
96
|
+
return getPlatformKind(hostPlatform) === 'web';
|
|
97
97
|
}
|
|
98
98
|
// Single-threaded JS no-alloc scratch for scalar convenience reads (getPlatformKind, etc.).
|
|
99
99
|
// Rust/native mirror uses a per-call local or thread-local instead.
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAWzE,4FAA4F;AAC5F,6FAA6F;AAC7F,gEAAgE;AAChE,MAAM,UAAU,uBAAuB,CAAC,CAAS,EAAE,CAAS;IAC1D,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,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ACxE,MAAM,UAAU,aAAa,CAAC,YAA4C;IACxE,OAAO,eAAe,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC;AACjD,CAAC;AAED,4FAA4F;AAC5F,oEAAoE;AACpE,MAAM,QAAQ,GAAiB,kBAAkB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/platform",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1201.9b49dee",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/types": "0.5.1-next.
|
|
43
|
-
"@flighthq/useragent": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1201.9b49dee",
|
|
42
|
+
"@flighthq/types": "0.5.1-next.1201.9b49dee",
|
|
43
|
+
"@flighthq/useragent": "0.5.1-next.1201.9b49dee"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
package/src/platform.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostPlatformProvider, PlatformInfo } from '@flighthq/types/contract';
|
|
2
2
|
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import * as platformContract from './platform';
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
isPlatformWeb,
|
|
20
20
|
} from './platform';
|
|
21
21
|
|
|
22
|
-
function fakeBackend(info: Partial<PlatformInfo>):
|
|
22
|
+
function fakeBackend(info: Partial<PlatformInfo>): HostPlatformProvider {
|
|
23
23
|
return {
|
|
24
24
|
[EntityRuntimeKey]: undefined,
|
|
25
25
|
getInfo(out) {
|
|
@@ -29,7 +29,7 @@ function fakeBackend(info: Partial<PlatformInfo>): PlatformBackend {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function fakeHost(info: Partial<PlatformInfo>):
|
|
32
|
+
function fakeHost(info: Partial<PlatformInfo>): { readonly system: { readonly platform: HostPlatformProvider } } {
|
|
33
33
|
return { system: { platform: fakeBackend(info) } };
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -93,19 +93,19 @@ describe('createPlatformInfo', () => {
|
|
|
93
93
|
|
|
94
94
|
describe('getPlatformEngine', () => {
|
|
95
95
|
it('returns the engine from the host backend', () => {
|
|
96
|
-
expect(getPlatformEngine(fakeHost({ engine: 'blink' }))).toBe('blink');
|
|
96
|
+
expect(getPlatformEngine(fakeHost({ engine: 'blink' }).system.platform)).toBe('blink');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it('returns gecko when set', () => {
|
|
100
|
-
expect(getPlatformEngine(fakeHost({ engine: 'gecko' }))).toBe('gecko');
|
|
100
|
+
expect(getPlatformEngine(fakeHost({ engine: 'gecko' }).system.platform)).toBe('gecko');
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('returns webkit when set', () => {
|
|
104
|
-
expect(getPlatformEngine(fakeHost({ engine: 'webkit' }))).toBe('webkit');
|
|
104
|
+
expect(getPlatformEngine(fakeHost({ engine: 'webkit' }).system.platform)).toBe('webkit');
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
it('returns unknown for native backends', () => {
|
|
108
|
-
expect(getPlatformEngine(fakeHost({ engine: 'unknown' }))).toBe('unknown');
|
|
108
|
+
expect(getPlatformEngine(fakeHost({ engine: 'unknown' }).system.platform)).toBe('unknown');
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
|
|
@@ -113,7 +113,7 @@ describe('getPlatformInfo', () => {
|
|
|
113
113
|
it('fills and returns the out parameter', () => {
|
|
114
114
|
const host = fakeHost({ arch: 'arm64', kind: 'mobile', name: 'ios' });
|
|
115
115
|
const out = createPlatformInfo();
|
|
116
|
-
expect(getPlatformInfo(host, out)).toBe(out);
|
|
116
|
+
expect(getPlatformInfo(host.system.platform, out)).toBe(out);
|
|
117
117
|
expect(out.name).toBe('ios');
|
|
118
118
|
expect(out.arch).toBe('arm64');
|
|
119
119
|
});
|
|
@@ -121,35 +121,35 @@ describe('getPlatformInfo', () => {
|
|
|
121
121
|
|
|
122
122
|
describe('getPlatformKind', () => {
|
|
123
123
|
it('returns the host backend kind', () => {
|
|
124
|
-
expect(getPlatformKind(fakeHost({ kind: 'desktop' }))).toBe('desktop');
|
|
124
|
+
expect(getPlatformKind(fakeHost({ kind: 'desktop' }).system.platform)).toBe('desktop');
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
describe('getPlatformName', () => {
|
|
129
129
|
it('returns the host backend name', () => {
|
|
130
|
-
expect(getPlatformName(fakeHost({ name: 'macos' }))).toBe('macos');
|
|
130
|
+
expect(getPlatformName(fakeHost({ name: 'macos' }).system.platform)).toBe('macos');
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
describe('getPlatformRuntime', () => {
|
|
135
135
|
it('returns web when no host shell is detected', () => {
|
|
136
|
-
expect(getPlatformRuntime(fakeHost({ runtime: 'web' }))).toBe('web');
|
|
136
|
+
expect(getPlatformRuntime(fakeHost({ runtime: 'web' }).system.platform)).toBe('web');
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
it('returns electron when set', () => {
|
|
140
|
-
expect(getPlatformRuntime(fakeHost({ runtime: 'electron' }))).toBe('electron');
|
|
140
|
+
expect(getPlatformRuntime(fakeHost({ runtime: 'electron' }).system.platform)).toBe('electron');
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
it('returns tauri when set', () => {
|
|
144
|
-
expect(getPlatformRuntime(fakeHost({ runtime: 'tauri' }))).toBe('tauri');
|
|
144
|
+
expect(getPlatformRuntime(fakeHost({ runtime: 'tauri' }).system.platform)).toBe('tauri');
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
it('returns capacitor when set', () => {
|
|
148
|
-
expect(getPlatformRuntime(fakeHost({ runtime: 'capacitor' }))).toBe('capacitor');
|
|
148
|
+
expect(getPlatformRuntime(fakeHost({ runtime: 'capacitor' }).system.platform)).toBe('capacitor');
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
it('returns native when set by a native backend', () => {
|
|
152
|
-
expect(getPlatformRuntime(fakeHost({ runtime: 'native' }))).toBe('native');
|
|
152
|
+
expect(getPlatformRuntime(fakeHost({ runtime: 'native' }).system.platform)).toBe('native');
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
@@ -161,76 +161,76 @@ describe('initializePlatformInfo', () => {
|
|
|
161
161
|
|
|
162
162
|
describe('isPlatformDesktop', () => {
|
|
163
163
|
it('is true only for desktop kind', () => {
|
|
164
|
-
expect(isPlatformDesktop(fakeHost({ kind: 'desktop' }))).toBe(true);
|
|
165
|
-
expect(isPlatformDesktop(fakeHost({ kind: 'web' }))).toBe(false);
|
|
164
|
+
expect(isPlatformDesktop(fakeHost({ kind: 'desktop' }).system.platform)).toBe(true);
|
|
165
|
+
expect(isPlatformDesktop(fakeHost({ kind: 'web' }).system.platform)).toBe(false);
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
describe('isPlatformMobile', () => {
|
|
170
170
|
it('is true only for mobile kind', () => {
|
|
171
|
-
expect(isPlatformMobile(fakeHost({ kind: 'mobile' }))).toBe(true);
|
|
171
|
+
expect(isPlatformMobile(fakeHost({ kind: 'mobile' }).system.platform)).toBe(true);
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
describe('isPlatformNative', () => {
|
|
176
176
|
it('is true for electron runtime', () => {
|
|
177
|
-
expect(isPlatformNative(fakeHost({ runtime: 'electron' }))).toBe(true);
|
|
177
|
+
expect(isPlatformNative(fakeHost({ runtime: 'electron' }).system.platform)).toBe(true);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
it('is true for tauri runtime', () => {
|
|
181
|
-
expect(isPlatformNative(fakeHost({ runtime: 'tauri' }))).toBe(true);
|
|
181
|
+
expect(isPlatformNative(fakeHost({ runtime: 'tauri' }).system.platform)).toBe(true);
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
it('is true for capacitor runtime', () => {
|
|
185
|
-
expect(isPlatformNative(fakeHost({ runtime: 'capacitor' }))).toBe(true);
|
|
185
|
+
expect(isPlatformNative(fakeHost({ runtime: 'capacitor' }).system.platform)).toBe(true);
|
|
186
186
|
});
|
|
187
187
|
|
|
188
188
|
it('is true for native runtime', () => {
|
|
189
|
-
expect(isPlatformNative(fakeHost({ runtime: 'native' }))).toBe(true);
|
|
189
|
+
expect(isPlatformNative(fakeHost({ runtime: 'native' }).system.platform)).toBe(true);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
it('is false for web runtime', () => {
|
|
193
|
-
expect(isPlatformNative(fakeHost({ runtime: 'web' }))).toBe(false);
|
|
193
|
+
expect(isPlatformNative(fakeHost({ runtime: 'web' }).system.platform)).toBe(false);
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
it('is false for unknown runtime', () => {
|
|
197
|
-
expect(isPlatformNative(fakeHost({ runtime: 'unknown' }))).toBe(false);
|
|
197
|
+
expect(isPlatformNative(fakeHost({ runtime: 'unknown' }).system.platform)).toBe(false);
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
describe('isPlatformTouch', () => {
|
|
202
202
|
it('reflects the backend isTouch flag', () => {
|
|
203
|
-
expect(isPlatformTouch(fakeHost({ isTouch: true }))).toBe(true);
|
|
203
|
+
expect(isPlatformTouch(fakeHost({ isTouch: true }).system.platform)).toBe(true);
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
describe('isPlatformVersionAtLeast', () => {
|
|
208
208
|
it('is true when version equals minimum', () => {
|
|
209
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '14.0' }), '14.0')).toBe(true);
|
|
209
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '14.0' }).system.platform, '14.0')).toBe(true);
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
it('is true when version exceeds minimum', () => {
|
|
213
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '15.0' }), '14.0')).toBe(true);
|
|
213
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '15.0' }).system.platform, '14.0')).toBe(true);
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
it('is false when version is below minimum', () => {
|
|
217
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '13.0' }), '14.0')).toBe(false);
|
|
217
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '13.0' }).system.platform, '14.0')).toBe(false);
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
it('is false when version is empty (unknown)', () => {
|
|
221
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '' }), '1.0')).toBe(false);
|
|
221
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '' }).system.platform, '1.0')).toBe(false);
|
|
222
222
|
});
|
|
223
223
|
|
|
224
224
|
it('handles patch-level comparison', () => {
|
|
225
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }), '10.15.6')).toBe(true);
|
|
226
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }), '10.15.7')).toBe(true);
|
|
227
|
-
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }), '10.15.8')).toBe(false);
|
|
225
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }).system.platform, '10.15.6')).toBe(true);
|
|
226
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }).system.platform, '10.15.7')).toBe(true);
|
|
227
|
+
expect(isPlatformVersionAtLeast(fakeHost({ version: '10.15.7' }).system.platform, '10.15.8')).toBe(false);
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
describe('isPlatformWeb', () => {
|
|
232
232
|
it('is true only for web kind', () => {
|
|
233
|
-
expect(isPlatformWeb(fakeHost({ kind: 'web' }))).toBe(true);
|
|
233
|
+
expect(isPlatformWeb(fakeHost({ kind: 'web' }).system.platform)).toBe(true);
|
|
234
234
|
});
|
|
235
235
|
});
|
|
236
236
|
describe('R3 boundary', () => {
|