Skip to content

Commit 586d984

Browse files
even more refactor
1 parent b381d49 commit 586d984

File tree

19 files changed

+582
-575
lines changed

19 files changed

+582
-575
lines changed

packages/app/src/app/components/CodeEditor/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ export class CodeEditor extends React.PureComponent<
3535
const { isModuleSynced, sandbox, currentModule: module, settings } = props;
3636

3737
const template = getDefinition(sandbox.template);
38-
const modulePath = getModulePath(
39-
sandbox.modules,
40-
sandbox.directories,
41-
module.id
42-
);
38+
const modulePath = module.path;
4339
const config = template.configurationFiles[modulePath];
4440

4541
return (

packages/app/src/app/overmind/effects/vscode/ModelsHandler.ts

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -77,52 +77,13 @@ export class ModelsHandler {
7777
}
7878

7979
public changeModule = (module: Module) => {
80-
const { sandbox } = this;
81-
82-
const path = getModulePath(sandbox.modules, sandbox.directories, module.id);
83-
84-
if (path && getCurrentModelPath(this.editorApi) !== path) {
85-
return this.editorApi.openFile(path);
80+
if (getCurrentModelPath(this.editorApi) !== module.path) {
81+
return this.editorApi.openFile(module.path);
8682
}
8783

8884
return Promise.resolve();
8985
};
9086

91-
public updateModules = () =>
92-
Promise.all(
93-
Object.keys(this.modelListeners).map(path => {
94-
const shortid = this.modelListeners[path].moduleShortid;
95-
const { model } = this.modelListeners[path];
96-
const module = this.sandbox.modules.find(m => m.shortid === shortid);
97-
if (!module) {
98-
// Deleted
99-
return Promise.resolve();
100-
}
101-
102-
const modulePath = getVSCodePath(this.sandbox, module.id);
103-
104-
if (modulePath !== model.uri.path) {
105-
return this.editorApi.textFileService
106-
.move(model.uri, this.monaco.Uri.file(modulePath))
107-
.then(() => {
108-
const editor = this.editorApi.getActiveCodeEditor();
109-
const currentModel = editor && editor.getModel();
110-
const isCurrentFile =
111-
currentModel && currentModel.uri.path === path;
112-
if (isCurrentFile) {
113-
return this.editorApi.openFile(
114-
modulePath.replace('/sandbox', '')
115-
);
116-
}
117-
118-
return Promise.resolve();
119-
});
120-
}
121-
122-
return Promise.resolve();
123-
})
124-
);
125-
12687
public applyOperations(operations: { [moduleShortid: string]: any }) {
12788
const operationsJSON = operations.toJSON ? operations.toJSON() : operations;
12889

@@ -138,15 +99,7 @@ export class ModelsHandler {
13899
return Promise.resolve();
139100
}
140101

141-
const moduleId = foundModule.id;
142-
143-
const modulePath =
144-
'/sandbox' +
145-
getModulePath(
146-
this.sandbox.modules,
147-
this.sandbox.directories,
148-
moduleId
149-
);
102+
const modulePath = '/sandbox' + foundModule.path;
150103

151104
const modelEditor = this.editorApi.editorService.editors.find(
152105
editor => editor.resource && editor.resource.path === modulePath

packages/app/src/app/overmind/effects/vscode/extensionHostWorker/common/fs.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { writeFile, rename, rmdir, unlink, mkdir } from '../../fs/utils';
1+
import {
2+
writeFile,
3+
rename,
4+
rmdir,
5+
unlink,
6+
mkdir,
7+
} from '../../sandboxFsSync/utils';
28
import { FileSystemConfiguration } from '../../../../../../../../../standalone-packages/codesandbox-browserfs';
39
import { getTypeFetcher } from './type-downloader';
410
import { EXTENSIONS_LOCATION } from '../../constants';
@@ -87,17 +93,15 @@ export async function initializeBrowserFS({
8793
case 'sandbox-fs': {
8894
currentSandboxFs = evt.data.$data;
8995

90-
console.log('HEEEEEY', currentSandboxFs);
91-
9296
if (!resolved) {
9397
resolve();
9498
resolved = true;
9599
}
96100
break;
97101
}
98102
case 'writeFile': {
99-
const { path, module } = evt.data.$data;
100-
writeFile(currentSandboxFs, path, module);
103+
const module = evt.data.$data;
104+
writeFile(currentSandboxFs, module);
101105
break;
102106
}
103107
case 'rename': {
@@ -106,18 +110,18 @@ export async function initializeBrowserFS({
106110
break;
107111
}
108112
case 'rmdir': {
109-
const { removePath } = evt.data.$data;
110-
rmdir(currentSandboxFs, removePath);
113+
const directory = evt.data.$data;
114+
rmdir(currentSandboxFs, directory);
111115
break;
112116
}
113117
case 'unlink': {
114-
const { removePath } = evt.data.$data;
115-
unlink(currentSandboxFs, removePath);
118+
const module = evt.data.$data;
119+
unlink(currentSandboxFs, module);
116120
break;
117121
}
118122
case 'mkdir': {
119-
const { path, directory } = evt.data.$data;
120-
mkdir(currentSandboxFs, path, directory);
123+
const directory = evt.data.$data;
124+
mkdir(currentSandboxFs, directory);
121125
break;
122126
}
123127
}

packages/app/src/app/overmind/effects/vscode/extensionHostWorker/workers/ext-host-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ self.addEventListener('message', async e => {
4242
process.env = data.data.env || {};
4343
process.env.HOME = '/home';
4444

45-
loader(true)(() => {
45+
loader()(() => {
4646
ctx.require(
4747
['vs/workbench/services/extensions/node/extensionHostProcess'],
4848
() => {

0 commit comments

Comments
 (0)