Compare commits

...

10 Commits

Author SHA1 Message Date
Anselm
9c5a6b9833 Publish
- jazz-example-pets@0.0.12
 - jazz-example-todo@0.0.37
 - cojson@0.3.3
 - cojson-simple-sync@0.3.3
 - cojson-storage-indexeddb@0.3.3
 - cojson-storage-sqlite@0.3.3
 - jazz-browser@0.3.3
 - jazz-browser-auth-local@0.3.3
 - jazz-browser-media-images@0.3.3
 - jazz-react@0.3.3
 - jazz-react-auth-local@0.3.3
 - jazz-react-media-images@0.3.3
2023-09-22 10:09:04 +01:00
Anselm
d300d265c4 manually update cojson 2023-09-22 10:07:55 +01:00
Anselm
1d72ce587f Update version 2023-09-22 09:53:25 +01:00
Anselm
3fdb41dcb9 More resilience against invalid JSON 2023-09-22 09:51:07 +01:00
Anselm
f20de2f04a v0.3.1 2023-09-22 09:36:32 +01:00
Anselm
31b31f111b Shorter logs on failed transactions 2023-09-22 09:34:54 +01:00
Anselm Eickhoff
2ae9fb9778 Fix example comment 2023-09-21 18:00:28 +01:00
Anselm Eickhoff
cd0da0f6bf Merge pull request #94 from gardencmp/ergonomic-covalues
Implement queries
2023-09-21 17:31:31 +01:00
Anselm
cd9bfbb9fa Publish
- jazz-example-pets@0.0.11
 - jazz-example-todo@0.0.36
 - cojson@0.3.0
 - cojson-simple-sync@0.3.0
 - cojson-storage-indexeddb@0.3.0
 - cojson-storage-sqlite@0.3.0
 - jazz-browser@0.3.0
 - jazz-browser-auth-local@0.3.0
 - jazz-browser-media-images@0.3.0
 - jazz-react@0.3.0
 - jazz-react-auth-local@0.3.0
 - jazz-react-media-images@0.3.0
2023-09-21 17:29:23 +01:00
Anselm
ed0428bf97 Pre-release fixes 2023-09-21 17:12:10 +01:00
20 changed files with 72 additions and 53 deletions

View File

