Compare commits

...

151 Commits

Author SHA1 Message Date
Guido D'Orsi
adde5b78f3 Merge pull request #1201 from garden-co/changeset-release/main
Version Packages
2025-01-14 16:24:28 +01:00
github-actions[bot]
06fd3a3686 Version Packages 2025-01-14 14:02:14 +00:00
Anselm Eickhoff
d231b6ae2a Merge pull request #1191 from garden-co/fix/create-jazz-app
Use example apps as starter with create-jazz-app
2025-01-14 14:00:52 +00:00
Benjamin S. Leveritt
e471fc5d23 Merge pull request #1204 from garden-co/jazz-648-homepage-generate-docs-pointing-to-wrong-jazz-react
Fix location of jazz-react entryPoint for docs gen
2025-01-14 13:15:35 +00:00
Benjamin S. Leveritt
84d06d180a Fix location of jazz-react entryPoint for docs gen 2025-01-14 13:13:18 +00:00
Benjamin S. Leveritt
342e4d9f5e Merge pull request #1173 from garden-co/jazz-534-richtext-changes
Improve coRichText support
2025-01-14 12:46:50 +00:00
Benjamin S. Leveritt
8eb92471ae Add changeset 2025-01-14 12:44:19 +00:00
Guido D'Orsi
0cfc32f591 Merge pull request #1198 from garden-co/changeset-release/main
Version Packages
2025-01-14 12:42:19 +01:00
github-actions[bot]
e8b1e07625 Version Packages 2025-01-14 10:20:58 +00:00
pax
f97946bd21 Merge pull request #1199 from garden-co/fix-react-usecontext-reference
Fix React.useContext() reference
2025-01-14 12:19:41 +02:00
pax-k
f7f461db31 chore: changeset 2025-01-14 12:04:47 +02:00
pax-k
653d09c337 fix: explicitly use useContext() instead of React.useContext() 2025-01-14 12:03:53 +02:00
pax-k
3fa5ac30ff chore: cleanup 2025-01-14 11:39:59 +02:00
Guido D'Orsi
4095041da9 Merge pull request #1179 from garden-co/jazz-640-api-make-the-current-active-account-the-default-in
Without me
2025-01-14 10:11:40 +01:00
Guido D'Orsi
c1c2f39cb5 test: fix failing test 2025-01-14 09:33:33 +01:00
Benjamin S. Leveritt
e5b93871f7 Add test for insertion at start 2025-01-14 08:22:04 +00:00
Benjamin S. Leveritt
896aeb571d Fix multiple insertions at start 2025-01-14 08:22:03 +00:00
Guido D'Orsi
f7f1a0aff0 fix: use groups as defult owner 2025-01-13 20:24:51 +01:00
Guido D'Orsi
3bc82dc382 Update homepage/homepage/app/docs/[framework]/[...slug]/guide/react.mdx
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:36:14 +01:00
Guido D'Orsi
99bac77ae7 Update homepage/homepage/app/docs/[framework]/[...slug]/guide/react.mdx
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:36:03 +01:00
Guido D'Orsi
5705ebdcad Update packages/jazz-tools/src/implementation/activeAccountContext.ts
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:35:54 +01:00
pax
f3fb445c9e Merge pull request #1197 from garden-co/JAZZ-638/set-specific-package-version-on-create-jazz-app
create-jazz-app gets the latest semver package version for jazz-* dependencies from NPM via HTTP
2025-01-13 18:19:08 +02:00
pax-k
c60fe8aae2 chore: cleanup 2025-01-13 18:15:43 +02:00
pax-k
d2a882e531 fix: actually throw an error if getLatestPackageVersions() fails, without falling back to "latest" 2025-01-13 18:11:37 +02:00
pax-k
036fa1f43b chore: changeset 2025-01-13 18:06:41 +02:00
pax-k
839b4af45c fix: fetching latest semver jazz-* package versions from NPM when using create-jazz-app, instead of using "latest" 2025-01-13 18:04:07 +02:00
Trisha Lim
3a9797ce75 Add changeset 2025-01-13 14:48:59 +00:00
Trisha Lim
b2f14c0339 Update examples README 2025-01-13 12:37:57 +00:00
Guido D'Orsi
5d9405ccc3 Merge pull request #1196 from garden-co/changeset-release/main
Version Packages
2025-01-13 12:09:46 +01:00
github-actions[bot]
d54db4358c Version Packages 2025-01-13 11:06:47 +00:00
Guido D'Orsi
a172f61494 fix: types for the WebSocket peer 2025-01-13 12:05:22 +01:00
Guido D'Orsi
225280d37a fix: fix type error and tsconfig 2025-01-12 23:45:40 +01:00
Guido D'Orsi
c735ab6b95 Merge pull request #1195 from garden-co/changeset-release/main
Version Packages
2025-01-12 23:37:50 +01:00
github-actions[bot]
d47e59783f Version Packages 2025-01-12 22:32:21 +00:00
Guido D'Orsi
8a390d255d fix: fix account type registration using the sources for the TS definitions 2025-01-12 23:31:15 +01:00
Guido D'Orsi
03540b22c1 fix: fix prepublish script on jazz-react-native-auth-clerk 2025-01-12 22:58:26 +01:00
Guido D'Orsi
fad96fe4f4 Merge pull request #1194 from garden-co/changeset-release/main
Version Packages
2025-01-12 22:54:05 +01:00
github-actions[bot]
19b706d125 Version Packages 2025-01-12 21:53:34 +00:00
Guido D'Orsi
c871912188 feat(rn): add clearUserCredentials API to programmatically delete the current user stored credentials 2025-01-12 22:52:05 +01:00
Guido D'Orsi
7124bd05c8 Merge pull request #1192 from garden-co/changeset-release/main
Version Packages
2025-01-12 20:13:38 +01:00
github-actions[bot]
783f444cff Version Packages 2025-01-12 15:44:47 +00:00
Guido D'Orsi
0f57687d81 Update .changeset 2025-01-12 16:42:24 +01:00
Guido D'Orsi
235bf1f4e4 Merge pull request #1190 from tobiaslins/fix-react-core-type-error
[jazz-react-core] Fix type error from `useRef`
2025-01-12 16:41:31 +01:00
Trisha Lim
2d7b4b6c82 Update create-jazz-app readme 2025-01-12 14:36:03 +00:00
Trisha Lim
68369c16da Clone example apps in create-jazz-app 2025-01-12 14:30:53 +00:00
Tobias Lins
90f36db63a Fix type error 2025-01-12 15:23:03 +01:00
Trisha Lim
f002110c28 Allow partial options in create-jazz-app 2025-01-12 13:53:37 +00:00
Guido D'Orsi
83513b624e Merge pull request #1187 from garden-co/changeset-release/main
Version Packages
2025-01-12 12:41:54 +01:00
github-actions[bot]
6042250940 Version Packages 2025-01-12 09:54:11 +00:00
Guido D'Orsi
f78c234780 fix(rn): add unstable_enablePackageExports to the metro config 2025-01-12 10:53:03 +01:00
Guido D'Orsi
21efae9276 Merge pull request #1185 from garden-co/changeset-release/main
Version Packages
2025-01-11 16:35:54 +01:00
github-actions[bot]
1e58606ae7 Version Packages 2025-01-11 14:44:01 +00:00
Guido D'Orsi
4a11682316 Merge pull request #1186 from tobiaslins/fix-priority-rn-sqlite
[React Native] Change priority of sqlite to `100`
2025-01-11 15:42:46 +01:00
Tobias Lins
3e92680b08 Update README.md 2025-01-11 15:12:37 +01:00
Tobias Lins
2be47d688b Change priority of sqlite to 100 2025-01-11 15:11:37 +01:00
Guido D'Orsi
2ddccdbca5 Update dull-walls-crash.md 2025-01-11 14:00:02 +01:00
Guido D'Orsi
ab05897cd6 Merge pull request #1183 from tobiaslins/improve-expo-secure-storage
[react native] don't require faceid for every KV operation
2025-01-11 13:56:16 +01:00
Tobias Lins
7cd691f5f0 Create dull-walls-crash.md 2025-01-11 13:48:08 +01:00
Tobias Lins
24a13af657 Improve initialization when using custom kv storage 2025-01-11 13:41:12 +01:00
Tobias Lins
b13530e84b don't require faceid for every get/set 2025-01-11 11:09:56 +01:00
Guido D'Orsi
3911b72f87 docs: fix version number on the rn upgrade docs 2025-01-11 00:23:32 +01:00
Guido D'Orsi
ec278cfcd8 Merge pull request #1182 from garden-co/changeset-release/main
Version Packages
2025-01-11 00:22:19 +01:00
github-actions[bot]
912730378e Version Packages 2025-01-10 21:59:07 +00:00
Guido D'Orsi
ac35f19f01 Merge pull request #1130 from tobiaslins/rn-storage-sqlite
feat: sqlite react native storage
2025-01-10 22:58:03 +01:00
Guido D'Orsi
c25a1af96e feat: update test and add active account management to testing utils 2025-01-10 17:20:47 +01:00
Guido D'Orsi
70667d06a1 fix: cover FileStream and createImage 2025-01-10 17:02:07 +01:00
Guido D'Orsi
31fd994d83 Merge pull request #1180 from garden-co/jazz-636-add-test-for-react-starter-app
Fix and test react starter app
2025-01-10 16:53:42 +01:00
Guido D'Orsi
fc934157f6 fix: remove unused import 2025-01-10 16:52:07 +01:00
Guido D'Orsi
0bbded1772 docs: update examples with the new simplified API 2025-01-10 16:50:51 +01:00
Trisha Lim
a6eea34c74 Run starter test 2025-01-10 15:35:16 +00:00
Trisha Lim
3605b746a9 Highlight new lines on upgrade guide 2025-01-10 15:32:02 +00:00
Trisha Lim
4b29a9aaa6 Test react starter app 2025-01-10 15:30:15 +00:00
Trisha Lim
e60a9f4a74 Fix react starter app 2025-01-10 15:26:56 +00:00
Guido D'Orsi
d1d773bc9c feat: make possible to call the load/subscribe/create API without passing me 2025-01-10 16:19:41 +01:00
Guido D'Orsi
55e8a269c0 fix: fix homepage type error 2025-01-10 12:45:42 +01:00
Guido D'Orsi
0db0aadd45 fix: fix homepage type error 2025-01-10 12:38:12 +01:00
Guido D'Orsi
83f3873e03 feat: make the persistence disabled by default 2025-01-10 12:26:14 +01:00
Guido D'Orsi
80fd3e9697 chore: changeset 2025-01-10 12:16:04 +01:00
Guido D'Orsi
bae8268b29 feat: add upgrade docs and option to disable storage 2025-01-10 12:14:16 +01:00
Benjamin S. Leveritt
466c5f695a Revert mark position calculations 2025-01-09 15:30:37 +00:00
Benjamin S. Leveritt
b6a70228ea Tidy up
Remove
2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
ac32c432da Fix test 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
066ac6bf98 Add subscription test 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
ccfa7d9943 Add sync test 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
90c76a01a6 Fix up import/exports 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
807b52cccf Remove unused test 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
fb7c6c6bbf Fix removeMark implementation with tests 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
12e619b990 Add tag type filter 2025-01-09 14:55:44 +00:00
Benjamin S. Leveritt
aba2f8110c Fix removeMark 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
862e3fc7ed Fix insertMark 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
51fc92759a Add .length method 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
c8fac3381d Refactor mark validation fn 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
9723090f91 Stablises mark resolution 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
4783e08c69 Add annotations 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
34959ff0ec Fixes formatting in tests 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
bec9be84d5 Add subscription tests 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
277ee9d7e4 Add test for sync and loading 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
314518a87f Add tests for position ops 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
c280fa11c3 Add test for splitting nested children 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
929f5785a8 Fix docs
Passing tests

