@livestore/livestore 0.0.10 → 0.0.12
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/package.json +7 -7
- package/src/__tests__/reactive.test.ts +39 -0
- package/src/react/useLiveStoreComponent.ts +4 -2
- package/src/reactive.ts +2 -1
- package/dist/.tsbuildinfo +0 -1
- package/dist/QueryCache.d.ts +0 -20
- package/dist/QueryCache.d.ts.map +0 -1
- package/dist/QueryCache.js +0 -71
- package/dist/QueryCache.js.map +0 -1
- package/dist/__tests__/react/fixture.d.ts +0 -141
- package/dist/__tests__/react/fixture.d.ts.map +0 -1
- package/dist/__tests__/react/fixture.js +0 -68
- package/dist/__tests__/react/fixture.js.map +0 -1
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts +0 -2
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts.map +0 -1
- package/dist/__tests__/react/useLiveStoreComponent.test.js +0 -78
- package/dist/__tests__/react/useLiveStoreComponent.test.js.map +0 -1
- package/dist/__tests__/reactive.test.d.ts +0 -2
- package/dist/__tests__/reactive.test.d.ts.map +0 -1
- package/dist/__tests__/reactive.test.js +0 -167
- package/dist/__tests__/reactive.test.js.map +0 -1
- package/dist/backends/base.d.ts +0 -13
- package/dist/backends/base.d.ts.map +0 -1
- package/dist/backends/base.js +0 -53
- package/dist/backends/base.js.map +0 -1
- package/dist/backends/index.d.ts +0 -45
- package/dist/backends/index.d.ts.map +0 -1
- package/dist/backends/index.js +0 -38
- package/dist/backends/index.js.map +0 -1
- package/dist/backends/noop.d.ts +0 -18
- package/dist/backends/noop.d.ts.map +0 -1
- package/dist/backends/noop.js +0 -21
- package/dist/backends/noop.js.map +0 -1
- package/dist/backends/tauri.d.ts +0 -22
- package/dist/backends/tauri.d.ts.map +0 -1
- package/dist/backends/tauri.js +0 -48
- package/dist/backends/tauri.js.map +0 -1
- package/dist/backends/utils/idb.d.ts +0 -10
- package/dist/backends/utils/idb.d.ts.map +0 -1
- package/dist/backends/utils/idb.js +0 -58
- package/dist/backends/utils/idb.js.map +0 -1
- package/dist/backends/web-in-memory.d.ts +0 -22
- package/dist/backends/web-in-memory.d.ts.map +0 -1
- package/dist/backends/web-in-memory.js +0 -45
- package/dist/backends/web-in-memory.js.map +0 -1
- package/dist/backends/web-worker.d.ts +0 -17
- package/dist/backends/web-worker.d.ts.map +0 -1
- package/dist/backends/web-worker.js +0 -139
- package/dist/backends/web-worker.js.map +0 -1
- package/dist/backends/web.d.ts +0 -27
- package/dist/backends/web.d.ts.map +0 -1
- package/dist/backends/web.js +0 -63
- package/dist/backends/web.js.map +0 -1
- package/dist/bounded-collections.d.ts +0 -34
- package/dist/bounded-collections.d.ts.map +0 -1
- package/dist/bounded-collections.js +0 -103
- package/dist/bounded-collections.js.map +0 -1
- package/dist/componentKey.d.ts +0 -20
- package/dist/componentKey.d.ts.map +0 -1
- package/dist/componentKey.js +0 -3
- package/dist/componentKey.js.map +0 -1
- package/dist/effect/LiveStore.d.ts +0 -42
- package/dist/effect/LiveStore.d.ts.map +0 -1
- package/dist/effect/LiveStore.js +0 -40
- package/dist/effect/LiveStore.js.map +0 -1
- package/dist/effect/index.d.ts +0 -2
- package/dist/effect/index.d.ts.map +0 -1
- package/dist/effect/index.js +0 -2
- package/dist/effect/index.js.map +0 -1
- package/dist/events.d.ts +0 -7
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -2
- package/dist/events.js.map +0 -1
- package/dist/inMemoryDatabase.d.ts +0 -65
- package/dist/inMemoryDatabase.d.ts.map +0 -1
- package/dist/inMemoryDatabase.js +0 -241
- package/dist/inMemoryDatabase.js.map +0 -1
- package/dist/index.d.ts +0 -20
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/otel.d.ts +0 -5
- package/dist/otel.d.ts.map +0 -1
- package/dist/otel.js +0 -17
- package/dist/otel.js.map +0 -1
- package/dist/react/LiveStoreContext.d.ts +0 -11
- package/dist/react/LiveStoreContext.d.ts.map +0 -1
- package/dist/react/LiveStoreContext.js +0 -10
- package/dist/react/LiveStoreContext.js.map +0 -1
- package/dist/react/LiveStoreProvider.d.ts +0 -21
- package/dist/react/LiveStoreProvider.d.ts.map +0 -1
- package/dist/react/LiveStoreProvider.js +0 -48
- package/dist/react/LiveStoreProvider.js.map +0 -1
- package/dist/react/index.d.ts +0 -7
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -6
- package/dist/react/index.js.map +0 -1
- package/dist/react/useGlobalQuery.d.ts +0 -3
- package/dist/react/useGlobalQuery.d.ts.map +0 -1
- package/dist/react/useGlobalQuery.js +0 -25
- package/dist/react/useGlobalQuery.js.map +0 -1
- package/dist/react/useGraphQL.d.ts +0 -11
- package/dist/react/useGraphQL.d.ts.map +0 -1
- package/dist/react/useGraphQL.js +0 -67
- package/dist/react/useGraphQL.js.map +0 -1
- package/dist/react/useLiveStoreComponent.d.ts +0 -70
- package/dist/react/useLiveStoreComponent.d.ts.map +0 -1
- package/dist/react/useLiveStoreComponent.js +0 -272
- package/dist/react/useLiveStoreComponent.js.map +0 -1
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts +0 -13
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts.map +0 -1
- package/dist/react/utils/useStateRefWithReactiveInput.js +0 -38
- package/dist/react/utils/useStateRefWithReactiveInput.js.map +0 -1
- package/dist/reactive.d.ts +0 -140
- package/dist/reactive.d.ts.map +0 -1
- package/dist/reactive.js +0 -301
- package/dist/reactive.js.map +0 -1
- package/dist/reactiveQueries/base-class.d.ts +0 -24
- package/dist/reactiveQueries/base-class.d.ts.map +0 -1
- package/dist/reactiveQueries/base-class.js +0 -22
- package/dist/reactiveQueries/base-class.js.map +0 -1
- package/dist/reactiveQueries/graphql.d.ts +0 -25
- package/dist/reactiveQueries/graphql.d.ts.map +0 -1
- package/dist/reactiveQueries/graphql.js +0 -18
- package/dist/reactiveQueries/graphql.js.map +0 -1
- package/dist/reactiveQueries/js.d.ts +0 -19
- package/dist/reactiveQueries/js.d.ts.map +0 -1
- package/dist/reactiveQueries/js.js +0 -13
- package/dist/reactiveQueries/js.js.map +0 -1
- package/dist/reactiveQueries/sql.d.ts +0 -31
- package/dist/reactiveQueries/sql.d.ts.map +0 -1
- package/dist/reactiveQueries/sql.js +0 -32
- package/dist/reactiveQueries/sql.js.map +0 -1
- package/dist/schema.d.ts +0 -163
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -92
- package/dist/schema.js.map +0 -1
- package/dist/store.d.ts +0 -192
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -539
- package/dist/store.js.map +0 -1
- package/dist/util.d.ts +0 -24
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -51
- package/dist/util.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/livestore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
34
|
-
"@livestore/utils": "
|
|
34
|
+
"@livestore/utils": "workspace:*",
|
|
35
35
|
"@opentelemetry/api": "^1.6.0",
|
|
36
36
|
"comlink": "^4.4.1",
|
|
37
|
-
"graphql": "^16.8.
|
|
37
|
+
"graphql": "^16.8.1",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
39
|
"sqlite-esm": "3.42.0-build6",
|
|
40
|
-
"uuid": "^9.0.
|
|
40
|
+
"uuid": "^9.0.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@tauri-apps/api": "^1.4.0",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"@tauri-apps/api": "^1.4.0",
|
|
54
54
|
"@testing-library/react": "^14.0.0",
|
|
55
55
|
"@types/lodash-es": "^4.17.9",
|
|
56
|
-
"@types/uuid": "^9.0.
|
|
56
|
+
"@types/uuid": "^9.0.4",
|
|
57
57
|
"jsdom": "^22.1.0",
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0",
|
|
60
60
|
"typescript": "5.2.2",
|
|
61
61
|
"vite": "4.4.9",
|
|
62
|
-
"vitest": "^0.34.
|
|
62
|
+
"vitest": "^0.34.6"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
|
@@ -225,3 +225,42 @@ describe('a diamond shaped graph', () => {
|
|
|
225
225
|
expect(dRuns.runs).toBe(2)
|
|
226
226
|
})
|
|
227
227
|
})
|
|
228
|
+
|
|
229
|
+
// TODO handle `undefined` in the graph
|
|
230
|
+
describe.todo('a trivial graph with undefined', () => {
|
|
231
|
+
const makeGraph = () => {
|
|
232
|
+
const graph = new ReactiveGraph({ otelTracer: makeNoopTracer() })
|
|
233
|
+
const a = graph.makeRef(undefined)
|
|
234
|
+
const b = graph.makeRef(2)
|
|
235
|
+
const numberOfRunsForC = { runs: 0 }
|
|
236
|
+
const c = graph.makeThunk(
|
|
237
|
+
(get) => {
|
|
238
|
+
numberOfRunsForC.runs++
|
|
239
|
+
return (get(a) ?? 0) + get(b)
|
|
240
|
+
},
|
|
241
|
+
undefined,
|
|
242
|
+
mockOtelCtx,
|
|
243
|
+
)
|
|
244
|
+
const d = graph.makeRef(3)
|
|
245
|
+
const e = graph.makeThunk((get) => get(c) + get(d), undefined, mockOtelCtx)
|
|
246
|
+
|
|
247
|
+
// a(1) b(2)
|
|
248
|
+
// \ /
|
|
249
|
+
// \ /
|
|
250
|
+
// c = a + b
|
|
251
|
+
// \
|
|
252
|
+
// \
|
|
253
|
+
// d(3) \
|
|
254
|
+
// \ \
|
|
255
|
+
// \ \
|
|
256
|
+
// e = c + d
|
|
257
|
+
|
|
258
|
+
return { graph, a, b, c, d, e, numberOfRunsForC }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
it('has the right initial values', () => {
|
|
262
|
+
const { c, e } = makeGraph()
|
|
263
|
+
expect(c.result).toBe(3)
|
|
264
|
+
expect(e.result).toBe(6)
|
|
265
|
+
})
|
|
266
|
+
})
|
|
@@ -14,6 +14,7 @@ import type { LiveStoreJSQuery } from '../reactiveQueries/js.js'
|
|
|
14
14
|
import type { LiveStoreSQLQuery } from '../reactiveQueries/sql.js'
|
|
15
15
|
import type { ComponentStateSchema } from '../schema.js'
|
|
16
16
|
import type { BaseGraphQLContext, LiveStoreQuery, QueryResult, Store } from '../store.js'
|
|
17
|
+
import type { Bindable } from '../util.js'
|
|
17
18
|
import { sql } from '../util.js'
|
|
18
19
|
import { useStore } from './LiveStoreContext.js'
|
|
19
20
|
import { useStateRefWithReactiveInput } from './utils/useStateRefWithReactiveInput.js'
|
|
@@ -26,6 +27,7 @@ export type QueryResults<TQuery> = { [queryName in keyof TQuery]: QueryResult<TQ
|
|
|
26
27
|
export type ReactiveSQL = <TResult>(
|
|
27
28
|
genQuery: (get: GetAtom) => string,
|
|
28
29
|
queriedTables: string[],
|
|
30
|
+
bindValues?: Bindable | undefined,
|
|
29
31
|
) => LiveStoreSQLQuery<TResult>
|
|
30
32
|
export type ReactiveGraphQL = <
|
|
31
33
|
TResult extends Record<string, any>,
|
|
@@ -156,8 +158,8 @@ export const useLiveStoreComponent = <TComponentState extends ComponentState, TQ
|
|
|
156
158
|
isTemporaryQuery: boolean
|
|
157
159
|
}) =>
|
|
158
160
|
queries({
|
|
159
|
-
rxSQL: <T>(genQuery: (get: GetAtom) => string, queriedTables: string[]) =>
|
|
160
|
-
store.querySQL<T>(genQuery, { queriedTables, otelContext }),
|
|
161
|
+
rxSQL: <T>(genQuery: (get: GetAtom) => string, queriedTables: string[], bindValues?: Bindable) =>
|
|
162
|
+
store.querySQL<T>(genQuery, { queriedTables, bindValues, otelContext }),
|
|
161
163
|
rxGraphQL: <Result extends Record<string, any>, Variables extends Record<string, any>>(
|
|
162
164
|
query: DocumentNode<Result, Variables>,
|
|
163
165
|
genVariableValues: (get: GetAtom) => Variables,
|