@livestore/react 0.4.0-dev.21 → 0.4.0-dev.22

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.
Files changed (97) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/StoreRegistryContext.d.ts +56 -0
  3. package/dist/StoreRegistryContext.d.ts.map +1 -0
  4. package/dist/StoreRegistryContext.js +61 -0
  5. package/dist/StoreRegistryContext.js.map +1 -0
  6. package/dist/__tests__/fixture.d.ts.map +1 -1
  7. package/dist/__tests__/fixture.js +1 -6
  8. package/dist/__tests__/fixture.js.map +1 -1
  9. package/dist/experimental/components/LiveList.d.ts +4 -2
  10. package/dist/experimental/components/LiveList.d.ts.map +1 -1
  11. package/dist/experimental/components/LiveList.js +6 -5
  12. package/dist/experimental/components/LiveList.js.map +1 -1
  13. package/dist/experimental/mod.d.ts +0 -1
  14. package/dist/experimental/mod.d.ts.map +1 -1
  15. package/dist/experimental/mod.js +0 -1
  16. package/dist/experimental/mod.js.map +1 -1
  17. package/dist/mod.d.ts +4 -3
  18. package/dist/mod.d.ts.map +1 -1
  19. package/dist/mod.js +3 -2
  20. package/dist/mod.js.map +1 -1
  21. package/dist/useClientDocument.d.ts.map +1 -1
  22. package/dist/useClientDocument.js +1 -4
  23. package/dist/useClientDocument.js.map +1 -1
  24. package/dist/useQuery.d.ts +1 -1
  25. package/dist/useQuery.d.ts.map +1 -1
  26. package/dist/useQuery.js +2 -5
  27. package/dist/useQuery.js.map +1 -1
  28. package/dist/useStore.d.ts +50 -46
  29. package/dist/useStore.d.ts.map +1 -1
  30. package/dist/useStore.js +66 -59
  31. package/dist/useStore.js.map +1 -1
  32. package/dist/useStore.test.d.ts.map +1 -0
  33. package/dist/{experimental/multi-store/useStore.test.js → useStore.test.js} +20 -22
  34. package/dist/useStore.test.js.map +1 -0
  35. package/package.json +7 -7
  36. package/src/StoreRegistryContext.tsx +69 -0
  37. package/src/__tests__/fixture.tsx +1 -13
  38. package/src/experimental/components/LiveList.tsx +13 -4
  39. package/src/experimental/mod.ts +0 -1
  40. package/src/mod.ts +4 -3
  41. package/src/useClientDocument.ts +1 -5
  42. package/src/useQuery.ts +2 -6
  43. package/src/{experimental/multi-store/useStore.test.tsx → useStore.test.tsx} +32 -30
  44. package/src/useStore.ts +94 -66
  45. package/dist/LiveStoreContext.d.ts +0 -40
  46. package/dist/LiveStoreContext.d.ts.map +0 -1
  47. package/dist/LiveStoreContext.js +0 -21
  48. package/dist/LiveStoreContext.js.map +0 -1
  49. package/dist/LiveStoreProvider.d.ts +0 -73
  50. package/dist/LiveStoreProvider.d.ts.map +0 -1
  51. package/dist/LiveStoreProvider.js +0 -233
  52. package/dist/LiveStoreProvider.js.map +0 -1
  53. package/dist/LiveStoreProvider.test.d.ts +0 -2
  54. package/dist/LiveStoreProvider.test.d.ts.map +0 -1
  55. package/dist/LiveStoreProvider.test.js +0 -117
  56. package/dist/LiveStoreProvider.test.js.map +0 -1
  57. package/dist/experimental/multi-store/StoreRegistry.d.ts +0 -105
  58. package/dist/experimental/multi-store/StoreRegistry.d.ts.map +0 -1
  59. package/dist/experimental/multi-store/StoreRegistry.js +0 -184
  60. package/dist/experimental/multi-store/StoreRegistry.js.map +0 -1
  61. package/dist/experimental/multi-store/StoreRegistry.test.d.ts +0 -2
  62. package/dist/experimental/multi-store/StoreRegistry.test.d.ts.map +0 -1
  63. package/dist/experimental/multi-store/StoreRegistry.test.js +0 -381
  64. package/dist/experimental/multi-store/StoreRegistry.test.js.map +0 -1
  65. package/dist/experimental/multi-store/StoreRegistryContext.d.ts +0 -10
  66. package/dist/experimental/multi-store/StoreRegistryContext.d.ts.map +0 -1
  67. package/dist/experimental/multi-store/StoreRegistryContext.js +0 -15
  68. package/dist/experimental/multi-store/StoreRegistryContext.js.map +0 -1
  69. package/dist/experimental/multi-store/mod.d.ts +0 -6
  70. package/dist/experimental/multi-store/mod.d.ts.map +0 -1
  71. package/dist/experimental/multi-store/mod.js +0 -6
  72. package/dist/experimental/multi-store/mod.js.map +0 -1
  73. package/dist/experimental/multi-store/storeOptions.d.ts +0 -4
  74. package/dist/experimental/multi-store/storeOptions.d.ts.map +0 -1
  75. package/dist/experimental/multi-store/storeOptions.js +0 -4
  76. package/dist/experimental/multi-store/storeOptions.js.map +0 -1
  77. package/dist/experimental/multi-store/types.d.ts +0 -25
  78. package/dist/experimental/multi-store/types.d.ts.map +0 -1
  79. package/dist/experimental/multi-store/types.js +0 -2
  80. package/dist/experimental/multi-store/types.js.map +0 -1
  81. package/dist/experimental/multi-store/useStore.d.ts +0 -11
  82. package/dist/experimental/multi-store/useStore.d.ts.map +0 -1
  83. package/dist/experimental/multi-store/useStore.js +0 -16
  84. package/dist/experimental/multi-store/useStore.js.map +0 -1
  85. package/dist/experimental/multi-store/useStore.test.d.ts.map +0 -1
  86. package/dist/experimental/multi-store/useStore.test.js.map +0 -1
  87. package/src/LiveStoreContext.ts +0 -41
  88. package/src/LiveStoreProvider.test.tsx +0 -248
  89. package/src/LiveStoreProvider.tsx +0 -430
  90. package/src/experimental/multi-store/StoreRegistry.test.ts +0 -518
  91. package/src/experimental/multi-store/StoreRegistry.ts +0 -253
  92. package/src/experimental/multi-store/StoreRegistryContext.tsx +0 -23
  93. package/src/experimental/multi-store/mod.ts +0 -5
  94. package/src/experimental/multi-store/storeOptions.ts +0 -8
  95. package/src/experimental/multi-store/types.ts +0 -37
  96. package/src/experimental/multi-store/useStore.ts +0 -26
  97. /package/dist/{experimental/multi-store/useStore.test.d.ts → useStore.test.d.ts} +0 -0
