Skip to content

Commit 781fd57

Browse files
authored
reorganize / readme (#327)
* reorganize / readme * no guest sign in when not necessary * clean logs, switch to esm.sh
1 parent add86c1 commit 781fd57

37 files changed

+148
-1131
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ jobs:
4646
${{ runner.os }}-
4747
4848
- name: Set correct access for docker containers (server/test/data)
49-
run: chmod -R a+rw test-server/data
49+
run: chmod -R a+rw test-util/server/data
5050

5151
- name: Build the docker-compose stack
52-
run: docker-compose -f test-server/docker-compose.yml up -d
52+
run: docker-compose -f test-util/server/docker-compose.yml up -d
5353

5454
- name: Check running containers
5555
run: docker ps -a
@@ -60,8 +60,8 @@ jobs:
6060
- name: NPM CI
6161
run: npm ci
6262

63-
- name: Bootstrap packages
64-
run: npm run bootstrap
63+
# - name: Bootstrap packages
64+
# run: npm run bootstrap
6565

6666
- name: Wait for Matrix
6767
run: npx wait-on http://localhost:8888/_matrix/static/

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"editor.defaultFormatter": "esbenp.prettier-vscode"
88
},
99
"search.exclude": {
10-
"packages/editor/public/types": true
10+
"packages/editor/public/types": true,
11+
"**/coverage": true,
12+
"**/dist": true
1113
},
1214
"vitest.exclude": [
1315
"**/node_modules/**",

CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Development
2+
3+
We use [Lerna](https://lerna.js.org/) to manage the monorepo with separate packages. In VS Code, it's best to open `typecell.code-workspace` to open the project as a workspace.
4+
5+
## Running
6+
7+
Node.js is required to run this project. To download Node.js, visit [nodejs.org](https://nodejs.org/en/).
8+
9+
To run the project, open the command line in the project's root directory and enter the following commands:
10+
11+
# Install all required npm modules for lerna, and bootstrap lerna packages
12+
npm install
13+
14+
# Initial build of all packages required by the main editor project
15+
npm run build
16+
17+
# Start the main editor project
18+
npm start
19+
20+
## Watch changes
21+
22+
npm run watch
23+
24+
The above `npm start` executes the `vite dev` command of `packages/editor` and watches for changes to this main package. However, you might also be making changes to other packages in the `packages` directory. To continuously watch and compile for changes, open a new terminal and run `npm run watch`.

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
![TypeCell Logo](./packages/editor/src/assets/logo_with_text.svg?raw=true)
1+
<p align="center">
2+
<a href="https://www.typecell.org">
3+
<img alt="TypeCell" src="./packages/editor/src/assets/logo_with_text.svg?raw=true" width="300" />
4+
</a>
5+
</p>
26

3-
Welcome to TypeCell! Let's reimagine how we can make it easier to understand, build and share knowledge.
7+
<p align="center">
8+
Welcome to TypeCell! An open source live programming environment. Together, we want to make it a lot easier to build software, and ultimately to understand, build and share knowledge.
9+
</p>
410

5-
# Development
11+
<p align="center">
12+
<a href="https://discord.gg/aDQxXezfNj"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a> <a href="https://matrix.to/#/#typecell-space:matrix.org"><img alt="Matrix" src="https://img.shields.io/badge/Chat on matrix%20-%23000.svg?&style=for-the-badge&logo=matrix&logoColor=white"/></a>
13+
</p>
614

7-
We use [Lerna](https://lerna.js.org/) to manage the monorepo with separate packages. In VS Code, it's best to open `typecell.code-workspace` to open the project as a workspace.
15+
## Contributing 🙌
816

9-
## Running
17+
See [CONTRIBUTING.md](CONTRIBUTING.md).
1018

11-
Node.js is required to run this project. To download Node.js, visit [nodejs.org](https://nodejs.org/en/).
19+
TypeCell is organised as a monorepo containing several packages. Directory structure:
1220

13-
To run the project, open the command line in the project's root directory and enter the following commands:
21+
```
22+
blocknote
23+
├── docs - Docs / samples (see https://www.typecell.org/docs/)
24+
├── packages
25+
│ ├── common - Utility functions shared across the codebase
26+
│ ├── editor - The main React application
27+
│ ├── engine - The live-code execution engine
28+
│ ├── packager - Tool to bundle TypeCell notebook apps (WIP)
29+
│ └── parsers - Helpers to convert to / from TypeCell notebooks
30+
├── patches - patch-package patches
31+
└── test-util - Server and data for unit tests
32+
```
1433

15-
# Install all required npm modules for lerna, and bootstrap lerna packages
16-
npm run install-lerna
17-
npm run bootstrap --force
34+
The codebase is automatically tested using Vitest and Playwright.
1835

19-
# Initial build of all packages required by the main editor project
20-
npm run build
36+
# Credits ❤️
2137

22-
# Start the editor project
23-
npm start
38+
TypeCell is proudly sponsored by the renowned [NLNet foundation](https://nlnet.nl/foundation/) who are on a mission to support an open internet, and protect the privacy and security of internet users. Check them out!
2439

25-
26-
## Watch changes
27-
28-
npm run watch
29-
30-
The above `npm start` executes the `react-scripts start` command of `packages/editor` and watches for changes to this main package. However, you might also be making changes to other packages in the `packages` directory. To continuously watch and compile for changes, open a new terminal and run `npm run watch`.
31-
32-
## Updating packages
33-
34-
If you've pulled changes from git that add new or update existing dependencies, use `npm run bootstrap` instead of `npm install` to install updated dependencies!
35-
36-
## Adding packages
37-
38-
- Add the dependency to the relevant `package.json` file (packages/xxx/packages.json)
39-
- run `npm run install-new-packages`
40-
- Double check `package-lock.json` to make sure only the relevant packages have been affected
40+
<a href="https://nlnet.nl"><img src="https://nlnet.nl/image/logos/NGIAssure_tag.svg" alt="NLNet" width="100"></a>

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4+
"license": "AGPL",
45
"devDependencies": {
56
"lerna": "^5.0.0",
67
"playwright": "^1.18.1",
@@ -12,11 +13,8 @@
1213
"packages/*"
1314
],
1415
"scripts": {
15-
"--postinstall": "npm run bootstrap",
1616
"patch-package": "patch-package",
1717
"postinstall": "patch-package",
18-
"bootstrap": "lerna bootstrap --ci -- --force",
19-
"install-new-packages": "lerna bootstrap -- --force",
2018
"playwright:dev": "lerna run playwright:dev --stream",
2119
"playwright:preview": "lerna run playwright:preview --stream",
2220
"install-playwright": "npx playwright install --with-deps",

packages/editor/.vscode/settings.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/editor/src/app/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export const App = observer((props: { config: ValidatedServerConfig }) => {
1515
const { sessionStore } = getStoreService();
1616
if (sessionStore.user === "loading") {
1717
return <div>Loading</div>;
18-
} else if (sessionStore.user === "offlineNoUser") {
19-
return <div>Offline</div>;
18+
// } else if (sessionStore.user === "offlineNoUser") {
19+
// return <div>Offline</div>;
2020
} else {
2121
return (
2222
<BrowserRouter>

packages/editor/src/app/main/components/NotebookOverview.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ export const NotebookOverview = observer(function (
7272

7373
const sessionStore = getStoreService().sessionStore;
7474

75-
if (
76-
sessionStore.user === "loading" ||
77-
sessionStore.user === "offlineNoUser"
78-
) {
79-
return <div>Not logged in</div>;
80-
}
81-
82-
// const user = sessionStore.user;
83-
const matrixClient = sessionStore.user.matrixClient;
84-
8575
useEffect(() => {
8676
// async function resolveRoom(roomId: string): Promise<Room | undefined> {
8777
// const result = await matrixClient.http.authedRequest(
@@ -99,6 +89,10 @@ export const NotebookOverview = observer(function (
9989
try {
10090
setLoading(true);
10191

92+
if (typeof sessionStore.user === "string") {
93+
sessionStore.enableGuest();
94+
return;
95+
}
10296
// A user's own rooms
10397
// const result = await matrixClient.getJoinedRooms();
10498

@@ -108,6 +102,8 @@ export const NotebookOverview = observer(function (
108102
// const resolvedRooms = await (await Promise.all<Room | undefined>(promises)).filter(r => r).map(r => r as Room);
109103

110104
// Currently we limit search to Public rooms by this user
105+
const matrixClient = sessionStore.user.matrixClient;
106+
111107
const result = await matrixClient.http.authedRequest<any>(
112108
undefined as any,
113109
Method.Post,
@@ -138,7 +134,7 @@ export const NotebookOverview = observer(function (
138134
}
139135

140136
fetchNotebooks();
141-
}, [matrixClient, props.owner]);
137+
}, [sessionStore, sessionStore.user, props.owner]);
142138

143139
const notebookList = rooms ? (
144140
<>
@@ -152,6 +148,13 @@ export const NotebookOverview = observer(function (
152148
[]
153149
);
154150

151+
if (
152+
sessionStore.user === "loading" ||
153+
sessionStore.user === "offlineNoUser"
154+
) {
155+
return <div>Loading...</div>;
156+
}
157+
155158
return (
156159
<div>
157160
{/* <div className="header">{props.owner}'s notebooks</div> */}

packages/editor/src/app/matrix-auth/MatrixAuthStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class MatrixAuthStore extends lifecycle.Disposable {
6464
this._onLoggedInChanged.event;
6565

6666
// based on https://github.com/matrix-org/matrix-react-sdk/blob/96e16940bb9d30fbbbb1133fae796c1021e871f3/src/components/structures/MatrixChat.tsx#L350
67-
public async initialize() {
67+
public async initialize(enableGuest: boolean) {
6868
const params = decodeParams(window.location.search.substring(1));
6969
const loggedIn = await this.attemptTokenLogin(
7070
params as any,
@@ -89,7 +89,7 @@ export class MatrixAuthStore extends lifecycle.Disposable {
8989
return true;
9090
} else {
9191
return await this.loadSession({
92-
enableGuest: true,
92+
enableGuest,
9393
defaultDeviceDisplayName: MATRIX_CONFIG.defaultDeviceDisplayName,
9494
guestHsUrl: MATRIX_CONFIG.hsUrl,
9595
guestIsUrl: MATRIX_CONFIG.isUrl,

packages/editor/src/runtime/executor/executionHosts/sandboxed/OutputShadow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const OutputShadow = observer(
3535
x -= parentBB.x;
3636
runInAction(() => {
3737
if (props.positions.x !== x || props.positions.y !== y) {
38-
console.log("update pos", y, props.positions.y);
38+
// console.log("update pos", y, props.positions.y);
3939
props.positions.x = x;
4040
props.positions.y = y;
4141
}

0 commit comments

Comments
 (0)