@proappstore/sdk 1.6.0 → 1.7.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 +98 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,6 +133,104 @@ const license = await app.license.current()
|
|
|
133
133
|
const valid = await app.license.validate('LIC-ABC-123')
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
### Maps (Geocoding + Embeds)
|
|
137
|
+
|
|
138
|
+
Address-to-coordinates and map embeds. Powered by OpenStreetMap/Nominatim. No Google API keys needed.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// Geocode an address
|
|
142
|
+
const results = await app.maps.geocode('Times Square, New York')
|
|
143
|
+
// [{lat: 40.758, lng: -73.985, displayName: "Times Square...", address: {...}}]
|
|
144
|
+
|
|
145
|
+
// Reverse geocode
|
|
146
|
+
const place = await app.maps.reverseGeocode(40.758, -73.985)
|
|
147
|
+
|
|
148
|
+
// Embed map in iframe
|
|
149
|
+
<iframe src={app.maps.embedUrl(40.758, -73.985)} />
|
|
150
|
+
|
|
151
|
+
// Static tile image
|
|
152
|
+
<img src={app.maps.staticUrl(40.758, -73.985)} />
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Storage (File Upload)
|
|
156
|
+
|
|
157
|
+
Upload images, videos, documents. Public files get URLs usable in `<img src>` without auth.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
// Private upload (owner-only access)
|
|
161
|
+
await app.storage.upload('docs/resume.pdf', file, 'application/pdf')
|
|
162
|
+
|
|
163
|
+
// Public upload (anyone can view)
|
|
164
|
+
await app.storage.uploadPublic('avatar.jpg', file, 'image/jpeg')
|
|
165
|
+
const url = app.storage.publicUrl('avatar.jpg') // works in <img src>
|
|
166
|
+
|
|
167
|
+
// List, download, delete
|
|
168
|
+
const files = await app.storage.list()
|
|
169
|
+
const response = await app.storage.download('docs/resume.pdf')
|
|
170
|
+
await app.storage.delete('docs/resume.pdf')
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## React Hooks (recommended)
|
|
174
|
+
|
|
175
|
+
Hooks give you full control over your UI while the platform handles auth, subscriptions, and gating. Import from `@proappstore/sdk/hooks`.
|
|
176
|
+
|
|
177
|
+
### useProAuth
|
|
178
|
+
|
|
179
|
+
Auth state + actions. The primary way apps interact with platform identity.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { initPro } from '@proappstore/sdk'
|
|
183
|
+
import { useProAuth } from '@proappstore/sdk/hooks'
|
|
184
|
+
|
|
185
|
+
const app = initPro({ appId: 'my-app' })
|
|
186
|
+
|
|
187
|
+
function App() {
|
|
188
|
+
const { user, loading, signIn, signOut, deleteAccount } = useProAuth(app)
|
|
189
|
+
if (loading) return <p>Loading...</p>
|
|
190
|
+
if (!user) return <button onClick={signIn}>Sign in with GitHub</button>
|
|
191
|
+
return <p>Welcome, {user.login}! <button onClick={signOut}>Sign out</button></p>
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### useProSubscription
|
|
196
|
+
|
|
197
|
+
Subscription state + actions. Check if user is subscribed, upgrade, manage billing.
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { useProSubscription } from '@proappstore/sdk/hooks'
|
|
201
|
+
|
|
202
|
+
function Billing() {
|
|
203
|
+
const { subscription, isPro, loading, upgrade, manageBilling } = useProSubscription(app)
|
|
204
|
+
if (loading) return <p>Loading...</p>
|
|
205
|
+
if (!isPro) return <button onClick={() => upgrade()}>Upgrade to Pro</button>
|
|
206
|
+
return <button onClick={manageBilling}>Manage billing</button>
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### useProGate
|
|
211
|
+
|
|
212
|
+
Combined auth + subscription gate. Returns a single `gate` state for easy conditional rendering.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { initPro } from '@proappstore/sdk'
|
|
216
|
+
import { useProGate } from '@proappstore/sdk/hooks'
|
|
217
|
+
|
|
218
|
+
const app = initPro({ appId: 'my-app' })
|
|
219
|
+
|
|
220
|
+
function App() {
|
|
221
|
+
const { gate, user, signIn, upgrade } = useProGate(app, { allowFree: true })
|
|
222
|
+
|
|
223
|
+
if (gate === 'loading') return <p>Loading...</p>
|
|
224
|
+
if (gate === 'signed-out') return <button onClick={signIn}>Sign in</button>
|
|
225
|
+
if (gate === 'no-subscription') return <button onClick={() => upgrade()}>Upgrade</button>
|
|
226
|
+
return <p>Welcome, {user?.login}!</p>
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Gate states: `'loading'` | `'signed-out'` | `'no-subscription'` | `'ready'`
|
|
231
|
+
|
|
232
|
+
Pass `{ allowFree: true }` to skip the subscription check (lets free users through).
|
|
233
|
+
|
|
136
234
|
## ProShell Component
|
|
137
235
|
|
|
138
236
|
A React component that handles auth gates, subscription checks, and renders a platform-level shell with topbar and user menu.
|