Skip to content

Commit 8b891c4

Browse files
running step 2 of refactor
1 parent a00cddf commit 8b891c4

File tree

15 files changed

+696
-220
lines changed

15 files changed

+696
-220
lines changed

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@
150150
"normalizr": "^3.2.3",
151151
"onigasm": "^2.2.1",
152152
"ot": "^0.0.15",
153-
"overmind": "^19.3.0-1569928101550",
153+
"overmind": "^20.0.0-1570104917847",
154154
"overmind-devtools": "^19.0.0",
155-
"overmind-react": "^20.3.0-1569928101550",
155+
"overmind-react": "^21.0.0-1570104917847",
156156
"phoenix": "^1.3.0",
157157
"postcss": "^6.0.9",
158158
"postcss-selector-parser": "^2.2.3",

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

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
1-
import React from 'react';
2-
import { render } from 'react-dom';
3-
import { ThemeProvider } from 'styled-components';
4-
import { TextOperation } from 'ot';
5-
import { debounce } from 'lodash-es';
1+
import DEFAULT_PRETTIER_CONFIG from '@codesandbox/common/lib/prettify-default-config';
62
import {
73
getModulePath,
84
resolveModule,
95
} from '@codesandbox/common/lib/sandbox/modules';
10-
import { listen, actions, dispatch } from 'codesandbox-api';
11-
12-
import prettify from 'app/src/app/utils/prettify';
13-
import DEFAULT_PRETTIER_CONFIG from '@codesandbox/common/lib/prettify-default-config';
14-
import getUI from '@codesandbox/common/lib/templates/configuration/ui';
15-
166
import getTemplate from '@codesandbox/common/lib/templates';
7+
import getUI from '@codesandbox/common/lib/templates/configuration/ui';
178
import theme from '@codesandbox/common/lib/theme';
189
import {
1910
Module,
20-
Sandbox,
21-
ModuleError,
2211
ModuleCorrection,
12+
ModuleError,
13+
Sandbox,
2314
} from '@codesandbox/common/lib/types';
2415
import { getTextOperation } from '@codesandbox/common/lib/utils/diff';
25-
16+
/* eslint-enable import/no-webpack-loader-syntax */
17+
import { clone } from 'app/componentConnectors';
18+
import prettify from 'app/src/app/utils/prettify';
19+
import { actions, dispatch, listen } from 'codesandbox-api';
20+
import { debounce } from 'lodash-es';
21+
import { TextOperation } from 'ot';
22+
import React from 'react';
23+
import { render } from 'react-dom';
24+
import { ThemeProvider } from 'styled-components';
2625
/* eslint-disable import/no-webpack-loader-syntax */
2726
// @ts-ignore
2827
import LinterWorker from 'worker-loader?publicPath=/&name=monaco-linter.[hash:8].worker.js!../Monaco/workers/linter';
29-
/* eslint-enable import/no-webpack-loader-syntax */
30-
import { clone } from 'app/componentConnectors';
31-
import eventToTransform from '../Monaco/event-to-transform';
32-
import MonacoEditorComponent from './MonacoReactComponent';
33-
import { Container, GlobalStyles } from './elements';
34-
import getSettings from '../Monaco/settings';
3528

36-
import { Props, Editor } from '../types'; // eslint-disable-line
29+
import eventToTransform from '../Monaco/event-to-transform';
30+
import { updateUserSelections } from '../Monaco/live-decorations';
3731
import getMode from '../Monaco/mode';
38-
3932
import {
40-
lineAndColumnToIndex,
4133
indexToLineAndColumn,
34+
lineAndColumnToIndex,
4235
} from '../Monaco/monaco-index-converter';
43-
import { updateUserSelections } from '../Monaco/live-decorations';
36+
import getSettings from '../Monaco/settings';
37+
import { Editor, Props } from '../types'; // eslint-disable-line
4438
import { Configuration } from './Configuration';
39+
import { Container, GlobalStyles } from './elements';
40+
import MonacoEditorComponent from './MonacoReactComponent';
4541

4642
function getSelection(lines, selection) {
4743
const startSelection = lineAndColumnToIndex(

packages/app/src/app/components/CodeEditor/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
2+
DiffTab,
23
Module,
3-
Sandbox,
4-
ModuleError,
54
ModuleCorrection,
6-
Settings,
5+
ModuleError,
76
ModuleTab,
8-
DiffTab,
7+
Sandbox,
8+
Settings,
99
} from '@codesandbox/common/lib/types';
1010

1111
export interface Editor {
@@ -51,8 +51,8 @@ export type Props = {
5151
onNpmDependencyAdded?: (name: string) => void;
5252
onSave?: (code: string) => void;
5353
settings: Settings;
54-
height?: string;
55-
width?: string;
54+
height?: number;
55+
width?: number;
5656
hideNavigation?: boolean;
5757
dependencies?: { [name: string]: string };
5858
highlightedLines?: Array<number>;

packages/app/src/app/overmind/effects/fsSync.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { getGlobal } from '@codesandbox/common/lib/utils/global';
33
import { protocolAndHost } from '@codesandbox/common/lib/utils/url-generator';
44
import { json } from 'overmind';
55

6+
import { EXTENSIONS_LOCATION } from './vscode/manager/constants';
7+
import { getTypeFetcher } from './vscode/manager/extensionHostWorker/common/type-downloader';
8+
69
const global = getGlobal() as Window & { BrowserFS: any };
710

811
const fs = global.BrowserFS.BFSRequire('fs');
@@ -155,5 +158,57 @@ export default {
155158
});
156159

157160
options.onModulesByPathChange(sendFiles);
161+
162+
return new Promise((resolve, reject) => {
163+
window.BrowserFS.configure(
164+
{
165+
fs: 'MountableFileSystem',
166+
options: {
167+
'/': { fs: 'InMemory', options: {} },
168+
'/sandbox': {
169+
fs: 'CodeSandboxEditorFS',
170+
options: {
171+
api: {
172+
getState: () => ({
173+
modulesByPath: window.getState().editor.currentSandbox
174+
? window.getState().editor.modulesByPath
175+
: {},
176+
}),
177+
},
178+
},
179+
},
180+
'/sandbox/node_modules': {
181+
fs: 'CodeSandboxFS',
182+
options: getTypeFetcher().options,
183+
},
184+
'/vscode': {
185+
fs: 'LocalStorage',
186+
},
187+
'/home': {
188+
fs: 'LocalStorage',
189+
},
190+
'/extensions': {
191+
fs: 'BundledHTTPRequest',
192+
options: {
193+
index: EXTENSIONS_LOCATION + '/extensions/index.json',
194+
baseUrl: EXTENSIONS_LOCATION + '/extensions',
195+
bundle: EXTENSIONS_LOCATION + '/bundles/main.min.json',
196+
logReads: process.env.NODE_ENV === 'development',
197+
},
198+
},
199+
'/extensions/custom-theme': {
200+
fs: 'InMemory',
201+
},
202+
},
203+
},
204+
async e => {
205+
if (e) {
206+
reject(e);
207+
} else {
208+
resolve();
209+
}
210+
}
211+
);
212+
});
158213
},
159214
};

0 commit comments

Comments
 (0)