Compare commits

..

4 Commits

Author SHA1 Message Date
pax-k
7f3990de3f feat(docs): process mdx files in docs layout - wip 2024-11-11 17:39:21 +02:00
pax
7118fa0413 feat(docs): extract table of contents - wip 2024-11-07 00:13:35 +00:00
Trisha Lim
60928b3a44 Remove custom layouts for docs with TOC 2024-11-05 11:19:10 +00:00
Trisha Lim
c3335f8def Docs: autogenerate heading links and table of contents 2024-11-05 11:14:46 +00:00
1288 changed files with 59620 additions and 124536 deletions

View File

@@ -1,35 +1,30 @@
{ {
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json", "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": "@changesets/cli/changelog", "changelog": "@changesets/cli/changelog",
"commit": false, "commit": false,
"fixed": [], "fixed": [],
"linked": [ "linked": [
[ [
"cojson", "cojson",
"cojson-storage", "jazz-tools",
"cojson-storage-indexeddb", "jazz-browser",
"cojson-storage-sqlite", "jazz-browser-media-images",
"cojson-transport-ws", "jazz-browser-auth-clerk",
"jazz-browser", "jazz-react-auth-clerk",
"jazz-browser-auth-clerk", "jazz-react",
"jazz-browser-media-images", "jazz-react-native",
"jazz-nodejs", "jazz-nodejs",
"jazz-react", "jazz-run",
"jazz-react-auth-clerk", "cojson-transport-ws",
"jazz-react-native", "cojson-storage-indexeddb",
"jazz-react-native-auth-clerk", "cojson-storage-sqlite"
"jazz-react-native-media-images", ]
"jazz-run", ],
"jazz-svelte", "access": "public",
"jazz-tools", "baseBranch": "main",
"jazz-vue" "updateInternalDependencies": "patch",
] "ignore": [],
], "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"access": "public", "onlyUpdatePeerDependentsWhenOutOfRange": true
"baseBranch": "main", }
"updateInternalDependencies": "patch",
"ignore": [],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}
} }

View File

@@ -1,11 +0,0 @@
# EditorConfig is awesome: https://editorconfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

1
.envrc
View File

@@ -1 +0,0 @@
use flake

View File

@@ -1,2 +0,0 @@
# Formatted workspace with biome
be0a09a22295cd5d2ee3ef323e2d999da8a14110

View File

@@ -11,15 +11,12 @@ jobs:
matrix: matrix:
example: [ example: [
"chat", "chat",
"clerk", "chat-clerk",
"passkey",
"inspector", "inspector",
"music-player", "music-player",
"password-manager", "password-manager",
"pets", "pets",
"reactions",
"todo", "todo",
"onboarding",
] ]
steps: steps:
@@ -58,4 +55,4 @@ jobs:
run: | run: |
pnpm install pnpm install
pnpm turbo build; pnpm turbo build;
working-directory: ./examples/${{ matrix.example }} working-directory: ./examples/${{ matrix.example }}

View File

@@ -1,52 +0,0 @@
name: Build Starters
on:
push:
branches: [ "main" ]
jobs:
build-starters:
runs-on: ubuntu-latest
strategy:
matrix:
starter: [
"react-demo-auth-tailwind",
]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Enable corepack
run: corepack enable
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
cache: 'pnpm'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Pnpm Build
run: |
pnpm install
pnpm turbo build;
working-directory: ./starters/${{ matrix.starter }}

View File

@@ -1,18 +0,0 @@
name: Code quality
on:
push:
pull_request:
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci .

View File

@@ -9,7 +9,7 @@ on:
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5 continue-on-error: true
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

21
.github/workflows/monorepo-linting.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Monorepo linting
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
monorepo-linting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
- name: Run sherif
run: npx sherif@1.0.0

View File

@@ -13,7 +13,7 @@ jobs:
continue-on-error: true continue-on-error: true
strategy: strategy:
matrix: matrix:
project: ["tests/e2e", "examples/chat", "examples/file-share-svelte", "examples/form", "examples/music-player", "examples/pets", "examples/onboarding", "starters/react-demo-auth-tailwind"] project: ["e2e/BinaryCoStream", "e2e/CoValues", "examples/chat", "examples/music-player", "examples/pets"]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@@ -41,16 +41,20 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-pnpm-store- ${{ runner.os }}-pnpm-store-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Pnpm Build - name: Pnpm Build
run: pnpm turbo build run: pnpm turbo build
working-directory: ./${{ matrix.project }} working-directory: ./${{ matrix.project }}
- name: Build jazz-run
run: pnpm exec turbo build && chmod +x dist/index.js;
working-directory: ./packages/jazz-run
- name: Install Playwright Browsers - name: Install Playwright Browsers
run: pnpm exec playwright install run: pnpm exec playwright install --with-deps
working-directory: ./${{ matrix.project }} working-directory: ./${{ matrix.project }}
- name: Run Playwright tests - name: Run Playwright tests

View File

@@ -4,13 +4,6 @@ on:
push: push:
branches: branches:
- main - main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run tmate session for debugging"
required: false
default: false
concurrency: ${{ github.workflow }}-${{ github.ref }} concurrency: ${{ github.workflow }}-${{ github.ref }}
@@ -55,11 +48,4 @@ jobs:
publish: pnpm release publish: pnpm release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Enable tmate debugging only if the workflow is manually triggered, debug_enabled is true, and the workflow failed
- name: Setup tmate session for debugging
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
with:
timeout-minutes: 15

View File

@@ -41,7 +41,7 @@ jobs:
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Pnpm Build - name: Pnpm Build
run: pnpm turbo build --filter="./packages/*" run: pnpm turbo build
- name: Unit Tests - name: Unit Tests
run: pnpm test:ci run: pnpm test:ci

16
.gitignore vendored
View File

@@ -4,18 +4,4 @@ lerna-debug.log
docsTmp docsTmp
.DS_Store .DS_Store
.turbo .turbo
coverage coverage
.direnv
# Next.js
**/.next
# Vite output
**/dist
# Playwright
test-results
.husky
.vscode/settings.json

View File

@@ -1 +1 @@
22 20

1
.nvmrc
View File

@@ -1 +0,0 @@
22

9
.prettierrc.js Normal file
View File

@@ -0,0 +1,9 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: "all",
tabWidth: 4,
semi: true,
singleQuote: false,
};
export default config;

View File

@@ -59,7 +59,7 @@ representative at an online or offline event.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to [the community leaders responsible for enforcement](mailto:hello@garden.co). reported to [the community leaders responsible for enforcement](mailto:hello@gcmp.io).
All complaints will be reviewed and investigated promptly and fairly. All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the All community leaders are obligated to respect the privacy and security of the

View File

@@ -6,7 +6,7 @@ Thank you for considering contributing to Jazz! Jazz is an open-source framework
### 1. Reporting Bugs ### 1. Reporting Bugs
If you find a bug, please [open an issue with as much detail as possible](https://github.com/garden-co/jazz/issues). Include: If you find a bug, please [open an issue with as much detail as possible](https://github.com/gardencmp/jazz/issues). Include:
- A clear and descriptive title. - A clear and descriptive title.
- Steps to reproduce the issue. - Steps to reproduce the issue.
@@ -36,11 +36,9 @@ We welcome all ideas! If you have suggestions, feel free to open an issue marked
### 5. Local Setup ### 5. Local Setup
You'll need Node.js 20.x or 22.x installed (we're working on support for 23.x), and pnpm 9.x installed. If you're using nix, run `nix develop` to get a shell with the correct versions of everything installed.
1. **Clone the repository**: 1. **Clone the repository**:
```bash ```bash
git clone https://github.com/garden-co/jazz.git git clone https://github.com/gardencmp/jazz.git
``` ```
2. **Install dependencies**: 2. **Install dependencies**:
@@ -55,13 +53,7 @@ You'll need Node.js 20.x or 22.x installed (we're working on support for 23.x),
### 6. Testing ### 6. Testing
Please write tests for any new features or bug fixes. We use Vitest for unit tests, and Playwright for e2e tests. Make sure all tests pass before submitting a pull request. Please write tests for any new features or bug fixes. We use Vitest for unit tests. Make sure all tests pass before submitting a pull request.
```bash
pnpm test
```
NB: You'll need to run `pnpm exec playwright install` to install the Playwright browsers before first run.
### 7. Communication ### 7. Communication

View File

@@ -1,20 +1,12 @@
# Jazz - Build local-first apps # Jazz - Instant sync
**Jazz is an open-source toolkit for building apps with *distributed state.*** **Jazz is an open-source toolkit for building apps with *distributed state.***
## Getting started
We recommend reading the [homepage](https://jazz.tools) and [docs](https://jazz.tools/docs) to get an overview of what Jazz is and how it works.
If you're interested in contributing, please read [CONTRIBUTING.md](./CONTRIBUTING.md).
For community and support, please join our [Discord](https://discord.gg/utDMjHYg42).
---
- Homepage: [jazz.tools](https://jazz.tools) - Homepage: [jazz.tools](https://jazz.tools)
- Docs: [jazz.tools/docs](https://jazz.tools/docs) - Docs: [jazz.tools/docs](https://jazz.tools/docs)
- Community & support: [Discord](https://discord.gg/utDMjHYg42) - Community & support: [Discord](https://discord.gg/utDMjHYg42)
- Updates: [X](https://x.com/jazz_tools) & [Email](https://garden.co/news) - Updates: [Twitter](https://twitter.com/jazz_tools) & [Email](https://gcmp.io/news)
Copyright 2024 — Garden Computing, Inc. Copyright 2024 — Garden Computing, Inc.

View File

@@ -1,77 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [
"jazz-tools.json",
"**/ios/**",
"**/android/**",
"packages/jazz-svelte/**",
"examples/*svelte*/**"
]
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false,
"rules": {
"recommended": true,
"correctness": {
"useImportExtensions": {
"level": "error",
"options": {
"suggestedExtensions": {
"ts": {
"module": "js",
"component": "jsx"
}
}
}
}
}
}
},
"overrides": [
{
"include": ["packages/**/src/**"],
"linter": {
"enabled": true,
"rules": {
"recommended": false
}
}
},
{
"include": ["packages/**/src/tests/**", "packages/**/src/test/**"],
"linter": {
"rules": {
"correctness": {
"useImportExtensions": "off"
}
}
}
},
{
"include": ["packages/cojson-storage-indexeddb/**"],
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "info"
}
}
}
}
]
}

View File

@@ -0,0 +1,98 @@
# @jazz-e2e/binarycostream
## 0.0.93
### Patch Changes
- Updated dependencies [cce679b]
- jazz-tools@0.8.15
- jazz-react@0.8.15
## 0.0.92
### Patch Changes
- Updated dependencies [36273b3]
- jazz-tools@0.8.14
- jazz-react@0.8.14
## 0.0.91
### Patch Changes
- Updated dependencies [fd011d7]
- jazz-tools@0.8.13
- jazz-react@0.8.13
## 0.0.90
### Patch Changes
- Updated dependencies [6ed75eb]
- Updated dependencies [3cc6aee]
- cojson@0.8.12
- jazz-react@0.8.12
- jazz-tools@0.8.12
## 0.0.89
### Patch Changes
- Updated dependencies [1ed4ab5]
- cojson@0.8.11
- jazz-react@0.8.11
- jazz-tools@0.8.11
## 0.0.88
### Patch Changes
- jazz-react@0.8.7
## 0.0.87
### Patch Changes
- jazz-react@0.8.6
## 0.0.86
### Patch Changes
- Updated dependencies [c3f4e6b]
- Updated dependencies [d9152ed]
- jazz-tools@0.8.5
- cojson@0.8.5
- jazz-react@0.8.5
## 0.0.85
### Patch Changes
- Updated dependencies
- hash-slash@0.2.1
## 0.0.84
### Patch Changes
- Updated dependencies
- cojson@0.8.3
- jazz-react@0.8.3
- jazz-tools@0.8.3
## 0.0.83
### Patch Changes
- Updated dependencies [a075f90]
- jazz-tools@0.8.2
- jazz-react@0.8.2
## 0.0.82
### Patch Changes
- Updated dependencies
- jazz-tools@0.8.1
- jazz-react@0.8.1

View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/jazz-logo.png" />
<link rel="stylesheet" href="/src/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Jazz BinaryCoStream Tests</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/app.tsx"></script>
</body>
</html>

View File

@@ -0,0 +1,34 @@
{
"name": "@jazz-e2e/binarycostream",
"private": true,
"version": "0.0.93",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"test": "playwright test",
"test:ui": "playwright test --ui"
},
"lint-staged": {
"*.{js,jsx,mdx,json}": "prettier --write"
},
"dependencies": {
"cojson": "workspace:0.8.12",
"hash-slash": "workspace:0.2.1",
"is-ci": "^3.0.1",
"jazz-react": "workspace:0.8.15",
"jazz-tools": "workspace:0.8.15",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@types/node": "^22.5.1",
"@types/react": "^18.2.19",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react-swc": "^3.3.2",
"typescript": "^5.3.3",
"vite": "^5.0.10"
}
}

