Skip to content

Commit f0e3fc6

Browse files
christianalfoniCompuIves
authored andcommitted
Overmind refactor: Round 2 (codesandbox#2137)
* refactored sandboxPageMounted with related stuff * a lot of refactoring * more refactoring * jup, more refactor * profile refactored * update overmind * refactored zeit, netlify, dashboard and deployment * so much refactoring... * refactored files namespace * refactored git namespace * refactored live some more * final refactoring before testing * hooking into components * revert hooks to old API to support state transition * overmind needs observer, does not work only with inject * move hoc * fix types and Observer * fix last types * fix linting issues * remove old ot file and typecheck overmind as well * Apply suggestions from code review Co-Authored-By: Michaël De Boey <[email protected]> * fix getState for VSCode
1 parent 01da61e commit f0e3fc6

File tree

233 files changed

+6192
-5957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+6192
-5957
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282
"lerna": "^2.5.1",
8383
"prettier": "1.17.0",
8484
"pretty-quick": "^1.10.0",
85-
"typescript": "3.5.2"
85+
"typescript": "3.5.3"
8686
},
8787
"dependencies": {
88-
"@typescript-eslint/eslint-plugin": "^1.9.0",
89-
"@typescript-eslint/parser": "^1.9.0",
88+
"@typescript-eslint/eslint-plugin": "^1.13.0",
89+
"@typescript-eslint/parser": "^1.13.0",
9090
"opencollective": "^1.0.3"
9191
},
9292
"collective": {

packages/app/config/babel.dev.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ module.exports = {
2222
},
2323
],
2424
// JSX, Flow
25-
require.resolve('@babel/preset-react'),
26-
2725
require.resolve('@babel/preset-typescript'),
26+
require.resolve('@babel/preset-react'),
2827
].filter(Boolean),
2928
plugins: [
3029
require.resolve('@babel/plugin-transform-template-literals'),

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"shortid": "^2.2.8",
274274
"store": "^2.0.12",
275275
"string-replace-loader": "^2.1.1",
276-
"styled-components": "^4.2.0",
276+
"styled-components": "^4.3.2",
277277
"subworkers": "^1.0.1",
278278
"svg-react-loader": "^0.4.4",
279279
"tern": "^0.21.0",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { inject as mobxInject, observer as mobxObserver } from 'mobx-react';
2+
import { observer as mobxHooksObserver } from 'mobx-react-lite';
3+
import { connect } from './overmind';
4+
5+
const isOvermind = location.search.includes('overmind=true');
6+
7+
export const inject: any = isOvermind
8+
? () => component => component
9+
: mobxInject;
10+
11+
export const observer: any = isOvermind ? connect : mobxObserver;
12+
13+
export const hooksObserver: any = isOvermind ? connect : mobxHooksObserver;
14+
15+
export const Observer = isOvermind
16+
? inject('store', 'signals')(
17+
connect(({ store, signals, children }: any) =>
18+
children({ store, signals })
19+
)
20+
)
21+
: inject('store', 'signals')(
22+
observer(({ store, signals, children }: any) =>
23+
children({ store, signals })
24+
)
25+
);

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

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,11 @@ import {
33
Sandbox,
44
ModuleError,
55
ModuleCorrection,
6+
Settings,
7+
ModuleTab,
8+
DiffTab,
69
} from '@codesandbox/common/lib/types';
710

8-
export type Settings = {
9-
autoCompleteEnabled: boolean;
10-
autoDownloadTypes: boolean;
11-
codeMirror: boolean;
12-
clearConsoleEnabled: boolean;
13-
fontFamily?: string;
14-
fontSize: number;
15-
lineHeight: number;
16-
lintEnabled: boolean;
17-
vimMode: boolean;
18-
tabWidth: number;
19-
enableLigatures: boolean;
20-
forceRefresh: boolean;
21-
experimentVSCode: boolean;
22-
prettierConfig: Object;
23-
zenMode: boolean;
24-
livePreviewEnabled: boolean;
25-
instantPreviewEnabled: boolean;
26-
};
27-
28-
type ModuleTab = {
29-
type: 'MODULE';
30-
moduleShortid: string;
31-
dirty: boolean;
32-
};
33-
34-
type DiffTab = {
35-
id: string;
36-
type: 'DIFF';
37-
codeA: string;
38-
codeB: string;
39-
titleA: string;
40-
titleB: string;
41-
fileTitle?: string;
42-
};
43-
44-
export type Tab = ModuleTab | DiffTab;
45-
4611
export interface Editor {
4712
changeSandbox?: (
4813
sandbox: Sandbox,
@@ -72,7 +37,7 @@ export interface Editor {
7237

7338
export type Props = {
7439
currentModule: Module;
75-
currentTab?: Tab;
40+
currentTab?: ModuleTab | DiffTab;
7641
sandbox: Sandbox;
7742
isModuleSynced: (shortid: string) => boolean;
7843
customEditorAPI?: {

packages/app/src/app/components/Overlay/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { observer } from 'mobx-react';
2+
import { observer } from 'app/componentConnectors';
33

44
import { Transition, animated, config } from 'react-spring/renderprops';
55
import track from '@codesandbox/common/lib/utils/analytics';

packages/app/src/app/controller.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)