Compare commits
375 Commits
styling/co
...
authv2-exa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94131ba6d6 | ||
|
|
03df4fee8e | ||
|
|
c658ed3404 | ||
|
|
99e58e60dc | ||
|
|
a9ad0284e9 | ||
|
|
6e2d791c4b | ||
|
|
f9be857bbb | ||
|
|
1288ac140e | ||
|
|
7f07f7e049 | ||
|
|
b22589bbad | ||
|
|
be144adeee | ||
|
|
513619b04e | ||
|
|
81f6a75aac | ||
|
|
913d03de75 | ||
|
|
2d0172d839 | ||
|
|
27d46641e3 | ||
|
|
1014816d79 | ||
|
|
441194acb7 | ||
|
|
c9bea7200f | ||
|
|
9eaa88bd83 | ||
|
|
6ada48d57a | ||
|
|
8fa978df21 | ||
|
|
df7356fd24 | ||
|
|
153fa4ce44 | ||
|
|
6105bd2c88 | ||
|
|
c06d63eec1 | ||
|
|
4ee7359370 | ||
|
|
7b5c47b377 | ||
|
|
7ad57e88f3 | ||
|
|
c181e55557 | ||
|
|
7e0cd721e6 | ||
|
|
4d01cbae03 | ||
|
|
13f6389559 | ||
|
|
f6ea9bcc50 | ||
|
|
f6f2766eac | ||
|
|
f8f63bface | ||
|
|
5ec561fec4 | ||
|
|
277787cbd2 | ||
|
|
dda4336721 | ||
|
|
59ddff40ab | ||
|
|
064d19b48c | ||
|
|
3ea269f4d8 | ||
|
|
c4b8befe27 | ||
|
|
06f667ef2a | ||
|
|
bac3cc7bf8 | ||
|
|
6ad0a9f886 | ||
|
|
9b12932b66 | ||
|
|
82bb0d51d9 | ||
|
|
39dede92e8 | ||
|
|
84f4e6e48d | ||
|
|
e629dea585 | ||
|
|
2faf22ffff | ||
|
|
2273505a13 | ||
|
|
19eb29d831 | ||
|
|
738c4c2bd7 | ||
|
|
64e2273475 | ||
|
|
5a85c89154 | ||
|
|
8898b10e89 | ||
|
|
dc2d4e25f7 | ||
|
|
9275c4f6c0 | ||
|
|
cb75cc62b2 | ||
|
|
b141f6a62f | ||
|
|
4a251a528c | ||
|
|
ac3c2df474 | ||
|
|
681f973d4b | ||
|
|
338be7622f | ||
|
|
1227047b03 | ||
|
|
9afde8d0be | ||
|
|
c2ca1feba0 | ||
|
|
f8b6119996 | ||
|
|
98c265304a | ||
|
|
675e3e8046 | ||
|
|
4acba8c990 | ||
|
|
a93adeb1fe | ||
|
|
a7c90f749e | ||
|
|
cf8773f3de | ||
|
|
3be94ae1e7 | ||
|
|
6a8aa06d18 | ||
|
|
dc17889209 | ||
|
|
55f9d8e120 | ||
|
|
15b9457ed8 | ||
|
|
898297e95c | ||
|
|
0fc4f24cd5 | ||
|
|
63b5ad9edf | ||
|
|
873c3264ca | ||
|
|
34f89e48aa | ||
|
|
b01cc1fe9d | ||
|
|
3a6e34589f | ||
|
|
a1d512d9d7 | ||
|
|
51bf6b7fdc | ||
|
|
b5826fc0a5 | ||
|
|
becdd2f451 | ||
|
|
3b20bf354f | ||
|
|
fff7fe934b | ||
|
|
24b3b6afc1 | ||
|
|
c2eed7e2c4 | ||
|
|
f97ef696e3 | ||
|
|
ad65cb8ab5 | ||
|
|
8d8131410a | ||
|
|
7491711b72 | ||
|
|
5933aa59c1 | ||
|
|
da96bec465 | ||
|
|
483422c0e9 | ||
|
|
3df93cc147 | ||
|
|
d686edfa6c | ||
|
|
497b0ade1f | ||
|
|
4c8d128eee | ||
|
|
86acbcd0d6 | ||
|
|
9111c85445 | ||
|
|
1d87879787 | ||
|
|
7c777f2bdf | ||
|
|
aa8067b8d0 | ||
|
|
bd66cdeb78 | ||
|
|
8d29e50669 | ||
|
|
5a7398d242 | ||
|
|
74b984fbe6 | ||
|
|
f8e00204b4 | ||
|
|
76543df765 | ||
|
|
15d4b2a5f7 | ||
|
|
2e67f91fe0 | ||
|
|
df106ca680 | ||
|
|
c58f93b597 | ||
|
|
3f2a0ead1b | ||
|
|
c9e6d2998e | ||
|
|
0eb21a3471 | ||
|
|
99e88d3497 | ||
|
|
f09ce70d3c | ||
|
|
7d62e2735f | ||
|
|
40634c6ec1 | ||
|
|
5863badbb0 | ||
|
|
8bc758ce95 | ||
|
|
56d26222e7 | ||
|
|
bd34084104 | ||
|
|
f5e6fe927d | ||
|
|
93c49639c2 | ||
|
|
aabe7bef34 | ||
|
|
909165d813 | ||
|
|
6bee742b65 | ||
|
|
23486d01b9 | ||
|
|
b761d5a730 | ||
|
|
9181e74fc8 | ||
|
|
5e83864f41 | ||
|
|
73079ca1b7 | ||
|
|
789cf66de2 | ||
|
|
c36f19a97f | ||
|
|
109338923a | ||
|
|
f4c2501b06 | ||
|
|
9161229474 | ||
|
|
265f2f40bf | ||
|
|
d2935ac2ae | ||
|
|
aaf00b8a20 | ||
|
|
f9c6a49d2a | ||
|
|
2f54a48a3d | ||
|
|
be4dd0a787 | ||
|
|
f3f072e7cf | ||
|
|
a6270bf552 | ||
|
|
de5f2d6d5b | ||
|
|
4aa377dea7 | ||
|
|
efbf3d84ac | ||
|
|
b90393b43e | ||
|
|
31ae73fe0e | ||
|
|
7a5adfc4dc | ||
|
|
850e264912 | ||
|
|
aa81779ad8 | ||
|
|
72c97c0835 | ||
|
|
12809a6733 | ||
|
|
c55aeff98e | ||
|
|
16b76e401c | ||
|
|
d2470efd6f | ||
|
|
1a97b1b77c | ||
|
|
adde5b78f3 | ||
|
|
06fd3a3686 | ||
|
|
d231b6ae2a | ||
|
|
f76274c19a | ||
|
|
e471fc5d23 | ||
|
|
cb1b602255 | ||
|
|
a728dbf632 | ||
|
|
84d06d180a | ||
|
|
342e4d9f5e | ||
|
|
8eb92471ae | ||
|
|
0cfc32f591 | ||
|
|
e8b1e07625 | ||
|
|
f97946bd21 | ||
|
|
f7f461db31 | ||
|
|
653d09c337 | ||
|
|
3fa5ac30ff | ||
|
|
4095041da9 | ||
|
|
c1c2f39cb5 | ||
|
|
e5b93871f7 | ||
|
|
896aeb571d | ||
|
|
f7f1a0aff0 | ||
|
|
3bc82dc382 | ||
|
|
99bac77ae7 | ||
|
|
5705ebdcad | ||
|
|
f3fb445c9e | ||
|
|
c60fe8aae2 | ||
|
|
d2a882e531 | ||
|
|
036fa1f43b | ||
|
|
839b4af45c | ||
|
|
3a9797ce75 | ||
|
|
b2f14c0339 | ||
|
|
5d9405ccc3 | ||
|
|
d54db4358c | ||
|
|
a172f61494 | ||
|
|
225280d37a | ||
|
|
c735ab6b95 | ||
|
|
d47e59783f | ||
|
|
8a390d255d | ||
|
|
03540b22c1 | ||
|
|
fad96fe4f4 | ||
|
|
19b706d125 | ||
|
|
c871912188 | ||
|
|
7124bd05c8 | ||
|
|
783f444cff | ||
|
|
0f57687d81 | ||
|
|
235bf1f4e4 | ||
|
|
2d7b4b6c82 | ||
|
|
68369c16da | ||
|
|
90f36db63a | ||
|
|
f002110c28 | ||
|
|
83513b624e | ||
|
|
6042250940 | ||
|
|
f78c234780 | ||
|
|
21efae9276 | ||
|
|
1e58606ae7 | ||
|
|
4a11682316 | ||
|
|
3e92680b08 | ||
|
|
2be47d688b | ||
|
|
2ddccdbca5 | ||
|
|
ab05897cd6 | ||
|
|
7cd691f5f0 | ||
|
|
24a13af657 | ||
|
|
b13530e84b | ||
|
|
3911b72f87 | ||
|
|
ec278cfcd8 | ||
|
|
912730378e | ||
|
|
ac35f19f01 | ||
|
|
c25a1af96e | ||
|
|
70667d06a1 | ||
|
|
31fd994d83 | ||
|
|
fc934157f6 | ||
|
|
0bbded1772 | ||
|
|
a6eea34c74 | ||
|
|
3605b746a9 | ||
|
|
4b29a9aaa6 | ||
|
|
e60a9f4a74 | ||
|
|
d1d773bc9c | ||
|
|
55e8a269c0 | ||
|
|
0db0aadd45 | ||
|
|
83f3873e03 | ||
|
|
80fd3e9697 | ||
|
|
bae8268b29 | ||
|
|
466c5f695a | ||
|
|
b6a70228ea | ||
|
|
ac32c432da | ||
|
|
066ac6bf98 | ||
|
|
ccfa7d9943 | ||
|
|
90c76a01a6 | ||
|
|
807b52cccf | ||
|
|
fb7c6c6bbf | ||
|
|
12e619b990 | ||
|
|
aba2f8110c | ||
|
|
862e3fc7ed | ||
|
|
51fc92759a | ||
|
|
c8fac3381d | ||
|
|
9723090f91 | ||
|
|
4783e08c69 | ||
|
|
34959ff0ec | ||
|
|
bec9be84d5 | ||
|
|
277ee9d7e4 | ||
|
|
314518a87f | ||
|
|
c280fa11c3 | ||
|
|
929f5785a8 | ||
|
|
9ae92c19ab | ||
|
|
599bb7355e | ||
|
|
ad76a2f44f | ||
|
|
3a3ad44f13 | ||
|
|
db01bfb0a8 | ||
|
|
3e9b7e829c | ||
|
|
530720f2b9 | ||
|
|
a5d6d364db | ||
|
|
cb7e580942 | ||
|
|
8653fc7eb1 | ||
|
|
d077702250 | ||
|
|
472b15d940 | ||
|
|
f71176b362 | ||
|
|
aa5f988776 | ||
|
|
328311e781 | ||
|
|
f2875de83d | ||
|
|
2108f918b4 | ||
|
|
32441bdcd6 | ||
|
|
b80b9c08db | ||
|
|
4f09c94098 | ||
|
|
5e47f2fb52 | ||
|
|
47f2f62b4f | ||
|
|
61642b2536 | ||
|
|
20d12c5aa1 | ||
|
|
dd9ac6e4f8 | ||
|
|
1b7196938f | ||
|
|
5d9818914c | ||
|
|
f33ec81f19 | ||
|
|
a9dbcc29d0 | ||
|
|
f30f92d1b6 | ||
|
|
33d250d0e1 | ||
|
|
f025ffa7b1 | ||
|
|
6467bb89b3 | ||
|
|
7fc9195068 | ||
|
|
2e7e276abf | ||
|
|
cc249d3e8b | ||
|
|
2db8b35cf7 | ||
|
|
f098002da5 | ||
|
|
0b47d279c0 | ||
|
|
a3234f3912 | ||
|
|
2a6f2bbb4b | ||
|
|
fcdad5d80d | ||
|
|
dfa15c1e0f | ||
|
|
bead3462e7 | ||
|
|
246f91937c | ||
|
|
468de3d3af | ||
|
|
ee292b8855 | ||
|
|
38a6361aed | ||
|
|
0231650b6b | ||
|
|
35e4af88d0 | ||
|
|
a44a1496ca | ||
|
|
7ebc77c95f | ||
|
|
de20b17989 | ||
|
|
cae4b244e8 | ||
|
|
eed5aec08d | ||
|
|
90fa0e0588 | ||
|
|
2269bd4d8f | ||
|
|
b3bd55f969 | ||
|
|
dd91354eb4 | ||
|
|
27c294166b | ||
|
|
0cdf004902 | ||
|
|
9dd8d9510b | ||
|
|
6de44dd8d1 | ||
|
|
41e88b82b7 | ||
|
|
afe73c05fe | ||
|
|
f4fc60707f | ||
|
|
8527c3fef9 | ||
|
|
c279174465 | ||
|
|
49fa18825b | ||
|
|
32d7dca15b | ||
|
|
8ba2d47e48 | ||
|
|
c4d5cad2d4 | ||
|
|
718543cf83 | ||
|
|
ca8f21358e | ||
|
|
d56fc0874c | ||
|
|
d09584fa88 | ||
|
|
ade4890ede | ||
|
|
b734c66a90 | ||
|
|
bc979ba26e | ||
|
|
906acaf417 | ||
|
|
432724f63e | ||
|
|
1e5e3a1599 | ||
|
|
37699c1831 | ||
|
|
6c6da24281 | ||
|
|
2d85476433 | ||
|
|
cdc8a6b568 | ||
|
|
1b539483d1 | ||
|
|
25eab61cd0 | ||
|
|
43a782937f | ||
|
|
de1a3ee84a | ||
|
|
b12eb407cb | ||
|
|
90096d65e9 | ||
|
|
0e7f1aa44a | ||
|
|
68932ee4ce | ||
|
|
cf22cfcc88 | ||
|
|
c5b5eacba5 | ||
|
|
380bcb2d14 | ||
|
|
956a4d1b5e | ||
|
|
b7fb4b4b0b | ||
|
|
4433745cff | ||
|
|
8eda79227b | ||
|
|
1a3ec55e6e |
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
"jazz-react-native": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Fix username key hashing in DemoAuth
|
|
||||||
Improve error handling when loading an existing account fails
|
|
||||||
Fix the double context creation in Reacc development mode
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
"cojson": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Add the assign method to RawCoMap to create bulk transactions and optimize RawCoMap init
|
|
||||||
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
project: ["tests/e2e", "examples/chat", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "examples/onboarding"]
|
project: ["tests/e2e", "examples/chat", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "examples/onboarding", "starters/react-demo-auth-tailwind"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -1,5 +1,194 @@
|
|||||||
# chat-rn-clerk
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-react-native@0.9.15
|
||||||
|
- jazz-react-native-auth-clerk@0.9.15
|
||||||
|
- jazz-react-native-media-images@0.9.15
|
||||||
|
|
||||||
|
## 1.0.55
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-react-native@0.9.14
|
||||||
|
- jazz-react-native-auth-clerk@0.9.14
|
||||||
|
- jazz-react-native-media-images@0.9.14
|
||||||
|
|
||||||
|
## 1.0.54
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.13
|
||||||
|
- jazz-react-native-auth-clerk@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-react-native-media-images@0.9.13
|
||||||
|
|
||||||
|
## 1.0.53
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.12
|
||||||
|
- jazz-react-native-auth-clerk@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-react-native-media-images@0.9.12
|
||||||
|
|
||||||
|
## 1.0.52
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.11
|
||||||
|
- jazz-react-native-auth-clerk@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-react-native-media-images@0.9.11
|
||||||
|
|
||||||
|
## 1.0.51
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- f76274c: Fix image handling in react-native
|
||||||
|
- Updated dependencies [f76274c]
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react-native@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-react-native-auth-clerk@0.9.10
|
||||||
|
- jazz-react-native-media-images@0.9.10
|
||||||
|
|
||||||
|
## 1.0.50
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-react-native@0.9.9
|
||||||
|
- jazz-react-native-auth-clerk@0.9.9
|
||||||
|
- jazz-react-native-media-images@0.9.9
|
||||||
|
|
||||||
|
## 1.0.49
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react-native@0.9.8
|
||||||
|
- jazz-react-native-auth-clerk@0.9.8
|
||||||
|
- jazz-react-native-media-images@0.9.8
|
||||||
|
|
||||||
|
## 1.0.48
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8a390d2]
|
||||||
|
- jazz-react-native@0.9.6
|
||||||
|
- jazz-react-native-auth-clerk@0.9.6
|
||||||
|
|
||||||
|
## 1.0.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [c871912]
|
||||||
|
- jazz-react-native@0.9.5
|
||||||
|
- jazz-react-native-auth-clerk@0.9.5
|
||||||
|
|
||||||
|
## 1.0.46
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.4
|
||||||
|
- jazz-react-native-auth-clerk@0.9.4
|
||||||
|
|
||||||
|
## 1.0.45
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [7cd691f]
|
||||||
|
- jazz-react-native@0.9.3
|
||||||
|
- jazz-react-native-auth-clerk@0.9.3
|
||||||
|
|
||||||
|
## 1.0.44
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [80fd3e9]
|
||||||
|
- jazz-react-native@0.9.2
|
||||||
|
- jazz-react-native-auth-clerk@0.9.2
|
||||||
|
|
||||||
|
## 1.0.43
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-react-native@0.9.1
|
||||||
|
- jazz-react-native-auth-clerk@0.9.1
|
||||||
|
- jazz-react-native-media-images@0.9.1
|
||||||
|
|
||||||
|
## 1.0.42
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1da4d55]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- Updated dependencies [1e5e3a1]
|
||||||
|
- jazz-react-native@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-react-native-auth-clerk@0.9.0
|
||||||
|
- jazz-react-native-media-images@0.9.0
|
||||||
|
|
||||||
## 1.0.41
|
## 1.0.41
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -37,7 +37,13 @@
|
|||||||
],
|
],
|
||||||
"expo-secure-store",
|
"expo-secure-store",
|
||||||
"expo-font",
|
"expo-font",
|
||||||
"expo-router"
|
"expo-router",
|
||||||
|
[
|
||||||
|
"expo-image-picker",
|
||||||
|
{
|
||||||
|
"photosPermission": "The app accesses your photos to let you share them with your friends."
|
||||||
|
}
|
||||||
|
]
|
||||||
],
|
],
|
||||||
"extra": {
|
"extra": {
|
||||||
"eas": {
|
"eas": {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Redirect, Stack } from "expo-router";
|
import { Redirect, Stack } from "expo-router";
|
||||||
|
import { useIsAuthenticated } from "jazz-react-native";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useAuth } from "../../src/auth-context";
|
|
||||||
|
|
||||||
export default function HomeLayout() {
|
export default function HomeLayout() {
|
||||||
const { isAuthenticated } = useAuth();
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
return <Redirect href={"/chat"} />;
|
return <Redirect href={"/chat"} />;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Redirect, Stack } from "expo-router";
|
import { Redirect, Stack } from "expo-router";
|
||||||
import { useAuth } from "../../src/auth-context";
|
import { useIsAuthenticated } from "jazz-react-native";
|
||||||
|
|
||||||
export default function UnAuthenticatedLayout() {
|
export default function UnAuthenticatedLayout() {
|
||||||
const { isAuthenticated } = useAuth();
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
return <Redirect href={"/chat"} />;
|
return <Redirect href={"/chat"} />;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { useAccount, useCoState } from "@/src/jazz";
|
|
||||||
import { Chat, Message } from "@/src/schema";
|
import { Chat, Message } from "@/src/schema";
|
||||||
import { useFocusEffect, useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import * as Clipboard from "expo-clipboard";
|
import * as Clipboard from "expo-clipboard";
|
||||||
|
import * as ImagePicker from "expo-image-picker";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
|
import { useAccount, useCoState } from "jazz-react-native";
|
||||||
|
import { ProgressiveImg } from "jazz-react-native";
|
||||||
|
import { createImage } from "jazz-react-native-media-images";
|
||||||
import { Group, ID } from "jazz-tools";
|
import { Group, ID } from "jazz-tools";
|
||||||
import { useEffect, useLayoutEffect, useState } from "react";
|
import { useEffect, useLayoutEffect, useState } from "react";
|
||||||
import React, {
|
import React, {
|
||||||
@@ -16,6 +19,8 @@ import React, {
|
|||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
TextInput,
|
TextInput,
|
||||||
Button,
|
Button,
|
||||||
|
Image,
|
||||||
|
ActivityIndicator,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
|
||||||
export default function Conversation() {
|
export default function Conversation() {
|
||||||
@@ -25,6 +30,7 @@ export default function Conversation() {
|
|||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
const loadedChat = useCoState(Chat, chat?.id, [{}]);
|
const loadedChat = useCoState(Chat, chat?.id, [{}]);
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (chat) return;
|
if (chat) return;
|
||||||
@@ -81,6 +87,32 @@ export default function Conversation() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleImageUpload = async () => {
|
||||||
|
try {
|
||||||
|
const result = await ImagePicker.launchImageLibraryAsync({
|
||||||
|
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||||
|
base64: true,
|
||||||
|
quality: 0.7,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.canceled && result.assets[0].base64 && chat) {
|
||||||
|
setIsUploading(true);
|
||||||
|
const base64Uri = `data:image/jpeg;base64,${result.assets[0].base64}`;
|
||||||
|
|
||||||
|
const image = await createImage(base64Uri, {
|
||||||
|
owner: chat._owner,
|
||||||
|
maxSize: 2048,
|
||||||
|
});
|
||||||
|
|
||||||
|
chat.push(Message.create({ text: "", image }, { owner: chat._owner }));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Alert.alert("Error", "Failed to upload image");
|
||||||
|
} finally {
|
||||||
|
setIsUploading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderMessageItem = ({ item }: { item: Message }) => {
|
const renderMessageItem = ({ item }: { item: Message }) => {
|
||||||
const isMe = item._edits.text.by?.isMe;
|
const isMe = item._edits.text.by?.isMe;
|
||||||
return (
|
return (
|
||||||
@@ -106,14 +138,27 @@ export default function Conversation() {
|
|||||||
isMe ? "flex-row" : "flex-row",
|
isMe ? "flex-row" : "flex-row",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Text
|
{item.image && (
|
||||||
className={clsx(
|
<ProgressiveImg image={item.image} maxWidth={1024}>
|
||||||
!isMe ? "text-black" : "text-gray-200",
|
{({ src, res, originalSize }) => (
|
||||||
`text-md max-w-[85%]`,
|
<Image
|
||||||
)}
|
source={{ uri: src }}
|
||||||
>
|
className="w-48 h-48 rounded-lg mb-2"
|
||||||
{item.text}
|
resizeMode="cover"
|
||||||
</Text>
|
/>
|
||||||
|
)}
|
||||||
|
</ProgressiveImg>
|
||||||
|
)}
|
||||||
|
{item.text && (
|
||||||
|
<Text
|
||||||
|
className={clsx(
|
||||||
|
!isMe ? "text-black" : "text-gray-200",
|
||||||
|
`text-md max-w-[85%]`,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{item.text}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
<Text
|
<Text
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"text-[10px] text-right ml-2",
|
"text-[10px] text-right ml-2",
|
||||||
@@ -147,6 +192,17 @@ export default function Conversation() {
|
|||||||
className="p-3 bg-white border-t border-gray-300"
|
className="p-3 bg-white border-t border-gray-300"
|
||||||
>
|
>
|
||||||
<SafeAreaView className="flex-row items-center gap-2">
|
<SafeAreaView className="flex-row items-center gap-2">
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={handleImageUpload}
|
||||||
|
disabled={isUploading}
|
||||||
|
className="h-10 w-10 items-center justify-center"
|
||||||
|
>
|
||||||
|
{isUploading ? (
|
||||||
|
<ActivityIndicator size="small" color="#0000ff" />
|
||||||
|
) : (
|
||||||
|
<Text className="text-2xl">🖼️</Text>
|
||||||
|
)}
|
||||||
|
</TouchableOpacity>
|
||||||
<TextInput
|
<TextInput
|
||||||
className="flex-1 rounded-full h-10 px-4 bg-gray-100 border border-gray-300 focus:border-blue-500 focus:bg-white"
|
className="flex-1 rounded-full h-10 px-4 bg-gray-100 border border-gray-300 focus:border-blue-500 focus:bg-white"
|
||||||
value={message}
|
value={message}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import React, {
|
|||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
|
||||||
import { useUser } from "@clerk/clerk-expo";
|
import { useUser } from "@clerk/clerk-expo";
|
||||||
import { useAccount } from "../../src/jazz";
|
import { useAccount } from "jazz-react-native";
|
||||||
import { Chat } from "../../src/schema";
|
import { Chat } from "../../src/schema";
|
||||||
|
|
||||||
export default function ChatScreen() {
|
export default function ChatScreen() {
|
||||||
@@ -20,10 +20,15 @@ export default function ChatScreen() {
|
|||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
|
|
||||||
|
function handleLogOut() {
|
||||||
|
logOut();
|
||||||
|
router.navigate("/");
|
||||||
|
}
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
headerTitle: "Chat",
|
headerTitle: "Chat",
|
||||||
headerRight: () => <Button onPress={logOut} title="Logout" />,
|
headerRight: () => <Button onPress={handleLogOut} title="Logout" />,
|
||||||
});
|
});
|
||||||
}, [navigation]);
|
}, [navigation]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "chat-rn-clerk",
|
"name": "chat-rn-clerk",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"version": "1.0.41",
|
"version": "1.0.61",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "expo export -p ios",
|
"build": "expo export -p ios",
|
||||||
"start": "expo start",
|
"start": "expo start",
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"@bam.tech/react-native-image-resizer": "^3.0.11",
|
"@bam.tech/react-native-image-resizer": "^3.0.11",
|
||||||
"@clerk/clerk-expo": "^2.2.21",
|
"@clerk/clerk-expo": "^2.2.21",
|
||||||
"@expo/vector-icons": "^14.0.2",
|
"@expo/vector-icons": "^14.0.2",
|
||||||
|
"@op-engineering/op-sqlite": "^11.2.12",
|
||||||
"@react-native-community/netinfo": "^11.4.1",
|
"@react-native-community/netinfo": "^11.4.1",
|
||||||
"@react-navigation/native": "^7.0.13",
|
"@react-navigation/native": "^7.0.13",
|
||||||
"@react-navigation/native-stack": "^7.1.14",
|
"@react-navigation/native-stack": "^7.1.14",
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
"expo-dev-client": "~5.0.5",
|
"expo-dev-client": "~5.0.5",
|
||||||
"expo-file-system": "^18.0.4",
|
"expo-file-system": "^18.0.4",
|
||||||
"expo-font": "~13.0.1",
|
"expo-font": "~13.0.1",
|
||||||
|
"expo-image-picker": "~16.0.4",
|
||||||
"expo-linking": "~7.0.3",
|
"expo-linking": "~7.0.3",
|
||||||
"expo-router": "~4.0.11",
|
"expo-router": "~4.0.11",
|
||||||
"expo-secure-store": "~14.0.0",
|
"expo-secure-store": "~14.0.0",
|
||||||
|
|||||||
@@ -1,62 +1,20 @@
|
|||||||
import { useClerk, useUser } from "@clerk/clerk-expo";
|
import { useClerk } from "@clerk/clerk-expo";
|
||||||
import { useJazzClerkAuth } from "jazz-react-native-auth-clerk";
|
import { JazzProviderWithClerk } from "jazz-react-native-auth-clerk";
|
||||||
import React, {
|
import React, { PropsWithChildren } from "react";
|
||||||
createContext,
|
|
||||||
PropsWithChildren,
|
|
||||||
useContext,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import { Text, View } from "react-native";
|
|
||||||
import { Jazz, kvStore } from "./jazz";
|
|
||||||
|
|
||||||
const AuthContext = createContext<{
|
|
||||||
isAuthenticated: boolean;
|
|
||||||
isLoading: boolean;
|
|
||||||
}>({
|
|
||||||
isAuthenticated: false,
|
|
||||||
isLoading: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
export function useAuth() {
|
|
||||||
return useContext(AuthContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function JazzAndAuth({ children }: PropsWithChildren) {
|
export function JazzAndAuth({ children }: PropsWithChildren) {
|
||||||
const { isSignedIn, isLoaded: isClerkLoaded } = useUser();
|
|
||||||
const clerk = useClerk();
|
const clerk = useClerk();
|
||||||
const [auth, state] = useJazzClerkAuth(clerk, kvStore);
|
|
||||||
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isSignedIn && isClerkLoaded && auth) {
|
|
||||||
setIsAuthenticated(true);
|
|
||||||
} else {
|
|
||||||
setIsAuthenticated(false);
|
|
||||||
}
|
|
||||||
}, [isSignedIn, isClerkLoaded, auth]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContext.Provider
|
<JazzProviderWithClerk
|
||||||
value={{ isAuthenticated, isLoading: !isClerkLoaded || !auth }}
|
clerk={clerk}
|
||||||
|
storage="sqlite"
|
||||||
|
sync={{
|
||||||
|
peer: "wss://cloud.jazz.tools/?key=chat-rn-clerk-example-jazz@garden.co",
|
||||||
|
when: "signedUp", // This makes the app work in local mode when the user is not authenticated
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{state?.errors?.length > 0 &&
|
{children}
|
||||||
state.errors.map((error) => (
|
</JazzProviderWithClerk>
|
||||||
<View key={error}>
|
|
||||||
<Text style={{ color: "red" }}>{error}</Text>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
{auth && clerk.user ? (
|
|
||||||
<Jazz.Provider
|
|
||||||
auth={auth}
|
|
||||||
peer="wss://cloud.jazz.tools/?key=chat-rn-clerk-example-jazz@garden.co"
|
|
||||||
storage={undefined}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
) : (
|
|
||||||
children
|
|
||||||
)}
|
|
||||||
</AuthContext.Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
import { createJazzRNApp } from "jazz-react-native";
|
|
||||||
|
|
||||||
export const Jazz = createJazzRNApp();
|
|
||||||
export const { useAccount, useCoState, useAcceptInvite, kvStore } = Jazz;
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { CoList, CoMap, co } from "jazz-tools";
|
import { CoList, CoMap, ImageDefinition, co } from "jazz-tools";
|
||||||
|
|
||||||
export class Message extends CoMap {
|
export class Message extends CoMap {
|
||||||
text = co.string;
|
text = co.string;
|
||||||
|
image = co.optional.ref(ImageDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Chat extends CoList.Of(co.ref(Message)) {}
|
export class Chat extends CoList.Of(co.ref(Message)) {}
|
||||||
|
|||||||
@@ -1,5 +1,158 @@
|
|||||||
# chat-rn
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-react-native@0.9.15
|
||||||
|
|
||||||
|
## 1.0.52
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-react-native@0.9.14
|
||||||
|
|
||||||
|
## 1.0.51
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
|
||||||
|
## 1.0.50
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
|
||||||
|
## 1.0.49
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
|
||||||
|
## 1.0.48
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [f76274c]
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react-native@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
|
||||||
|
## 1.0.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-react-native@0.9.9
|
||||||
|
|
||||||
|
## 1.0.46
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react-native@0.9.8
|
||||||
|
|
||||||
|
## 1.0.45
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8a390d2]
|
||||||
|
- jazz-react-native@0.9.6
|
||||||
|
|
||||||
|
## 1.0.44
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [c871912]
|
||||||
|
- jazz-react-native@0.9.5
|
||||||
|
|
||||||
|
## 1.0.43
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react-native@0.9.4
|
||||||
|
|
||||||
|
## 1.0.42
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [7cd691f]
|
||||||
|
- jazz-react-native@0.9.3
|
||||||
|
|
||||||
|
## 1.0.41
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [80fd3e9]
|
||||||
|
- jazz-react-native@0.9.2
|
||||||
|
|
||||||
|
## 1.0.40
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-react-native@0.9.1
|
||||||
|
|
||||||
|
## 1.0.39
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1da4d55]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- Updated dependencies [1e5e3a1]
|
||||||
|
- jazz-react-native@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
|
||||||
## 1.0.38
|
## 1.0.38
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chat-rn",
|
"name": "chat-rn",
|
||||||
"version": "1.0.38",
|
"version": "1.0.58",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "expo export -p ios",
|
"build": "expo export -p ios",
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/core-asynciterator-polyfill": "^1.0.2",
|
"@azure/core-asynciterator-polyfill": "^1.0.2",
|
||||||
|
"@op-engineering/op-sqlite": "^11.2.12",
|
||||||
"@react-native-community/netinfo": "^11.4.1",
|
"@react-native-community/netinfo": "^11.4.1",
|
||||||
"@react-navigation/native": "^7.0.13",
|
"@react-navigation/native": "^7.0.13",
|
||||||
"@react-navigation/native-stack": "^7.1.14",
|
"@react-navigation/native-stack": "^7.1.14",
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ import * as Linking from "expo-linking";
|
|||||||
import React, { StrictMode, useEffect, useState } from "react";
|
import React, { StrictMode, useEffect, useState } from "react";
|
||||||
import HandleInviteScreen from "./invite";
|
import HandleInviteScreen from "./invite";
|
||||||
|
|
||||||
import { DemoAuthBasicUI, useDemoAuth } from "jazz-react-native";
|
import { JazzProvider } from "jazz-react-native";
|
||||||
import ChatScreen from "./chat";
|
import ChatScreen from "./chat";
|
||||||
import { Jazz } from "./jazz";
|
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator();
|
const Stack = createNativeStackNavigator();
|
||||||
|
|
||||||
@@ -29,12 +28,10 @@ const linking = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [auth, state] = useDemoAuth();
|
|
||||||
const [initialRoute, setInitialRoute] = useState<
|
const [initialRoute, setInitialRoute] = useState<
|
||||||
"ChatScreen" | "HandleInviteScreen"
|
"ChatScreen" | "HandleInviteScreen"
|
||||||
>("ChatScreen");
|
>("ChatScreen");
|
||||||
const navigationRef = useNavigationContainerRef();
|
const navigationRef = useNavigationContainerRef();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Linking.getInitialURL().then((url) => {
|
Linking.getInitialURL().then((url) => {
|
||||||
if (url) {
|
if (url) {
|
||||||
@@ -45,16 +42,13 @@ function App() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!auth) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<Jazz.Provider
|
<JazzProvider
|
||||||
auth={auth}
|
storage="sqlite"
|
||||||
peer="wss://cloud.jazz.tools/?key=chat-rn-example-jazz@garden.co"
|
sync={{
|
||||||
storage={undefined}
|
peer: "wss://cloud.jazz.tools/?key=chat-rn-example-jazz@garden.co",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<NavigationContainer linking={linking} ref={navigationRef}>
|
<NavigationContainer linking={linking} ref={navigationRef}>
|
||||||
<Stack.Navigator initialRouteName={initialRoute}>
|
<Stack.Navigator initialRouteName={initialRoute}>
|
||||||
@@ -70,10 +64,7 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
</Jazz.Provider>
|
</JazzProvider>
|
||||||
{state.state !== "signedIn" ? (
|
|
||||||
<DemoAuthBasicUI appName="Jazz Chat" state={state} />
|
|
||||||
) : null}
|
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import * as Clipboard from "expo-clipboard";
|
import * as Clipboard from "expo-clipboard";
|
||||||
import { Group, ID } from "jazz-tools";
|
import { Group, ID, Profile } from "jazz-tools";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import React, {
|
import React, {
|
||||||
Button,
|
Button,
|
||||||
@@ -14,7 +14,7 @@ import React, {
|
|||||||
Alert,
|
Alert,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
|
||||||
import { useAccount, useCoState } from "./jazz";
|
import { useAccount, useCoState } from "jazz-react-native";
|
||||||
import { Chat, Message } from "./schema";
|
import { Chat, Message } from "./schema";
|
||||||
|
|
||||||
export default function ChatScreen({ navigation }: { navigation: any }) {
|
export default function ChatScreen({ navigation }: { navigation: any }) {
|
||||||
@@ -22,10 +22,16 @@ export default function ChatScreen({ navigation }: { navigation: any }) {
|
|||||||
const [chatId, setChatId] = useState<ID<Chat>>();
|
const [chatId, setChatId] = useState<ID<Chat>>();
|
||||||
const loadedChat = useCoState(Chat, chatId, [{}]);
|
const loadedChat = useCoState(Chat, chatId, [{}]);
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
|
const profile = useCoState(Profile, me._refs.profile?.id, {});
|
||||||
|
|
||||||
|
function handleLogOut() {
|
||||||
|
setChatId(undefined);
|
||||||
|
logOut();
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
headerRight: () => <Button onPress={logOut} title="Logout" />,
|
headerRight: () => <Button onPress={handleLogOut} title="Logout" />,
|
||||||
headerLeft: () =>
|
headerLeft: () =>
|
||||||
loadedChat ? (
|
loadedChat ? (
|
||||||
<Button
|
<Button
|
||||||
@@ -131,6 +137,18 @@ export default function ChatScreen({ navigation }: { navigation: any }) {
|
|||||||
<View className="flex flex-col h-full">
|
<View className="flex flex-col h-full">
|
||||||
{!loadedChat ? (
|
{!loadedChat ? (
|
||||||
<View className="flex flex-col h-full items-center justify-center">
|
<View className="flex flex-col h-full items-center justify-center">
|
||||||
|
<Text className="text-m font-bold mb-6">Username</Text>
|
||||||
|
<TextInput
|
||||||
|
className="rounded h-12 p-2 mb-12 w-40 border border-gray-200 block"
|
||||||
|
value={profile?.name ?? ""}
|
||||||
|
onChangeText={(value) => {
|
||||||
|
if (profile) {
|
||||||
|
profile.name = value;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
textAlignVertical="center"
|
||||||
|
onSubmitEditing={sendMessage}
|
||||||
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={createChat}
|
onPress={createChat}
|
||||||
className="bg-blue-500 p-4 rounded-md"
|
className="bg-blue-500 p-4 rounded-md"
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
|
import { useAcceptInvite } from "jazz-react-native";
|
||||||
import React, { Text } from "react-native";
|
import React, { Text } from "react-native";
|
||||||
import { useAcceptInvite } from "./jazz";
|
|
||||||
import { Chat } from "./schema";
|
import { Chat } from "./schema";
|
||||||
|
|
||||||
type ChatScreenParams = {
|
|
||||||
valueHint?: string;
|
|
||||||
valueID?: string;
|
|
||||||
inviteSecret?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function HandleInviteScreen({
|
export default function HandleInviteScreen({
|
||||||
navigation,
|
navigation,
|
||||||
}: {
|
}: {
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
import { createJazzRNApp } from "jazz-react-native";
|
|
||||||
|
|
||||||
export const Jazz = createJazzRNApp();
|
|
||||||
export const { useAccount, useCoState, useAcceptInvite } = Jazz;
|
|
||||||
@@ -1,5 +1,138 @@
|
|||||||
# chat-vue
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-browser@0.9.15
|
||||||
|
- jazz-vue@0.9.15
|
||||||
|
|
||||||
|
## 0.0.39
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-browser@0.9.14
|
||||||
|
- jazz-vue@0.9.14
|
||||||
|
|
||||||
|
## 0.0.38
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-browser@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-vue@0.9.13
|
||||||
|
|
||||||
|
## 0.0.37
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-browser@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-vue@0.9.12
|
||||||
|
|
||||||
|
## 0.0.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-browser@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-vue@0.9.11
|
||||||
|
|
||||||
|
## 0.0.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-browser@0.9.10
|
||||||
|
- jazz-vue@0.9.10
|
||||||
|
|
||||||
|
## 0.0.34
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-browser@0.9.9
|
||||||
|
- jazz-vue@0.9.9
|
||||||
|
|
||||||
|
## 0.0.33
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-browser@0.9.8
|
||||||
|
- jazz-vue@0.9.8
|
||||||
|
|
||||||
|
## 0.0.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- Updated dependencies [5d98189]
|
||||||
|
- jazz-browser@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-vue@0.9.1
|
||||||
|
|
||||||
|
## 0.0.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [9dd8d95]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-vue@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-browser@0.9.0
|
||||||
|
|
||||||
## 0.0.30
|
## 0.0.30
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,29 +1,55 @@
|
|||||||
# Chat example with Jazz and Vue
|
# Chat example with Jazz and Vue
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example chat-vue --project-name chat-vue
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the todo-vue example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/chat-vue
|
cd chat-vue
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/chat-vue/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chat-vue",
|
"name": "chat-vue",
|
||||||
"version": "0.0.30",
|
"version": "0.0.45",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useAccount } from "jazz-vue";
|
||||||
import AppContainer from "./components/AppContainer.vue";
|
import AppContainer from "./components/AppContainer.vue";
|
||||||
import TopBar from "./components/TopBar.vue";
|
import TopBar from "./components/TopBar.vue";
|
||||||
import { useAccount } from "./main";
|
|
||||||
|
|
||||||
const { me, logOut } = useAccount();
|
const { me, logOut } = useAccount();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,36 +1,30 @@
|
|||||||
import { DemoAuthBasicUI, createJazzVueApp, useDemoAuth } from "jazz-vue";
|
import { DemoAuthBasicUI, JazzProvider } from "jazz-vue";
|
||||||
import { createApp, defineComponent, h } from "vue";
|
import { createApp, defineComponent, h } from "vue";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
|
|
||||||
const Jazz = createJazzVueApp();
|
|
||||||
export const { useAccount, useCoState } = Jazz;
|
|
||||||
const { JazzProvider } = Jazz;
|
|
||||||
|
|
||||||
const RootComponent = defineComponent({
|
const RootComponent = defineComponent({
|
||||||
name: "RootComponent",
|
name: "RootComponent",
|
||||||
setup() {
|
setup() {
|
||||||
const { authMethod, state } = useDemoAuth();
|
return () =>
|
||||||
|
|
||||||
return () => [
|
|
||||||
h(
|
h(
|
||||||
JazzProvider,
|
JazzProvider,
|
||||||
{
|
{
|
||||||
auth: authMethod.value,
|
sync: {
|
||||||
peer: "wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co",
|
peer: "wss://cloud.jazz.tools/?key=vue-todo-example-jazz@garden.co",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
h(
|
||||||
default: () => h(App),
|
DemoAuthBasicUI,
|
||||||
},
|
{
|
||||||
),
|
appName: "Jazz Vue Chat",
|
||||||
|
},
|
||||||
state.state !== "signedIn" &&
|
{
|
||||||
h(DemoAuthBasicUI, {
|
default: () => h(App),
|
||||||
appName: "Jazz Chat",
|
},
|
||||||
state,
|
),
|
||||||
}),
|
);
|
||||||
];
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { ID } from "jazz-tools";
|
import type { ID } from "jazz-tools";
|
||||||
|
import { useCoState } from "jazz-vue";
|
||||||
import { type PropType, computed, defineComponent, ref } from "vue";
|
import { type PropType, computed, defineComponent, ref } from "vue";
|
||||||
import ChatBody from "../components/ChatBody.vue";
|
import ChatBody from "../components/ChatBody.vue";
|
||||||
import ChatBubble from "../components/ChatBubble.vue";
|
import ChatBubble from "../components/ChatBubble.vue";
|
||||||
import ChatInput from "../components/ChatInput.vue";
|
import ChatInput from "../components/ChatInput.vue";
|
||||||
import EmptyChatMessage from "../components/EmptyChatMessage.vue";
|
import EmptyChatMessage from "../components/EmptyChatMessage.vue";
|
||||||
import { useCoState } from "../main";
|
|
||||||
import { Chat, Message } from "../schema";
|
import { Chat, Message } from "../schema";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Group } from "jazz-tools";
|
import { Group } from "jazz-tools";
|
||||||
|
import { useAccount } from "jazz-vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useAccount } from "../main";
|
|
||||||
import { Chat } from "../schema";
|
import { Chat } from "../schema";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -1,5 +1,144 @@
|
|||||||
# jazz-example-chat
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-browser-media-images@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
|
||||||
|
## 0.0.135
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-browser-media-images@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
|
||||||
|
## 0.0.134
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-browser-media-images@0.9.13
|
||||||
|
|
||||||
|
## 0.0.133
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-browser-media-images@0.9.12
|
||||||
|
|
||||||
|
## 0.0.132
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-browser-media-images@0.9.11
|
||||||
|
|
||||||
|
## 0.0.131
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- f76274c: Fix image handling in react-native
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-browser-media-images@0.9.10
|
||||||
|
|
||||||
|
## 0.0.130
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-browser-media-images@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
|
||||||
|
## 0.0.129
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
- jazz-browser-media-images@0.9.8
|
||||||
|
|
||||||
|
## 0.0.128
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
|
||||||
|
## 0.0.127
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-browser-media-images@0.9.1
|
||||||
|
|
||||||
|
## 0.0.126
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-browser-media-images@0.9.0
|
||||||
|
|
||||||
## 0.0.125
|
## 0.0.125
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -2,30 +2,56 @@
|
|||||||
|
|
||||||
Live version: [https://chat.jazz.tools](https://chat.jazz.tools)
|
Live version: [https://chat.jazz.tools](https://chat.jazz.tools)
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example chat --project-name chat
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the chat example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/chat
|
cd chat
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/chat/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
@@ -34,4 +60,4 @@ If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or
|
|||||||
|
|
||||||
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
||||||
|
|
||||||
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/main.tsx](./src/main.tsx).
|
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<JazzProvider>` provider component in [./src/main.tsx](./src/main.tsx).
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jazz-example-chat",
|
"name": "jazz-example-chat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.125",
|
"version": "0.0.141",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { inIframe, onChatLoad } from "@/util.ts";
|
import { getRandomUsername, inIframe, onChatLoad } from "@/util.ts";
|
||||||
import { useIframeHashRouter } from "hash-slash";
|
import { useIframeHashRouter } from "hash-slash";
|
||||||
|
import { JazzProvider, useAccount } from "jazz-react";
|
||||||
import { Group, ID } from "jazz-tools";
|
import { Group, ID } from "jazz-tools";
|
||||||
|
import { StrictMode } from "react";
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
import { ChatScreen } from "./chatScreen.tsx";
|
import { ChatScreen } from "./chatScreen.tsx";
|
||||||
import { useAccount } from "./main.tsx";
|
|
||||||
import { Chat } from "./schema.ts";
|
import { Chat } from "./schema.ts";
|
||||||
|
import { ThemeProvider } from "./themeProvider.tsx";
|
||||||
import { AppContainer, TopBar } from "./ui.tsx";
|
import { AppContainer, TopBar } from "./ui.tsx";
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
@@ -12,9 +15,9 @@ export function App() {
|
|||||||
|
|
||||||
const createChat = () => {
|
const createChat = () => {
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
const group = Group.create({ owner: me });
|
const group = Group.create();
|
||||||
group.addMember("everyone", "writer");
|
group.addMember("everyone", "writer");
|
||||||
const chat = Chat.create([], { owner: group });
|
const chat = Chat.create([], group);
|
||||||
router.navigate("/#/chat/" + chat.id);
|
router.navigate("/#/chat/" + chat.id);
|
||||||
|
|
||||||
// for https://jazz.tools marketing site demo only
|
// for https://jazz.tools marketing site demo only
|
||||||
@@ -24,7 +27,15 @@ export function App() {
|
|||||||
return (
|
return (
|
||||||
<AppContainer>
|
<AppContainer>
|
||||||
<TopBar>
|
<TopBar>
|
||||||
<p>{me?.profile?.name}</p>
|
<input
|
||||||
|
type="text"
|
||||||
|
value={me?.profile?.name ?? ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (!me?.profile) return;
|
||||||
|
me.profile.name = e.target.value;
|
||||||
|
}}
|
||||||
|
placeholder="Set username"
|
||||||
|
/>
|
||||||
{!inIframe && <button onClick={logOut}>Log out</button>}
|
{!inIframe && <button onClick={logOut}>Log out</button>}
|
||||||
</TopBar>
|
</TopBar>
|
||||||
{router.route({
|
{router.route({
|
||||||
@@ -34,3 +45,21 @@ export function App() {
|
|||||||
</AppContainer>
|
</AppContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const defaultProfileName = url.searchParams.get("user") ?? getRandomUsername();
|
||||||
|
|
||||||
|
createRoot(document.getElementById("root")!).render(
|
||||||
|
<ThemeProvider>
|
||||||
|
<StrictMode>
|
||||||
|
<JazzProvider
|
||||||
|
sync={{
|
||||||
|
peer: "wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co",
|
||||||
|
}}
|
||||||
|
defaultProfileName={defaultProfileName}
|
||||||
|
>
|
||||||
|
<App />
|
||||||
|
</JazzProvider>
|
||||||
|
</StrictMode>
|
||||||
|
</ThemeProvider>,
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createImage } from "jazz-browser-media-images";
|
import { createImage } from "jazz-browser-media-images";
|
||||||
|
import { useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useAccount, useCoState } from "./main.tsx";
|
|
||||||
import { Chat, Message } from "./schema.ts";
|
import { Chat, Message } from "./schema.ts";
|
||||||
import {
|
import {
|
||||||
BubbleBody,
|
BubbleBody,
|
||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
|
|
||||||
export function ChatScreen(props: { chatID: ID<Chat> }) {
|
export function ChatScreen(props: { chatID: ID<Chat> }) {
|
||||||
const chat = useCoState(Chat, props.chatID, [{}]);
|
const chat = useCoState(Chat, props.chatID, [{}]);
|
||||||
const { me } = useAccount();
|
|
||||||
const [showNLastMessages, setShowNLastMessages] = useState(30);
|
const [showNLastMessages, setShowNLastMessages] = useState(30);
|
||||||
|
|
||||||
if (!chat)
|
if (!chat)
|
||||||
@@ -27,8 +26,6 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const sendImage = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const sendImage = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (!me?.profile) return;
|
|
||||||
|
|
||||||
const file = event.currentTarget.files?.[0];
|
const file = event.currentTarget.files?.[0];
|
||||||
|
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
@@ -39,12 +36,7 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createImage(file, { owner: chat._owner }).then((image) => {
|
createImage(file, { owner: chat._owner }).then((image) => {
|
||||||
chat.push(
|
chat.push(Message.create({ text: file.name, image: image }, chat._owner));
|
||||||
Message.create(
|
|
||||||
{ text: file.name, image: image },
|
|
||||||
{ owner: chat._owner },
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import { ThemeProvider } from "@/themeProvider.tsx";
|
|
||||||
import { DemoAuthBasicUI, createJazzReactApp, useDemoAuth } from "jazz-react";
|
|
||||||
import { StrictMode } from "react";
|
|
||||||
import { createRoot } from "react-dom/client";
|
|
||||||
import { App } from "./app.tsx";
|
|
||||||
|
|
||||||
const Jazz = createJazzReactApp();
|
|
||||||
export const { useAccount, useCoState } = Jazz;
|
|
||||||
|
|
||||||
function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
|
||||||
const [auth, state] = useDemoAuth();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Jazz.Provider
|
|
||||||
auth={auth}
|
|
||||||
peer="wss://cloud.jazz.tools/?key=chat-example-jazz@garden.co"
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
{state.state !== "signedIn" && (
|
|
||||||
<DemoAuthBasicUI appName="Jazz Chat" state={state} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
|
||||||
<ThemeProvider>
|
|
||||||
<StrictMode>
|
|
||||||
<JazzAndAuth>
|
|
||||||
<App />
|
|
||||||
</JazzAndAuth>
|
|
||||||
</StrictMode>
|
|
||||||
</ThemeProvider>,
|
|
||||||
);
|
|
||||||
@@ -15,3 +15,20 @@ export function onChatLoad(chat: Chat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const inIframe = window.self !== window.top;
|
export const inIframe = window.self !== window.top;
|
||||||
|
|
||||||
|
const animals = [
|
||||||
|
"elephant",
|
||||||
|
"penguin",
|
||||||
|
"giraffe",
|
||||||
|
"octopus",
|
||||||
|
"kangaroo",
|
||||||
|
"dolphin",
|
||||||
|
"cheetah",
|
||||||
|
"koala",
|
||||||
|
"platypus",
|
||||||
|
"pangolin",
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getRandomUsername() {
|
||||||
|
return `Anonymous ${animals[Math.floor(Math.random() * animals.length)]}`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,48 +1,35 @@
|
|||||||
import { test } from "@playwright/test";
|
import { test } from "@playwright/test";
|
||||||
import { ChatPage } from "./pages/ChatPage";
|
import { ChatPage } from "./pages/ChatPage";
|
||||||
import { LoginPage } from "./pages/LoginPage";
|
|
||||||
|
|
||||||
test("chat between two users", async ({ page }) => {
|
test("chat between two users", async ({ page: marioPage, browser }) => {
|
||||||
const loginPage = new LoginPage(page);
|
const context = await browser.newContext();
|
||||||
|
const luigiPage = await context.newPage();
|
||||||
|
|
||||||
const mario = "S. Mario";
|
await marioPage.goto("/");
|
||||||
const luigi = "Luigi";
|
|
||||||
|
|
||||||
await loginPage.goto();
|
const marioChat = new ChatPage(marioPage);
|
||||||
await loginPage.fillUsername(mario);
|
const luigiChat = new ChatPage(luigiPage);
|
||||||
await loginPage.signup();
|
|
||||||
|
|
||||||
const chatPage = new ChatPage(page);
|
await marioChat.setUsername("Mario");
|
||||||
|
|
||||||
const message1ByMario = "Hello Luigi, are you ready to save the princess?";
|
const message1ByMario = "Hello Luigi, are you ready to save the princess?";
|
||||||
|
|
||||||
await chatPage.sendMessage(message1ByMario);
|
await marioChat.sendMessage(message1ByMario);
|
||||||
await chatPage.expectMessageRow(message1ByMario);
|
await marioChat.expectMessageRow(message1ByMario);
|
||||||
|
|
||||||
const roomURL = page.url();
|
const roomURL = marioPage.url();
|
||||||
|
await luigiPage.goto(roomURL);
|
||||||
|
|
||||||
await chatPage.logout();
|
await luigiChat.setUsername("Luigi");
|
||||||
|
|
||||||
await loginPage.expectLoaded();
|
await luigiChat.expectMessageRow(message1ByMario);
|
||||||
|
|
||||||
await loginPage.fillUsername(luigi);
|
|
||||||
await loginPage.signup();
|
|
||||||
|
|
||||||
await page.goto(roomURL);
|
|
||||||
|
|
||||||
await chatPage.expectMessageRow(message1ByMario);
|
|
||||||
|
|
||||||
const message2ByLuigi =
|
const message2ByLuigi =
|
||||||
"No, I'm not ready yet. I'm still trying to find the key to the castle.";
|
"No, I'm not ready yet. I'm still trying to find the key to the castle.";
|
||||||
|
|
||||||
await chatPage.sendMessage(message2ByLuigi);
|
await luigiChat.sendMessage(message2ByLuigi);
|
||||||
await chatPage.expectMessageRow(message2ByLuigi);
|
await luigiChat.expectMessageRow(message2ByLuigi);
|
||||||
|
|
||||||
await chatPage.logout();
|
await marioChat.expectMessageRow(message1ByMario);
|
||||||
await loginPage.loginAs(mario);
|
await luigiChat.expectMessageRow(message2ByLuigi);
|
||||||
|
|
||||||
await page.goto(roomURL);
|
|
||||||
|
|
||||||
await chatPage.expectMessageRow(message1ByMario);
|
|
||||||
await chatPage.expectMessageRow(message2ByLuigi);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export class ChatPage {
|
|||||||
readonly page: Page;
|
readonly page: Page;
|
||||||
readonly messageInput: Locator;
|
readonly messageInput: Locator;
|
||||||
readonly logoutButton: Locator;
|
readonly logoutButton: Locator;
|
||||||
|
readonly usernameInput: Locator;
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.messageInput = page.getByRole("textbox", {
|
this.messageInput = page.getByRole("textbox", {
|
||||||
@@ -13,6 +13,11 @@ export class ChatPage {
|
|||||||
this.logoutButton = page.getByRole("button", {
|
this.logoutButton = page.getByRole("button", {
|
||||||
name: "Log out",
|
name: "Log out",
|
||||||
});
|
});
|
||||||
|
this.usernameInput = page.getByPlaceholder("Set username");
|
||||||
|
}
|
||||||
|
|
||||||
|
async setUsername(username: string) {
|
||||||
|
await this.usernameInput.fill(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMessage(message: string) {
|
async sendMessage(message: string) {
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import { Locator, Page, expect } from "@playwright/test";
|
|
||||||
|
|
||||||
export class LoginPage {
|
|
||||||
readonly page: Page;
|
|
||||||
readonly usernameInput: Locator;
|
|
||||||
readonly signupButton: Locator;
|
|
||||||
|
|
||||||
constructor(page: Page) {
|
|
||||||
this.page = page;
|
|
||||||
this.usernameInput = page.getByRole("textbox");
|
|
||||||
this.signupButton = page.getByRole("button", {
|
|
||||||
name: "Sign up",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async goto() {
|
|
||||||
this.page.goto("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fillUsername(value: string) {
|
|
||||||
await this.usernameInput.clear();
|
|
||||||
await this.usernameInput.fill(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginAs(value: string) {
|
|
||||||
await this.page
|
|
||||||
.getByRole("button", {
|
|
||||||
name: value,
|
|
||||||
})
|
|
||||||
.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async signup() {
|
|
||||||
await this.signupButton.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async expectLoaded() {
|
|
||||||
await expect(this.signupButton).toBeVisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,144 @@
|
|||||||
# minimal-auth-clerk
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
- jazz-react-auth-clerk@0.9.15
|
||||||
|
|
||||||
|
## 0.0.34
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
- jazz-react-auth-clerk@0.9.14
|
||||||
|
|
||||||
|
## 0.0.33
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-react-auth-clerk@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
|
||||||
|
## 0.0.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-react-auth-clerk@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
|
||||||
|
## 0.0.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-react-auth-clerk@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
|
||||||
|
## 0.0.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-react-auth-clerk@0.9.10
|
||||||
|
|
||||||
|
## 0.0.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
- jazz-react-auth-clerk@0.9.9
|
||||||
|
|
||||||
|
## 0.0.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
- jazz-react-auth-clerk@0.9.8
|
||||||
|
|
||||||
|
## 0.0.27
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
- jazz-react-auth-clerk@0.9.4
|
||||||
|
|
||||||
|
## 0.0.26
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-react-auth-clerk@0.9.1
|
||||||
|
|
||||||
|
## 0.0.25
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-react-auth-clerk@0.9.0
|
||||||
|
|
||||||
## 0.0.24
|
## 0.0.24
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -4,30 +4,56 @@ This is an example of how to use clerk authentication with Jazz.
|
|||||||
|
|
||||||
Live version: https://clerk-demo.jazz.tools
|
Live version: https://clerk-demo.jazz.tools
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example clerk --project-name clerk
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the clerk example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/clerk
|
cd clerk
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/clerk/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "clerk",
|
"name": "clerk",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.24",
|
"version": "0.0.40",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clerk/clerk-react": "^5.4.1",
|
"@clerk/clerk-react": "^5.4.1",
|
||||||
"jazz-react": "workspace:*",
|
"jazz-react": "workspace:*",
|
||||||
"jazz-react-auth-clerk": "workspace:0.8.51",
|
"jazz-react-auth-clerk": "workspace:0.9.20",
|
||||||
"jazz-tools": "workspace:*",
|
"jazz-tools": "workspace:*",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "^18.3.1"
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
import { useAccount } from "./main";
|
import { SignInButton } from "@clerk/clerk-react";
|
||||||
|
import { useAccount, useIsAuthenticated } from "jazz-react";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { me, logOut } = useAccount();
|
const { me, logOut } = useAccount();
|
||||||
|
|
||||||
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
|
if (isAuthenticated) {
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<h1>You're logged in</h1>
|
||||||
|
<p>Welcome back, {me?.profile?.name}</p>
|
||||||
|
<button onClick={() => logOut()}>Logout</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<h1>You're logged in</h1>
|
<h1>You're not logged in</h1>
|
||||||
<p>Welcome back, {me?.profile?.name}</p>
|
<SignInButton />
|
||||||
<button onClick={() => logOut()}>Logout</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 200px;
|
max-width: 400px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { ClerkProvider, SignInButton, useClerk } from "@clerk/clerk-react";
|
import { ClerkProvider, useClerk } from "@clerk/clerk-react";
|
||||||
import { createJazzReactApp } from "jazz-react";
|
|
||||||
import { useJazzClerkAuth } from "jazz-react-auth-clerk";
|
|
||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import App from "./App.tsx";
|
import App from "./App.tsx";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import { JazzProviderWithClerk } from "jazz-react-auth-clerk";
|
||||||
|
|
||||||
// Import your publishable key
|
// Import your publishable key
|
||||||
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
|
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
|
||||||
@@ -13,38 +12,28 @@ if (!PUBLISHABLE_KEY) {
|
|||||||
throw new Error("Add your Clerk publishable key to the .env.local file");
|
throw new Error("Add your Clerk publishable key to the .env.local file");
|
||||||
}
|
}
|
||||||
|
|
||||||
const Jazz = createJazzReactApp();
|
function JazzProvider({ children }: { children: React.ReactNode }) {
|
||||||
export const { useAccount, useCoState } = Jazz;
|
|
||||||
|
|
||||||
function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
|
||||||
const clerk = useClerk();
|
const clerk = useClerk();
|
||||||
const [auth, state] = useJazzClerkAuth(clerk);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="container">
|
<JazzProviderWithClerk
|
||||||
{state?.errors?.map((error) => (
|
clerk={clerk}
|
||||||
<div key={error}>{error}</div>
|
sync={{
|
||||||
))}
|
peer: "wss://cloud.jazz.tools/?key=minimal-auth-clerk-example@garden.co",
|
||||||
{clerk.user && auth ? (
|
when: "signedUp", // This makes the app work in local mode when the user is not authenticated
|
||||||
<Jazz.Provider
|
}}
|
||||||
auth={auth}
|
>
|
||||||
peer="wss://cloud.jazz.tools/?key=minimal-auth-clerk-example@garden.co"
|
{children}
|
||||||
>
|
</JazzProviderWithClerk>
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
) : (
|
|
||||||
<SignInButton />
|
|
||||||
)}
|
|
||||||
</main>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
||||||
<JazzAndAuth>
|
<JazzProvider>
|
||||||
<App />
|
<App />
|
||||||
</JazzAndAuth>
|
</JazzProvider>
|
||||||
</ClerkProvider>
|
</ClerkProvider>
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,122 @@
|
|||||||
# file-share-svelte
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-svelte@0.9.15
|
||||||
|
|
||||||
|
## 0.0.19
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-svelte@0.9.14
|
||||||
|
|
||||||
|
## 0.0.18
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-svelte@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
|
||||||
|
## 0.0.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-svelte@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
|
||||||
|
## 0.0.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-svelte@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
|
||||||
|
## 0.0.15
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-svelte@0.9.10
|
||||||
|
|
||||||
|
## 0.0.14
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-svelte@0.9.9
|
||||||
|
|
||||||
|
## 0.0.13
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-svelte@0.9.8
|
||||||
|
|
||||||
|
## 0.0.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-svelte@0.9.1
|
||||||
|
|
||||||
|
## 0.0.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [9dd8d95]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-svelte@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
|
||||||
## 0.0.10
|
## 0.0.10
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "file-share-svelte",
|
"name": "file-share-svelte",
|
||||||
"version": "0.0.10",
|
"version": "0.0.25",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { SharedFile } from '$lib/schema';
|
import { SharedFile } from '$lib/schema';
|
||||||
import { FileStream } from 'jazz-tools';
|
import { FileStream } from 'jazz-tools';
|
||||||
import { File, FileDown, Trash2, Link2 } from 'lucide-svelte';
|
import { File, FileDown, Trash2, Link2 } from 'lucide-svelte';
|
||||||
import { useAccount } from '$lib/jazz';
|
import { useAccount } from 'jazz-svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { formatFileSize } from '$lib/utils';
|
import { formatFileSize } from '$lib/utils';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import { createJazzApp } from 'jazz-svelte';
|
|
||||||
import { FileShareAccount } from './schema';
|
|
||||||
|
|
||||||
export const { useAccount, useCoState, useAcceptInvite, useAccountOrGuest, Provider } =
|
|
||||||
createJazzApp({
|
|
||||||
AccountSchema: FileShareAccount
|
|
||||||
});
|
|
||||||
@@ -17,6 +17,6 @@ export function formatFileSize(bytes: number): string {
|
|||||||
* @param createdAt The creation date
|
* @param createdAt The creation date
|
||||||
* @returns A unique file ID string
|
* @returns A unique file ID string
|
||||||
*/
|
*/
|
||||||
export function generateTempFileId(fileName: string, createdAt: Date): string {
|
export function generateTempFileId(fileName: string | undefined, createdAt: Date | undefined): string {
|
||||||
return `file-${fileName}-${createdAt.getTime()}`;
|
return `file-${fileName ?? 'unknown'}-${createdAt?.getTime() ?? 0}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
declare module 'jazz-svelte' {
|
||||||
|
interface Register {
|
||||||
|
Account: FileShareAccount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Provider } from '$lib/jazz';
|
import { JazzProvider } from 'jazz-svelte';
|
||||||
import { PasskeyAuthBasicUI, usePasskeyAuth } from 'jazz-svelte';
|
import { PasskeyAuthBasicUI, usePasskeyAuth } from 'jazz-svelte';
|
||||||
import { Toaster } from 'svelte-sonner';
|
import { Toaster } from 'svelte-sonner';
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
|
import { FileShareAccount } from '$lib/schema';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
const auth = usePasskeyAuth({
|
|
||||||
appName: 'File Share'
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -16,17 +22,16 @@
|
|||||||
|
|
||||||
<Toaster richColors />
|
<Toaster richColors />
|
||||||
|
|
||||||
{#if auth.state.state === 'ready'}
|
<JazzProvider
|
||||||
<div class="fixed inset-0 flex items-center justify-center bg-gray-50/80">
|
AccountSchema={FileShareAccount}
|
||||||
<div class="rounded-lg bg-white p-8 shadow-lg">
|
sync={{
|
||||||
<PasskeyAuthBasicUI state={auth.state} />
|
peer: "wss://cloud.jazz.tools/?key=minimal-svelte-auth-passkey@garden.co",
|
||||||
</div>
|
when: "signedUp",
|
||||||
</div>
|
}}
|
||||||
{/if}
|
>
|
||||||
{#if auth.current}
|
<PasskeyAuthBasicUI appName="File Share">
|
||||||
<Provider auth={auth.current} peer="wss://cloud.jazz.tools/?key=file-share-svelte@garden.co">
|
|
||||||
<div class="min-h-screen bg-gray-100">
|
<div class="min-h-screen bg-gray-100">
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</div>
|
</div>
|
||||||
</Provider>
|
</PasskeyAuthBasicUI>
|
||||||
{/if}
|
</JazzProvider>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { useAccount, useCoState } from '$lib/jazz';
|
import { useAccount, useCoState } from 'jazz-svelte';
|
||||||
import { SharedFile, ListOfSharedFiles } from '$lib/schema';
|
import { SharedFile, ListOfSharedFiles } from '$lib/schema';
|
||||||
import { createInviteLink } from 'jazz-svelte';
|
import { createInviteLink } from 'jazz-svelte';
|
||||||
import { FileStream } from 'jazz-tools';
|
import { FileStream } from 'jazz-tools';
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
const input = event.target as HTMLInputElement;
|
const input = event.target as HTMLInputElement;
|
||||||
const files = input.files;
|
const files = input.files;
|
||||||
|
|
||||||
if (!files || !files.length || !me?.root?.sharedFiles || !me.root.publicGroup) return;
|
if (!files || !files.length || !me.root?.sharedFiles || !me.root.publicGroup) return;
|
||||||
|
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
const fileName = file.name;
|
const fileName = file.name;
|
||||||
@@ -129,12 +129,14 @@
|
|||||||
{#if sharedFiles.current}
|
{#if sharedFiles.current}
|
||||||
{#if !(sharedFiles.current.length === 0 && uploadingFiles.size === 0)}
|
{#if !(sharedFiles.current.length === 0 && uploadingFiles.size === 0)}
|
||||||
{#each [...sharedFiles.current, ...uploadingFiles.values()] as file (generateTempFileId(file?.name, file?.createdAt))}
|
{#each [...sharedFiles.current, ...uploadingFiles.values()] as file (generateTempFileId(file?.name, file?.createdAt))}
|
||||||
<FileItem
|
{#if file}
|
||||||
{file}
|
<FileItem
|
||||||
loading={uploadingFiles.has(generateTempFileId(file?.name, file?.createdAt))}
|
{file}
|
||||||
onShare={shareFile}
|
loading={uploadingFiles.has(generateTempFileId(file?.name, file?.createdAt))}
|
||||||
onDelete={deleteFile}
|
onShare={shareFile}
|
||||||
/>
|
onDelete={deleteFile}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
<p class="text-center text-gray-500">No files yet</p>
|
<p class="text-center text-gray-500">No files yet</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { useAccount, useCoState } from '$lib/jazz';
|
import { useAccount, useCoState } from 'jazz-svelte';
|
||||||
import { SharedFile } from '$lib/schema';
|
import { SharedFile } from '$lib/schema';
|
||||||
import { File, FileDown, Link2 } from 'lucide-svelte';
|
import { File, FileDown, Link2 } from 'lucide-svelte';
|
||||||
import type { ID } from 'jazz-tools';
|
import type { ID } from 'jazz-tools';
|
||||||
|
|||||||
@@ -1,5 +1,143 @@
|
|||||||
# form
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-browser-media-images@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
|
||||||
|
## 0.0.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-browser-media-images@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
|
||||||
|
## 0.0.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-browser-media-images@0.9.13
|
||||||
|
|
||||||
|
## 0.0.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-browser-media-images@0.9.12
|
||||||
|
|
||||||
|
## 0.0.27
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-browser-media-images@0.9.11
|
||||||
|
|
||||||
|
## 0.0.26
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-browser-media-images@0.9.10
|
||||||
|
|
||||||
|
## 0.0.25
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-browser-media-images@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
|
||||||
|
## 0.0.24
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
- jazz-browser-media-images@0.9.8
|
||||||
|
|
||||||
|
## 0.0.23
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
|
||||||
|
## 0.0.22
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-browser-media-images@0.9.1
|
||||||
|
|
||||||
|
## 0.0.21
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-browser-media-images@0.9.0
|
||||||
|
|
||||||
## 0.0.20
|
## 0.0.20
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -17,30 +17,56 @@ converting it into a `BubbleTeaOrder`.
|
|||||||
|
|
||||||
[See the full guide here.](https://jazz.tools/docs/react/design-patterns/form)
|
[See the full guide here.](https://jazz.tools/docs/react/design-patterns/form)
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example form --project-name form
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the form example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/form
|
cd form
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/form/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
@@ -49,4 +75,4 @@ If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or
|
|||||||
|
|
||||||
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
||||||
|
|
||||||
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/main.tsx](./src/main.tsx).
|
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<JazzProvider>` provider component in [./src/main.tsx](./src/main.tsx).
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "form",
|
"name": "form",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.20",
|
"version": "0.0.36",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useIframeHashRouter } from "hash-slash";
|
import { useIframeHashRouter } from "hash-slash";
|
||||||
|
import { useAccount } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { CreateOrder } from "./CreateOrder.tsx";
|
import { CreateOrder } from "./CreateOrder.tsx";
|
||||||
import { EditOrder } from "./EditOrder.tsx";
|
import { EditOrder } from "./EditOrder.tsx";
|
||||||
import { Orders } from "./Orders.tsx";
|
import { Orders } from "./Orders.tsx";
|
||||||
import { useAccount } from "./main";
|
|
||||||
import { BubbleTeaOrder } from "./schema.ts";
|
import { BubbleTeaOrder } from "./schema.ts";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useIframeHashRouter } from "hash-slash";
|
import { useIframeHashRouter } from "hash-slash";
|
||||||
|
import { useAccount, useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Errors } from "./Errors.tsx";
|
import { Errors } from "./Errors.tsx";
|
||||||
import { LinkToHome } from "./LinkToHome.tsx";
|
import { LinkToHome } from "./LinkToHome.tsx";
|
||||||
import { OrderForm } from "./OrderForm.tsx";
|
import { OrderForm } from "./OrderForm.tsx";
|
||||||
import { useAccount, useCoState } from "./main.tsx";
|
|
||||||
import {
|
import {
|
||||||
BubbleTeaOrder,
|
BubbleTeaOrder,
|
||||||
DraftBubbleTeaOrder,
|
DraftBubbleTeaOrder,
|
||||||
@@ -30,12 +30,9 @@ export function CreateOrder() {
|
|||||||
me.root.orders.push(draft as BubbleTeaOrder);
|
me.root.orders.push(draft as BubbleTeaOrder);
|
||||||
|
|
||||||
// reset the draft
|
// reset the draft
|
||||||
me.root.draft = DraftBubbleTeaOrder.create(
|
me.root.draft = DraftBubbleTeaOrder.create({
|
||||||
{
|
addOns: ListOfBubbleTeaAddOns.create([]),
|
||||||
addOns: ListOfBubbleTeaAddOns.create([], me),
|
});
|
||||||
},
|
|
||||||
me,
|
|
||||||
);
|
|
||||||
|
|
||||||
router.navigate("/");
|
router.navigate("/");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useAccount } from "./main.tsx";
|
import { useAccount } from "jazz-react";
|
||||||
|
|
||||||
export function DraftIndicator() {
|
export function DraftIndicator() {
|
||||||
const { me } = useAccount({
|
const { me } = useAccount({
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
import { useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { LinkToHome } from "./LinkToHome.tsx";
|
import { LinkToHome } from "./LinkToHome.tsx";
|
||||||
import { OrderForm } from "./OrderForm.tsx";
|
import { OrderForm } from "./OrderForm.tsx";
|
||||||
import { OrderThumbnail } from "./OrderThumbnail.tsx";
|
import { OrderThumbnail } from "./OrderThumbnail.tsx";
|
||||||
import { useCoState } from "./main.tsx";
|
|
||||||
import { BubbleTeaOrder } from "./schema.ts";
|
import { BubbleTeaOrder } from "./schema.ts";
|
||||||
|
|
||||||
export function EditOrder(props: { id: ID<BubbleTeaOrder> }) {
|
export function EditOrder(props: { id: ID<BubbleTeaOrder> }) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { useAccount } from "jazz-react";
|
||||||
import { DraftIndicator } from "./DraftIndicator.tsx";
|
import { DraftIndicator } from "./DraftIndicator.tsx";
|
||||||
import { OrderThumbnail } from "./OrderThumbnail.tsx";
|
import { OrderThumbnail } from "./OrderThumbnail.tsx";
|
||||||
import { useAccount } from "./main.tsx";
|
|
||||||
|
|
||||||
export function Orders() {
|
export function Orders() {
|
||||||
const { me } = useAccount({
|
const { me } = useAccount({
|
||||||
|
|||||||
@@ -1,39 +1,25 @@
|
|||||||
import { DemoAuthBasicUI, createJazzReactApp, useDemoAuth } from "jazz-react";
|
import { JazzProvider } from "jazz-react";
|
||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import App from "./App.tsx";
|
import App from "./App.tsx";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { JazzAccount } from "./schema.ts";
|
import { JazzAccount } from "./schema.ts";
|
||||||
|
|
||||||
const Jazz = createJazzReactApp({
|
declare module "jazz-react" {
|
||||||
AccountSchema: JazzAccount,
|
interface Register {
|
||||||
});
|
Account: JazzAccount;
|
||||||
|
}
|
||||||
export const { useAccount, useCoState } = Jazz;
|
|
||||||
|
|
||||||
function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
|
||||||
const [auth, authState] = useDemoAuth();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Jazz.Provider
|
|
||||||
auth={auth}
|
|
||||||
peer="wss://cloud.jazz.tools/?key=form-example@garden.co"
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
|
|
||||||
{authState.state !== "signedIn" && (
|
|
||||||
<DemoAuthBasicUI appName="Form" state={authState} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<JazzAndAuth>
|
<JazzProvider
|
||||||
|
sync={{
|
||||||
|
peer: "wss://cloud.jazz.tools/?key=form-example@garden.co",
|
||||||
|
}}
|
||||||
|
AccountSchema={JazzAccount}
|
||||||
|
>
|
||||||
<App />
|
<App />
|
||||||
</JazzAndAuth>
|
</JazzProvider>
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
import { LoginPage } from "./pages/LoginPage";
|
|
||||||
|
|
||||||
test("create and edit an order", async ({ page }) => {
|
test("create and edit an order", async ({ page }) => {
|
||||||
const loginPage = new LoginPage(page);
|
await page.goto("/");
|
||||||
|
|
||||||
await loginPage.goto();
|
|
||||||
await loginPage.fillUsername("Alice");
|
|
||||||
await loginPage.signup();
|
|
||||||
|
|
||||||
// start an order
|
// start an order
|
||||||
await page.getByRole("link", { name: "Add new order" }).click();
|
await page.getByRole("link", { name: "Add new order" }).click();
|
||||||
await page.getByLabel("Base tea").selectOption("Oolong");
|
await page.getByLabel("Base tea").selectOption("Oolong");
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import { Locator, Page, expect } from "@playwright/test";
|
|
||||||
|
|
||||||
export class LoginPage {
|
|
||||||
readonly page: Page;
|
|
||||||
readonly usernameInput: Locator;
|
|
||||||
readonly signupButton: Locator;
|
|
||||||
|
|
||||||
constructor(page: Page) {
|
|
||||||
this.page = page;
|
|
||||||
this.usernameInput = page.getByRole("textbox");
|
|
||||||
this.signupButton = page.getByRole("button", {
|
|
||||||
name: "Sign up",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async goto() {
|
|
||||||
this.page.goto("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fillUsername(value: string) {
|
|
||||||
await this.usernameInput.clear();
|
|
||||||
await this.usernameInput.fill(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginAs(value: string) {
|
|
||||||
await this.page
|
|
||||||
.getByRole("button", {
|
|
||||||
name: value,
|
|
||||||
})
|
|
||||||
.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async signup() {
|
|
||||||
await this.signupButton.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async expectLoaded() {
|
|
||||||
await expect(this.signupButton).toBeVisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,143 @@
|
|||||||
# image-upload
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-browser-media-images@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
|
||||||
|
## 0.0.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-browser-media-images@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
|
||||||
|
## 0.0.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-browser-media-images@0.9.13
|
||||||
|
|
||||||
|
## 0.0.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-browser-media-images@0.9.12
|
||||||
|
|
||||||
|
## 0.0.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-browser-media-images@0.9.11
|
||||||
|
|
||||||
|
## 0.0.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-browser-media-images@0.9.10
|
||||||
|
|
||||||
|
## 0.0.27
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-browser-media-images@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
|
||||||
|
## 0.0.26
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
- jazz-browser-media-images@0.9.8
|
||||||
|
|
||||||
|
## 0.0.25
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
|
||||||
|
## 0.0.24
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-browser-media-images@0.9.1
|
||||||
|
|
||||||
|
## 0.0.23
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-browser-media-images@0.9.0
|
||||||
|
|
||||||
## 0.0.22
|
## 0.0.22
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -4,30 +4,56 @@ This is an example of how to upload and render images with Jazz.
|
|||||||
|
|
||||||
Live version: https://image-upload-demo.jazz.tools
|
Live version: https://image-upload-demo.jazz.tools
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example image-upload --project-name image-upload
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the image-upload example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/image-upload
|
cd image-upload
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/image-upload/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "image-upload",
|
"name": "image-upload",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.22",
|
"version": "0.0.38",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { useAccount } from "jazz-react";
|
||||||
import ImageUpload from "./ImageUpload.tsx";
|
import ImageUpload from "./ImageUpload.tsx";
|
||||||
import { useAccount } from "./main";
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { me, logOut } = useAccount();
|
const { me, logOut } = useAccount();
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { createImage } from "jazz-browser-media-images";
|
import { createImage } from "jazz-browser-media-images";
|
||||||
import { ProgressiveImg } from "jazz-react";
|
import { ProgressiveImg, useAccount } from "jazz-react";
|
||||||
import { ImageDefinition } from "jazz-tools";
|
import { ImageDefinition } from "jazz-tools";
|
||||||
import { ChangeEvent, useRef } from "react";
|
import { ChangeEvent, useRef } from "react";
|
||||||
import { useAccount } from "./main.tsx";
|
|
||||||
|
|
||||||
function Image({ image }: { image: ImageDefinition }) {
|
function Image({ image }: { image: ImageDefinition }) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,39 +1,25 @@
|
|||||||
import { DemoAuthBasicUI, createJazzReactApp, useDemoAuth } from "jazz-react";
|
import { JazzProvider } from "jazz-react";
|
||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import App from "./App.tsx";
|
import App from "./App.tsx";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { JazzAccount } from "./schema.ts";
|
import { JazzAccount } from "./schema.ts";
|
||||||
|
|
||||||
const Jazz = createJazzReactApp({
|
declare module "jazz-react" {
|
||||||
AccountSchema: JazzAccount,
|
interface Register {
|
||||||
});
|
Account: JazzAccount;
|
||||||
|
}
|
||||||
export const { useAccount, useCoState } = Jazz;
|
|
||||||
|
|
||||||
function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
|
||||||
const [auth, authState] = useDemoAuth();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Jazz.Provider
|
|
||||||
auth={auth}
|
|
||||||
peer="wss://cloud.jazz.tools/?key=image-upload-example@garden.co"
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
|
|
||||||
{authState.state !== "signedIn" && (
|
|
||||||
<DemoAuthBasicUI appName="Image upload" state={authState} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<JazzAndAuth>
|
<JazzProvider
|
||||||
|
sync={{
|
||||||
|
peer: "wss://cloud.jazz.tools/?key=image-upload-example@garden.co",
|
||||||
|
}}
|
||||||
|
AccountSchema={JazzAccount}
|
||||||
|
>
|
||||||
<App />
|
<App />
|
||||||
</JazzAndAuth>
|
</JazzProvider>
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,71 @@
|
|||||||
# jazz-example-inspector
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [8d29e50]
|
||||||
|
- cojson-transport-ws@0.9.13
|
||||||
|
- cojson@0.9.13
|
||||||
|
|
||||||
|
## 0.0.97
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [15d4b2a]
|
||||||
|
- cojson-transport-ws@0.9.12
|
||||||
|
- cojson@0.9.12
|
||||||
|
|
||||||
|
## 0.0.96
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [efbf3d8]
|
||||||
|
- Updated dependencies [5863bad]
|
||||||
|
- cojson@0.9.11
|
||||||
|
- cojson-transport-ws@0.9.11
|
||||||
|
|
||||||
|
## 0.0.95
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4aa377d]
|
||||||
|
- cojson@0.9.10
|
||||||
|
- cojson-transport-ws@0.9.10
|
||||||
|
|
||||||
|
## 0.0.94
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- cojson@0.9.9
|
||||||
|
- cojson-transport-ws@0.9.9
|
||||||
|
|
||||||
|
## 0.0.93
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- Updated dependencies [1ef3226]
|
||||||
|
- cojson@0.9.0
|
||||||
|
- cojson-transport-ws@0.9.0
|
||||||
|
|
||||||
## 0.0.92
|
## 0.0.92
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jazz-inspector",
|
"name": "jazz-inspector-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.92",
|
"version": "0.0.100",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
"@radix-ui/react-toast": "^1.1.4",
|
"@radix-ui/react-toast": "^1.1.4",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"cojson": "workspace:0.8.50",
|
"cojson": "workspace:0.9.19",
|
||||||
"cojson-transport-ws": "workspace:0.8.50",
|
"cojson-transport-ws": "workspace:0.9.19",
|
||||||
"hash-slash": "workspace:0.2.1",
|
"hash-slash": "workspace:0.2.1",
|
||||||
"lucide-react": "^0.274.0",
|
"lucide-react": "^0.274.0",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
|
|||||||
@@ -1,5 +1,145 @@
|
|||||||
# jazz-example-musicplayer
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-inspector@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
|
||||||
|
## 0.0.55
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-inspector@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
|
||||||
|
## 0.0.54
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-inspector@0.9.13
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
|
||||||
|
## 0.0.53
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-inspector@0.9.12
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
|
||||||
|
## 0.0.52
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-inspector@0.9.11
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
|
||||||
|
## 0.0.51
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
|
||||||
|
## 0.0.50
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
|
||||||
|
## 0.0.49
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
|
||||||
|
## 0.0.48
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
|
||||||
|
## 0.0.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
|
||||||
|
## 0.0.46
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
|
||||||
## 0.0.45
|
## 0.0.45
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -2,30 +2,56 @@
|
|||||||
|
|
||||||
Live version: https://music-demo.jazz.tools
|
Live version: https://music-demo.jazz.tools
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example music-player --project-name music-player
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the music-player example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/music-player
|
cd music-player
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/music-player/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
|
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
@@ -34,4 +60,4 @@ If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or
|
|||||||
|
|
||||||
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
||||||
|
|
||||||
You can also run a local sync server by running `npx cojson-simple-sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/2_main.tsx](./src/2_main.tsx).
|
You can also run a local sync server by running `npx cojson-simple-sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<JazzProvider>` provider component in [./src/2_main.tsx](./src/2_main.tsx).
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jazz-example-music-player",
|
"name": "jazz-example-music-player",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.45",
|
"version": "0.0.62",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -13,13 +13,17 @@
|
|||||||
"test:ui": "playwright test --ui"
|
"test:ui": "playwright test --ui"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@radix-ui/react-dialog": "^1.1.4",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-label": "^2.1.1",
|
||||||
|
"@radix-ui/react-slot": "^1.1.1",
|
||||||
"@radix-ui/react-toast": "^1.1.4",
|
"@radix-ui/react-toast": "^1.1.4",
|
||||||
|
"@radix-ui/react-tooltip": "^1.1.6",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"jazz-react": "workspace:0.8.51",
|
"jazz-react": "workspace:0.9.20",
|
||||||
"jazz-tools": "workspace:0.8.51",
|
"jazz-tools": "workspace:0.9.20",
|
||||||
|
"jazz-inspector": "workspace:*",
|
||||||
"lucide-react": "^0.274.0",
|
"lucide-react": "^0.274.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export class MusicaAccount extends Account {
|
|||||||
* You can use it to set up the account root and any other initial CoValues you need.
|
* You can use it to set up the account root and any other initial CoValues you need.
|
||||||
*/
|
*/
|
||||||
migrate() {
|
migrate() {
|
||||||
if (!this._refs.root) {
|
if (this.root === undefined) {
|
||||||
const ownership = { owner: this };
|
const ownership = { owner: this };
|
||||||
|
|
||||||
const tracks = ListOfTracks.create([], ownership);
|
const tracks = ListOfTracks.create([], ownership);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Toaster } from "@/components/ui/toaster";
|
import { Toaster } from "@/components/ui/toaster";
|
||||||
|
import { JazzInspector } from "jazz-inspector";
|
||||||
/* eslint-disable react-refresh/only-export-components */
|
/* eslint-disable react-refresh/only-export-components */
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
@@ -10,26 +11,20 @@ import { PlayerControls } from "./components/PlayerControls";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
import { MusicaAccount } from "@/1_schema";
|
import { MusicaAccount } from "@/1_schema";
|
||||||
import { DemoAuthBasicUI, createJazzReactApp, useDemoAuth } from "jazz-react";
|
import { JazzProvider } from "jazz-react";
|
||||||
import { useUploadExampleData } from "./lib/useUploadExampleData";
|
import { useUploadExampleData } from "./lib/useUploadExampleData";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walkthrough: The top-level provider `<Jazz.Provider/>`
|
* Walkthrough: The top-level provider `<JazzProvider/>`
|
||||||
*
|
*
|
||||||
* This shows how to use the top-level provider `<Jazz.Provider/>`,
|
* This shows how to use the top-level provider `<JazzProvider/>`,
|
||||||
* which provides the rest of the app with a controlled account (used through `useAccount` later).
|
* which provides the rest of the app with a controlled account (used through `useAccount` later).
|
||||||
* Here we use `DemoAuth` which is great for prototyping you app without wasting time on figuring out
|
* Here we use `DemoAuth` which is great for prototyping you app without wasting time on figuring out
|
||||||
* the best way to do auth.
|
* the best way to do auth.
|
||||||
*
|
*
|
||||||
* `<Jazz.Provider/>` also runs our account migration
|
* `<JazzProvider/>` also runs our account migration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Jazz = createJazzReactApp({
|
|
||||||
AccountSchema: MusicaAccount,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const { useAccount, useCoState, useAcceptInvite } = Jazz;
|
|
||||||
|
|
||||||
function Main() {
|
function Main() {
|
||||||
const mediaPlayer = useMediaPlayer();
|
const mediaPlayer = useMediaPlayer();
|
||||||
|
|
||||||
@@ -59,33 +54,31 @@ function Main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
const peer =
|
||||||
const [auth, state] = useDemoAuth();
|
(new URL(window.location.href).searchParams.get(
|
||||||
|
"peer",
|
||||||
|
) as `ws://${string}`) ??
|
||||||
|
"wss://cloud.jazz.tools/?key=music-player-example-jazz@garden.co";
|
||||||
|
|
||||||
const peer =
|
declare module "jazz-react" {
|
||||||
(new URL(window.location.href).searchParams.get(
|
interface Register {
|
||||||
"peer",
|
Account: MusicaAccount;
|
||||||
) as `ws://${string}`) ??
|
}
|
||||||
"wss://cloud.jazz.tools/?key=music-player-example-jazz@garden.co";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Jazz.Provider
|
|
||||||
storage={["singleTabOPFS", "indexedDB"]}
|
|
||||||
auth={auth}
|
|
||||||
peer={peer}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Jazz.Provider>
|
|
||||||
<DemoAuthBasicUI appName="Jazz Music Player" state={state} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<JazzAndAuth>
|
<JazzProvider
|
||||||
|
sync={{
|
||||||
|
peer,
|
||||||
|
when: "signedUp", // This makes the app work in local mode when the user is anonymous
|
||||||
|
}}
|
||||||
|
storage="indexedDB"
|
||||||
|
AccountSchema={MusicaAccount}
|
||||||
|
defaultProfileName="Anonymous unicorn"
|
||||||
|
>
|
||||||
<Main />
|
<Main />
|
||||||
</JazzAndAuth>
|
<JazzInspector />
|
||||||
|
</JazzProvider>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { createInviteLink } from "jazz-react";
|
import {
|
||||||
|
createInviteLink,
|
||||||
|
useAccount,
|
||||||
|
useCoState,
|
||||||
|
useIsAuthenticated,
|
||||||
|
} from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
import { Playlist } from "./1_schema";
|
import { Playlist } from "./1_schema";
|
||||||
import { useAccount, useCoState } from "./2_main";
|
|
||||||
import { createNewPlaylist, uploadMusicTracks } from "./4_actions";
|
import { createNewPlaylist, uploadMusicTracks } from "./4_actions";
|
||||||
import { MediaPlayer } from "./5_useMediaPlayer";
|
import { MediaPlayer } from "./5_useMediaPlayer";
|
||||||
|
import { AuthButton } from "./components/AuthButton";
|
||||||
import { FileUploadButton } from "./components/FileUploadButton";
|
import { FileUploadButton } from "./components/FileUploadButton";
|
||||||
import { LogoutButton } from "./components/LogoutButton";
|
|
||||||
import { MusicTrackRow } from "./components/MusicTrackRow";
|
import { MusicTrackRow } from "./components/MusicTrackRow";
|
||||||
import { PlaylistTitleInput } from "./components/PlaylistTitleInput";
|
import { PlaylistTitleInput } from "./components/PlaylistTitleInput";
|
||||||
import { SidePanel } from "./components/SidePanel";
|
import { SidePanel } from "./components/SidePanel";
|
||||||
@@ -32,19 +36,15 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
async function handleFileLoad(files: FileList) {
|
async function handleFileLoad(files: FileList) {
|
||||||
if (!me) return;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Follow this function definition to see how we update
|
* Follow this function definition to see how we update
|
||||||
* values in Jazz and manage files!
|
* values in Jazz and manage files!
|
||||||
*/
|
*/
|
||||||
await uploadMusicTracks(me, files);
|
await uploadMusicTracks(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCreatePlaylist() {
|
async function handleCreatePlaylist() {
|
||||||
if (!me) return;
|
const playlist = await createNewPlaylist();
|
||||||
|
|
||||||
const playlist = await createNewPlaylist(me);
|
|
||||||
|
|
||||||
navigate(`/playlist/${playlist.id}`);
|
navigate(`/playlist/${playlist.id}`);
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,8 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-screen text-gray-800 bg-blue-50">
|
<div className="flex flex-col h-screen text-gray-800 bg-blue-50">
|
||||||
<div className="flex flex-1 overflow-hidden">
|
<div className="flex flex-1 overflow-hidden">
|
||||||
@@ -91,12 +93,12 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
|
|||||||
<Button onClick={handleCreatePlaylist}>New playlist</Button>
|
<Button onClick={handleCreatePlaylist}>New playlist</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!isRootPlaylist && (
|
{!isRootPlaylist && isAuthenticated && (
|
||||||
<Button onClick={handlePlaylistShareClick}>
|
<Button onClick={handlePlaylistShareClick}>
|
||||||
Share playlist
|
Share playlist
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<LogoutButton />
|
<AuthButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul className="flex flex-col">
|
<ul className="flex flex-col">
|
||||||
|
|||||||
@@ -22,14 +22,22 @@ import {
|
|||||||
* pattern that best fits your app.
|
* pattern that best fits your app.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function uploadMusicTracks(
|
export async function uploadMusicTracks(files: Iterable<File>) {
|
||||||
account: MusicaAccount,
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
files: Iterable<File>,
|
root: {
|
||||||
) {
|
rootPlaylist: {
|
||||||
|
tracks: [],
|
||||||
|
},
|
||||||
|
playlists: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!me) return;
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
// The ownership object defines the user that owns the created coValues
|
// The ownership object defines the user that owns the created coValues
|
||||||
// We are creating a group for each CoValue in order to be able to share them via Playlist
|
// We are creating a group for each CoValue in order to be able to share them via Playlist
|
||||||
const group = Group.create(account);
|
const group = Group.create();
|
||||||
|
|
||||||
const data = await getAudioFileData(file);
|
const data = await getAudioFileData(file);
|
||||||
|
|
||||||
@@ -50,15 +58,23 @@ export async function uploadMusicTracks(
|
|||||||
|
|
||||||
// The newly created musicTrack can be associated to the
|
// The newly created musicTrack can be associated to the
|
||||||
// user track list using a simple push call
|
// user track list using a simple push call
|
||||||
account.root?.rootPlaylist?.tracks?.push(musicTrack);
|
me.root.rootPlaylist.tracks.push(musicTrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createNewPlaylist(account: MusicaAccount) {
|
export async function createNewPlaylist() {
|
||||||
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
|
root: {
|
||||||
|
playlists: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!me) throw new Error("Current playlist not resolved");
|
||||||
|
|
||||||
// Since playlists are meant to be shared we associate them
|
// Since playlists are meant to be shared we associate them
|
||||||
// to a group which will contain the keys required to get
|
// to a group which will contain the keys required to get
|
||||||
// access to the "owned" values
|
// access to the "owned" values
|
||||||
const playlistGroup = Group.create(account);
|
const playlistGroup = Group.create();
|
||||||
|
|
||||||
const playlist = Playlist.create(
|
const playlist = Playlist.create(
|
||||||
{
|
{
|
||||||
@@ -70,7 +86,7 @@ export async function createNewPlaylist(account: MusicaAccount) {
|
|||||||
|
|
||||||
// Again, we associate the new playlist to the
|
// Again, we associate the new playlist to the
|
||||||
// user by pushing it into the playlists CoList
|
// user by pushing it into the playlists CoList
|
||||||
account.root?.playlists?.push(playlist);
|
me.root.playlists.push(playlist);
|
||||||
|
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
@@ -78,10 +94,7 @@ export async function createNewPlaylist(account: MusicaAccount) {
|
|||||||
export async function addTrackToPlaylist(
|
export async function addTrackToPlaylist(
|
||||||
playlist: Playlist,
|
playlist: Playlist,
|
||||||
track: MusicTrack,
|
track: MusicTrack,
|
||||||
account: MusicaAccount | undefined,
|
|
||||||
) {
|
) {
|
||||||
if (!account) return;
|
|
||||||
|
|
||||||
const alreadyAdded = playlist.tracks?.some(
|
const alreadyAdded = playlist.tracks?.some(
|
||||||
(t) => t?.id === track.id || t?._refs.sourceTrack?.id === track.id,
|
(t) => t?.id === track.id || t?._refs.sourceTrack?.id === track.id,
|
||||||
);
|
);
|
||||||
@@ -108,12 +121,8 @@ export async function addTrackToPlaylist(
|
|||||||
*
|
*
|
||||||
* Doing this for backwards compatibility for when the Group inheritance wasn't possible
|
* Doing this for backwards compatibility for when the Group inheritance wasn't possible
|
||||||
*/
|
*/
|
||||||
const blob = await FileStream.loadAsBlob(track._refs.file.id, account);
|
const blob = await FileStream.loadAsBlob(track._refs.file.id);
|
||||||
const waveform = await MusicTrackWaveform.load(
|
const waveform = await MusicTrackWaveform.load(track._refs.waveform.id, {});
|
||||||
track._refs.waveform.id,
|
|
||||||
account,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!blob || !waveform) return;
|
if (!blob || !waveform) return;
|
||||||
|
|
||||||
@@ -142,13 +151,25 @@ export async function updateMusicTrackTitle(track: MusicTrack, title: string) {
|
|||||||
track.title = title;
|
track.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateActivePlaylist(
|
export async function updateActivePlaylist(playlist?: Playlist) {
|
||||||
playlist: Playlist,
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
me: MusicaAccount,
|
root: {
|
||||||
) {
|
activePlaylist: {},
|
||||||
me.root!.activePlaylist = playlist ?? me.root!.rootPlaylist;
|
rootPlaylist: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!me) return;
|
||||||
|
|
||||||
|
me.root.activePlaylist = playlist ?? me.root.rootPlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateActiveTrack(track: MusicTrack, me: MusicaAccount) {
|
export async function updateActiveTrack(track: MusicTrack) {
|
||||||
me.root!.activeTrack = track;
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
|
root: {},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!me) return;
|
||||||
|
|
||||||
|
me.root.activeTrack = track;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
import { MusicTrack, Playlist } from "@/1_schema";
|
import { MusicTrack, Playlist } from "@/1_schema";
|
||||||
import { usePlayMedia } from "@/lib/audio/usePlayMedia";
|
import { usePlayMedia } from "@/lib/audio/usePlayMedia";
|
||||||
import { usePlayState } from "@/lib/audio/usePlayState";
|
import { usePlayState } from "@/lib/audio/usePlayState";
|
||||||
|
import { useAccount } from "jazz-react";
|
||||||
import { FileStream, ID } from "jazz-tools";
|
import { FileStream, ID } from "jazz-tools";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { useAccount } from "./2_main";
|
|
||||||
import { updateActivePlaylist, updateActiveTrack } from "./4_actions";
|
import { updateActivePlaylist, updateActiveTrack } from "./4_actions";
|
||||||
import { getNextTrack, getPrevTrack } from "./lib/getters";
|
import { getNextTrack, getPrevTrack } from "./lib/getters";
|
||||||
|
|
||||||
export function useMediaPlayer() {
|
export function useMediaPlayer() {
|
||||||
const { me } = useAccount();
|
const { me } = useAccount({
|
||||||
|
root: {},
|
||||||
|
});
|
||||||
|
|
||||||
const playState = usePlayState();
|
const playState = usePlayState();
|
||||||
const playMedia = usePlayMedia();
|
const playMedia = usePlayMedia();
|
||||||
|
|
||||||
const [loading, setLoading] = useState<ID<MusicTrack> | null>(null);
|
const [loading, setLoading] = useState<ID<MusicTrack> | null>(null);
|
||||||
|
|
||||||
const activeTrackId = me?.root?._refs.activeTrack?.id;
|
const activeTrackId = me?.root._refs.activeTrack?.id;
|
||||||
|
|
||||||
// Reference used to avoid out-of-order track loads
|
// Reference used to avoid out-of-order track loads
|
||||||
const lastLoadedTrackId = useRef<ID<MusicTrack> | null>(null);
|
const lastLoadedTrackId = useRef<ID<MusicTrack> | null>(null);
|
||||||
|
|
||||||
async function loadTrack(track: MusicTrack) {
|
async function loadTrack(track: MusicTrack) {
|
||||||
if (!me.root) return;
|
|
||||||
|
|
||||||
lastLoadedTrackId.current = track.id;
|
lastLoadedTrackId.current = track.id;
|
||||||
|
|
||||||
setLoading(track.id);
|
setLoading(track.id);
|
||||||
|
|
||||||
const file = await FileStream.loadAsBlob(track._refs.file.id, me);
|
const file = await FileStream.loadAsBlob(track._refs.file.id);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
setLoading(null);
|
setLoading(null);
|
||||||
@@ -40,7 +40,7 @@ export function useMediaPlayer() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActiveTrack(track, me);
|
updateActiveTrack(track);
|
||||||
|
|
||||||
await playMedia(file);
|
await playMedia(file);
|
||||||
|
|
||||||
@@ -48,20 +48,16 @@ export function useMediaPlayer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function playNextTrack() {
|
async function playNextTrack() {
|
||||||
if (!me?.root) return;
|
const track = await getNextTrack();
|
||||||
|
|
||||||
const track = await getNextTrack(me);
|
|
||||||
|
|
||||||
if (track) {
|
if (track) {
|
||||||
updateActiveTrack(track, me);
|
updateActiveTrack(track);
|
||||||
await loadTrack(track);
|
await loadTrack(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function playPrevTrack() {
|
async function playPrevTrack() {
|
||||||
if (!me?.root) return;
|
const track = await getPrevTrack();
|
||||||
|
|
||||||
const track = await getPrevTrack(me);
|
|
||||||
|
|
||||||
if (track) {
|
if (track) {
|
||||||
await loadTrack(track);
|
await loadTrack(track);
|
||||||
@@ -69,14 +65,12 @@ export function useMediaPlayer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setActiveTrack(track: MusicTrack, playlist?: Playlist) {
|
async function setActiveTrack(track: MusicTrack, playlist?: Playlist) {
|
||||||
if (!me?.root) return;
|
|
||||||
|
|
||||||
if (activeTrackId === track.id && lastLoadedTrackId.current !== null) {
|
if (activeTrackId === track.id && lastLoadedTrackId.current !== null) {
|
||||||
playState.toggle();
|
playState.toggle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActivePlaylist(playlist!, me);
|
updateActivePlaylist(playlist);
|
||||||
|
|
||||||
await loadTrack(track);
|
await loadTrack(track);
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
|
import { useAcceptInvite } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Playlist } from "./1_schema";
|
import { MusicaAccount, Playlist } from "./1_schema";
|
||||||
import { useAcceptInvite, useAccount } from "./2_main";
|
|
||||||
|
|
||||||
export function InvitePage() {
|
export function InvitePage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { me } = useAccount({
|
|
||||||
root: {
|
|
||||||
playlists: [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
useAcceptInvite({
|
useAcceptInvite({
|
||||||
invitedObjectSchema: Playlist,
|
invitedObjectSchema: Playlist,
|
||||||
onAccept: useCallback(
|
onAccept: useCallback(
|
||||||
async (playlistId: ID<Playlist>) => {
|
async (playlistId: ID<Playlist>) => {
|
||||||
if (!me) return;
|
const playlist = await Playlist.load(playlistId, {});
|
||||||
|
|
||||||
const playlist = await Playlist.load(playlistId, me, {});
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
|
root: {
|
||||||
|
playlists: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!me) return;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
playlist &&
|
playlist &&
|
||||||
@@ -30,7 +30,7 @@ export function InvitePage() {
|
|||||||
|
|
||||||
navigate("/playlist/" + playlistId);
|
navigate("/playlist/" + playlistId);
|
||||||
},
|
},
|
||||||
[navigate, me],
|
[navigate],
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
40
examples/music-player/src/components/AuthButton.tsx
Normal file
40
examples/music-player/src/components/AuthButton.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { useAccount, useIsAuthenticated } from "jazz-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { AuthModal } from "./AuthModal";
|
||||||
|
|
||||||
|
export function AuthButton() {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const { logOut } = useAccount();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
|
function handleSignOut() {
|
||||||
|
logOut();
|
||||||
|
navigate("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAuthenticated) {
|
||||||
|
return (
|
||||||
|
<Button variant="outline" onClick={handleSignOut}>
|
||||||
|
Sign out
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
className="bg-white text-black hover:bg-gray-100"
|
||||||
|
>
|
||||||
|
Sign up
|
||||||
|
</Button>
|
||||||
|
<AuthModal open={open} onOpenChange={setOpen} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
97
examples/music-player/src/components/AuthModal.tsx
Normal file
97
examples/music-player/src/components/AuthModal.tsx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { usePasskeyAuth } from "jazz-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
interface AuthModalProps {
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuthModal({ open, onOpenChange }: AuthModalProps) {
|
||||||
|
const [username, setUsername] = useState("");
|
||||||
|
const [isSignUp, setIsSignUp] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const auth = usePasskeyAuth({
|
||||||
|
appName: "Jazz Music Player",
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleViewChange = () => {
|
||||||
|
setIsSignUp(!isSignUp);
|
||||||
|
setError(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isSignUp) {
|
||||||
|
await auth.signUp(username);
|
||||||
|
} else {
|
||||||
|
await auth.logIn();
|
||||||
|
}
|
||||||
|
onOpenChange(false);
|
||||||
|
} catch (error) {
|
||||||
|
setError(error instanceof Error ? error.message : "Unknown error");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogContent className="sm:max-w-[425px]">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="text-2xl font-bold">
|
||||||
|
{isSignUp ? "Create account" : "Welcome back"}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
{isSignUp
|
||||||
|
? "Sign up to enable network sync and share your playlists with others"
|
||||||
|
: "Changes done before logging in will be lost"}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
|
{isSignUp && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="username">Username</Label>
|
||||||
|
<Input
|
||||||
|
id="username"
|
||||||
|
value={username}
|
||||||
|
onChange={(e) => setUsername(e.target.value)}
|
||||||
|
placeholder="Enter your username"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{error && <div className="text-sm text-red-500">{error}</div>}
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full bg-blue-600 hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
{isSignUp ? "Sign up with passkey" : "Login with passkey"}
|
||||||
|
</Button>
|
||||||
|
<div className="text-center text-sm">
|
||||||
|
{isSignUp ? "Already have an account?" : "Don't have an account?"}{" "}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleViewChange}
|
||||||
|
className="text-blue-600 hover:underline"
|
||||||
|
>
|
||||||
|
{isSignUp ? "Login" : "Sign up"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
37
examples/music-player/src/components/LocalOnlyTag.tsx
Normal file
37
examples/music-player/src/components/LocalOnlyTag.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipProvider,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
|
import { useIsAuthenticated } from "jazz-react";
|
||||||
|
import { Info } from "lucide-react";
|
||||||
|
|
||||||
|
export function LocalOnlyTag() {
|
||||||
|
const isAuthenticated = useIsAuthenticated();
|
||||||
|
|
||||||
|
if (isAuthenticated) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<div className="inline-flex items-center gap-1.5 cursor-help">
|
||||||
|
<Badge variant="default" className="h-5 text-xs font-normal">
|
||||||
|
Local only
|
||||||
|
</Badge>
|
||||||
|
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="max-w-[250px]">
|
||||||
|
<p>
|
||||||
|
Sign up to enable network sync and share your playlists with others
|
||||||
|
</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useAccount } from "@/2_main";
|
import { useAccount } from "jazz-react";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
|
|
||||||
export function LogoutButton() {
|
export function LogoutButton() {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { MusicTrack, Playlist } from "@/1_schema";
|
import { MusicTrack, Playlist } from "@/1_schema";
|
||||||
import { useAccount, useCoState } from "@/2_main";
|
|
||||||
import { addTrackToPlaylist } from "@/4_actions";
|
import { addTrackToPlaylist } from "@/4_actions";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -8,6 +7,7 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useAccount, useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { MoreHorizontal } from "lucide-react";
|
import { MoreHorizontal } from "lucide-react";
|
||||||
import { MusicTrackTitleInput } from "./MusicTrackTitleInput";
|
import { MusicTrackTitleInput } from "./MusicTrackTitleInput";
|
||||||
@@ -43,7 +43,7 @@ export function MusicTrackRow({
|
|||||||
|
|
||||||
function handleAddToPlaylist(playlist: Playlist) {
|
function handleAddToPlaylist(playlist: Playlist) {
|
||||||
if (!track) return;
|
if (!track) return;
|
||||||
addTrackToPlaylist(playlist, track, me);
|
addTrackToPlaylist(playlist, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MusicTrack } from "@/1_schema";
|
import { MusicTrack } from "@/1_schema";
|
||||||
import { useCoState } from "@/2_main";
|
|
||||||
import { updateMusicTrackTitle } from "@/4_actions";
|
import { updateMusicTrackTitle } from "@/4_actions";
|
||||||
|
import { useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { ChangeEvent, useState } from "react";
|
import { ChangeEvent, useState } from "react";
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { MusicTrack } from "@/1_schema";
|
import { MusicTrack } from "@/1_schema";
|
||||||
import { useAccount, useCoState } from "@/2_main";
|
|
||||||
import { MediaPlayer } from "@/5_useMediaPlayer";
|
import { MediaPlayer } from "@/5_useMediaPlayer";
|
||||||
import { useMediaEndListener } from "@/lib/audio/useMediaEndListener";
|
import { useMediaEndListener } from "@/lib/audio/useMediaEndListener";
|
||||||
import { usePlayState } from "@/lib/audio/usePlayState";
|
import { usePlayState } from "@/lib/audio/usePlayState";
|
||||||
import { useKeyboardListener } from "@/lib/useKeyboardListener";
|
import { useKeyboardListener } from "@/lib/useKeyboardListener";
|
||||||
|
import { useAccount, useCoState } from "jazz-react";
|
||||||
import { Pause, Play, SkipBack, SkipForward } from "lucide-react";
|
import { Pause, Play, SkipBack, SkipForward } from "lucide-react";
|
||||||
import { Waveform } from "./Waveform";
|
import { Waveform } from "./Waveform";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Playlist } from "@/1_schema";
|
import { Playlist } from "@/1_schema";
|
||||||
import { useCoState } from "@/2_main";
|
|
||||||
import { updatePlaylistTitle } from "@/4_actions";
|
import { updatePlaylistTitle } from "@/4_actions";
|
||||||
|
import { useCoState } from "jazz-react";
|
||||||
import { ID } from "jazz-tools";
|
import { ID } from "jazz-tools";
|
||||||
import { ChangeEvent, useState } from "react";
|
import { ChangeEvent, useState } from "react";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useAccount } from "@/2_main";
|
import { useAccount } from "jazz-react";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
|
import { LocalOnlyTag } from "./LocalOnlyTag";
|
||||||
|
|
||||||
export function SidePanel() {
|
export function SidePanel() {
|
||||||
const { playlistId } = useParams();
|
const { playlistId } = useParams();
|
||||||
@@ -25,7 +26,7 @@ export function SidePanel() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className="w-64 p-6 bg-white overflow-y-auto">
|
<aside className="w-64 p-6 bg-white overflow-y-auto">
|
||||||
<div className="flex items-center mb-6">
|
<div className="flex items-center mb-1">
|
||||||
<svg
|
<svg
|
||||||
className="w-8 h-8 mr-2"
|
className="w-8 h-8 mr-2"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
@@ -46,6 +47,9 @@ export function SidePanel() {
|
|||||||
</svg>
|
</svg>
|
||||||
<span className="text-xl font-bold text-blue-600">Music Player</span>
|
<span className="text-xl font-bold text-blue-600">Music Player</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mb-6">
|
||||||
|
<LocalOnlyTag />
|
||||||
|
</div>
|
||||||
<nav>
|
<nav>
|
||||||
<h2 className="mb-2 text-sm font-semibold text-gray-600">Playlists</h2>
|
<h2 className="mb-2 text-sm font-semibold text-gray-600">Playlists</h2>
|
||||||
<ul className="space-y-1">
|
<ul className="space-y-1">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MusicTrack, MusicTrackWaveform } from "@/1_schema";
|
import { MusicTrack, MusicTrackWaveform } from "@/1_schema";
|
||||||
import { useCoState } from "@/2_main";
|
|
||||||
import { usePlayerCurrentTime } from "@/lib/audio/usePlayerCurrentTime";
|
import { usePlayerCurrentTime } from "@/lib/audio/usePlayerCurrentTime";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useCoState } from "jazz-react";
|
||||||
|
|
||||||
export function Waveform(props: { track: MusicTrack; height: number }) {
|
export function Waveform(props: { track: MusicTrack; height: number }) {
|
||||||
const { track, height } = props;
|
const { track, height } = props;
|
||||||
|
|||||||
36
examples/music-player/src/components/ui/badge.tsx
Normal file
36
examples/music-player/src/components/ui/badge.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { type VariantProps, cva } from "class-variance-authority";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const badgeVariants = cva(
|
||||||
|
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default:
|
||||||
|
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
||||||
|
secondary:
|
||||||
|
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||||
|
destructive:
|
||||||
|
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
||||||
|
outline: "text-foreground",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export interface BadgeProps
|
||||||
|
extends React.HTMLAttributes<HTMLDivElement>,
|
||||||
|
VariantProps<typeof badgeVariants> {}
|
||||||
|
|
||||||
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge, badgeVariants };
|
||||||
120
examples/music-player/src/components/ui/dialog.tsx
Normal file
120
examples/music-player/src/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||||
|
import { X } from "lucide-react";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const Dialog = DialogPrimitive.Root;
|
||||||
|
|
||||||
|
const DialogTrigger = DialogPrimitive.Trigger;
|
||||||
|
|
||||||
|
const DialogPortal = DialogPrimitive.Portal;
|
||||||
|
|
||||||
|
const DialogClose = DialogPrimitive.Close;
|
||||||
|
|
||||||
|
const DialogOverlay = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
||||||
|
|
||||||
|
const DialogContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
<span className="sr-only">Close</span>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
));
|
||||||
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
const DialogHeader = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
DialogHeader.displayName = "DialogHeader";
|
||||||
|
|
||||||
|
const DialogFooter = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
DialogFooter.displayName = "DialogFooter";
|
||||||
|
|
||||||
|
const DialogTitle = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"text-lg font-semibold leading-none tracking-tight",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
||||||
|
|
||||||
|
const DialogDescription = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
ref={ref}
|
||||||
|
className={cn("text-sm text-muted-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogPortal,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogClose,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
};
|
||||||
22
examples/music-player/src/components/ui/input.tsx
Normal file
22
examples/music-player/src/components/ui/input.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
||||||
|
({ className, type, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type={type}
|
||||||
|
className={cn(
|
||||||
|
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
Input.displayName = "Input";
|
||||||
|
|
||||||
|
export { Input };
|
||||||
24
examples/music-player/src/components/ui/label.tsx
Normal file
24
examples/music-player/src/components/ui/label.tsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||||
|
import { type VariantProps, cva } from "class-variance-authority";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const labelVariants = cva(
|
||||||
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
||||||
|
);
|
||||||
|
|
||||||
|
const Label = React.forwardRef<
|
||||||
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
||||||
|
VariantProps<typeof labelVariants>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<LabelPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn(labelVariants(), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
Label.displayName = LabelPrimitive.Root.displayName;
|
||||||
|
|
||||||
|
export { Label };
|
||||||
30
examples/music-player/src/components/ui/tooltip.tsx
Normal file
30
examples/music-player/src/components/ui/tooltip.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const TooltipProvider = TooltipPrimitive.Provider;
|
||||||
|
|
||||||
|
const Tooltip = TooltipPrimitive.Root;
|
||||||
|
|
||||||
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
||||||
|
|
||||||
|
const TooltipContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof TooltipPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
||||||
|
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||||
|
<TooltipPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
||||||
@@ -1,10 +1,18 @@
|
|||||||
import { MusicaAccount } from "../1_schema";
|
import { MusicaAccount } from "../1_schema";
|
||||||
|
|
||||||
export async function getNextTrack(account: MusicaAccount) {
|
export async function getNextTrack() {
|
||||||
if (!account.root?.activePlaylist?.tracks) return;
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
|
root: {
|
||||||
|
activePlaylist: {
|
||||||
|
tracks: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const tracks = account.root.activePlaylist.tracks;
|
if (!me) return;
|
||||||
const activeTrack = account.root._refs.activeTrack;
|
|
||||||
|
const tracks = me.root.activePlaylist.tracks;
|
||||||
|
const activeTrack = me.root._refs.activeTrack;
|
||||||
|
|
||||||
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);
|
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);
|
||||||
|
|
||||||
@@ -13,11 +21,19 @@ export async function getNextTrack(account: MusicaAccount) {
|
|||||||
return tracks[nextIndex];
|
return tracks[nextIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPrevTrack(account: MusicaAccount) {
|
export async function getPrevTrack() {
|
||||||
if (!account.root?.activePlaylist?.tracks) return;
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
|
root: {
|
||||||
|
activePlaylist: {
|
||||||
|
tracks: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const tracks = account.root.activePlaylist.tracks;
|
if (!me) return;
|
||||||
const activeTrack = account.root._refs.activeTrack;
|
|
||||||
|
const tracks = me.root.activePlaylist.tracks;
|
||||||
|
const activeTrack = me.root._refs.activeTrack;
|
||||||
|
|
||||||
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);
|
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,33 @@
|
|||||||
// eslint-disable-next-line react-compiler/react-compiler
|
import { MusicaAccount } from "@/1_schema";
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
import { useAccount } from "jazz-react";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { MusicaAccount } from "../1_schema";
|
|
||||||
import { useAccount } from "../2_main";
|
|
||||||
import { uploadMusicTracks } from "../4_actions";
|
import { uploadMusicTracks } from "../4_actions";
|
||||||
|
|
||||||
export function useUploadExampleData() {
|
export function useUploadExampleData() {
|
||||||
const { me } = useAccount({
|
const { me } = useAccount();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
uploadOnboardingData();
|
||||||
|
}, [me.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadOnboardingData() {
|
||||||
|
const me = await MusicaAccount.getMe().ensureLoaded({
|
||||||
root: {},
|
root: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const shouldUploadOnboardingData = me?.root?.exampleDataLoaded === false;
|
if (!me) throw new Error("Me not resolved");
|
||||||
|
|
||||||
useEffect(() => {
|
if (me.root.exampleDataLoaded) return;
|
||||||
if (me?.root && shouldUploadOnboardingData) {
|
|
||||||
me.root.exampleDataLoaded = true;
|
|
||||||
|
|
||||||
uploadOnboardingData(me).then(() => {
|
me.root.exampleDataLoaded = true;
|
||||||
me.root.exampleDataLoaded = true;
|
|
||||||
});
|
try {
|
||||||
}
|
const trackFile = await (await fetch("/example.mp3")).blob();
|
||||||
}, [shouldUploadOnboardingData]);
|
|
||||||
}
|
await uploadMusicTracks([new File([trackFile], "Example song")]);
|
||||||
|
} catch (error) {
|
||||||
async function uploadOnboardingData(me: MusicaAccount) {
|
me.root.exampleDataLoaded = false;
|
||||||
const trackFile = await (await fetch("/example.mp3")).blob();
|
throw error;
|
||||||
|
}
|
||||||
return uploadMusicTracks(me, [new File([trackFile], "Example song")]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,84 @@
|
|||||||
import { test } from "@playwright/test";
|
import { BrowserContext, test } from "@playwright/test";
|
||||||
import { HomePage } from "./pages/HomePage";
|
import { HomePage } from "./pages/HomePage";
|
||||||
import { LoginPage } from "./pages/LoginPage";
|
|
||||||
|
|
||||||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|
||||||
test("create a new playlist and share", async ({ page }) => {
|
async function mockAuthenticator(context: BrowserContext) {
|
||||||
const loginPage = new LoginPage(page);
|
await context.addInitScript(() => {
|
||||||
|
Object.defineProperty(window.navigator, "credentials", {
|
||||||
|
value: {
|
||||||
|
...window.navigator.credentials,
|
||||||
|
create: async () => ({
|
||||||
|
type: "public-key",
|
||||||
|
id: new Uint8Array([1, 2, 3, 4]),
|
||||||
|
rawId: new Uint8Array([1, 2, 3, 4]),
|
||||||
|
response: {
|
||||||
|
clientDataJSON: new Uint8Array([1]),
|
||||||
|
attestationObject: new Uint8Array([2]),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
get: async () => ({
|
||||||
|
type: "public-key",
|
||||||
|
id: new Uint8Array([1, 2, 3, 4]),
|
||||||
|
rawId: new Uint8Array([1, 2, 3, 4]),
|
||||||
|
response: {
|
||||||
|
authenticatorData: new Uint8Array([1]),
|
||||||
|
clientDataJSON: new Uint8Array([2]),
|
||||||
|
signature: new Uint8Array([3]),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await loginPage.goto();
|
// Configure the authenticator
|
||||||
await loginPage.fillUsername("S. Mario");
|
test.beforeEach(async ({ context }) => {
|
||||||
await loginPage.signup();
|
// Enable virtual authenticator environment
|
||||||
|
await mockAuthenticator(context);
|
||||||
|
});
|
||||||
|
|
||||||
const homePage = new HomePage(page);
|
test("create a new playlist and share", async ({
|
||||||
|
page: marioPage,
|
||||||
|
browser,
|
||||||
|
}) => {
|
||||||
|
await marioPage.goto("/");
|
||||||
|
|
||||||
|
const marioHome = new HomePage(marioPage);
|
||||||
|
|
||||||
// The example song should be loaded
|
// The example song should be loaded
|
||||||
await homePage.expectMusicTrack("Example song");
|
await marioHome.expectMusicTrack("Example song");
|
||||||
await homePage.editTrackTitle("Example song", "Super Mario World");
|
await marioHome.editTrackTitle("Example song", "Super Mario World");
|
||||||
|
|
||||||
await homePage.createPlaylist();
|
await marioHome.createPlaylist();
|
||||||
await homePage.editPlaylistTitle("Save the princess");
|
await marioHome.editPlaylistTitle("Save the princess");
|
||||||
|
|
||||||
await homePage.navigateToPlaylist("All tracks");
|
await marioHome.navigateToPlaylist("All tracks");
|
||||||
await homePage.addTrackToPlaylist("Super Mario World", "Save the princess");
|
await marioHome.addTrackToPlaylist("Super Mario World", "Save the princess");
|
||||||
|
|
||||||
await homePage.navigateToPlaylist("Save the princess");
|
await marioHome.navigateToPlaylist("Save the princess");
|
||||||
await homePage.expectMusicTrack("Super Mario World");
|
await marioHome.expectMusicTrack("Super Mario World");
|
||||||
|
|
||||||
const url = await homePage.getShareLink();
|
await marioHome.signUp("Mario");
|
||||||
|
|
||||||
|
const url = await marioHome.getShareLink();
|
||||||
|
|
||||||
await sleep(4000); // Wait for the sync to complete
|
await sleep(4000); // Wait for the sync to complete
|
||||||
|
|
||||||
await homePage.logout();
|
const luigiContext = await browser.newContext();
|
||||||
|
await mockAuthenticator(luigiContext);
|
||||||
|
|
||||||
await loginPage.goto();
|
const luigiPage = await luigiContext.newPage();
|
||||||
await loginPage.fillUsername("Luigi");
|
await luigiPage.goto("/");
|
||||||
await loginPage.signup();
|
|
||||||
|
|
||||||
await page.goto(url);
|
const luigiHome = new HomePage(luigiPage);
|
||||||
|
|
||||||
await homePage.expectMusicTrack("Super Mario World");
|
await luigiHome.signUp("Luigi");
|
||||||
await homePage.playMusicTrack("Super Mario World");
|
|
||||||
await homePage.expectActiveTrackPlaying();
|
await luigiPage.goto(url);
|
||||||
|
|
||||||
|
await luigiHome.expectMusicTrack("Super Mario World");
|
||||||
|
await luigiHome.playMusicTrack("Super Mario World");
|
||||||
|
await luigiHome.expectActiveTrackPlaying();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,6 +95,17 @@ export class HomePage {
|
|||||||
.click();
|
.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async signUp(name: string) {
|
||||||
|
await this.page.getByRole("button", { name: "Sign up" }).click();
|
||||||
|
await this.page.getByRole("textbox", { name: "Username" }).fill(name);
|
||||||
|
await this.page
|
||||||
|
.getByRole("button", { name: "Sign up with passkey" })
|
||||||
|
.click();
|
||||||
|
await expect(
|
||||||
|
this.page.getByRole("button", { name: "Sign out" }),
|
||||||
|
).toBeVisible();
|
||||||
|
}
|
||||||
|
|
||||||
async logout() {
|
async logout() {
|
||||||
await this.logoutButton.click();
|
await this.logoutButton.click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import { Locator, Page, expect } from "@playwright/test";
|
|
||||||
|
|
||||||
export class LoginPage {
|
|
||||||
readonly page: Page;
|
|
||||||
readonly usernameInput: Locator;
|
|
||||||
readonly signupButton: Locator;
|
|
||||||
|
|
||||||
constructor(page: Page) {
|
|
||||||
this.page = page;
|
|
||||||
this.usernameInput = page.getByRole("textbox");
|
|
||||||
this.signupButton = page.getByRole("button", {
|
|
||||||
name: "Sign up",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async goto() {
|
|
||||||
this.page.goto("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fillUsername(value: string) {
|
|
||||||
await this.usernameInput.clear();
|
|
||||||
await this.usernameInput.fill(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginAs(value: string) {
|
|
||||||
await this.page
|
|
||||||
.getByRole("button", {
|
|
||||||
name: value,
|
|
||||||
})
|
|
||||||
.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async signup() {
|
|
||||||
await this.signupButton.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async expectLoaded() {
|
|
||||||
await expect(this.signupButton).toBeVisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,143 @@
|
|||||||
# jazz-example-onboarding
|
# 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
|
||||||
|
|
||||||
|
- Updated dependencies [7491711]
|
||||||
|
- jazz-tools@0.9.15
|
||||||
|
- jazz-browser-media-images@0.9.15
|
||||||
|
- jazz-react@0.9.15
|
||||||
|
|
||||||
|
## 0.0.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [3df93cc]
|
||||||
|
- jazz-tools@0.9.14
|
||||||
|
- jazz-browser-media-images@0.9.14
|
||||||
|
- jazz-react@0.9.14
|
||||||
|
|
||||||
|
## 0.0.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.13
|
||||||
|
- jazz-tools@0.9.13
|
||||||
|
- jazz-browser-media-images@0.9.13
|
||||||
|
|
||||||
|
## 0.0.34
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.12
|
||||||
|
- jazz-tools@0.9.12
|
||||||
|
- jazz-browser-media-images@0.9.12
|
||||||
|
|
||||||
|
## 0.0.33
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.11
|
||||||
|
- jazz-tools@0.9.11
|
||||||
|
- jazz-browser-media-images@0.9.11
|
||||||
|
|
||||||
|
## 0.0.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [5e83864]
|
||||||
|
- jazz-react@0.9.10
|
||||||
|
- jazz-tools@0.9.10
|
||||||
|
- jazz-browser-media-images@0.9.10
|
||||||
|
|
||||||
|
## 0.0.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [8eb9247]
|
||||||
|
- jazz-tools@0.9.9
|
||||||
|
- jazz-browser-media-images@0.9.9
|
||||||
|
- jazz-react@0.9.9
|
||||||
|
|
||||||
|
## 0.0.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [d1d773b]
|
||||||
|
- jazz-tools@0.9.8
|
||||||
|
- jazz-react@0.9.8
|
||||||
|
- jazz-browser-media-images@0.9.8
|
||||||
|
|
||||||
|
## 0.0.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- jazz-react@0.9.4
|
||||||
|
|
||||||
|
## 0.0.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [1b71969]
|
||||||
|
- jazz-react@0.9.1
|
||||||
|
- jazz-tools@0.9.1
|
||||||
|
- jazz-browser-media-images@0.9.1
|
||||||
|
|
||||||
|
## 0.0.27
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [956a4d1]
|
||||||
|
- Updated dependencies [8eda792]
|
||||||
|
- jazz-react@0.9.0
|
||||||
|
- jazz-tools@0.9.0
|
||||||
|
- jazz-browser-media-images@0.9.0
|
||||||
|
|
||||||
## 0.0.26
|
## 0.0.26
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,29 +1,54 @@
|
|||||||
# Onboarding example with Jazz and React
|
# Onboarding example with Jazz and React
|
||||||
|
|
||||||
## Installing & running the example locally
|
## Getting started
|
||||||
|
|
||||||
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
|
You can either
|
||||||
|
1. Clone the jazz repository, and run the app within the monorepo.
|
||||||
|
2. Or create a new Jazz project using this example as a template.
|
||||||
|
|
||||||
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
|
|
||||||
|
### Using the example as a template
|
||||||
|
|
||||||
|
Create a new Jazz project, and use this example as a template.
|
||||||
```bash
|
```bash
|
||||||
npx degit gardencmp/jazz jazz
|
npx create-jazz-app@latest --example onboarding --project-name onboarding
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to the onboarding example directory:
|
Go to the new project directory.
|
||||||
```bash
|
```bash
|
||||||
cd jazz/examples/onboarding
|
cd onboarding
|
||||||
```
|
```
|
||||||
|
|
||||||
Install and build dependencies:
|
Run the dev server.
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the monorepo
|
||||||
|
|
||||||
|
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
|
||||||
|
|
||||||
|
Clone the jazz repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/garden-co/jazz.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Install and build dependencies.
|
||||||
```bash
|
```bash
|
||||||
pnpm i && npx turbo build
|
pnpm i && npx turbo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the dev server:
|
Go to the example directory.
|
||||||
|
```bash
|
||||||
|
cd jazz/examples/onboarding/
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the dev server.
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
|
||||||
## Questions / problems / feedback
|
## Questions / problems / feedback
|
||||||
|
|
||||||
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.
|
||||||
@@ -32,4 +57,4 @@ If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or
|
|||||||
|
|
||||||
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
|
||||||
|
|
||||||
You can also run a local sync server by running `npx cojson-simple-sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/main.tsx](./src/main.tsx).
|
You can also run a local sync server by running `npx cojson-simple-sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<JazzProvider>` provider component in [./src/main.tsx](./src/main.tsx).
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user