local-lite 2.0.6 → 3.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 (82) hide show
  1. package/README.md +0 -30
  2. package/dist/adapters/local/index.d.ts +1 -0
  3. package/dist/adapters/local/index.js +1 -0
  4. package/dist/adapters/local/sqlite-wasm.d.ts +25 -0
  5. package/dist/adapters/local/sqlite-wasm.js +55 -0
  6. package/dist/adapters/remote/convex.d.ts +1 -1
  7. package/dist/adapters/remote/convex.js +25 -3
  8. package/dist/adapters/remote/demo.d.ts +3 -3
  9. package/dist/adapters/remote/demo.js +11 -3
  10. package/dist/adapters/remote/firestore.d.ts +1 -1
  11. package/dist/adapters/remote/firestore.js +57 -91
  12. package/dist/adapters/remote/index.d.ts +2 -1
  13. package/dist/adapters/remote/index.js +1 -0
  14. package/dist/adapters/remote/postgres.d.ts +37 -0
  15. package/dist/adapters/remote/postgres.js +119 -0
  16. package/dist/adapters/remote/self-hosted.d.ts +12 -0
  17. package/dist/adapters/remote/self-hosted.js +55 -4
  18. package/dist/adapters/remote/supabase.d.ts +1 -1
  19. package/dist/adapters/remote/supabase.js +22 -5
  20. package/dist/auth/apple.js +0 -6
  21. package/dist/auth/github.js +0 -3
  22. package/dist/auth/google.js +0 -3
  23. package/dist/auth/identity.d.ts +0 -5
  24. package/dist/auth/identity.js +0 -3
  25. package/dist/auth/microsoft.js +0 -3
  26. package/dist/auth/unified.d.ts +5 -5
  27. package/dist/auth/unified.js +1 -1
  28. package/dist/config/index.d.ts +0 -12
  29. package/dist/config/index.js +3 -26
  30. package/dist/config/types.d.ts +3 -2
  31. package/dist/core/audit.d.ts +52 -0
  32. package/dist/core/audit.js +153 -0
  33. package/dist/core/client.d.ts +4 -0
  34. package/dist/core/client.js +7 -0
  35. package/dist/core/conflict.d.ts +24 -0
  36. package/dist/core/conflict.js +77 -0
  37. package/dist/core/field-encryption.d.ts +25 -0
  38. package/dist/core/field-encryption.js +128 -0
  39. package/dist/core/index.d.ts +2 -0
  40. package/dist/core/index.js +2 -0
  41. package/dist/core/query-builder.d.ts +51 -0
  42. package/dist/core/query-builder.js +278 -35
  43. package/dist/core/query.js +6 -1
  44. package/dist/core/types.d.ts +2 -1
  45. package/dist/devtools/BenchmarkModal.js +285 -1
  46. package/dist/email/index.d.ts +1 -1
  47. package/dist/email/index.js +2 -2
  48. package/dist/index.d.ts +2 -27
  49. package/dist/index.js +2 -27
  50. package/dist/presence/index.d.ts +45 -0
  51. package/dist/presence/index.js +142 -0
  52. package/dist/reactive/event-emitter.d.ts +10 -1
  53. package/dist/reactive/event-emitter.js +44 -1
  54. package/dist/reactive/live-query.d.ts +18 -0
  55. package/dist/reactive/live-query.js +71 -0
  56. package/dist/schema/index.d.ts +1 -0
  57. package/dist/schema/index.js +1 -0
  58. package/dist/schema/typed.d.ts +38 -0
  59. package/dist/schema/typed.js +33 -0
  60. package/dist/server/dashboard.d.ts +2 -0
  61. package/dist/server/dashboard.js +1272 -1044
  62. package/dist/solid/index.d.ts +24 -0
  63. package/dist/solid/index.js +35 -0
  64. package/dist/storage/firebase.d.ts +3 -3
  65. package/dist/storage/firebase.js +40 -94
  66. package/dist/svelte/index.d.ts +15 -0
  67. package/dist/svelte/index.js +27 -0
  68. package/dist/testing/index.d.ts +22 -0
  69. package/dist/testing/index.js +74 -0
  70. package/dist/vue/index.d.ts +27 -0
  71. package/dist/vue/index.js +37 -0
  72. package/package.json +46 -9
  73. package/dist/kv/index.d.ts +0 -3
  74. package/dist/kv/index.js +0 -19
  75. package/dist/kv/manager.d.ts +0 -52
  76. package/dist/kv/manager.js +0 -167
  77. package/dist/kv/store.d.ts +0 -13
  78. package/dist/kv/store.js +0 -85
  79. package/dist/kv/types.d.ts +0 -27
  80. package/dist/kv/types.js +0 -2
  81. package/dist/react/kv.d.ts +0 -9
  82. package/dist/react/kv.js +0 -53
