Skip to content

Commit f531c99

Browse files
committed
Initial commit.
0 parents  commit f531c99

File tree

450 files changed

+73496
-0
lines changed

Some content is hidden

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

450 files changed

+73496
-0
lines changed

.babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "presets": ["react", "es2015", "stage-0"] }

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
/node_modules/
3+
/dist/
4+
/semantic/dist/

App/constants/ActionTypes.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
export const TOGGLE_COMPACT_CODE = 'TOGGLE_COMPACT_CODE'
3+
export const TOGGLE_SELF_DEFENDING = 'TOGGLE_SELF_DEFENDING'
4+
export const TOGGLE_DISABLE_CONSOLE_OUTPUT = 'TOGGLE_DISABLE_CONSOLE_OUTPUT'
5+
6+
export const TOGGLE_DEBUG_PROTECTION = 'TOGGLE_DEBUG_PROTECTION'
7+
export const TOGGLE_DEBUG_PROTECTION_INTERVAL = 'TOGGLE_DEBUG_PROTECTION_INTERVAL'
8+
9+
export const SET_SOURCEMAP_MODE = 'SET_SOURCEMAP_MODE'
10+
export const SET_SOURCEMAP_BASE_URL = 'SET_SOURCEMAP_BASE_URL'
11+
export const SET_SOURCEMAP_FILE_NAME = 'SET_SOURCEMAP_FILE_NAME'
12+
13+
export const SET_UNICODE_ARRAY_THRESHOLD = 'SET_UNICODE_ARRAY_THRESHOLD'
14+
export const TOGGLE_ROTATE_UNICODE_ARRAY = 'TOGGLE_ROTATE_UNICODE_ARRAY'
15+
export const TOGGLE_UNICODE_ARRAY = 'TOGGLE_UNICODE_ARRAY'
16+
export const TOGGLE_WRAP_UNICODE_ARRAY_CALLS = 'TOGGLE_WRAP_UNICODE_ARRAY_CALLS'
17+
export const TOGGLE_ENCODE_UNICODE_LITERALS = 'TOGGLE_ENCODE_UNICODE_LITERALS'
18+
19+
export const ADD_DOMAIN_LOCK = 'ADD_DOMAIN_LOCK'
20+
export const REMOVE_DOMAIN_LOCK = 'REMOVE_DOMAIN_LOCK'
21+
22+
export const ADD_RESERVED_NAME = 'ADD_RESERVED_NAME'
23+
export const REMOVE_RESERVED_NAME = 'REMOVE_RESERVED_NAME'

App/containers/Editor.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React, { Component } from 'react';
2+
3+
import Codemirror from 'react-codemirror';
4+
5+
require('codemirror/lib/codemirror.css');
6+
require('codemirror/mode/javascript/javascript');
7+
8+
9+
class Editor extends Component {
10+
constructor(props) {
11+
super(props);
12+
this.state = {
13+
code: props.value,
14+
}
15+
this.updateCode = this.updateCode.bind(this);
16+
}
17+
18+
componentDidMount () {
19+
this.refs.editor.getCodeMirror().execCommand('selectAll');
20+
}
21+
22+
componentWillReceiveProps (nextProps) {
23+
// console.log (nextProps);
24+
this.setState({
25+
code: nextProps.value
26+
});
27+
}
28+
29+
updateCode (newCode) {
30+
this.setState({
31+
code: newCode
32+
});
33+
this.props.onChange(newCode);
34+
}
35+
36+
render () {
37+
var options = {
38+
lineNumbers: true,
39+
mode: 'javascript',
40+
autofocus: true,
41+
};
42+
return (
43+
<Codemirror ref='editor' value={this.state.code} onChange={this.updateCode} options={options} />
44+
)
45+
}
46+
47+
}
48+
49+
export default Editor;

