Skip to content

Commit 1efa6ee

Browse files
authored
Dependency cleanup (codesandbox#1742)
1 parent a11878f commit 1efa6ee

File tree

28 files changed

+389
-332
lines changed

28 files changed

+389
-332
lines changed

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"add-contributor": "all-contributors add",
2626
"generate": "all-contributors generate",
2727
"precommit": "lint-staged",
28-
"postinstall": "rimraf node_modules/@types packages/app/node_modules/styled-components node_modules/react-split-pane/node_modules/react* && cp -R node_modules/uglify-es node_modules/terser && yarn lerna run install-dependencies --scope vscode-textmate --scope codesandbox-browserfs --scope sse-loading-screen --stream && opencollective postinstall",
28+
"postinstall": "rimraf node_modules/@types/react-native && rimraf packages/app/node_modules/styled-components node_modules/react-split-pane/node_modules/react* && cp -R node_modules/uglify-es node_modules/terser && yarn lerna run install-dependencies --scope vscode-textmate --scope codesandbox-browserfs --scope sse-loading-screen --stream && opencollective postinstall",
2929
"typecheck": "lerna run typecheck --scope app"
3030
},
3131
"lint-staged": {
@@ -49,18 +49,16 @@
4949
"packages/dynamic-pages"
5050
],
5151
"nohoist": [
52-
"**/@types",
53-
"**/@types/**",
5452
"**/react-codemirror2",
5553
"**/react-codemirror2/**"
5654
]
5755
},
5856
"resolutions": {
5957
"uglify-es": "npm:terser",
60-
"react-split-pane/react-dom": "^16.8.3"
58+
"react-split-pane/react-dom": "^16.8.6"
6159
},
6260
"devDependencies": {
63-
"@types/react": "^16.8.6",
61+
"@types/react": "^16.8.12",
6462
"all-contributors-cli": "^5.4.0",
6563
"babel-eslint": "^8.2.1",
6664
"eslint": "CompuIves/eslint#add/define-parser",
@@ -77,7 +75,7 @@
7775
"lerna": "^2.5.1",
7876
"lint-staged": "^5.0.0",
7977
"prettier": "^1.8.2",
80-
"typescript": "^3.3.1"
78+
"typescript": "^3.4.2"
8179
},
8280
"dependencies": {
8381
"opencollective": "^1.0.3"

packages/app/config/babel.dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ module.exports = {
3636
require.resolve('@babel/plugin-syntax-dynamic-import'),
3737
require.resolve('babel-plugin-styled-components'),
3838
require.resolve('babel-plugin-macros'),
39+
require.resolve('babel-plugin-graphql-tag'),
3940
],
4041
};

packages/app/config/babel.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
require.resolve('@babel/plugin-syntax-dynamic-import'),
3333
require.resolve('babel-plugin-styled-components'),
3434
require.resolve('babel-plugin-macros'),
35+
require.resolve('babel-plugin-graphql-tag'),
3536
// Optimization: hoist JSX that never changes out of render()
3637
// Disabled because of issues:
3738
// * https://github.com/facebookincubator/create-react-app/issues/525

packages/app/integration-tests/tests/__image_snapshots__/github-reactjs-redux-tree-master-examples-real-world-snap.png renamed to packages/app/integration-tests/tests/__image_snapshots__/github-reduxjs-redux-tree-master-examples-real-world-snap.png

File renamed without changes.

packages/app/integration-tests/tests/__image_snapshots__/github-reactjs-redux-tree-master-examples-todomvc-snap.png renamed to packages/app/integration-tests/tests/__image_snapshots__/github-reduxjs-redux-tree-master-examples-todomvc-snap.png

File renamed without changes.

