@symbiote-native/device 0.3.0 → 2.0.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/README.md +122 -42
- package/package.json +27 -15
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A wrapper package for [SymbioteNative](../../README.md) that makes
|
|
|
4
4
|
[`expo-device`](https://github.com/expo/expo/tree/main/packages/expo-device)
|
|
5
5
|
— physical device information: brand/model/OS constants, uptime, max-memory,
|
|
6
6
|
root/jailbreak detection, side-loading detection, and platform-feature queries — usable from
|
|
7
|
-
**every** adapter, React, Vue, and Angular, not just React. Like
|
|
7
|
+
**every** adapter, React, Vue, Svelte, Solid, and Angular, not just React. Like
|
|
8
8
|
[`@symbiote-native/local-auth`](../local-auth) and unlike this repo's stateful Expo wrapper
|
|
9
9
|
([`@symbiote-native/sensors`](../sensors), an `EventEmitter` + live-subscription surface), every
|
|
10
10
|
export here is either an eagerly-resolved constant or a one-shot async call with no per-instance
|
|
@@ -56,16 +56,16 @@ src/core/ Eager constants (isDevice, brand, manufacturer, modelId, modelName
|
|
|
56
56
|
src/angular/ @symbiote-native/device/angular — export * from '../core'
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
`./react`, `./vue`, and `./
|
|
60
|
-
physical per-framework file, since there's nothing to subscribe to or clean up.
|
|
61
|
-
a physical file/subpath since Angular ships through a separate `ngc`/AOT build
|
|
59
|
+
`./react`, `./vue`, `./svelte`, and `./solid` are `exports`-map aliases straight onto
|
|
60
|
+
`src/core/` — no physical per-framework file, since there's nothing to subscribe to or clean up.
|
|
61
|
+
`./angular` stays a physical file/subpath since Angular ships through a separate `ngc`/AOT build
|
|
62
|
+
(`build-ngc/`).
|
|
62
63
|
|
|
63
64
|
## Use it
|
|
64
65
|
|
|
65
66
|
```tsx
|
|
66
67
|
// React
|
|
67
68
|
import { useEffect, useState } from 'react';
|
|
68
|
-
import { Text, View } from '@symbiote-native/react';
|
|
69
69
|
import {
|
|
70
70
|
brand,
|
|
71
71
|
deviceName,
|
|
@@ -87,20 +87,20 @@ function DeviceScreen() {
|
|
|
87
87
|
}, []);
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
90
|
+
<view>
|
|
91
|
+
<text>{isDevice ? 'Real device' : 'Simulator/emulator'}</text>
|
|
92
|
+
<text>{`${brand ?? 'unknown'} ${modelName ?? ''}`}</text>
|
|
93
|
+
<text>{`${osName ?? 'unknown OS'} ${osVersion ?? ''}`}</text>
|
|
94
|
+
<text>{deviceName ?? 'unnamed device'}</text>
|
|
95
|
+
<text>
|
|
96
96
|
{uptime === null ? 'checking uptime…' : `Uptime: ${uptime}ms`}
|
|
97
|
-
</
|
|
98
|
-
<
|
|
97
|
+
</text>
|
|
98
|
+
<text>
|
|
99
99
|
{maxMemory === null
|
|
100
100
|
? 'checking memory…'
|
|
101
101
|
: `Max memory: ${maxMemory} bytes`}
|
|
102
|
-
</
|
|
103
|
-
</
|
|
102
|
+
</text>
|
|
103
|
+
</view>
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
```
|
|
@@ -109,7 +109,6 @@ function DeviceScreen() {
|
|
|
109
109
|
<!-- Vue -->
|
|
110
110
|
<script setup lang="ts">
|
|
111
111
|
import { onMounted, ref } from 'vue';
|
|
112
|
-
import { Text, View } from '@symbiote-native/vue';
|
|
113
112
|
import {
|
|
114
113
|
brand,
|
|
115
114
|
deviceName,
|
|
@@ -131,25 +130,103 @@ onMounted(() => {
|
|
|
131
130
|
</script>
|
|
132
131
|
|
|
133
132
|
<template>
|
|
134
|
-
<
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
<
|
|
133
|
+
<view>
|
|
134
|
+
<text>{{ isDevice ? 'Real device' : 'Simulator/emulator' }}</text>
|
|
135
|
+
<text>{{ `${brand ?? 'unknown'} ${modelName ?? ''}` }}</text>
|
|
136
|
+
<text>{{ `${osName ?? 'unknown OS'} ${osVersion ?? ''}` }}</text>
|
|
137
|
+
<text>{{ deviceName ?? 'unnamed device' }}</text>
|
|
138
|
+
<text>{{
|
|
140
139
|
uptime === null ? 'checking uptime…' : `Uptime: ${uptime}ms`
|
|
141
|
-
}}</
|
|
142
|
-
<
|
|
140
|
+
}}</text>
|
|
141
|
+
<text>{{
|
|
143
142
|
maxMemory === null ? 'checking memory…' : `Max memory: ${maxMemory} bytes`
|
|
144
|
-
}}</
|
|
145
|
-
</
|
|
143
|
+
}}</text>
|
|
144
|
+
</view>
|
|
146
145
|
</template>
|
|
147
146
|
```
|
|
148
147
|
|
|
148
|
+
```svelte
|
|
149
|
+
<!-- Svelte -->
|
|
150
|
+
<script lang="ts">
|
|
151
|
+
import {
|
|
152
|
+
brand,
|
|
153
|
+
deviceName,
|
|
154
|
+
getMaxMemoryAsync,
|
|
155
|
+
getUptimeAsync,
|
|
156
|
+
isDevice,
|
|
157
|
+
modelName,
|
|
158
|
+
osName,
|
|
159
|
+
osVersion,
|
|
160
|
+
} from '@symbiote-native/device/svelte';
|
|
161
|
+
|
|
162
|
+
let uptime = $state<number | null>(null);
|
|
163
|
+
let maxMemory = $state<number | null>(null);
|
|
164
|
+
|
|
165
|
+
$effect(() => {
|
|
166
|
+
getUptimeAsync().then(value => (uptime = value));
|
|
167
|
+
getMaxMemoryAsync().then(value => (maxMemory = value));
|
|
168
|
+
});
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<view>
|
|
172
|
+
<text>{isDevice ? 'Real device' : 'Simulator/emulator'}</text>
|
|
173
|
+
<text>{`${brand ?? 'unknown'} ${modelName ?? ''}`}</text>
|
|
174
|
+
<text>{`${osName ?? 'unknown OS'} ${osVersion ?? ''}`}</text>
|
|
175
|
+
<text>{deviceName ?? 'unnamed device'}</text>
|
|
176
|
+
<text>{uptime === null ? 'checking uptime…' : `Uptime: ${uptime}ms`}</text>
|
|
177
|
+
<text>
|
|
178
|
+
{maxMemory === null ? 'checking memory…' : `Max memory: ${maxMemory} bytes`}
|
|
179
|
+
</text>
|
|
180
|
+
</view>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
// Solid — a component body runs once, so the two async values need a signal; the eager
|
|
185
|
+
// constants (brand, modelName, ...) are plain reads with nothing to subscribe to.
|
|
186
|
+
import { createSignal, onMount } from 'solid-js';
|
|
187
|
+
import {
|
|
188
|
+
brand,
|
|
189
|
+
deviceName,
|
|
190
|
+
getMaxMemoryAsync,
|
|
191
|
+
getUptimeAsync,
|
|
192
|
+
isDevice,
|
|
193
|
+
modelName,
|
|
194
|
+
osName,
|
|
195
|
+
osVersion,
|
|
196
|
+
} from '@symbiote-native/device/solid';
|
|
197
|
+
|
|
198
|
+
function DeviceScreen() {
|
|
199
|
+
const [uptime, setUptime] = createSignal<number | null>(null);
|
|
200
|
+
const [maxMemory, setMaxMemory] = createSignal<number | null>(null);
|
|
201
|
+
|
|
202
|
+
onMount(() => {
|
|
203
|
+
void getUptimeAsync().then(setUptime);
|
|
204
|
+
void getMaxMemoryAsync().then(setMaxMemory);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<view>
|
|
209
|
+
<text>{isDevice ? 'Real device' : 'Simulator/emulator'}</text>
|
|
210
|
+
<text>{`${brand ?? 'unknown'} ${modelName ?? ''}`}</text>
|
|
211
|
+
<text>{`${osName ?? 'unknown OS'} ${osVersion ?? ''}`}</text>
|
|
212
|
+
<text>{deviceName ?? 'unnamed device'}</text>
|
|
213
|
+
<text>
|
|
214
|
+
{uptime() === null ? 'checking uptime…' : `Uptime: ${uptime()}ms`}
|
|
215
|
+
</text>
|
|
216
|
+
<text>
|
|
217
|
+
{maxMemory() === null
|
|
218
|
+
? 'checking memory…'
|
|
219
|
+
: `Max memory: ${maxMemory()} bytes`}
|
|
220
|
+
</text>
|
|
221
|
+
</view>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
149
226
|
```ts
|
|
150
227
|
// Angular
|
|
151
228
|
import { Component, signal } from '@angular/core';
|
|
152
|
-
import {
|
|
229
|
+
import { SYMBIOTE_ELEMENTS } from '@symbiote-native/angular';
|
|
153
230
|
import {
|
|
154
231
|
brand,
|
|
155
232
|
deviceName,
|
|
@@ -163,22 +240,22 @@ import {
|
|
|
163
240
|
|
|
164
241
|
@Component({
|
|
165
242
|
standalone: true,
|
|
166
|
-
imports: [
|
|
243
|
+
imports: [SYMBIOTE_ELEMENTS],
|
|
167
244
|
template: `
|
|
168
|
-
<
|
|
169
|
-
<
|
|
170
|
-
<
|
|
171
|
-
<
|
|
172
|
-
<
|
|
173
|
-
<
|
|
245
|
+
<view>
|
|
246
|
+
<text>{{ isDevice ? 'Real device' : 'Simulator/emulator' }}</text>
|
|
247
|
+
<text>{{ brand ?? 'unknown' }} {{ modelName ?? '' }}</text>
|
|
248
|
+
<text>{{ osName ?? 'unknown OS' }} {{ osVersion ?? '' }}</text>
|
|
249
|
+
<text>{{ deviceName ?? 'unnamed device' }}</text>
|
|
250
|
+
<text>{{
|
|
174
251
|
uptime() === null ? 'checking uptime…' : 'Uptime: ' + uptime() + 'ms'
|
|
175
|
-
}}</
|
|
176
|
-
<
|
|
252
|
+
}}</text>
|
|
253
|
+
<text>{{
|
|
177
254
|
maxMemory() === null
|
|
178
255
|
? 'checking memory…'
|
|
179
256
|
: 'Max memory: ' + maxMemory() + ' bytes'
|
|
180
|
-
}}</
|
|
181
|
-
</
|
|
257
|
+
}}</text>
|
|
258
|
+
</view>
|
|
182
259
|
`,
|
|
183
260
|
})
|
|
184
261
|
export class DeviceScreen {
|
|
@@ -208,8 +285,8 @@ These snippets mirror the real canary demo screens — `examples/expo-react/scre
|
|
|
208
285
|
## API
|
|
209
286
|
|
|
210
287
|
Eagerly-resolved constants, plus a handful of one-shot async functions — no event stream, no
|
|
211
|
-
per-instance state — so the React/Vue/Angular entry points above are plain
|
|
212
|
-
with nothing adapter-specific to add.
|
|
288
|
+
per-instance state — so the React/Vue/Svelte/Solid/Angular entry points above are plain
|
|
289
|
+
re-exports of `core` with nothing adapter-specific to add.
|
|
213
290
|
|
|
214
291
|
```ts
|
|
215
292
|
// Constants — resolved once, at import time, straight off the native module:
|
|
@@ -250,6 +327,8 @@ import { getDeviceTypeAsync, isDevice } from '@symbiote-native/device';
|
|
|
250
327
|
// or the framework-scoped entry points — identical surface, re-exported verbatim:
|
|
251
328
|
import { getDeviceTypeAsync } from '@symbiote-native/device/react';
|
|
252
329
|
import { getDeviceTypeAsync } from '@symbiote-native/device/vue';
|
|
330
|
+
import { getDeviceTypeAsync } from '@symbiote-native/device/svelte';
|
|
331
|
+
import { getDeviceTypeAsync } from '@symbiote-native/device/solid';
|
|
253
332
|
import { getDeviceTypeAsync } from '@symbiote-native/device/angular';
|
|
254
333
|
```
|
|
255
334
|
|
|
@@ -273,9 +352,10 @@ the real `requireNativeModule` resolution (`src/core/device.test.ts`, `vitest`)
|
|
|
273
352
|
`installFabric()`, no ViewConfig. Native rendering itself is verified on-device (see the parent
|
|
274
353
|
[README](../../README.md) for the project's testing model).
|
|
275
354
|
|
|
276
|
-
Native autolinking wiring for `expo-modules-core` packages is already done in
|
|
355
|
+
Native autolinking wiring for `expo-modules-core` packages is already done in all six Expo
|
|
277
356
|
canary apps (`examples/expo-react`, `examples/expo-vue-sfc`, `examples/expo-vue-tsx`,
|
|
278
|
-
`examples/expo-
|
|
357
|
+
`examples/expo-svelte`, `examples/expo-solid`, `examples/expo-angular`) via
|
|
358
|
+
`@symbiote-native/local-auth`/`@symbiote-native/sensors` — this
|
|
279
359
|
package reuses that same wiring with zero further app-side changes, since
|
|
280
360
|
`expo-modules-autolinking` discovers any `expo-modules-core` package already present in
|
|
281
361
|
`node_modules`. A dedicated `DeviceScreen` demo has not been wired into those canaries yet.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/device",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "expo-device wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. Device brand/model/OS constants, uptime, max-memory, root/jailbreak detection, side-loading detection, and platform-feature queries.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,6 +13,18 @@
|
|
|
13
13
|
"url": "https://github.com/OneEyed1366/symbiote-native/issues"
|
|
14
14
|
},
|
|
15
15
|
"author": "Andrey Prokopenko <psevdoproger@gmail.com>",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"symbiote-native",
|
|
19
|
+
"expo-device",
|
|
20
|
+
"react",
|
|
21
|
+
"vue",
|
|
22
|
+
"svelte",
|
|
23
|
+
"solid",
|
|
24
|
+
"angular",
|
|
25
|
+
"device-info",
|
|
26
|
+
"root-detection"
|
|
27
|
+
],
|
|
16
28
|
"type": "module",
|
|
17
29
|
"main": "./build/core/index.js",
|
|
18
30
|
"module": "./build/core/index.js",
|
|
@@ -61,19 +73,19 @@
|
|
|
61
73
|
"expo-modules-core": "57.0.5"
|
|
62
74
|
},
|
|
63
75
|
"peerDependencies": {
|
|
64
|
-
"@symbiote-native/angular": ">=0.6.2",
|
|
65
|
-
"@symbiote-native/engine": ">=0.1.7",
|
|
66
|
-
"@symbiote-native/react": ">=0.2.8",
|
|
67
|
-
"@symbiote-native/solid": ">=0.0.1",
|
|
68
|
-
"@symbiote-native/svelte": ">=0.1.0",
|
|
69
|
-
"@symbiote-native/vue": ">=0.3.8",
|
|
70
76
|
"@angular/core": ">=20",
|
|
71
77
|
"@vue/runtime-core": "^3.5.13",
|
|
72
78
|
"react": ">=19.0.0",
|
|
73
79
|
"react-native": ">=0.86",
|
|
74
80
|
"solid-js": ">=1.9.0",
|
|
75
81
|
"svelte": ">=5.56.0",
|
|
76
|
-
"vue": ">=3.5.0"
|
|
82
|
+
"vue": ">=3.5.0",
|
|
83
|
+
"@symbiote-native/angular": "^2.0.0",
|
|
84
|
+
"@symbiote-native/engine": "^0.5.0",
|
|
85
|
+
"@symbiote-native/react": "^2.0.0",
|
|
86
|
+
"@symbiote-native/solid": "^2.0.0",
|
|
87
|
+
"@symbiote-native/svelte": "^2.0.0",
|
|
88
|
+
"@symbiote-native/vue": "^2.0.0"
|
|
77
89
|
},
|
|
78
90
|
"peerDependenciesMeta": {
|
|
79
91
|
"@symbiote-native/angular": {
|
|
@@ -121,13 +133,13 @@
|
|
|
121
133
|
"solid-js": "^1.9.14",
|
|
122
134
|
"svelte": "^5.56.0",
|
|
123
135
|
"typescript": "~6.0.0",
|
|
124
|
-
"@symbiote-native/angular": "0.
|
|
125
|
-
"@symbiote-native/engine": "0.
|
|
126
|
-
"@symbiote-native/react": "0.
|
|
127
|
-
"@symbiote-native/solid": "0.
|
|
128
|
-
"@symbiote-native/svelte": "0.
|
|
129
|
-
"@symbiote-native/test-utils": "0.
|
|
130
|
-
"@symbiote-native/vue": "0.
|
|
136
|
+
"@symbiote-native/angular": "2.0.0",
|
|
137
|
+
"@symbiote-native/engine": "0.5.0",
|
|
138
|
+
"@symbiote-native/react": "2.0.0",
|
|
139
|
+
"@symbiote-native/solid": "2.0.0",
|
|
140
|
+
"@symbiote-native/svelte": "2.0.0",
|
|
141
|
+
"@symbiote-native/test-utils": "0.3.0",
|
|
142
|
+
"@symbiote-native/vue": "2.0.0"
|
|
131
143
|
},
|
|
132
144
|
"scripts": {
|
|
133
145
|
"typecheck": "tsc --build",
|