Skip to content

Commit a2f09c4

Browse files
committed
Merge branch 'release-2.0.0' into release
2 parents f44f531 + bc89b0e commit a2f09c4

Some content is hidden

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

61 files changed

+2618
-1543
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ ML5_LIBRARY_PASS=helloml5
2222
MOBILE_ENABLED=true
2323
MONGO_URL=mongodb://localhost:27017/p5js-web-editor
2424
PORT=8000
25+
PREVIEW_PORT=8002
26+
EDITOR_URL=http://localhost:8000
27+
PREVIEW_URL=http://localhost:8002
2528
S3_BUCKET=<your-s3-bucket>
2629
S3_BUCKET_URL_BASE=<alt-for-s3-url>
2730
SESSION_SECRET=whatever_you_want_this_to_be_it_only_matters_for_production

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"tabWidth": 2,
1515
"trailingComma": "none",
1616
"useTabs": false,
17-
"quoteProps": "as-needed"
17+
"quoteProps": "as-needed",
18+
"endOfLine":"auto"
1819
}

client/components/Nav.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,16 @@ class Nav extends React.PureComponent {
647647
Português
648648
</button>
649649
</li>
650+
<li className="nav__dropdown-item">
651+
<button
652+
onFocus={this.handleFocusForLang}
653+
onBlur={this.handleBlur}
654+
value="de"
655+
onClick={(e) => this.handleLangSelection(e)}
656+
>
657+
Deutsch
658+
</button>
659+
</li>
650660
<li className="nav__dropdown-item">
651661
<button
652662
onFocus={this.handleFocusForLang}

client/i18n.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import i18n from 'i18next';
22
import { initReactI18next } from 'react-i18next';
33
import Backend from 'i18next-http-backend';
4-
import { enUS, es, ja, hi, ptBR } from 'date-fns/locale';
4+
import { enUS, es, ja, hi, ptBR, de } from 'date-fns/locale';
55

66
const fallbackLng = ['en-US'];
7-
const availableLanguages = ['en-US', 'es-419', 'ja', 'hi', 'pt-BR'];
7+
const availableLanguages = ['en-US', 'es-419', 'ja', 'hi', 'pt-BR', 'de'];
88

99
export function languageKeyToLabel(lang) {
1010
const languageMap = {
1111
'en-US': 'English',
1212
'es-419': 'Español',
1313
ja: '日本語',
1414
hi: 'हिन्दी',
15-
'pt-BR': 'Português'
15+
'pt-BR': 'Português',
16+
de: 'Deutsch'
1617
};
1718
return languageMap[lang];
1819
}
@@ -23,6 +24,7 @@ export function languageKeyToDateLocale(lang) {
2324
'es-419': es,
2425
ja,
2526
hi,
27+
de,
2628
'pt-BR': ptBR
2729
};
2830
return languageMap[lang];

client/index.integration.test.jsx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('index.jsx integration', () => {
139139
expect(
140140
screen.getByRole('heading', { name: /preview/i })
141141
).toBeInTheDocument();
142-
const preview = screen.getByRole('main', { name: /sketch output/i });
142+
const preview = screen.getByTitle(/sketch preview/i);
143143
expect(preview).toBeInTheDocument();
144144
});
145145

@@ -152,24 +152,27 @@ describe('index.jsx integration', () => {
152152
expect(screen.getByText('Sketch Files')).toBeInTheDocument();
153153
});
154154

155-
it('clicking on play updates the preview iframe with a srcdoc, stop clears it', () => {
156-
const playButton = screen.getByRole('button', {
157-
name: /play only visual sketch/i
158-
});
159-
const preview = screen.getByRole('main', { name: /sketch output/i });
160-
expect(preview.getAttribute('srcdoc')).toBeFalsy();
161-
act(() => {
162-
fireEvent.click(playButton);
163-
});
164-
165-
expect(preview.getAttribute('srcdoc')).toBeTruthy();
166-
167-
const stopButton = screen.getByRole('button', {
168-
name: /stop sketch/i
169-
});
170-
act(() => {
171-
fireEvent.click(stopButton);
172-
});
173-
expect(preview.getAttribute('srcdoc')).toMatch(/(^|")\s*($|")/);
174-
});
155+
// this test doesn't make sense anymore :/
156+
// how to fix it? could check if sketch gets sent to iframe
157+
// via postmessage or something
158+
// it('clicking on play updates the preview iframe with a srcdoc, stop clears it', () => {
159+
// const playButton = screen.getByRole('button', {
160+
// name: /play only visual sketch/i
161+
// });
162+
// const preview = screen.getByRole('main', { name: /sketch preview/i });
163+
// expect(preview.getAttribute('srcdoc')).toBeFalsy();
164+
// act(() => {
165+
// fireEvent.click(playButton);
166+
// });
167+
168+
// expect(preview.getAttribute('srcdoc')).toBeTruthy();
169+
170+
// const stopButton = screen.getByRole('button', {
171+
// name: /stop sketch/i
172+
// });
173+
// act(() => {
174+
// fireEvent.click(stopButton);
175+
// });
176+
// expect(preview.getAttribute('srcdoc')).toMatch(/(^|")\s*($|")/);
177+
// });
175178
});

