Compare commits

..

67 Commits

Author SHA1 Message Date
Anselm Eickhoff
6921e621d7 Merge pull request #749 from gardencmp/changeset-release/main
Version Packages
2024-11-14 09:41:28 +00:00
github-actions[bot]
1b0ef401fb Version Packages 2024-11-14 09:29:38 +00:00
pax
1833983b8d Merge pull request #754 from gardencmp/jazz-tools-ts-target
Change jazz-tools TS target to ES2021
2024-11-14 11:28:21 +02:00
pax-k
149ca97c48 chore: changeset 2024-11-14 11:15:25 +02:00
pax-k
f01a7621b0 fix: change jazz-tools TS target to ES2021 2024-11-14 11:13:13 +02:00
Anselm Eickhoff
ec7c416097 Merge pull request #744 from gardencmp/better-known-state
fix: dispatch more updates to knownState
2024-11-13 14:16:50 +00:00
Guido D'Orsi
0f30eeaec6 chore: changeset 2024-11-13 15:12:18 +01:00
Guido D'Orsi
5a3cf04ba7 fix: dispatch more updates to knownState 2024-11-13 12:32:24 +01:00
Anselm Eickhoff
d6e744d948 Merge pull request #738 from gardencmp/changeset-release/main 2024-11-12 22:11:31 +00:00
github-actions[bot]
23b3acb58c Version Packages 2024-11-12 22:10:32 +00:00
Anselm Eickhoff
f32d0c1fad Merge pull request #743 from gardencmp/fix/react-provider-multiple-storage
fix: fixes the react provider intialization when multiple storage options are provided
2024-11-12 22:09:16 +00:00
Guido D'Orsi
a69ed0b7cd chore: changeset 2024-11-12 22:43:19 +01:00
Guido D'Orsi
b4d7024b98 fix: fixes the react provider intialization when multiple storage options are provided 2024-11-12 22:42:27 +01:00
Guido D'Orsi
c0395dd0a3 Merge pull request #723 from gardencmp/feature/typescript-as-dev
fix: set up typescript as dev dependency
2024-11-12 18:48:28 +01:00
Guido D'Orsi
51d7ca09d9 Merge remote-tracking branch 'origin/main' into feature/typescript-as-dev 2024-11-12 18:41:56 +01:00
Anselm Eickhoff
cf0a38d6bf Merge pull request #739 from gardencmp/fix/autologin
Move auto login check to useEffect
2024-11-12 10:56:35 +00:00
Trisha Lim
dd9b13fbaa Add changeset 2024-11-11 20:37:22 +00:00
Trisha Lim
6a982a29cb Move auto login check to useEffect 2024-11-11 20:35:41 +00:00
Anselm Eickhoff
ebc1b03158 Merge pull request #737 from gardencmp/feat/demo-auth-user-prop 2024-11-11 19:41:24 +00:00
Trisha Lim
c6931b82a0 Add changeset 2024-11-11 18:58:22 +00:00
Anselm Eickhoff
279e2202ba Merge pull request #710 from gardencmp/trishalim-jazz-455 2024-11-11 18:40:32 +00:00
Anselm Eickhoff
ec2324519e Merge pull request #735 from gardencmp/feat/demo-auth-user-prop 2024-11-11 18:38:46 +00:00
Anselm Eickhoff
5932f50c68 Merge pull request #699 from gardencmp/trishalim-jazz-458 2024-11-11 18:36:30 +00:00
Anselm Eickhoff
00906e5d08 Merge pull request #732 from gardencmp/fix/todo-demo-link 2024-11-11 18:35:59 +00:00
Trisha Lim
7bc5fca440 Add user prop to demo auth to skip login on demos 2024-11-11 16:35:55 +00:00
Trisha Lim
e30eb224ae Update demo links 2024-11-11 16:20:09 +00:00
Trisha Lim
983ea7cf03 Fix link to demo for pets example 2024-11-11 16:15:12 +00:00
Trisha Lim
ad2d453e33 Thumbnail fixes for mobile/tablet 2024-11-11 16:13:40 +00:00
Trisha Lim
15d711f6de Formatting fixes 2024-11-11 16:13:40 +00:00
Trisha Lim
7441a7d3d8 Formatting fixes 2024-11-11 16:13:40 +00:00
Trisha Lim
0d756209e9 Layout for mobile 2024-11-11 16:13:40 +00:00
Trisha Lim
b20c2ca173 Add images, description to examples 2024-11-11 16:13:40 +00:00
Trisha Lim
987a186db3 Add tech and features to example apps 2024-11-11 16:13:40 +00:00
Trisha Lim
f4e0b59fa1 Indicate active page on side nav 2024-11-11 16:13:31 +00:00
Trisha Lim
0d2112d8d0 Fix link to demo for todo example 2024-11-11 12:40:31 +00:00
Anselm Eickhoff
6fdab780a9 Merge pull request #730 from gardencmp/changeset-release/main
Version Packages
2024-11-10 13:17:22 +00:00
github-actions[bot]
159e2eb7f6 Version Packages 2024-11-10 13:16:08 +00:00
Anselm Eickhoff
9daa50dd7d Merge pull request #729 from gardencmp/aeplay-jazz-479
Set a CoValue as errored per peer after first error
2024-11-10 13:14:49 +00:00
Anselm
9c2aadb7d5 Add changeset 2024-11-10 13:09:57 +00:00
Anselm
7d0d81b16e Set a CoValue as errored per peer after first error 2024-11-10 13:09:36 +00:00
Guido D'Orsi
760a1c10c5 chore(sync): add a comment about syncing after sending an ack 2024-11-08 16:46:29 +00:00
Anselm Eickhoff
fac73f0e44 Merge pull request #726 from gardencmp/changeset-release/main
Version Packages
2024-11-08 16:42:11 +00:00
github-actions[bot]
80b04e78c9 Version Packages 2024-11-08 16:39:19 +00:00
Anselm Eickhoff
b23c0d75fe Merge pull request #725 from gardencmp/aeplay-jazz-477
Immediately ack new content before syncing it upstream
2024-11-08 16:38:03 +00:00
Anselm
d4319d8a0e Add changeset 2024-11-08 16:32:29 +00:00
Anselm
52cd4a9a0f Immediately ack new content before syncing it upstream 2024-11-08 16:31:52 +00:00
Guido D'Orsi
3ef3ff3db9 chore: changeset 2024-11-08 12:22:34 +00:00
Guido D'Orsi
549ec2047f fix: set up typescript as dev dependency 2024-11-08 12:21:50 +00:00
Anselm Eickhoff
ac241981f6 Merge pull request #722 from gardencmp/changeset-release/main
Version Packages
2024-11-08 12:09:49 +00:00
github-actions[bot]
b3504dce9c Version Packages 2024-11-08 12:07:47 +00:00
Anselm Eickhoff
f859d9f1c5 Merge pull request #711 from gardencmp/feature/non-optimistic-sync-state
feat: add a sync state subscription manager
2024-11-08 12:06:34 +00:00
Guido D'Orsi
d433cf473f chore: changeset 2024-11-08 12:03:25 +00:00
Guido D'Orsi
c6cd6cba20 Merge remote-tracking branch 'origin/main' into feature/non-optimistic-sync-state 2024-11-08 12:01:05 +00:00
Guido D'Orsi
9c7333d4f0 fix(createWorkerAccount): use the new sync wait API 2024-11-08 12:00:55 +00:00
Anselm Eickhoff
970f870245 Merge pull request #720 from gardencmp/aeplay-jazz-475
Less noisy logs if clients send empty WebSocket messages
2024-11-08 11:42:30 +00:00
Anselm
a2dbaf86d2 Fix unused var 2024-11-08 11:38:24 +00:00
Anselm
b6162f0fc4 Add changeset 2024-11-08 11:34:52 +00:00
Anselm
91cfa6aa8f Less noisy logs if clients send empty WebSocket messages 2024-11-08 11:34:28 +00:00
Guido D'Orsi
4fd6bbd41d Merge remote-tracking branch 'origin/main' into feature/non-optimistic-sync-state 2024-11-08 09:57:46 +00:00
Guido D'Orsi
0ea3ef31ac chore(PeerState): explain the difference between knownState and optimisticKnownState 2024-11-07 10:11:32 +00:00
Guido D'Orsi
d02613e2ec chore: add jazz-tools.json to the biome ignore 2024-11-07 09:21:42 +00:00
Guido D'Orsi
8ff036e5ff test: cover the content acknowledgment flow 2024-11-07 09:15:09 +00:00
Guido D'Orsi
d0733e2a3b chore: revert jazz-run changes 2024-11-07 00:25:31 +00:00
Guido D'Orsi
ad4f1b74f6 chore: fix type error 2024-11-07 00:20:26 +00:00
Guido D'Orsi
04d97e4a2d chore: format 2024-11-07 00:17:03 +00:00
Guido D'Orsi
3f9e749122 Merge remote-tracking branch 'origin/main' into feature/non-optimistic-sync-state 2024-11-07 00:12:56 +00:00
Guido D'Orsi
aa1dd3e10a feat: add a sync state subscription manager 2024-11-07 00:06:30 +00:00
86 changed files with 2617 additions and 339 deletions

View File