@@ -1,233 +0,0 @@
1
- import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { LogConfig, provideOtel, UnknownError } from '@livestore/common';
3
- import { createStore, makeShutdownDeferred, StoreInterrupted } from '@livestore/livestore';
4
- import { errorToString, IS_REACT_NATIVE, LS_DEV, omitUndefineds } from '@livestore/utils';
5
- import { Cause, Deferred, Effect, Exit, identity, Schema, Scope, TaskTracing } from '@livestore/utils/effect';
6
- import React from 'react';
7
- import { LiveStoreContext } from "./LiveStoreContext.js";
8
- const defaultRenderError = (error) => IS_REACT_NATIVE ? null : Schema.is(UnknownError)(error) ? error.toString() : errorToString(error);
9
- const defaultRenderShutdown = (cause) => {
10
- const reason = cause._tag === 'LiveStore.StoreInterrupted'
11
- ? `interrupted due to: ${cause.reason}`
12
- : cause._tag === 'InvalidPushError' || cause._tag === 'InvalidPullError'
13
- ? `sync error: ${cause.cause}`
14
- : cause.reason === 'devtools-import'
15
- ? 'devtools import'
16
- : cause.reason === 'devtools-reset'
17
- ? 'devtools reset'
18
- : cause.reason === 'adapter-reset'
19
- ? 'adapter reset'
20
- : cause.reason === 'manual'
21
- ? 'manual shutdown'
22
- : 'unknown reason';
23
- return IS_REACT_NATIVE ? null : _jsxs(_Fragment, { children: ["LiveStore Shutdown due to ", reason] });
24
- };
25
- const defaultRenderLoading = (status) => IS_REACT_NATIVE ? null : _jsxs(_Fragment, { children: ["LiveStore is loading (", status.stage, ")..."] });
26
- export const LiveStoreProvider = ({ renderLoading = defaultRenderLoading, renderError = defaultRenderError, renderShutdown = defaultRenderShutdown, otelOptions, children, schema, storeId = 'default', boot, adapter, batchUpdates, disableDevtools, signal, confirmUnsavedChanges = true, params, syncPayload, syncPayloadSchema, debug, logger, logLevel, }) => {
27
- const storeCtx = useCreateStore({
28
- storeId,
29
- schema,
30
- adapter,
31
- batchUpdates,
32
- confirmUnsavedChanges,
33
- ...omitUndefineds({
34
- otelOptions,
35
- boot,
36
- disableDevtools,
37
- params,
38
- signal,
39
- syncPayload,
40
- syncPayloadSchema,
41
- debug,
42
- }),
43
- logger,
44
- logLevel,
45
- });
46
- if (storeCtx.stage === 'error') {
47
- return renderError(storeCtx.error);
48
- }
49
- if (storeCtx.stage === 'shutdown') {
50
- return renderShutdown(storeCtx.cause);
51
- }
52
- if (storeCtx.stage !== 'running') {
53
- return renderLoading(storeCtx);
54
- }
55
- globalThis.__debugLiveStore ??= {};
56
- if (Object.keys(globalThis.__debugLiveStore).length === 0) {
57
- globalThis.__debugLiveStore._ = storeCtx.store;
58
- }
59
- globalThis.__debugLiveStore[debug?.instanceId ?? storeId] = storeCtx.store;
60
- return _jsx(LiveStoreContext.Provider, { value: storeCtx, children: children });
61
- };
62
- const useCreateStore = ({ schema, storeId, otelOptions, boot, adapter, batchUpdates, disableDevtools, signal, context, params, confirmUnsavedChanges, syncPayload, syncPayloadSchema, debug, logger, logLevel, }) => {
63
- const [_, rerender] = React.useState(0);
64
- const ctxValueRef = React.useRef({
65
- value: { stage: 'loading' },
66
- componentScope: undefined,
67
- shutdownDeferred: undefined,
68
- previousShutdownDeferred: undefined,
69
- counter: 0,
70
- });
71
- const debugInstanceId = debug?.instanceId;
72
- // console.debug(`useCreateStore (${ctxValueRef.current.counter})`, ctxValueRef.current.value.stage)
73
- const inputPropsCacheRef = React.useRef({
74
- schema,
75
- otelOptions,
76
- boot,
77
- adapter,
78
- batchUpdates,
79
- disableDevtools,
80
- signal,
81
- context,
82
- params,
83
- confirmUnsavedChanges,
84
- syncPayload,
85
- syncPayloadSchema,
86
- debugInstanceId,
87
- });
88
- const interrupt = React.useCallback((componentScope, shutdownDeferred, error) => Effect.gen(function* () {
89
- // console.log('[@livestore/livestore/react] interupting', error)
90
- yield* Scope.close(componentScope, Exit.fail(error));
91
- yield* Deferred.fail(shutdownDeferred, error);
92
- }).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] interupting', cause)), Effect.runFork), []);
93
- const inputPropChanges = {
94
- schema: inputPropsCacheRef.current.schema !== schema,
95
- otelOptions: inputPropsCacheRef.current.otelOptions !== otelOptions,
96
- boot: inputPropsCacheRef.current.boot !== boot,
97
- adapter: inputPropsCacheRef.current.adapter !== adapter,
98
- batchUpdates: inputPropsCacheRef.current.batchUpdates !== batchUpdates,
99
- disableDevtools: inputPropsCacheRef.current.disableDevtools !== disableDevtools,
100
- signal: inputPropsCacheRef.current.signal !== signal,
101
- context: inputPropsCacheRef.current.context !== context,
102
- params: inputPropsCacheRef.current.params !== params,
103
- confirmUnsavedChanges: inputPropsCacheRef.current.confirmUnsavedChanges !== confirmUnsavedChanges,
104
- syncPayload: inputPropsCacheRef.current.syncPayload !== syncPayload,
105
- syncPayloadSchema: inputPropsCacheRef.current.syncPayloadSchema !== syncPayloadSchema,
106
- debugInstanceId: inputPropsCacheRef.current.debugInstanceId !== debugInstanceId,
107
- };
108
- if (inputPropChanges.schema ||
109
- inputPropChanges.otelOptions ||
110
- inputPropChanges.boot ||
111
- inputPropChanges.adapter ||
112
- inputPropChanges.batchUpdates ||
113
- inputPropChanges.disableDevtools ||
114
- inputPropChanges.signal ||
115
- inputPropChanges.context ||
116
- inputPropChanges.params ||
117
- inputPropChanges.confirmUnsavedChanges ||
118
- inputPropChanges.syncPayload ||
119
- inputPropChanges.syncPayloadSchema) {
120
- inputPropsCacheRef.current = {
121
- schema,
122
- otelOptions,
123
- boot,
124
- adapter,
125
- batchUpdates,
126
- disableDevtools,
127
- signal,
128
- context,
129
- params,
130
- confirmUnsavedChanges,
131
- syncPayload,
132
- syncPayloadSchema,
133
- debugInstanceId,
134
- };
135
- if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
136
- const changedInputProps = Object.keys(inputPropChanges).filter((key) => inputPropChanges[key]);
137
- interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: `re-rendering due to changed input props: ${changedInputProps.join(', ')}` }));
138
- ctxValueRef.current.componentScope = undefined;
139
- ctxValueRef.current.shutdownDeferred = undefined;
140
- }
141
- ctxValueRef.current = {
142
- value: { stage: 'loading' },
143
- componentScope: undefined,
144
- shutdownDeferred: undefined,
145
- previousShutdownDeferred: ctxValueRef.current.shutdownDeferred,
146
- counter: ctxValueRef.current.counter + 1,
147
- };
148
- }
149
- React.useEffect(() => {
150
- const counter = ctxValueRef.current.counter;
151
- const setContextValue = (value) => {
152
- if (ctxValueRef.current.counter !== counter)
153
- return;
154
- ctxValueRef.current.value = value;
155
- rerender((c) => c + 1);
156
- };
157
- signal?.addEventListener('abort', () => {
158
- if (ctxValueRef.current.componentScope !== undefined &&
159
- ctxValueRef.current.shutdownDeferred !== undefined &&
160
- ctxValueRef.current.counter === counter) {
161
- interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'Aborted via provided AbortController' }));
162
- ctxValueRef.current.componentScope = undefined;
163
- ctxValueRef.current.shutdownDeferred = undefined;
164
- }
165
- });
166
- const cancel = Effect.gen(function* () {
167
- // Wait for the previous store to fully shutdown before creating a new one
168
- if (ctxValueRef.current.previousShutdownDeferred) {
169
- yield* Deferred.await(ctxValueRef.current.previousShutdownDeferred);
170
- }
171
- const componentScope = yield* Scope.make().pipe(Effect.acquireRelease(Scope.close));
172
- const shutdownDeferred = yield* makeShutdownDeferred;
173
- ctxValueRef.current.componentScope = componentScope;
174
- ctxValueRef.current.shutdownDeferred = shutdownDeferred;
175
- yield* Effect.gen(function* () {
176
- const store = yield* createStore({
177
- schema,
178
- storeId,
179
- adapter,
180
- shutdownDeferred,
181
- ...omitUndefineds({
182
- boot,
183
- batchUpdates,
184
- disableDevtools,
185
- context,
186
- params,
187
- confirmUnsavedChanges,
188
- syncPayload,
189
- syncPayloadSchema,
190
- }),
191
- onBootStatus: (status) => {
192
- if (ctxValueRef.current.value.stage === 'running' || ctxValueRef.current.value.stage === 'error')
193
- return;
194
- // NOTE sometimes when status come in in rapid succession, only the last value will be rendered by React
195
- setContextValue(status);
196
- },
197
- debug: { ...omitUndefineds({ instanceId: debugInstanceId }) },
198
- }).pipe(Effect.tapErrorCause((cause) => Deferred.failCause(shutdownDeferred, cause)));
199
- setContextValue({ stage: 'running', store });
200
- }).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope));
201
- const shutdownContext = (cause) => Effect.sync(() => setContextValue({ stage: 'shutdown', cause }));
202
- yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', Cause.pretty(cause))), Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)), Effect.catchTag('InvalidPushError', (cause) => shutdownContext(cause)), Effect.catchTag('InvalidPullError', (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);
203
- }).pipe(Effect.scoped, Effect.withSpan('@livestore/react:useCreateStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel(omitUndefineds({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer })), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), LogConfig.withLoggerConfig({ logger, logLevel }, { threadName: 'window' }), Effect.runCallback);
204
- return () => {
205
- cancel();
206
- if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
207
- interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'unmounting component' }));
208
- ctxValueRef.current.componentScope = undefined;
209
- ctxValueRef.current.shutdownDeferred = undefined;
210
- }
211
- };
212
- }, [
213
- schema,
214
- otelOptions,
215
- boot,
216
- adapter,
217
- batchUpdates,
218
- disableDevtools,
219
- signal,
220
- storeId,
221
- context,
222
- params,
223
- confirmUnsavedChanges,
224
- syncPayload,
225
- syncPayloadSchema,
226
- debugInstanceId,
227
- interrupt,
228
- logger,
229
- logLevel,
230
- ]);
231
- return ctxValueRef.current.value;
232
- };
233
- //# sourceMappingURL=LiveStoreProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE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,CAAC;gBAC3G,SAAS,CACP,WAAW,CAAC,OAAO,CAAC,cAAc,EAClC,WAAW,CAAC,OAAO,CAAC,gBAAgB,EACpC,IAAI,gBAAgB,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,iBAAiB;QACjB,eAAe;QACf,SAAS;QACT,MAAM;QACN,QAAQ;KACT,CAAC,CAAA;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;AAClC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LiveStoreProvider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiveStoreProvider.test.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.test.tsx"],"names":[],"mappings":""}
@@ -1,117 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /** biome-ignore-all lint/a11y: test files need a11y disabled */
3
- import { makeInMemoryAdapter } from '@livestore/adapter-web';
4
- import { queryDb, StoreInternalsSymbol } from '@livestore/livestore';
5
- import { Schema } from '@livestore/utils/effect';
6
- import * as ReactTesting from '@testing-library/react';
7
- import React from 'react';
8
- import { unstable_batchedUpdates as batchUpdates } from 'react-dom';
9
- import { describe, expect, it } from 'vitest';
10
- import { events, schema, tables } from "./__tests__/fixture.js";
11
- import { LiveStoreProvider } from "./LiveStoreProvider.js";
12
- import * as LiveStoreReact from "./mod.js";
13
- describe.each([true, false])('LiveStoreProvider (strictMode: %s)', (strictMode) => {
14
- const WithStrictMode = strictMode ? React.StrictMode : React.Fragment;
15
- it('simple', async () => {
16
- let appRenderCount = 0;
17
- const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
18
- const App = () => {
19
- appRenderCount++;
20
- const { store } = LiveStoreReact.useStore();
21
- const todos = store.useQuery(allTodos$);
22
- return _jsx("div", { children: JSON.stringify(todos) });
23
- };
24
- const abortController = new AbortController();
25
- const Root = ({ forceUpdate }) => {
26
- const bootCb = React.useCallback((store) => store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false })), []);
27
- // biome-ignore lint/correctness/useExhaustiveDependencies: forceUpdate is used to force a re-render
28
- const adapterMemo = React.useMemo(() => makeInMemoryAdapter(), [forceUpdate]);
29
- 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, {}) }) }));
30
- };
31
- const { rerender } = ReactTesting.render(_jsx(Root, { forceUpdate: 1 }));
32
- expect(appRenderCount).toBe(0);
33
- await ReactTesting.waitForElementToBeRemoved(() => ReactTesting.screen.getByText((_) => _.startsWith('Loading LiveStore')));
34
- expect(appRenderCount).toBe(strictMode ? 2 : 1);
35
- rerender(_jsx(Root, { forceUpdate: 2 }));
36
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText('Loading LiveStore: loading'));
37
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText((_) => _.includes('buy milk')));
38
- expect(appRenderCount).toBe(strictMode ? 4 : 2);
39
- abortController.abort();
40
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText('LiveStore Shutdown due to interrupted', { exact: false }));
41
- });
42
- // TODO test aborting during boot
43
- it('error during boot', async () => {
44
- let appRenderCount = 0;
45
- const App = () => {
46
- appRenderCount++;
47
- return _jsx("div", { children: "hello world" });
48
- };
49
- const Root = ({ forceUpdate }) => {
50
- const bootCb = React.useCallback((_store) => {
51
- // This should trigger an error because we're trying to insert invalid data
52
- throw new Error('Simulated boot error');
53
- }, []);
54
- // biome-ignore lint/correctness/useExhaustiveDependencies: forceUpdate is used to force a re-render
55
- const adapterMemo = React.useMemo(() => makeInMemoryAdapter(), [forceUpdate]);
56
- 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, {}) }) }));
57
- };
58
- ReactTesting.render(_jsx(Root, { forceUpdate: 1 }));
59
- expect(appRenderCount).toBe(0);
60
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText((_) => _.startsWith('LiveStore.UnknownError')));
61
- });
62
- it('unmounts when store is shutdown', async () => {
63
- let appRenderCount = 0;
64
- const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
65
- const shutdownDeferred = Promise.withResolvers();
66
- const App = () => {
67
- appRenderCount++;
68
- const { store } = LiveStoreReact.useStore();
69
- React.useEffect(() => {
70
- shutdownDeferred.promise.then(() => {
71
- console.log('shutdown');
72
- return store.shutdown();
73
- });
74
- }, [store]);
75
- const todos = store.useQuery(allTodos$);
76
- return _jsx("div", { children: JSON.stringify(todos) });
77
- };
78
- const adapter = makeInMemoryAdapter();
79
- const Root = () => {
80
- return (_jsx(WithStrictMode, { children: _jsx(LiveStoreProvider, { schema: schema, renderLoading: (status) => _jsxs("div", { children: ["Loading LiveStore: ", status.stage] }), adapter: adapter, batchUpdates: batchUpdates, children: _jsx(App, {}) }) }));
81
- };
82
- ReactTesting.render(_jsx(Root, {}));
83
- expect(appRenderCount).toBe(0);
84
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText('[]'));
85
- React.act(() => shutdownDeferred.resolve());
86
- expect(appRenderCount).toBe(strictMode ? 2 : 1);
87
- await ReactTesting.waitFor(() => ReactTesting.screen.getByText('LiveStore Shutdown due to manual shutdown', { exact: false }));
88
- });
89
- });
90
- it('should work two stores with the same storeId', async () => {
91
- const allTodos$ = queryDb({ query: `select * from todos`, schema: Schema.Array(tables.todos.rowSchema) });
92
- const appRenderCount = {
93
- store1: 0,
94
- store2: 0,
95
- };
96
- const App = () => {
97
- const { store } = LiveStoreReact.useStore();
98
- const instanceId = store[StoreInternalsSymbol].clientSession.debugInstanceId;
99
- appRenderCount[instanceId]++;
100
- const todos = store.useQuery(allTodos$);
101
- 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] })] }));
102
- };
103
- const Root = () => {
104
- const storeId = 'fixed-store-id';
105
- 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, {}) })] }));
106
- };
107
- const { container } = ReactTesting.render(_jsx(Root, {}));
108
- await ReactTesting.waitFor(() => ReactTesting.screen.getByRole('heading', { name: 'store1' }));
109
- await ReactTesting.waitFor(() => ReactTesting.screen.getByRole('heading', { name: 'store2' }));
110
- expect(appRenderCount.store1).toBe(1);
111
- expect(appRenderCount.store2).toBe(1);
112
- ReactTesting.fireEvent.click(ReactTesting.screen.getByText('create todo store1'));
113
- expect(appRenderCount.store1).toBe(2);
114
- expect(container.querySelector('#store1 > div[role="content"]')?.textContent).toBe('[{"id":"t1","text":"buy milk","completed":false}]');
115
- expect(container.querySelector('#store2 > div[role="content"]')?.textContent).toBe('[]');
116
- });
117
- //# sourceMappingURL=LiveStoreProvider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AC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAEjF,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAErC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,+BAA+B,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAChF,mDAAmD,CACpD,CAAA;IAED,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,+BAA+B,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1F,CAAC,CAAC,CAAA"}
@@ -1,105 +0,0 @@
1
- import { UnknownError } from '@livestore/common';
2
- import type { LiveStoreSchema } from '@livestore/common/schema';
3
- import { type Store } from '@livestore/livestore';
4
- import { Effect, type OtelTracer, Runtime, type Scope } from '@livestore/utils/effect';
5
- import type { CachedStoreOptions } from './types.ts';
6
- type DefaultStoreOptions = Partial<Pick<CachedStoreOptions, 'batchUpdates' | 'disableDevtools' | 'confirmUnsavedChanges' | 'syncPayload' | 'debug' | 'otelOptions'>> & {
7
- /**
8
- * The time in milliseconds that unused stores remain in memory.
9
- * When a store becomes unused (no active retentions), it will be disposed
10
- * after this duration.
11
- *
12
- * Stores transition to the unused state as soon as they have no
13
- * active retentions, so when all components which use that store
14
- * have unmounted.
15
- *
16
- * @remarks
17
- * - If set to `Infinity`, will disable disposal
18
- * - The maximum allowed time is about {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value | 24 days}
19
- *
20
- * @defaultValue `60_000` (60 seconds) or `Infinity` during SSR to avoid
21
- * disposing stores before server render completes.
22
- */
23
- unusedCacheTime?: number;
24
- /**
25
- * Optionally, pass a custom runtime that will be used to run all operations (loading, caching, etc.).
26
- */
27
- runtime?: Runtime.Runtime<Scope.Scope | OtelTracer.OtelTracer>;
28
- };
29
- /**
30
- * Store Registry coordinating store loading, caching, and retention
31
- *
32
- * @public
33
- */
34
- export declare class StoreRegistry {
35
- #private;
36
- /**
37
- * Creates a new StoreRegistry instance.
38
- *
39
- * @param params.defaultOptions - Default options applied to all stores managed by this registry when they are loaded.
40
- *
41
- * @example
42
- * ```ts
43
- * const registry = new StoreRegistry({
44
- * defaultOptions: {
45
- * batchUpdates,
46
- * unusedCacheTime: 30_000,
47
- * }
48
- * })
49
- * ```
50
- */
51
- constructor(params?: {
52
- defaultOptions?: DefaultStoreOptions;
53
- });
54
- /**
55
- * Gets a cached store or loads a new one, with the store lifetime scoped to the caller.
56
- *
57
- * @typeParam TSchema - The schema type for the store
58
- * @returns An Effect that yields the store, scoped to the provided Scope
59
- *
60
- * @remarks
61
- * - Stores are kept in cache and reused while any scope holds them
62
- * - When the scope closes, the reference is released; the store is disposed after `unusedCacheTime`
63
- * if no other scopes retain it
64
- * - Concurrent calls with the same storeId share the same store instance
65
- */
66
- getOrLoad: <TSchema extends LiveStoreSchema>(options: CachedStoreOptions<TSchema>) => Effect.Effect<Store<TSchema>, UnknownError, Scope.Scope>;
67
- /**
68
- * Get or load a store, returning it directly if already loaded or a promise if loading.
69
- *
70
- * @typeParam TSchema - The schema type for the store
71
- * @returns The loaded store if available, or a Promise that resolves to the loaded store
72
- * @throws unknown loading error
73
- *
74
- * @remarks
75
- * - Returns the store instance directly (synchronous) when already loaded
76
- * - Returns a stable Promise reference when loading is in progress or needs to be initiated
77
- * - Throws with the same error instance on subsequent calls after failure
78
- * - Applies default options from registry config, with call-site options taking precedence
79
- * - Concurrent calls with the same storeId share the same store instance
80
- */
81
- getOrLoadPromise: <TSchema extends LiveStoreSchema>(options: CachedStoreOptions<TSchema>) => Store<TSchema> | Promise<Store<TSchema>>;
82
- /**
83
- * Retains the store in cache until the returned release function is called.
84
- *
85
- * @returns A release function that, when called, removes this retention hold
86
- *
87
- * @remarks
88
- * - Multiple retains on the same store are independent; each must be released separately
89
- * - If the store isn't cached yet, it will be loaded and then retained
90
- */
91
- retain: (options: CachedStoreOptions<any>) => (() => void);
92
- /**
93
- * Warms the cache for a store without adding a retention.
94
- *
95
- * @typeParam TSchema - The schema of the store to preload
96
- * @returns A promise that resolves when the loading is complete (success or failure)
97
- *
98
- * @remarks
99
- * - We don't return the store or throw as this is a fire-and-forget operation.
100
- * - If the entry remains unused after preload resolves/rejects, it is scheduled for disposal.
101
- */
102
- preload: <TSchema extends LiveStoreSchema>(options: CachedStoreOptions<TSchema>) => Promise<void>;
103
- }
104
- export {};
105
- //# sourceMappingURL=StoreRegistry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StoreRegistry.d.ts","sourceRoot":"","sources":["../../../src/experimental/multi-store/StoreRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAEL,MAAM,EAON,KAAK,UAAU,EAEf,OAAO,EACP,KAAK,KAAK,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAYpD,KAAK,mBAAmB,GAAG,OAAO,CAChC,IAAI,CACF,kBAAkB,EAClB,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,aAAa,GAAG,OAAO,GAAG,aAAa,CACvG,CACF,GAAG;IACF;;;;;;;;;;;;;;;OAeG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;CAC/D,CAAA;AAkCD;;;;GAIG;AACH,qBAAa,aAAa;;IAmBxB;;;;;;;;;;;;;;OAcG;gBACS,MAAM,GAAE;QAAE,cAAc,CAAC,EAAE,mBAAmB,CAAA;KAAO;IAkBjE;;;;;;;;;;;OAWG;IACH,SAAS,GAAI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