View File

@@ -0,0 +1,53 @@
import { defineConfig, devices } from "@playwright/test";
import isCI from "is-ci";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: isCI,
/* Retry on CI only */
retries: isCI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: isCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://localhost:5173/",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
permissions: ["clipboard-read", "clipboard-write"],
},
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
/* Run your local dev server before starting the tests */
webServer: [
{
command: "pnpm preview --port 5173",
url: "http://localhost:5173/",
reuseExistingServer: !isCI,
},
],
});

View File

@@ -0,0 +1,42 @@
import { Account, BinaryCoStream, ID } from "jazz-tools";
import { useEffect } from "react";
import { useAccount, useCoState } from "./jazz";
import { UploadedFile } from "./schema";
import { waitForCoValue } from "./lib/waitForCoValue";
async function getUploadedFile(
me: Account,
uploadedFileId: ID<UploadedFile>) {
const uploadedFile = await waitForCoValue(UploadedFile, uploadedFileId, me, Boolean, {})
uploadedFile.coMapDownloaded = true;
await BinaryCoStream.loadAsBlob(uploadedFile._refs.file.id, me);
return uploadedFile;
}
export function DownloaderPeer(props: { testCoMapId: ID<UploadedFile> }) {
const account = useAccount();
const testCoMap = useCoState(UploadedFile, props.testCoMapId, {});
useEffect(() => {
getUploadedFile(account.me, props.testCoMapId).then(value => {
value.syncCompleted = true;
});
}, []);
return (
<>
<h1>Downloader Peer</h1>
<div>Fetching: {props.testCoMapId}</div>
<div data-testid="result">
Covalue: {Boolean(testCoMap?.id) ? "Downloaded" : "Not Downloaded"}
</div>
<div data-testid="result">
File:{" "}
{Boolean(testCoMap?.syncCompleted) ? "Downloaded" : "Not Downloaded"}
</div>
</>
);
}

View File

