Compare commits

..

2 Commits

Author SHA1 Message Date
Trisha Lim
95f51ea783 Update gitignore 2025-01-24 14:51:57 +08:00
Trisha Lim
82b0268c4d Fix example readme instructions 2025-01-24 14:49:54 +08:00
142 changed files with 913 additions and 2669 deletions

View File

@@ -1,54 +1,5 @@
# chat-rn-clerk
## 1.0.61
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react-native@0.9.20
- jazz-react-native-auth-clerk@0.9.20
- jazz-react-native-media-images@0.9.20
## 1.0.60
### Patch Changes
- jazz-react-native@0.9.19
- jazz-react-native-auth-clerk@0.9.19
- jazz-tools@0.9.19
- jazz-react-native-media-images@0.9.19
## 1.0.59
### Patch Changes
- jazz-react-native@0.9.18
- jazz-react-native-auth-clerk@0.9.18
- jazz-tools@0.9.18
- jazz-react-native-media-images@0.9.18
## 1.0.58
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react-native@0.9.17
- jazz-react-native-auth-clerk@0.9.17
- jazz-react-native-media-images@0.9.17
## 1.0.57
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-react-native-auth-clerk@0.9.16
- jazz-tools@0.9.16
- jazz-react-native@0.9.16
- jazz-react-native-media-images@0.9.16
## 1.0.56
### Patch Changes

View File

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

View File

@@ -1,44 +1,5 @@
# chat-rn
## 1.0.58
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react-native@0.9.20
## 1.0.57
### Patch Changes
- jazz-react-native@0.9.19
- jazz-tools@0.9.19
## 1.0.56
### Patch Changes
- jazz-react-native@0.9.18
- jazz-tools@0.9.18
## 1.0.55
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react-native@0.9.17
## 1.0.54
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react-native@0.9.16
## 1.0.53
### Patch Changes

View File

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

View File

@@ -1,49 +1,5 @@
# chat-vue
## 0.0.45
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
- jazz-vue@0.9.20
## 0.0.44
### Patch Changes
- jazz-browser@0.9.19
- jazz-tools@0.9.19
- jazz-vue@0.9.19
## 0.0.43
### Patch Changes
- jazz-browser@0.9.18
- jazz-tools@0.9.18
- jazz-vue@0.9.18
## 0.0.42
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser@0.9.17
- jazz-vue@0.9.17
## 0.0.41
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser@0.9.16
- jazz-vue@0.9.16
## 0.0.40
### Patch Changes

View File

@@ -11,6 +11,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example chat-vue --project-name chat-vue
```
or
```bash
npx create-jazz-app@latest --example chat-vue --project-name chat-vue
```

View File

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

View File

@@ -1,49 +1,5 @@
# jazz-example-chat
## 0.0.141
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.140
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.139
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.138
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.137
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.136
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example chat --project-name chat
```
or
```bash
npx create-jazz-app@latest --example chat --project-name chat
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat",
"private": true,
"version": "0.0.141",
"version": "0.0.136",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,49 +1,5 @@
# minimal-auth-clerk
## 0.0.40
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
- jazz-react-auth-clerk@0.9.20
## 0.0.39
### Patch Changes
- jazz-react@0.9.19
- jazz-react-auth-clerk@0.9.19
- jazz-tools@0.9.19
## 0.0.38
### Patch Changes
- jazz-react@0.9.18
- jazz-react-auth-clerk@0.9.18
- jazz-tools@0.9.18
## 0.0.37
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
- jazz-react-auth-clerk@0.9.17
## 0.0.36
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-react-auth-clerk@0.9.16
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.35
### Patch Changes

View File

@@ -15,6 +15,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example clerk --project-name clerk
```
or
```bash
npx create-jazz-app@latest --example clerk --project-name clerk
```

View File

