@powerhousedao/academy 5.1.0-dev.9 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -1108
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +1 -2
- package/blog/TheChallengeOfChange.md +0 -1
- package/docs/academy/00-EthereumArgentinaHackathon.md +207 -0
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +27 -24
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +9 -118
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +28 -110
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +145 -191
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +218 -0
- package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/05-VetraStudio.md +6 -48
- package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
- package/docs/academy/01-GetStarted/_04-BuildToDoListEditor +1 -1
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +2 -2
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +44 -75
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +22 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +31 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +206 -211
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +62 -176
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +0 -21
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +319 -309
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +0 -4
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +0 -4
- package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -1
- package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +35 -111
- package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +76 -255
- package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +160 -281
- package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +35 -188
- package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +7 -95
- package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
- package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +2 -6
- package/docs/academy/04-APIReferences/01-ReactHooks.md +501 -291
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +39 -7
- package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
- package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
- package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +24 -72
- package/docs/academy/08-Glossary.md +0 -7
- package/docusaurus.config.ts +3 -28
- package/package.json +1 -1
- package/sidebars.ts +12 -49
- package/src/css/custom.css +18 -26
- package/docs/academy/01-GetStarted/04-WriteDocumentModelTests.md +0 -378
- package/docs/academy/01-GetStarted/05-BuildToDoListEditor.md +0 -560
- package/docs/academy/03-ExampleUsecases/TodoList/00-GetTheStarterCode.md +0 -24
- package/docs/academy/03-ExampleUsecases/TodoList/01-GenerateTodoListDocumentModel.md +0 -211
- package/docs/academy/03-ExampleUsecases/TodoList/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/03-ExampleUsecases/TodoList/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/03-ExampleUsecases/TodoList/04-GenerateTodoListDocumentEditor.md +0 -45
- package/docs/academy/03-ExampleUsecases/TodoList/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/03-ExampleUsecases/TodoList/06-GenerateTodoDriveExplorer.md +0 -61
- package/docs/academy/03-ExampleUsecases/TodoList/07-AddSharedComponentForShowingTodoListStats.md +0 -384
- package/docs/academy/03-ExampleUsecases/TodoList/_category_.json +0 -8
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/VetraPackageLibrary.md +0 -7
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/_category_.json +0 -9
- package/docs/academy/04-APIReferences/06-VetraRemoteDrive.md +0 -160
- package/docs/academy/04-APIReferences/renown-sdk/00-Overview.md +0 -316
- package/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md +0 -672
- package/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md +0 -957
- package/docs/academy/04-APIReferences/renown-sdk/_category_.json +0 -8
- package/docs/academy/10-TodoListTutorial/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/10-TodoListTutorial/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/10-TodoListTutorial/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/10-TodoListTutorial/07-AddSharedComponentForShowingTodoListStats.md +0 -370
- package/static/img/Vetra-logo-dark.svg +0 -11
- package/static/img/vetra-logo-light.svg +0 -11
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/Modules.png +0 -0
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/VetraStudioDrive.png +0 -0
- /package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/{02-RevisionHistoryTimeline/360/237/232/247" → 02-RevisionHistoryTimeline} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /01-WhatIsADocumentModel" → 01-WhatIsADocumentModel} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-DAOandDocumentsModelsQ+A" → 02-DAOandDocumentsModelsQ+A} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-domain-modeling" → 02-domain-modeling} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /03-BenefitsOfDocumentModels" → 03-BenefitsOfDocumentModels} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /04-UtilitiesAndTips" → 04-UtilitiesAndTips} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /05-best-practices" → 05-best-practices} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /_category_.json" → _category_.json} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /three-data-layers.png" → three-data-layers.png} +0 -0
|
@@ -1,122 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Implement Chatroom Editor
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
📦 **Reference Code**: [chatroom-demo](https://github.com/powerhouse-inc/chatroom-demo)
|
|
5
|
-
|
|
6
|
-
This tutorial covers building the ChatRoom editor:
|
|
7
|
-
1. **Editor Scaffolding**: Generating the editor template with `ph generate --editor`
|
|
8
|
-
2. **Component Implementation**: Building a complete, interactive chat UI with components
|
|
9
|
-
|
|
10
|
-
Explore the complete implementation in the `editors/chat-room-editor/` directory.
|
|
11
|
-
:::
|
|
12
|
-
|
|
13
|
-
<details>
|
|
14
|
-
<summary>📖 How to use this tutorial</summary>
|
|
15
|
-
|
|
16
|
-
This tutorial shows building from **generated scaffolding** to a **complete chat UI**.
|
|
17
|
-
|
|
18
|
-
### Compare your generated editor
|
|
19
|
-
|
|
20
|
-
After running `pnpm generate --editor`:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Compare generated scaffolding with the reference
|
|
24
|
-
git diff tutorial/main -- editors/chat-room-editor/
|
|
25
|
-
|
|
26
|
-
# View the generated editor template
|
|
27
|
-
git show tutorial/main:editors/chat-room-editor/editor.tsx
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Browse the complete implementation
|
|
31
|
-
|
|
32
|
-
Explore the production-ready component structure:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# List all components in the reference
|
|
36
|
-
git ls-tree -r --name-only tutorial/main editors/chat-room-editor/components/
|
|
37
|
-
|
|
38
|
-
# View a specific component
|
|
39
|
-
git show tutorial/main:editors/chat-room-editor/components/ChatRoom.tsx
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Visual comparison with GitHub Desktop
|
|
43
|
-
|
|
44
|
-
After committing your editor code:
|
|
45
|
-
1. **Branch** menu → **"Compare to Branch..."**
|
|
46
|
-
2. Select `tutorial/main`
|
|
47
|
-
3. See all your custom components vs. the reference implementation
|
|
48
|
-
|
|
49
|
-
See step 1 for detailed GitHub Desktop instructions.
|
|
50
|
-
|
|
51
|
-
</details>
|
|
52
|
-
|
|
53
|
-
In this chapter we will continue with the interface or editor implementation of the **ChatRoom** document model. This means you will create a user interface for the **ChatRoom** document model which will be used inside the Connect app to visualize your chatroom, send messages, and react with emojis.
|
|
3
|
+
In this section you will implement the `Chatroom` document model editor. This means you will create a simple user interface for the `Chatroom` document model which will be used inside the Connect app to visualise our chatroom, send messages and emoji reactions.
|
|
54
4
|
|
|
55
5
|
## Generate the editor template
|
|
56
6
|
|
|
57
|
-
Run
|
|
58
|
-
This command reads the **ChatRoom** document model definition from the `document-models` folder and generates the editor template in the `editors/chat-room-editor` folder.
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
pnpm generate --editor chat-room-editor --document-types powerhouse/chat-room
|
|
62
|
-
```
|
|
7
|
+
Run below command to generate the editor template for the `Chatroom` document model. This command reads the `Chatroom` document model definition from the `document-models` folder and generates the editor template in the `editors/chat-room/editor.tsx` folder.
|
|
63
8
|
|
|
64
|
-
Notice the `--editor` flag which
|
|
9
|
+
Notice the `--editor` flag which defines the `chatroom` document model editor. And the `--document-types` flag which defines the document type `powerhouse/chatroom`.
|
|
65
10
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
editors/chat-room-editor/
|
|
70
|
-
├── components/
|
|
71
|
-
│ └── EditName.tsx # Auto-generated component for editing document name
|
|
72
|
-
├── editor.tsx # Main editor component (to be customized)
|
|
73
|
-
└── module.ts # Editor module configuration
|
|
11
|
+
```bash
|
|
12
|
+
ph generate --editor ChatRoomEditor --document-types powerhouse/chat-room
|
|
74
13
|
```
|
|
75
14
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
### Editor implementation options
|
|
79
|
-
|
|
80
|
-
When building your editor component within the Powerhouse ecosystem, you have several options for styling:
|
|
81
|
-
|
|
82
|
-
1. **Default HTML Styling:** Standard HTML tags will render with default styles offered through the boilerplate.
|
|
83
|
-
2. **Tailwind CSS:** Connect Studio comes with Tailwind CSS integrated. You can directly use Tailwind utility classes.
|
|
84
|
-
3. **Custom CSS Files:** You can import traditional CSS files to apply custom styles.
|
|
85
|
-
|
|
86
|
-
Connect Studio provides a dynamic local environment. By running `ph connect`, you can visualize your components instantly as you build them.
|
|
15
|
+
Once complete, navigate to the `editors/chat-room/editor.tsx` file and open it in your editor.
|
|
87
16
|
|
|
88
|
-
|
|
17
|
+
As you'll see you will need to add more complex logic to make the chatroom functional and interact with our document model.
|
|
89
18
|
|
|
90
|
-
|
|
19
|
+
## Add the necessary components for your editor first
|
|
91
20
|
|
|
92
|
-
|
|
21
|
+
Download the repository of the chatroom-demo as a zip file https://github.com/powerhouse-inc/chatroom-demo
|
|
22
|
+
and navigate to .../chatroom-demo-main/editors/chat-room-editor to copy both the components folder & utils function. In this repository you will also find all of the other code snippets we've been using in this tutorial.
|
|
93
23
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- `editor.tsx` - Main editor wrapper (imports ChatRoom)
|
|
97
|
-
- `ChatRoom.tsx` - Main container component that orchestrates all other components
|
|
98
|
-
- `Message.tsx` - Individual message component with reactions
|
|
99
|
-
- `EmojiReaction.tsx` - Emoji reaction UI component
|
|
100
|
-
- `TextInput.tsx` - Input component for sending messages
|
|
101
|
-
- `Avatar.tsx` - User avatar component
|
|
102
|
-
|
|
103
|
-
### Option 1: Copy components from the reference
|
|
104
|
-
|
|
105
|
-
Download the repository of the chatroom-demo as a zip file from https://github.com/powerhouse-inc/chatroom-demo and navigate to `editors/chat-room-editor` to copy both the `components` folder and `utils.ts` file.
|
|
24
|
+
Drag the folder with react components & utils functions into your VSCode of your chat-room-editor.
|
|
106
25
|
|
|
107
26
|
In this folder you'll find:
|
|
108
|
-
|
|
27
|
+
|
|
28
|
+
- An avatar to be set for each chat room participant
|
|
109
29
|
- The chatroom environment itself
|
|
110
30
|
- A header for the chatroom
|
|
111
|
-
- The UI for rendering
|
|
31
|
+
- The UI for rendering the message, username and reaction popup.
|
|
112
32
|
- The emoji reaction interface
|
|
113
|
-
- A text input field
|
|
33
|
+
- A UI for a text input field
|
|
114
34
|
|
|
115
|
-
The utils function will help you with mapping information from the document model to your chatroom components
|
|
35
|
+
The utils function will help you with mapping information from the document model to your chatroom components. Such as your emoji values to the relevant emoji to be displayed.
|
|
116
36
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
If you want to understand how everything connects, here's the main `editor.tsx` implementation:
|
|
37
|
+
Now, let's copy & paste the code below into the `editor.tsx` file located at `editors/chat-room-editor`and save the file.
|
|
120
38
|
|
|
121
39
|
```typescript
|
|
122
40
|
import { generateId } from "document-model/core";
|
|
@@ -146,7 +64,6 @@ export default function Editor() {
|
|
|
146
64
|
return <div>Loading...</div>;
|
|
147
65
|
}
|
|
148
66
|
|
|
149
|
-
// Map document messages to component props
|
|
150
67
|
const messages: ChatRoomProps["messages"] =
|
|
151
68
|
document.state.global.messages.map((message) => ({
|
|
152
69
|
id: message.id,
|
|
@@ -158,9 +75,10 @@ export default function Editor() {
|
|
|
158
75
|
reactions: mapReactions(message.reactions),
|
|
159
76
|
}));
|
|
160
77
|
|
|
161
|
-
// Handler for sending messages
|
|
162
78
|
const onSendMessage: ChatRoomProps["onSendMessage"] = (message) => {
|
|
163
|
-
if (!message)
|
|
79
|
+
if (!message) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
164
82
|
|
|
165
83
|
dispatch(
|
|
166
84
|
addMessage({
|
|
@@ -176,7 +94,6 @@ export default function Editor() {
|
|
|
176
94
|
);
|
|
177
95
|
};
|
|
178
96
|
|
|
179
|
-
// Handler for adding reactions
|
|
180
97
|
const addReaction = (
|
|
181
98
|
messageId: string,
|
|
182
99
|
userId: string,
|
|
@@ -191,7 +108,6 @@ export default function Editor() {
|
|
|
191
108
|
);
|
|
192
109
|
};
|
|
193
110
|
|
|
194
|
-
// Handler for removing reactions
|
|
195
111
|
const removeReaction = (
|
|
196
112
|
messageId: string,
|
|
197
113
|
userId: string,
|
|
@@ -206,13 +122,14 @@ export default function Editor() {
|
|
|
206
122
|
);
|
|
207
123
|
};
|
|
208
124
|
|
|
209
|
-
// Handler for clicking on reactions (toggle behavior)
|
|
210
125
|
const onClickReaction: MessageProps["onClickReaction"] = (reaction) => {
|
|
211
126
|
const message = messages.find(
|
|
212
127
|
(message) => message.id === reaction.messageId,
|
|
213
128
|
);
|
|
214
129
|
|
|
215
|
-
if (!message)
|
|
130
|
+
if (!message) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
216
133
|
|
|
217
134
|
const messageId = reaction.messageId;
|
|
218
135
|
const reactionType = reactionKeyToReactionType(reaction.type);
|
|
@@ -233,7 +150,6 @@ export default function Editor() {
|
|
|
233
150
|
}
|
|
234
151
|
};
|
|
235
152
|
|
|
236
|
-
// Handlers for editing chat metadata
|
|
237
153
|
const onSubmitTitle: ChatRoomProps["onSubmitTitle"] = (title) => {
|
|
238
154
|
dispatch(editChatName({ name: title }));
|
|
239
155
|
};
|
|
@@ -245,7 +161,11 @@ export default function Editor() {
|
|
|
245
161
|
};
|
|
246
162
|
|
|
247
163
|
return (
|
|
248
|
-
<div
|
|
164
|
+
<div
|
|
165
|
+
style={{
|
|
166
|
+
height: "calc(100vh - 140px)",
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
249
169
|
<ChatRoom
|
|
250
170
|
description={
|
|
251
171
|
document.state.global.description || "This is a chat room demo"
|
|
@@ -263,91 +183,18 @@ export default function Editor() {
|
|
|
263
183
|
}
|
|
264
184
|
```
|
|
265
185
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
- We use `useSelectedChatRoomDocument` hook to get the document state and dispatch function
|
|
269
|
-
- We use `useUser` to get the current user information (for authentication)
|
|
270
|
-
- We map the document's messages to props that our ChatRoom component expects
|
|
271
|
-
- We create handlers for sending messages, adding/removing reactions, and editing metadata
|
|
272
|
-
- We dispatch operations (`addMessage`, `addEmojiReaction`, etc.) from our generated creators
|
|
273
|
-
|
|
274
|
-
:::info Key Concept: useSelectedChatRoomDocument hook
|
|
275
|
-
The `useSelectedChatRoomDocument` hook is generated by the Powerhouse CLI. It provides:
|
|
276
|
-
1. The current document state (`document`)
|
|
277
|
-
2. A dispatch function to send actions to the reducer
|
|
278
|
-
|
|
279
|
-
This hook connects your React components to the document model's state and operations.
|
|
280
|
-
:::
|
|
281
|
-
|
|
282
|
-
## Test your editor
|
|
283
|
-
|
|
284
|
-
Now you can run the Connect app and see the **ChatRoom** editor in action:
|
|
186
|
+
Now you can run the Connect app and see the `Chatroom` editor in action.
|
|
285
187
|
|
|
286
188
|
```bash
|
|
287
189
|
ph connect
|
|
288
190
|
```
|
|
289
191
|
|
|
290
|
-
In
|
|
291
|
-
|
|
292
|
-
:::warning Authentication Required
|
|
293
|
-
A warning will prompt you to login before you can send messages. Login with an Ethereum address via Renown to start sending messages.
|
|
294
|
-
:::
|
|
295
|
-
|
|
296
|
-

|
|
297
|
-
|
|
298
|
-
**Try it out:**
|
|
299
|
-
1. Create a new ChatRoom document
|
|
300
|
-
2. Login with your Ethereum wallet
|
|
301
|
-
3. Send messages using the input field
|
|
302
|
-
4. React to messages with emoji reactions
|
|
303
|
-
5. Click the chat name or description to edit them
|
|
304
|
-
|
|
305
|
-
Congratulations! 🎉
|
|
306
|
-
If you managed to follow this tutorial until this point, you have successfully implemented the **ChatRoom** document model with its reducer operations and editor.
|
|
307
|
-
|
|
308
|
-
## Compare with the reference implementation
|
|
309
|
-
|
|
310
|
-
The tutorial repository includes the complete ChatRoom editor with all components:
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
editors/chat-room-editor/
|
|
314
|
-
├── components/
|
|
315
|
-
│ ├── Avatar.tsx # User avatar display
|
|
316
|
-
│ ├── ChatRoom.tsx # Main chat container
|
|
317
|
-
│ ├── Header.tsx # Chat header with title/description
|
|
318
|
-
│ ├── Message.tsx # Individual message display
|
|
319
|
-
│ ├── EmojiReaction.tsx # Reaction UI
|
|
320
|
-
│ ├── TextInput.tsx # Message input field
|
|
321
|
-
│ └── index.ts # Component exports
|
|
322
|
-
├── editor.tsx # Main editor component
|
|
323
|
-
├── utils.ts # Utility functions for data mapping
|
|
324
|
-
└── module.ts # Editor module configuration
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
**View individual components from the reference:**
|
|
192
|
+
In connect, in the bottom right corner you'll find a new Document Model that you can create: `ChatRoom`. Click on it to create a new Chat Room document. A warning will prompt you to login before you are able to send messages.
|
|
328
193
|
|
|
329
|
-
|
|
330
|
-
# See the ChatRoom component implementation
|
|
331
|
-
git show tutorial/main:editors/chat-room-editor/components/ChatRoom.tsx
|
|
332
|
-
|
|
333
|
-
# Explore the Message component
|
|
334
|
-
git show tutorial/main:editors/chat-room-editor/components/Message.tsx
|
|
335
|
-
|
|
336
|
-
# Compare your implementation with the reference
|
|
337
|
-
git diff tutorial/main -- editors/chat-room-editor/
|
|
338
|
-
```
|
|
194
|
+
Login with an ethereum address via Renown to start sending messages.
|
|
339
195
|
|
|
340
|
-
|
|
196
|
+
Below GIF shows the `Chatroom` editor in action.
|
|
341
197
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
✅ **Component-based architecture** - Breaking down complex UIs into reusable components
|
|
345
|
-
✅ **Document model hooks** - Using `useSelectedChatRoomDocument` to connect React to your document state
|
|
346
|
-
✅ **User authentication** - Using `useUser` hook for wallet-based authentication
|
|
347
|
-
✅ **Action dispatching** - How to dispatch operations from your UI
|
|
348
|
-
✅ **Type-safe development** - Leveraging TypeScript with generated types from your SDL
|
|
349
|
-
✅ **Real-time collaboration** - Building features that work across multiple users
|
|
350
|
-
|
|
351
|
-
## Up next: Local Reactor
|
|
198
|
+

|
|
352
199
|
|
|
353
|
-
|
|
200
|
+
If you managed to follow this tutorial until this point, you have successfully implemented the `ChatRoom` document model with its reducer operations and editor.
|
|
@@ -1,103 +1,15 @@
|
|
|
1
1
|
# Launch a local Reactor
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
📦 **Reference Code**: [chatroom-demo](https://github.com/powerhouse-inc/chatroom-demo)
|
|
3
|
+
Now we'll create a local Reactor instance to simulate the behaviour of the chatroom synchronising messages between two nodes or users in the network.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
:::
|
|
5
|
+
Wind down connect and run the following command in your terminal.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
`ph reactor`
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
This spins up a reactor, which represents a node that is usally hosted as a remote server, but in our case we run it locally on our machine. The reactor you've created will become available as a public drive in your left hand side bar.
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- Hosts and synchronizes documents across multiple clients
|
|
15
|
-
- Manages document state and operations
|
|
16
|
-
- Enables real-time collaboration between users
|
|
11
|
+
If you would now open up two different browser windows you will be able to login into two version of connect, with two different ethereum addresses to start validating the functionality of your chatroom.
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
Please go ahead now and send a message to yourself, give yourself a thumbs up or try to make your ENS name appear as your profile when logging in. Also remind yourself that you are able to see the revision history of your document and all it's operation history in the top right corner.
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
First, stop the Connect application if it's running. Then start the Reactor:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
ph reactor
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
This spins up a Reactor that:
|
|
29
|
-
- Runs locally on your machine
|
|
30
|
-
- Creates a public drive accessible from your Connect sidebar
|
|
31
|
-
- Enables synchronization between multiple browser sessions
|
|
32
|
-
|
|
33
|
-
## Test real-time collaboration
|
|
34
|
-
|
|
35
|
-
To validate the real-time functionality of your ChatRoom:
|
|
36
|
-
|
|
37
|
-
1. **Open two browser windows** with the Connect application
|
|
38
|
-
2. **Navigate to the Reactor drive** in the left sidebar (it will appear as a public drive)
|
|
39
|
-
3. **Login with different Ethereum addresses** in each window
|
|
40
|
-
4. **Create a ChatRoom document** in one window
|
|
41
|
-
5. **Open the same document** in the other window
|
|
42
|
-
|
|
43
|
-
Now you can:
|
|
44
|
-
- Send messages from one window and see them appear in the other
|
|
45
|
-
- React to messages with emojis and watch the reactions sync
|
|
46
|
-
- Edit the chat name or description and see updates propagate
|
|
47
|
-
|
|
48
|
-
:::info Real-time Sync
|
|
49
|
-
The Reactor ensures that all operations are synchronized across connected clients. Each message and reaction is recorded as an operation, maintaining a complete history that can be replayed to reconstruct the document state.
|
|
50
|
-
:::
|
|
51
|
-
|
|
52
|
-
## Additional features to explore
|
|
53
|
-
|
|
54
|
-
While testing your ChatRoom, try these features:
|
|
55
|
-
|
|
56
|
-
1. **Operation History**: Click on the revision history in the top right corner to see all operations performed on the document
|
|
57
|
-
|
|
58
|
-
2. **ENS Integration**: If you login with an Ethereum address that has an ENS name, your name and avatar will appear in your messages
|
|
59
|
-
|
|
60
|
-
3. **Reaction Toggling**: Click on an existing reaction to toggle it on/off for your user
|
|
61
|
-
|
|
62
|
-
## Running Connect alongside Reactor
|
|
63
|
-
|
|
64
|
-
You can also run Connect and Reactor together. In separate terminal windows:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Terminal 1: Start the Reactor
|
|
68
|
-
ph reactor
|
|
69
|
-
|
|
70
|
-
# Terminal 2: Start Connect (in a separate terminal)
|
|
71
|
-
ph connect
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
This allows you to:
|
|
75
|
-
- Use Connect's local drive for development
|
|
76
|
-
- Access the Reactor's public drive for collaboration testing
|
|
77
|
-
- Switch between local and synchronized documents
|
|
78
|
-
|
|
79
|
-
## What you've accomplished
|
|
80
|
-
|
|
81
|
-
Congratulations! 🎉 You've now completed the ChatRoom tutorial and learned how to:
|
|
82
|
-
|
|
83
|
-
✅ **Create a Powerhouse project** - Initialize and configure a new project
|
|
84
|
-
✅ **Define a document model** - Design schemas using GraphQL SDL
|
|
85
|
-
✅ **Implement reducers** - Write the business logic for state transitions
|
|
86
|
-
✅ **Build an editor** - Create a React-based UI for your document
|
|
87
|
-
✅ **Test with a Reactor** - Validate real-time collaboration features
|
|
88
|
-
|
|
89
|
-
## Next steps
|
|
90
|
-
|
|
91
|
-
Now that you've completed this tutorial, you can:
|
|
92
|
-
|
|
93
|
-
1. **Explore the Mastery Track** - Dive deeper into [Document Model Creation](/academy/MasteryTrack/DocumentModelCreation/WhatIsADocumentModel) for advanced concepts
|
|
94
|
-
|
|
95
|
-
2. **Try Vetra Studio** - Use AI-assisted development with [Vetra Studio](/academy/GetStarted/VetraStudio) for faster iteration
|
|
96
|
-
|
|
97
|
-
3. **Build your own project** - Apply what you've learned to create your own document models and editors
|
|
98
|
-
|
|
99
|
-
4. **Join the community** - Connect with other Powerhouse builders and share your creations
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
*This tutorial demonstrated one of the many ways to use document models within the Powerhouse ecosystem. The patterns you've learned here apply to any collaborative application you want to build.*
|
|
15
|
+
Congratulations! You've now explored one of the many ways to use document models within the powerhouse ecosystem.
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
"position": 2,
|
|
4
4
|
"link": {
|
|
5
5
|
"type": "generated-index",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Get started with the Chatroom tutoria: Jump into creating a new Powerhouse project if you have NodeJs, VSCode, and Git installed. Whe are going to create a new document model that represents a chat. So you as a user can post messages into that chat room, react to the messages. This chatroom will be synchronized between different connect instances. Let's explore the potential of the tools available in the powerhouse toolkit"
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -8,7 +8,7 @@ The **Powerhouse CLI tool** is the only essential tool to install on this page.
|
|
|
8
8
|
You can find all of the commands on this page, similar to what would displayed when using ph --help or ph _command_ --help.
|
|
9
9
|
Use the table of content or the search function to find what you are looking for.
|
|
10
10
|
|
|
11
|
-
The Powerhouse CLI (`ph-cmd`) is a command-line interface tool that provides essential commands for managing Powerhouse
|
|
11
|
+
The Powerhouse CLI (`ph-cmd`) is a command-line interface tool that provides essential commands for managing Powerhouse projects. You can get access to the Powerhouse ecosystem tools by installing them globally.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
pnpm install -g ph-cmd
|
|
@@ -16,11 +16,7 @@ pnpm install -g ph-cmd
|
|
|
16
16
|
|
|
17
17
|
:::
|
|
18
18
|
|
|
19
|
-
<!-- AUTO-GENERATED-CLI-COMMANDS-START -->\n<!-- This content is automatically generated. Do not edit directly. -->\n
|
|
20
|
-
|
|
21
|
-
### ph-cmd Commands
|
|
22
|
-
|
|
23
|
-
- [Checkout](#checkout)
|
|
19
|
+
<!-- AUTO-GENERATED-CLI-COMMANDS-START -->\n<!-- This content is automatically generated. Do not edit directly. -->\n### ph-cmd Commands\n\n- [Checkout](#checkout)
|
|
24
20
|
- [Init](#init)
|
|
25
21
|
- [Setup Globals](#setup-globals)
|
|
26
22
|
- [Update](#update)
|