@@ -1,13 +1,14 @@
import { useAccount, useCoState } from "jazz-react";
import { ID } from "jazz-tools"; import { ID } from "jazz-tools";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { createCredentiallessIframe } from "../../lib/createCredentiallessIframe"; import { useAccount, useCoState } from "./jazz";
import { waitForCoValue } from "../../lib/waitForCoValue"; import { createCredentiallessIframe } from "./lib/createCredentiallessIframe";
import { BytesRadioGroup } from "./lib/BytesRadioGroup";
import { generateTestFile } from "./lib/generateTestFile"; import { generateTestFile } from "./lib/generateTestFile";
import { getDownloaderPeerUrl } from "./lib/getDownloaderPeerUrl"; import { getDownloaderPeerUrl } from "./lib/getDownloaderPeerUrl";
import { getDefaultFileSize, getIsAutoUpload } from "./lib/searchParams";
import { UploadedFile } from "./schema"; import { UploadedFile } from "./schema";
import { waitForCoValue } from "./lib/waitForCoValue";
import { getDefaultFileSize, getIsAutoUpload } from "./lib/searchParams";
import { BytesRadioGroup } from "./lib/BytesRadioGroup";
export function UploaderPeer() { export function UploaderPeer() {
const account = useAccount(); const account = useAccount();
const [uploadedFileId, setUploadedFileId] = useState< const [uploadedFileId, setUploadedFileId] = useState<
@@ -15,16 +16,12 @@ export function UploaderPeer() {
>(undefined); >(undefined);
const [syncDuration, setSyncDuration] = useState<number | null>(null); const [syncDuration, setSyncDuration] = useState<number | null>(null);
const [bytes, setBytes] = useState(getDefaultFileSize); const [bytes, setBytes] = useState(getDefaultFileSize);
const [synced, setSynced] = useState(false);
const testFile = useCoState(UploadedFile, uploadedFileId, {}); const testFile = useCoState(UploadedFile, uploadedFileId, {});
async function uploadTestFile() { async function uploadTestFile() {
if (!account) return; if (!account) return;
setUploadedFileId(undefined);
setSynced(false);
// Mark the sync start // Mark the sync start
performance.mark("sync-start"); performance.mark("sync-start");
@@ -37,10 +34,6 @@ export function UploaderPeer() {
setSyncDuration(null); setSyncDuration(null);
setUploadedFileId(file.id); setUploadedFileId(file.id);
account.me.waitForAllCoValuesSync().then(() => {
setSynced(true);
});
// The downloader peer will set the syncCompleted to true when the download is complete. // The downloader peer will set the syncCompleted to true when the download is complete.
// We use this to measure the sync duration. // We use this to measure the sync duration.
await waitForCoValue( await waitForCoValue(
@@ -48,7 +41,7 @@ export function UploaderPeer() {
file.id, file.id,
account.me, account.me,
(value) => value.syncCompleted, (value) => value.syncCompleted,
{}, {}
); );
iframe.remove(); iframe.remove();
@@ -70,28 +63,24 @@ export function UploaderPeer() {
<BytesRadioGroup selectedValue={bytes} onChange={setBytes} /> <BytesRadioGroup selectedValue={bytes} onChange={setBytes} />
<button onClick={uploadTestFile}>Upload Test File</button> <button onClick={uploadTestFile}>Upload Test File</button>
{uploadedFileId && ( {uploadedFileId && <div>{uploadedFileId}</div>}
<>
<div>{uploadedFileId}</div>
<div data-testid="synced-with-server">
Synced with the server: {String(synced)}
</div>
</>
)}
{syncDuration && ( {syncDuration && (
<div data-testid="sync-duration"> <div data-testid="sync-duration">
Two way sync duration: {syncDuration.toFixed(2)}ms Sync Duration: {syncDuration.toFixed(2)}ms
</div> </div>
)} )}
{uploadedFileId && ( {uploadedFileId && (
<div data-testid="result"> <div data-testid="result">
Two way sync completed: {String(Boolean(syncDuration))} Sync Completed: {String(Boolean(syncDuration))}
</div> </div>
)} )}
{testFile?.coMapDownloaded && ( {testFile?.coMapDownloaded && (
<div data-testid="co-map-downloaded">CoMap synced!</div> <div data-testid="co-map-downloaded">
CoMap synced!
</div>
)} )}
</> </>
); );
} }

View File

@@ -0,0 +1,24 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { DownloaderPeer } from "./DownloaderPeer";
import { UploaderPeer } from "./UploaderPeer";
import { getValueId } from "./lib/searchParams";
import { AuthAndJazz } from "./jazz";
function Main() {
const valueId = getValueId();
if (valueId) {
return <DownloaderPeer testCoMapId={valueId} />;
}
return <UploaderPeer />;
}
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<AuthAndJazz>
<Main />
</AuthAndJazz>
</React.StrictMode>,
);

View File

@@ -0,0 +1,36 @@
import { createJazzReactApp, useDemoAuth } from "jazz-react";
import { getValueId } from "./lib/searchParams";
import { useEffect, useRef } from "react";
const key = getValueId()
? `downloader-e2e@jazz.tools`
: `uploader-e2e@jazz.tools`;
const localSync = new URLSearchParams(location.search).has("localSync");
const Jazz = createJazzReactApp();
export const { useAccount, useCoState } = Jazz;
export function AuthAndJazz({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
const signedUp = useRef(false);
useEffect(() => {
if (state.state === "ready" && !signedUp.current) {
state.signUp('Mister X');
signedUp.current = true;
}
}, [state.state])
return (
<Jazz.Provider auth={auth} peer={
localSync
? `ws://localhost:4200?key=${key}`
: `wss://cloud.jazz.tools/?key=${key}`
}>
{children}
</Jazz.Provider>
);
}

View File

@@ -4,54 +4,46 @@ export function BytesRadioGroup(props: {
}) { }) {
return ( return (
<p> <p>
<BytesRadioInput <BytesRadioInput
label="1KB" label="1KB"
value={1e3} value={1e3}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/> <BytesRadioInput
<BytesRadioInput label="10KB"
label="10KB" value={1e4}
value={1e4} selectedValue={props.selectedValue}
selectedValue={props.selectedValue} onChange={props.onChange} />
onChange={props.onChange}
/>
<BytesRadioInput <BytesRadioInput
label="100KB" label="100KB"
value={1e5} value={1e5}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
<BytesRadioInput <BytesRadioInput
label="150KB" label="150KB"
value={1e5 + 5e4} value={1e5 + 5e4}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
<BytesRadioInput <BytesRadioInput
label="200KB" label="200KB"
value={2e6} value={2e6}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
<BytesRadioInput <BytesRadioInput
label="500KB" label="500KB"
value={5e6} value={5e6}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
<BytesRadioInput <BytesRadioInput
label="1MB" label="1MB"
value={1e6} value={1e6}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
<BytesRadioInput <BytesRadioInput
label="10MB" label="10MB"
value={1e7} value={1e7}
selectedValue={props.selectedValue} selectedValue={props.selectedValue}
onChange={props.onChange} onChange={props.onChange} />
/>
</p> </p>
); );
} }
@@ -68,8 +60,7 @@ function BytesRadioInput(props: {
name="bytes" name="bytes"
value={props.value} value={props.value}
checked={props.value === props.selectedValue} checked={props.value === props.selectedValue}
onChange={() => props.onChange(props.value)} onChange={() => props.onChange(props.value)} />
/>
{props.label} {props.label}
</label> </label>
); );

View File

@@ -1,4 +1,4 @@
import { Account, FileStream, Group } from "jazz-tools"; import { Account, Group, BinaryCoStream } from "jazz-tools";
import { UploadedFile } from "../schema"; import { UploadedFile } from "../schema";
export async function generateTestFile(me: Account, bytes: number) { export async function generateTestFile(me: Account, bytes: number) {
@@ -8,14 +8,14 @@ export async function generateTestFile(me: Account, bytes: number) {
const ownership = { owner: group }; const ownership = { owner: group };
const testFile = UploadedFile.create( const testFile = UploadedFile.create(
{ {
file: await FileStream.createFromBlob( file: await BinaryCoStream.createFromBlob(
new Blob(["1".repeat(bytes)], { type: "image/png" }), new Blob(['1'.repeat(bytes)], { type: 'image/png' }),
ownership, ownership
), ),
syncCompleted: false, syncCompleted: false,
coMapDownloaded: false, coMapDownloaded: false,
}, },
ownership, ownership
); );
const url = new URL(window.location.href); const url = new URL(window.location.href);
@@ -24,3 +24,4 @@ export async function generateTestFile(me: Account, bytes: number) {
return testFile; return testFile;
} }

View File

@@ -1,4 +1,5 @@
import { UploadedFile } from "../schema"; import { UploadedFile } from "src/schema";
export function getDownloaderPeerUrl(value: UploadedFile) { export function getDownloaderPeerUrl(value: UploadedFile) {
const url = new URL(window.location.href); const url = new URL(window.location.href);

View File

@@ -0,0 +1,14 @@
import { ID } from "jazz-tools";
import { UploadedFile } from "../schema";
export function getValueId() {
return new URLSearchParams(location.search).get("valueId") as ID<UploadedFile> | undefined ?? undefined;
}
export function getIsAutoUpload() {
return new URLSearchParams(location.search).has("auto");
}
export function getDefaultFileSize() {
return parseInt(new URLSearchParams(location.search).get("fileSize") ?? 1e3.toString());
}

View File

@@ -12,24 +12,25 @@ export function waitForCoValue<T extends CoValue>(
valueId: ID<T>, valueId: ID<T>,
account: Account, account: Account,
predicate: (value: T) => boolean, predicate: (value: T) => boolean,
depth: DepthsIn<T>, depth: DepthsIn<T>
) { ) {
return new Promise<T>((resolve) => { return new Promise<T>((resolve) => {
function subscribe() { function subscribe() {
subscribeToCoValue( const unsubscribe = subscribeToCoValue(
coMap, coMap,
valueId, valueId,
account, account,
depth, depth,
(value, unsubscribe) => { (value) => {
if (predicate(value)) { if (predicate(value)) {
resolve(value); resolve(value);
unsubscribe(); unsubscribe();
} }
}, },
() => { () => {
unsubscribe();
setTimeout(subscribe, 100); setTimeout(subscribe, 100);
}, }
); );
} }

View File

@@ -1,7 +1,7 @@
import { CoMap, FileStream, co } from "jazz-tools"; import { BinaryCoStream, co, CoMap } from "jazz-tools";
export class UploadedFile extends CoMap { export class UploadedFile extends CoMap {
file = co.ref(FileStream); file = co.ref(BinaryCoStream);
syncCompleted = co.boolean; syncCompleted = co.boolean;
coMapDownloaded = co.boolean; coMapDownloaded = co.boolean;
} }

View File

@@ -1,33 +1,23 @@
import { test, expect } from "@playwright/test";
import { setTimeout } from "node:timers/promises"; import { setTimeout } from "node:timers/promises";
import { expect, test } from "@playwright/test";
test.describe("FileStream - Sync", () => { test.describe("BinaryCoStream - Sync", () => {
test("should sync a file between the two peers", async ({ page }) => { test("should sync a file between the two peers", async ({ page }) => {
await page.goto("/file-stream"); await page.goto("/");
await page.getByRole("button", { name: "Upload Test File" }).click(); await page.getByRole("button", { name: "Upload Test File" }).click();
await page.getByTestId("sync-duration").waitFor(); await page.getByTestId("sync-duration").waitFor();
await expect(page.getByTestId("synced-with-server")).toHaveText( await expect(page.getByTestId("result")).toHaveText("Sync Completed: true");
"Synced with the server: true",
);
await expect(page.getByTestId("result")).toHaveText(
"Two way sync completed: true",
);
}); });
test("should handle reconnections", async ({ page, browser }) => { test("should handle reconnections", async ({ page, browser }) => {
const context = browser.contexts()[0]; const context = browser.contexts()[0];
await page.goto("/file-stream?fileSize=" + 1e6); // 1MB file await page.goto("/?fileSize=" + 1e6); // 1MB file
await page.getByRole("button", { name: "Upload Test File" }).click(); await page.getByRole("button", { name: "Upload Test File" }).click();
await expect(page.getByTestId("synced-with-server")).toHaveText(
"Synced with the server: false",
);
// Wait for the coMapDonwloaded signal to ensure that the iframe is loaded // Wait for the coMapDonwloaded signal to ensure that the iframe is loaded
await page.getByTestId("co-map-downloaded").waitFor(); await page.getByTestId("co-map-downloaded").waitFor();
@@ -41,12 +31,6 @@ test.describe("FileStream - Sync", () => {
// Wait for the sync to complete // Wait for the sync to complete
await page.getByTestId("sync-duration").waitFor(); await page.getByTestId("sync-duration").waitFor();
await expect(page.getByTestId("synced-with-server")).toHaveText( await expect(page.getByTestId("result")).toHaveText("Sync Completed: true");
"Synced with the server: true",
);
await expect(page.getByTestId("result")).toHaveText(
"Two way sync completed: true",
);
}); });
}); });

View File

@@ -21,5 +21,5 @@
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"baseUrl": "." "baseUrl": "."
}, },
"include": ["src"] "include": ["src"],
} }

View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build: {
minify: false
}
})

View File

@@ -23,5 +23,8 @@ dist-ssr
*.sln *.sln
*.sw? *.sw?
sync-db/
/test-results/ /test-results/
/playwright-report/ /playwright-report/
/blob-report/
/playwright/.cache/

90
e2e/CoValues/CHANGELOG.md Normal file
View File

@@ -0,0 +1,90 @@
# @jazz-e2e/covalues
## 0.0.92
### Patch Changes
- Updated dependencies [cce679b]
- jazz-tools@0.8.15
- jazz-react@0.8.15
## 0.0.91
### Patch Changes
- Updated dependencies [36273b3]
- jazz-tools@0.8.14
- jazz-react@0.8.14
## 0.0.90
### Patch Changes
- Updated dependencies [fd011d7]
- jazz-tools@0.8.13
- jazz-react@0.8.13
## 0.0.89
### Patch Changes
- Updated dependencies [6ed75eb]
- Updated dependencies [3cc6aee]
- cojson@0.8.12
- jazz-react@0.8.12
- jazz-tools@0.8.12
## 0.0.88
### Patch Changes
- Updated dependencies [1ed4ab5]
- cojson@0.8.11
- jazz-react@0.8.11
- jazz-tools@0.8.11
## 0.0.87
### Patch Changes
- jazz-react@0.8.7
## 0.0.86
### Patch Changes
- jazz-react@0.8.6
## 0.0.85
### Patch Changes
- Updated dependencies [c3f4e6b]
- Updated dependencies [d9152ed]
- jazz-tools@0.8.5
- cojson@0.8.5
- jazz-react@0.8.5
## 0.0.84
### Patch Changes
- Updated dependencies
- hash-slash@0.2.1
## 0.0.83
### Patch Changes
- Updated dependencies
- cojson@0.8.3
- jazz-react@0.8.3
- jazz-tools@0.8.3
## 0.0.82
### Patch Changes
- Updated dependencies [a075f90]
- jazz-tools@0.8.2
- jazz-react@0.8.2

View File

@@ -1,19 +1,18 @@
{ {
"name": "@jazz/e2e-test-suite", "name": "@jazz-e2e/covalues",
"private": true, "private": true,
"version": "0.0.110", "version": "0.0.92",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"dev:local": "VITE_WS_PEER=ws://localhost:4200/ vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"format-and-lint": "biome check .",
"format-and-lint:fix": "biome check . --write",
"test": "playwright test", "test": "playwright test",
"sync": "jazz-run sync",
"test:ui": "playwright test --ui" "test:ui": "playwright test --ui"
}, },
"lint-staged": {
"*.{js,jsx,mdx,json}": "prettier --write"
},
"dependencies": { "dependencies": {
"cojson": "workspace:*", "cojson": "workspace:*",
"hash-slash": "workspace:*", "hash-slash": "workspace:*",
@@ -33,7 +32,6 @@
"@vitejs/plugin-react-swc": "^3.3.2", "@vitejs/plugin-react-swc": "^3.3.2",
"jstat": "^1.9.6", "jstat": "^1.9.6",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"jazz-run": "workspace:*",
"vite": "^5.0.10" "vite": "^5.0.10"
} }
} }

View File

@@ -0,0 +1,53 @@
import { defineConfig, devices } from "@playwright/test";
import isCI from "is-ci";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: isCI,
/* Retry on CI only */
retries: isCI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: isCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://localhost:5173/",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
permissions: ["clipboard-read", "clipboard-write"],
},
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
/* Run your local dev server before starting the tests */
webServer: [
{
command: "pnpm preview --port 5173",
url: "http://localhost:5173/",
reuseExistingServer: !isCI,
},
],
});

30
e2e/CoValues/src/app.tsx Normal file
View File

@@ -0,0 +1,30 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { AuthAndJazz } from "./jazz";
import { TestInput } from "./pages/TestInput";
import { ResumeSyncState } from "./pages/ResumeSyncState";
import { RouterProvider, createBrowserRouter } from "react-router-dom";
const router = createBrowserRouter([
{
path: "/test-input",
element: <TestInput />,
},
{
path: "/resume-sync",
element: <ResumeSyncState />,
},
{
path: "/",
element: <TestInput />,
},
]);
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<AuthAndJazz>
<RouterProvider router={router} />
</AuthAndJazz>
</React.StrictMode>,
);

43
e2e/CoValues/src/jazz.tsx Normal file
View File

@@ -0,0 +1,43 @@
import { createJazzReactApp, useDemoAuth } from "jazz-react";
import { useEffect, useRef } from "react";
const key = `test-comap@jazz.tools`;
const url = new URL(window.location.href);
const peer =
(url.searchParams.get("peer") as `ws://${string}`) ??
`wss://cloud.jazz.tools/`;
const Jazz = createJazzReactApp();
export const { useAccount, useCoState } = Jazz;
function getUserInfo() {
return url.searchParams.get("userName") ?? "Mister X";
}
export function AuthAndJazz({ children }: { children: React.ReactNode }) {
const [auth, state] = useDemoAuth();
const signedUp = useRef(false);
useEffect(() => {
if (state.state === "ready" && !signedUp.current) {
const userName = getUserInfo();
if (state.existingUsers.includes(userName)) {
state.logInAs(userName);
} else {
state.signUp(userName);
}
signedUp.current = true;
}
}, [state.state]);
return (
<Jazz.Provider auth={auth} peer={`${peer}?key=${key}`}>
{children}
</Jazz.Provider>
);
}

View File

@@ -0,0 +1,53 @@
import { co, CoMap, Group, ID } from "jazz-tools";
import { useAccount, useCoState } from "../jazz";
import { useEffect, useState } from "react";
export class ResumeSyncCoMap extends CoMap {
value = co.string;
}
function getIdParam() {
const url = new URL(window.location.href);
return (url.searchParams.get("id") as ID<ResumeSyncCoMap>) ?? undefined;
}
export function ResumeSyncState() {
const [id, setId] = useState(getIdParam);
const coMap = useCoState(ResumeSyncCoMap, id);
const { me } = useAccount();
useEffect(() => {
if (id) {
const url = new URL(window.location.href);
url.searchParams.set("id", id);
history.pushState({}, "", url.toString());
}
}, [id])
useEffect(() => {
if (!me || id) return;
const group = Group.create({ owner: me });
group.addMember("everyone", "writer");
setId(ResumeSyncCoMap.create({ value: "" }, { owner: group }).id);
}, [me]);
if (!coMap) return null;
return (
<div>
<h1>Resume Sync State</h1>
<p data-testid="id">{coMap.id}</p>
<label htmlFor="value">Value</label>
<input
id="value"
value={coMap.value ?? ""}
onChange={(e) => {
coMap.value = e.target.value;
}}
/>
</div>
);
}

View File

@@ -1,5 +1,5 @@
import { useAccount, useCoState } from "jazz-react"; import { co, CoMap, Group, ID } from "jazz-tools";
import { CoMap, Group, ID, co } from "jazz-tools"; import { useAccount, useCoState } from "../jazz";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
export class InputTestCoMap extends CoMap { export class InputTestCoMap extends CoMap {

View File

@@ -1,11 +1,8 @@
import { test, expect } from "@playwright/test";
import { setTimeout } from "node:timers/promises"; import { setTimeout } from "node:timers/promises";
import { expect, test } from "@playwright/test";
test.describe("ResumeSyncState", () => { test.describe("ResumeSyncState", () => {
test.skip("should resume the sync even after a page reload", async ({ test.skip("should resume the sync even after a page reload", async ({ page, browser }) => {
page,
browser,
}) => {
const context = page.context(); const context = page.context();
await page.goto("/resume-sync?userName=SuperMario"); await page.goto("/resume-sync?userName=SuperMario");
@@ -23,7 +20,7 @@ test.describe("ResumeSyncState", () => {
// Navigate away from the page // Navigate away from the page
await page.goto(`about:blank`); await page.goto(`about:blank`);
await setTimeout(1000); await setTimeout(1000);
await context.setOffline(false); await context.setOffline(false);
@@ -43,10 +40,8 @@ test.describe("ResumeSyncState", () => {
// The initial user should have synced the value even if the coValue was not loaded // The initial user should have synced the value even if the coValue was not loaded
// when the user is back online // when the user is back online
await expect( await expect(newUserPage.getByRole("textbox", { name: "Value" })).toHaveValue("Mammamia!", {
newUserPage.getByRole("textbox", { name: "Value" }), timeout: 20_000
).toHaveValue("Mammamia!", {
timeout: 20_000,
}); });
}); });
}); });

View File

@@ -1,14 +1,14 @@
import { expect, test } from "@playwright/test"; import { test, expect } from "@playwright/test";
test.describe("CoMap - TestInput", () => { test.describe("CoMap - TestInput", () => {
test("should keep the cursor position when typing", async ({ page }) => { test("should keep the cursor position when typing", async ({ page }) => {
await page.goto("/test-input"); await page.goto("/test-input");
await page.getByRole("textbox").fill("xx"); await page.getByRole("textbox").fill("xx");
await page.getByRole("textbox").press("ArrowLeft"); await page.getByRole('textbox').press('ArrowLeft');
await page.getByRole("textbox").press("y"); await page.getByRole("textbox").press("y");
await page.getByRole("textbox").press("y"); await page.getByRole("textbox").press("y");
await expect(page.getByRole("textbox")).toHaveValue("xyyx"); await expect(page.getByRole('textbox')).toHaveValue("xyyx");
}); });
}); });

View File

@@ -19,11 +19,7 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"baseUrl": ".", "baseUrl": "."
"paths": {
"@/*": ["./src/*"]
}
}, },
"include": ["src"], "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
} }

View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build: {
minify: false
}
})

View File

@@ -0,0 +1,11 @@
{
"extends": [
"next/core-web-vitals",
"prettier",
"plugin:prettier/recommended"
],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"]
}
}

