Coder Social home page Coder Social logo

syn's Introduction

syn

Generalized DNA for building real-time shared-state hApps on holochain

Syn: Etymology. From Ancient Greek συμ- (sum-), variant of συν- (sun-), from σύν (sún, “with, in company with, together with”).

Design

This project makes it easy to build collaborative apps in the distributed peer-to-peer context of Holochain. Syn uses Holochain's infrastructure for data integrity and peer-to-peer networking to store regular "commits" of the shared content's state, while coordinating batches of delta's that comprise those commits between nodes. The approach is generalized for many different use-cases, where the app-developer need only define:

  1. A renderer for content state
  2. A patch-grammar for applying deltas to content
  3. A function to apply deltas to the content state
  4. Any user interaction that should generate those deltas in the given grammar

For more details read the design documents, read the article, and check out the example app, SynText, in the /ui directory.

Installation

  1. Install the nix-shell.
  2. Clone this repo: git clone https://github.com/holochain/syn && cd ./syn
  3. Enter the nix shell: nix-shell.
  4. Run npm install

Building the DNA

  • Build the DNA (assumes you are still in the nix shell for correct rust/cargo versions from step above):
npm run build:happ

UI

We have provided a sample UI that implements collaborative text editing in a minimal editor. To run this UI in test mode:

npm run start

And the same in another terminal:

npm run start

Now open two browser tabs pointing to the locations that the output from those commands indicates.

Now you should be able to see both agents and start editing text on either tab and see it appear on the other.

Testing

npm run test

License

License: CAL 1.0

Copyright (C) 2020-2021, Holochain Foundation

This program is free software: you can redistribute it and/or modify it under the terms of the license provided in the LICENSE file (CAL-1.0). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syn's People

Contributors

btakita avatar guillemcordoba avatar harlantwood avatar maackle avatar matthme avatar qubist avatar zippy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syn's Issues

Browsers connected to localhost:8888 & localhost:8889 do not see each other's sessions

The https://localhost:8889 window does not see the session in the https://localhost:8888 window

I added some debug! statements to the init function https://github.com/holochain/syn/blob/main/zomes/syn/src/lib.rs#L340 in the zome, & the expected console output was not outputted when starting the zomes. I'm still familiarizing myself on how the RSM works, but this is unexpected to me.

Upgrading hdk dependencies to holochain/holochain#main

Placeholder issue re: the process of upgrading the dependencies to holochain/holochain#main. Depending on the amount of effort for me (and my limited understanding), I may or may not complete this. Primarily using this project as a reference to bootstrap development on another project.

Convert ui ESM modules & svelte components into Typescript

I was able to successfully compile the hApp & get the ui client to run. However, I'm not able to see the port 8889 client to see commits from the port 8888 client (& vice versa) until a reconnect occurs.

In following the ui code, I see & am working on an opportunity to convert the Svelte & ESM modules into Typescript, to enhance my understanding. If there is not already an effort to do so, I'd like to refactor the Svelte & ESM modules to Typescript for my own understanding of how the UI & the hApp work. I already made some good progress & I'll submit a Pull Request soon.

Can't start UI

Following the README leads to a npm error before the UI can start.

> @syn/[email protected] start /home/feldi/Downloads/syn
> cross-env HC_PORT=$(port) concurrently -k "npm run dev:libs" "npm run start:happ" "npm run dev -w syntext"

[1] 
[1] > @syn/[email protected] start:happ /home/feldi/Downloads/syn
[1] > npm run build:happ && hc s generate -r=$HC_PORT dna/workdir/happ/syn.happ -a syn network --bootstrap https://bootstrap-staging.holo.host/ quic
[1] 
[0] 
[0] > @syn/[email protected] dev:libs /home/feldi/Downloads/syn
[0] > concurrently -k "npm run build:watch -w @syn/zome-client" "npm run build:watch -w @syn/store" "npm run build:watch -w @syn/elements"
[0] 
[2] npm ERR! missing script: dev
[2] 
[2] npm ERR! A complete log of this run can be found in:
[2] npm ERR!     /home/feldi/.npm/_logs/2021-09-08T09_55_09_009Z-debug.log
[2] npm run dev -w syntext exited with code 1
--> Sending SIGTERM to other processes..
[0] npm run dev:libs exited with code SIGTERM
--> Sending SIGTERM to other processes..
[1] npm run start:happ exited with code SIGTERM
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @syn/[email protected] start: `cross-env HC_PORT=$(port) concurrently -k "npm run dev:libs" "npm run start:happ" "npm run dev -w syntext"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @syn/[email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I'm using nix-shell 2.3.15.
For installation I followed the holochain developer guide: https://developer.holochain.org/install/

Decouple base library from svelte

I see the syn.js logic using svelte stores, which is fine for this UI, but won't be usable for other UIs built on top of this library and with any other framework.

I suggest using MobX, a js-only updatable and reactive store which has impressed me a lot, what do you think @zippy @qubist ? If you agree, I will gladly do the refactor, but only if you feel comfortable switching to that :)

Implement heartbeat

  • Participants should send heartbeat.
  • Scribe should keep track of "last seen"
  • periodic task on scribe should change status of unseen folk (in-session/not in session)
  • UI should show grayed-out hexes according to user status

Fails at "npm install"

I am trying to run the demo

I have successfully run nix-shell in the syn root folder, I have logged out and back in and run nix-shell again.

When I run "nom install" I get the following errors, any ideas what I need to do to fix these?

[nix-shell:~/syn]$ npm install
npm WARN deprecated @whi/[email protected]: WARNING: this package has been renamed to @whi/http. Use @whi/http to install newer versions.
npm WARN deprecated [email protected]: Please update to the latest object-keys
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see axios/axios#3410
npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 2
npm ERR! git dep preparation failed
npm ERR! command /nix/store/p6h1iz5lcvfz1hg1z497ypa22rv52xxx-nodejs-16.8.0/bin/node /nix/store/p6h1iz5lcvfz1hg1z497ypa22rv52xxx-nodejs-16.8.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/ubuntu/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! > @holochain/[email protected] prepare
npm ERR! > npm run build
npm ERR!
npm ERR!
npm ERR! > @holochain/[email protected] build
npm ERR! > rm -rf ./lib ; tsc -d
npm ERR!
npm ERR! src/cell.ts(1,18): error TS2305: Module '"../node_modules/@holochain/conductor-api/lib"' has no exported member 'CellNick'.
npm ERR! src/conductor.ts(10,3): error TS2305: Module '"../node_modules/@holochain/conductor-api/lib"' has no exported member 'CellNick'.
npm ERR! src/conductor.ts(279,7): error TS2322: Type '{ hash: Buffer; nick: string; }[]' is not assignable to type 'InstallAppDnaPayload[]'.
npm ERR! Property 'role_id' is missing in type '{ hash: Buffer; nick: string; }' but required in type 'InstallAppDnaPayload'.
npm ERR! src/conductor.ts(326,48): error TS2339: Property 'cell_nick' does not exist on type 'InstalledCell'.
npm ERR! src/player.ts(8,35): error TS2305: Module '"../node_modules/@holochain/conductor-api/lib"' has no exported member 'CellNick'.
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see axios/axios#3410
npm ERR! npm WARN deprecated @holochain/[email protected]: Use @holochain/client instead
npm ERR! npm WARN deprecated [email protected]: Support has ended for 9.x series. Upgrade to @latest
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 2
npm ERR! npm ERR! path /home/ubuntu/.npm/_cacache/tmp/git-clone-4b353882
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c npm run build
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /home/ubuntu/.npm/_logs/2022-01-25T12_42_27_343Z-debug.log

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2022-01-25T12_43_08_835Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.