despia-native 1.0.9 → 1.0.10

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 +77 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  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
4
 
5
+ **Import:** `import despia from 'despia-native';` (default export, not destructured)
6
+
7
+ **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.
8
+
5
9
  ## About Despia
6
10
 
7
11
  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.
@@ -51,18 +55,26 @@ npm install despia-native
51
55
 
52
56
  ### Step 1: Import Despia SDK
53
57
 
58
+ **IMPORTANT: Always import as `despia` (default export), NOT as `{Commands}` or destructured imports!**
59
+
54
60
  ```javascript
55
- // ES6/ES2015 modules
61
+ // CORRECT - ES6/ES2015 modules (default import)
56
62
  import despia from 'despia-native';
57
63
 
58
- // CommonJS
64
+ // CORRECT - CommonJS
59
65
  const despia = require('despia-native');
60
66
 
61
- // Browser (if using UMD build)
67
+ // CORRECT - Browser (if using UMD build)
62
68
  // <script src="despia-native.js"></script>
63
69
  // despia is available globally
70
+
71
+ // WRONG - Don't do this!
72
+ // import { Commands } from 'despia-native';
73
+ // import { despia } from 'despia-native';
64
74
  ```
65
75
 
76
+ **The SDK exports a single function called `despia` as the default export.**
77
+
66
78
  ### Step 2: Use Native Features
67
79
 
68
80
  ```javascript
@@ -113,6 +125,68 @@ despia('takescreenshot://');
113
125
  despia('shareapp://message?=Hello&url=https://myapp.com');
114
126
  ```
115
127
 
128
+ ### Common Import Issues
129
+
130
+ **If you get errors like "Commands is not a function" or "despia is not defined":**
131
+
132
+ ```javascript
133
+ // WRONG - This will cause errors
134
+ import { Commands } from 'despia-native';
135
+ import { despia } from 'despia-native';
136
+
137
+ // CORRECT - Always use default import
138
+ import despia from 'despia-native';
139
+
140
+ // Now you can use it
141
+ despia('lighthaptic://');
142
+ ```
143
+
144
+ **The package exports a single function as the default export, not named exports.**
145
+
146
+ ## When to Use This SDK Package
147
+
148
+ ### Vanilla JavaScript (works without this package)
149
+
150
+ ```javascript
151
+ // This WORKS in vanilla JavaScript:
152
+ window.despia = 'lighthaptic://';
153
+ window.despia = 'getappversion://';
154
+ ```
155
+
156
+ **Vanilla JS is fine for simple cases, but lacks:**
157
+ - **TypeScript Support** - No type definitions or autocomplete
158
+ - **Command Queuing** - Commands may be lost or executed out of order
159
+ - **Variable Watching** - Can't wait for responses from native commands
160
+ - **Error Handling** - No timeout or error management
161
+ - **Type Safety** - No validation or IntelliSense
162
+
163
+ ### Modern Frameworks Need This Package
164
+
165
+ ```javascript
166
+ // This WON'T work in TypeScript, React, Vue, etc.:
167
+ window.despia = 'lighthaptic://'; // TypeScript errors, no type safety
168
+ window.despia = 'getappversion://'; // No command queuing, no variable watching
169
+ ```
170
+
171
+ ### Modern Frameworks (TypeScript, React, Vue, etc.)
172
+
173
+ ```javascript
174
+ // This WORKS perfectly in modern frameworks:
175
+ import despia from 'despia-native';
176
+
177
+ despia('lighthaptic://'); // Type-safe, queued, with error handling
178
+ const result = await despia('getappversion://', ['versionNumber']); // Variable watching
179
+ ```
180
+
181
+ **Benefits of using this SDK:**
182
+ - **TypeScript Support** - Full type definitions and autocomplete
183
+ - **Command Queuing** - Sequential execution, no lost commands
184
+ - **Variable Watching** - Automatic waiting for native responses
185
+ - **Error Handling** - Timeouts, error management, debugging
186
+ - **Type Safety** - Validated commands, autocomplete, IntelliSense
187
+
188
+ **This package is REQUIRED for TypeScript, React, Vue, Angular, and other modern frameworks.**
189
+
116
190
  ## Usage
117
191
 
118
192
  ### 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.10",
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",