@livestore/livestore 0.0.58-dev.9 → 0.1.0-dev.2

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 (191) hide show
  1. package/README.md +1 -117
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/effect/LiveStore.d.ts +6 -6
  4. package/dist/effect/LiveStore.d.ts.map +1 -1
  5. package/dist/effect/LiveStore.js +1 -1
  6. package/dist/effect/LiveStore.js.map +1 -1
  7. package/dist/global-state.d.ts.map +1 -1
  8. package/dist/global-state.js +2 -1
  9. package/dist/global-state.js.map +1 -1
  10. package/dist/index.d.ts +11 -8
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/reactiveQueries/base-class.d.ts +5 -4
  15. package/dist/reactiveQueries/base-class.d.ts.map +1 -1
  16. package/dist/reactiveQueries/base-class.js.map +1 -1
  17. package/dist/reactiveQueries/computed.d.ts +35 -0
  18. package/dist/reactiveQueries/computed.d.ts.map +1 -0
  19. package/dist/reactiveQueries/computed.js +57 -0
  20. package/dist/reactiveQueries/computed.js.map +1 -0
  21. package/dist/reactiveQueries/graphql.d.ts +2 -1
  22. package/dist/reactiveQueries/graphql.d.ts.map +1 -1
  23. package/dist/reactiveQueries/graphql.js.map +1 -1
  24. package/dist/reactiveQueries/sql.d.ts +2 -2
  25. package/dist/reactiveQueries/sql.d.ts.map +1 -1
  26. package/dist/reactiveQueries/sql.js +3 -3
  27. package/dist/reactiveQueries/sql.js.map +1 -1
  28. package/dist/reactiveQueries/sql.test.js +2 -2
  29. package/dist/reactiveQueries/sql.test.js.map +1 -1
  30. package/dist/row-query.d.ts +3 -2
  31. package/dist/row-query.d.ts.map +1 -1
  32. package/dist/row-query.js +14 -10
  33. package/dist/row-query.js.map +1 -1
  34. package/dist/store/create-store.d.ts +28 -0
  35. package/dist/store/create-store.d.ts.map +1 -0
  36. package/dist/store/create-store.js +85 -0
  37. package/dist/store/create-store.js.map +1 -0
  38. package/dist/store/devtools.d.ts +19 -0
  39. package/dist/store/devtools.d.ts.map +1 -0
  40. package/dist/store/devtools.js +141 -0
  41. package/dist/store/devtools.js.map +1 -0
  42. package/dist/store/store-context.d.ts +26 -0
  43. package/dist/store/store-context.d.ts.map +1 -0
  44. package/dist/store/store-context.js +6 -0
  45. package/dist/store/store-context.js.map +1 -0
  46. package/dist/store/store-types.d.ts +98 -0
  47. package/dist/store/store-types.d.ts.map +1 -0
  48. package/dist/store/store-types.js +6 -0
  49. package/dist/store/store-types.js.map +1 -0
  50. package/dist/store/store.d.ts +88 -0
  51. package/dist/store/store.d.ts.map +1 -0
  52. package/dist/store/store.js +367 -0
  53. package/dist/store/store.js.map +1 -0
  54. package/dist/store-devtools.d.ts +2 -2
  55. package/dist/store-devtools.d.ts.map +1 -1
  56. package/dist/store-devtools.js +2 -2
  57. package/dist/store-devtools.js.map +1 -1
  58. package/dist/store.d.ts +8 -8
  59. package/dist/store.d.ts.map +1 -1
  60. package/dist/store.js +54 -54
  61. package/dist/store.js.map +1 -1
  62. package/dist/utils/dev.d.ts +1 -0
  63. package/dist/utils/dev.d.ts.map +1 -1
  64. package/dist/utils/dev.js +5 -0
  65. package/dist/utils/dev.js.map +1 -1
  66. package/dist/{react/utils → utils}/stack-info.d.ts +1 -2
  67. package/dist/utils/stack-info.d.ts.map +1 -0
  68. package/dist/{react/utils → utils}/stack-info.js +1 -9
  69. package/dist/utils/stack-info.js.map +1 -0
  70. package/dist/utils/stack-info.test.d.ts.map +1 -0
  71. package/dist/{__tests__/react/utils → utils}/stack-info.test.js +1 -1
  72. package/dist/utils/stack-info.test.js.map +1 -0
  73. package/dist/utils/tests/fixture.d.ts +259 -0
  74. package/dist/utils/tests/fixture.d.ts.map +1 -0
  75. package/dist/utils/tests/fixture.js +32 -0
  76. package/dist/utils/tests/fixture.js.map +1 -0
  77. package/dist/utils/tests/mod.d.ts +3 -0
  78. package/dist/utils/tests/mod.d.ts.map +1 -0
  79. package/dist/utils/tests/mod.js +3 -0
  80. package/dist/utils/tests/mod.js.map +1 -0
  81. package/dist/utils/tests/otel.d.ts.map +1 -0
  82. package/dist/{__tests__/react/utils → utils/tests}/otel.js +3 -3
  83. package/dist/utils/tests/otel.js.map +1 -0
  84. package/package.json +13 -20
  85. package/src/ambient.d.ts +3 -1
  86. package/src/effect/LiveStore.ts +7 -7
  87. package/src/global-state.ts +5 -1
  88. package/src/index.ts +19 -7
  89. package/src/reactiveQueries/base-class.ts +5 -4
  90. package/src/reactiveQueries/{js.ts → computed.ts} +3 -3
  91. package/src/reactiveQueries/graphql.ts +2 -1
  92. package/src/reactiveQueries/sql.test.ts +2 -2
  93. package/src/reactiveQueries/sql.ts +5 -5
  94. package/src/row-query.ts +33 -17
  95. package/src/store/create-store.ts +214 -0
  96. package/src/{store-devtools.ts → store/devtools.ts} +9 -9
  97. package/src/store/store-types.ts +110 -0
  98. package/src/{store.ts → store/store.ts} +56 -415
  99. package/src/utils/dev.ts +6 -0
  100. package/src/{__tests__/react/utils → utils}/stack-info.test.ts +1 -1
  101. package/src/{react/utils → utils}/stack-info.ts +2 -12
  102. package/src/utils/tests/fixture.ts +73 -0
  103. package/src/utils/tests/mod.ts +2 -0
  104. package/src/{__tests__/react/utils → utils/tests}/otel.ts +4 -4
  105. package/tsconfig.json +1 -2
  106. package/vitest.config.js +0 -8
  107. package/dist/__tests__/react/fixture.d.ts +0 -461
  108. package/dist/__tests__/react/fixture.d.ts.map +0 -1
  109. package/dist/__tests__/react/fixture.js +0 -68
  110. package/dist/__tests__/react/fixture.js.map +0 -1
  111. package/dist/__tests__/react/utils/otel.d.ts.map +0 -1
  112. package/dist/__tests__/react/utils/otel.js.map +0 -1
  113. package/dist/__tests__/react/utils/stack-info.test.d.ts.map +0 -1
  114. package/dist/__tests__/react/utils/stack-info.test.js.map +0 -1
  115. package/dist/react/LiveStoreContext.d.ts +0 -7
  116. package/dist/react/LiveStoreContext.d.ts.map +0 -1
  117. package/dist/react/LiveStoreContext.js +0 -13
  118. package/dist/react/LiveStoreContext.js.map +0 -1
  119. package/dist/react/LiveStoreProvider.d.ts +0 -49
  120. package/dist/react/LiveStoreProvider.d.ts.map +0 -1
  121. package/dist/react/LiveStoreProvider.js +0 -169
  122. package/dist/react/LiveStoreProvider.js.map +0 -1
  123. package/dist/react/LiveStoreProvider.test.d.ts +0 -2
  124. package/dist/react/LiveStoreProvider.test.d.ts.map +0 -1
  125. package/dist/react/LiveStoreProvider.test.js +0 -62
  126. package/dist/react/LiveStoreProvider.test.js.map +0 -1
  127. package/dist/react/components/LiveList.d.ts +0 -21
  128. package/dist/react/components/LiveList.d.ts.map +0 -1
  129. package/dist/react/components/LiveList.js +0 -31
  130. package/dist/react/components/LiveList.js.map +0 -1
  131. package/dist/react/index.d.ts +0 -11
  132. package/dist/react/index.d.ts.map +0 -1
  133. package/dist/react/index.js +0 -10
  134. package/dist/react/index.js.map +0 -1
  135. package/dist/react/useAtom.d.ts +0 -10
  136. package/dist/react/useAtom.d.ts.map +0 -1
  137. package/dist/react/useAtom.js +0 -37
  138. package/dist/react/useAtom.js.map +0 -1
  139. package/dist/react/useLocalId.d.ts +0 -10
  140. package/dist/react/useLocalId.d.ts.map +0 -1
  141. package/dist/react/useLocalId.js +0 -22
  142. package/dist/react/useLocalId.js.map +0 -1
  143. package/dist/react/useQuery.d.ts +0 -9
  144. package/dist/react/useQuery.d.ts.map +0 -1
  145. package/dist/react/useQuery.js +0 -70
  146. package/dist/react/useQuery.js.map +0 -1
  147. package/dist/react/useQuery.test.d.ts +0 -2
  148. package/dist/react/useQuery.test.d.ts.map +0 -1
  149. package/dist/react/useQuery.test.js +0 -51
  150. package/dist/react/useQuery.test.js.map +0 -1
  151. package/dist/react/useRow.d.ts +0 -46
  152. package/dist/react/useRow.d.ts.map +0 -1
  153. package/dist/react/useRow.js +0 -94
  154. package/dist/react/useRow.js.map +0 -1
  155. package/dist/react/useRow.test.d.ts +0 -2
  156. package/dist/react/useRow.test.d.ts.map +0 -1
  157. package/dist/react/useRow.test.js +0 -208
  158. package/dist/react/useRow.test.js.map +0 -1
  159. package/dist/react/useTemporaryQuery.d.ts +0 -22
  160. package/dist/react/useTemporaryQuery.d.ts.map +0 -1
  161. package/dist/react/useTemporaryQuery.js +0 -75
  162. package/dist/react/useTemporaryQuery.js.map +0 -1
  163. package/dist/react/useTemporaryQuery.test.d.ts +0 -2
  164. package/dist/react/useTemporaryQuery.test.d.ts.map +0 -1
  165. package/dist/react/useTemporaryQuery.test.js +0 -59
  166. package/dist/react/useTemporaryQuery.test.js.map +0 -1
  167. package/dist/react/utils/stack-info.d.ts.map +0 -1
  168. package/dist/react/utils/stack-info.js.map +0 -1
  169. package/dist/react/utils/useStateRefWithReactiveInput.d.ts +0 -13
  170. package/dist/react/utils/useStateRefWithReactiveInput.d.ts.map +0 -1
  171. package/dist/react/utils/useStateRefWithReactiveInput.js +0 -38
  172. package/dist/react/utils/useStateRefWithReactiveInput.js.map +0 -1
  173. package/src/__tests__/react/fixture.tsx +0 -126
  174. package/src/react/LiveStoreContext.ts +0 -20
  175. package/src/react/LiveStoreProvider.test.tsx +0 -109
  176. package/src/react/LiveStoreProvider.tsx +0 -291
  177. package/src/react/__snapshots__/useRow.test.tsx.snap +0 -359
  178. package/src/react/components/LiveList.tsx +0 -84
  179. package/src/react/index.ts +0 -19
  180. package/src/react/useAtom.ts +0 -55
  181. package/src/react/useLocalId.ts +0 -34
  182. package/src/react/useQuery.test.tsx +0 -82
  183. package/src/react/useQuery.ts +0 -106
  184. package/src/react/useRow.test.tsx +0 -345
  185. package/src/react/useRow.ts +0 -180
  186. package/src/react/useTemporaryQuery.test.tsx +0 -98
  187. package/src/react/useTemporaryQuery.ts +0 -131
  188. package/src/react/utils/useStateRefWithReactiveInput.ts +0 -51
  189. package/src/store-context.ts +0 -23
  190. /package/dist/{__tests__/react/utils → utils}/stack-info.test.d.ts +0 -0
  191. /package/dist/{__tests__/react/utils → utils/tests}/otel.d.ts +0 -0
