Compare commits

...

9 Commits

Author SHA1 Message Date
Anselm
eec8ee7027 Publish
- jazz-example-pets@0.0.20
 - jazz-example-todo@0.0.44
 - jazz-example-twit@0.0.7
 - cojson@0.4.7
 - cojson-simple-sync@0.4.7
 - cojson-storage-indexeddb@0.4.7
 - cojson-storage-sqlite@0.4.7
 - jazz-autosub@0.4.7
 - jazz-browser@0.4.7
 - jazz-browser-auth-local@0.4.7
 - jazz-browser-media-images@0.4.8
 - jazz-react@0.4.7
 - jazz-react-auth-local@0.4.7
2023-10-04 21:23:52 +01:00
Anselm
188eb2e1e3 Update docs 2023-10-04 21:23:28 +01:00
Anselm
62867b32d9 Get rid of more cyclic imports 2023-10-04 21:22:52 +01:00
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
25 changed files with 194 additions and 152 deletions

110
DOCS.md
View File

@@ -2902,9 +2902,9 @@ class Group<P, R, Meta> {
asObject(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -2923,9 +2923,9 @@ class Group<P, R, Meta> {
toJSON(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -3027,9 +3027,9 @@ class Group<P, R, Meta> {
set(
kv: {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
},
privacy?: "private" | "trusting"
): Group<P, R, Meta> {...}
@@ -3043,9 +3043,9 @@ TODO: document
| name | description |
| ----: | ---- |
| `kv.everyone` | TODO: document |
| `kv.readKey` | TODO: document |
| `kv.profile` | TODO: document |
| `kv.root` | TODO: document |
| `kv.readKey` | TODO: document |
| `privacy?` | TODO: document |
</details>
@@ -3374,7 +3374,7 @@ class Group<P, R, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3404,7 +3404,7 @@ class Group<P, R, Meta> {
lastEditAt<K extends Object>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3433,7 +3433,7 @@ class Group<P, R, Meta> {
editsAt<K extends Object>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3880,7 +3880,7 @@ class CoMap<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -3910,7 +3910,7 @@ class CoMap<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -3939,7 +3939,7 @@ class CoMap<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4324,7 +4324,7 @@ class MutableCoMap<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4354,7 +4354,7 @@ class MutableCoMap<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4383,7 +4383,7 @@ class MutableCoMap<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4782,7 +4782,7 @@ class CoList<Item, Meta> {
editAt(
idx: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -4809,7 +4809,7 @@ TODO: document
class CoList<Item, Meta> {
deletionEdits(): {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
}[] {...}
@@ -5211,7 +5211,7 @@ class MutableCoList<Item, Meta> {
editAt(
idx: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5238,7 +5238,7 @@ TODO: document
class MutableCoList<Item, Meta> {
deletionEdits(): {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
}[] {...}
@@ -5608,7 +5608,7 @@ class CoStream<Item, Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5638,7 +5638,7 @@ class CoStream<Item, Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5667,7 +5667,7 @@ class CoStream<Item, Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5694,9 +5694,9 @@ TODO: document
class CoStream<Item, Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5723,9 +5723,9 @@ TODO: document
class CoStream<Item, Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6074,7 +6074,7 @@ class MutableCoStream<Item, Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6104,7 +6104,7 @@ class MutableCoStream<Item, Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6133,7 +6133,7 @@ class MutableCoStream<Item, Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6160,9 +6160,9 @@ TODO: document
class MutableCoStream<Item, Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6189,9 +6189,9 @@ TODO: document
class MutableCoStream<Item, Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6669,7 +6669,7 @@ class BinaryCoStream<Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6699,7 +6699,7 @@ class BinaryCoStream<Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6728,7 +6728,7 @@ class BinaryCoStream<Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6755,9 +6755,9 @@ TODO: document
class BinaryCoStream<Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6784,9 +6784,9 @@ TODO: document
class BinaryCoStream<Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7214,7 +7214,7 @@ class MutableBinaryCoStream<Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7244,7 +7244,7 @@ class MutableBinaryCoStream<Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7273,7 +7273,7 @@ class MutableBinaryCoStream<Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7300,9 +7300,9 @@ TODO: document
class MutableBinaryCoStream<Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7329,9 +7329,9 @@ TODO: document
class MutableBinaryCoStream<Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7578,9 +7578,9 @@ class Account<P, R, Meta> {
asObject(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -7599,9 +7599,9 @@ class Account<P, R, Meta> {
toJSON(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -7703,9 +7703,9 @@ class Account<P, R, Meta> {
set(
kv: {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
},
privacy?: "private" | "trusting"
): Account<P, R, Meta> {...}
@@ -7719,9 +7719,9 @@ TODO: document
| name | description |
| ----: | ---- |
| `kv.everyone` | TODO: document |
| `kv.readKey` | TODO: document |
| `kv.profile` | TODO: document |
| `kv.root` | TODO: document |
| `kv.readKey` | TODO: document |
| `privacy?` | TODO: document |
</details>
@@ -8050,7 +8050,7 @@ class Account<P, R, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8080,7 +8080,7 @@ class Account<P, R, Meta> {
lastEditAt<K extends Object>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8109,7 +8109,7 @@ class Account<P, R, Meta> {
editsAt<K extends Object>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8571,7 +8571,7 @@ class Profile<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -8601,7 +8601,7 @@ class Profile<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -8630,7 +8630,7 @@ class Profile<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.17",
"version": "0.0.20",
"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.8",
"jazz-react": "^0.4.7",
"jazz-react-auth-local": "^0.4.7",
"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.44",
"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.7",
"jazz-react-auth-local": "^0.4.7",
"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.7",
"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.8",
"jazz-react": "^0.4.7",
"jazz-react-auth-local": "^0.4.7",
"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.7",
"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.7",
"cojson-storage-sqlite": "^0.4.7",
"ws": "^8.13.0"
},
"scripts": {

View File

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

View File

@@ -1,13 +1,13 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.4.5",
"version": "0.4.7",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^8.5.2",
"cojson": "^0.4.5",
"cojson": "^0.4.7",
"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.7",
"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

@@ -1,7 +1,5 @@
import { randomBytes } from "@noble/hashes/utils";
import { AnyCoValue, CoValue } from "./coValue.js";
import { BinaryCoStream, CoStream } from "./coValues/coStream.js";
import { CoMap } from "./coValues/coMap.js";
import {
Encrypted,
Hash,
@@ -30,14 +28,13 @@ import { Group, expectGroup } from "./coValues/group.js";
import { LocalNode } from "./localNode.js";
import { CoValueKnownState, NewContentMessage } from "./sync.js";
import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
import { CoList } from "./coValues/coList.js";
import {
Account,
AccountID,
GeneralizedControlledAccount,
isAccountID,
} from "./coValues/account.js";
import { Stringified, stableStringify } from "./jsonStringify.js";
import { coreToCoValue } from "./coreToCoValue.js";
import { isAccountID } from "./typeCheckers.js";
export const MAX_RECOMMENDED_TX_SIZE = 100 * 1024;
@@ -517,31 +514,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

@@ -153,10 +153,6 @@ export class AnonymousControlledAccount
export type AccountMeta = { type: "account" };
export type AccountID = CoID<Account>;
export function isAccountID(id: AccountID | AgentID): id is AccountID {
return id.startsWith("co_");
}
export type ProfileShape = {
name: string;
};

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 "../typeCheckers.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 "../typeCheckers.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";

View File

@@ -1,10 +1,11 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { CoValue, CoID, isCoValue } from "../coValue.js";
import { CoValue, CoID } from "../coValue.js";
import { isAccountID, isCoValue } from "../typeCheckers.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { Group } from "./group.js";
import { AgentID, SessionID, TransactionID } from "../ids.js";
import { base64URLtoBytes, bytesToBase64url } from "../base64url.js";
import { AccountID, isAccountID } from "./account.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";
export type BinaryStreamInfo = {

View File

@@ -0,0 +1,37 @@
import type { 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

@@ -36,7 +36,8 @@ import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
import type { Everyone } from "./coValues/group.js";
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
import { parseJSON } from "./jsonStringify.js";
import { Account, Profile, isAccountID } from "./coValues/account.js";
import { Account, Profile } from "./coValues/account.js";
import { isAccountID } from "./typeCheckers.js";
import type { SessionID, AgentID } from "./ids.js";
import type { CoID, AnyCoValue } from "./coValue.js";

View File

@@ -0,0 +1,15 @@
import type { CoValue } from "./coValue.js";
import type { AccountID, AgentID, JsonValue } from "./index.js";
export function isCoValue(
value: JsonValue | CoValue | undefined
): value is CoValue {
return (
typeof value === "object" && !!value && "id" in value && "headerMeta" in value && "core" in value
);
}
export function isAccountID(id: AccountID | AgentID): id is AccountID {
return id.startsWith("co_");
}

View File

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

View File

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

View File

@@ -1,22 +1,20 @@
{
"name": "jazz-browser-media-images",
"version": "0.4.5",
"version": "0.4.8",
"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.7",
"image-blob-reduce": "^4.1.0",
"jazz-autosub": "^0.4.5",
"jazz-browser": "^0.4.5",
"jazz-autosub": "^0.4.7",
"jazz-browser": "^0.4.7",
"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.7",
"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.7",
"cojson-storage-indexeddb": "^0.4.7",
"jazz-autosub": "^0.4.7",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react-auth-local",
"version": "0.4.5",
"version": "0.4.7",
"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.7",
"jazz-react": "^0.4.7",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

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