packages/app/integration-tests/tests/sandboxes.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const SANDBOXES = [
66
'vue',
77
'svelte',
88
'react-ts',
9-
{ id: 'github/reactjs/redux/tree/master/examples/todomvc', threshold: 0.04 },
9+
{ id: 'github/reduxjs/redux/tree/master/examples/todomvc', threshold: 0.04 },
1010
'vVoQVk78',
1111
'github/faceyspacey/redux-first-router-codesandbox/tree/master',
1212
'mZRjw05yp',
1313
'o29j95wx9',
1414
'k3q1zjjml5',
15-
'github/reactjs/redux/tree/master/examples/real-world',
15+
'github/reduxjs/redux/tree/master/examples/real-world',
1616
'github/CompuIves/codesandbox-presentation',
1717
'lp5rjr0z4z',
1818
'nOymMxyY',

packages/app/package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@babel/plugin-transform-runtime": "^7.1.0",
3636
"@babel/plugin-transform-template-literals": "^7.0.0",
3737
"@babel/polyfill": "^7.0.0",
38-
"@babel/preset-env": "^7.1.0",
3938
"@babel/preset-flow": "^7.0.0",
4039
"@babel/preset-react": "^7.0.0",
4140
"@babel/preset-typescript": "^7.1.0",
@@ -44,17 +43,19 @@
4443
"@types/gsap": "^1.20.1",
4544
"@types/jest": "^24.0.11",
4645
"@types/lodash-es": "^4.17.2",
47-
"@types/react": "^16.8.3",
48-
"@types/react-dom": "^16.0.11",
46+
"@types/prop-types": "^15.7.0",
47+
"@types/react": "^16.8.12",
48+
"@types/react-dom": "^16.8.3",
4949
"@types/react-icons": "2.2.7",
5050
"@types/resolve": "^0.0.8",
5151
"@types/socket.io-client": "^1.4.32",
52-
"@types/styled-components": "^4.1.6",
52+
"@types/styled-components": "^4.1.13",
5353
"autoprefixer": "8.5.0",
5454
"babel-core": "7.0.0-bridge.0",
5555
"babel-jest": "^23.6.0",
5656
"babel-loader": "8.0.2",
5757
"babel-plugin-codegen": "^1.2.0",
58+
"babel-plugin-graphql-tag": "^2.1.0",
5859
"babel-plugin-lodash": "^3.3.4",
5960
"babel-plugin-styled-components": "^1.9.4",
6061
"babel-plugin-syntax-dynamic-import": "^6.18.0",
@@ -111,7 +112,7 @@
111112
"style-loader": "^0.21.0",
112113
"sw-precache-webpack-plugin": "^0.11.5",
113114
"terser": "^3.8.0",
114-
"typescript": "^3.3.1",
115+
"typescript": "^3.4.2",
115116
"uglifyjs-webpack-plugin": "^1.2.5",
116117
"url-loader": "1.0.1",
117118
"webpack": "^4.10.2",
@@ -134,7 +135,7 @@
134135
"@svgr/core": "^2.4.1",
135136
"@vue/babel-preset-app": "^3.2.0",
136137
"airtable": "^0.5.8",
137-
"apollo-boost": "^0.1.7",
138+
"apollo-boost": "^0.3.1",
138139
"apollo-link-batch-http": "^1.2.2",
139140
"apollo-link-context": "^1.0.8",
140141
"axios": "^0.16.2",
@@ -178,8 +179,8 @@
178179
"fuse.js": "^3.2.1",
179180
"geniejs": "^0.5.1",
180181
"glamor": "^2.20.25",
181-
"graphql": "^0.11.7",
182-
"graphql-tag": "^2.9.2",
182+
"graphql": "^14.1.1",
183+
"graphql-tag": "^2.10.1",
183184
"gsap": "^1.20.3",
184185
"gulp": "^3.9.1",
185186
"gulp-filter": "^5.0.0",
@@ -222,13 +223,13 @@
222223
"qs": "^6.5.0",
223224
"querystring": "^0.2.0",
224225
"rc-slider": "^8.2.0",
225-
"react": "^16.8.3",
226+
"react": "^16.8.6",
226227
"react-addons-css-transition-group": "^15.6.0",
227-
"react-apollo": "^2.1.4",
228+
"react-apollo": "^2.5.4",
228229
"react-day-picker": "^7.2.4",
229230
"react-dnd": "^7.0.2",
230231
"react-dnd-html5-backend": "^2.4.1",
231-
"react-dom": "^16.8.3",
232+
"react-dom": "^16.8.6",
232233
"react-draggable": "^3.0.5",
233234
"react-error-overlay": "^1.0.10",
234235
"react-icons": "^2.2.7",
@@ -251,7 +252,7 @@
251252
"shortid": "^2.2.8",
252253
"store": "^2.0.12",
253254
"string-replace-loader": "^2.1.1",
254-
"styled-components": "^4.1.2",
255+
"styled-components": "^4.2.0",
255256
"subworkers": "^1.0.1",
256257
"svg-react-loader": "^0.4.4",
257258
"tern": "^0.21.0",

packages/app/src/app/pages/Dashboard/Content/SandboxCard/KebabIcon.js renamed to packages/app/src/app/pages/Dashboard/Content/SandboxCard/KebabIcon.tsx

File renamed without changes.

packages/app/src/app/pages/Dashboard/Content/SandboxCard/elements.js renamed to packages/app/src/app/pages/Dashboard/Content/SandboxCard/elements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export const Container = styled.div`
1717
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
1818
`;
1919

20-
export const StyledContextMenu = styled(ContextMenu)`
20+
export const StyledContextMenu = styled(ContextMenu)<{
21+
isDraggingItem: boolean;
22+
}>`
2123
padding-right: ${PADDING}px;
2224
box-sizing: border-box;
2325
opacity: ${({ isDraggingItem }) => (isDraggingItem ? 0 : 1)};

packages/app/src/app/pages/Dashboard/Content/SandboxCard/index.js renamed to packages/app/src/app/pages/Dashboard/Content/SandboxCard/index.tsx

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Unlisted from 'react-icons/lib/md/insert-link';
1212
import Private from 'react-icons/lib/md/lock';
1313

1414
import Input from '@codesandbox/common/lib/components/Input';
15-
import getTemplate from '@codesandbox/common/lib/templates';
15+
import getTemplate, { TemplateType } from '@codesandbox/common/lib/templates';
1616
import theme from '@codesandbox/common/lib/theme';
1717
import track from '@codesandbox/common/lib/utils/analytics';
1818

@@ -33,27 +33,47 @@ import {
3333
} from './elements';
3434

3535
type Props = {
36-
id: string,
37-
title: string,
38-
details: string,
39-
selected: boolean,
40-
setSandboxesSelected: (ids: string[], additive?: boolean) => void,
41-
deleteSandboxes: () => void,
42-
permanentlyDeleteSandboxes: () => void,
43-
collectionPath: string, // eslint-disable-line react/no-unused-prop-types
44-
collectionTeamId: ?string,
45-
sandbox: Object,
46-
page: ?string,
47-
privacy: number,
48-
isPatron: boolean,
49-
setSandboxesPrivacy: () => void,
50-
undeleteSandboxes: () => void,
36+
id: string;
37+
title: string;
38+
details: string;
39+
selected: boolean;
40+
template: TemplateType;
41+
screenshotUrl: string | undefined;
42+
setSandboxesSelected: (
43+
ids: string[],
44+
options?: { additive?: boolean; range?: boolean }
45+
) => void;
46+
selectedCount: number;
47+
deleteSandboxes: () => void;
48+
permanentlyDeleteSandboxes: () => void;
49+
collectionPath: string; // eslint-disable-line react/no-unused-prop-types
50+
collectionTeamId: string | undefined;
51+
sandbox: Object;
52+
page: string | undefined;
53+
privacy: number;
54+
isPatron: boolean;
55+
setSandboxesPrivacy: (privacy: 0 | 1 | 2) => void;
56+
isScrolling: () => boolean;
57+
undeleteSandboxes: () => void;
58+
removedAt?: number;
59+
style?: React.CSSProperties;
60+
61+
// React-DnD, lazy typings
62+
connectDragSource: any;
63+
isDraggingItem: any;
64+
connectDragPreview: any;
5165
};
5266

53-
class SandboxItem extends React.PureComponent<Props> {
67+
type State = {
68+
renamingSandbox: boolean;
69+
screenshotUrl: string | undefined;
70+
};
71+
72+
class SandboxItem extends React.PureComponent<Props, State> {
5473
el: HTMLDivElement;
74+
screenshotTimeout: number;
5575

56-
state = {
76+
state: State = {
5777
renamingSandbox: false,
5878
screenshotUrl: this.props.screenshotUrl,
5979
};
@@ -85,7 +105,7 @@ class SandboxItem extends React.PureComponent<Props> {
85105
checkScreenshot() {
86106
if (!this.state.screenshotUrl && this.hasScreenshot()) {
87107
// We only request the screenshot if the sandbox card is in view for > 1 second
88-
this.screenshotTimeout = setTimeout(() => {
108+
this.screenshotTimeout = window.setTimeout(() => {
89109
this.requestScreenshot();
90110
}, 1000);
91111
}
@@ -275,21 +295,19 @@ class SandboxItem extends React.PureComponent<Props> {
275295
].filter(Boolean);
276296
};
277297

278-
selectSandbox = e => {
298+
selectSandbox = (e: React.MouseEvent | React.FocusEvent) => {
279299
this.props.setSandboxesSelected([this.props.id], {
280-
additive: e.metaKey,
281-
range: e.shiftKey,
300+
additive: 'metaKey' in e ? e.metaKey : false,
301+
range: 'shiftKey' in e ? e.shiftKey : false,
282302
});
283303
};
284304

285-
openSandbox = (e, openNewWindow = false) => {
286-
// check for cmd click
287-
const cmd = e.ctrlKey || e.metaKey;
288-
// Git sandboxes aren't shown here anyway
305+
openSandbox = (openNewWindow = false) => {
306+
// @ts-ignore Git sandboxes aren't shown here anyway
289307
const url = sandboxUrl({ id: this.props.id });
290308

291309
if (!this.props.removedAt) {
292-
if (openNewWindow === true || cmd) {
310+
if (openNewWindow === true) {
293311
track('Dashboard - Sandbox Opened in a new tab');
294312
window.open(url, '_blank');
295313
} else {
@@ -300,36 +318,36 @@ class SandboxItem extends React.PureComponent<Props> {
300318
return true;
301319
};
302320

303-
handleMouseDown = e => {
321+
handleMouseDown = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
304322
e.stopPropagation();
305323

306324
if (!this.props.selected || e.metaKey) {
307325
this.selectSandbox(e);
308326
}
309327
};
310328

311-
handleKeyDown = (e: KeyboardEvent) => {
329+
handleKeyDown = (e: React.KeyboardEvent) => {
312330
if (e.keyCode === ENTER) {
313331
track('Dashboard - Sandbox Opened With Enter');
314332
// enter
315333
this.openSandbox();
316334
}
317335
};
318336

319-
handleOnContextMenu = e => {
337+
handleOnContextMenu = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
320338
track('Dashboard - Sandbox Context Menu Opened');
321339
if (!this.props.selected) {
322340
this.selectSandbox(e);
323341
}
324342
};
325343

326-
handleOnFocus = e => {
344+
handleOnFocus = (e: React.FocusEvent) => {
327345
if (!this.props.selected) {
328346
this.selectSandbox(e);
329347
}
330348
};
331349

332-
handleOnBlur = (e: MouseEvent) => {
350+
handleOnBlur = (e: React.FocusEvent) => {
333351
if (this.props.selected && e.bubbles) {
334352
this.props.setSandboxesSelected([]);
335353
}
@@ -387,8 +405,8 @@ class SandboxItem extends React.PureComponent<Props> {
387405
details,
388406
template,
389407
connectDragSource,
390-
selected,
391408
isDraggingItem,
409+
selected,
392410
} = this.props;
393411

394412
const { screenshotUrl } = this.state;
@@ -420,7 +438,12 @@ class SandboxItem extends React.PureComponent<Props> {
420438
onContextMenu(e);
421439
this.handleOnContextMenu(e);
422440
}}
423-
onDoubleClick={this.openSandbox}
441+
onDoubleClick={event => {
442+
// check for cmd click
443+
const cmd = event.ctrlKey || event.metaKey;
444+
445+
this.openSandbox(!!cmd);
446+
}}
424447
onBlur={this.handleOnBlur}
425448
onFocus={this.handleOnFocus}
426449
onKeyDown={this.handleKeyDown}
@@ -505,7 +528,6 @@ class SandboxItem extends React.PureComponent<Props> {
505528
onBlur={saveName}
506529
block
507530
defaultValue={title}
508-
small
509531
/>
510532
);
511533
}}

0 commit comments

Comments
 (0)