@livestore/livestore 0.0.54 → 0.0.55-dev.1
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/dist/.tsbuildinfo +1 -1
- package/dist/effect/LiveStore.d.ts +8 -7
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +10 -10
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/react/LiveStoreProvider.d.ts +2 -1
- package/dist/react/LiveStoreProvider.d.ts.map +1 -1
- package/dist/react/LiveStoreProvider.js +4 -4
- package/dist/react/LiveStoreProvider.js.map +1 -1
- package/dist/store.d.ts +11 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +39 -30
- package/dist/store.js.map +1 -1
- package/package.json +5 -5
- package/src/effect/LiveStore.ts +21 -19
- package/src/react/LiveStoreProvider.tsx +19 -16
- package/src/store.ts +53 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BootDb, StoreAdapterFactory, UnexpectedError } from '@livestore/common';
|
|
1
|
+
import type { BootDb, BootStatus, StoreAdapterFactory, UnexpectedError } from '@livestore/common';
|
|
2
2
|
import type { LiveStoreSchema } from '@livestore/common/schema';
|
|
3
|
-
import type { Cause } from '@livestore/utils/effect';
|
|
4
|
-
import { Context, Deferred, Effect, Layer
|
|
3
|
+
import type { Cause, Scope } from '@livestore/utils/effect';
|
|
4
|
+
import { Context, Deferred, Effect, Layer } from '@livestore/utils/effect';
|
|
5
5
|
import * as otel from '@opentelemetry/api';
|
|
6
6
|
import type { GraphQLSchema } from 'graphql';
|
|
7
7
|
import type { MainDatabaseWrapper } from '../MainDatabaseWrapper.js';
|
|
@@ -22,14 +22,14 @@ export type LiveStoreCreateStoreOptions<GraphQLContext extends BaseGraphQLContex
|
|
|
22
22
|
schema: LiveStoreSchema;
|
|
23
23
|
graphQLOptions?: GraphQLOptions<GraphQLContext>;
|
|
24
24
|
otelOptions?: OtelOptions;
|
|
25
|
-
boot?: (db: BootDb, parentSpan: otel.Span) =>
|
|
25
|
+
boot?: (db: BootDb, parentSpan: otel.Span) => void | Promise<void> | Effect.Effect<void, unknown, otel.Tracer>;
|
|
26
26
|
adapter: StoreAdapterFactory;
|
|
27
27
|
batchUpdates?: (run: () => void) => void;
|
|
28
28
|
disableDevtools?: boolean;
|
|
29
29
|
signal?: AbortSignal;
|
|
30
30
|
};
|
|
31
31
|
export declare const LiveStoreContextRunning: Context.Tag<LiveStoreContextRunning, LiveStoreContextRunning>;
|
|
32
|
-
export type DeferredStoreContext = Deferred.Deferred<LiveStoreContextRunning>;
|
|
32
|
+
export type DeferredStoreContext = Deferred.Deferred<LiveStoreContextRunning, UnexpectedError>;
|
|
33
33
|
export declare const DeferredStoreContext: Context.Tag<DeferredStoreContext, DeferredStoreContext>;
|
|
34
34
|
export type LiveStoreContextProps<GraphQLContext extends BaseGraphQLContext> = {
|
|
35
35
|
schema: LiveStoreSchema;
|
|
@@ -37,11 +37,12 @@ export type LiveStoreContextProps<GraphQLContext extends BaseGraphQLContext> = {
|
|
|
37
37
|
schema: Effect.Effect<GraphQLSchema, never, otel.Tracer>;
|
|
38
38
|
makeContext: (db: MainDatabaseWrapper) => GraphQLContext;
|
|
39
39
|
};
|
|
40
|
-
boot?: (db: BootDb) => Effect.Effect<void>;
|
|
40
|
+
boot?: (db: BootDb) => Effect.Effect<void, unknown, otel.Tracer>;
|
|
41
41
|
adapter: StoreAdapterFactory;
|
|
42
42
|
disableDevtools?: boolean;
|
|
43
|
+
onBootStatus?: (status: BootStatus) => void;
|
|
43
44
|
};
|
|
44
45
|
export declare const LiveStoreContextLayer: <GraphQLContext extends BaseGraphQLContext>(props: LiveStoreContextProps<GraphQLContext>) => Layer.Layer<LiveStoreContextRunning, UnexpectedError | Cause.TimeoutException, otel.Tracer>;
|
|
45
46
|
export declare const LiveStoreContextDeferred: Layer.Layer<DeferredStoreContext, never, never>;
|
|
46
|
-
export declare const makeLiveStoreContext: <GraphQLContext extends BaseGraphQLContext>({ schema, graphQLOptions: graphQLOptions_, boot
|
|
47
|
+
export declare const makeLiveStoreContext: <GraphQLContext extends BaseGraphQLContext>({ schema, graphQLOptions: graphQLOptions_, boot, adapter, disableDevtools, onBootStatus, }: LiveStoreContextProps<GraphQLContext>) => Effect.Effect<LiveStoreContextRunning, UnexpectedError | Cause.TimeoutException, DeferredStoreContext | Scope.Scope | otel.Tracer>;
|
|
47
48
|
//# sourceMappingURL=LiveStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStore.d.ts","sourceRoot":"","sources":["../../src/effect/LiveStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"LiveStore.d.ts","sourceRoot":"","sources":["../../src/effect/LiveStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAY,MAAM,EAAY,KAAK,EAAoB,MAAM,yBAAyB,CAAA;AAChH,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIzF,MAAM,MAAM,gBAAgB,GACxB,uBAAu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MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACxD,WAAW,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,cAAc,CAAA;KACzD,CAAA;IACD,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChE,OAAO,EAAE,mBAAmB,CAAA;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,cAAc,SAAS,kBAAkB,SACtE,qBAAqB,CAAC,cAAc,CAAC,KAC3C,KAAK,CAAC,KAAK,CAAC,uBAAuB,EAAE,eAAe,GAAG,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAI1F,CAAA;AAEH,eAAO,MAAM,wBAAwB,iDAGpC,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,cAAc,SAAS,kBAAkB,8FAO3E,qBAAqB,CAAC,cAAc,CAAC,KAAG,MAAM,CAAC,MAAM,CACtD,uBAAuB,EACvB,eAAe,GAAG,KAAK,CAAC,gBAAgB,EACxC,oBAAoB,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAuC/C,CAAA"}
|
package/dist/effect/LiveStore.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { Context, Deferred, Duration, Effect, Layer, OtelTracer, pipe
|
|
1
|
+
import { Context, Deferred, Duration, Effect, FiberSet, Layer, OtelTracer, pipe } from '@livestore/utils/effect';
|
|
2
2
|
import * as otel from '@opentelemetry/api';
|
|
3
3
|
import { createStore } from '../store.js';
|
|
4
4
|
export const LiveStoreContextRunning = Context.GenericTag('@livestore/livestore/effect/LiveStoreContextRunning');
|
|
5
5
|
export const DeferredStoreContext = Context.GenericTag('@livestore/livestore/effect/DeferredStoreContext');
|
|
6
6
|
export const LiveStoreContextLayer = (props) => Layer.scoped(LiveStoreContextRunning, makeLiveStoreContext(props)).pipe(Layer.withSpan('LiveStore'), Layer.provide(LiveStoreContextDeferred));
|
|
7
7
|
export const LiveStoreContextDeferred = Layer.effect(DeferredStoreContext, Deferred.make());
|
|
8
|
-
export const makeLiveStoreContext = ({ schema, graphQLOptions: graphQLOptions_, boot
|
|
9
|
-
const runtime = yield* Effect.runtime();
|
|
8
|
+
export const makeLiveStoreContext = ({ schema, graphQLOptions: graphQLOptions_, boot, adapter, disableDevtools, onBootStatus, }) => pipe(Effect.gen(function* () {
|
|
10
9
|
const otelRootSpanContext = otel.context.active();
|
|
11
|
-
const storeScope = yield* Scope.make();
|
|
12
|
-
yield* Effect.addFinalizer((ex) => Scope.close(storeScope, ex));
|
|
13
10
|
const otelTracer = yield* OtelTracer.Tracer;
|
|
14
11
|
const graphQLOptions = yield* graphQLOptions_
|
|
15
12
|
? Effect.all({ schema: graphQLOptions_.schema, makeContext: Effect.succeed(graphQLOptions_.makeContext) })
|
|
16
13
|
: Effect.succeed(undefined);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: undefined;
|
|
14
|
+
// TODO join fiber set and close tear down parent scope in case of error (Needs refactor with Mike A)
|
|
15
|
+
const fiberSet = yield* FiberSet.make();
|
|
20
16
|
const store = yield* createStore({
|
|
21
17
|
schema,
|
|
22
18
|
graphQLOptions,
|
|
@@ -27,9 +23,13 @@ export const makeLiveStoreContext = ({ schema, graphQLOptions: graphQLOptions_,
|
|
|
27
23
|
boot,
|
|
28
24
|
adapter,
|
|
29
25
|
disableDevtools,
|
|
30
|
-
|
|
26
|
+
fiberSet,
|
|
27
|
+
onBootStatus,
|
|
31
28
|
});
|
|
32
29
|
window.__debugLiveStore = store;
|
|
33
30
|
return { stage: 'running', store };
|
|
34
|
-
}), Effect.
|
|
31
|
+
}), Effect.tapErrorCause((cause) => Effect.flatMap(DeferredStoreContext, (def) => Deferred.failCause(def, cause))), Effect.tap((storeCtx) => Effect.flatMap(DeferredStoreContext, (def) => Deferred.succeed(def, storeCtx))),
|
|
32
|
+
// This can take quite a while.
|
|
33
|
+
// TODO make this configurable
|
|
34
|
+
Effect.timeout(Duration.minutes(5)), Effect.withSpan('@livestore/livestore/effect:makeLiveStoreContext'));
|
|
35
35
|
//# sourceMappingURL=LiveStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStore.js","sourceRoot":"","sources":["../../src/effect/LiveStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"LiveStore.js","sourceRoot":"","sources":["../../src/effect/LiveStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAChH,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA+BzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC,UAAU,CACvD,qDAAqD,CACtD,CAAA;AAGD,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,UAAU,CACpD,kDAAkD,CACnD,CAAA;AAgBD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAA4C,EACiD,EAAE,CAC/F,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CACrE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAC3B,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC,CACxC,CAAA;AAEH,M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AAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAC9G,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxG,+BAA+B;AAC/B,8BAA8B;AAC9B,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EACnC,MAAM,CAAC,QAAQ,CAAC,kDAAkD,CAAC,CACpE,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type BootDb, type BootStatus, type StoreAdapterFactory } from '@livestore/common';
|
|
2
2
|
import type { LiveStoreSchema } from '@livestore/common/schema';
|
|
3
|
+
import { Effect } from '@livestore/utils/effect';
|
|
3
4
|
import type * as otel from '@opentelemetry/api';
|
|
4
5
|
import type { ReactElement, ReactNode } from 'react';
|
|
5
6
|
import type { BaseGraphQLContext, GraphQLOptions, OtelOptions } from '../store.js';
|
|
6
7
|
interface LiveStoreProviderProps<GraphQLContext> {
|
|
7
8
|
schema: LiveStoreSchema;
|
|
8
|
-
boot?: (db: BootDb, parentSpan: otel.Span) =>
|
|
9
|
+
boot?: (db: BootDb, parentSpan: otel.Span) => void | Promise<void> | Effect.Effect<void, unknown, otel.Tracer>;
|
|
9
10
|
graphQLOptions?: GraphQLOptions<GraphQLContext>;
|
|
10
11
|
otelOptions?: OtelOptions;
|
|
11
12
|
renderLoading: (status: BootStatus) => ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../../src/react/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK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ED,eAAO,MAAM,iBAAiB,GAAI,cAAc,SAAS,kBAAkB,2HAWxE,sBAAsB,CAAC,cAAc,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,KAAG,GAAG,CAAC,OA+B1E,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnexpectedError } from '@livestore/common';
|
|
2
2
|
import { errorToString } from '@livestore/utils';
|
|
3
|
-
import { Effect, Exit, Logger, LogLevel, Schema, Scope } from '@livestore/utils/effect';
|
|
3
|
+
import { Effect, Exit, FiberSet, Logger, LogLevel, Schema, Scope } from '@livestore/utils/effect';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { createStore } from '../store.js';
|
|
6
6
|
import { LiveStoreContext } from './LiveStoreContext.js';
|
|
@@ -85,8 +85,8 @@ const useCreateStore = ({ schema, graphQLOptions, otelOptions, boot, adapter, ba
|
|
|
85
85
|
ctxValueRef.current.scope = undefined;
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
createStore({
|
|
89
|
-
|
|
88
|
+
FiberSet.make().pipe(Effect.andThen((fiberSet) => createStore({
|
|
89
|
+
fiberSet,
|
|
90
90
|
schema,
|
|
91
91
|
graphQLOptions,
|
|
92
92
|
otelOptions,
|
|
@@ -99,7 +99,7 @@ const useCreateStore = ({ schema, graphQLOptions, otelOptions, boot, adapter, ba
|
|
|
99
99
|
return;
|
|
100
100
|
setContextValue(status);
|
|
101
101
|
},
|
|
102
|
-
})
|
|
102
|
+
})), Effect.tapSync((store) => setContextValue({ stage: 'running', store })), Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))), Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))), Scope.extend(storeScope), Effect.forkIn(storeScope), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.pretty), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runFork);
|
|
103
103
|
return () => {
|
|
104
104
|
if (ctxValueRef.current.scope !== undefined) {
|
|
105
105
|
Scope.close(ctxValueRef.current.scope, Exit.void).pipe(Effect.tapCauseLogPretty, Effect.runFork);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../../src/react/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0D,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAE3G,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../../src/react/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0D,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAE3G,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGjG,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAcxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAA4C,EAC3E,aAAa,EACb,cAAc,EACd,WAAW,EACX,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,eAAe,EACf,MAAM,GAC4D,EAAe,EAAE;IACnF,MAAM,QAAQ,GAAG,cAAc,CAAC;QAC9B,MAAM;QACN,cAAc;QACd,WAAW;QACX,IAAI;QACJ,OAAO;QACP,YAAY;QACZ,eAAe;QACf,MAAM;KACP,CAAC,CAAA;IAEF,I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AG,SAAS,CAAA;YACvC,CAAC;QACH,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC,CAAA;IAE/F,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;AAClC,CAAC,CAAA"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BootDb, BootStatus, ParamsObject, ResetMode, StoreAdapter, StoreAdapterFactory } from '@livestore/common';
|
|
2
2
|
import { UnexpectedError } from '@livestore/common';
|
|
3
3
|
import type { LiveStoreSchema, MutationEvent } from '@livestore/common/schema';
|
|
4
|
-
import { Effect, Scope } from '@livestore/utils/effect';
|
|
4
|
+
import { Effect, FiberSet, Inspectable, Scope } from '@livestore/utils/effect';
|
|
5
5
|
import * as otel from '@opentelemetry/api';
|
|
6
6
|
import type { GraphQLSchema } from 'graphql';
|
|
7
7
|
import { MainDatabaseWrapper } from './MainDatabaseWrapper.js';
|
|
@@ -28,7 +28,7 @@ export type StoreOptions<TGraphQLContext extends BaseGraphQLContext, TSchema ext
|
|
|
28
28
|
otelOptions: OtelOptions;
|
|
29
29
|
reactivityGraph: ReactivityGraph;
|
|
30
30
|
disableDevtools?: boolean;
|
|
31
|
-
|
|
31
|
+
fiberSet: FiberSet.FiberSet;
|
|
32
32
|
__processedMutationIds: Set<string>;
|
|
33
33
|
};
|
|
34
34
|
export type RefreshReason = DebugRefreshReasonBase | {
|
|
@@ -69,10 +69,10 @@ export type StoreMutateOptions = {
|
|
|
69
69
|
*/
|
|
70
70
|
persisted?: boolean;
|
|
71
71
|
};
|
|
72
|
-
export declare class Store<TGraphQLContext extends BaseGraphQLContext = BaseGraphQLContext, TSchema extends LiveStoreSchema = LiveStoreSchema> {
|
|
72
|
+
export declare class Store<TGraphQLContext extends BaseGraphQLContext = BaseGraphQLContext, TSchema extends LiveStoreSchema = LiveStoreSchema> extends Inspectable.Class {
|
|
73
73
|
id: string;
|
|
74
74
|
readonly devtoolsConnectionId: string;
|
|
75
|
-
private
|
|
75
|
+
private fiberSet;
|
|
76
76
|
reactivityGraph: ReactivityGraph;
|
|
77
77
|
mainDbWrapper: MainDatabaseWrapper;
|
|
78
78
|
adapter: StoreAdapter;
|
|
@@ -147,6 +147,10 @@ export declare class Store<TGraphQLContext extends BaseGraphQLContext = BaseGrap
|
|
|
147
147
|
__devDownloadDb: () => void;
|
|
148
148
|
__devDownloadMutationLogDb: () => Promise<void>;
|
|
149
149
|
dangerouslyResetStorage: (mode: ResetMode) => Promise<void>;
|
|
150
|
+
toJSON: () => {
|
|
151
|
+
_tag: string;
|
|
152
|
+
reactivityGraph: import("./reactive.js").ReactiveGraphSnapshot;
|
|
153
|
+
};
|
|
150
154
|
}
|
|
151
155
|
export type CreateStoreOptions<TGraphQLContext extends BaseGraphQLContext, TSchema extends LiveStoreSchema> = {
|
|
152
156
|
schema: TSchema;
|
|
@@ -154,7 +158,7 @@ export type CreateStoreOptions<TGraphQLContext extends BaseGraphQLContext, TSche
|
|
|
154
158
|
reactivityGraph?: ReactivityGraph;
|
|
155
159
|
graphQLOptions?: GraphQLOptions<TGraphQLContext>;
|
|
156
160
|
otelOptions?: Partial<OtelOptions>;
|
|
157
|
-
boot?: (db: BootDb, parentSpan: otel.Span) =>
|
|
161
|
+
boot?: (db: BootDb, parentSpan: otel.Span) => void | Promise<void> | Effect.Effect<void, unknown, otel.Tracer>;
|
|
158
162
|
batchUpdates?: (run: () => void) => void;
|
|
159
163
|
disableDevtools?: boolean;
|
|
160
164
|
onBootStatus?: (status: BootStatus) => void;
|
|
@@ -163,8 +167,8 @@ export type CreateStoreOptions<TGraphQLContext extends BaseGraphQLContext, TSche
|
|
|
163
167
|
export declare const createStorePromise: <TGraphQLContext extends BaseGraphQLContext, TSchema extends LiveStoreSchema = LiveStoreSchema>({ signal, ...options }: CreateStoreOptions<TGraphQLContext, TSchema> & {
|
|
164
168
|
signal?: AbortSignal;
|
|
165
169
|
}) => Promise<Store<TGraphQLContext, TSchema>>;
|
|
166
|
-
export declare const createStore: <TGraphQLContext extends BaseGraphQLContext, TSchema extends LiveStoreSchema = LiveStoreSchema>({ schema, graphQLOptions, otelOptions, adapter: adapterFactory, boot, reactivityGraph, batchUpdates, disableDevtools, onBootStatus,
|
|
167
|
-
|
|
170
|
+
export declare const createStore: <TGraphQLContext extends BaseGraphQLContext, TSchema extends LiveStoreSchema = LiveStoreSchema>({ schema, graphQLOptions, otelOptions, adapter: adapterFactory, boot, reactivityGraph, batchUpdates, disableDevtools, onBootStatus, fiberSet, }: CreateStoreOptions<TGraphQLContext, TSchema> & {
|
|
171
|
+
fiberSet: FiberSet.FiberSet;
|
|
168
172
|
}) => Effect.Effect<Store<TGraphQLContext, TSchema>, UnexpectedError, Scope.Scope>;
|
|
169
173
|
declare class ReferenceCountedSet<T> {
|
|
170
174
|
private map;
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EAEV,YAAY,EAEZ,SAAS,EACT,YAAY,EACZ,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAKL,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAI9E,OAAO,EACL,MAAM,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EAEV,YAAY,EAEZ,SAAS,EACT,YAAY,EACZ,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAKL,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO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QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAA;CAAE,KAAG,MAAM,CAAC,MAAM,CAC/F,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,EAC/B,eAAe,EACf,KAAK,CAAC,KAAK,CAuIZ,CAAA;AAID,cAAM,mBAAmB,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAgB;;IAM3B,GAAG,QAAS,CAAC,UAGZ;IAED,MAAM,QAAS,CAAC,UAOf;IAED,GAAG,QAAS,CAAC,aAEZ;IAED,IAAI,IAAI,WAEP;IAEA,CAAC,MAAM,CAAC,QAAQ,CAAC;CAKnB"}
|
package/dist/store.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Devtools, getExecArgsFromMutation, liveStoreVersion, prepareBindValues, UnexpectedError, } from '@livestore/common';
|
|
2
2
|
import { makeMutationEventSchemaMemo } from '@livestore/common/schema';
|
|
3
|
-
import { assertNever,
|
|
3
|
+
import { assertNever, makeNoopTracer, shouldNeverHappen, throttle } from '@livestore/utils';
|
|
4
4
|
import { cuid } from '@livestore/utils/cuid';
|
|
5
|
-
import { Effect, Exit, Layer, Logger, LogLevel, OtelTracer, Queue, Runtime, Schema, Scope, Stream, } from '@livestore/utils/effect';
|
|
5
|
+
import { Effect, Exit, FiberSet, Inspectable, Layer, Logger, LogLevel, OtelTracer, Queue, Runtime, Schema, Scope, Stream, } from '@livestore/utils/effect';
|
|
6
6
|
import * as otel from '@opentelemetry/api';
|
|
7
7
|
import { globalReactivityGraph } from './global-state.js';
|
|
8
8
|
import { emptyDebugInfo as makeEmptyDebugInfo, MainDatabaseWrapper } from './MainDatabaseWrapper.js';
|
|
@@ -11,10 +11,10 @@ import { downloadBlob } from './utils/dev.js';
|
|
|
11
11
|
import { getDurationMsFromSpan } from './utils/otel.js';
|
|
12
12
|
let storeCount = 0;
|
|
13
13
|
const uniqueStoreId = () => `store-${++storeCount}`;
|
|
14
|
-
export class Store {
|
|
14
|
+
export class Store extends Inspectable.Class {
|
|
15
15
|
id = uniqueStoreId();
|
|
16
16
|
devtoolsConnectionId = cuid();
|
|
17
|
-
|
|
17
|
+
fiberSet;
|
|
18
18
|
reactivityGraph;
|
|
19
19
|
mainDbWrapper;
|
|
20
20
|
adapter;
|
|
@@ -33,11 +33,12 @@ export class Store {
|
|
|
33
33
|
/** RC-based set to see which queries are currently subscribed to */
|
|
34
34
|
activeQueries;
|
|
35
35
|
__mutationEventSchema;
|
|
36
|
-
constructor({ adapter, schema, graphQLOptions, reactivityGraph, otelOptions, disableDevtools, __processedMutationIds,
|
|
36
|
+
constructor({ adapter, schema, graphQLOptions, reactivityGraph, otelOptions, disableDevtools, __processedMutationIds, fiberSet, }) {
|
|
37
|
+
super();
|
|
37
38
|
this.mainDbWrapper = new MainDatabaseWrapper({ otel: otelOptions, db: adapter.mainDb });
|
|
38
39
|
this.adapter = adapter;
|
|
39
40
|
this.schema = schema;
|
|
40
|
-
this.
|
|
41
|
+
this.fiberSet = fiberSet;
|
|
41
42
|
// TODO refactor
|
|
42
43
|
this.__mutationEventSchema = makeMutationEventSchemaMemo(schema);
|
|
43
44
|
// TODO remove this temporary solution and find a better way to avoid re-processing the same mutation
|
|
@@ -88,7 +89,8 @@ export class Store {
|
|
|
88
89
|
otel.trace.getSpan(this.otel.mutationsSpanContext).end();
|
|
89
90
|
otel.trace.getSpan(this.otel.queriesSpanContext).end();
|
|
90
91
|
}));
|
|
91
|
-
|
|
92
|
+
yield* Effect.never;
|
|
93
|
+
}).pipe(Effect.scoped, Effect.withSpan('LiveStore:store-constructor'), FiberSet.run(fiberSet), runEffectFork);
|
|
92
94
|
}
|
|
93
95
|
static createStore = (storeOptions, parentSpan) => {
|
|
94
96
|
const ctx = otel.trace.setSpan(otel.context.active(), parentSpan);
|
|
@@ -134,7 +136,7 @@ export class Store {
|
|
|
134
136
|
* Currently only used when shutting down the app for debugging purposes (e.g. to close Otel spans).
|
|
135
137
|
*/
|
|
136
138
|
destroy = async () => {
|
|
137
|
-
await
|
|
139
|
+
await FiberSet.clear(this.fiberSet).pipe(Effect.withSpan('Store:destroy'), runEffectPromise);
|
|
138
140
|
};
|
|
139
141
|
mutate = (firstMutationOrTxnFnOrOptions, ...restMutations) => {
|
|
140
142
|
let mutationsEvents;
|
|
@@ -320,6 +322,7 @@ export class Store {
|
|
|
320
322
|
label: `tableRef:${tableName}`,
|
|
321
323
|
meta: { liveStoreRefType: 'table' },
|
|
322
324
|
});
|
|
325
|
+
// #region devtools
|
|
323
326
|
// TODO shutdown behaviour
|
|
324
327
|
bootDevtools = () => Effect.gen(this, function* () {
|
|
325
328
|
const sendToDevtoolsContentscript = (message) => {
|
|
@@ -327,6 +330,7 @@ export class Store {
|
|
|
327
330
|
};
|
|
328
331
|
sendToDevtoolsContentscript(Devtools.DevtoolsWindowMessage.LoadIframe.make({}));
|
|
329
332
|
const channelId = this.adapter.coordinator.devtools.channelId;
|
|
333
|
+
const runtime = yield* Effect.runtime();
|
|
330
334
|
window.addEventListener('message', (event) => {
|
|
331
335
|
const decodedMessageRes = Schema.decodeOption(Devtools.DevtoolsWindowMessage.MessageForStore)(event.data);
|
|
332
336
|
if (decodedMessageRes._tag === 'None')
|
|
@@ -365,6 +369,7 @@ export class Store {
|
|
|
365
369
|
requestIdleCallback(() => sendToDevtools(Devtools.ReactivityGraphRes.make({
|
|
366
370
|
reactivityGraph: this.reactivityGraph.getSnapshot({ includeResults }),
|
|
367
371
|
requestId,
|
|
372
|
+
channelId,
|
|
368
373
|
liveStoreVersion,
|
|
369
374
|
})), { timeout: 500 });
|
|
370
375
|
send();
|
|
@@ -379,6 +384,7 @@ export class Store {
|
|
|
379
384
|
sendToDevtools(Devtools.DebugInfoRes.make({
|
|
380
385
|
debugInfo: this.mainDbWrapper.debugInfo,
|
|
381
386
|
requestId,
|
|
387
|
+
channelId,
|
|
382
388
|
liveStoreVersion,
|
|
383
389
|
}));
|
|
384
390
|
break;
|
|
@@ -398,6 +404,7 @@ export class Store {
|
|
|
398
404
|
sendToDevtools(Devtools.DebugInfoHistoryRes.make({
|
|
399
405
|
debugInfoHistory: buffer,
|
|
400
406
|
requestId,
|
|
407
|
+
channelId,
|
|
401
408
|
liveStoreVersion,
|
|
402
409
|
}));
|
|
403
410
|
buffer.length = 0;
|
|
@@ -423,13 +430,13 @@ export class Store {
|
|
|
423
430
|
}
|
|
424
431
|
case 'LSD.DebugInfoResetReq': {
|
|
425
432
|
this.mainDbWrapper.debugInfo.slowQueries.clear();
|
|
426
|
-
sendToDevtools(Devtools.DebugInfoResetRes.make({ requestId, liveStoreVersion }));
|
|
433
|
+
sendToDevtools(Devtools.DebugInfoResetRes.make({ requestId, channelId, liveStoreVersion }));
|
|
427
434
|
break;
|
|
428
435
|
}
|
|
429
436
|
case 'LSD.DebugInfoRerunQueryReq': {
|
|
430
437
|
const { queryStr, bindValues, queriedTables } = decodedMessage;
|
|
431
438
|
this.mainDbWrapper.select(queryStr, { bindValues, queriedTables, skipCache: true });
|
|
432
|
-
sendToDevtools(Devtools.DebugInfoRerunQueryRes.make({ requestId, liveStoreVersion }));
|
|
439
|
+
sendToDevtools(Devtools.DebugInfoRerunQueryRes.make({ requestId, channelId, liveStoreVersion }));
|
|
433
440
|
break;
|
|
434
441
|
}
|
|
435
442
|
case 'LSD.ReactivityGraphUnsubscribe': {
|
|
@@ -451,6 +458,7 @@ export class Store {
|
|
|
451
458
|
})),
|
|
452
459
|
requestId,
|
|
453
460
|
liveStoreVersion,
|
|
461
|
+
channelId,
|
|
454
462
|
})), { timeout: 500 });
|
|
455
463
|
send();
|
|
456
464
|
// Same as in the reactivity graph subscription case above, we need to throttle the updates
|
|
@@ -467,12 +475,13 @@ export class Store {
|
|
|
467
475
|
}
|
|
468
476
|
});
|
|
469
477
|
storeMessagePort.start();
|
|
470
|
-
}),
|
|
478
|
+
}), Runtime.runFork(runtime));
|
|
471
479
|
return;
|
|
472
480
|
}
|
|
473
481
|
});
|
|
474
482
|
sendToDevtoolsContentscript(Devtools.DevtoolsWindowMessage.StoreReady.make({ channelId }));
|
|
475
483
|
});
|
|
484
|
+
// #endregion devtools
|
|
476
485
|
__devDownloadDb = () => {
|
|
477
486
|
const data = this.mainDbWrapper.export();
|
|
478
487
|
downloadBlob(data, `livestore-${Date.now()}.db`);
|
|
@@ -483,6 +492,12 @@ export class Store {
|
|
|
483
492
|
};
|
|
484
493
|
// TODO allow for graceful store reset without requiring a full page reload (which should also call .boot)
|
|
485
494
|
dangerouslyResetStorage = (mode) => this.adapter.coordinator.dangerouslyReset(mode).pipe(runEffectPromise);
|
|
495
|
+
toJSON = () => {
|
|
496
|
+
return {
|
|
497
|
+
_tag: 'Store',
|
|
498
|
+
reactivityGraph: this.reactivityGraph.getSnapshot({ includeResults: true }),
|
|
499
|
+
};
|
|
500
|
+
};
|
|
486
501
|
}
|
|
487
502
|
/** Create a new LiveStore Store */
|
|
488
503
|
export const createStorePromise = async ({ signal, ...options }) => Effect.gen(function* () {
|
|
@@ -493,21 +508,26 @@ export const createStorePromise = async ({ signal, ...options }) => Effect.gen(f
|
|
|
493
508
|
Scope.close(scope, Exit.void).pipe(Effect.tapCauseLogPretty, Runtime.runFork(runtime));
|
|
494
509
|
});
|
|
495
510
|
}
|
|
496
|
-
return yield* createStore({ ...options,
|
|
511
|
+
return yield* FiberSet.make().pipe(Effect.andThen((fiberSet) => createStore({ ...options, fiberSet })), Scope.extend(scope));
|
|
497
512
|
}).pipe(Effect.withSpan('createStore'), runEffectPromise);
|
|
498
|
-
|
|
513
|
+
// #region createStore
|
|
514
|
+
export const createStore = ({ schema, graphQLOptions, otelOptions, adapter: adapterFactory, boot, reactivityGraph = globalReactivityGraph, batchUpdates, disableDevtools, onBootStatus, fiberSet, }) => {
|
|
499
515
|
const otelTracer = otelOptions?.tracer ?? makeNoopTracer();
|
|
500
516
|
const otelRootSpanContext = otelOptions?.rootSpanContext ?? otel.context.active();
|
|
501
517
|
const TracingLive = Layer.unwrapEffect(Effect.map(OtelTracer.make, Layer.setTracer)).pipe(Layer.provide(Layer.sync(OtelTracer.Tracer, () => otelTracer)));
|
|
502
518
|
return Effect.gen(function* () {
|
|
503
519
|
const span = yield* OtelTracer.currentOtelSpan.pipe(Effect.orDie);
|
|
504
|
-
const bootStatusQueue = yield* Queue.unbounded();
|
|
520
|
+
const bootStatusQueue = yield* Queue.unbounded().pipe(Effect.acquireRelease(Queue.shutdown));
|
|
505
521
|
yield* Queue.take(bootStatusQueue).pipe(Effect.tapSync((status) => onBootStatus?.(status)), Effect.forever, Effect.tapCauseLogPretty, Effect.forkScoped);
|
|
506
522
|
const adapter = yield* adapterFactory({
|
|
507
523
|
schema,
|
|
508
524
|
devtoolsEnabled: disableDevtools !== true,
|
|
509
525
|
bootStatusQueue,
|
|
510
|
-
shutdown: (cause) =>
|
|
526
|
+
shutdown: (cause) => Effect.gen(function* () {
|
|
527
|
+
yield* Effect.logWarning(`Shutting down LiveStore`, cause);
|
|
528
|
+
// TODO close parent scope? (Needs refactor with Mike A)
|
|
529
|
+
yield* FiberSet.clear(fiberSet);
|
|
530
|
+
}).pipe(Effect.withSpan('livestore:shutdown')),
|
|
511
531
|
}).pipe(Effect.withPerformanceMeasure('livestore:makeAdapter'), Effect.withSpan('createStore:makeAdapter'));
|
|
512
532
|
if (batchUpdates !== undefined) {
|
|
513
533
|
reactivityGraph.effectsWrapper = batchUpdates;
|
|
@@ -572,18 +592,8 @@ export const createStore = ({ schema, graphQLOptions, otelOptions, adapter: adap
|
|
|
572
592
|
}
|
|
573
593
|
},
|
|
574
594
|
};
|
|
575
|
-
|
|
576
|
-
try: () => boot(bootDbImpl, span),
|
|
577
|
-
catch: (cause) => new UnexpectedError({ cause }),
|
|
578
|
-
});
|
|
579
|
-
// NOTE only awaiting if it's actually a promise to avoid unnecessary async/await
|
|
580
|
-
if (isPromise(booting)) {
|
|
581
|
-
yield* Effect.tryPromise({ try: () => booting, catch: (cause) => new UnexpectedError({ cause }) });
|
|
582
|
-
}
|
|
595
|
+
yield* Effect.tryAll(() => boot(bootDbImpl, span)).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('createStore:boot'));
|
|
583
596
|
}
|
|
584
|
-
// TODO: we can't apply the schema at this point, we've already loaded persisted data!
|
|
585
|
-
// Think about what to do about this case.
|
|
586
|
-
// await applySchema(db, schema)
|
|
587
597
|
return Store.createStore({
|
|
588
598
|
adapter,
|
|
589
599
|
schema,
|
|
@@ -592,16 +602,15 @@ export const createStore = ({ schema, graphQLOptions, otelOptions, adapter: adap
|
|
|
592
602
|
reactivityGraph,
|
|
593
603
|
disableDevtools,
|
|
594
604
|
__processedMutationIds,
|
|
595
|
-
|
|
605
|
+
fiberSet,
|
|
596
606
|
}, span);
|
|
597
|
-
}).pipe(
|
|
598
|
-
// Effect.scoped,
|
|
599
|
-
Effect.withSpan('createStore', {
|
|
607
|
+
}).pipe(Effect.withSpan('createStore', {
|
|
600
608
|
parent: otelOptions?.rootSpanContext
|
|
601
609
|
? OtelTracer.makeExternalSpan(otel.trace.getSpanContext(otelOptions.rootSpanContext))
|
|
602
610
|
: undefined,
|
|
603
611
|
}), Effect.provide(TracingLive));
|
|
604
612
|
};
|
|
613
|
+
// #endregion createStore
|
|
605
614
|
// TODO consider replacing with Effect's RC data structures
|
|
606
615
|
class ReferenceCountedSet {
|
|
607
616
|
map;
|