* chore(packages): Update redux utils * feat(Panes): Invert control of panes map creation * feat(Modern): Add view * feat(Panes): Decouple panes from Challenges * fix(Challenges): Decouple challenge views from panes map * fix(Challenge/views): PanesMap => mapStateToPanesMap This clarifies what these functions are doing * fix(Challenges): Add view type * fix(Panes): Remove unneeded panes container * feat(Panes): Invert control of pane content render This decouples the Panes from the content they render, allowing for greater flexibility. * feat(Modern): Add side panel This is common between modern and classic * feat(seed): Array to string file content * fix(files): Modern files should be polyvinyls * feat(Modern): Create editors per file * fix(seed/React): Incorrect keyfile name * feat(Modern): Highligh jsx correctly This adds highlighting for jsx. Unfortunately, this disables linting for non-javascript files as jshint will only work for those * feat(rechallenge): Add jsx ext to babel transformer * feat(seed): Normalize challenge files head/tail/content * refactor(rechallenge/build): Rename function * fix(code-storage): Pull in files from localStorage * feat(Modern/React): Add Enzyme to test runner This enables testing of React challenges * feat(Modern): Add submission type * refactor(Panes): Rename panes map update action
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import { Observable } from 'rx';
|
|
import { getValues } from 'redux-form';
|
|
import identity from 'lodash/identity';
|
|
|
|
import { fetchScript } from '../utils/fetch-and-cache.js';
|
|
import throwers from '../rechallenge/throwers';
|
|
import {
|
|
applyTransformers,
|
|
proxyLoggerTransformer
|
|
} from '../rechallenge/transformers';
|
|
import {
|
|
cssToHtml,
|
|
jsToHtml,
|
|
concactHtml
|
|
} from '../rechallenge/builders.js';
|
|
import {
|
|
createFileStream,
|
|
pipe
|
|
} from '../../common/utils/polyvinyl.js';
|
|
|
|
|
|
const jQuery = {
|
|
src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'
|
|
};
|
|
const frameRunner = {
|
|
src: '/js/frame-runner.js',
|
|
crossDomain: false,
|
|
cacheBreaker: true
|
|
};
|
|
const globalRequires = [
|
|
{
|
|
link: 'https://cdnjs.cloudflare.com/' +
|
|
'ajax/libs/normalize/4.2.0/normalize.min.css'
|
|
},
|
|
jQuery
|
|
];
|
|
|
|
export function buildFromFiles(files, required, shouldProxyConsole) {
|
|
const finalRequires = [...globalRequires, ...required ];
|
|
return createFileStream(files)
|
|
::pipe(throwers)
|
|
::pipe(applyTransformers)
|
|
::pipe(shouldProxyConsole ? proxyLoggerTransformer : identity)
|
|
::pipe(jsToHtml)
|
|
::pipe(cssToHtml)
|
|
::concactHtml(finalRequires, frameRunner);
|
|
}
|
|
|
|
export function buildBackendChallenge(state) {
|
|
const { solution: url } = getValues(state.form.BackEndChallenge);
|
|
return Observable.combineLatest(
|
|
fetchScript(frameRunner),
|
|
fetchScript(jQuery)
|
|
)
|
|
.map(([ frameRunner, jQuery ]) => ({
|
|
build: jQuery + frameRunner,
|
|
source: { url },
|
|
checkChallengePayload: { solution: url }
|
|
}));
|
|
}
|