Compare commits

..

6 Commits

Author SHA1 Message Date
Anselm
ccebd2447d Publish
- jazz-example-pets@0.0.19
 - jazz-example-todo@0.0.43
 - jazz-example-twit@0.0.6
 - cojson@0.4.6
 - cojson-simple-sync@0.4.6
 - cojson-storage-indexeddb@0.4.6
 - cojson-storage-sqlite@0.4.6
 - jazz-autosub@0.4.6
 - jazz-browser@0.4.6
 - jazz-browser-auth-local@0.4.6
 - jazz-browser-media-images@0.4.7
 - jazz-react@0.4.6
 - jazz-react-auth-local@0.4.6
2023-10-04 21:01:44 +01:00
Anselm
08dca75789 Address some circular deps in cojson typescript 2023-10-04 21:00:59 +01:00
Anselm
f1cd639a09 Add project list to todo example 2023-10-03 13:59:00 +01:00
Anselm Eickhoff
be18e4de14 Merge pull request #111 from gardencmp/autosub-api
Autosub API
2023-10-01 13:18:40 +01:00
Anselm
7e62c91d44 Publish
- jazz-example-pets@0.0.18
 - jazz-example-twit@0.0.5
 - jazz-browser-media-images@0.4.6
2023-10-01 12:27:10 +01:00
Anselm
b2d5a103b5 move image-blob-reduce types to proper deps 2023-10-01 12:26:53 +01:00
22 changed files with 136 additions and 86 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.17",
"version": "0.0.19",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,9 +16,9 @@
"@types/qrcode": "^1.5.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-browser-media-images": "^0.4.5",
"jazz-react": "^0.4.5",
"jazz-react-auth-local": "^0.4.5",
"jazz-browser-media-images": "^0.4.7",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.42",
"version": "0.0.43",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,8 +16,8 @@
"@types/qrcode": "^1.5.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "^0.4.5",
"jazz-react-auth-local": "^0.4.5",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,6 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider, createHashRouter } from "react-router-dom";
import {
RouterProvider,
createHashRouter,
useNavigate,
} from "react-router-dom";
import "./index.css";
import { WithJazz, useJazz, useAcceptInvite } from "jazz-react";
@@ -14,8 +18,8 @@ import {
import { PrettyAuthUI } from "./components/Auth.tsx";
import { NewProjectForm } from "./3_NewProjectForm.tsx";
import { ProjectTodoTable } from "./4_ProjectTodoTable.tsx";
import { migration } from "./1_types.ts";
import { AccountMigration } from "cojson";
import { TodoAccountRoot, migration } from "./1_types.ts";
import { AccountMigration, Profile } from "cojson";
/**
* Walkthrough: The top-level provider `<WithJazz/>`
@@ -61,7 +65,7 @@ function App() {
const router = createHashRouter([
{
path: "/",
element: <NewProjectForm />,
element: <HomeScreen />,
},
{
path: "/project/:projectId",
@@ -91,4 +95,27 @@ function App() {
);
}
export function HomeScreen() {
const { me } = useJazz<Profile, TodoAccountRoot>();
const navigate = useNavigate();
return (
<>
{me.root?.projects?.length ? <h1>My Projects</h1> : null}
{me.root?.projects?.map((project) => {
return (
<Button
key={project?.id}
onClick={() => navigate("/project/" + project?.id)}
variant="ghost"
>
{project?.title}
</Button>
);
})}
<NewProjectForm />
</>
);
}
/** Walkthrough: Continue with ./3_NewProjectForm.tsx */

View File

@@ -2,16 +2,17 @@ import { useCallback } from "react";
import { useJazz } from "jazz-react";
import { ListOfTasks, TodoProject } from "./1_types";
import { ListOfTasks, TodoAccountRoot, TodoProject } from "./1_types";
import { SubmittableInput } from "./basicComponents";
import { useNavigate } from "react-router";
import { Profile } from "cojson";
export function NewProjectForm() {
// `me` represents the current user account, which will determine
// access rights to CoValues. We get it from the top-level provider `<WithJazz/>`.
const { me } = useJazz();
const { me } = useJazz<Profile, TodoAccountRoot>();
const navigate = useNavigate();
const createProject = useCallback(
@@ -29,6 +30,8 @@ export function NewProjectForm() {
tasks: projectGroup.createList<ListOfTasks>().id,
});
me.root?.projects?.append(project.id);
navigate("/project/" + project.id);
},
[me, navigate]

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-twit",
"private": true,
"version": "0.0.4",
"version": "0.0.6",
"type": "module",
"scripts": {
"dev": "vite",
@@ -18,9 +18,9 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"javascript-time-ago": "^2.5.9",
"jazz-browser-media-images": "^0.4.5",
"jazz-react": "^0.4.5",
"jazz-react-auth-local": "^0.4.5",
"jazz-browser-media-images": "^0.4.7",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -4,7 +4,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.5",
"version": "0.4.6",
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/ws": "^8.5.5",
@@ -16,8 +16,8 @@
"typescript": "5.0.2"
},
"dependencies": {
"cojson": "^0.4.5",
"cojson-storage-sqlite": "^0.4.5",
"cojson": "^0.4.6",
"cojson-storage-sqlite": "^0.4.6",
"ws": "^8.13.0"
},
"scripts": {

View File

@@ -1,11 +1,11 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.5",
"cojson": "^0.4.6",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,13 +1,13 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^8.5.2",
"cojson": "^0.4.5",
"cojson": "^0.4.6",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.5",
"version": "0.4.6",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",

View File

@@ -65,15 +65,4 @@ export function expectStream(content: CoValue): CoStream {
}
return content as CoStream;
}
export function isCoValue(
value: JsonValue | CoValue | undefined
): value is CoValue {
return (
value instanceof CoMap ||
value instanceof CoList ||
value instanceof CoStream ||
value instanceof BinaryCoStream
);
}
}

