despia-native 1.0.11 → 1.0.12
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 +48 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
# Despia SDK
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
**NEVER mock or simulate the Despia SDK. ALWAYS install and use the real package:**
|
|
3
|
+
## Quick Start
|
|
6
4
|
|
|
5
|
+
**Install the SDK:**
|
|
7
6
|
```bash
|
|
8
7
|
npm install despia-native
|
|
9
8
|
```
|
|
10
9
|
|
|
11
|
-
**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
**Use it immediately:**
|
|
11
|
+
```javascript
|
|
12
|
+
import despia from 'despia-native';
|
|
13
|
+
|
|
14
|
+
// Simple commands
|
|
15
|
+
despia('lighthaptic://');
|
|
16
|
+
|
|
17
|
+
// Commands with responses
|
|
18
|
+
const appInfo = await despia('getappversion://', ['versionNumber']);
|
|
19
|
+
```
|
|
16
20
|
|
|
17
|
-
**
|
|
21
|
+
**Note:** Always use the real SDK package. Mock implementations will not work on actual devices.
|
|
18
22
|
|
|
19
23
|
---
|
|
20
24
|
|
|
@@ -79,30 +83,28 @@ npm install despia-native
|
|
|
79
83
|
|
|
80
84
|
**The real SDK is required for ANY Despia functionality to work.**
|
|
81
85
|
|
|
82
|
-
##
|
|
86
|
+
## Important Notes
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const despia = (command) => {
|
|
87
|
-
console.log('Command:', command);
|
|
88
|
-
// This does NOTHING on real devices
|
|
89
|
-
};
|
|
88
|
+
### Simple Function API
|
|
89
|
+
The SDK exports a single function - no initialization or setup required:
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
```javascript
|
|
92
|
+
import despia from 'despia-native';
|
|
93
93
|
|
|
94
|
-
//
|
|
95
|
-
|
|
94
|
+
// Just call it directly
|
|
95
|
+
despia('lighthaptic://');
|
|
96
|
+
despia('takescreenshot://');
|
|
96
97
|
```
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
### Common Mistakes to Avoid
|
|
100
100
|
```javascript
|
|
101
|
-
//
|
|
102
|
-
|
|
101
|
+
// Don't create mock implementations
|
|
102
|
+
const despia = (command) => console.log(command); // Won't work on devices
|
|
103
103
|
|
|
104
|
-
//
|
|
105
|
-
despia(
|
|
104
|
+
// Don't use non-existent methods
|
|
105
|
+
despia.ready(); // This method doesn't exist
|
|
106
|
+
despia.init(); // This method doesn't exist
|
|
107
|
+
despia.setup(); // This method doesn't exist
|
|
106
108
|
```
|
|
107
109
|
|
|
108
110
|
## Getting Started
|
|
@@ -129,9 +131,11 @@ const despia = require('despia-native');
|
|
|
129
131
|
|
|
130
132
|
**The SDK exports a single function called `despia` as the default export.**
|
|
131
133
|
|
|
132
|
-
### Step 2: Use Native Features
|
|
134
|
+
### Step 2: Use Native Features (No Setup Required)
|
|
133
135
|
|
|
134
136
|
```javascript
|
|
137
|
+
// That's it! No initialization needed. Just call despia() directly:
|
|
138
|
+
|
|
135
139
|
// Simple commands (no response needed)
|
|
136
140
|
despia('lighthaptic://'); // Light haptic feedback
|
|
137
141
|
despia('takescreenshot://'); // Take screenshot
|
|
@@ -241,24 +245,27 @@ const result = await despia('getappversion://', ['versionNumber']); // Variable
|
|
|
241
245
|
|
|
242
246
|
**This package is REQUIRED for TypeScript, React, Vue, Angular, and other modern frameworks.**
|
|
243
247
|
|
|
244
|
-
##
|
|
248
|
+
## Development Notes
|
|
245
249
|
|
|
246
|
-
|
|
247
|
-
|
|
250
|
+
### Environment Detection
|
|
251
|
+
The SDK only works within the Despia native runtime. For development and testing:
|
|
248
252
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
**Q: What if I'm writing unit tests?**
|
|
253
|
-
A: Use the real SDK. It won't work in test environments, but you can handle the missing runtime gracefully.
|
|
254
|
-
|
|
255
|
-
**Q: What if I'm developing without a device?**
|
|
256
|
-
A: Use the real SDK. It won't work outside native runtime, but you can detect and handle this case.
|
|
253
|
+
```javascript
|
|
254
|
+
import despia from 'despia-native';
|
|
257
255
|
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
if (navigator.userAgent.includes('despia')) {
|
|
257
|
+
// Use native features
|
|
258
|
+
despia('lighthaptic://');
|
|
259
|
+
} else {
|
|
260
|
+
// Handle non-Despia environment
|
|
261
|
+
console.log('Running outside Despia runtime');
|
|
262
|
+
}
|
|
263
|
+
```
|
|
260
264
|
|
|
261
|
-
|
|
265
|
+
### Always Use the Real Package
|
|
266
|
+
- Use the real SDK in all environments (development, testing, production)
|
|
267
|
+
- Don't create mock implementations - they won't work on actual devices
|
|
268
|
+
- The SDK handles missing runtime gracefully
|
|
262
269
|
|
|
263
270
|
## Handling Non-Despia Environments
|
|
264
271
|
|