Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Mar 26, 2024
2 parents 6a2ed1a + 1e2b0c5 commit 8d4ef54
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 94 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# We
# Moss

_We_ is a Holochain runtime that makes it trivially easy for groups to build collaboration spaces by composing custom "Applet" suites to meet their collaboration needs.
_Moss_ is a reference implementation of a Frame for [The Weave](https://weave.social), which can also be understood as a Holochain runtime that makes it trivially easy for groups to build collaboration spaces by composing custom "Tool" suites to meet their collaboration needs.

_We_ is composed of a group management DNA, together with a defined pattern on how to build _Applet_ DNAs that can be added to a _We_ group. Each such group as well as each _Applet_ used within a group is its own private peer-to-peer network.
_Moss_ is composed of a group management DNA, together with a defined pattern on how to build _Tool_ DNAs that can be added to a _Moss_ group. Each such group as well as each _Tool_ used within a group is its own private peer-to-peer network.

For more about the motivation behind _We_, read [this blogpost](https://eric.harris-braun.com/blog/2022/07/26/id-390).
_Moss_ used to be called _We_, and you can read about it's early instantiation in [this blogpost](https://eric.harris-braun.com/blog/2022/07/26/id-390).

## Design

For details about the design, read the [design document](docs/Design.md).

## Creating We Applets
## Creating Moss Tools

The details on how to create a _we applet_ can be found [here](docs/How-to-create-a-we-applet.md).
The details on how to create a _Tool_ can be found [here](docs/how-to-create-a-tool.md).

## Installation

Go to [the releases page](https://github.com/lightningrodlabs/we/releases) and download the latest release for your Operating System.

## For Developers
## For Developers of Moss

### Environment Setup

Expand All @@ -38,8 +38,8 @@ This command will

- install all npm dependencies
- build the required local libraries
- build the We group DNA and the zomes in the crates folder
- fetch the required holochain and lair binaries from [here](https://github.com/matthme/holochain-binaries/releases)
- build the Moss group DNA and the zomes in the crates folder
- fetch the required `holochain` and `lair-keystore` binaries from [here](https://github.com/matthme/holochain-binaries/releases)
- fetch the default apps (at the time of writing those are the app library and the feedback board)
- run the necessary commands to link the packages in `libs/we-applet` and `libs/we-elements` with `yarn link` to have them be hot-reloaded in the example applet

Expand All @@ -53,7 +53,7 @@ yarn build:example-applet
yarn applet-dev-example
```

We will start up 2 agents each with the same group and 3 applets installed. One of the applets will be in hot-reloading mode, i.e. you can modify the code in the `example/ui/` directory and should see the changes immediately. You should also see changes applied to the `src/renderer/src` directory immediately reflected.
Moss will start up 2 agents each with the same group and 3 applets installed. One of the applets will be in hot-reloading mode, i.e. you can modify the code in the `example/ui/` directory and should see the changes immediately. You should also see changes applied to the `src/renderer/src` directory immediately reflected.

#### Rust add-ons

Expand All @@ -76,7 +76,7 @@ yarn build:linux

[![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license)

Copyright (C) 2021, Harris-Braun Enterprises, LLC
Copyright (C) 2021-2024, Harris-Braun Enterprises, LLC

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,
Expand Down
65 changes: 0 additions & 65 deletions docs/How-to-create-a-we-applet.md

This file was deleted.

18 changes: 18 additions & 0 deletions docs/how-to-create-a-tool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Weave Tool

A _Weave_ Tool is a Holochain application and associated UI that's only intended to be used inside a Weave `Frame` environment. This means that the UI, instead of rendering a full blown web application, only renders the appropriate elements that the `Frame` requests.

**Nomenclature Caveat**: In this document we refer to a `Frame` which is the general term for a runtime that implements the [Weave Interaction Pattern](https://theweave.social/#technical). _Moss_ is a reference implementation of a `Frame`. You may also see the term `applet` in some code libraries which is a remnant of the term "Tool" and will be phased out over time.

At the technical level, a Weave Tool is just a normal Holochain `.webhapp`, with 2 main differences from any other web hApp:

- UI code:

- Your UI code may offer different rendering modes or UI widgets as well as offer the affordances described by the [Weave Interaction Pattern](https://theweave.social/#technical) (search, attachments, embedding, notification, etc.)

- hApp code:
- You don't need the profiles zome or any other zome that deals with profiles, as they will be managed by the we group DNA.

## How to create a Tool

Check out the [README](../libs/we-applet/README.md) of the `@lightningrodlabs/we-applet` npm package for instructions on how to modify your hApp UI in order to become Weave compatible.
32 changes: 16 additions & 16 deletions libs/we-applet/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# @lightningrodlabs/we-applet

This package contains the interfaces and contracts that a Holochain app UI needs to implement in order to become a We Applet.
This package contains the interfaces and contracts that a Holochain app UI needs to implement in order to run as a Tool in a Weave Frame like [Moss](theweave.social#tryit).

The differences between a We Applet and a normal Holochain App are:
The differences between a Weave Tool and a normal Holochain App are:

- A We Applet can make use of the profiles zome provided by We instead of using its own profiles module
- A We Applet can provide more than just the default "main" UI. It can additionally provide:
- A Weave Tool can make use of the profiles zome provided by the Frame instead of using its own profiles module
- A Weave Tool can provide more than just the default "main" UI. It can additionally provide:
- UI elements to display single "assets"
- UI widgets/blocks of any kind
- UI elements ("main" view or "blocks") that render information across all instances of that same Applet type
- A We Applet can provide `AppletServices` for We or other Applets to use, including:
- search: Searching in the Applet that returns Holochain Resource Locators (HRLs) with context pointing to an asset
- UI elements ("main" view or "blocks") that render information across all instances of that same Tool type
- A Weave Tool can provide `AppletServices` for the Frame or other Applets to use, including:
- search: Searching in the Tool that returns Holochain Resource Locators (HRLs) with context pointing to an asset
- creatables: Assets that can be created on-the-fly by a user.
- getAssetInfo(): A function that returns info for the asset associated to the WAL if it exists in the Applet and the method is implemented.
- blockTypes: Types of UI widgets/blocks that this Applet can render if requested by We.
- getAssetInfo(): A function that returns info for the asset associated to the WAL if it exists in the Tool and the method is implemented.
- blockTypes: Types of UI widgets/blocks that this Tool can render if requested by the Frame.

**Definition**: An "asset" is anything that a) can be identified with an HRL plus arbitrary context and b) has an associated
**Definition**: An "Asset" is anything that a) can be identified with an HRL plus arbitrary context and b) has an associated
"asset-view", i.e. it can be displayed by the applet if requested.

### Implementing a most basic applet UI
Expand All @@ -24,15 +24,15 @@ The differences between a We Applet and a normal Holochain App are:
import { WeClient, isWeContext } from '@lightningrodlabs/we-applet';
if (!isWeContext) {
// do non-We related rendering logic (launcher, kangaroo, electron, ...)
// do non-the Frame related rendering logic (launcher, kangaroo, electron, ...)
}
const weClient = await WeClient.connect();
if (
(weClient.renderInfo.type !== "applet-view")
|| (weClient.renderInfo.view.type !== "main")
) throw new Error("This Applet only implements the applet main view.");
) throw new Error("This Tool only implements the applet main view.");
const appAgentClient = weClient.renderInfo.appletClient;
const profilesClient = weClient.renderInfo.profilesClient;
Expand All @@ -41,16 +41,16 @@ const profilesClient = weClient.renderInfo.profilesClient;
```

### Implementing an (almost) full-fletched We Applet
### Implementing an (almost) full-fletched Weave Tool

```typescript=
import { WeClient, AppletServices, WAL, AssetInfo } from '@lightningrodlabs/we-applet';
// First define your AppletServices that We can call on your applet
// First define your AppletServices that the Frame can call on your applet
// to do things like search your applet or get information
// about the available block views etc.
const appletServices: Appletservices = {
// Types of attachment that this Applet offers for other Applets to attach
// Types of attachment that this Tool offers for other Applets to attach
creatables: {
'post': {
label: 'post',
Expand All @@ -62,7 +62,7 @@ const appletServices: Appletservices = {
}
},
// Types of UI widgets/blocks that this Applet supports
// Types of UI widgets/blocks that this Tool supports
blockTypes: {
'most_recent_posts': {
label: 'most_recent_posts',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "org.lightningrodlabs.we-electron-alpha",
"version": "0.11.3",
"version": "0.11.4",
"private": true,
"description": "Moss (Alpha)",
"main": "./out/main/index.js",
Expand Down
53 changes: 52 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
session,
desktopCapturer,
Notification,
systemPreferences,
} from 'electron';
import path from 'path';
import fs from 'fs';
Expand Down Expand Up @@ -399,10 +400,60 @@ app.whenReady().then(async () => {
session.defaultSession.setPermissionRequestHandler(
async (_webContents, permission, callback, details) => {
if (permission === 'media') {
const unknownRequested = !details.mediaTypes || details.mediaTypes.length === 0;
const videoRequested = details.mediaTypes?.includes('video') || unknownRequested;
const audioRequested = details.mediaTypes?.includes('audio') || unknownRequested;

// On macOS, OS level permission for camera/microhone access needs to be given
if (process.platform === 'darwin') {
if (audioRequested) {
const audioAccess = systemPreferences.getMediaAccessStatus('microphone');
if (audioAccess === 'denied') {
dialog.showMessageBoxSync(MAIN_WINDOW!, {
type: 'error',
message:
"Audio permission has been denied ealier. You need to allow audio for Moss in your Computer's System Preferences and restart Moss to allow audio.",
});
return;
} else if (audioAccess !== 'granted') {
const allowed = await systemPreferences.askForMediaAccess('microphone');
if (!allowed) {
dialog.showMessageBoxSync(MAIN_WINDOW!, {
type: 'error',
message:
"Audio permission has been denied. You need to allow audio for Moss in your Computer's System Preferences and restart Moss if you want to allow audio.",
});
return;
}
}
}
if (videoRequested) {
const videoAccess = systemPreferences.getMediaAccessStatus('camera');
if (videoAccess === 'denied') {
dialog.showMessageBoxSync(MAIN_WINDOW!, {
type: 'error',
message:
"Video permission has been denied ealier. You need to allow video for Moss in your Computer's System Preferences and restart Moss to allow video.",
});
return;
} else if (videoAccess !== 'granted') {
const allowed = await systemPreferences.askForMediaAccess('camera');
if (!allowed) {
dialog.showMessageBoxSync(MAIN_WINDOW!, {
type: 'error',
message:
"Video permission has been denied. You need to allow video for Moss in your Computer's System Preferences and restart Moss if you want to allow video.",
});
return;
}
}
}
}

let messageContent = `An Applet wants to access the following:${
details.mediaTypes?.includes('video') ? '\n* camera' : ''
}${details.mediaTypes?.includes('audio') ? '\n* microphone' : ''}`;
if (!details.mediaTypes || details.mediaTypes.length === 0) {
if (unknownRequested) {
messageContent =
'An Applet wants to access either or all of the following:\n* camera\n* microphone\n* screen share';
}
Expand Down

0 comments on commit 8d4ef54

Please sign in to comment.