Skip to content

Commit d02b9bb

Browse files
authored
Executor Refactor (codesandbox#2060)
* Initial executor commit * CLeanup * Update the terminal logic * Intermediate * Update packages/app/src/app/components/Preview/DevTools/Terminal/index.tsx Co-Authored-By: Michaël De Boey <[email protected]> * Update packages/app/src/app/components/Preview/DevTools/Terminal/index.tsx Co-Authored-By: Michaël De Boey <[email protected]> * Update packages/app/src/app/store/modules/server/actions.js Co-Authored-By: Michaël De Boey <[email protected]> * Update packages/app/src/app/components/Preview/DevTools/Terminal/index.tsx Co-Authored-By: Michaël De Boey <[email protected]> * Fix syntax error * Remove server logic from preview * Fix rendering and moving of terminals * Build executors in CI * Fix terminal rendering * Improve rendering and overlay messages of terminal * Allow non-signed in users to see terminal * Connect to stream * Allow for custom URLs * Move tabs logic to store * Move DevTools logic to store * Ports * Fix embeds * Reinitializing sandbox * Fix container state * Fix typecheck and test * Allow executors to build * Fix hibernate status * Fix types * Add savedCode to Module * Apply suggestions from code review Co-Authored-By: Michaël De Boey <[email protected]> * Update packages/app/src/app/components/Preview/DevTools/index.tsx Co-Authored-By: Michaël De Boey <[email protected]> * Only show overlay for unrecoverable server errors * Prisma extension * Show container errors that are recoverable as warnings instead * Server status: refactor messages. * Close SSE websocket when sandbox hibernates. * Update socket.io-client to 2.2.0. * SSE: Show "sandbox started" message. * Bump CircleCI cache keys version. * Small syntax tweaks * DevTools: refactor to flexbox. * Remove unused heights. * Fix terminal sizing initially and resize sending * Save the workspace config in store if sandbox is not owned * Make function implicit return * sse-loading-screen updates: - updated socket.io-client to 2.2.0 - added ports support * Update browser tests to use sandboxes repository.
1 parent 79eb3f3 commit d02b9bb

File tree

116 files changed

+4729
-1676
lines changed

Some content is hidden

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

116 files changed

+4729
-1676
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build:prod": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" lerna run build --scope homepage --stream && lerna run build --scope app --stream && lerna run copy-assets --scope app --stream",
99
"build:embed": "lerna run build:embed --scope app --stream && gulp",
1010
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
11-
"build:deps": "lerna run build:dev --scope codesandbox-api --scope @codesandbox/notifications && lerna run build:dev --scope @codesandbox/common && lerna run build:dev --scope vscode-textmate --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks && lerna run build --scope codesandbox-deps",
11+
"build:deps": "lerna run build:dev --scope codesandbox-api --scope @codesandbox/notifications --scope @codesandbox/executors && lerna run build:dev --scope @codesandbox/common && lerna run build:dev --scope vscode-textmate --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks && lerna run build --scope codesandbox-deps",
1212
"build:common": "lerna run build:dev --scope @codesandbox/common --stream",
1313
"build:dynamic": "lerna run build --scope dynamic-pages --stream",
1414
"start": "yarn build:deps && yarn start:fast",
@@ -43,7 +43,8 @@
4343
"packages/react-embed",
4444
"packages/dynamic-pages",
4545
"packages/notifications",
46-
"packages/deps"
46+
"packages/deps",
47+
"packages/executors"
4748
],
4849
"nohoist": [
4950
"**/react-codemirror2",

packages/app/integration-tests/browser-tests/browsers.test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ function getDriver(capabilities) {
2727
function testPageWitCapabilities(capabilities) {
2828
const driver = getDriver(getCapabilities(capabilities));
2929
// Test if a sandbox can be loaded on IE11
30-
return driver.get('http://localhost:3002/#new').then(async () => {
31-
const element = webdriver.By.css('h1');
32-
await driver.wait(webdriver.until.elementLocated(element), 60000);
33-
driver.quit();
34-
});
30+
return driver
31+
.get(
32+
'http://localhost:3002/#github/codesandbox/integration-sandboxes/tree/master/new'
33+
)
34+
.then(async () => {
35+
const element = webdriver.By.css('h1');
36+
await driver.wait(webdriver.until.elementLocated(element), 60000);
37+
driver.quit();
38+
});
3539
}
3640

3741
const usedDescribe = process.env.BROWSER_STACK_KEY ? describe : describe.skip;

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
"@babel/preset-env": "^7.4.2",
131131
"@cerebral/http": "^4.0.0",
132132
"@cerebral/mobx-state-tree": "^3.0.0",
133+
"@codesandbox/executors": "^0.1.0",
133134
"@codesandbox/template-icons": "^0.5.0",
134135
"@emmetio/codemirror-plugin": "^0.3.5",
135136
"@svgr/core": "^2.4.1",

packages/app/scripts/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function addMiddleware(devServer, index) {
229229
devServer.use(
230230
'/api',
231231
proxy({
232-
target: 'https://codesandbox.io',
232+
target: 'https://codesandbox.stream',
233233
changeOrigin: true,
234234
})
235235
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type State = {
6565
export default class CodeEditor extends React.PureComponent<
6666
Props & {
6767
editor?: 'vscode' | 'monaco' | 'codemirror';
68-
style: React.CSSProperties;
68+
style?: React.CSSProperties;
6969
},
7070
State
7171
> {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export type Settings = {
2121
experimentVSCode: boolean;
2222
prettierConfig: Object;
2323
zenMode: boolean;
24+
livePreviewEnabled: boolean;
25+
instantPreviewEnabled: boolean;
2426
};
2527

2628
type ModuleTab = {
@@ -69,10 +71,10 @@ export interface Editor {
6971

7072
export type Props = {
7173
currentModule: Module;
72-
currentTab: Tab | undefined;
74+
currentTab?: Tab;
7375
sandbox: Sandbox;
7476
isModuleSynced: (shortid: string) => boolean;
75-
customEditorAPI: {
77+
customEditorAPI?: {
7678
getCustomEditor: (
7779
path: string
7880
) => (container: HTMLElement, extraProps: object) => void;
@@ -90,11 +92,11 @@ export type Props = {
9092
highlightedLines?: Array<number>;
9193
tsconfig?: Object;
9294
readOnly?: boolean;
93-
isLive: boolean;
95+
isLive?: boolean;
9496
sendTransforms?: (transform: any) => void;
9597
receivingCode?: boolean;
9698
onCodeReceived?: () => void;
97-
onSelectionChanged: (d: { selection: any; moduleShortid: string }) => void;
99+
onSelectionChanged?: (d: { selection: any; moduleShortid: string }) => void;
98100
onModuleStateMismatch?: () => void;
99-
theme: any;
101+
theme?: any;
100102
};

packages/app/src/app/components/Preview/DevTools/Browser/index.tsx

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

packages/app/src/app/components/Preview/DevTools/Console/elements.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export const Container = styled.div`
77
color: ${props =>
88
props.theme['editor.foreground'] ||
99
(props.theme.light ? '#636363' : 'rgba(255, 255, 255, 0.8)')};
10-
width: 100%;
11-
height: 100%;
10+
flex: auto;
1211
display: flex;
1312
flex-direction: column;
1413
border-color: ${props => props.theme['statusBar.border'] || '#191C1D'};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
import PlusIcon from 'react-icons/lib/go/plus';
5+
import ContextMenu from 'app/components/ContextMenu';
6+
7+
const Container = styled.button`
8+
transition: 0.3s ease color;
9+
display: flex;
10+
height: 100%;
11+
12+
align-items: center;
13+
font-size: 0.8rem;
14+
padding: 0 1rem;
15+
16+
outline: none;
17+
border: none;
18+
background-color: transparent;
19+
color: inherit;
20+
21+
cursor: pointer;
22+
23+
&:hover {
24+
color: white;
25+
}
26+
`;
27+
28+
export function AddTab() {
29+
return (
30+
<ContextMenu
31+
childFunction
32+
items={[
33+
{
34+
title: 'Browser Pane',
35+
icon: PlusIcon,
36+
action: () => {
37+
alert('test');
38+
return true;
39+
},
40+
},
41+
]}
42+
>
43+
{onContextMenu => (
44+
<Container onClick={onContextMenu}>
45+
<PlusIcon />
46+
</Container>
47+
)}
48+
</ContextMenu>
49+
);
50+
}

packages/app/src/app/components/Preview/DevTools/Tabs/Tab/elements.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const Tab = styled.div<{ active: boolean; isOver: boolean }>`
1717
display: flex;
1818
align-items: center;
1919
padding: 0 1.25rem;
20+
width: max-content;
2021
2122
padding-right: 1.75rem;
2223
height: 100%;

0 commit comments

Comments
 (0)