@@ -0,0 +1,24 @@
1
+ import { LocalFirstClient } from '../core/client.js';
2
+ import { QueryOptions, SyncStatusEvent } from '../core/types.js';
3
+ export interface SolidApi {
4
+ createSignal<T>(value: T): [() => T, (next: T) => void];
5
+ onCleanup?: (fn: () => void) => void;
6
+ }
7
+ /**
8
+ * SolidJS primitive for live local-lite queries.
9
+ * Pass `{ createSignal, onCleanup }` from `'solid-js'`.
10
+ */
11
+ export declare function createLiveQuery<T = any>(client: LocalFirstClient, tableName: string, options: QueryOptions | undefined, solid: SolidApi): {
12
+ data: () => T[];
13
+ loading: () => boolean;
14
+ error: () => Error | null;
15
+ refresh: () => Promise<void>;
16
+ dispose: () => void;
17
+ };
18
+ /**
19
+ * SolidJS signal for tracking `client.syncWorker` status.
20
+ */
21
+ export declare function createSyncStatus(client: LocalFirstClient, solid: SolidApi): {
22
+ status: () => SyncStatusEvent;
23
+ dispose: () => void;
24
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLiveQuery = createLiveQuery;
4
+ exports.createSyncStatus = createSyncStatus;
5
+ const live_query_js_1 = require("../reactive/live-query.js");
6
+ /**
7
+ * SolidJS primitive for live local-lite queries.
8
+ * Pass `{ createSignal, onCleanup }` from `'solid-js'`.
9
+ */
10
+ function createLiveQuery(client, tableName, options, solid) {
11
+ const [data, setData] = solid.createSignal([]);
12
+ const [loading, setLoading] = solid.createSignal(true);
13
+ const [error, setError] = solid.createSignal(null);
14
+ const { refresh, dispose } = (0, live_query_js_1.subscribeLiveQuery)(client, tableName, options, (state) => {
15
+ setData(state.data);
16
+ setLoading(state.loading);
17
+ setError(state.error);
18
+ });
19
+ solid.onCleanup?.(dispose);
20
+ return { data, loading, error, refresh, dispose };
21
+ }
22
+ /**
23
+ * SolidJS signal for tracking `client.syncWorker` status.
24
+ */
25
+ function createSyncStatus(client, solid) {
26
+ const [status, setStatus] = solid.createSignal({
27
+ isOnline: true,
28
+ isPushing: false,
29
+ isPulling: false,
30
+ pendingCount: 0,
31
+ });
32
+ const dispose = (0, live_query_js_1.subscribeSyncStatus)(client, setStatus);
33
+ solid.onCleanup?.(dispose);
34
+ return { status, dispose };
35
+ }
@@ -38,7 +38,7 @@ export interface FirebaseStorageUploaderInstance extends RemoteStorageUploader {
38
38
  delete(keyOrPath: string): Promise<void>;
39
39
  }
40
40
  /**
41
- * Creates a RemoteStorageUploader that syncs binary files to Firebase Cloud Storage.
42
- * Supports both Firebase v9+ modular SDK and v8/compat SDKs.
41
+ * Creates a RemoteStorageUploader that syncs binary files to Firebase Cloud Storage
42
+ * using the Firebase v11+ modular SDK (`firebase/storage`).
43
43
  */
44
- export declare function createFirebaseStorageUploader(storageOrApp: any, options?: FirebaseStorageUploaderOptions): FirebaseStorageUploaderInstance;
44
+ export declare function createFirebaseStorageUploader(storage: any, options?: FirebaseStorageUploaderOptions): FirebaseStorageUploaderInstance;
@@ -2,20 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFirebaseStorageUploader = createFirebaseStorageUploader;
4
4
  /**
5
- * Creates a RemoteStorageUploader that syncs binary files to Firebase Cloud Storage.
6
- * Supports both Firebase v9+ modular SDK and v8/compat SDKs.
5
+ * Creates a RemoteStorageUploader that syncs binary files to Firebase Cloud Storage
6
+ * using the Firebase v11+ modular SDK (`firebase/storage`).
7
7
  */
8
- function createFirebaseStorageUploader(storageOrApp, options = {}) {
9
- if (!storageOrApp) {
10
- throw new Error('Firebase Storage instance, app, or modular client must be provided.');
8
+ function createFirebaseStorageUploader(storage, options = {}) {
9
+ if (!storage) {
10
+ throw new Error('FirebaseStorage instance must be provided.');
11
11
  }
12
- // Determine storage instance
13
- let storageInstance = storageOrApp;
14
- if (typeof storageOrApp.storage === 'function') {
15
- // FirebaseApp compat
16
- storageInstance = storageOrApp.storage(options.bucket);
17
- }
18
- const mod = options.storageModule || {};
12
+ let cachedMod = options.storageModule ?? null;
13
+ const getMod = async () => {
14
+ if (cachedMod)
15
+ return cachedMod;
16
+ try {
17
+ const modName = 'firebase/storage';
18
+ cachedMod = (await import(/* @vite-ignore */ modName));
19
+ return cachedMod;
20
+ }
21
+ catch {
22
+ throw new Error('Modular firebase/storage SDK is required. Install firebase >=11 or pass options.storageModule.');
23
+ }
24
+ };
19
25
  const resolveRemotePath = (key, blob) => {
20
26
  if (options.pathTransform) {
21
27
  return options.pathTransform(key, blob);
@@ -27,26 +33,14 @@ function createFirebaseStorageUploader(storageOrApp, options = {}) {
27
33
  }
28
34
  return cleanKey;
29
35
  };
30
- const getRef = (path) => {
31
- // 1. Modular SDK ref(storage, path)
32
- if (typeof mod.ref === 'function') {
33
- return mod.ref(storageInstance, path);
34
- }
35
- // 2. Storage instance ref(path) method
36
- if (typeof storageInstance.ref === 'function') {
37
- return storageInstance.ref(path);
38
- }
39
- // 3. Storage instance from bucket
40
- if (typeof storageInstance.bucket === 'function') {
41
- const b = storageInstance.bucket(options.bucket);
42
- return typeof b.file === 'function' ? b.file(path) : b;
43
- }
44
- throw new Error('Cannot resolve Firebase Storage reference. Pass storageModule ({ ref, uploadBytes, getDownloadURL }) or a FirebaseStorage instance.');
45
- };
46
36
  return {
47
37
  async upload(blob, data) {
38
+ const mod = await getMod();
39
+ if (typeof mod.ref !== 'function' || typeof mod.uploadBytes !== 'function') {
40
+ throw new Error('Modular firebase/storage functions (ref, uploadBytes) are required.');
41
+ }
48
42
  const remotePath = resolveRemotePath(blob.key, blob);
49
- const fileRef = getRef(remotePath);
43
+ const fileRef = mod.ref(storage, remotePath);
50
44
  const metadata = {
51
45
  contentType: blob.mimeType || 'application/octet-stream',
52
46
  };
@@ -59,77 +53,29 @@ function createFirebaseStorageUploader(storageOrApp, options = {}) {
59
53
  : options.customMetadata;
60
54
  metadata.customMetadata = extra;
61
55
  }
62
- // Method A: Modular SDK uploadBytes
63
- if (typeof mod.uploadBytes === 'function') {
64
- await mod.uploadBytes(fileRef, data, metadata);
65
- let remoteUrl = remotePath;
66
- if (typeof mod.getDownloadURL === 'function') {
67
- remoteUrl = await mod.getDownloadURL(fileRef);
68
- }
69
- return { remoteUrl, metadata };
70
- }
71
- // Method B: Compat put() or upload()
72
- if (typeof fileRef.put === 'function') {
73
- const snapshot = await fileRef.put(data, metadata);
74
- let remoteUrl;
75
- if (typeof snapshot?.ref?.getDownloadURL === 'function') {
76
- remoteUrl = await snapshot.ref.getDownloadURL();
77
- }
78
- else if (typeof fileRef.getDownloadURL === 'function') {
79
- remoteUrl = await fileRef.getDownloadURL();
80
- }
81
- else {
82
- remoteUrl = remotePath;
83
- }
84
- return { remoteUrl, metadata };
85
- }
86
- // Method C: GCS admin save()
87
- if (typeof fileRef.save === 'function') {
88
- await fileRef.save(Buffer.isBuffer(data) ? data : Buffer.from(data), {
89
- contentType: metadata.contentType,
90
- metadata: metadata.customMetadata,
91
- });
92
- let remoteUrl = remotePath;
93
- if (typeof fileRef.getSignedUrl === 'function') {
94
- const [url] = await fileRef.getSignedUrl({
95
- action: 'read',
96
- expires: Date.now() + 86400 * 1000,
97
- });
98
- remoteUrl = url;
99
- }
100
- return { remoteUrl, metadata };
101
- }
102
- throw new Error('Unsupported Firebase Storage client: missing uploadBytes, put, or save method.');
56
+ await mod.uploadBytes(fileRef, data, metadata);
57
+ const remoteUrl = typeof mod.getDownloadURL === 'function'
58
+ ? await mod.getDownloadURL(fileRef)
59
+ : remotePath;
60
+ return { remoteUrl, metadata };
103
61
  },
104
62
  async getDownloadUrl(keyOrPath) {
105
- const remotePath = resolveRemotePath(keyOrPath);
106
- const fileRef = getRef(remotePath);
107
- if (typeof mod.getDownloadURL === 'function') {
108
- return await mod.getDownloadURL(fileRef);
109
- }
110
- if (typeof fileRef.getDownloadURL === 'function') {
111
- return await fileRef.getDownloadURL();
112
- }
113
- if (typeof fileRef.getSignedUrl === 'function') {
114
- const [url] = await fileRef.getSignedUrl({
115
- action: 'read',
116
- expires: Date.now() + 86400 * 1000,
117
- });
118
- return url;
63
+ const mod = await getMod();
64
+ if (typeof mod.ref !== 'function' || typeof mod.getDownloadURL !== 'function') {
65
+ throw new Error('Modular firebase/storage functions (ref, getDownloadURL) are required.');
119
66
  }
120
- return remotePath;
67
+ const remotePath = resolveRemotePath(keyOrPath);
68
+ const fileRef = mod.ref(storage, remotePath);
69
+ return await mod.getDownloadURL(fileRef);
121
70
  },
122
71
  async delete(keyOrPath) {
123
- const remotePath = resolveRemotePath(keyOrPath);
124
- const fileRef = getRef(remotePath);
125
- if (typeof mod.deleteObject === 'function') {
126
- await mod.deleteObject(fileRef);
127
- return;
128
- }
129
- if (typeof fileRef.delete === 'function') {
130
- await fileRef.delete();
131
- return;
72
+ const mod = await getMod();
73
+ if (typeof mod.ref !== 'function' || typeof mod.deleteObject !== 'function') {
74
+ throw new Error('Modular firebase/storage functions (ref, deleteObject) are required.');
132
75
  }
76
+ const remotePath = resolveRemotePath(keyOrPath);
77
+ const fileRef = mod.ref(storage, remotePath);
78
+ await mod.deleteObject(fileRef);
133
79
  },
134
80
  };
135
81
  }
@@ -0,0 +1,15 @@
1
+ import { LocalFirstClient } from '../core/client.js';
2
+ import { QueryOptions, SyncStatusEvent } from '../core/types.js';
3
+ import { type LiveQueryState } from '../reactive/live-query.js';
4
+ export type { LiveQueryState };
5
+ export interface SvelteReadable<T> {
6
+ subscribe(run: (value: T) => void): () => void;
7
+ }
8
+ /**
9
+ * Creates a Svelte-compatible Readable store (`$store` reactive) backed by a live local-lite query.
10
+ */
11
+ export declare function liveQuery<T = any>(client: LocalFirstClient, tableName: string, options?: QueryOptions): SvelteReadable<LiveQueryState<T>>;
12
+ /**
13
+ * Creates a Svelte-compatible Readable store tracking `client.syncWorker` status.
14
+ */
15
+ export declare function syncStatusStore(client: LocalFirstClient): SvelteReadable<SyncStatusEvent>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.liveQuery = liveQuery;
4
+ exports.syncStatusStore = syncStatusStore;
5
+ const live_query_js_1 = require("../reactive/live-query.js");
6
+ /**
7
+ * Creates a Svelte-compatible Readable store (`$store` reactive) backed by a live local-lite query.
8
+ */
9
+ function liveQuery(client, tableName, options) {
10
+ return {
11
+ subscribe(run) {
12
+ run({ data: [], loading: true, error: null });
13
+ const { dispose } = (0, live_query_js_1.subscribeLiveQuery)(client, tableName, options, run);
14
+ return dispose;
15
+ },
16
+ };
17
+ }
18
+ /**
19
+ * Creates a Svelte-compatible Readable store tracking `client.syncWorker` status.
20
+ */
21
+ function syncStatusStore(client) {
22
+ return {
23
+ subscribe(run) {
24
+ return (0, live_query_js_1.subscribeSyncStatus)(client, run);
25
+ },
26
+ };
27
+ }
@@ -0,0 +1,22 @@
1
+ import { LocalFirstClient, LocalFirstClientConfig } from '../core/client.js';
2
+ import { MemoryDemoRemoteAdapter } from '../adapters/remote/demo.js';
3
+ import { DefaultNetworkStatusProvider } from '../adapters/network/index.js';
4
+ export interface CreateTestClientOptions extends Partial<Omit<LocalFirstClientConfig, 'local'>> {
5
+ tables?: string[];
6
+ online?: boolean;
7
+ remoteLatencyMs?: number;
8
+ }
9
+ export interface TestClientHandle {
10
+ client: LocalFirstClient;
11
+ remote: MemoryDemoRemoteAdapter;
12
+ network: DefaultNetworkStatusProvider;
13
+ simulateOffline: () => void;
14
+ simulateOnline: () => void;
15
+ flushOutbox: () => Promise<void>;
16
+ injectRemoteChange: (tableName: string, rowId: string, payload: Record<string, any>, operation?: 'INSERT' | 'UPDATE' | 'DELETE') => Promise<void>;
17
+ dispose: () => Promise<void>;
18
+ }
19
+ /**
20
+ * Creates an isolated in-memory `LocalFirstClient` with controllable network and remote state for deterministic tests.
21
+ */
22
+ export declare function createTestClient(options?: CreateTestClientOptions): Promise<TestClientHandle>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTestClient = createTestClient;
4
+ const node_sqlite_1 = require("node:sqlite");
5
+ const client_js_1 = require("../core/client.js");
6
+ const node_sqlite_js_1 = require("../adapters/local/node-sqlite.js");
7
+ const demo_js_1 = require("../adapters/remote/demo.js");
8
+ const index_js_1 = require("../adapters/network/index.js");
9
+ /**
10
+ * Creates an isolated in-memory `LocalFirstClient` with controllable network and remote state for deterministic tests.
11
+ */
12
+ async function createTestClient(options = {}) {
13
+ const raw = new node_sqlite_1.DatabaseSync(':memory:');
14
+ const local = new node_sqlite_js_1.NodeSQLiteAdapter(raw);
15
+ const remote = options.remote ??
16
+ new demo_js_1.MemoryDemoRemoteAdapter(options.remoteLatencyMs ?? 0);
17
+ const injectedChanges = [];
18
+ if (!options.remote) {
19
+ const origFetch = remote.fetchChanges.bind(remote);
20
+ remote.fetchChanges = async (sinceTimestamp) => {
21
+ const base = await origFetch(sinceTimestamp);
22
+ const pending = injectedChanges.filter((c) => c.timestamp > sinceTimestamp);
23
+ return {
24
+ ...base,
25
+ timestamp: Date.now(),
26
+ changes: [...(base.changes ?? []), ...pending],
27
+ };
28
+ };
29
+ }
30
+ const network = options.network ??
31
+ new index_js_1.DefaultNetworkStatusProvider(options.online ?? true);
32
+ const client = new client_js_1.LocalFirstClient({
33
+ ...options,
34
+ local,
35
+ remote,
36
+ network,
37
+ tables: options.tables ?? ['todos'],
38
+ autoSchema: options.autoSchema ?? true,
39
+ autoStart: options.autoStart ?? false,
40
+ logger: options.logger ?? false,
41
+ });
42
+ await client.initialize();
43
+ return {
44
+ client,
45
+ remote,
46
+ network,
47
+ simulateOffline() {
48
+ network.setOnline(false);
49
+ },
50
+ simulateOnline() {
51
+ network.setOnline(true);
52
+ },
53
+ async flushOutbox() {
54
+ await client.syncWorker.pushLocalChanges();
55
+ await client.syncWorker.pullRemoteChanges();
56
+ },
57
+ async injectRemoteChange(tableName, rowId, payload, operation = 'UPDATE') {
58
+ const ts = Date.now() + 1000;
59
+ const change = {
60
+ tableName,
61
+ rowId,
62
+ operation,
63
+ timestamp: ts,
64
+ payload: operation === 'DELETE' ? null : payload,
65
+ };
66
+ injectedChanges.push(change);
67
+ remote.emitLiveChanges({ timestamp: ts, changes: [change] });
68
+ },
69
+ async dispose() {
70
+ client.stop();
71
+ raw.close();
72
+ },
73
+ };
74
+ }
@@ -0,0 +1,27 @@
1
+ import { LocalFirstClient } from '../core/client.js';
2
+ import { QueryOptions, SyncStatusEvent } from '../core/types.js';
3
+ export interface VueRef<T> {
4
+ value: T;
5
+ }
6
+ export interface VueCompositionApi {
7
+ ref<T>(initial: T): VueRef<T>;
8
+ onUnmounted?: (fn: () => void) => void;
9
+ }
10
+ /**
11
+ * Vue 3 composable for live local-lite queries.
12
+ * Pass `{ ref, onUnmounted }` from `'vue'` to avoid bundling Vue inside `local-lite`.
13
+ */
14
+ export declare function useLiveQuery<T = any>(client: LocalFirstClient, tableName: string, options: QueryOptions | undefined, vue: VueCompositionApi): {
15
+ data: VueRef<T[]>;
16
+ loading: VueRef<boolean>;
17
+ error: VueRef<Error | null>;
18
+ refresh: () => Promise<void>;
19
+ dispose: () => void;
20
+ };
21
+ /**
22
+ * Vue 3 composable for tracking `client.syncWorker` status.
23
+ */
24
+ export declare function useSyncStatus(client: LocalFirstClient, vue: VueCompositionApi): {
25
+ status: VueRef<SyncStatusEvent>;
26
+ dispose: () => void;
27
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLiveQuery = useLiveQuery;
4
+ exports.useSyncStatus = useSyncStatus;
5
+ const live_query_js_1 = require("../reactive/live-query.js");
6
+ /**
7
+ * Vue 3 composable for live local-lite queries.
8
+ * Pass `{ ref, onUnmounted }` from `'vue'` to avoid bundling Vue inside `local-lite`.
9
+ */
10
+ function useLiveQuery(client, tableName, options, vue) {
11
+ const data = vue.ref([]);
12
+ const loading = vue.ref(true);
13
+ const error = vue.ref(null);
14
+ const { refresh, dispose } = (0, live_query_js_1.subscribeLiveQuery)(client, tableName, options, (state) => {
15
+ data.value = state.data;
16
+ loading.value = state.loading;
17
+ error.value = state.error;
18
+ });
19
+ vue.onUnmounted?.(dispose);
20
+ return { data, loading, error, refresh, dispose };
21
+ }
22
+ /**
23
+ * Vue 3 composable for tracking `client.syncWorker` status.
24
+ */
25
+ function useSyncStatus(client, vue) {
26
+ const status = vue.ref({
27
+ isOnline: true,
28
+ isPushing: false,
29
+ isPulling: false,
30
+ pendingCount: 0,
31
+ });
32
+ const dispose = (0, live_query_js_1.subscribeSyncStatus)(client, (next) => {
33
+ status.value = next;
34
+ });
35
+ vue.onUnmounted?.(dispose);
36
+ return { status, dispose };
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-lite",
3
- "version": "2.0.6",
3
+ "version": "3.0.0",
4
4
  "description": "Never let a lost connection break a promise. Local-first sync that faithfully keeps data safe until you're back online.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -121,6 +121,16 @@
121
121
  "import": "./dist/adapters/local/node-sqlite.js",
122
122
  "default": "./dist/adapters/local/node-sqlite.js"
123
123
  },
124
+ "./sqlite-wasm": {
125
+ "types": "./dist/adapters/local/sqlite-wasm.d.ts",
126
+ "import": "./dist/adapters/local/sqlite-wasm.js",
127
+ "default": "./dist/adapters/local/sqlite-wasm.js"
128
+ },
129
+ "./postgres": {
130
+ "types": "./dist/adapters/remote/postgres.d.ts",
131
+ "import": "./dist/adapters/remote/postgres.js",
132
+ "default": "./dist/adapters/remote/postgres.js"
133
+ },
124
134
  "./core": {
125
135
  "types": "./dist/core/index.d.ts",
126
136
  "import": "./dist/core/index.js",
@@ -170,27 +180,54 @@
170
180
  "types": "./dist/payments/server.d.ts",
171
181
  "import": "./dist/payments/server.js",
172
182
  "default": "./dist/payments/server.js"
183
+ },
184
+ "./svelte": {
185
+ "types": "./dist/svelte/index.d.ts",
186
+ "import": "./dist/svelte/index.js",
187
+ "default": "./dist/svelte/index.js"
188
+ },
189
+ "./vue": {
190
+ "types": "./dist/vue/index.d.ts",
191
+ "import": "./dist/vue/index.js",
192
+ "default": "./dist/vue/index.js"
193
+ },
194
+ "./solid": {
195
+ "types": "./dist/solid/index.d.ts",
196
+ "import": "./dist/solid/index.js",
197
+ "default": "./dist/solid/index.js"
198
+ },
199
+ "./testing": {
200
+ "types": "./dist/testing/index.d.ts",
201
+ "import": "./dist/testing/index.js",
202
+ "default": "./dist/testing/index.js"
203
+ },
204
+ "./presence": {
205
+ "types": "./dist/presence/index.d.ts",
206
+ "import": "./dist/presence/index.js",
207
+ "default": "./dist/presence/index.js"
173
208
  }
174
209
  },
175
210
  "scripts": {
176
211
  "build": "tsc",
212
+ "docs": "node scripts/serve-docs.mjs",
213
+ "example": "npm run --prefix example dev",
177
214
  "test": "vitest run",
178
215
  "test:watch": "vitest",
179
216
  "test:package": "node scripts/package-smoke.mjs",
180
217
  "prepublishOnly": "npm run test && npm run build && npm run test:package"
181
218
  },
182
219
  "peerDependencies": {
183
- "@libsql/client": "^0.6.0",
184
- "@op-engineering/op-sqlite": "^0.1.0",
185
- "@supabase/supabase-js": "^2.0.0",
186
- "better-sqlite3": "^8.0.0",
187
- "convex": ">=1.0.0",
220
+ "@libsql/client": ">=0.14.0",
221
+ "@op-engineering/op-sqlite": ">=10.0.0",
222
+ "@supabase/supabase-js": ">=2.45.0",
223
+ "better-sqlite3": ">=11.0.0",
224
+ "convex": ">=1.15.0",
188
225
  "expo-file-system": ">=58.0.0",
189
226
  "expo-sqlite": ">=58.0.0",
190
- "firebase": ">=9.0.0",
227
+ "firebase": ">=11.0.0",
191
228
  "nodemailer": ">=6.9.0",
192
229
  "react": ">=18.0.0",
193
- "sql.js": "^1.8.0"
230
+ "sql.js": ">=1.10.0"
194
231
  },
195
232
  "peerDependenciesMeta": {
196
233
  "nodemailer": {
@@ -233,7 +270,7 @@
233
270
  "@types/react": "^19.3.0",
234
271
  "@types/uuid": "^11.0.0",
235
272
  "expo-sqlite": "^58.0.17",
236
- "nodemailer": "^10.5.0",
273
+ "nodemailer": "^10.6.0",
237
274
  "react": "^19.3.1",
238
275
  "typescript": "^7.0.2",
239
276
  "vitest": "^5.1.0"
@@ -1,3 +0,0 @@
1
- export * from './types.js';
2
- export * from './store.js';
3
- export * from './manager.js';
package/dist/kv/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types.js"), exports);
18
- __exportStar(require("./store.js"), exports);
19
- __exportStar(require("./manager.js"), exports);
@@ -1,52 +0,0 @@
1
- import { DBExecutable } from '../core/schema-manager.js';
2
- import { EventEmitter } from '../reactive/event-emitter.js';
3
- import { KVRecord, KVSetOptions, KVSetSecretOptions, KVStoreOptions } from './types.js';
4
- export declare class KVManager {
5
- private db;
6
- private tableName;
7
- private events?;
8
- constructor(db: DBExecutable, eventsOrOptions?: EventEmitter | KVStoreOptions, options?: KVStoreOptions);
9
- initialize(): Promise<void>;
10
- /**
11
- * Sets a value in the key-value store with optional TTL.
12
- * Emits an event on the event emitter if configured.
13
- */
14
- set(key: string, value: any, options?: KVSetOptions): Promise<void>;
15
- /**
16
- * Retrieves the value for a key, returning defaultValue if not found or expired.
17
- */
18
- get<T = any>(key: string, defaultValue?: T): Promise<T | undefined>;
19
- /**
20
- * Retrieves the full KVRecord metadata for a key.
21
- */
22
- getRecord(key: string): Promise<KVRecord | null>;
23
- /**
24
- * Checks whether a non-expired key exists in the store.
25
- */
26
- has(key: string): Promise<boolean>;
27
- /**
28
- * Removes a key from the store.
29
- * Emits an event on the event emitter if configured.
30
- */
31
- delete(key: string): Promise<void>;
32
- /**
33
- * Lists all non-expired keys, optionally filtered by a prefix.
34
- */
35
- keys(prefix?: string): Promise<string[]>;
36
- /**
37
- * Clears all stored key-value pairs.
38
- */
39
- clear(): Promise<void>;
40
- /**
41
- * Stores an encrypted secret using AES-256-GCM + PBKDF2 passphrase encryption.
42
- */
43
- setSecret(key: string, secretValue: any, options: KVSetSecretOptions): Promise<void>;
44
- /**
45
- * Decrypts and retrieves a stored secret.
46
- */
47
- getSecret<T = any>(key: string, passphrase: string, defaultValue?: T): Promise<T | undefined>;
48
- /**
49
- * Purges all expired keys immediately.
50
- */
51
- pruneExpired(): Promise<number>;
52
- }