@livestore/react 0.3.0-dev.9 → 0.3.1-dev.0
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/LICENSE +201 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/LiveStoreContext.d.ts +10 -4
- package/dist/LiveStoreContext.d.ts.map +1 -1
- package/dist/LiveStoreContext.js +1 -11
- package/dist/LiveStoreContext.js.map +1 -1
- package/dist/LiveStoreProvider.d.ts +29 -12
- package/dist/LiveStoreProvider.d.ts.map +1 -1
- package/dist/LiveStoreProvider.js +84 -55
- package/dist/LiveStoreProvider.js.map +1 -1
- package/dist/LiveStoreProvider.test.js +80 -29
- package/dist/LiveStoreProvider.test.js.map +1 -1
- package/dist/__tests__/fixture.d.ts +122 -556
- package/dist/__tests__/fixture.d.ts.map +1 -1
- package/dist/__tests__/fixture.js +71 -30
- package/dist/__tests__/fixture.js.map +1 -1
- package/dist/experimental/components/LiveList.d.ts +2 -2
- package/dist/experimental/components/LiveList.d.ts.map +1 -1
- package/dist/experimental/components/LiveList.js +10 -6
- package/dist/experimental/components/LiveList.js.map +1 -1
- package/dist/mod.d.ts +4 -5
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +4 -5
- package/dist/mod.js.map +1 -1
- package/dist/useClientDocument.d.ts +61 -0
- package/dist/useClientDocument.d.ts.map +1 -0
- package/dist/useClientDocument.js +79 -0
- package/dist/useClientDocument.js.map +1 -0
- package/dist/useClientDocument.test.d.ts +2 -0
- package/dist/useClientDocument.test.d.ts.map +1 -0
- package/dist/useClientDocument.test.js +175 -0
- package/dist/useClientDocument.test.js.map +1 -0
- package/dist/useQuery.d.ts +25 -3
- package/dist/useQuery.d.ts.map +1 -1
- package/dist/useQuery.js +67 -47
- package/dist/useQuery.js.map +1 -1
- package/dist/useQuery.test.d.ts +1 -1
- package/dist/useQuery.test.d.ts.map +1 -1
- package/dist/useQuery.test.js +86 -24
- package/dist/useQuery.test.js.map +1 -1
- package/dist/useRcResource.d.ts +76 -0
- package/dist/useRcResource.d.ts.map +1 -0
- package/dist/useRcResource.js +152 -0
- package/dist/useRcResource.js.map +1 -0
- package/dist/useRcResource.test.d.ts +2 -0
- package/dist/useRcResource.test.d.ts.map +1 -0
- package/dist/useRcResource.test.js +122 -0
- package/dist/useRcResource.test.js.map +1 -0
- package/dist/useStore.d.ts +9 -0
- package/dist/useStore.d.ts.map +1 -0
- package/dist/useStore.js +28 -0
- package/dist/useStore.js.map +1 -0
- package/dist/utils/useStateRefWithReactiveInput.d.ts.map +1 -1
- package/package.json +20 -13
- package/src/LiveStoreContext.ts +11 -16
- package/src/LiveStoreProvider.test.tsx +176 -37
- package/src/LiveStoreProvider.tsx +156 -81
- package/src/__snapshots__/useClientDocument.test.tsx.snap +613 -0
- package/src/__snapshots__/useQuery.test.tsx.snap +2011 -0
- package/src/__tests__/fixture.tsx +74 -47
- package/src/experimental/components/LiveList.tsx +10 -7
- package/src/mod.ts +5 -6
- package/src/useClientDocument.test.tsx +306 -0
- package/src/useClientDocument.ts +157 -0
- package/src/useQuery.test.tsx +182 -71
- package/src/useQuery.ts +95 -58
- package/src/useRcResource.test.tsx +167 -0
- package/src/useRcResource.ts +182 -0
- package/src/useStore.ts +36 -0
- package/dist/useAtom.d.ts +0 -5
- package/dist/useAtom.d.ts.map +0 -1
- package/dist/useAtom.js +0 -38
- package/dist/useAtom.js.map +0 -1
- package/dist/useRow.d.ts +0 -50
- package/dist/useRow.d.ts.map +0 -1
- package/dist/useRow.js +0 -93
- package/dist/useRow.js.map +0 -1
- package/dist/useRow.test.d.ts +0 -2
- package/dist/useRow.test.d.ts.map +0 -1
- package/dist/useRow.test.js +0 -202
- package/dist/useRow.test.js.map +0 -1
- package/dist/useScopedQuery.d.ts +0 -33
- package/dist/useScopedQuery.d.ts.map +0 -1
- package/dist/useScopedQuery.js +0 -87
- package/dist/useScopedQuery.js.map +0 -1
- package/dist/useScopedQuery.test.d.ts +0 -2
- package/dist/useScopedQuery.test.d.ts.map +0 -1
- package/dist/useScopedQuery.test.js +0 -60
- package/dist/useScopedQuery.test.js.map +0 -1
- package/src/__snapshots__/useRow.test.tsx.snap +0 -360
- package/src/useAtom.ts +0 -52
- package/src/useRow.test.tsx +0 -344
- package/src/useRow.ts +0 -188
- package/src/useScopedQuery.test.tsx +0 -96
- package/src/useScopedQuery.ts +0 -143
- package/tsconfig.json +0 -20
- package/vitest.config.js +0 -17
@@ -1,7 +1,13 @@
|
|
1
|
-
import type {
|
1
|
+
import type { LiveStoreContextRunning } from '@livestore/livestore';
|
2
2
|
import React from 'react';
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
import type { useClientDocument } from './useClientDocument.js';
|
4
|
+
import type { useQuery } from './useQuery.js';
|
5
|
+
export type ReactApi = {
|
6
|
+
useQuery: typeof useQuery;
|
7
|
+
useClientDocument: typeof useClientDocument;
|
6
8
|
};
|
9
|
+
export declare const LiveStoreContext: React.Context<{
|
10
|
+
stage: "running";
|
11
|
+
store: LiveStoreContextRunning["store"] & ReactApi;
|
12
|
+
} | undefined>;
|
7
13
|
//# sourceMappingURL=LiveStoreContext.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LiveStoreContext.d.ts","sourceRoot":"","sources":["../src/LiveStoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"LiveStoreContext.d.ts","sourceRoot":"","sources":["../src/LiveStoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,iBAAiB,EAAE,OAAO,iBAAiB,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,gBAAgB;WAClB,SAAS;WAAS,uBAAuB,CAAC,OAAO,CAAC,GAAG,QAAQ;cAC5D,CAAA"}
|
package/dist/LiveStoreContext.js
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
export const LiveStoreContext = React.createContext(undefined);
|
3
|
-
export const useStore = () => {
|
4
|
-
const storeContext = useContext(LiveStoreContext);
|
5
|
-
if (storeContext === undefined) {
|
6
|
-
throw new Error(`useStore can only be used inside StoreContext.Provider`);
|
7
|
-
}
|
8
|
-
if (storeContext.stage !== 'running') {
|
9
|
-
throw new Error(`useStore can only be used after the store is running`);
|
10
|
-
}
|
11
|
-
return storeContext;
|
12
|
-
};
|
13
3
|
//# sourceMappingURL=LiveStoreContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LiveStoreContext.js","sourceRoot":"","sources":["../src/LiveStoreContext.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"LiveStoreContext.js","sourceRoot":"","sources":["../src/LiveStoreContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAEjD,SAAS,CAAC,CAAA"}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import type { Adapter, BootStatus, IntentionalShutdownCause } from '@livestore/common';
|
1
|
+
import type { Adapter, BootStatus, IntentionalShutdownCause, MigrationsReport } from '@livestore/common';
|
2
2
|
import { UnexpectedError } from '@livestore/common';
|
3
3
|
import type { LiveStoreSchema } from '@livestore/common/schema';
|
4
|
-
import type {
|
5
|
-
import {
|
4
|
+
import type { OtelOptions, Store } from '@livestore/livestore';
|
5
|
+
import { StoreInterrupted } from '@livestore/livestore';
|
6
6
|
import type { OtelTracer } from '@livestore/utils/effect';
|
7
|
-
import { Effect } from '@livestore/utils/effect';
|
7
|
+
import { Effect, Schema } from '@livestore/utils/effect';
|
8
8
|
import type * as otel from '@opentelemetry/api';
|
9
9
|
import type { ReactElement, ReactNode } from 'react';
|
10
10
|
import React from 'react';
|
11
|
-
interface LiveStoreProviderProps
|
11
|
+
export interface LiveStoreProviderProps {
|
12
12
|
schema: LiveStoreSchema;
|
13
13
|
/**
|
14
14
|
* The `storeId` can be used to isolate multiple stores from each other.
|
@@ -21,15 +21,17 @@ interface LiveStoreProviderProps<GraphQLContext extends BaseGraphQLContext> {
|
|
21
21
|
* @default 'default'
|
22
22
|
*/
|
23
23
|
storeId?: string;
|
24
|
-
boot?: (store: Store<
|
25
|
-
|
24
|
+
boot?: (store: Store<LiveStoreSchema>, ctx: {
|
25
|
+
migrationsReport: MigrationsReport;
|
26
|
+
parentSpan: otel.Span;
|
27
|
+
}) => void | Promise<void> | Effect.Effect<void, unknown, OtelTracer.OtelTracer>;
|
26
28
|
otelOptions?: Partial<OtelOptions>;
|
27
|
-
renderLoading
|
29
|
+
renderLoading?: (status: BootStatus) => ReactElement;
|
28
30
|
renderError?: (error: UnexpectedError | unknown) => ReactElement;
|
29
|
-
renderShutdown?: (cause: IntentionalShutdownCause |
|
31
|
+
renderShutdown?: (cause: IntentionalShutdownCause | StoreInterrupted) => ReactElement;
|
30
32
|
adapter: Adapter;
|
31
33
|
/**
|
32
|
-
* In order for LiveStore to apply multiple
|
34
|
+
* In order for LiveStore to apply multiple events in a single render,
|
33
35
|
* you need to pass the `batchUpdates` function from either `react-dom` or `react-native`.
|
34
36
|
*
|
35
37
|
* ```ts
|
@@ -43,9 +45,24 @@ interface LiveStoreProviderProps<GraphQLContext extends BaseGraphQLContext> {
|
|
43
45
|
batchUpdates: (run: () => void) => void;
|
44
46
|
disableDevtools?: boolean;
|
45
47
|
signal?: AbortSignal;
|
48
|
+
/**
|
49
|
+
* Currently only used in the web adapter:
|
50
|
+
* If true, registers a beforeunload event listener to confirm unsaved changes.
|
51
|
+
*
|
52
|
+
* @default true
|
53
|
+
*/
|
54
|
+
confirmUnsavedChanges?: boolean;
|
55
|
+
/**
|
56
|
+
* Payload that will be passed to the sync backend when connecting
|
57
|
+
*
|
58
|
+
* @default undefined
|
59
|
+
*/
|
60
|
+
syncPayload?: Schema.JsonValue;
|
61
|
+
debug?: {
|
62
|
+
instanceId?: string;
|
63
|
+
};
|
46
64
|
}
|
47
|
-
export declare const LiveStoreProvider:
|
65
|
+
export declare const LiveStoreProvider: ({ renderLoading, renderError, renderShutdown, otelOptions, children, schema, storeId, boot, adapter, batchUpdates, disableDevtools, signal, confirmUnsavedChanges, syncPayload, debug, }: LiveStoreProviderProps & {
|
48
66
|
children?: ReactNode;
|
49
67
|
}) => React.ReactElement;
|
50
|
-
export {};
|
51
68
|
//# sourceMappingURL=LiveStoreProvider.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;
|
1
|
+
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAGV,WAAW,EAEX,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAqC,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAGL,MAAM,EAKN,MAAM,EAGP,MAAM,yBAAyB,CAAA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AAyBD,eAAO,MAAM,iBAAiB,GAAI,0LAgB/B,sBAAsB,GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,KAAG,KAAK,CAAC,YAkC5D,CAAA"}
|
@@ -1,35 +1,39 @@
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
1
2
|
import { provideOtel, UnexpectedError } from '@livestore/common';
|
2
|
-
import { createStore,
|
3
|
-
import { errorToString, LS_DEV } from '@livestore/utils';
|
4
|
-
import { Deferred, Effect, Exit, identity, Logger, LogLevel, Schema, Scope, TaskTracing } from '@livestore/utils/effect';
|
3
|
+
import { createStore, makeShutdownDeferred, StoreInterrupted } from '@livestore/livestore';
|
4
|
+
import { errorToString, IS_REACT_NATIVE, LS_DEV } from '@livestore/utils';
|
5
|
+
import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Schema, Scope, TaskTracing, } from '@livestore/utils/effect';
|
5
6
|
import React from 'react';
|
6
7
|
import { LiveStoreContext } from './LiveStoreContext.js';
|
7
|
-
const defaultRenderError = (error) => (
|
8
|
+
const defaultRenderError = (error) => IS_REACT_NATIVE ? _jsx(_Fragment, {}) : _jsx(_Fragment, { children: Schema.is(UnexpectedError)(error) ? error.toString() : errorToString(error) });
|
8
9
|
const defaultRenderShutdown = (cause) => {
|
9
|
-
const reason = cause._tag === 'LiveStore.
|
10
|
-
?
|
10
|
+
const reason = cause._tag === 'LiveStore.StoreInterrupted'
|
11
|
+
? `interrupted due to: ${cause.reason}`
|
11
12
|
: cause.reason === 'devtools-import'
|
12
13
|
? 'devtools import'
|
13
14
|
: cause.reason === 'devtools-reset'
|
14
15
|
? 'devtools reset'
|
15
|
-
: cause.reason === '
|
16
|
-
? '
|
17
|
-
:
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
: cause.reason === 'adapter-reset'
|
17
|
+
? 'adapter reset'
|
18
|
+
: cause.reason === 'manual'
|
19
|
+
? 'manual shutdown'
|
20
|
+
: 'unknown reason';
|
21
|
+
return IS_REACT_NATIVE ? _jsx(_Fragment, {}) : _jsxs(_Fragment, { children: ["LiveStore Shutdown due to ", reason] });
|
21
22
|
};
|
22
|
-
|
23
|
+
const defaultRenderLoading = (status) => IS_REACT_NATIVE ? _jsx(_Fragment, {}) : _jsxs(_Fragment, { children: ["LiveStore is loading (", status.stage, ")..."] });
|
24
|
+
export const LiveStoreProvider = ({ renderLoading = defaultRenderLoading, renderError = defaultRenderError, renderShutdown = defaultRenderShutdown, otelOptions, children, schema, storeId = 'default', boot, adapter, batchUpdates, disableDevtools, signal, confirmUnsavedChanges = true, syncPayload, debug, }) => {
|
23
25
|
const storeCtx = useCreateStore({
|
24
26
|
storeId,
|
25
27
|
schema,
|
26
|
-
graphQLOptions,
|
27
28
|
otelOptions,
|
28
29
|
boot,
|
29
30
|
adapter,
|
30
31
|
batchUpdates,
|
31
32
|
disableDevtools,
|
32
33
|
signal,
|
34
|
+
confirmUnsavedChanges,
|
35
|
+
syncPayload,
|
36
|
+
debug,
|
33
37
|
});
|
34
38
|
if (storeCtx.stage === 'error') {
|
35
39
|
return renderError(storeCtx.error);
|
@@ -44,65 +48,81 @@ export const LiveStoreProvider = ({ renderLoading, renderError = defaultRenderEr
|
|
44
48
|
if (Object.keys(globalThis.__debugLiveStore).length === 0) {
|
45
49
|
globalThis.__debugLiveStore['_'] = storeCtx.store;
|
46
50
|
}
|
47
|
-
globalThis.__debugLiveStore[storeId] = storeCtx.store;
|
48
|
-
return
|
51
|
+
globalThis.__debugLiveStore[debug?.instanceId ?? storeId] = storeCtx.store;
|
52
|
+
return _jsx(LiveStoreContext.Provider, { value: storeCtx, children: children });
|
49
53
|
};
|
50
|
-
const
|
51
|
-
const withSemaphore = (storeId) => {
|
52
|
-
let semaphore = semaphoreMap.get(storeId);
|
53
|
-
if (!semaphore) {
|
54
|
-
semaphore = Effect.makeSemaphore(1).pipe(Effect.runSync);
|
55
|
-
semaphoreMap.set(storeId, semaphore);
|
56
|
-
}
|
57
|
-
return semaphore.withPermits(1);
|
58
|
-
};
|
59
|
-
const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, adapter, batchUpdates, disableDevtools, reactivityGraph, signal, }) => {
|
54
|
+
const useCreateStore = ({ schema, storeId, otelOptions, boot, adapter, batchUpdates, disableDevtools, signal, context, params, confirmUnsavedChanges, syncPayload, debug, }) => {
|
60
55
|
const [_, rerender] = React.useState(0);
|
61
56
|
const ctxValueRef = React.useRef({
|
62
57
|
value: { stage: 'loading' },
|
63
58
|
componentScope: undefined,
|
64
59
|
shutdownDeferred: undefined,
|
60
|
+
previousShutdownDeferred: undefined,
|
65
61
|
counter: 0,
|
66
62
|
});
|
63
|
+
const debugInstanceId = debug?.instanceId;
|
67
64
|
// console.debug(`useCreateStore (${ctxValueRef.current.counter})`, ctxValueRef.current.value.stage)
|
68
65
|
const inputPropsCacheRef = React.useRef({
|
69
66
|
schema,
|
70
|
-
graphQLOptions,
|
71
67
|
otelOptions,
|
72
68
|
boot,
|
73
69
|
adapter,
|
74
70
|
batchUpdates,
|
75
71
|
disableDevtools,
|
76
|
-
reactivityGraph,
|
77
72
|
signal,
|
73
|
+
context,
|
74
|
+
params,
|
75
|
+
confirmUnsavedChanges,
|
76
|
+
syncPayload,
|
77
|
+
debugInstanceId,
|
78
78
|
});
|
79
79
|
const interrupt = (componentScope, shutdownDeferred, error) => Effect.gen(function* () {
|
80
80
|
// console.log('[@livestore/livestore/react] interupting', error)
|
81
81
|
yield* Scope.close(componentScope, Exit.fail(error));
|
82
82
|
yield* Deferred.fail(shutdownDeferred, error);
|
83
83
|
}).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] interupting', cause)), Effect.runFork);
|
84
|
-
|
85
|
-
inputPropsCacheRef.current.
|
86
|
-
inputPropsCacheRef.current.otelOptions !== otelOptions
|
87
|
-
inputPropsCacheRef.current.boot !== boot
|
88
|
-
inputPropsCacheRef.current.adapter !== adapter
|
89
|
-
inputPropsCacheRef.current.batchUpdates !== batchUpdates
|
90
|
-
inputPropsCacheRef.current.disableDevtools !== disableDevtools
|
91
|
-
inputPropsCacheRef.current.
|
92
|
-
inputPropsCacheRef.current.
|
84
|
+
const inputPropChanges = {
|
85
|
+
schema: inputPropsCacheRef.current.schema !== schema,
|
86
|
+
otelOptions: inputPropsCacheRef.current.otelOptions !== otelOptions,
|
87
|
+
boot: inputPropsCacheRef.current.boot !== boot,
|
88
|
+
adapter: inputPropsCacheRef.current.adapter !== adapter,
|
89
|
+
batchUpdates: inputPropsCacheRef.current.batchUpdates !== batchUpdates,
|
90
|
+
disableDevtools: inputPropsCacheRef.current.disableDevtools !== disableDevtools,
|
91
|
+
signal: inputPropsCacheRef.current.signal !== signal,
|
92
|
+
context: inputPropsCacheRef.current.context !== context,
|
93
|
+
params: inputPropsCacheRef.current.params !== params,
|
94
|
+
confirmUnsavedChanges: inputPropsCacheRef.current.confirmUnsavedChanges !== confirmUnsavedChanges,
|
95
|
+
syncPayload: inputPropsCacheRef.current.syncPayload !== syncPayload,
|
96
|
+
debugInstanceId: inputPropsCacheRef.current.debugInstanceId !== debugInstanceId,
|
97
|
+
};
|
98
|
+
if (inputPropChanges.schema ||
|
99
|
+
inputPropChanges.otelOptions ||
|
100
|
+
inputPropChanges.boot ||
|
101
|
+
inputPropChanges.adapter ||
|
102
|
+
inputPropChanges.batchUpdates ||
|
103
|
+
inputPropChanges.disableDevtools ||
|
104
|
+
inputPropChanges.signal ||
|
105
|
+
inputPropChanges.context ||
|
106
|
+
inputPropChanges.params ||
|
107
|
+
inputPropChanges.confirmUnsavedChanges ||
|
108
|
+
inputPropChanges.syncPayload) {
|
93
109
|
inputPropsCacheRef.current = {
|
94
110
|
schema,
|
95
|
-
graphQLOptions,
|
96
111
|
otelOptions,
|
97
112
|
boot,
|
98
113
|
adapter,
|
99
114
|
batchUpdates,
|
100
115
|
disableDevtools,
|
101
|
-
reactivityGraph,
|
102
116
|
signal,
|
117
|
+
context,
|
118
|
+
params,
|
119
|
+
confirmUnsavedChanges,
|
120
|
+
syncPayload,
|
121
|
+
debugInstanceId,
|
103
122
|
};
|
104
123
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
105
|
-
|
124
|
+
const changedInputProps = Object.keys(inputPropChanges).filter((key) => inputPropChanges[key]);
|
125
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: `re-rendering due to changed input props: ${changedInputProps.join(', ')}` }));
|
106
126
|
ctxValueRef.current.componentScope = undefined;
|
107
127
|
ctxValueRef.current.shutdownDeferred = undefined;
|
108
128
|
}
|
@@ -110,6 +130,7 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
110
130
|
value: { stage: 'loading' },
|
111
131
|
componentScope: undefined,
|
112
132
|
shutdownDeferred: undefined,
|
133
|
+
previousShutdownDeferred: ctxValueRef.current.shutdownDeferred,
|
113
134
|
counter: ctxValueRef.current.counter + 1,
|
114
135
|
};
|
115
136
|
}
|
@@ -125,60 +146,68 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
125
146
|
if (ctxValueRef.current.componentScope !== undefined &&
|
126
147
|
ctxValueRef.current.shutdownDeferred !== undefined &&
|
127
148
|
ctxValueRef.current.counter === counter) {
|
128
|
-
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new
|
149
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'Aborted via provided AbortController' }));
|
129
150
|
ctxValueRef.current.componentScope = undefined;
|
130
151
|
ctxValueRef.current.shutdownDeferred = undefined;
|
131
152
|
}
|
132
153
|
});
|
133
|
-
Effect.gen(function* () {
|
134
|
-
|
135
|
-
|
154
|
+
const cancel = Effect.gen(function* () {
|
155
|
+
// Wait for the previous store to fully shutdown before creating a new one
|
156
|
+
if (ctxValueRef.current.previousShutdownDeferred) {
|
157
|
+
yield* Deferred.await(ctxValueRef.current.previousShutdownDeferred);
|
158
|
+
}
|
159
|
+
const componentScope = yield* Scope.make().pipe(Effect.acquireRelease(Scope.close));
|
160
|
+
const shutdownDeferred = yield* makeShutdownDeferred;
|
136
161
|
ctxValueRef.current.componentScope = componentScope;
|
137
162
|
ctxValueRef.current.shutdownDeferred = shutdownDeferred;
|
138
163
|
yield* Effect.gen(function* () {
|
139
164
|
const store = yield* createStore({
|
140
165
|
schema,
|
141
166
|
storeId,
|
142
|
-
graphQLOptions,
|
143
167
|
boot,
|
144
168
|
adapter,
|
145
|
-
reactivityGraph,
|
146
169
|
batchUpdates,
|
147
170
|
disableDevtools,
|
148
171
|
shutdownDeferred,
|
172
|
+
context,
|
173
|
+
params,
|
174
|
+
confirmUnsavedChanges,
|
175
|
+
syncPayload,
|
149
176
|
onBootStatus: (status) => {
|
150
177
|
if (ctxValueRef.current.value.stage === 'running' || ctxValueRef.current.value.stage === 'error')
|
151
178
|
return;
|
179
|
+
// NOTE sometimes when status come in in rapid succession, only the last value will be rendered by React
|
152
180
|
setContextValue(status);
|
153
181
|
},
|
182
|
+
debug: { instanceId: debugInstanceId },
|
154
183
|
}).pipe(Effect.tapErrorCause((cause) => Deferred.failCause(shutdownDeferred, cause)));
|
155
184
|
setContextValue({ stage: 'running', store });
|
156
185
|
}).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope));
|
157
186
|
const shutdownContext = (cause) => Effect.sync(() => setContextValue({ stage: 'shutdown', cause }));
|
158
|
-
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', cause)), Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.
|
159
|
-
}).pipe(Effect.scoped,
|
160
|
-
// NOTE we're running the code above in a semaphore to make sure a previous store is always fully
|
161
|
-
// shutdown before a new one is created - especially when shutdown logic is async. You can't trust `React.useEffect`.
|
162
|
-
// Thank you to Mattia Manzati for this idea.
|
163
|
-
withSemaphore(storeId), Effect.withSpan('@livestore/react:useCreateStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer }), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.prettyWithThread('window')), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runFork);
|
187
|
+
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] 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);
|
188
|
+
}).pipe(Effect.scoped, Effect.withSpan('@livestore/react:useCreateStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer }), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.prettyWithThread('window')), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runCallback);
|
164
189
|
return () => {
|
190
|
+
cancel();
|
165
191
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
166
|
-
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted());
|
192
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'unmounting component' }));
|
167
193
|
ctxValueRef.current.componentScope = undefined;
|
168
194
|
ctxValueRef.current.shutdownDeferred = undefined;
|
169
195
|
}
|
170
196
|
};
|
171
197
|
}, [
|
172
198
|
schema,
|
173
|
-
graphQLOptions,
|
174
199
|
otelOptions,
|
175
200
|
boot,
|
176
201
|
adapter,
|
177
202
|
batchUpdates,
|
178
203
|
disableDevtools,
|
179
204
|
signal,
|
180
|
-
reactivityGraph,
|
181
205
|
storeId,
|
206
|
+
context,
|
207
|
+
params,
|
208
|
+
confirmUnsavedChanges,
|
209
|
+
syncPayload,
|
210
|
+
debugInstanceId,
|
182
211
|
]);
|
183
212
|
return ctxValueRef.current.value;
|
184
213
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
1
|
+
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAShE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC1F,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzE,OAAO,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,GACZ,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAyDxD,MAAM,kBAAkB,GAAG,CAAC,KAAgC,EAAE,EAAE,CAC9D,eAAe,CAAC,CAAC,CAAC,mBAAK,CAAC,CAAC,CAAC,4BAAG,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC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CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC,CACzD,CAAA;gBACD,WAAW,CAAC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAA;gBAC9C,WAAW,CAAC,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAA;YAClD,CAAC;QACH,CAAC,CAAA;IACH,CAAC,EAAE;QACD,MAAM;QACN,WAAW;QACX,IAAI;QACJ,OAAO;QACP,YAAY;QACZ,eAAe;QACf,MAAM;QACN,OAAO;QACP,OAAO;QACP,MAAM;QACN,qBAAqB;QACrB,WAAW;QACX,eAAe;KAChB,CAAC,CAAA;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;AAClC,CAAC,CAAA"}
|
@@ -1,68 +1,119 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { makeInMemoryAdapter } from '@livestore/adapter-web';
|
1
3
|
import { sql } from '@livestore/common';
|
2
|
-
import {
|
4
|
+
import { rawSqlEvent } from '@livestore/common/schema';
|
3
5
|
import { queryDb } from '@livestore/livestore';
|
4
6
|
import { Schema } from '@livestore/utils/effect';
|
5
|
-
import
|
6
|
-
import { render, screen, waitFor, waitForElementToBeRemoved } from '@testing-library/react';
|
7
|
+
import * as ReactTesting from '@testing-library/react';
|
7
8
|
import React from 'react';
|
8
9
|
import { unstable_batchedUpdates as batchUpdates } from 'react-dom';
|
9
10
|
import { describe, expect, it } from 'vitest';
|
10
|
-
import { schema, tables } from './__tests__/fixture.js';
|
11
|
+
import { events, schema, tables } from './__tests__/fixture.js';
|
11
12
|
import { LiveStoreProvider } from './LiveStoreProvider.js';
|
12
13
|
import * as LiveStoreReact from './mod.js';
|
13
|
-
describe('LiveStoreProvider', () => {
|
14
|
+
describe.each([true, false])('LiveStoreProvider (strictMode: %s)', (strictMode) => {
|
15
|
+
const WithStrictMode = strictMode ? React.StrictMode : React.Fragment;
|
14
16
|
it('simple', async () => {
|
15
17
|
let appRenderCount = 0;
|
16
|
-
const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.
|
18
|
+
const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
|
17
19
|
const App = () => {
|
18
20
|
appRenderCount++;
|
19
|
-
const
|
20
|
-
|
21
|
+
const { store } = LiveStoreReact.useStore();
|
22
|
+
const todos = store.useQuery(allTodos$);
|
23
|
+
return _jsx("div", { children: JSON.stringify(todos) });
|
21
24
|
};
|
22
25
|
const abortController = new AbortController();
|
23
26
|
const Root = ({ forceUpdate }) => {
|
24
|
-
const bootCb = React.useCallback((store) => store.
|
27
|
+
const bootCb = React.useCallback((store) => store.commit(rawSqlEvent({
|
25
28
|
sql: sql `INSERT OR IGNORE INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
26
29
|
})), []);
|
27
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
28
31
|
const adapterMemo = React.useMemo(() => makeInMemoryAdapter(), [forceUpdate]);
|
29
|
-
return (
|
30
|
-
"Loading LiveStore: ",
|
31
|
-
status.stage), adapter: adapterMemo, boot: bootCb, signal: abortController.signal, batchUpdates: batchUpdates },
|
32
|
-
React.createElement(App, null)));
|
32
|
+
return (_jsx(WithStrictMode, { children: _jsx(LiveStoreProvider, { schema: schema, renderLoading: (status) => _jsxs("div", { children: ["Loading LiveStore: ", status.stage] }), adapter: adapterMemo, boot: bootCb, signal: abortController.signal, batchUpdates: batchUpdates, children: _jsx(App, {}) }) }));
|
33
33
|
};
|
34
|
-
const { rerender } = render(
|
34
|
+
const { rerender } = ReactTesting.render(_jsx(Root, { forceUpdate: 1 }));
|
35
35
|
expect(appRenderCount).toBe(0);
|
36
|
-
await waitForElementToBeRemoved(() => screen.getByText((_) => _.startsWith('Loading LiveStore')));
|
37
|
-
expect(appRenderCount).toBe(1);
|
38
|
-
rerender(
|
39
|
-
await waitFor(() => screen.getByText('Loading LiveStore: loading'));
|
40
|
-
await waitFor(() => screen.getByText((_) => _.includes('buy milk')));
|
41
|
-
expect(appRenderCount).toBe(2);
|
36
|
+
await ReactTesting.waitForElementToBeRemoved(() => ReactTesting.screen.getByText((_) => _.startsWith('Loading LiveStore')));
|
37
|
+
expect(appRenderCount).toBe(strictMode ? 2 : 1);
|
38
|
+
rerender(_jsx(Root, { forceUpdate: 2 }));
|
39
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText('Loading LiveStore: loading'));
|
40
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText((_) => _.includes('buy milk')));
|
41
|
+
expect(appRenderCount).toBe(strictMode ? 4 : 2);
|
42
42
|
abortController.abort();
|
43
|
-
await waitFor(() => screen.getByText('LiveStore Shutdown due to
|
43
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText('LiveStore Shutdown due to interrupted', { exact: false }));
|
44
44
|
});
|
45
45
|
// TODO test aborting during boot
|
46
46
|
it('error during boot', async () => {
|
47
47
|
let appRenderCount = 0;
|
48
48
|
const App = () => {
|
49
49
|
appRenderCount++;
|
50
|
-
return
|
50
|
+
return _jsx("div", { children: "hello world" });
|
51
51
|
};
|
52
52
|
const Root = ({ forceUpdate }) => {
|
53
|
-
const bootCb = React.useCallback((store) => store.
|
53
|
+
const bootCb = React.useCallback((store) => store.commit(rawSqlEvent({
|
54
54
|
sql: sql `INSERT OR IGNORE INTO todos_missing_table (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
55
55
|
})), []);
|
56
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
57
57
|
const adapterMemo = React.useMemo(() => makeInMemoryAdapter(), [forceUpdate]);
|
58
|
-
return (
|
59
|
-
"Loading LiveStore: ",
|
60
|
-
status.stage), adapter: adapterMemo, boot: bootCb, batchUpdates: batchUpdates },
|
61
|
-
React.createElement(App, null)));
|
58
|
+
return (_jsx(WithStrictMode, { children: _jsx(LiveStoreProvider, { schema: schema, renderLoading: (status) => _jsxs("div", { children: ["Loading LiveStore: ", status.stage] }), adapter: adapterMemo, boot: bootCb, batchUpdates: batchUpdates, children: _jsx(App, {}) }) }));
|
62
59
|
};
|
63
|
-
render(
|
60
|
+
ReactTesting.render(_jsx(Root, { forceUpdate: 1 }));
|
64
61
|
expect(appRenderCount).toBe(0);
|
65
|
-
await waitFor(() => screen.getByText((_) => _.startsWith('LiveStore.UnexpectedError')));
|
62
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText((_) => _.startsWith('LiveStore.UnexpectedError')));
|
66
63
|
});
|
64
|
+
it('unmounts when store is shutdown', async () => {
|
65
|
+
let appRenderCount = 0;
|
66
|
+
const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
|
67
|
+
const shutdownDeferred = Promise.withResolvers();
|
68
|
+
const App = () => {
|
69
|
+
appRenderCount++;
|
70
|
+
const { store } = LiveStoreReact.useStore();
|
71
|
+
React.useEffect(() => {
|
72
|
+
shutdownDeferred.promise.then(() => {
|
73
|
+
console.log('shutdown');
|
74
|
+
return store.shutdown();
|
75
|
+
});
|
76
|
+
}, [store]);
|
77
|
+
const todos = store.useQuery(allTodos$);
|
78
|
+
return _jsx("div", { children: JSON.stringify(todos) });
|
79
|
+
};
|
80
|
+
const adapter = makeInMemoryAdapter();
|
81
|
+
const Root = () => {
|
82
|
+
return (_jsx(WithStrictMode, { children: _jsx(LiveStoreProvider, { schema: schema, renderLoading: (status) => _jsxs("div", { children: ["Loading LiveStore: ", status.stage] }), adapter: adapter, batchUpdates: batchUpdates, children: _jsx(App, {}) }) }));
|
83
|
+
};
|
84
|
+
ReactTesting.render(_jsx(Root, {}));
|
85
|
+
expect(appRenderCount).toBe(0);
|
86
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText('[]'));
|
87
|
+
React.act(() => shutdownDeferred.resolve());
|
88
|
+
expect(appRenderCount).toBe(strictMode ? 2 : 1);
|
89
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByText('LiveStore Shutdown due to manual shutdown', { exact: false }));
|
90
|
+
});
|
91
|
+
});
|
92
|
+
it('should work two stores with the same storeId', async () => {
|
93
|
+
const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
|
94
|
+
const appRenderCount = {
|
95
|
+
store1: 0,
|
96
|
+
store2: 0,
|
97
|
+
};
|
98
|
+
const App = () => {
|
99
|
+
const { store } = LiveStoreReact.useStore();
|
100
|
+
const instanceId = store.clientSession.debugInstanceId;
|
101
|
+
appRenderCount[instanceId]++;
|
102
|
+
const todos = store.useQuery(allTodos$);
|
103
|
+
return (_jsxs("div", { id: instanceId, children: [_jsx("div", { role: "heading", children: instanceId }), _jsx("div", { role: "content", children: JSON.stringify(todos) }), _jsxs("button", { onClick: () => store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false })), children: ["create todo ", instanceId] })] }));
|
104
|
+
};
|
105
|
+
const Root = () => {
|
106
|
+
const storeId = 'fixed-store-id';
|
107
|
+
return (_jsxs("div", { children: [_jsx(LiveStoreProvider, { storeId: storeId, debug: { instanceId: 'store1' }, schema: schema, adapter: makeInMemoryAdapter(), batchUpdates: batchUpdates, children: _jsx(App, {}) }), _jsx(LiveStoreProvider, { storeId: storeId, debug: { instanceId: 'store2' }, schema: schema, adapter: makeInMemoryAdapter(), batchUpdates: batchUpdates, children: _jsx(App, {}) })] }));
|
108
|
+
};
|
109
|
+
const { container } = ReactTesting.render(_jsx(Root, {}));
|
110
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByRole('heading', { name: 'store1' }));
|
111
|
+
await ReactTesting.waitFor(() => ReactTesting.screen.getByRole('heading', { name: 'store2' }));
|
112
|
+
expect(appRenderCount.store1).toBe(1);
|
113
|
+
expect(appRenderCount.store2).toBe(1);
|
114
|
+
ReactTesting.fireEvent.click(ReactTesting.screen.getByText('create todo store1'));
|
115
|
+
expect(appRenderCount.store1).toBe(2);
|
116
|
+
expect(container.querySelector('#store1 > div[role="content"]')?.textContent).toBe('[{"id":"t1","text":"buy milk","completed":false}]');
|
117
|
+
expect(container.querySelector('#store2 > div[role="content"]')?.textContent).toBe('[]');
|
67
118
|
});
|
68
119
|
//# sourceMappingURL=LiveStoreProvider.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.test.js","sourceRoot":"","sources":["../src/LiveStoreProvider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"LiveStoreProvider.test.js","sourceRoot":"","sources":["../src/LiveStoreProvider.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAc,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,cAAc,MAAM,UAAU,CAAA;AAE1C,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,oCAAoC,EAAE,CAAC,UAAU,EAAE,EAAE;IAChF,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAA;IAErE,EAAE,CAAC,QAAQ,EA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