36
examples/book-shelf/.gitignore vendored Normal file
View File

@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

View File

@@ -0,0 +1,11 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "avoid",
"printWidth": 80,
"plugins": ["prettier-plugin-tailwindcss"]
}

View File

@@ -0,0 +1,69 @@
# jazz-example-book-shelf
## 0.1.8
### Patch Changes
- Updated dependencies [cce679b]
- jazz-tools@0.8.15
- jazz-browser-media-images@0.8.15
- jazz-react@0.8.15
## 0.1.7
### Patch Changes
- Updated dependencies [36273b3]
- jazz-tools@0.8.14
- jazz-browser-media-images@0.8.14
- jazz-react@0.8.14
## 0.1.6
### Patch Changes
- Updated dependencies [fd011d7]
- jazz-tools@0.8.13
- jazz-browser-media-images@0.8.13
- jazz-react@0.8.13
## 0.1.5
### Patch Changes
- Updated dependencies [3cc6aee]
- jazz-react@0.8.12
- jazz-tools@0.8.12
- jazz-browser-media-images@0.8.12
## 0.1.4
### Patch Changes
- jazz-react@0.8.11
- jazz-tools@0.8.11
- jazz-browser-media-images@0.8.11
## 0.1.3
### Patch Changes
- jazz-browser-media-images@0.8.7
- jazz-react@0.8.7
## 0.1.2
### Patch Changes
- jazz-browser-media-images@0.8.6
- jazz-react@0.8.6
## 0.1.1
### Patch Changes
- Updated dependencies [c3f4e6b]
- Updated dependencies [d9152ed]
- jazz-tools@0.8.5
- jazz-browser-media-images@0.8.5
- jazz-react@0.8.5

View File

@@ -1,4 +1,4 @@
FROM caddy:2.7.3-alpine FROM caddy:2.7.3-alpine
LABEL org.opencontainers.image.source="https://github.com/garden-co/jazz" LABEL org.opencontainers.image.source="https://github.com/gardencmp/jazz"
COPY ./dist /usr/share/caddy/ COPY ./dist /usr/share/caddy/

View File

@@ -0,0 +1,43 @@
# Jazz Book Shelf Example
Live version: [https://books-demo.jazz.tools](https://books-demo.jazz.tools)
## Installing & running the example locally
(this requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
Start by checking out `jazz`
Install dependencies:
```bash
pnpm install
```
Go to the `examples/book-shelf` directory.
```bash
cd examples/book-shelf
```
Install dependencies:
```bash
pnpm install
```
Start the dev server:
```bash
pnpm dev
```
## 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.
## Configuration: sync server
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/components/JazzAndAuth.tsx](./src/2_main.tsx).

View File

@@ -0,0 +1,56 @@
job "example-bookShelf$BRANCH_SUFFIX" {
region = "global"
datacenters = ["*"]
group "static" {
count = 4
network {
port "http" {
to = 80
}
}
constraint {
attribute = "${node.class}"
operator = "="
value = "cloud"
}
spread {
attribute = "${node.datacenter}"
weight = 100
}
constraint {
distinct_hosts = true
}
task "server" {
driver = "docker"
config {
image = "$DOCKER_TAG"
ports = ["http"]
auth = {
username = "$DOCKER_USER"
password = "$DOCKER_PASSWORD"
}
}
service {
tags = ["public"]
name = "example-bookShelf$BRANCH_SUFFIX"
port = "http"
provider = "consul"
}
resources {
cpu = 50 # MHz
memory = 50 # MB
}
}
}
}
# deploy bump 4

5
examples/book-shelf/next-env.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;

View File

@@ -0,0 +1,35 @@
{
"name": "jazz-example-book-shelf",
"version": "0.1.8",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --write ."
},
"dependencies": {
"clsx": "^2.0.0",
"jazz-browser-media-images": "workspace:0.8.15",
"jazz-react": "workspace:0.8.15",
"jazz-tools": "workspace:0.8.15",
"next": "14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^22.5.1",
"@types/react": "^18.2.19",
"@types/react-dom": "^18.2.7",
"eslint": "^8.46.0",
"eslint-config-next": "14.2.5",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"postcss": "^8.4.27",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "3.3.2",
"typescript": "^5.3.3"
}
}

View File

@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};
export default config;

View File