App/containers/EntryInput.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React, { Component } from 'react';
2+
import { Form } from 'semantic-ui-react';
3+
4+
class EntryInput extends React.Component {
5+
6+
static propTypes = {
7+
label: React.PropTypes.string,
8+
actionAddEntryToState: React.PropTypes.func.isRequired,
9+
actionRemoveEntryFromState: React.PropTypes.func.isRequired,
10+
entries: React.PropTypes.array.isRequired,
11+
placeholder: React.PropTypes.string,
12+
buttonIcon: React.PropTypes.string,
13+
}
14+
15+
constructor(props) {
16+
super(props);
17+
18+
this.state = {
19+
value: '',
20+
}
21+
22+
this.handleAdd = this.handleAdd.bind(this);
23+
24+
}
25+
26+
handleAdd(event) {
27+
event.preventDefault();
28+
this.props.actionAddEntryToState(this.state.value);
29+
this.setState({
30+
value: '',
31+
})
32+
}
33+
34+
handleRemove(entry) {
35+
this.props.actionRemoveEntryFromState(entry)
36+
}
37+
38+
handleOnChange(value) {
39+
this.setState({
40+
value: value,
41+
})
42+
}
43+
44+
render() {
45+
const {entries, label, buttonIcon, placeholder} = this.props;
46+
47+
return (
48+
<div>
49+
<Form.Input
50+
label={label}
51+
onChange={(event) => this.handleOnChange(event.target.value) }
52+
value={this.state.value}
53+
action={{ icon: buttonIcon, onClick:this.handleAdd}}
54+
placeholder={placeholder}
55+
/>
56+
<Labels entries={entries} onCloseClick={::this.handleRemove}/>
57+
</div>
58+
);
59+
60+
}
61+
62+
}
63+
64+
export default EntryInput;
65+
66+
const Labels = ({entries, onCloseClick}) =>
67+
<div className="ui labels">
68+
{entries.map(entry =>
69+
<span className="ui label" key={entry}>
70+
{entry}
71+
<i onClick={() => onCloseClick(entry)} className="icon close"></i>
72+
</span>
73+
)}
74+
</div>

App/containers/Options.js

