Skip to content

Commit 6f4d6e2

Browse files
TheMythologistsalmonkarpRichDom2185
authored
Sessions overhaul (#30)
* Fix sessions remote presence * Add selectionManager * Improve documentation on developing * deps: upgrade sharedb package * deps: upgrade dependencies * dev: convert to typescript * Remove unnecessary submodule * Add AceRadarView * deps: use modern websocket implementation * Store connected users in binding class * Push role to types * Fix: Duplicated user during reconnect * Implement changing of language * Revert "Fix: Duplicated user during reconnect" This reverts commit 758b978. * Initialise own id in `connectedUsers` * Only allow owners to change language * Implement changing of roles * Use tsup * Update tsconfig * Use TS types * Migrate README to markdown --------- Co-authored-by: salmonkarp <[email protected]> Co-authored-by: Richard Dominick <[email protected]>
1 parent 905a6e0 commit 6f4d6e2

14 files changed

+2322
-3068
lines changed

.babelrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Sharedb-ace
2+
3+
![NPM Badge](https://badge.fury.io/js/@sourceacademy%2Fsharedb-ace.svg)
4+
5+
This is a fork of the [original sharedb-ace repository](https://github.com/jethrokuan/sharedb-ace).
6+
7+
Sharedb-ace provides two-way bindings between [ShareDB](https://github.com/share/sharedb) and [Ace Editor](http://ace.c9.io/).
8+
9+
## Installation
10+
11+
Using npm:
12+
13+
```bash
14+
npm install @sourceacademy/sharedb-ace
15+
```
16+
17+
Using pre-compiled js from unpkg CDN:
18+
19+
```html
20+
<script src="https://unpkg.com/sharedb-ace@latest/dist/sharedb-ace.min.js"></script>
21+
```
22+
23+
## Documentation
24+
25+
### Single Ace-editor Instance
26+
27+
Setup the ShareDB document as a string:
28+
29+
```javascript
30+
ShareAce.on('ready', function() {
31+
ShareAce.add(editor, [], [ Plugins, Here ]);
32+
});
33+
```
34+
35+
### Multiple Ace-editor Instances
36+
37+
Your setup may be more complex, and requires the use of multiple ace-instances synchronized over one connection. Setup the ShareDB document to be a JSON object.
38+
39+
For example:
40+
41+
```javascript
42+
{
43+
"foo": "",
44+
"bar": ""
45+
}
46+
```
47+
48+
Next, connect the two paths to two separate ace editor instances:
49+
50+
```javascript
51+
ShareAce.on('ready', function() {
52+
ShareAce.add(editor1, ["foo"], []);
53+
ShareAce.add(editor2, ["bar"], []);
54+
});
55+
```
56+
57+
## Developing sharedb-ace
58+
59+
1. Fork or clone this repo:
60+
61+
```bash
62+
git clone https://github.com/jethrokuan/sharedb-ace.git
63+
```
64+
65+
```bash
66+
cd sharedb-ace && yarn install
67+
```
68+
69+
To test the package locally, run the following on this sharedb-ace repository:
70+
71+
```bash
72+
yarn build
73+
yarn link
74+
```
75+
76+
Then, run the following on the frontend repository:
77+
78+
```bash
79+
yarn link @sourceacademy/sharedb-ace
80+
```
81+
82+
Now, whenever you want to update the ShareDB Ace binding, simply run `yarn build`.
83+
84+
### Generating JS Docs
85+
86+
We generate javascript documentation using inline documentation.
87+
88+
```bash
89+
jsdoc source/*.js --destination ./docs/
90+
```
91+
92+
### License
93+
94+
> Copyright 2019 Jethro Kuan
95+
>
96+
> Permission is hereby granted, free of charge, to any person obtaining
97+
> a copy of this software and associated documentation files (the
98+
> "Software"), to deal in the Software without restriction, including
99+
> without limitation the rights to use, copy, modify, merge, publish,
100+
> distribute, sublicense, and/or sell copies of the Software, and to
101+
> permit persons to whom the Software is furnished to do so, subject to
102+
> the following conditions:
103+
>
104+
> The above copyright notice and this permission notice shall be
105+
> included in all copies or substantial portions of the Software.
106+
>
107+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
108+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
109+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
110+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
111+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
112+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
113+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.org

Lines changed: 0 additions & 75 deletions
This file was deleted.

ace

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

package.json

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,59 @@
11
{
22
"name": "@sourceacademy/sharedb-ace",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "ShareDB integration with Ace Editor",
5-
"main": "./distribution/sharedb-ace.js",
5+
"main": "dist/sharedb-ace.js",
6+
"module": "dist/sharedb-ace.mjs",
7+
"types": "dist/sharedb-ace.d.ts",
8+
"exports": {
9+
".": {
10+
"import": "./dist/sharedb-ace.js",
11+
"types": "./dist/sharedb-ace.d.ts"
12+
},
13+
"./binding": {
14+
"import": "./dist/sharedb-ace-binding.js",
15+
"types": "./dist/sharedb-ace-binding.d.ts"
16+
},
17+
"./types": {
18+
"import": "./dist/types.js",
19+
"types": "./dist/types.d.ts"
20+
}
21+
},
622
"repository": "https://github.com/source-academy/sharedb-ace",
723
"author": "Jethro Kuan",
824
"files": [
9-
"dist",
10-
"distribution"
25+
"dist"
1126
],
1227
"license": "MIT",
1328
"scripts": {
14-
"build": "yarn run build:yarn && yarn run build:dist",
15-
"build:yarn": "babel source --out-dir distribution --presets=@babel/preset-env",
16-
"build:dist": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack",
29+
"build": "tsup",
1730
"test": "echo 'doing nothing'",
1831
"docs": "jsdoc source/*.js -d ./docs/"
1932
},
33+
"dependencies": {
34+
"@convergencelabs/ace-collab-ext": "^0.6.0",
35+
"event-emitter-es6": "^1.1.5",
36+
"logdown": "^3.3.1",
37+
"partysocket": "^1.0.3",
38+
"sharedb": "^5.1.1"
39+
},
2040
"devDependencies": {
21-
"@babel/cli": "^7.10.5",
22-
"@babel/core": "^7.11.1",
23-
"@babel/preset-env": "^7.11.0",
41+
"@types/event-emitter-es6": "^1.1.4",
42+
"@types/sharedb": "^5.1.0",
43+
"ace-builds": "^1.38.0",
2444
"amd-loader": "^0.0.8",
25-
"assert": "^2.0.0",
45+
"assert": "^2.1.0",
2646
"babel-loader": "^8.1.0",
2747
"chai": "^4.2.0",
2848
"chai-as-promised": "^7.1.1",
2949
"chai-json-equal": "^0.0.1",
30-
"cross-env": "^7.0.3",
3150
"eslint": "^7.6.0",
3251
"jsdom": "^16.3.0",
3352
"mocha": "^8.1.1",
34-
"webpack": "^5.90.3",
35-
"webpack-cli": "^5.1.4"
53+
"react-ace": "^14.0.1",
54+
"tsc": "^2.0.4",
55+
"tsup": "^8.4.0",
56+
"typescript": "^5.7.3"
3657
},
37-
"dependencies": {
38-
"event-emitter-es6": "^1.1.5",
39-
"logdown": "^3.3.1",
40-
"reconnecting-websocket": "^4.4.0",
41-
"sharedb": "^1.4.1"
42-
}
58+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
4359
}

0 commit comments

Comments
 (0)