@@ -0,0 +1,136 @@
"use client";
import { ChangeEvent, useState } from "react";
import { BookReview, ListOfBookReviews } from "@/schema";
import { useAccount } from "@/components/JazzAndAuth";
import { useRouter } from "next/navigation";
import RatingInput from "@/components/RatingInput";
import { createImage } from "jazz-browser-media-images";
import { Group, ImageDefinition } from "jazz-tools";
import { Container } from "@/components/Container";
import { Button } from "@/components/Button";
export default function AddBookReview() {
const { me } = useAccount();
const [title, setTitle] = useState("");
const [author, setAuthor] = useState("");
const [review, setReview] = useState("");
const [rating, setRating] = useState(0);
const [dateRead, setDateRead] = useState(
new Date().toISOString().split("T")[0]
);
const [coverImage, setCoverImage] = useState<ImageDefinition | undefined>();
const router = useRouter();
const onDateChange = (event: ChangeEvent<HTMLInputElement>) => {
const date = new Date(event.currentTarget.value)
.toISOString()
.split("T")[0];
setDateRead(date);
};
const onImageChange = (event: ChangeEvent<HTMLInputElement>) => {
const file = event.currentTarget.files?.[0];
const group = Group.create({ owner: me });
group.addMember("everyone", "reader");
if (file) {
createImage(file, { owner: group }).then(image => {
setCoverImage(image);
});
}
};
const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (!me?.profile) return;
const bookReview = BookReview.create(
{
title,
author,
review,
rating,
dateRead: new Date(dateRead),
cover: coverImage,
},
{
owner: me.profile._owner,
}
);
if (!me.profile.bookReviews) {
me.profile.bookReviews = ListOfBookReviews.create([], {
owner: me.profile._owner,
});
}
me.profile.bookReviews.push(bookReview);
router.push("/");
};
return (
<Container className="grid max-w-lg gap-8 py-8">
<h1 className="text-lg font-semibold text-black">Add book review</h1>
<form action="" className="grid gap-4" onSubmit={onSubmit}>
<label className="grid gap-1 text-sm text-gray-600">
Cover
<input type="file" onChange={onImageChange} />
</label>
<label className="grid gap-1 text-sm text-gray-600">
Title
<input
className="rounded border border-gray-300 px-2 py-1 shadow-sm"
type="text"
value={title}
required
onChange={e => setTitle(e.target.value)}
></input>
</label>
<label className="grid gap-1 text-sm text-gray-600">
Author
<input
className="rounded border border-gray-300 px-2 py-1 shadow-sm"
type="text"
value={author}
required
onChange={e => setAuthor(e.target.value)}
></input>
</label>
<label className="grid gap-1 text-sm text-gray-600">
Date read
<input
className="rounded border border-gray-300 px-2 py-1 shadow-sm"
type="date"
value={dateRead}
required
onChange={onDateChange}
/>
</label>
<div className="grid gap-1 text-sm text-gray-600">
Rating
<RatingInput value={rating} onChange={rating => setRating(rating)} />
</div>
<label className="grid gap-1 text-sm text-gray-600">
Review
<textarea
className="rounded border border-gray-300 px-2 py-1 shadow-sm"
value={review}
onChange={e => setReview(e.target.value)}
></textarea>
</label>
<Button variant="primary" type="submit">
Add
</Button>
</form>
</Container>
);
}

View File

@@ -0,0 +1,172 @@
"use client";
import { useCoState } from "@/components/JazzAndAuth";
import { BookReview } from "@/schema";
import { Group, ID } from "jazz-tools";
import { BookCover } from "@/components/BookCover";
import clsx from "clsx";
import RatingInput from "@/components/RatingInput";
import Rating from "@/components/Rating";
import { Container } from "@/components/Container";
const BookReviewTitle = ({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly: boolean;
}) => {
const className = "font-serif text-2xl font-bold lg:text-4xl";
if (readOnly) {
return <h1 className={className}>{bookReview.title}</h1>;
}
return (
<input
value={bookReview.title}
placeholder="Book title"
className={clsx(
className,
"w-full rounded border border-transparent px-2 py-1 hover:border-gray-300 hover:shadow-sm"
)}
onChange={e => (bookReview.title = e.target.value)}
></input>
);
};
const BookReviewAuthor = ({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly: boolean;
}) => {
const className = "text-gray-700";
if (readOnly) {
return <p className={className}>by {bookReview.author}</p>;
}
return (
<input
value={bookReview.author}
placeholder="Author"
className={clsx(
className,
"w-full rounded border border-transparent px-2 py-1 hover:border-gray-300 hover:shadow-sm"
)}
onChange={e => (bookReview.author = e.target.value)}
></input>
);
};
const BookReviewDateRead = ({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly: boolean;
}) => {
const className = "text-gray-700 max-w-[10rem]";
if (readOnly) {
return (
bookReview.dateRead && (
<p className={className}>{bookReview.dateRead.toLocaleDateString()}</p>
)
);
}
return (
<input
type="date"
value={bookReview.dateRead?.toISOString().split("T")[0]}
placeholder="Date read"
className={clsx(
className,
"w-full rounded border border-transparent px-2 py-1 hover:border-gray-300 hover:shadow-sm"
)}
onChange={e => {
const date = new Date(e.target.value);
bookReview.dateRead = date;
}}
></input>
);
};
const BookReviewReview = ({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly: boolean;
}) => {
const className = "text-sm leading-relaxed text-gray-600";
if (readOnly) {
if (bookReview.review) {
return <p className={className}>{bookReview.review}</p>;
}
}
return (
<textarea
value={bookReview.review}
placeholder="Write your review here..."
className={clsx(
className,
"w-full rounded border border-transparent px-2 py-1 hover:border-gray-300 hover:shadow-sm"
)}
onChange={e => (bookReview.review = e.target.value)}
></textarea>
);
};
const BookReviewRating = ({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly: boolean;
}) => {
const className = "text-2xl sm:mx-0";
if (readOnly) {
return <Rating className={className} rating={bookReview.rating} />;
}
return (
<RatingInput
className={clsx(className, "p-2")}
onChange={rating => (bookReview.rating = rating)}
value={bookReview.rating}
/>
);
};
export default function Page({ params }: { params: { slug: string } }) {
const bookReview = useCoState(BookReview, params.slug as ID<BookReview>);
if (!bookReview) return <></>;
const readOnly = !(bookReview._owner.castAs(Group).myRole() === "admin");
return (
<Container className="grid gap-12 py-8">
<div className="flex flex-col gap-6 sm:flex-row md:gap-10">
<div className="w-[180px]">
<BookCover bookReview={bookReview} readOnly={readOnly} />
</div>
<div className="-mx-2 grid max-w-lg flex-1 gap-3 sm:mx-0">
<BookReviewTitle bookReview={bookReview} readOnly={readOnly} />
<BookReviewAuthor bookReview={bookReview} readOnly={readOnly} />
<BookReviewDateRead bookReview={bookReview} readOnly={readOnly} />
<BookReviewRating bookReview={bookReview} readOnly={readOnly} />
<BookReviewReview bookReview={bookReview} readOnly={readOnly} />
</div>
</div>
</Container>
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:focus {
@apply outline-none;
}
:focus-visible {
@apply ring-2 ring-purple-600/75 dark:ring-2 dark:ring-white/75;
}
}

View File

@@ -0,0 +1,39 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { JazzAndAuth } from "@/components/JazzAndAuth";
import { Nav } from "@/components/Nav";
import { Fraunces } from "next/font/google";
import clsx from "clsx";
const fraunces = Fraunces({
subsets: ["latin"],
display: "swap",
variable: "--font-fraunces",
});
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Jazz Book Shelf",
description: "Jazz Book Shelf",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={clsx(inter.className, fraunces.variable)}>
<JazzAndAuth>
<header>
<Nav />
</header>
<main>{children}</main>
</JazzAndAuth>
</body>
</html>
);
}

View File

@@ -0,0 +1,27 @@
"use client";
import { useAccount } from "@/components/JazzAndAuth";
import UserProfile from "@/components/UserProfile";
import { JazzAccount } from "@/schema";
import { ID } from "jazz-tools";
import { Container } from "@/components/Container";
export default function Home() {
const { me } = useAccount();
return (
<Container className="grid gap-12 py-8">
<UserProfile id={me?.id as ID<JazzAccount>} />
<label className="flex flex-wrap items-center gap-3">
Share your profile:
<input
type="text"
className="w-full rounded border p-1"
value={`${window.location.origin}/user/${me?.id}`}
readOnly
/>
</label>
</Container>
);
}

View File

@@ -0,0 +1,14 @@
import UserProfile from "@/components/UserProfile";
import { JazzAccount } from "@/schema";
import { ID } from "jazz-tools";
import { Container } from "@/components/Container";
export default function Page({ params }: { params: { slug: string } }) {
const { slug } = params;
return (
<Container className="py-8">
<UserProfile id={slug as ID<JazzAccount>} />
</Container>
);
}

View File

@@ -0,0 +1,134 @@
import { ProgressiveImg } from "jazz-react";
import { BookReview } from "@/schema";
import { ChangeEvent, useRef, useState } from "react";
import { Group, ImageDefinition } from "jazz-tools";
import { createImage } from "jazz-browser-media-images";
import { useAccount } from "@/components/JazzAndAuth";
import clsx from "clsx";
import PlusIcon from "@/components/icons/PlusIcon";
import { Button } from "@/components/Button";
const BookCoverContainer = ({
children,
className = "",
}: {
children: React.ReactNode;
className?: string;
}) => {
return (
<div className={clsx("h-[240px] lg:h-[260px]", className)}>{children}</div>
);
};
const MockCover = ({ bookReview }: { bookReview: BookReview }) => {
return (
<div className="flex h-full flex-col items-center justify-center gap-3 rounded-l-sm rounded-r-md bg-gray-100 px-3 text-center shadow-lg">
<p className="font-medium">{bookReview.title}</p>
<p className="text-xs">{bookReview.author}</p>
</div>
);
};
export function BookCoverReadOnly({
bookReview,
className,
}: {
bookReview: BookReview;
className?: string;
}) {
if (bookReview.cover) {
return (
<BookCoverContainer className={className}>
<ProgressiveImg image={bookReview.cover}>
{({ src }) => (
<img
className="max-h-full max-w-full rounded-l-sm rounded-r-md shadow-lg"
src={src}
/>
)}
</ProgressiveImg>
</BookCoverContainer>
);
}
return (
<BookCoverContainer className={className}>
<MockCover bookReview={bookReview} />
</BookCoverContainer>
);
}
export function BookCoverInput({ bookReview }: { bookReview: BookReview }) {
const { me } = useAccount();
const inputRef = useRef<HTMLInputElement>(null);
const onImageChange = (event: ChangeEvent<HTMLInputElement>) => {
if (!me?.profile) return;
const file = event.currentTarget.files?.[0];
if (file) {
createImage(file, { owner: me.profile._owner }).then(image => {
bookReview.cover = image;
});
}
};
const onUploadClick = () => {
inputRef.current?.click();
};
const remove = () => {
bookReview.cover = null;
};
if (bookReview.cover) {
return (
<div className="group relative inline-block">
<BookCoverReadOnly
className="transition-opacity group-hover:opacity-40"
bookReview={bookReview}
/>
<div className="absolute left-0 top-0 hidden h-full w-full items-center justify-center rounded-l-sm rounded-r-md group-hover:flex">
<Button
variant="tertiary"
type="button"
className="shadow"
onClick={remove}
>
Remove
</Button>
</div>
</div>
);
}
return (
<BookCoverContainer className="flex w-[180px] flex-col justify-center rounded-l-sm rounded-r-md bg-gray-100 p-3 shadow-lg">
<button
className="flex h-full w-full flex-col items-center justify-center gap-3 text-gray-500 transition-colors hover:text-gray-600"
type="button"
onClick={onUploadClick}
>
<PlusIcon className="h-10 w-10" />
Upload book cover
</button>
<label className="sr-only">
Cover
<input ref={inputRef} type="file" onChange={onImageChange} />
</label>
</BookCoverContainer>
);
}
export function BookCover({
bookReview,
readOnly,
}: {
bookReview: BookReview;
readOnly?: boolean;
}) {
if (readOnly) return <BookCoverReadOnly bookReview={bookReview} />;
return <BookCoverInput bookReview={bookReview} />;
}

