- remove toplevel option from terser as it will cause certain error
- rename some functions name to fix above issue, but finally no relation with it. - correct source map command line options - optimize commands
This commit is contained in:
parent
5bb7a2e0f3
commit
f1bb8de22a
|
@ -7,11 +7,10 @@
|
|||
"repository": "https://github.com/xenkuo/comNG",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
"prestart": "terser src/base.js src/editor.js src/serialport.js --source-map -o src/index.js -c -m toplevel",
|
||||
"start": "electron-forge start",
|
||||
"rebuild": "electron-rebuild -f -w serialport",
|
||||
"package": "electron-forge package",
|
||||
"premake": "terser src/base.js src/editor.js src/serialport.js --source-map -o src/index.js -c -m toplevel",
|
||||
"premake": "rm src/index.js.map && terser src/base.js src/editor.js src/serialport.js -o src/index.js -c -m",
|
||||
"make": "electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "echo \"No linting configured\""
|
||||
|
|
28
src/base.js
28
src/base.js
|
@ -6,8 +6,8 @@ const appVersion = remote.app.getVersion();
|
|||
const appUpdaterUrl =
|
||||
"https://gitee.com/api/v5/repos/xenkuo/comNG/releases/latest";
|
||||
|
||||
var M = require("materialize-css");
|
||||
M.AutoInit();
|
||||
var mcss = require("materialize-css");
|
||||
mcss.AutoInit();
|
||||
|
||||
var config;
|
||||
var barHeight;
|
||||
|
@ -139,14 +139,14 @@ window.onload = () => {
|
|||
menu.offsetHeight +
|
||||
"px";
|
||||
|
||||
M.Tabs.getInstance(document.getElementById("menu-tabs")).select(
|
||||
mcss.Tabs.getInstance(document.getElementById("menu-tabs")).select(
|
||||
config.menu.tab
|
||||
);
|
||||
|
||||
let baudSelect = document.getElementById("baud-select");
|
||||
baudSelect.options[0].text = config.general.customized;
|
||||
baudSelect.selectedIndex = config.baudIndex;
|
||||
M.FormSelect.init(baudSelect);
|
||||
mcss.FormSelect.init(baudSelect);
|
||||
|
||||
portUpdate();
|
||||
|
||||
|
@ -164,16 +164,16 @@ window.onload = () => {
|
|||
|
||||
let databits = document.getElementById("databits-select");
|
||||
databits.selectedIndex = config.general.databitsIndex;
|
||||
M.FormSelect.init(databits);
|
||||
mcss.FormSelect.init(databits);
|
||||
let parity = document.getElementById("parity-select");
|
||||
parity.selectedIndex = config.general.parityIndex;
|
||||
M.FormSelect.init(parity);
|
||||
mcss.FormSelect.init(parity);
|
||||
let stopbits = document.getElementById("stopbits-select");
|
||||
stopbits.selectedIndex = config.general.stopbitsIndex;
|
||||
M.FormSelect.init(stopbits);
|
||||
mcss.FormSelect.init(stopbits);
|
||||
let flowcontrol = document.getElementById("flowcontrol-select");
|
||||
flowcontrol.selectedIndex = config.general.flowcontrolIndex;
|
||||
M.FormSelect.init(flowcontrol);
|
||||
mcss.FormSelect.init(flowcontrol);
|
||||
|
||||
document.getElementById("editor-font-family").value =
|
||||
config.general.fontFamily;
|
||||
|
@ -371,7 +371,7 @@ document.body.onclick = (e) => {
|
|||
};
|
||||
|
||||
document.getElementById("menu-tabs").onclick = () => {
|
||||
let tabs = M.Tabs.getInstance(document.getElementById("menu-tabs"));
|
||||
let tabs = mcss.Tabs.getInstance(document.getElementById("menu-tabs"));
|
||||
|
||||
configUpdate("menu.tab", tabs.$content[0].id);
|
||||
};
|
||||
|
@ -404,7 +404,7 @@ document.getElementById("customized").onblur = (e) => {
|
|||
let baudSelect = document.getElementById("baud-select");
|
||||
|
||||
baudSelect.options[0].text = customized;
|
||||
M.FormSelect.init(baudSelect);
|
||||
mcss.FormSelect.init(baudSelect);
|
||||
};
|
||||
|
||||
document.getElementById("databits-select").onchange = (e) => {
|
||||
|
@ -463,8 +463,8 @@ document.getElementById("trans-send-btn").onclick = () => {
|
|||
if (serialWrite(data) === false) return;
|
||||
|
||||
p.value += "\n" + document.getElementById("trans-data").value;
|
||||
M.updateTextFields(p);
|
||||
M.textareaAutoResize(p);
|
||||
mcss.updateTextFields(p);
|
||||
mcss.textareaAutoResize(p);
|
||||
p.scrollTop = p.scrollHeight;
|
||||
|
||||
if (document.getElementById("trans-repeat-switch").checked === true) {
|
||||
|
@ -491,8 +491,8 @@ document.getElementById("trans-log-btn").onclick = () => {
|
|||
let p = document.getElementById("trans-log-area");
|
||||
|
||||
p.value = "";
|
||||
M.updateTextFields(p);
|
||||
M.textareaAutoResize(p);
|
||||
mcss.updateTextFields(p);
|
||||
mcss.textareaAutoResize(p);
|
||||
};
|
||||
|
||||
document.getElementById("bar-color-head").oninput = (e) => {
|
||||
|
|
|
@ -40,8 +40,8 @@ function decoGet() {
|
|||
return decoTable[decoIndex++ % decoMod];
|
||||
}
|
||||
|
||||
function decoApply(m, text) {
|
||||
let matches = m.findMatches(
|
||||
function decoApply(model, text) {
|
||||
let matches = model.findMatches(
|
||||
text,
|
||||
false,
|
||||
false,
|
||||
|
@ -56,7 +56,7 @@ function decoApply(m, text) {
|
|||
for (let i of matches) {
|
||||
let range = i.range;
|
||||
|
||||
m.deltaDecorations(
|
||||
model.deltaDecorations(
|
||||
[],
|
||||
[
|
||||
{
|
||||
|
@ -74,8 +74,8 @@ function decoApply(m, text) {
|
|||
}
|
||||
}
|
||||
|
||||
function decoRemove(m, text) {
|
||||
let matches = m.findMatches(
|
||||
function decoRemove(model, text) {
|
||||
let matches = model.findMatches(
|
||||
text,
|
||||
false,
|
||||
false,
|
||||
|
@ -85,11 +85,11 @@ function decoRemove(m, text) {
|
|||
);
|
||||
|
||||
for (let match of matches) {
|
||||
let decos = m.getDecorationsInRange(match.range);
|
||||
let decos = model.getDecorationsInRange(match.range);
|
||||
|
||||
// super word remove decoration will cause sub word decoration to 1
|
||||
for (let deco of decos) {
|
||||
m.deltaDecorations([deco.id], []);
|
||||
model.deltaDecorations([deco.id], []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,11 @@ function decoRemove(m, text) {
|
|||
function highlightToggle() {
|
||||
console.log("highligh toggle");
|
||||
let decoExpectedLength = 1;
|
||||
let m = editor.getModel();
|
||||
let model = editor.getModel();
|
||||
let range = editor.getSelection();
|
||||
let text = m.getValueInRange(range);
|
||||
let text = model.getValueInRange(range);
|
||||
if (text === "") {
|
||||
let word = m.getWordAtPosition(editor.getPosition());
|
||||
let word = model.getWordAtPosition(editor.getPosition());
|
||||
text = word.word;
|
||||
range.startColumn = word.startColumn;
|
||||
range.endColumn = word.endColumn;
|
||||
|
@ -110,11 +110,11 @@ function highlightToggle() {
|
|||
|
||||
if (text === "") return;
|
||||
|
||||
let decos = m.getDecorationsInRange(range);
|
||||
let decos = model.getDecorationsInRange(range);
|
||||
if (decos.length === decoExpectedLength) {
|
||||
decoApply(m, text);
|
||||
decoApply(model, text);
|
||||
} else {
|
||||
decoRemove(m, text);
|
||||
decoRemove(model, text);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// All of the Node.js APIs are available in the preload process.
|
||||
// It has the same sandbox as a Chrome extension.
|
||||
|
||||
let pjson = require("../package.json");
|
||||
if ("dev" == pjson.mode) {
|
||||
console.log("dev mode");
|
||||
|
@ -7,8 +8,10 @@ if ("dev" == pjson.mode) {
|
|||
const fs = require("fs");
|
||||
let terser = require("terser");
|
||||
let options = {
|
||||
toplevel: true,
|
||||
sourceMap: true,
|
||||
sourceMap: {
|
||||
filename: "index.js",
|
||||
url: "index.js.map",
|
||||
},
|
||||
};
|
||||
let result = terser.minify(
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ function portUpdate() {
|
|||
pSelect.options.add(new Option(item.path, index));
|
||||
if (index === config.pathIndex) pSelect.selectedIndex = index;
|
||||
});
|
||||
M.FormSelect.init(pSelect);
|
||||
mcss.FormSelect.init(pSelect);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
|
@ -127,7 +127,7 @@ function serialGetOptions() {
|
|||
}
|
||||
|
||||
function toast(text) {
|
||||
M.toast({ html: text, displayLength: 1000 });
|
||||
mcss.toast({ html: text, displayLength: 1000 });
|
||||
// alert(text)
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ document.getElementById("port-switch").onclick = (e) => {
|
|||
if (config.general.modemSignal === true) {
|
||||
modemSignalTimer = setInterval(modemSignalTimerHandle, 100);
|
||||
}
|
||||
port.set({rts: true, dtr: true}, (e) => {
|
||||
port.set({ rts: true, dtr: true }, (e) => {
|
||||
if (e !== null) console.error(e);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue