Skip to content

Commit

Permalink
fix!: bump peerbit
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Jan 12, 2024
1 parent 7b67d2d commit 33c5b6a
Show file tree
Hide file tree
Showing 53 changed files with 3,693 additions and 3,561 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ module.exports = {
],
"ignorePatterns": ["/**/*.test.ts", "/**/lib/", "/**/frontend/build", "/**/frontend/dist", "/**/test-utils/"],
"rules": {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-as-const": "off"
"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/no-empty-interface": "off",
"no-useless-escape": "off",
"no-return-await": "error",
"@typescript-eslint/no-unsafe-declaration-mergin": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off"
},
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
"@types/jest": "^29.2.3",
"@types/node": "^17.0.32",
"@types/prettier": "^2.4.2",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"eslint": "^8.27.0",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.5.0",
"jest-extended": "^4.0.0",
"lerna": "^7.3.0",
"prettier": "^2.7.1",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"lerna": "^8.0.1",
"shx": "^0.3.4",
"start-server-and-test": "^1.14.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.1.3",
"typescript": "^5.3.3",
"typescript-esm": "^2.0.0",
"json": "^11.0.0"
}
Expand Down
15 changes: 7 additions & 8 deletions packages/collaborative-learning/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"deploy": "yarn build && NODE_DEBUG=gh-pages gh-pages -d dist"
},
"dependencies": {
"peerbit": "^2",
"@peerbit/document": "^3",
"peerbit": "^3",
"@peerbit/document": "^4",
"@tensorflow/tfjs": "^4.2.0",
"@peerbit/react": "*",
"react": "^18.2.0",
Expand All @@ -27,12 +27,11 @@
"@mui/icons-material": "^5.10.16"
},
"devDependencies": {
"@types/dom-webcodecs": "^0.1.5",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.0.3",
"typescript": "^5.1.3",
"vite": "^4.4.7"
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4",
"typescript": "^5.3.3",
"vite": "^5.0.10"
},
"browserslist": {
"production": [
Expand Down
35 changes: 13 additions & 22 deletions packages/collaborative-learning/frontend/src/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { usePeer } from "@peerbit/react";
import { usePeer, useProgram } from "@peerbit/react";
import { useState, useEffect, useRef } from "react";
import { useParams } from "react-router-dom";
import * as tf from "@tensorflow/tfjs";
Expand Down Expand Up @@ -170,28 +170,17 @@ export const Content = () => {
const [usingCamera, setUsingCamera] = useState(false);
const p2pStorage = useRef<P2PStorage | tf.io.IOHandler>();
const [modelDate, setModelDate] = useState<Date>(null);
const [subscribers, setSubscribers] = useState(1);

// The p2p database of model weights
const modelDB = useProgram(new ModelDatabase({ id: MODEL_DATABASE_ID }), {
existing: "reuse",
});

useEffect(() => {
if (p2pStorage.current || !peer) {
if (!modelDB.program) {
return;
}
setProcessing(true);
peer.open(new ModelDatabase({ id: MODEL_DATABASE_ID }), {
existing: "reuse",
}).then(async (db) => {
db.events.addEventListener("join", (e) => {
db.getReady().then((set) => setSubscribers(set.size + 1));
});

db.events.addEventListener("leave", (e) => {
db.getReady().then((set) => setSubscribers(set.size + 1));
});

p2pStorage.current = new P2PStorage(db, MODEL_ID);

setProcessing(false);
});
p2pStorage.current = new P2PStorage(modelDB.program, MODEL_ID);
}, [peer?.identity.publicKey.hashcode()]);

const enableCam = () => {
Expand Down Expand Up @@ -320,8 +309,8 @@ export const Content = () => {
</Grid>
<Grid item sx={{ display: "flex", flexDirection: "row" }}>
<Typography>Online: &nbsp;</Typography>
<Typography>{subscribers}</Typography>
{subscribers === 1 && (
<Typography>{modelDB.peerCounter}</Typography>
{modelDB.peerCounter === 1 && (
<Typography>&nbsp;(just you)</Typography>
)}
</Grid>
Expand Down Expand Up @@ -442,7 +431,9 @@ export const Content = () => {
<Button
startIcon={<PublicIcon />}
color="secondary"
disabled={!p2pStorage.current || subscribers <= 1}
disabled={
!p2pStorage.current || modelDB.peerCounter <= 1
}
onClick={() => {
tf.loadLayersModel(p2pStorage.current)
.then((loaded) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/collaborative-learning/frontend/src/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Program } from "@peerbit/program";
import { DocumentIndex, Documents } from "@peerbit/document";
import { Documents } from "@peerbit/document";
import { field, variant } from "@dao-xyz/borsh";

export class Model {
Expand Down
6 changes: 6 additions & 0 deletions packages/collaborative-learning/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import fs from "fs";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
optimizeDeps: {
esbuildOptions: {
target: "esnext",
},
exclude: ["@peerbit/any-store"], // https://github.com/vitejs/vite/issues/11672
},
build: {
target: "esnext",
},
Expand Down
7 changes: 3 additions & 4 deletions packages/file-share/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@
"test:integration": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit"
},
"devDependencies": {
"@peerbit/test-utils": "^1",
"@types/yargs": "^17.0.24",
"typescript": "^5.1.3"
"@peerbit/test-utils": "^2",
"typescript": "^5.3.3"
},
"dependencies": {
"@peerbit/please-lib": "^0.0.7",
"chalk": "^5.3.0",
"peerbit": "^2",
"peerbit": "^3",
"yargs": "^17.7.2"
}
}
15 changes: 7 additions & 8 deletions packages/file-share/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fs from "fs";
import * as yargs from "yargs";
import { Argv } from "yargs";
import chalk from "chalk";
import { waitForAsync } from "@peerbit/time";
import { waitFor } from "@peerbit/time";
import path from "path";
import { multiaddr } from "@multiformats/multiaddr";

Expand Down Expand Up @@ -38,12 +38,13 @@ const cli = async (args?: string[]) => {
const peerbit = await Peerbit.create();
const files = await peerbit.open(new Files({ id: ID }));

// TODO fix types
return yargs
.default(args)
.command({
.command<any>({
command: "put <path>",
describe: "Put file",
builder: (yargs: Argv) => {
builder: (yargs) => {
yargs.positional("path", {
type: "string",
describe: "Where to save it",
Expand Down Expand Up @@ -76,10 +77,10 @@ const cli = async (args?: string[]) => {
);
},
})
.command({
.command<any>({
command: "get <id> [path]",
describe: "Get file",
builder: (yargs: Argv) => {
builder: (yargs) => {
yargs.positional("id", {
type: "string",
describe: "The file id. Obtained when putting the file",
Expand Down Expand Up @@ -118,9 +119,7 @@ const cli = async (args?: string[]) => {
console.log("Fetching file with id: " + args.id);

// wait for at least 1 replicator
await waitForAsync(
async () => (await files.getReady()).size >= 1
);
await waitFor(async () => (await files.getReady()).size >= 1);

const file = await files.getById(args.id.trim());

Expand Down
12 changes: 6 additions & 6 deletions packages/file-share/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@peerbit/please-lib": "^0.0.7",
"peerbit": "^2",
"peerbit": "^3",
"@peerbit/react": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -27,11 +27,11 @@
"@radix-ui/react-toggle": "^1.0.3"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.0.3",
"typescript": "^5.1.3",
"vite": "^4.4.7",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"tailwindcss": "^3.3.3",
"postcss": "^8.4.26",
"autoprefixer": "^10.4.14"
Expand Down
Loading

0 comments on commit 33c5b6a

Please sign in to comment.