Compare commits

..

62 Commits

Author SHA1 Message Date
Guido D'Orsi
adde5b78f3 Merge pull request #1201 from garden-co/changeset-release/main
Version Packages
2025-01-14 16:24:28 +01:00
github-actions[bot]
06fd3a3686 Version Packages 2025-01-14 14:02:14 +00:00
Anselm Eickhoff
d231b6ae2a Merge pull request #1191 from garden-co/fix/create-jazz-app
Use example apps as starter with create-jazz-app
2025-01-14 14:00:52 +00:00
Benjamin S. Leveritt
e471fc5d23 Merge pull request #1204 from garden-co/jazz-648-homepage-generate-docs-pointing-to-wrong-jazz-react
Fix location of jazz-react entryPoint for docs gen
2025-01-14 13:15:35 +00:00
Benjamin S. Leveritt
84d06d180a Fix location of jazz-react entryPoint for docs gen 2025-01-14 13:13:18 +00:00
Benjamin S. Leveritt
342e4d9f5e Merge pull request #1173 from garden-co/jazz-534-richtext-changes
Improve coRichText support
2025-01-14 12:46:50 +00:00
Benjamin S. Leveritt
8eb92471ae Add changeset 2025-01-14 12:44:19 +00:00
Guido D'Orsi
0cfc32f591 Merge pull request #1198 from garden-co/changeset-release/main
Version Packages
2025-01-14 12:42:19 +01:00
github-actions[bot]
e8b1e07625 Version Packages 2025-01-14 10:20:58 +00:00
pax
f97946bd21 Merge pull request #1199 from garden-co/fix-react-usecontext-reference
Fix React.useContext() reference
2025-01-14 12:19:41 +02:00
pax-k
f7f461db31 chore: changeset 2025-01-14 12:04:47 +02:00
pax-k
653d09c337 fix: explicitly use useContext() instead of React.useContext() 2025-01-14 12:03:53 +02:00
pax-k
3fa5ac30ff chore: cleanup 2025-01-14 11:39:59 +02:00
Guido D'Orsi
4095041da9 Merge pull request #1179 from garden-co/jazz-640-api-make-the-current-active-account-the-default-in
Without me
2025-01-14 10:11:40 +01:00
Guido D'Orsi
c1c2f39cb5 test: fix failing test 2025-01-14 09:33:33 +01:00
Benjamin S. Leveritt
e5b93871f7 Add test for insertion at start 2025-01-14 08:22:04 +00:00
Benjamin S. Leveritt
896aeb571d Fix multiple insertions at start 2025-01-14 08:22:03 +00:00
Guido D'Orsi
f7f1a0aff0 fix: use groups as defult owner 2025-01-13 20:24:51 +01:00
Guido D'Orsi
3bc82dc382 Update homepage/homepage/app/docs/[framework]/[...slug]/guide/react.mdx
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:36:14 +01:00
Guido D'Orsi
99bac77ae7 Update homepage/homepage/app/docs/[framework]/[...slug]/guide/react.mdx
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:36:03 +01:00
Guido D'Orsi
5705ebdcad Update packages/jazz-tools/src/implementation/activeAccountContext.ts
Co-authored-by: Anselm Eickhoff <anselm.eickhoff@gmail.com>
2025-01-13 19:35:54 +01:00
pax
f3fb445c9e Merge pull request #1197 from garden-co/JAZZ-638/set-specific-package-version-on-create-jazz-app
create-jazz-app gets the latest semver package version for jazz-* dependencies from NPM via HTTP
2025-01-13 18:19:08 +02:00
pax-k
c60fe8aae2 chore: cleanup 2025-01-13 18:15:43 +02:00
pax-k
d2a882e531 fix: actually throw an error if getLatestPackageVersions() fails, without falling back to "latest" 2025-01-13 18:11:37 +02:00
pax-k
036fa1f43b chore: changeset 2025-01-13 18:06:41 +02:00
pax-k
839b4af45c fix: fetching latest semver jazz-* package versions from NPM when using create-jazz-app, instead of using "latest" 2025-01-13 18:04:07 +02:00
Trisha Lim
3a9797ce75 Add changeset 2025-01-13 14:48:59 +00:00
Trisha Lim
b2f14c0339 Update examples README 2025-01-13 12:37:57 +00:00
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
159 changed files with 3798 additions and 768 deletions

View File

@@ -1,5 +1,25 @@
# chat-rn-clerk
## 1.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
- jazz-react-native-auth-clerk@0.9.9
- jazz-react-native-media-images@0.9.9
## 1.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
- jazz-react-native-auth-clerk@0.9.8
- jazz-react-native-media-images@0.9.8
## 1.0.48
### Patch Changes