+242
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
2+
import React, { Component } from 'react';
3+
import {render} from 'react-dom';
4+
5+
import classNames from 'classnames';
6+
import Dropzone from 'react-dropzone';
7+
8+
import { Form } from 'stardust';
9+
import { Grid, Segment, Divider } from 'semantic-ui-react';
10+
11+
import * as types from '../constants/ActionTypes';
12+
13+
import EntryInput from '../containers/EntryInput';
14+
15+
16+
export const SOURCEMAP_OFF = 'off'
17+
export const SOURCEMAP_INLINE = 'inline'
18+
export const SOURCEMAP_SEPARATE = 'separate'
19+
20+
const SOURCEMAP_OPTIONS = [
21+
{ text: 'Off', value: SOURCEMAP_OFF },
22+
{ text: 'Inline', value: SOURCEMAP_INLINE },
23+
{ text: 'Separate', value: SOURCEMAP_SEPARATE },
24+
];
25+
26+
27+
class Options extends React.Component {
28+
29+
componentWillMount() {
30+
this.store = this.context.store;
31+
}
32+
33+
toggleOption(optionType) {
34+
this.store.dispatch({
35+
'type': optionType,
36+
});
37+
}
38+
39+
addDomainLock(domain) {
40+
this.store.dispatch({
41+
'type': types.ADD_DOMAIN_LOCK,
42+
domain,
43+
});
44+
}
45+
46+
removeDomainLock(domain) {
47+
this.store.dispatch({
48+
'type': types.REMOVE_DOMAIN_LOCK,
49+
domain,
50+
});
51+
}
52+
53+
addReservedName(name) {
54+
this.store.dispatch({
55+
'type': types.ADD_RESERVED_NAME,
56+
name,
57+
});
58+
}
59+
60+
removeReservedName(name) {
61+
this.store.dispatch({
62+
'type': types.REMOVE_RESERVED_NAME,
63+
name,
64+
});
65+
}
66+
67+
handleUnicodeThreshold(threshold) {
68+
this.store.dispatch({
69+
'type': types.SET_UNICODE_ARRAY_THRESHOLD,
70+
threshold,
71+
});
72+
}
73+
74+
handleSourceMapMode(mode) {
75+
this.store.dispatch({
76+
'type': types.SET_SOURCEMAP_MODE,
77+
mode,
78+
});
79+
}
80+
81+
handleSourceMapBaseUrl(baseUrl) {
82+
this.store.dispatch({
83+
'type': types.SET_SOURCEMAP_BASE_URL,
84+
baseUrl,
85+
});
86+
}
87+
88+
handleSourceMapFileName(fileName) {
89+
this.store.dispatch({
90+
'type': types.SET_SOURCEMAP_FILE_NAME,
91+
fileName,
92+
});
93+
}
94+
95+
render() {
96+
const state = this.store.getState().options;
97+
98+
return (
99+
<Form>
100+
<Grid columns={4} relaxed>
101+
<Grid.Column>
102+
<Segment basic>
103+
104+
<Form.Checkbox
105+
label='Compact code'
106+
checked={state.compactCode}
107+
onChange={() => this.toggleOption(types.TOGGLE_COMPACT_CODE) } />
108+
109+
<Form.Checkbox
110+
label='Self Defending'
111+
checked={state.selfDefending}
112+
onChange={() => this.toggleOption(types.TOGGLE_SELF_DEFENDING) } />
113+
114+
<Divider />
115+
116+
<Form.Checkbox
117+
label='Disable Console Output'
118+
checked={state.disableConsoleOutput}
119+
onChange={() => this.toggleOption(types.TOGGLE_DISABLE_CONSOLE_OUTPUT) } />
120+
121+
<Divider />
122+
123+
<Form.Checkbox
124+
label='Debug Protection'
125+
checked={state.debugProtection}
126+
onChange={() => this.toggleOption(types.TOGGLE_DEBUG_PROTECTION) } />
127+
128+
<Form.Checkbox
129+
label='Debug Protection Interval'
130+
checked={state.debugProtectionInterval}
131+
disabled={!state.debugProtection}
132+
onChange={() => this.toggleOption(types.TOGGLE_DEBUG_PROTECTION_INTERVAL) } />
133+
134+
</Segment>
135+
</Grid.Column>
136+
137+
<Divider vertical />
138+
139+
<Grid.Column>
140+
<Segment basic>
141+
142+
<Form.Checkbox
143+
label='Unicode Array'
144+
checked={state.unicodeArray}
145+
onChange={() => this.toggleOption(types.TOGGLE_UNICODE_ARRAY) } />
146+
147+
<Form.Checkbox
148+
label='Rotate Unicode Array'
149+
checked={state.rotateUnicodeArray}
150+
disabled={!state.rotateUnicodeArrayEnabled}
151+
onChange={() => this.toggleOption(types.TOGGLE_ROTATE_UNICODE_ARRAY) } />
152+
153+
<Form.Checkbox
154+
label='Wrap Unicode Array Calls'
155+
checked={state.wrapUnicodeArrayCalls}
156+
disabled={!state.wrapUnicodeArrayCallsEnabled}
157+
onChange={() => this.toggleOption(types.TOGGLE_WRAP_UNICODE_ARRAY_CALLS) } />
158+
159+
<Form.Checkbox
160+
label='Encode Unicode Array Calls'
161+
checked={state.encodeUnicodeLiterals}
162+
disabled={!state.encodeUnicodeLiteralsEnabled}
163+
onChange={() => this.toggleOption(types.TOGGLE_ENCODE_UNICODE_LITERALS) } />
164+
165+
<Form.Input
166+
type='number'
167+
label='Unicode Array Threshold'
168+
defaultValue={state.unicodeArrayThreshold}
169+
min="0"
170+
max="1"
171+
step="0.1"
172+
onChange={(event) => this.handleUnicodeThreshold(event.target.value) }
173+
disabled={!state.unicodeArrayThresholdEnabled} />
174+
175+
</Segment>
176+
</Grid.Column>
177+
178+
<Divider vertical />
179+
180+
<Grid.Column>
181+
<Segment basic>
182+
183+
<Form.Select
184+
label='Sourcemaps'
185+
value={state.sourceMapMode}
186+
onChange={(event, value) => this.handleSourceMapMode(value) }
187+
options={SOURCEMAP_OPTIONS} />
188+
189+
<Form.Input
190+
label='Source Map Base URL'
191+
disabled={!state.sourceMapSeparate}
192+
onBlur={(event) => this.handleSourceMapBaseUrl(event.target.value) }
193+
defaultValue={state.sourceMapBaseUrl}
194+
placeholder='http://localhost:3000' />
195+
196+
<Form.Input
197+
label='Source Map File Name'
198+
disabled={!state.sourceMapSeparate}
199+
onChange={(event) => this.handleSourceMapFileName(event.target.value) }
200+
value={state.sourMapFileName}
201+
placeholder='example' />
202+
203+
</Segment>
204+
</Grid.Column>
205+
206+
<Divider vertical />
207+
<Grid.Column>
208+
<Segment basic>
209+
210+
<EntryInput
211+
label='Add a domain lock'
212+
actionAddEntryToState={::this.addDomainLock}
213+
actionRemoveEntryFromState={::this.removeDomainLock}
214+
placeholder="domain.com"
215+
entries={state.domainLock}
216+
buttonIcon="plus" />
217+
218+
<EntryInput
219+
label='Reserved Names'
220+
actionAddEntryToState={::this.addReservedName}
221+
actionRemoveEntryFromState={::this.removeReservedName}
222+
placeholder="^someVariable"
223+
entries={state.reservedNames}
224+
buttonIcon="plus" />
225+
226+
</Segment>
227+
</Grid.Column>
228+
229+
</Grid>
230+
</Form>
231+
232+
);
233+
234+
}
235+
236+
}
237+
238+
Options.contextTypes = {
239+
store: React.PropTypes.object
240+
};
241+
242+
export default Options;

0 commit comments

Comments
 (0)