View File

@@ -0,0 +1,30 @@
import { BookReview } from "@/schema";
import Rating from "@/components/Rating";
import { Group } from "jazz-tools";
import RatingInput from "@/components/RatingInput";
import { BookCover } from "@/components/BookCover";
export function BookReviewHeader({ bookReview }: { bookReview: BookReview }) {
const { title, author, rating, review, dateRead } = bookReview;
return (
<div className="grid gap-5">
<div>
<h1 className="mb-1 font-serif text-2xl font-bold md:mb-3 lg:text-4xl">
{title}
</h1>
<p className="text-gray-500">by {author}</p>
</div>
{bookReview._owner.castAs(Group).myRole() === "admin" ? (
<RatingInput
onChange={rating => (bookReview.rating = rating)}
value={rating}
/>
) : (
<Rating className="mx-auto text-2xl sm:mx-0" rating={rating} />
)}
</div>
);
}

View File

@@ -0,0 +1,35 @@
"use client";
import { BookReview } from "../schema";
import { ID } from "jazz-tools";
import { useCoState } from "@/components/JazzAndAuth";
import Link from "next/link";
import { BookCover, BookCoverReadOnly } from "@/components/BookCover";
import StarIcon from "@/components/icons/StarIcon";
export function BookReviewThumbnail({ id }: { id: ID<BookReview> }) {
const bookReview = useCoState(BookReview, id);
if (!bookReview) return <></>;
return (
<div className="inline-flex shrink-0 gap-4 rounded border p-4 sm:block sm:space-y-6 sm:border-0 sm:p-0 md:w-[200px]">
<Link href={`/book/${bookReview.id}`} className="sm:block sm:flex-1">
<BookCoverReadOnly bookReview={bookReview} />
</Link>
<div className="flex-1">
<Link href={`/book/${bookReview.id}`}>
<h2 className="mb-1 text-sm font-medium">{bookReview.title}</h2>
</Link>
<div className="mb-2 flex flex-col gap-2 text-sm text-gray-500 sm:flex-row sm:items-center">
<p>{bookReview.author}</p>
<div className="flex items-center gap-0.5 text-xs font-semibold leading-none">
<StarIcon className="-mt-px text-base text-yellow-400" />
{bookReview.rating}
</div>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,65 @@
import Link from "next/link";
import type { ComponentProps } from "react";
import clsx from "clsx";
interface Props {
variant?: "primary" | "secondary" | "tertiary";
className?: string;
size?: "sm" | "md" | "lg";
}
interface AnchorProps
extends Props,
React.AnchorHTMLAttributes<HTMLAnchorElement> {
href: string;
}
type ButtonProps = ComponentProps<"button"> & Props;
export function Button(props: AnchorProps | ButtonProps) {
const {
className: customClassName = "",
variant = "primary",
children,
size = "md",
} = props;
const variantClassNames = {
base: "inline-flex gap-2 items-center justify-center rounded-full overflow-hidden transition-colors",
primary:
"bg-purple-300 font-medium text-purple-950 px-4 py-2 rounded-full hover:bg-purple-200",
secondary:
"rounded-full bg-slate-100 font-medium text-slate-600 hover:bg-slate-200",
tertiary: "rounded-full bg-white text-purple-950 font-medium",
};
const sizeClassNames = {
sm: "py-1.5 px-3 text-sm",
md: "py-2 px-5",
lg: "py-2 md:py-2.5 px-6 md:text-lg",
};
const className = clsx(
customClassName,
variantClassNames.base,
variantClassNames[variant],
sizeClassNames[size]
);
if (!!(props as AnchorProps).href) {
const anchorProps = props as AnchorProps;
return (
<Link href={anchorProps.href} className={className}>
{children}
</Link>
);
}
const buttonProps = props as ButtonProps;
return (
<button {...buttonProps} className={className}>
{children}
</button>
);
}

View File

@@ -0,0 +1,13 @@
import clsx from "clsx";
export function Container({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}) {
return (
<div className={clsx("mx-auto max-w-4xl px-4", className)}>{children}</div>
);
}

View File

@@ -0,0 +1,29 @@
"use client";
import { createJazzReactApp, useDemoAuth, DemoAuthBasicUI } from "jazz-react";
import { JazzAccount } from "@/schema";
const Jazz = createJazzReactApp({
AccountSchema: JazzAccount,
});
export const { useAccount, useCoState } = Jazz;
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
const [auth, authState] = useDemoAuth();
return (
<>
<Jazz.Provider
auth={auth}
// replace `you@example.com` with your email as a temporary API key
peer="wss://cloud.jazz.tools/?key=you@example.com"
>
{children}
</Jazz.Provider>
{authState.state !== "signedIn" && (
<DemoAuthBasicUI appName="Jazz Book Shelf" state={authState} />
)}
</>
);
}

View File

@@ -0,0 +1,26 @@
"use client";
import { useAccount } from "@/components/JazzAndAuth";
import Link from "next/link";
import { Container } from "@/components/Container";
import { Button } from "@/components/Button";
export function Nav() {
const { me, logOut } = useAccount();
return (
<nav className="border-b py-3">
<Container className="flex items-center justify-between gap-12 text-sm">
<Link href="/" className="font-serif text-lg font-semibold">
Jazz Book Shelf
</Link>
<div className="flex items-center gap-4 text-sm">
<p>{me?.profile?.name}</p>
<Button variant="secondary" onClick={logOut}>
Log out
</Button>
</div>
</Container>
</nav>
);
}

View File

@@ -0,0 +1,21 @@
import StarIcon from "@/components/icons/StarIcon";
import StarOutlineIcon from "@/components/icons/StarOutlineIcon";
export default function Rating({
rating,
className = "",
}: {
rating?: number;
className?: string;
}) {
const max = 5;
const outline = max - (rating || 0);
return (
<div className={`inline-flex gap-0.5 text-yellow-400 ${className}`}>
{rating ? [...Array(rating)].map((x, i) => <StarIcon key={i} />) : <></>}
{[...Array(outline)].map((x, i) => (
<StarOutlineIcon key={i} />
))}
</div>
);
}

View File

@@ -0,0 +1,47 @@
"use client";
import StarOutlineIcon from "@/components/icons/StarOutlineIcon";
import StarIcon from "@/components/icons/StarIcon";
import clsx from "clsx";
interface RatingInputProps {
value?: number;
onChange: (value: number) => void;
className?: string;
}
export default function RatingInput({
value = 0,
onChange,
className,
}: RatingInputProps) {
const handleChange = (newRating: number) => {
onChange(newRating > 5 ? 5 : newRating);
};
return (
<div className={clsx(className, "flex gap-0.5 text-2xl text-yellow-400")}>
{[...Array(5)].map((_, i) => {
return i < value ? (
<button
type="button"
className="focus:outline-none"
onClick={() => handleChange(i + 1)}
key={i}
>
<StarIcon />
</button>
) : (
<button
type="button"
className="focus:outline-none"
onClick={() => handleChange(i + 1)}
key={i}
>
<StarOutlineIcon />
</button>
);
})}
</div>
);
}

View File

@@ -0,0 +1,39 @@
"use client";
import { useCoState } from "@/components/JazzAndAuth";
import { Group, ID } from "jazz-tools";
import { JazzAccount, JazzProfile, ListOfBookReviews } from "@/schema";
import { BookReviewThumbnail } from "@/components/BookReviewThumbnail";
import { Button } from "@/components/Button";
export default function UserProfile({ id }: { id: ID<JazzAccount> }) {
const user = useCoState(JazzAccount, id);
const profile = useCoState(JazzProfile, user?.profile?.id);
const bookReviews = useCoState(
ListOfBookReviews,
user?.profile?._refs.bookReviews?.id,
[{}]
);
return (
<div className="grid gap-4">
<div className="flex items-center justify-between">
<h1 className="font-serif text-lg font-medium sm:text-2xl">
{profile?.name}&apos;s book shelf
</h1>
{profile?._owner.castAs(Group).myRole() === "admin" && (
<Button href="/add" variant="primary">
Add book
</Button>
)}
</div>
<div className="grid gap-4 md:grid-cols-4">
{bookReviews?.map(bookReview => (
<BookReviewThumbnail key={bookReview.id} id={bookReview.id} />
))}
</div>
</div>
);
}

View File

@@ -1,4 +1,4 @@
export function LinkIcon() { export default function PlusIcon({ className }: { className?: string }) {
return ( return (
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -6,12 +6,14 @@ export function LinkIcon() {
viewBox="0 0 24 24" viewBox="0 0 24 24"
strokeWidth={1.5} strokeWidth={1.5}
stroke="currentColor" stroke="currentColor"
className="w-3 h-3" className={className}
width="1em"
height="1em"
> >
<path <path
strokeLinecap="round" strokeLinecap="round"
strokeLinejoin="round" strokeLinejoin="round"
d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244" d="M12 4.5v15m7.5-7.5h-15"
/> />
</svg> </svg>
); );

View File

@@ -0,0 +1,18 @@
export default function StarIcon({ className }: { className?: string }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
className={className}
width="1em"
height="1em"
>
<path
fillRule="evenodd"
d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z"
clipRule="evenodd"
/>
</svg>
);
}

View File

@@ -0,0 +1,20 @@
export default function StarOutlineIcon({ className }: { className?: string }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className={className}
width="1em"
height="1em"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"
/>
</svg>
);
}

View File

@@ -0,0 +1,37 @@
import {
CoMap,
co,
CoList,
Account,
Profile,
ImageDefinition,
Encoders,
} from "jazz-tools";
export class BookReview extends CoMap {
title = co.string;
author = co.string;
rating = co.number;
dateRead? = co.encoded(Encoders.Date);
review? = co.string;
cover? = co.ref(ImageDefinition, { optional: true });
}
export class ListOfBookReviews extends CoList.Of(co.ref(BookReview)) {}
/** The profile is an app-specific per-user public `CoMap`
* where you can store top-level objects for that user */
export class JazzProfile extends Profile {
bookReviews = co.ref(ListOfBookReviews);
}
export class JazzAccount extends Account {
profile = co.ref(JazzProfile);
/** The account migration is run on account creation and on every log-in.
* You can use it to set up the account root and any other initial CoValues you need.
*/
migrate(this: JazzAccount, creationProps?: { name: string }) {
super.migrate(creationProps);
}
}

View File

@@ -0,0 +1,25 @@
import type { Config } from "tailwindcss";
const colors = require("tailwindcss/colors");
const config: Config = {
content: [
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
serif: ["var(--font-fraunces)"],
},
colors: {
purple: {
...colors.purple,
950: "#211f5a",
},
},
},
},
plugins: [],
};
export default config;

