Compare commits

..

94 Commits

Author SHA1 Message Date
Guido D'Orsi
99e88d3497 Merge pull request #1220 from garden-co/changeset-release/main
Version Packages
2025-01-20 13:06:56 +01:00
github-actions[bot]
f09ce70d3c Version Packages 2025-01-20 11:57:26 +00:00
Guido D'Orsi
7d62e2735f Merge pull request #1219 from garden-co/custom-logger
feat: make it possible to customize the logger in cojson
2025-01-20 12:56:11 +01:00
Guido D'Orsi
5863badbb0 feat: make it possible to customize the logger in cojson 2025-01-20 12:34:31 +01:00
Guido D'Orsi
56d26222e7 Merge pull request #1214 from garden-co/feat/queue-optimization
perf: optimize queue processing under heavy load
2025-01-20 12:30:58 +01:00
Guido D'Orsi
bd34084104 Merge pull request #1218 from garden-co/feat/inspector-component
feat: in-app inspector component for react web
2025-01-20 12:27:09 +01:00
Guido D'Orsi
f5e6fe927d chore: clean deps 2025-01-20 12:21:56 +01:00
Guido D'Orsi
93c49639c2 feat: in-app inspector component 2025-01-19 19:58:07 +01:00
Guido D'Orsi
909165d813 test: cover nested SchemaUnion 2025-01-18 00:27:33 +01:00
Guido D'Orsi
6bee742b65 Merge pull request #1207 from garden-co/changeset-release/main
Version Packages
2025-01-18 00:26:30 +01:00
github-actions[bot]
23486d01b9 Version Packages 2025-01-17 23:23:34 +00:00
Guido D'Orsi
b761d5a730 Merge pull request #1215 from garden-co/fix/auth-issues
fix: improve error management on initial auth, fixed an infinite loop when migration fails
2025-01-18 00:22:06 +01:00
Guido D'Orsi
9181e74fc8 chore: add ts-ignore on an error flagged by some Typescript versions 2025-01-18 00:14:54 +01:00
Guido D'Orsi
5e83864f41 fix: improve error management on initial auth, fixed an infinite loop when migration fails 2025-01-18 00:12:46 +01:00
Guido D'Orsi
789cf66de2 test: fix failing test 2025-01-17 20:00:44 +01:00
Guido D'Orsi
de5f2d6d5b Merge pull request #1213 from garden-co/fix/handle-unknown-covaule-types
perf: skip coValue content creation on access
2025-01-17 14:44:03 +01:00
Guido D'Orsi
4aa377dea7 chore: changeset 2025-01-17 14:42:05 +01:00
Guido D'Orsi
efbf3d84ac chore: changeset 2025-01-17 14:41:51 +01:00
Guido D'Orsi
b90393b43e perf: optimize queue processing under heavy load 2025-01-17 14:28:00 +01:00
Guido D'Orsi
31ae73fe0e perf: skip coValue content creation on access 2025-01-17 12:49:24 +01:00
Guido D'Orsi
7a5adfc4dc Merge pull request #1212 from garden-co/fix/handle-unknown-covaule-types
feat: handle unknown coValue content instead of triggering an error
2025-01-17 12:23:50 +01:00
Guido D'Orsi
850e264912 feat: handle unknown coValue content instead of triggering an error 2025-01-17 12:02:32 +01:00
Anselm Eickhoff
aa81779ad8 Update page.tsx 2025-01-17 09:59:40 +00:00
Guido D'Orsi
72c97c0835 Merge pull request #1208 from garden-co/0.9.8-changelog
docs: add the 0.9.8 changelog
2025-01-14 18:35:21 +01:00
Guido D'Orsi
12809a6733 docs: add the 0.9.8 changelog 2025-01-14 17:21:51 +01:00
Guido D'Orsi
c55aeff98e docs: fix CoMap load & subscribe docs example 2025-01-14 16:56:47 +01:00
Guido D'Orsi
16b76e401c docs: fix jazz-tools tsDoc generation 2025-01-14 16:48:42 +01:00
Guido D'Orsi
d2470efd6f test: add a test to cover an indirect communication between nodes 2025-01-14 16:45:11 +01:00
pax
1a97b1b77c Merge pull request #1205 from garden-co/JAZZ-647/fix-image-handling-in-rn-chat-demo
Fix image handling in RN Chat Demo
2025-01-14 17:43:54 +02:00
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
pax-k
f76274c19a chore: changeset 2025-01-14 15:15:59 +02: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
pax-k
cb1b602255 Merge remote-tracking branch 'upstream/main' into JAZZ-647/fix-image-handling-in-rn-chat-demo 2025-01-14 15:14:30 +02:00
pax-k
a728dbf632 fix: image handling in react-native 2025-01-14 15:14:06 +02: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
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
Trisha Lim
f002110c28 Allow partial options in create-jazz-app 2025-01-12 13:53:37 +00: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
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
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
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
227 changed files with 7484 additions and 1333 deletions

View File

@@ -1,5 +1,46 @@
# chat-rn-clerk # chat-rn-clerk
## 1.0.52
### Patch Changes
- jazz-react-native@0.9.11
- jazz-react-native-auth-clerk@0.9.11
- jazz-tools@0.9.11
- jazz-react-native-media-images@0.9.11
## 1.0.51
### Patch Changes
- f76274c: Fix image handling in react-native
- Updated dependencies [f76274c]
- Updated dependencies [5e83864]
- jazz-react-native@0.9.10
- jazz-tools@0.9.10
- jazz-react-native-auth-clerk@0.9.10
- jazz-react-native-media-images@0.9.10
## 1.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
- jazz-react-native-auth-clerk@0.9.9
- jazz-react-native-media-images@0.9.9
## 1.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
- jazz-react-native-auth-clerk@0.9.8
- jazz-react-native-media-images@0.9.8
## 1.0.48 ## 1.0.48
### Patch Changes ### Patch Changes

View File