@@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": []
"ignore": ["jazz-tools.json"]
},
"formatter": {
"enabled": true,

View File

@@ -1,5 +1,52 @@
# @jazz-e2e/binarycostream
## 0.0.99
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.98
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.97
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.96
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.95
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.94
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@jazz-e2e/binarycostream",
"private": true,
"version": "0.0.94",
"version": "0.0.99",
"type": "module",
"scripts": {
"dev": "vite",
@@ -13,11 +13,11 @@
"test:ui": "playwright test --ui"
},
"dependencies": {
"cojson": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"hash-slash": "workspace:0.2.1",
"is-ci": "^3.0.1",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},

View File

@@ -1,5 +1,52 @@
# @jazz-e2e/covalues
## 0.0.98
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.97
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.96
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.95
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.94
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.93
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@jazz-e2e/covalues",
"private": true,
"version": "0.0.93",
"version": "0.0.98",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,49 @@
# jazz-example-book-shelf
## 0.1.14
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react@0.8.21
- jazz-browser-media-images@0.8.21
## 0.1.13
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
- jazz-browser-media-images@0.8.20
## 0.1.12
### Patch Changes
- jazz-react@0.8.19
- jazz-tools@0.8.19
- jazz-browser-media-images@0.8.19
## 0.1.11
### Patch Changes
- jazz-react@0.8.18
- jazz-tools@0.8.18
- jazz-browser-media-images@0.8.18
## 0.1.10
### Patch Changes
- jazz-react@0.8.17
- jazz-tools@0.8.17
- jazz-browser-media-images@0.8.17
## 0.1.9
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-example-book-shelf",
"version": "0.1.9",
"version": "0.1.14",
"private": true,
"scripts": {
"dev": "next dev",
@@ -11,9 +11,9 @@
},
"dependencies": {
"clsx": "^2.0.0",
"jazz-browser-media-images": "workspace:0.8.16",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-browser-media-images": "workspace:0.8.21",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"next": "14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"

View File

@@ -1,5 +1,57 @@
# jazz-example-chat
## 0.0.98
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-react@0.8.21
- jazz-react-auth-clerk@0.8.21
## 0.0.97
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
- jazz-react-auth-clerk@0.8.20
## 0.0.96
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-react@0.8.19
- jazz-react-auth-clerk@0.8.19
- jazz-tools@0.8.19
## 0.0.95
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-react@0.8.18
- jazz-react-auth-clerk@0.8.18
- jazz-tools@0.8.18
## 0.0.94
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-react@0.8.17
- jazz-react-auth-clerk@0.8.17
- jazz-tools@0.8.17
## 0.0.93
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat-clerk",
"private": true,
"version": "0.0.93",
"version": "0.0.98",
"type": "module",
"scripts": {
"dev": "vite",
@@ -17,11 +17,11 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cojson": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"hash-slash": "workspace:0.2.1",
"jazz-react": "workspace:0.8.16",
"jazz-react-auth-clerk": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-react-auth-clerk": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,5 +1,51 @@
# chat-rn-clerk
## 1.0.14
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react-auth-clerk@0.8.21
- jazz-react-native@0.8.21
- jazz-react-native-media-images@0.8.17
## 1.0.13
### Patch Changes
- Updated dependencies [3ef3ff3]
- jazz-react-native-media-images@0.8.16
- jazz-react-native@0.8.20
- jazz-react-auth-clerk@0.8.20
## 1.0.12
### Patch Changes
- jazz-react-auth-clerk@0.8.19
- jazz-react-native@0.8.19
- jazz-tools@0.8.19
- jazz-react-native-media-images@0.8.15
## 1.0.11
### Patch Changes
- jazz-react-auth-clerk@0.8.18
- jazz-react-native@0.8.18
- jazz-tools@0.8.18
- jazz-react-native-media-images@0.8.14
## 1.0.10
### Patch Changes
- jazz-react-auth-clerk@0.8.17
- jazz-react-native@0.8.17
- jazz-tools@0.8.17
- jazz-react-native-media-images@0.8.13
## 1.0.9
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "chat-rn-clerk",
"main": "index.js",
"version": "1.0.9",
"version": "1.0.14",
"scripts": {
"build": "expo export -p ios",
"start": "expo start",

View File

@@ -1,5 +1,41 @@
# chat-rn
## 1.0.16
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react-native@0.8.21
## 1.0.15
### Patch Changes
- Updated dependencies [3ef3ff3]
- jazz-react-native@0.8.20
## 1.0.14
### Patch Changes
- jazz-react-native@0.8.19
- jazz-tools@0.8.19
## 1.0.13
### Patch Changes
- jazz-react-native@0.8.18
- jazz-tools@0.8.18
## 1.0.12
### Patch Changes
- jazz-react-native@0.8.17
- jazz-tools@0.8.17
## 1.0.11
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-rn",
"version": "1.0.11",
"version": "1.0.16",
"main": "index.js",
"scripts": {
"build": "expo export -p ios",

View File

@@ -1,5 +1,45 @@
# chat-vue
## 0.0.6
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-browser@0.8.21
- jazz-vue@0.8.11
## 0.0.5
### Patch Changes
- jazz-browser@0.8.20
- jazz-vue@0.8.10
## 0.0.4
### Patch Changes
- jazz-browser@0.8.19
- jazz-tools@0.8.19
- jazz-vue@0.8.9
## 0.0.3
### Patch Changes
- jazz-browser@0.8.18
- jazz-tools@0.8.18
- jazz-vue@0.8.8
## 0.0.2
### Patch Changes
- jazz-browser@0.8.17
- jazz-tools@0.8.17
- jazz-vue@0.8.7
## 0.0.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-vue",
"version": "0.0.1",
"version": "0.0.6",
"private": true,
"type": "module",
"scripts": {

View File

@@ -1,5 +1,52 @@
# jazz-example-chat
## 0.0.100
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.99
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.98
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.97
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.96
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.95
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat",
"private": true,
"version": "0.0.95",
"version": "0.0.100",
"type": "module",
"scripts": {
"dev": "vite",
@@ -18,10 +18,10 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cojson": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"hash-slash": "workspace:0.2.1",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,5 +1,38 @@
# jazz-example-inspector
## 0.0.73
### Patch Changes
- Updated dependencies [0f30eea]
- cojson@0.8.21
- cojson-transport-ws@0.8.21
## 0.0.72
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- cojson-transport-ws@0.8.19
## 0.0.71
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- cojson-transport-ws@0.8.18
## 0.0.70
### Patch Changes
- Updated dependencies [d433cf4]
- Updated dependencies [b6162f0]
- cojson@0.8.17
- cojson-transport-ws@0.8.17
## 0.0.69
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-inspector",
"private": true,
"version": "0.0.69",
"version": "0.0.73",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,8 +16,8 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cojson": "workspace:0.8.16",
"cojson-transport-ws": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"cojson-transport-ws": "workspace:0.8.21",
"hash-slash": "workspace:0.2.1",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",

View File

@@ -1,5 +1,44 @@
# jazz-example-musicplayer
## 0.0.20
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.19
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.18
### Patch Changes
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.17
### Patch Changes
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.16
### Patch Changes
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.15
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-music-player",
"private": true,
"version": "0.0.15",
"version": "0.0.20",
"type": "module",
"scripts": {
"dev": "vite",
@@ -18,8 +18,8 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"lucide-react": "^0.274.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",

View File

@@ -70,7 +70,11 @@ function JazzAndAuth({ children }: { children: React.ReactNode }) {
return (
<>
<Jazz.Provider auth={auth} peer={peer}>
<Jazz.Provider
storage={["singleTabOPFS", "indexedDB"]}
auth={auth}
peer={peer}
>
{children}
</Jazz.Provider>
<DemoAuthBasicUI appName="Jazz Music Player" state={state} />

View File

@@ -1,5 +1,44 @@
# jazz-password-manager
## 0.0.19
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.18
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.17
### Patch Changes
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.16
### Patch Changes
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.15
### Patch Changes
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.14
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-password-manager",
"private": true,
"version": "0.0.14",
"version": "0.0.19",
"type": "module",
"scripts": {
"dev": "vite",
@@ -12,8 +12,8 @@
"clean-install": "rm -rf node_modules pnpm-lock.yaml && pnpm install"
},
"dependencies": {
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.41.5",

View File

@@ -1,5 +1,49 @@
# jazz-example-pets
## 0.0.117
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react@0.8.21
- jazz-browser-media-images@0.8.21
## 0.0.116
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
- jazz-browser-media-images@0.8.20
## 0.0.115
### Patch Changes
- jazz-react@0.8.19
- jazz-tools@0.8.19
- jazz-browser-media-images@0.8.19
## 0.0.114
### Patch Changes
- jazz-react@0.8.18
- jazz-tools@0.8.18
- jazz-browser-media-images@0.8.18
## 0.0.113
### Patch Changes
- jazz-react@0.8.17
- jazz-tools@0.8.17
- jazz-browser-media-images@0.8.17
## 0.0.112
### Patch Changes

View File

@@ -1,6 +1,6 @@
# Jazz Rate-My-Pet List Example
Live version: https://example-pets.jazz.tools
Live version: https://pets-demo.jazz.tools/
## Installing & running the example locally

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.112",
"version": "0.0.117",
"type": "module",
"scripts": {
"dev": "vite",
@@ -19,9 +19,9 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-browser-media-images": "workspace:0.8.16",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-browser-media-images": "workspace:0.8.21",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",
@@ -41,7 +41,7 @@
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.14",
"is-ci": "^3.0.1",
"jazz-run": "workspace:0.8.16",
"jazz-run": "workspace:0.8.21",
"postcss": "^8.4.27",
"tailwindcss": "3.3.2",
"typescript": "^5.3.3",

View File

@@ -1,5 +1,44 @@
# jazz-example-todo
## 0.0.116
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-react@0.8.21
## 0.0.115
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
## 0.0.114
### Patch Changes
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.0.113
### Patch Changes
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.0.112
### Patch Changes
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.0.111
### Patch Changes

View File

@@ -1,6 +1,6 @@
# Jazz Todo List Example
Live version: https://example-todo.jazz.tools
Live version: https://todo-demo.jazz.tools/
## Installing & running the example locally

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.111",
"version": "0.0.116",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,8 +16,8 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -4,7 +4,7 @@ import Link from "next/link";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
children: React.ReactNode;
variant?: "primary" | "secondary" | "tertiary";
size?: "md" | "lg";
size?: "sm" | "md" | "lg";
href?: string;
}
@@ -20,6 +20,7 @@ export function Button(props: ButtonProps) {
} = props;
const sizeClasses = {
sm: "text-sm py-1 px-2",
md: "py-2 px-3",
lg: "md:text-lg py-2 px-3 md:px-8 md:py-3",
};
@@ -34,7 +35,7 @@ export function Button(props: ButtonProps) {
const classNames = clsx(
className,
"inline-block rounded-lg text-center transition-colors",
"inline-flex items-center gap-2 rounded-lg text-center transition-colors",
sizeClasses[size],
variantClasses[variant],
disabled && "opacity-50 cursor-not-allowed pointer-events-none",

View File

@@ -1,48 +1,305 @@
import { ClerkFullLogo } from "@/components/icons/ClerkFullLogo";
import { NextjsLogo } from "@/components/icons/NextjsLogo";
import { ReactLogo } from "@/components/icons/ReactLogo";
import { ReactNativeLogo } from "@/components/icons/ReactNativeLogo";
import { Button } from "gcmp-design-system/src/app/components/atoms/Button";
import { GappedGrid } from "gcmp-design-system/src/app/components/molecules/GappedGrid";
import { CloudUploadIcon, FingerprintIcon, KeyRoundIcon } from "lucide-react";
type Example = {
name: string;
slug: string;
description?: string;
illustration?: React.ReactNode;
tech?: string[];
features?: string[];
demoUrl?: string;
};
const tech = {
react: "React",
nextjs: "Next.js",
reactNative: "React Native",
};
const features = {
fileUpload: "File upload",
passkey: "Passkey auth",
clerk: "Clerk auth",
inviteLink: "Invite link",
};
const ChatIllustration = () => (
<div className="p-4 flex flex-col gap-4 justify-center h-full">
<div className="flex flex-col gap-1 items-end">
<p className="text-2xs">Sebastian</p>
<p className="inline-block text-xs py-1.5 px-3 rounded-full bg-blue text-white">
No one likes jazz. Not even you.
</p>
</div>
<div className="flex flex-col gap-1 items-start">
<p className="text-2xs">Mia</p>
<p className="inline-block text-xs py-1.5 px-3 rounded-full bg-stone-200 text-stone-900 dark:bg-white">
I do like jazz now, because of you.
</p>
</div>
</div>
);
const ClerkIllustration = () => (
<div className="flex items-center justify-center h-full p-8">
<ClerkFullLogo className="w-36 h-auto" />
</div>
);
const MusicIllustration = () => (
<div className="flex flex-col items-center justify-center h-full p-8">
<div className="py-3 px-4 border border-dashed border-blue dark:border-blue-500 rounded-lg flex gap-2 flex-col items-center">
<CloudUploadIcon
size={30}
strokeWidth={1.5}
className="stroke-blue mx-auto dark:stroke-blue-500"
/>
<p className="whitespace-nowrap text-xs text-stone-900 dark:text-white">
tortured-poets-department.mp3
</p>
</div>
</div>
);
const BookShelfIllustration = () => (
<div className="h-full p-6 md:p-5">
<div className="flex justify-between items-baseline">
<p className="font-display font-medium tracking-tight text-sm text-stone-900 dark:text-white">
Your book shelf
</p>
<p className="bg-blue-100 text-blue-800 py-1 px-3 rounded-full font-medium text-xs">
Add book
</p>
</div>
<div className="relative grid grid-cols-3 gap-4 mt-3">
{["malibu.jpg", "pathless.jpg", "upgrade.jpg"].map((book) => (
<img
key={book}
src={`/book-covers/${book}`}
alt=""
className="w-full h-full object-cover rounded-r-md shadow-sm border dark:border-none"
/>
))}
<div className="absolute bottom-0 w-full h-10 bg-gradient-to-t from-white dark:from-stone-925 to-transparent md:hidden" />
</div>
</div>
);
const PetIllustration = () => (
<div className="h-full p-4 bg-[url('/dog.jpg')] bg-cover bg-center p-4 flex items-end">
<div className="inline-flex justify-center gap-1 mx-auto">
{["😍", "😮", "🤩", "😂", "👍"].map((emoji) => (
<button
type="button"
key={emoji}
className="size-6 rounded shadow-sm bg-white leading-none hover:bg-stone-100"
>
{emoji}
</button>
))}
</div>
</div>
);
const reactExamples = [
{
name: "Chat",
slug: "chat",
description: "A simple app that creates a chat room with a shareable link.",
tech: [tech.react],
demoUrl: "https://chat.jazz.tools",
illustration: <ChatIllustration />,
},
{
name: "Chat",
slug: "chat-clerk",
description:
"Exactly like the chat app, but it uses Clerk for authentication.",
tech: [tech.react],
features: [features.clerk],
demoUrl: "https://chat-clerk-demo.jazz.tools",
illustration: <ClerkIllustration />,
},
{
name: "Music player",
slug: "music-player",
description:
"Upload your favorite songs, and share them with your friends.",
tech: [tech.react],
features: [features.fileUpload],
demoUrl: "https://music-demo.jazz.tools",
illustration: <MusicIllustration />,
},
{
name: "Rate my pet",
slug: "pets",
description:
"Upload a photo of your pet, and invite your friends to react to it.",
tech: [tech.react],
features: [features.fileUpload, features.inviteLink],
demoUrl: "https://pets-demo.jazz.tools",
illustration: <PetIllustration />,
},
{
name: "Todo list",
slug: "todo",
description: "A todo list where you can collaborate with invited guests.",
tech: [tech.react],
features: [features.inviteLink],
demoUrl: "https://todo-demo.jazz.tools",
illustration: (
<div className="h-full w-full bg-cover bg-[url('/todo.jpg')] bg-left-bottom"></div>
),
},
{
name: "Password manager",
slug: "password-manager",
description: "A secure password manager, using Passkey for authentication.",
tech: [tech.react],
features: [features.passkey],
demoUrl: "https://passwords-demo.jazz.tools",
illustration: (
<div className="flex bg-stone-100 h-full flex-col items-center justify-center dark:bg-transparent">
<div className="p-4 flex flex-col items-center gap-3 rounded-md shadow-xl shadow-stone-400/20 bg-white dark:shadow-none">
<FingerprintIcon
size={36}
strokeWidth={0.75}
className="stroke-red-600"
/>
<p className="text-xs dark:text-stone-900">Continue with Touch ID</p>
</div>
</div>
),
},
];
const nextExamples = [
{
name: "Book shelf",
slug: "book-shelf",
description:
"Track and rate the books you read, readable by everyone with the link.",
tech: [tech.nextjs],
features: [features.fileUpload],
demoUrl: "https://books-demo.jazz.tools",
imageUrl: "/books.jpg",
illustration: <BookShelfIllustration />,
},
];
const rnExamples: Example[] = [
{
name: "Chat",
slug: "chat-rn",
description: "A simple app that creates a chat room with a shareable link.",
tech: [tech.reactNative],
illustration: <ChatIllustration />,
},
{
name: "Chat",
slug: "chat-rn-clerk",
description: "Exactly like the React Native chat app, with Clerk for auth.",
tech: [tech.reactNative],
features: [features.clerk],
illustration: <ClerkIllustration />,
},
];
const categories = [
{
name: "React",
logo: ReactLogo,
examples: reactExamples,
},
{
name: "Next.js",
logo: NextjsLogo,
examples: nextExamples,
},
{
name: "React Native",
logo: ReactNativeLogo,
examples: rnExamples,
},
];
function Example({ example }: { example: Example }) {
const { name, slug, tech, features, description, demoUrl, illustration } =
example;
const githubUrl = `https://github.com/gardencmp/jazz/tree/main/examples/${slug}`;
return (
<div className="border bg-stone-50 shadow-sm p-3 flex flex-col gap-3 rounded-lg md:gap-4 dark:bg-stone-950">
<div className="aspect-[16/9] overflow-hidden w-full rounded-md bg-white border dark:bg-stone-925 sm:aspect-[2/1] md:aspect-[3/2]">
{illustration}
</div>
<div className="flex-1 space-y-2">
<h2 className="font-medium text-stone-900 dark:text-white leading-none">
{name}
</h2>
<div className="flex gap-1">
{tech?.map((tech) => (
<p
className="bg-green-50 border border-green-500 text-green-600 rounded-full py-0.5 px-2 text-xs dark:bg-green-800 dark:text-green-200 dark:border-green-700"
key={tech}
>
{tech}
</p>
))}
{features?.map((feature) => (
<p
className="bg-pink-50 border border-pink-500 text-pink-600 rounded-full py-0.5 px-2 text-xs dark:bg-pink-800 dark:text-pink-200 dark:border-pink-700"
key={feature}
>
{feature}
</p>
))}
</div>
<p className="text-sm">{description}</p>
<div className="flex gap-2">
<Button href={githubUrl} variant="secondary" size="sm">
View code
</Button>
{demoUrl && (
<Button href={demoUrl} variant="secondary" size="sm">
View demo
</Button>
)}
</div>
</div>
</div>
);
}
export default function Page() {
const examples = [
{
name: "Chat",
slug: "chat",
},
{
name: "Chat (with Clerk for auth)",
slug: "chat-clerk",
},
{
name: "Music player",
slug: "music-player",
},
{
name: "Pets",
slug: "pets",
},
{
name: "Todo",
slug: "todo",
},
{
name: "Password manager",
slug: "password-manager",
},
{
name: "Book shelf",
slug: "book-shelf",
},
];
return (
<>
<h1>Example Apps</h1>
<ul>
{examples.map(({ name, slug }) => (
<li key={name}>
<a
href={`https://github.com/gardencmp/jazz/tree/main/examples/${slug}`}
>
{name}
</a>
</li>
))}
</ul>
{categories.map((category) => (
<div className="my-12" key={category.name}>
<div className="flex items-center gap-3 mb-5">
<category.logo className="h-8 w-8" />
<h2 className="my-0">{category.name}</h2>
</div>
<div className="not-prose grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8">
{category.examples.map((example) => (
<Example key={example.slug} example={example} />
))}
</div>
</div>
))}
</>
);
}

View File

@@ -21,7 +21,7 @@ export default function Page() {
<Link
href={product.url}
key={product.url}
className="group border bg-stone-50 shadow-sm p-3 flex flex-col gap-3 rounded-lg md:p-4 md:gap-4 dark:bg-stone-900"
className="group border bg-stone-50 shadow-sm p-3 flex flex-col gap-3 rounded-lg md:gap-4 dark:bg-stone-950"
>
<Image
className="rounded-md border dark:border-0"

View File

@@ -1,5 +1,8 @@
"use client";
import { clsx } from "clsx";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ReactNode } from "react";
export function SideNavItem({
@@ -15,6 +18,7 @@ export function SideNavItem({
className,
"py-1 flex items-center hover:transition-colors",
);
const path = usePathname();
if (href) {
return (
@@ -24,6 +28,9 @@ export function SideNavItem({
classes,
href &&
"hover:text-black dark:hover:text-stone-200 transition-colors hover:transition-none",
{
"text-black": path === href,
},
)}
>
{children}

View File

@@ -0,0 +1,51 @@
import { clsx } from "clsx";
import React from "react";
import type { SVGProps } from "react";
export function ClerkFullLogo(props: SVGProps<SVGSVGElement>) {
return (
<svg
{...props}
className={clsx(props.className, "text-black dark:text-white")}
xmlns="http://www.w3.org/2000/svg"
width="110"
height="32"
viewBox="0 0 110 32"
fill="none"
>
<ellipse
cx="16.0003"
cy="16"
rx="4.99998"
ry="5"
fill="#6C47FF"
fillOpacity="1"
style={{
fill: "color(display-p3 0.4235 0.2784 1.0000)",
}}
/>
<path
d="M25.0091 27.8382C25.4345 28.2636 25.3918 28.9679 24.8919 29.3027C22.3488 31.0062 19.2899 31.9997 15.999 31.9997C12.7082 31.9997 9.64934 31.0062 7.10615 29.3027C6.60632 28.9679 6.56361 28.2636 6.989 27.8382L10.6429 24.1843C10.9732 23.854 11.4855 23.8019 11.9012 24.0148C13.1302 24.6445 14.5232 24.9997 15.999 24.9997C17.4749 24.9997 18.8678 24.6445 20.0969 24.0148C20.5126 23.8019 21.0249 23.854 21.3552 24.1843L25.0091 27.8382Z"
fill="#6C47FF"
fillOpacity="1"
style={{
fill: "color(display-p3 0.4235 0.2784 1.0000)",
}}
/>
<path
d="M24.8928 2.697C25.3926 3.0318 25.4353 3.73609 25.0099 4.16149L21.356 7.81544C21.0258 8.14569 20.5134 8.19785 20.0978 7.98491C18.8687 7.35525 17.4758 7 15.9999 7C11.0294 7 6.99997 11.0294 6.99997 16C6.99997 17.4759 7.35522 18.8688 7.98488 20.0979C8.19782 20.5136 8.14565 21.0259 7.81541 21.3561L4.16147 25.0101C3.73607 25.4355 3.03178 25.3927 2.69698 24.8929C0.993522 22.3497 0 19.2909 0 16C0 7.16344 7.16341 0 15.9999 0C19.2908 0 22.3496 0.993529 24.8928 2.697Z"
fill="#BAB1FF"
style={{
fill: "color(display-p3 0.7294 0.6941 1.0000)",
}}
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M100.405 21.2489C100.421 21.2324 100.442 21.2231 100.465 21.2231C100.493 21.2231 100.518 21.2375 100.533 21.2613L105.275 28.8821C105.321 28.9554 105.401 29 105.487 29L109.75 29C109.946 29 110.066 28.7848 109.963 28.6183L103.457 18.1226C103.399 18.0278 103.41 17.9056 103.485 17.823L109.752 10.908C109.898 10.7473 109.784 10.4901 109.567 10.4901H105.12C105.05 10.4901 104.983 10.5194 104.936 10.5711L97.6842 18.4755C97.5301 18.6435 97.25 18.5345 97.25 18.3065V3.25C97.25 3.11193 97.138 3 97 3H93.25C93.1119 3 93 3.11193 93 3.25V28.75C93 28.8881 93.1119 29 93.25 29L97 29C97.138 29 97.25 28.8881 97.25 28.75V24.7373C97.25 24.6741 97.2739 24.6132 97.317 24.567L100.405 21.2489ZM52.2502 3.25C52.2502 3.11193 52.3621 3 52.5002 3H56.2501C56.3882 3 56.5001 3.11193 56.5001 3.25V28.75C56.5001 28.8881 56.3882 29 56.2501 29H52.5002C52.3621 29 52.2502 28.8881 52.2502 28.75V3.25ZM46.958 23.5912C46.8584 23.5052 46.7094 23.5117 46.6137 23.602C46.0293 24.1537 45.3447 24.595 44.5947 24.9028C43.7719 25.2407 42.8873 25.4108 41.995 25.4028C41.2415 25.4252 40.4913 25.2963 39.7906 25.0241C39.09 24.7519 38.4537 24.3422 37.9209 23.8202C36.9531 22.8322 36.396 21.4215 36.396 19.7399C36.396 16.3735 38.6356 14.0709 41.995 14.0709C42.896 14.0585 43.7888 14.241 44.6094 14.6052C45.3533 14.9355 46.0214 15.4077 46.5748 15.9934C46.6694 16.0936 46.8266 16.1052 46.9309 16.015L49.4625 13.8244C49.5659 13.7349 49.5785 13.5786 49.4873 13.4767C47.583 11.3488 44.5997 10.25 41.7627 10.25C36.0506 10.25 32.0003 14.1031 32.0003 19.7719C32.0003 22.5756 33.0069 24.9365 34.7044 26.6036C36.402 28.2707 38.8203 29.25 41.6108 29.25C45.1097 29.25 47.9259 27.9082 49.577 26.187C49.6739 26.086 49.6632 25.9252 49.5572 25.8338L46.958 23.5912ZM77.1575 20.9877C77.1436 21.1129 77.0371 21.2066 76.9111 21.2066H63.7746C63.615 21.2066 63.4961 21.3546 63.5377 21.5087C64.1913 23.9314 66.1398 25.3973 68.7994 25.3973C69.6959 25.4161 70.5846 25.2317 71.3968 24.8582C72.1536 24.5102 72.8249 24.0068 73.3659 23.3828C73.4314 23.3073 73.5454 23.2961 73.622 23.3602L76.2631 25.6596C76.3641 25.7476 76.3782 25.8999 76.2915 26.0021C74.697 27.8832 72.1135 29.25 68.5683 29.25C63.1142 29.25 59.0001 25.4731 59.0001 19.7348C59.0001 16.9197 59.9693 14.559 61.5847 12.8921C62.4374 12.0349 63.4597 11.3584 64.5882 10.9043C65.7168 10.4502 66.9281 10.2281 68.1473 10.2517C73.6753 10.2517 77.25 14.1394 77.25 19.5075C77.2431 20.0021 77.2123 20.4961 77.1575 20.9877ZM63.6166 17.5038C63.5702 17.6581 63.6894 17.8084 63.8505 17.8084H72.5852C72.7467 17.8084 72.8659 17.6572 72.8211 17.5021C72.2257 15.4416 70.7153 14.0666 68.3696 14.0666C67.6796 14.0447 66.993 14.1696 66.3565 14.4326C65.7203 14.6957 65.149 15.0908 64.6823 15.5907C64.1914 16.1473 63.8285 16.7998 63.6166 17.5038ZM90.2473 10.2527C90.3864 10.2512 90.5 10.3636 90.5 10.5027V14.7013C90.5 14.8469 90.3762 14.9615 90.2311 14.9508C89.8258 14.9207 89.4427 14.8952 89.1916 14.8952C85.9204 14.8952 84 17.1975 84 20.2195V28.75C84 28.8881 83.8881 29 83.75 29H80C79.862 29 79.75 28.8881 79.75 28.75V10.7623C79.75 10.6242 79.862 10.5123 80 10.5123H83.75C83.8881 10.5123 84 10.6242 84 10.7623V13.287C84 13.3013 84.0116 13.3128 84.0258 13.3128C84.034 13.3128 84.0416 13.3089 84.0465 13.3024C85.5124 11.3448 87.676 10.2559 89.9617 10.2559L90.2473 10.2527Z"
className="fill-[#131316] dark:fill-white"
fillOpacity="1"
/>
</svg>
);
}

View File

@@ -0,0 +1,11 @@
import { SiNextdotjs } from "@icons-pack/react-simple-icons";
import { clsx } from "clsx";
export function NextjsLogo(props: React.SVGProps<SVGSVGElement>) {
return (
<SiNextdotjs
{...props}
className={clsx(props.className, "fill-black dark:fill-white")}
/>
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@@ -1,5 +1,39 @@
# cojson-storage-indexeddb
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- cojson@0.8.21
## 0.8.20
### Patch Changes
- 3ef3ff3: Remove typescript from the direct dependencies
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,19 +1,19 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.8.16",
"version": "0.8.21",
"main": "dist/index.js",
"type": "module",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "workspace:0.8.16",
"typescript": "^5.3.3"
"cojson": "workspace:0.8.21"
},
"devDependencies": {
"@vitest/browser": "^0.34.1",
"fake-indexeddb": "^6.0.0",
"vitest": "1.5.3",
"webdriverio": "^8.15.0"
"webdriverio": "^8.15.0",
"typescript": "^5.3.3"
},
"scripts": {
"dev": "tsc --watch --sourceMap --outDir dist",

View File

@@ -1,5 +1,33 @@
# cojson-storage-sqlite
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- cojson@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,13 +1,13 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.8.16",
"version": "0.8.21",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^8.5.2",
"cojson": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"typescript": "^5.3.3"
},
"devDependencies": {

View File

@@ -1,5 +1,34 @@
# cojson-transport-nodejs-ws
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- cojson@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
## 0.8.17
### Patch Changes
- b6162f0: Less noisy logs if clients send empty WebSocket messages
- Updated dependencies [d433cf4]
- cojson@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,12 +1,12 @@
{
"name": "cojson-transport-ws",
"type": "module",
"version": "0.8.16",
"version": "0.8.21",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"typescript": "^5.3.3"
},
"scripts": {

View File

@@ -147,6 +147,11 @@ export function createWebSocketPeer({
);
function handleIncomingMsg(event: { data: unknown }) {
if (event.data === "") {
console.log("client", id, "sent empty message");
return;
}
const result = deserializeMessages(event.data);
if (!result.ok) {

View File

@@ -1,5 +1,29 @@
# cojson
## 0.8.21
### Patch Changes
- 0f30eea: Improved the known state tracking within the PeerState.knownState property
## 0.8.19
### Patch Changes
- 9c2aadb: Set a CoValue as errored per peer after first error
## 0.8.18
### Patch Changes
- d4319d8: Immediately ack new content before syncing it upstream
## 0.8.17
### Patch Changes
- d433cf4: Add a new API to wait for a CoValue to be uploaded in a peer
## 0.8.16
### Patch Changes

View File

@@ -19,7 +19,7 @@
},
"type": "module",
"license": "MIT",
"version": "0.8.16",
"version": "0.8.21",
"devDependencies": {
"@types/jest": "^29.5.3",
"typescript": "^5.3.3",

View File

@@ -5,7 +5,7 @@ import {
emptyKnownState,
} from "./sync.js";
type PeerKnownStateActions =
export type PeerKnownStateActions =
| {
type: "SET_AS_EMPTY";
id: RawCoID;
@@ -66,6 +66,12 @@ export class PeerKnownStates {
return this.coValues.has(id);
}
clone() {
const clone = new PeerKnownStates();
clone.coValues = new Map(this.coValues);
return clone;
}
dispatch(action: PeerKnownStateActions) {
switch (action.type) {
case "UPDATE_HEADER":

View File

@@ -1,18 +1,46 @@
import { PeerKnownStates } from "./PeerKnownStates.js";
import { PeerKnownStateActions, PeerKnownStates } from "./PeerKnownStates.js";
import {
PriorityBasedMessageQueue,
QueueEntry,
} from "./PriorityBasedMessageQueue.js";
import { TryAddTransactionsError } from "./coValueCore.js";
import { RawCoID } from "./ids.js";
import { CO_VALUE_PRIORITY } from "./priority.js";
import { Peer, SyncMessage } from "./sync.js";
export class PeerState {
constructor(private peer: Peer) {}
constructor(
private peer: Peer,
knownStates: PeerKnownStates | undefined,
) {
this.optimisticKnownStates = knownStates?.clone() ?? new PeerKnownStates();
this.knownStates = knownStates?.clone() ?? new PeerKnownStates();
}
readonly optimisticKnownStates = new PeerKnownStates();
/**
* Here we to collect all the known states that a given peer has told us about.
*
* This can be used to safely track the sync state of a coValue in a given peer.
*/
readonly knownStates: PeerKnownStates;
/**
* This one collects the known states "optimistically".
* We use it to keep track of the content we have sent to a given peer.
*
* The main difference with knownState is that this is updated when the content is sent to the peer without
* waiting for any acknowledgement from the peer.
*/
readonly optimisticKnownStates: PeerKnownStates;
readonly toldKnownState: Set<RawCoID> = new Set();
dispatchToKnownStates(action: PeerKnownStateActions) {
this.knownStates.dispatch(action);
this.optimisticKnownStates.dispatch(action);
}
readonly erroredCoValues: Map<RawCoID, TryAddTransactionsError> = new Map();
get id() {
return this.peer.id;
}

View File

@@ -0,0 +1,124 @@
import { RawCoID } from "./ids.js";
import {
CoValueKnownState,
PeerID,
SyncManager,
emptyKnownState,
} from "./sync.js";
export class SyncStateSubscriptionManager {
constructor(private syncManager: SyncManager) {}
private listeners = new Set<
(
peerId: PeerID,
knownState: CoValueKnownState,
uploadCompleted: boolean,
) => void
>();
private listenersByPeers = new Map<
PeerID,
Set<(knownState: CoValueKnownState, uploadCompleted: boolean) => void>
>();
subscribeToUpdates(
listener: (
peerId: PeerID,
knownState: CoValueKnownState,
uploadCompleted: boolean,
) => void,
) {
this.listeners.add(listener);
return () => {
this.listeners.delete(listener);
};
}
subscribeToPeerUpdates(
peerId: PeerID,
listener: (knownState: CoValueKnownState, uploadCompleted: boolean) => void,
) {
const listeners = this.listenersByPeers.get(peerId) ?? new Set();
if (listeners.size === 0) {
this.listenersByPeers.set(peerId, listeners);
}
listeners.add(listener);
return () => {
listeners.delete(listener);
};
}
triggerUpdate(peerId: PeerID, id: RawCoID) {
const peer = this.syncManager.peers[peerId];
if (!peer) {
return;
}
const peerListeners = this.listenersByPeers.get(peer.id);
// If we don't have any active listeners do nothing
if (!peerListeners?.size && !this.listeners.size) {
return;
}
const knownState = peer.knownStates.get(id) ?? emptyKnownState(id);
const fullyUploadedIntoPeer = this.getIsCoValueFullyUploadedIntoPeer(
peerId,
id,
);
for (const listener of this.listeners) {
listener(peerId, knownState, fullyUploadedIntoPeer);
}
if (!peerListeners) return;
for (const listener of peerListeners) {
listener(knownState, fullyUploadedIntoPeer);
}
}
getIsCoValueFullyUploadedIntoPeer(peerId: PeerID, id: RawCoID) {
const peer = this.syncManager.peers[peerId];
const entry = this.syncManager.local.coValues[id];
if (!peer || !entry) {
return false;
}
if (entry.state.type !== "available") {
return false;
}
const coValue = entry.state.coValue;
const knownState = peer.knownStates.get(id);
if (!knownState) {
return false;
}
return getIsUploadCompleted(
coValue.knownState().sessions,
knownState.sessions,
);
}
}
function getIsUploadCompleted(
from: Record<string, number>,
to: Record<string, number>,
) {
for (const sessionId of Object.keys(from)) {
if (from[sessionId] !== to[sessionId]) {
return false;
}
}
return true;
}

View File

@@ -1,4 +1,4 @@
import { Result, err, ok } from "neverthrow";
import { Result, ok } from "neverthrow";
import { CoID, RawCoValue } from "../coValue.js";
import {
CoValueCore,

View File

@@ -1,4 +1,5 @@
import { PeerState } from "./PeerState.js";
import { SyncStateSubscriptionManager } from "./SyncStateSubscriptionManager.js";
import { CoValueHeader, Transaction } from "./coValueCore.js";
import { CoValueCore } from "./coValueCore.js";
import { CoValueState } from "./coValueState.js";
@@ -116,8 +117,11 @@ export class SyncManager {
constructor(local: LocalNode) {
this.local = local;
this.syncStateSubscriptionManager = new SyncStateSubscriptionManager(this);
}
syncStateSubscriptionManager: SyncStateSubscriptionManager;
peersInPriorityOrder(): PeerState[] {
return Object.values(this.peers).sort((a, b) => {
const aPriority = a.priority || 0;
@@ -127,6 +131,10 @@ export class SyncManager {
});
}
getPeers(): PeerState[] {
return Object.values(this.peers);
}
async loadFromPeers(id: RawCoID, forPeer?: PeerID) {
const eligiblePeers = this.peersInPriorityOrder().filter(
(peer) => peer.id !== forPeer && peer.isServerOrStoragePeer(),
@@ -135,6 +143,12 @@ export class SyncManager {
const coValueEntry = this.local.coValues[id];
for (const peer of eligiblePeers) {
if (peer.erroredCoValues.has(id)) {
console.error(
`Skipping load on errored coValue ${id} from peer ${peer.id}`,
);
continue;
}
await peer.pushOutgoingMessage({
action: "load",
id: id,
@@ -149,6 +163,12 @@ export class SyncManager {
}
async handleSyncMessage(msg: SyncMessage, peer: PeerState) {
if (peer.erroredCoValues.has(msg.id)) {
console.error(
`Skipping message ${msg.action} on errored coValue ${msg.id} from peer ${peer.id}`,
);
return;
}
// TODO: validate
switch (msg.action) {
case "load":
@@ -298,9 +318,20 @@ export class SyncManager {
}
addPeer(peer: Peer) {
const peerState = new PeerState(peer);
const prevPeer = this.peers[peer.id];
const peerState = new PeerState(peer, prevPeer?.knownStates);
this.peers[peer.id] = peerState;
if (prevPeer && !prevPeer.closed) {
prevPeer.gracefulShutdown();
}
const unsubscribeFromKnownStatesUpdates = peerState.knownStates.subscribe(
(id) => {
this.syncStateSubscriptionManager.triggerUpdate(peer.id, id);
},
);
if (peerState.isServerOrStoragePeer()) {
const initialSync = async () => {
for (const id of Object.keys(this.local.coValues) as RawCoID[]) {
@@ -358,8 +389,9 @@ export class SyncManager {
}
})
.finally(() => {
peer.outgoing.close();
delete this.peers[peer.id];
const state = this.peers[peer.id];
state?.gracefulShutdown();
unsubscribeFromKnownStatesUpdates();
});
}
@@ -368,7 +400,7 @@ export class SyncManager {
}
async handleLoad(msg: LoadMessage, peer: PeerState) {
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "SET",
id: msg.id,
value: knownStateIn(msg),
@@ -422,7 +454,7 @@ export class SyncManager {
const loaded = await entry.state.ready;
if (loaded === "unavailable") {
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "SET",
id: msg.id,
value: knownStateIn(msg),
@@ -449,7 +481,7 @@ export class SyncManager {
async handleKnownState(msg: KnownStateMessage, peer: PeerState) {
let entry = this.local.coValues[msg.id];
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "COMBINE_WITH",
id: msg.id,
value: knownStateIn(msg),
@@ -514,7 +546,7 @@ export class SyncManager {
return;
}
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "UPDATE_HEADER",
id: msg.id,
header: true,
@@ -603,10 +635,11 @@ export class SyncManager {
"our last known tx idx now: " +
coValue.sessionLogs.get(sessionID)?.transactions.length,
);
peer.erroredCoValues.set(msg.id, result.error);
continue;
}
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "UPDATE_SESSION_COUNTER",
id: msg.id,
sessionId: sessionID,
@@ -616,8 +649,6 @@ export class SyncManager {
});
}
await this.syncCoValue(coValue);
if (invalidStateAssumed) {
this.trySendToPeer(peer, {
action: "known",
@@ -626,11 +657,32 @@ export class SyncManager {
}).catch((e) => {
console.error("Error sending known state correction", e);
});
} else {
/**
* We are sending a known state message to the peer to acknowledge the
* receipt of the new content.
*
* This way the sender knows that the content has been received and applied
* and can update their peer's knownState accordingly.
*/
this.trySendToPeer(peer, {
action: "known",
...coValue.knownState(),
}).catch((e: unknown) => {
console.error("Error sending known state", e);
});
}
/**
* We do send a correction/ack message before syncing to give an immediate
* response to the peers that are waiting for confirmation that a coValue is
* fully synced
*/
await this.syncCoValue(coValue);
}
async handleCorrection(msg: KnownStateMessage, peer: PeerState) {
peer.optimisticKnownStates.dispatch({
peer.dispatchToKnownStates({
type: "SET",
id: msg.id,
value: knownStateIn(msg),
@@ -670,6 +722,8 @@ export class SyncManager {
async actuallySyncCoValue(coValue: CoValueCore) {
// let blockingSince = performance.now();
for (const peer of this.peersInPriorityOrder()) {
if (peer.closed) continue;
if (peer.erroredCoValues.has(coValue.id)) continue;
// if (performance.now() - blockingSince > 5) {
// await new Promise<void>((resolve) => {
// setTimeout(resolve, 0);
@@ -684,6 +738,35 @@ export class SyncManager {
await this.sendNewContentIncludingDependencies(coValue.id, peer);
}
}
for (const peer of this.getPeers()) {
this.syncStateSubscriptionManager.triggerUpdate(peer.id, coValue.id);
}
}
async waitForUploadIntoPeer(peerId: PeerID, id: RawCoID) {
const isAlreadyUploaded =
this.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
peerId,
id,
);
if (isAlreadyUploaded) {
return true;
}
return new Promise((resolve) => {
const unsubscribe =
this.syncStateSubscriptionManager.subscribeToPeerUpdates(
peerId,
(knownState, uploadCompleted) => {
if (uploadCompleted && knownState.id === id) {
resolve(true);
unsubscribe?.();
}
},
);
});
}
gracefulShutdown() {

View File

@@ -1,4 +1,5 @@
import { describe, expect, test, vi } from "vitest";
import { PeerKnownStateActions } from "../PeerKnownStates.js";
import { PeerState } from "../PeerState.js";
import { CO_VALUE_PRIORITY } from "../priority.js";
import { Peer, SyncMessage } from "../sync.js";
@@ -15,7 +16,7 @@ function setup() {
close: vi.fn(),
},
};
const peerState = new PeerState(mockPeer);
const peerState = new PeerState(mockPeer, undefined);
return { mockPeer, peerState };
}
@@ -115,4 +116,46 @@ describe("PeerState", () => {
contentMessageMid,
);
});
test("should clone the knownStates into optimisticKnownStates and knownStates when passed as argument", () => {
const { peerState, mockPeer } = setup();
const action: PeerKnownStateActions = {
type: "SET",
id: "co_z1",
value: {
id: "co_z1",
header: false,
sessions: {},
},
};
peerState.dispatchToKnownStates(action);
const newPeerState = new PeerState(mockPeer, peerState.knownStates);
expect(newPeerState.knownStates).toEqual(peerState.knownStates);
expect(newPeerState.optimisticKnownStates).toEqual(peerState.knownStates);
});
test("should dispatch to both states", () => {
const { peerState } = setup();
const knownStatesSpy = vi.spyOn(peerState.knownStates, "dispatch");
const optimisticKnownStatesSpy = vi.spyOn(
peerState.optimisticKnownStates,
"dispatch",
);
const action: PeerKnownStateActions = {
type: "SET",
id: "co_z1",
value: {
id: "co_z1",
header: false,
sessions: {},
},
};
peerState.dispatchToKnownStates(action);
expect(knownStatesSpy).toHaveBeenCalledWith(action);
expect(optimisticKnownStatesSpy).toHaveBeenCalledWith(action);
});
});

View File

@@ -0,0 +1,232 @@
import { describe, expect, onTestFinished, test, vi } from "vitest";
import { connectedPeers } from "../streamUtils.js";
import { emptyKnownState } from "../sync.js";
import { createTestNode, waitFor } from "./testUtils.js";
describe("SyncStateSubscriptionManager", () => {
test("subscribeToUpdates receives updates when peer state changes", async () => {
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
// Connect nodes
const [clientAsPeer, jazzCloudAsPeer] = connectedPeers(
"clientConnection",
"jazzCloudConnection",
{
peer1role: "client",
peer2role: "server",
},
);
client.syncManager.addPeer(jazzCloudAsPeer);
jazzCloud.syncManager.addPeer(clientAsPeer);
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
const updateSpy = vi.fn();
const unsubscribe = subscriptionManager.subscribeToUpdates(updateSpy);
await client.syncManager.actuallySyncCoValue(map.core);
expect(updateSpy).toHaveBeenCalledWith(
"jazzCloudConnection",
emptyKnownState(map.core.id),
false,
);
await waitFor(() => {
return subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
expect(updateSpy).toHaveBeenCalledWith(
"jazzCloudConnection",
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
true,
);
// Cleanup
unsubscribe();
});
test("subscribeToPeerUpdates receives updates only for specific peer", async () => {
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
// Connect nodes
const [clientAsPeer, jazzCloudAsPeer] = connectedPeers(
"clientConnection",
"jazzCloudConnection",
{
peer1role: "client",
peer2role: "server",
},
);
const [clientStoragePeer] = connectedPeers("clientStorage", "unusedPeer", {
peer1role: "client",
peer2role: "server",
});
client.syncManager.addPeer(jazzCloudAsPeer);
client.syncManager.addPeer(clientStoragePeer);
jazzCloud.syncManager.addPeer(clientAsPeer);
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
const updateToJazzCloudSpy = vi.fn();
const updateToStorageSpy = vi.fn();
const unsubscribe1 = subscriptionManager.subscribeToPeerUpdates(
"jazzCloudConnection",
updateToJazzCloudSpy,
);
const unsubscribe2 = subscriptionManager.subscribeToPeerUpdates(
"clientStorage",
updateToStorageSpy,
);
onTestFinished(() => {
unsubscribe1();
unsubscribe2();
});
await client.syncManager.actuallySyncCoValue(map.core);
expect(updateToJazzCloudSpy).toHaveBeenCalledWith(
emptyKnownState(map.core.id),
false,
);
await waitFor(() => {
return subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
expect(updateToJazzCloudSpy).toHaveBeenLastCalledWith(
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
true,
);
expect(updateToStorageSpy).toHaveBeenLastCalledWith(
emptyKnownState(map.core.id),
false,
);
});
test("getIsCoValueFullyUploadedIntoPeer returns correct status", async () => {
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
// Connect nodes
const [clientAsPeer, jazzCloudAsPeer] = connectedPeers(
"clientConnection",
"jazzCloudConnection",
{
peer1role: "client",
peer2role: "server",
},
);
client.syncManager.addPeer(jazzCloudAsPeer);
jazzCloud.syncManager.addPeer(clientAsPeer);
await client.syncManager.actuallySyncCoValue(map.core);
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
expect(
subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
),
).toBe(false);
await waitFor(() => {
return subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
expect(
subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
),
).toBe(true);
});
test("unsubscribe stops receiving updates", async () => {
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
// Connect nodes
const [clientAsPeer, jazzCloudAsPeer] = connectedPeers(
"clientConnection",
"jazzCloudConnection",
{
peer1role: "client",
peer2role: "server",
},
);
client.syncManager.addPeer(jazzCloudAsPeer);
jazzCloud.syncManager.addPeer(clientAsPeer);
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
const anyUpdateSpy = vi.fn();
const unsubscribe1 = subscriptionManager.subscribeToUpdates(anyUpdateSpy);
const unsubscribe2 = subscriptionManager.subscribeToPeerUpdates(
"jazzCloudConnection",
anyUpdateSpy,
);
unsubscribe1();
unsubscribe2();
await client.syncManager.actuallySyncCoValue(map.core);
anyUpdateSpy.mockClear();
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
expect(anyUpdateSpy).not.toHaveBeenCalled();
});
});

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "vitest";
import { describe, expect, test, vi } from "vitest";
import { expectMap } from "../coValue.js";
import { CoValueHeader } from "../coValueCore.js";
import { RawAccountID } from "../coValues/account.js";
@@ -10,7 +10,11 @@ import { LocalNode } from "../localNode.js";
import { getPriorityFromHeader } from "../priority.js";
import { connectedPeers, newQueuePair } from "../streamUtils.js";
import { SyncMessage } from "../sync.js";
import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
import {
createTestNode,
randomAnonymousAccountAndSessionID,
waitFor,
} from "./testUtils.js";
const Crypto = await WasmCrypto.create();
@@ -1561,6 +1565,310 @@ describe("sync - extra tests", () => {
});
});
function createTwoConnectedNodes() {
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Connect nodes initially
const [connectionWithClientAsPeer, jazzCloudConnectionAsPeer] =
connectedPeers("connectionWithClient", "jazzCloudConnection", {
peer1role: "client",
peer2role: "server",
});
client.syncManager.addPeer(jazzCloudConnectionAsPeer);
jazzCloud.syncManager.addPeer(connectionWithClientAsPeer);
return {
client,
jazzCloud,
connectionWithClientAsPeer,
jazzCloudConnectionAsPeer,
};
}
describe("SyncManager - knownStates vs optimisticKnownStates", () => {
test("knownStates and optimisticKnownStates are the same when the coValue is fully synced", async () => {
const { client, jazzCloud } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const mapOnClient = group.createMap();
mapOnClient.set("key1", "value1", "trusting");
await client.syncManager.actuallySyncCoValue(mapOnClient.core);
// Wait for the full sync to complete
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
mapOnClient.core.id,
);
});
const peerStateClient = client.syncManager.peers["jazzCloudConnection"]!;
const peerStateJazzCloud =
jazzCloud.syncManager.peers["connectionWithClient"]!;
// The optimisticKnownStates should be the same as the knownStates after the full sync is complete
expect(
peerStateClient.optimisticKnownStates.get(mapOnClient.core.id),
).toEqual(peerStateClient.knownStates.get(mapOnClient.core.id));
// On the other node the knownStates should be updated correctly based on the messages we received
expect(
peerStateJazzCloud.optimisticKnownStates.get(mapOnClient.core.id),
).toEqual(peerStateJazzCloud.knownStates.get(mapOnClient.core.id));
});
test("optimisticKnownStates is updated as new transactions are sent, while knownStates only when the updates are acknowledged", async () => {
const { client, jazzCloudConnectionAsPeer } = createTwoConnectedNodes();
// Create test data and sync the first change
// We want that both the nodes know about the coValue so we can test
// the content acknowledgement flow.
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
await client.syncManager.actuallySyncCoValue(map.core);
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
// Block the content messages
// The main difference between optimisticKnownStates and knownStates is that
// optimisticKnownStates is updated when the content messages are sent,
// while knownStates is only updated when we receive the "known" messages
// that are acknowledging the receipt of the content messages
const push = jazzCloudConnectionAsPeer.outgoing.push;
const pushSpy = vi.spyOn(jazzCloudConnectionAsPeer.outgoing, "push");
const blockedMessages: SyncMessage[] = [];
pushSpy.mockImplementation(async (msg) => {
if (msg.action === "content") {
blockedMessages.push(msg);
return Promise.resolve();
}
return push.call(jazzCloudConnectionAsPeer.outgoing, msg);
});
map.set("key2", "value2", "trusting");
await client.syncManager.actuallySyncCoValue(map.core);
const peerState = client.syncManager.peers["jazzCloudConnection"]!;
expect(peerState.optimisticKnownStates.get(map.core.id)).not.toEqual(
peerState.knownStates.get(map.core.id),
);
// Restore the implementation of push and send the blocked messages
// After this the full sync can be completed and the other node will
// respond with a "known" message acknowledging the receipt of the content messages
pushSpy.mockRestore();
for (const msg of blockedMessages) {
await jazzCloudConnectionAsPeer.outgoing.push(msg);
}
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
expect(peerState.optimisticKnownStates.get(map.core.id)).toEqual(
peerState.knownStates.get(map.core.id),
);
});
});
describe("SyncManager.addPeer", () => {
test("new peer gets a copy of previous peer's knownStates when replacing it", async () => {
const { client } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
await client.syncManager.actuallySyncCoValue(map.core);
// Wait for initial sync
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
// Store the initial known states
const initialKnownStates =
client.syncManager.peers["jazzCloudConnection"]!.knownStates;
// Create new connection with same ID
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
// Add new peer with same ID
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify that the new peer has a copy of the previous known states
const newPeerKnownStates =
client.syncManager.peers["jazzCloudConnection"]!.knownStates;
expect(newPeerKnownStates).not.toBe(initialKnownStates); // Should be a different instance
expect(newPeerKnownStates.get(map.core.id)).toEqual(
initialKnownStates.get(map.core.id),
);
});
test("new peer with new ID starts with empty knownStates", async () => {
const { client } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
await client.syncManager.actuallySyncCoValue(map.core);
// Wait for initial sync
await waitFor(() => {
return client.syncManager.syncStateSubscriptionManager.getIsCoValueFullyUploadedIntoPeer(
"jazzCloudConnection",
map.core.id,
);
});
// Connect second peer with different ID
const [brandNewPeer] = connectedPeers("brandNewPeer", "unusedPeer", {
peer1role: "client",
peer2role: "server",
});
// Add new peer with different ID
client.syncManager.addPeer(brandNewPeer);
// Verify that the new peer starts with empty known states
const newPeerKnownStates =
client.syncManager.peers["brandNewPeer"]!.knownStates;
expect(newPeerKnownStates.get(map.core.id)).toBe(undefined);
});
test("when adding a peer with the same ID as a previous peer, the previous peer is closed", async () => {
const { client } = createTwoConnectedNodes();
// Store reference to first peer
const firstPeer = client.syncManager.peers["jazzCloudConnection"]!;
const closeSpy = vi.spyOn(firstPeer, "gracefulShutdown");
// Create and add replacement peer
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify thet the first peer had ben closed correctly
expect(closeSpy).toHaveBeenCalled();
expect(firstPeer.closed).toBe(true);
});
test("when adding a peer with the same ID as a previous peer and the previous peer is closed, do not attempt to close it again", async () => {
const { client } = createTwoConnectedNodes();
// Store reference to first peer
const firstPeer = client.syncManager.peers["jazzCloudConnection"]!;
firstPeer.gracefulShutdown();
const closeSpy = vi.spyOn(firstPeer, "gracefulShutdown");
// Create and add replacement peer
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify thet the first peer had not been closed again
expect(closeSpy).not.toHaveBeenCalled();
expect(firstPeer.closed).toBe(true);
});
});
describe("waitForUploadIntoPeer", () => {
test("should resolve when the coValue is fully uploaded into the peer", async () => {
const { client, jazzCloudConnectionAsPeer: peer } =
createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
await client.syncManager.actuallySyncCoValue(map.core);
await expect(
Promise.race([
client.syncManager.waitForUploadIntoPeer(peer.id, map.core.id),
new Promise((_, reject) =>
setTimeout(() => reject(new Error("Timeout")), 100),
),
]),
).resolves.toBe(true);
});
test("should not resolve when the coValue is not synced", async () => {
const { client, jazzCloudConnectionAsPeer: peer } =
createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
vi.spyOn(peer.outgoing, "push").mockImplementation(async () => {
return Promise.resolve();
});
await client.syncManager.actuallySyncCoValue(map.core);
await expect(
Promise.race([
client.syncManager.waitForUploadIntoPeer(peer.id, map.core.id),
new Promise((_, reject) =>
setTimeout(() => reject(new Error("Timeout")), 100),
),
]),
).rejects.toThrow("Timeout");
});
});
function groupContentEx(group: RawGroup) {
return {
action: "content",

View File

@@ -18,6 +18,11 @@ export function randomAnonymousAccountAndSessionID(): [
return [new ControlledAgent(agentSecret, Crypto), sessionID];
}
export function createTestNode() {
const [admin, session] = randomAnonymousAccountAndSessionID();
return new LocalNode(admin, session, Crypto);
}
export function newGroup() {
const [admin, sessionID] = randomAnonymousAccountAndSessionID();
@@ -93,3 +98,31 @@ export function shouldNotResolve<T>(
setTimeout(resolve, ops.timeout);
});
}
export function waitFor(callback: () => boolean | void) {
return new Promise<void>((resolve, reject) => {
const checkPassed = () => {
try {
return { ok: callback(), error: null };
} catch (error) {
return { ok: false, error };
}
};
let retries = 0;
const interval = setInterval(() => {
const { ok, error } = checkPassed();
if (ok !== false) {
clearInterval(interval);
resolve();
}
if (++retries > 10) {
clearInterval(interval);
reject(error);
}
}, 100);
});
}

View File

@@ -1,5 +1,48 @@
# jazz-browser-media-images
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-browser@0.8.21
## 0.8.20
### Patch Changes
- jazz-browser@0.8.20
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-browser@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-browser@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-browser@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,14 +1,14 @@
{
"name": "jazz-browser-auth-clerk",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "workspace:0.8.16",
"jazz-browser": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16"
"cojson": "workspace:0.8.21",
"jazz-browser": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21"
},
"scripts": {
"format-and-lint": "biome check .",

View File

@@ -1,5 +1,40 @@
# jazz-browser-media-images
## 0.8.21
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
- jazz-browser@0.8.21
## 0.8.20
### Patch Changes
- jazz-browser@0.8.20
## 0.8.19
### Patch Changes
- jazz-browser@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- jazz-browser@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- jazz-browser@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser-media-images",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",
@@ -8,8 +8,8 @@
"dependencies": {
"@types/image-blob-reduce": "^4.1.1",
"image-blob-reduce": "^4.1.0",
"jazz-browser": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"jazz-browser": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"pica": "^9.0.1",
"typescript": "^5.3.3"
},

View File

@@ -1,5 +1,54 @@
# jazz-browser
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- cojson-storage-indexeddb@0.8.21
- cojson-transport-ws@0.8.21
## 0.8.20
### Patch Changes
- Updated dependencies [3ef3ff3]
- cojson-storage-indexeddb@0.8.20
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- cojson-storage-indexeddb@0.8.19
- cojson-transport-ws@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- cojson-storage-indexeddb@0.8.18
- cojson-transport-ws@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- Updated dependencies [b6162f0]
- cojson@0.8.17
- cojson-transport-ws@0.8.17
- cojson-storage-indexeddb@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,16 +1,16 @@
{
"name": "jazz-browser",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"@scure/bip39": "^1.3.0",
"cojson": "workspace:0.8.16",
"cojson-storage-indexeddb": "workspace:0.8.16",
"cojson-transport-ws": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"cojson-storage-indexeddb": "workspace:0.8.21",
"cojson-transport-ws": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"typescript": "^5.3.3"
},
"scripts": {

View File

@@ -1,5 +1,43 @@
# jazz-autosub
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- cojson-transport-ws@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- cojson-transport-ws@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- cojson-transport-ws@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- Updated dependencies [b6162f0]
- cojson@0.8.17
- cojson-transport-ws@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -5,11 +5,11 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.8.16",
"version": "0.8.21",
"dependencies": {
"cojson": "workspace:0.8.16",
"cojson-transport-ws": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"cojson-transport-ws": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21",
"ws": "^8.14.2"
},
"devDependencies": {

View File

@@ -1,5 +1,57 @@
# jazz-browser-media-images
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-browser-auth-clerk@0.8.21
- jazz-react@0.8.21
## 0.8.20
### Patch Changes
- Updated dependencies [dd9b13f]
- Updated dependencies [a69ed0b]
- Updated dependencies [3ef3ff3]
- Updated dependencies [c6931b8]
- jazz-react@0.8.20
- jazz-browser-auth-clerk@0.8.20
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-browser-auth-clerk@0.8.19
- jazz-react@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-browser-auth-clerk@0.8.18
- jazz-react@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-browser-auth-clerk@0.8.17
- jazz-react@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,15 +1,15 @@
{
"name": "jazz-react-auth-clerk",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "dist/index.js",
"types": "src/index.tsx",
"license": "MIT",
"dependencies": {
"cojson": "workspace:0.8.16",
"jazz-browser-auth-clerk": "workspace:0.8.16",
"jazz-react": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16"
"cojson": "workspace:0.8.21",
"jazz-browser-auth-clerk": "workspace:0.8.21",
"jazz-react": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21"
},
"peerDependencies": {
"react": "^18.2.0"

View File

@@ -1,5 +1,36 @@
# jazz-browser-media-images
## 0.8.17
### Patch Changes
- Updated dependencies [149ca97]
- jazz-tools@0.8.21
## 0.8.16
### Patch Changes
- 3ef3ff3: Remove typescript from the direct dependencies
## 0.8.15
### Patch Changes
- jazz-tools@0.8.19
## 0.8.14
### Patch Changes
- jazz-tools@0.8.18
## 0.8.13
### Patch Changes
- jazz-tools@0.8.17
## 0.8.12
### Patch Changes

View File

@@ -1,18 +1,18 @@
{
"name": "jazz-react-native-media-images",
"version": "0.8.12",
"version": "0.8.17",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"jazz-tools": "workspace:*",
"typescript": "^5.3.3"
"jazz-tools": "workspace:*"
},
"devDependencies": {
"@bam.tech/react-native-image-resizer": "^3.0.10",
"expo-file-system": "^17.0.1",
"react-native": "~0.74.5"
"react-native": "~0.74.5",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@bam.tech/react-native-image-resizer": "*",

View File

@@ -1,5 +1,49 @@
# jazz-browser
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- cojson-transport-ws@0.8.21
## 0.8.20
### Patch Changes
- 3ef3ff3: Remove typescript from the direct dependencies
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- cojson-transport-ws@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- cojson-transport-ws@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- Updated dependencies [b6162f0]
- cojson@0.8.17
- cojson-transport-ws@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-react-native",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -18,8 +18,7 @@
"@scure/bip39": "^1.3.0",
"cojson": "workspace:*",
"cojson-transport-ws": "workspace:*",
"jazz-tools": "workspace:*",
"typescript": "^5.3.3"
"jazz-tools": "workspace:*"
},
"peerDependencies": {
"@react-native-community/netinfo": "*",
@@ -31,7 +30,8 @@
"@react-native-community/netinfo": "^11.3.1",
"expo-linking": "~6.3.1",
"expo-secure-store": "~13.0.2",
"react-native": "~0.74.5"
"react-native": "~0.74.5",
"typescript": "^5.3.3"
},
"scripts": {
"dev": "tsc --watch --sourceMap --outDir dist",

View File

@@ -1,5 +1,52 @@
# jazz-react
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-browser@0.8.21
## 0.8.20
### Patch Changes
- dd9b13f: Move auto login check to useEffect
- a69ed0b: Fix the Jazz.Provider initialization when multiple storage options are provided
- 3ef3ff3: Remove typescript from the direct dependencies
- c6931b8: Add user prop to demo auth to skip login on demos
- jazz-browser@0.8.20
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-browser@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-browser@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-browser@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -1,21 +1,21 @@
{
"name": "jazz-react",
"version": "0.8.16",
"version": "0.8.21",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"@scure/bip39": "^1.3.0",
"cojson": "workspace:0.8.16",
"jazz-browser": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.16",
"typescript": "^5.3.3"
"cojson": "workspace:0.8.21",
"jazz-browser": "workspace:0.8.21",
"jazz-tools": "workspace:0.8.21"
},
"devDependencies": {
"@types/react": "^18.2.19",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"typescript": "^5.3.3"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",

View File

@@ -1,7 +1,7 @@
import { AgentSecret } from "cojson";
import { BrowserDemoAuth } from "jazz-browser";
import { Account, ID } from "jazz-tools";
import { useMemo, useState } from "react";
import { useEffect, useMemo, useState } from "react";
type DemoAuthState = (
| {
@@ -69,9 +69,11 @@ export function useDemoAuth({
export const DemoAuthBasicUI = ({
appName,
state,
user,
}: {
appName: string;
state: DemoAuthState;
user?: string;
}) => {
const [username, setUsername] = useState<string>("");
const darkMode =
@@ -79,6 +81,20 @@ export const DemoAuthBasicUI = ({
? window.matchMedia("(prefers-color-scheme: dark)").matches
: false;
const isAutoLogin = !!(user && state.state === "ready");
useEffect(() => {
if (!isAutoLogin) return;
if (state.existingUsers.includes(user)) {
state.logInAs(user);
} else {
state.signUp(user);
}
}, [isAutoLogin]);
if (isAutoLogin) return <></>;
return (
<div
style={{

View File

@@ -50,72 +50,75 @@ export function createJazzReactApp<Acc extends Account>({
const effectExecuted = useRef(false);
effectExecuted.current = false;
useEffect(() => {
// Avoid double execution of the effect in development mode for easier debugging.
if (process.env.NODE_ENV === "development") {
if (effectExecuted.current) {
return;
useEffect(
() => {
// Avoid double execution of the effect in development mode for easier debugging.
if (process.env.NODE_ENV === "development") {
if (effectExecuted.current) {
return;
}
effectExecuted.current = true;
// In development mode we don't return a cleanup function because otherwise
// the double effect execution would mark the context as done immediately.
//
// So we mark it as done in the subsequent execution.
const previousContext = ctx;
if (previousContext) {
previousContext.done();
}
}
effectExecuted.current = true;
async function createContext() {
const currentContext = await createJazzBrowserContext<Acc>(
auth === "guest"
? {
peer,
storage,
}
: {
AccountSchema,
auth,
peer,
storage,
},
);
const logOut = () => {
currentContext.logOut();
setCtx(undefined);
setSessionCount(sessionCount + 1);
if (process.env.NODE_ENV === "development") {
// In development mode we don't return a cleanup function
// so we mark the context as done here.
currentContext.done();
}
};
setCtx({
...currentContext,
logOut,
});
return currentContext;
}
const promise = createContext();
// In development mode we don't return a cleanup function because otherwise
// the double effect execution would mark the context as done immediately.
//
// So we mark it as done in the subsequent execution.
const previousContext = ctx;
if (previousContext) {
previousContext.done();
if (process.env.NODE_ENV === "development") {
return;
}
}
async function createContext() {
const currentContext = await createJazzBrowserContext<Acc>(
auth === "guest"
? {
peer,
storage,
}
: {
AccountSchema,
auth,
peer,
storage,
},
);
const logOut = () => {
currentContext.logOut();
setCtx(undefined);
setSessionCount(sessionCount + 1);
if (process.env.NODE_ENV === "development") {
// In development mode we don't return a cleanup function
// so we mark the context as done here.
currentContext.done();
}
return () => {
void promise.then((context) => context.done());
};
setCtx({
...currentContext,
logOut,
});
return currentContext;
}
const promise = createContext();
// In development mode we don't return a cleanup function because otherwise
// the double effect execution would mark the context as done immediately.
if (process.env.NODE_ENV === "development") {
return;
}
return () => {
void promise.then((context) => context.done());
};
}, [AccountSchema, auth, peer, storage, sessionCount]);
},
[AccountSchema, auth, peer, sessionCount].concat(storage as any),
);
return (
<JazzContext.Provider value={ctx}>{ctx && children}</JazzContext.Provider>

View File

@@ -1,5 +1,48 @@
# jazz-run
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- cojson-storage-sqlite@0.8.21
- cojson-transport-ws@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- cojson-storage-sqlite@0.8.19
- cojson-transport-ws@0.8.19
- jazz-tools@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- cojson-storage-sqlite@0.8.18
- cojson-transport-ws@0.8.18
- jazz-tools@0.8.18
## 0.8.17
### Patch Changes
- d433cf4: Improve the sync wait using the new API from the sync manager
- Updated dependencies [d433cf4]
- Updated dependencies [b6162f0]
- cojson@0.8.17
- cojson-transport-ws@0.8.17
- cojson-storage-sqlite@0.8.17
- jazz-tools@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -3,7 +3,7 @@
"bin": "./dist/index.js",
"type": "module",
"license": "MIT",
"version": "0.8.16",
"version": "0.8.21",
"scripts": {
"format-and-lint": "biome check .",
"format-and-lint:fix": "biome check . --write",
@@ -18,11 +18,11 @@
"@effect/printer-ansi": "^0.34.5",
"@effect/schema": "^0.71.1",
"@effect/typeclass": "^0.25.5",
"cojson": "workspace:0.8.16",
"cojson-storage-sqlite": "workspace:0.8.16",
"cojson-transport-ws": "workspace:0.8.16",
"cojson": "workspace:0.8.21",
"cojson-storage-sqlite": "workspace:0.8.21",
"cojson-transport-ws": "workspace:0.8.21",
"effect": "^3.6.5",
"jazz-tools": "workspace:0.8.16",
"jazz-tools": "workspace:0.8.21",
"ws": "^8.14.2"
},
"devDependencies": {

View File

@@ -47,8 +47,8 @@ export const createWorkerAccount = async ({
await Promise.race([
Promise.all([
waitForSync(account, peer, accountCoValue),
waitForSync(account, peer, accountProfileCoValue),
syncManager.waitForUploadIntoPeer(peer.id, accountCoValue.id),
syncManager.waitForUploadIntoPeer(peer.id, accountProfileCoValue.id),
]),
failAfter(
4_000,
@@ -73,7 +73,7 @@ export const createWorkerAccount = async ({
peersToLoadFrom: [peer2],
crypto,
}),
failAfter(4_000, "Timeout: Account loading check failed"),
failAfter(10_000, "Timeout: Account loading check failed"),
]);
return {
@@ -82,62 +82,6 @@ export const createWorkerAccount = async ({
};
};
function waitForSync(account: Account, peer: Peer, coValue: CoValueCore) {
const syncManager = account._raw.core.node.syncManager;
const peerState = syncManager.peers[peer.id];
if (!peerState) {
throw new Error(`Peer state for ${peer.id} not found`);
}
const isSynced = () => {
const knownState = coValue.knownState();
if (!peerState.optimisticKnownStates.get(coValue.id)) {
return false;
}
return isEqualSession(
knownState.sessions,
peerState.optimisticKnownStates.get(coValue.id)?.sessions ?? {},
);
};
if (isSynced()) {
return Promise.resolve(true);
}
return new Promise((resolve) => {
const unsubscribe = peerState?.optimisticKnownStates.subscribe(
(id, knownState) => {
if (id !== coValue.id) return;
if (isSynced()) {
resolve(true);
unsubscribe?.();
}
},
);
});
}
function isEqualSession(a: Record<string, number>, b: Record<string, number>) {
const keysA = Object.keys(a);
const keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
for (const sessionId of keysA) {
if (a[sessionId] !== b[sessionId]) {
return false;
}
}
return true;
}
function failAfter(ms: number, errorMessage: string) {
return new Promise((_, reject) => {
setTimeout(() => reject(new Error(errorMessage)), ms);

View File

@@ -1,5 +1,34 @@
# jazz-tools
## 0.8.21
### Patch Changes
- 149ca97: changed jazz-tools TS target to ES2021
- Updated dependencies [0f30eea]
- cojson@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
## 0.8.16
### Patch Changes

View File

@@ -19,7 +19,7 @@
},
"type": "module",
"license": "MIT",
"version": "0.8.16",
"version": "0.8.21",
"dependencies": {
"cojson": "workspace:*",
"fast-check": "^3.17.2"

View File

@@ -2,7 +2,7 @@
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "es2022",
"target": "ES2021",
"moduleResolution": "bundler",
"moduleDetection": "force",
"strict": true,

View File

@@ -1,5 +1,48 @@
# jazz-react
## 0.8.11
### Patch Changes
- Updated dependencies [0f30eea]
- Updated dependencies [149ca97]
- cojson@0.8.21
- jazz-tools@0.8.21
- jazz-browser@0.8.21
## 0.8.10
### Patch Changes
- jazz-browser@0.8.20
## 0.8.9
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
- jazz-browser@0.8.19
- jazz-tools@0.8.19
## 0.8.8
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
- jazz-browser@0.8.18
- jazz-tools@0.8.18
## 0.8.7
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
- jazz-browser@0.8.17
- jazz-tools@0.8.17
## 0.8.6
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-vue",
"version": "0.8.6",
"version": "0.8.11",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

126
pnpm-lock.yaml generated
View File

@@ -46,7 +46,7 @@ importers:
e2e/BinaryCoStream:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/cojson
hash-slash:
specifier: workspace:0.2.1
@@ -55,10 +55,10 @@ importers:
specifier: ^3.0.1
version: 3.0.1
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
react:
specifier: 18.3.1
@@ -150,13 +150,13 @@ importers:
specifier: ^2.0.0
version: 2.0.0
jazz-browser-media-images:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-browser-media-images
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
next:
specifier: 14.2.5
@@ -205,16 +205,16 @@ importers:
specifier: ^2.0.0
version: 2.0.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/cojson
hash-slash:
specifier: workspace:0.2.1
version: link:../../packages/hash-slash
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
lucide-react:
specifier: ^0.274.0
@@ -302,19 +302,19 @@ importers:
specifier: ^2.0.0
version: 2.0.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/cojson
hash-slash:
specifier: workspace:0.2.1
version: link:../../packages/hash-slash
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-react-auth-clerk:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react-auth-clerk
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
lucide-react:
specifier: ^0.274.0
@@ -738,10 +738,10 @@ importers:
specifier: ^2.0.0
version: 2.0.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/cojson
cojson-transport-ws:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/cojson-transport-ws
hash-slash:
specifier: workspace:0.2.1
@@ -823,10 +823,10 @@ importers:
specifier: ^2.0.0
version: 2.0.0
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
lucide-react:
specifier: ^0.274.0
@@ -881,10 +881,10 @@ importers:
examples/password-manager:
dependencies:
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
react:
specifier: 18.3.1
@@ -945,13 +945,13 @@ importers:
specifier: ^2.0.0
version: 2.0.0
jazz-browser-media-images:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-browser-media-images
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
lucide-react:
specifier: ^0.274.0
@@ -1006,7 +1006,7 @@ importers:
specifier: ^3.0.1
version: 3.0.1
jazz-run:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-run
postcss:
specifier: ^8.4.27
@@ -1044,10 +1044,10 @@ importers:
specifier: ^2.0.0
version: 2.0.0
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../../packages/jazz-tools
lucide-react:
specifier: ^0.274.0
@@ -1145,11 +1145,8 @@ importers:
packages/cojson-storage-indexeddb:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
typescript:
specifier: ^5.3.3
version: 5.3.3
devDependencies:
'@vitest/browser':
specifier: ^0.34.1
@@ -1157,6 +1154,9 @@ importers:
fake-indexeddb:
specifier: ^6.0.0
version: 6.0.0
typescript:
specifier: ^5.3.3
version: 5.3.3
vitest:
specifier: 1.5.3
version: 1.5.3(@types/node@22.5.1)(@vitest/browser@0.34.6)(@vitest/ui@1.5.3)(happy-dom@15.8.3)(jsdom@20.0.3)(terser@5.33.0)
@@ -1170,7 +1170,7 @@ importers:
specifier: ^8.5.2
version: 8.7.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
typescript:
specifier: ^5.3.3
@@ -1183,7 +1183,7 @@ importers:
packages/cojson-transport-ws:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
typescript:
specifier: ^5.3.3
@@ -1211,16 +1211,16 @@ importers:
specifier: ^1.3.0
version: 1.3.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
cojson-storage-indexeddb:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson-storage-indexeddb
cojson-transport-ws:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson-transport-ws
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
typescript:
specifier: ^5.3.3
@@ -1229,13 +1229,13 @@ importers:
packages/jazz-browser-auth-clerk:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
jazz-browser:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-browser
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
devDependencies:
typescript:
@@ -1251,10 +1251,10 @@ importers:
specifier: ^4.1.0
version: 4.1.0
jazz-browser:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-browser
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
pica:
specifier: ^9.0.1
@@ -1270,13 +1270,13 @@ importers:
packages/jazz-nodejs:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
cojson-transport-ws:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson-transport-ws
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
ws:
specifier: ^8.14.2
@@ -1295,17 +1295,14 @@ importers:
specifier: ^1.3.0
version: 1.3.0
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
jazz-browser:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-browser
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
typescript:
specifier: ^5.3.3
version: 5.3.3
devDependencies:
'@types/react':
specifier: ^18.2.19
@@ -1316,20 +1313,23 @@ importers:
react-dom:
specifier: 18.3.1
version: 18.3.1(react@18.3.1)
typescript:
specifier: ^5.3.3
version: 5.3.3
packages/jazz-react-auth-clerk:
dependencies:
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
jazz-browser-auth-clerk:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-browser-auth-clerk
jazz-react:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-react
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
react:
specifier: 18.3.1
@@ -1356,9 +1356,6 @@ importers:
jazz-tools:
specifier: workspace:*
version: link:../jazz-tools
typescript:
specifier: ^5.3.3
version: 5.3.3
devDependencies:
'@react-native-community/netinfo':
specifier: ^11.3.1
@@ -1372,15 +1369,15 @@ importers:
react-native:
specifier: ~0.74.5
version: 0.74.5(@babel/core@7.25.2)(@babel/preset-env@7.25.4(@babel/core@7.25.2))(@types/react@18.2.79)(react@18.3.1)
typescript:
specifier: ^5.3.3
version: 5.3.3
packages/jazz-react-native-media-images:
dependencies:
jazz-tools:
specifier: workspace:*
version: link:../jazz-tools
typescript:
specifier: ^5.3.3
version: 5.6.2
devDependencies:
'@bam.tech/react-native-image-resizer':
specifier: ^3.0.10
@@ -1391,6 +1388,9 @@ importers:
react-native:
specifier: ~0.74.5
version: 0.74.5(@babel/core@7.25.2)(@babel/preset-env@7.25.4(@babel/core@7.25.2))(@types/react@18.2.79)(react@18.3.1)
typescript:
specifier: ^5.3.3
version: 5.6.2
packages/jazz-run:
dependencies:
@@ -1413,19 +1413,19 @@ importers:
specifier: ^0.25.5
version: 0.25.5(effect@3.6.5)
cojson:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson
cojson-storage-sqlite:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson-storage-sqlite
cojson-transport-ws:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../cojson-transport-ws
effect:
specifier: ^3.6.5
version: 3.6.5
jazz-tools:
specifier: workspace:0.8.16
specifier: workspace:0.8.21
version: link:../jazz-tools
ws:
specifier: ^8.14.2