View File

@@ -3,25 +3,26 @@
"target": "ES2020", "target": "ES2020",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"], "lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext", "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "jsx": "preserve",
"jsx": "react-jsx", "incremental": true,
"plugins": [
"strict": true, {
"noUnusedLocals": true, "name": "next"
"noUnusedParameters": true, }
"noFallthroughCasesInSwitch": true, ],
"baseUrl": "./",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
} }
}, },
"include": ["src"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"references": [{ "path": "./tsconfig.node.json" }] "exclude": ["node_modules"]
} }

View File

@@ -0,0 +1,13 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {},
};

View File

@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "avoid",
"printWidth": 80
}

View File

@@ -0,0 +1,986 @@
# jazz-example-chat
## 0.0.92
### Patch Changes
- Updated dependencies [cce679b]
- Updated dependencies [221c58f]
- jazz-tools@0.8.15
- jazz-react-auth-clerk@0.8.15
- jazz-react@0.8.15
## 0.0.91
### Patch Changes
- Updated dependencies [36273b3]
- jazz-tools@0.8.14
- jazz-react@0.8.14
- jazz-react-auth-clerk@0.8.14
## 0.0.90
### Patch Changes
- Updated dependencies [fd011d7]
- jazz-tools@0.8.13
- jazz-react@0.8.13
- jazz-react-auth-clerk@0.8.13
## 0.0.89
### Patch Changes
- Updated dependencies [6ed75eb]
- Updated dependencies [3cc6aee]
- cojson@0.8.12
- jazz-react@0.8.12
- jazz-react-auth-clerk@0.8.12
- jazz-tools@0.8.12
## 0.0.88
### Patch Changes
- Updated dependencies [1ed4ab5]
- cojson@0.8.11
- jazz-react@0.8.11
- jazz-react-auth-clerk@0.8.11
- jazz-tools@0.8.11
## 0.0.87
### Patch Changes
- jazz-react@0.8.7
- jazz-react-auth-clerk@0.8.7
## 0.0.86
### Patch Changes
- jazz-react@0.8.6
- jazz-react-auth-clerk@0.8.6
## 0.0.85
### Patch Changes
- Updated dependencies [c3f4e6b]
- Updated dependencies [d9152ed]
- jazz-tools@0.8.5
- cojson@0.8.5
- jazz-react@0.8.5
- jazz-react-auth-clerk@0.8.5
## 0.0.84
### Patch Changes
- Updated dependencies
- hash-slash@0.2.1
## 0.0.83
### Patch Changes
- Updated dependencies
- cojson@0.8.3
- jazz-react@0.8.3
- jazz-react-auth-clerk@0.8.3
- jazz-tools@0.8.3
## 0.0.82
### Patch Changes
- Updated dependencies [a075f90]
- jazz-tools@0.8.2
- jazz-react@0.8.2
- jazz-react-auth-clerk@0.8.2
## 0.0.81
### Patch Changes
- Updated dependencies
- jazz-tools@0.8.1
- jazz-react@0.8.1
- jazz-react-auth-clerk@0.8.1
## 0.0.82
### Patch Changes
- Updated dependencies [6a147c2]
- Updated dependencies [ad40b88]
- Updated dependencies [23369dc]
- Updated dependencies [c2b62a0]
- Updated dependencies [1a979b6]
- Updated dependencies [bcec3be]
- Updated dependencies [6ce2051]
- cojson@0.8.0
- jazz-tools@0.8.0
- jazz-react@0.8.0
## 0.0.82-guest-auth.6
### Patch Changes
- Updated dependencies
- jazz-react@0.7.35-guest-auth.6
- jazz-tools@0.7.35-guest-auth.6
## 0.0.82
### Patch Changes
- Updated dependencies [49a8b54]
- Updated dependencies [35bbcd9]
- Updated dependencies [6f80282]
- Updated dependencies [35bbcd9]
- Updated dependencies [cac2ec9]
- Updated dependencies [f350e90]
- jazz-tools@0.7.35
- cojson@0.7.35
- jazz-react@0.7.35
## 0.0.81
### Patch Changes
- Updated dependencies [5d91f9f]
- Updated dependencies [5094e6d]
- Updated dependencies [b09589b]
- Updated dependencies [2c3a40c]
- Updated dependencies [4e16575]
- Updated dependencies [ea882ab]
- cojson@0.7.34
- jazz-react@0.7.34
- jazz-tools@0.7.34
## 0.0.81-neverthrow.6
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.8
- jazz-react@0.7.34-neverthrow.8
- jazz-tools@0.7.34-neverthrow.8
## 0.0.81-neverthrow.5
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.7
- jazz-react@0.7.34-neverthrow.7
- jazz-tools@0.7.34-neverthrow.7
## 0.0.81-neverthrow.4
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.4
- jazz-react@0.7.34-neverthrow.4
- jazz-tools@0.7.34-neverthrow.4
## 0.0.81-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- jazz-react@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.0.81-neverthrow.2
### Patch Changes
- jazz-react@0.7.34-neverthrow.2
## 0.0.81-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- jazz-react@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.0.81-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- jazz-react@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.0.80
### Patch Changes
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
- jazz-react@0.7.33
- jazz-tools@0.7.33
## 0.0.80-hotfixes.5
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.5
- jazz-react@0.7.33-hotfixes.5
- jazz-tools@0.7.33-hotfixes.5
## 0.0.80-hotfixes.4
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.4
- jazz-react@0.7.33-hotfixes.4
- jazz-tools@0.7.33-hotfixes.4
## 0.0.80-hotfixes.3
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.3
- jazz-react@0.7.33-hotfixes.3
- jazz-tools@0.7.33-hotfixes.3
## 0.0.80-hotfixes.2
### Patch Changes
- jazz-react@0.7.33-hotfixes.2
## 0.0.80-hotfixes.1
### Patch Changes
- jazz-react@0.7.33-hotfixes.1
## 0.0.80-hotfixes.0
### Patch Changes
- Updated dependencies
- cojson@0.7.33-hotfixes.0
- jazz-react@0.7.33-hotfixes.0
- jazz-tools@0.7.33-hotfixes.0
## 0.0.79
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.32
- jazz-react@0.7.32
## 0.0.78
### Patch Changes
- Updated dependencies
- cojson@0.7.31
- jazz-react@0.7.31
- jazz-tools@0.7.31
## 0.0.77
### Patch Changes
- jazz-react@0.7.30
## 0.0.76
### Patch Changes
- Updated dependencies
- cojson@0.7.29
- jazz-react@0.7.29
- jazz-tools@0.7.29
## 0.0.75
### Patch Changes
- Updated dependencies
- cojson@0.7.28
- jazz-react@0.7.28
- jazz-tools@0.7.28
## 0.0.74
### Patch Changes
- jazz-react@0.7.27
## 0.0.73
### Patch Changes
- Updated dependencies
- cojson@0.7.26
- jazz-react@0.7.26
- jazz-tools@0.7.26
## 0.0.72
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.25
- jazz-react@0.7.25
## 0.0.71
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.24
- jazz-react@0.7.24
## 0.0.70
### Patch Changes
- Updated dependencies
- cojson@0.7.23
- jazz-react@0.7.23
- jazz-tools@0.7.23
## 0.0.69
### Patch Changes
- jazz-react@0.7.22
## 0.0.68
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.21
- jazz-react@0.7.21
## 0.0.67
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.20
- jazz-react@0.7.20
## 0.0.66
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.19
- jazz-react@0.7.19
## 0.0.65
### Patch Changes
- Updated dependencies
- cojson@0.7.18
- jazz-react@0.7.18
- jazz-tools@0.7.18
## 0.0.64
### Patch Changes
- Updated dependencies
- cojson@0.7.17
- jazz-react@0.7.17
- jazz-tools@0.7.17
## 0.0.63
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.16
- jazz-react@0.7.16
## 0.0.62
### Patch Changes
- Updated dependencies
- jazz-react@0.7.15
## 0.0.61
### Patch Changes
- Updated dependencies
- cojson@0.7.14
- jazz-tools@0.7.14
- jazz-react@0.7.14
## 0.0.60
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-react@0.7.13
## 0.0.59
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-react@0.7.12
## 0.0.58
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- jazz-react@0.7.11
- jazz-tools@0.7.11
## 0.0.57
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- jazz-react@0.7.10
- jazz-tools@0.7.10
## 0.0.56
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- jazz-react@0.7.9
- jazz-tools@0.7.9
## 0.0.55
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-react@0.7.8
## 0.0.54
### Patch Changes
- Updated dependencies [9fdc91c]
- jazz-react@0.7.7
## 0.0.53
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.6
- jazz-react@0.7.6
## 0.0.52
### Patch Changes
- Updated dependencies
- jazz-react@0.7.5
## 0.0.51
### Patch Changes
- Updated dependencies
- jazz-react@0.7.4
## 0.0.50
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.3
- jazz-react@0.7.3
## 0.0.49
### Patch Changes
- Updated dependencies
- jazz-react@0.7.2
## 0.0.48
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.1
- jazz-react@0.7.1
## 0.0.47
### Patch Changes
- Updated dependencies [8636319]
- Updated dependencies [1a35307]
- Updated dependencies [8636319]
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [59c18c3]
- Updated dependencies [19f52b7]
- Updated dependencies [8636319]
- Updated dependencies [1a35307]
- Updated dependencies [d8fe2b1]
- Updated dependencies [19004b4]
- Updated dependencies [a78f168]
- Updated dependencies [1200aae]
- Updated dependencies [60d5ca2]
- Updated dependencies [52675c9]
- Updated dependencies [129e2c1]
- Updated dependencies [6d49e9b]
- Updated dependencies [1cfa279]
- Updated dependencies [704af7d]
- Updated dependencies [e97f730]
- Updated dependencies [1a35307]
- Updated dependencies [460478f]
- Updated dependencies [6b0418f]
- Updated dependencies [e299c3e]
- Updated dependencies [ed5643a]
- Updated dependencies [bde684f]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [63374cc]
- Updated dependencies [8636319]
- Updated dependencies [01ac646]
- Updated dependencies [a5e68a4]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [1a35307]
- Updated dependencies [5fa277c]
- Updated dependencies [60d5ca2]
- Updated dependencies [21771c4]
- Updated dependencies [77c2b56]
- Updated dependencies [63374cc]
- Updated dependencies [d2e03ff]
- Updated dependencies [354bdcd]
- Updated dependencies [ece35b3]
- Updated dependencies [60d5ca2]
- Updated dependencies [69ac514]
- Updated dependencies [f8a5c46]
- Updated dependencies [f0f6f1b]
- Updated dependencies [e5eed5b]
- Updated dependencies [1a44f87]
- Updated dependencies [627d895]
- Updated dependencies [1200aae]
- Updated dependencies [63374cc]
- Updated dependencies [ece35b3]
- Updated dependencies [38d4410]
- Updated dependencies [85d2b62]
- Updated dependencies [fd86c11]
- Updated dependencies [52675c9]
- jazz-tools@0.7.0
- cojson@0.7.0
- jazz-react@0.7.0
- hash-slash@0.2.0
## 0.0.47-alpha.42
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.42
- cojson@0.7.0-alpha.42
- jazz-react@0.7.0-alpha.42
## 0.0.47-alpha.41
### Patch Changes
- jazz-tools@0.7.0-alpha.41
- jazz-react@0.7.0-alpha.41
## 0.0.47-alpha.40
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.40
## 0.0.47-alpha.39
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.39
- jazz-react@0.7.0-alpha.39
- jazz-tools@0.7.0-alpha.39
## 0.0.47-alpha.38
### Patch Changes
- Updated dependencies
- Updated dependencies
- Updated dependencies
- Updated dependencies
- Updated dependencies
- jazz-tools@0.7.0-alpha.38
- jazz-react@0.7.0-alpha.38
- cojson@0.7.0-alpha.38
## 0.0.47-alpha.37
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.37
- cojson@0.7.0-alpha.37
- jazz-tools@0.7.0-alpha.37
## 0.0.47-alpha.36
### Patch Changes
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- Updated dependencies [6b0418f]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
- jazz-tools@0.7.0-alpha.36
- jazz-react@0.7.0-alpha.36
## 0.0.47-alpha.35
### Patch Changes
- Updated dependencies
- Updated dependencies
- cojson@0.7.0-alpha.35
- jazz-tools@0.7.0-alpha.35
- jazz-react@0.7.0-alpha.35
## 0.0.47-alpha.34
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.34
- jazz-react@0.7.0-alpha.34
## 0.0.47-alpha.33
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.33
## 0.0.47-alpha.32
### Patch Changes
- Updated dependencies
- Updated dependencies
- Updated dependencies
- hash-slash@0.2.0-alpha.3
- jazz-tools@0.7.0-alpha.32
- jazz-react@0.7.0-alpha.32
## 0.0.47-alpha.31
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.31
- jazz-react@0.7.0-alpha.31
## 0.0.47-alpha.30
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.30
- jazz-react@0.7.0-alpha.30
## 0.0.47-alpha.29
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.29
- cojson@0.7.0-alpha.29
- jazz-react@0.7.0-alpha.29
## 0.0.47-alpha.28
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.28
- cojson@0.7.0-alpha.28
- jazz-react@0.7.0-alpha.28
## 0.0.47-alpha.27
### Patch Changes
- Updated dependencies
- Updated dependencies
- jazz-tools@0.7.0-alpha.27
- cojson@0.7.0-alpha.27
- jazz-react@0.7.0-alpha.27
## 0.0.47-alpha.26
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.26
- jazz-react@0.7.0-alpha.26
## 0.0.47-alpha.25
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.25
- jazz-react@0.7.0-alpha.25
## 0.0.47-alpha.24
### Patch Changes
- Updated dependencies
- Updated dependencies
- Updated dependencies
- jazz-tools@0.7.0-alpha.24
- cojson@0.7.0-alpha.24
- jazz-react@0.7.0-alpha.24
## 0.0.47-alpha.23
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.23
- jazz-react@0.7.0-alpha.23
## 0.0.47-alpha.22
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.22
- jazz-react@0.7.0-alpha.22
## 0.0.47-alpha.21
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.21
- jazz-tools@0.7.0-alpha.21
## 0.0.47-alpha.20
### Patch Changes
- Updated dependencies
- Updated dependencies
- jazz-react@0.7.0-alpha.20
- jazz-tools@0.7.0-alpha.20
## 0.0.47-alpha.19
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.19
- jazz-react@0.7.0-alpha.19
## 0.0.47-alpha.18
### Patch Changes
- jazz-react@0.7.0-alpha.18
## 0.0.47-alpha.17
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.17
- jazz-react@0.7.0-alpha.17
## 0.0.47-alpha.16
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.16
- jazz-react@0.7.0-alpha.16
## 0.0.47-alpha.15
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.15
- jazz-react@0.7.0-alpha.15
## 0.0.47-alpha.14
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.14
- jazz-react@0.7.0-alpha.14
## 0.0.47-alpha.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.13
- jazz-react@0.7.0-alpha.13
## 0.0.47-alpha.12
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.12
- jazz-tools@0.7.0-alpha.12
## 0.0.47-alpha.11
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.11
- jazz-tools@0.7.0-alpha.11
- cojson@0.7.0-alpha.11
## 0.0.47-alpha.10
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.10
- jazz-tools@0.7.0-alpha.10
- cojson@0.7.0-alpha.10
## 0.0.47-alpha.9
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.9
- jazz-tools@0.7.0-alpha.9
## 0.0.47-alpha.8
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.8
- jazz-tools@0.7.0-alpha.8
## 0.0.47-alpha.7
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.7
- jazz-tools@0.7.0-alpha.7
- cojson@0.7.0-alpha.7
## 0.0.47-alpha.6
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.6
- jazz-tools@0.7.0-alpha.6
## 0.0.47-alpha.5
### Patch Changes
- Updated dependencies
- jazz-react@0.7.0-alpha.5
- jazz-tools@0.7.0-alpha.5
- cojson@0.7.0-alpha.5
## 0.0.47-alpha.4
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.4
- jazz-react@0.7.0-alpha.4
## 0.0.47-alpha.3
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.0-alpha.3
- jazz-react@0.7.0-alpha.3
## 0.0.47-alpha.2
### Patch Changes
- Updated dependencies
- hash-slash@0.2.0-alpha.2
- jazz-react@0.7.0-alpha.2
- jazz-tools@0.7.0-alpha.2
## 0.0.47-alpha.1
### Patch Changes
- Updated dependencies
- hash-slash@0.2.0-alpha.1
- jazz-react@0.7.0-alpha.1
- jazz-tools@0.7.0-alpha.1
- cojson@0.7.0-alpha.1
## 0.0.47-alpha.0
### Patch Changes
- Updated dependencies
- hash-slash@0.2.0-alpha.0
- jazz-react@0.7.0-alpha.0
- jazz-tools@0.7.0-alpha.0
- cojson@0.7.0-alpha.0
## 0.0.46
### Patch Changes
- Updated dependencies
- jazz-react@0.5.0
- jazz-react-auth-local@0.4.16

