despia-native 1.0.9 → 1.0.11

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.
Files changed (2) hide show
  1. package/README.md +172 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,29 @@
1
1
  # Despia SDK
2
2
 
3
+ ## CRITICAL: ALWAYS USE THE REAL SDK
4
+
5
+ **NEVER mock or simulate the Despia SDK. ALWAYS install and use the real package:**
6
+
7
+ ```bash
8
+ npm install despia-native
9
+ ```
10
+
11
+ **Why?**
12
+ - The SDK handles critical native bridge communication
13
+ - Mocking will break ALL native features
14
+ - Your app will NOT work on actual devices without the real SDK
15
+ - There is NO valid reason to mock this in any scenario
16
+
17
+ **If you see any tutorial, example, or code that creates a fake despia function - it's WRONG.**
18
+
19
+ ---
20
+
3
21
  JavaScript SDK for [Despia](https://despia.com) - Transform your web app into a native iOS & Android app without writing Swift or Kotlin. This npm package provides command queuing and variable watching for seamless integration with Despia's GPU-accelerated native runtime, enabling access to 25+ device APIs through simple JavaScript calls.
4
22
 
23
+ **Import:** `import despia from 'despia-native';` (default export, not destructured)
24
+
25
+ **IMPORTANT: This SDK package is REQUIRED for TypeScript, React, Vue, and other modern frameworks!** While `window.despia = ""` works in vanilla JavaScript, this package provides type safety, command queuing, and variable watching for professional development environments.
26
+
5
27
  ## About Despia
6
28
 
7
29
  Despia bridges the gap between web and native mobile development. Build your app using the web technologies you already know, then deploy it as a truly native application to the App Store and Google Play - complete with hardware acceleration, offline support, and deep OS integration.
@@ -41,28 +63,72 @@ Our visual editor allows you to configure native widgets, shortcuts, and dynamic
41
63
  - **UI Controls** - Loading indicators, navigation bars, dynamic layouts
42
64
  - **Plus 8+ additional native capabilities**
43
65
 
44
- ## Installation
66
+ ## Installation (REQUIRED - NO EXCEPTIONS)
45
67
 
46
68
  ```bash
47
69
  npm install despia-native
48
70
  ```
49
71
 
72
+ **This is NOT optional. Your app will NOT work without this package.**
73
+
74
+ **Do not attempt to:**
75
+ - Write your own version
76
+ - Copy/paste a mock implementation
77
+ - Use window.despia directly in frameworks
78
+ - Create a "simplified" version
79
+
80
+ **The real SDK is required for ANY Despia functionality to work.**
81
+
82
+ ## NEVER DO THIS - YOUR APP WILL NOT WORK
83
+
84
+ ```javascript
85
+ // WRONG - This breaks everything
86
+ const despia = (command) => {
87
+ console.log('Command:', command);
88
+ // This does NOTHING on real devices
89
+ };
90
+
91
+ // WRONG - This also breaks everything
92
+ const mockDespia = () => { /* ... */ };
93
+
94
+ // WRONG - Don't create your own version
95
+ window.despia = 'somecommand://';
96
+ ```
97
+
98
+ ## ALWAYS DO THIS - THE ONLY CORRECT WAY
99
+
100
+ ```javascript
101
+ // CORRECT - The ONLY way to use Despia
102
+ import despia from 'despia-native';
103
+
104
+ // Now your commands actually work
105
+ despia('lighthaptic://'); // Device actually vibrates
106
+ ```
107
+
50
108
  ## Getting Started
51
109
 
52
110
  ### Step 1: Import Despia SDK
53
111
 
112
+ **IMPORTANT: Always import as `despia` (default export), NOT as `{Commands}` or destructured imports!**
113
+
54
114
  ```javascript
55
- // ES6/ES2015 modules
115
+ // CORRECT - ES6/ES2015 modules (default import)
56
116
  import despia from 'despia-native';
57
117
 
58
- // CommonJS
118
+ // CORRECT - CommonJS
59
119
  const despia = require('despia-native');
60
120
 
61
- // Browser (if using UMD build)
121
+ // CORRECT - Browser (if using UMD build)
62
122
  // <script src="despia-native.js"></script>
63
123
  // despia is available globally
124
+
125
+ // WRONG - Don't do this!
126
+ // import { Commands } from 'despia-native';
127
+ // import { despia } from 'despia-native';
64
128
  ```
65
129
 
130
+ **The SDK exports a single function called `despia` as the default export.**
131
+
66
132
  ### Step 2: Use Native Features
67
133
 
68
134
  ```javascript
@@ -113,6 +179,108 @@ despia('takescreenshot://');
113
179
  despia('shareapp://message?=Hello&url=https://myapp.com');
114
180
  ```
115
181
 
182
+ ### Common Import Issues
183
+
184
+ **If you get errors like "Commands is not a function" or "despia is not defined":**
185
+
186
+ ```javascript
187
+ // WRONG - This will cause errors
188
+ import { Commands } from 'despia-native';
189
+ import { despia } from 'despia-native';
190
+
191
+ // CORRECT - Always use default import
192
+ import despia from 'despia-native';
193
+
194
+ // Now you can use it
195
+ despia('lighthaptic://');
196
+ ```
197
+
198
+ **The package exports a single function as the default export, not named exports.**
199
+
200
+ ## When to Use This SDK Package
201
+
202
+ ### Vanilla JavaScript (works without this package)
203
+
204
+ ```javascript
205
+ // This WORKS in vanilla JavaScript:
206
+ window.despia = 'lighthaptic://';
207
+ window.despia = 'getappversion://';
208
+ ```
209
+
210
+ **Vanilla JS is fine for simple cases, but lacks:**
211
+ - **TypeScript Support** - No type definitions or autocomplete
212
+ - **Command Queuing** - Commands may be lost or executed out of order
213
+ - **Variable Watching** - Can't wait for responses from native commands
214
+ - **Error Handling** - No timeout or error management
215
+ - **Type Safety** - No validation or IntelliSense
216
+
217
+ ### Modern Frameworks Need This Package
218
+
219
+ ```javascript
220
+ // This WON'T work in TypeScript, React, Vue, etc.:
221
+ window.despia = 'lighthaptic://'; // TypeScript errors, no type safety
222
+ window.despia = 'getappversion://'; // No command queuing, no variable watching
223
+ ```
224
+
225
+ ### Modern Frameworks (TypeScript, React, Vue, etc.)
226
+
227
+ ```javascript
228
+ // This WORKS perfectly in modern frameworks:
229
+ import despia from 'despia-native';
230
+
231
+ despia('lighthaptic://'); // Type-safe, queued, with error handling
232
+ const result = await despia('getappversion://', ['versionNumber']); // Variable watching
233
+ ```
234
+
235
+ **Benefits of using this SDK:**
236
+ - **TypeScript Support** - Full type definitions and autocomplete
237
+ - **Command Queuing** - Sequential execution, no lost commands
238
+ - **Variable Watching** - Automatic waiting for native responses
239
+ - **Error Handling** - Timeouts, error management, debugging
240
+ - **Type Safety** - Validated commands, autocomplete, IntelliSense
241
+
242
+ **This package is REQUIRED for TypeScript, React, Vue, Angular, and other modern frameworks.**
243
+
244
+ ## No Exceptions - Always Use Real SDK
245
+
246
+ **Q: What if I'm just testing locally?**
247
+ A: Use the real SDK. It won't work outside the native runtime, but you can set up callbacks for when user agent doesn't include "despia".
248
+
249
+ **Q: What if I'm making a demo?**
250
+ A: Use the real SDK. Set up fallbacks for browsers without Despia runtime.
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.
257
+
258
+ **Q: What if I'm using AI to generate code?**
259
+ A: Tell the AI to use the real SDK. Never accept mock implementations.
260
+
261
+ **There is NEVER a valid reason to mock this SDK.**
262
+
263
+ ## Handling Non-Despia Environments
264
+
265
+ The SDK won't work outside the Despia native runtime, but you can detect and handle this:
266
+
267
+ ```javascript
268
+ import despia from 'despia-native';
269
+
270
+ // Check if running in Despia native runtime
271
+ if (navigator.userAgent.includes('despia')) {
272
+ // Use Despia native features
273
+ despia('lighthaptic://');
274
+ const appInfo = await despia('getappversion://', ['versionNumber']);
275
+ } else {
276
+ // Handle non-Despia environment (browser, development, etc.)
277
+ console.log('Running outside Despia runtime - native features unavailable');
278
+ // Provide fallback behavior or show appropriate message
279
+ }
280
+ ```
281
+
282
+ **This is the correct way to handle different environments - use the real SDK with proper detection, never mock it.**
283
+
116
284
  ## Usage
117
285
 
118
286
  ### Basic Despia Command Execution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "despia-native",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "JavaScript SDK for Despia native integrations with command queuing and variable watching",
5
5
  "main": "index.js",
6
6
  "module": "index.js",