@livestore/solid 0.0.0-snapshot-2411da6706c12365b5aa4533b551b9b6554d4617 → 0.0.0-snapshot-97ca7eac46b6a583b22d40189126d06a377ec1b0
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/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js.map +1 -1
- package/dist/store.d.ts +3 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +8 -9
- package/dist/store.js.map +1 -1
- package/package.json +8 -7
- package/src/query.ts +4 -4
- package/src/store.ts +25 -27
package/dist/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiveQueries } from '@livestore/livestore/internal';
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
|
-
export declare const query: <TQuery extends
|
|
3
|
+
export declare const query: <TQuery extends LiveQueries.LiveQueryDef.Any>(queryDef: TQuery, initialValue: LiveQueries.GetResult<TQuery>) => Solid.Accessor<LiveQueries.GetResult<TQuery>>;
|
|
4
4
|
//# sourceMappingURL=query.d.ts.map
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAIjC,eAAO,MAAM,KAAK,GAAI,MAAM,SAAS,WAAW,CAAC,YAAY,CAAC,GAAG,EAC/D,UAAU,MAAM,EAEhB,cAAc,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,KAC1C,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAa9C,CAAA"}
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,QAAgB;AAChB,qDAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,QAAgB;AAChB,qDAAqD;AACrD,YAA2C,EACI,EAAE;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAE1D,MAAM,KAAK,GAAG,aAAa,EAAE,CAAA;IAE7B,wCAAwC;IACxC,MAAM,WAAW,GAAG,KAAK,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEtE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,EAAE,EAAE,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateStoreOptions, LiveStoreSchema, Store } from '@livestore/livestore';
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
|
-
export declare const storeToExport: Solid.Accessor<Store<
|
|
4
|
-
export declare const getStore: <Schema extends LiveStoreSchema
|
|
3
|
+
export declare const storeToExport: Solid.Accessor<Store<LiveStoreSchema, {}> | undefined>, setStoreToExport: Solid.Setter<Store<LiveStoreSchema, {}> | undefined>;
|
|
4
|
+
export declare const getStore: <Schema extends LiveStoreSchema>({ adapter, schema, storeId, }: Pick<CreateStoreOptions<Schema>, "schema" | "adapter" | "storeId">) => Promise<Solid.Accessor<Store<Schema> | undefined>>;
|
|
5
5
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,eAAe,EAEf,KAAK,EACN,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AA0CjC,eAAO,MAAO,aAAa,0DAAE,gBAAgB,sDAA0D,CAAA;AA4GvG,eAAO,MAAM,QAAQ,GAAU,MAAM,SAAS,eAAe,EAAE,+BAI5D,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,KAAG,OAAO,CAC7E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAc1C,CAAA"}
|
package/dist/store.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { provideOtel } from '@livestore/common';
|
|
2
|
-
import { createStore
|
|
1
|
+
import { provideOtel, StoreInterrupted } from '@livestore/common';
|
|
2
|
+
import { createStore } from '@livestore/livestore';
|
|
3
3
|
import { LS_DEV } from '@livestore/utils';
|
|
4
|
-
import { Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect';
|
|
4
|
+
import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect';
|
|
5
5
|
import * as Solid from 'solid-js';
|
|
6
6
|
const interrupt = (componentScope, shutdownDeferred, error) => Effect.gen(function* () {
|
|
7
|
-
// console.log('[@livestore/livestore/
|
|
7
|
+
// console.log('[@livestore/livestore/solid] interupting', error)
|
|
8
8
|
yield* Scope.close(componentScope, Exit.fail(error));
|
|
9
9
|
yield* Deferred.fail(shutdownDeferred, error);
|
|
10
10
|
}).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] interrupting', cause)), Effect.runFork);
|
|
@@ -25,7 +25,7 @@ const storeValue = {
|
|
|
25
25
|
};
|
|
26
26
|
const [, setInternalStore] = Solid.createSignal(storeValue);
|
|
27
27
|
export const [storeToExport, setStoreToExport] = Solid.createSignal();
|
|
28
|
-
const setupStore = async ({ schema, storeId,
|
|
28
|
+
const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disableDevtools, signal, setupDone, }) => {
|
|
29
29
|
Solid.createEffect(() => {
|
|
30
30
|
const counter = storeValue.counter;
|
|
31
31
|
const setContextValue = (value) => {
|
|
@@ -46,7 +46,7 @@ const setupStore = async ({ schema, storeId, graphQLOptions, boot, adapter, batc
|
|
|
46
46
|
if (storeValue.componentScope !== undefined &&
|
|
47
47
|
storeValue.shutdownDeferred !== undefined &&
|
|
48
48
|
storeValue.counter === counter) {
|
|
49
|
-
interrupt(storeValue.componentScope, storeValue.shutdownDeferred, new
|
|
49
|
+
interrupt(storeValue.componentScope, storeValue.shutdownDeferred, new StoreInterrupted({ reason: 'Aborted via provided AbortController' }));
|
|
50
50
|
storeValue.componentScope = undefined;
|
|
51
51
|
storeValue.shutdownDeferred = undefined;
|
|
52
52
|
}
|
|
@@ -58,7 +58,6 @@ const setupStore = async ({ schema, storeId, graphQLOptions, boot, adapter, batc
|
|
|
58
58
|
const store = yield* createStore({
|
|
59
59
|
schema,
|
|
60
60
|
storeId,
|
|
61
|
-
graphQLOptions,
|
|
62
61
|
boot,
|
|
63
62
|
adapter,
|
|
64
63
|
batchUpdates,
|
|
@@ -73,11 +72,11 @@ const setupStore = async ({ schema, storeId, graphQLOptions, boot, adapter, batc
|
|
|
73
72
|
setupDone();
|
|
74
73
|
}).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope));
|
|
75
74
|
const shutdownContext = (cause) => Effect.sync(() => setContextValue({ stage: 'shutdown', cause }));
|
|
76
|
-
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/
|
|
75
|
+
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] shutdown', Cause.pretty(cause))), Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)), Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))), Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))), Effect.exit);
|
|
77
76
|
}).pipe(Effect.scoped, withSemaphore(storeId), Effect.withSpan('@livestore/solid:setupStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({}), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.prettyWithThread('window')), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runFork);
|
|
78
77
|
Solid.onCleanup(() => {
|
|
79
78
|
if (storeValue.componentScope !== undefined && storeValue.shutdownDeferred !== undefined) {
|
|
80
|
-
interrupt(storeValue.componentScope, storeValue.shutdownDeferred, new StoreInterrupted());
|
|
79
|
+
interrupt(storeValue.componentScope, storeValue.shutdownDeferred, new StoreInterrupted({ reason: 'unmounting component' }));
|
|
81
80
|
storeValue.componentScope = undefined;
|
|
82
81
|
storeValue.shutdownDeferred = undefined;
|
|
83
82
|
}
|
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,WAAW,EAAwB,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,WAAW,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAA;AAUtH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACvH,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAEjC,MAAM,SAAS,GAAG,CAAC,cAAoC,EAAE,gBAAkC,EAAE,KAAuB,EAAE,EAAE,CACtH,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,iEAAiE;IACjE,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AAC/C,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC,EACpG,MAAM,CAAC,OAAO,CACf,CAAA;AAGH,MAAM,YAAY,GAAG,IAAI,GAAG,EAA+B,CAAA;AAC3D,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAE,EAAE;IAC7C,IAAI,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3C,I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CAAA;IAE/C,MAAM,UAAU,CAAC;QACf,OAAO;QACP,MAAM;QACN,OAAO;QACP,SAAS,EAAE,SAAS,CAAC,OAAO;KAC7B,CAAC,CAAA;IAEF,MAAM,SAAS,CAAC,OAAO,CAAA;IAEvB,OAAO,aAAyD,CAAA;AAClE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/solid",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-97ca7eac46b6a583b22d40189126d06a377ec1b0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,16 +11,17 @@
|
|
|
11
11
|
"types": "./dist/mod.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@opentelemetry/api": "1.9.0",
|
|
14
|
-
"@livestore/common": "0.0.0-snapshot-
|
|
15
|
-
"@livestore/livestore": "0.0.0-snapshot-
|
|
16
|
-
"@livestore/utils": "0.0.0-snapshot-
|
|
14
|
+
"@livestore/common": "0.0.0-snapshot-97ca7eac46b6a583b22d40189126d06a377ec1b0",
|
|
15
|
+
"@livestore/livestore": "0.0.0-snapshot-97ca7eac46b6a583b22d40189126d06a377ec1b0",
|
|
16
|
+
"@livestore/utils": "0.0.0-snapshot-97ca7eac46b6a583b22d40189126d06a377ec1b0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
20
20
|
"jsdom": "^26.0.0",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"solid-js": "^1.9.4",
|
|
22
|
+
"typescript": "^5.8.2",
|
|
23
|
+
"vite": "^6.2.1",
|
|
24
|
+
"vitest": "^3.0.8"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"solid-js": "~1.9.4"
|
package/src/query.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiveQueries } from '@livestore/livestore/internal'
|
|
2
2
|
import * as Solid from 'solid-js'
|
|
3
3
|
|
|
4
4
|
import { storeToExport } from './store.js'
|
|
5
5
|
|
|
6
|
-
export const query = <TQuery extends
|
|
6
|
+
export const query = <TQuery extends LiveQueries.LiveQueryDef.Any>(
|
|
7
7
|
queryDef: TQuery,
|
|
8
8
|
// TODO do we actually need an `initialValue` at all?
|
|
9
|
-
initialValue: GetResult<TQuery>,
|
|
10
|
-
): Solid.Accessor<GetResult<TQuery>> => {
|
|
9
|
+
initialValue: LiveQueries.GetResult<TQuery>,
|
|
10
|
+
): Solid.Accessor<LiveQueries.GetResult<TQuery>> => {
|
|
11
11
|
const [value, setValue] = Solid.createSignal(initialValue)
|
|
12
12
|
|
|
13
13
|
const store = storeToExport()
|
package/src/store.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type IntentionalShutdownCause, provideOtel, type UnexpectedError } from '@livestore/common'
|
|
1
|
+
import { type IntentionalShutdownCause, provideOtel, StoreInterrupted, type UnexpectedError } from '@livestore/common'
|
|
2
2
|
import type {
|
|
3
|
-
BaseGraphQLContext,
|
|
4
3
|
BootStatus,
|
|
5
4
|
CreateStoreOptions,
|
|
6
5
|
LiveStoreContext as StoreContext_,
|
|
@@ -9,18 +8,14 @@ import type {
|
|
|
9
8
|
ShutdownDeferred,
|
|
10
9
|
Store,
|
|
11
10
|
} from '@livestore/livestore'
|
|
12
|
-
import { createStore
|
|
11
|
+
import { createStore } from '@livestore/livestore'
|
|
13
12
|
import { LS_DEV } from '@livestore/utils'
|
|
14
|
-
import { Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect'
|
|
13
|
+
import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect'
|
|
15
14
|
import * as Solid from 'solid-js'
|
|
16
15
|
|
|
17
|
-
const interrupt = (
|
|
18
|
-
componentScope: Scope.CloseableScope,
|
|
19
|
-
shutdownDeferred: ShutdownDeferred,
|
|
20
|
-
error: StoreAbort | StoreInterrupted,
|
|
21
|
-
) =>
|
|
16
|
+
const interrupt = (componentScope: Scope.CloseableScope, shutdownDeferred: ShutdownDeferred, error: StoreInterrupted) =>
|
|
22
17
|
Effect.gen(function* () {
|
|
23
|
-
// console.log('[@livestore/livestore/
|
|
18
|
+
// console.log('[@livestore/livestore/solid] interupting', error)
|
|
24
19
|
yield* Scope.close(componentScope, Exit.fail(error))
|
|
25
20
|
yield* Deferred.fail(shutdownDeferred, error)
|
|
26
21
|
}).pipe(
|
|
@@ -60,17 +55,16 @@ const [, setInternalStore] = Solid.createSignal<{
|
|
|
60
55
|
|
|
61
56
|
export const [storeToExport, setStoreToExport] = Solid.createSignal<LiveStoreContextRunning['store']>()
|
|
62
57
|
|
|
63
|
-
const setupStore = async
|
|
58
|
+
const setupStore = async ({
|
|
64
59
|
schema,
|
|
65
60
|
storeId,
|
|
66
|
-
graphQLOptions,
|
|
67
61
|
boot,
|
|
68
62
|
adapter,
|
|
69
63
|
batchUpdates,
|
|
70
64
|
disableDevtools,
|
|
71
65
|
signal,
|
|
72
66
|
setupDone,
|
|
73
|
-
}: CreateStoreOptions<
|
|
67
|
+
}: CreateStoreOptions<LiveStoreSchema> & { signal?: AbortSignal; setupDone: () => void }) => {
|
|
74
68
|
Solid.createEffect(() => {
|
|
75
69
|
const counter = storeValue.counter
|
|
76
70
|
|
|
@@ -94,7 +88,11 @@ const setupStore = async <GraphQLContext extends BaseGraphQLContext>({
|
|
|
94
88
|
storeValue.shutdownDeferred !== undefined &&
|
|
95
89
|
storeValue.counter === counter
|
|
96
90
|
) {
|
|
97
|
-
interrupt(
|
|
91
|
+
interrupt(
|
|
92
|
+
storeValue.componentScope,
|
|
93
|
+
storeValue.shutdownDeferred,
|
|
94
|
+
new StoreInterrupted({ reason: 'Aborted via provided AbortController' }),
|
|
95
|
+
)
|
|
98
96
|
storeValue.componentScope = undefined
|
|
99
97
|
storeValue.shutdownDeferred = undefined
|
|
100
98
|
}
|
|
@@ -104,14 +102,13 @@ const setupStore = async <GraphQLContext extends BaseGraphQLContext>({
|
|
|
104
102
|
const componentScope = yield* Scope.make()
|
|
105
103
|
const shutdownDeferred = yield* Deferred.make<
|
|
106
104
|
void,
|
|
107
|
-
UnexpectedError | IntentionalShutdownCause |
|
|
105
|
+
UnexpectedError | IntentionalShutdownCause | StoreInterrupted
|
|
108
106
|
>()
|
|
109
107
|
|
|
110
108
|
yield* Effect.gen(function* () {
|
|
111
109
|
const store = yield* createStore({
|
|
112
110
|
schema,
|
|
113
111
|
storeId,
|
|
114
|
-
graphQLOptions,
|
|
115
112
|
boot,
|
|
116
113
|
adapter,
|
|
117
114
|
batchUpdates,
|
|
@@ -126,13 +123,13 @@ const setupStore = async <GraphQLContext extends BaseGraphQLContext>({
|
|
|
126
123
|
setupDone()
|
|
127
124
|
}).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope))
|
|
128
125
|
|
|
129
|
-
const shutdownContext = (cause: IntentionalShutdownCause |
|
|
126
|
+
const shutdownContext = (cause: IntentionalShutdownCause | StoreInterrupted) =>
|
|
130
127
|
Effect.sync(() => setContextValue({ stage: 'shutdown', cause }))
|
|
131
128
|
|
|
132
129
|
yield* Deferred.await(shutdownDeferred).pipe(
|
|
133
|
-
Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/
|
|
130
|
+
Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] shutdown', Cause.pretty(cause))),
|
|
134
131
|
Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)),
|
|
135
|
-
Effect.catchTag('LiveStore.
|
|
132
|
+
Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)),
|
|
136
133
|
Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))),
|
|
137
134
|
Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))),
|
|
138
135
|
Effect.exit,
|
|
@@ -152,7 +149,11 @@ const setupStore = async <GraphQLContext extends BaseGraphQLContext>({
|
|
|
152
149
|
|
|
153
150
|
Solid.onCleanup(() => {
|
|
154
151
|
if (storeValue.componentScope !== undefined && storeValue.shutdownDeferred !== undefined) {
|
|
155
|
-
interrupt(
|
|
152
|
+
interrupt(
|
|
153
|
+
storeValue.componentScope,
|
|
154
|
+
storeValue.shutdownDeferred,
|
|
155
|
+
new StoreInterrupted({ reason: 'unmounting component' }),
|
|
156
|
+
)
|
|
156
157
|
storeValue.componentScope = undefined
|
|
157
158
|
storeValue.shutdownDeferred = undefined
|
|
158
159
|
}
|
|
@@ -160,15 +161,12 @@ const setupStore = async <GraphQLContext extends BaseGraphQLContext>({
|
|
|
160
161
|
})
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
export const getStore = async <
|
|
164
|
-
Schema extends LiveStoreSchema,
|
|
165
|
-
GraphQLContext extends BaseGraphQLContext = BaseGraphQLContext,
|
|
166
|
-
>({
|
|
164
|
+
export const getStore = async <Schema extends LiveStoreSchema>({
|
|
167
165
|
adapter,
|
|
168
166
|
schema,
|
|
169
167
|
storeId,
|
|
170
|
-
}: Pick<CreateStoreOptions<
|
|
171
|
-
Solid.Accessor<Store<
|
|
168
|
+
}: Pick<CreateStoreOptions<Schema>, 'schema' | 'adapter' | 'storeId'>): Promise<
|
|
169
|
+
Solid.Accessor<Store<Schema> | undefined>
|
|
172
170
|
> => {
|
|
173
171
|
const setupDone = Promise.withResolvers<void>()
|
|
174
172
|
|
|
@@ -181,5 +179,5 @@ export const getStore = async <
|
|
|
181
179
|
|
|
182
180
|
await setupDone.promise
|
|
183
181
|
|
|
184
|
-
return storeToExport as unknown as Solid.Accessor<Store<
|
|
182
|
+
return storeToExport as unknown as Solid.Accessor<Store<Schema>>
|
|
185
183
|
}
|