@gjsify/native-platform 0.7.1

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.
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";const e=typeof java<`u`,t=typeof NSFileManager<`u`,n=e||t;function platformName(){return e?`android`:t?`ios`:`unknown`}function assertNativeScript(){if(!n)throw Error(`Platform not supported`)}const r={platform:`unknown`,osVersion:`unknown`,sdkInt:null,deviceModel:`unknown`,manufacturer:`unknown`};function androidInfo(){let e=android?.os?.Build;return e?{platform:`android`,osVersion:e.VERSION?.RELEASE??`unknown`,sdkInt:typeof e.VERSION?.SDK_INT==`number`?e.VERSION.SDK_INT:null,deviceModel:e.MODEL??`unknown`,manufacturer:e.MANUFACTURER??`unknown`}:{...r,platform:`android`}}function iosInfo(){let e=UIDevice?.currentDevice;return e?{platform:`ios`,osVersion:e.systemVersion??`unknown`,sdkInt:null,deviceModel:e.model??`unknown`,manufacturer:`Apple`}:{...r,platform:`ios`,manufacturer:`Apple`}}function platformInfo(){return e?androidInfo():t?iosInfo():{...r}}function osVersion(){return platformInfo().osVersion}function sdkInt(){return platformInfo().sdkInt}function deviceModel(){return platformInfo().deviceModel}export{assertNativeScript,deviceModel,e as isAndroid,t as isIOS,n as isNativeScript,osVersion,platformInfo,platformName,sdkInt};
@@ -0,0 +1,38 @@
1
+ /** True when running under NativeScript on Android (the Java bridge is present). */
2
+ export declare const isAndroid: boolean;
3
+ /** True when running under NativeScript on iOS (the Foundation bridge is present). */
4
+ export declare const isIOS: boolean;
5
+ /** True when running under NativeScript on any platform. */
6
+ export declare const isNativeScript: boolean;
7
+ export type PlatformName = 'android' | 'ios' | 'unknown';
8
+ /** The current platform, or `'unknown'` outside NativeScript. */
9
+ export declare function platformName(): PlatformName;
10
+ /**
11
+ * Throw if not running under NativeScript. Use this to guard code paths that
12
+ * genuinely require a native bridge (the info getters below stay non-throwing).
13
+ */
14
+ export declare function assertNativeScript(): void;
15
+ export interface PlatformInfo {
16
+ /** `'android'`, `'ios'`, or `'unknown'`. */
17
+ platform: PlatformName;
18
+ /** OS release string — e.g. Android `"13"` or iOS `"17.0"`; `'unknown'` otherwise. */
19
+ osVersion: string;
20
+ /** Android API level (e.g. `33`); `null` on iOS or off-platform. */
21
+ sdkInt: number | null;
22
+ /** Device model — e.g. `"Pixel 7"` / `"iPhone"`; `'unknown'` if unavailable. */
23
+ deviceModel: string;
24
+ /** Device manufacturer — Android `Build.MANUFACTURER`, iOS `"Apple"`; `'unknown'` otherwise. */
25
+ manufacturer: string;
26
+ }
27
+ /**
28
+ * Platform, OS version, SDK level, device model and manufacturer.
29
+ * Non-throwing: returns an all-`'unknown'` record outside NativeScript so
30
+ * callers can read it unconditionally and branch on `platform`.
31
+ */
32
+ export declare function platformInfo(): PlatformInfo;
33
+ /** OS release string — convenience accessor over {@link platformInfo}. */
34
+ export declare function osVersion(): string;
35
+ /** Android API level, or `null` on iOS / off-platform. */
36
+ export declare function sdkInt(): number | null;
37
+ /** Device model, or `'unknown'` if unavailable. */
38
+ export declare function deviceModel(): string;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@gjsify/native-platform",
3
+ "version": "0.7.1",
4
+ "description": "NativeScript platform detection — Android/iOS runtime, OS version, SDK level and device model",
5
+ "type": "module",
6
+ "module": "lib/esm/index.js",
7
+ "types": "lib/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "default": "./lib/esm/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "lib"
16
+ ],
17
+ "scripts": {
18
+ "clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.gjs.mjs test.node.mjs || exit 0",
19
+ "check": "gjsify tsc --noEmit",
20
+ "build": "gjsify run build:gjsify && gjsify run build:types",
21
+ "build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
22
+ "build:types": "gjsify tsc",
23
+ "build:test": "gjsify run build:test:gjs && gjsify run build:test:node",
24
+ "build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
25
+ "build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
26
+ "test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:node && gjsify run test:gjs",
27
+ "test:gjs": "gjsify run test.gjs.mjs",
28
+ "test:node": "node test.node.mjs"
29
+ },
30
+ "keywords": [
31
+ "gjs",
32
+ "nativescript",
33
+ "platform",
34
+ "android",
35
+ "ios"
36
+ ],
37
+ "devDependencies": {
38
+ "@gjsify/cli": "^0.7.1",
39
+ "@gjsify/unit": "^0.7.1",
40
+ "@types/node": "^25.9.2",
41
+ "typescript": "^6.0.3"
42
+ },
43
+ "gjsify": {
44
+ "runtimes": {
45
+ "gjs": "none",
46
+ "node": "none",
47
+ "browser": "none",
48
+ "nativescript": "native"
49
+ }
50
+ },
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/gjsify/gjsify.git",
55
+ "directory": "packages/nativescript-bridge/platform"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/gjsify/gjsify/issues"
59
+ },
60
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/nativescript-bridge/platform#readme"
61
+ }