Skip to content
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

Switch from browserfs to OPFS #14263

Merged
merged 16 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)


<!-- ## 1.56.0 - not yet released -->
<a name="breaking_changes_1.56.0">[Breaking Changes:](#breaking_changes_1.56.0)</a>
- [core] Do not dispose dialogs on close - [#14456](https://github.com/eclipse-theia/theia/pull/14456) - Contributed on behalf of STMicroelectronics
- [core] fixed electron win background color [#14491](https://github.com/eclipse-theia/theia/pull/14491) - Contributed on behalf of STMicroelectronics
- [plugin] added stubs for the additional LanguageModel APIs [#14446](https://github.com/eclipse-theia/theia/pull/14446) - Contributed on behalf of STMicroelectronics
- [plugin] added support for ThemeColor property id [#14437](https://github.com/eclipse-theia/theia/pull/14437) - Contributed on behalf of STMicroelectronics
- [plugin] supported MappedEditProviders proposed API evolution [#14453](https://github.com/eclipse-theia/theia/pull/14453) - Contributed on behalf of STMicroelectronics
- [browser-only] remove browserfs dependency (replaced by OPFS) [#14263](https://github.com/eclipse-theia/theia/pull/14263)

## 1.55.0 - 10/31/2024

Expand Down
3 changes: 2 additions & 1 deletion configs/base.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lib": [
"ES2019",
"ES2020.Promise",
"DOM"
"DOM",
"DOM.AsyncIterable"
],
"sourceMap": true
}
Expand Down
9 changes: 8 additions & 1 deletion configs/build.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"extends": [
"./base.eslintrc.json",
"./errors.eslintrc.json"
]
],
"parserOptions": {
"lib": [
"ES2019",
"ES2020.Promise",
"DOM"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
// *****************************************************************************

import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
import { bindBrowserFSInitialization } from './filesystem/example-filesystem-initialization';
import { bindOPFSInitialization } from './filesystem/example-filesystem-initialization';

export default new ContainerModule((
bind: interfaces.Bind,
_unbind: interfaces.Unbind,
_isBound: interfaces.IsBound,
rebind: interfaces.Rebind,
) => {
bindBrowserFSInitialization(bind, rebind);
bindOPFSInitialization(bind, rebind);
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,34 @@
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';
import { OPFSInitialization, DefaultOPFSInitialization } from '@theia/filesystem/lib/browser-only/opfs-filesystem-initialization';
import { OPFSFileSystemProvider } from '@theia/filesystem/lib/browser-only/opfs-filesystem-provider';

@injectable()
export class ExampleBrowserFSInitialization extends DefaultBrowserFSInitialization {
export class ExampleOPFSInitialization extends DefaultOPFSInitialization {

@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);
override async initializeFS(provider: OPFSFileSystemProvider): Promise<void> {
// Check whether the directory exists
if (await provider.exists(new URI('/home/workspace'))) {
await provider.readdir(new URI('/home/workspace'));
} else {
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 });
}

if (await provider.exists(new URI('/home/workspace2'))) {
await provider.readdir(new URI('/home/workspace2'));
} else {
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 });
}
}
}

export const bindBrowserFSInitialization = (bind: interfaces.Bind, rebind: interfaces.Rebind): void => {
bind(ExampleBrowserFSInitialization).toSelf();
rebind(BrowserFSInitialization).toService(ExampleBrowserFSInitialization);
export const bindOPFSInitialization = (bind: interfaces.Bind, rebind: interfaces.Rebind): void => {
bind(ExampleOPFSInitialization).toSelf();
rebind(OPFSInitialization).toService(ExampleOPFSInitialization);
};
1 change: 0 additions & 1 deletion packages/filesystem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"@types/tar-fs": "^1.16.1",
"async-mutex": "^0.3.1",
"body-parser": "^1.18.3",
"browserfs": "^1.4.3",
robertjndw marked this conversation as resolved.
Show resolved Hide resolved
"http-status-codes": "^1.3.0",
"minimatch": "^5.1.0",
"multer": "1.4.4-lts.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

import { ContainerModule } from '@theia/core/shared/inversify';
import { FileSystemProvider } from '../common/files';
import { BrowserFSFileSystemProvider } from './browserfs-filesystem-provider';
import { OPFSFileSystemProvider } from './opfs-filesystem-provider';
import { RemoteFileSystemProvider, RemoteFileSystemServer } from '../common/remote-file-system-provider';
import { BrowserFSInitialization, DefaultBrowserFSInitialization } from './browserfs-filesystem-initialization';
import { OPFSInitialization, DefaultOPFSInitialization } from './opfs-filesystem-initialization';
import { BrowserOnlyFileSystemProviderServer } from './browser-only-filesystem-provider-server';

export default new ContainerModule((bind, _unbind, isBound, rebind) => {
bind(DefaultBrowserFSInitialization).toSelf();
bind(BrowserFSFileSystemProvider).toSelf();
bind(BrowserFSInitialization).toService(DefaultBrowserFSInitialization);
bind(DefaultOPFSInitialization).toSelf();
bind(OPFSFileSystemProvider).toSelf();
bind(OPFSInitialization).toService(DefaultOPFSInitialization);
if (isBound(FileSystemProvider)) {
rebind(FileSystemProvider).to(BrowserFSFileSystemProvider).inSingletonScope();
rebind(FileSystemProvider).to(OPFSFileSystemProvider).inSingletonScope();
} else {
bind(FileSystemProvider).to(BrowserFSFileSystemProvider).inSingletonScope();
bind(FileSystemProvider).to(OPFSFileSystemProvider).inSingletonScope();
}
if (isBound(RemoteFileSystemProvider)) {
rebind(RemoteFileSystemServer).to(BrowserOnlyFileSystemProviderServer).inSingletonScope();
Expand Down

This file was deleted.

Loading
Loading