@@ -37,7 +37,13 @@
], ],
"expo-secure-store", "expo-secure-store",
"expo-font", "expo-font",
"expo-router" "expo-router",
[
"expo-image-picker",
{
"photosPermission": "The app accesses your photos to let you share them with your friends."
}
]
], ],
"extra": { "extra": {
"eas": { "eas": {

View File

@@ -2,8 +2,11 @@ import { Chat, Message } from "@/src/schema";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import clsx from "clsx"; import clsx from "clsx";
import * as Clipboard from "expo-clipboard"; import * as Clipboard from "expo-clipboard";
import * as ImagePicker from "expo-image-picker";
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { useAccount, useCoState } from "jazz-react-native"; import { useAccount, useCoState } from "jazz-react-native";
import { ProgressiveImg } from "jazz-react-native";
import { createImage } from "jazz-react-native-media-images";
import { Group, ID } from "jazz-tools"; import { Group, ID } from "jazz-tools";
import { useEffect, useLayoutEffect, useState } from "react"; import { useEffect, useLayoutEffect, useState } from "react";
import React, { import React, {
@@ -16,6 +19,8 @@ import React, {
KeyboardAvoidingView, KeyboardAvoidingView,
TextInput, TextInput,
Button, Button,
Image,
ActivityIndicator,
} from "react-native"; } from "react-native";
export default function Conversation() { export default function Conversation() {
@@ -25,6 +30,7 @@ export default function Conversation() {
const [message, setMessage] = useState(""); const [message, setMessage] = useState("");
const loadedChat = useCoState(Chat, chat?.id, [{}]); const loadedChat = useCoState(Chat, chat?.id, [{}]);
const navigation = useNavigation(); const navigation = useNavigation();
const [isUploading, setIsUploading] = useState(false);
useEffect(() => { useEffect(() => {
if (chat) return; if (chat) return;
@@ -81,6 +87,32 @@ export default function Conversation() {
} }
}; };
const handleImageUpload = async () => {
try {
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
base64: true,
quality: 0.7,
});
if (!result.canceled && result.assets[0].base64 && chat) {
setIsUploading(true);
const base64Uri = `data:image/jpeg;base64,${result.assets[0].base64}`;
const image = await createImage(base64Uri, {
owner: chat._owner,
maxSize: 2048,
});
chat.push(Message.create({ text: "", image }, { owner: chat._owner }));
}
} catch (error) {
Alert.alert("Error", "Failed to upload image");
} finally {
setIsUploading(false);
}
};
const renderMessageItem = ({ item }: { item: Message }) => { const renderMessageItem = ({ item }: { item: Message }) => {
const isMe = item._edits.text.by?.isMe; const isMe = item._edits.text.by?.isMe;
return ( return (
@@ -106,14 +138,27 @@ export default function Conversation() {
isMe ? "flex-row" : "flex-row", isMe ? "flex-row" : "flex-row",
)} )}
> >
<Text {item.image && (
className={clsx( <ProgressiveImg image={item.image} maxWidth={1024}>
!isMe ? "text-black" : "text-gray-200", {({ src, res, originalSize }) => (
`text-md max-w-[85%]`, <Image
)} source={{ uri: src }}
> className="w-48 h-48 rounded-lg mb-2"
{item.text} resizeMode="cover"
</Text> />
)}
</ProgressiveImg>
)}
{item.text && (
<Text
className={clsx(
!isMe ? "text-black" : "text-gray-200",
`text-md max-w-[85%]`,
)}
>
{item.text}
</Text>
)}
<Text <Text
className={clsx( className={clsx(
"text-[10px] text-right ml-2", "text-[10px] text-right ml-2",
@@ -147,6 +192,17 @@ export default function Conversation() {
className="p-3 bg-white border-t border-gray-300" className="p-3 bg-white border-t border-gray-300"
> >
<SafeAreaView className="flex-row items-center gap-2"> <SafeAreaView className="flex-row items-center gap-2">
<TouchableOpacity
onPress={handleImageUpload}
disabled={isUploading}
className="h-10 w-10 items-center justify-center"
>
{isUploading ? (
<ActivityIndicator size="small" color="#0000ff" />
) : (
<Text className="text-2xl">🖼</Text>
)}
</TouchableOpacity>
<TextInput <TextInput
className="flex-1 rounded-full h-10 px-4 bg-gray-100 border border-gray-300 focus:border-blue-500 focus:bg-white" className="flex-1 rounded-full h-10 px-4 bg-gray-100 border border-gray-300 focus:border-blue-500 focus:bg-white"
value={message} value={message}

View File

@@ -1,7 +1,7 @@
{ {
"name": "chat-rn-clerk", "name": "chat-rn-clerk",
"main": "index.js", "main": "index.js",
"version": "1.0.48", "version": "1.0.52",
"scripts": { "scripts": {
"build": "expo export -p ios", "build": "expo export -p ios",
"start": "expo start", "start": "expo start",
@@ -35,6 +35,7 @@
"expo-dev-client": "~5.0.5", "expo-dev-client": "~5.0.5",
"expo-file-system": "^18.0.4", "expo-file-system": "^18.0.4",
"expo-font": "~13.0.1", "expo-font": "~13.0.1",
"expo-image-picker": "~16.0.4",
"expo-linking": "~7.0.3", "expo-linking": "~7.0.3",
"expo-router": "~4.0.11", "expo-router": "~4.0.11",
"expo-secure-store": "~14.0.0", "expo-secure-store": "~14.0.0",

View File

@@ -1,7 +1,8 @@
import { CoList, CoMap, co } from "jazz-tools"; import { CoList, CoMap, ImageDefinition, co } from "jazz-tools";
export class Message extends CoMap { export class Message extends CoMap {
text = co.string; text = co.string;
image = co.optional.ref(ImageDefinition);
} }
export class Chat extends CoList.Of(co.ref(Message)) {} export class Chat extends CoList.Of(co.ref(Message)) {}

View File

@@ -1,5 +1,37 @@
# chat-rn # chat-rn
## 1.0.49
### Patch Changes
- jazz-react-native@0.9.11
- jazz-tools@0.9.11
## 1.0.48
### Patch Changes
- Updated dependencies [f76274c]
- Updated dependencies [5e83864]
- jazz-react-native@0.9.10
- jazz-tools@0.9.10
## 1.0.47
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
## 1.0.46
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
## 1.0.45 ## 1.0.45
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,40 @@
# chat-vue # chat-vue
## 0.0.36
### Patch Changes
- jazz-browser@0.9.11
- jazz-tools@0.9.11
- jazz-vue@0.9.11
## 0.0.35
### Patch Changes
- Updated dependencies [5e83864]
- jazz-tools@0.9.10
- jazz-browser@0.9.10
- jazz-vue@0.9.10
## 0.0.34
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser@0.9.9
- jazz-vue@0.9.9
## 0.0.33
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-browser@0.9.8
- jazz-vue@0.9.8
## 0.0.32 ## 0.0.32
### Patch Changes ### Patch Changes

View File

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

View File

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

View File

@@ -1,5 +1,41 @@
# jazz-example-chat # jazz-example-chat
## 0.0.132
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.131
### Patch Changes
- f76274c: Fix image handling in react-native
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 0.0.130
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.129
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.128 ## 0.0.128
### Patch Changes ### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,40 @@
# minimal-auth-clerk # minimal-auth-clerk
## 0.0.31
### Patch Changes
- jazz-react@0.9.11
- jazz-react-auth-clerk@0.9.11
- jazz-tools@0.9.11
## 0.0.30
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-react-auth-clerk@0.9.10
## 0.0.29
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
- jazz-react-auth-clerk@0.9.9
## 0.0.28
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-react-auth-clerk@0.9.8
## 0.0.27 ## 0.0.27
### Patch Changes ### 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 Live version: https://clerk-demo.jazz.tools
## Installing & running the example locally ## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation)) You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash ```bash
npx degit gardencmp/jazz jazz 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 ```bash
cd jazz/examples/clerk cd clerk
``` ```
Install and build dependencies: Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/clerk/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,36 @@
# file-share-svelte # file-share-svelte
## 0.0.16
### Patch Changes
- jazz-svelte@0.9.11
- jazz-tools@0.9.11
## 0.0.15
### Patch Changes
- Updated dependencies [5e83864]
- jazz-tools@0.9.10
- jazz-svelte@0.9.10
## 0.0.14
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-svelte@0.9.9
## 0.0.13
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-svelte@0.9.8
## 0.0.12 ## 0.0.12
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,40 @@
# form # form
## 0.0.27
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.26
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 0.0.25
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.24
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.23 ## 0.0.23
### Patch Changes ### 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) [See the full guide here.](https://jazz.tools/docs/react/design-patterns/form)
## Installing & running the example locally ## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation)) You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash ```bash
npx degit gardencmp/jazz jazz 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 ```bash
cd jazz/examples/form cd form
``` ```
Install and build dependencies: Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/form/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

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

View File

@@ -1,5 +1,40 @@
# image-upload # image-upload
## 0.0.29
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.28
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 0.0.27
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.26
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.25 ## 0.0.25
### Patch Changes ### 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 Live version: https://image-upload-demo.jazz.tools
## Installing & running the example locally ## Getting started
(This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation)) You can either
1. Clone the jazz repository, and run the app within the monorepo.
2. Or create a new Jazz project using this example as a template.
Start by downloading the [jazz repository](https://github.com/garden-co/jazz):
### Using the example as a template
Create a new Jazz project, and use this example as a template.
```bash ```bash
npx degit gardencmp/jazz jazz 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 ```bash
cd jazz/examples/image-upload cd image-upload
``` ```
Install and build dependencies: Run the dev server.
```bash
npm run dev
```
### Using the monorepo
This requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation).
Clone the jazz repository.
```bash
git clone https://github.com/garden-co/jazz.git
```
Install and build dependencies.
```bash ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/image-upload/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,30 @@
# jazz-example-inspector # jazz-example-inspector
## 0.0.96
### Patch Changes
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
- cojson-transport-ws@0.9.11
## 0.0.95
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
- cojson-transport-ws@0.9.10
## 0.0.94
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-transport-ws@0.9.9
## 0.0.93 ## 0.0.93
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,37 @@
# jazz-example-musicplayer # jazz-example-musicplayer
## 0.0.52
### Patch Changes
- jazz-inspector@0.9.11
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.51
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 0.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.48 ## 0.0.48
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,7 +1,7 @@
{ {
"name": "jazz-example-music-player", "name": "jazz-example-music-player",
"private": true, "private": true,
"version": "0.0.48", "version": "0.0.52",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -18,8 +18,9 @@
"@radix-ui/react-toast": "^1.1.4", "@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"jazz-react": "workspace:0.9.4", "jazz-react": "workspace:0.9.11",
"jazz-tools": "workspace:0.9.1", "jazz-tools": "workspace:0.9.11",
"jazz-inspector": "workspace:*",
"lucide-react": "^0.274.0", "lucide-react": "^0.274.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",

View File

@@ -1,4 +1,5 @@
import { Toaster } from "@/components/ui/toaster"; import { Toaster } from "@/components/ui/toaster";
import { JazzInspector } from "jazz-inspector";
/* eslint-disable react-refresh/only-export-components */ /* eslint-disable react-refresh/only-export-components */
import React from "react"; import React from "react";
import ReactDOM from "react-dom/client"; import ReactDOM from "react-dom/client";
@@ -65,12 +66,13 @@ function JazzAndAuth({ children }: { children: React.ReactNode }) {
return ( return (
<> <>
<JazzProvider <JazzProvider
storage={["singleTabOPFS", "indexedDB"]} storage="indexedDB"
auth={auth} auth={auth}
peer={peer} peer={peer}
AccountSchema={MusicaAccount} AccountSchema={MusicaAccount}
> >
{children} {children}
<JazzInspector />
</JazzProvider> </JazzProvider>
<DemoAuthBasicUI appName="Jazz Music Player" state={state} /> <DemoAuthBasicUI appName="Jazz Music Player" state={state} />
</> </>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,40 @@
# jazz-example-onboarding # jazz-example-onboarding
## 0.0.33
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.32
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 0.0.31
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.30
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.29 ## 0.0.29
### Patch Changes ### Patch Changes

View File

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

View File

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

View File

@@ -1,5 +1,36 @@
# organization # organization
## 0.0.25
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.24
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 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 ## 0.0.21
### Patch Changes ### 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. 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 ```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 ```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 ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/organization/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,29 @@
# passkey-svelte # passkey-svelte
## 0.0.20
### Patch Changes
- jazz-svelte@0.9.11
## 0.0.19
### Patch Changes
- jazz-svelte@0.9.10
## 0.0.18
### Patch Changes
- jazz-svelte@0.9.9
## 0.0.17
### Patch Changes
- jazz-svelte@0.9.8
## 0.0.16 ## 0.0.16
### Patch Changes ### Patch Changes

View File

@@ -10,34 +10,59 @@ This example showcases how to:
- Manage authentication state - Manage authentication state
- Implement secure login/logout flows - 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 git clone https://github.com/garden-co/jazz.git
``` ```
2. Navigate to the example directory: Install and build dependencies.
```bash
```sh pnpm i && npx turbo build
cd examples/passkey-svelte
``` ```
3. Install dependencies: Go to the example directory.
```bash
```sh cd jazz/examples/passkey-svelte/
pnpm install
``` ```
4. Start the development server: Start the dev server.
```bash
```sh
pnpm dev 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 ## Learn More

View File

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

View File

@@ -1,5 +1,36 @@
# minimal-auth-passkey # minimal-auth-passkey
## 0.0.30
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.29
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 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 ## 0.0.26
### Patch Changes ### 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 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 ```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 ```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 ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/passkey/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,36 @@
# jazz-password-manager # jazz-password-manager
## 0.0.51
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.50
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 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 ## 0.0.47
### Patch Changes ### Patch Changes

View File

@@ -4,30 +4,60 @@ Live version: https://passwords-demo.jazz.tools
![Password Manager Screenshot](demo.png "Screenshot") ![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 ```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 ```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 ```bash
pnpm i && npx turbo build 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 ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Structure ## Structure
- [`src/components`](./src/components/): UI components - [`src/components`](./src/components/): UI components

View File

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

View File

@@ -1,5 +1,40 @@
# jazz-example-pets # jazz-example-pets
## 0.0.149
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.148
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 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 ## 0.0.145
### Patch Changes ### Patch Changes

View File

@@ -2,30 +2,59 @@
Live version: https://pets-demo.jazz.tools/ 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 ```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 ```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 ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/pets/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback

View File

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

View File

@@ -1,5 +1,40 @@
# reactions # reactions
## 0.0.29
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
- jazz-browser-media-images@0.9.11
## 0.0.28
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
- jazz-browser-media-images@0.9.10
## 0.0.27
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-browser-media-images@0.9.9
- jazz-react@0.9.9
## 0.0.26
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-browser-media-images@0.9.8
## 0.0.25 ## 0.0.25
### Patch Changes ### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: [https://reactions-demo.jazz.tools](https://reactions-demo.jazz.tools) 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 ```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 ```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 ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/reactions/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,40 @@
# todo-vue # todo-vue
## 0.0.34
### Patch Changes
- jazz-browser@0.9.11
- jazz-tools@0.9.11
- jazz-vue@0.9.11
## 0.0.33
### Patch Changes
- Updated dependencies [5e83864]
- jazz-tools@0.9.10
- jazz-browser@0.9.10
- jazz-vue@0.9.10
## 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 ## 0.0.30
### Patch Changes ### Patch Changes

View File

@@ -1,29 +1,59 @@
# Todo list example with Jazz and Vue # 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 ```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 ```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 ```bash
pnpm i && npx turbo build 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 ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -1,5 +1,36 @@
# jazz-example-todo # jazz-example-todo
## 0.0.148
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.147
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 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 ## 0.0.144
### Patch Changes ### Patch Changes

View File

@@ -2,30 +2,60 @@
Live version: https://todo-demo.jazz.tools/ 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 ```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 ```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 ```bash
pnpm i && npx turbo build pnpm i && npx turbo build
``` ```
Start the dev server: Go to the example directory.
```bash
cd jazz/examples/todo/
```
Start the dev server.
```bash ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Structure ## Structure
- [`src/basicComponents`](./src/basicComponents): simple components to build the UI, unrelated to Jazz (uses [shadcn/ui](https://ui.shadcn.com)) - [`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", "name": "jazz-example-todo",
"private": true, "private": true,
"version": "0.0.144", "version": "0.0.148",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -16,8 +16,8 @@
"@radix-ui/react-toast": "^1.1.4", "@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"jazz-react": "workspace:0.9.4", "jazz-react": "workspace:0.9.11",
"jazz-tools": "workspace:0.9.1", "jazz-tools": "workspace:0.9.11",
"lucide-react": "^0.274.0", "lucide-react": "^0.274.0",
"qrcode": "^1.5.3", "qrcode": "^1.5.3",
"react": "^18.3.1", "react": "^18.3.1",

View File

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

View File

@@ -1,5 +1,36 @@
# version-history # version-history
## 0.0.26
### Patch Changes
- jazz-react@0.9.11
- jazz-tools@0.9.11
## 0.0.25
### Patch Changes
- Updated dependencies [5e83864]
- jazz-react@0.9.10
- jazz-tools@0.9.10
## 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 ## 0.0.22
### Patch Changes ### 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. 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 ```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 ```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 ```bash
pnpm i && npx turbo build 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 ```bash
pnpm dev pnpm dev
``` ```
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
## Questions / problems / feedback ## Questions / problems / feedback
If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong. If you have feedback, let us know on [Discord](https://discord.gg/utDMjHYg42) or open an issue or PR to fix something that seems wrong.

View File

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

View File

@@ -61,14 +61,6 @@ const team: Array<TeamMember> = [
location: "Portsmouth, UK ", location: "Portsmouth, UK ",
github: "bensleveritt", github: "bensleveritt",
}, },
{
name: "Marina Orlova",
titles: ["Full-Stack Dev"],
location: "Tarragona, Spain ",
linkedin: "marina-orlova-52a34394",
github: "marinoska",
image: "marina.jpeg",
},
{ {
name: "Giordano Ricci", name: "Giordano Ricci",
titles: ["Full-Stack Dev", "DevOps"], titles: ["Full-Stack Dev", "DevOps"],

View File

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

View File

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

View File

@@ -36,9 +36,9 @@ You can add group members by ID by using `Account.load` and `Group.addMember`.
```tsx ```tsx
import { Group, Account } from "jazz-tools"; 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"); group.addMember(bob, "writer");
``` ```
</CodeGroup> </CodeGroup>
@@ -49,7 +49,7 @@ Note: if the account ID is of type `string`, because it comes from a URL paramet
```tsx ```tsx
import { Group, Account, ID } from "jazz-tools"; 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"); group.addMember(bob, "writer");
``` ```
</CodeGroup> </CodeGroup>

View File

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

View File

@@ -186,10 +186,8 @@ Now, finally, let's implement creating an issue:
import { useState } from "react"; // old import { useState } from "react"; // old
import { Issue } from "./schema"; // old import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount } from "jazz-react";
// old // old
function App() {// old function App() {// old
const { me } = useAccount();
const [issue, setIssue] = useState<Issue>(); // old const [issue, setIssue] = useState<Issue>(); // old
// old // old
const createIssue = () => { const createIssue = () => {
@@ -200,7 +198,6 @@ function App() {// old
estimate: 5, estimate: 5,
status: "backlog", status: "backlog",
}, },
{ owner: me },
); );
setIssue(newIssue); setIssue(newIssue);
}; };
@@ -234,7 +231,7 @@ We'll already notice one interesting thing here:
- We have to create every CoValue with an `owner`! - 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" - 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.** **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 { useState } from "react"; // old
import { Issue } from "./schema"; // old import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // old import { IssueComponent } from "./components/Issue.tsx"; // old
import { useAccount, useCoState } from "jazz-react"; import { useCoState } from "jazz-react";
import { ID } from "jazz-tools" import { ID } from "jazz-tools"
// old // old
function App() { // old function App() { // old
const { me } = useAccount(); // old
const [issueID, setIssueID] = useState<ID<Issue>>(); const [issueID, setIssueID] = useState<ID<Issue>>();
// old // old
const issue = useCoState(Issue, issueID); const issue = useCoState(Issue, issueID);
@@ -277,7 +273,6 @@ function App() { // old
estimate: 5, // old estimate: 5, // old
status: "backlog", // old status: "backlog", // old
}, // old }, // old
{ owner: me }, // old
); // old ); // old
setIssueID(newIssue.id); setIssueID(newIssue.id);
}; // old }; // old
@@ -381,10 +376,9 @@ This works because CoValues
<CodeGroup size="sm"> <CodeGroup size="sm">
```ts ```ts
function useCoState<V extends CoValue>(Schema: CoValueClass<V>, id?: ID<V>): V | undefined { function useCoState<V extends CoValue>(Schema: CoValueClass<V>, id?: ID<V>): V | undefined {
const { me } = useAccount();
const [value, setValue] = useState<V>(); const [value, setValue] = useState<V>();
useEffect(() => Schema.subscribe(id, me, [], setValue), [id]); useEffect(() => Schema.subscribe(id, [], setValue), [id]);
return value; 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 { useState } from "react"; // old
import { Issue } from "./schema"; // old import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // 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 import { ID } from "jazz-tools" // old
// old // old
function App() { // old function App() { // old
const { me } = useAccount(); // old
const [issueID, setIssueID] = useState<ID<Issue> | undefined>( const [issueID, setIssueID] = useState<ID<Issue> | undefined>(
(window.location.search?.replace("?issue=", "") || undefined) as ID<Issue> | undefined, (window.location.search?.replace("?issue=", "") || undefined) as ID<Issue> | undefined,
); );
@@ -428,7 +421,6 @@ function App() { // old
estimate: 5, // old estimate: 5, // old
status: "backlog", // old status: "backlog", // old
}, // old }, // old
{ owner: me }, // old
); // old ); // old
setIssueID(newIssue.id); // old setIssueID(newIssue.id); // old
window.history.pushState({}, "", `?issue=${newIssue.id}`); 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 { useState } from "react"; // old
import { Issue } from "./schema"; // old import { Issue } from "./schema"; // old
import { IssueComponent } from "./components/Issue.tsx"; // 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" import { ID, Group } from "jazz-tools"
// old // old
function App() { // 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 { useState } from "react"; // old
import { Project, ListOfIssues } from "./schema"; import { Project, ListOfIssues } from "./schema";
import { ProjectComponent } from "./components/Project.tsx"; import { ProjectComponent } from "./components/Project.tsx";
import { useAccount } from "jazz-react";
import { ID, Group } from "jazz-tools" import { ID, Group } from "jazz-tools"
// old // old
function App() { // old function App() { // old
const { me } = useAccount(); // old
const [projectID, setProjectID] = useState<ID<Project> | undefined>( const [projectID, setProjectID] = useState<ID<Project> | undefined>(
(window.location.search?.replace("?project=", "") || undefined) as 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* const issue = useCoState(Issue, issueID); // *bin*
// old // old
const createProject = () => { const createProject = () => {
const group = Group.create({ owner: me }); const group = Group.create();
group.addMember("everyone", "writer"); group.addMember("everyone", "writer");
const newProject = Project.create( const newProject = Project.create(
@@ -584,7 +574,7 @@ function App() { // old
name: "New Project", name: "New Project",
issues: ListOfIssues.create([], { owner: group }) issues: ListOfIssues.create([], { owner: group })
}, },
{ owner: group }, group,
); );
setProjectID(newProject.id); setProjectID(newProject.id);
window.history.pushState({}, "", `?project=${newProject.id}`); window.history.pushState({}, "", `?project=${newProject.id}`);
@@ -622,7 +612,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {
description: "", description: "",
estimate: 0, estimate: 0,
status: "backlog", status: "backlog",
}, { owner: project._owner })); }, project._owner));
}; };
return project ? ( return project ? (
@@ -673,7 +663,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {//
description: "",// old description: "",// old
estimate: 0,// old estimate: 0,// old
status: "backlog",// old status: "backlog",// old
}, { owner: project._owner }));// old }, project._owner));// old
};// old };// old
// old // old
return project ? (// 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 { useState } from "react"; // old
import { Project, ListOfIssues } from "./schema"; // old import { Project, ListOfIssues } from "./schema"; // old
import { ProjectComponent } from "./components/Project.tsx"; // old import { ProjectComponent } from "./components/Project.tsx"; // old
import { useAccount } from "jazz-react"; // old
import { ID, Group } from "jazz-tools" // old import { ID, Group } from "jazz-tools" // old
// old // old
function App() { // old function App() { // old
const { me } = useAccount(); // old
const [projectID, setProjectID] = useState<ID<Project> | undefined>( // old const [projectID, setProjectID] = useState<ID<Project> | undefined>( // old
(window.location.search?.replace("?project=", "") || undefined) as ID<Project> | undefined, // old (window.location.search?.replace("?project=", "") || undefined) as ID<Project> | undefined, // old
); // old ); // old
// old // old
const createProject = () => { // old const createProject = () => { // old
const group = Group.create({ owner: me }); // old const group = Group.create(); // old
group.addMember("everyone", "writer"); // *bin* group.addMember("everyone", "writer"); // *bin*
// old // old
const newProject = Project.create( // old const newProject = Project.create( // old
@@ -749,7 +737,7 @@ function App() { // old
name: "New Project", // old name: "New Project", // old
issues: ListOfIssues.create([], { owner: group }) // old issues: ListOfIssues.create([], { owner: group }) // old
}, // old }, // old
{ owner: group }, // old group, // old
); // old ); // old
setProjectID(newProject.id); // old setProjectID(newProject.id); // old
window.history.pushState({}, "", `?project=${newProject.id}`); // old window.history.pushState({}, "", `?project=${newProject.id}`); // old
@@ -792,7 +780,7 @@ export function ProjectComponent({ projectID }: { projectID: ID<Project> }) {//
description: "",// old description: "",// old
estimate: 0,// old estimate: 0,// old
status: "backlog",// old status: "backlog",// old
}, { owner: project._owner }));// old }, project._owner));// old
};// old };// old
// old // old
return project ? (// old return project ? (// old

View File

@@ -186,19 +186,40 @@ Lastly, ensure that the `"main"` field in your `package.json` points to `index.j
``` ```
</CodeGroup> </CodeGroup>
## Using Jazz ## Setting up the provider
### `createJazzRNApp()` Wrap your app components with the `JazzProvider:
Create a file `jazz.tsx` with the following contents:
<CodeGroup> <CodeGroup>
```tsx ```tsx
import { createJazzRNApp } from "jazz-react-native"; 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> </CodeGroup>
You can optionally pass a custom `kvStore` and `AccountSchema` to `createJazzRNApp()`, otherwise, it defaults to `ExpoSecureStoreAdapter` and `Account`. You can optionally pass a custom `kvStore` and `AccountSchema` to `createJazzRNApp()`, otherwise, it defaults to `ExpoSecureStoreAdapter` and `Account`.
@@ -219,24 +240,77 @@ In the demos, you'll find details on:
### Working with Images ### Working with Images
To work with images in Jazz, import the `createImage` function from [`jazz-react-native-media-images`](https://github.com/garden-co/jazz/tree/main/packages/jazz-react-native-media-images). Jazz provides a complete solution for handling images in React Native, including uploading, processing, and displaying them. Here's how to work with images:
#### Uploading Images
To upload images, use the `createImage` function from `jazz-react-native-media-images`. This function handles image processing and creates an `ImageDefinition` that can be stored in your Jazz covalues:
<CodeGroup> <CodeGroup>
```tsx ```tsx
import { createImage } from "jazz-react-native-media-images"; import { createImage } from "jazz-react-native-media-images";
import * as ImagePicker from 'expo-image-picker';
const base64ImageDataURI = "data:image/png;base64,..."; // Example: Image upload from device library
const handleImageUpload = async () => {
try {
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
base64: true, // Important: We need base64 data
quality: 0.7,
});
const image = await createImage(base64ImageDataURI, { if (!result.canceled && result.assets[0].base64) {
owner: newPetPost._owner, const base64Uri = `data:image/jpeg;base64,${result.assets[0].base64}`;
maxSize: 2048, // optional: specify maximum image size
});
someCovalue.image = image; const image = await createImage(base64Uri, {
owner: someCovalue._owner, // Set appropriate owner
maxSize: 2048, // Optional: limit maximum image size
});
// Store the image in your covalue
someCovalue.image = image;
}
} catch (error) {
console.error('Failed to upload image:', error);
}
};
``` ```
</CodeGroup> </CodeGroup>
For a complete implementation, please refer to [this](https://github.com/garden-co/jazz/blob/main/examples/pets/src/3_NewPetPostForm.tsx) demo. #### Displaying Images
To display images, use the `ProgressiveImg` component from `jazz-react-native`. This component handles both images uploaded from React Native and desktop browsers:
<CodeGroup>
```tsx
import { ProgressiveImg } from "jazz-react-native";
import { Image } from "react-native";
// Inside your render function:
<ProgressiveImg image={someCovalue.image} maxWidth={1024}>
{({ src, res, originalSize }) => (
<Image
source={{ uri: src }}
style={{
width: 300, // Adjust size as needed
height: 300,
borderRadius: 8,
}}
resizeMode="cover"
/>
)}
</ProgressiveImg>
```
</CodeGroup>
The `ProgressiveImg` component:
- Automatically handles different image formats
- Provides progressive loading with placeholder images
- Supports different resolutions based on the `maxWidth` prop
- Works seamlessly with React Native's `Image` component
For a complete implementation example, see the [Chat Example](https://github.com/garden-co/jazz/blob/main/examples/chat-rn-clerk/app/chat/[chatId].tsx).
### Running your app ### Running your app

View File

@@ -148,18 +148,16 @@ export class MyAppAccount extends Account {
root = co.ref(MyAppRoot); root = co.ref(MyAppRoot);
async migrate() { async migrate() {
const me = this;
// we specifically need to check for undefined, // we specifically need to check for undefined,
// because the root might simply be not loaded (`null`) yet // because the root might simply be not loaded (`null`) yet
if (me.root === undefined) { if (this.root === undefined) {
me.root = MyAppRoot.create({ this.root = MyAppRoot.create({
// Using a group to set the owner is always a good idea. // Using a group to set the owner is always a good idea.
// This way if in the future we want to share // This way if in the future we want to share
// this coValue we can do so easily. // this coValue we can do so easily.
myChats: ListOfChats.create([], Group.create(me)), myChats: ListOfChats.create([], Group.create()),
myContacts: ListOfAccounts.create([], Group.create(me)) myContacts: ListOfAccounts.create([], Group.create())
}, Group.create(me)); });
} }
} }
} }
@@ -182,17 +180,15 @@ export class MyAppAccount extends Account {
root = co.ref(MyAppRoot);// old root = co.ref(MyAppRoot);// old
async migrate() { // old async migrate() { // old
const me = this; // old if (this.root === undefined) { // old
this.root = MyAppRoot.create({ // old
if (me.root === undefined) { // old myChats: ListOfChats.create([], Group.create()), // old
me.root = MyAppRoot.create({ // old myContacts: ListOfAccounts.create([], Group.create()) // old
myChats: ListOfChats.create([], Group.create(me)), // old }); // old
myContacts: ListOfAccounts.create([], Group.create(me)) // old
}, Group.create(me)); // old
} // old } // old
// We need to load the root field to check for the myContacts field // We need to load the root field to check for the myContacts field
const result = await me.ensureLoaded({ const result = await this.ensureLoaded({
root: {}, root: {},
}); });
@@ -203,7 +199,7 @@ export class MyAppAccount extends Account {
// we specifically need to check for undefined, // we specifically need to check for undefined,
// because myBookmarks might simply be not loaded (`null`) yet // because myBookmarks might simply be not loaded (`null`) yet
if (root.myBookmarks === undefined) { 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( const project: TodoProject = TodoProject.create(
{ {
title: "New Project", title: "New Project",
tasks: ListOfTasks.create([], { owner: me }), tasks: ListOfTasks.create([], Group.create()),
}, },
{ owner: me } Group.create()
); );
``` ```
</CodeGroup> </CodeGroup>

View File

@@ -0,0 +1,74 @@
import { ContentByFramework, CodeGroup } from '@/components/forMdx'
export const metadata = { title: "Upgrade to Jazz 0.9.0" };
# Jazz 0.9.8 - Without me!
<h2 className="not-prose text-sm text-stone-600 dark:text-stone-400 mb-5 pb-2 border-b">
14 January 2025
</h2>
<div>
We have simplified the API to make the "me" value always optional!
This removes the need of using `useAccount` like the 90% of the time!
</div>
<CodeGroup>
{/* prettier-ignore */}
```ts
import { useState } from "react";
import { Issue } from "./schema";
import { IssueComponent } from "./components/Issue.tsx";
function App() {
const [issue, setIssue] = useState<Issue>();
const createIssue = () => {
setIssue(Issue.create(
{
title: "Buy terrarium",
description: "Make sure it's big enough for 10 snails.",
estimate: 5,
status: "backlog",
}, // The owner defaults now to a group managed by the current user!
));
};
if (issue) {
return <IssueComponent issue={issue} />;
} else {
return <button onClick={createIssue}>Create Issue</button>;
}
}
```
</CodeGroup>
<div>
This also applies to the load API:
</div>
<CodeGroup>
{/* prettier-ignore */}
```ts
const issue = Issue.load(issueId, {})
```
</CodeGroup>
<div>
And `Group.create`:
</div>
<CodeGroup>
{/* prettier-ignore */}
```tsx
const group = Group.create()
const sharedIssue = Issue.create(payload, group)
group.addMember('everyone', 'reader')
```
</CodeGroup>
<div>
Everything is backward compatible, so no upgrade steps are required.
With this Jazz API becomes way more lean and more is coming!
</div>

View File

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

View File

@@ -13,7 +13,9 @@ export function DocNav({ className }: { className?: string }) {
return { return {
...headerItem, ...headerItem,
items: headerItem.items items: headerItem.items
.filter((item) => !item.framework || item.framework === framework) .filter(
(item) => !("framework" in item) || item.framework === framework,
)
.map((item) => { .map((item) => {
if (!item.href?.startsWith("/docs")) return item; if (!item.href?.startsWith("/docs")) return item;

View File

@@ -3,12 +3,11 @@ import { Application } from "typedoc";
for (const { packageName, entryPoint, tsconfig, typedocOptions } of [ for (const { packageName, entryPoint, tsconfig, typedocOptions } of [
{ {
packageName: "jazz-tools", packageName: "jazz-tools",
entryPoint: "index.web.ts", entryPoint: "exports.ts",
tsconfig: "tsconfig.web.json",
}, },
{ {
packageName: "jazz-react", packageName: "jazz-react",
entryPoint: "index.tsx", entryPoint: "index.ts",
typedocOptions: { typedocOptions: {
skipErrorChecking: true, // TODO: remove this. Temporary workaround skipErrorChecking: true, // TODO: remove this. Temporary workaround
}, },

View File

@@ -50,16 +50,27 @@ export const docNavigationItems = [
href: "/docs/project-setup/server-side", href: "/docs/project-setup/server-side",
done: 80, done: 80,
}, },
],
},
{
name: "Updates",
items: [
{ {
// upgrade guides // upgrade guides
name: "Enable local persistence", name: "Jazz 0.9.8 - Without me!",
href: "/docs/upgrade/0-9-8",
done: 100,
},
{
// upgrade guides
name: "Jazz 0.9.2 - Local persistence on React Native",
href: "/docs/upgrade/react-native-local-persistence", href: "/docs/upgrade/react-native-local-persistence",
done: 100, done: 100,
framework: "react-native", framework: "react-native",
}, },
{ {
// upgrade guides // upgrade guides
name: "Upgrade to Jazz 0.9.0", name: "Jazz 0.9.0 - Upgrade guide",
href: "/docs/upgrade/0-9-0", href: "/docs/upgrade/0-9-0",
done: 100, done: 100,
}, },

View File

@@ -1,5 +1,30 @@
# cojson-storage-indexeddb # cojson-storage-indexeddb
## 0.9.11
### Patch Changes
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
- cojson-storage@0.9.11
## 0.9.10
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
- cojson-storage@0.9.10
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.9.0 ## 0.9.0
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,30 @@
# cojson-storage-sqlite # cojson-storage-sqlite
## 0.8.54
### Patch Changes
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
- cojson-storage@0.9.11
## 0.8.53
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
- cojson-storage@0.9.10
## 0.8.52
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.8.51 ## 0.8.51
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,31 @@
# cojson-storage-sqlite # cojson-storage-sqlite
## 0.9.11
### Patch Changes
- 5863bad: Wrap all the console logs with a logger class to make possible to customize the logger
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
- cojson-storage@0.9.11
## 0.9.10
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
- cojson-storage@0.9.10
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.9.0 ## 0.9.0
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,10 @@
import { Database as DatabaseT } from "better-sqlite3"; import { Database as DatabaseT } from "better-sqlite3";
import { CojsonInternalTypes, OutgoingSyncQueue, SessionID } from "cojson"; import {
CojsonInternalTypes,
OutgoingSyncQueue,
SessionID,
logger,
} from "cojson";
import RawCoID = CojsonInternalTypes.RawCoID; import RawCoID = CojsonInternalTypes.RawCoID;
import Signature = CojsonInternalTypes.Signature; import Signature = CojsonInternalTypes.Signature;
import Transaction = CojsonInternalTypes.Transaction; import Transaction = CojsonInternalTypes.Transaction;
@@ -48,7 +53,7 @@ export class SQLiteClient implements DBClientInterface {
header: parsedHeader, header: parsedHeader,
}; };
} catch (e) { } catch (e) {
console.warn(coValueId, "Invalid JSON in header", e, coValueRow?.header); logger.warn(coValueId, "Invalid JSON in header", e, coValueRow?.header);
return; return;
} }
} }
@@ -75,7 +80,7 @@ export class SQLiteClient implements DBClientInterface {
tx: JSON.parse(transactionRow.tx) as Transaction, tx: JSON.parse(transactionRow.tx) as Transaction,
})); }));
} catch (e) { } catch (e) {
console.warn("Invalid JSON in transaction", e); logger.warn("Invalid JSON in transaction", e);
return []; return [];
} }
} }

View File

@@ -4,6 +4,7 @@ import {
OutgoingSyncQueue, OutgoingSyncQueue,
Peer, Peer,
cojsonInternals, cojsonInternals,
logger,
} from "cojson"; } from "cojson";
import { SyncManager, TransactionRow } from "cojson-storage"; import { SyncManager, TransactionRow } from "cojson-storage";
import { SQLiteClient } from "./sqliteClient.js"; import { SQLiteClient } from "./sqliteClient.js";
@@ -40,25 +41,23 @@ export class SQLiteNode {
await new Promise((resolve) => setTimeout(resolve, 0)); await new Promise((resolve) => setTimeout(resolve, 0));
} }
} catch (e) { } catch (e) {
console.error( logger.error(
new Error( `Error reading from localNode, handling msg\n\n${JSON.stringify(
`Error reading from localNode, handling msg\n\n${JSON.stringify( msg,
msg, (k, v) =>
(k, v) => k === "changes" || k === "encryptedChanges"
k === "changes" || k === "encryptedChanges" ? v.slice(0, 20) + "..."
? v.slice(0, 20) + "..." : v,
: v, )}`,
)}`, e,
{ cause: e },
),
); );
} }
} }
};
processMessages().catch((e) => processMessages().catch((e) =>
console.error("Error in processMessages in sqlite", e), logger.error("Error in processMessages in sqlite", e),
); );
};
} }
static async asPeer({ static async asPeer({
@@ -97,10 +96,7 @@ export class SQLiteNode {
db.pragma("user_version") as [{ user_version: number }] db.pragma("user_version") as [{ user_version: number }]
)[0].user_version as number; )[0].user_version as number;
console.log("DB version", oldVersion);
if (oldVersion === 0) { if (oldVersion === 0) {
console.log("Migration 0 -> 1: Basic schema");
db.prepare( db.prepare(
`CREATE TABLE IF NOT EXISTS transactions ( `CREATE TABLE IF NOT EXISTS transactions (
ses INTEGER, ses INTEGER,
@@ -138,15 +134,10 @@ export class SQLiteNode {
).run(); ).run();
db.pragma("user_version = 1"); db.pragma("user_version = 1");
console.log("Migration 0 -> 1: Basic schema - done");
} }
if (oldVersion <= 1) { if (oldVersion <= 1) {
// fix embarrassing off-by-one error for transaction indices // fix embarrassing off-by-one error for transaction indices
console.log(
"Migration 1 -> 2: Fix off-by-one error for transaction indices",
);
const txs = db const txs = db
.prepare(`SELECT * FROM transactions`) .prepare(`SELECT * FROM transactions`)
.all() as TransactionRow[]; .all() as TransactionRow[];
@@ -163,14 +154,9 @@ export class SQLiteNode {
} }
db.pragma("user_version = 2"); db.pragma("user_version = 2");
console.log(
"Migration 1 -> 2: Fix off-by-one error for transaction indices - done",
);
} }
if (oldVersion <= 2) { if (oldVersion <= 2) {
console.log("Migration 2 -> 3: Add signatureAfter");
db.prepare( db.prepare(
`CREATE TABLE IF NOT EXISTS signatureAfter ( `CREATE TABLE IF NOT EXISTS signatureAfter (
ses INTEGER, ses INTEGER,
@@ -185,7 +171,6 @@ export class SQLiteNode {
).run(); ).run();
db.pragma("user_version = 3"); db.pragma("user_version = 3");
console.log("Migration 2 -> 3: Add signatureAfter - done!!");
} }
return new SQLiteNode(db, fromLocalNode, toLocalNode); return new SQLiteNode(db, fromLocalNode, toLocalNode);

View File

@@ -1,5 +1,28 @@
# cojson-storage # cojson-storage
## 0.9.11
### Patch Changes
- 5863bad: Wrap all the console logs with a logger class to make possible to customize the logger
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
## 0.9.10
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
## 0.9.0 ## 0.9.0
### Patch Changes ### Patch Changes

View File

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

View File

@@ -6,6 +6,7 @@ import {
SyncMessage, SyncMessage,
cojsonInternals, cojsonInternals,
emptyKnownState, emptyKnownState,
logger,
} from "cojson"; } from "cojson";
import { collectNewTxs, getDependedOnCoValues } from "./syncUtils.js"; import { collectNewTxs, getDependedOnCoValues } from "./syncUtils.js";
import { DBClientInterface, StoredSessionRow } from "./types.js"; import { DBClientInterface, StoredSessionRow } from "./types.js";
@@ -314,7 +315,7 @@ export class SyncManager {
return this.toLocalNode return this.toLocalNode
.push(msg) .push(msg)
.catch((e) => .catch((e) =>
console.error(`Error sending ${msg.action} state, id ${msg.id}`, e), logger.error(`Error sending ${msg.action} state, id ${msg.id}`, e),
); );
} }
} }

View File

@@ -1,5 +1,28 @@
# cojson-transport-nodejs-ws # cojson-transport-nodejs-ws
## 0.9.11
### Patch Changes
- 5863bad: Wrap all the console logs with a logger class to make possible to customize the logger
- Updated dependencies [efbf3d8]
- Updated dependencies [5863bad]
- cojson@0.9.11
## 0.9.10
### Patch Changes
- Updated dependencies [4aa377d]
- cojson@0.9.10
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
## 0.9.0 ## 0.9.0
### Patch Changes ### Patch Changes

View File

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

View File

@@ -4,6 +4,7 @@ import {
PingTimeoutError, PingTimeoutError,
SyncMessage, SyncMessage,
cojsonInternals, cojsonInternals,
logger,
} from "cojson"; } from "cojson";
import { BatchedOutgoingMessages } from "./BatchedOutgoingMessages.js"; import { BatchedOutgoingMessages } from "./BatchedOutgoingMessages.js";
import { deserializeMessages } from "./serialization.js"; import { deserializeMessages } from "./serialization.js";
@@ -136,7 +137,7 @@ export function createWebSocketPeer({
function handleClose() { function handleClose() {
incoming incoming
.push("Disconnected") .push("Disconnected")
.catch((e) => console.error("Error while pushing disconnect msg", e)); .catch((e) => logger.error("Error while pushing disconnect msg", e));
emitClosedEvent(); emitClosedEvent();
} }
@@ -145,7 +146,7 @@ export function createWebSocketPeer({
const pingTimeout = createPingTimeoutListener(expectPings, () => { const pingTimeout = createPingTimeoutListener(expectPings, () => {
incoming incoming
.push("PingTimeout") .push("PingTimeout")
.catch((e) => console.error("Error while pushing ping timeout", e)); .catch((e) => logger.error("Error while pushing ping timeout", e));
emitClosedEvent(); emitClosedEvent();
}); });
@@ -156,14 +157,13 @@ export function createWebSocketPeer({
function handleIncomingMsg(event: { data: unknown }) { function handleIncomingMsg(event: { data: unknown }) {
if (event.data === "") { if (event.data === "") {
console.log("client", id, "sent empty message");
return; return;
} }
const result = deserializeMessages(event.data); const result = deserializeMessages(event.data);
if (!result.ok) { if (!result.ok) {
console.error( logger.warn(
"Error while deserializing messages", "Error while deserializing messages",
event.data, event.data,
result.error, result.error,
@@ -184,7 +184,7 @@ export function createWebSocketPeer({
if (msg && "action" in msg) { if (msg && "action" in msg) {
incoming incoming
.push(msg) .push(msg)
.catch((e) => console.error("Error while pushing incoming msg", e)); .catch((e) => logger.error("Error while pushing incoming msg", e));
} }
} }
} }
@@ -197,7 +197,6 @@ export function createWebSocketPeer({
outgoing: { outgoing: {
push: outgoingMessages.sendMessage, push: outgoingMessages.sendMessage,
close() { close() {
console.log("Trying to close", id, websocket.readyState);
outgoingMessages.close(); outgoingMessages.close();
websocket.removeEventListener("message", handleIncomingMsg); websocket.removeEventListener("message", handleIncomingMsg);

View File

@@ -1,4 +1,4 @@
import { SyncMessage } from "cojson"; import { SyncMessage, logger } from "cojson";
import { PingMsg } from "./types.js"; import { PingMsg } from "./types.js";
export function addMessageToBacklog(backlog: string, message: SyncMessage) { export function addMessageToBacklog(backlog: string, message: SyncMessage) {
@@ -24,7 +24,7 @@ export function deserializeMessages(messages: unknown) {
| PingMsg[], | PingMsg[],
} as const; } as const;
} catch (e) { } catch (e) {
console.error("Error while deserializing messages", e); logger.error("Error while deserializing messages", e);
return { return {
ok: false, ok: false,
error: e, error: e,

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