@powersync/nuxt 0.1.0 → 2.0.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.
Files changed (55) hide show
  1. package/README.md +36 -59
  2. package/dist/module.d.mts +4 -3
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +74 -64
  5. package/dist/runtime/assets/devtools-theme.d.ts +1 -0
  6. package/dist/runtime/assets/devtools-theme.js +33 -0
  7. package/dist/runtime/options.d.ts +13 -0
  8. package/dist/runtime/options.js +0 -0
  9. package/dist/runtime/plugin.client.js +8 -8
  10. package/package.json +12 -13
  11. package/dist/runtime/components/BucketsInspectorTab.d.vue.ts +0 -3
  12. package/dist/runtime/components/BucketsInspectorTab.vue +0 -544
  13. package/dist/runtime/components/BucketsInspectorTab.vue.d.ts +0 -3
  14. package/dist/runtime/components/ConfigInspectorTab.d.vue.ts +0 -3
  15. package/dist/runtime/components/ConfigInspectorTab.vue +0 -84
  16. package/dist/runtime/components/ConfigInspectorTab.vue.d.ts +0 -3
  17. package/dist/runtime/components/DataInspectorTab.d.vue.ts +0 -3
  18. package/dist/runtime/components/DataInspectorTab.vue +0 -564
  19. package/dist/runtime/components/DataInspectorTab.vue.d.ts +0 -3
  20. package/dist/runtime/components/LoadingSpinner.d.vue.ts +0 -3
  21. package/dist/runtime/components/LoadingSpinner.vue +0 -12
  22. package/dist/runtime/components/LoadingSpinner.vue.d.ts +0 -3
  23. package/dist/runtime/components/LogsTab.d.vue.ts +0 -3
  24. package/dist/runtime/components/LogsTab.vue +0 -273
  25. package/dist/runtime/components/LogsTab.vue.d.ts +0 -3
  26. package/dist/runtime/components/PowerSyncInstanceTab.d.vue.ts +0 -3
  27. package/dist/runtime/components/PowerSyncInstanceTab.vue +0 -7
  28. package/dist/runtime/components/PowerSyncInstanceTab.vue.d.ts +0 -3
  29. package/dist/runtime/components/SyncStatusTab.d.vue.ts +0 -3
  30. package/dist/runtime/components/SyncStatusTab.vue +0 -161
  31. package/dist/runtime/components/SyncStatusTab.vue.d.ts +0 -3
  32. package/dist/runtime/composables/usePowerSyncInspector.d.ts +0 -39
  33. package/dist/runtime/composables/usePowerSyncInspector.js +0 -17
  34. package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.d.ts +0 -153
  35. package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.js +0 -216
  36. package/dist/runtime/layouts/powersync-inspector-layout.d.vue.ts +0 -13
  37. package/dist/runtime/layouts/powersync-inspector-layout.vue +0 -63
  38. package/dist/runtime/layouts/powersync-inspector-layout.vue.d.ts +0 -13
  39. package/dist/runtime/pages/__powersync-inspector.d.vue.ts +0 -3
  40. package/dist/runtime/pages/__powersync-inspector.vue +0 -119
  41. package/dist/runtime/pages/__powersync-inspector.vue.d.ts +0 -3
  42. package/dist/runtime/utils/AppSchema.d.ts +0 -27
  43. package/dist/runtime/utils/AppSchema.js +0 -23
  44. package/dist/runtime/utils/DynamicSchemaManager.d.ts +0 -16
  45. package/dist/runtime/utils/DynamicSchemaManager.js +0 -82
  46. package/dist/runtime/utils/JsSchemaGenerator.d.ts +0 -8
  47. package/dist/runtime/utils/JsSchemaGenerator.js +0 -28
  48. package/dist/runtime/utils/NuxtPowerSyncDatabase.d.ts +0 -42
  49. package/dist/runtime/utils/NuxtPowerSyncDatabase.js +0 -97
  50. package/dist/runtime/utils/RustClientInterceptor.d.ts +0 -24
  51. package/dist/runtime/utils/RustClientInterceptor.js +0 -90
  52. package/dist/runtime/utils/TokenConnector.d.ts +0 -14
  53. package/dist/runtime/utils/TokenConnector.js +0 -57
  54. package/dist/runtime/utils/index.d.ts +0 -1
  55. package/dist/runtime/utils/index.js +0 -1