View File

@@ -0,0 +1,4 @@
FROM caddy:2.7.3-alpine
LABEL org.opencontainers.image.source="https://github.com/gardencmp/jazz"
COPY ./dist /usr/share/caddy/

View File

@@ -0,0 +1,42 @@
# Jazz Chat Example (with Clerk auth)
Live version: [https://chat-clerk-demo.jazz.tools](https://chat-clerk-demo.jazz.tools)
## Installing & running the example locally
(this requires `pnpm` to be installed, see [https://pnpm.io/installation](https://pnpm.io/installation))
Start by checking out `jazz`
```bash
git clone https://github.com/gardencmp/jazz.git
cd jazz/examples/chat-clerk
pnpm pack --pack-destination /tmp
mkdir -p ~/jazz-examples/chat-clerk # or any other directory
tar -xf /tmp/jazz-example-chat-* --strip-components 1 -C ~/jazz-examples/chat-clerk
cd ~/jazz-examples/chat-clerk
```
This ensures that you have the example app without git history and independent of the Jazz multi-package monorepo.
Install dependencies:
```bash
pnpm install
```
Start the dev server:
```bash
pnpm dev
```
## 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.
## Configuration: sync server
By default, the example app uses [Jazz Cloud](https://jazz.tools/cloud) (`wss://cloud.jazz.tools`) - so cross-device use, invites and collaboration should just work.
You can also run a local sync server by running `npx jazz-run sync` and adding the query param `?sync=ws://localhost:4200` to the URL of the example app (for example: `http://localhost:5173/?peer=ws://localhost:4200`), or by setting the `sync` parameter of the `<Jazz.Provider>` provider component in [./src/2_main.tsx](./src/2_main.tsx).

View File

@@ -2,11 +2,13 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/jazz-logo.png" />
<link rel="stylesheet" href="/src/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Jazz onboarding example</title> <title>Jazz Chat Example</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/app.tsx"></script>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,56 @@
job "chat$BRANCH_SUFFIX" {
region = "global"
datacenters = ["*"]
group "static" {
count = 4
network {
port "http" {
to = 80
}
}
constraint {
attribute = "${node.class}"
operator = "="
value = "cloud"
}
spread {
attribute = "${node.datacenter}"
weight = 100
}
constraint {
distinct_hosts = true
}
task "server" {
driver = "docker"
config {
image = "$DOCKER_TAG"
ports = ["http"]
auth = {
username = "$DOCKER_USER"
password = "$DOCKER_PASSWORD"
}
}
service {
tags = ["public"]
name = "chat$BRANCH_SUFFIX"
port = "http"
provider = "consul"
}
resources {
cpu = 50 # MHz
memory = 50 # MB
}
}
}
}
# deploy bump 4

View File

@@ -0,0 +1,56 @@
{
"name": "jazz-example-chat-clerk",
"private": true,
"version": "0.0.92",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "echo 'chat example is codegolfed'",
"preview": "vite preview"
},
"lint-staged": {
"*.{ts,tsx}": "eslint --fix",
"*.{js,jsx,mdx,json}": "prettier --write"
},
"dependencies": {
"@clerk/clerk-react": "^5.4.1",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cojson": "workspace:0.8.12",
"hash-slash": "workspace:0.2.1",
"jazz-react": "workspace:0.8.15",
"jazz-react-auth-clerk": "workspace:0.8.15",
"jazz-tools": "workspace:0.8.15",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.16.0",
"react-router-dom": "^6.16.0",
"react-use": "^17.4.0",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7",
"uniqolor": "^1.1.0"
},
"devDependencies": {
"@types/qrcode": "^1.5.1",
"@types/react": "^18.2.19",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.14",
"eslint": "^8.46.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.27",
"tailwindcss": "3.3.2",
"typescript": "^5.3.3",
"vite": "^5.0.10"
}
}

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

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