@livestore/livestore 0.0.12 → 0.0.14
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 +25 -28
- package/dist/.tsbuildinfo +1 -0
- package/dist/QueryCache.d.ts +20 -0
- package/dist/QueryCache.d.ts.map +1 -0
- package/dist/QueryCache.js +71 -0
- package/dist/QueryCache.js.map +1 -0
- package/dist/__tests__/react/fixture.d.ts +26 -0
- package/dist/__tests__/react/fixture.d.ts.map +1 -0
- package/dist/__tests__/react/fixture.js +60 -0
- package/dist/__tests__/react/fixture.js.map +1 -0
- package/dist/__tests__/react/useComponentState.test.d.ts +2 -0
- package/dist/__tests__/react/useComponentState.test.d.ts.map +1 -0
- package/dist/__tests__/react/useComponentState.test.js +68 -0
- package/dist/__tests__/react/useComponentState.test.js.map +1 -0
- package/dist/__tests__/react/useLQuery.test.d.ts +2 -0
- package/dist/__tests__/react/useLQuery.test.d.ts.map +1 -0
- package/dist/__tests__/react/useLQuery.test.js +38 -0
- package/dist/__tests__/react/useLQuery.test.js.map +1 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts +2 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.d.ts.map +1 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.js +73 -0
- package/dist/__tests__/react/useLiveStoreComponent.test.js.map +1 -0
- package/dist/__tests__/react/useQuery.test.d.ts +2 -0
- package/dist/__tests__/react/useQuery.test.d.ts.map +1 -0
- package/dist/__tests__/react/useQuery.test.js +33 -0
- package/dist/__tests__/react/useQuery.test.js.map +1 -0
- package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.d.ts +2 -0
- package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.d.ts.map +1 -0
- package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.js +38 -0
- package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.js.map +1 -0
- package/dist/__tests__/reactive.test.d.ts +2 -0
- package/dist/__tests__/reactive.test.d.ts.map +1 -0
- package/dist/__tests__/reactive.test.js +271 -0
- package/dist/__tests__/reactive.test.js.map +1 -0
- package/dist/__tests__/reactiveQueries/sql.test.d.ts +2 -0
- package/dist/__tests__/reactiveQueries/sql.test.d.ts.map +1 -0
- package/dist/__tests__/reactiveQueries/sql.test.js +337 -0
- package/dist/__tests__/reactiveQueries/sql.test.js.map +1 -0
- package/dist/bounded-collections.d.ts +34 -0
- package/dist/bounded-collections.d.ts.map +1 -0
- package/dist/bounded-collections.js +103 -0
- package/dist/bounded-collections.js.map +1 -0
- package/dist/componentKey.d.ts +20 -0
- package/dist/componentKey.d.ts.map +1 -0
- package/dist/componentKey.js +3 -0
- package/dist/componentKey.js.map +1 -0
- package/dist/effect/LiveStore.d.ts +36 -0
- package/dist/effect/LiveStore.d.ts.map +1 -0
- package/dist/effect/LiveStore.js +41 -0
- package/dist/effect/LiveStore.js.map +1 -0
- package/dist/effect/index.d.ts +2 -0
- package/dist/effect/index.d.ts.map +1 -0
- package/dist/effect/index.js +2 -0
- package/dist/effect/index.js.map +1 -0
- package/dist/events.d.ts +7 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/inMemoryDatabase.d.ts +56 -0
- package/dist/inMemoryDatabase.d.ts.map +1 -0
- package/dist/inMemoryDatabase.js +223 -0
- package/dist/inMemoryDatabase.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations.d.ts +16 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +67 -0
- package/dist/migrations.js.map +1 -0
- package/dist/otel.d.ts +4 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +6 -0
- package/dist/otel.js.map +1 -0
- package/dist/react/LiveStoreContext.d.ts +11 -0
- package/dist/react/LiveStoreContext.d.ts.map +1 -0
- package/dist/react/LiveStoreContext.js +10 -0
- package/dist/react/LiveStoreContext.js.map +1 -0
- package/dist/react/LiveStoreProvider.d.ts +20 -0
- package/dist/react/LiveStoreProvider.d.ts.map +1 -0
- package/dist/react/LiveStoreProvider.js +52 -0
- package/dist/react/LiveStoreProvider.js.map +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +6 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useComponentState.d.ts +50 -0
- package/dist/react/useComponentState.d.ts.map +1 -0
- package/dist/react/useComponentState.js +248 -0
- package/dist/react/useComponentState.js.map +1 -0
- package/dist/react/useGlobalQuery.d.ts +3 -0
- package/dist/react/useGlobalQuery.d.ts.map +1 -0
- package/dist/react/useGlobalQuery.js +26 -0
- package/dist/react/useGlobalQuery.js.map +1 -0
- package/dist/react/useGraphQL.d.ts +13 -0
- package/dist/react/useGraphQL.d.ts.map +1 -0
- package/dist/react/useGraphQL.js +87 -0
- package/dist/react/useGraphQL.js.map +1 -0
- package/dist/react/useLiveStoreComponent.d.ts +75 -0
- package/dist/react/useLiveStoreComponent.d.ts.map +1 -0
- package/dist/react/useLiveStoreComponent.js +361 -0
- package/dist/react/useLiveStoreComponent.js.map +1 -0
- package/dist/react/useQuery.d.ts +3 -0
- package/dist/react/useQuery.d.ts.map +1 -0
- package/dist/react/useQuery.js +42 -0
- package/dist/react/useQuery.js.map +1 -0
- package/dist/react/useTemporaryQuery.d.ts +8 -0
- package/dist/react/useTemporaryQuery.d.ts.map +1 -0
- package/dist/react/useTemporaryQuery.js +17 -0
- package/dist/react/useTemporaryQuery.js.map +1 -0
- package/dist/react/utils/extractNamesFromStackTrace.d.ts +3 -0
- package/dist/react/utils/extractNamesFromStackTrace.d.ts.map +1 -0
- package/dist/react/utils/extractNamesFromStackTrace.js +40 -0
- package/dist/react/utils/extractNamesFromStackTrace.js.map +1 -0
- package/dist/react/utils/extractStackInfoFromStackTrace.d.ts +7 -0
- package/dist/react/utils/extractStackInfoFromStackTrace.d.ts.map +1 -0
- package/dist/react/utils/extractStackInfoFromStackTrace.js +40 -0
- package/dist/react/utils/extractStackInfoFromStackTrace.js.map +1 -0
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts +13 -0
- package/dist/react/utils/useStateRefWithReactiveInput.d.ts.map +1 -0
- package/dist/react/utils/useStateRefWithReactiveInput.js +38 -0
- package/dist/react/utils/useStateRefWithReactiveInput.js.map +1 -0
- package/dist/reactive.d.ts +134 -0
- package/dist/reactive.d.ts.map +1 -0
- package/dist/reactive.js +409 -0
- package/dist/reactive.js.map +1 -0
- package/dist/reactiveQueries/base-class.d.ts +32 -0
- package/dist/reactiveQueries/base-class.d.ts.map +1 -0
- package/dist/reactiveQueries/base-class.js +30 -0
- package/dist/reactiveQueries/base-class.js.map +1 -0
- package/dist/reactiveQueries/graph.d.ts +10 -0
- package/dist/reactiveQueries/graph.d.ts.map +1 -0
- package/dist/reactiveQueries/graph.js +6 -0
- package/dist/reactiveQueries/graph.js.map +1 -0
- package/dist/reactiveQueries/graphql.d.ts +42 -0
- package/dist/reactiveQueries/graphql.d.ts.map +1 -0
- package/dist/reactiveQueries/graphql.js +99 -0
- package/dist/reactiveQueries/graphql.js.map +1 -0
- package/dist/reactiveQueries/js.d.ts +23 -0
- package/dist/reactiveQueries/js.d.ts.map +1 -0
- package/dist/reactiveQueries/js.js +36 -0
- package/dist/reactiveQueries/js.js.map +1 -0
- package/dist/reactiveQueries/sql.d.ts +35 -0
- package/dist/reactiveQueries/sql.d.ts.map +1 -0
- package/dist/reactiveQueries/sql.js +97 -0
- package/dist/reactiveQueries/sql.js.map +1 -0
- package/dist/schema.d.ts +81 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +46 -0
- package/dist/schema.js.map +1 -0
- package/dist/storage/in-memory/index.d.ts +15 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -0
- package/dist/storage/in-memory/index.js +14 -0
- package/dist/storage/in-memory/index.js.map +1 -0
- package/dist/storage/index.d.ts +14 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/tauri/index.d.ts +19 -0
- package/dist/storage/tauri/index.d.ts.map +1 -0
- package/dist/storage/tauri/index.js +38 -0
- package/dist/storage/tauri/index.js.map +1 -0
- package/dist/storage/utils/idb.d.ts +10 -0
- package/dist/storage/utils/idb.d.ts.map +1 -0
- package/dist/storage/utils/idb.js +58 -0
- package/dist/storage/utils/idb.js.map +1 -0
- package/dist/storage/web-worker/index.d.ts +27 -0
- package/dist/storage/web-worker/index.d.ts.map +1 -0
- package/dist/storage/web-worker/index.js +74 -0
- package/dist/storage/web-worker/index.js.map +1 -0
- package/dist/storage/web-worker/worker.d.ts +13 -0
- package/dist/storage/web-worker/worker.d.ts.map +1 -0
- package/dist/storage/web-worker/worker.js +110 -0
- package/dist/storage/web-worker/worker.js.map +1 -0
- package/dist/store.d.ts +159 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +626 -0
- package/dist/store.js.map +1 -0
- package/dist/util.d.ts +28 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +55 -0
- package/dist/util.js.map +1 -0
- package/package.json +47 -19
- package/src/QueryCache.ts +1 -1
- package/src/__tests__/react/fixture.tsx +35 -39
- package/src/__tests__/react/{useLiveStoreComponent.test.tsx → useComponentState.test.tsx} +9 -20
- package/src/__tests__/react/useQuery.test.tsx +48 -0
- package/src/__tests__/react/utils/extractStackInfoFromStackTrace.test.ts +40 -0
- package/src/__tests__/reactive.test.ts +194 -142
- package/src/__tests__/reactiveQueries/sql.test.ts +372 -0
- package/src/effect/LiveStore.ts +22 -31
- package/src/events.ts +1 -1
- package/src/inMemoryDatabase.ts +117 -142
- package/src/index.ts +18 -22
- package/src/migrations.ts +119 -0
- package/src/otel.ts +0 -11
- package/src/react/LiveStoreProvider.tsx +24 -23
- package/src/react/index.ts +12 -7
- package/src/react/useComponentState.ts +409 -0
- package/src/react/useQuery.ts +58 -0
- package/src/react/useTemporaryQuery.ts +21 -0
- package/src/react/utils/extractStackInfoFromStackTrace.ts +47 -0
- package/src/reactive.ts +386 -267
- package/src/reactiveQueries/base-class.ts +61 -39
- package/src/reactiveQueries/graph.ts +15 -0
- package/src/reactiveQueries/graphql.ts +147 -31
- package/src/reactiveQueries/js.ts +54 -21
- package/src/reactiveQueries/sql.ts +128 -37
- package/src/schema.ts +69 -145
- package/src/storage/in-memory/index.ts +21 -0
- package/src/storage/index.ts +27 -0
- package/src/{backends/tauri.ts → storage/tauri/index.ts} +14 -28
- package/src/storage/web-worker/index.ts +116 -0
- package/src/{backends/web-worker.ts → storage/web-worker/worker.ts} +17 -52
- package/src/store.ts +466 -457
- package/src/util.ts +13 -3
- package/tsconfig.json +1 -3
- package/src/backends/base.ts +0 -67
- package/src/backends/index.ts +0 -98
- package/src/backends/noop.ts +0 -32
- package/src/backends/web-in-memory.ts +0 -65
- package/src/backends/web.ts +0 -97
- package/src/react/useGlobalQuery.ts +0 -40
- package/src/react/useGraphQL.ts +0 -112
- package/src/react/useLiveStoreComponent.ts +0 -483
- /package/src/{backends → storage}/utils/idb.ts +0 -0
package/dist/reactive.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// This is a simple implementation of a reactive dependency graph.
|
|
2
|
+
import { pick, shouldNeverHappen } from '@livestore/utils';
|
|
3
|
+
import { isEqual, max, uniqueId } from 'lodash-es';
|
|
4
|
+
import { BoundArray } from './bounded-collections.js';
|
|
5
|
+
// import { getDurationMsFromSpan } from './otel.js'
|
|
6
|
+
export const NOT_REFRESHED_YET = Symbol.for('NOT_REFRESHED_YET');
|
|
7
|
+
export const unknownRefreshReason = () => {
|
|
8
|
+
// debugger
|
|
9
|
+
return { _tag: 'unknown' };
|
|
10
|
+
};
|
|
11
|
+
const uniqueNodeId = () => uniqueId('node-');
|
|
12
|
+
const uniqueRefreshInfoId = () => uniqueId('refresh-info-');
|
|
13
|
+
const serializeAtom = (atom) => ({
|
|
14
|
+
...pick(atom, ['_tag', 'height', 'id', 'label', 'meta']),
|
|
15
|
+
sub: Array.from(atom.sub).map((a) => a.id),
|
|
16
|
+
super: Array.from(atom.super).map((a) => a.id),
|
|
17
|
+
});
|
|
18
|
+
// const serializeEffect = (effect: Effect): SerializedEffect => pick(effect, ['_tag', 'id'])
|
|
19
|
+
export class ReactiveGraph {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.atoms = new Set();
|
|
22
|
+
this.debugRefreshInfos = new BoundArray(5000);
|
|
23
|
+
this.getSnapshot = () => ({
|
|
24
|
+
atoms: Array.from(this.atoms).map(serializeAtom),
|
|
25
|
+
// effects: Array.from(this.effects).map(serializeEffect),
|
|
26
|
+
// dirtyNodes: Array.from(this.dirtyNodes).map((a) => a.id),
|
|
27
|
+
});
|
|
28
|
+
this.effectsWrapper = options?.effectsWrapper ?? ((runEffects) => runEffects());
|
|
29
|
+
}
|
|
30
|
+
makeRef(val, options) {
|
|
31
|
+
const ref = {
|
|
32
|
+
_tag: 'ref',
|
|
33
|
+
id: uniqueNodeId(),
|
|
34
|
+
isDirty: false,
|
|
35
|
+
previousResult: val,
|
|
36
|
+
height: 0,
|
|
37
|
+
computeResult: () => ref.previousResult,
|
|
38
|
+
sub: new Set(),
|
|
39
|
+
super: new Set(),
|
|
40
|
+
label: options?.label,
|
|
41
|
+
meta: options?.meta,
|
|
42
|
+
equal: options?.equal ?? isEqual,
|
|
43
|
+
};
|
|
44
|
+
this.atoms.add(ref);
|
|
45
|
+
return ref;
|
|
46
|
+
}
|
|
47
|
+
makeThunk(getResult_, options) {
|
|
48
|
+
// const computeResult = (): T => {
|
|
49
|
+
// const getAtom = (atom: Atom<T, any>): T => {
|
|
50
|
+
// const __getResult = atom._tag === 'thunk' ? atom.__getResult.toString() : ''
|
|
51
|
+
// if (atom.isDirty) {
|
|
52
|
+
// console.log('atom is dirty', atom.id, atom.label ?? '', atom._tag, __getResult)
|
|
53
|
+
// const result = atom.computeResult()
|
|
54
|
+
// atom.isDirty = false
|
|
55
|
+
// atom.previousResult = result
|
|
56
|
+
// return result
|
|
57
|
+
// } else {
|
|
58
|
+
// console.log('atom is clean', atom.id, atom.label ?? '', atom._tag, __getResult)
|
|
59
|
+
// return atom.previousResult as T
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// let resultChanged = false
|
|
63
|
+
// const debugInfoForAtom = {
|
|
64
|
+
// atom: serializeAtom(null as TODO),
|
|
65
|
+
// resultChanged,
|
|
66
|
+
// // debugInfo: unknownRefreshReason() as TDebugThunkInfo,
|
|
67
|
+
// debugInfo: { _tag: 'unknown' } as TDebugThunkInfo,
|
|
68
|
+
// durationMs: 0,
|
|
69
|
+
// } satisfies AtomDebugInfo<TDebugThunkInfo>
|
|
70
|
+
const addDebugInfo = (_debugInfo) => {
|
|
71
|
+
// debugInfoForAtom.debugInfo = debugInfo
|
|
72
|
+
};
|
|
73
|
+
// debugInfoForRefreshedAtoms.push(debugInfoForAtom)
|
|
74
|
+
// return getResult_(getAtom as GetAtom, addDebugInfo, this.context!)
|
|
75
|
+
// }
|
|
76
|
+
const thunk = {
|
|
77
|
+
_tag: 'thunk',
|
|
78
|
+
id: uniqueNodeId(),
|
|
79
|
+
previousResult: NOT_REFRESHED_YET,
|
|
80
|
+
isDirty: true,
|
|
81
|
+
height: 0,
|
|
82
|
+
computeResult: (otelContext) => {
|
|
83
|
+
if (thunk.isDirty) {
|
|
84
|
+
// Reset previous subcomputations as we're about to re-add them as part of the `doEffect` call below
|
|
85
|
+
thunk.sub = new Set();
|
|
86
|
+
const compute_ = (atom, otelContext) => {
|
|
87
|
+
this.addEdge(thunk, atom);
|
|
88
|
+
return compute(atom, otelContext);
|
|
89
|
+
};
|
|
90
|
+
const result = getResult_(compute_, addDebugInfo, this.context ?? shouldNeverHappen('No store context set yet'), otelContext);
|
|
91
|
+
thunk.isDirty = false;
|
|
92
|
+
thunk.previousResult = result;
|
|
93
|
+
thunk.recomputations++;
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return thunk.previousResult;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
sub: new Set(),
|
|
101
|
+
super: new Set(),
|
|
102
|
+
recomputations: 0,
|
|
103
|
+
label: options?.label,
|
|
104
|
+
meta: options?.meta,
|
|
105
|
+
equal: options?.equal ?? isEqual,
|
|
106
|
+
__getResult: getResult_,
|
|
107
|
+
};
|
|
108
|
+
this.atoms.add(thunk);
|
|
109
|
+
// this.dirtyNodes.add(thunk)
|
|
110
|
+
const debugRefreshReason = options?.debugRefreshReason ?? { _tag: 'makeThunk', label: options?.label };
|
|
111
|
+
const refreshDebugInfo = {
|
|
112
|
+
id: uniqueRefreshInfoId(),
|
|
113
|
+
reason: debugRefreshReason,
|
|
114
|
+
skippedRefresh: true,
|
|
115
|
+
refreshedAtoms: [],
|
|
116
|
+
durationMs: 0,
|
|
117
|
+
completedTimestamp: Date.now(),
|
|
118
|
+
graphSnapshot: this.getSnapshot(),
|
|
119
|
+
};
|
|
120
|
+
this.debugRefreshInfos.push(refreshDebugInfo);
|
|
121
|
+
return thunk;
|
|
122
|
+
}
|
|
123
|
+
destroy(node) {
|
|
124
|
+
// Recursively destroy any supercomputations
|
|
125
|
+
if (node._tag === 'ref' || node._tag === 'thunk') {
|
|
126
|
+
for (const superComp of node.super) {
|
|
127
|
+
this.destroy(superComp);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Destroy this node
|
|
131
|
+
for (const subComp of node.sub) {
|
|
132
|
+
this.removeEdge(node, subComp);
|
|
133
|
+
}
|
|
134
|
+
if (node._tag !== 'effect') {
|
|
135
|
+
this.atoms.delete(node);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
makeEffect(doEffect, options) {
|
|
139
|
+
const effect = {
|
|
140
|
+
_tag: 'effect',
|
|
141
|
+
id: uniqueNodeId(),
|
|
142
|
+
doEffect: (otelContext) => {
|
|
143
|
+
// Reset previous subcomputations as we're about to re-add them as part of the `doEffect` call below
|
|
144
|
+
effect.sub = new Set();
|
|
145
|
+
const getAtom = (atom, otelContext) => {
|
|
146
|
+
this.addEdge(effect, atom);
|
|
147
|
+
return compute(atom, otelContext);
|
|
148
|
+
};
|
|
149
|
+
doEffect(getAtom, otelContext);
|
|
150
|
+
},
|
|
151
|
+
sub: new Set(),
|
|
152
|
+
};
|
|
153
|
+
// this.effects.add(effect)
|
|
154
|
+
// this.dirtyNodes.add(effect)
|
|
155
|
+
const debugRefreshReason = options?.debugRefreshReason ?? { _tag: 'makeEffect', label: options?.label };
|
|
156
|
+
const refreshDebugInfo = {
|
|
157
|
+
id: uniqueRefreshInfoId(),
|
|
158
|
+
reason: debugRefreshReason ?? unknownRefreshReason(),
|
|
159
|
+
skippedRefresh: true,
|
|
160
|
+
refreshedAtoms: [],
|
|
161
|
+
durationMs: 0,
|
|
162
|
+
completedTimestamp: Date.now(),
|
|
163
|
+
graphSnapshot: this.getSnapshot(),
|
|
164
|
+
};
|
|
165
|
+
this.debugRefreshInfos.push(refreshDebugInfo);
|
|
166
|
+
return effect;
|
|
167
|
+
}
|
|
168
|
+
setRef(ref, val, options) {
|
|
169
|
+
const { debugRefreshReason } = options ?? {};
|
|
170
|
+
ref.previousResult = val;
|
|
171
|
+
const effectsToRefresh = new Set();
|
|
172
|
+
markSuperCompDirtyRec(ref, effectsToRefresh);
|
|
173
|
+
this.effectsWrapper(() => {
|
|
174
|
+
for (const effect of effectsToRefresh) {
|
|
175
|
+
effect.doEffect(options?.otelContext);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
const refreshDebugInfo = {
|
|
179
|
+
id: uniqueRefreshInfoId(),
|
|
180
|
+
reason: debugRefreshReason ?? unknownRefreshReason(),
|
|
181
|
+
skippedRefresh: true,
|
|
182
|
+
refreshedAtoms: [],
|
|
183
|
+
durationMs: 0,
|
|
184
|
+
completedTimestamp: Date.now(),
|
|
185
|
+
graphSnapshot: this.getSnapshot(),
|
|
186
|
+
};
|
|
187
|
+
this.debugRefreshInfos.push(refreshDebugInfo);
|
|
188
|
+
}
|
|
189
|
+
setRefs(refs, options) {
|
|
190
|
+
const debugRefreshReason = options?.debugRefreshReason;
|
|
191
|
+
const effectsToRefresh = new Set();
|
|
192
|
+
for (const [ref, val] of refs) {
|
|
193
|
+
ref.previousResult = val;
|
|
194
|
+
markSuperCompDirtyRec(ref, effectsToRefresh);
|
|
195
|
+
}
|
|
196
|
+
this.effectsWrapper(() => {
|
|
197
|
+
for (const effect of effectsToRefresh) {
|
|
198
|
+
effect.doEffect(options?.otelContext);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
const refreshDebugInfo = {
|
|
202
|
+
id: uniqueRefreshInfoId(),
|
|
203
|
+
reason: debugRefreshReason ?? unknownRefreshReason(),
|
|
204
|
+
skippedRefresh: true,
|
|
205
|
+
refreshedAtoms: [],
|
|
206
|
+
durationMs: 0,
|
|
207
|
+
completedTimestamp: Date.now(),
|
|
208
|
+
graphSnapshot: this.getSnapshot(),
|
|
209
|
+
};
|
|
210
|
+
this.debugRefreshInfos.push(refreshDebugInfo);
|
|
211
|
+
}
|
|
212
|
+
// get<T>(atom: Atom<T, TContext>, context: Atom<any, TContext> | Effect): T {
|
|
213
|
+
// // Autotracking: if we're getting the value of an atom,
|
|
214
|
+
// // that means it's a subcomputation for the currently refreshing atom.
|
|
215
|
+
// this.addEdge(context, atom)
|
|
216
|
+
// const dependencyMightBeStale = context._tag !== 'effect' && context.height <= atom.height
|
|
217
|
+
// const dependencyNotRefreshedYet = atom.result === NOT_REFRESHED_YET
|
|
218
|
+
// if (dependencyMightBeStale || dependencyNotRefreshedYet) {
|
|
219
|
+
// throw new DependencyNotReadyError(
|
|
220
|
+
// `${this.label(context)} referenced dependency ${this.label(atom)} which isn't ready`,
|
|
221
|
+
// )
|
|
222
|
+
// }
|
|
223
|
+
// return atom.result
|
|
224
|
+
// }
|
|
225
|
+
/**
|
|
226
|
+
* Update the graph to be consistent with the current values of the root atoms.
|
|
227
|
+
* Generally we run this after a ref is updated.
|
|
228
|
+
* At the end of the refresh, we run any effects that were scheduled.
|
|
229
|
+
*
|
|
230
|
+
* @param roots Root atoms to start the refresh from
|
|
231
|
+
*/
|
|
232
|
+
// refresh(
|
|
233
|
+
// options?:
|
|
234
|
+
// | {
|
|
235
|
+
// otelHint?: string
|
|
236
|
+
// debugRefreshReason?: RefreshReasonWithGenericReasons<TDebugRefreshReason>
|
|
237
|
+
// }
|
|
238
|
+
// | undefined,
|
|
239
|
+
// otelContext: otel.Context = otel.context.active(),
|
|
240
|
+
// ): void {
|
|
241
|
+
// const otelHint = options?.otelHint ?? ''
|
|
242
|
+
// const debugRefreshReason = options?.debugRefreshReason
|
|
243
|
+
// const roots = [...this.dirtyNodes]
|
|
244
|
+
// const debugInfoForRefreshedAtoms: AtomDebugInfo<TDebugThunkInfo>[] = []
|
|
245
|
+
// // if (otelHint.includes('tableName')) {
|
|
246
|
+
// // console.log('refresh', otelHint, { shouldTrace })
|
|
247
|
+
// // }
|
|
248
|
+
// this.otelTracer.startActiveSpan(`LiveStore.refresh:${otelHint}`, {}, otelContext, (span) => {
|
|
249
|
+
// const atomsToRefresh = roots.filter(isAtom)
|
|
250
|
+
// const effectsToRun = new Set(roots.filter(isEffect))
|
|
251
|
+
// span.setAttribute('livestore.hint', otelHint)
|
|
252
|
+
// span.setAttribute('livestore.rootsCount', roots.length)
|
|
253
|
+
// // span.setAttribute('sstack', new Error().stack!)
|
|
254
|
+
// // Sort in topological order, starting with minimum height
|
|
255
|
+
// while (atomsToRefresh.length > 0) {
|
|
256
|
+
// atomsToRefresh.sort((a, b) => a.height - b.height)
|
|
257
|
+
// const atomToRefresh = atomsToRefresh.shift()!
|
|
258
|
+
// // Recompute the value
|
|
259
|
+
// let resultChanged = false
|
|
260
|
+
// const debugInfoForAtom = {
|
|
261
|
+
// atom: serializeAtom(atomToRefresh),
|
|
262
|
+
// resultChanged,
|
|
263
|
+
// // debugInfo: unknownRefreshReason() as TDebugThunkInfo,
|
|
264
|
+
// debugInfo: { _tag: 'unknown' } as TDebugThunkInfo,
|
|
265
|
+
// durationMs: 0,
|
|
266
|
+
// } satisfies AtomDebugInfo<TDebugThunkInfo>
|
|
267
|
+
// try {
|
|
268
|
+
// atomToRefresh.sub = new Set()
|
|
269
|
+
// const beforeTimestamp = performance.now()
|
|
270
|
+
// const newResult = atomToRefresh.getResult(
|
|
271
|
+
// (atom) => this.get(atom, atomToRefresh),
|
|
272
|
+
// (debugInfo) => {
|
|
273
|
+
// debugInfoForAtom.debugInfo = debugInfo
|
|
274
|
+
// },
|
|
275
|
+
// this.context ?? shouldNeverHappen(`No context provided yet for ReactiveGraph`),
|
|
276
|
+
// )
|
|
277
|
+
// const afterTimestamp = performance.now()
|
|
278
|
+
// debugInfoForAtom.durationMs = afterTimestamp - beforeTimestamp
|
|
279
|
+
// // Determine if the result changed to do early cutoff and avoid further unnecessary updates.
|
|
280
|
+
// // Refs never depend on anything, so if a ref is being refreshed it definitely changed.
|
|
281
|
+
// // For thunks, we use a deep equality check.
|
|
282
|
+
// resultChanged =
|
|
283
|
+
// atomToRefresh._tag === 'ref' ||
|
|
284
|
+
// (atomToRefresh._tag === 'thunk' && !atomToRefresh.equal(atomToRefresh.result, newResult))
|
|
285
|
+
// if (resultChanged) {
|
|
286
|
+
// atomToRefresh.result = newResult
|
|
287
|
+
// }
|
|
288
|
+
// this.dirtyNodes.delete(atomToRefresh)
|
|
289
|
+
// } catch (e) {
|
|
290
|
+
// if (e instanceof DependencyNotReadyError) {
|
|
291
|
+
// // If we hit a dependency that wasn't ready yet,
|
|
292
|
+
// // abort this recomputation and try again later.
|
|
293
|
+
// if (!atomsToRefresh.includes(atomToRefresh)) {
|
|
294
|
+
// atomsToRefresh.push(atomToRefresh)
|
|
295
|
+
// }
|
|
296
|
+
// } else {
|
|
297
|
+
// throw e
|
|
298
|
+
// }
|
|
299
|
+
// }
|
|
300
|
+
// debugInfoForRefreshedAtoms.push(debugInfoForAtom)
|
|
301
|
+
// if (!resultChanged) {
|
|
302
|
+
// continue
|
|
303
|
+
// }
|
|
304
|
+
// // Schedule supercomputations
|
|
305
|
+
// for (const superComp of atomToRefresh.super) {
|
|
306
|
+
// switch (superComp._tag) {
|
|
307
|
+
// case 'ref':
|
|
308
|
+
// case 'thunk': {
|
|
309
|
+
// if (!atomsToRefresh.includes(superComp)) {
|
|
310
|
+
// atomsToRefresh.push(superComp)
|
|
311
|
+
// }
|
|
312
|
+
// break
|
|
313
|
+
// }
|
|
314
|
+
// case 'effect': {
|
|
315
|
+
// effectsToRun.add(superComp)
|
|
316
|
+
// break
|
|
317
|
+
// }
|
|
318
|
+
// }
|
|
319
|
+
// }
|
|
320
|
+
// }
|
|
321
|
+
// this.effectsWrapper(() => {
|
|
322
|
+
// for (const effect of effectsToRun) {
|
|
323
|
+
// effect.doEffect((atom: Atom<any, TContext>) => this.get(atom, effect))
|
|
324
|
+
// this.dirtyNodes.delete(effect)
|
|
325
|
+
// }
|
|
326
|
+
// })
|
|
327
|
+
// span.end()
|
|
328
|
+
// const spanDurationMs = getDurationMsFromSpan(span)
|
|
329
|
+
// const refreshDebugInfo: RefreshDebugInfo<
|
|
330
|
+
// RefreshReasonWithGenericReasons<TDebugRefreshReason>,
|
|
331
|
+
// TDebugThunkInfo
|
|
332
|
+
// > = {
|
|
333
|
+
// id: uniqueRefreshInfoId(),
|
|
334
|
+
// reason: debugRefreshReason ?? unknownRefreshReason(),
|
|
335
|
+
// refreshedAtoms: debugInfoForRefreshedAtoms,
|
|
336
|
+
// skippedRefresh: false,
|
|
337
|
+
// durationMs: spanDurationMs,
|
|
338
|
+
// completedTimestamp: Date.now(),
|
|
339
|
+
// graphSnapshot: this.getSnapshot(),
|
|
340
|
+
// }
|
|
341
|
+
// this.debugRefreshInfos.push(refreshDebugInfo)
|
|
342
|
+
// })
|
|
343
|
+
// }
|
|
344
|
+
label(atom) {
|
|
345
|
+
if (atom._tag === 'effect') {
|
|
346
|
+
return `unknown effect`;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
return atom.label ?? `unknown ${atom._tag}`;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
addEdge(superComp, subComp) {
|
|
353
|
+
superComp.sub.add(subComp);
|
|
354
|
+
subComp.super.add(superComp);
|
|
355
|
+
this.updateAtomHeight(superComp);
|
|
356
|
+
}
|
|
357
|
+
removeEdge(superComp, subComp) {
|
|
358
|
+
superComp.sub.delete(subComp);
|
|
359
|
+
subComp.super.delete(superComp);
|
|
360
|
+
this.updateAtomHeight(superComp);
|
|
361
|
+
}
|
|
362
|
+
updateAtomHeight(atom) {
|
|
363
|
+
switch (atom._tag) {
|
|
364
|
+
case 'ref': {
|
|
365
|
+
atom.height = 0;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
case 'thunk': {
|
|
369
|
+
atom.height = (max([...atom.sub].map((atom) => atom.height)) || 0) + 1;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
case 'effect': {
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
get atomsCount() {
|
|
378
|
+
return this.atoms.size;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// const isAtom = <T, TContext>(a: Atom<T, TContext> | Effect): a is Atom<T, TContext> =>
|
|
382
|
+
// a._tag === 'ref' || a._tag === 'thunk'
|
|
383
|
+
// const isEffect = <T, TContext>(a: Atom<T, TContext> | Effect): a is Effect => a._tag === 'effect'
|
|
384
|
+
const compute = (atom, otelContext) => {
|
|
385
|
+
// const __getResult = atom._tag === 'thunk' ? atom.__getResult.toString() : ''
|
|
386
|
+
if (atom.isDirty) {
|
|
387
|
+
// console.log('atom is dirty', atom.id, atom.label ?? '', atom._tag, __getResult)
|
|
388
|
+
const result = atom.computeResult(otelContext);
|
|
389
|
+
atom.isDirty = false;
|
|
390
|
+
atom.previousResult = result;
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
// console.log('atom is clean', atom.id, atom.label ?? '', atom._tag, __getResult)
|
|
395
|
+
return atom.previousResult;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
const markSuperCompDirtyRec = (atom, effectsToRefresh) => {
|
|
399
|
+
for (const superComp of atom.super) {
|
|
400
|
+
if (superComp._tag === 'thunk' || superComp._tag === 'ref') {
|
|
401
|
+
superComp.isDirty = true;
|
|
402
|
+
markSuperCompDirtyRec(superComp, effectsToRefresh);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
effectsToRefresh.add(superComp);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
//# sourceMappingURL=reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../src/reactive.ts"],"names":[],"mappings":"AAAA,kEAAkE;AA0BlE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,oDAAoD;AAEpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAyFhE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,WAAW;IACX,OAAO,EAAE,IAAI,EAAE,SAAkB,EAAE,CAAA;AACrC,CAAC,CAAA;AAoBD,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAC5C,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;AAE3D,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAkB,EAAE,CAAC,CAAC;IAChE,GAAG,IAAI,CAAC,IAA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AAE;IACtE,+EAA+E;IAC/E,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,kFAAkF;QAClF,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAC9C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAA;QAC5B,OAAO,MAAM,CAAA;KACd;SAAM;QACL,kFAAkF;QAClF,OAAO,IAAI,CAAC,cAAmB,CAAA;KAChC;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAI,IAAkB,EAAE,gBAA6B,EAAE,EAAE;IACrF,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE;QAClC,IAAI,SAAS,CAAC,IAAI,KAAK,OAAO,IAAI,SAAS,CAAC,IAAI,KAAK,KAAK,EAAE;YAC1D,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;YACxB,qBAAqB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;SACnD;aAAM;YACL,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;SAChC;KACF;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import type { StackInfo } from '../react/utils/extractStackInfoFromStackTrace.js';
|
|
3
|
+
import type { Atom, GetAtom, Thunk } from '../reactive.js';
|
|
4
|
+
import { type DbContext } from './graph.js';
|
|
5
|
+
import type { LiveStoreJSQuery } from './js.js';
|
|
6
|
+
export type UnsubscribeQuery = () => void;
|
|
7
|
+
export interface ILiveStoreQuery<TResult> {
|
|
8
|
+
id: number;
|
|
9
|
+
/** A reactive thunk representing the query results */
|
|
10
|
+
results$: Thunk<TResult, DbContext>;
|
|
11
|
+
label: string;
|
|
12
|
+
run: (otelContext?: otel.Context) => TResult;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
activeSubscriptions: Set<SubscriberInfo>;
|
|
15
|
+
}
|
|
16
|
+
export type SubscriberInfo = {
|
|
17
|
+
stack: StackInfo[];
|
|
18
|
+
};
|
|
19
|
+
export declare abstract class LiveStoreQueryBase<TResult> implements ILiveStoreQuery<TResult> {
|
|
20
|
+
id: number;
|
|
21
|
+
/** Human-readable label for the query for debugging */
|
|
22
|
+
abstract label: string;
|
|
23
|
+
abstract results$: Thunk<TResult, DbContext>;
|
|
24
|
+
activeSubscriptions: Set<SubscriberInfo>;
|
|
25
|
+
get runs(): number;
|
|
26
|
+
abstract destroy: () => void;
|
|
27
|
+
run: (otelContext?: otel.Context) => TResult;
|
|
28
|
+
runAndDestroy: (otelContext?: otel.Context) => TResult;
|
|
29
|
+
}
|
|
30
|
+
export type GetAtomResult = <T>(atom: Atom<T, any> | LiveStoreJSQuery<T>) => T;
|
|
31
|
+
export declare const makeGetAtomResult: (get: GetAtom, otelContext: otel.Context) => GetAtomResult;
|
|
32
|
+
//# sourceMappingURL=base-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-class.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/base-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAA;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAA;AAIzC,MAAM,WAAW,eAAe,CAAC,OAAO;IACtC,EAAE,EAAE,MAAM,CAAA;IAEV,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAEnC,KAAK,EAAE,MAAM,CAAA;IAEb,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,KAAK,OAAO,CAAA;IAE5C,OAAO,IAAI,IAAI,CAAA;IAEf,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CACzC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,SAAS,EAAE,CAAA;CACnB,CAAA;AAED,8BAAsB,kBAAkB,CAAC,OAAO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IACnF,EAAE,SAAmB;IAErB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAE5C,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAY;IAEpD,IAAI,IAAI,WAEP;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAQ5B,GAAG,iBAAkB,KAAK,OAAO,KAAG,OAAO,CAA4C;IAEvF,aAAa,iBAAkB,KAAK,OAAO,KAAG,OAAO,CAIpD;CACF;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAE9E,eAAO,MAAM,iBAAiB,QAAS,OAAO,eAAe,KAAK,OAAO,kBAOxE,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
let queryIdCounter = 0;
|
|
2
|
+
export class LiveStoreQueryBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.id = queryIdCounter++;
|
|
5
|
+
this.activeSubscriptions = new Set();
|
|
6
|
+
// subscribe = (
|
|
7
|
+
// onNewValue: (value: TResult) => void,
|
|
8
|
+
// onSubsubscribe?: () => void,
|
|
9
|
+
// options?: { label?: string } | undefined,
|
|
10
|
+
// ): (() => void) => this.store.subscribe(this as any, onNewValue as any, onSubsubscribe, options)
|
|
11
|
+
this.run = (otelContext) => this.results$.computeResult(otelContext);
|
|
12
|
+
this.runAndDestroy = (otelContext) => {
|
|
13
|
+
const result = this.run(otelContext);
|
|
14
|
+
this.destroy();
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
get runs() {
|
|
19
|
+
return this.results$.recomputations;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export const makeGetAtomResult = (get, otelContext) => {
|
|
23
|
+
const getAtom = (atom) => {
|
|
24
|
+
if (atom._tag === 'thunk' || atom._tag === 'ref')
|
|
25
|
+
return get(atom, otelContext);
|
|
26
|
+
return get(atom.results$, otelContext);
|
|
27
|
+
};
|
|
28
|
+
return getAtom;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=base-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-class.js","sourceRoot":"","sources":["../../src/reactiveQueries/base-class.ts"],"names":[],"mappings":"AASA,IAAI,cAAc,GAAG,CAAC,CAAA;AAqBtB,MAAM,OAAgB,kBAAkB;IAAxC;QACE,OAAE,GAAG,cAAc,EAAE,CAAA;QAOrB,wBAAmB,GAAwB,IAAI,GAAG,EAAE,CAAA;QAQpD,gBAAgB;QAChB,0CAA0C;QAC1C,iCAAiC;QACjC,8CAA8C;QAC9C,mGAAmG;QAEnG,QAAG,GAAG,CAAC,WAA0B,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAEvF,kBAAa,GAAG,CAAC,WAA0B,EAAW,EAAE;YACtD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YACpC,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;IACH,CAAC;IAnBC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAA;IACrC,CAAC;CAiBF;AAID,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAE,WAAyB,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAkB,CAAC,IAAI,EAAE,EAAE;QACtC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAC/E,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as otel from '@opentelemetry/api';
|
|
2
|
+
import { ReactiveGraph } from '../reactive.js';
|
|
3
|
+
import type { QueryDebugInfo, RefreshReason, Store } from '../store.js';
|
|
4
|
+
export type DbContext = {
|
|
5
|
+
store: Store;
|
|
6
|
+
otelTracer: otel.Tracer;
|
|
7
|
+
rootOtelContext: otel.Context;
|
|
8
|
+
};
|
|
9
|
+
export declare const dbGraph: ReactiveGraph<RefreshReason, QueryDebugInfo, DbContext>;
|
|
10
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,IAAI,CAAC,MAAM,CAAA;IACvB,eAAe,EAAE,IAAI,CAAC,OAAO,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,OAAO,yDAElB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/reactiveQueries/graph.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAS9C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,aAAa,CAA2C;IACjF,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;CACvE,CAAC,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
import * as otel from '@opentelemetry/api';
|
|
3
|
+
import * as graphql from 'graphql';
|
|
4
|
+
import type { Thunk } from '../reactive.js';
|
|
5
|
+
import { type BaseGraphQLContext, type Store } from '../store.js';
|
|
6
|
+
import { type GetAtomResult, LiveStoreQueryBase } from './base-class.js';
|
|
7
|
+
import { type DbContext } from './graph.js';
|
|
8
|
+
import { LiveStoreJSQuery } from './js.js';
|
|
9
|
+
export declare const queryGraphQL: <TResult extends Record<string, any>, TVariableValues extends Record<string, any>>(document: DocumentNode<TResult, TVariableValues>, genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues), { label }?: {
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
}) => LiveStoreGraphQLQuery<TResult, TVariableValues, BaseGraphQLContext>;
|
|
12
|
+
export declare class LiveStoreGraphQLQuery<TResult extends Record<string, any>, TVariableValues extends Record<string, any>, TContext extends BaseGraphQLContext> extends LiveStoreQueryBase<TResult> {
|
|
13
|
+
_tag: 'graphql';
|
|
14
|
+
/** The abstract GraphQL query */
|
|
15
|
+
document: DocumentNode<TResult, TVariableValues>;
|
|
16
|
+
/** A reactive thunk representing the query results */
|
|
17
|
+
results$: Thunk<TResult, DbContext>;
|
|
18
|
+
variableValues$: Thunk<TVariableValues, DbContext>;
|
|
19
|
+
label: string;
|
|
20
|
+
constructor({ document, label, genVariableValues, }: {
|
|
21
|
+
document: DocumentNode<TResult, TVariableValues>;
|
|
22
|
+
genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues);
|
|
23
|
+
label?: string;
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Returns a new reactive query that contains the result of
|
|
27
|
+
* running an arbitrary JS computation on the results of this SQL query.
|
|
28
|
+
*/
|
|
29
|
+
pipe: <U>(fn: (result: TResult, get: GetAtomResult) => U) => LiveStoreJSQuery<U>;
|
|
30
|
+
queryOnce: ({ document, otelContext, otelTracer, variableValues, store, }: {
|
|
31
|
+
document: graphql.DocumentNode;
|
|
32
|
+
otelContext: otel.Context;
|
|
33
|
+
otelTracer: otel.Tracer;
|
|
34
|
+
variableValues: TVariableValues;
|
|
35
|
+
store: Store<TContext>;
|
|
36
|
+
}) => {
|
|
37
|
+
result: TResult;
|
|
38
|
+
queriedTables: string[];
|
|
39
|
+
};
|
|
40
|
+
destroy: () => void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAE1F,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EA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