@@ -7394,12 +7394,12 @@ TODO: document
----
## `createImage(image, inGroup)`
## `createImage(imageBlobOrFile, inGroup)`
<sup>(function in `jazz-react-media-images`)</sup>
```typescript
export function createImage(image: Blob | File, inGroup: Group): Promise<Media.ImageDefinition>
export function createImage(imageBlobOrFile: Blob | File, inGroup: Group): Promise<Media.ImageDefinition>
```
TODO: document
@@ -7407,7 +7407,7 @@ TODO: document
| name | description |
| ----: | ---- |
| `image` | TODO: document |
| `imageBlobOrFile` | TODO: document |
| `inGroup` | TODO: document |

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.10",
"version": "0.0.12",
"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-react": "^0.3.0-alpha.0",
"jazz-react-auth-local": "^0.3.0-alpha.0",
"jazz-react-media-images": "^0.3.0-alpha.0",
"jazz-react": "^0.3.3",
"jazz-react-auth-local": "^0.3.3",
"jazz-react-media-images": "^0.3.3",
"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.35",
"version": "0.0.37",
"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.3.0-alpha.0",
"jazz-react-auth-local": "^0.3.0-alpha.0",
"jazz-react": "^0.3.3",
"jazz-react-auth-local": "^0.3.3",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -24,7 +24,7 @@ import { useParams } from "react-router";
/** Walkthrough: Reactively rendering a todo project as a table,
* adding and editing tasks
*
* Here in `<TodoTable/>`, we use `useSyncedData()` for the first time,
* Here in `<TodoTable/>`, we use `useSyncedQuery()` for the first time,
* in this case to load the CoValue for our `TodoProject` as well as
* the `ListOfTasks` referenced in it.
*/
@@ -32,7 +32,7 @@ import { useParams } from "react-router";
export function ProjectTodoTable() {
const projectId = useParams<{ projectId: CoID<TodoProject> }>().projectId;
// `useSyncedData()` reactively subscribes to updates to a CoValue's
// `useSyncedQuery()` reactively subscribes to updates to a CoValue's
// content - whether we create edits locally, load persisted data, or receive
// sync updates from other devices or participants!
// It also recursively resolves and subsribes to all referenced CoValues.

View File

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

View File

@@ -16,7 +16,7 @@ const localNode = new LocalNode(
);
SQLiteStorage.asPeer({ filename: "./sync.db" })
.then((storage) => localNode.sync.addPeer(storage))
.then((storage) => localNode.syncManager.addPeer(storage))
.catch((e) => console.error(e));
wss.on("connection", function connection(ws, req) {
@@ -34,8 +34,6 @@ wss.on("connection", function connection(ws, req) {
clearInterval(pinging);
});
const clientAddress =
(req.headers["x-forwarded-for"] as string | undefined)
?.split(",")[0]
@@ -43,7 +41,7 @@ wss.on("connection", function connection(ws, req) {
const clientId = clientAddress + "@" + new Date().toISOString();
localNode.sync.addPeer({
localNode.syncManager.addPeer({
id: clientId,
role: "client",
incoming: websocketReadableStream(ws),

View File

@@ -1,11 +1,11 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.3.0-alpha.0",
"cojson": "^0.3.3",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -12,7 +12,7 @@ test.skip("Should be able to initialize and load from empty DB", async () => {
)
);
node.sync.addPeer(await IDBStorage.asPeer({ trace: true }));
node.syncManager.addPeer(await IDBStorage.asPeer({ trace: true }));
console.log("yay!");
@@ -20,7 +20,7 @@ test.skip("Should be able to initialize and load from empty DB", async () => {
await new Promise((resolve) => setTimeout(resolve, 200));
expect(node.sync.peers["storage"]).toBeDefined();
expect(node.syncManager.peers["storage"]).toBeDefined();
});
test("Should be able to sync data to database and then load that from a new node", async () => {
@@ -33,7 +33,7 @@ test("Should be able to sync data to database and then load that from a new node
)
);
node1.sync.addPeer(
node1.syncManager.addPeer(
await IDBStorage.asPeer({ trace: true, localNodeName: "node1" })
);
@@ -56,7 +56,7 @@ test("Should be able to sync data to database and then load that from a new node
)
);
node2.sync.addPeer(
node2.syncManager.addPeer(
await IDBStorage.asPeer({ trace: true, localNodeName: "node2" })
);

View File

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

View File

@@ -5,7 +5,7 @@
"types": "dist/index.d.ts",
"type": "module",
"license": "MIT",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",

View File

@@ -73,7 +73,24 @@ export function determineValidTransactions(
// console.log("before", { memberState, validTransactions });
const transactor = accountOrAgentIDfromSessionID(sessionID);
const changes = parseJSON(tx.changes);
let changes;
try {
changes = parseJSON(tx.changes);
} catch (e) {
console.warn(
coValue.id,
"Invalid JSON in transaction",
e,
tx,
JSON.stringify(tx.changes, (k, v) =>
k === "changes" || k === "encryptedChanges"
? v.slice(0, 20) + "..."
: v
)
);
continue;
}
const change = changes[0] as
| MapOpPayload<AccountID | AgentID, Role>

View File

@@ -505,7 +505,11 @@ export class SyncManager {
console.error(
"Failed to add transactions",
msg.id,
newTransactions
JSON.stringify(newTransactions, (k, v) =>
k === "changes" || k === "encryptedChanges"
? v.slice(0, 20) + "..."
: v
)
);
continue;
}

View File

@@ -1,11 +1,11 @@
{
"name": "jazz-browser-auth-local",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"jazz-browser": "^0.3.0-alpha.0",
"jazz-browser": "^0.3.3",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -72,7 +72,7 @@ export class BrowserLocalAuth implements AuthProvider {
this.appHostname
);
for (const peer of initialPeers) {
node.sync.addPeer(peer);
node.syncManager.addPeer(peer);
}
doneSigningUpOrLoggingIn(node);
this.driver.onSignedIn({ logOut });

View File

@@ -1,13 +1,13 @@
{
"name": "jazz-browser-media-images",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.3.0-alpha.0",
"cojson": "^0.3.3",
"image-blob-reduce": "^4.1.0",
"jazz-browser": "^0.3.0-alpha.0",
"jazz-browser": "^0.3.3",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-browser",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.3.0-alpha.0",
"cojson-storage-indexeddb": "^0.3.0-alpha.0",
"cojson": "^0.3.3",
"cojson-storage-indexeddb": "^0.3.3",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -49,7 +49,7 @@ export async function createBrowserNode({
async function websocketReconnectLoop() {
while (shouldTryToReconnect) {
if (
Object.keys(node.sync.peers).some((peerId) =>
Object.keys(node.syncManager.peers).some((peerId) =>
peerId.includes(syncAddress)
)
) {
@@ -58,7 +58,7 @@ export async function createBrowserNode({
);
} else {
console.log("Websocket disconnected, trying to reconnect");
node.sync.addPeer(createWebSocketPeer(syncAddress));
node.syncManager.addPeer(createWebSocketPeer(syncAddress));
await new Promise((resolve) =>
setTimeout(resolve, reconnectionTimeout)
);
@@ -73,7 +73,7 @@ export async function createBrowserNode({
done: () => {
shouldTryToReconnect = false;
console.log("Cleaning up node");
for (const peer of Object.values(node.sync.peers)) {
for (const peer of Object.values(node.syncManager.peers)) {
peer.outgoing
.close()
.catch((e) => console.error("Error while closing peer", e));

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react-auth-local",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"jazz-browser-auth-local": "^0.3.0-alpha.0",
"jazz-react": "^0.3.0-alpha.0",
"jazz-browser-auth-local": "^0.3.3",
"jazz-react": "^0.3.3",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,14 +1,14 @@
{
"name": "jazz-react-media-images",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.3.0-alpha.0",
"jazz-browser": "^0.3.0-alpha.0",
"jazz-browser-media-images": "^0.3.0-alpha.0",
"jazz-react": "^0.3.0-alpha.0",
"cojson": "^0.3.3",
"jazz-browser": "^0.3.3",
"jazz-browser-media-images": "^0.3.3",
"jazz-react": "^0.3.3",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react",
"version": "0.3.0-alpha.0",
"version": "0.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.3.0-alpha.0",
"jazz-browser": "^0.3.0-alpha.0",
"cojson": "^0.3.3",
"jazz-browser": "^0.3.3",
"typescript": "^5.1.6"
},
"devDependencies": {