1- import React from 'react ';
2- import { render } from 'react-dom ';
3- import { ThemeProvider } from 'styled-components' ;
4- import { Router } from 'react-router-dom ';
5- import { ApolloProvider } from 'react-apollo' ;
1+ import '@codesandbox/common/lib/global.css ';
2+ import 'normalize.css ';
3+
4+ import './split-pane.css ';
5+
66import { ApolloProvider as HooksProvider } from '@apollo/react-hooks' ;
7- import _debug from '@codesandbox/common/lib/utils/debug' ;
8- import { createOvermind } from 'overmind' ;
7+ import requirePolyfills from '@codesandbox/common/lib/load-dynamic-polyfills' ;
8+ import registerServiceWorker from '@codesandbox/common/lib/registerServiceWorker' ;
9+ import theme from '@codesandbox/common/lib/theme' ;
910import {
1011 initializeSentry ,
1112 logError ,
1213} from '@codesandbox/common/lib/utils/analytics' ;
13- import '@codesandbox/common/lib/global.css' ;
14- import history from 'app/utils/history' ;
15- import { client } from 'app/graphql/client' ;
16- import registerServiceWorker from '@codesandbox/common/lib/registerServiceWorker' ;
17- import requirePolyfills from '@codesandbox/common/lib/load-dynamic-polyfills' ;
14+ import _debug from '@codesandbox/common/lib/utils/debug' ;
1815import {
19- notificationState ,
2016 convertTypeToStatus ,
17+ notificationState ,
2118} from '@codesandbox/common/lib/utils/notifications' ;
22- import { NotificationStatus } from '@codesandbox/notifications' ;
23- import 'normalize.css' ;
24- import theme from '@codesandbox/common/lib/theme' ;
2519import { isSafari } from '@codesandbox/common/lib/utils/platform' ;
26-
27- // eslint-disable-next-line
28- import * as childProcess from 'node-services/lib/child_process' ;
20+ import { NotificationStatus } from '@codesandbox/notifications' ;
21+ import { client } from 'app/graphql/client' ;
22+ import history from 'app/utils/history' ;
23+ import { createOvermind } from 'overmind' ;
2924import { Provider as ActualOvermindProvider } from 'overmind-react' ;
30- import { Routes as App } from './pages' ;
31- import { Provider as OvermindProvider } from './overmind/Provider' ;
25+ import React from 'react' ;
26+ import { ApolloProvider } from 'react-apollo' ;
27+ import { render } from 'react-dom' ;
28+ import { Router } from 'react-router-dom' ;
29+ import { ThemeProvider } from 'styled-components' ;
30+
3231import { config } from './overmind' ;
33- import './split-pane.css' ;
34- import { getTypeFetcher } from './vscode/extensionHostWorker/common/type-downloader' ;
35- import { vscode } from './vscode' ;
36- import {
37- initializeThemeCache ,
38- initializeSettings ,
39- initializeExtensionsFolder ,
40- initializeCustomTheme ,
41- setVimExtensionEnabled ,
42- } from './vscode/initializers' ;
43- import { EXTENSIONS_LOCATION } from './vscode/constants' ;
32+ import { Provider as OvermindProvider } from './overmind/Provider' ;
33+ import { Routes as App } from './pages' ;
4434
4535const debug = _debug ( 'cs:app' ) ;
4636
@@ -66,10 +56,29 @@ if (process.env.NODE_ENV === 'production') {
6656
6757window . __isTouch = ! matchMedia ( '(pointer:fine)' ) . matches ;
6858
69- let getState ;
70- let getSignal ;
59+ const overmind = createOvermind ( config , {
60+ devtools :
61+ ( window . opener && window . opener !== window ) || ! window . chrome
62+ ? false
63+ : 'localhost:3031' ,
64+ name :
65+ 'CodeSandbox - ' +
66+ ( navigator . userAgent . indexOf ( 'Chrome/76' ) > 0 ? 'Chrome' : 'Canary' ) ,
67+ logProxies : true ,
68+ } ) ;
7169
72- async function boot ( overmind ) {
70+ /*
71+ Temporary global functions to grab state and actions, related to old
72+ Cerebral implementation
73+ */
74+ window . getState = path =>
75+ path
76+ ? path . split ( '.' ) . reduce ( ( aggr , key ) => aggr [ key ] , overmind . state )
77+ : overmind . state ;
78+ window . getSignal = path =>
79+ path . split ( '.' ) . reduce ( ( aggr , key ) => aggr [ key ] , overmind . actions ) ;
80+
81+ overmind . initialized . then ( ( ) => {
7382 requirePolyfills ( ) . then ( ( ) => {
7483 if ( isSafari ) {
7584 import ( 'subworkers' ) ;
@@ -89,7 +98,7 @@ async function boot(overmind) {
8998 registerServiceWorker ( '/service-worker.js' , {
9099 onUpdated : ( ) => {
91100 debug ( 'Updated SW' ) ;
92- getSignal ( 'setUpdateStatus' ) ( { status : 'available' } ) ;
101+ window . getSignal ( 'setUpdateStatus' ) ( { status : 'available' } ) ;
93102
94103 notificationState . addNotification ( {
95104 title : 'CodeSandbox Update Available' ,
@@ -138,135 +147,4 @@ async function boot(overmind) {
138147 logError ( e ) ;
139148 }
140149 } ) ;
141- }
142-
143- async function initialize ( ) {
144- /*
145- Configure Cerebral and Overmind
146- */
147-
148- const overmind = createOvermind ( config , {
149- devtools :
150- ( window . opener && window . opener !== window ) || ! window . chrome
151- ? false
152- : 'localhost:3031' ,
153- name :
154- 'CodeSandbox - ' +
155- ( navigator . userAgent . indexOf ( 'Chrome/76' ) > 0 ? 'Chrome' : 'Canary' ) ,
156- logProxies : true ,
157- } ) ;
158-
159- getState = path =>
160- path
161- ? path . split ( '.' ) . reduce ( ( aggr , key ) => aggr [ key ] , overmind . state )
162- : overmind . state ;
163- getSignal = path =>
164- path . split ( '.' ) . reduce ( ( aggr , key ) => aggr [ key ] , overmind . actions ) ;
165-
166- window . getState = getState ;
167- window . getSignal = getSignal ;
168-
169- // Configures BrowserFS to use the LocalStorage file system.
170- window . BrowserFS . configure (
171- {
172- fs : 'MountableFileSystem' ,
173- options : {
174- '/' : { fs : 'InMemory' , options : { } } ,
175- '/sandbox' : {
176- fs : 'CodeSandboxEditorFS' ,
177- options : {
178- api : {
179- getState : ( ) => ( {
180- modulesByPath : getState ( ) . editor . currentSandbox
181- ? getState ( ) . editor . modulesByPath
182- : { } ,
183- } ) ,
184- } ,
185- } ,
186- } ,
187- '/sandbox/node_modules' : {
188- fs : 'CodeSandboxFS' ,
189- options : getTypeFetcher ( ) . options ,
190- } ,
191- '/vscode' : {
192- fs : 'LocalStorage' ,
193- } ,
194- '/home' : {
195- fs : 'LocalStorage' ,
196- } ,
197- '/extensions' : {
198- fs : 'BundledHTTPRequest' ,
199- options : {
200- index : EXTENSIONS_LOCATION + '/extensions/index.json' ,
201- baseUrl : EXTENSIONS_LOCATION + '/extensions' ,
202- bundle : EXTENSIONS_LOCATION + '/bundles/main.min.json' ,
203- logReads : process . env . NODE_ENV === 'development' ,
204- } ,
205- } ,
206- '/extensions/custom-theme' : {
207- fs : 'InMemory' ,
208- } ,
209- } ,
210- } ,
211- async e => {
212- if ( e ) {
213- console . error ( 'Problems initializing FS' , e ) ;
214- // An error happened!
215- throw e ;
216- }
217-
218- const isVSCode = getState ( ) . preferences . settings . experimentVSCode ;
219-
220- if ( isVSCode ) {
221- // For first-timers initialize a theme in the cache so it doesn't jump colors
222- initializeExtensionsFolder ( ) ;
223- initializeCustomTheme ( ) ;
224- initializeThemeCache ( ) ;
225- initializeSettings ( ) ;
226- setVimExtensionEnabled (
227- localStorage . getItem ( 'settings.vimmode' ) === 'true'
228- ) ;
229- }
230-
231- // eslint-disable-next-line global-require
232- vscode . loadScript (
233- [
234- isVSCode
235- ? 'vs/editor/codesandbox.editor.main'
236- : 'vs/editor/editor.main' ,
237- ] ,
238- isVSCode ,
239- ( ) => {
240- if ( process . env . NODE_ENV === 'development' ) {
241- console . log ( 'Loaded Monaco' ) ; // eslint-disable-line
242- }
243- if ( isVSCode ) {
244- vscode . acquireController ( {
245- getSignal,
246- getState,
247- } ) ;
248-
249- import (
250- 'worker-loader?publicPath=/&name=ext-host-worker.[hash:8].worker.js!./vscode/extensionHostWorker/bootstrappers/ext-host'
251- ) . then ( ExtHostWorkerLoader => {
252- childProcess . addDefaultForkHandler ( ExtHostWorkerLoader . default ) ;
253- // child_process.preloadWorker('/vs/bootstrap-fork');
254- } ) ;
255-
256- // import('worker-loader?publicPath=/&name=ext-host-worker.[hash:8].worker.js!./vscode/extensionHostWorker/services/searchService').then(
257- // SearchServiceWorker => {
258- // child_process.addForkHandler(
259- // 'csb:search-service',
260- // SearchServiceWorker.default
261- // );
262- // }
263- // );
264- }
265- boot ( overmind ) ;
266- }
267- ) ;
268- }
269- ) ;
270- }
271-
272- initialize ( ) ;
150+ } ) ;
0 commit comments