Skip to content

Commit 3ba847c

Browse files
author
sanex3339
committed
Fixed some bugs related to values reset
1 parent 6146073 commit 3ba847c

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

App/actions/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ export const updateCode = (code) => ({
99

1010
export const obfuscateCode = (code, options) => {
1111
return (dispatch) => {
12-
const message = {
13-
code,
14-
options
15-
};
16-
1712
if (!options.sourceMap) {
1813
delete options.sourceMapMode
1914
}
@@ -24,6 +19,11 @@ export const obfuscateCode = (code, options) => {
2419
options.stringArrayEncoding = options.stringArrayEncoding === 'true';
2520
}
2621

22+
const message = {
23+
code,
24+
options
25+
};
26+
2727
obfuscationWorker.postMessage(message);
2828

2929
dispatch({

App/containers/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class App extends Component {
2626
obfuscate() {
2727
const {dispatch} = this.props;
2828
const {code, options} = this.props;
29-
dispatch(actions.obfuscateCode(code, options));
29+
30+
dispatch(actions.obfuscateCode(code, {...options}));
3031
}
3132

3233
downloadCode() {

App/containers/OptionsContainer.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ const Options = ({dispatch, options}) =>
8383

8484
<Form.Input
8585
label='Identifiers Prefix'
86-
onBlur={(event) => dispatch(actions.setIdentifiersPrefix(event.target.value))}
87-
defaultValue={options.identifiersPrefix}
88-
placeholder=''/>
86+
value={options.identifiersPrefix}
87+
placeholder=''
88+
onChange={(event, {value}) => dispatch(actions.setIdentifiersPrefix(value))}
89+
/>
8990

9091
<Form.Checkbox
9192
label='Rename Globals'
@@ -109,11 +110,11 @@ const Options = ({dispatch, options}) =>
109110
<Form.Input
110111
type='number'
111112
label='Control Flow Flattening Threshold'
112-
defaultValue={options.controlFlowFlatteningThreshold}
113+
value={options.controlFlowFlatteningThreshold}
113114
min="0"
114115
max="1"
115116
step="0.1"
116-
onChange={(event) => dispatch(actions.setControlFlowFlatteningThreshold(parseFloat(event.target.value)))}
117+
onChange={(event, {value}) => dispatch(actions.setControlFlowFlatteningThreshold(parseFloat(value)))}
117118
disabled={!options.controlFlowFlattening}/>
118119

119120
<Divider/>
@@ -126,11 +127,11 @@ const Options = ({dispatch, options}) =>
126127
<Form.Input
127128
type='number'
128129
label='Dead Code Injection Threshold'
129-
defaultValue={options.deadCodeInjectionThreshold}
130+
value={options.deadCodeInjectionThreshold}
130131
min="0"
131132
max="1"
132133
step="0.1"
133-
onChange={(event) => dispatch(actions.setDeadCodeInjectionThreshold(parseFloat(event.target.value)))}
134+
onChange={(event, {value}) => dispatch(actions.setDeadCodeInjectionThreshold(parseFloat(value)))}
134135
disabled={!options.deadCodeInjection}/>
135136

136137

@@ -168,11 +169,11 @@ const Options = ({dispatch, options}) =>
168169
<Form.Input
169170
type='number'
170171
label='String Array Threshold'
171-
defaultValue={options.stringArrayThreshold}
172+
value={options.stringArrayThreshold}
172173
min="0"
173174
max="1"
174175
step="0.1"
175-
onChange={(event) => dispatch(actions.setStringArrayThreshold(parseFloat(event.target.value)))}
176+
onChange={(event, {value}) => dispatch(actions.setStringArrayThreshold(parseFloat(value)))}
176177
disabled={!options.stringArrayThresholdEnabled}/>
177178

178179
<Divider/>
@@ -185,10 +186,10 @@ const Options = ({dispatch, options}) =>
185186
<Form.Input
186187
type='number'
187188
label='Split Strings Chunk Length'
188-
defaultValue={options.splitStringsChunkLength}
189+
value={options.splitStringsChunkLength}
189190
min="1"
190191
step="1"
191-
onChange={(event) => dispatch(actions.setSplitStringsChunkLength(parseInt(event.target.value)))}
192+
onChange={(event, {value}) => dispatch(actions.setSplitStringsChunkLength(parseInt(value)))}
192193
disabled={!options.splitStringsChunkLengthEnabled}/>
193194

194195
<Divider/>
@@ -272,27 +273,27 @@ const Options = ({dispatch, options}) =>
272273
<Form.Input
273274
label='Source Map Base URL'
274275
disabled={!options.sourceMapSeparate}
275-
onBlur={(event) => dispatch(actions.setSourceMapBaseUrl(event.target.value))}
276-
defaultValue={options.sourceMapBaseUrl}
276+
onChange={(event, {value}) => dispatch(actions.setSourceMapBaseUrl(value))}
277+
value={options.sourceMapBaseUrl}
277278
placeholder='http://localhost:3000'/>
278279

279280
<Form.Input
280281
label='Source Map File Name'
281282
disabled={!options.sourceMapSeparate}
282-
onBlur={(event) => dispatch(actions.setSourceMapFileName(event.target.value))}
283-
defaultValue={options.sourceMapFileName}
283+
onChange={(event, {value}) => dispatch(actions.setSourceMapFileName(value))}
284+
value={options.sourceMapFileName}
284285
placeholder='example'/>
285286

286287
<Divider/>
287288

288289
<Form.Input
289290
type='number'
290291
label='Seed'
291-
defaultValue={options.seed}
292+
value={options.seed}
292293
min="0"
293294
max="99999999"
294295
step="1"
295-
onChange={(event) => dispatch(actions.setSeed(parseInt(event.target.value)))}/>
296+
onChange={(event, {value}) => dispatch(actions.setSeed(parseInt(value)))}/>
296297

297298
<Divider/>
298299

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator-web",
3-
"version": "3.3.5",
3+
"version": "3.4.0",
44
"description": "",
55
"engines": {
66
"node": ">=12.13.1"

0 commit comments

Comments
 (0)