Skip to content

Commit 2ae2b3f

Browse files
committed
Merge branch 'master' into skeleton-experiment
2 parents 35c8588 + 3118c21 commit 2ae2b3f

File tree

92 files changed

+3745
-923
lines changed

Some content is hidden

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

92 files changed

+3745
-923
lines changed

.circleci/config.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ aliases:
2626

2727
- &restore_deps_cache
2828
keys:
29-
- v33-dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
30-
- v33-dependency-cache-{{ .Branch }}
31-
- v33-dependency-cache
29+
- v34-dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
30+
- v34-dependency-cache-{{ .Branch }}
31+
- v34-dependency-cache
3232

3333
- &save_deps_cache
34-
key: v33-dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
34+
key: v34-dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
3535
paths:
3636
- node_modules
3737
- packages/app/node_modules
@@ -51,51 +51,51 @@ aliases:
5151

5252
- &restore_standalone_deps_cache
5353
keys:
54-
- v33-standalone-dependency-cache-{{ .Branch }}-{{ checksum
54+
- v34-standalone-dependency-cache-{{ .Branch }}-{{ checksum
5555
"standalone-packages/codesandbox-browserfs/yarn.lock" }}
56-
- v33-standalone-dependency-cache-{{ .Branch }}
57-
- v33-standalone-dependency-cache
56+
- v34-standalone-dependency-cache-{{ .Branch }}
57+
- v34-standalone-dependency-cache
5858

5959
- &save_standalone_deps_cache
6060
key:
61-
v33-standalone-dependency-cache-{{ .Branch }}-{{ checksum
61+
v34-standalone-dependency-cache-{{ .Branch }}-{{ checksum
6262
"standalone-packages/codesandbox-browserfs/yarn.lock" }}
6363
paths:
6464
- standalone-packages/codesandbox-browserfs/node_modules
6565

6666
- &restore_prod_homepage_cache
67-
key: v33-prod-homepage-build-cache-master
67+
key: v34-prod-homepage-build-cache-master
6868

6969
- &restore_prod_result
7070
key:
71-
v33-prod-build-result-{{ .Environment.CIRCLE_BRANCH
71+
v34-prod-build-result-{{ .Environment.CIRCLE_BRANCH
7272
}}-{{.Environment.CIRCLE_SHA1 }}
7373

7474
- &save_prod_build_cache
7575
key:
76-
v33-prod-build-cache-{{ .Environment.CIRCLE_BRANCH
76+
v34-prod-build-cache-{{ .Environment.CIRCLE_BRANCH
7777
}}-{{.Environment.CIRCLE_SHA1 }}
7878
paths:
7979
- packages/app/node_modules/.cache
8080

8181
- &restore_prod_build_cache
8282
keys:
83-
- v33-prod-build-cache-{{ .Environment.CIRCLE_BRANCH
83+
- v34-prod-build-cache-{{ .Environment.CIRCLE_BRANCH
8484
}}-{{.Environment.CIRCLE_SHA1 }}
85-
- v33-prod-build-cache-{{ .Environment.CIRCLE_BRANCH }}-
86-
- v33-prod-build-cache-master-
85+
- v34-prod-build-cache-{{ .Environment.CIRCLE_BRANCH }}-
86+
- v34-prod-build-cache-master-
8787

8888
# To persist the images built by sharp
8989
- &save_prod_homepage_cache
9090
key:
91-
v33-prod-homepage-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{
91+
v34-prod-homepage-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{
9292
.Environment.CIRCLE_SHA1 }}
9393
paths:
9494
- ./packages/homepage/public
9595

9696
- &save_prod_result
9797
key:
98-
v33-prod-build-result-{{ .Environment.CIRCLE_BRANCH }}-{{
98+
v34-prod-build-result-{{ .Environment.CIRCLE_BRANCH }}-{{
9999
.Environment.CIRCLE_SHA1 }}
100100
paths:
101101
- ./www
@@ -136,14 +136,14 @@ commands:
136136
steps:
137137
- restore_cache:
138138
keys:
139-
- v33-source-cache-{{ .Branch }}-{{ .Revision }}
140-
- v33-source-cache-{{ .Branch }}-
141-
- v33-source-cache-
139+
- v34-source-cache-{{ .Branch }}-{{ .Revision }}
140+
- v34-source-cache-{{ .Branch }}-
141+
- v34-source-cache-
142142

143143
- checkout
144144

145145
- save_cache:
146-
key: v33-source-cache-{{ .Branch }}-{{ .Revision }}
146+
key: v34-source-cache-{{ .Branch }}-{{ .Revision }}
147147
paths:
148148
- '.git'
149149
build_deps:

.drone.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
- yarn build
2727

2828
- name: deploy
29-
image: lbogdan/codesandbox-deploy-plugin:3
29+
image: lbogdan/codesandbox-deploy-plugin:4
3030
settings:
3131
domain: &domain build.csb.dev
3232
volumes:
@@ -124,7 +124,7 @@ steps:
124124
- yarn build
125125

126126
- name: deploy
127-
image: lbogdan/codesandbox-deploy-plugin:2
127+
image: lbogdan/codesandbox-deploy-plugin:4
128128
settings:
129129
domain: &domain build.csb.dev
130130
volumes:
@@ -177,6 +177,6 @@ trigger:
177177
branch: master
178178
---
179179
kind: signature
180-
hmac: e625eaf2e469b9b6763641d4cc1f089900ef8d8c41db32c6f6aacb27bee8c19c
180+
hmac: a229340365980b689bbe4c5f92d721cf3b6ce176670293a925f329501a054fe4
181181

182182
...

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"javascriptreact",
77
{ "language": "typescript", "autoFix": true },
88
{ "language": "typescriptreact", "autoFix": true }
9-
]
9+
],
10+
"files.watcherExclude": {
11+
"**/node_modules": true,
12+
"**/node_modules/**": false
13+
}
1014
}

packages/app/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"apollo-boost": "^0.4.4",
8787
"apollo-link-batch-http": "^1.2.12",
8888
"apollo-link-context": "^1.0.18",
89+
"astring": "^1.4.3",
8990
"axios": "^0.19.0",
9091
"babel-code-frame": "^6.26.0",
9192
"babel-macros": "^2.0.0",
@@ -115,6 +116,7 @@
115116
"downshift": "^1.0.0-rc.14",
116117
"eslint-plugin-react-hooks": "1.6.0",
117118
"eslint-plugin-vue": "^4.2.2",
119+
"estree-walker": "^1.0.1",
118120
"file-saver": "^1.3.3",
119121
"fontfaceobserver": "^2.0.13",
120122
"fuse.js": "^3.2.1",
@@ -146,6 +148,7 @@
146148
"lodash-es": "^4.17.2",
147149
"lru-cache": "^4.1.3",
148150
"match-sorter": "^1.8.1",
151+
"meriyah": "^1.9.7",
149152
"minimatch": "^3.0.4",
150153
"mobx": "^5.11.0",
151154
"mobx-react": "^6.1.1",
@@ -158,9 +161,9 @@
158161
"normalizr": "^3.2.3",
159162
"onigasm": "^2.2.1",
160163
"ot": "^0.0.15",
161-
"overmind": "^21.0.0-1576231149763",
164+
"overmind": "^22.0.0-1579617484651",
162165
"overmind-devtools": "^19.0.0",
163-
"overmind-react": "^22.0.0-1576231149763",
166+
"overmind-react": "^23.0.0-1579617484651",
164167
"phoenix": "^1.4.11",
165168
"postcss": "^6.0.9",
166169
"postcss-selector-parser": "^2.2.3",
@@ -214,6 +217,7 @@
214217
"subworkers": "^1.0.1",
215218
"svg-react-loader": "^0.4.4",
216219
"tern": "^0.21.0",
220+
"use-interval": "^1.2.1",
217221
"util": "0.11.1",
218222
"vue": "^2.5.2",
219223
"vue-eslint-parser": "^2.0.3",

packages/app/src/app/overmind/effects/live/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ export default {
195195
this.send('live:module_state', {});
196196
}
197197
},
198+
sendExternalResourcesChanged(externalResources: string[]) {
199+
return this.send('sandbox:external-resources', {
200+
externalResources,
201+
});
202+
},
198203
sendUserCurrentModule(moduleShortid: string) {
199204
return this.send('user:current-module', {
200205
moduleShortid,

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,22 @@ export class VSCodeEffect {
157157
]).then(() => this.loadEditor(window.monaco, container));
158158
});
159159

160-
options.reaction(
161-
state =>
162-
!state.live.isLive ||
163-
state.live.roomInfo?.mode === 'open' ||
164-
(state.live.roomInfo?.mode === 'classroom' &&
165-
state.live.isCurrentEditor),
166-
canEdit => {
167-
this.setReadOnly(!canEdit);
168-
}
169-
);
160+
// Only set the read only state when the editor is initialized.
161+
this.initialized.then(() => {
162+
// ReadOnly mode is derivative, it's based on a couple conditions, of which the
163+
// most important one is Live. If you're in a classroom live session as spectator,
164+
// you should not be allowed to edit.
165+
options.reaction(
166+
state =>
167+
!state.live.isLive ||
168+
state.live.roomInfo?.mode === 'open' ||
169+
(state.live.roomInfo?.mode === 'classroom' &&
170+
state.live.isCurrentEditor),
171+
canEdit => {
172+
this.setReadOnly(!canEdit);
173+
}
174+
);
175+
});
170176

171177
return this.initialized;
172178
}

packages/app/src/app/overmind/effects/vscode/initializers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function initializeCustomTheme() {
124124

125125
installCustomTheme(
126126
'codesandbox-black-0.0.1',
127-
'CodeSandbox Black',
127+
'CodeSandbox Black.',
128128
JSON.stringify(codeSandboxBlackTheme)
129129
);
130130
}

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
6666
// This happens when we fork. This can be avoided with state first routing
6767
if (state.editor.isForkingSandbox) {
6868
effects.vscode.openModule(state.editor.currentModule);
69+
70+
await actions.editor.internal.initializeLiveSandbox(
71+
state.editor.currentSandbox
72+
);
73+
6974
state.editor.isForkingSandbox = false;
7075
return;
7176
}

packages/app/src/app/overmind/namespaces/editor/internalActions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ export const saveCode: AsyncAction<{
9797
return;
9898
}
9999

100-
module.code = code;
100+
if (module.code !== code) {
101+
actions.editor.codeChanged({ moduleShortid, code });
102+
}
101103

102104
try {
103105
const updatedModule = await effects.api.saveModuleCode(sandbox.id, module);

packages/app/src/app/overmind/namespaces/live/actions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const roomJoined: AsyncAction<{
2828
return;
2929
}
3030

31-
await effects.vscode.initialize;
31+
await effects.vscode.initialized;
3232
await effects.vscode.closeAllTabs();
3333

3434
if (state.live.isLive) {
@@ -97,6 +97,7 @@ export const liveMessageReceived: Operator<LiveMessage> = pipe(
9797
[LiveMessageEvent.MODULE_STATE]: liveMessage.onModuleState,
9898
[LiveMessageEvent.USER_ENTERED]: liveMessage.onUserEntered,
9999
[LiveMessageEvent.USER_LEFT]: liveMessage.onUserLeft,
100+
[LiveMessageEvent.EXTERNAL_RESOURCES]: liveMessage.onExternalResources,
100101
[LiveMessageEvent.MODULE_SAVED]: liveMessage.onModuleSaved,
101102
[LiveMessageEvent.MODULE_CREATED]: liveMessage.onModuleCreated,
102103
[LiveMessageEvent.MODULE_MASS_CREATED]: liveMessage.onModuleMassCreated,
@@ -193,13 +194,11 @@ export const onRemoveEditorClicked: Action<any> = (
193194
export const onSessionCloseClicked: Action = ({ actions, effects }) => {
194195
effects.live.sendClosed();
195196
actions.live.internal.disconnect();
196-
actions.live.internal.reset();
197197
};
198198

199199
export const onNavigateAway: Action = ({ actions, state }) => {
200200
if (state.live.isLive) {
201201
actions.live.internal.disconnect();
202-
actions.live.internal.reset();
203202
}
204203
};
205204

packages/app/src/app/overmind/namespaces/live/internalActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export const reset: Action = ({ state, actions, effects }) => {
4747
effects.live.resetClients();
4848
};
4949

50-
export const disconnect: Action = ({ effects }) => {
51-
effects.live.resetClients();
50+
export const disconnect: Action = ({ effects, actions }) => {
5251
effects.live.disconnect();
52+
actions.live.internal.reset();
5353
};
5454

5555
export const initialize: AsyncAction<string, Sandbox> = async (

packages/app/src/app/overmind/namespaces/live/liveMessageOperators.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export const onJoin: Operator<LiveMessage<{
1717
}>> = mutate(({ effects, state }, { data }) => {
1818
state.live.liveUserId = data.live_user_id;
1919

20-
effects.notificationToast.success(
21-
state.live.isTeam ? 'Connected to Live Team!' : 'Connected to Live!'
22-
);
20+
// Show message to confirm that you've joined a live session if you're not the owner
21+
if (!state.live.isCurrentEditor) {
22+
effects.notificationToast.success('Connected to Live!');
23+
}
2324

2425
if (state.live.reconnecting) {
2526
effects.live.getAllClients().forEach(client => {
@@ -36,6 +37,13 @@ export const onModuleState: Operator<LiveMessage<{
3637
actions.live.internal.initializeModuleState(data.module_state);
3738
});
3839

40+
export const onExternalResources: Operator<LiveMessage<{
41+
externalResources: string[];
42+
}>> = mutate(({ state, actions }, { data }) => {
43+
state.editor.currentSandbox.externalResources = data.externalResources;
44+
actions.editor.internal.updatePreviewCode();
45+
});
46+
3947
export const onUserEntered: Operator<LiveMessage<{
4048
users: any[];
4149
editor_ids: string[];

packages/app/src/app/overmind/namespaces/profile/actions.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ import { Sandbox } from '@codesandbox/common/lib/types';
22
import { Action, AsyncAction } from 'app/overmind';
33
import { withLoadApp } from 'app/overmind/factories';
44

5-
export const profileMounted: AsyncAction<{
6-
username: string;
7-
}> = withLoadApp(async ({ state, effects }, { username }) => {
8-
state.profile.isLoadingProfile = true;
9-
state.profile.notFound = false;
10-
11-
const profile = await effects.api.getProfile(username);
12-
13-
state.profile.profiles[profile.id] = profile;
14-
state.profile.currentProfileId = profile.id;
5+
export const profileMounted: AsyncAction<string> = withLoadApp(
6+
async ({ effects, state }, username) => {
7+
state.profile.isLoadingProfile = true;
8+
state.profile.notFound = false;
9+
10+
const profile = await effects.api.getProfile(username);
11+
12+
state.profile.profiles[profile.id] = profile;
13+
state.profile.currentProfileId = profile.id;
14+
15+
if (
16+
profile.showcasedSandboxShortid &&
17+
!state.editor.sandboxes[profile.showcasedSandboxShortid]
18+
) {
19+
state.editor.sandboxes[
20+
profile.showcasedSandboxShortid
21+
] = await effects.api.getSandbox(profile.showcasedSandboxShortid);
22+
}
1523

16-
if (
17-
profile.showcasedSandboxShortid &&
18-
!state.editor.sandboxes[profile.showcasedSandboxShortid]
19-
) {
20-
state.editor.sandboxes[
21-
profile.showcasedSandboxShortid
22-
] = await effects.api.getSandbox(profile.showcasedSandboxShortid);
24+
state.profile.isLoadingProfile = false;
2325
}
24-
25-
state.profile.isLoadingProfile = false;
26-
});
26+
);
2727

2828
export const sandboxesPageChanged: AsyncAction<{
2929
page: number;

0 commit comments

Comments
 (0)