@basictech/react 0.7.0 → 0.8.0-beta.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/.turbo/turbo-build.log +13 -12
- package/AUTH_IMPLEMENTATION_GUIDE.md +20 -18
- package/changelog.md +24 -2
- package/dist/index.d.mts +121 -48
- package/dist/index.d.ts +121 -48
- package/dist/index.js +1996 -758
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1981 -749
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/readme.md +50 -1
- package/src/AuthContext.tsx +294 -818
- package/src/config.ts +1 -19
- package/src/context.tsx +104 -0
- package/src/core/auth/AuthManager.ts +858 -0
- package/src/core/db/RemoteCollection.ts +30 -16
- package/src/core/db/index.ts +1 -1
- package/src/core/db/types.ts +13 -1
- package/src/dev/BasicDevToolbar.tsx +665 -0
- package/src/index.ts +10 -3
- package/src/sync/index.ts +15 -29
- package/src/sync/syncProtocol.js +84 -22
- package/src/sync/tokenRegistry.ts +20 -0
- package/src/updater/updateMigrations.ts +3 -3
- package/src/updater/versionUpdater.ts +3 -10
- package/src/utils/network.ts +68 -15
- package/src/utils/normalizeClientId.ts +22 -0
- package/src/utils/resolveDid.ts +101 -0
- package/src/utils/schema.ts +3 -4
- package/src/utils/storage.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basictech/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -12,11 +12,13 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsup",
|
|
14
14
|
"dev": "tsup --watch",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
15
16
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
17
|
},
|
|
17
18
|
"author": "",
|
|
18
19
|
"license": "ISC",
|
|
19
20
|
"dependencies": {
|
|
21
|
+
"semver": "^7.7.2",
|
|
20
22
|
"ajv": "^8.17.1",
|
|
21
23
|
"dexie": "^4.2.1",
|
|
22
24
|
"dexie-observable": "^4.0.1-beta.13",
|
|
@@ -24,11 +26,11 @@
|
|
|
24
26
|
"dexie-syncable": "^4.0.1-beta.13",
|
|
25
27
|
"jwt-decode": "^4.0.0",
|
|
26
28
|
"uuid": "^10.0.0",
|
|
27
|
-
"@basictech/schema": "0.
|
|
29
|
+
"@basictech/schema": "0.7.0-beta.0"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@repo/typescript-config": "*",
|
|
31
|
-
"tsup": "^
|
|
33
|
+
"tsup": "^8.0.0",
|
|
32
34
|
"typescript": "^5.0.0"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
package/readme.md
CHANGED
|
@@ -99,6 +99,7 @@ Root provider component. Must wrap your entire app.
|
|
|
99
99
|
schema={schema} // Required: Your Basic schema
|
|
100
100
|
debug={false} // Optional: Enable console logging
|
|
101
101
|
dbMode="sync" // Optional: "sync" (default) or "remote"
|
|
102
|
+
devToolbar={false} // Optional: Floating dev status bar (localhost / dev / debug)
|
|
102
103
|
/>
|
|
103
104
|
```
|
|
104
105
|
|
|
@@ -109,6 +110,7 @@ Root provider component. Must wrap your entire app.
|
|
|
109
110
|
| `schema` | `object` | required | Schema with `project_id` and `tables` |
|
|
110
111
|
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
111
112
|
| `dbMode` | `"sync" \| "remote"` | `"sync"` | Database mode |
|
|
113
|
+
| `devToolbar` | `boolean` | `false` | Show the Basic dev toolbar (only when `localhost`, `NODE_ENV === "development"`, or `debug={true}`) |
|
|
112
114
|
|
|
113
115
|
#### Database Modes
|
|
114
116
|
|
|
@@ -137,11 +139,58 @@ const {
|
|
|
137
139
|
|
|
138
140
|
// Database
|
|
139
141
|
db, // Database instance
|
|
140
|
-
dbStatus, //
|
|
142
|
+
dbStatus, // DBStatus - see below
|
|
141
143
|
dbMode, // "sync" | "remote"
|
|
144
|
+
|
|
145
|
+
// Dev / schema snapshot (for custom tooling)
|
|
146
|
+
devInfo, // BasicSchemaDevInfo | null — local vs remote schema status
|
|
147
|
+
refreshSchemaStatus, // () => Promise<void> — re-fetch schema status from API
|
|
142
148
|
} = useBasic()
|
|
143
149
|
```
|
|
144
150
|
|
|
151
|
+
#### `DBStatus` (sync connection state)
|
|
152
|
+
|
|
153
|
+
When `dbMode === "sync"`, `dbStatus` is one of:
|
|
154
|
+
|
|
155
|
+
| Value | Description |
|
|
156
|
+
|-------|-------------|
|
|
157
|
+
| `LOADING` | SDK initializing |
|
|
158
|
+
| `OFFLINE` | Not connected |
|
|
159
|
+
| `CONNECTING` | Connecting to sync server |
|
|
160
|
+
| `ONLINE` | Connected and idle |
|
|
161
|
+
| `SYNCING` | Syncing data |
|
|
162
|
+
| `ERROR` | Sync error |
|
|
163
|
+
| `ERROR_WILL_RETRY` | Sync error but client will retry (e.g. expired token). Use this to show "Reconnecting…" or trigger token refresh. |
|
|
164
|
+
|
|
165
|
+
Import the enum for comparisons: `import { useBasic, DBStatus } from '@basictech/react'`.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Development toolbar
|
|
170
|
+
|
|
171
|
+
A small floating bar (similar in spirit to Next.js dev indicators) shows **auth**, **database mode**, **sync status**, and **schema vs server** health. It is **opt-in** and only appears in development: `localhost` / `127.0.0.1` / `.local`, `NODE_ENV === "development"`, or when `debug` is `true` on the provider or on the standalone component.
|
|
172
|
+
|
|
173
|
+
**Option A — provider flag**
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
<BasicProvider schema={schema} devToolbar debug>
|
|
177
|
+
<App />
|
|
178
|
+
</BasicProvider>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Option B — place the component yourself** (must be under `BasicProvider`; respects the same visibility rules, or pass `debug` to force):
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { BasicDevToolbar } from '@basictech/react'
|
|
185
|
+
|
|
186
|
+
<BasicProvider schema={schema}>
|
|
187
|
+
<App />
|
|
188
|
+
<BasicDevToolbar />
|
|
189
|
+
</BasicProvider>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The expanded panel includes **Refresh schema** (re-runs the remote schema check) and **Copy debug info** (JSON snapshot **without** raw access tokens). You can also read `devInfo` and call `refreshSchemaStatus()` from `useBasic()` for your own UI.
|
|
193
|
+
|
|
145
194
|
---
|
|
146
195
|
|
|
147
196
|
### `useQuery()`
|