nativine 1.0.2
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 +410 -0
- package/dist/core/bridge.d.ts +52 -0
- package/dist/core/platform.d.ts +15 -0
- package/dist/index.d.ts +182 -0
- package/dist/modules/ads.d.ts +40 -0
- package/dist/modules/auth.d.ts +45 -0
- package/dist/modules/biometrics.d.ts +60 -0
- package/dist/modules/cache.d.ts +25 -0
- package/dist/modules/camera.d.ts +35 -0
- package/dist/modules/clipboard.d.ts +28 -0
- package/dist/modules/contacts.d.ts +28 -0
- package/dist/modules/device.d.ts +84 -0
- package/dist/modules/downloads.d.ts +31 -0
- package/dist/modules/events.d.ts +55 -0
- package/dist/modules/haptics.d.ts +44 -0
- package/dist/modules/location.d.ts +31 -0
- package/dist/modules/navigation.d.ts +60 -0
- package/dist/modules/network.d.ts +54 -0
- package/dist/modules/onesignal.d.ts +70 -0
- package/dist/modules/pedometer.d.ts +66 -0
- package/dist/modules/print.d.ts +14 -0
- package/dist/modules/reviews.d.ts +19 -0
- package/dist/modules/screenshot.d.ts +21 -0
- package/dist/modules/share.d.ts +46 -0
- package/dist/modules/storage.d.ts +56 -0
- package/dist/modules/toast.d.ts +19 -0
- package/dist/modules/ui.d.ts +109 -0
- package/dist/modules/updates.d.ts +15 -0
- package/dist/nativine.cjs.js +1984 -0
- package/dist/nativine.cjs.js.map +1 -0
- package/dist/nativine.esm.js +1954 -0
- package/dist/nativine.esm.js.map +1 -0
- package/dist/nativine.umd.js +2 -0
- package/dist/nativine.umd.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://assets.nativine.com/asset-1784820238974-121251783.png" alt="Nativine" width="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">nativine</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
The most powerful JavaScript bridge ever made for WebViews.<br>
|
|
9
|
+
Access 50+ native device APIs from your web app with TypeScript support.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/nativine"><img src="https://img.shields.io/npm/v/nativine.svg" alt="npm version" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/nativine"><img src="https://img.shields.io/npm/dm/nativine.svg" alt="npm downloads" /></a>
|
|
15
|
+
<a href="https://bundlephobia.com/package/nativine"><img src="https://img.shields.io/bundlephobia/minzip/nativine" alt="bundle size" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/nativine"><img src="https://img.shields.io/npm/l/nativine.svg" alt="license" /></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **50+ native APIs** across 12 namespaces
|
|
24
|
+
- **TypeScript-first** with full type declarations
|
|
25
|
+
- **Promise-based** async methods (no string callbacks)
|
|
26
|
+
- **3 output formats**: ESM, CJS, UMD (CDN-ready)
|
|
27
|
+
- **Tree-shakeable** — import only what you need
|
|
28
|
+
- **Graceful web fallback** — every method safely no-ops in browsers
|
|
29
|
+
- **Event system** — subscribe to `appResume`, `appPause`, `keyboardShow` events
|
|
30
|
+
- **Zero dependencies** in production
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### npm / yarn / pnpm
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install nativine
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import nativine from 'nativine';
|
|
42
|
+
|
|
43
|
+
if (nativine.isNativeApp) {
|
|
44
|
+
const info = await nativine.device.getInfo();
|
|
45
|
+
console.log(`Running on ${info.model} (${info.platform})`);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### CDN / Script Tag
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<script src="https://cdn.jsdelivr.net/npm/nativine@latest/dist/nativine.umd.js"></script>
|
|
53
|
+
<script>
|
|
54
|
+
if (Nativine.default.isNativeApp) {
|
|
55
|
+
Nativine.default.haptics.vibrate(200);
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## API Reference
|
|
63
|
+
|
|
64
|
+
### Detection
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
nativine.isNativeApp // boolean — true if inside a Nativine app
|
|
68
|
+
nativine.platform // 'android' | 'ios' | 'web'
|
|
69
|
+
nativine.isAndroid // boolean
|
|
70
|
+
nativine.isIos // boolean
|
|
71
|
+
nativine.version // SDK version string
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 📱 Device
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const info = await nativine.device.getInfo();
|
|
80
|
+
// { model, manufacturer, osVersion, appVersion, appVersionCode,
|
|
81
|
+
// packageName, locale, screenWidth, screenHeight, density, platform }
|
|
82
|
+
|
|
83
|
+
const insets = await nativine.device.getSafeAreaInsets();
|
|
84
|
+
// { top, bottom, left, right }
|
|
85
|
+
|
|
86
|
+
const version = await nativine.device.getAppVersion();
|
|
87
|
+
// "1.2.0"
|
|
88
|
+
|
|
89
|
+
const id = await nativine.device.getDeviceId();
|
|
90
|
+
// "a1b2c3d4-..." (anonymous, per-installation)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 🎨 UI
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
nativine.ui.statusBar({ color: '#1a1a2e', style: 'light' });
|
|
99
|
+
nativine.ui.navigationBar({ color: '#16213e' });
|
|
100
|
+
nativine.ui.hideSplashScreen();
|
|
101
|
+
nativine.ui.setOrientation('landscape'); // 'portrait' | 'landscape' | 'auto'
|
|
102
|
+
nativine.ui.showNativeComponents();
|
|
103
|
+
nativine.ui.hideNativeComponents();
|
|
104
|
+
nativine.ui.setPullToRefresh(false);
|
|
105
|
+
nativine.ui.setPinchToZoom(true);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### 🧭 Navigation
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
nativine.navigation.goBack();
|
|
114
|
+
nativine.navigation.goForward();
|
|
115
|
+
nativine.navigation.navigate('/products');
|
|
116
|
+
nativine.navigation.openInBrowser('https://docs.nativine.com');
|
|
117
|
+
nativine.navigation.closeApp();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### 📳 Haptics
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
nativine.haptics.vibrate(200); // duration in ms
|
|
126
|
+
|
|
127
|
+
nativine.haptics.feedback('light'); // light tap
|
|
128
|
+
nativine.haptics.feedback('medium'); // standard tap
|
|
129
|
+
nativine.haptics.feedback('heavy'); // strong tap
|
|
130
|
+
nativine.haptics.feedback('success'); // double tap pattern
|
|
131
|
+
nativine.haptics.feedback('error'); // triple tap pattern
|
|
132
|
+
nativine.haptics.feedback('warning');
|
|
133
|
+
nativine.haptics.feedback('selection');
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 💾 Storage (Persistent)
|
|
139
|
+
|
|
140
|
+
Data stored here survives WebView cache clears (uses SharedPreferences / UserDefaults).
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
nativine.storage.set('auth_token', 'abc123');
|
|
144
|
+
const token = nativine.storage.get('auth_token'); // 'abc123'
|
|
145
|
+
const user = nativine.storage.get('missing_key', '{}'); // '{}'
|
|
146
|
+
nativine.storage.remove('auth_token');
|
|
147
|
+
nativine.storage.clear();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 📤 Share
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
nativine.share({
|
|
156
|
+
title: 'Check this out!',
|
|
157
|
+
text: 'Amazing content',
|
|
158
|
+
url: 'https://example.com'
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
nativine.shareFile({
|
|
162
|
+
filePath: '/storage/emulated/0/Download/report.pdf',
|
|
163
|
+
mimeType: 'application/pdf'
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### 🔐 Auth
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
// Google Sign-In
|
|
173
|
+
const user = await nativine.auth.googleSignIn();
|
|
174
|
+
// { email, displayName, idToken, photoUrl, id }
|
|
175
|
+
|
|
176
|
+
await nativine.auth.googleSignOut();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### 🔒 Biometrics
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
const { available, biometryType } = await nativine.biometrics.isAvailable();
|
|
185
|
+
// { available: true, biometryType: 'fingerprint' | 'face' | 'iris' }
|
|
186
|
+
|
|
187
|
+
const result = await nativine.biometrics.authenticate({
|
|
188
|
+
reason: 'Verify identity',
|
|
189
|
+
allowFallback: true
|
|
190
|
+
});
|
|
191
|
+
// { success: true }
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### 👥 Contacts
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
const contacts = await nativine.contacts.getAll();
|
|
200
|
+
// [{ name, phone, email }, ...]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### 📋 Clipboard
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
await nativine.clipboard.copy('Copied text!');
|
|
209
|
+
const text = await nativine.clipboard.read();
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### 📥 Downloads
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
nativine.downloads.downloadFile({
|
|
218
|
+
url: 'https://example.com/report.pdf',
|
|
219
|
+
filename: 'monthly-report.pdf',
|
|
220
|
+
openAfterDownload: true
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### 📷 Scanner
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const result = await nativine.scanner.scan();
|
|
230
|
+
// { value: 'https://example.com', format: 'QR_CODE' }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### 📍 Location
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
const loc = await nativine.location.getCurrent();
|
|
239
|
+
// { latitude, longitude, accuracy, altitude?, speed? }
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### 🌐 Network
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
const status = await nativine.network.isOnline();
|
|
248
|
+
// { online: true, type: 'wifi' | 'cellular' | 'none' }
|
|
249
|
+
|
|
250
|
+
const unsubscribe = nativine.network.onConnectivityChange((status) => {
|
|
251
|
+
console.log(status.online ? 'Online' : 'Offline');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Later: stop listening
|
|
255
|
+
unsubscribe();
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### 🗑️ Cache
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
nativine.cache.clear();
|
|
264
|
+
nativine.cache.clearCookies();
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### 🖨️ Print
|
|
270
|
+
|
|
271
|
+
```javascript
|
|
272
|
+
nativine.print();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### 🛡️ Screenshot Protection
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
nativine.screenshot.setProtection(true); // Block screenshots
|
|
281
|
+
nativine.screenshot.setProtection(false); // Allow screenshots
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### ⭐ Reviews
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
nativine.reviews.request(); // Triggers Google Play / App Store review dialog
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### 🔄 Updates
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
nativine.updates.check(); // Triggers in-app update check (Android)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
### 📺 Ads
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
nativine.ads.showInterstitial();
|
|
306
|
+
|
|
307
|
+
const reward = await nativine.ads.showRewarded();
|
|
308
|
+
if (reward.rewarded) {
|
|
309
|
+
unlockPremiumContent();
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
### 🔔 OneSignal
|
|
316
|
+
|
|
317
|
+
```javascript
|
|
318
|
+
nativine.onesignal.setExternalUserId('user_123');
|
|
319
|
+
nativine.onesignal.sendTag('plan', 'premium');
|
|
320
|
+
nativine.onesignal.sendTags({ plan: 'premium', language: 'en' });
|
|
321
|
+
const playerId = await nativine.onesignal.getPlayerId();
|
|
322
|
+
nativine.onesignal.removeExternalUserId();
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
### 🏃 Pedometer / Step Counter
|
|
328
|
+
|
|
329
|
+
```javascript
|
|
330
|
+
// Check availability
|
|
331
|
+
const { available } = await nativine.pedometer.isAvailable();
|
|
332
|
+
|
|
333
|
+
if (available) {
|
|
334
|
+
// Start tracking
|
|
335
|
+
nativine.pedometer.startTracking();
|
|
336
|
+
|
|
337
|
+
// Listen for real-time updates
|
|
338
|
+
nativine.on('stepUpdate', ({ steps }) => {
|
|
339
|
+
console.log(`Current steps: ${steps}`);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// Or fetch manually
|
|
343
|
+
const { steps } = await nativine.pedometer.getStepCount();
|
|
344
|
+
|
|
345
|
+
// Stop tracking when done
|
|
346
|
+
nativine.pedometer.stopTracking();
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
### 💬 Toast
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
nativine.toast('Item added to cart!');
|
|
356
|
+
nativine.toast('Processing...', 'long'); // 'short' (~2s) or 'long' (~3.5s)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
### 📡 Events
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
// App lifecycle
|
|
365
|
+
nativine.on('appResume', () => fetchLatestData());
|
|
366
|
+
nativine.on('appPause', () => saveState());
|
|
367
|
+
|
|
368
|
+
// Bridge ready
|
|
369
|
+
nativine.on('pageReady', () => initializeApp());
|
|
370
|
+
|
|
371
|
+
// Keyboard
|
|
372
|
+
nativine.on('keyboardShow', ({ height }) => adjustLayout(height));
|
|
373
|
+
nativine.on('keyboardHide', () => resetLayout());
|
|
374
|
+
|
|
375
|
+
// Unsubscribe
|
|
376
|
+
const unsub = nativine.on('appResume', handler);
|
|
377
|
+
unsub(); // Remove this specific listener
|
|
378
|
+
|
|
379
|
+
// Remove all listeners for an event
|
|
380
|
+
nativine.off('appResume');
|
|
381
|
+
|
|
382
|
+
// Remove ALL listeners
|
|
383
|
+
nativine.off();
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Tree Shaking
|
|
389
|
+
|
|
390
|
+
Import only the modules you need to minimize bundle size:
|
|
391
|
+
|
|
392
|
+
```javascript
|
|
393
|
+
import { haptics, device, isNativeApp } from 'nativine';
|
|
394
|
+
|
|
395
|
+
if (isNativeApp) {
|
|
396
|
+
haptics.vibrate(100);
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Requirements
|
|
403
|
+
|
|
404
|
+
- Nativine app built with template v2.0+
|
|
405
|
+
- Android 7.0+ (API 24+)
|
|
406
|
+
- iOS 14+ (coming soon)
|
|
407
|
+
|
|
408
|
+
## License
|
|
409
|
+
|
|
410
|
+
ISC © [Nativine](https://nativine.com)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nativine Bridge Dispatcher
|
|
3
|
+
*
|
|
4
|
+
* Low-level bridge call mechanism that provides a unified, Promise-based interface
|
|
5
|
+
* for communicating with the native Android/iOS app shell.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - Android: Calls `window.nativine.<method>(args, callbackId)` via @JavascriptInterface
|
|
9
|
+
* - iOS: Calls `window.webkit.messageHandlers.nativine.postMessage({ method, args, callbackId })`
|
|
10
|
+
* - Web: Returns rejected promises or no-ops gracefully
|
|
11
|
+
*
|
|
12
|
+
* The native side resolves the Promise by calling: `window[callbackId](jsonResult)`
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when a bridge method is called outside a native app context.
|
|
16
|
+
*/
|
|
17
|
+
export declare class NativineNotAvailableError extends Error {
|
|
18
|
+
constructor(method: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when a bridge call times out waiting for native response.
|
|
22
|
+
*/
|
|
23
|
+
export declare class NativineTimeoutError extends Error {
|
|
24
|
+
constructor(method: string, timeoutMs: number);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Makes an async call to the native bridge and returns a Promise that resolves
|
|
28
|
+
* when the native side responds via the callback.
|
|
29
|
+
*
|
|
30
|
+
* @param method - The native method name to call (e.g., 'getDeviceInfo')
|
|
31
|
+
* @param args - Optional arguments to pass to the native method (serialized as JSON string)
|
|
32
|
+
* @param timeoutMs - Timeout in milliseconds (default: 10s)
|
|
33
|
+
* @returns Promise that resolves with the parsed native response
|
|
34
|
+
*/
|
|
35
|
+
export declare function callNativeAsync<T = any>(method: string, args?: Record<string, any>, timeoutMs?: number): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Makes a synchronous (fire-and-forget) call to the native bridge.
|
|
38
|
+
* Used for methods that don't need a return value (e.g., vibrate, statusBar).
|
|
39
|
+
*
|
|
40
|
+
* @param method - The native method name to call
|
|
41
|
+
* @param args - Optional arguments
|
|
42
|
+
*/
|
|
43
|
+
export declare function callNativeSync(method: string, args?: Record<string, any>): void;
|
|
44
|
+
/**
|
|
45
|
+
* Calls a native method that returns a synchronous value via @JavascriptInterface.
|
|
46
|
+
* Only works on Android where @JavascriptInterface methods can return values directly.
|
|
47
|
+
*
|
|
48
|
+
* @param method - The native method name
|
|
49
|
+
* @param args - Arguments to pass
|
|
50
|
+
* @returns The return value from the native method, or undefined
|
|
51
|
+
*/
|
|
52
|
+
export declare function callNativeDirect<T = any>(method: string, ...args: any[]): T | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nativine Platform Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects whether the web page is running inside a Nativine-powered native app
|
|
5
|
+
* and identifies the platform (Android, iOS, or Web).
|
|
6
|
+
*/
|
|
7
|
+
export type Platform = 'android' | 'ios' | 'web';
|
|
8
|
+
/** The detected platform: `'android'`, `'ios'`, or `'web'` */
|
|
9
|
+
export declare const platform: Platform;
|
|
10
|
+
/** `true` if the page is running inside a Nativine native app (Android or iOS) */
|
|
11
|
+
export declare const isNativeApp: boolean;
|
|
12
|
+
/** `true` if the page is running inside a Nativine Android app */
|
|
13
|
+
export declare const isAndroid: boolean;
|
|
14
|
+
/** `true` if the page is running inside a Nativine iOS app */
|
|
15
|
+
export declare const isIos: boolean;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nativine JavaScript Bridge
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-grade bridge for communicating between web apps and Nativine native shells.
|
|
5
|
+
* Provides 50+ APIs across 12 namespaces with full TypeScript support, Promise-based
|
|
6
|
+
* async methods, and graceful web fallbacks.
|
|
7
|
+
*
|
|
8
|
+
* @example ESM (recommended)
|
|
9
|
+
* ```js
|
|
10
|
+
* import nativine from 'nativine';
|
|
11
|
+
*
|
|
12
|
+
* if (nativine.isNativeApp) {
|
|
13
|
+
* const info = await nativine.device.getInfo();
|
|
14
|
+
* nativine.haptics.vibrate(200);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example CDN / Script tag
|
|
19
|
+
* ```html
|
|
20
|
+
* <script src="https://cdn.jsdelivr.net/npm/nativine@latest/dist/nativine.umd.js"></script>
|
|
21
|
+
* <script>
|
|
22
|
+
* if (Nativine.isNativeApp) {
|
|
23
|
+
* Nativine.haptics.vibrate(200);
|
|
24
|
+
* }
|
|
25
|
+
* </script>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @packageDocumentation
|
|
29
|
+
*/
|
|
30
|
+
import { platform, isNativeApp, isAndroid, isIos } from './core/platform';
|
|
31
|
+
import type { Platform } from './core/platform';
|
|
32
|
+
import * as device from './modules/device';
|
|
33
|
+
import * as ui from './modules/ui';
|
|
34
|
+
import * as navigation from './modules/navigation';
|
|
35
|
+
import * as haptics from './modules/haptics';
|
|
36
|
+
import * as storage from './modules/storage';
|
|
37
|
+
import * as shareModule from './modules/share';
|
|
38
|
+
import * as auth from './modules/auth';
|
|
39
|
+
import * as biometrics from './modules/biometrics';
|
|
40
|
+
import * as contacts from './modules/contacts';
|
|
41
|
+
import * as clipboard from './modules/clipboard';
|
|
42
|
+
import * as downloads from './modules/downloads';
|
|
43
|
+
import * as scanner from './modules/camera';
|
|
44
|
+
import * as location from './modules/location';
|
|
45
|
+
import * as network from './modules/network';
|
|
46
|
+
import * as cache from './modules/cache';
|
|
47
|
+
import * as printModule from './modules/print';
|
|
48
|
+
import * as screenshot from './modules/screenshot';
|
|
49
|
+
import * as reviews from './modules/reviews';
|
|
50
|
+
import * as updates from './modules/updates';
|
|
51
|
+
import * as ads from './modules/ads';
|
|
52
|
+
import * as onesignal from './modules/onesignal';
|
|
53
|
+
import * as toastModule from './modules/toast';
|
|
54
|
+
import * as pedometer from './modules/pedometer';
|
|
55
|
+
import { on, off } from './modules/events';
|
|
56
|
+
declare const nativine: {
|
|
57
|
+
/** The detected platform: `'android'`, `'ios'`, or `'web'` */
|
|
58
|
+
platform: Platform;
|
|
59
|
+
/** `true` if running inside a Nativine native app */
|
|
60
|
+
isNativeApp: boolean;
|
|
61
|
+
/** `true` if running inside a Nativine Android app */
|
|
62
|
+
isAndroid: boolean;
|
|
63
|
+
/** `true` if running inside a Nativine iOS app */
|
|
64
|
+
isIos: boolean;
|
|
65
|
+
/** The version of this SDK */
|
|
66
|
+
version: string;
|
|
67
|
+
device: {
|
|
68
|
+
getInfo: typeof device.getInfo;
|
|
69
|
+
getSafeAreaInsets: typeof device.getSafeAreaInsets;
|
|
70
|
+
getAppVersion: typeof device.getAppVersion;
|
|
71
|
+
getDeviceId: typeof device.getDeviceId;
|
|
72
|
+
};
|
|
73
|
+
ui: {
|
|
74
|
+
statusBar: typeof ui.statusBar;
|
|
75
|
+
navigationBar: typeof ui.navigationBar;
|
|
76
|
+
hideSplashScreen: typeof ui.hideSplashScreen;
|
|
77
|
+
setOrientation: typeof ui.setOrientation;
|
|
78
|
+
showNativeComponents: typeof ui.showNativeComponents;
|
|
79
|
+
hideNativeComponents: typeof ui.hideNativeComponents;
|
|
80
|
+
setPullToRefresh: typeof ui.setPullToRefresh;
|
|
81
|
+
setPinchToZoom: typeof ui.setPinchToZoom;
|
|
82
|
+
};
|
|
83
|
+
navigation: {
|
|
84
|
+
goBack: typeof navigation.goBack;
|
|
85
|
+
goForward: typeof navigation.goForward;
|
|
86
|
+
navigate: typeof navigation.navigate;
|
|
87
|
+
openInBrowser: typeof navigation.openInBrowser;
|
|
88
|
+
closeApp: typeof navigation.closeApp;
|
|
89
|
+
};
|
|
90
|
+
haptics: {
|
|
91
|
+
vibrate: typeof haptics.vibrate;
|
|
92
|
+
feedback: typeof haptics.feedback;
|
|
93
|
+
};
|
|
94
|
+
storage: {
|
|
95
|
+
set: typeof storage.set;
|
|
96
|
+
get: typeof storage.get;
|
|
97
|
+
remove: typeof storage.remove;
|
|
98
|
+
clear: typeof storage.clear;
|
|
99
|
+
};
|
|
100
|
+
share: typeof shareModule.share;
|
|
101
|
+
shareFile: typeof shareModule.shareFile;
|
|
102
|
+
auth: {
|
|
103
|
+
googleSignIn: typeof auth.googleSignIn;
|
|
104
|
+
googleSignOut: typeof auth.googleSignOut;
|
|
105
|
+
};
|
|
106
|
+
biometrics: {
|
|
107
|
+
isAvailable: typeof biometrics.isAvailable;
|
|
108
|
+
authenticate: typeof biometrics.authenticate;
|
|
109
|
+
};
|
|
110
|
+
contacts: {
|
|
111
|
+
getAll: typeof contacts.getAll;
|
|
112
|
+
};
|
|
113
|
+
clipboard: {
|
|
114
|
+
copy: typeof clipboard.copy;
|
|
115
|
+
read: typeof clipboard.read;
|
|
116
|
+
};
|
|
117
|
+
downloads: {
|
|
118
|
+
downloadFile: typeof downloads.downloadFile;
|
|
119
|
+
};
|
|
120
|
+
scanner: {
|
|
121
|
+
scan: typeof scanner.scan;
|
|
122
|
+
};
|
|
123
|
+
location: {
|
|
124
|
+
getCurrent: typeof location.getCurrent;
|
|
125
|
+
};
|
|
126
|
+
network: {
|
|
127
|
+
isOnline: typeof network.isOnline;
|
|
128
|
+
onConnectivityChange: typeof network.onConnectivityChange;
|
|
129
|
+
};
|
|
130
|
+
cache: {
|
|
131
|
+
clear: typeof cache.clear;
|
|
132
|
+
clearCookies: typeof cache.clearCookies;
|
|
133
|
+
};
|
|
134
|
+
print: typeof printModule.printPage;
|
|
135
|
+
screenshot: {
|
|
136
|
+
setProtection: typeof screenshot.setProtection;
|
|
137
|
+
};
|
|
138
|
+
reviews: {
|
|
139
|
+
request: typeof reviews.request;
|
|
140
|
+
};
|
|
141
|
+
updates: {
|
|
142
|
+
check: typeof updates.check;
|
|
143
|
+
};
|
|
144
|
+
ads: {
|
|
145
|
+
showInterstitial: typeof ads.showInterstitial;
|
|
146
|
+
showRewarded: typeof ads.showRewarded;
|
|
147
|
+
};
|
|
148
|
+
onesignal: {
|
|
149
|
+
setExternalUserId: typeof onesignal.setExternalUserId;
|
|
150
|
+
removeExternalUserId: typeof onesignal.removeExternalUserId;
|
|
151
|
+
sendTag: typeof onesignal.sendTag;
|
|
152
|
+
sendTags: typeof onesignal.sendTags;
|
|
153
|
+
getPlayerId: typeof onesignal.getPlayerId;
|
|
154
|
+
};
|
|
155
|
+
toast: typeof toastModule.showToast;
|
|
156
|
+
pedometer: {
|
|
157
|
+
isAvailable: typeof pedometer.isAvailable;
|
|
158
|
+
getStepCount: typeof pedometer.getStepCount;
|
|
159
|
+
startTracking: typeof pedometer.startTracking;
|
|
160
|
+
stopTracking: typeof pedometer.stopTracking;
|
|
161
|
+
};
|
|
162
|
+
on: typeof on;
|
|
163
|
+
off: typeof off;
|
|
164
|
+
};
|
|
165
|
+
export default nativine;
|
|
166
|
+
export { platform, isNativeApp, isAndroid, isIos, device, ui, navigation, haptics, storage, auth, biometrics, contacts, clipboard, downloads, scanner, location, network, cache, screenshot, reviews, updates, ads, onesignal, pedometer, on, off, };
|
|
167
|
+
export type { Platform } from './core/platform';
|
|
168
|
+
export type { NativineEvent } from './modules/events';
|
|
169
|
+
export type { DeviceInfo, SafeAreaInsets } from './modules/device';
|
|
170
|
+
export type { StatusBarOptions, NavigationBarOptions } from './modules/ui';
|
|
171
|
+
export type { HapticFeedbackType } from './modules/haptics';
|
|
172
|
+
export type { ShareOptions, ShareFileOptions } from './modules/share';
|
|
173
|
+
export type { GoogleSignInResult } from './modules/auth';
|
|
174
|
+
export type { BiometricAvailability, BiometricAuthOptions, BiometricAuthResult, BiometryType } from './modules/biometrics';
|
|
175
|
+
export type { Contact } from './modules/contacts';
|
|
176
|
+
export type { DownloadFileOptions } from './modules/downloads';
|
|
177
|
+
export type { ScanResult, ScanOptions } from './modules/camera';
|
|
178
|
+
export type { LocationResult } from './modules/location';
|
|
179
|
+
export type { ConnectivityStatus } from './modules/network';
|
|
180
|
+
export type { ToastDuration } from './modules/toast';
|
|
181
|
+
export type { RewardedAdResult } from './modules/ads';
|
|
182
|
+
export type { StepCountResult, PedometerAvailability } from './modules/pedometer';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ads Module
|
|
3
|
+
*
|
|
4
|
+
* Control AdMob interstitial and rewarded ad display from your web app.
|
|
5
|
+
*/
|
|
6
|
+
export interface RewardedAdResult {
|
|
7
|
+
/** Whether the user watched the full ad and earned the reward */
|
|
8
|
+
rewarded: boolean;
|
|
9
|
+
/** Reward amount (if configured in AdMob) */
|
|
10
|
+
amount?: number;
|
|
11
|
+
/** Reward type (if configured in AdMob) */
|
|
12
|
+
type?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Show a fullscreen interstitial ad.
|
|
16
|
+
* The ad must be pre-loaded by the native app.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```js
|
|
20
|
+
* // Show an ad between content transitions
|
|
21
|
+
* nativine.ads.showInterstitial();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function showInterstitial(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Show a rewarded video ad.
|
|
27
|
+
* Returns a Promise that resolves when the user finishes watching.
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise resolving with the reward result
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```js
|
|
33
|
+
* const result = await nativine.ads.showRewarded();
|
|
34
|
+
* if (result.rewarded) {
|
|
35
|
+
* // Grant premium access for 24 hours
|
|
36
|
+
* unlockPremiumContent();
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function showRewarded(): Promise<RewardedAdResult>;
|