Skip to content

Commit ab3bf02

Browse files
committed
Improved source map option
1 parent 64b4816 commit ab3bf02

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

App/actions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const resetOptions = () => {
5656
dispatch({
5757
'type': types.RESET_OPTIONS,
5858
});
59-
setOptionsPreset(OPTIONS_PRESET_DEFAULT);
59+
dispatch(setOptionsPreset(OPTIONS_PRESET_DEFAULT));
6060
};
6161
};
6262

App/constants/ActionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const TOGGLE_DISABLE_CONSOLE_OUTPUT = 'TOGGLE_DISABLE_CONSOLE_OUTPUT';
1919
export const TOGGLE_DEBUG_PROTECTION = 'TOGGLE_DEBUG_PROTECTION';
2020
export const TOGGLE_DEBUG_PROTECTION_INTERVAL = 'TOGGLE_DEBUG_PROTECTION_INTERVAL';
2121

22+
export const TOGGLE_SOURCEMAP = 'TOGGLE_SOURCEMAP';
2223
export const SET_SOURCEMAP_MODE = 'SET_SOURCEMAP_MODE';
2324
export const SET_SOURCEMAP_BASE_URL = 'SET_SOURCEMAP_BASE_URL';
2425
export const SET_SOURCEMAP_FILE_NAME = 'SET_SOURCEMAP_FILE_NAME';

App/containers/OptionsContainer.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ const OPTIONS_PRESET_OPTIONS = [
2222
{text: 'high', value: OPTIONS_PRESET_HIGH_OBFUSCATION},
2323
];
2424

25-
export const SOURCEMAP_OFF = 'off';
2625
export const SOURCEMAP_INLINE = 'inline';
2726
export const SOURCEMAP_SEPARATE = 'separate';
2827

2928
const SOURCEMAP_OPTIONS = [
30-
{text: 'Off', value: SOURCEMAP_OFF},
3129
{text: 'Inline', value: SOURCEMAP_INLINE},
3230
{text: 'Separate', value: SOURCEMAP_SEPARATE},
3331
];
@@ -214,7 +212,7 @@ const Options = ({dispatch, options}) => {
214212
value={options.stringArrayThreshold}
215213
min="0"
216214
max="1"
217-
step="0.1"
215+
step="0.05"
218216
onChange={(event, {value}) => dispatch(actions.setStringArrayThreshold(parseFloat(value)))}
219217
disabled={!options.stringArrayThresholdEnabled}/>
220218

@@ -319,23 +317,29 @@ const Options = ({dispatch, options}) => {
319317
<Grid.Column>
320318
<Segment basic>
321319

320+
<Form.Checkbox
321+
label='Enable Source Map'
322+
checked={options.sourceMap}
323+
onChange={() => dispatch(actions.toggleOption(types.TOGGLE_SOURCEMAP))}/>
324+
322325
<Form.Select
323-
label='Sourcemaps'
326+
label='Source Map Mode'
324327
value={options.sourceMapMode}
328+
disabled={!options.sourceMap}
325329
fluid
326330
onChange={(event, {value}) => dispatch(actions.setSourceMapMode(value))}
327331
options={SOURCEMAP_OPTIONS}/>
328332

329333
<Form.Input
330334
label='Source Map Base URL'
331-
disabled={!options.sourceMapSeparate}
335+
disabled={!options.sourceMap || options.sourceMapMode !== SOURCEMAP_SEPARATE}
332336
onChange={(event, {value}) => dispatch(actions.setSourceMapBaseUrl(value))}
333337
value={options.sourceMapBaseUrl}
334338
placeholder='http://localhost:3000'/>
335339

336340
<Form.Input
337341
label='Source Map File Name'
338-
disabled={!options.sourceMapSeparate}
342+
disabled={!options.sourceMap || options.sourceMapMode !== SOURCEMAP_SEPARATE}
339343
onChange={(event, {value}) => dispatch(actions.setSourceMapFileName(value))}
340344
value={options.sourceMapFileName}
341345
placeholder='example'/>

App/reducers/options.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const initialState = {
3636

3737
simplify: true,
3838

39-
stringArrayThreshold: 0.8,
39+
stringArrayThreshold: 0.75,
4040
stringArrayThresholdEnabled: true,
4141

4242
stringArrayEncoding: [
@@ -47,10 +47,9 @@ const initialState = {
4747
numbersToExpressions: false,
4848

4949
sourceMap: false,
50-
sourceMapMode: SOURCEMAP_OFF,
50+
sourceMapMode: SOURCEMAP_SEPARATE,
5151
sourceMapBaseUrl: '',
5252
sourceMapFileName: '',
53-
sourceMapSeparate: false,
5453

5554
domainLock: [],
5655
domainLockEnabled: true,
@@ -203,13 +202,18 @@ export const options = (state = initialState, action) => {
203202
stringArrayThreshold: action.threshold
204203
};
205204

205+
case types.TOGGLE_SOURCEMAP: {
206+
return {
207+
...state,
208+
sourceMap: !state.sourceMap
209+
};
210+
}
211+
206212
case types.SET_SOURCEMAP_MODE: {
207213
const mode = action.mode;
208214
return {
209215
...state,
210-
sourceMap: mode !== SOURCEMAP_OFF,
211-
sourceMapMode: mode,
212-
sourceMapSeparate: mode === SOURCEMAP_SEPARATE
216+
sourceMapMode: mode
213217
};
214218
}
215219

0 commit comments

Comments
 (0)