-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser-Only: Run Theia without a backend #12852
Comments
so, this "backend-less/browser only" theia is to theia-desktop what github.dev or vscode.dev are to github.codespaces right? |
Yes that's a fair comparison when looking at the "github.dev web based editor". The clarification is needed as GitHub codespaces is also served via the github.dev domain. |
this blog about vscode-dev lists many more (practical) scenarios where the serverless application becomes indispensible my
|
@goyalyashpal For these use cases, it's probably still best to have a full Theia instance running (for example in the cloud). The backend-less Theia version has other use-cases. For example, we're currently working on #2842 which in conjunction with the backend-less Theia would allow users to join any workspace in the web without needing to setup a whole Theia server instance. |
Extremely valuable contribution 🚀 I do Theia based project from the beginning and must admit that security considerations around backend-less option give me a way better confidence. You have an option to control everything you want via dedicated service (the great way for virtualization of resources). P.S. Taking into account extensible design of the tool I would wish (as a user) to see browser-only version first (where the backend comes as an option) |
@sdirix Hi, found this while looking for a viable front end option for a desktop app I am planning to build. https://minimal--browseronly-theia.netlify.app/# is almost exactly what I want as a starting point. I will be really grateful if you could point me to the repository where the sources for this app can be found. (I am not looking to use electron for the desktop app itself; i just need the front end that theia provides) |
@jjkavalam It's the browser-only example app found in this repo. |
@msujew Sorry for not being clear enough. I want to extract that example out of the repo into an independent directory (basically integrate it into another project that I have). So I am doing:
This gives me:
Also, I understand that the How to generate them ? After generation can I just move the |
@jjkavalam Please take a look at our documentation on how to build your own app. In addition to the steps outlined there, you need to set the |
@msujew Thank you. I was able to make progress. Following the guide, i have a
However, am interested in a very minimal setup similar to https://minimal--browseronly-theia.netlify.app/. I wonder which packages i could safely remove without breaking anything else ? |
@jjkavalam You can likely get away just with |
Current state
File management
Features
theia test
for browser-only targetsTesting
Documentation
tl;dr;
We would like to enable a new use case for Theia applications: Support for "browser-only" Theia applications which can be executed without a backend.
Our vision is to support Theia "browser-only" applications as a first class citizen, next to the "browser" and "electron" targets. For this we adapted the Theia CLI tooling to support the new
browser-only
target andfrontendOnly
Theia extensions. Using this tooling the feature can be supported in a minimally invasive way, requiring none (or little to none) changes to existing Theia based applications.Check it out yourself
Because it's so easy to host static sites, we deployed three example applications for you to check out:
hello world
command implemented by a Theia pluginFile > Import repository
action. Note that this uses the open proxy cors.isomorphic-git.org so it's pretty slow. This proxy is freely available so please be considerate with its usage.Details
Click here for the original issue text including high level overview of the feature
Motivation
Support of browser-only use cases is a value adding feature for the whole Theia ecosystem. While the existing Theia framework offers large flexibility and therefore supports a wide array of use cases, it requires the deployment and execution of a Node based backend. This often comes with a lot of operational effort and additional costs.
There are many use cases in which not the full feature set of Theia based applications are required. For example, demo and quick start applications often come with hard coded examples anyway, do not require persistent storage and can work without terminal support.
This feature is requested from time to time in the community too:
Implementation
Theia's tooling already generates the frontend separately from the backend in the
lib/frontend
directory. So technically the frontend can already be served with any web server. However, the frontend will try to establish a web socket connection to its backend and many services will not work when their proxy counterparts are not available.Tooling changes
We added a new target for Theia applications:
browser-only
, e.gWe added a new entry for Theia extension modules:
frontendOnly
, e.g.For this target, the Theia CLI (
theia build
) will:src-gen
thefrontend
/frontendOnly
pairs are handled in the same way asbackend
/backendElectron
are, i.e. if both are present,frontend
will be skipped.Using these new tools we were able to replace, mock and/or remove all services which need to connect to the Theia backend.
theia start
is supported for browser-only targets too: It will launch the frontend with thewebpack-dev-server
.Implementation changes
Using the tooling described above we were able to support the new browser-only target almost without any changes to the existing code base. The current PR only contains two breaking changes: A rename of a class, and the move of some classes from the
node
directory to thecommon
directory. All other changes are only contained withinfrontendOnly
modules.The following subsections describe the most important features:
Filesystem
Since there is no native file system available in the browser, we settled on using BrowserFS, as it offers a Node compatible API, is feature rich and is well supported.
We foresee that every browser-only Theia application might want to handle the filesystem in a different way, for example to exclusively bundle some hard coded files, handling persistence via webworker cache, local storage, IndexedDB or only in memory. Therefore, we added a new service, the
BrowserFSInitialization
, that can be customized to support any behavior.In the PR, we used this service in the new "browser-only" example application to initialize the file system with some basic example JSON files.
WebSocketConnectionProvider
The
WebSocketConnectionProvider
of Theia is used to create proxy services for Theia's RPC mechanism.Via our proposed PR, we already support a minimal Theia without using any proxy services consisting of
@theia/core
,@theia/filesystem
,@theia/editor
,@theia/getting-started
,@theia/keymaps
,@theia/markers
,@theia/monaco
,@theia/navigator
,@theia/outline-view
,@theia/preferences
,@theia/property-view
,@theia/userstorage
,@theia/variable-resolver
and@theia/workspace
.To enable using all Theia packages, even if they still depend on
WebSocketConnectionProvider
, we rebindWebSocketConnectionProvider
to a mock implementation whose connections will always timeout. This allows using all Theia packages without further changes, even though the functionality will be broken wherever it relies on the backend, e.g. the file search will never complete.Eventually we would like to see all Theia packages supporting their full feature set (as far as possible) for the browser-only case as well. Once that is the case, we technically no longer need a mocked
WebSocketConnectionProvider
in the browser-only frontend, however it might make sense to still keep it for 3rd-party dependencies which are not adapted yet.Outlook
For performance reasons it could make sense to move some services to web workers to lessen the load on the main Javascript thread of the frontend. For this use case an alternative
ConnectionProvider
could be implemented which bridges the gap to the web worker instead of to the backend.Open Tasks
We think it already makes sense to merge this feature into the Theia code base via this PR. It's already possible to create specific feature-complete browser-only applications for certain use cases. The situation will only become better with more features being iteratively enabled over time. In communication with the community it must be made clear that a "browser-only" Theia can't support all use cases of a regular "browser" or "electron" Theia and that for now this feature shall be considered experimental.
We collected a non-exhaustive list of tasks which can be tackled as a follow up of the current PR.
File management
Features
theia test
for browser-only targetsDocumentation
Theia plugins and VS Code web extensions support
The largest missing piece is Theia plugins and VS Code web extensions support.
The good news is that we already have a POC showcasing that the support of Theia plugins and VS Code web extensions is conceptually feasible:
hello world
command implemented by a Theia pluginFile > Import repository
action. Note that this uses the open proxy cors.isomorphic-git.org so it's pretty slow. This proxy is freely available so please be considerate with its usage.Conceptually, Theia is well prepared to support Theia plugins and VS Code web extensions in the browser-only case, as these are already executed in the browser in a webworker.
However, it will require some substantial effort until plugin support will be ready for production in the browser-only case:
Even though there is no obstacle for eventually fully supporting Theia plugins and VS Code web extensions in the browser-only case, it will require some work.
Summary
With the support of browser-only applications we hope to open an exciting new chapter for the Theia framework. Please have a look at our PR and the hosted example applications and share your opinion below. Thank you!
The text was updated successfully, but these errors were encountered: