Compare commits
417 Commits
jazz-react
...
cojson-sto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b675249960 | ||
|
|
05198e4181 | ||
|
|
ec9cb40fa4 | ||
|
|
fae9b521b8 | ||
|
|
ec1e2e4539 | ||
|
|
9550dcd6e7 | ||
|
|
4547525579 | ||
|
|
856ba0c1fa | ||
|
|
aaf217c61b | ||
|
|
29e05c4ad4 | ||
|
|
65719f21a3 | ||
|
|
05ff90c3c4 | ||
|
|
07408970bd | ||
|
|
ebd5ae2985 | ||
|
|
b0270e72d2 | ||
|
|
95c3001a7f | ||
|
|
4ba3ea6b4e | ||
|
|
fc6eab7efe | ||
|
|
c30fb098fe | ||
|
|
2ff226cf9a | ||
|
|
08bd887ab7 | ||
|
|
3396ed4b72 | ||
|
|
a703bc3102 | ||
|
|
18dc96c7b1 | ||
|
|
f8d9e9f5c8 | ||
|
|
e9e7f45e02 | ||
|
|
3b96af8686 | ||
|
|
49fb6311ad | ||
|
|
bce150c391 | ||
|
|
f8f07941fa | ||
|
|
6a1b01417b | ||
|
|
db60152b73 | ||
|
|
ebf082c145 | ||
|
|
f8b98ee3e1 | ||
|
|
01ef60bf04 | ||
|
|
17273a60e7 | ||
|
|
0439f4c404 | ||
|
|
e47fe35b15 | ||
|
|
f9e4520d64 | ||
|
|
91f23ee555 | ||
|
|
d06df65bd9 | ||
|
|
e9b9b85695 | ||
|
|
6a97cfd53d | ||
|
|
3497beea9e | ||
|
|
7ecd643719 | ||
|
|
4c26d43e2e | ||
|
|
b089f0bb5d | ||
|
|
d6c99a3ab9 | ||
|
|
fb41802011 | ||
|
|
e4313d94ed | ||
|
|
30bc01a4fd | ||
|
|
de6eccd197 | ||
|
|
ca6e98359c | ||
|
|
092fed118a | ||
|
|
3bb702d520 | ||
|
|
5f1979a61a | ||
|
|
1861867708 | ||
|
|
9ef32e0039 | ||
|
|
375db82ad4 | ||
|
|
1d2ed44548 | ||
|
|
e0dd4b678a | ||
|
|
db113ba816 | ||
|
|
6f58c43b48 | ||
|
|
0ff0710226 | ||
|
|
ce5c5a1558 | ||
|
|
500fc29a9e | ||
|
|
b7976929d0 | ||
|
|
6db4e8837c | ||
|
|
588a9aff0b | ||
|
|
399057b262 | ||
|
|
12daa15ef7 | ||
|
|
9356ffbd4e | ||
|
|
866d1b310a | ||
|
|
225103b095 | ||
|
|
328227316c | ||
|
|
dd5fe12dfe | ||
|
|
f837cfe994 | ||
|
|
f80bef8fef | ||
|
|
1bba26081b | ||
|
|
9efb2e2dd8 | ||
|
|
4b12b051e3 | ||
|
|
6bf2ddb7a8 | ||
|
|
978c30a7ca | ||
|
|
e2c02824e7 | ||
|
|
e05dff9c32 | ||
|
|
267ea4cf46 | ||
|
|
6dac7c7ce5 | ||
|
|
d0724a2c13 | ||
|
|
4c632e14a4 | ||
|
|
d7238267d9 | ||
|
|
a6cf01f867 | ||
|
|
17d148b1d2 | ||
|
|
2544782988 | ||
|
|
8f42c7a749 | ||
|
|
62aa4146af | ||
|
|
d423e3c4b3 | ||
|
|
bdac4d1188 | ||
|
|
47c9004d5f | ||
|
|
de19a6db37 | ||
|
|
cdc885994c | ||
|
|
6e1b27b0c9 | ||
|
|
64483ea09b | ||
|
|
1310c19bb0 | ||
|
|
dae58f8d54 | ||
|
|
b4af381043 | ||
|
|
6ac8bebf90 | ||
|
|
81d63606a6 | ||
|
|
29d0b6fa03 | ||
|
|
36cf5b1dbb | ||
|
|
13c1dc34f7 | ||
|
|
4530c4a9d2 | ||
|
|
ba8dc07630 | ||
|
|
c841b2da58 | ||
|
|
b42e5f5d82 | ||
|
|
24137a1269 | ||
|
|
22b5c4f083 | ||
|
|
5810572f54 | ||
|
|
ab3c61b7ca | ||
|
|
53b2cd93eb | ||
|
|
95cee57379 | ||
|
|
a5df996d67 | ||
|
|
a041ee5c4b | ||
|
|
a518e8b667 | ||
|
|
673197cf8e | ||
|
|
9a9aa1e811 | ||
|
|
793342b67a | ||
|
|
13074beebf | ||
|
|
9696bda2e9 | ||
|
|
87e0a23186 | ||
|
|
1acc9eb37b | ||
|
|
9ba228c804 | ||
|
|
a4bad7aab8 | ||
|
|
4e9aae1887 | ||
|
|
093bab7fbc | ||
|
|
b2449a3bae | ||
|
|
49784a7e65 | ||
|
|
bc3d7bbb18 | ||
|
|
935cd745ba | ||
|
|
608d06d46f | ||
|
|
7690e19014 | ||
|
|
4626c79c46 | ||
|
|
aad0bd60f4 | ||
|
|
1fbe8d9651 | ||
|
|
2ba762b4c8 | ||
|
|
f24855e8e5 | ||
|
|
e299fc9d51 | ||
|
|
0bd293f632 | ||
|
|
d8d186da09 | ||
|
|
9ddc5fa060 | ||
|
|
910683dce4 | ||
|
|
bb0f0ecbc0 | ||
|
|
1f54b4875a | ||
|
|
68759f1797 | ||
|
|
cdc5cbd6d6 | ||
|
|
f55097c480 | ||
|
|
e9695fa2eb | ||
|
|
0c11110567 | ||
|
|
f2db858221 | ||
|
|
a362cbba51 | ||
|
|
39c2586d3b | ||
|
|
4336342f74 | ||
|
|
3a5dfbe008 | ||
|
|
504e42b7ea | ||
|
|
6a9baa304f | ||
|
|
99b9b10d2d | ||
|
|
f42b73b09b | ||
|
|
41a62a8dde | ||
|
|
73f99a11b1 | ||
|
|
587d5267bb | ||
|
|
a747e1f466 | ||
|
|
95c967783b | ||
|
|
89ff69f005 | ||
|
|
e5eed7bd35 | ||
|
|
698d3b0a81 | ||
|
|
cb5e55d18f | ||
|
|
dcf8243551 | ||
|
|
39ae497153 | ||
|
|
cdab27084c | ||
|
|
17b499e68a | ||
|
|
f3f2344948 | ||
|
|
ce4064f6a7 | ||
|
|
d66bd6ee1f | ||
|
|
02c27ababc | ||
|
|
4296069148 | ||
|
|
e0b5df7f9e | ||
|
|
264c1c1fa5 | ||
|
|
54b2907f08 | ||
|
|
4dcb1d9af2 | ||
|
|
65862b085f | ||
|
|
8957684618 | ||
|
|
2c3ac8f2aa | ||
|
|
44332544ca | ||
|
|
421b225fed | ||
|
|
0ab6a5c739 | ||
|
|
65ce5dc40a | ||
|
|
c240395e76 | ||
|
|
25fd7e832f | ||
|
|
fa1f15d3af | ||
|
|
67a90b01f1 | ||
|
|
a20b4e4983 | ||
|
|
25de875826 | ||
|
|
0db0bdd97d | ||
|
|
0fd7d1c18a | ||
|
|
d4960e7f15 | ||
|
|
31ea2ef07a | ||
|
|
6e28ac946b | ||
|
|
cfce22fc63 | ||
|
|
752f453e80 | ||
|
|
19dabe8ffe | ||
|
|
d2234dc2ba | ||
|
|
21c935cb3d | ||
|
|
07d652c5e0 | ||
|
|
686b311590 | ||
|
|
80fe01e50d | ||
|
|
2ebb9351cd | ||
|
|
2dd7bdb007 | ||
|
|
d0e8b97926 | ||
|
|
f83897e64c | ||
|
|
ec4e56df61 | ||
|
|
f3e0b1ed74 | ||
|
|
ca9162476c | ||
|
|
f98f6f1a7a | ||
|
|
2624d037f3 | ||
|
|
66419abc66 | ||
|
|
608bd77f1c | ||
|
|
1b8029860e | ||
|
|
2d7917b169 | ||
|
|
4bec7b90c1 | ||
|
|
f822c3a787 | ||
|
|
7b25324660 | ||
|
|
6a81a1c9c5 | ||
|
|
4dd2c70f0f | ||
|
|
9d23d8ab6c | ||
|
|
a89611ae3b | ||
|
|
43433b75fe | ||
|
|
85830ad805 | ||
|
|
114f0fffab | ||
|
|
97e2e568cd | ||
|
|
d42298687c | ||
|
|
a19780566b | ||
|
|
dfc8935616 | ||
|
|
a6c0a4b4c8 | ||
|
|
19972d3183 | ||
|
|
566cddcd3e | ||
|
|
6e3dca448a | ||
|
|
6410d27f49 | ||
|
|
a2258ab728 | ||
|
|
c1f464bb41 | ||
|
|
0ca964c2f0 | ||
|
|
48d96956c6 | ||
|
|
c320615d8b | ||
|
|
2fd5f28404 | ||
|
|
e2ee06bebe | ||
|
|
daf6b5b3d2 | ||
|
|
038ac38e88 | ||
|
|
7e57eea71d | ||
|
|
34904eac47 | ||
|
|
0332daa038 | ||
|
|
924794a3a4 | ||
|
|
12e3d2ace0 | ||
|
|
d1bd998000 | ||
|
|
c803f8accb | ||
|
|
76e17835f9 | ||
|
|
db3dd94d82 | ||
|
|
4392888032 | ||
|
|
aa1c80e35b | ||
|
|
b4798fe733 | ||
|
|
582ab63d2f | ||
|
|
45ed69b943 | ||
|
|
ebb751bb38 | ||
|
|
5a39eec078 | ||
|
|
acb2d35bdc | ||
|
|
50d6c7770b | ||
|
|
d8019697a6 | ||
|
|
cc2ffeb286 | ||
|
|
cc204723d2 | ||
|
|
fc647f715b | ||
|
|
1c54a3b5e1 | ||
|
|
7fdb1952a6 | ||
|
|
6cfcb01cf0 | ||
|
|
bccff51061 | ||
|
|
02ec3fd436 | ||
|
|
ce177ca53e | ||
|
|
d7895504a4 | ||
|
|
699db46ed6 | ||
|
|
d303be6709 | ||
|
|
fe6f561afd | ||
|
|
93c7f6c253 | ||
|
|
3b2831f7de | ||
|
|
902e539f56 | ||
|
|
9e9946cf48 | ||
|
|
ecfc883419 | ||
|
|
a861fba3b1 | ||
|
|
37d9e60128 | ||
|
|
6db84dc673 | ||
|
|
f0ae3e47b6 | ||
|
|
4aded04223 | ||
|
|
051e6c497e | ||
|
|
9b2a73b900 | ||
|
|
dd8ed599f7 | ||
|
|
33e51267e3 | ||
|
|
59251a58c4 | ||
|
|
e090b3992d | ||
|
|
31794684a0 | ||
|
|
14fcc8dde5 | ||
|
|
13f1821c04 | ||
|
|
4c3b85abcd | ||
|
|
4b0544fd0d | ||
|
|
568674a7fa | ||
|
|
ef012f07aa | ||
|
|
eee2330325 | ||
|
|
b83ec05ccc | ||
|
|
386525db48 | ||
|
|
a8809d840c | ||
|
|
005fc1f8c9 | ||
|
|
3129982582 | ||
|
|
5d7bb70c7d | ||
|
|
1a7a84f71b | ||
|
|
1d51bdc016 | ||
|
|
8da6f3a897 | ||
|
|
dca9293ae7 | ||
|
|
558bab2e58 | ||
|
|
2b362fd331 | ||
|
|
f03f1b6de8 | ||
|
|
bd57177586 | ||
|
|
9e0e2709a5 | ||
|
|
01b2ab7148 | ||
|
|
44b7d39467 | ||
|
|
5373ee2858 | ||
|
|
b19cab78d3 | ||
|
|
3f86dfce4f | ||
|
|
12f8bfa28f | ||
|
|
53211a4fca | ||
|
|
d0f188a072 | ||
|
|
9e55542872 | ||
|
|
0a6cd4e9b2 | ||
|
|
7af6cedfd6 | ||
|
|
847d379fe9 | ||
|
|
69954caee6 | ||
|
|
6a5bd28d07 | ||
|
|
ba58bc3ace | ||
|
|
94cb615a38 | ||
|
|
b130f46b6c | ||
|
|
989d59f978 | ||
|
|
c3dd099ee1 | ||
|
|
4dc7cf9389 | ||
|
|
882fd55d69 | ||
|
|
b2fdb8b9e5 | ||
|
|
e879ec981e | ||
|
|
980609ca87 | ||
|
|
71cd7396b7 | ||
|
|
dedc3e277c | ||
|
|
656866729d | ||
|
|
f93dd1f779 | ||
|
|
80d499f002 | ||
|
|
c9a87e52f3 | ||
|
|
3f98d9ab73 | ||
|
|
abb0e8fada | ||
|
|
be2e1f3c61 | ||
|
|
75f20d8176 | ||
|
|
e6bef5275b | ||
|
|
9813db1603 | ||
|
|
a3143f20a9 | ||
|
|
f54beb2d88 | ||
|
|
b7ce1e2da0 | ||
|
|
6dba138ec7 | ||
|
|
32f59a618f | ||
|
|
9b2de387ed | ||
|
|
b612258c5e | ||
|
|
09b59ed18b | ||
|
|
b7b186b67e | ||
|
|
f2ba925db6 | ||
|
|
bc9488241f | ||
|
|
4fc36779dd | ||
|
|
bc008aeb23 | ||
|
|
8ad45a421e | ||
|
|
197317efbf | ||
|
|
775ad975f3 | ||
|
|
eaedf455d4 | ||
|
|
017f6c8074 | ||
|
|
48dd922712 | ||
|
|
202b320ad1 | ||
|
|
ea094ae64b | ||
|
|
9412aeb938 | ||
|
|
785fc893ee | ||
|
|
4f5e471667 | ||
|
|
fc6b20d370 | ||
|
|
e4886d1b03 | ||
|
|
dfb2b19209 | ||
|
|
1a92d6b1e5 | ||
|
|
d5c1f49cc5 | ||
|
|
7d6ce843de | ||
|
|
0298f0eb29 | ||
|
|
794c56dfac | ||
|
|
6b9382b5e9 | ||
|
|
08ae9b295f | ||
|
|
917e8a21d8 | ||
|
|
595e3c89df | ||
|
|
b9afa42662 | ||
|
|
5246a54118 | ||
|
|
a036391f69 | ||
|
|
6ad24315bb | ||
|
|
48a83c356d | ||
|
|
756d52d106 | ||
|
|
83876a3523 | ||
|
|
b77c6d4edc | ||
|
|
c74fc11b25 | ||
|
|
7a636bd8c2 | ||
|
|
3167ff16cd | ||
|
|
2e70b2b295 | ||
|
|
9a5e6eed16 | ||
|
|
28d74d73f8 | ||
|
|
6c9d90449a | ||
|
|
5398978d74 | ||
|
|
53148db482 | ||
|
|
44a0b54026 | ||
|
|
c877d377d2 |
5
.github/workflows/code-quality.yml
vendored
@@ -15,4 +15,7 @@ jobs:
|
||||
with:
|
||||
version: latest
|
||||
- name: Run Biome
|
||||
run: biome ci .
|
||||
run: biome ci .
|
||||
|
||||
- name: Check Catalog Dependencies
|
||||
run: node scripts/check-catalog-deps.js
|
||||
|
||||
2
.github/workflows/playwright.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
project: ["tests/e2e", "examples/chat", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "starters/react-passkey-auth"]
|
||||
project: ["tests/e2e", "examples/chat", "examples/clerk", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "starters/react-passkey-auth"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"**/android/**",
|
||||
"packages/jazz-svelte/**",
|
||||
"examples/*svelte*/**",
|
||||
"examples/jazz-paper-scissors/src/routeTree.gen.ts",
|
||||
"homepage/homepage/**",
|
||||
"**/package.json"
|
||||
]
|
||||
|
||||
@@ -1,5 +1,92 @@
|
||||
# chat-rn-expo-clerk
|
||||
|
||||
## 1.0.105
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
- jazz-react-native-media-images@0.13.13
|
||||
|
||||
## 1.0.104
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-expo@0.13.12
|
||||
- jazz-react-native-media-images@0.13.12
|
||||
|
||||
## 1.0.103
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-expo@0.13.11
|
||||
- jazz-react-native-media-images@0.13.11
|
||||
|
||||
## 1.0.102
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
- jazz-react-native-media-images@0.13.10
|
||||
|
||||
## 1.0.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-expo@0.13.9
|
||||
- jazz-react-native-media-images@0.13.9
|
||||
|
||||
## 1.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.8
|
||||
|
||||
## 1.0.99
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-expo@0.13.7
|
||||
- jazz-react-native-media-images@0.13.7
|
||||
|
||||
## 1.0.98
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-expo@0.13.5
|
||||
- jazz-react-native-media-images@0.13.5
|
||||
|
||||
## 1.0.97
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-expo@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-react-native-media-images@0.13.4
|
||||
|
||||
## 1.0.96
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-expo@0.13.3
|
||||
- jazz-react-native-media-images@0.13.3
|
||||
|
||||
## 1.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -2,28 +2,39 @@ import "../global.css";
|
||||
import { ClerkLoaded, ClerkProvider } from "@clerk/clerk-expo";
|
||||
import { secureStore } from "@clerk/clerk-expo/secure-store";
|
||||
import { useFonts } from "expo-font";
|
||||
import { Slot } from "expo-router";
|
||||
import { Slot, useRouter, useSegments } from "expo-router";
|
||||
import * as SplashScreen from "expo-splash-screen";
|
||||
import { useIsAuthenticated, useJazzContext } from "jazz-expo";
|
||||
import React, { useEffect } from "react";
|
||||
import { tokenCache } from "../cache";
|
||||
import { JazzAndAuth } from "../src/auth-context";
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
export default function RootLayout() {
|
||||
const [loaded] = useFonts({
|
||||
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
|
||||
});
|
||||
function InitialLayout() {
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
const segments = useSegments();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (loaded) {
|
||||
SplashScreen.hideAsync();
|
||||
}
|
||||
}, [loaded]);
|
||||
const inAuthGroup = segments[0] === "(auth)";
|
||||
|
||||
if (!loaded) {
|
||||
return null;
|
||||
}
|
||||
if (isAuthenticated && inAuthGroup) {
|
||||
router.replace("/chat");
|
||||
} else if (!isAuthenticated && !inAuthGroup) {
|
||||
router.replace("/");
|
||||
}
|
||||
|
||||
SplashScreen.hideAsync();
|
||||
}, [isAuthenticated, segments, router]);
|
||||
|
||||
return <Slot />;
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
const [fontsLoaded] = useFonts({
|
||||
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
|
||||
});
|
||||
|
||||
const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY;
|
||||
|
||||
@@ -33,6 +44,17 @@ export default function RootLayout() {
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (fontsLoaded) {
|
||||
} else {
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
}
|
||||
}, [fontsLoaded]);
|
||||
|
||||
if (!fontsLoaded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ClerkProvider
|
||||
tokenCache={tokenCache}
|
||||
@@ -41,7 +63,7 @@ export default function RootLayout() {
|
||||
>
|
||||
<ClerkLoaded>
|
||||
<JazzAndAuth>
|
||||
<Slot />
|
||||
<InitialLayout />
|
||||
</JazzAndAuth>
|
||||
</ClerkLoaded>
|
||||
</ClerkProvider>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "chat-rn-expo-clerk",
|
||||
"main": "index.js",
|
||||
"version": "1.0.95",
|
||||
"version": "1.0.105",
|
||||
"scripts": {
|
||||
"build": "expo export -p ios",
|
||||
"start": "expo start",
|
||||
@@ -12,9 +12,6 @@
|
||||
"web": "expo start --web",
|
||||
"run:ios": "pnpm expo prebuild && npx pod-install && pnpm expo run:ios"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-expo"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.2",
|
||||
"@bacons/text-decoder": "0.0.0",
|
||||
@@ -60,14 +57,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/react": "~18.3.12",
|
||||
"@types/react-test-renderer": "^19.0.0",
|
||||
"jest": "^29.6.3",
|
||||
"jest-expo": "~52.0.2",
|
||||
"react-test-renderer": "18.3.1",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2"
|
||||
"typescript": "5.6.2"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
||||
@@ -1,5 +1,83 @@
|
||||
# chat-rn-expo
|
||||
|
||||
## 1.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 1.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-expo@0.13.12
|
||||
|
||||
## 1.0.90
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-expo@0.13.11
|
||||
|
||||
## 1.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 1.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-expo@0.13.9
|
||||
|
||||
## 1.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-expo@0.13.8
|
||||
|
||||
## 1.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-expo@0.13.7
|
||||
|
||||
## 1.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-expo@0.13.5
|
||||
|
||||
## 1.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-expo@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 1.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-expo@0.13.3
|
||||
|
||||
## 1.0.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-rn-expo",
|
||||
"version": "1.0.82",
|
||||
"version": "1.0.92",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "expo export -p ios",
|
||||
@@ -45,7 +45,7 @@
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/react": "~18.3.12",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2"
|
||||
"typescript": "5.6.2"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
||||
@@ -1,5 +1,101 @@
|
||||
# chat-rn
|
||||
|
||||
## 1.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ec9cb40]
|
||||
- cojson@0.13.13
|
||||
- cojson-transport-ws@0.13.13
|
||||
- jazz-react-native@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 1.0.99
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- Updated dependencies [65719f2]
|
||||
- jazz-tools@0.13.12
|
||||
- cojson@0.13.12
|
||||
- jazz-react-native@0.13.12
|
||||
- cojson-transport-ws@0.13.12
|
||||
|
||||
## 1.0.98
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- Updated dependencies [3396ed4]
|
||||
- Updated dependencies [17273a6]
|
||||
- Updated dependencies [267ea4c]
|
||||
- cojson@0.13.11
|
||||
- jazz-tools@0.13.11
|
||||
- cojson-transport-ws@0.13.11
|
||||
- jazz-react-native@0.13.11
|
||||
|
||||
## 1.0.97
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f837cfe]
|
||||
- cojson@0.13.10
|
||||
- cojson-transport-ws@0.13.10
|
||||
- jazz-react-native@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 1.0.96
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react-native@0.13.9
|
||||
|
||||
## 1.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- Updated dependencies [4e9aae1]
|
||||
- Updated dependencies [21c935c]
|
||||
- Updated dependencies [aa1c80e]
|
||||
- Updated dependencies [13074be]
|
||||
- jazz-tools@0.13.7
|
||||
- cojson@0.13.7
|
||||
- jazz-react-native@0.13.7
|
||||
- cojson-transport-ws@0.13.7
|
||||
|
||||
## 1.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e090b39]
|
||||
- Updated dependencies [fe6f561]
|
||||
- cojson@0.13.5
|
||||
- jazz-tools@0.13.5
|
||||
- cojson-transport-ws@0.13.5
|
||||
- jazz-react-native@0.13.5
|
||||
|
||||
## 1.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-react-native@0.13.4
|
||||
|
||||
## 1.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [b19cab7]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- cojson-transport-ws@0.13.3
|
||||
- jazz-react-native@0.13.3
|
||||
|
||||
## 1.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "chat-rn",
|
||||
"version": "1.0.91",
|
||||
"version": "1.0.100",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
"ios": "react-native run-ios",
|
||||
"lint": "eslint .",
|
||||
"start": "react-native start",
|
||||
"test": "jest",
|
||||
"pods": "pod-install"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -47,16 +46,13 @@
|
||||
"@react-native/typescript-config": "0.76.7",
|
||||
"@rnx-kit/metro-config": "^2.0.1",
|
||||
"@rnx-kit/metro-resolver-symlinks": "^0.2.1",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-test-renderer": "^18.0.0",
|
||||
"babel-jest": "^29.6.3",
|
||||
"eslint": "^8.19.0",
|
||||
"jest": "^29.6.3",
|
||||
"pod-install": "^0.3.5",
|
||||
"prettier": "2.8.8",
|
||||
"react-test-renderer": "18.3.1",
|
||||
"typescript": "5.0.4"
|
||||
"typescript": "5.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
||||
@@ -1,5 +1,86 @@
|
||||
# chat-vue
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-browser@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
- jazz-vue@0.13.13
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- Updated dependencies [29e05c4]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-browser@0.13.12
|
||||
- jazz-vue@0.13.12
|
||||
|
||||
## 0.0.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-browser@0.13.11
|
||||
- jazz-vue@0.13.11
|
||||
|
||||
## 0.0.81
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-browser@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
- jazz-vue@0.13.10
|
||||
|
||||
## 0.0.80
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-browser@0.13.9
|
||||
- jazz-vue@0.13.9
|
||||
|
||||
## 0.0.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-browser@0.13.7
|
||||
- jazz-vue@0.13.7
|
||||
|
||||
## 0.0.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-browser@0.13.5
|
||||
- jazz-vue@0.13.5
|
||||
|
||||
## 0.0.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-browser@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-vue@0.13.4
|
||||
|
||||
## 0.0.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-browser@0.13.3
|
||||
- jazz-vue@0.13.3
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="icon" href="./public/favicon.ico" type="image/png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<title>Jazz Chat Vue Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-vue",
|
||||
"version": "0.0.75",
|
||||
"version": "0.0.84",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -31,8 +31,8 @@
|
||||
"npm-run-all2": "^6.2.3",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11",
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11",
|
||||
"vite-plugin-vue-devtools": "^7.4.6",
|
||||
"vue-tsc": "^2.1.6"
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 15 KiB |
@@ -1,5 +1,97 @@
|
||||
# jazz-example-chat
|
||||
|
||||
## 0.0.182
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.13
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.181
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-inspector@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.0.180
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-inspector@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.0.179
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.10
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.178
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-inspector@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.0.177
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [22b5c4f]
|
||||
- Updated dependencies [31ea2ef]
|
||||
- Updated dependencies [4530c4a]
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-inspector@0.13.7
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.0.176
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c320615]
|
||||
- jazz-inspector@0.13.6
|
||||
|
||||
## 0.0.175
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [08ae9b2]
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-inspector@0.13.5
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.0.174
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-inspector@0.13.4
|
||||
|
||||
## 0.0.173
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- Updated dependencies [017f6c8]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-inspector@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.0.172
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-chat",
|
||||
"private": true,
|
||||
"version": "0.0.172",
|
||||
"version": "0.0.182",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -31,7 +31,7 @@
|
||||
"is-ci": "^3.0.1",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -36,7 +36,7 @@ const config: Config = {
|
||||
blue: {
|
||||
...colors.indigo,
|
||||
500: "#5870F1",
|
||||
DEFAULT: "#3313F7",
|
||||
DEFAULT: "#146AFF",
|
||||
},
|
||||
},
|
||||
container: {
|
||||
@@ -56,18 +56,6 @@ const config: Config = {
|
||||
plugins: [
|
||||
plugin(({ addBase }) =>
|
||||
addBase({
|
||||
":root": {
|
||||
"--gcmp-border-color": stonePalette[200],
|
||||
"--gcmp-invert-border-color": stonePalette[900],
|
||||
},
|
||||
"*": {
|
||||
borderColor: "var(--gcmp-border-color)",
|
||||
},
|
||||
"@media (prefers-color-scheme: dark)": {
|
||||
"*": {
|
||||
borderColor: "var(--gcmp-invert-border-color)",
|
||||
},
|
||||
},
|
||||
"*:focus": {
|
||||
outline: "none",
|
||||
},
|
||||
|
||||
2
examples/clerk/.gitignore
vendored
@@ -22,3 +22,5 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
playwright-report
|
||||
@@ -1,5 +1,92 @@
|
||||
# minimal-auth-clerk
|
||||
|
||||
## 0.0.81
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.13
|
||||
- jazz-react-auth-clerk@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.80
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
- jazz-react-auth-clerk@0.13.12
|
||||
|
||||
## 0.0.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
- jazz-react-auth-clerk@0.13.11
|
||||
|
||||
## 0.0.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.10
|
||||
- jazz-react-auth-clerk@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
- jazz-react-auth-clerk@0.13.9
|
||||
|
||||
## 0.0.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react-auth-clerk@0.13.8
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
- jazz-react-auth-clerk@0.13.7
|
||||
|
||||
## 0.0.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
- jazz-react-auth-clerk@0.13.5
|
||||
|
||||
## 0.0.73
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react-auth-clerk@0.13.4
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 0.0.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
- jazz-react-auth-clerk@0.13.3
|
||||
|
||||
## 0.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"name": "clerk",
|
||||
"private": true,
|
||||
"version": "0.0.71",
|
||||
"version": "0.0.81",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"format-and-lint": "biome check .",
|
||||
"format-and-lint:fix": "biome check . --write"
|
||||
"format-and-lint:fix": "biome check . --write",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clerk/clerk-react": "^5.4.1",
|
||||
@@ -19,12 +21,13 @@
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"globals": "^15.11.0",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
53
examples/clerk/playwright.config.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import isCI from "is-ci";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: "http://localhost:5173/",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
permissions: ["clipboard-read", "clipboard-write"],
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: [
|
||||
{
|
||||
command: "pnpm preview --port 5173",
|
||||
url: "http://localhost:5173/",
|
||||
reuseExistingServer: !isCI,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SignInButton } from "@clerk/clerk-react";
|
||||
import { SignInButton, SignOutButton } from "@clerk/clerk-react";
|
||||
import { useAccount, useIsAuthenticated } from "jazz-react";
|
||||
|
||||
function App() {
|
||||
const { me, logOut } = useAccount();
|
||||
const { me } = useAccount();
|
||||
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
|
||||
@@ -11,7 +11,7 @@ function App() {
|
||||
<div className="container">
|
||||
<h1>You're logged in</h1>
|
||||
<p>Welcome back, {me?.profile?.name}</p>
|
||||
<button onClick={() => logOut()}>Logout</button>
|
||||
<SignOutButton>Logout</SignOutButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ClerkProvider, useClerk } from "@clerk/clerk-react";
|
||||
import { ClerkProvider, SignOutButton, useClerk } from "@clerk/clerk-react";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App.tsx";
|
||||
@@ -28,12 +28,23 @@ function JazzProvider({ children }: { children: React.ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
||||
<JazzProvider>
|
||||
<App />
|
||||
</JazzProvider>
|
||||
</ClerkProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
// Route to test that when the Clerk user expires, the app is logged out
|
||||
if (location.search.includes("expirationTest")) {
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
||||
<SignOutButton>Simulate expiration</SignOutButton>
|
||||
</ClerkProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
} else {
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/">
|
||||
<JazzProvider>
|
||||
<App />
|
||||
</JazzProvider>
|
||||
</ClerkProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
}
|
||||
|
||||
36
examples/clerk/tests/expiration.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("login & expiration", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
|
||||
expect(page.getByText("You're not logged in")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Email address" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Password" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page.waitForURL("/");
|
||||
|
||||
await page.getByText("You're logged in").waitFor({ state: "visible" });
|
||||
|
||||
expect(page.getByText("You're logged in")).toBeVisible();
|
||||
|
||||
await page.goto("/?expirationTest");
|
||||
|
||||
// Simulate expiration by logging out outside of Jazz
|
||||
await page.getByRole("button", { name: "Simulate expiration" }).click();
|
||||
|
||||
await page.goto("/");
|
||||
|
||||
await page.getByText("You're not logged in").waitFor({ state: "visible" });
|
||||
});
|
||||
33
examples/clerk/tests/logout.spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("login & logout", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
|
||||
expect(page.getByText("You're not logged in")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Email address" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Password" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page.waitForURL("/");
|
||||
|
||||
await page.getByText("You're logged in").waitFor({ state: "visible" });
|
||||
|
||||
expect(page.getByText("You're logged in")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Logout" }).click();
|
||||
|
||||
await page.getByText("You're not logged in").waitFor({ state: "visible" });
|
||||
|
||||
expect(page.getByText("You're not logged in")).toBeVisible();
|
||||
});
|
||||
33
examples/clerk/tests/reload.spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("login & reload", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
|
||||
expect(page.getByText("You're not logged in")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Email address" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page
|
||||
.getByRole("textbox", { name: "Password" })
|
||||
.fill("guido+clerk-test@garden.co");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page.waitForURL("/");
|
||||
|
||||
await page.getByText("You're logged in").waitFor({ state: "visible" });
|
||||
|
||||
expect(page.getByText("You're logged in")).toBeVisible();
|
||||
|
||||
await page.reload();
|
||||
|
||||
await page.getByText("You're logged in").waitFor({ state: "visible" });
|
||||
|
||||
expect(page.getByText("You're logged in")).toBeVisible();
|
||||
});
|
||||
@@ -1,5 +1,76 @@
|
||||
# file-share-svelte
|
||||
|
||||
## 0.0.64
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-svelte@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.63
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-svelte@0.13.12
|
||||
|
||||
## 0.0.62
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-svelte@0.13.11
|
||||
|
||||
## 0.0.61
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-svelte@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.60
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-svelte@0.13.9
|
||||
|
||||
## 0.0.59
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-svelte@0.13.7
|
||||
|
||||
## 0.0.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-svelte@0.13.5
|
||||
|
||||
## 0.0.57
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-svelte@0.13.4
|
||||
|
||||
## 0.0.56
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-svelte@0.13.3
|
||||
|
||||
## 0.0.55
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "file-share-svelte",
|
||||
"version": "0.0.55",
|
||||
"version": "0.0.64",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -33,9 +33,9 @@
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"typescript": "5.6.2",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^6.0.11"
|
||||
"vite": "6.0.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -1,5 +1,97 @@
|
||||
# jazz-tailwind-demo-auth-starter
|
||||
|
||||
## 0.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.13
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-inspector@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-inspector@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.10
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-inspector@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [22b5c4f]
|
||||
- Updated dependencies [31ea2ef]
|
||||
- Updated dependencies [4530c4a]
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-inspector@0.13.7
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c320615]
|
||||
- jazz-inspector@0.13.6
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [08ae9b2]
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-inspector@0.13.5
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-inspector@0.13.4
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- Updated dependencies [017f6c8]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-inspector@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en" class="h-full">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="icon" type="image/png" href="./public/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Jazz | React + Demo Auth + Tailwind</title>
|
||||
</head>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "filestream",
|
||||
"private": true,
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.21",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -27,7 +27,7 @@
|
||||
"is-ci": "^3.0.1",
|
||||
"postcss": "^8.5.3",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
examples/filestream/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -14,7 +14,7 @@ export function Logo() {
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M136.179 44.8277C136.179 44.8277 136.179 44.8277 136.179 44.8276V21.168C117.931 28.5527 97.9854 32.6192 77.0897 32.6192C65.1466 32.6192 53.5138 31.2908 42.331 28.7737V51.4076C42.331 51.4076 42.331 51.4076 42.331 51.4076V81.1508C41.2955 80.4385 40.1568 79.8458 38.9405 79.3915C36.1732 78.358 33.128 78.0876 30.1902 78.6145C27.2524 79.1414 24.5539 80.4419 22.4358 82.3516C20.3178 84.2613 18.8754 86.6944 18.291 89.3433C17.7066 91.9921 18.0066 94.7377 19.1528 97.2329C20.2991 99.728 22.2403 101.861 24.7308 103.361C27.2214 104.862 30.1495 105.662 33.1448 105.662H33.1455C33.6061 105.662 33.8365 105.662 34.0314 105.659C44.5583 105.449 53.042 96.9656 53.2513 86.4386C53.2534 86.3306 53.2544 86.2116 53.2548 86.0486H53.2552V85.7149L53.2552 85.5521V82.0762L53.2552 53.1993C61.0533 54.2324 69.0092 54.7656 77.0897 54.7656C77.6696 54.7656 78.2489 54.7629 78.8276 54.7574V110.696C77.792 109.983 76.6533 109.391 75.437 108.936C72.6697 107.903 69.6246 107.632 66.6867 108.159C63.7489 108.686 61.0504 109.987 58.9323 111.896C56.8143 113.806 55.3719 116.239 54.7875 118.888C54.2032 121.537 54.5031 124.283 55.6494 126.778C56.7956 129.273 58.7368 131.405 61.2273 132.906C63.7179 134.406 66.646 135.207 69.6414 135.207C70.1024 135.207 70.3329 135.207 70.5279 135.203C81.0548 134.994 89.5385 126.51 89.7478 115.983C89.7517 115.788 89.7517 115.558 89.7517 115.097V111.621L89.7517 54.3266C101.962 53.4768 113.837 51.4075 125.255 48.2397V80.9017C124.219 80.1894 123.081 79.5966 121.864 79.1424C119.097 78.1089 116.052 77.8384 113.114 78.3653C110.176 78.8922 107.478 80.1927 105.36 82.1025C103.242 84.0122 101.799 86.4453 101.215 89.0941C100.631 91.743 100.931 94.4886 102.077 96.9837C103.223 99.4789 105.164 101.612 107.655 103.112C110.145 104.612 113.073 105.413 116.069 105.413C116.53 105.413 116.76 105.413 116.955 105.409C127.482 105.2 135.966 96.7164 136.175 86.1895C136.179 85.9945 136.179 85.764 136.179 85.3029V81.8271L136.179 44.8277Z"
|
||||
fill="#3313F7"
|
||||
fill="#146AFF"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,76 @@
|
||||
# form
|
||||
|
||||
## 0.1.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.1.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.1.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.1.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.1.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 0.1.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Jazz | Form example</title>
|
||||
<link rel="icon" type="image/png" href="./public/favicon.ico">
|
||||
</head>
|
||||
<body class="h-full flex flex-col bg-white text-stone-700 dark:text-stone-400 dark:bg-stone-925">
|
||||
<div id="root" class="align-self-center flex-1"></div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "form",
|
||||
"private": true,
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.22",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -29,7 +29,7 @@
|
||||
"is-ci": "^3.0.1",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
examples/form/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -12,14 +12,14 @@ export function Orders() {
|
||||
<section className="space-y-5">
|
||||
<a
|
||||
href={`/#/order`}
|
||||
className="block relative p-3 bg-white border text-center rounded-md dark:bg-stone-900"
|
||||
className="block relative p-3 bg-white border border-stone-200 text-center rounded-md dark:bg-stone-900 dark:border-stone-900"
|
||||
>
|
||||
<strong>Add new order</strong>
|
||||
<DraftIndicator />
|
||||
</a>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h1 className="text-lg pb-2 border-b mb-3">
|
||||
<h1 className="text-lg pb-2 border-b mb-3 border-stone-200 dark:border-stone-700">
|
||||
<strong>Your orders 🧋</strong>
|
||||
</h1>
|
||||
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--border-default: theme("colors.stone.200");
|
||||
}
|
||||
|
||||
.dark {
|
||||
--border-default: theme("colors.stone.900");
|
||||
}
|
||||
|
||||
@layer components {
|
||||
strong {
|
||||
@apply font-semibold text-stone-900 dark:text-white;
|
||||
|
||||
@@ -34,6 +34,9 @@ const config: Config = {
|
||||
colors: {
|
||||
stone: stonePaletteWithAlpha,
|
||||
},
|
||||
borderColor: {
|
||||
default: "var(--border-default)",
|
||||
},
|
||||
container: {
|
||||
center: true,
|
||||
padding: {
|
||||
@@ -52,18 +55,6 @@ const config: Config = {
|
||||
formsPlugin,
|
||||
plugin(({ addBase }) =>
|
||||
addBase({
|
||||
":root": {
|
||||
"--gcmp-border-color": stonePalette[200],
|
||||
"--gcmp-invert-border-color": stonePalette[900],
|
||||
},
|
||||
"*": {
|
||||
borderColor: "var(--gcmp-border-color)",
|
||||
},
|
||||
"@media (prefers-color-scheme: dark)": {
|
||||
"*": {
|
||||
borderColor: "var(--gcmp-invert-border-color)",
|
||||
},
|
||||
},
|
||||
"*:focus": {
|
||||
outline: "none",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,76 @@
|
||||
# image-upload
|
||||
|
||||
## 0.0.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.0.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.0.73
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.0.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 0.0.70
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.0.69
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Jazz | Image upload example</title>
|
||||
<link rel="icon" href="./public/favicon.ico" type="image/png">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-upload",
|
||||
"private": true,
|
||||
"version": "0.0.69",
|
||||
"version": "0.0.78",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -22,8 +22,8 @@
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"globals": "^15.11.0",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11",
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17"
|
||||
|
||||
BIN
examples/image-upload/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -1,5 +1,98 @@
|
||||
# jazz-example-inspector
|
||||
|
||||
## 0.0.132
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ec9cb40]
|
||||
- cojson@0.13.13
|
||||
- cojson-transport-ws@0.13.13
|
||||
- jazz-inspector@0.13.13
|
||||
|
||||
## 0.0.131
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [65719f2]
|
||||
- cojson@0.13.12
|
||||
- jazz-inspector@0.13.12
|
||||
- cojson-transport-ws@0.13.12
|
||||
|
||||
## 0.0.130
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- Updated dependencies [3396ed4]
|
||||
- Updated dependencies [267ea4c]
|
||||
- cojson@0.13.11
|
||||
- cojson-transport-ws@0.13.11
|
||||
- jazz-inspector@0.13.11
|
||||
|
||||
## 0.0.129
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f837cfe]
|
||||
- cojson@0.13.10
|
||||
- cojson-transport-ws@0.13.10
|
||||
- jazz-inspector@0.13.10
|
||||
|
||||
## 0.0.128
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.9
|
||||
|
||||
## 0.0.127
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4530c4a: improve preview of Account types
|
||||
- Updated dependencies [22b5c4f]
|
||||
- Updated dependencies [31ea2ef]
|
||||
- Updated dependencies [4530c4a]
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- Updated dependencies [4e9aae1]
|
||||
- Updated dependencies [21c935c]
|
||||
- Updated dependencies [aa1c80e]
|
||||
- Updated dependencies [13074be]
|
||||
- jazz-inspector@0.13.7
|
||||
- cojson@0.13.7
|
||||
- cojson-transport-ws@0.13.7
|
||||
|
||||
## 0.0.126
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c320615]
|
||||
- jazz-inspector@0.13.6
|
||||
|
||||
## 0.0.125
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [08ae9b2]
|
||||
- Updated dependencies [e090b39]
|
||||
- jazz-inspector@0.13.5
|
||||
- cojson@0.13.5
|
||||
- cojson-transport-ws@0.13.5
|
||||
|
||||
## 0.0.124
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.4
|
||||
|
||||
## 0.0.123
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b19cab7]
|
||||
- Updated dependencies [017f6c8]
|
||||
- cojson-transport-ws@0.13.3
|
||||
- jazz-inspector@0.13.3
|
||||
|
||||
## 0.0.122
|
||||
|
||||
### Patch Changes
|
||||
|
||||
BIN
examples/inspector/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-inspector-app",
|
||||
"private": true,
|
||||
"version": "0.0.122",
|
||||
"version": "0.0.132",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -30,7 +30,7 @@
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -18,7 +18,7 @@ import {
|
||||
PageStack,
|
||||
Select,
|
||||
} from "jazz-inspector";
|
||||
import { resolveCoValue, useResolvedCoValue } from "jazz-inspector";
|
||||
import { AccountOrGroupText } from "jazz-inspector";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { usePagePath } from "./use-page-path";
|
||||
|
||||
@@ -239,7 +239,7 @@ function AccountSwitcher({
|
||||
{accounts.map((account) => (
|
||||
<option key={account.id} value={account.id}>
|
||||
{localNode ? (
|
||||
<AccountNameDisplay accountId={account.id} node={localNode} />
|
||||
<AccountOrGroupText coId={account.id} showId node={localNode} />
|
||||
) : (
|
||||
account.id
|
||||
)}
|
||||
@@ -311,31 +311,3 @@ function AddAccountForm({
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function AccountNameDisplay({
|
||||
accountId,
|
||||
node,
|
||||
}: {
|
||||
accountId: CoID<RawAccount>;
|
||||
node: LocalNode;
|
||||
}) {
|
||||
const { snapshot } = useResolvedCoValue(accountId, node);
|
||||
const [name, setName] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (snapshot && typeof snapshot === "object" && "profile" in snapshot) {
|
||||
const profileId = snapshot.profile as CoID<RawCoValue>;
|
||||
resolveCoValue(profileId, node).then((profileResult) => {
|
||||
if (
|
||||
profileResult.snapshot &&
|
||||
typeof profileResult.snapshot === "object" &&
|
||||
"name" in profileResult.snapshot
|
||||
) {
|
||||
setName(profileResult.snapshot.name as string);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [snapshot, node]);
|
||||
|
||||
return name ? `${name} <${accountId}>` : accountId;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const config: Config = {
|
||||
800: "#2A12BE",
|
||||
900: "#12046A",
|
||||
950: "#1e1b4b",
|
||||
DEFAULT: "#3313F7",
|
||||
DEFAULT: "#146AFF",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
2
examples/jazz-paper-scissors/.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
VITE_JAZZ_WORKER_ACCOUNT=
|
||||
JAZZ_WORKER_SECRET=
|
||||
3
examples/jazz-paper-scissors/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
dist
|
||||
|
||||
.env
|
||||
8
examples/jazz-paper-scissors/.prettierignore
Normal file
@@ -0,0 +1,8 @@
|
||||
# Ignore artifacts:
|
||||
build
|
||||
coverage
|
||||
|
||||
**/.git
|
||||
**/.svn
|
||||
**/.hg
|
||||
**/node_modules
|
||||
24
examples/jazz-paper-scissors/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Jazz Paper Scissors
|
||||
|
||||
## Setup
|
||||
|
||||
First of we need to create a new account for the dealer:
|
||||
|
||||
```bash
|
||||
pnpm generate-env
|
||||
```
|
||||
|
||||
This will generate a .env file like this one
|
||||
|
||||
```
|
||||
VITE_JAZZ_WORKER_ACCOUNT=co_zn95yzQd1z24DJCgayN53ShyuMR
|
||||
JAZZ_WORKER_SECRET=sealerSecret_z3Tcq41gtELJRHk3SzQutR2DhkpvEScQQP8DG8yeSh7zJ/signerSecret_zDsLhoNRSxjXrX6oSGzGH3XQQHDyp8QS292p28RToANYq
|
||||
```
|
||||
|
||||
This should be enough the setup everything
|
||||
|
||||
Then run pnpm dev to start both the local build and the worker
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
21
examples/jazz-paper-scissors/components.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"iconLibrary": "lucide"
|
||||
}
|
||||
21
examples/jazz-paper-scissors/generate-env.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as fs from "fs";
|
||||
import { createWorkerAccount } from "jazz-run/createWorkerAccount";
|
||||
|
||||
if (fs.existsSync(".env")) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const account = await createWorkerAccount({
|
||||
name: "jazz-paper-scissors-worker",
|
||||
peer: "wss://cloud.jazz.tools/?key=jazz-paper-scissors@garden.co",
|
||||
});
|
||||
|
||||
fs.writeFileSync(
|
||||
".env",
|
||||
`
|
||||
VITE_JAZZ_WORKER_ACCOUNT=${account.accountID}
|
||||
JAZZ_WORKER_SECRET=${account.agentSecret}
|
||||
`,
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
20
examples/jazz-paper-scissors/index.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-tsrouter-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<title>Jazz example - Jazz Paper Scissors</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
44
examples/jazz-paper-scissors/package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "jazz-paper-scissors",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "npm-run-all --parallel dev:web dev:worker",
|
||||
"dev:web": "vite",
|
||||
"dev:worker": "tsx --watch --env-file=.env ./src/worker.ts",
|
||||
"build": "vite build && tsc",
|
||||
"serve": "vite preview",
|
||||
"generate-env": "tsx generate-env.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
"@radix-ui/react-separator": "^1.1.2",
|
||||
"@radix-ui/react-slot": "^1.1.2",
|
||||
"@tailwindcss/vite": "^4.0.17",
|
||||
"@tanstack/react-router": "^1.115.0",
|
||||
"@tanstack/react-router-devtools": "^1.114.29",
|
||||
"@tanstack/router-plugin": "^1.114.30",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"jazz-inspector": "workspace:*",
|
||||
"jazz-nodejs": "workspace:*",
|
||||
"jazz-react": "workspace:*",
|
||||
"jazz-tools": "workspace:*",
|
||||
"lucide-react": "^0.485.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"tailwind-merge": "^3.0.2",
|
||||
"tailwindcss": "^4.0.17",
|
||||
"tw-animate-css": "^1.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"jazz-run": "workspace:*",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
15
examples/jazz-paper-scissors/public/manifest.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "TanStack App",
|
||||
"name": "Create TanStack App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
3
examples/jazz-paper-scissors/public/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
33
examples/jazz-paper-scissors/src/app.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
||||
import { useAccount } from "jazz-react";
|
||||
import { routeTree } from "./routeTree.gen";
|
||||
|
||||
// Create a new router instance
|
||||
const router = createRouter({
|
||||
routeTree,
|
||||
context: {
|
||||
// @ts-expect-error - just a placeholder - me is set in the App component down below
|
||||
me: undefined,
|
||||
},
|
||||
defaultPreload: "intent",
|
||||
scrollRestoration: true,
|
||||
defaultStructuralSharing: true,
|
||||
defaultPreloadStaleTime: 0,
|
||||
});
|
||||
|
||||
// Register the router instance for type safety
|
||||
declare module "@tanstack/react-router" {
|
||||
interface Register {
|
||||
router: typeof router;
|
||||
}
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const { me } = useAccount();
|
||||
|
||||
if (!me) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
return <RouterProvider router={router} context={{ me }} />;
|
||||
}
|
||||
79
examples/jazz-paper-scissors/src/components/ui/button.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
import type * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Loader2Icon } from "lucide-react";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
outline:
|
||||
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||
ghost:
|
||||
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
||||
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
||||
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||
icon: "size-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
interface Props
|
||||
extends React.ComponentProps<"button">,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
loading?: boolean;
|
||||
loadingText?: string;
|
||||
}
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
loading = false,
|
||||
disabled,
|
||||
loadingText = "Loading...",
|
||||
children,
|
||||
...props
|
||||
}: Props) {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
disabled={loading || disabled}
|
||||
{...props}
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<Loader2Icon className="mr-2 h-4 w-4 animate-spin" />
|
||||
{loadingText}
|
||||
</>
|
||||
) : (
|
||||
children
|
||||
)}
|
||||
</Comp>
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, buttonVariants };
|
||||
109
examples/jazz-paper-scissors/src/components/ui/card.tsx
Normal file
@@ -0,0 +1,109 @@
|
||||
import type * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
className={cn(
|
||||
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn("leading-none font-semibold", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-muted-foreground text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardSmall({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-small"
|
||||
className={cn(
|
||||
"sm-card grid grid-flow-col justify-items-center gap-6 rounded-xl border py-6 shadow-sm m-4",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-6", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center px-6 [.border-t]:pt-6 border-t",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardSmall,
|
||||
};
|
||||
21
examples/jazz-paper-scissors/src/components/ui/input.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
||||
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Input };
|
||||
@@ -0,0 +1,13 @@
|
||||
import { JazzProvider } from "jazz-react";
|
||||
|
||||
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<JazzProvider
|
||||
sync={{
|
||||
peer: "wss://cloud.jazz.tools/?key=jazz-paper-scissors@garden.co",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</JazzProvider>
|
||||
);
|
||||
}
|
||||
22
examples/jazz-paper-scissors/src/components/ui/label.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Label({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||
return (
|
||||
<LabelPrimitive.Root
|
||||
data-slot="label"
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Label };
|
||||
28
examples/jazz-paper-scissors/src/components/ui/separator.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Separator({
|
||||
className,
|
||||
orientation = "horizontal",
|
||||
decorative = true,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
||||
return (
|
||||
<SeparatorPrimitive.Root
|
||||
data-slot="separator-root"
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Separator };
|
||||
5
examples/jazz-paper-scissors/src/constants.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
if (!import.meta.env.VITE_JAZZ_WORKER_ACCOUNT) {
|
||||
throw new Error(".env missing, run `pnpm generate-env`");
|
||||
}
|
||||
|
||||
export const WORKER_ID = import.meta.env.VITE_JAZZ_WORKER_ACCOUNT;
|
||||
120
examples/jazz-paper-scissors/src/index.css
Normal file
@@ -0,0 +1,120 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
:root {
|
||||
--radius: 0.625rem;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
23
examples/jazz-paper-scissors/src/lib/utils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a player selections, returns the winner of the current game.
|
||||
*/
|
||||
export function determineWinner(player1Choice: string, player2Choice: string) {
|
||||
if (player1Choice === player2Choice) {
|
||||
return "draw";
|
||||
} else if (
|
||||
(player1Choice === "rock" && player2Choice === "scissors") ||
|
||||
(player1Choice === "paper" && player2Choice === "rock") ||
|
||||
(player1Choice === "scissors" && player2Choice === "paper")
|
||||
) {
|
||||
return "player1";
|
||||
} else {
|
||||
return "player2";
|
||||
}
|
||||
}
|
||||
24
examples/jazz-paper-scissors/src/main.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { JazzInspector } from "jazz-inspector";
|
||||
import { StrictMode } from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import "./index.css";
|
||||
import { JazzProvider } from "jazz-react";
|
||||
import { App } from "./app";
|
||||
|
||||
const rootElement = document.getElementById("app");
|
||||
if (rootElement && !rootElement.innerHTML) {
|
||||
const root = ReactDOM.createRoot(rootElement);
|
||||
root.render(
|
||||
<StrictMode>
|
||||
<JazzProvider
|
||||
sync={{
|
||||
peer: "wss://cloud.jazz.tools/?key=jazz-paper-scissors@garden.co",
|
||||
}}
|
||||
>
|
||||
<JazzInspector />
|
||||
<App />
|
||||
</JazzProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
}
|
||||
177
examples/jazz-paper-scissors/src/routeTree.gen.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// @ts-nocheck
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
|
||||
// This file was automatically generated by TanStack Router.
|
||||
// You should NOT make any changes in this file as it will be overwritten.
|
||||
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
||||
|
||||
// Import Routes
|
||||
|
||||
import { Route as rootRoute } from "./routes/__root";
|
||||
import { Route as AuthenticatedImport } from "./routes/_authenticated";
|
||||
import { Route as IndexImport } from "./routes/index";
|
||||
import { Route as AuthenticatedWaitingRoomWaitingRoomIdImport } from "./routes/_authenticated/waiting-room.$waitingRoomId";
|
||||
import { Route as AuthenticatedGameGameIdImport } from "./routes/_authenticated/game.$gameId";
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
const AuthenticatedRoute = AuthenticatedImport.update({
|
||||
id: "/_authenticated",
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any);
|
||||
|
||||
const IndexRoute = IndexImport.update({
|
||||
id: "/",
|
||||
path: "/",
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any);
|
||||
|
||||
const AuthenticatedWaitingRoomWaitingRoomIdRoute =
|
||||
AuthenticatedWaitingRoomWaitingRoomIdImport.update({
|
||||
id: "/waiting-room/$waitingRoomId",
|
||||
path: "/waiting-room/$waitingRoomId",
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any);
|
||||
|
||||
const AuthenticatedGameGameIdRoute = AuthenticatedGameGameIdImport.update({
|
||||
id: "/game/$gameId",
|
||||
path: "/game/$gameId",
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any);
|
||||
|
||||
// Populate the FileRoutesByPath interface
|
||||
|
||||
declare module "@tanstack/react-router" {
|
||||
interface FileRoutesByPath {
|
||||
"/": {
|
||||
id: "/";
|
||||
path: "/";
|
||||
fullPath: "/";
|
||||
preLoaderRoute: typeof IndexImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
"/_authenticated": {
|
||||
id: "/_authenticated";
|
||||
path: "";
|
||||
fullPath: "";
|
||||
preLoaderRoute: typeof AuthenticatedImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
"/_authenticated/game/$gameId": {
|
||||
id: "/_authenticated/game/$gameId";
|
||||
path: "/game/$gameId";
|
||||
fullPath: "/game/$gameId";
|
||||
preLoaderRoute: typeof AuthenticatedGameGameIdImport;
|
||||
parentRoute: typeof AuthenticatedImport;
|
||||
};
|
||||
"/_authenticated/waiting-room/$waitingRoomId": {
|
||||
id: "/_authenticated/waiting-room/$waitingRoomId";
|
||||
path: "/waiting-room/$waitingRoomId";
|
||||
fullPath: "/waiting-room/$waitingRoomId";
|
||||
preLoaderRoute: typeof AuthenticatedWaitingRoomWaitingRoomIdImport;
|
||||
parentRoute: typeof AuthenticatedImport;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export the route tree
|
||||
|
||||
interface AuthenticatedRouteChildren {
|
||||
AuthenticatedGameGameIdRoute: typeof AuthenticatedGameGameIdRoute;
|
||||
AuthenticatedWaitingRoomWaitingRoomIdRoute: typeof AuthenticatedWaitingRoomWaitingRoomIdRoute;
|
||||
}
|
||||
|
||||
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
||||
AuthenticatedGameGameIdRoute: AuthenticatedGameGameIdRoute,
|
||||
AuthenticatedWaitingRoomWaitingRoomIdRoute:
|
||||
AuthenticatedWaitingRoomWaitingRoomIdRoute,
|
||||
};
|
||||
|
||||
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||
AuthenticatedRouteChildren,
|
||||
);
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
"/": typeof IndexRoute;
|
||||
"": typeof AuthenticatedRouteWithChildren;
|
||||
"/game/$gameId": typeof AuthenticatedGameGameIdRoute;
|
||||
"/waiting-room/$waitingRoomId": typeof AuthenticatedWaitingRoomWaitingRoomIdRoute;
|
||||
}
|
||||
|
||||
export interface FileRoutesByTo {
|
||||
"/": typeof IndexRoute;
|
||||
"": typeof AuthenticatedRouteWithChildren;
|
||||
"/game/$gameId": typeof AuthenticatedGameGameIdRoute;
|
||||
"/waiting-room/$waitingRoomId": typeof AuthenticatedWaitingRoomWaitingRoomIdRoute;
|
||||
}
|
||||
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRoute;
|
||||
"/": typeof IndexRoute;
|
||||
"/_authenticated": typeof AuthenticatedRouteWithChildren;
|
||||
"/_authenticated/game/$gameId": typeof AuthenticatedGameGameIdRoute;
|
||||
"/_authenticated/waiting-room/$waitingRoomId": typeof AuthenticatedWaitingRoomWaitingRoomIdRoute;
|
||||
}
|
||||
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath;
|
||||
fullPaths: "/" | "" | "/game/$gameId" | "/waiting-room/$waitingRoomId";
|
||||
fileRoutesByTo: FileRoutesByTo;
|
||||
to: "/" | "" | "/game/$gameId" | "/waiting-room/$waitingRoomId";
|
||||
id:
|
||||
| "__root__"
|
||||
| "/"
|
||||
| "/_authenticated"
|
||||
| "/_authenticated/game/$gameId"
|
||||
| "/_authenticated/waiting-room/$waitingRoomId";
|
||||
fileRoutesById: FileRoutesById;
|
||||
}
|
||||
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute;
|
||||
AuthenticatedRoute: typeof AuthenticatedRouteWithChildren;
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
AuthenticatedRoute: AuthenticatedRouteWithChildren,
|
||||
};
|
||||
|
||||
export const routeTree = rootRoute
|
||||
._addFileChildren(rootRouteChildren)
|
||||
._addFileTypes<FileRouteTypes>();
|
||||
|
||||
/* ROUTE_MANIFEST_START
|
||||
{
|
||||
"routes": {
|
||||
"__root__": {
|
||||
"filePath": "__root.tsx",
|
||||
"children": [
|
||||
"/",
|
||||
"/_authenticated"
|
||||
]
|
||||
},
|
||||
"/": {
|
||||
"filePath": "index.tsx"
|
||||
},
|
||||
"/_authenticated": {
|
||||
"filePath": "_authenticated.tsx",
|
||||
"children": [
|
||||
"/_authenticated/game/$gameId",
|
||||
"/_authenticated/waiting-room/$waitingRoomId"
|
||||
]
|
||||
},
|
||||
"/_authenticated/game/$gameId": {
|
||||
"filePath": "_authenticated/game.$gameId.tsx",
|
||||
"parent": "/_authenticated"
|
||||
},
|
||||
"/_authenticated/waiting-room/$waitingRoomId": {
|
||||
"filePath": "_authenticated/waiting-room.$waitingRoomId.tsx",
|
||||
"parent": "/_authenticated"
|
||||
}
|
||||
}
|
||||
}
|
||||
ROUTE_MANIFEST_END */
|
||||
19
examples/jazz-paper-scissors/src/routes/__root.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Outlet, createRootRouteWithContext } from "@tanstack/react-router";
|
||||
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
||||
import type { Account } from "jazz-tools";
|
||||
import { JazzAndAuth } from "../components/ui/jazz-and-auth";
|
||||
|
||||
interface RouterContext {
|
||||
me: Account;
|
||||
}
|
||||
|
||||
export const Route = createRootRouteWithContext<RouterContext>()({
|
||||
component: () => (
|
||||
<>
|
||||
<JazzAndAuth>
|
||||
<Outlet />
|
||||
<TanStackRouterDevtools />
|
||||
</JazzAndAuth>
|
||||
</>
|
||||
),
|
||||
});
|
||||
12
examples/jazz-paper-scissors/src/routes/_authenticated.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Outlet, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_authenticated")({
|
||||
component: RouteComponent,
|
||||
beforeLoad: ({ context }) => {
|
||||
return context;
|
||||
},
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return <Outlet />;
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
CardSmall,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { WORKER_ID } from "@/constants";
|
||||
import { Game, NewGameIntent, PlayIntent } from "@/schema";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { experimental_useInboxSender, useCoState } from "jazz-react";
|
||||
import { type ID } from "jazz-tools";
|
||||
import { Badge, CircleHelp, Scissors, ScrollText } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const playIcon = (selection: string | undefined) => {
|
||||
switch (selection) {
|
||||
case "rock":
|
||||
return <Badge className="w-5 h-5" />;
|
||||
case "paper":
|
||||
return <ScrollText className="w-5 h-5" />;
|
||||
case "scissors":
|
||||
return <Scissors className="w-5 h-5" />;
|
||||
default:
|
||||
return <CircleHelp className="w-5 h-5" />;
|
||||
}
|
||||
};
|
||||
|
||||
export const Route = createFileRoute("/_authenticated/game/$gameId")({
|
||||
component: RouteComponent,
|
||||
loader: async ({ context: { me }, params: { gameId } }) => {
|
||||
const game = await Game.load(gameId as ID<Game>, {
|
||||
resolve: {
|
||||
player1: true,
|
||||
player2: true,
|
||||
},
|
||||
});
|
||||
if (!game) {
|
||||
throw redirect({ to: "/" });
|
||||
}
|
||||
|
||||
return { gameId, me, loaderGame: game };
|
||||
},
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const { gameId, me, loaderGame } = Route.useLoaderData();
|
||||
|
||||
const isPlayer1 = loaderGame.player1?.account?.isMe;
|
||||
const player = isPlayer1 ? "player1" : "player2";
|
||||
|
||||
const [playSelection, setPlaySelection] = useState(
|
||||
loaderGame[player]?.playSelection ?? "",
|
||||
);
|
||||
const sendInboxMessage = experimental_useInboxSender(WORKER_ID);
|
||||
|
||||
const game = useCoState(Game, gameId as ID<Game>);
|
||||
|
||||
useEffect(() => {
|
||||
let gameCompleted = Boolean(loaderGame.outcome);
|
||||
|
||||
return loaderGame.subscribe((game) => {
|
||||
if (gameCompleted && !game.outcome) {
|
||||
setPlaySelection(""); // Reset play selection when one player clicks on "Start a new game"
|
||||
}
|
||||
|
||||
gameCompleted = Boolean(game.outcome);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const gameComplete = game.outcome !== undefined;
|
||||
|
||||
const opponent = isPlayer1 ? "player2" : "player1";
|
||||
|
||||
const currentPlayer = game[player];
|
||||
const opponentPlayer = game[opponent];
|
||||
|
||||
const opponentSelection = opponentPlayer?.playSelection;
|
||||
|
||||
const onSubmit = async (playSelection: string) => {
|
||||
sendInboxMessage(
|
||||
PlayIntent.create({ type: "play", gameId, player, playSelection }),
|
||||
);
|
||||
};
|
||||
|
||||
const onNewGame = async () => {
|
||||
sendInboxMessage(NewGameIntent.create({ type: "newGame", gameId }));
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="mx-auto max-w-5xl">
|
||||
<div className="mx-auto text-center">
|
||||
<CardHeader>
|
||||
<CardTitle>Jazz, Paper, Scissors!</CardTitle>
|
||||
<span>Welcome {isPlayer1 ? "Player 1" : "Player 2"}</span>
|
||||
<span>
|
||||
{game?.player1Score ?? 0} - {game?.player2Score ?? 0}
|
||||
</span>
|
||||
</CardHeader>
|
||||
{gameComplete ? (
|
||||
<>
|
||||
<div className="border">
|
||||
Game Over,{" "}
|
||||
{game?.outcome === player
|
||||
? "You Win!"
|
||||
: game?.outcome === "draw"
|
||||
? "It's a Draw!"
|
||||
: "You Lose!"}
|
||||
</div>
|
||||
<Button onClick={onNewGame}>Start a new game</Button>
|
||||
</>
|
||||
) : null}
|
||||
<CardContent>
|
||||
<div>
|
||||
{playSelection === "" ? "Make Your Selection" : "Your Selection: "}
|
||||
</div>
|
||||
<CardSmall>{playIcon(playSelection)}</CardSmall>
|
||||
{gameComplete ? null : (
|
||||
<>
|
||||
<dl className="grid grid-cols-3 gap-x-8 gap-y-16 text-center">
|
||||
<Button
|
||||
variant={"outline"}
|
||||
size={"icon"}
|
||||
onClick={() => setPlaySelection("rock")}
|
||||
>
|
||||
<Badge className="w-5 h-5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
size={"icon"}
|
||||
onClick={() => setPlaySelection("paper")}
|
||||
>
|
||||
<ScrollText className="w-5 h-5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
size={"icon"}
|
||||
onClick={() => setPlaySelection("scissors")}
|
||||
>
|
||||
<Scissors className="w-5 h-5" />
|
||||
</Button>
|
||||
</dl>
|
||||
<div className="m-4">
|
||||
<Button
|
||||
disabled={
|
||||
playSelection === "" ||
|
||||
Boolean(currentPlayer?.playSelection)
|
||||
}
|
||||
onClick={() => onSubmit(playSelection)}
|
||||
>
|
||||
Go!
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div>Your Opponent Selected:</div>
|
||||
<CardSmall>{playIcon(opponentSelection)}</CardSmall>
|
||||
</CardContent>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { WORKER_ID } from "@/constants";
|
||||
import { JoinGameRequest, WaitingRoom } from "@/schema";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { Group, type ID, InboxSender } from "jazz-tools";
|
||||
import { ClipboardCopyIcon, Loader2Icon } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const Route = createFileRoute(
|
||||
"/_authenticated/waiting-room/$waitingRoomId",
|
||||
)({
|
||||
component: RouteComponent,
|
||||
loader: async ({ context: { me }, params: { waitingRoomId } }) => {
|
||||
const waitingRoom = await WaitingRoom.load(
|
||||
waitingRoomId as ID<WaitingRoom>,
|
||||
{
|
||||
resolve: {
|
||||
game: true,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!waitingRoom) {
|
||||
throw redirect({ to: "/" });
|
||||
}
|
||||
if (!waitingRoom?.account1?.isMe) {
|
||||
const sender = await InboxSender.load<JoinGameRequest, WaitingRoom>(
|
||||
WORKER_ID,
|
||||
me,
|
||||
// { account1: {}, account2: {}, me, game: {} },
|
||||
);
|
||||
sender.sendMessage(
|
||||
JoinGameRequest.create(
|
||||
{ type: "joinGame", waitingRoom },
|
||||
{ owner: Group.create({ owner: me }) },
|
||||
),
|
||||
);
|
||||
// If the waiting room already has a game, redirect to the game
|
||||
if (waitingRoom?.game) {
|
||||
throw redirect({ to: `/game/${waitingRoom.game.id}` as string });
|
||||
}
|
||||
}
|
||||
|
||||
return { waitingRoom };
|
||||
},
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const { waitingRoom } = Route.useLoaderData();
|
||||
const navigate = Route.useNavigate();
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!waitingRoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
return waitingRoom.subscribe(
|
||||
{
|
||||
resolve: {
|
||||
game: true,
|
||||
},
|
||||
},
|
||||
async () => {
|
||||
if (waitingRoom.game) {
|
||||
navigate({ to: `/game/${waitingRoom.game.id}` });
|
||||
}
|
||||
},
|
||||
);
|
||||
}, [waitingRoom]);
|
||||
|
||||
const onCopyClick = () => {
|
||||
navigator.clipboard.writeText(window.location.toString());
|
||||
setCopied(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-screen flex flex-col w-full place-items-center justify-center p-2">
|
||||
<Card className="w-[500px]">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center">
|
||||
<Loader2Icon className="animate-spin inline h-8 w-8 mr-2" />
|
||||
Waiting for opponent to join the game
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Share this link with your friend to join the game. The game will
|
||||
automatically start once they join.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex">
|
||||
<Input
|
||||
className="w-full border bg-muted rounded-e-none"
|
||||
readOnly
|
||||
value={`${window.location}`}
|
||||
/>
|
||||
<Button onClick={onCopyClick} className="rounded-s-none w-25">
|
||||
{copied ? (
|
||||
"Copied!"
|
||||
) : (
|
||||
<>
|
||||
<ClipboardCopyIcon className="w-5 h-5" />
|
||||
Copy
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
54
examples/jazz-paper-scissors/src/routes/index.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { WORKER_ID } from "@/constants";
|
||||
import { CreateGameRequest } from "@/schema";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { experimental_useInboxSender as useInboxSender } from "jazz-react";
|
||||
import { useState } from "react";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: HomeComponent,
|
||||
});
|
||||
|
||||
function HomeComponent() {
|
||||
const createGame = useInboxSender(WORKER_ID);
|
||||
const navigate = useNavigate({ from: "/" });
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const onNewGameClick = async () => {
|
||||
setIsLoading(true);
|
||||
|
||||
const waitingRoomId = await createGame(
|
||||
CreateGameRequest.create({
|
||||
type: "createGame",
|
||||
}),
|
||||
);
|
||||
if (!waitingRoomId) {
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
navigate({ to: `/waiting-room/$waitingRoomId`, params: { waitingRoomId } });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-screen flex flex-col w-full place-items-center justify-center p-2">
|
||||
<Card className="w-[500px]">
|
||||
<CardHeader>
|
||||
<CardTitle>Welcome to Jazz, Paper, Scissors!</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<div className="flex items-center p-4">
|
||||
<Button
|
||||
onClick={onNewGameClick}
|
||||
loading={isLoading}
|
||||
loadingText="Creating game..."
|
||||
className="w-full"
|
||||
>
|
||||
New Game
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
65
examples/jazz-paper-scissors/src/schema.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Account, CoMap, SchemaUnion, co } from "jazz-tools";
|
||||
|
||||
export class Game extends CoMap {
|
||||
player1 = co.ref(Player);
|
||||
player2? = co.ref(Player);
|
||||
outcome? = co.literal("player1", "player2", "draw");
|
||||
player1Score = co.number;
|
||||
player2Score = co.number;
|
||||
|
||||
/**
|
||||
* Given a player, returns the opponent in the current game.
|
||||
*/
|
||||
getOpponent(player: Player) {
|
||||
// TODO: player may be unrelated to this game
|
||||
const opponent =
|
||||
player.account?.id === this.player1?.account?.id
|
||||
? this.player2
|
||||
: this.player1;
|
||||
|
||||
if (!opponent) {
|
||||
throw new Error("Opponent not found");
|
||||
}
|
||||
|
||||
return opponent.ensureLoaded({
|
||||
// account: {},
|
||||
resolve: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class Player extends CoMap {
|
||||
account = co.ref(Account);
|
||||
playSelection? = co.string;
|
||||
}
|
||||
|
||||
export class WaitingRoom extends CoMap {
|
||||
account1 = co.ref(Account);
|
||||
account2 = co.optional.ref(Account);
|
||||
game = co.optional.ref(Game);
|
||||
}
|
||||
|
||||
export class InboxMessage extends CoMap {
|
||||
type = co.literal("play", "createGame", "joinGame", "newGame");
|
||||
}
|
||||
|
||||
export class PlayIntent extends InboxMessage {
|
||||
type = co.literal("play");
|
||||
gameId = co.string;
|
||||
player = co.literal("player1", "player2");
|
||||
playSelection = co.string;
|
||||
}
|
||||
|
||||
export class NewGameIntent extends InboxMessage {
|
||||
type = co.literal("newGame");
|
||||
gameId = co.string;
|
||||
}
|
||||
|
||||
export class CreateGameRequest extends InboxMessage {
|
||||
type = co.literal("createGame");
|
||||
}
|
||||
|
||||
export class JoinGameRequest extends InboxMessage {
|
||||
type = co.literal("joinGame");
|
||||
waitingRoom = co.ref(WaitingRoom);
|
||||
}
|
||||
201
examples/jazz-paper-scissors/src/worker.ts
Normal file
@@ -0,0 +1,201 @@
|
||||
import {
|
||||
Game,
|
||||
InboxMessage,
|
||||
JoinGameRequest,
|
||||
NewGameIntent,
|
||||
PlayIntent,
|
||||
Player,
|
||||
WaitingRoom,
|
||||
} from "@/schema";
|
||||
import { startWorker } from "jazz-nodejs";
|
||||
import { Account, Group, type ID } from "jazz-tools";
|
||||
import { determineWinner } from "./lib/utils";
|
||||
|
||||
if (!process.env.VITE_JAZZ_WORKER_ACCOUNT || !process.env.JAZZ_WORKER_SECRET) {
|
||||
throw new Error(".env missing, run `pnpm generate-env`");
|
||||
}
|
||||
|
||||
const {
|
||||
worker,
|
||||
experimental: { inbox },
|
||||
} = await startWorker({
|
||||
accountID: process.env.VITE_JAZZ_WORKER_ACCOUNT,
|
||||
syncServer: "wss://cloud.jazz.tools/?key=jazz-paper-scissors@garden.co ",
|
||||
});
|
||||
|
||||
inbox.subscribe(
|
||||
InboxMessage,
|
||||
async (message, senderID) => {
|
||||
const playerAccount = await Account.load(senderID, { loadAs: worker });
|
||||
if (!playerAccount) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (message.type) {
|
||||
case "play":
|
||||
handlePlayIntent(senderID, message.castAs(PlayIntent));
|
||||
break;
|
||||
|
||||
case "newGame":
|
||||
handleNewGameIntent(senderID, message.castAs(NewGameIntent));
|
||||
break;
|
||||
|
||||
case "createGame":
|
||||
const waitingRoomGroup = Group.create({ owner: worker });
|
||||
waitingRoomGroup.addMember("everyone", "reader");
|
||||
const waitingRoom = WaitingRoom.create(
|
||||
{ account1: playerAccount },
|
||||
{ owner: waitingRoomGroup },
|
||||
);
|
||||
|
||||
console.log("waiting room created with id:", waitingRoom.id);
|
||||
return waitingRoom;
|
||||
|
||||
case "joinGame":
|
||||
const joinGameRequest = message.castAs(JoinGameRequest);
|
||||
if (
|
||||
!joinGameRequest.waitingRoom ||
|
||||
!joinGameRequest.waitingRoom.account1
|
||||
) {
|
||||
console.error("No waiting room in join game request");
|
||||
return;
|
||||
}
|
||||
joinGameRequest.waitingRoom.account2 = playerAccount;
|
||||
|
||||
const game = await createGame({
|
||||
account1: joinGameRequest.waitingRoom.account1,
|
||||
account2: joinGameRequest.waitingRoom.account2,
|
||||
});
|
||||
console.log("game created with id:", game.id);
|
||||
|
||||
joinGameRequest.waitingRoom.game = game;
|
||||
return joinGameRequest.waitingRoom.game;
|
||||
}
|
||||
},
|
||||
{ retries: 3 },
|
||||
);
|
||||
|
||||
console.log("worker", worker.id, "started");
|
||||
|
||||
interface CreateGameParams {
|
||||
account1: Account;
|
||||
account2: Account;
|
||||
}
|
||||
|
||||
async function createGame({ account1, account2 }: CreateGameParams) {
|
||||
const publicReadOnly = Group.create({ owner: worker });
|
||||
publicReadOnly.addMember(account1, "reader");
|
||||
publicReadOnly.addMember(account2, "reader");
|
||||
|
||||
const player1 = createPlayer({ account: account1 });
|
||||
const player2 = createPlayer({ account: account2 });
|
||||
|
||||
const game = Game.create(
|
||||
{
|
||||
player1: player1,
|
||||
player2: player2,
|
||||
player1Score: 0,
|
||||
player2Score: 0,
|
||||
},
|
||||
{ owner: publicReadOnly },
|
||||
);
|
||||
|
||||
await game.waitForSync();
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
interface CreatePlayerParams {
|
||||
account: Account;
|
||||
}
|
||||
|
||||
function createPlayer({ account }: CreatePlayerParams) {
|
||||
const publicRead = Group.create({ owner: worker });
|
||||
publicRead.addMember("everyone", "reader");
|
||||
|
||||
const player = Player.create(
|
||||
{
|
||||
account,
|
||||
},
|
||||
{ owner: publicRead },
|
||||
);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
async function handleNewGameIntent(_: ID<Account>, message: NewGameIntent) {
|
||||
const gameId = message.gameId;
|
||||
|
||||
const game = await Game.load(gameId as ID<Game>, {
|
||||
loadAs: worker,
|
||||
resolve: {
|
||||
player1: true,
|
||||
player2: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!game) {
|
||||
throw new Error("Game not found");
|
||||
}
|
||||
|
||||
if (game.outcome) {
|
||||
game.outcome = undefined;
|
||||
game.player1.playSelection = undefined;
|
||||
|
||||
if (game.player2) {
|
||||
game.player2.playSelection = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePlayIntent(_: ID<Account>, message: PlayIntent) {
|
||||
// determine current player, update game with outcome
|
||||
const gameId = message.gameId;
|
||||
if (!gameId) {
|
||||
console.error("Game not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const game = await Game.load(gameId as ID<Game>, {
|
||||
loadAs: worker,
|
||||
resolve: {
|
||||
player1: true,
|
||||
player2: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!game) {
|
||||
throw new Error("Game not found");
|
||||
}
|
||||
|
||||
const currentPlayer = game[message.player as "player1" | "player2"];
|
||||
|
||||
if (!currentPlayer) {
|
||||
throw new Error("Player not found");
|
||||
}
|
||||
|
||||
if (currentPlayer.playSelection) {
|
||||
throw new Error("Player already made a selection");
|
||||
}
|
||||
|
||||
currentPlayer.playSelection = message.playSelection;
|
||||
|
||||
const player1Selection = game?.player1.playSelection;
|
||||
const player2Selection = game?.player2?.playSelection;
|
||||
|
||||
// once both players have a selection, determine the winner
|
||||
if (
|
||||
!!player1Selection &&
|
||||
player1Selection !== "" &&
|
||||
!!player2Selection &&
|
||||
player2Selection !== ""
|
||||
) {
|
||||
const outcome = determineWinner(player1Selection, player2Selection);
|
||||
game.outcome = outcome;
|
||||
if (outcome === "player1") {
|
||||
game.player1Score += 1;
|
||||
} else if (outcome === "player2") {
|
||||
game.player2Score += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
examples/jazz-paper-scissors/tsconfig.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"jsx": "react-jsx",
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"types": ["vite/client"],
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
18
examples/jazz-paper-scissors/vite.config.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { resolve } from "node:path";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
||||
import viteReact from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
TanStackRouterVite({ autoCodeSplitting: true }),
|
||||
viteReact(),
|
||||
tailwindcss(),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,3 @@
|
||||
VITE_CURSOR_FEED_ID=multi-cursors-250425-1708
|
||||
VITE_GROUP_ID=co_zXE8C8sd9QxEbxnt3neRvFRPFUc
|
||||
VITE_OLD_CURSOR_AGE_SECONDS=36000
|
||||
VITE_OLD_CURSOR_AGE_SECONDS=36000
|
||||
|
||||
@@ -1,5 +1,76 @@
|
||||
# multi-cursors
|
||||
|
||||
## 0.0.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.73
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.0.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.70
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.0.69
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.0.68
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.0.67
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 0.0.66
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.0.65
|
||||
|
||||
### Patch Changes
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "multi-cursors",
|
||||
"private": true,
|
||||
"version": "0.0.65",
|
||||
"version": "0.0.74",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -28,8 +28,8 @@
|
||||
"is-ci": "^3.0.1",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11",
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11",
|
||||
"vitest": "3.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export function Logo() {
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M136.179 44.8277C136.179 44.8277 136.179 44.8277 136.179 44.8276V21.168C117.931 28.5527 97.9854 32.6192 77.0897 32.6192C65.1466 32.6192 53.5138 31.2908 42.331 28.7737V51.4076C42.331 51.4076 42.331 51.4076 42.331 51.4076V81.1508C41.2955 80.4385 40.1568 79.8458 38.9405 79.3915C36.1732 78.358 33.128 78.0876 30.1902 78.6145C27.2524 79.1414 24.5539 80.4419 22.4358 82.3516C20.3178 84.2613 18.8754 86.6944 18.291 89.3433C17.7066 91.9921 18.0066 94.7377 19.1528 97.2329C20.2991 99.728 22.2403 101.861 24.7308 103.361C27.2214 104.862 30.1495 105.662 33.1448 105.662H33.1455C33.6061 105.662 33.8365 105.662 34.0314 105.659C44.5583 105.449 53.042 96.9656 53.2513 86.4386C53.2534 86.3306 53.2544 86.2116 53.2548 86.0486H53.2552V85.7149L53.2552 85.5521V82.0762L53.2552 53.1993C61.0533 54.2324 69.0092 54.7656 77.0897 54.7656C77.6696 54.7656 78.2489 54.7629 78.8276 54.7574V110.696C77.792 109.983 76.6533 109.391 75.437 108.936C72.6697 107.903 69.6246 107.632 66.6867 108.159C63.7489 108.686 61.0504 109.987 58.9323 111.896C56.8143 113.806 55.3719 116.239 54.7875 118.888C54.2032 121.537 54.5031 124.283 55.6494 126.778C56.7956 129.273 58.7368 131.405 61.2273 132.906C63.7179 134.406 66.646 135.207 69.6414 135.207C70.1024 135.207 70.3329 135.207 70.5279 135.203C81.0548 134.994 89.5385 126.51 89.7478 115.983C89.7517 115.788 89.7517 115.558 89.7517 115.097V111.621L89.7517 54.3266C101.962 53.4768 113.837 51.4075 125.255 48.2397V80.9017C124.219 80.1894 123.081 79.5966 121.864 79.1424C119.097 78.1089 116.052 77.8384 113.114 78.3653C110.176 78.8922 107.478 80.1927 105.36 82.1025C103.242 84.0122 101.799 86.4453 101.215 89.0941C100.631 91.743 100.931 94.4886 102.077 96.9837C103.223 99.4789 105.164 101.612 107.655 103.112C110.145 104.612 113.073 105.413 116.069 105.413C116.53 105.413 116.76 105.413 116.955 105.409C127.482 105.2 135.966 96.7164 136.175 86.1895C136.179 85.9945 136.179 85.764 136.179 85.3029V81.8271L136.179 44.8277Z"
|
||||
fill="#3313F7"
|
||||
fill="#146AFF"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
import { useAccount } from "jazz-react";
|
||||
import { CoFeedEntry, co } from "jazz-tools";
|
||||
import { CursorMoveEvent, useCanvas } from "../hooks/useCanvas";
|
||||
import { Cursor as CursorType, ViewBox } from "../types";
|
||||
import { Cursor as CursorType, Vec2, ViewBox } from "../types";
|
||||
import { centerOfBounds } from "../utils/centerOfBounds";
|
||||
import { getColor } from "../utils/getColor";
|
||||
import { getName } from "../utils/getName";
|
||||
import { Boundary } from "./Boundary";
|
||||
import { CanvasBackground } from "./CanvasBackground";
|
||||
import { CanvasDemoContent } from "./CanvasDemoContent";
|
||||
import { Cursor } from "./Cursor";
|
||||
|
||||
const OLD_CURSOR_AGE_SECONDS = Number(
|
||||
import.meta.env.VITE_OLD_CURSOR_AGE_SECONDS,
|
||||
);
|
||||
|
||||
const DEBUG = import.meta.env.VITE_DEBUG === "true";
|
||||
|
||||
// For debugging purposes, we can set a fixed bounds
|
||||
@@ -25,14 +17,20 @@ const debugBounds: ViewBox = {
|
||||
};
|
||||
|
||||
interface CanvasProps {
|
||||
remoteCursors: CoFeedEntry<co<CursorType>>[];
|
||||
remoteCursors: {
|
||||
entry: CoFeedEntry<co<CursorType>>;
|
||||
position: Vec2;
|
||||
color: string;
|
||||
name: string;
|
||||
age: number;
|
||||
isMe?: boolean;
|
||||
active?: boolean;
|
||||
}[];
|
||||
onCursorMove: (move: CursorMoveEvent) => void;
|
||||
name: string;
|
||||
}
|
||||
|
||||
function Canvas({ remoteCursors, onCursorMove, name }: CanvasProps) {
|
||||
const { me } = useAccount();
|
||||
|
||||
const {
|
||||
svgProps,
|
||||
isDragging,
|
||||
@@ -56,33 +54,21 @@ function Canvas({ remoteCursors, onCursorMove, name }: CanvasProps) {
|
||||
<CanvasDemoContent />
|
||||
{DEBUG && <Boundary bounds={bounds} />}
|
||||
|
||||
{remoteCursors.map((entry) => {
|
||||
if (
|
||||
entry.tx.sessionID === me?.sessionID ||
|
||||
(OLD_CURSOR_AGE_SECONDS &&
|
||||
entry.madeAt < new Date(Date.now() - 1000 * OLD_CURSOR_AGE_SECONDS))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const name = getName(entry.by?.profile?.name, entry.tx.sessionID);
|
||||
const color = getColor(entry.tx.sessionID);
|
||||
const age = new Date().getTime() - new Date(entry.madeAt).getTime();
|
||||
|
||||
return (
|
||||
{remoteCursors.map((cursor) =>
|
||||
!cursor.isMe && cursor.active ? (
|
||||
<Cursor
|
||||
key={entry.tx.sessionID}
|
||||
position={entry.value.position}
|
||||
color={color}
|
||||
key={cursor.entry.tx.sessionID}
|
||||
position={cursor.position}
|
||||
color={cursor.color}
|
||||
isDragging={false}
|
||||
isRemote={true}
|
||||
name={name}
|
||||
age={age}
|
||||
name={cursor.name}
|
||||
age={cursor.age}
|
||||
centerOfBounds={center}
|
||||
bounds={bounds}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
) : null,
|
||||
)}
|
||||
|
||||
{isMouseOver ? (
|
||||
<Cursor
|
||||
|
||||
@@ -1,29 +1,84 @@
|
||||
import { useAccount, useCoState } from "jazz-react";
|
||||
import { ID } from "jazz-tools";
|
||||
import { CursorFeed } from "../schema";
|
||||
import { getColor } from "../utils/getColor.ts";
|
||||
import { getName } from "../utils/getName";
|
||||
import Canvas from "./Canvas";
|
||||
|
||||
const OLD_CURSOR_AGE_SECONDS = Number(
|
||||
import.meta.env.VITE_OLD_CURSOR_AGE_SECONDS,
|
||||
);
|
||||
|
||||
function Avatar({
|
||||
name,
|
||||
color,
|
||||
active,
|
||||
}: { name: string; color: string; active: boolean }) {
|
||||
return (
|
||||
<span
|
||||
title={name}
|
||||
className={[
|
||||
"size-6 text-xs font-medium uppercase bg-white inline-flex items-center justify-center rounded-full border-2",
|
||||
active ? "" : "opacity-50",
|
||||
].join(" ")}
|
||||
style={{ color, borderColor: color }}
|
||||
>
|
||||
{name.replace("Anonymous ", "")[0]}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/** A higher order component that wraps the canvas. */
|
||||
function Container({ cursorFeedID }: { cursorFeedID: ID<CursorFeed> }) {
|
||||
const { me } = useAccount();
|
||||
const cursors = useCoState(CursorFeed, cursorFeedID, { resolve: true });
|
||||
|
||||
return (
|
||||
<Canvas
|
||||
onCursorMove={(move) => {
|
||||
if (!(cursors && me)) return;
|
||||
const remoteCursors = Object.values(cursors?.perSession ?? {})
|
||||
.map((entry) => ({
|
||||
entry,
|
||||
position: entry.value.position,
|
||||
color: getColor(entry.tx.sessionID),
|
||||
name: getName(entry.by?.profile?.name, entry.tx.sessionID),
|
||||
age: new Date().getTime() - new Date(entry.madeAt).getTime(),
|
||||
active:
|
||||
!OLD_CURSOR_AGE_SECONDS ||
|
||||
entry.madeAt >= new Date(Date.now() - 1000 * OLD_CURSOR_AGE_SECONDS),
|
||||
isMe: entry.tx.sessionID === me?.sessionID,
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
return b.entry.madeAt.getTime() - a.entry.madeAt.getTime();
|
||||
});
|
||||
|
||||
cursors.push({
|
||||
position: {
|
||||
x: move.position.x,
|
||||
y: move.position.y,
|
||||
},
|
||||
});
|
||||
}}
|
||||
remoteCursors={Object.values(cursors?.perSession ?? {})}
|
||||
name={getName(me?.profile?.name, me?.sessionID)}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<div className="absolute top-4 right-4 bg-white p-2 rounded-lg shadow">
|
||||
<div className="flex items-center gap-1">
|
||||
{remoteCursors.slice(0, 5).map(({ name, color, entry, active }) => (
|
||||
<Avatar
|
||||
key={entry.tx.sessionID}
|
||||
name={name}
|
||||
color={color}
|
||||
active={active}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Canvas
|
||||
onCursorMove={(move) => {
|
||||
if (!(cursors && me)) return;
|
||||
|
||||
cursors.push({
|
||||
position: {
|
||||
x: move.position.x,
|
||||
y: move.position.y,
|
||||
},
|
||||
});
|
||||
}}
|
||||
remoteCursors={remoteCursors}
|
||||
name={getName(me?.profile?.name, me?.sessionID)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,92 @@
|
||||
# multiauth
|
||||
|
||||
## 0.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.13
|
||||
- jazz-react-auth-clerk@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
- jazz-react-auth-clerk@0.13.12
|
||||
|
||||
## 0.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
- jazz-react-auth-clerk@0.13.11
|
||||
|
||||
## 0.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react@0.13.10
|
||||
- jazz-react-auth-clerk@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
- jazz-react-auth-clerk@0.13.9
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-react-auth-clerk@0.13.8
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
- jazz-react-auth-clerk@0.13.7
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
- jazz-react-auth-clerk@0.13.5
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react-auth-clerk@0.13.4
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
- jazz-react-auth-clerk@0.13.3
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
BIN
examples/multiauth/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "multiauth",
|
||||
"private": true,
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.22",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -24,7 +24,7 @@
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"globals": "^15.11.0",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,97 @@
|
||||
# jazz-example-musicplayer
|
||||
|
||||
## 0.0.103
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.13
|
||||
- jazz-react@0.13.13
|
||||
- jazz-tools@0.13.13
|
||||
|
||||
## 0.0.102
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4547525]
|
||||
- jazz-tools@0.13.12
|
||||
- jazz-inspector@0.13.12
|
||||
- jazz-react@0.13.12
|
||||
|
||||
## 0.0.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [17273a6]
|
||||
- jazz-tools@0.13.11
|
||||
- jazz-inspector@0.13.11
|
||||
- jazz-react@0.13.11
|
||||
|
||||
## 0.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-inspector@0.13.10
|
||||
- jazz-react@0.13.10
|
||||
- jazz-tools@0.13.10
|
||||
|
||||
## 0.0.99
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a6cf01f]
|
||||
- jazz-tools@0.13.9
|
||||
- jazz-inspector@0.13.9
|
||||
- jazz-react@0.13.9
|
||||
|
||||
## 0.0.98
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [22b5c4f]
|
||||
- Updated dependencies [31ea2ef]
|
||||
- Updated dependencies [4530c4a]
|
||||
- Updated dependencies [bc3d7bb]
|
||||
- jazz-inspector@0.13.7
|
||||
- jazz-tools@0.13.7
|
||||
- jazz-react@0.13.7
|
||||
|
||||
## 0.0.97
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c320615]
|
||||
- jazz-inspector@0.13.6
|
||||
|
||||
## 0.0.96
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [08ae9b2]
|
||||
- Updated dependencies [fe6f561]
|
||||
- jazz-inspector@0.13.5
|
||||
- jazz-tools@0.13.5
|
||||
- jazz-react@0.13.5
|
||||
|
||||
## 0.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3129982]
|
||||
- jazz-react@0.13.4
|
||||
- jazz-tools@0.13.4
|
||||
- jazz-inspector@0.13.4
|
||||
|
||||
## 0.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12f8bfa]
|
||||
- Updated dependencies [bd57177]
|
||||
- Updated dependencies [017f6c8]
|
||||
- jazz-tools@0.13.3
|
||||
- jazz-inspector@0.13.3
|
||||
- jazz-react@0.13.3
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
BIN
examples/music-player/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-example-music-player",
|
||||
"private": true,
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.103",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -40,7 +40,7 @@
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.27",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.11"
|
||||
"typescript": "5.6.2",
|
||||
"vite": "6.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 8.1 KiB |
54
examples/music-player/tests/auth.spec.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { BrowserContext, test } from "@playwright/test";
|
||||
import { HomePage } from "./pages/HomePage";
|
||||
|
||||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
async function mockAuthenticator(context: BrowserContext) {
|
||||
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,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Configure the authenticator
|
||||
test.beforeEach(async ({ context }) => {
|
||||
// Enable virtual authenticator environment
|
||||
await mockAuthenticator(context);
|
||||
});
|
||||
|
||||
test("sign up and log out", async ({ page: marioPage }) => {
|
||||
await marioPage.goto("/");
|
||||
|
||||
const marioHome = new HomePage(marioPage);
|
||||
|
||||
await marioHome.signUp("Mario");
|
||||
|
||||
await marioHome.logoutButton.waitFor({
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
await marioHome.logOut();
|
||||
});
|
||||
@@ -11,8 +11,12 @@ export class HomePage {
|
||||
name: "Playlist title",
|
||||
});
|
||||
|
||||
loginButton = this.page.getByRole("button", {
|
||||
name: "Sign up",
|
||||
});
|
||||
|
||||
logoutButton = this.page.getByRole("button", {
|
||||
name: "Logout",
|
||||
name: "Sign out",
|
||||
});
|
||||
|
||||
async expectActiveTrackPlaying() {
|
||||
@@ -131,12 +135,21 @@ export class HomePage {
|
||||
await this.page
|
||||
.getByRole("button", { name: "Sign up with passkey" })
|
||||
.click();
|
||||
await expect(
|
||||
this.page.getByRole("button", { name: "Sign out" }),
|
||||
).toBeVisible();
|
||||
|
||||
await this.logoutButton.waitFor({
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
await expect(this.logoutButton).toBeVisible();
|
||||
}
|
||||
|
||||
async logout() {
|
||||
async logOut() {
|
||||
await this.logoutButton.click();
|
||||
|
||||
await this.loginButton.waitFor({
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
await expect(this.loginButton).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||