Skip to content

Commit a68339c

Browse files
committed
Merge branch 'master' into fix-embed-default-file
2 parents 8a41ecd + f199b12 commit a68339c

File tree

138 files changed

+2667
-1661
lines changed

Some content is hidden

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

138 files changed

+2667
-1661
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,15 @@
13201320
"contributions": [
13211321
"code"
13221322
]
1323+
},
1324+
{
1325+
"login": "siddharthkp",
1326+
"name": "Sid",
1327+
"avatar_url": "https://avatars0.githubusercontent.com/u/1863771?v=4",
1328+
"profile": "https://sid.st",
1329+
"contributions": [
1330+
"code"
1331+
]
13231332
}
13241333
],
13251334
"repoType": "github",

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [CodeSandbox](https://codesandbox.io) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/codesandbox) [![All Contributors](https://img.shields.io/badge/all_contributors-140-orange.svg?style=flat-square)](#contributors) [![CircleCI](https://circleci.com/gh/codesandbox/codesandbox-client.svg?style=svg)](https://circleci.com/gh/codesandbox/codesandbox-client) [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf)](https://www.browserstack.com/automate/public-build/cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
1+
# [CodeSandbox](https://codesandbox.io) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/codesandbox) [![All Contributors](https://img.shields.io/badge/all_contributors-141-orange.svg?style=flat-square)](#contributors) [![CircleCI](https://circleci.com/gh/codesandbox/codesandbox-client.svg?style=svg)](https://circleci.com/gh/codesandbox/codesandbox-client) [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf)](https://www.browserstack.com/automate/public-build/cVJuczlJWUtqWXhIbFN1ZjVQekF4NzNsd3phNEZRaGlWU0pHYVVkdGRFWT0tLXFtTVhaOWRySmN0ZG5QVDNDQ0g5Z0E9PQ==--79fe3eae4f149a400d396c9b12d3988f685785cf) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
22

33
[![Backers on Open Collective](https://opencollective.com/codesandbox/backers/badge.svg)](#backers)
44
[![Sponsors on Open Collective](https://opencollective.com/codesandbox/sponsors/badge.svg)](#sponsors)
@@ -63,6 +63,7 @@ Thanks goes to these wonderful people
6363
| [<img src="https://avatars2.githubusercontent.com/u/8527474?v=4" width="100px;"/><br /><sub><b>Neville Mehta</b></sub>](https://twitter.com/ask_neville)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=nm123github "Code") | [<img src="https://avatars0.githubusercontent.com/u/1813468?v=4" width="100px;"/><br /><sub><b>Vasiliy</b></sub>](https://github.com/Yeti-or)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=Yeti-or "Code") | [<img src="https://avatars3.githubusercontent.com/u/2793951?v=4" width="100px;"/><br /><sub><b>Romain Lanz</b></sub>](https://slynova.io)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=RomainLanz "Code") | [<img src="https://avatars2.githubusercontent.com/u/1233790?v=4" width="100px;"/><br /><sub><b>LiBe</b></sub>](http://libe.toile-libre.org)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=libetl "Code") | [<img src="https://avatars0.githubusercontent.com/u/5333019?v=4" width="100px;"/><br /><sub><b>Jeremy Bolding</b></sub>](http://thecodechef.github.io)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=thecodechef "Code") | [<img src="https://avatars1.githubusercontent.com/u/9664363?v=4" width="100px;"/><br /><sub><b>Evan Bacon</b></sub>](https://twitter.com/baconbrix)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=EvanBacon "Code") | [<img src="https://avatars3.githubusercontent.com/u/6643991?v=4" width="100px;"/><br /><sub><b>Michaël De Boey</b></sub>](https://michaeldeboey.be)<br />[📝](#blog-MichaelDeBoey "Blogposts") [🐛](https://github.com/codesandbox/codesandbox-client/issues?q=author%3AMichaelDeBoey "Bug reports") [💻](https://github.com/codesandbox/codesandbox-client/commits?author=MichaelDeBoey "Code") [📖](https://github.com/codesandbox/codesandbox-client/commits?author=MichaelDeBoey "Documentation") [🚇](#infra-MichaelDeBoey "Infrastructure (Hosting, Build-Tools, etc)") [🔧](#tool-MichaelDeBoey "Tools") |
6464
| [<img src="https://avatars1.githubusercontent.com/u/14077091?v=4" width="100px;"/><br /><sub><b>gabeeden</b></sub>](https://github.com/gabeeden)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=gabeeden "Code") | [<img src="https://avatars0.githubusercontent.com/u/7698292?v=4" width="100px;"/><br /><sub><b>Tiffany White</b></sub>](https://tiffanywhite.dev)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=twhite96 "Code") | [<img src="https://avatars3.githubusercontent.com/u/32302360?v=4" width="100px;"/><br /><sub><b>James Bedford</b></sub>](http://www.dopest.tech)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=JABedford "Code") | [<img src="https://avatars0.githubusercontent.com/u/3314957?v=4" width="100px;"/><br /><sub><b>Scott</b></sub>](https://www.patreon.com/user?u=16255660)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=smolinari "Code") | [<img src="https://avatars1.githubusercontent.com/u/12200583?v=4" width="100px;"/><br /><sub><b>Dutiyesh Salunkhe</b></sub>](https://github.com/dutiyesh)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=dutiyesh "Code") | [<img src="https://avatars2.githubusercontent.com/u/13641726?v=4" width="100px;"/><br /><sub><b>Halit Ogunc</b></sub>](http://halit.dev)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=halitogunc "Code") | [<img src="https://avatars0.githubusercontent.com/u/22376783?v=4" width="100px;"/><br /><sub><b>Yash Joshi</b></sub>](https://github.com/jyash97)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=jyash97 "Code") |
6565
| [<img src="https://avatars3.githubusercontent.com/u/1769092?v=4" width="100px;"/><br /><sub><b>Yehor</b></sub>](https://github.com/batiskafff)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=batiskafff "Code") | [<img src="https://avatars2.githubusercontent.com/u/6972822?v=4" width="100px;"/><br /><sub><b>Jens de Rond</b></sub>](https://github.com/Jensderond)<br />[🐛](https://github.com/codesandbox/codesandbox-client/issues?q=author%3AJensderond "Bug reports") [💻](https://github.com/codesandbox/codesandbox-client/commits?author=Jensderond "Code") | [<img src="https://avatars2.githubusercontent.com/u/2502947?v=4" width="100px;"/><br /><sub><b>Benjamin Schachter</b></sub>](http://benjaminschachter.com)<br />[📖](https://github.com/codesandbox/codesandbox-client/commits?author=benschac "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/14234815?v=4" width="100px;"/><br /><sub><b>Rafael</b></sub>](https://github.com/RafaelKr)<br />[🐛](https://github.com/codesandbox/codesandbox-client/issues?q=author%3ARafaelKr "Bug reports") [💻](https://github.com/codesandbox/codesandbox-client/commits?author=RafaelKr "Code") | [<img src="https://avatars0.githubusercontent.com/u/19686979?v=4" width="100px;"/><br /><sub><b>baremetalfreak</b></sub>](https://github.com/baremetalfreak)<br />[💬](#question-baremetalfreak "Answering Questions") [🐛](https://github.com/codesandbox/codesandbox-client/issues?q=author%3Abaremetalfreak "Bug reports") [💻](https://github.com/codesandbox/codesandbox-client/commits?author=baremetalfreak "Code") | [<img src="https://avatars0.githubusercontent.com/u/13278577?v=4" width="100px;"/><br /><sub><b>Javed</b></sub>](https://github.com/JayBee007)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=JayBee007 "Code") | [<img src="https://avatars1.githubusercontent.com/u/29365693?v=4" width="100px;"/><br /><sub><b>R4M80MRX</b></sub>](https://github.com/R4M80MrX)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=R4M80MrX "Code") |
66+
| [<img src="https://avatars0.githubusercontent.com/u/1863771?v=4" width="100px;"/><br /><sub><b>Sid</b></sub>](https://sid.st)<br />[💻](https://github.com/codesandbox/codesandbox-client/commits?author=siddharthkp "Code") |
6667

6768
<!-- ALL-CONTRIBUTORS-LIST:END -->
6869

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"url": "https://github.com/codesandbox/codesandbox-client"
99
},
1010
"scripts": {
11+
"commit": "concurrently \"yarn typecheck\" \"yarn lint\" && git commit -m",
1112
"build": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" yarn build:deps && yarn build:prod",
1213
"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",
1314
"build:embed": "lerna run build:embed --scope app --stream && gulp",

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@
214214
"normalizr": "^3.2.3",
215215
"onigasm": "^2.2.1",
216216
"ot": "^0.0.15",
217-
"overmind": "^19.0.1",
217+
"overmind": "^19.1.1",
218218
"overmind-devtools": "^19.0.0",
219-
"overmind-react": "^19.0.0",
219+
"overmind-react": "^20.1.1",
220220
"phoenix": "^1.3.0",
221221
"postcss": "^6.0.9",
222222
"postcss-selector-parser": "^2.2.3",

packages/app/src/app/componentConnectors.ts

100644100755
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1+
import { json } from 'overmind';
12
import { inject as mobxInject, observer as mobxObserver } from 'mobx-react';
23
import { observer as mobxHooksObserver } from 'mobx-react-lite';
34
import { connect } from './overmind';
45

5-
const isOvermind = location.search.includes('overmind=true');
6+
const isOvermind = localStorage.getItem('overmind') === 'true';
67

78
export const inject: any = isOvermind
89
? () => component => component
9-
: mobxInject;
10+
: (...injects) => mobxInject('reaction', ...injects);
1011

1112
export const observer: any = isOvermind ? connect : mobxObserver;
1213

1314
export const hooksObserver: any = isOvermind ? connect : mobxHooksObserver;
1415

1516
export const Observer = isOvermind
16-
? inject('store', 'signals')(
17-
connect(({ store, signals, children }: any) =>
18-
children({ store, signals })
19-
)
17+
? connect(({ store, signals, reaction, children }: any) =>
18+
children({ store, signals, reaction })
2019
)
2120
: inject('store', 'signals')(
22-
observer(({ store, signals, children }: any) =>
23-
children({ store, signals })
21+
observer(({ store, signals, reaction, children }: any) =>
22+
children({ store, signals, reaction })
2423
)
2524
);
25+
26+
export const clone = isOvermind
27+
? json
28+
: obj => {
29+
if (obj.toJSON) {
30+
return obj.toJSON();
31+
}
32+
33+
if (obj.toJS) {
34+
return obj.toJS();
35+
}
36+
37+
return obj;
38+
};

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ import { getTextOperation } from '@codesandbox/common/lib/utils/diff';
2727
// @ts-ignore
2828
import LinterWorker from 'worker-loader?publicPath=/&name=monaco-linter.[hash:8].worker.js!../Monaco/workers/linter';
2929
/* eslint-enable import/no-webpack-loader-syntax */
30-
30+
import { clone } from 'app/componentConnectors';
3131
import eventToTransform from '../Monaco/event-to-transform';
3232
import MonacoEditorComponent, { EditorAPI } from './MonacoReactComponent';
3333
import { Container, GlobalStyles } from './elements';
3434
import getSettings from '../Monaco/settings';
3535

3636
import { Props, Editor } from '../types';
3737
import getMode from '../Monaco/mode';
38+
3839
import {
3940
lineAndColumnToIndex,
4041
indexToLineAndColumn,
@@ -698,7 +699,7 @@ export class VSCode extends React.Component<Props> implements Editor {
698699
};
699700

700701
applyOperations = (operations: { [moduleShortid: string]: any }) => {
701-
const operationsJSON = operations.toJSON();
702+
const operationsJSON = operations.toJSON ? operations.toJSON() : operations;
702703

703704
Object.keys(operationsJSON).forEach(moduleShortid => {
704705
const operation = TextOperation.fromJSON(operationsJSON[moduleShortid]);
@@ -1119,8 +1120,7 @@ export class VSCode extends React.Component<Props> implements Editor {
11191120
<Configuration
11201121
onChange={this.props.onChange}
11211122
// Copy the object, we don't want mutations in the component
1122-
// @ts-ignore
1123-
currentModule={currentModule.toJSON()}
1123+
currentModule={clone(currentModule)}
11241124
config={config}
11251125
sandbox={this.sandbox}
11261126
{...extraProps}

packages/app/src/app/components/SandboxList/SandboxList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ export const SandboxList: React.FC<ISandboxListProps> = ({
7373
<StatBody>{s.likeCount}</StatBody>
7474
<StatBody>{s.viewCount}</StatBody>
7575
<StatBody>{s.forkCount}</StatBody>
76-
{isCurrentUser && (
76+
{isCurrentUser && onDelete ? (
7777
<DeleteBody>
7878
<DeleteSandboxButton id={s.id} onDelete={onDelete} />
7979
</DeleteBody>
80-
)}
80+
) : null}
8181
</SandboxRow>
8282
);
8383
})}

packages/app/src/app/index.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render } from 'react-dom';
33
import { ThemeProvider } from 'styled-components';
44
import { Router } from 'react-router-dom';
55
import { ApolloProvider } from 'react-apollo';
6+
import { reaction } from 'mobx';
67
import { ApolloProvider as HooksProvider } from '@apollo/react-hooks';
78
import { Provider } from 'mobx-react';
89
import _debug from '@codesandbox/common/lib/utils/debug';
@@ -33,7 +34,7 @@ import { Routes as App } from './pages';
3334
import { Provider as OvermindProvider } from './overmind/Provider';
3435
import './split-pane.css';
3536
import { getTypeFetcher } from './vscode/extensionHostWorker/common/type-downloader';
36-
37+
import overmindLogo from './overmind.png';
3738
import { vscode } from './vscode';
3839
import {
3940
initializeThemeCache,
@@ -123,7 +124,11 @@ async function boot(state, signals, overmind) {
123124
render(
124125
<Signals.Provider value={signals}>
125126
<Store.Provider value={state}>
126-
<Provider store={state} signals={signals}>
127+
<Provider
128+
store={state}
129+
signals={signals}
130+
reaction={(cbA, cbB) => reaction(() => cbA(state), cbB)}
131+
>
127132
<ApolloProvider client={client}>
128133
<OvermindProvider value={overmind}>
129134
<HooksProvider client={client}>
@@ -154,20 +159,51 @@ async function initialize() {
154159
let state = null;
155160
let overmind = null;
156161

157-
if (location.search.includes('overmind=true')) {
162+
window.useOvermind = useIt => {
163+
if (typeof useIt === 'undefined') {
164+
return localStorage.getItem('overmind');
165+
}
166+
167+
localStorage.setItem('overmind', JSON.stringify(useIt));
168+
location.reload(true);
169+
170+
return useIt;
171+
};
172+
173+
if (localStorage.getItem('overmind') === 'true') {
158174
await Promise.all([import('overmind'), import('./overmind')]).then(
159175
modules => {
160176
const createOvermind = modules[0].createOvermind;
161177
const config = modules[1].config;
162178

163179
overmind = createOvermind(config, {
164-
devtools: 'localhost:3032',
180+
devtools:
181+
window.opener && window.opener !== window && !window.chrome
182+
? false
183+
: 'localhost:3031',
184+
name: 'CodeSandbox',
165185
logProxies: true,
166186
});
167187

168-
getState = () => overmind.state;
188+
getState = path =>
189+
path
190+
? path.split('.').reduce((aggr, key) => aggr[key], overmind.state)
191+
: overmind.state;
169192
getSignal = path =>
170193
path.split('.').reduce((aggr, key) => aggr[key], overmind.actions);
194+
195+
const logoContainer = document.createElement('div');
196+
logoContainer.style.position = 'fixed';
197+
logoContainer.style.bottom = '30px';
198+
logoContainer.style.left = '10px';
199+
logoContainer.style.zIndex = '999999';
200+
logoContainer.style.width = '40px';
201+
logoContainer.style.height = '40px';
202+
logoContainer.style.borderRadius = '3px';
203+
logoContainer.style.backgroundImage = `url(${overmindLogo})`;
204+
logoContainer.style.backgroundSize = 'cover';
205+
logoContainer.style.backgroundSize = 'cover';
206+
document.body.appendChild(logoContainer);
171207
}
172208
);
173209
} else {
@@ -195,6 +231,9 @@ async function initialize() {
195231
getSignal = controller.getSignal.bind(controller);
196232
}
197233

234+
window.getState = getState;
235+
window.getSignal = getSignal;
236+
198237
// Configures BrowserFS to use the LocalStorage file system.
199238
window.BrowserFS.configure(
200239
{

packages/app/src/app/overmind.png

55.9 KB
Loading

packages/app/src/app/overmind/Provider.ts

100644100755
File mode changed.

0 commit comments

Comments
 (0)