@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basictech/react",
3
- "version": "0.7.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.6.0"
29
+ "@basictech/schema": "0.7.0-beta.0"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@repo/typescript-config": "*",
31
- "tsup": "^7.2.0",
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, // "OFFLINE" | "CONNECTING" | "ONLINE" | "SYNCING"
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()`