View File

@@ -38,6 +38,7 @@ import {
isAccountID,
} from "./coValues/account.js";
import { Stringified, stableStringify } from "./jsonStringify.js";
import { coreToCoValue } from "./coreToCoValue.js";
export const MAX_RECOMMENDED_TX_SIZE = 100 * 1024;
@@ -517,31 +518,7 @@ export class CoValueCore {
return this._cachedContent;
}
let newContent;
if (this.header.type === "comap") {
if (this.header.ruleset.type === "group") {
if (
this.header.meta?.type === "account" &&
!options?.ignorePrivateTransactions
) {
newContent = new Account(this);
} else {
newContent = new Group(this, options);
}
} else {
newContent = new CoMap(this);
}
} else if (this.header.type === "colist") {
newContent = new CoList(this);
} else if (this.header.type === "costream") {
if (this.header.meta && this.header.meta.type === "binary") {
newContent = new BinaryCoStream(this);
} else {
newContent = new CoStream(this);
}
} else {
throw new Error(`Unknown coValue type ${this.header.type}`);
}
const newContent = coreToCoValue(this, options);
if (!options?.ignorePrivateTransactions) {
this._cachedContent = newContent;

View File

@@ -1,5 +1,6 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { CoID, CoValue, isCoValue } from "../coValue.js";
import { CoID, CoValue } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { AgentID, SessionID, TransactionID } from "../ids.js";
import { AccountID } from "./account.js";

View File

@@ -1,6 +1,7 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { AgentID, TransactionID } from "../ids.js";
import { CoID, CoValue, isCoValue } from "../coValue.js";
import { CoID, CoValue } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";

View File

@@ -1,5 +1,6 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { CoValue, CoID, isCoValue } from "../coValue.js";
import { CoValue, CoID } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { Group } from "./group.js";
import { AgentID, SessionID, TransactionID } from "../ids.js";

View File

@@ -0,0 +1,37 @@
import { CoValueCore } from "./coValueCore.js";
import { Account } from "./coValues/account.js";
import { Group } from "./coValues/group.js";
import { CoMap } from "./coValues/coMap.js";
import { CoList } from "./coValues/coList.js";
import { CoStream } from "./coValues/coStream.js";
import { BinaryCoStream } from "./coValues/coStream.js";
export function coreToCoValue(
core: CoValueCore,
options?: { ignorePrivateTransactions: true }
) {
if (core.header.type === "comap") {
if (core.header.ruleset.type === "group") {
if (
core.header.meta?.type === "account" &&
!options?.ignorePrivateTransactions
) {
return new Account(core);
} else {
return new Group(core, options);
}
} else {
return new CoMap(core);
}
} else if (core.header.type === "colist") {
return new CoList(core);
} else if (core.header.type === "costream") {
if (core.header.meta && core.header.meta.type === "binary") {
return new BinaryCoStream(core);
} else {
return new CoStream(core);
}
} else {
throw new Error(`Unknown coValue type ${core.header.type}`);
}
}

View File

@@ -0,0 +1,16 @@
import { JsonValue } from "./jsonValue.js";
import { CoMap } from "./coValues/coMap.js";
import { BinaryCoStream, CoStream } from "./coValues/coStream.js";
import { CoList } from "./coValues/coList.js";
import { CoValue } from "./coValue.js";
export function isCoValue(
value: JsonValue | CoValue | undefined
): value is CoValue {
return (
value instanceof CoMap ||
value instanceof CoList ||
value instanceof CoStream ||
value instanceof BinaryCoStream
);
}

View File

@@ -5,9 +5,9 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.5",
"version": "0.4.6",
"dependencies": {
"cojson": "^0.4.5"
"cojson": "^0.4.6"
},
"scripts": {
"test": "jest",

View File

@@ -1,11 +1,11 @@
{
"name": "jazz-browser-auth-local",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"jazz-browser": "^0.4.5",
"jazz-browser": "^0.4.6",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,22 +1,20 @@
{
"name": "jazz-browser-media-images",
"version": "0.4.5",
"version": "0.4.7",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.5",
"@types/image-blob-reduce": "^4.1.1",
"cojson": "^0.4.6",
"image-blob-reduce": "^4.1.0",
"jazz-autosub": "^0.4.5",
"jazz-browser": "^0.4.5",
"jazz-autosub": "^0.4.6",
"jazz-browser": "^0.4.6",
"typescript": "^5.1.6"
},
"scripts": {
"lint": "eslint src/**/*.ts",
"build": "npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@types/image-blob-reduce": "^4.1.1"
}
}

View File

@@ -1,13 +1,13 @@
{
"name": "jazz-browser",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.5",
"cojson-storage-indexeddb": "^0.4.5",
"jazz-autosub": "^0.4.5",
"cojson": "^0.4.6",
"cojson-storage-indexeddb": "^0.4.6",
"jazz-autosub": "^0.4.6",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react-auth-local",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.tsx",
"license": "MIT",
"dependencies": {
"jazz-browser-auth-local": "^0.4.5",
"jazz-react": "^0.4.5",
"jazz-browser-auth-local": "^0.4.6",
"jazz-react": "^0.4.6",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.5",
"jazz-browser": "^0.4.5",
"cojson": "^0.4.6",
"jazz-browser": "^0.4.6",
"typescript": "^5.1.6"
},
"devDependencies": {