@livestore/solid 0.4.0-dev.21 → 0.4.0-dev.23

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 (94) 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.jsx +60 -0
  5. package/dist/StoreRegistryContext.jsx.map +1 -0
  6. package/dist/__tests__/fixture.d.ts +14 -0
  7. package/dist/__tests__/fixture.d.ts.map +1 -0
  8. package/dist/__tests__/fixture.jsx +13 -0
  9. package/dist/__tests__/fixture.jsx.map +1 -0
  10. package/dist/experimental/components/LiveList.d.ts +24 -0
  11. package/dist/experimental/components/LiveList.d.ts.map +1 -0
  12. package/dist/experimental/components/LiveList.jsx +24 -0
  13. package/dist/experimental/components/LiveList.jsx.map +1 -0
  14. package/dist/experimental/mod.d.ts +2 -0
  15. package/dist/experimental/mod.d.ts.map +1 -0
  16. package/dist/experimental/mod.js +2 -0
  17. package/dist/experimental/mod.js.map +1 -0
  18. package/dist/mod.d.ts +6 -2
  19. package/dist/mod.d.ts.map +1 -1
  20. package/dist/mod.js +4 -2
  21. package/dist/mod.js.map +1 -1
  22. package/dist/useClientDocument.client.test.d.ts +2 -0
  23. package/dist/useClientDocument.client.test.d.ts.map +1 -0
  24. package/dist/useClientDocument.client.test.jsx +177 -0
  25. package/dist/useClientDocument.client.test.jsx.map +1 -0
  26. package/dist/useClientDocument.d.ts +71 -0
  27. package/dist/useClientDocument.d.ts.map +1 -0
  28. package/dist/useClientDocument.js +74 -0
  29. package/dist/useClientDocument.js.map +1 -0
  30. package/dist/useClientDocument.server.test.d.ts +6 -0
  31. package/dist/useClientDocument.server.test.d.ts.map +1 -0
  32. package/dist/useClientDocument.server.test.jsx +76 -0
  33. package/dist/useClientDocument.server.test.jsx.map +1 -0
  34. package/dist/useQuery.client.test.d.ts +2 -0
  35. package/dist/useQuery.client.test.d.ts.map +1 -0
  36. package/dist/useQuery.client.test.jsx +165 -0
  37. package/dist/useQuery.client.test.jsx.map +1 -0
  38. package/dist/useQuery.d.ts +32 -0
  39. package/dist/useQuery.d.ts.map +1 -0
  40. package/dist/useQuery.js +64 -0
  41. package/dist/useQuery.js.map +1 -0
  42. package/dist/useQuery.server.test.d.ts +6 -0
  43. package/dist/useQuery.server.test.d.ts.map +1 -0
  44. package/dist/useQuery.server.test.jsx +88 -0
  45. package/dist/useQuery.server.test.jsx.map +1 -0
  46. package/dist/useStore.client.test.d.ts +2 -0
  47. package/dist/useStore.client.test.d.ts.map +1 -0
  48. package/dist/useStore.client.test.jsx +438 -0
  49. package/dist/useStore.client.test.jsx.map +1 -0
  50. package/dist/useStore.d.ts +91 -0
  51. package/dist/useStore.d.ts.map +1 -0
  52. package/dist/useStore.js +94 -0
  53. package/dist/useStore.js.map +1 -0
  54. package/dist/useStore.server.test.d.ts +6 -0
  55. package/dist/useStore.server.test.d.ts.map +1 -0
  56. package/dist/useStore.server.test.jsx +56 -0
  57. package/dist/useStore.server.test.jsx.map +1 -0
  58. package/dist/utils.d.ts +4 -0
  59. package/dist/utils.d.ts.map +1 -0
  60. package/dist/utils.js +7 -0
  61. package/dist/utils.js.map +1 -0
  62. package/dist/whenever.d.ts +32 -0
  63. package/dist/whenever.d.ts.map +1 -0
  64. package/dist/whenever.js +51 -0
  65. package/dist/whenever.js.map +1 -0
  66. package/package.json +65 -17
  67. package/src/StoreRegistryContext.tsx +70 -0
  68. package/src/__snapshots__/useClientDocument.client.test.tsx.snap +570 -0
  69. package/src/__snapshots__/useQuery.client.test.tsx.snap +1550 -0
  70. package/src/__tests__/fixture.tsx +42 -0
  71. package/src/experimental/components/LiveList.tsx +54 -0
  72. package/src/experimental/mod.ts +1 -0
  73. package/src/mod.ts +6 -2
  74. package/src/useClientDocument.client.test.tsx +299 -0
  75. package/src/useClientDocument.server.test.tsx +107 -0
  76. package/src/useClientDocument.ts +146 -0
  77. package/src/useQuery.client.test.tsx +293 -0
  78. package/src/useQuery.server.test.tsx +128 -0
  79. package/src/useQuery.ts +115 -0
  80. package/src/useStore.client.test.tsx +632 -0
  81. package/src/useStore.server.test.tsx +70 -0
  82. package/src/useStore.ts +179 -0
  83. package/src/utils.ts +10 -0
  84. package/src/whenever.ts +80 -0
  85. package/dist/query.d.ts +0 -4
  86. package/dist/query.d.ts.map +0 -1
  87. package/dist/query.js +0 -15
  88. package/dist/query.js.map +0 -1
  89. package/dist/store.d.ts +0 -6
  90. package/dist/store.d.ts.map +0 -1
  91. package/dist/store.js +0 -99
  92. package/dist/store.js.map +0 -1
  93. package/src/query.ts +0 -22
  94. package/src/store.ts +0 -196