Remove duplicate `createPlainText` from inherited account
2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
9ae92c19ab Fix imports for coPlainText 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
599bb7355e Fix comment 2025-01-09 14:55:43 +00:00
Benjamin S. Leveritt
ad76a2f44f Fix libs for coPlainText 2025-01-09 14:55:43 +00:00
Anselm Eickhoff
3a3ad44f13 More progress 2025-01-09 14:55:42 +00:00
Anselm Eickhoff
db01bfb0a8 More implementation 2025-01-09 14:55:42 +00:00
Guido D'Orsi
3e9b7e829c Merge pull request #1175 from garden-co/jazz-639-fix-passkey-svelte
Fix imports for passkey-svelte
2025-01-09 15:51:05 +01:00
Benjamin S. Leveritt
530720f2b9 Fix imports 2025-01-09 14:47:23 +00:00
Benjamin S. Leveritt
a5d6d364db Merge pull request #877 from garden-co/benjamin-jazz-534
Bring CoPlainText up to current
2025-01-09 13:05:56 +00:00
Benjamin S. Leveritt
cb7e580942 Simplify Segmenter comment
Co-authored-by: Guido D'Orsi <guido@float.com>
2025-01-09 12:02:51 +00:00
Benjamin S. Leveritt
8653fc7eb1 Improve thrown error for envs missing Segmenter 2025-01-09 12:02:51 +00:00
Benjamin S. Leveritt
d077702250 Move segmenter into constructor
Chore: Fix formatting
2025-01-09 12:02:51 +00:00
Benjamin S. Leveritt
472b15d940 Move segmenter into class 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
f71176b362 Chore: Fix formatting 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
aa5f988776 Fix imports 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
328311e781 Moves Document into component 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
f2875de83d Add comments 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
2108f918b4 Chore: Format source 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
32441bdcd6 Fix export types 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
b80b9c08db Fix exports for rich-text example 2025-01-09 10:58:19 +00:00
Benjamin S. Leveritt
4f09c94098 Fix libs for coPlainText 2025-01-09 10:58:15 +00:00
pax
5e47f2fb52 Merge pull request #1168 from garden-co/changeset-release/main
Version Packages
2025-01-09 12:22:38 +02:00
github-actions[bot]
47f2f62b4f Version Packages 2025-01-09 10:19:41 +00:00
pax
61642b2536 Merge pull request #1170 from garden-co/feat/anonymous-auth
feat: add Onboarding auth to handle users onboarding without an auth screen
2025-01-09 12:18:12 +02:00
pax-k
20d12c5aa1 chore: formatting 2025-01-09 12:16:56 +02:00
pax-k
dd9ac6e4f8 fix: migrate DemoAuth old localStorage key to new one 2025-01-09 12:16:23 +02:00
Guido D'Orsi
1b7196938f feat: add Onboarding auth to handle users onboarding without an auth screen 2025-01-09 11:11:06 +01:00
pax-k
5d9818914c chore: changeset 2025-01-09 12:08:40 +02:00
pax-k
f33ec81f19 fix: DemoAuth localStorage key name 2025-01-09 12:01:08 +02:00
Guido D'Orsi
a9dbcc29d0 fix: migrate starter to jazz 0.9 2025-01-09 09:35:08 +01:00
Anselm Eickhoff
f30f92d1b6 Merge pull request #1167 from garden-co/fix/set-fixed-version-starter-app
Set fixed version for packages in starter apps (temporary fix)
2025-01-08 22:52:37 +00:00
Trisha Lim
33d250d0e1 Add changeset 2025-01-08 22:27:33 +00:00
Trisha Lim
f025ffa7b1 Set fixed version for packages in starter apps 2025-01-08 22:20:00 +00:00
Guido D'Orsi
6467bb89b3 docs: fix ensureLoaded migrate example 2025-01-08 21:58:00 +01:00
Trisha Lim
7fc9195068 Fix face id icon 2025-01-08 18:30:28 +00:00
Guido D'Orsi
2db8b35cf7 feat: simplify storage setup and update docs 2025-01-08 18:12:22 +01:00
Guido D'Orsi
a3234f3912 Merge remote-tracking branch 'origin/main' into pr-rn-storage-sqlite 2025-01-08 16:38:35 +01:00
Tobias Lins
7ebc77c95f Update chat.tsx 2025-01-08 09:54:55 +01:00
Tobias Lins
de20b17989 Update App.tsx 2025-01-08 09:53:37 +01:00
Tobias Lins
cae4b244e8 Update polyfills.js 2025-01-08 09:52:53 +01:00
Tobias Lins
eed5aec08d Cleanup 2025-01-08 09:51:29 +01:00
Tobias Lins
90fa0e0588 Merge remote-tracking branch 'upstream/main' into rn-storage-sqlite 2025-01-08 09:26:44 +01:00
Anselm Eickhoff
f4fc60707f More progress 2025-01-07 07:51:07 +00:00
Anselm Eickhoff
8527c3fef9 More plaintext progress 2025-01-07 07:50:26 +00:00
Anselm Eickhoff
c279174465 Rich text progress 2025-01-07 07:50:26 +00:00
Anselm
49fa18825b Progress on text 2025-01-07 07:50:26 +00:00
Anselm
32d7dca15b More implementation 2025-01-07 07:50:25 +00:00
Anselm
8ba2d47e48 Implement RawCoPlainText 2025-01-07 07:40:30 +00:00
Tobias Lins
c4d5cad2d4 Fixes 2025-01-05 10:53:59 +01:00
Tobias Lins
718543cf83 fix tx support 2025-01-04 16:52:05 +01:00
Tobias Lins
ca8f21358e Move to other library 2025-01-04 12:42:22 +01:00
Tobias Lins
d09584fa88 WIP sqlite react native storage 2025-01-04 11:24:13 +01:00
206 changed files with 7193 additions and 799 deletions

View File

@@ -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", "examples/onboarding"]
project: ["tests/e2e", "examples/chat", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "examples/onboarding", "starters/react-demo-auth-tailwind"]
steps:
- uses: actions/checkout@v3

View File

