local-lite 0.0.3 → 0.0.5
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 +421 -362
- package/dist/adapters/local/better-sqlite3.d.ts +2 -0
- package/dist/adapters/local/better-sqlite3.js +46 -25
- package/dist/adapters/local/expo-sqlite.d.ts +5 -1
- package/dist/adapters/local/expo-sqlite.js +40 -7
- package/dist/adapters/local/index.d.ts +1 -0
- package/dist/adapters/local/node-sqlite.d.ts +2 -0
- package/dist/adapters/local/node-sqlite.js +45 -22
- package/dist/adapters/local/op-sqlite.d.ts +1 -0
- package/dist/adapters/local/op-sqlite.js +6 -0
- package/dist/adapters/local/sql-js.d.ts +1 -0
- package/dist/adapters/local/sql-js.js +5 -0
- package/dist/adapters/network/index.js +33 -0
- package/dist/adapters/remote/convex.d.ts +2 -2
- package/dist/adapters/remote/convex.js +8 -12
- package/dist/adapters/remote/demo.d.ts +1 -1
- package/dist/adapters/remote/demo.js +3 -0
- package/dist/adapters/remote/firestore.d.ts +3 -2
- package/dist/adapters/remote/firestore.js +69 -46
- package/dist/adapters/remote/index.d.ts +6 -4
- package/dist/adapters/remote/supabase.d.ts +34 -6
- package/dist/adapters/remote/supabase.js +340 -79
- package/dist/config/index.js +7 -10
- package/dist/config/resolve-local.js +12 -1
- package/dist/config/resolve-remote.js +33 -28
- package/dist/config/types.d.ts +30 -5
- package/dist/core/client.d.ts +133 -5
- package/dist/core/client.js +431 -46
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.js +30 -0
- package/dist/core/outbox-store.d.ts +8 -4
- package/dist/core/outbox-store.js +84 -65
- package/dist/core/query-builder.d.ts +119 -0
- package/dist/core/query-builder.js +372 -0
- package/dist/core/query.d.ts +8 -0
- package/dist/core/query.js +37 -0
- package/dist/core/schema-manager.d.ts +9 -0
- package/dist/core/schema-manager.js +103 -0
- package/dist/core/sync-worker.d.ts +38 -1
- package/dist/core/sync-worker.js +351 -104
- package/dist/core/table-manager.js +26 -29
- package/dist/core/types.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/react/BenchmarkModal.d.ts +32 -0
- package/dist/react/BenchmarkModal.js +777 -0
- package/dist/react/SyncInspector.d.ts +31 -0
- package/dist/react/SyncInspector.js +585 -0
- package/dist/react/index.d.ts +89 -18
- package/dist/react/index.js +450 -105
- package/dist/react/runner.d.ts +7 -0
- package/dist/react/runner.js +42 -0
- package/dist/react/status.d.ts +24 -0
- package/dist/react/status.js +123 -0
- package/dist/react/theme.d.ts +18 -0
- package/dist/react/theme.js +46 -0
- package/dist/schema/generator.d.ts +49 -0
- package/dist/schema/generator.js +209 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +17 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.js +20 -0
- package/package.json +143 -133
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { LocalFirstClient } from '../core/client.js';
|
|
2
|
-
import {
|
|
1
|
+
import { LocalFirstClient, TransactionalClient } from '../core/client.js';
|
|
2
|
+
import { BatchMutation, MutateOptions, QueryOptions } from '../core/types.js';
|
|
3
3
|
export type LiveQueryFn<T> = (client: LocalFirstClient) => Promise<T[]> | T[];
|
|
4
|
+
/**
|
|
5
|
+
* Clears the in-memory live query cache.
|
|
6
|
+
*/
|
|
7
|
+
export declare function clearLiveQueryCache(): void;
|
|
4
8
|
/**
|
|
5
9
|
* Hook to execute a live reactive table query that automatically re-runs
|
|
6
10
|
* whenever the table is mutated locally or via incoming remote delta.
|
|
@@ -24,25 +28,92 @@ export declare function useLiveQuery<T = any>(client: LocalFirstClient | null |
|
|
|
24
28
|
refetch: () => Promise<void>;
|
|
25
29
|
loading: boolean;
|
|
26
30
|
};
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
export type MultiQuerySpec<T = any> = string | (QueryOptions & {
|
|
32
|
+
table?: string;
|
|
33
|
+
}) | LiveQueryFn<T>;
|
|
34
|
+
export type MultiQueryInput = Array<string | (QueryOptions & {
|
|
35
|
+
table: string;
|
|
36
|
+
})> | Record<string, MultiQuerySpec>;
|
|
37
|
+
export interface UseLiveQueriesResult<T extends Record<string, any[]>> {
|
|
38
|
+
data: T;
|
|
39
|
+
loading: boolean;
|
|
40
|
+
refetch: () => Promise<void>;
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* Reactive multi-table live query hook that loads data from multiple tables concurrently.
|
|
44
|
+
*
|
|
45
|
+
* Benefits:
|
|
46
|
+
* - Parallel fetching: queries SQLite tables concurrently via Promise.all.
|
|
47
|
+
* - Single atomic React commit: coalesces multiple table results into a single state update,
|
|
48
|
+
* preventing cascading re-renders and UI freezing.
|
|
49
|
+
* - Multi-table event coordination: listens to mutations across all requested tables,
|
|
50
|
+
* coalescing updates so downstream calculations only run once.
|
|
51
|
+
* - Zero-latency cache read-through: returns instant cached rows on mount.
|
|
52
|
+
*
|
|
53
|
+
* Usage with dictionary:
|
|
54
|
+
* ```ts
|
|
55
|
+
* const { data, loading } = useLiveQueries(client, {
|
|
56
|
+
* projects: 'projects',
|
|
57
|
+
* tasks: { where: { project_id: '123' }, orderBy: 'created_at' },
|
|
58
|
+
* tags: { table: 'labels' }
|
|
59
|
+
* });
|
|
60
|
+
* // data.projects, data.tasks, data.tags
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Usage with array:
|
|
64
|
+
* ```ts
|
|
65
|
+
* const { data, loading } = useLiveQueries(client, ['projects', 'tasks', 'tags']);
|
|
66
|
+
* // data.projects, data.tasks, data.tags
|
|
67
|
+
* ```
|
|
40
68
|
*/
|
|
41
|
-
export declare function
|
|
69
|
+
export declare function useLiveQueries<T extends Record<string, any[]> = Record<string, any[]>>(client: LocalFirstClient | null | undefined, queries: MultiQueryInput): UseLiveQueriesResult<T>;
|
|
42
70
|
/**
|
|
43
|
-
*
|
|
71
|
+
* Reactive hook to query a single record by primary key with 0ms cache read-through.
|
|
72
|
+
* Automatically re-renders only when this specific row or table changes.
|
|
44
73
|
*/
|
|
45
|
-
export declare function
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
export declare function useLiveRow<T = any>(client: LocalFirstClient | null | undefined, tableName: string, rowId: string | null | undefined, options?: {
|
|
75
|
+
includeDeleted?: boolean;
|
|
76
|
+
}): {
|
|
77
|
+
data: T | null;
|
|
78
|
+
refetch: () => Promise<void>;
|
|
79
|
+
loading: boolean;
|
|
48
80
|
};
|
|
81
|
+
export interface InfiniteQueryOptions extends QueryOptions {
|
|
82
|
+
pageSize?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface UseLiveInfiniteQueryResult<T> {
|
|
85
|
+
data: T[];
|
|
86
|
+
loading: boolean;
|
|
87
|
+
isFetchingNextPage: boolean;
|
|
88
|
+
hasNextPage: boolean;
|
|
89
|
+
fetchNextPage: () => Promise<void>;
|
|
90
|
+
refetch: () => Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reactive infinite query hook that progressively loads pages of records
|
|
94
|
+
* with live updates when underlying table rows are inserted, updated, or synced.
|
|
95
|
+
*/
|
|
96
|
+
export declare function useLiveInfiniteQuery<T = any>(client: LocalFirstClient | null | undefined, tableName: string, options?: InfiniteQueryOptions): UseLiveInfiniteQueryResult<T>;
|
|
97
|
+
export interface UseMutationsResult<TTable extends string = string> {
|
|
98
|
+
client: LocalFirstClient | null | undefined;
|
|
99
|
+
insert: <T extends Record<string, any> = Record<string, any>>(tableName: TTable | (string & {}), payload: T, options?: MutateOptions) => Promise<string | undefined>;
|
|
100
|
+
insertMany: <T extends Record<string, any> = Record<string, any>>(tableName: TTable | (string & {}), records: T[], options?: MutateOptions) => Promise<string[] | undefined>;
|
|
101
|
+
update: <T extends Record<string, any> = Record<string, any>>(tableName: TTable | (string & {}), rowId: string, payload: Partial<T>, options?: MutateOptions) => Promise<void>;
|
|
102
|
+
updateMany: <T extends Record<string, any> = Record<string, any>>(tableName: TTable | (string & {}), updates: Array<{
|
|
103
|
+
id: string;
|
|
104
|
+
payload: Partial<T>;
|
|
105
|
+
}>, options?: MutateOptions) => Promise<void>;
|
|
106
|
+
delete: (tableName: TTable | (string & {}), rowId: string, options?: MutateOptions) => Promise<void>;
|
|
107
|
+
batch: (mutations: BatchMutation[]) => Promise<string[] | undefined>;
|
|
108
|
+
transaction: <T>(action: (txClient: TransactionalClient) => Promise<T>) => Promise<T | undefined>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Universal mutations hook providing memoized, null-safe helpers for database operations.
|
|
112
|
+
*/
|
|
113
|
+
export declare function useMutations<TTable extends string = string>(client: LocalFirstClient | null | undefined): UseMutationsResult<TTable>;
|
|
114
|
+
export * from './runner.js';
|
|
115
|
+
export * from './status.js';
|
|
116
|
+
export * from './theme.js';
|
|
117
|
+
export * from './BenchmarkModal.js';
|
|
118
|
+
export { SyncInspector, SyncIndicator } from './SyncInspector.js';
|
|
119
|
+
export type { SyncInspectorProps, SyncIndicatorProps } from './SyncInspector.js';
|