@@ -0,0 +1,570 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`useClientDocument > otel > should update the data based on component key 1`] = `
4
+ {
5
+ "_name": "createStore",
6
+ "attributes": {
7
+ "debugInstanceId": "test",
8
+ "storeId": "default",
9
+ },
10
+ "children": [
11
+ {
12
+ "_name": "makeClientSessionSyncProcessor",
13
+ },
14
+ {
15
+ "_name": "livestore.in-memory-db:execute",
16
+ "attributes": {
17
+ "sql.query": "
18
+ PRAGMA page_size=32768;
19
+ PRAGMA cache_size=10000;
20
+ PRAGMA synchronous='OFF';
21
+ PRAGMA temp_store='MEMORY';
22
+ PRAGMA foreign_keys='ON'; -- we want foreign key constraints to be enforced
23
+ ",
24
+ },
25
+ },
26
+ {
27
+ "_name": "client-session-sync-processor:boot",
28
+ "children": [
29
+ {
30
+ "_name": "client-session-sync-processor:pull",
31
+ "attributes": {
32
+ "code.stacktrace": "<STACKTRACE>",
33
+ "span.label": "⚠︎ Interrupted",
34
+ "status.interrupted": true,
35
+ },
36
+ },
37
+ {
38
+ "_name": "@livestore/common:LeaderSyncProcessor:push",
39
+ "attributes": {
40
+ "batch": "undefined",
41
+ "batchSize": 1,
42
+ },
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ "_name": "LiveStore:commits",
48
+ },
49
+ {
50
+ "_name": "LiveStore:queries",
51
+ "children": [
52
+ {
53
+ "_name": "LiveStore:useClientDocument:UserInfo:u1",
54
+ "attributes": {
55
+ "firstStackInfo": "{"frames":[{"name":"check","filePath":"__REPLACED_FOR_SNAPSHOT__"},{"name":"useClientDocument","filePath":"__REPLACED_FOR_SNAPSHOT__"}]}",
56
+ "label": "SELECT * FROM 'UserInfo' WHERE id = ?",
57
+ },
58
+ "children": [
59
+ {
60
+ "_name": "sql-in-memory-select",
61
+ "attributes": {
62
+ "sql.cached": false,
63
+ "sql.query": "SELECT 1 FROM 'UserInfo' WHERE id = ?",
64
+ "sql.rowsCount": 0,
65
+ },
66
+ },
67
+ {
68
+ "_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
69
+ "attributes": {
70
+ "livestore.debugRefreshReason": "useQuery:initial-run:UserInfo.get:u1",
71
+ "sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
72
+ "sql.rowsCount": 1,
73
+ },
74
+ "children": [
75
+ {
76
+ "_name": "sql-in-memory-select",
77
+ "attributes": {
78
+ "sql.cached": false,
79
+ "sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
80
+ "sql.rowsCount": 1,
81
+ },
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ "_name": "LiveStore.subscribe",
87
+ "attributes": {
88
+ "label": "UserInfo.get:u1",
89
+ "queryLabel": "UserInfo.get:u1",
90
+ },
91
+ "children": [
92
+ {
93
+ "_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
94
+ "attributes": {
95
+ "livestore.debugRefreshReason": "commit",
96
+ "sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
97
+ "sql.rowsCount": 1,
98
+ },
99
+ "children": [
100
+ {
101
+ "_name": "sql-in-memory-select",
102
+ "attributes": {
103
+ "sql.cached": false,
104
+ "sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
105
+ "sql.rowsCount": 1,
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ ],
111
+ },
112
+ ],
113
+ },
114
+ ],
115
+ },
116
+ ],
117
+ }
118
+ `;
119
+
120
+ exports[`useClientDocument > otel > should update the data based on component key 2`] = `
121
+ [
122
+ {
123
+ "_name": "LiveStore:commit",
124
+ "attributes": {
125
+ "livestore.commitLabel": "UserInfo.set:u1",
126
+ "livestore.eventTags": "[
127
+ "UserInfoSet"
128
+ ]",
129
+ "livestore.eventsCount": 1,
130
+ },
131
+ "children": [
132
+ {
133
+ "_name": "client-session-sync-processor:encode-events",
134
+ },
135
+ {
136
+ "_name": "client-session-sync-processor:materialize-events",
137
+ "children": [
138
+ {
139
+ "_name": "client-session-sync-processor:materialize-event",
140
+ "children": [
141
+ {
142
+ "_name": "livestore.in-memory-db:execute",
143
+ "attributes": {
144
+ "sql.query": "
145
+ INSERT INTO 'UserInfo' (id, value)
146
+ VALUES (?, ?)
147
+ ON CONFLICT (id) DO UPDATE SET value = json_set(json_set(value, ?, json(?)), ?, json(?))
148
+ ",
149
+ },
150
+ },
151
+ ],
152
+ },
153
+ ],
154
+ },
155
+ {
156
+ "_name": "client-session-sync-processor:push",
157
+ "attributes": {
158
+ "batchSize": 1,
159
+ "eventCounts": "{
160
+ "UserInfoSet": 1
161
+ }",
162
+ "mergeResultTag": "advance",
163
+ },
164
+ },
165
+ ],
166
+ },
167
+ {
168
+ "_name": "LiveStore:commit",
169
+ "attributes": {
170
+ "livestore.eventTags": "[
171
+ "UserInfoSet"
172
+ ]",
173
+ "livestore.eventsCount": 1,
174
+ },
175
+ "children": [
176
+ {
177
+ "_name": "client-session-sync-processor:encode-events",
178
+ },
179
+ {
180
+ "_name": "client-session-sync-processor:materialize-events",
181
+ "children": [
182
+ {
183
+ "_name": "client-session-sync-processor:materialize-event",
184
+ "children": [
185
+ {
186
+ "_name": "livestore.in-memory-db:execute",
187
+ "attributes": {
188
+ "sql.query": "
189
+ INSERT INTO 'UserInfo' (id, value)
190
+ VALUES (?, ?)
191
+ ON CONFLICT (id) DO UPDATE SET value = json_set(value, ?, json(?))
192
+ ",
193
+ },
194
+ },
195
+ ],
196
+ },
197
+ ],
198
+ },
199
+ {
200
+ "_name": "client-session-sync-processor:push",
201
+ "attributes": {
202
+ "batchSize": 1,
203
+ "eventCounts": "{
204
+ "UserInfoSet": 1
205
+ }",
206
+ "mergeResultTag": "advance",
207
+ },
208
+ },
209
+ ],
210
+ },
211
+ ]
212
+ `;
213
+
214
+ exports[`useClientDocument > should update the data based on component key 1`] = `
215
+ {
216
+ "atoms": [
217
+ {
218
+ "_tag": "ref",
219
+ "id": "node-1",
220
+ "isDestroyed": false,
221
+ "isDirty": false,
222
+ "label": "tableRef:todos",
223
+ "meta": {
224
+ "liveStoreRefType": "table",
225
+ },
226
+ "previousResult": {
227
+ "_tag": "Some",
228
+ "value": "null",
229
+ },
230
+ "refreshes": 0,
231
+ "sub": [],
232
+ "super": [],
233
+ },
234
+ {
235
+ "_tag": "ref",
236
+ "id": "node-2",
237
+ "isDestroyed": false,
238
+ "isDirty": false,
239
+ "label": "tableRef:app",
240
+ "meta": {
241
+ "liveStoreRefType": "table",
242
+ },
243
+ "previousResult": {
244
+ "_tag": "Some",
245
+ "value": "null",
246
+ },
247
+ "refreshes": 0,
248
+ "sub": [],
249
+ "super": [],
250
+ },
251
+ {
252
+ "_tag": "ref",
253
+ "id": "node-3",
254
+ "isDestroyed": false,
255
+ "isDirty": false,
256
+ "label": "tableRef:UserInfo",
257
+ "meta": {
258
+ "liveStoreRefType": "table",
259
+ },
260
+ "previousResult": {
261
+ "_tag": "Some",
262
+ "value": "null",
263
+ },
264
+ "refreshes": 1,
265
+ "sub": [],
266
+ "super": [
267
+ "node-9",
268
+ ],
269
+ },
270
+ {
271
+ "_tag": "ref",
272
+ "id": "node-4",
273
+ "isDestroyed": false,
274
+ "isDirty": false,
275
+ "label": "tableRef:AppRouter",
276
+ "meta": {
277
+ "liveStoreRefType": "table",
278
+ },
279
+ "previousResult": {
280
+ "_tag": "Some",
281
+ "value": "null",
282
+ },
283
+ "refreshes": 0,
284
+ "sub": [],
285
+ "super": [],
286
+ },
287
+ {
288
+ "_tag": "ref",
289
+ "id": "node-5",
290
+ "isDestroyed": false,
291
+ "isDirty": false,
292
+ "label": "tableRef:Kv",
293
+ "meta": {
294
+ "liveStoreRefType": "table",
295
+ },
296
+ "previousResult": {
297
+ "_tag": "Some",
298
+ "value": "null",
299
+ },
300
+ "refreshes": 0,
301
+ "sub": [],
302
+ "super": [],
303
+ },
304
+ {
305
+ "_tag": "ref",
306
+ "id": "node-6",
307
+ "isDestroyed": false,
308
+ "isDirty": false,
309
+ "label": "tableRef:__livestore_schema",
310
+ "meta": {
311
+ "liveStoreRefType": "table",
312
+ },
313
+ "previousResult": {
314
+ "_tag": "Some",
315
+ "value": "null",
316
+ },
317
+ "refreshes": 0,
318
+ "sub": [],
319
+ "super": [],
320
+ },
321
+ {
322
+ "_tag": "ref",
323
+ "id": "node-7",
324
+ "isDestroyed": false,
325
+ "isDirty": false,
326
+ "label": "tableRef:__livestore_schema_event_defs",
327
+ "meta": {
328
+ "liveStoreRefType": "table",
329
+ },
330
+ "previousResult": {
331
+ "_tag": "Some",
332
+ "value": "null",
333
+ },
334
+ "refreshes": 0,
335
+ "sub": [],
336
+ "super": [],
337
+ },
338
+ {
339
+ "_tag": "ref",
340
+ "id": "node-8",
341
+ "isDestroyed": false,
342
+ "isDirty": false,
343
+ "label": "tableRef:__livestore_session_changeset",
344
+ "meta": {
345
+ "liveStoreRefType": "table",
346
+ },
347
+ "previousResult": {
348
+ "_tag": "Some",
349
+ "value": "null",
350
+ },
351
+ "refreshes": 0,
352
+ "sub": [],
353
+ "super": [],
354
+ },
355
+ {
356
+ "_tag": "thunk",
357
+ "id": "node-9",
358
+ "isDestroyed": false,
359
+ "isDirty": false,
360
+ "label": "UserInfo.get:u1:results",
361
+ "meta": {
362
+ "liveStoreThunkType": "db.result",
363
+ },
364
+ "previousResult": {
365
+ "_tag": "Some",
366
+ "value": "{"username":"","text":""}",
367
+ },
368
+ "recomputations": 1,
369
+ "sub": [
370
+ "node-3",
371
+ ],
372
+ "super": [
373
+ "node-10",
374
+ ],
375
+ },
376
+ ],
377
+ "deferredEffects": [],
378
+ "effects": [
379
+ {
380
+ "_tag": "effect",
381
+ "id": "node-10",
382
+ "invocations": 1,
383
+ "isDestroyed": false,
384
+ "label": "subscribe:UserInfo.get:u1",
385
+ "sub": [
386
+ "node-9",
387
+ ],
388
+ },
389
+ ],
390
+ }
391
+ `;
392
+
393
+ exports[`useClientDocument > should update the data based on component key 2`] = `
394
+ {
395
+ "atoms": [
396
+ {
397
+ "_tag": "ref",
398
+ "id": "node-1",
399
+ "isDestroyed": false,
400
+ "isDirty": false,
401
+ "label": "tableRef:todos",
402
+ "meta": {
403
+ "liveStoreRefType": "table",
404
+ },
405
+ "previousResult": {
406
+ "_tag": "Some",
407
+ "value": "null",
408
+ },
409
+ "refreshes": 0,
410
+ "sub": [],
411
+ "super": [],
412
+ },
413
+ {
414
+ "_tag": "ref",
415
+ "id": "node-2",
416
+ "isDestroyed": false,
417
+ "isDirty": false,
418
+ "label": "tableRef:app",
419
+ "meta": {
420
+ "liveStoreRefType": "table",
421
+ },
422
+ "previousResult": {
423
+ "_tag": "Some",
424
+ "value": "null",
425
+ },
426
+ "refreshes": 0,
427
+ "sub": [],
428
+ "super": [],
429
+ },
430
+ {
431
+ "_tag": "ref",
432
+ "id": "node-3",
433
+ "isDestroyed": false,
434
+ "isDirty": false,
435
+ "label": "tableRef:UserInfo",
436
+ "meta": {
437
+ "liveStoreRefType": "table",
438
+ },
439
+ "previousResult": {
440
+ "_tag": "Some",
441
+ "value": "null",
442
+ },
443
+ "refreshes": 2,
444
+ "sub": [],
445
+ "super": [
446
+ "node-11",
447
+ ],
448
+ },
449
+ {
450
+ "_tag": "ref",
451
+ "id": "node-4",
452
+ "isDestroyed": false,
453
+ "isDirty": false,
454
+ "label": "tableRef:AppRouter",
455
+ "meta": {
456
+ "liveStoreRefType": "table",
457
+ },
458
+ "previousResult": {
459
+ "_tag": "Some",
460
+ "value": "null",
461
+ },
462
+ "refreshes": 0,
463
+ "sub": [],
464
+ "super": [],
465
+ },
466
+ {
467
+ "_tag": "ref",
468
+ "id": "node-5",
469
+ "isDestroyed": false,
470
+ "isDirty": false,
471
+ "label": "tableRef:Kv",
472
+ "meta": {
473
+ "liveStoreRefType": "table",
474
+ },
475
+ "previousResult": {
476
+ "_tag": "Some",
477
+ "value": "null",
478
+ },
479
+ "refreshes": 0,
480
+ "sub": [],
481
+ "super": [],
482
+ },
483
+ {
484
+ "_tag": "ref",
485
+ "id": "node-6",
486
+ "isDestroyed": false,
487
+ "isDirty": false,
488
+ "label": "tableRef:__livestore_schema",
489
+ "meta": {
490
+ "liveStoreRefType": "table",
491
+ },
492
+ "previousResult": {
493
+ "_tag": "Some",
494
+ "value": "null",
495
+ },
496
+ "refreshes": 0,
497
+ "sub": [],
498
+ "super": [],
499
+ },
500
+ {
501
+ "_tag": "ref",
502
+ "id": "node-7",
503
+ "isDestroyed": false,
504
+ "isDirty": false,
505
+ "label": "tableRef:__livestore_schema_event_defs",
506
+ "meta": {
507
+ "liveStoreRefType": "table",
508
+ },
509
+ "previousResult": {
510
+ "_tag": "Some",
511
+ "value": "null",
512
+ },
513
+ "refreshes": 0,
514
+ "sub": [],
515
+ "super": [],
516
+ },
517
+ {
518
+ "_tag": "ref",
519
+ "id": "node-8",
520
+ "isDestroyed": false,
521
+ "isDirty": false,
522
+ "label": "tableRef:__livestore_session_changeset",
523
+ "meta": {
524
+ "liveStoreRefType": "table",
525
+ },
526
+ "previousResult": {
527
+ "_tag": "Some",
528
+ "value": "null",
529
+ },
530
+ "refreshes": 0,
531
+ "sub": [],
532
+ "super": [],
533
+ },
534
+ {
535
+ "_tag": "thunk",
536
+ "id": "node-11",
537
+ "isDestroyed": false,
538
+ "isDirty": false,
539
+ "label": "UserInfo.get:u2:results",
540
+ "meta": {
541
+ "liveStoreThunkType": "db.result",
542
+ },
543
+ "previousResult": {
544
+ "_tag": "Some",
545
+ "value": "{"username":"username_u2","text":""}",
546
+ },
547
+ "recomputations": 1,
548
+ "sub": [
549
+ "node-3",
550
+ ],
551
+ "super": [
552
+ "node-12",
553
+ ],
554
+ },
555
+ ],
556
+ "deferredEffects": [],
557
+ "effects": [
558
+ {
559
+ "_tag": "effect",
560
+ "id": "node-12",
561
+ "invocations": 1,
562
+ "isDestroyed": false,
563
+ "label": "subscribe:UserInfo.get:u2",
564
+ "sub": [
565
+ "node-11",
566
+ ],
567
+ },
568
+ ],
569
+ }
570
+ `;