@@ -1,5 +1,74 @@
# chat-rn-clerk
## 1.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
- jazz-react-native-auth-clerk@0.9.9
- jazz-react-native-media-images@0.9.9
## 1.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
- jazz-react-native-auth-clerk@0.9.8
- jazz-react-native-media-images@0.9.8
## 1.0.48
### Patch Changes
- Updated dependencies [8a390d2]
- jazz-react-native@0.9.6
- jazz-react-native-auth-clerk@0.9.6
## 1.0.47
### Patch Changes
- Updated dependencies [c871912]
- jazz-react-native@0.9.5
- jazz-react-native-auth-clerk@0.9.5
## 1.0.46
### Patch Changes
- jazz-react-native@0.9.4
- jazz-react-native-auth-clerk@0.9.4
## 1.0.45
### Patch Changes
- Updated dependencies [7cd691f]
- jazz-react-native@0.9.3
- jazz-react-native-auth-clerk@0.9.3
## 1.0.44
### Patch Changes
- Updated dependencies [80fd3e9]
- jazz-react-native@0.9.2
- jazz-react-native-auth-clerk@0.9.2
## 1.0.43
### Patch Changes
- Updated dependencies [1b71969]
- jazz-tools@0.9.1
- jazz-react-native@0.9.1
- jazz-react-native-auth-clerk@0.9.1
- jazz-react-native-media-images@0.9.1
## 1.0.42
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "chat-rn-clerk",
"main": "index.js",
"version": "1.0.42",
"version": "1.0.50",
"scripts": {
"build": "expo export -p ios",
"start": "expo start",
@@ -20,6 +20,7 @@
"@bam.tech/react-native-image-resizer": "^3.0.11",
"@clerk/clerk-expo": "^2.2.21",
"@expo/vector-icons": "^14.0.2",
"@op-engineering/op-sqlite": "^11.2.12",
"@react-native-community/netinfo": "^11.4.1",
"@react-navigation/native": "^7.0.13",
"@react-navigation/native-stack": "^7.1.14",

View File

@@ -50,6 +50,7 @@ export function JazzAndAuth({ children }: PropsWithChildren) {
{auth && clerk.user ? (
<JazzProvider
auth={auth}
storage="sqlite"
peer="wss://cloud.jazz.tools/?key=chat-rn-clerk-example-jazz@garden.co"
>
{children}

View File

@@ -1,5 +1,63 @@
# chat-rn
## 1.0.47
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
## 1.0.46
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
## 1.0.45
### Patch Changes
- Updated dependencies [8a390d2]
- jazz-react-native@0.9.6
## 1.0.44
### Patch Changes
- Updated dependencies [c871912]
- jazz-react-native@0.9.5
## 1.0.43
### Patch Changes
- jazz-react-native@0.9.4
## 1.0.42
### Patch Changes
- Updated dependencies [7cd691f]
- jazz-react-native@0.9.3
## 1.0.41
### Patch Changes
- Updated dependencies [80fd3e9]
- jazz-react-native@0.9.2
## 1.0.40
### Patch Changes
- Updated dependencies [1b71969]
- jazz-tools@0.9.1
- jazz-react-native@0.9.1
## 1.0.39
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "chat-rn",
"version": "1.0.39",
"version": "1.0.47",
"main": "index.js",
"scripts": {
"build": "expo export -p ios",
@@ -13,6 +13,7 @@
},
"dependencies": {
"@azure/core-asynciterator-polyfill": "^1.0.2",
"@op-engineering/op-sqlite": "^11.2.12",
"@react-native-community/netinfo": "^11.4.1",
"@react-navigation/native": "^7.0.13",
"@react-navigation/native-stack": "^7.1.14",

View File

@@ -33,7 +33,6 @@ function App() {
"ChatScreen" | "HandleInviteScreen"
>("ChatScreen");
const navigationRef = useNavigationContainerRef();
useEffect(() => {
Linking.getInitialURL().then((url) => {
if (url) {
@@ -52,6 +51,7 @@ function App() {
<StrictMode>
<JazzProvider
auth={auth}
storage="sqlite"
peer="wss://cloud.jazz.tools/?key=chat-rn-example-jazz@garden.co"
>
<NavigationContainer linking={linking} ref={navigationRef}>

View File

@@ -1,5 +1,33 @@
# chat-vue
## 0.0.34
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser@0.9.9
- jazz-vue@0.9.9
## 0.0.33
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-browser@0.9.8
- jazz-vue@0.9.8
## 0.0.32
### Patch Changes
- Updated dependencies [1b71969]
- Updated dependencies [5d98189]
- jazz-browser@0.9.1
- jazz-tools@0.9.1
- jazz-vue@0.9.1
## 0.0.31
### Patch Changes

View File

@@ -1,29 +1,59 @@
# Chat example with Jazz and Vue
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example chat-vue --project-name chat-vue
```
or
```bash
npx create-jazz-app@latest --example chat-vue --project-name chat-vue
```
Go to the todo-vue example directory:
Go to the new project directory.
```bash
cd jazz/examples/chat-vue
cd chat-vue
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/chat-vue/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,38 @@
# jazz-example-chat
## 0.0.130
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.129
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.128
### Patch Changes
- jazz-react@0.9.4
## 0.0.127
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.126
### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: [https://chat.jazz.tools](https://chat.jazz.tools)
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example chat --project-name chat
```
or
```bash
npx create-jazz-app@latest --example chat --project-name chat
```
Go to the chat example directory:
Go to the new project directory.
```bash
cd jazz/examples/chat
cd chat
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/chat/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -16,9 +16,9 @@ export function App() {
const createChat = () => {
if (!me) return;
const group = Group.create({ owner: me });
const group = Group.create();
group.addMember("everyone", "writer");
const chat = Chat.create([], { owner: group });
const chat = Chat.create([], group);
router.navigate("/#/chat/" + chat.id);
// for https://jazz.tools marketing site demo only

View File

@@ -1,5 +1,5 @@
import { createImage } from "jazz-browser-media-images";
import { useAccount, useCoState } from "jazz-react";
import { useCoState } from "jazz-react";
import { ID } from "jazz-tools";
import { useState } from "react";
import { Chat, Message } from "./schema.ts";
@@ -18,7 +18,6 @@ import {
export function ChatScreen(props: { chatID: ID<Chat> }) {
const chat = useCoState(Chat, props.chatID, [{}]);
const { me } = useAccount();
const [showNLastMessages, setShowNLastMessages] = useState(30);
if (!chat)
@@ -27,8 +26,6 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
);
const sendImage = (event: React.ChangeEvent<HTMLInputElement>) => {
if (!me?.profile) return;
const file = event.currentTarget.files?.[0];
if (!file) return;
@@ -38,13 +35,8 @@ export function ChatScreen(props: { chatID: ID<Chat> }) {
return;
}
createImage(file, { owner: chat._owner }).then((image) => {
chat.push(
Message.create(
{ text: file.name, image: image },
{ owner: chat._owner },
),
);
createImage(file).then((image) => {
chat.push(Message.create({ text: file.name, image: image }, chat._owner));
});
};

View File

@@ -1,5 +1,39 @@
# minimal-auth-clerk
## 0.0.29
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
- jazz-react-auth-clerk@0.9.9
## 0.0.28
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-react-auth-clerk@0.9.8
## 0.0.27
### Patch Changes
- jazz-react@0.9.4
- jazz-react-auth-clerk@0.9.4
## 0.0.26
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-react-auth-clerk@0.9.1
## 0.0.25
### Patch Changes

View File

@@ -4,30 +4,60 @@ This is an example of how to use clerk authentication with Jazz.
Live version: https://clerk-demo.jazz.tools
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --start clerk --project-name clerk
```
or
```bash
npx create-jazz-app@latest --start clerk --project-name clerk
```
Go to the clerk example directory:
Go to the new project directory.
```bash
cd jazz/examples/clerk
cd clerk
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/clerk/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,29 @@
# file-share-svelte
## 0.0.14
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-svelte@0.9.9
## 0.0.13
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-svelte@0.9.8
## 0.0.12
### Patch Changes
- Updated dependencies [1b71969]
- jazz-tools@0.9.1
- jazz-svelte@0.9.1
## 0.0.11
### Patch Changes

View File

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

View File

@@ -1,5 +1,38 @@
# form
## 0.0.25
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.24
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.23
### Patch Changes
- jazz-react@0.9.4
## 0.0.22
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.21
### Patch Changes

View File

@@ -17,30 +17,60 @@ converting it into a `BubbleTeaOrder`.
[See the full guide here.](https://jazz.tools/docs/react/design-patterns/form)
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --start form --project-name form
```
or
```bash
npx create-jazz-app@latest --start form --project-name form
```
Go to the form example directory:
Go to the new project directory.
```bash
cd jazz/examples/form
cd form
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/form/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -30,12 +30,9 @@ export function CreateOrder() {
me.root.orders.push(draft as BubbleTeaOrder);
// reset the draft
me.root.draft = DraftBubbleTeaOrder.create(
{
addOns: ListOfBubbleTeaAddOns.create([], me),
},
me,
);
me.root.draft = DraftBubbleTeaOrder.create({
addOns: ListOfBubbleTeaAddOns.create([]),
});
router.navigate("/");
};

View File

@@ -1,5 +1,38 @@
# image-upload
## 0.0.27
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.26
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.25
### Patch Changes
- jazz-react@0.9.4
## 0.0.24
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.23
### Patch Changes

View File

@@ -4,30 +4,60 @@ This is an example of how to upload and render images with Jazz.
Live version: https://image-upload-demo.jazz.tools
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example image-upload --project-name image-upload
```
or
```bash
npx create-jazz-app@latest --example image-upload --project-name image-upload
```
Go to the image-upload example directory:
Go to the new project directory.
```bash
cd jazz/examples/image-upload
cd image-upload
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/image-upload/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,13 @@
# jazz-example-inspector
## 0.0.94
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-transport-ws@0.9.9
## 0.0.93
### Patch Changes

View File

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

View File

@@ -1,5 +1,35 @@
# jazz-example-musicplayer
## 0.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.48
### Patch Changes
- jazz-react@0.9.4
## 0.0.47
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.46
### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: https://music-demo.jazz.tools
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example music-player --project-name music-player
```
or
```bash
npx create-jazz-app@latest --example music-player --project-name music-player
```
Go to the music-player example directory:
Go to the new project directory.
```bash
cd jazz/examples/music-player
cd music-player
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/music-player/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -65,7 +65,7 @@ function JazzAndAuth({ children }: { children: React.ReactNode }) {
return (
<>
<JazzProvider
storage={["singleTabOPFS", "indexedDB"]}
storage="indexedDB"
auth={auth}
peer={peer}
AccountSchema={MusicaAccount}

View File

@@ -31,19 +31,15 @@ export function HomePage({ mediaPlayer }: { mediaPlayer: MediaPlayer }) {
const { toast } = useToast();
async function handleFileLoad(files: FileList) {
if (!me) return;
/**
* Follow this function definition to see how we update
* values in Jazz and manage files!
*/
await uploadMusicTracks(me, files);
await uploadMusicTracks(files);
}
async function handleCreatePlaylist() {
if (!me) return;
const playlist = await createNewPlaylist(me);
const playlist = await createNewPlaylist();
navigate(`/playlist/${playlist.id}`);
}

View File

@@ -22,14 +22,22 @@ import {
* pattern that best fits your app.
*/
export async function uploadMusicTracks(
account: MusicaAccount,
files: Iterable<File>,
) {
export async function uploadMusicTracks(files: Iterable<File>) {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
rootPlaylist: {
tracks: [],
},
playlists: [],
},
});
if (!me) return;
for (const file of files) {
// The ownership object defines the user that owns the created coValues
// We are creating a group for each CoValue in order to be able to share them via Playlist
const group = Group.create(account);
const group = Group.create();
const data = await getAudioFileData(file);
@@ -50,15 +58,23 @@ export async function uploadMusicTracks(
// The newly created musicTrack can be associated to the
// user track list using a simple push call
account.root?.rootPlaylist?.tracks?.push(musicTrack);
me.root.rootPlaylist.tracks.push(musicTrack);
}
}
export async function createNewPlaylist(account: MusicaAccount) {
export async function createNewPlaylist() {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
playlists: [],
},
});
if (!me) throw new Error("Current playlist not resolved");
// Since playlists are meant to be shared we associate them
// to a group which will contain the keys required to get
// access to the "owned" values
const playlistGroup = Group.create(account);
const playlistGroup = Group.create();
const playlist = Playlist.create(
{
@@ -70,7 +86,7 @@ export async function createNewPlaylist(account: MusicaAccount) {
// Again, we associate the new playlist to the
// user by pushing it into the playlists CoList
account.root?.playlists?.push(playlist);
me.root.playlists.push(playlist);
return playlist;
}
@@ -78,10 +94,7 @@ export async function createNewPlaylist(account: MusicaAccount) {
export async function addTrackToPlaylist(
playlist: Playlist,
track: MusicTrack,
account: MusicaAccount | undefined,
) {
if (!account) return;
const alreadyAdded = playlist.tracks?.some(
(t) => t?.id === track.id || t?._refs.sourceTrack?.id === track.id,
);
@@ -108,12 +121,8 @@ export async function addTrackToPlaylist(
*
* Doing this for backwards compatibility for when the Group inheritance wasn't possible
*/
const blob = await FileStream.loadAsBlob(track._refs.file.id, account);
const waveform = await MusicTrackWaveform.load(
track._refs.waveform.id,
account,
{},
);
const blob = await FileStream.loadAsBlob(track._refs.file.id);
const waveform = await MusicTrackWaveform.load(track._refs.waveform.id, {});
if (!blob || !waveform) return;
@@ -142,13 +151,25 @@ export async function updateMusicTrackTitle(track: MusicTrack, title: string) {
track.title = title;
}
export async function updateActivePlaylist(
playlist: Playlist,
me: MusicaAccount,
) {
me.root!.activePlaylist = playlist ?? me.root!.rootPlaylist;
export async function updateActivePlaylist(playlist?: Playlist) {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
activePlaylist: {},
rootPlaylist: {},
},
});
if (!me) return;
me.root.activePlaylist = playlist ?? me.root.rootPlaylist;
}
export async function updateActiveTrack(track: MusicTrack, me: MusicaAccount) {
me.root!.activeTrack = track;
export async function updateActiveTrack(track: MusicTrack) {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {},
});
if (!me) return;
me.root.activeTrack = track;
}

View File

@@ -8,26 +8,26 @@ import { updateActivePlaylist, updateActiveTrack } from "./4_actions";
import { getNextTrack, getPrevTrack } from "./lib/getters";
export function useMediaPlayer() {
const { me } = useAccount();
const { me } = useAccount({
root: {},
});
const playState = usePlayState();
const playMedia = usePlayMedia();
const [loading, setLoading] = useState<ID<MusicTrack> | null>(null);
const activeTrackId = me?.root?._refs.activeTrack?.id;
const activeTrackId = me?.root._refs.activeTrack?.id;
// Reference used to avoid out-of-order track loads
const lastLoadedTrackId = useRef<ID<MusicTrack> | null>(null);
async function loadTrack(track: MusicTrack) {
if (!me.root) return;
lastLoadedTrackId.current = track.id;
setLoading(track.id);
const file = await FileStream.loadAsBlob(track._refs.file.id, me);
const file = await FileStream.loadAsBlob(track._refs.file.id);
if (!file) {
setLoading(null);
@@ -40,7 +40,7 @@ export function useMediaPlayer() {
return;
}
updateActiveTrack(track, me);
updateActiveTrack(track);
await playMedia(file);
@@ -48,20 +48,16 @@ export function useMediaPlayer() {
}
async function playNextTrack() {
if (!me?.root) return;
const track = await getNextTrack(me);
const track = await getNextTrack();
if (track) {
updateActiveTrack(track, me);
updateActiveTrack(track);
await loadTrack(track);
}
}
async function playPrevTrack() {
if (!me?.root) return;
const track = await getPrevTrack(me);
const track = await getPrevTrack();
if (track) {
await loadTrack(track);
@@ -69,14 +65,12 @@ export function useMediaPlayer() {
}
async function setActiveTrack(track: MusicTrack, playlist?: Playlist) {
if (!me?.root) return;
if (activeTrackId === track.id && lastLoadedTrackId.current !== null) {
playState.toggle();
return;
}
updateActivePlaylist(playlist!, me);
updateActivePlaylist(playlist);
await loadTrack(track);

View File

@@ -1,25 +1,25 @@
import { useAcceptInvite, useAccount } from "jazz-react";
import { useAcceptInvite } from "jazz-react";
import { ID } from "jazz-tools";
import { useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { Playlist } from "./1_schema";
import { MusicaAccount, Playlist } from "./1_schema";
export function InvitePage() {
const navigate = useNavigate();
const { me } = useAccount({
root: {
playlists: [],
},
});
useAcceptInvite({
invitedObjectSchema: Playlist,
onAccept: useCallback(
async (playlistId: ID<Playlist>) => {
if (!me) return;
const playlist = await Playlist.load(playlistId, {});
const playlist = await Playlist.load(playlistId, me, {});
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
playlists: [],
},
});
if (!me) return;
if (
playlist &&
@@ -30,7 +30,7 @@ export function InvitePage() {
navigate("/playlist/" + playlistId);
},
[navigate, me],
[navigate],
),
});

View File

@@ -43,7 +43,7 @@ export function MusicTrackRow({
function handleAddToPlaylist(playlist: Playlist) {
if (!track) return;
addTrackToPlaylist(playlist, track, me);
addTrackToPlaylist(playlist, track);
}
return (

View File

@@ -1,10 +1,18 @@
import { MusicaAccount } from "../1_schema";
export async function getNextTrack(account: MusicaAccount) {
if (!account.root?.activePlaylist?.tracks) return;
export async function getNextTrack() {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
activePlaylist: {
tracks: [],
},
},
});
const tracks = account.root.activePlaylist.tracks;
const activeTrack = account.root._refs.activeTrack;
if (!me) return;
const tracks = me.root.activePlaylist.tracks;
const activeTrack = me.root._refs.activeTrack;
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);
@@ -13,11 +21,19 @@ export async function getNextTrack(account: MusicaAccount) {
return tracks[nextIndex];
}
export async function getPrevTrack(account: MusicaAccount) {
if (!account.root?.activePlaylist?.tracks) return;
export async function getPrevTrack() {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
activePlaylist: {
tracks: [],
},
},
});
const tracks = account.root.activePlaylist.tracks;
const activeTrack = account.root._refs.activeTrack;
if (!me) return;
const tracks = me.root.activePlaylist.tracks;
const activeTrack = me.root._refs.activeTrack;
const currentIndex = tracks.findIndex((item) => item?.id === activeTrack.id);

View File

@@ -1,30 +1,30 @@
import { useAccount } from "jazz-react";
// eslint-disable-next-line react-compiler/react-compiler
/* eslint-disable react-hooks/exhaustive-deps */
import { MusicaAccount } from "@/1_schema";
import { useEffect } from "react";
import { MusicaAccount } from "../1_schema";
import { uploadMusicTracks } from "../4_actions";
export function useUploadExampleData() {
const { me } = useAccount({
useEffect(() => {
uploadOnboardingData();
}, []);
}
async function uploadOnboardingData() {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {},
});
const shouldUploadOnboardingData = me?.root?.exampleDataLoaded === false;
if (!me) throw new Error("Me not resolved");
useEffect(() => {
if (me?.root && shouldUploadOnboardingData) {
me.root.exampleDataLoaded = true;
if (me.root.exampleDataLoaded) return;
uploadOnboardingData(me).then(() => {
me.root.exampleDataLoaded = true;
});
}
}, [shouldUploadOnboardingData]);
}
async function uploadOnboardingData(me: MusicaAccount) {
const trackFile = await (await fetch("/example.mp3")).blob();
return uploadMusicTracks(me, [new File([trackFile], "Example song")]);
me.root.exampleDataLoaded = true;
try {
const trackFile = await (await fetch("/example.mp3")).blob();
await uploadMusicTracks([new File([trackFile], "Example song")]);
} catch (error) {
me.root.exampleDataLoaded = false;
throw error;
}
}

View File

@@ -1,5 +1,38 @@
# jazz-example-onboarding
## 0.0.31
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.30
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.29
### Patch Changes
- jazz-react@0.9.4
## 0.0.28
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.27
### Patch Changes

View File

@@ -1,29 +1,58 @@
# Onboarding example with Jazz and React
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example onboarding --project-name onboarding
```
or
```bash
npx create-jazz-app@latest --example onboarding --project-name onboarding
```
Go to the onboarding example directory:
Go to the new project directory.
```bash
cd jazz/examples/onboarding
cd onboarding
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/onboarding/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,35 @@
# organization
## 0.0.23
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.22
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.21
### Patch Changes
- jazz-react@0.9.4
## 0.0.20
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.19
### Patch Changes

View File

@@ -5,30 +5,60 @@ Different apps have different names for this concept, such as "teams" or "worksp
Refer to the [documentation](https://jazz.tools/docs/react/design-patterns/organization) for more information.
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example organization --project-name organization
```
or
```bash
npx create-jazz-app@latest --example organization --project-name organization
```
Go to the organization example directory:
Go to the new project directory.
```bash
cd jazz/examples/organization
cd organization
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/organization/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,23 @@
# passkey-svelte
## 0.0.18
### Patch Changes
- jazz-svelte@0.9.9
## 0.0.17
### Patch Changes
- jazz-svelte@0.9.8
## 0.0.16
### Patch Changes
- jazz-svelte@0.9.1
## 0.0.15
### Patch Changes

View File

@@ -10,34 +10,59 @@ This example showcases how to:
- Manage authentication state
- Implement secure login/logout flows
## Getting Started
## Getting started
1. Clone the repository:
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
```sh
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npm create jazz-app@latest --example passkey-svelte --project-name passkey-svelte
```
or
```bash
npx create-jazz-app@latest --example passkey-svelte --project-name passkey-svelte
```
Go to the new project directory.
```bash
cd passkey-svelte
```
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
2. Navigate to the example directory:
```sh
cd examples/passkey-svelte
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
3. Install dependencies:
```sh
pnpm install
Go to the example directory.
```bash
cd jazz/examples/passkey-svelte/
```
4. Start the development server:
```sh
Start the dev server.
```bash
pnpm dev
```
5. Open your browser and visit [http://localhost:5173](http://localhost:5173)
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Learn More

View File

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

View File

@@ -1,3 +0,0 @@
import { createJazzApp } from 'jazz-svelte';
export const { useAccount, useCoState, Provider } = createJazzApp();

View File

@@ -1,6 +1,5 @@
<script lang="ts">
import { usePasskeyAuth, PasskeyAuthBasicUI } from 'jazz-svelte';
import { Provider } from '$lib/jazz';
import { JazzProvider, PasskeyAuthBasicUI, usePasskeyAuth } from 'jazz-svelte';
let { children } = $props();
@@ -15,12 +14,12 @@
<PasskeyAuthBasicUI state={auth.state} />
{#if auth.current}
<Provider
<JazzProvider
auth={auth.current}
peer="wss://cloud.jazz.tools/?key=minimal-svelte-auth-passkey@garden.co"
>
{@render children?.()}
</Provider>
</JazzProvider>
{/if}
</div>

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { useAccount } from '$lib/jazz';
import { useAccount } from 'jazz-svelte';
const account = useAccount({
root: {}

View File

@@ -1,5 +1,35 @@
# minimal-auth-passkey
## 0.0.28
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.27
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.26
### Patch Changes
- jazz-react@0.9.4
## 0.0.25
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.24
### Patch Changes

View File

@@ -4,30 +4,59 @@ This is an example of how to use passkey authentication with Jazz.
Live version: https://passkey-demo.jazz.tools
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example passkey --project-name passkey
```
or
```bash
npx create-jazz-app@latest --example passkey --project-name passkey
```
Go to the passkey example directory:
Go to the new project directory.
```bash
cd jazz/examples/passkey
cd passkey
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/passkey/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,35 @@
# jazz-password-manager
## 0.0.49
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.48
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.47
### Patch Changes
- jazz-react@0.9.4
## 0.0.46
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.45
### Patch Changes

View File

@@ -4,30 +4,60 @@ Live version: https://passwords-demo.jazz.tools
![Password Manager Screenshot](demo.png "Screenshot")
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example password-manager --project-name password-manager
```
or
```bash
npx create-jazz-app@latest --example password-manager --project-name password-manager
```
Go to the password-manager example directory:
Go to the new project directory.
```bash
cd jazz/examples/password-manager
cd password-manager
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/password-manager/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Structure
- [`src/components`](./src/components/): UI components

View File

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

View File

@@ -1,5 +1,38 @@
# jazz-example-pets
## 0.0.147
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.146
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.145
### Patch Changes
- jazz-react@0.9.4
## 0.0.144
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.143
### Patch Changes

View File

@@ -2,30 +2,59 @@
Live version: https://pets-demo.jazz.tools/
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example pets --project-name pets
```
or
```bash
npx create-jazz-app@latest --example pets --project-name pets
```
Go to the pets example directory:
Go to the new project directory.
```bash
cd jazz/examples/pets
cd pets
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/pets/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.143",
"version": "0.0.147",
"type": "module",
"scripts": {
"dev": "vite",
@@ -19,9 +19,9 @@
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-browser-media-images": "workspace:0.9.0",
"jazz-react": "workspace:0.9.0",
"jazz-tools": "workspace:0.9.0",
"jazz-browser-media-images": "workspace:0.9.9",
"jazz-react": "workspace:0.9.9",
"jazz-tools": "workspace:0.9.9",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.3.1",
@@ -41,7 +41,7 @@
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.20",
"is-ci": "^3.0.1",
"jazz-run": "workspace:0.9.0",
"jazz-run": "workspace:0.9.9",
"postcss": "^8.4.27",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",

View File

@@ -1,5 +1,38 @@
# reactions
## 0.0.27
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.26
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.25
### Patch Changes
- jazz-react@0.9.4
## 0.0.24
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
- jazz-browser-media-images@0.9.1
## 0.0.23
### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: [https://reactions-demo.jazz.tools](https://reactions-demo.jazz.tools)
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example reactions --project-name reactions
```
or
```bash
npx create-jazz-app@latest --example reactions --project-name reactions
```
Go to the reactions example directory:
Go to the new project directory.
```bash
cd jazz/examples/reactions
cd reactions
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/reactions/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,33 @@
# todo-vue
## 0.0.32
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser@0.9.9
- jazz-vue@0.9.9
## 0.0.31
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-browser@0.9.8
- jazz-vue@0.9.8
## 0.0.30
### Patch Changes
- Updated dependencies [1b71969]
- Updated dependencies [5d98189]
- jazz-browser@0.9.1
- jazz-tools@0.9.1
- jazz-vue@0.9.1
## 0.0.29
### Patch Changes

View File

@@ -1,29 +1,59 @@
# Todo list example with Jazz and Vue
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example todo-vue --project-name todo-vue
```
or
```bash
npx create-jazz-app@latest --example todo-vue --project-name todo-vue
```
Go to the todo-vue example directory:
Go to the new project directory.
```bash
cd jazz/examples/todo-vue
cd todo-vue
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/todo-vue/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,35 @@
# jazz-example-todo
## 0.0.146
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.145
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.144
### Patch Changes
- jazz-react@0.9.4
## 0.0.143
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.142
### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: https://todo-demo.jazz.tools/
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example todo --project-name todo
```
or
```bash
npx create-jazz-app@latest --example todo --project-name todo
```
Go to the todo example directory:
Go to the new project directory.
```bash
cd jazz/examples/todo
cd todo
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/todo/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Structure
- [`src/basicComponents`](./src/basicComponents): simple components to build the UI, unrelated to Jazz (uses [shadcn/ui](https://ui.shadcn.com))

View File

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

View File

@@ -70,7 +70,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
</JazzAndAuth>
</div>
</ThemeProvider>
,
</React.StrictMode>,
);

View File

@@ -1,5 +1,35 @@
# version-history
## 0.0.24
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.23
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.22
### Patch Changes
- jazz-react@0.9.4
## 0.0.21
### Patch Changes
- Updated dependencies [1b71969]
- jazz-react@0.9.1
- jazz-tools@0.9.1
## 0.0.20
### Patch Changes

View File

@@ -2,30 +2,60 @@
A minimal example showing how to use Jazz's built-in version history to show and restore changes.
## Installing & running the example locally
## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash
npx degit gardencmp/jazz jazz
npm create jazz-app@latest --example version-history --project-name version-history
```
or
```bash
npx create-jazz-app@latest --example version-history --project-name version-history
```
Go to the version-history example directory:
Go to the new project directory.
```bash
cd jazz/examples/version-history
cd version-history
```
Install and build dependencies:
Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash
pnpm i && npx turbo build
```
Start the dev server:
Go to the example directory.
```bash
cd jazz/examples/version-history/
```
Start the dev server.
```bash
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -130,7 +130,7 @@ export function Icon({
aria-hidden="true"
size={sizes[size]}
strokeWidth={strokeWidths[size]}
strokeLinecap="butt"
strokeLinecap="round"
className={className}
{...svgProps}
/>

View File

@@ -125,7 +125,7 @@ export function CreateOrder() {
const [draft, setDraft] = useState<DraftBubbleTeaOrder>();
useEffect(() => {
setDraft(DraftBubbleTeaOrder.create({}, { owner: me }));
setDraft(DraftBubbleTeaOrder.create({}));
}, [me?.id]);
const onSave = (e: React.FormEvent<HTMLFormElement>) => {
@@ -179,7 +179,7 @@ export function CreateOrder() { // old
const [draft, setDraft] = useState<DraftBubbleTeaOrder>(); // old
useEffect(() => { // old
setDraft(DraftBubbleTeaOrder.create({}, { owner: me })); // old
setDraft(DraftBubbleTeaOrder.create({})); // old
}, [me?.id]); // old
const onSave = (e: React.FormEvent<HTMLFormElement>) => { // old
@@ -229,14 +229,10 @@ export class JazzAccount extends Account {
root = co.ref(AccountRoot);
migrate(this: JazzAccount, creationProps?: { name: string }) {
super.migrate(creationProps);
if (this.root === undefined) {
const draft = DraftBubbleTeaOrder.create({});
if (!this._refs.root) {
const ownership = { owner: this };
const draft = DraftBubbleTeaOrder.create({}, ownership);
this.root = AccountRoot.create({ draft }, ownership);
this.root = AccountRoot.create({ draft });
}
}
}
@@ -303,11 +299,11 @@ export function CreateOrder() {// old
// create a new empty draft
me.root.draft = DraftBubbleTeaOrder.create(
{}, { owner: me },
{},
);
};// old
return <CreateOrderForm id={me?.root?.draft.id} onSave={onSave} />
return <CreateOrderForm id={me.root.draft.id} onSave={onSave} />
} // old
function CreateOrderForm({

View File

@@ -54,11 +54,9 @@ export class JazzAccount extends Account {
root = co.ref(JazzAccountRoot);
async migrate() {
if (!this._refs.root) {
if (this.root === undefined) {
// Using a Group as an owner allows you to give access to other users
const initialOrganizationOwnership = {
owner: Group.create({ owner: this }),
};
const organizationGroup = Group.create();
const organizations = ListOfOrganizations.create(
[
@@ -66,17 +64,15 @@ export class JazzAccount extends Account {
Organization.create(
{
name: "My organization",
projects: ListOfProjects.create([], initialOrganizationOwnership),
projects: ListOfProjects.create([], organizationGroup),
},
initialOrganizationOwnership,
organizationGroup,
),
],
{ owner: this },
);
this.root = JazzAccountRoot.create(
{ organizations },
{ owner: this },
);
}
}
@@ -101,22 +97,27 @@ When the user accepts the invite, add the `Organization` to the user's `organiza
<CodeGroup>
```ts
const onAccept = (organizationId: ID<Organization>) => {
if (me?.root?.organizations) {
Organization.load(organizationId, me, []).then((organization) => {
if (organization) {
// Avoid duplicates
const ids = me.root.organizations.map(
(organization) => organization?.id,
);
const onAccept = async (organizationId: ID<Organization>) => {
const me = await MusicaAccount.getMe().ensureLoaded({
root: {
organizations: [],
},
});
if (ids.includes(organizationId)) return;
if (!me) throw new Error("Failed to load account data");
me.root.organizations.push(organization);
navigate("/organizations/" + organizationId);
}
});
}
const organization = await Organization.load(organizationId, []);
if (!organization) throw new Error("Failed to load organization data");
const ids = me.root.organizations.map(
(organization) => organization?.id,
);
if (ids.includes(organizationId)) return;
me.root.organizations.push(organization);
navigate("/organizations/" + organizationId);
};
useAcceptInvite({

View File

@@ -36,9 +36,9 @@ You can add group members by ID by using `Account.load` and `Group.addMember`.
```tsx
import { Group, Account } from "jazz-tools";
const group = Group.create({ owner: me });
const group = Group.create();
const bob = await Account.load(bobsID, me, []);
const bob = await Account.load(bobsID, []);
group.addMember(bob, "writer");
```
</CodeGroup>
@@ -49,7 +49,7 @@ Note: if the account ID is of type `string`, because it comes from a URL paramet
```tsx
import { Group, Account, ID } from "jazz-tools";
const bob = await Account.load(bobsID as ID<Account>, me, []);
const bob = await Account.load(bobsID as ID<Account>, []);
group.addMember(bob, "writer");
```
</CodeGroup>

View File

@@ -13,7 +13,7 @@ access to "everyone".
<CodeGroup>
```ts
const group = Group.create({ owner: me });
const group = Group.create();
group.addMember("everyone", "writer"); // *highlight*
```
</CodeGroup>

View File

@@ -186,10 +186,8 @@ Now, finally, let's implement creating an issue:
import { useState } from "react"; // old
import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount } from "jazz-react";
// old
function App() {// old
const { me } = useAccount();
const [issue, setIssue] = useState<Issue>(); // old
// old
const createIssue = () => {
@@ -200,7 +198,6 @@ function App() {// old
estimate: 5,
status: "backlog",
},
{ owner: me },
);
setIssue(newIssue);
};
@@ -234,7 +231,7 @@ We'll already notice one interesting thing here:
- We have to create every CoValue with an `owner`!
- this will determine access rights on the CoValue, which we'll learn about in "Groups & Permissions"
- here we set `owner` to the current user `me`, which we get from the Jazz context / `useAccount`
- here the `owner` is set automatically to a group managed by the current user because we have not declared any
**Behind the scenes, Jazz not only creates the Issue in memory but also automatically syncs an encrypted version to the cloud and persists it locally. The Issue also has a globally unique ID.**
@@ -260,11 +257,10 @@ Let's modify `src/App.tsx`:
import { useState } from "react"; // old
import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount, useCoState } from "jazz-react";
import { useCoState } from "jazz-react";
import { ID } from "jazz-tools"
// old
function App() { // old
const { me } = useAccount(); // old
const [issueID, setIssueID] = useState<ID<Issue>>();
// old
const issue = useCoState(Issue, issueID);
@@ -277,7 +273,6 @@ function App() { // old
estimate: 5, // old
status: "backlog", // old
}, // old
{ owner: me }, // old
); // old
setIssueID(newIssue.id);
}; // old
@@ -381,10 +376,9 @@ This works because CoValues
<CodeGroup size="sm">
```ts
function useCoState<V extends CoValue>(Schema: CoValueClass<V>, id?: ID<V>): V | undefined {
const { me } = useAccount();
const [value, setValue] = useState<V>();
useEffect(() => Schema.subscribe(id, me, [], setValue), [id]);
useEffect(() => Schema.subscribe(id, [], setValue), [id]);
return value;
}
@@ -409,11 +403,10 @@ So let's store the ID in the browser's URL and make sure our useState is in sync
import { useState } from "react"; // old
import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount, useCoState } from "jazz-react"; // old
import { useCoState } from "jazz-react"; // old
import { ID } from "jazz-tools" // old
// old
function App() { // old
const { me } = useAccount(); // old
const [issueID, setIssueID] = useState<ID<Issue> | undefined>(
(window.location.search?.replace("?issue=", "") || undefined) as ID<Issue> | undefined,
);
@@ -428,7 +421,6 @@ function App() { // old
estimate: 5, // old
status: "backlog", // old
}, // old
{ owner: me }, // old
); // old
setIssueID(newIssue.id); // old
window.history.pushState({}, "", `?issue=${newIssue.id}`);
@@ -470,7 +462,7 @@ All we have to do is create a new group to own each new issue and add "everyone"
import { useState } from "react"; // old
import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount, useCoState } from "jazz-react"; // old
import { useCoState } from "jazz-react"; // old
import { ID, Group } from "jazz-tools"
// old
function App() { // old
@@ -564,11 +556,9 @@ First, we'll change `App.tsx` to create and render `Project`s instead of `Issue`
import { useState } from "react"; // old
import { Project, ListOfIssues } from "./schema";
import { ProjectComponent } from "./components/Project.tsx";
import { useAccount } from "jazz-react";
import { ID, Group } from "jazz-tools"
// old
function App() { // old
const { me } = useAccount(); // old
const [projectID, setProjectID] = useState<ID<Project> | undefined>(
(window.location.search?.replace("?project=", "") || undefined) as ID<Project> | undefined
);
@@ -576,7 +566,7 @@ function App() { // old
const issue = useCoState(Issue, issueID); // *bin*
// old
const createProject = () => {
const group = Group.create({ owner: me });
const group = Group.create();
group.addMember("everyone", "writer");
const newProject = Project.create(
@@ -584,7 +574,7 @@ function App() { // old
name: "New Project",
issues: ListOfIssues.create([], { owner: group })
},
{ owner: group },
group,
);
setProjectID(newProject.id);
window.history.pushState({}, "", `?project=${newProject.id}`);
@@ -622,7 +612,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {
description: "",
estimate: 0,
status: "backlog",
}, { owner: project._owner }));
}, project._owner));
};
return project ? (
@@ -673,7 +663,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {//
description: "",// old
estimate: 0,// old
status: "backlog",// old
}, { owner: project._owner }));// old
}, project._owner));// old
};// old
// old
return project ? (// old
@@ -731,17 +721,15 @@ Turns out, we're already mostly there! First, let's remove making the Project pu
import { useState } from "react"; // old
import { Project, ListOfIssues } from "./schema"; // old
import { ProjectComponent } from "./components/Project.tsx"; // old
import { useAccount } from "jazz-react"; // old
import { ID, Group } from "jazz-tools" // old
// old
function App() { // old
const { me } = useAccount(); // old
const [projectID, setProjectID] = useState<ID<Project> | undefined>( // old
(window.location.search?.replace("?project=", "") || undefined) as ID<Project> | undefined, // old
); // old
// old
const createProject = () => { // old
const group = Group.create({ owner: me }); // old
const group = Group.create(); // old
group.addMember("everyone", "writer"); // *bin*
// old
const newProject = Project.create( // old
@@ -749,7 +737,7 @@ function App() { // old
name: "New Project", // old
issues: ListOfIssues.create([], { owner: group }) // old
}, // old
{ owner: group }, // old
group, // old
); // old
setProjectID(newProject.id); // old
window.history.pushState({}, "", `?project=${newProject.id}`); // old
@@ -792,7 +780,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {//
description: "",// old
estimate: 0,// old
status: "backlog",// old
}, { owner: project._owner }));// old
}, project._owner));// old
};// old
// old
return project ? (// old

View File

@@ -36,9 +36,7 @@ Tested with:
```bash
npx expo install expo-linking expo-secure-store expo-file-system @react-native-community/netinfo @bam.tech/react-native-image-resizer @azure/core-asynciterator-polyfill
npm i -S react-native-polyfill-globals react-native-url-polyfill web-streams-polyfill@3.2.1 base-64 text-encoding react-native-fetch-api react-native-get-random-values buffer
npm i -D @babel/plugin-transform-class-static-block
npm i -S react-native-polyfill-globals react-native-url-polyfill web-streams-polyfill@3.2.1 base-64 text-encoding react-native-fetch-api react-native-get-random-values buffer @op-engineering/op-sqlite
npm i -S jazz-tools jazz-react-native jazz-react-native-media-images
@@ -188,19 +186,40 @@ Lastly, ensure that the `"main"` field in your `package.json` points to `index.j
```
</CodeGroup>
## Using Jazz
## Setting up the provider
### `createJazzRNApp()`
Create a file `jazz.tsx` with the following contents:
Wrap your app components with the `JazzProvider:
<CodeGroup>
```tsx
import { createJazzRNApp } from "jazz-react-native";
```tsx
import { JazzProvider, useDemoAuth, DemoAuthBasicUI } from "jazz-react-native";
import { MyAppAccount } from "./schema";
export const Jazz = createJazzRNApp();
export const { useAccount, useCoState, useAcceptInvite } = Jazz;
```
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=you@example.com"
AccountSchema={MyAppAccount}
>
{children}
</JazzProvider>
<DemoAuthBasicUI appName="My App" state={state} />
</>
);
}
// Register the Account schema so `useAccount` returns our custom `MyAppAccount`
declare module "jazz-react-native" {
interface Register {
Account: MyAppAccount;
}
}
```
</CodeGroup>
You can optionally pass a custom `kvStore` and `AccountSchema` to `createJazzRNApp()`, otherwise, it defaults to `ExpoSecureStoreAdapter` and `Account`.

View File

@@ -148,18 +148,16 @@ export class MyAppAccount extends Account {
root = co.ref(MyAppRoot);
async migrate() {
const me = this;
// we specifically need to check for undefined,
// because the root might simply be not loaded (`null`) yet
if (me.root === undefined) {
me.root = MyAppRoot.create({
if (this.root === undefined) {
this.root = MyAppRoot.create({
// Using a group to set the owner is always a good idea.
// This way if in the future we want to share
// this coValue we can do so easily.
myChats: ListOfChats.create([], Group.create(me)),
myContacts: ListOfAccounts.create([], Group.create(me))
}, Group.create(me));
myChats: ListOfChats.create([], Group.create()),
myContacts: ListOfAccounts.create([], Group.create())
});
}
}
}
@@ -182,26 +180,26 @@ export class MyAppAccount extends Account {
root = co.ref(MyAppRoot);// old
async migrate() { // old
const me = this; // old
if (me.root === undefined) { // old
me.root = MyAppRoot.create({ // old
myChats: ListOfChats.create([], Group.create(me)), // old
myContacts: ListOfAccounts.create([], Group.create(me)) // old
}, Group.create(me)); // old
if (this.root === undefined) { // old
this.root = MyAppRoot.create({ // old
myChats: ListOfChats.create([], Group.create()), // old
myContacts: ListOfAccounts.create([], Group.create()) // old
}); // old
} // old
// We need to load the root field to check for the myContacts field
const { root } = await me.ensureLoaded({
const result = await this.ensureLoaded({
root: {},
});
if (!root) throw new Error("Root missing!"); // this should never happen
if (!result) throw new Error("Root missing!"); // this should never happen
const { root } = result;
// we specifically need to check for undefined,
// because myBookmarks might simply be not loaded (`null`) yet
if (root.myBookmarks === undefined) {
root.myBookmarks = ListOfBookmarks.create([], Group.create(me));
root.myBookmarks = ListOfBookmarks.create([], Group.create());
}
}
}

View File

@@ -52,9 +52,9 @@ import { TodoProject, ListOfTasks } from "./schema";
const project: TodoProject = TodoProject.create(
{
title: "New Project",
tasks: ListOfTasks.create([], { owner: me }),
tasks: ListOfTasks.create([], Group.create()),
},
{ owner: me }
Group.create()
);
```
</CodeGroup>

View File

@@ -21,7 +21,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<div>
The `JazzProvider` is now imported from `jazz-react` instead of `createJazzReactApp`.
While `createJazzReactApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
While `createJazzReactApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
we found that this approach made the Jazz setup awkward and confusing for some users.
So we decided to remove `createJazzReactApp` step and to provide the types through namespace declarations:
@@ -46,29 +46,29 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<JazzProvider
auth={passkeyAuth} // old
peer="wss://cloud.jazz.tools/?key=you@example.com" // old
AccountSchema={MyAppAccount} {/* The custom Account schema is passed here */}
AccountSchema={MyAppAccount} {/* The custom Account schema is passed here */} // *add*
>
{children} // old
</JazzProvider>
<PasskeyAuthBasicUI state={passKeyState} /> // old
</> // old
);
);
}
// Register the Account schema so `useAccount` returns our custom `MyAppAccount`
declare module "jazz-react" {
interface Register {
Account: MyAppAccount;
}
}
declare module "jazz-react" { // *add*
interface Register { // *add*
Account: MyAppAccount; // *add*
} // *add*
} // *add*
```
</CodeGroup>
<h3>Top level imports for hooks</h3>
<div>
All Jazz hooks are now available as top-level imports from the `jazz-react` package.
All Jazz hooks are now available as top-level imports from the `jazz-react` package.
This change improves IDE intellisense support and simplifies imports:
</div>
@@ -86,7 +86,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<>
Hello {me.profile?.name}
</>
);
);
}
```
</CodeGroup>
@@ -105,7 +105,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
```tsx
import { createJazzTestAccount, JazzTestProvider } from "jazz-react/testing";
import { renderHook } from "@testing-library/react"; // old
import { usePlaylist } from "./usePlaylist"; // old
import { usePlaylist } from "./usePlaylist"; // old
import { Playlist, MusicAccount } from "./schema"; // old
test("should load the playlist", async () => {
@@ -146,7 +146,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<div>
The `JazzProvider` is now imported from `jazz-react-native` instead of `createJazzRNApp`.
While `createJazzRNApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
While `createJazzRNApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
we found that this approach made the Jazz setup awkward and confusing for some users.
So we decided to remove `createJazzRNApp` step and to provide the types through namespace declarations:
@@ -177,7 +177,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
</JazzProvider>
<DemoAuthBasicUI appName="My App" state={state} /> // old
</> // old
);
);
}
// Register the Account schema so `useAccount` returns our custom `MyAppAccount`
@@ -192,8 +192,8 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<h3>Top level imports for hooks</h3>
<div>
All Jazz hooks are now available as top-level imports from the `jazz-react-native` package.
All Jazz hooks are now available as top-level imports from the `jazz-react-native` package.
This change improves IDE intellisense support and simplifies imports:
</div>
@@ -211,7 +211,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<>
Hello {me.profile?.name}
</>
);
);
}
```
</CodeGroup>
@@ -271,7 +271,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<div>
The `JazzProvider` is now imported from `jazz-svelte` instead of `createJazzApp`.
While `createJazzApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
While `createJazzApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
we found that this approach made the Jazz setup awkward and confusing for some users.
So we decided to remove `createJazzApp` step and to provide the types through namespace declarations:
@@ -302,7 +302,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
let AccountSchema = MyAccount;
</script>
<JazzProvider {auth} {peer} {AccountSchema}>
<JazzProvider {auth} {peer} {AccountSchema}>
<App />
</JazzProvider>
```
@@ -311,8 +311,8 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<h3>Top level imports for hooks</h3>
<div>
All Jazz hooks are now available as top-level imports from the `jazz-svelte` package.
All Jazz hooks are now available as top-level imports from the `jazz-svelte` package.
This change improves IDE intellisense support and simplifies imports:
</div>
@@ -387,7 +387,7 @@ export const metadata = { title: "Upgrade to Jazz 0.9.0" };
<div>
The `JazzProvider` is now imported from `jazz-vue` instead of `createJazzVueApp`.
While `createJazzReactApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
While `createJazzReactApp` was originally designed to setup strong typing for custom Account schemas in `useAccount`,
we found that this approach made the Jazz setup awkward and confusing for some users.
So we decided to remove `createJazzReactApp` step and to provide the types through namespace declarations:
@@ -409,7 +409,7 @@ export const { useAccount, useCoState } = Jazz; // *bin*
const { JazzProvider } = Jazz; // *bin*
const RootComponent = defineComponent({ // old
name: "RootComponent", // old
name: "RootComponent", // old
setup() { // old
const { authMethod, state } = useDemoAuth(); // old
return () => [ // old
@@ -449,8 +449,8 @@ app.mount("#app"); // old
<h3>Top level imports for hooks</h3>
<div>
All Jazz hooks are now available as top-level imports from the `jazz-vue` package.
All Jazz hooks are now available as top-level imports from the `jazz-vue` package.
This change improves IDE intellisense support and simplifies imports:
</div>

View File

@@ -0,0 +1,49 @@
import { ContentByFramework, CodeGroup } from '@/components/forMdx'
export const metadata = { title: "Enable local persistence" };
# Enable local persistence
<h2 className="not-prose text-sm text-stone-600 dark:text-stone-400 mb-5 pb-2 border-b">
10 January 2025
</h2>
<ContentByFramework framework="react-native">
<div>
Version 0.9.2 introduces local persistence for React Native apps using SQLite.
If you are upgrading from a version before 0.9.2, you need to enable local persistence by following the steps below.
Local persistence will become the default in 0.10.0.
</div>
<h3>Add the required dependencies</h3>
<div>
As SQLite package we now use `@op-engineering/op-sqlite`.
To get local persistence working, you need to add `@op-engineering/op-sqlite` as a direct dependency to your project and run `npx pod-install`.
</div>
<h3>Update your JazzProvider to enable local persistence</h3>
<div>
Local persistence is now disabled by default.
To enable it, you need to pass the `storage` option to the `JazzProvider` component:
</div>
<CodeGroup>
```tsx
<JazzProvider
auth={auto}
storage="sqlite"
peer="wss://cloud.jazz.tools/?key=you@example.com"
AccountSchema={MyAppAccount}
>
<App />
</JazzProvider>
```
</CodeGroup>
</ContentByFramework>

View File

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

View File

@@ -12,19 +12,21 @@ export function DocNav({ className }: { className?: string }) {
const items = docNavigationItems.map((headerItem) => {
return {
...headerItem,
items: headerItem.items.map((item) => {
if (!item.href?.startsWith("/docs")) return item;
items: headerItem.items
.filter((item) => !item.framework || item.framework === framework)
.map((item) => {
if (!item.href?.startsWith("/docs")) return item;
let done =
typeof item.done === "number" ? item.done : item.done[framework];
let href = item.href.replace("/docs", `/docs/${framework}`);
let done =
typeof item.done === "number" ? item.done : item.done[framework];
let href = item.href.replace("/docs", `/docs/${framework}`);
return {
...item,
href,
done,
};
}),
return {
...item,
href,
done,
};
}),
};
});

View File

@@ -1,5 +1,6 @@
import { ThemeToggle } from "@/components/ThemeToggle";
import { socials } from "@/lib/socials";
import { useFramework } from "@/lib/use-framework";
import { JazzLogo } from "gcmp-design-system/src/app/components/atoms/logos/JazzLogo";
import { Nav } from "gcmp-design-system/src/app/components/organisms/Nav";
import { DocNav } from "./docs/nav";

View File

@@ -8,7 +8,7 @@ for (const { packageName, entryPoint, tsconfig, typedocOptions } of [
},
{
packageName: "jazz-react",
entryPoint: "index.tsx",
entryPoint: "index.ts",
typedocOptions: {
skipErrorChecking: true, // TODO: remove this. Temporary workaround
},

View File

@@ -50,6 +50,13 @@ export const docNavigationItems = [
href: "/docs/project-setup/server-side",
done: 80,
},
{
// upgrade guides
name: "Enable local persistence",
href: "/docs/upgrade/react-native-local-persistence",
done: 100,
framework: "react-native",
},
{
// upgrade guides
name: "Upgrade to Jazz 0.9.0",

View File

@@ -1,5 +1,13 @@
# cojson-storage-indexeddb
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.9.0
### Patch Changes

View File

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

View File

@@ -0,0 +1,171 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
\*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
\*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
\*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
\*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*
.DS_Store

View File

@@ -0,0 +1,2 @@
coverage
node_modules

View File

@@ -0,0 +1,603 @@
# cojson-storage-sqlite
## 0.8.52
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.8.51
### Patch Changes
- 2be47d6: Fix priority of rn sqlite
## 0.8.50
### Patch Changes
- Updated dependencies [43378ef]
- cojson@0.8.50
- cojson-storage@0.8.50
## 0.8.49
### Patch Changes
- Updated dependencies [25dfd90]
- cojson@0.8.49
- cojson-storage@0.8.49
## 0.8.48
### Patch Changes
- Updated dependencies [10ea733]
- cojson@0.8.48
- cojson-storage@0.8.48
## 0.8.45
### Patch Changes
- Updated dependencies [6f0bd7f]
- Updated dependencies [fca6a0b]
- Updated dependencies [88d7d9a]
- cojson@0.8.45
- cojson-storage@0.8.45
## 0.8.44
### Patch Changes
- Updated dependencies [5d20c81]
- cojson@0.8.44
- cojson-storage@0.8.44
## 0.8.41
### Patch Changes
- Updated dependencies [3252502]
- Updated dependencies [6370348]
- Updated dependencies [ac216b9]
- cojson@0.8.41
- cojson-storage@0.8.41
## 0.8.40
### Patch Changes
- Updated dependencies [e905c84]
- cojson-storage@0.8.40
## 0.8.39
### Patch Changes
- ecc7c96: Bump better-sqlite3 dependency, which drops support for Node v21
- Updated dependencies [249eecb]
- Updated dependencies [3121551]
- cojson@0.8.39
- cojson-storage@0.8.39
## 0.8.38
### Patch Changes
- da13eca: Improve work scheduling under pressure
- Updated dependencies [b00ee91]
- Updated dependencies [f488c09]
- cojson@0.8.38
- cojson-storage@0.8.38
## 0.8.37
### Patch Changes
- Updated dependencies [3d9f12e]
- cojson@0.8.37
- cojson-storage@0.8.37
## 0.8.36
### Patch Changes
- 1afbd2c: Refactor the SQLite and IndexedDB storage packages to extract common synchronization functionality into newly created cojson-storage package.
- Updated dependencies [441fe27]
- Updated dependencies [1afbd2c]
- cojson@0.8.36
- cojson-storage@0.8.36
## 0.8.35
### Patch Changes
- 8b87117: Implement Group Inheritance
- Updated dependencies [3f15a23]
- Updated dependencies [46f2ab8]
- Updated dependencies [8b87117]
- Updated dependencies [a6b6ccf]
- cojson@0.8.35
## 0.8.34
### Patch Changes
- Updated dependencies [e4f110f]
- cojson@0.8.34
## 0.8.32
### Patch Changes
- Updated dependencies [df42b2b]
- cojson@0.8.32
## 0.8.31
### Patch Changes
- Updated dependencies [e511d6d]
- cojson@0.8.31
## 0.8.30
### Patch Changes
- Updated dependencies [0a2fae3]
- Updated dependencies [99cda2f]
- cojson@0.8.30
## 0.8.29
### Patch Changes
- Updated dependencies [dcc9c2e]
- Updated dependencies [699553f]
- cojson@0.8.29
## 0.8.28
### Patch Changes
- Updated dependencies [605734c]
- cojson@0.8.28
## 0.8.27
### Patch Changes
- Updated dependencies [75fdff4]
- cojson@0.8.27
## 0.8.25
### Patch Changes
- 63d46c9: Fix: sqlite not delivering depended-on CoValues
## 0.8.23
### Patch Changes
- Updated dependencies [6f745be]
- Updated dependencies [124bf67]
- cojson@0.8.23
## 0.8.21
### Patch Changes
- Updated dependencies [0f30eea]
- cojson@0.8.21
## 0.8.19
### Patch Changes
- Updated dependencies [9c2aadb]
- cojson@0.8.19
## 0.8.18
### Patch Changes
- Updated dependencies [d4319d8]
- cojson@0.8.18
## 0.8.17
### Patch Changes
- Updated dependencies [d433cf4]
- cojson@0.8.17
## 0.8.16
### Patch Changes
- Updated dependencies [b934fab]
- cojson@0.8.16
## 0.8.12
### Patch Changes
- 6ed75eb: Introduce "storage" peer role
- Updated dependencies [6ed75eb]
- cojson@0.8.12
## 0.8.11
### Patch Changes
- Updated dependencies [1ed4ab5]
- cojson@0.8.11
## 0.8.5
### Patch Changes
- Updated dependencies [c3f4e6b]
- Updated dependencies [d9152ed]
- cojson@0.8.5
## 0.8.3
### Patch Changes
- Updated dependencies
- cojson@0.8.3
## 0.8.0
### Patch Changes
- Updated dependencies [6a147c2]
- Updated dependencies [ad40b88]
- cojson@0.8.0
## 0.7.35
### Patch Changes
- f350e90: Added a priority system for the sync messages
- Updated dependencies [35bbcd9]
- Updated dependencies [f350e90]
- cojson@0.7.35
## 0.7.34
### Patch Changes
- Updated dependencies [5d91f9f]
- Updated dependencies [5094e6d]
- Updated dependencies [b09589b]
- Updated dependencies [2c3a40c]
- Updated dependencies [4e16575]
- Updated dependencies [ea882ab]
- cojson@0.7.34
## 0.7.34-neverthrow.8
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.8
## 0.7.34-neverthrow.7
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.7
## 0.7.34-neverthrow.4
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.4
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- 3bf5127: Allow crashing whole node on peer errors
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
## 0.7.33-hotfixes.6
### Patch Changes
- Get rid of simulated errors
## 0.7.33-hotfixes.5
### Patch Changes
- Make simulated errors even more likely
- Updated dependencies
- cojson@0.7.33-hotfixes.5
## 0.7.33-hotfixes.4
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.4
## 0.7.33-hotfixes.3
### Patch Changes
- Allow crashing whole node on peer errors
- Updated dependencies
- cojson@0.7.33-hotfixes.3
## 0.7.33-hotfixes.0
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.0
## 0.7.31
### Patch Changes
- Updated dependencies
- cojson@0.7.31
## 0.7.29
### Patch Changes
- Updated dependencies
- cojson@0.7.29
## 0.7.28
### Patch Changes
- Updated dependencies
- cojson@0.7.28
## 0.7.26
### Patch Changes
- Remove Effect from jazz/cojson internals
- Updated dependencies
- cojson@0.7.26
## 0.7.23
### Patch Changes
- Updated dependencies
- cojson@0.7.23
## 0.7.18
### Patch Changes
- Updated dependencies
- cojson@0.7.18
## 0.7.17
### Patch Changes
- Updated dependencies
- cojson@0.7.17
## 0.7.14
### Patch Changes
- Updated dependencies
- cojson@0.7.14
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
## 0.7.0
### Patch Changes
- c4151fc: Support stricter TS lint rules
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
## 0.7.0-alpha.42
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.42
## 0.7.0-alpha.39
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.39
## 0.7.0-alpha.38
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.38
## 0.7.0-alpha.37
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.37
## 0.7.0-alpha.36
### Patch Changes
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
## 0.7.0-alpha.35
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.35
## 0.7.0-alpha.29
### Patch Changes
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
## 0.7.0-alpha.28
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.28
## 0.7.0-alpha.27
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.27
## 0.7.0-alpha.24
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.24
## 0.7.0-alpha.11
### Patch Changes
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
## 0.7.0-alpha.10
### Patch Changes
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
## 0.5.3-alpha.1
### Patch Changes
- Use effect schema much less
- Updated dependencies
- cojson@0.7.0-alpha.1
## 0.5.3-alpha.0
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.0
## 0.5.2
### Patch Changes
- Updated dependencies
- cojson@0.6.0
## 0.5.1
### Patch Changes
- Make typedefs for better-sqlite3 a normal dependency
## 0.5.0
### Minor Changes
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
### Patch Changes
- Updated dependencies
- cojson@0.5.0

View File

@@ -0,0 +1,19 @@
Copyright 2024, Garden Computing, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,3 @@
# CoJSON Storage SQLite for React Native
This implements persistence for CoJSON / Jazz (see [jazz.tools](https://jazz.tools)) using SQLite.

View File

@@ -0,0 +1,23 @@
{
"name": "cojson-storage-rn-sqlite",
"type": "module",
"version": "0.8.52",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "workspace:*",
"cojson-storage": "workspace:*"
},
"devDependencies": {
"@op-engineering/op-sqlite": "^11.2.12",
"typescript": "~5.6.2"
},
"scripts": {
"dev": "tsc --watch --sourceMap --outDir dist",
"format-and-lint": "biome check .",
"format-and-lint:fix": "biome check . --write",
"build": "rm -rf ./dist && tsc --sourceMap --outDir dist",
"prepublishOnly": "npm run build"
}
}

View File

@@ -0,0 +1,159 @@
import { type DB as DatabaseT } from "@op-engineering/op-sqlite";
import { CojsonInternalTypes, type OutgoingSyncQueue, RawCoID } from "cojson";
import type {
DBClientInterface,
SessionRow,
SignatureAfterRow,
StoredCoValueRow,
StoredSessionRow,
TransactionRow,
} from "cojson-storage";
import { Transaction } from "cojson/src/coValueCore.js";
import { Signature } from "cojson/src/crypto/crypto.js";
export class SQLiteClient implements DBClientInterface {
private readonly db: DatabaseT;
constructor(db: DatabaseT, _: OutgoingSyncQueue) {
this.db = db;
}
async getCoValue(coValueId: RawCoID): Promise<StoredCoValueRow | undefined> {
const { rows } = await this.db.execute(
"SELECT * FROM coValues WHERE id = ?",
[coValueId],
);
if (!rows || rows.length === 0) return;
const coValueRow = rows[0] as any & { rowID: number };
try {
const parsedHeader =
coValueRow?.header &&
(JSON.parse(coValueRow.header) as CojsonInternalTypes.CoValueHeader);
return {
...coValueRow,
header: parsedHeader,
};
} catch (e) {
console.warn(coValueId, "Invalid JSON in header", e, coValueRow?.header);
return;
}
}
async getCoValueSessions(coValueRowId: number): Promise<StoredSessionRow[]> {
const { rows } = await this.db.execute(
"SELECT * FROM sessions WHERE coValue = ?",
[coValueRowId],
);
return rows as StoredSessionRow[];
}
async getNewTransactionInSession(
sessionRowId: number,
firstNewTxIdx: number,
): Promise<TransactionRow[]> {
const { rows } = await this.db.execute(
"SELECT * FROM transactions WHERE ses = ? AND idx >= ?",
[sessionRowId, firstNewTxIdx],
);
if (!rows || rows.length === 0) return [];
try {
return rows.map((row: any) => ({
...row,
tx: JSON.parse(row.tx) as Transaction,
}));
} catch (e) {
console.warn("Invalid JSON in transaction", e);
return [];
}
}
getSignatures(
sessionRowId: number,
firstNewTxIdx: number,
): Promise<SignatureAfterRow[]> | SignatureAfterRow[] {
const { rows } = this.db.executeSync(
"SELECT * FROM signatureAfter WHERE ses = ? AND idx >= ?",
[sessionRowId, firstNewTxIdx],
);
return rows as SignatureAfterRow[];
}
async addCoValue(
msg: CojsonInternalTypes.NewContentMessage,
): Promise<number> {
const { insertId } = await this.db.execute(
"INSERT INTO coValues (id, header) VALUES (?, ?)",
[msg.id, JSON.stringify(msg.header)],
);
return insertId ?? 0;
}
async addSessionUpdate({
sessionUpdate,
}: {
sessionUpdate: SessionRow;
}): Promise<number> {
const { rows } = await this.db.execute(
`INSERT INTO sessions (coValue, sessionID, lastIdx, lastSignature, bytesSinceLastSignature)
VALUES (?, ?, ?, ?, ?)
ON CONFLICT(coValue, sessionID)
DO UPDATE SET lastIdx=excluded.lastIdx,
lastSignature=excluded.lastSignature,
bytesSinceLastSignature=excluded.bytesSinceLastSignature
RETURNING rowID`,
[
sessionUpdate.coValue,
sessionUpdate.sessionID,
sessionUpdate.lastIdx,
sessionUpdate.lastSignature,
sessionUpdate.bytesSinceLastSignature!,
],
);
return rows[0]?.rowID as number;
}
async addTransaction(
sessionRowID: number,
nextIdx: number,
newTransaction: Transaction,
): Promise<void> {
await this.db.execute(
"INSERT INTO transactions (ses, idx, tx) VALUES (?, ?, ?)",
[sessionRowID, nextIdx, JSON.stringify(newTransaction)],
);
}
async addSignatureAfter({
sessionRowID,
idx,
signature,
}: {
sessionRowID: number;
idx: number;
signature: Signature;
}): Promise<void> {
await this.db.execute(
"INSERT INTO signatureAfter (ses, idx, signature) VALUES (?, ?, ?)",
[sessionRowID, idx, signature],
);
}
async unitOfWork(
operationsCallback: () => Promise<unknown>[],
): Promise<void> {
try {
await this.db.transaction(async () => {
await Promise.all(operationsCallback());
});
} catch (e) {
console.error("Transaction failed:", e);
throw e;
}
}
}

View File

@@ -0,0 +1,4 @@
export {
SQLiteReactNative,
SQLiteReactNative as SQLiteStorage,
} from "./sqlite-react-native.js";

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