-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,626 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
extends: [ | ||
'../../configs/build.eslintrc.json' | ||
], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: 'tsconfig.json' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div align='center'> | ||
|
||
<br /> | ||
|
||
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' /> | ||
|
||
<h2>ECLIPSE THEIA - COLLABORATION EXTENSION</h2> | ||
|
||
<hr /> | ||
|
||
</div> | ||
|
||
## Description | ||
|
||
The `@theia/collaboration` extension features to enable collaboration between multiple peers using Theia. | ||
|
||
## Additional Information | ||
|
||
- [API documentation for `@theia/collaboration`](https://eclipse-theia.github.io/theia/docs/next/modules/collaboration.html) | ||
- [Theia - GitHub](https://github.com/eclipse-theia/theia) | ||
- [Theia - Website](https://theia-ide.org/) | ||
|
||
## License | ||
|
||
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/) | ||
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp) | ||
|
||
## Trademark | ||
"Theia" is a trademark of the Eclipse Foundation | ||
https://www.eclipse.org/theia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "@theia/collaboration", | ||
"version": "1.45.0", | ||
"description": "Theia - Collaboration Extension", | ||
"dependencies": { | ||
"@theia/core": "1.45.0", | ||
"@theia/editor": "1.45.0", | ||
"@theia/filesystem": "1.45.0", | ||
"@theia/monaco": "1.45.0", | ||
"@theia/monaco-editor-core": "1.72.3", | ||
"@theia/workspace": "1.45.0", | ||
"open-collaboration-protocol": "0.0.6", | ||
"open-collaboration-rpc": "0.0.5", | ||
"socket.io-client": "^4.5.3", | ||
"yjs": "^13.6.7" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"theiaExtensions": [ | ||
{ | ||
"frontend": "lib/browser/collaboration-frontend-module" | ||
} | ||
], | ||
"keywords": [ | ||
"theia-extension" | ||
], | ||
"license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/eclipse-theia/theia.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/eclipse-theia/theia/issues" | ||
}, | ||
"homepage": "https://github.com/eclipse-theia/theia", | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "theiaext build", | ||
"clean": "theiaext clean", | ||
"compile": "theiaext compile", | ||
"lint": "theiaext lint", | ||
"test": "theiaext test", | ||
"watch": "theiaext watch" | ||
}, | ||
"devDependencies": { | ||
"@theia/ext-scripts": "1.45.0" | ||
}, | ||
"nyc": { | ||
"extends": "../../configs/nyc.json" | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
packages/collaboration/src/browser/collaboration-color-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 TypeFox and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { injectable } from '@theia/core/shared/inversify'; | ||
|
||
export interface CollaborationColor { | ||
r: number; | ||
g: number; | ||
b: number; | ||
} | ||
|
||
export namespace CollaborationColor { | ||
export function fromString(code: string): CollaborationColor { | ||
if (code.startsWith('#')) { | ||
code = code.substring(1); | ||
} | ||
const r = parseInt(code.substring(0, 2), 16); | ||
const g = parseInt(code.substring(2, 4), 16); | ||
const b = parseInt(code.substring(4, 6), 16); | ||
return { r, g, b }; | ||
} | ||
|
||
export const Gold = fromString('#FFD700'); | ||
export const Tomato = fromString('#FF6347'); | ||
export const Aquamarine = fromString('#7FFFD4'); | ||
export const Beige = fromString('#F5F5DC'); | ||
export const Coral = fromString('#FF7F50'); | ||
export const DarkOrange = fromString('#FF8C00'); | ||
export const VioletRed = fromString('#C71585'); | ||
export const DodgerBlue = fromString('#1E90FF'); | ||
export const Chocolate = fromString('#D2691E'); | ||
export const LightGreen = fromString('#90EE90'); | ||
export const MediumOrchid = fromString('#BA55D3'); | ||
export const Orange = fromString('#FFA500'); | ||
} | ||
|
||
@injectable() | ||
export class CollaborationColorService { | ||
|
||
light = 'white'; | ||
dark = 'black'; | ||
|
||
getColors(): CollaborationColor[] { | ||
return [ | ||
CollaborationColor.Gold, | ||
CollaborationColor.Aquamarine, | ||
CollaborationColor.Tomato, | ||
CollaborationColor.MediumOrchid, | ||
CollaborationColor.LightGreen, | ||
CollaborationColor.Orange, | ||
CollaborationColor.Beige, | ||
CollaborationColor.Chocolate, | ||
CollaborationColor.VioletRed, | ||
CollaborationColor.Coral, | ||
CollaborationColor.DodgerBlue, | ||
CollaborationColor.DarkOrange | ||
]; | ||
} | ||
|
||
requiresDarkFont(color: CollaborationColor): boolean { | ||
return ((color.r * 0.299) + (color.g * 0.587) + (color.b * 0.114)) > 186; | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
packages/collaboration/src/browser/collaboration-file-system-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 TypeFox and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { Disposable, Emitter, Event, URI } from '@theia/core'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { | ||
FileChange, FileDeleteOptions, | ||
FileOverwriteOptions, FileSystemProviderCapabilities, FileType, Stat, WatchOptions, FileSystemProviderWithFileReadWriteCapability, FileWriteOptions | ||
} from '@theia/filesystem/lib/common/files'; | ||
import { ProtocolBroadcastConnection } from 'open-collaboration-protocol'; | ||
|
||
@injectable() | ||
export class CollaborationFileSystemProvider implements FileSystemProviderWithFileReadWriteCapability { | ||
|
||
static readonly SCHEME = 'collaboration'; | ||
|
||
capabilities = FileSystemProviderCapabilities.FileReadWrite; | ||
|
||
protected _readonly: boolean; | ||
|
||
get readonly(): boolean { | ||
return this._readonly; | ||
} | ||
|
||
set readonly(value: boolean) { | ||
if (this._readonly !== value) { | ||
this._readonly = value; | ||
if (value) { | ||
this.capabilities |= FileSystemProviderCapabilities.Readonly; | ||
} else { | ||
this.capabilities &= ~FileSystemProviderCapabilities.Readonly; | ||
} | ||
this.onDidChangeCapabilitiesEmitter.fire(); | ||
} | ||
} | ||
|
||
constructor(readonly connection: ProtocolBroadcastConnection) { | ||
} | ||
|
||
protected encoder = new TextEncoder(); | ||
protected decoder = new TextDecoder(); | ||
protected onDidChangeCapabilitiesEmitter = new Emitter<void>(); | ||
protected onDidChangeFileEmitter = new Emitter<readonly FileChange[]>(); | ||
protected onFileWatchErrorEmitter = new Emitter<void>(); | ||
|
||
get onDidChangeCapabilities(): Event<void> { | ||
return this.onDidChangeCapabilitiesEmitter.event; | ||
} | ||
get onDidChangeFile(): Event<readonly FileChange[]> { | ||
return this.onDidChangeFileEmitter.event; | ||
} | ||
get onFileWatchError(): Event<void> { | ||
return this.onFileWatchErrorEmitter.event; | ||
} | ||
async readFile(resource: URI): Promise<Uint8Array> { | ||
const stringValue = await this.connection.fs.readFile(this.getHostPath(resource)); | ||
return this.encoder.encode(stringValue); | ||
} | ||
async writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> { | ||
const stringValue = this.decoder.decode(content); | ||
await this.connection.fs.writeFile(this.getHostPath(resource), stringValue); | ||
} | ||
watch(resource: URI, opts: WatchOptions): Disposable { | ||
return Disposable.NULL; | ||
} | ||
stat(resource: URI): Promise<Stat> { | ||
return this.connection.fs.stat(this.getHostPath(resource)); | ||
} | ||
mkdir(resource: URI): Promise<void> { | ||
return this.connection.fs.mkdir(this.getHostPath(resource)); | ||
} | ||
async readdir(resource: URI): Promise<[string, FileType][]> { | ||
const record = await this.connection.fs.readdir(this.getHostPath(resource)); | ||
return Object.entries(record); | ||
} | ||
delete(resource: URI, opts: FileDeleteOptions): Promise<void> { | ||
return this.connection.fs.delete(this.getHostPath(resource)); | ||
} | ||
rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { | ||
return this.connection.fs.rename(this.getHostPath(from), this.getHostPath(to)); | ||
} | ||
|
||
protected getHostPath(uri: URI): string { | ||
const path = uri.path.toString().substring(1).split('/'); | ||
return path.slice(1).join('/'); | ||
} | ||
|
||
triggerEvent(changes: FileChange[]): void { | ||
this.onDidChangeFileEmitter.fire(changes); | ||
} | ||
|
||
} |
Oops, something went wrong.