@@ -0,0 +1,73 @@
1
+ import type { FromInputSchema } from '@livestore/common/schema'
2
+ import type { Store } from '@livestore/livestore'
3
+ import { createStore, DbSchema, globalReactivityGraph, makeReactivityGraph, makeSchema } from '@livestore/livestore'
4
+ import { Effect, FiberSet } from '@livestore/utils/effect'
5
+ import { makeInMemoryAdapter } from '@livestore/web'
6
+ import type * as otel from '@opentelemetry/api'
7
+
8
+ export type Todo = {
9
+ id: string
10
+ text: string
11
+ completed: boolean
12
+ }
13
+
14
+ export type Filter = 'all' | 'active' | 'completed'
15
+
16
+ export type AppState = {
17
+ newTodoText: string
18
+ filter: Filter
19
+ }
20
+
21
+ export const todos = DbSchema.table(
22
+ 'todos',
23
+ {
24
+ id: DbSchema.text({ primaryKey: true }),
25
+ text: DbSchema.text({ default: '', nullable: false }),
26
+ completed: DbSchema.boolean({ default: false, nullable: false }),
27
+ },
28
+ { deriveMutations: true, isSingleton: false },
29
+ )
30
+
31
+ export const app = DbSchema.table(
32
+ 'app',
33
+ {
34
+ id: DbSchema.text({ primaryKey: true, default: 'static' }),
35
+ newTodoText: DbSchema.text({ default: '', nullable: true }),
36
+ filter: DbSchema.text({ default: 'all', nullable: false }),
37
+ },
38
+ { isSingleton: true },
39
+ )
40
+
41
+ export const tables = { todos, app }
42
+ export const schema = makeSchema({ tables })
43
+
44
+ export interface FixtureSchema extends FromInputSchema.DeriveSchema<{ tables: typeof tables }> {}
45
+
46
+ export const makeTodoMvc = ({
47
+ otelTracer,
48
+ otelContext,
49
+ useGlobalReactivityGraph = true,
50
+ }: {
51
+ otelTracer?: otel.Tracer
52
+ otelContext?: otel.Context
53
+ useGlobalReactivityGraph?: boolean
54
+ } = {}) =>
55
+ Effect.gen(function* () {
56
+ const reactivityGraph = useGlobalReactivityGraph ? globalReactivityGraph : makeReactivityGraph()
57
+
58
+ const fiberSet = yield* FiberSet.make()
59
+
60
+ const store: Store<any, FixtureSchema> = yield* createStore({
61
+ schema,
62
+ storeId: 'default',
63
+ adapter: makeInMemoryAdapter(),
64
+ reactivityGraph,
65
+ otelOptions: {
66
+ tracer: otelTracer,
67
+ rootSpanContext: otelContext,
68
+ },
69
+ fiberSet,
70
+ })
71
+
72
+ return { store, reactivityGraph }
73
+ })
@@ -0,0 +1,2 @@
1
+ export * from './fixture.js'
2
+ export * from './otel.js'
@@ -7,7 +7,7 @@ type SimplifiedNestedSpan = { _name: string; attributes: any; children: Simplifi
7
7
  export const getSimplifiedRootSpan = (
8
8
  exporter: InMemorySpanExporter,
9
9
  mapAttributes?: (attributes: Attributes) => Attributes,
10
- ) => {
10
+ ): SimplifiedNestedSpan => {
11
11
  const spans = exporter.getFinishedSpans()
12
12
  const spansMap = new Map<string, NestedSpan>(spans.map((span) => [span.spanContext().spanId, { span, children: [] }]))
13
13
 
@@ -23,14 +23,14 @@ export const getSimplifiedRootSpan = (
23
23
  type NestedSpan = { span: ReadableSpan; children: NestedSpan[] }
24
24
  const rootSpan = spansMap.get(spans.find((_) => _.name === 'test')!.spanContext().spanId)!
25
25
 
26
- const simplifySpan = (span: NestedSpan): SimplifiedNestedSpan =>
26
+ const simplifySpanRec = (span: NestedSpan): SimplifiedNestedSpan =>
27
27
  omitEmpty({
28
28
  _name: span.span.name,
29
29
  attributes: mapAttributesfn(span.span.attributes),
30
30
  children: span.children
31
31
  .filter((_) => _.span.name !== 'createStore')
32
32
  // .sort((a, b) => compareHrTime(a.span.startTime, b.span.startTime))
33
- .map(simplifySpan),
33
+ .map(simplifySpanRec),
34
34
  })
35
35
 
36
36
  // console.dir(
@@ -38,7 +38,7 @@ export const getSimplifiedRootSpan = (
38
38
  // { depth: 10 },
39
39
  // )
40
40
 
41
- return simplifySpan(rootSpan)
41
+ return simplifySpanRec(rootSpan)
42
42
  }
43
43
 
44
44
  // const compareHrTime = (a: [number, number], b: [number, number]) => {
package/tsconfig.json CHANGED
@@ -3,7 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "./dist",
5
5
  "rootDir": "./src",
6
- "jsx": "react",
7
6
  "skipLibCheck": true,
8
7
  "resolveJsonModule": true,
9
8
  // "jsx": "preserve",
@@ -11,7 +10,7 @@
11
10
  },
12
11
  "include": ["./src"],
13
12
  "references": [
14
- { "path": "../../effect-db-schema" },
13
+ { "path": "../db-schema" },
15
14
  { "path": "../common" },
16
15
  { "path": "../web" },
17
16
  { "path": "../utils" }
package/vitest.config.js CHANGED
@@ -1,14 +1,6 @@
1
1
  import { defineConfig } from 'vite'
2
2
 
3
3
  export default defineConfig({
4
- test: {
5
- // Needed for React hook tests
6
- environment: 'jsdom',
7
- },
8
- esbuild: {
9
- // TODO remove once `using` keyword supported OOTB with Vite https://github.com/vitejs/vite/issues/15464#issuecomment-1872485703
10
- target: 'es2020',
11
- },
12
4
  resolve: {
13
5
  alias: {
14
6
  '@livestore/wa-sqlite/dist/wa-sqlite.mjs': '@livestore/wa-sqlite/dist/wa-sqlite.node.mjs',
@@ -1,461 +0,0 @@
1
- import { Effect, Schema as __Schema } from '@livestore/utils/effect';
2
- import type * as otel from '@opentelemetry/api';
3
- import React from 'react';
4
- import { DbSchema } from '../../index.js';
5
- export type Todo = {
6
- id: string;
7
- text: string;
8
- completed: boolean;
9
- };
10
- export type Filter = 'all' | 'active' | 'completed';
11
- export type AppState = {
12
- newTodoText: string;
13
- filter: Filter;
14
- };
15
- export declare const todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"todos", {
16
- id: {
17
- columnType: "text";
18
- schema: __Schema.Schema<string, string, never>;
19
- default: import("effect/Option").None<never>;
20
- nullable: false;
21
- primaryKey: true;
22
- };
23
- text: {
24
- columnType: "text";
25
- schema: __Schema.Schema<string, string, never>;
26
- default: import("effect/Option").Some<"">;
27
- nullable: false;
28
- primaryKey: false;
29
- };
30
- completed: {
31
- columnType: "integer";
32
- schema: __Schema.Schema<boolean, number, never>;
33
- default: import("effect/Option").Some<false>;
34
- nullable: false;
35
- primaryKey: false;
36
- };
37
- }>, false, {
38
- isSingleton: false;
39
- disableAutomaticIdColumn: false;
40
- deriveMutations: {
41
- enabled: true;
42
- localOnly: boolean;
43
- };
44
- isSingleColumn: false;
45
- }, __Schema.Schema<{
46
- readonly id: string;
47
- readonly text: string;
48
- readonly completed: boolean;
49
- }, {
50
- readonly id: string;
51
- readonly text: string;
52
- readonly completed: number;
53
- }, never>>;
54
- export declare const app: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"app", {
55
- id: {
56
- columnType: "text";
57
- schema: __Schema.Schema<string, string, never>;
58
- default: import("effect/Option").None<never>;
59
- nullable: false;
60
- primaryKey: true;
61
- };
62
- newTodoText: {
63
- columnType: "text";
64
- schema: __Schema.Schema<string | null, string | null, never>;
65
- default: import("effect/Option").Some<"">;
66
- nullable: true;
67
- primaryKey: false;
68
- };
69
- filter: {
70
- columnType: "text";
71
- schema: __Schema.Schema<string, string, never>;
72
- default: import("effect/Option").Some<"all">;
73
- nullable: false;
74
- primaryKey: false;
75
- };
76
- }>, false, {
77
- isSingleton: false;
78
- disableAutomaticIdColumn: false;
79
- deriveMutations: never;
80
- isSingleColumn: false;
81
- }, __Schema.Schema<{
82
- readonly id: string;
83
- readonly newTodoText: string | null;
84
- readonly filter: string;
85
- }, {
86
- readonly id: string;
87
- readonly newTodoText: string | null;
88
- readonly filter: string;
89
- }, never>>;
90
- export declare const tables: {
91
- todos: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"todos", {
92
- id: {
93
- columnType: "text";
94
- schema: __Schema.Schema<string, string, never>;
95
- default: import("effect/Option").None<never>;
96
- nullable: false;
97
- primaryKey: true;
98
- };
99
- text: {
100
- columnType: "text";
101
- schema: __Schema.Schema<string, string, never>;
102
- default: import("effect/Option").Some<"">;
103
- nullable: false;
104
- primaryKey: false;
105
- };
106
- completed: {
107
- columnType: "integer";
108
- schema: __Schema.Schema<boolean, number, never>;
109
- default: import("effect/Option").Some<false>;
110
- nullable: false;
111
- primaryKey: false;
112
- };
113
- }>, false, {
114
- isSingleton: false;
115
- disableAutomaticIdColumn: false;
116
- deriveMutations: {
117
- enabled: true;
118
- localOnly: boolean;
119
- };
120
- isSingleColumn: false;
121
- }, __Schema.Schema<{
122
- readonly id: string;
123
- readonly text: string;
124
- readonly completed: boolean;
125
- }, {
126
- readonly id: string;
127
- readonly text: string;
128
- readonly completed: number;
129
- }, never>>;
130
- app: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"app", {
131
- id: {
132
- columnType: "text";
133
- schema: __Schema.Schema<string, string, never>;
134
- default: import("effect/Option").None<never>;
135
- nullable: false;
136
- primaryKey: true;
137
- };
138
- newTodoText: {
139
- columnType: "text";
140
- schema: __Schema.Schema<string | null, string | null, never>;
141
- default: import("effect/Option").Some<"">;
142
- nullable: true;
143
- primaryKey: false;
144
- };
145
- filter: {
146
- columnType: "text";
147
- schema: __Schema.Schema<string, string, never>;
148
- default: import("effect/Option").Some<"all">;
149
- nullable: false;
150
- primaryKey: false;
151
- };
152
- }>, false, {
153
- isSingleton: false;
154
- disableAutomaticIdColumn: false;
155
- deriveMutations: never;
156
- isSingleColumn: false;
157
- }, __Schema.Schema<{
158
- readonly id: string;
159
- readonly newTodoText: string | null;
160
- readonly filter: string;
161
- }, {
162
- readonly id: string;
163
- readonly newTodoText: string | null;
164
- readonly filter: string;
165
- }, never>>;
166
- userInfo: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"UserInfo", {
167
- username: {
168
- columnType: "text";
169
- schema: __Schema.Schema<string, string, never>;
170
- default: import("effect/Option").Some<"">;
171
- nullable: false;
172
- primaryKey: false;
173
- };
174
- text: {
175
- columnType: "text";
176
- schema: __Schema.Schema<string, string, never>;
177
- default: import("effect/Option").Some<"">;
178
- nullable: false;
179
- primaryKey: false;
180
- };
181
- id: DbSchema.SqliteDsl.ColumnDefinition<string, string>;
182
- }>, false, {
183
- isSingleton: false;
184
- disableAutomaticIdColumn: false;
185
- deriveMutations: {
186
- enabled: true;
187
- localOnly: boolean;
188
- };
189
- isSingleColumn: false;
190
- }, __Schema.Schema<{
191
- readonly username: string;
192
- readonly text: string;
193
- readonly id: string;
194
- }, {
195
- readonly username: string;
196
- readonly text: string;
197
- readonly id: string;
198
- }, never>>;
199
- AppRouterSchema: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"AppRouter", {
200
- currentTaskId: {
201
- columnType: "text";
202
- schema: __Schema.Schema<string | null, string | null, never>;
203
- default: import("effect/Option").Some<null>;
204
- nullable: true;
205
- primaryKey: false;
206
- };
207
- id: DbSchema.SqliteDsl.ColumnDefinition<"singleton", "singleton">;
208
- }>, false, {
209
- isSingleton: true;
210
- disableAutomaticIdColumn: false;
211
- deriveMutations: {
212
- enabled: true;
213
- localOnly: boolean;
214
- };
215
- isSingleColumn: false;
216
- }, __Schema.Schema<{
217
- readonly currentTaskId: string | null;
218
- readonly id: "singleton";
219
- }, {
220
- readonly currentTaskId: string | null;
221
- readonly id: "singleton";
222
- }, never>>;
223
- };
224
- export declare const schema: {
225
- readonly _Type: import("@livestore/common/dist/schema/index.js").LiveStoreSchemaSymbol;
226
- readonly _DbSchemaType: {
227
- todos: DbSchema.SqliteDsl.TableDefinition<"todos", {
228
- id: {
229
- columnType: "text";
230
- schema: __Schema.Schema<string, string, never>;
231
- default: import("effect/Option").None<never>;
232
- nullable: false;
233
- primaryKey: true;
234
- };
235
- text: {
236
- columnType: "text";
237
- schema: __Schema.Schema<string, string, never>;
238
- default: import("effect/Option").Some<"">;
239
- nullable: false;
240
- primaryKey: false;
241
- };
242
- completed: {
243
- columnType: "integer";
244
- schema: __Schema.Schema<boolean, number, never>;
245
- default: import("effect/Option").Some<false>;
246
- nullable: false;
247
- primaryKey: false;
248
- };
249
- }>;
250
- app: DbSchema.SqliteDsl.TableDefinition<"app", {
251
- id: {
252
- columnType: "text";
253
- schema: __Schema.Schema<string, string, never>;
254
- default: import("effect/Option").None<never>;
255
- nullable: false;
256
- primaryKey: true;
257
- };
258
- newTodoText: {
259
- columnType: "text";
260
- schema: __Schema.Schema<string | null, string | null, never>;
261
- default: import("effect/Option").Some<"">;
262
- nullable: true;
263
- primaryKey: false;
264
- };
265
- filter: {
266
- columnType: "text";
267
- schema: __Schema.Schema<string, string, never>;
268
- default: import("effect/Option").Some<"all">;
269
- nullable: false;
270
- primaryKey: false;
271
- };
272
- }>;
273
- UserInfo: DbSchema.SqliteDsl.TableDefinition<"UserInfo", {
274
- username: {
275
- columnType: "text";
276
- schema: __Schema.Schema<string, string, never>;
277
- default: import("effect/Option").Some<"">;
278
- nullable: false;
279
- primaryKey: false;
280
- };
281
- text: {
282
- columnType: "text";
283
- schema: __Schema.Schema<string, string, never>;
284
- default: import("effect/Option").Some<"">;
285
- nullable: false;
286
- primaryKey: false;
287
- };
288
- id: DbSchema.SqliteDsl.ColumnDefinition<string, string>;
289
- }>;
290
- AppRouter: DbSchema.SqliteDsl.TableDefinition<"AppRouter", {
291
- currentTaskId: {
292
- columnType: "text";
293
- schema: __Schema.Schema<string | null, string | null, never>;
294
- default: import("effect/Option").Some<null>;
295
- nullable: true;
296
- primaryKey: false;
297
- };
298
- id: DbSchema.SqliteDsl.ColumnDefinition<"singleton", "singleton">;
299
- }>;
300
- };
301
- readonly _MutationDefMapType: never;
302
- readonly tables: Map<string, DbSchema.TableDef>;
303
- readonly mutations: import("@livestore/common/dist/schema/mutations.js").MutationDefMap;
304
- readonly hash: number;
305
- migrationOptions: import("@livestore/common/dist/adapter-types.js").MigrationOptions;
306
- };
307
- export declare const makeTodoMvc: ({ otelTracer, otelContext, useGlobalReactivityGraph, strictMode, }?: {
308
- otelTracer?: otel.Tracer;
309
- otelContext?: otel.Context;
310
- useGlobalReactivityGraph?: boolean;
311
- strictMode?: boolean;
312
- }) => Effect.Effect<{
313
- wrapper: ({ children }: any) => React.JSX.Element;
314
- AppComponentSchema: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"UserInfo", {
315
- username: {
316
- columnType: "text";
317
- schema: __Schema.Schema<string, string, never>;
318
- default: import("effect/Option").Some<"">;
319
- nullable: false;
320
- primaryKey: false;
321
- };
322
- text: {
323
- columnType: "text";
324
- schema: __Schema.Schema<string, string, never>;
325
- default: import("effect/Option").Some<"">;
326
- nullable: false;
327
- primaryKey: false;
328
- };
329
- id: DbSchema.SqliteDsl.ColumnDefinition<string, string>;
330
- }>, false, {
331
- isSingleton: false;
332
- disableAutomaticIdColumn: false;
333
- deriveMutations: {
334
- enabled: true;
335
- localOnly: boolean;
336
- };
337
- isSingleColumn: false;
338
- }, __Schema.Schema<{
339
- readonly username: string;
340
- readonly text: string;
341
- readonly id: string;
342
- }, {
343
- readonly username: string;
344
- readonly text: string;
345
- readonly id: string;
346
- }, never>>;
347
- AppRouterSchema: DbSchema.TableDef<DbSchema.SqliteDsl.TableDefinition<"AppRouter", {
348
- currentTaskId: {
349
- columnType: "text";
350
- schema: __Schema.Schema<string | null, string | null, never>;
351
- default: import("effect/Option").Some<null>;
352
- nullable: true;
353
- primaryKey: false;
354
- };
355
- id: DbSchema.SqliteDsl.ColumnDefinition<"singleton", "singleton">;
356
- }>, false, {
357
- isSingleton: true;
358
- disableAutomaticIdColumn: false;
359
- deriveMutations: {
360
- enabled: true;
361
- localOnly: boolean;
362
- };
363
- isSingleColumn: false;
364
- }, __Schema.Schema<{
365
- readonly currentTaskId: string | null;
366
- readonly id: "singleton";
367
- }, {
368
- readonly currentTaskId: string | null;
369
- readonly id: "singleton";
370
- }, never>>;
371
- store: import("../../store.js").Store<import("../../store.js").BaseGraphQLContext, {
372
- readonly _Type: import("@livestore/common/dist/schema/index.js").LiveStoreSchemaSymbol;
373
- readonly _DbSchemaType: {
374
- todos: DbSchema.SqliteDsl.TableDefinition<"todos", {
375
- id: {
376
- columnType: "text";
377
- schema: __Schema.Schema<string, string, never>;
378
- default: import("effect/Option").None<never>;
379
- nullable: false;
380
- primaryKey: true;
381
- };
382
- text: {
383
- columnType: "text";
384
- schema: __Schema.Schema<string, string, never>;
385
- default: import("effect/Option").Some<"">;
386
- nullable: false;
387
- primaryKey: false;
388
- };
389
- completed: {
390
- columnType: "integer";
391
- schema: __Schema.Schema<boolean, number, never>;
392
- default: import("effect/Option").Some<false>;
393
- nullable: false;
394
- primaryKey: false;
395
- };
396
- }>;
397
- app: DbSchema.SqliteDsl.TableDefinition<"app", {
398
- id: {
399
- columnType: "text";
400
- schema: __Schema.Schema<string, string, never>;
401
- default: import("effect/Option").None<never>;
402
- nullable: false;
403
- primaryKey: true;
404
- };
405
- newTodoText: {
406
- columnType: "text";
407
- schema: __Schema.Schema<string | null, string | null, never>;
408
- default: import("effect/Option").Some<"">;
409
- nullable: true;
410
- primaryKey: false;
411
- };
412
- filter: {
413
- columnType: "text";
414
- schema: __Schema.Schema<string, string, never>;
415
- default: import("effect/Option").Some<"all">;
416
- nullable: false;
417
- primaryKey: false;
418
- };
419
- }>;
420
- UserInfo: DbSchema.SqliteDsl.TableDefinition<"UserInfo", {
421
- username: {
422
- columnType: "text";
423
- schema: __Schema.Schema<string, string, never>;
424
- default: import("effect/Option").Some<"">;
425
- nullable: false;
426
- primaryKey: false;
427
- };
428
- text: {
429
- columnType: "text";
430
- schema: __Schema.Schema<string, string, never>;
431
- default: import("effect/Option").Some<"">;
432
- nullable: false;
433
- primaryKey: false;
434
- };
435
- id: DbSchema.SqliteDsl.ColumnDefinition<string, string>;
436
- }>;
437
- AppRouter: DbSchema.SqliteDsl.TableDefinition<"AppRouter", {
438
- currentTaskId: {
439
- columnType: "text";
440
- schema: __Schema.Schema<string | null, string | null, never>;
441
- default: import("effect/Option").Some<null>;
442
- nullable: true;
443
- primaryKey: false;
444
- };
445
- id: DbSchema.SqliteDsl.ColumnDefinition<"singleton", "singleton">;
446
- }>;
447
- };
448
- readonly _MutationDefMapType: never;
449
- readonly tables: Map<string, DbSchema.TableDef>;
450
- readonly mutations: import("@livestore/common/dist/schema/mutations.js").MutationDefMap;
451
- readonly hash: number;
452
- migrationOptions: import("@livestore/common/dist/adapter-types.js").MigrationOptions;
453
- }>;
454
- reactivityGraph: import("../../index.js").ReactivityGraph;
455
- makeRenderCount: () => {
456
- readonly val: number;
457
- inc: () => void;
458
- };
459
- strictMode: boolean;
460
- }, import("@livestore/common/dist/adapter-types.js").UnexpectedError, import("effect/Scope").Scope>;
461
- //# sourceMappingURL=fixture.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAE9E,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAe,QAAQ,EAAwC,MAAM,gBAAgB,CAAA;AAG5F,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEnD,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQjB,CAAA;AAED,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAId,CAAA;AAmBF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA4C,CAAA;AAC/D,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAyB,CAAA;AAE5C,eAAO,MAAM,WAAW,wEAKrB;IACD,UAAU,CAAC,EAAE,IAAI,CAAC,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAA;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;4BAuCkC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGAiBlC,CAAA"}
@@ -1,68 +0,0 @@
1
- import { Effect, FiberSet } from '@livestore/utils/effect';
2
- import { makeInMemoryAdapter } from '@livestore/web';
3
- import React from 'react';
4
- import { globalReactivityGraph } from '../../global-state.js';
5
- import { createStore, DbSchema, makeReactivityGraph, makeSchema, sql } from '../../index.js';
6
- import * as LiveStoreReact from '../../react/index.js';
7
- export const todos = DbSchema.table('todos', {
8
- id: DbSchema.text({ primaryKey: true }),
9
- text: DbSchema.text({ default: '', nullable: false }),
10
- completed: DbSchema.boolean({ default: false, nullable: false }),
11
- }, { deriveMutations: true, isSingleton: false });
12
- export const app = DbSchema.table('app', {
13
- id: DbSchema.text({ primaryKey: true }),
14
- newTodoText: DbSchema.text({ default: '', nullable: true }),
15
- filter: DbSchema.text({ default: 'all', nullable: false }),
16
- });
17
- const userInfo = DbSchema.table('UserInfo', {
18
- username: DbSchema.text({ default: '' }),
19
- text: DbSchema.text({ default: '' }),
20
- }, { deriveMutations: true });
21
- const AppRouterSchema = DbSchema.table('AppRouter', {
22
- currentTaskId: DbSchema.text({ default: null, nullable: true }),
23
- }, { isSingleton: true, deriveMutations: true });
24
- export const tables = { todos, app, userInfo, AppRouterSchema };
25
- export const schema = makeSchema({ tables });
26
- export const makeTodoMvc = ({ otelTracer, otelContext, useGlobalReactivityGraph = true, strictMode = process.env.REACT_STRICT_MODE !== undefined, } = {}) => Effect.gen(function* () {
27
- const reactivityGraph = useGlobalReactivityGraph ? globalReactivityGraph : makeReactivityGraph();
28
- const makeRenderCount = () => {
29
- let val = 0;
30
- const inc = () => {
31
- val += strictMode ? 0.5 : 1;
32
- };
33
- return {
34
- get val() {
35
- return val;
36
- },
37
- inc,
38
- };
39
- };
40
- const fiberSet = yield* FiberSet.make();
41
- const store = yield* createStore({
42
- schema,
43
- storeId: 'default',
44
- boot: (db) => db.execute(sql `INSERT OR IGNORE INTO app (id, newTodoText, filter) VALUES ('static', '', 'all');`),
45
- adapter: makeInMemoryAdapter(),
46
- reactivityGraph,
47
- otelOptions: {
48
- tracer: otelTracer,
49
- rootSpanContext: otelContext,
50
- },
51
- fiberSet,
52
- });
53
- // TODO improve typing of `LiveStoreContext`
54
- const storeContext = { stage: 'running', store };
55
- const MaybeStrictMode = strictMode ? React.StrictMode : React.Fragment;
56
- const wrapper = ({ children }) => (React.createElement(MaybeStrictMode, null,
57
- React.createElement(LiveStoreReact.LiveStoreContext.Provider, { value: storeContext }, children)));
58
- return {
59
- wrapper,
60
- AppComponentSchema: userInfo,
61
- AppRouterSchema,
62
- store,
63
- reactivityGraph,
64
- makeRenderCount,
65
- strictMode,
66
- };
67
- });
68
- //# sourceMappingURL=fixture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixture.js","sourceRoot":"","sources":["../../../src/__tests__/react/fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,gBA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