-
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.
Support 'browser-only' Theia (#12853)
Adds tooling, adapts the current code base and provides an example application for the new 'browser-only' Theia application target. This target generates a Theia frontend application which can run without a backend, transforming the Theia application to a static site. Adapts tooling to: - support new 'browser-only' application target - support new 'frontendOnly' and 'frontendOnlyPreload' module declarations - use http-server when starting 'browser-only' applications Replaces backend services with browser-only variants - implementation of BrowserFS-based filesystem - implementation of 'ServiceConnectionProvider' which timeouts for all requests, enabling loading all Theia packages Adds a browser-only example application and api-samples showcasing the customization of the new BrowserFS-based filesystem. Co-authored-by: Remi Schnekenburger <[email protected]> Co-authored-by: Alexandra Buzila <[email protected]> Co-authored-by: Tobias Ortmayr <[email protected]> Co-authored-by: Eugen Neufeld <[email protected]>
- Loading branch information
1 parent
a6d7e9b
commit 6f01be5
Showing
71 changed files
with
1,602 additions
and
63 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
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
27 changes: 27 additions & 0 deletions
27
examples/api-samples/src/browser-only/api-samples-frontend-only-module.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,27 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 EclipseSource 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 { ContainerModule, interfaces } from '@theia/core/shared/inversify'; | ||
import { bindBrowserFSInitialization } from './filesystem/example-filesystem-initialization'; | ||
|
||
export default new ContainerModule(( | ||
bind: interfaces.Bind, | ||
_unbind: interfaces.Unbind, | ||
_isBound: interfaces.IsBound, | ||
rebind: interfaces.Rebind, | ||
) => { | ||
bindBrowserFSInitialization(bind, rebind); | ||
}); |
51 changes: 51 additions & 0 deletions
51
examples/api-samples/src/browser-only/filesystem/example-filesystem-initialization.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,51 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 EclipseSource 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 { URI } from '@theia/core'; | ||
import { inject, injectable, interfaces } from '@theia/core/shared/inversify'; | ||
import { EncodingService } from '@theia/core/lib/common/encoding-service'; | ||
import { BrowserFSInitialization, DefaultBrowserFSInitialization } from '@theia/filesystem/lib/browser-only/browserfs-filesystem-initialization'; | ||
import { BrowserFSFileSystemProvider } from '@theia/filesystem/lib/browser-only/browserfs-filesystem-provider'; | ||
import type { FSModule } from 'browserfs/dist/node/core/FS'; | ||
|
||
@injectable() | ||
export class ExampleBrowserFSInitialization extends DefaultBrowserFSInitialization { | ||
|
||
@inject(EncodingService) | ||
protected encodingService: EncodingService; | ||
|
||
override async initializeFS(fs: FSModule, provider: BrowserFSFileSystemProvider): Promise<void> { | ||
try { | ||
if (!fs.existsSync('/home/workspace')) { | ||
await provider.mkdir(new URI('/home/workspace')); | ||
await provider.writeFile(new URI('/home/workspace/my-file.txt'), this.encodingService.encode('foo').buffer, { create: true, overwrite: false }); | ||
await provider.writeFile(new URI('/home/workspace/my-file2.txt'), this.encodingService.encode('bar').buffer, { create: true, overwrite: false }); | ||
} | ||
if (!fs.existsSync('/home/workspace2')) { | ||
await provider.mkdir(new URI('/home/workspace2')); | ||
await provider.writeFile(new URI('/home/workspace2/my-file.json'), this.encodingService.encode('{ foo: true }').buffer, { create: true, overwrite: false }); | ||
await provider.writeFile(new URI('/home/workspace2/my-file2.json'), this.encodingService.encode('{ bar: false }').buffer, { create: true, overwrite: false }); | ||
} | ||
} catch (e) { | ||
console.error('An error occurred while initializing the demo workspaces', e); | ||
} | ||
} | ||
} | ||
|
||
export const bindBrowserFSInitialization = (bind: interfaces.Bind, rebind: interfaces.Rebind): void => { | ||
bind(ExampleBrowserFSInitialization).toSelf(); | ||
rebind(BrowserFSInitialization).toService(ExampleBrowserFSInitialization); | ||
}; |
Oops, something went wrong.