View File

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

View File

@@ -1,5 +1,21 @@
# chat-rn
## 1.0.47
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react-native@0.9.9
## 1.0.46
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react-native@0.9.8
## 1.0.45
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,23 @@
# minimal-auth-clerk
## 0.0.29
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
- jazz-react-auth-clerk@0.9.9
## 0.0.28
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
- jazz-react-auth-clerk@0.9.8
## 0.0.27
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# jazz-example-musicplayer
## 0.0.50
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.49
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.48
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# organization
## 0.0.23
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.22
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.21
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# minimal-auth-passkey
## 0.0.28
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.27
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.26
### Patch Changes

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# jazz-password-manager
## 0.0.49
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.48
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.47
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# jazz-example-todo
## 0.0.146
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.145
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.144
### Patch Changes

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# version-history
## 0.0.24
### Patch Changes
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- jazz-react@0.9.9
## 0.0.23
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-react@0.9.8
## 0.0.22
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -186,19 +186,40 @@ Lastly, ensure that the `"main"` field in your `package.json` points to `index.j
```
</CodeGroup>
## Using Jazz
## Setting up the provider
### `createJazzRNApp()`
Create a file `jazz.tsx` with the following contents:
Wrap your app components with the `JazzProvider:
<CodeGroup>
```tsx
import { createJazzRNApp } from "jazz-react-native";
```tsx
import { JazzProvider, useDemoAuth, DemoAuthBasicUI } from "jazz-react-native";
import { MyAppAccount } from "./schema";
export const Jazz = createJazzRNApp();
export const { useAccount, useCoState, useAcceptInvite } = Jazz;
```
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
return (
<>
<JazzProvider
auth={auth}
peer="wss://cloud.jazz.tools/?key=you@example.com"
AccountSchema={MyAppAccount}
>
{children}
</JazzProvider>
<DemoAuthBasicUI appName="My App" state={state} />
</>
);
}
// Register the Account schema so `useAccount` returns our custom `MyAppAccount`
declare module "jazz-react-native" {
interface Register {
Account: MyAppAccount;
}
}
```
</CodeGroup>
You can optionally pass a custom `kvStore` and `AccountSchema` to `createJazzRNApp()`, otherwise, it defaults to `ExpoSecureStoreAdapter` and `Account`.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,13 @@
# cojson-storage-sqlite
## 0.8.52
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
- cojson-storage@0.9.9
## 0.8.51
### Patch Changes

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,12 @@
# cojson-transport-nodejs-ws
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- cojson@0.9.9
## 0.9.0
### Patch Changes

View File

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

View File

@@ -1,5 +1,11 @@
# cojson
## 0.9.9
### Patch Changes
- 8eb9247: Add CoPlainText and CoRichText covalues
## 0.9.0
### Patch Changes

View File

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

View File

@@ -41,6 +41,7 @@ export type AnyRawCoValue =
| RawAccount
| Profile
| RawCoList
| RawCoPlainText
| RawCoStream
| RawBinaryCoStream;

View File

@@ -1,11 +1,6 @@
import { CoValueCore } from "../coValueCore.js";
import { JsonObject } from "../jsonValue.js";
import {
DeletionOpPayload,
InsertionOpPayload,
OpID,
RawCoList,
} from "./coList.js";
import { DeletionOpPayload, OpID, RawCoList } from "./coList.js";
export type StringifiedOpID = string & { __stringifiedOpID: true };
@@ -88,33 +83,22 @@ export class RawCoPlainText<
text: string,
privacy: "private" | "trusting" = "private",
) {
const ops: InsertionOpPayload<string>[] = [];
let prevOpId: OpID | "start" | undefined = this.mapping.opIDbeforeIdx[idx];
if (!prevOpId) {
if (idx === 0) {
prevOpId = "start";
} else {
throw new Error("Invalid idx");
const graphemes = [...this._segmenter.segment(text)].map((g) => g.segment);
if (idx === 0) {
// For insertions at start, just prepend each character, in reverse
for (const grapheme of graphemes.reverse()) {
this.prepend(grapheme, 0, privacy);
}
} else {
// For other insertions, use append after the specified index
// We append in forward order to maintain the text order
let after = idx - 1;
for (const grapheme of graphemes) {
this.append(grapheme, after, privacy);
after++; // Move the insertion point forward for each grapheme
}
}
const nextTxId = this.core.nextTransactionID();
let changeIdx = 0;
for (const grapheme of this._segmenter.segment(text)) {
ops.push({
op: "app",
value: grapheme.segment,
after: prevOpId,
});
prevOpId = {
sessionID: nextTxId.sessionID,
txIndex: nextTxId.txIndex,
changeIdx,
};
changeIdx++;
}
this.core.makeTransaction(ops, privacy);
this.rebuildFromCore();
}
deleteRange(
@@ -131,7 +115,6 @@ export class RawCoPlainText<
op: "del",
insertion,
});
console.log("deleting idx", idx);
let nextIdx = idx + 1;
while (!this.mapping.opIDbeforeIdx[nextIdx] && nextIdx < to) {
nextIdx++;

View File

@@ -701,8 +701,8 @@ export class RawGroup<
}
/**
* Creates a new `CoList` within this group, with the specified specialized
* `CoList` type `L` and optional static metadata.
* Creates a new `CoPlainText` within this group, with the specified specialized
* `CoPlainText` type `T` and optional static metadata.
*
* @category 3. Value creation
*/

View File

@@ -132,3 +132,22 @@ test("init the list correctly", () => {
"hello",
]);
});
test("Items prepended to start appear with latest first", () => {
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
const coValue = node.createCoValue({
type: "colist",
ruleset: { type: "unsafeAllowAll" },
meta: null,
...Crypto.createdNowUnique(),
});
const content = expectList(coValue.getCurrentContent());
content.prepend("first", 0, "trusting");
content.prepend("second", 0, "trusting");
content.prepend("third", 0, "trusting");
expect(content.toJSON()).toEqual(["third", "second", "first"]);
});

View File

@@ -74,14 +74,60 @@ test("Can insert and delete in CoPlainText", () => {
content.insertAfter(5, " world", "trusting");
expect(content.toString()).toEqual("hello world");
content.insertAfter(0, "Hello, ", "trusting");
expect(content.toString()).toEqual("Hello, hello world");
console.log("first delete");
content.deleteRange({ from: 3, to: 8 }, "trusting");
expect(content.toString()).toEqual("helrld");
content.deleteRange({ from: 6, to: 12 }, "trusting");
expect(content.toString()).toEqual("Hello, world");
content.insertAfter(2, "😍", "trusting");
expect(content.toString()).toEqual("he😍lrld");
expect(content.toString()).toEqual("He😍llo, world");
console.log("second delete");
content.deleteRange({ from: 2, to: 4 }, "trusting");
expect(content.toString()).toEqual("helrld");
expect(content.toString()).toEqual("Hello, world");
});
test("Multiple items appended after start appear in correct order", () => {
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
const coValue = node.createCoValue({
type: "coplaintext",
ruleset: { type: "unsafeAllowAll" },
meta: null,
...Crypto.createdNowUnique(),
});
const content = expectPlainText(coValue.getCurrentContent());
// Add multiple items in a single transaction, all after start
content.insertAfter(0, "h", "trusting");
content.insertAfter(1, "e", "trusting");
content.insertAfter(2, "y", "trusting");
// They should appear in insertion order (hey), not reversed (yeh)
expect(content.toString()).toEqual("hey");
});
test("Items inserted at start appear with latest first", () => {
const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
const coValue = node.createCoValue({
type: "coplaintext",
ruleset: { type: "unsafeAllowAll" },
meta: null,
...Crypto.createdNowUnique(),
});
const content = expectPlainText(coValue.getCurrentContent());
// Insert multiple items at the start
content.insertAfter(0, "first", "trusting");
content.insertAfter(0, "second", "trusting");
content.insertAfter(0, "third", "trusting");
// They should appear in reverse chronological order
// because newer items should appear before older items
expect(content.toString()).toEqual("thirdsecondfirst");
});

View File

@@ -1,5 +1,17 @@
# create-jazz-app
## 0.1.7
### Patch Changes
- 3a9797c: Add example param to create-jazz-app
## 0.1.6
### Patch Changes
- 036fa1f: Fix fetching latest semver jazz-\* package versions from NPM when using create-jazz-app, instead of using "latest"
## 0.1.5
### Patch Changes

View File

@@ -14,7 +14,7 @@
You can create a new Jazz app in two ways:
### Interactive Mode
### Interactive mode
Simply run:
@@ -33,7 +33,7 @@ Then follow the interactive prompts to select your:
- Package manager
- Project name
### Command Line Mode
### Command line mode
Or specify all options directly:
@@ -41,7 +41,18 @@ Or specify all options directly:
npm create jazz-app@latest -- --starter react-demo-auth --project-name my-app --package-manager npm
```
## Available Starters
### Start with an example app
You can use any of our example apps as a template for your own app, instead of choosing one of the starters.
Use the `--example` parameter, and pass
the directory name of the example app found [here](https://github.com/garden-co/jazz/tree/main/examples).
```bash
npm create jazz-app@latest --example chat
```
## Available starters
Currently implemented starters:
@@ -55,12 +66,12 @@ Currently implemented starters:
More starters coming soon! Check the help menu (`create-jazz-app --help`) for the latest list.
## System Requirements
## System requirements
- Node.js 14.0.0 or later
- Package manager of your choice (npm, yarn, pnpm, bun, or deno)
## What Happens When You Run It?
## What happens when you run it?
1. 🎭 Prompts for your preferences (or uses command line arguments)
2. 📥 Clones the appropriate starter template

View File

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

View File

@@ -15,25 +15,81 @@ const program = new Command();
const jazzGradient = gradient(["#FF4D4D", "#FF9900", "#FFD700"]);
type PackageManager = "npm" | "yarn" | "pnpm" | "bun" | "deno";
type ScaffoldOptions = {
starter: FrameworkAuthPair;
template: FrameworkAuthPair | string;
projectName: string;
packageManager: "npm" | "yarn" | "pnpm" | "bun" | "deno";
packageManager: PackageManager;
};
type PromptOptions = {
starter?: FrameworkAuthPair;
example?: string;
projectName?: string;
packageManager?: PackageManager;
};
async function getLatestPackageVersions(
dependencies: Record<string, string>,
): Promise<Record<string, string>> {
const versionsSpinner = ora({
text: chalk.blue("Fetching package versions..."),
spinner: "dots",
}).start();
const versions: Record<string, string> = {};
const failures: string[] = [];
await Promise.all(
Object.keys(dependencies).map(async (pkg) => {
if (
typeof dependencies[pkg] === "string" &&
dependencies[pkg].includes("workspace:")
) {
try {
const response = await fetch(
`https://registry.npmjs.org/${pkg}/latest`,
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
versions[pkg] = `^${data.version}`; // Using caret for minor version updates
} catch (error) {
failures.push(pkg);
}
}
}),
);
if (failures.length > 0) {
versionsSpinner.fail(
chalk.red(
`Failed to fetch versions for packages: ${failures.join(", ")}. Please check your internet connection and try again.`,
),
);
throw new Error("Failed to fetch package versions");
}
versionsSpinner.succeed(chalk.green("Package versions fetched successfully"));
return versions;
}
async function scaffoldProject({
starter,
template,
projectName,
packageManager,
}: ScaffoldOptions): Promise<void> {
console.log("\n" + jazzGradient.multiline("Jazz App Creator\n"));
const starterConfig = frameworkToAuthExamples[starter];
const starterConfig = frameworkToAuthExamples[
template as FrameworkAuthPair
] || { name: template, repo: "garden-co/jazz/examples/" + template };
if (!starterConfig) {
throw new Error(`Invalid starter: ${starter}`);
throw new Error(`Invalid template: ${template}`);
}
const devCommand = starter === "react-native-expo-clerk-auth" ? "ios" : "dev";
const devCommand =
template === "react-native-expo-clerk-auth" ? "ios" : "dev";
if (!starterConfig.repo) {
throw new Error(
@@ -43,7 +99,7 @@ async function scaffoldProject({
// Step 2: Clone starter
const cloneSpinner = ora({
text: chalk.blue(`Cloning starter: ${chalk.bold(starterConfig.name)}`),
text: chalk.blue(`Cloning template: ${chalk.bold(starterConfig.name)}`),
spinner: "dots",
}).start();
@@ -72,9 +128,13 @@ async function scaffoldProject({
// Replace workspace: dependencies with latest
if (packageJson.dependencies) {
const latestVersions = await getLatestPackageVersions(
packageJson.dependencies,
);
Object.entries(packageJson.dependencies).forEach(([pkg, version]) => {
if (typeof version === "string" && version.includes("workspace:")) {
packageJson.dependencies[pkg] = "latest";
packageJson.dependencies[pkg] = latestVersions[pkg];
}
});
}
@@ -106,7 +166,7 @@ async function scaffoldProject({
}
// Additional setup for React Native
if (starter === "react-native-expo-clerk-auth") {
if (template === "react-native-expo-clerk-auth") {
const rnSpinner = ora({
text: chalk.blue("Setting up React Native project..."),
spinner: "dots",
@@ -146,12 +206,20 @@ module.exports = withNativeWind(config, { input: "./src/global.css" });
);
}
async function promptUser(): Promise<ScaffoldOptions> {
async function promptUser(
partialOptions: PromptOptions,
): Promise<ScaffoldOptions> {
console.log("\n" + jazzGradient.multiline("Jazz App Creator\n"));
console.log(chalk.blue.bold("Let's create your Jazz app! 🎷\n"));
const answers = (await inquirer.prompt([
{
const questions = [];
if (partialOptions.starter && partialOptions.example) {
throw new Error("Please specify either a starter or an example, not both.");
}
if (!partialOptions.example && !partialOptions.starter) {
questions.push({
type: "list",
name: "starter",
message: chalk.cyan("Choose a starter:"),
@@ -161,8 +229,11 @@ async function promptUser(): Promise<ScaffoldOptions> {
name: chalk.white(value.name),
value: key,
})),
},
{
});
}
if (!partialOptions.packageManager) {
questions.push({
type: "list",
name: "packageManager",
message: chalk.cyan("Choose a package manager:"),
@@ -174,26 +245,33 @@ async function promptUser(): Promise<ScaffoldOptions> {
{ name: chalk.white("deno"), value: "deno" },
],
default: "npm",
},
{
});
}
if (!partialOptions.projectName) {
questions.push({
type: "input",
name: "projectName",
message: chalk.cyan("Enter your project name:"),
validate: (input: string) =>
input ? true : chalk.red("Project name cannot be empty"),
},
])) as ScaffoldOptions;
});
}
return answers;
const answers = await inquirer.prompt(questions);
return {
...answers,
...partialOptions,
template: partialOptions.starter || partialOptions.example,
} as ScaffoldOptions;
}
function validateOptions(
options: Partial<ScaffoldOptions>,
): options is ScaffoldOptions {
function validateOptions(options: PromptOptions): options is ScaffoldOptions {
const errors: string[] = [];
if (!options.starter) {
errors.push("Starter template is required");
if (!options.starter && !options.example) {
errors.push("Starter or example template is required");
}
if (!options.projectName) {
errors.push("Project name is required");
@@ -223,6 +301,7 @@ function validateOptions(
program
.description(chalk.blue("CLI to generate Jazz starter projects"))
.option("-s, --starter <starter>", chalk.cyan("Starter template to use"))
.option("-e, --example <name>", chalk.cyan("Example project to use"))
.option("-n, --project-name <name>", chalk.cyan("Name of the project"))
.option(
"-p, --package-manager <manager>",
@@ -230,23 +309,30 @@ program
)
.action(async (options) => {
try {
// If all required options are provided, use them directly
if (options.starter && options.projectName && options.packageManager) {
const nonInteractiveOptions = {
starter: options.starter as FrameworkAuthPair,
projectName: options.projectName,
packageManager:
options.packageManager as ScaffoldOptions["packageManager"],
};
const partialOptions: PromptOptions = {};
// Validate will throw if invalid
validateOptions(nonInteractiveOptions);
await scaffoldProject(nonInteractiveOptions);
} else {
// Otherwise, fall back to interactive mode
const scaffoldOptions = await promptUser();
await scaffoldProject(scaffoldOptions);
if (options.starter && options.example) {
throw new Error(
chalk.red(
"Cannot specify both starter and example. Please choose one.",
),
);
}
if (options.starter)
partialOptions.starter = options.starter as FrameworkAuthPair;
if (options.example) partialOptions.example = options.example;
if (options.projectName) partialOptions.projectName = options.projectName;
if (options.packageManager)
partialOptions.packageManager =
options.packageManager as ScaffoldOptions["packageManager"];
// Get missing options through prompts
const scaffoldOptions = await promptUser(partialOptions);
// Validate will throw if invalid
validateOptions(scaffoldOptions);
await scaffoldProject(scaffoldOptions);
} catch (error: any) {
if (error instanceof Error && error.name === "ExitPromptError") {
console.log(chalk.yellow("\n👋 Until next time!\n"));

View File

@@ -1,5 +1,23 @@
# jazz-browser-media-images
## 0.9.9
### Patch Changes
- Updated dependencies [8eb9247]
- Updated dependencies [8eb9247]
- jazz-tools@0.9.9
- cojson@0.9.9
- jazz-browser@0.9.9
## 0.9.8
### Patch Changes
- Updated dependencies [d1d773b]
- jazz-tools@0.9.8
- jazz-browser@0.9.8
## 0.9.1
### Patch Changes

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