client/modules/IDE/actions/ide.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as ActionTypes from '../../../constants';
22
import { clearConsole } from './console';
3+
import { dispatchMessage, MessageTypes } from '../../../utils/dispatcher';
34

45
export function startVisualSketch() {
56
return {
@@ -171,18 +172,6 @@ export function closeShareModal() {
171172
};
172173
}
173174

174-
export function showEditorOptions() {
175-
return {
176-
type: ActionTypes.SHOW_EDITOR_OPTIONS
177-
};
178-
}
179-
180-
export function closeEditorOptions() {
181-
return {
182-
type: ActionTypes.CLOSE_EDITOR_OPTIONS
183-
};
184-
}
185-
186175
export function showKeyboardShortcutModal() {
187176
return {
188177
type: ActionTypes.SHOW_KEYBOARD_SHORTCUT_MODAL
@@ -260,9 +249,23 @@ export function showRuntimeErrorWarning() {
260249
}
261250

262251
export function startSketch() {
263-
return (dispatch) => {
252+
return (dispatch, getState) => {
264253
dispatch(clearConsole());
265-
dispatch(startSketchAndRefresh());
254+
dispatch(startVisualSketch());
255+
dispatch(showRuntimeErrorWarning());
256+
const state = getState();
257+
dispatchMessage({
258+
type: MessageTypes.SKETCH,
259+
payload: {
260+
files: state.files,
261+
basePath: window.location.pathname,
262+
gridOutput: state.preferences.gridOutput,
263+
textOutput: state.preferences.textOutput
264+
}
265+
});
266+
dispatchMessage({
267+
type: MessageTypes.START
268+
});
266269
};
267270
}
268271

@@ -276,6 +279,9 @@ export function startAccessibleSketch() {
276279

277280
export function stopSketch() {
278281
return (dispatch) => {
282+
dispatchMessage({
283+
type: MessageTypes.STOP
284+
});
279285
dispatch(stopAccessibleOutput());
280286
dispatch(stopVisualSketch());
281287
};

client/modules/IDE/actions/preferences.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,24 +159,6 @@ export function setGridOutput(value) {
159159
};
160160
}
161161

162-
export function setSoundOutput(value) {
163-
return (dispatch, getState) => {
164-
dispatch({
165-
type: ActionTypes.SET_SOUND_OUTPUT,
166-
value
167-
});
168-
const state = getState();
169-
if (state.user.authenticated) {
170-
const formParams = {
171-
preferences: {
172-
soundOutput: value
173-
}
174-
};
175-
updatePreferences(formParams, dispatch);
176-
}
177-
};
178-
}
179-
180162
export function setTheme(value) {
181163
// return {
182164
// type: ActionTypes.SET_THEME,
@@ -225,7 +207,6 @@ export function setAllAccessibleOutput(value) {
225207
return (dispatch) => {
226208
dispatch(setTextOutput(value));
227209
dispatch(setGridOutput(value));
228-
dispatch(setSoundOutput(value));
229210
};
230211
}
231212

client/modules/IDE/actions/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function setNewProject(project) {
5454
export function getProject(id, username) {
5555
return (dispatch, getState) => {
5656
dispatch(justOpenedProject());
57-
apiClient
57+
return apiClient
5858
.get(`/${username}/projects/${id}`)
5959
.then((response) => {
6060
dispatch(setProject(response.data));

client/modules/IDE/components/ConsoleInput.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CodeMirror from 'codemirror';
44
import { Encode } from 'console-feed';
55

66
import RightArrowIcon from '../../../images/right-arrow.svg';
7-
import { dispatch } from '../../../utils/dispatcher';
7+
import { dispatchMessage, MessageTypes } from '../../../utils/dispatcher';
88

99
// heavily inspired by
1010
// https://github.com/codesandbox/codesandbox-client/blob/92a1131f4ded6f7d9c16945dc7c18aa97c8ada27/packages/app/src/app/components/Preview/DevTools/Console/Input/index.tsx
@@ -19,7 +19,8 @@ class ConsoleInput extends React.Component {
1919
}
2020

2121
componentDidMount() {
22-
this._cm = CodeMirror(this.codemirrorContainer, { // eslint-disable-line
22+
this._cm = CodeMirror(this.codemirrorContainer, {
23+
// eslint-disable-line
2324
theme: `p5-${this.props.theme}`,
2425
scrollbarStyle: null,
2526
keymap: 'sublime',
@@ -39,9 +40,12 @@ class ConsoleInput extends React.Component {
3940
{ log: Encode({ method: 'command', data: [value] }) }
4041
];
4142
const consoleEvent = [{ method: 'command', data: [value] }];
42-
dispatch({
43-
source: 'console',
44-
messages
43+
dispatchMessage({
44+
type: MessageTypes.EXECUTE,
45+
payload: {
46+
source: 'console',
47+
messages
48+
}
4549
});
4650
this.props.dispatchConsoleEvent(consoleEvent);
4751
cm.setValue('');

0 commit comments

Comments
 (0)