@@ -1,273 +0,0 @@
1
- <template>
2
- <div border="t" border-color="gray-100" relative n-bg="base" flex="~ col" h="screen" overflow="hidden">
3
- <!-- Toolbar -->
4
- <div class="flex items-center justify-between gap-3 px-3 py-2 border-b border-gray-200 dark:border-neutral-700">
5
- <div class="flex items-center gap-2 flex-1">
6
- <NTextInput
7
- v-model="searchQuery"
8
- n="xs"
9
- class="flex-1 max-w-md"
10
- placeholder="Search logs..."
11
- icon="carbon:search"
12
- />
13
-
14
- <select
15
- v-model="selectedLevel"
16
- class="px-2 py-1 text-xs border border-gray-300 dark:border-neutral-600 rounded bg-white dark:bg-neutral-800"
17
- >
18
- <option value="all">All Levels</option>
19
- <option value="error">Error</option>
20
- <option value="warn">Warning</option>
21
- <option value="info">Info</option>
22
- <option value="debug">Debug</option>
23
- <option value="trace">Trace</option>
24
- </select>
25
- </div>
26
-
27
- <div class="flex items-center gap-2">
28
- <NBadge n="slate xs">
29
- {{ filteredLogs.length }}
30
- </NBadge>
31
- <NButton n="xs red" icon="carbon:trash-can" @click="clearLogs"> Clear </NButton>
32
- </div>
33
- </div>
34
-
35
- <!-- Logs Table -->
36
- <div class="flex-1 overflow-auto">
37
- <div v-if="filteredLogs.length === 0" class="text-center py-12">
38
- <div class="text-gray-500 dark:text-gray-400 text-sm">No logs found</div>
39
- </div>
40
-
41
- <table v-else class="w-full">
42
- <thead
43
- class="sticky top-0 bg-gray-50 dark:bg-neutral-900 border-b border-gray-200 dark:border-neutral-700 z-10"
44
- >
45
- <tr>
46
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-8" />
47
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-32">Time</th>
48
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-20">Source</th>
49
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-20">Level</th>
50
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400">Message</th>
51
- <th class="px-2 py-1.5 text-left text-xs font-medium text-gray-500 dark:text-gray-400 w-16" />
52
- </tr>
53
- </thead>
54
- <tbody>
55
- <template v-for="log in filteredLogs" :key="log.key">
56
- <tr
57
- class="log-entry hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors cursor-pointer border-b border-b-gray-100 dark:border-b-neutral-800"
58
- @click="toggleExpand(log.key)"
59
- >
60
- <td class="px-2 py-1.5">
61
- <div class="w-1.5 h-1.5 rounded-full" :class="getLogDotClass(log)" />
62
- </td>
63
- <td class="px-2 py-1.5">
64
- <span class="text-xs font-mono text-gray-600 dark:text-gray-400">
65
- {{ log.value ? formatTime(log.value.date) : "" }}
66
- </span>
67
- </td>
68
- <td class="px-2 py-1.5">
69
- <div class="text-xs text-gray-700 dark:text-gray-300 truncate max-w-3xl">
70
- {{ getLogSource(log) }}
71
- </div>
72
- </td>
73
- <td class="px-2 py-1.5">
74
- <NBadge :n="`${getLogBadgeColor(log)} xs`">
75
- {{ getLogType(log) }}
76
- </NBadge>
77
- </td>
78
- <td class="px-2 py-1.5">
79
- <div class="text-xs text-gray-700 dark:text-gray-300 truncate max-w-3xl">
80
- {{ getLogMessage(log) }}
81
- </div>
82
- </td>
83
- <td class="px-2 py-1.5 text-center">
84
- <NIcon
85
- v-if="hasExtraData(log)"
86
- :icon="expandedLogs.has(log.key) ? 'carbon:chevron-up' : 'carbon:constraint'"
87
- class="text-gray-600 text-xs"
88
- />
89
- </td>
90
- </tr>
91
- <tr v-if="expandedLogs.has(log.key) && hasExtraData(log)" class="bg-gray-50 dark:bg-neutral-900/50">
92
- <td colspan="12">
93
- <div class="px-10 py-2">
94
- <div class="inline-flex items-center gap-2 mb-2">
95
- <NIcon n="sm" icon="carbon:object" />
96
- <span class="text-xs text-gray-600 dark:text-gray-400">JSON</span>
97
- </div>
98
- <div
99
- class="bg-white dark:bg-neutral-800 p-3 rounded border border-gray-200 dark:border-neutral-700 overflow-x-auto"
100
- >
101
- <div class="json-code-block text-xs" v-html="highlightedJson.get(log.key) ?? ''" />
102
- </div>
103
- </div>
104
- </td>
105
- </tr>
106
- </template>
107
- </tbody>
108
- </table>
109
- </div>
110
- </div>
111
- </template>
112
-
113
- <script setup>
114
- import { useDiagnosticsLogger } from "#imports";
115
- import { ref, computed, onMounted, onUnmounted } from "vue";
116
- import Fuse from "fuse.js";
117
- import { codeToHtml } from "shiki";
118
- const { logsStorage, emitter } = useDiagnosticsLogger();
119
- const searchQuery = ref("");
120
- const selectedLevel = ref("all");
121
- const expandedLogs = ref(/* @__PURE__ */ new Set());
122
- const logs = ref([]);
123
- const highlightedJson = ref(/* @__PURE__ */ new Map());
124
- async function loadInitialLogs() {
125
- const keys = await logsStorage.getKeys("log:");
126
- const items = await logsStorage.getItems(keys.map((key) => ({ key })));
127
- logs.value = items.sort((a, b) => {
128
- const dateA = a.value ? new Date(a.value.date).getTime() : 0;
129
- const dateB = b.value ? new Date(b.value.date).getTime() : 0;
130
- return dateB - dateA;
131
- });
132
- }
133
- const handleLog = (event) => {
134
- logs.value.unshift({ key: event.key, value: event.value });
135
- };
136
- onMounted(() => {
137
- loadInitialLogs();
138
- emitter.on("log", handleLog);
139
- });
140
- onUnmounted(() => {
141
- emitter.off("log", handleLog);
142
- });
143
- const fuse = computed(() => {
144
- if (!logs.value || logs.value.length === 0) return null;
145
- return new Fuse(logs.value, {
146
- keys: [
147
- { name: "message", getFn: (log) => getLogMessage(log), weight: 2 },
148
- { name: "type", getFn: (log) => log.value?.type || "" },
149
- { name: "extraData", getFn: (log) => getSearchableExtraData(log), weight: 0.5 }
150
- ],
151
- threshold: 0.3,
152
- includeScore: true,
153
- useExtendedSearch: true,
154
- includeMatches: true
155
- });
156
- });
157
- const filteredLogs = computed(() => {
158
- let filtered = logs.value || [];
159
- if (selectedLevel.value !== "all") {
160
- filtered = filtered.filter((log) => log.value?.type === selectedLevel.value);
161
- }
162
- if (searchQuery.value && fuse.value) {
163
- const searchResults = fuse.value.search(searchQuery.value);
164
- const searchedItems = searchResults.map((result) => result.item);
165
- if (selectedLevel.value !== "all") {
166
- filtered = filtered.filter((log) => searchedItems.some((item) => item.key === log.key));
167
- } else {
168
- filtered = searchedItems;
169
- }
170
- }
171
- return filtered;
172
- });
173
- async function toggleExpand(key) {
174
- if (expandedLogs.value.has(key)) {
175
- expandedLogs.value.delete(key);
176
- } else {
177
- expandedLogs.value.add(key);
178
- if (!highlightedJson.value.has(key)) {
179
- const log = logs.value.find((l) => l.key === key);
180
- if (log) {
181
- const jsonStr = formatExtraData(log);
182
- const html = await codeToHtml(jsonStr || '""', {
183
- lang: "json",
184
- themes: {
185
- light: "catppuccin-latte",
186
- dark: "catppuccin-frappe"
187
- }
188
- });
189
- highlightedJson.value.set(key, typeof html === "string" ? html : "");
190
- }
191
- }
192
- }
193
- }
194
- function getLogMessage(log) {
195
- if (!log.value?.args || log.value.args.length === 0) return "Empty log message";
196
- return String(log.value.args[0] || "Empty log message");
197
- }
198
- function getLogSource(log) {
199
- const context = log.value?.args[2];
200
- return context?.name ?? "";
201
- }
202
- function hasExtraData(log) {
203
- return !!(log.value?.args && log.value.args.length > 2 && log.value.args[1] && !(typeof log.value.args[1] === "object" && log.value.args[1] !== null && Object.keys(log.value.args[1]).length === 0));
204
- }
205
- function formatExtraData(log) {
206
- if (!log.value?.args || log.value.args.length <= 1) return "";
207
- const data = log.value.args[1];
208
- if (data === void 0 || data === null) return "";
209
- const str = JSON.stringify(data, null, 2);
210
- return typeof str === "string" ? str : "";
211
- }
212
- function getSearchableExtraData(log) {
213
- if (!log.value?.args || log.value.args.length <= 1) return "";
214
- const data = log.value.args[1];
215
- if (!data) return "";
216
- try {
217
- const jsonStr = JSON.stringify(data);
218
- const result = jsonStr.replace(/[{}[\]",:]/g, " ").replace(/\s+/g, " ").trim();
219
- return result;
220
- } catch {
221
- return String(data);
222
- }
223
- }
224
- function formatTime(date) {
225
- return new Date(date).toLocaleTimeString("en-US", {
226
- hour12: false,
227
- hour: "2-digit",
228
- minute: "2-digit",
229
- second: "2-digit",
230
- fractionalSecondDigits: 3
231
- });
232
- }
233
- function getLogType(log) {
234
- return (log.value?.type || "info").toUpperCase();
235
- }
236
- function getLogDotClass(log) {
237
- const type = log.value?.type || "info";
238
- const classes = {
239
- error: "bg-red-500",
240
- warn: "bg-yellow-500",
241
- info: "bg-blue-500",
242
- debug: "bg-gray-400",
243
- trace: "bg-gray-300 dark:bg-gray-500"
244
- };
245
- return classes[type] || classes.info;
246
- }
247
- function getLogBadgeColor(log) {
248
- const type = log.value?.type || "info";
249
- const colors = {
250
- error: "red",
251
- warn: "yellow",
252
- info: "blue",
253
- debug: "gray",
254
- trace: "slate"
255
- };
256
- return colors[type] || colors.info;
257
- }
258
- async function clearLogs() {
259
- const keys = await logsStorage.getKeys("log:");
260
- await Promise.all(keys.map((key) => logsStorage.removeItem(key)));
261
- logs.value = [];
262
- expandedLogs.value.clear();
263
- highlightedJson.value.clear();
264
- }
265
- </script>
266
-
267
- <style scoped>
268
- .log-entry{animation:slideIn .2s ease-out}@keyframes slideIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}
269
- </style>
270
-
271
- <style>
272
- .json-code-block{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;line-height:1.4}.json-code-block pre{background:transparent!important;overflow:visible}.json-code-block code,.json-code-block pre{font-family:inherit;font-size:inherit;line-height:inherit;margin:0;padding:0}.json-code-block code{counter-increment:step 0;counter-reset:step;display:block}.json-code-block code .line:before{color:rgba(115,138,148,.4);content:counter(step);counter-increment:step;display:inline-block;margin-right:1.5rem;text-align:right;width:1rem}.dark .json-code-block code .line:before{color:#858080}
273
- </style>
@@ -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;
@@ -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;
@@ -1,7 +0,0 @@
1
- <template>
2
- <div>
3
- <h1>PowerSync Instance</h1>
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts"></script>
@@ -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;
@@ -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;
@@ -1,161 +0,0 @@
1
- <template>
2
- <div border="t" border-color="gray-100" relative n-bg="base" flex="~ col" h="screen">
3
- <div flex="~ col gap-2">
4
- <NSectionBlock icon="carbon:data-share" text="Data Flow">
5
- <div grid="~ cols-6 gap-4" mb="4">
6
- <!-- Download Progress -->
7
- <div flex="~ col gap-2">
8
- <span text="sm gray-500">Download Progress</span>
9
- <div flex="~ items-center gap-2">
10
- <template v-if="downloadProgressDetails !== null">
11
- <div flex="1" bg="gray-200" rounded="full" h="2">
12
- <div
13
- bg="blue-600"
14
- h="2"
15
- rounded="full"
16
- transition="all"
17
- duration="300"
18
- :style="{
19
- width: `${totalDownloadProgress}%`
20
- }"
21
- />
22
- </div>
23
- <span text="sm" font="medium">{{ totalDownloadProgress }}%</span>
24
- </template>
25
- <template v-else>
26
- <span text="sm gray-400">No active download</span>
27
- </template>
28
- </div>
29
- </div>
30
-
31
- <!-- Error Indicator -->
32
- <div flex="~ col gap-2">
33
- <span text="sm gray-500">Status</span>
34
- <NBadge
35
- :n="downloadError ? 'red' : 'green'"
36
- :icon="downloadError ? 'carbon:warning-filled' : 'carbon:checkmark-filled'"
37
- >
38
- {{ downloadError ? "Error" : "Healthy" }}
39
- </NBadge>
40
- </div>
41
-
42
- <!-- Error Details -->
43
- <div flex="~ col gap-2" col="span-4">
44
- <span text="sm gray-500">Error Message</span>
45
- <NBadge v-if="downloadError" n="red sm" icon="carbon:warning-filled">
46
- {{ downloadError.message }}
47
- </NBadge>
48
- <NBadge v-else n="slate sm" icon="carbon:checkmark-filled"> N/A </NBadge>
49
- </div>
50
- </div>
51
-
52
- <div grid="~ cols-6 gap-4" mb="4">
53
- <!-- Upload Progress -->
54
- <div flex="~ col gap-2">
55
- <span text="sm gray-500">Upload Progress</span>
56
- <div flex="~ items-center gap-2">
57
- <span v-if="syncStatus?.uploading">upload in progress...</span>
58
- <span v-else text="sm gray-400">No active upload</span>
59
- </div>
60
- </div>
61
-
62
- <!-- Error Indicator -->
63
- <div flex="~ col gap-2">
64
- <span text="sm gray-500">Status</span>
65
- <NBadge
66
- :n="uploadError ? 'red' : 'green'"
67
- :icon="uploadError ? 'carbon:warning-filled' : 'carbon:checkmark-filled'"
68
- >
69
- {{ uploadError ? "Error" : "Healthy" }}
70
- </NBadge>
71
- </div>
72
-
73
- <div flex="~ col gap-2">
74
- <span text="sm gray-500">Upload Queue Count</span>
75
- <span text="sm"> {{ uploadQueueCount }} </span>
76
- </div>
77
-
78
- <div flex="~ col gap-2">
79
- <span text="sm gray-500">Upload Queue Size</span>
80
- <span text="sm">
81
- {{ uploadQueueSize }}
82
- </span>
83
- </div>
84
-
85
- <!-- Error Details -->
86
- <div flex="~ col gap-2" col="span-2">
87
- <span text="sm gray-500">Error Message</span>
88
- <NBadge v-if="uploadError" n="red sm" icon="carbon:warning-filled">
89
- {{ uploadError.message }}
90
- </NBadge>
91
- <NBadge v-else n="slate sm" icon="carbon:checkmark-filled"> N/A </NBadge>
92
- </div>
93
- </div>
94
- </NSectionBlock>
95
-
96
- <span border="b" border-color="gray-100" />
97
-
98
- <template v-for="(section, index) in metricSections" :key="section.text">
99
- <NSectionBlock :icon="section.icon" :text="section.text">
100
- <NTip v-if="!isDiagnosticSchemaSetup" n="red6 dark:red5" icon="carbon:warning-alt">
101
- Make sure to extend your schema with the diagnostics schema using the `diagnosticsSchema` from the
102
- `usePowerSyncInspector` composable.
103
- </NTip>
104
- <div v-else :grid="`~ cols-${section.cols} gap-4`" mb="4">
105
- <div v-for="metric in section.metrics" :key="metric.label" flex="~ col gap-2">
106
- <span text="sm gray-500">{{ metric.label }}</span>
107
- <span text="sm">{{ metric.value }}</span>
108
- </div>
109
- </div>
110
- </NSectionBlock>
111
-
112
- <span v-if="index < metricSections.length - 1" border="b" border-color="gray-100" />
113
- </template>
114
-
115
- <span border="b" border-color="gray-100" />
116
- </div>
117
- </div>
118
- </template>
119
-
120
- <script setup>
121
- import { usePowerSyncInspectorDiagnostics } from "#imports";
122
- import { computed, onMounted } from "vue";
123
- const {
124
- db,
125
- isDiagnosticSchemaSetup,
126
- syncStatus,
127
- downloadProgressDetails,
128
- totalDownloadProgress,
129
- downloadError,
130
- uploadError,
131
- uploadQueueCount,
132
- uploadQueueSize,
133
- totals
134
- } = usePowerSyncInspectorDiagnostics();
135
- const metricSections = computed(() => [
136
- {
137
- icon: "carbon:data-volume",
138
- text: "Data Size",
139
- cols: 5,
140
- metrics: [
141
- { label: "Buckets Synced", value: totals.value?.buckets },
142
- { label: "Rows Synced", value: totals.value?.row_count },
143
- { label: "Data size", value: totals.value?.data_size },
144
- { label: "Metadata size", value: totals.value?.metadata_size },
145
- { label: "Download size", value: totals.value?.download_size }
146
- ]
147
- },
148
- {
149
- icon: "carbon:data-share",
150
- text: "Operations",
151
- cols: 2,
152
- metrics: [
153
- { label: "Total operations", value: totals.value?.total_operations },
154
- { label: "Downloaded operations", value: totals.value?.downloaded_operations }
155
- ]
156
- }
157
- ]);
158
- onMounted(async () => {
159
- await db?.value?.waitForFirstSync();
160
- });
161
- </script>
@@ -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;
@@ -1,39 +0,0 @@
1
- import { DynamicSchemaManager } from '../utils/DynamicSchemaManager.js';
2
- declare function getCurrentSchemaManager(): DynamicSchemaManager;
3
- /**
4
- * A composable for setting up PowerSync Inspector functionality.
5
- *
6
- * This composable provides utilities for schema management and diagnostics setup.
7
- * It exposes the diagnostics schema and internal utilities needed for the inspector.
8
- *
9
- * @returns An object containing:
10
- * - `diagnosticsSchema` - The schema for diagnostics data collection. Use this to extend your app schema with diagnostic tables.
11
- * - `getCurrentSchemaManager()` - Used internally. Gets the current schema manager instance for dynamic schema operations.
12
- *
13
- * @example
14
- * ```typescript
15
- * const { diagnosticsSchema } = usePowerSyncInspector()
16
- *
17
- * // Combine with your app schema
18
- * const combinedSchema = new Schema([
19
- * ...yourAppSchema.tables,
20
- * ...diagnosticsSchema.tables,
21
- * ])
22
- * ```
23
- */
24
- export declare function usePowerSyncInspector(): {
25
- diagnosticsSchema: import("@powersync/common").Schema<{
26
- local_bucket_data: import("@powersync/common").Table<{
27
- total_operations: import("@powersync/common").BaseColumnType<number | null>;
28
- last_op: import("@powersync/common").BaseColumnType<string | null>;
29
- download_size: import("@powersync/common").BaseColumnType<number | null>;
30
- downloaded_operations: import("@powersync/common").BaseColumnType<number | null>;
31
- downloading: import("@powersync/common").BaseColumnType<number | null>;
32
- }>;
33
- local_schema: import("@powersync/common").Table<{
34
- data: import("@powersync/common").BaseColumnType<string | null>;
35
- }>;
36
- }>;
37
- getCurrentSchemaManager: typeof getCurrentSchemaManager;
38
- };
39
- export {};
@@ -1,17 +0,0 @@
1
- import { DiagnosticsAppSchema } from "../utils/AppSchema.js";
2
- import { DynamicSchemaManager } from "../utils/DynamicSchemaManager.js";
3
- let currentSchemaManager = null;
4
- function getCurrentSchemaManager() {
5
- if (currentSchemaManager) {
6
- return currentSchemaManager;
7
- }
8
- currentSchemaManager = new DynamicSchemaManager();
9
- return currentSchemaManager;
10
- }
11
- export function usePowerSyncInspector() {
12
- const diagnosticsSchema = DiagnosticsAppSchema;
13
- return {
14
- diagnosticsSchema,
15
- getCurrentSchemaManager
16
- };
17
- }
@@ -1,153 +0,0 @@
1
- import type { CommonPowerSyncDatabase, PowerSyncBackendConnector, SyncOptions, SyncStatus, UploadQueueStats } from '@powersync/common';
2
- import type { ComputedRef, Ref } from 'vue';
3
- export type BucketRow = {
4
- name: string;
5
- id: number;
6
- tables: string[];
7
- data_size: number;
8
- metadata_size: number;
9
- row_count: number;
10
- download_size: number;
11
- downloaded_operations: number;
12
- total_operations: number;
13
- downloading: number;
14
- };
15
- export type TableRow = {
16
- name: string;
17
- count: number;
18
- size: number;
19
- };
20
- /** Aggregated statistics from the diagnostics composable. */
21
- export type UsePowerSyncInspectorDiagnosticsTotals = {
22
- buckets: number;
23
- row_count: number;
24
- downloaded_operations: number | undefined;
25
- total_operations: number;
26
- data_size: string;
27
- metadata_size: string;
28
- download_size: string;
29
- };
30
- type ReadonlyRef<T> = Readonly<Ref<T>>;
31
- /**
32
- * Return type of {@link usePowerSyncInspectorDiagnostics}.
33
- * Uses named types so the signature stays readable in docs and IDE.
34
- */
35
- export interface UsePowerSyncInspectorDiagnosticsReturn {
36
- db: Ref<CommonPowerSyncDatabase> | undefined;
37
- connector: ComputedRef<PowerSyncBackendConnector | null>;
38
- connectionOptions: ComputedRef<SyncOptions | null>;
39
- isDiagnosticSchemaSetup: ReadonlyRef<boolean>;
40
- /** Current sync status. Typed as SyncStatus for a concise doc signature; at runtime it may be a readonly proxy. */
41
- syncStatus: ReadonlyRef<SyncStatus>;
42
- hasSynced: ReadonlyRef<boolean>;
43
- isConnected: ReadonlyRef<boolean>;
44
- isSyncing: ReadonlyRef<boolean>;
45
- isDownloading: ReadonlyRef<boolean>;
46
- isUploading: ReadonlyRef<boolean>;
47
- downloadError: ReadonlyRef<unknown>;
48
- uploadError: ReadonlyRef<unknown>;
49
- downloadProgressDetails: ReadonlyRef<unknown>;
50
- lastSyncedAt: ReadonlyRef<Date | null>;
51
- totalDownloadProgress: ReadonlyRef<string>;
52
- uploadQueueStats: ReadonlyRef<UploadQueueStats | null>;
53
- uploadQueueCount: ReadonlyRef<number>;
54
- uploadQueueSize: ReadonlyRef<string>;
55
- userID: ReadonlyRef<string | null>;
56
- bucketRows: ReadonlyRef<BucketRow[] | null>;
57
- tableRows: ReadonlyRef<TableRow[] | null>;
58
- totals: ReadonlyRef<UsePowerSyncInspectorDiagnosticsTotals>;
59
- clearData: () => Promise<void>;
60
- formatBytes: (bytes: number, decimals?: number) => string;
61
- }
62
- /**
63
- * A comprehensive composable that provides real-time diagnostics data and sync status monitoring
64
- * for your PowerSync client and local database.
65
- *
66
- * This composable can be used to create your own inspector or to monitor sync status in your application.
67
- * It provides reactive properties that update automatically as the sync state changes.
68
- *
69
- * @returns An object containing:
70
- *
71
- * **Database & Connection:**
72
- * - `db` - The PowerSync database instance
73
- * - `connector` - The current PowerSync backend connector (computed)
74
- * - `connectionOptions` - The current connection options (computed)
75
- * - `isDiagnosticSchemaSetup` - Whether the diagnostic schema is properly set up
76
- *
77
- * **Sync Status:**
78
- * - `syncStatus` - The current sync status object
79
- * - `hasSynced` - Whether the database has completed at least one sync
80
- * - `isConnected` - Whether the database is currently connected
81
- * - `isSyncing` - Whether a sync operation is in progress
82
- * - `isDownloading` - Whether data is currently being downloaded
83
- * - `isUploading` - Whether data is currently being uploaded
84
- * - `lastSyncedAt` - The timestamp of the last successful sync
85
- *
86
- * **Progress & Statistics:**
87
- * - `totalDownloadProgress` - Total download progress as a percentage string (computed)
88
- * - `uploadQueueStats` - Statistics about the upload queue
89
- * - `uploadQueueCount` - Number of items in the upload queue (computed)
90
- * - `uploadQueueSize` - Size of the upload queue in human-readable format (computed)
91
- * - `bucketRows` - Array of bucket data rows
92
- * - `tableRows` - Array of table statistics rows
93
- * - `totals` - Aggregated statistics including bucket count, row count, and data sizes (computed)
94
- *
95
- * **Error Handling:**
96
- * - `downloadError` - Any error that occurred during download
97
- * - `uploadError` - Any error that occurred during upload
98
- * - `downloadProgressDetails` - Detailed download progress information
99
- *
100
- * **User Info:**
101
- * - `userID` - The current user ID extracted from the authentication token (computed)
102
- *
103
- * **Utilities:**
104
- * - `clearData()` - Disconnects and clears all local PowerSync data, then reconnects. Useful for resetting the sync state during development or troubleshooting.
105
- * - `formatBytes(bytes, decimals?)` - Formats byte counts into readable file sizes (e.g., "1.5 MiB"). Default decimals is 2.
106
- *
107
- * @example
108
- * ```vue
109
- * <script setup lang="ts">
110
- * const {
111
- * isConnected,
112
- * hasSynced,
113
- * isSyncing,
114
- * totalDownloadProgress,
115
- * uploadQueueStats,
116
- * bucketRows,
117
- * totals,
118
- * clearData,
119
- * } = usePowerSyncInspectorDiagnostics()
120
- * </script>
121
- *
122
- * <template>
123
- * <div>
124
- * <!-- Connection Status -->
125
- * <div v-if="isConnected" class="status-connected">
126
- * Connected {{ hasSynced ? '✅' : '⏳' }}
127
- * </div>
128
- *
129
- * <!-- Sync Progress -->
130
- * <div v-if="isSyncing">
131
- * Syncing... {{ totalDownloadProgress }}%
132
- * </div>
133
- *
134
- * <!-- Statistics -->
135
- * <div v-if="totals">
136
- * <p>Buckets: {{ totals.buckets }}</p>
137
- * <p>Total Rows: {{ totals.row_count }}</p>
138
- * <p>Data Size: {{ totals.data_size }}</p>
139
- * </div>
140
- *
141
- * <!-- Upload Queue -->
142
- * <div v-if="uploadQueueStats">
143
- * Pending uploads: {{ uploadQueueStats.count }}
144
- * </div>
145
- *
146
- * <!-- Debug Actions -->
147
- * <button @click="clearData">Clear Data</button>
148
- * </div>
149
- * </template>
150
- * ```
151
- */
152
- export declare function usePowerSyncInspectorDiagnostics(): UsePowerSyncInspectorDiagnosticsReturn;
153
- export {};