rozenite-sqlite 0.0.2 → 0.0.7
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/CHANGELOG.md +7 -0
- package/README.md +161 -0
- package/dist/rozenite.json +1 -1
- package/package.json +11 -7
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# rozenite-sqlite
|
|
2
|
+
|
|
3
|
+
A [Rozenite](https://rozenite.dev) devtools plugin that adds a live SQLite explorer panel to your React Native app. Browse your databases, inspect tables, run arbitrary SQL queries, and view row details — all from the Rozenite devtools panel without leaving your development workflow.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- React Native app using [Rozenite devtools](https://rozenite.dev)
|
|
8
|
+
- A SQLite library (e.g. [`expo-sqlite`](https://docs.expo.dev/versions/latest/sdk/sqlite/), [`op-sqlite`](https://github.com/OP-Engineering/op-sqlite), [`react-native-quick-sqlite`](https://github.com/margelo/react-native-quick-sqlite)) — any library works as long as you can execute raw SQL queries
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install rozenite-sqlite
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Make sure you also have the Rozenite devtools set up in your project. Refer to the [Rozenite docs](https://rozenite.dev/docs) for the initial setup.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Call `useRozeniteSQLite` once near the root of your app (or in the component that holds your database instances). The hook handles all communication with the devtools panel — you don't interact with the plugin bridge directly.
|
|
21
|
+
|
|
22
|
+
The `sqlExecutor` callback is fully library-agnostic — you provide the bridge between the plugin and whichever SQLite library you use. It receives the database name and a raw SQL string, and must return a `Promise<Record<string, unknown>[]>` (an array of row objects).
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useRozeniteSQLite } from 'rozenite-sqlite/react-native';
|
|
26
|
+
|
|
27
|
+
export default function App() {
|
|
28
|
+
useRozeniteSQLite({
|
|
29
|
+
databases: ['app.db', 'cache.db'],
|
|
30
|
+
sqlExecutor: async (dbName, query) => {
|
|
31
|
+
// Use any SQLite library here — see examples below
|
|
32
|
+
const db = myDatabases[dbName];
|
|
33
|
+
return db.getAllAsync(query);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ... rest of your app
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### With expo-sqlite (`openDatabaseSync`)
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import * as SQLite from 'expo-sqlite';
|
|
45
|
+
import { useRozeniteSQLite } from 'rozenite-sqlite/react-native';
|
|
46
|
+
|
|
47
|
+
export default function App() {
|
|
48
|
+
useRozeniteSQLite({
|
|
49
|
+
databases: ['app.db', 'cache.db'],
|
|
50
|
+
sqlExecutor: async (dbName, query) => {
|
|
51
|
+
const db = SQLite.openDatabaseSync(dbName);
|
|
52
|
+
return db.getAllSync(query) as Record<string, unknown>[];
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// ...
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> `openDatabaseSync` returns the existing open connection if the database is already open, so it's safe to call on every query without storing the instance.
|
|
61
|
+
|
|
62
|
+
### With expo-sqlite (`openDatabaseAsync`)
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useEffect, useState } from 'react';
|
|
66
|
+
import * as SQLite from 'expo-sqlite';
|
|
67
|
+
import { useRozeniteSQLite } from 'rozenite-sqlite/react-native';
|
|
68
|
+
|
|
69
|
+
export default function App() {
|
|
70
|
+
const [databases, setDatabases] = useState<Record<string, SQLite.SQLiteDatabase>>({});
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const setup = async () => {
|
|
74
|
+
const app = await SQLite.openDatabaseAsync('app.db');
|
|
75
|
+
const cache = await SQLite.openDatabaseAsync('cache.db');
|
|
76
|
+
setDatabases({ app, cache });
|
|
77
|
+
};
|
|
78
|
+
setup();
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
useRozeniteSQLite({
|
|
82
|
+
databases: Object.keys(databases).map((key) => `${key}.db`),
|
|
83
|
+
sqlExecutor: async (dbName, query) => {
|
|
84
|
+
const key = dbName.replace(/\.db$/, '');
|
|
85
|
+
const db = databases[key];
|
|
86
|
+
if (!db) throw new Error(`Database "${dbName}" not found`);
|
|
87
|
+
return db.getAllAsync(query) as Promise<Record<string, unknown>[]>;
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// ...
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### With a custom native module
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { useRozeniteSQLite } from 'rozenite-sqlite/react-native';
|
|
99
|
+
import SqliteServiceModule from './SqliteServiceModule';
|
|
100
|
+
|
|
101
|
+
export default function App() {
|
|
102
|
+
useRozeniteSQLite({
|
|
103
|
+
databases: ['app.db'],
|
|
104
|
+
sqlExecutor: async (dbName, query) => {
|
|
105
|
+
const result = await SqliteServiceModule.execute(dbName, query, true);
|
|
106
|
+
return JSON.parse(result) as Record<string, unknown>[];
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ...
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### With op-sqlite
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { open } from '@op-engineering/op-sqlite';
|
|
118
|
+
import { useRozeniteSQLite } from 'rozenite-sqlite/react-native';
|
|
119
|
+
|
|
120
|
+
const db = open({ name: 'app.db' });
|
|
121
|
+
|
|
122
|
+
export default function App() {
|
|
123
|
+
useRozeniteSQLite({
|
|
124
|
+
databases: ['app.db'],
|
|
125
|
+
sqlExecutor: async (_dbName, query) => {
|
|
126
|
+
const result = db.execute(query);
|
|
127
|
+
return result.rows?._array ?? [];
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ...
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## API
|
|
136
|
+
|
|
137
|
+
### `useRozeniteSQLite(config)`
|
|
138
|
+
|
|
139
|
+
A React hook that connects your app to the Rozenite SQLite devtools panel.
|
|
140
|
+
|
|
141
|
+
| Parameter | Type | Description |
|
|
142
|
+
|-----------|------|-------------|
|
|
143
|
+
| `config.databases` | `string[]` | List of database names exposed to the panel, e.g. `["app.db", "cache.db"]` |
|
|
144
|
+
| `config.sqlExecutor` | `(dbName: string, query: string) => Promise<Record<string, unknown>[]>` | Library-agnostic SQL runner — receives the database name and a raw SQL query, returns an array of row objects |
|
|
145
|
+
|
|
146
|
+
The hook has no return value. It registers message handlers for the devtools panel and cleans them up automatically when the component unmounts or when the client reconnects.
|
|
147
|
+
|
|
148
|
+
## Devtools Panel Features
|
|
149
|
+
|
|
150
|
+
Once connected, the Rozenite SQLite panel provides:
|
|
151
|
+
|
|
152
|
+
- **Database switcher** — select from all registered databases
|
|
153
|
+
- **Table browser** — list all user tables in the selected database
|
|
154
|
+
- **Data grid** — paginated view of rows with column headers
|
|
155
|
+
- **Row detail panel** — inspect all fields of a selected row
|
|
156
|
+
- **SQL console** — run arbitrary `SELECT` (or any) queries against the selected database
|
|
157
|
+
- **Refresh** — reload the current table data on demand
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|
package/dist/rozenite.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"rozenite-sqlite","version":"0.0.
|
|
1
|
+
{"name":"rozenite-sqlite","version":"0.0.7","description":"SQLite explorer for RN devtools","panels":[{"name":"SQLite","source":"/panel.html"}]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rozenite-sqlite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "SQLite explorer for RN devtools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/react-native.js",
|
|
@@ -14,17 +14,21 @@
|
|
|
14
14
|
"@rozenite/plugin-bridge": "1.0.0-alpha.3"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"vite": "^6.0.0",
|
|
17
18
|
"@rozenite/vite-plugin": "1.0.0-alpha.3",
|
|
18
|
-
"@types/react": "~18.3.12",
|
|
19
|
-
"react-native": "0.76.0",
|
|
20
|
-
"react-native-web": "0.21.0",
|
|
21
|
-
"rozenite": "1.0.0-alpha.3",
|
|
22
19
|
"typescript": "^5.7.3",
|
|
23
|
-
"
|
|
20
|
+
"rozenite": "1.0.0-alpha.3",
|
|
21
|
+
"react-native-web": "0.21.0",
|
|
22
|
+
"react-native": "0.76.0",
|
|
23
|
+
"@types/react": "~18.3.12"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "*",
|
|
27
27
|
"react-native": "*"
|
|
28
28
|
},
|
|
29
|
-
"license": "MIT"
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/groot007/rozenite-sqlite-plugin"
|
|
33
|
+
}
|
|
30
34
|
}
|