@@ -1,7 +1,7 @@
{
"name": "clerk",
"private": true,
"version": "0.0.40",
"version": "0.0.35",
"type": "module",
"scripts": {
"dev": "vite",
@@ -13,7 +13,7 @@
"dependencies": {
"@clerk/clerk-react": "^5.4.1",
"jazz-react": "workspace:*",
"jazz-react-auth-clerk": "workspace:0.9.20",
"jazz-react-auth-clerk": "workspace:0.9.15",
"jazz-tools": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"

View File

@@ -1,44 +1,5 @@
# file-share-svelte
## 0.0.25
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-svelte@0.9.20
## 0.0.24
### Patch Changes
- jazz-svelte@0.9.19
- jazz-tools@0.9.19
## 0.0.23
### Patch Changes
- jazz-svelte@0.9.18
- jazz-tools@0.9.18
## 0.0.22
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-svelte@0.9.17
## 0.0.21
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-svelte@0.9.16
## 0.0.20
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "file-share-svelte",
"version": "0.0.25",
"version": "0.0.20",
"private": true,
"type": "module",
"scripts": {

View File

@@ -1,49 +1,5 @@
# form
## 0.0.36
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.35
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.34
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.33
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.32
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.31
### Patch Changes

View File

@@ -28,6 +28,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example form --project-name form
```
or
```bash
npx create-jazz-app@latest --example form --project-name form
```

View File

@@ -1,7 +1,7 @@
{
"name": "form",
"private": true,
"version": "0.0.36",
"version": "0.0.31",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,49 +1,5 @@
# image-upload
## 0.0.38
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.37
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.36
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.35
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.34
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.33
### Patch Changes

View File

@@ -15,6 +15,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example image-upload --project-name image-upload
```
or
```bash
npx create-jazz-app@latest --example image-upload --project-name image-upload
```

View File

@@ -1,7 +1,7 @@
{
"name": "image-upload",
"private": true,
"version": "0.0.38",
"version": "0.0.33",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,21 +1,5 @@
# jazz-example-inspector
## 0.0.100
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- cojson-transport-ws@0.9.19
## 0.0.99
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- cojson-transport-ws@0.9.18
## 0.0.98
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-inspector-app",
"private": true,
"version": "0.0.100",
"version": "0.0.98",
"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.9.19",
"cojson-transport-ws": "workspace:0.9.19",
"cojson": "workspace:0.9.13",
"cojson-transport-ws": "workspace:0.9.13",
"hash-slash": "workspace:0.2.1",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",

View File

@@ -1,56 +1,5 @@
# jazz-example-musicplayer
## 0.0.62
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-inspector@0.9.21
- jazz-react@0.9.20
## 0.0.61
### Patch Changes
- jazz-inspector@0.9.20
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.60
### Patch Changes
- Updated dependencies [2faf22f]
- jazz-inspector@0.9.19
## 0.0.59
### Patch Changes
- jazz-inspector@0.9.18
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.58
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-inspector@0.9.17
- jazz-react@0.9.17
## 0.0.57
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-inspector@0.9.16
- jazz-react@0.9.16
## 0.0.56
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example music-player --project-name music-player
```
or
```bash
npx create-jazz-app@latest --example music-player --project-name music-player
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-music-player",
"private": true,
"version": "0.0.62",
"version": "0.0.56",
"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.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-react": "workspace:0.9.15",
"jazz-tools": "workspace:0.9.15",
"jazz-inspector": "workspace:*",
"lucide-react": "^0.274.0",
"react": "^18.3.1",

View File

@@ -1,49 +1,5 @@
# jazz-example-onboarding
## 0.0.42
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.41
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.40
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.39
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.38
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.37
### Patch Changes

View File

@@ -11,6 +11,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example onboarding --project-name onboarding
```
or
```bash
npx create-jazz-app@latest --example onboarding --project-name onboarding
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-onboarding",
"private": true,
"version": "0.0.42",
"version": "0.0.37",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,44 +1,5 @@
# organization
## 0.0.34
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.33
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.32
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.31
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
## 0.0.30
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.29
### Patch Changes

View File

@@ -16,6 +16,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example organization --project-name organization
```
or
```bash
npx create-jazz-app@latest --example organization --project-name organization
```

View File

@@ -1,7 +1,7 @@
{
"name": "organization",
"private": true,
"version": "0.0.34",
"version": "0.0.29",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,35 +1,5 @@
# passkey-svelte
## 0.0.29
### Patch Changes
- jazz-svelte@0.9.20
## 0.0.28
### Patch Changes
- jazz-svelte@0.9.19
## 0.0.27
### Patch Changes
- jazz-svelte@0.9.18
## 0.0.26
### Patch Changes
- jazz-svelte@0.9.17
## 0.0.25
### Patch Changes
- jazz-svelte@0.9.16
## 0.0.24
### Patch Changes

View File

@@ -21,6 +21,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example passkey-svelte --project-name passkey-svelte
```
or
```bash
npx create-jazz-app@latest --example passkey-svelte --project-name passkey-svelte
```

View File

@@ -1,6 +1,6 @@
{
"name": "passkey-svelte",
"version": "0.0.29",
"version": "0.0.24",
"type": "module",
"private": true,
"scripts": {

View File

@@ -1,44 +1,5 @@
# minimal-auth-passkey
## 0.0.39
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.38
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.37
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.36
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
## 0.0.35
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.34
### Patch Changes

View File

@@ -15,6 +15,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example passkey --project-name passkey
```
or
```bash
npx create-jazz-app@latest --example passkey --project-name passkey
```

View File

@@ -1,7 +1,7 @@
{
"name": "passkey",
"private": true,
"version": "0.0.39",
"version": "0.0.34",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,44 +1,5 @@
# jazz-password-manager
## 0.0.60
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.59
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.58
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.57
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
## 0.0.56
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.55
### Patch Changes

View File

@@ -15,6 +15,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example password-manager --project-name password-manager
```
or
```bash
npx create-jazz-app@latest --example password-manager --project-name password-manager
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-password-manager",
"private": true,
"version": "0.0.60",
"version": "0.0.55",
"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.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-react": "workspace:0.9.15",
"jazz-tools": "workspace:0.9.15",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.41.5",

View File

@@ -1,49 +1,5 @@
# jazz-example-pets
## 0.0.158
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.157
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.156
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.155
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.154
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.153
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example pets --project-name pets
```
or
```bash
npx create-jazz-app@latest --example pets --project-name pets
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.158",
"version": "0.0.153",
"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.9.20",
"jazz-react": "workspace:0.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-browser-media-images": "workspace:0.9.15",
"jazz-react": "workspace:0.9.15",
"jazz-tools": "workspace:0.9.15",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.3.1",
@@ -41,7 +41,7 @@
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.20",
"is-ci": "^3.0.1",
"jazz-run": "workspace:0.9.20",
"jazz-run": "workspace:0.9.15",
"postcss": "^8.4.27",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",

View File

@@ -1,49 +1,5 @@
# reactions
## 0.0.38
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser-media-images@0.9.20
- jazz-react@0.9.20
## 0.0.37
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
- jazz-browser-media-images@0.9.19
## 0.0.36
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
- jazz-browser-media-images@0.9.18
## 0.0.35
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser-media-images@0.9.17
- jazz-react@0.9.17
## 0.0.34
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser-media-images@0.9.16
- jazz-react@0.9.16
## 0.0.33
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example reactions --project-name reactions
```
or
```bash
npx create-jazz-app@latest --example reactions --project-name reactions
```

View File

@@ -1,7 +1,7 @@
{
"name": "reactions",
"private": true,
"version": "0.0.38",
"version": "0.0.33",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,49 +1,5 @@
# todo-vue
## 0.0.43
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
- jazz-vue@0.9.20
## 0.0.42
### Patch Changes
- jazz-browser@0.9.19
- jazz-tools@0.9.19
- jazz-vue@0.9.19
## 0.0.41
### Patch Changes
- jazz-browser@0.9.18
- jazz-tools@0.9.18
- jazz-vue@0.9.18
## 0.0.40
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser@0.9.17
- jazz-vue@0.9.17
## 0.0.39
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser@0.9.16
- jazz-vue@0.9.16
## 0.0.38
### Patch Changes

View File

@@ -11,6 +11,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example todo-vue --project-name todo-vue
```
or
```bash
npx create-jazz-app@latest --example todo-vue --project-name todo-vue
```

View File

@@ -1,6 +1,6 @@
{
"name": "todo-vue",
"version": "0.0.43",
"version": "0.0.38",
"private": true,
"type": "module",
"scripts": {

View File

@@ -1,44 +1,5 @@
# jazz-example-todo
## 0.0.157
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.156
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.155
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.154
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
## 0.0.153
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.152
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example todo --project-name todo
```
or
```bash
npx create-jazz-app@latest --example todo --project-name todo
```

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.157",
"version": "0.0.152",
"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.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-react": "workspace:0.9.15",
"jazz-tools": "workspace:0.9.15",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.3.1",

View File

@@ -1,44 +1,5 @@
# version-history
## 0.0.35
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react@0.9.20
## 0.0.34
### Patch Changes
- jazz-react@0.9.19
- jazz-tools@0.9.19
## 0.0.33
### Patch Changes
- jazz-react@0.9.18
- jazz-tools@0.9.18
## 0.0.32
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react@0.9.17
## 0.0.31
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react@0.9.16
## 0.0.30
### Patch Changes

View File

@@ -13,6 +13,10 @@ You can either
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example version-history --project-name version-history
```
or
```bash
npx create-jazz-app@latest --example version-history --project-name version-history
```

View File

@@ -1,7 +1,7 @@
{
"name": "version-history",
"private": true,
"version": "0.0.35",
"version": "0.0.30",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -132,7 +132,7 @@ As you develop your app, you'll likely want to
- initialise data in a user's `root` and `profile`
- add more data to your `root` and `profile` schemas
You can achieve both by overriding the `migrate()` method on your `Account` schema class.
You can achieve both by overriding the static `migrate()` method on your `Account` schema class.
### When migrations run

View File

@@ -8,6 +8,14 @@ The Jazz docs are currently heavily work in progress, sorry about that!
Run the following command to create a new Jazz project from one of our example apps:
<CodeGroup>
```sh
npm create jazz-app@latest
```
</CodeGroup>
or
<CodeGroup>
```sh
npx create-jazz-app@latest

View File

@@ -1,21 +1,5 @@
# cojson-storage-indexeddb
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- cojson-storage@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- cojson-storage@0.9.18
## 0.9.13
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.9.19",
"version": "0.9.13",
"main": "dist/index.js",
"type": "module",
"types": "src/index.ts",

View File

@@ -1,21 +1,5 @@
# cojson-storage-sqlite
## 0.8.58
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- cojson-storage@0.9.19
## 0.8.57
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- cojson-storage@0.9.18
## 0.8.56
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-storage-rn-sqlite",
"type": "module",
"version": "0.8.58",
"version": "0.8.56",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",

View File

@@ -1,21 +1,5 @@
# cojson-storage-sqlite
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- cojson-storage@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- cojson-storage@0.9.18
## 0.9.13
### Patch Changes

View File

@@ -1,13 +1,13 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.9.19",
"version": "0.9.13",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^11.7.0",
"cojson": "workspace:0.9.19",
"cojson": "workspace:0.9.13",
"cojson-storage": "workspace:*"
},
"devDependencies": {

View File

@@ -1,19 +1,5 @@
# cojson-storage
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
## 0.9.13
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "cojson-storage",
"version": "0.9.19",
"version": "0.9.13",
"main": "dist/index.js",
"type": "module",
"types": "src/index.ts",

View File

@@ -1,19 +1,5 @@
# cojson-transport-nodejs-ws
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
## 0.9.13
### Patch Changes

View File

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

View File

@@ -1,17 +1,5 @@
# cojson
## 0.9.19
### Patch Changes
- 6ad0a9f: Export Json types
## 0.9.18
### Patch Changes
- 8898b10: Export AccountRole type
## 0.9.13
### Patch Changes

View File

@@ -24,7 +24,7 @@
},
"type": "module",
"license": "MIT",
"version": "0.9.19",
"version": "0.9.13",
"devDependencies": {
"@opentelemetry/sdk-metrics": "^1.29.0",
"@types/jest": "^29.5.3",

View File

@@ -17,8 +17,6 @@ import { OpID, RawCoList } from "./coValues/coList.js";
import { RawCoMap } from "./coValues/coMap.js";
import { RawCoPlainText, stringifyOpID } from "./coValues/coPlainText.js";
import {
BinaryStreamItem,
BinaryStreamStart,
CoStreamItem,
RawBinaryCoStream,
RawCoStream,
@@ -40,7 +38,7 @@ import {
} from "./ids.js";
import { Stringified, parseJSON, stableStringify } from "./jsonStringify.js";
import { LocalNode } from "./localNode.js";
import type { AccountRole, Role } from "./permissions.js";
import type { Role } from "./permissions.js";
import { Channel, connectedPeers } from "./streamUtils.js";
import { accountOrAgentIDfromSessionID } from "./typeUtils/accountOrAgentIDfromSessionID.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
@@ -59,7 +57,7 @@ import type {
import type { InviteSecret } from "./coValues/group.js";
import type { AgentSecret } from "./crypto/crypto.js";
import type { AgentID, RawCoID, SessionID } from "./ids.js";
import type { JsonObject, JsonValue } from "./jsonValue.js";
import type { JsonValue } from "./jsonValue.js";
import type * as Media from "./media.js";
import { disablePermissionErrors } from "./permissions.js";
import type {
@@ -130,7 +128,6 @@ export {
ControlledAgent,
RawControlledAccount,
MAX_RECOMMENDED_TX_SIZE,
JsonObject,
JsonValue,
Peer,
BinaryStreamInfo,
@@ -146,8 +143,6 @@ export {
RawCoPlainText,
stringifyOpID,
logger,
base64URLtoBytes,
bytesToBase64url,
};
export type {
@@ -162,10 +157,7 @@ export type {
CoValueUniqueness,
Stringified,
CoStreamItem,
BinaryStreamItem,
BinaryStreamStart,
OpID,
AccountRole,
};
// eslint-disable-next-line @typescript-eslint/no-namespace

View File

@@ -1,36 +1,43 @@
import { beforeEach, describe, expect, onTestFinished, test, vi } from "vitest";
import { describe, expect, onTestFinished, test, vi } from "vitest";
import {
GlobalSyncStateListenerCallback,
PeerSyncStateListenerCallback,
} from "../SyncStateManager.js";
import { accountHeaderForInitialAgentSecret } from "../coValues/account.js";
import { connectedPeers } from "../streamUtils.js";
import { emptyKnownState } from "../sync.js";
import {
blockMessageTypeOnOutgoingPeer,
connectNodeToSyncServer,
createTestNode,
createTwoConnectedNodes,
loadCoValueOrFail,
setupSyncServer,
waitFor,
} from "./testUtils.js";
let jazzCloud = setupSyncServer();
beforeEach(async () => {
jazzCloud = setupSyncServer();
});
describe("SyncStateManager", () => {
test("subscribeToUpdates receives updates when peer state changes", async () => {
// Setup nodes
const client = createTestNode();
const { nodeToServerPeer } = connectNodeToSyncServer(client);
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.syncState;
const updateSpy: GlobalSyncStateListenerCallback = vi.fn();
@@ -39,21 +46,21 @@ describe("SyncStateManager", () => {
await client.syncManager.actuallySyncCoValue(map.core);
expect(updateSpy).toHaveBeenCalledWith(
nodeToServerPeer.id,
"jazzCloudConnection",
emptyKnownState(map.core.id),
{ uploaded: false },
);
await waitFor(() => {
return subscriptionManager.getCurrentSyncState(
nodeToServerPeer.id,
"jazzCloudConnection",
map.core.id,
).uploaded;
});
expect(updateSpy).toHaveBeenCalledWith(
nodeToServerPeer.id,
client.syncManager.peers[nodeToServerPeer.id]!.knownStates.get(
"jazzCloudConnection",
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
{ uploaded: true },
@@ -66,30 +73,42 @@ describe("SyncStateManager", () => {
test("subscribeToPeerUpdates receives updates only for specific peer", async () => {
// Setup nodes
const client = createTestNode();
const { nodeToServerPeer } = connectNodeToSyncServer(client);
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.syncState;
const updateToJazzCloudSpy: PeerSyncStateListenerCallback = vi.fn();
const updateToStorageSpy: PeerSyncStateListenerCallback = vi.fn();
const unsubscribe1 = subscriptionManager.subscribeToPeerUpdates(
nodeToServerPeer.id,
"jazzCloudConnection",
updateToJazzCloudSpy,
);
const unsubscribe2 = subscriptionManager.subscribeToPeerUpdates(
clientStoragePeer.id,
"clientStorage",
updateToStorageSpy,
);
@@ -107,13 +126,13 @@ describe("SyncStateManager", () => {
await waitFor(() => {
return subscriptionManager.getCurrentSyncState(
nodeToServerPeer.id,
"jazzCloudConnection",
map.core.id,
).uploaded;
});
expect(updateToJazzCloudSpy).toHaveBeenLastCalledWith(
client.syncManager.peers[nodeToServerPeer.id]!.knownStates.get(
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
{ uploaded: true },
@@ -128,50 +147,80 @@ describe("SyncStateManager", () => {
test("getIsCoValueFullyUploadedIntoPeer returns correct status", async () => {
// Setup nodes
const client = createTestNode();
const { nodeToServerPeer } = connectNodeToSyncServer(client);
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.syncState;
expect(
subscriptionManager.getCurrentSyncState(nodeToServerPeer.id, map.core.id)
.uploaded,
subscriptionManager.getCurrentSyncState(
"jazzCloudConnection",
map.core.id,
).uploaded,
).toBe(false);
await waitFor(() => {
return subscriptionManager.getCurrentSyncState(
nodeToServerPeer.id,
"jazzCloudConnection",
map.core.id,
).uploaded;
});
expect(
subscriptionManager.getCurrentSyncState(nodeToServerPeer.id, map.core.id)
.uploaded,
subscriptionManager.getCurrentSyncState(
"jazzCloudConnection",
map.core.id,
).uploaded,
).toBe(true);
});
test("unsubscribe stops receiving updates", async () => {
// Setup nodes
const client = createTestNode();
const { nodeToServerPeer } = connectNodeToSyncServer(client);
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.syncState;
const anyUpdateSpy = vi.fn();
const unsubscribe1 = subscriptionManager.subscribeToUpdates(anyUpdateSpy);
const unsubscribe2 = subscriptionManager.subscribeToPeerUpdates(
nodeToServerPeer.id,
"jazzCloudConnection",
anyUpdateSpy,
);
@@ -184,7 +233,7 @@ describe("SyncStateManager", () => {
await waitFor(() => {
return subscriptionManager.getCurrentSyncState(
nodeToServerPeer.id,
"jazzCloudConnection",
map.core.id,
).uploaded;
});
@@ -194,21 +243,22 @@ describe("SyncStateManager", () => {
test("getCurrentSyncState should return the correct state", async () => {
// Setup nodes
const clientNode = createTestNode();
const serverNode = jazzCloud;
const {
nodeToServerPeer: clientToServerPeer,
serverToNodePeer: serverToClientPeer,
} = connectNodeToSyncServer(clientNode);
node1: clientNode,
node2: serverNode,
node1ToNode2Peer: clientToServerPeer,
node2ToNode1Peer: serverToClientPeer,
} = await createTwoConnectedNodes("client", "server");
// Create test data
const group = clientNode.createGroup();
const group = clientNode.node.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
group.addMember("everyone", "writer");
// Initially should not be synced
expect(
clientNode.syncManager.syncState.getCurrentSyncState(
clientNode.node.syncManager.syncState.getCurrentSyncState(
clientToServerPeer.id,
map.core.id,
),
@@ -218,13 +268,13 @@ describe("SyncStateManager", () => {
await map.core.waitForSync();
expect(
clientNode.syncManager.syncState.getCurrentSyncState(
clientNode.node.syncManager.syncState.getCurrentSyncState(
clientToServerPeer.id,
map.core.id,
),
).toEqual({ uploaded: true });
const mapOnServer = await loadCoValueOrFail(serverNode, map.id);
const mapOnServer = await loadCoValueOrFail(serverNode.node, map.id);
// Block the content messages so the client won't fully sync immediately
const outgoing = blockMessageTypeOnOutgoingPeer(
@@ -235,14 +285,14 @@ describe("SyncStateManager", () => {
mapOnServer.set("key2", "value2", "trusting");
expect(
clientNode.syncManager.syncState.getCurrentSyncState(
clientNode.node.syncManager.syncState.getCurrentSyncState(
clientToServerPeer.id,
map.core.id,
),
).toEqual({ uploaded: true });
expect(
serverNode.syncManager.syncState.getCurrentSyncState(
serverNode.node.syncManager.syncState.getCurrentSyncState(
serverToClientPeer.id,
map.core.id,
),
@@ -254,14 +304,14 @@ describe("SyncStateManager", () => {
await mapOnServer.core.waitForSync();
expect(
clientNode.syncManager.syncState.getCurrentSyncState(
clientNode.node.syncManager.syncState.getCurrentSyncState(
clientToServerPeer.id,
map.core.id,
),
).toEqual({ uploaded: true });
expect(
serverNode.syncManager.syncState.getCurrentSyncState(
serverNode.node.syncManager.syncState.getCurrentSyncState(
serverToClientPeer.id,
map.core.id,
),

View File

@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { afterEach, describe, expect, test, vi } from "vitest";
import { expectMap } from "../coValue.js";
import type { CoValueHeader } from "../coValueCore.js";
import type { RawAccountID } from "../coValues/account.js";
@@ -12,27 +12,17 @@ import { connectedPeers, newQueuePair } from "../streamUtils.js";
import type { SyncMessage } from "../sync.js";
import {
blockMessageTypeOnOutgoingPeer,
connectNodeToSyncServer,
connectTwoPeers,
createConnectedTestAgentNode,
createConnectedTestNode,
createTestMetricReader,
createTestNode,
loadCoValueOrFail,
randomAnonymousAccountAndSessionID,
setupSyncServer,
tearDownTestMetricReader,
waitFor,
} from "./testUtils.js";
const Crypto = await WasmCrypto.create();
let jazzCloud = setupSyncServer();
beforeEach(async () => {
jazzCloud = setupSyncServer();
});
test("Node replies with initial tx and header to empty subscribe", async () => {
const [admin, session] = randomAnonymousAccountAndSessionID();
const node = new LocalNode(admin, session, Crypto);
@@ -871,34 +861,111 @@ test.skip("When loading a coValue on one node, the server node it is requested f
});
test("Can sync a coValue through a server to another client", async () => {
const { node: client1 } = await createConnectedTestNode();
const [admin, session] = randomAnonymousAccountAndSessionID();
const client1 = new LocalNode(admin, session, Crypto);
const group = client1.createGroup();
const map = group.createMap();
map.set("hello", "world", "trusting");
const { node: client2 } = await createConnectedTestNode();
const [serverUser, serverSession] = randomAnonymousAccountAndSessionID();
const mapOnClient2 = await loadCoValueOrFail(client2, map.id);
const server = new LocalNode(serverUser, serverSession, Crypto);
expect(mapOnClient2.get("hello")).toEqual("world");
const [serverAsPeerForClient1, client1AsPeer] = connectedPeers(
"serverFor1",
"client1",
{
peer1role: "server",
peer2role: "client",
// trace: true,
},
);
client1.syncManager.addPeer(serverAsPeerForClient1);
server.syncManager.addPeer(client1AsPeer);
const client2 = new LocalNode(
admin,
Crypto.newRandomSessionID(admin.id),
Crypto,
);
const [serverAsPeerForClient2, client2AsPeer] = connectedPeers(
"serverFor2",
"client2",
{
peer1role: "server",
peer2role: "client",
// trace: true,
},
);
client2.syncManager.addPeer(serverAsPeerForClient2);
server.syncManager.addPeer(client2AsPeer);
const mapOnClient2 = await client2.loadCoValueCore(map.core.id);
if (mapOnClient2 === "unavailable") {
throw new Error("Map is unavailable");
}
expect(expectMap(mapOnClient2.getCurrentContent()).get("hello")).toEqual(
"world",
);
});
test("Can sync a coValue with private transactions through a server to another client", async () => {
const { node: client1 } = await createConnectedTestNode();
const [admin, session] = randomAnonymousAccountAndSessionID();
const client1 = new LocalNode(admin, session, Crypto);
const group = client1.createGroup();
const map = group.createMap();
map.set("hello", "world", "private");
group.addMember("everyone", "reader");
const { node: client2 } = await createConnectedTestNode();
const [serverUser, serverSession] = randomAnonymousAccountAndSessionID();
const mapOnClient2 = await loadCoValueOrFail(client2, map.id);
const server = new LocalNode(serverUser, serverSession, Crypto);
expect(mapOnClient2.get("hello")).toEqual("world");
const [serverAsPeer, client1AsPeer] = connectedPeers("server", "client1", {
// trace: true,
peer1role: "server",
peer2role: "client",
});
client1.syncManager.addPeer(serverAsPeer);
server.syncManager.addPeer(client1AsPeer);
const client2 = new LocalNode(
admin,
client1.crypto.newRandomSessionID(admin.id),
Crypto,
);
const [serverAsOtherPeer, client2AsPeer] = connectedPeers(
"server",
"client2",
{
// trace: true,
peer1role: "server",
peer2role: "client",
},
);
client2.syncManager.addPeer(serverAsOtherPeer);
server.syncManager.addPeer(client2AsPeer);
const mapOnClient2 = await client2.loadCoValueCore(map.core.id);
if (mapOnClient2 === "unavailable") {
throw new Error("Map is unavailable");
}
expect(expectMap(mapOnClient2.getCurrentContent()).get("hello")).toEqual(
"world",
);
});
test.skip("When a peer's incoming/readable stream closes, we remove the peer", async () => {
@@ -956,32 +1023,111 @@ test.skip("When a peer's incoming/readable stream closes, we remove the peer", a
*/
});
test.skip("When a peer's outgoing/writable stream closes, we remove the peer", async () => {
/*
const [admin, session] = randomAnonymousAccountAndSessionID();
const node = new LocalNode(admin, session, Crypto);
const group = node.createGroup();
const [inRx] = await Effect.runPromise(newStreamPair());
const [outRx, outTx] = await Effect.runPromise(newStreamPair());
node.syncManager.addPeer({
id: "test",
incoming: inRx,
outgoing: outTx,
role: "server",
});
// expect(yield* Queue.take(outRxQ)).toMatchObject({
// action: "load",
// id: admin.id,
// });
expect(yield * Queue.take(outRxQ)).toMatchObject({
action: "load",
id: group.core.id,
});
const map = group.createMap();
const mapSubscribeMsg = await reader.read();
expect(mapSubscribeMsg.value).toEqual({
action: "load",
...map.core.knownState(),
} satisfies SyncMessage);
// expect(yield* Queue.take(outRxQ)).toMatchObject(admContEx(admin.id));
expect(yield * Queue.take(outRxQ)).toMatchObject(groupContentEx(group));
const mapContentMsg = await reader.read();
expect(mapContentMsg.value).toEqual({
action: "content",
id: map.core.id,
header: map.core.header,
new: {},
} satisfies SyncMessage);
reader.releaseLock();
await outRx.cancel();
map.set("hello", "world", "trusting");
await new Promise((resolve) => setTimeout(resolve, 100));
expect(node.syncManager.peers["test"]).toBeUndefined();
*/
});
test("If we start loading a coValue before connecting to a peer that has it, it will load it once we connect", async () => {
const { node: node1 } = await createConnectedTestNode();
const [admin, session] = randomAnonymousAccountAndSessionID();
const node1 = new LocalNode(admin, session, Crypto);
const group = node1.createGroup();
const map = group.createMap();
map.set("hello", "world", "trusting");
const node2 = createTestNode();
const node2 = new LocalNode(
admin,
Crypto.newRandomSessionID(admin.id),
Crypto,
);
const mapOnNode2Promise = loadCoValueOrFail(node2, map.id);
const [node1asPeer, node2asPeer] = connectedPeers("peer1", "peer2", {
peer1role: "server",
peer2role: "client",
// trace: true,
});
node1.syncManager.addPeer(node2asPeer);
const mapOnNode2Promise = node2.loadCoValueCore(map.core.id);
expect(node2.coValuesStore.get(map.core.id).state.type).toEqual("unknown");
connectNodeToSyncServer(node2);
node2.syncManager.addPeer(node1asPeer);
const mapOnNode2 = await mapOnNode2Promise;
if (mapOnNode2 === "unavailable") {
throw new Error("Map is unavailable");
}
expect(mapOnNode2.get("hello")).toEqual("world");
expect(expectMap(mapOnNode2.getCurrentContent()).get("hello")).toEqual(
"world",
);
});
test("should keep the peer state when the peer closes", async () => {
const client = createTestNode();
const { nodeToServerPeer, serverToNodePeer } =
connectNodeToSyncServer(client);
const {
client,
jazzCloud,
jazzCloudConnectionAsPeer,
connectionWithClientAsPeer,
} = createTwoConnectedNodes();
const group = jazzCloud.createGroup();
const map = group.createMap();
@@ -990,23 +1136,25 @@ test("should keep the peer state when the peer closes", async () => {
await client.loadCoValueCore(map.core.id);
const syncManager = client.syncManager;
const peerState = syncManager.peers[nodeToServerPeer.id];
const peerState = syncManager.peers[jazzCloudConnectionAsPeer.id];
// @ts-expect-error Simulating a peer closing, leveraging the direct connection between the client/server peers
await serverToNodePeer.outgoing.push("Disconnected");
await connectionWithClientAsPeer.outgoing.push("Disconnected");
await waitFor(() => peerState?.closed);
expect(syncManager.peers[nodeToServerPeer.id]).not.toBeUndefined();
expect(syncManager.peers[jazzCloudConnectionAsPeer.id]).not.toBeUndefined();
});
test("should delete the peer state when the peer closes if deletePeerStateOnClose is true", async () => {
const client = createTestNode();
const {
client,
jazzCloud,
jazzCloudConnectionAsPeer,
connectionWithClientAsPeer,
} = createTwoConnectedNodes();
const { nodeToServerPeer, serverToNodePeer } =
connectNodeToSyncServer(client);
nodeToServerPeer.deletePeerStateOnClose = true;
jazzCloudConnectionAsPeer.deletePeerStateOnClose = true;
const group = jazzCloud.createGroup();
const map = group.createMap();
@@ -1016,14 +1164,14 @@ test("should delete the peer state when the peer closes if deletePeerStateOnClos
const syncManager = client.syncManager;
const peerState = syncManager.peers[nodeToServerPeer.id];
const peerState = syncManager.peers[jazzCloudConnectionAsPeer.id];
// @ts-expect-error Simulating a peer closing, leveraging the direct connection between the client/server peers
await serverToNodePeer.outgoing.push("Disconnected");
await connectionWithClientAsPeer.outgoing.push("Disconnected");
await waitFor(() => peerState?.closed);
expect(syncManager.peers[nodeToServerPeer.id]).toBeUndefined();
expect(syncManager.peers[jazzCloudConnectionAsPeer.id]).toBeUndefined();
});
describe("sync - extra tests", () => {
@@ -1476,6 +1624,29 @@ 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,
};
}
test("a value created on one node can be loaded on anotehr node even if not directly connected", async () => {
const userA = createTestNode();
const userB = createTestNode();
@@ -1500,7 +1671,7 @@ test("a value created on one node can be loaded on anotehr node even if not dire
describe("SyncManager - knownStates vs optimisticKnownStates", () => {
test("knownStates and optimisticKnownStates are the same when the coValue is fully synced", async () => {
const { node: client } = await createConnectedTestNode();
const { client, jazzCloud } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
@@ -1512,8 +1683,9 @@ describe("SyncManager - knownStates vs optimisticKnownStates", () => {
// Wait for the full sync to complete
await mapOnClient.core.waitForSync();
const peerStateClient = client.syncManager.getPeers()[0]!;
const peerStateJazzCloud = jazzCloud.syncManager.getPeers()[0]!;
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(
@@ -1527,7 +1699,7 @@ describe("SyncManager - knownStates vs optimisticKnownStates", () => {
});
test("optimisticKnownStates is updated as new transactions are sent, while knownStates only when the updates are acknowledged", async () => {
const { node: client, nodeToServerPeer } = await createConnectedTestNode();
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
@@ -1545,7 +1717,7 @@ describe("SyncManager - knownStates vs optimisticKnownStates", () => {
// while knownStates is only updated when we receive the "known" messages
// that are acknowledging the receipt of the content messages
const outgoing = blockMessageTypeOnOutgoingPeer(
nodeToServerPeer,
jazzCloudConnectionAsPeer,
"content",
);
@@ -1553,7 +1725,8 @@ describe("SyncManager - knownStates vs optimisticKnownStates", () => {
await client.syncManager.actuallySyncCoValue(map.core);
const peerState = client.syncManager.peers[nodeToServerPeer.id]!;
const peerState = client.syncManager.peers["jazzCloudConnection"]!;
expect(peerState.optimisticKnownStates.get(map.core.id)).not.toEqual(
peerState.knownStates.get(map.core.id),
);
@@ -1574,7 +1747,7 @@ describe("SyncManager - knownStates vs optimisticKnownStates", () => {
describe("SyncManager.addPeer", () => {
test("new peer gets a copy of previous peer's knownStates when replacing it", async () => {
const { node: client } = await createConnectedTestNode();
const { client } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
@@ -1586,24 +1759,26 @@ describe("SyncManager.addPeer", () => {
// Wait for initial sync
await map.core.waitForSync();
const firstPeerState = client.syncManager.getPeers()[0]!;
// Store the initial known states
const initialKnownStates = firstPeerState.knownStates;
const initialKnownStates =
client.syncManager.peers["jazzCloudConnection"]!.knownStates;
// Create new connection with same ID
const [secondPeer] = connectedPeers(firstPeerState.id, "unusedPeer", {
peer1role: "server",
peer2role: "client",
});
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
// Add new peer with same ID
client.syncManager.addPeer(secondPeer);
const newPeerState = client.syncManager.getPeers()[0]!;
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify that the new peer has a copy of the previous known states
const newPeerKnownStates = newPeerState.knownStates;
const newPeerKnownStates =
client.syncManager.peers["jazzCloudConnection"]!.knownStates;
expect(newPeerKnownStates).not.toBe(initialKnownStates); // Should be a different instance
expect(newPeerKnownStates.get(map.core.id)).toEqual(
@@ -1612,7 +1787,7 @@ describe("SyncManager.addPeer", () => {
});
test("new peer with new ID starts with empty knownStates", async () => {
const { node: client } = await createConnectedTestNode();
const { client } = createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
@@ -1640,19 +1815,23 @@ describe("SyncManager.addPeer", () => {
});
test("when adding a peer with the same ID as a previous peer, the previous peer is closed", async () => {
const { node: client } = await createConnectedTestNode();
const { client } = createTwoConnectedNodes();
// Store reference to first peer
const firstPeer = client.syncManager.getPeers()[0]!;
const firstPeer = client.syncManager.peers["jazzCloudConnection"]!;
const closeSpy = vi.spyOn(firstPeer, "gracefulShutdown");
// Create and add replacement peer
const [secondPeer] = connectedPeers(firstPeer.id, "unusedPeer", {
peer1role: "server",
peer2role: "client",
});
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
client.syncManager.addPeer(secondPeer);
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify thet the first peer had ben closed correctly
expect(closeSpy).toHaveBeenCalled();
@@ -1660,21 +1839,25 @@ describe("SyncManager.addPeer", () => {
});
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 { node: client } = await createConnectedTestNode();
const { client } = createTwoConnectedNodes();
// Store reference to first peer
const firstPeer = client.syncManager.getPeers()[0]!;
const firstPeer = client.syncManager.peers["jazzCloudConnection"]!;
firstPeer.gracefulShutdown();
const closeSpy = vi.spyOn(firstPeer, "gracefulShutdown");
// Create and add replacement peer
const [secondPeer] = connectedPeers(firstPeer.id, "unusedPeer", {
peer1role: "server",
peer2role: "client",
});
const [jazzCloudConnectionAsPeer2] = connectedPeers(
"jazzCloudConnection",
"unusedPeer",
{
peer1role: "server",
peer2role: "client",
},
);
client.syncManager.addPeer(secondPeer);
client.syncManager.addPeer(jazzCloudConnectionAsPeer2);
// Verify thet the first peer had not been closed again
expect(closeSpy).not.toHaveBeenCalled();
@@ -1682,15 +1865,24 @@ describe("SyncManager.addPeer", () => {
});
test("when adding a server peer the local coValues should be sent to it", async () => {
const { node: client, addServerPeer } = await createConnectedTestNode({
connected: false,
});
// Setup nodes
const client = createTestNode();
const jazzCloud = createTestNode();
// Connect nodes initially
const [connectionWithClientAsPeer, jazzCloudConnectionAsPeer] =
connectedPeers("connectionWithClient", "jazzCloudConnection", {
peer1role: "client",
peer2role: "server",
});
jazzCloud.syncManager.addPeer(connectionWithClientAsPeer);
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
addServerPeer();
client.syncManager.addPeer(jazzCloudConnectionAsPeer);
await map.core.waitForSync();
@@ -1700,8 +1892,18 @@ describe("SyncManager.addPeer", () => {
describe("loadCoValueCore with retry", () => {
test("should load the value if available on the server", async () => {
const { node: client } = await createConnectedTestNode();
const { node: anotherClient } = await createConnectedTestNode();
const { client, jazzCloud } = createTwoConnectedNodes();
const anotherClient = createTestNode();
const [
connectionWithAnotherClientAsPeer,
jazzCloudConnectionAsPeerForAnotherClient,
] = connectedPeers("connectionWithAnotherClient", "jazzCloudConnection", {
peer1role: "client",
peer2role: "server",
});
jazzCloud.syncManager.addPeer(connectionWithAnotherClientAsPeer);
const group = anotherClient.createGroup();
const map = group.createMap();
@@ -1709,12 +1911,25 @@ describe("loadCoValueCore with retry", () => {
const promise = client.loadCoValueCore(map.id);
anotherClient.syncManager.addPeer(
jazzCloudConnectionAsPeerForAnotherClient,
);
await expect(promise).resolves.not.toBe("unavailable");
});
test("should handle correctly two subsequent loads", async () => {
const { node: client } = await createConnectedTestNode();
const { node: anotherClient } = await createConnectedTestNode();
const { client, jazzCloud } = createTwoConnectedNodes();
const anotherClient = createTestNode();
const [
connectionWithAnotherClientAsPeer,
jazzCloudConnectionAsPeerForAnotherClient,
] = connectedPeers("connectionWithAnotherClient", "jazzCloudConnection", {
peer1role: "client",
peer2role: "server",
});
jazzCloud.syncManager.addPeer(connectionWithAnotherClientAsPeer);
const group = anotherClient.createGroup();
const map = group.createMap();
@@ -1723,6 +1938,10 @@ describe("loadCoValueCore with retry", () => {
const promise1 = client.loadCoValueCore(map.id);
const promise2 = client.loadCoValueCore(map.id);
anotherClient.syncManager.addPeer(
jazzCloudConnectionAsPeerForAnotherClient,
);
await expect(promise1).resolves.not.toBe("unavailable");
await expect(promise2).resolves.not.toBe("unavailable");
});
@@ -1730,7 +1949,8 @@ describe("loadCoValueCore with retry", () => {
describe("waitForSyncWithPeer", () => {
test("should resolve when the coValue is fully uploaded into the peer", async () => {
const { node: client } = await createConnectedTestNode();
const { client, jazzCloudConnectionAsPeer: peer } =
createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
@@ -1739,32 +1959,21 @@ describe("waitForSyncWithPeer", () => {
await client.syncManager.actuallySyncCoValue(map.core);
const peer = client.syncManager.getPeers()[0];
if (!peer) {
throw new Error("No peer found");
}
await expect(
client.syncManager.waitForSyncWithPeer(peer.id, map.core.id, 100),
).resolves.toBe(true);
});
test("should not resolve when the coValue is not synced", async () => {
const { node: client } = await createConnectedTestNode();
const peer = client.syncManager.getPeers()[0];
if (!peer) {
throw new Error("No peer found");
}
const { client, jazzCloudConnectionAsPeer: peer } =
createTwoConnectedNodes();
// Create test data
const group = client.createGroup();
const map = group.createMap();
map.set("key1", "value1", "trusting");
vi.spyOn(peer, "pushOutgoingMessage").mockImplementation(async () => {
vi.spyOn(peer.outgoing, "push").mockImplementation(async () => {
return Promise.resolve();
});
@@ -1777,7 +1986,7 @@ describe("waitForSyncWithPeer", () => {
});
test("Should not crash when syncing an unknown coValue type", async () => {
const { node: client } = await createConnectedTestNode();
const { client, jazzCloud } = createTwoConnectedNodes();
const coValue = client.createCoValue({
type: "ooops" as any,
@@ -1788,10 +1997,8 @@ test("Should not crash when syncing an unknown coValue type", async () => {
await coValue.waitForSync();
const { node: anotherClient } = await createConnectedTestNode();
const coValueOnTheOtherNode = await loadCoValueOrFail(
anotherClient,
jazzCloud,
coValue.getCurrentContent().id,
);
expect(coValueOnTheOtherNode.id).toBe(coValue.id);
@@ -1885,163 +2092,6 @@ describe("metrics", () => {
});
});
describe("sync protocol", () => {
test("should have the correct messages exchanged between client and server", async () => {
// Creating the account from agent to simplify the messages exchange
const { node: client, messages } = await createConnectedTestAgentNode();
const group = client.createGroup();
const map = group.createMap();
map.set("hello", "world", "trusting");
const mapOnJazzCloud = await loadCoValueOrFail(jazzCloud, map.id);
expect(mapOnJazzCloud.get("hello")).toEqual("world");
expect(messages).toEqual([
{
from: "client",
msg: {
action: "load",
header: true,
id: group.id,
sessions: {
[client.currentSessionID]: 3,
},
},
},
{
from: "server",
msg: {
action: "load",
header: false,
id: group.id,
sessions: {},
},
},
{
from: "client",
msg: {
action: "load",
header: true,
id: map.id,
sessions: {
[client.currentSessionID]: 1,
},
},
},
{
from: "server",
msg: {
action: "load",
header: false,
id: map.id,
sessions: {},
},
},
{
from: "client",
msg: {
action: "content",
header: {
createdAt: expect.any(String),
meta: null,
ruleset: {
initialAdmin: client.account.id,
type: "group",
},
type: "comap",
uniqueness: expect.any(String),
},
id: group.id,
new: {
[client.currentSessionID]: {
after: 0,
lastSignature: expect.any(String),
newTransactions: expect.any(Array),
},
},
priority: 0,
},
},
{
from: "client",
msg: {
action: "content",
header: {
createdAt: expect.any(String),
meta: null,
ruleset: {
group: group.id,
type: "ownedByGroup",
},
type: "comap",
uniqueness: expect.any(String),
},
id: map.id,
new: {
[client.currentSessionID]: {
after: 0,
lastSignature: expect.any(String),
newTransactions: expect.any(Array),
},
},
priority: 3,
},
},
{
from: "server",
msg: {
action: "known",
header: true,
id: group.id,
sessions: {
[client.currentSessionID]: 3,
},
},
},
{
// TODO: This is a redundant message, we should remove it
from: "client",
msg: {
action: "content",
header: {
createdAt: expect.any(String),
meta: null,
ruleset: {
group: group.id,
type: "ownedByGroup",
},
type: "comap",
uniqueness: expect.any(String),
},
id: map.id,
new: {
[client.currentSessionID]: {
after: 0,
lastSignature: expect.any(String),
newTransactions: expect.any(Array),
},
},
priority: 3,
},
},
{
// TODO: This is a redundant message, we should remove it
from: "server",
msg: {
action: "known",
asDependencyOf: undefined,
header: true,
id: group.id,
sessions: {
[client.currentSessionID]: 3,
},
},
},
]);
});
});
function groupContentEx(group: RawGroup) {
return {
action: "content",
@@ -2049,9 +2099,27 @@ function groupContentEx(group: RawGroup) {
};
}
function _admContEx(adminID: RawAccountID) {
return {
action: "content",
id: adminID,
};
}
function groupStateEx(group: RawGroup) {
return {
action: "known",
id: group.core.id,
};
}
function _admStateEx(adminID: RawAccountID) {
return {
action: "known",
id: adminID,
};
}
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

View File

@@ -17,12 +17,6 @@ import { expectGroup } from "../typeUtils/expectGroup.js";
const Crypto = await WasmCrypto.create();
const syncServer: {
current: undefined | LocalNode;
} = {
current: undefined,
};
export function randomAnonymousAccountAndSessionID(): [
ControlledAgent,
SessionID,
@@ -39,6 +33,25 @@ export function createTestNode() {
return new LocalNode(admin, session, Crypto);
}
export function connectTwoPeers(
a: LocalNode,
b: LocalNode,
aRole: "client" | "server",
bRole: "client" | "server",
) {
const [aAsPeer, bAsPeer] = connectedPeers(
"peer:" + a.account.id,
"peer:" + b.account.id,
{
peer1role: aRole,
peer2role: bRole,
},
);
a.syncManager.addPeer(bAsPeer);
b.syncManager.addPeer(aAsPeer);
}
export async function createTwoConnectedNodes(
node1Role: Peer["role"],
node2Role: Peer["role"],
@@ -136,25 +149,6 @@ export async function createThreeConnectedNodes(
};
}
export function connectTwoPeers(
a: LocalNode,
b: LocalNode,
aRole: "client" | "server",
bRole: "client" | "server",
) {
const [aAsPeer, bAsPeer] = connectedPeers(
"peer:" + a.account.id,
"peer:" + b.account.id,
{
peer1role: aRole,
peer2role: bRole,
},
);
a.syncManager.addPeer(bAsPeer);
b.syncManager.addPeer(aAsPeer);
}
export function newGroup() {
const [admin, sessionID] = randomAnonymousAccountAndSessionID();
@@ -374,90 +368,3 @@ export function createTestMetricReader() {
export function tearDownTestMetricReader() {
metrics.disable();
}
export function setupSyncServer() {
syncServer.current = createTestNode();
return syncServer.current;
}
export async function createConnectedTestAgentNode(opts = { connected: true }) {
if (!syncServer.current) {
throw new Error("Sync server not initialized");
}
const [admin, session] = randomAnonymousAccountAndSessionID();
const node = new LocalNode(admin, session, Crypto);
const { nodeToServerPeer, serverToNodePeer, messages, addServerPeer } =
connectNodeToSyncServer(node, opts.connected);
return { node, nodeToServerPeer, serverToNodePeer, messages, addServerPeer };
}
export async function createConnectedTestNode(opts = { connected: true }) {
if (!syncServer.current) {
throw new Error("Sync server not initialized");
}
const ctx = await LocalNode.withNewlyCreatedAccount({
peersToLoadFrom: [],
crypto: Crypto,
creationProps: { name: "Client" },
});
const { nodeToServerPeer, serverToNodePeer, messages, addServerPeer } =
connectNodeToSyncServer(ctx.node, opts.connected);
return {
node: ctx.node,
accountID: ctx.accountID,
nodeToServerPeer,
serverToNodePeer,
messages,
addServerPeer,
};
}
export function connectNodeToSyncServer(node: LocalNode, connected = true) {
if (!syncServer.current) {
throw new Error("Sync server not initialized");
}
const [nodeToServerPeer, serverToNodePeer] = connectedPeers(
syncServer.current.account.id,
node.account.id,
{
peer1role: "server",
peer2role: "client",
},
);
const messages: {
from: "client" | "server";
msg: SyncMessage;
}[] = [];
const serverPush = serverToNodePeer.outgoing.push;
serverToNodePeer.outgoing.push = (msg) => {
messages.push({ from: "server", msg });
return serverPush.call(serverToNodePeer.outgoing, msg);
};
const clientPush = nodeToServerPeer.outgoing.push;
nodeToServerPeer.outgoing.push = (msg) => {
messages.push({ from: "client", msg });
return clientPush.call(nodeToServerPeer.outgoing, msg);
};
syncServer.current.syncManager.addPeer(serverToNodePeer);
if (connected) {
node.syncManager.addPeer(nodeToServerPeer);
}
return {
nodeToServerPeer,
serverToNodePeer,
messages,
addServerPeer: () => node.syncManager.addPeer(nodeToServerPeer),
};
}

View File

@@ -1,11 +1,5 @@
# create-jazz-app
## 0.1.8
### Patch Changes
- 0fc4f24: fix create-jazz-app fails if no starter param
## 0.1.7
### Patch Changes

View File

@@ -17,6 +17,13 @@ You can create a new Jazz app in two ways:
### Interactive mode
Simply run:
```bash
npm create jazz-app@latest
```
or
```bash
npx create-jazz-app@latest
```
@@ -31,7 +38,7 @@ Then follow the interactive prompts to select your:
Or specify all options directly:
```bash
npx create-jazz-app@latest --starter react-demo-auth --project-name my-app --package-manager npm
npm create jazz-app@latest -- --starter react-demo-auth --project-name my-app --package-manager npm
```
### Start with an example app

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.1.8",
"version": "0.1.7",
"bin": {
"create-jazz-app": "./dist/index.js"
},

View File

@@ -263,8 +263,7 @@ async function promptUser(
return {
...answers,
...partialOptions,
template:
answers.starter || partialOptions.starter || partialOptions.example,
template: partialOptions.starter || partialOptions.example,
} as ScaffoldOptions;
}

View File

@@ -1,51 +1,5 @@
# jazz-browser-media-images
## 0.9.20
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- jazz-browser@0.9.19
- jazz-tools@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- jazz-browser@0.9.18
- jazz-tools@0.9.18
## 0.9.17
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser@0.9.17
## 0.9.16
### Patch Changes
- 24b3b6a: Extract friendly user name for profile creation when authenticating using Clerk with a regular email address.
Email passed to creationProps when using Clerk auth
Clear stored Clerk credentials on logout
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser@0.9.16
## 0.9.15
### Patch Changes

View File

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

View File

@@ -1,6 +1,8 @@
import { AgentSecret } from "cojson";
import { Account, AuthMethod, AuthResult, Credentials, ID } from "jazz-tools";
const localStorageKey = "jazz-clerk-auth";
export type MinimalClerkClient = {
user:
| {
@@ -8,10 +10,6 @@ export type MinimalClerkClient = {
unsafeMetadata: Record<string, any>;
fullName: string | null;
username: string | null;
firstName: string | null;
primaryEmailAddress: {
emailAddress: string;
} | null;
id: string;
update: (args: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -23,8 +21,6 @@ export type MinimalClerkClient = {
signOut: () => Promise<void>;
};
const localStorageKey = "jazz-clerk-auth";
function saveCredentialsToLocalStorage(credentials: Credentials) {
localStorage.setItem(
localStorageKey,
@@ -35,10 +31,6 @@ function saveCredentialsToLocalStorage(credentials: Credentials) {
);
}
function clearStoredCredentials() {
localStorage.removeItem(localStorageKey);
}
export class BrowserClerkAuth implements AuthMethod {
constructor(
public driver: BrowserClerkAuth.Driver,
@@ -46,21 +38,8 @@ export class BrowserClerkAuth implements AuthMethod {
) {}
async start(): Promise<AuthResult> {
// clear localStorage if the current Clerk user doesn't match stored credentials
let locallyStoredCredentials = localStorage.getItem(localStorageKey);
if (locallyStoredCredentials && this.clerkClient.user) {
try {
const stored = JSON.parse(locallyStoredCredentials);
const clerkMetadata = this.clerkClient.user.unsafeMetadata;
if (clerkMetadata.jazzAccountID !== stored.accountID) {
clearStoredCredentials();
}
} catch (e) {
clearStoredCredentials();
}
}
locallyStoredCredentials = localStorage.getItem(localStorageKey);
// Check local storage for credentials
const locallyStoredCredentials = localStorage.getItem(localStorageKey);
if (locallyStoredCredentials) {
try {
@@ -74,7 +53,7 @@ export class BrowserClerkAuth implements AuthMethod {
this.driver.onError(error);
},
logOut: () => {
clearStoredCredentials();
localStorage.removeItem(localStorageKey);
void this.clerkClient.signOut();
},
};
@@ -107,7 +86,6 @@ export class BrowserClerkAuth implements AuthMethod {
this.driver.onError(error);
},
logOut: () => {
clearStoredCredentials();
void this.clerkClient.signOut();
},
};
@@ -118,15 +96,8 @@ export class BrowserClerkAuth implements AuthMethod {
creationProps: {
name:
this.clerkClient.user.fullName ||
this.clerkClient.user.firstName ||
this.clerkClient.user.username ||
this.clerkClient.user.primaryEmailAddress?.emailAddress?.split(
"@",
)[0] ||
this.clerkClient.user.id,
other: {
email: this.clerkClient.user.primaryEmailAddress?.emailAddress,
},
},
saveCredentials: async ({ accountID, secret }: Credentials) => {
saveCredentialsToLocalStorage({
@@ -145,7 +116,6 @@ export class BrowserClerkAuth implements AuthMethod {
this.driver.onError(error);
},
logOut: () => {
clearStoredCredentials();
void this.clerkClient.signOut();
},
};

View File

@@ -30,8 +30,6 @@ describe("BrowserClerkAuth", () => {
unsafeMetadata: {},
fullName: "Test User",
username: "testuser",
firstName: null,
primaryEmailAddress: null,
id: "test-id",
update: vi.fn(),
},
@@ -77,8 +75,6 @@ describe("BrowserClerkAuth", () => {
},
fullName: "Test User",
username: "testuser",
firstName: null,
primaryEmailAddress: null,
id: "test-id",
update: vi.fn(),
},
@@ -119,68 +115,5 @@ describe("BrowserClerkAuth", () => {
expect(mockClerkClient.signOut).toHaveBeenCalled();
});
it("should resolve name from available user fields", async () => {
const testCases = [
{
user: {
unsafeMetadata: {},
fullName: "Full Name",
firstName: null,
username: null,
primaryEmailAddress: null,
id: "test-id",
update: vi.fn(),
},
expected: "Full Name",
},
{
user: {
unsafeMetadata: {},
fullName: null,
firstName: "First",
username: null,
primaryEmailAddress: null,
id: "test-id",
update: vi.fn(),
},
expected: "First",
},
{
user: {
unsafeMetadata: {},
fullName: null,
firstName: null,
username: "username123",
primaryEmailAddress: null,
id: "test-id",
update: vi.fn(),
},
expected: "username123",
},
{
user: {
unsafeMetadata: {},
fullName: null,
firstName: null,
username: null,
primaryEmailAddress: { emailAddress: "test@example.com" },
id: "test-id",
update: vi.fn(),
},
expected: "test",
},
];
for (const { user, expected } of testCases) {
const auth = new BrowserClerkAuth(mockDriver, {
...mockClerkClient,
user,
});
const result = await auth.start();
expect(result.type).toBe("new");
expect((result as any).creationProps.name).toBe(expected);
}
});
});
});

View File

@@ -1,44 +1,5 @@
# jazz-browser-media-images
## 0.9.20
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-browser@0.9.20
## 0.9.19
### Patch Changes
- jazz-browser@0.9.19
- jazz-tools@0.9.19
## 0.9.18
### Patch Changes
- jazz-browser@0.9.18
- jazz-tools@0.9.18
## 0.9.17
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-browser@0.9.17
## 0.9.16
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-browser@0.9.16
## 0.9.15
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser-media-images",
"version": "0.9.20",
"version": "0.9.15",
"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.9.20",
"jazz-tools": "workspace:0.9.20",
"jazz-browser": "workspace:0.9.15",
"jazz-tools": "workspace:0.9.15",
"pica": "^9.0.1",
"typescript": "~5.6.2"
},

View File

@@ -0,0 +1,59 @@
// @vitest-environment happy-dom
import { createJazzTestAccount, setActiveAccount } from "jazz-tools/testing";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { createImage } from "../index.js";
beforeEach(async () => {
const account = await createJazzTestAccount();
setActiveAccount(account);
});
vi.mock("pica", () => {
return {
default: vi.fn().mockImplementation(() => ({
resize: vi.fn().mockResolvedValue({}),
})),
};
});
const originalWidth = 400;
const originalHeight = 300;
// Mock ImageBlobReduce
vi.mock("image-blob-reduce", () => {
return {
default: vi.fn().mockImplementation(() => ({
toCanvas: vi.fn().mockImplementation(async () => ({
toDataURL: () => "data:image/png;base64,mockedBase64Data",
})),
toBlob: vi.fn().mockImplementation(async (blob, { max }) => {
// Return a new blob with mock dimensions based on max size
return new Blob(["reduced-image-data"], { type: "image/jpeg" });
}),
after: vi.fn().mockImplementation((event, callback) => {
// Simulate the _blob_to_image callback with mock dimensions
callback({
image: { width: originalWidth, height: originalHeight },
orientation: 1,
});
}),
})),
};
});
describe("createImage", () => {
it("should create an image definition with correct dimensions", async () => {
// Create a test blob that simulates a 400x300 image
const blob = new Blob(["fake-image-data"], { type: "image/jpeg" });
Object.defineProperty(blob, "size", { value: 1024 * 50 }); // 50KB
const imageDefinition = await createImage(blob);
expect(imageDefinition.originalSize).toEqual([
originalWidth,
originalHeight,
]);
expect(imageDefinition.placeholderDataURL).toBeDefined();
});
});

View File

@@ -1,47 +1,5 @@
# jazz-browser
## 0.9.20
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
## 0.9.19
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- cojson-storage-indexeddb@0.9.19
- cojson-transport-ws@0.9.19
- jazz-tools@0.9.19
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- cojson-storage-indexeddb@0.9.18
- cojson-transport-ws@0.9.18
- jazz-tools@0.9.18
## 0.9.17
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
## 0.9.16
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
## 0.9.15
### Patch Changes

View File

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

View File

@@ -12,8 +12,7 @@ import {
InviteSecret,
SessionID,
WasmCrypto,
createInviteLink as baseCreateInviteLink,
consumeInviteLink,
cojsonInternals,
createJazzContext,
} from "jazz-tools";
import { OPFSFilesystem } from "./OPFSFilesystem.js";
@@ -213,19 +212,68 @@ export function createInviteLink<C extends CoValue>(
valueHint,
}: { baseURL?: string; valueHint?: string } = {},
): string {
return baseCreateInviteLink(value, role, baseURL, valueHint);
const coValueCore = value._raw.core;
let currentCoValue = coValueCore;
while (currentCoValue.header.ruleset.type === "ownedByGroup") {
currentCoValue = currentCoValue.getGroup().core;
}
const { ruleset, meta } = currentCoValue.header;
if (ruleset.type !== "group" || meta?.type === "account") {
throw new Error("Can't create invite link for object without group");
}
const group = cojsonInternals.expectGroup(currentCoValue.getCurrentContent());
const inviteSecret = group.createInvite(role);
return `${baseURL}#/invite/${valueHint ? valueHint + "/" : ""}${
value.id
}/${inviteSecret}`;
}
/** @category Invite Links */
export { parseInviteLink } from "jazz-tools";
export function parseInviteLink<C extends CoValue>(
inviteURL: string,
):
| {
valueID: ID<C>;
valueHint?: string;
inviteSecret: InviteSecret;
}
| undefined {
const url = new URL(inviteURL);
const parts = url.hash.split("/");
let valueHint: string | undefined;
let valueID: ID<C> | undefined;
let inviteSecret: InviteSecret | undefined;
if (parts[0] === "#" && parts[1] === "invite") {
if (parts.length === 5) {
valueHint = parts[2];
valueID = parts[3] as ID<C>;
inviteSecret = parts[4] as InviteSecret;
} else if (parts.length === 4) {
valueID = parts[2] as ID<C>;
inviteSecret = parts[3] as InviteSecret;
}
if (!valueID || !inviteSecret) {
return undefined;
}
return { valueID, inviteSecret, valueHint };
}
}
/** @category Invite Links */
export async function consumeInviteLinkFromWindowLocation<V extends CoValue>({
export function consumeInviteLinkFromWindowLocation<V extends CoValue>({
as,
forValueHint,
invitedObjectSchema,
}: {
as?: Account;
as: Account;
forValueHint?: string;
invitedObjectSchema: CoValueClass<V>;
}): Promise<
@@ -236,20 +284,22 @@ export async function consumeInviteLinkFromWindowLocation<V extends CoValue>({
}
| undefined
> {
const result = await consumeInviteLink({
inviteURL: window.location.href,
as,
forValueHint,
invitedObjectSchema,
return new Promise((resolve, reject) => {
const result = parseInviteLink<V>(window.location.href);
if (result && result.valueHint === forValueHint) {
as.acceptInvite(result.valueID, result.inviteSecret, invitedObjectSchema)
.then(() => {
resolve(result);
window.history.replaceState(
{},
"",
window.location.href.replace(/#.*$/, ""),
);
})
.catch(reject);
} else {
resolve(undefined);
}
});
if (result) {
window.history.replaceState(
{},
"",
window.location.href.replace(/#.*$/, ""),
);
}
return result;
}

View File

@@ -1,54 +1,5 @@
# jazz-inspector
## 0.9.21
### Patch Changes
- Updated dependencies [b01cc1f]
- jazz-tools@0.9.20
- jazz-react-core@0.9.20
## 0.9.20
### Patch Changes
- Updated dependencies [6ad0a9f]
- cojson@0.9.19
- jazz-react-core@0.8.60
- jazz-tools@0.9.19
## 0.9.19
### Patch Changes
- 2faf22f: Fix published files config
## 0.9.18
### Patch Changes
- Updated dependencies [8898b10]
- cojson@0.9.18
- jazz-react-core@0.8.59
- jazz-tools@0.9.18
## 0.9.17
### Patch Changes
- Updated dependencies [c2ca1fe]
- Updated dependencies [1227047]
- jazz-tools@0.9.17
- jazz-react-core@0.8.58
## 0.9.16
### Patch Changes
- Updated dependencies [24b3b6a]
- jazz-tools@0.9.16
- jazz-react-core@0.8.57
## 0.9.15
### Patch Changes

View File

@@ -1,13 +1,12 @@
{
"name": "jazz-inspector",
"version": "0.9.21",
"version": "0.9.15",
"type": "module",
"main": "./dist/app.js",
"types": "./dist/app.d.ts",
"files": ["dist/**", "src"],
"main": "./dist/jazz-inspector.js",
"types": "./src/app.tsx",
"scripts": {
"dev": "vite build --watch",
"build": "rm -rf ./dist && tsc --sourceMap --outDir dist",
"build": "tsc && vite build",
"format-and-lint": "biome check .",
"format-and-lint:fix": "biome check . --write",
"preview": "vite preview"

View File

@@ -1 +1 @@
export { JazzInspector } from "./viewer/new-app.js";
export { JazzInspector } from "./viewer/new-app.tsx";

View File

@@ -1,5 +1,5 @@
import React from "react";
import { PageInfo } from "./types.js";
import { PageInfo } from "./types.ts";
interface BreadcrumbsProps {
path: PageInfo[];

View File

@@ -5,12 +5,16 @@ import {
RawCoStream,
RawCoValue,
} from "cojson";
import { base64URLtoBytes } from "cojson";
import { BinaryStreamItem, BinaryStreamStart, CoStreamItem } from "cojson";
import type { JsonObject, JsonValue } from "cojson";
import { base64URLtoBytes } from "cojson/src/base64url.ts";
import {
BinaryStreamItem,
BinaryStreamStart,
CoStreamItem,
} from "cojson/src/coValues/coStream.ts";
import type { JsonObject, JsonValue } from "cojson/src/jsonValue.ts";
import { useEffect, useState } from "react";
import { PageInfo } from "./types.js";
import { AccountOrGroupPreview } from "./value-renderer.js";
import { PageInfo } from "./types.ts";
import { AccountOrGroupPreview } from "./value-renderer.tsx";
// typeguard for BinaryStreamStart
function isBinaryStreamStart(item: unknown): item is BinaryStreamStart {

View File

@@ -1,8 +1,8 @@
import { CoID, LocalNode, RawCoValue } from "cojson";
import { JsonObject } from "cojson";
import { ResolveIcon } from "./type-icon.js";
import { PageInfo, isCoId } from "./types.js";
import { CoMapPreview, ValueRenderer } from "./value-renderer.js";
import { JsonObject } from "cojson/src/jsonValue.ts";
import { ResolveIcon } from "./type-icon.tsx";
import { PageInfo, isCoId } from "./types.ts";
import { CoMapPreview, ValueRenderer } from "./value-renderer.tsx";
export function GridView({
data,

View File

@@ -1,9 +1,9 @@
import { CoID, RawCoValue } from "cojson";
import { createUseAccountHooks } from "jazz-react-core";
import React, { useState } from "react";
import { Breadcrumbs } from "./breadcrumbs.js";
import { PageStack } from "./page-stack.js";
import { usePagePath } from "./use-page-path.js";
import { Breadcrumbs } from "./breadcrumbs.tsx";
import { PageStack } from "./page-stack.tsx";
import { usePagePath } from "./use-page-path.ts";
const { useAccount } = createUseAccountHooks();

View File

@@ -1,5 +1,5 @@
import { CoID, LocalNode, RawCoValue } from "cojson";
import { Page } from "./page.js"; // Assuming you have a Page component
import { Page } from "./page.tsx"; // Assuming you have a Page component
// Define the structure of a page in the path
interface PageInfo {

View File

@@ -1,12 +1,12 @@
import { CoID, LocalNode, RawCoStream, RawCoValue } from "cojson";
import { useEffect, useState } from "react";
import { CoStreamView } from "./co-stream-view.js";
import { GridView } from "./grid-view.js";
import { TableView } from "./table-viewer.js";
import { TypeIcon } from "./type-icon.js";
import { PageInfo } from "./types.js";
import { useResolvedCoValue } from "./use-resolve-covalue.js";
import { AccountOrGroupPreview } from "./value-renderer.js";
import { CoStreamView } from "./co-stream-view.tsx";
import { GridView } from "./grid-view.tsx";
import { TableView } from "./table-viewer.tsx";
import { TypeIcon } from "./type-icon.tsx";
import { PageInfo } from "./types.ts";
import { useResolvedCoValue } from "./use-resolve-covalue.ts";
import { AccountOrGroupPreview } from "./value-renderer.tsx";
type PageProps = {
coId: CoID<RawCoValue>;

View File

@@ -1,10 +1,10 @@
import { CoID, LocalNode, RawCoValue } from "cojson";
import type { JsonObject } from "cojson";
import type { JsonObject } from "cojson/src/jsonValue.ts";
import { useMemo, useState } from "react";
import { LinkIcon } from "../link-icon.js";
import { PageInfo } from "./types.js";
import { useResolvedCoValues } from "./use-resolve-covalue.js";
import { ValueRenderer } from "./value-renderer.js";
import { LinkIcon } from "../link-icon.tsx";
import { PageInfo } from "./types.ts";
import { useResolvedCoValues } from "./use-resolve-covalue.ts";
import { ValueRenderer } from "./value-renderer.tsx";
export function TableView({
data,

View File

@@ -3,7 +3,7 @@ import {
CoJsonType,
ExtendedCoJsonType,
useResolvedCoValue,
} from "./use-resolve-covalue.js";
} from "./use-resolve-covalue.ts";
export const TypeIcon = ({
type,

View File

@@ -1,6 +1,6 @@
import { CoID, RawCoValue } from "cojson";
import { useCallback, useEffect, useState } from "react";
import { PageInfo } from "./types.js";
import { PageInfo } from "./types.ts";
export function usePagePath(defaultPath?: PageInfo[]) {
const [path, setPath] = useState<PageInfo[]>([]);

Some files were not shown because too many files have changed in this diff Show More