@powersync/nuxt 0.0.0-dev-20260827080125 → 0.0.0-dev-20261015114518
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 +36 -59
- package/dist/module.d.mts +4 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +74 -64
- package/dist/runtime/assets/devtools-theme.d.ts +1 -0
- package/dist/runtime/assets/devtools-theme.js +33 -0
- package/dist/runtime/options.d.ts +13 -0
- package/dist/runtime/options.js +0 -0
- package/dist/runtime/plugin.client.js +8 -8
- package/package.json +12 -13
- package/dist/runtime/components/BucketsInspectorTab.d.vue.ts +0 -3
- package/dist/runtime/components/BucketsInspectorTab.vue +0 -544
- package/dist/runtime/components/BucketsInspectorTab.vue.d.ts +0 -3
- package/dist/runtime/components/ConfigInspectorTab.d.vue.ts +0 -3
- package/dist/runtime/components/ConfigInspectorTab.vue +0 -84
- package/dist/runtime/components/ConfigInspectorTab.vue.d.ts +0 -3
- package/dist/runtime/components/DataInspectorTab.d.vue.ts +0 -3
- package/dist/runtime/components/DataInspectorTab.vue +0 -564
- package/dist/runtime/components/DataInspectorTab.vue.d.ts +0 -3
- package/dist/runtime/components/LoadingSpinner.d.vue.ts +0 -3
- package/dist/runtime/components/LoadingSpinner.vue +0 -12
- package/dist/runtime/components/LoadingSpinner.vue.d.ts +0 -3
- package/dist/runtime/components/LogsTab.d.vue.ts +0 -3
- package/dist/runtime/components/LogsTab.vue +0 -273
- package/dist/runtime/components/LogsTab.vue.d.ts +0 -3
- package/dist/runtime/components/PowerSyncInstanceTab.d.vue.ts +0 -3
- package/dist/runtime/components/PowerSyncInstanceTab.vue +0 -7
- package/dist/runtime/components/PowerSyncInstanceTab.vue.d.ts +0 -3
- package/dist/runtime/components/SyncStatusTab.d.vue.ts +0 -3
- package/dist/runtime/components/SyncStatusTab.vue +0 -161
- package/dist/runtime/components/SyncStatusTab.vue.d.ts +0 -3
- package/dist/runtime/composables/usePowerSyncInspector.d.ts +0 -39
- package/dist/runtime/composables/usePowerSyncInspector.js +0 -17
- package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.d.ts +0 -153
- package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.js +0 -216
- package/dist/runtime/layouts/powersync-inspector-layout.d.vue.ts +0 -13
- package/dist/runtime/layouts/powersync-inspector-layout.vue +0 -63
- package/dist/runtime/layouts/powersync-inspector-layout.vue.d.ts +0 -13
- package/dist/runtime/pages/__powersync-inspector.d.vue.ts +0 -3
- package/dist/runtime/pages/__powersync-inspector.vue +0 -119
- package/dist/runtime/pages/__powersync-inspector.vue.d.ts +0 -3
- package/dist/runtime/utils/AppSchema.d.ts +0 -27
- package/dist/runtime/utils/AppSchema.js +0 -23
- package/dist/runtime/utils/DynamicSchemaManager.d.ts +0 -16
- package/dist/runtime/utils/DynamicSchemaManager.js +0 -82
- package/dist/runtime/utils/JsSchemaGenerator.d.ts +0 -8
- package/dist/runtime/utils/JsSchemaGenerator.js +0 -28
- package/dist/runtime/utils/NuxtPowerSyncDatabase.d.ts +0 -42
- package/dist/runtime/utils/NuxtPowerSyncDatabase.js +0 -97
- package/dist/runtime/utils/RustClientInterceptor.d.ts +0 -24
- package/dist/runtime/utils/RustClientInterceptor.js +0 -90
- package/dist/runtime/utils/TokenConnector.d.ts +0 -14
- package/dist/runtime/utils/TokenConnector.js +0 -57
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -1
package/README.md
CHANGED
|
@@ -22,8 +22,7 @@ PowerSync Nuxt module integrated with the [Nuxt Devtools](https://github.com/nux
|
|
|
22
22
|
|
|
23
23
|
- **Real-time offline-first sync** — PowerSync keeps a local SQLite database in sync with your backend (Postgres, MongoDB, MySQL, or SQL Server). Your app reads from local SQLite and works offline; changes sync automatically when the connection is restored.
|
|
24
24
|
- **Auto-imported composables** — `usePowerSync()`, `useQuery()`, and `usePowerSyncKysely()` are available in every component without explicit imports.
|
|
25
|
-
- **Built-in diagnostics** —
|
|
26
|
-
- **Data inspection** — Browse your local SQLite database in the browser without external tools — useful for verifying what data has synced and debugging data issues during development.
|
|
25
|
+
- **Built-in diagnostics** — The PowerSync tab in Nuxt DevTools shows the sync status, buckets, streams, config and logs of your client. You can also browse the local SQLite database and run SQL against it, to check what data has synced.
|
|
27
26
|
- **Kysely support** — Opt-in type-safe queries via `@powersync/kysely-driver`, enabled with `kysely: true` in your PowerSync config.
|
|
28
27
|
|
|
29
28
|
## Installation
|
|
@@ -67,14 +66,14 @@ export default defineNuxtConfig({
|
|
|
67
66
|
2. Create a PowerSync plugin (e.g., `plugins/powersync.client.ts`):
|
|
68
67
|
|
|
69
68
|
```typescript
|
|
70
|
-
import {
|
|
69
|
+
import { PowerSyncDatabase } from '@powersync/web';
|
|
71
70
|
import { createPowerSyncPlugin } from '@powersync/nuxt';
|
|
72
71
|
import { AppSchema } from '~/powersync/AppSchema';
|
|
73
72
|
import { PowerSyncConnector } from '~/powersync/PowerSyncConnector';
|
|
74
73
|
|
|
75
74
|
export default defineNuxtPlugin({
|
|
76
75
|
async setup(nuxtApp) {
|
|
77
|
-
const db = new
|
|
76
|
+
const db = new PowerSyncDatabase({
|
|
78
77
|
database: {
|
|
79
78
|
dbFilename: 'your-db-filename.sqlite'
|
|
80
79
|
},
|
|
@@ -180,14 +179,14 @@ export class PowerSyncConnector implements PowerSyncBackendConnector {
|
|
|
180
179
|
Finally, putting everything together, create a [plugin](https://nuxt.com/docs/4.x/guide/directory-structure/app/plugins) called `powersync.client.ts` to setup PowerSync.
|
|
181
180
|
|
|
182
181
|
```typescript
|
|
182
|
+
import { PowerSyncDatabase } from '@powersync/web';
|
|
183
183
|
import { createPowerSyncPlugin } from '@powersync/nuxt';
|
|
184
|
-
import { NuxtPowerSyncDatabase } from '@powersync/nuxt';
|
|
185
184
|
import { AppSchema } from '~/powersync/AppSchema';
|
|
186
185
|
import { PowerSyncConnector } from '~/powersync/PowerSyncConnector';
|
|
187
186
|
|
|
188
187
|
export default defineNuxtPlugin({
|
|
189
188
|
async setup(nuxtApp) {
|
|
190
|
-
const db = new
|
|
189
|
+
const db = new PowerSyncDatabase({
|
|
191
190
|
database: {
|
|
192
191
|
dbFilename: 'a-db-name.sqlite'
|
|
193
192
|
},
|
|
@@ -250,7 +249,7 @@ const users = await db.selectFrom('users').selectAll().execute();
|
|
|
250
249
|
|
|
251
250
|
### Enabling Diagnostics
|
|
252
251
|
|
|
253
|
-
|
|
252
|
+
Diagnostics show the live state of your app's own PowerSync client inside Nuxt DevTools. They run in development only; nothing is added to a production build.
|
|
254
253
|
|
|
255
254
|
1. **Enable diagnostics in your config**:
|
|
256
255
|
|
|
@@ -271,75 +270,53 @@ export default defineNuxtConfig({
|
|
|
271
270
|
});
|
|
272
271
|
```
|
|
273
272
|
|
|
274
|
-
|
|
273
|
+
With `useDiagnostics: true`, the module picks the integration for your Nuxt DevTools version:
|
|
275
274
|
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
- Stores the connector internally (accessible via diagnostics)
|
|
279
|
-
- Configures logging for diagnostics
|
|
275
|
+
- **Nuxt DevTools 3** (what Nuxt 4 ships): the module loads the diagnostics agent into your app during `nuxt dev`, serves the diagnostics UI, and registers a **PowerSync** tab that follows the DevTools colour mode. The UI is served outside your app's router, so route middleware such as an auth guard does not apply to it.
|
|
276
|
+
- **Nuxt DevTools 4** (built on Vite DevTools): the module mounts the PowerSync devframe definition. You get a **PowerSync** dock, the same as a plain Vite app. The first time, DevTools asks you to confirm the browser with a one-time code printed in your terminal. For the MCP tools, see [MCP](https://github.com/powersync-ja/powersync-js/tree/main/tools/diagnostics#mcp).
|
|
280
277
|
|
|
281
|
-
2. **
|
|
278
|
+
2. **Enable the core diagnostics stream** when you connect. This gives the Buckets tab per-bucket totals:
|
|
282
279
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
- **Direct URL**: `http://localhost:3000/__powersync-inspector`
|
|
287
|
-
|
|
288
|
-
## PowerSync Inspector
|
|
289
|
-
|
|
290
|
-
PowerSync Inspector is a tool that helps inspect and diagnose the state of your PowerSync client directly from your app in real-time.
|
|
291
|
-
|
|
292
|
-
<div align="center">
|
|
293
|
-
<img src="./img/inspector.png" alt="PowerSync Logo" />
|
|
294
|
-
</div>
|
|
295
|
-
|
|
296
|
-
### Setup
|
|
297
|
-
|
|
298
|
-
To setup the PowerSync inspector, you need to follow the steps in the [Enabling Diagnostics](#enabling-diagnostics) section.
|
|
299
|
-
|
|
300
|
-
Once setup, the inspector can be accessed on the `http://localhost:3000/__powersync-inspector` route or via the [Nuxt Devtools](#nuxt-devtools).
|
|
301
|
-
|
|
302
|
-
### Features
|
|
303
|
-
|
|
304
|
-
#### Sync Status
|
|
305
|
-
|
|
306
|
-
The `Sync Status` tab provides a real-time view of the sync status of your PowerSync client, including:
|
|
307
|
-
|
|
308
|
-
- Connection status
|
|
309
|
-
- Sync progress
|
|
310
|
-
- Upload queue statistics
|
|
311
|
-
- Error monitoring
|
|
280
|
+
```typescript
|
|
281
|
+
await db.connect(connector, { diagnostics: true });
|
|
282
|
+
```
|
|
312
283
|
|
|
313
|
-
|
|
284
|
+
3. **Open Nuxt DevTools** and select the **PowerSync** tab or dock.
|
|
314
285
|
|
|
315
|
-
|
|
286
|
+
## PowerSync Diagnostics
|
|
316
287
|
|
|
317
|
-
|
|
288
|
+
PowerSync DevTools show the live state of your PowerSync client inside Nuxt DevTools. Full guide: [PowerSync DevTools](https://docs.powersync.com/tools/devtools-overview).
|
|
318
289
|
|
|
319
|
-
|
|
290
|
+
### Tabs
|
|
320
291
|
|
|
321
|
-
|
|
292
|
+
- **Sync Status**: connection state, sync progress, the upload queue, priority sync, and a "Sync now" checkpoint request.
|
|
293
|
+
- **Data Inspector**: a searchable table and view tree, and a SQL console with syntax highlighting.
|
|
294
|
+
- **Buckets**: per-bucket downloaded and total operations, size, and a drill-down into a bucket's operations.
|
|
295
|
+
- **Streams**: sync stream subscriptions with progress, TTL, and priority, and a subscribe/unsubscribe form.
|
|
296
|
+
- **Config**: connection details and the schema as a tree or JSON.
|
|
297
|
+
- **Logs**: client logs with a level filter and search.
|
|
322
298
|
|
|
323
|
-
|
|
299
|
+
### How it works
|
|
324
300
|
|
|
325
|
-
|
|
301
|
+
The module uses [`@powersync/diagnostics`](https://github.com/powersync-ja/powersync-js/tree/main/tools/diagnostics). See that package for the MCP tools.
|
|
326
302
|
|
|
327
|
-
|
|
303
|
+
### Migrating from `NuxtPowerSyncDatabase`
|
|
328
304
|
|
|
329
|
-
|
|
305
|
+
Earlier versions had a `NuxtPowerSyncDatabase` class that enabled diagnostics on connect. It is now removed. Use `PowerSyncDatabase` from `@powersync/web` and pass the option yourself:
|
|
330
306
|
|
|
331
|
-
|
|
307
|
+
```diff
|
|
308
|
+
- import { NuxtPowerSyncDatabase } from '@powersync/nuxt';
|
|
309
|
+
+ import { PowerSyncDatabase } from '@powersync/web';
|
|
332
310
|
|
|
333
|
-
|
|
311
|
+
- const db = new NuxtPowerSyncDatabase({ database: { dbFilename: 'app.sqlite' }, schema: AppSchema });
|
|
312
|
+
+ const db = new PowerSyncDatabase({ database: { dbFilename: 'app.sqlite' }, schema: AppSchema });
|
|
334
313
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
unocss: {
|
|
338
|
-
autoImport: false
|
|
339
|
-
}
|
|
340
|
-
});
|
|
314
|
+
- await db.connect(connector);
|
|
315
|
+
+ await db.connect(connector, { diagnostics: true });
|
|
341
316
|
```
|
|
342
317
|
|
|
318
|
+
The `useDiagnostics: true` module option is the one switch for the DevTools tab and the in-app agent.
|
|
319
|
+
|
|
343
320
|
## Development
|
|
344
321
|
|
|
345
322
|
```bash
|
package/dist/module.d.mts
CHANGED
|
@@ -15,10 +15,11 @@ import * as nuxt_schema from 'nuxt/schema';
|
|
|
15
15
|
*/
|
|
16
16
|
interface PowerSyncNuxtModuleOptions {
|
|
17
17
|
/**
|
|
18
|
-
* Enable diagnostics
|
|
18
|
+
* Enable the PowerSync diagnostics tab in Nuxt DevTools.
|
|
19
19
|
*
|
|
20
|
-
* When
|
|
21
|
-
*
|
|
20
|
+
* When `true`, the module loads the diagnostics agent into the app during `nuxt dev`, serves the
|
|
21
|
+
* diagnostics UI, and registers the DevTools tab. Nothing is added to a production build. Pass
|
|
22
|
+
* `{ diagnostics: true }` to `connect()` as well to get per-bucket totals from the SQLite core.
|
|
22
23
|
*
|
|
23
24
|
* @default false
|
|
24
25
|
*/
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join, dirname } from 'node:path';
|
|
4
|
+
import { createResolver, addVitePlugin, defineNuxtModule, findPath, addPlugin, addImports } from '@nuxt/kit';
|
|
2
5
|
import { defu } from 'defu';
|
|
6
|
+
import { UI_ROUTE } from '@powersync/diagnostics';
|
|
3
7
|
import { addImportsFrom } from '../dist/runtime/utils/addImportsFrom.js';
|
|
4
8
|
|
|
9
|
+
const DEVTOOLS_THEME_SCRIPT = "/__powersync-nuxt/devtools-theme.js";
|
|
5
10
|
function setupDevToolsUI(nuxt) {
|
|
6
11
|
const port = nuxt.options.devServer?.port || 3e3;
|
|
7
|
-
const
|
|
12
|
+
const resolver = createResolver(import.meta.url);
|
|
13
|
+
const themeScriptPath = resolver.resolve("./runtime/assets/devtools-theme.js");
|
|
14
|
+
addVitePlugin({
|
|
15
|
+
name: "powersync-devtools-theme",
|
|
16
|
+
apply: "serve",
|
|
17
|
+
configureServer(server) {
|
|
18
|
+
server.middlewares.use(DEVTOOLS_THEME_SCRIPT, (_request, response, next) => {
|
|
19
|
+
try {
|
|
20
|
+
response.setHeader("Content-Type", "text/javascript; charset=utf-8");
|
|
21
|
+
response.setHeader("Cache-Control", "no-store");
|
|
22
|
+
response.end(readFileSync(themeScriptPath));
|
|
23
|
+
} catch {
|
|
24
|
+
next();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
8
29
|
const iconUrl = `http://localhost:${port}/assets/powersync-icon.svg`;
|
|
9
30
|
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
10
31
|
tabs.push({
|
|
11
|
-
// unique identifier
|
|
12
32
|
name: "powersync-inspector",
|
|
13
|
-
|
|
14
|
-
title: "Powersync Inspector",
|
|
15
|
-
// any icon from Iconify, or a URL to an image
|
|
16
|
-
// Using HTTP URL so devtools recognizes it as an image URL
|
|
33
|
+
title: "PowerSync",
|
|
17
34
|
icon: iconUrl,
|
|
18
|
-
// iframe view
|
|
19
35
|
view: {
|
|
20
36
|
type: "iframe",
|
|
21
|
-
|
|
37
|
+
// `sdks` narrows the UI's setup screen to what a Nuxt app uses.
|
|
38
|
+
src: `http://localhost:${port}${UI_ROUTE}?sdks=nuxt,web`
|
|
22
39
|
}
|
|
23
40
|
});
|
|
24
41
|
});
|
|
@@ -35,17 +52,32 @@ const module$1 = defineNuxtModule({
|
|
|
35
52
|
kysely: false
|
|
36
53
|
},
|
|
37
54
|
moduleDependencies: {
|
|
38
|
-
"@nuxt/devtools-ui-kit": {},
|
|
39
55
|
"@vueuse/nuxt": {}
|
|
40
56
|
},
|
|
41
57
|
async setup(options, nuxt) {
|
|
42
58
|
const resolver = createResolver(import.meta.url);
|
|
43
|
-
nuxt.options.runtimeConfig.public.powerSyncModuleOptions
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
const runtimeOptions = nuxt.options.runtimeConfig.public.powerSyncModuleOptions ??= {};
|
|
60
|
+
nuxt.hook("modules:done", async () => {
|
|
61
|
+
const devtoolsMajor = nuxtDevtoolsMajor(nuxt);
|
|
62
|
+
runtimeOptions.diagnosticsTransport = devtoolsMajor >= 4 ? "devframe" : "page";
|
|
63
|
+
if (!options.useDiagnostics || !nuxt.options.dev) return;
|
|
64
|
+
if (devtoolsMajor >= 4) {
|
|
65
|
+
const { default: powersyncDevtools } = await import('@powersync/diagnostics/vite');
|
|
66
|
+
addVitePlugin(powersyncDevtools({ sdks: ["nuxt", "web"] }));
|
|
67
|
+
} else {
|
|
68
|
+
const { default: powersyncStatic } = await import('@powersync/diagnostics/vite-static');
|
|
69
|
+
addVitePlugin(powersyncStatic({ scripts: [DEVTOOLS_THEME_SCRIPT] }));
|
|
70
|
+
setupDevToolsUI(nuxt);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.assign(
|
|
74
|
+
runtimeOptions,
|
|
75
|
+
defu(runtimeOptions, {
|
|
46
76
|
useDiagnostics: options.useDiagnostics,
|
|
77
|
+
// Set in `modules:done`, once the Nuxt DevTools generation is known.
|
|
78
|
+
diagnosticsTransport: "page",
|
|
47
79
|
kysely: options.kysely
|
|
48
|
-
}
|
|
80
|
+
})
|
|
49
81
|
);
|
|
50
82
|
if (options.kysely) {
|
|
51
83
|
const kyselyDriverPath = await findPath("@powersync/kysely-driver");
|
|
@@ -56,18 +88,6 @@ const module$1 = defineNuxtModule({
|
|
|
56
88
|
}
|
|
57
89
|
}
|
|
58
90
|
addPlugin(resolver.resolve("./runtime/plugin.client"));
|
|
59
|
-
addImports({
|
|
60
|
-
name: "NuxtPowerSyncDatabase",
|
|
61
|
-
from: resolver.resolve("./runtime/utils/NuxtPowerSyncDatabase")
|
|
62
|
-
});
|
|
63
|
-
addImports({
|
|
64
|
-
name: "usePowerSyncInspector",
|
|
65
|
-
from: resolver.resolve("./runtime/composables/usePowerSyncInspector")
|
|
66
|
-
});
|
|
67
|
-
addImports({
|
|
68
|
-
name: "usePowerSyncInspectorDiagnostics",
|
|
69
|
-
from: resolver.resolve("./runtime/composables/usePowerSyncInspectorDiagnostics")
|
|
70
|
-
});
|
|
71
91
|
if (options.kysely) {
|
|
72
92
|
addImports({
|
|
73
93
|
name: "usePowerSyncKysely",
|
|
@@ -78,26 +98,11 @@ const module$1 = defineNuxtModule({
|
|
|
78
98
|
name: "useDiagnosticsLogger",
|
|
79
99
|
from: resolver.resolve("./runtime/composables/useDiagnosticsLogger")
|
|
80
100
|
});
|
|
81
|
-
addComponentsDir({
|
|
82
|
-
path: resolver.resolve("runtime/components")
|
|
83
|
-
});
|
|
84
|
-
addLayout(resolver.resolve("./runtime/layouts/powersync-inspector-layout.vue"), "powersync-inspector-layout");
|
|
85
|
-
extendPages((pages) => {
|
|
86
|
-
pages.push({
|
|
87
|
-
path: "/__powersync-inspector",
|
|
88
|
-
// file: resolver.resolve("#build/pages/__powersync-inspector.vue"),
|
|
89
|
-
file: resolver.resolve("./runtime/pages/__powersync-inspector.vue"),
|
|
90
|
-
name: "Powersync Inspector"
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
101
|
addImportsFrom(
|
|
94
102
|
[
|
|
95
103
|
"createPowerSyncPlugin",
|
|
96
104
|
"providePowerSync",
|
|
97
105
|
"usePowerSync",
|
|
98
|
-
"usePowerSyncQuery",
|
|
99
|
-
"usePowerSyncStatus",
|
|
100
|
-
"usePowerSyncWatchedQuery",
|
|
101
106
|
"useQuery",
|
|
102
107
|
"useStatus",
|
|
103
108
|
"useWatchedQuerySubscription",
|
|
@@ -110,7 +115,7 @@ const module$1 = defineNuxtModule({
|
|
|
110
115
|
"@powersync/vue"
|
|
111
116
|
);
|
|
112
117
|
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
113
|
-
nuxt.options.build.transpile.push("
|
|
118
|
+
nuxt.options.build.transpile.push("@powersync/web", "@journeyapps/wa-sqlite");
|
|
114
119
|
if (options.kysely) {
|
|
115
120
|
nuxt.options.build.transpile.push("@powersync/kysely-driver");
|
|
116
121
|
}
|
|
@@ -134,30 +139,35 @@ const module$1 = defineNuxtModule({
|
|
|
134
139
|
replacement: `${assetsDir}/$1`
|
|
135
140
|
});
|
|
136
141
|
nuxt.options.vite.resolve.alias = aliasArray;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
const plugins = config.plugins || [];
|
|
156
|
-
plugins.push(vitePlugin);
|
|
157
|
-
config.plugins = plugins;
|
|
142
|
+
const assetPath = resolver.resolve("./runtime/assets/powersync-icon.svg");
|
|
143
|
+
addVitePlugin({
|
|
144
|
+
name: "powersync-assets",
|
|
145
|
+
apply: "serve",
|
|
146
|
+
configureServer(server) {
|
|
147
|
+
server.middlewares.use("/assets/powersync-icon.svg", (_request, response, next) => {
|
|
148
|
+
try {
|
|
149
|
+
response.setHeader("Content-Type", "image/svg+xml");
|
|
150
|
+
response.end(readFileSync(assetPath));
|
|
151
|
+
} catch {
|
|
152
|
+
next();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
158
156
|
});
|
|
159
|
-
setupDevToolsUI(nuxt);
|
|
160
157
|
}
|
|
161
158
|
});
|
|
159
|
+
const DEVTOOLS_MODULES = ["@nuxt/devtools", "@nuxt/devtools-nightly", "@nuxt/devtools-edge"];
|
|
160
|
+
function nuxtDevtoolsMajor(nuxt) {
|
|
161
|
+
const installed = nuxt.options._installedModules.find((entry) => DEVTOOLS_MODULES.includes(entry.meta?.name ?? ""));
|
|
162
|
+
const fromMeta = installed?.meta?.version;
|
|
163
|
+
if (fromMeta) return Number(fromMeta.split(".")[0]) || 3;
|
|
164
|
+
try {
|
|
165
|
+
const from = installed?.entryPath ? join(dirname(installed.entryPath), "package.json") : join(nuxt.options.rootDir, "package.json");
|
|
166
|
+
const pkg = createRequire(from)("@nuxt/devtools/package.json");
|
|
167
|
+
return Number(pkg.version.split(".")[0]) || 3;
|
|
168
|
+
} catch {
|
|
169
|
+
return 3;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
162
172
|
|
|
163
173
|
export { module$1 as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Runs inside the diagnostics UI page when it is a Nuxt DevTools 3 tab. Nuxt DevTools assigns its
|
|
2
|
+
// iframe client to `window.__NUXT_DEVTOOLS__` on every same-origin tab, before or shortly after the
|
|
3
|
+
// page's scripts run, and fires `host:update:reactivity` when its state changes. This script reads the
|
|
4
|
+
// host's colour mode from it and hands it to the UI through the UI's own theme message, so the UI
|
|
5
|
+
// package needs to know nothing about Nuxt.
|
|
6
|
+
const THEME_MESSAGE_TYPE = 'powersync-diagnostics:theme';
|
|
7
|
+
|
|
8
|
+
function postTheme(client) {
|
|
9
|
+
const mode = client?.host?.app?.colorMode?.value;
|
|
10
|
+
if (mode !== 'dark' && mode !== 'light') return;
|
|
11
|
+
window.postMessage({ type: THEME_MESSAGE_TYPE, theme: mode }, location.origin);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function follow(client) {
|
|
15
|
+
if (!client) return;
|
|
16
|
+
postTheme(client);
|
|
17
|
+
client.host?.hooks?.hook('host:update:reactivity', () => postTheme(client));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (window.__NUXT_DEVTOOLS__) {
|
|
21
|
+
follow(window.__NUXT_DEVTOOLS__);
|
|
22
|
+
} else {
|
|
23
|
+
// Not connected yet: catch the assignment the host makes once the iframe has loaded.
|
|
24
|
+
let current;
|
|
25
|
+
Object.defineProperty(window, '__NUXT_DEVTOOLS__', {
|
|
26
|
+
configurable: true,
|
|
27
|
+
get: () => current,
|
|
28
|
+
set: (client) => {
|
|
29
|
+
current = client;
|
|
30
|
+
follow(client);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the module writes to `runtimeConfig.public.powerSyncModuleOptions` for its runtime plugin.
|
|
3
|
+
* Derived from {@link PowerSyncNuxtModuleOptions} at build time; not set by the app.
|
|
4
|
+
*/
|
|
5
|
+
export interface PowerSyncRuntimeOptions {
|
|
6
|
+
useDiagnostics: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Which page-side agent the runtime plugin loads during `nuxt dev`: none under Nuxt DevTools 4, where
|
|
9
|
+
* the devframe dock script serves the page, or the `postMessage` agent (`page`) under Nuxt DevTools 3.
|
|
10
|
+
*/
|
|
11
|
+
diagnosticsTransport: 'devframe' | 'page';
|
|
12
|
+
kysely: boolean;
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineNuxtPlugin,
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
2
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
3
3
|
const runtimeConfig = useRuntimeConfig();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
4
|
+
const moduleOptions = runtimeConfig.public.powerSyncModuleOptions ?? {};
|
|
5
|
+
nuxtApp.vueApp.config.globalProperties.$powerSyncModuleOptions = moduleOptions;
|
|
6
|
+
if (import.meta.dev && moduleOptions.useDiagnostics && moduleOptions.diagnosticsTransport === "page") {
|
|
7
|
+
import("@powersync/diagnostics/page").catch((error) => {
|
|
8
|
+
console.error("[powersync-diagnostics] failed to load the diagnostics client", error);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
11
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/nuxt",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20261015114518",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -39,23 +39,22 @@
|
|
|
39
39
|
"@nuxt/devtools-kit": "^3.2.3",
|
|
40
40
|
"@nuxt/devtools-ui-kit": "^3.2.3",
|
|
41
41
|
"@nuxt/kit": "^4.3.1",
|
|
42
|
-
"@tanstack/vue-table": "^8.21.3",
|
|
43
42
|
"@vueuse/core": "^14.2.1",
|
|
44
43
|
"@vueuse/nuxt": "^14.2.1",
|
|
44
|
+
"bson": "^6.10.4",
|
|
45
45
|
"defu": "^6.1.4",
|
|
46
46
|
"fuse.js": "^7.1.0",
|
|
47
47
|
"mitt": "^3.0.1",
|
|
48
48
|
"reka-ui": "^2.9.1",
|
|
49
49
|
"shiki": "^3.23.0",
|
|
50
|
-
"unocss": "^66.6.6",
|
|
51
50
|
"unstorage": "^1.17.4",
|
|
52
|
-
"
|
|
51
|
+
"@powersync/diagnostics": "0.0.0-dev-20261015114518"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
|
-
"@powersync/kysely-driver": "2.0.
|
|
56
|
-
"@powersync/vue": "0.
|
|
57
|
-
"@powersync/web": "0.0.0-dev-
|
|
58
|
-
"@powersync/shared-internals": "0.0.0-dev-
|
|
54
|
+
"@powersync/kysely-driver": "2.0.2",
|
|
55
|
+
"@powersync/vue": "0.7.0",
|
|
56
|
+
"@powersync/web": "0.0.0-dev-20261015114518",
|
|
57
|
+
"@powersync/shared-internals": "0.0.0-dev-20261015114518"
|
|
59
58
|
},
|
|
60
59
|
"peerDependenciesMeta": {
|
|
61
60
|
"@powersync/kysely-driver": {
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
}
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
|
-
"@journeyapps/wa-sqlite": "2.0.
|
|
65
|
+
"@journeyapps/wa-sqlite": "2.0.7",
|
|
67
66
|
"@nuxt/module-builder": "^1.0.2",
|
|
68
67
|
"@nuxt/schema": "^4.3.1",
|
|
69
68
|
"@nuxt/test-utils": "^4.0.3",
|
|
@@ -72,10 +71,10 @@
|
|
|
72
71
|
"vitest": "^4.1.10",
|
|
73
72
|
"vue": "^3.5.30",
|
|
74
73
|
"vue-tsc": "^3.2.5",
|
|
75
|
-
"@powersync/
|
|
76
|
-
"@powersync/
|
|
77
|
-
"@powersync/
|
|
78
|
-
"@powersync/
|
|
74
|
+
"@powersync/common": "0.0.0-dev-20261015114518",
|
|
75
|
+
"@powersync/kysely-driver": "2.0.2",
|
|
76
|
+
"@powersync/vue": "0.7.0",
|
|
77
|
+
"@powersync/web": "0.0.0-dev-20261015114518"
|
|
79
78
|
},
|
|
80
79
|
"scripts": {
|
|
81
80
|
"prebuild": "nuxt-module-build prepare",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|