Removing unique file dependencies in QML, removing comments from JS Builds (except first one, ~-30% build size)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2024-09-26 22:36:42 +02:00
parent 49aa23de92
commit 95b47effdf
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
24 changed files with 176 additions and 100 deletions

View file

@ -20,7 +20,7 @@ import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
//import QtQuick.Controls 2.15 //import QtQuick.Controls 2.15
import eu.ad5001.MixedMenu 1.1 import eu.ad5001.MixedMenu 1.1
import "js/history/index.mjs" as HistoryLib import "js/index.mjs" as JS
/*! /*!
@ -119,7 +119,7 @@ MenuBar {
icon.color: sysPalette.buttonText icon.color: sysPalette.buttonText
onTriggered: { onTriggered: {
var newObj = Modules.Objects.createNewRegisteredObject(modelData) var newObj = Modules.Objects.createNewRegisteredObject(modelData)
history.addToHistory(new HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export())) history.addToHistory(new JS.HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export()))
objectLists.update() objectLists.update()
} }
} }

View file

@ -19,7 +19,7 @@
import QtQuick import QtQuick
import QtQml import QtQml
import QtQuick.Window import QtQuick.Window
import "../js/history/index.mjs" as HistoryLib import "../js/index.mjs" as JS
/*! /*!
\qmltype History \qmltype History
@ -97,9 +97,9 @@ Item {
function unserialize(undoSt, redoSt) { function unserialize(undoSt, redoSt) {
clear(); clear();
for(let i = 0; i < undoSt.length; i++) for(let i = 0; i < undoSt.length; i++)
undoStack.push(new HistoryLib.Actions[undoSt[i][0]](...undoSt[i][1])) undoStack.push(new JS.HistoryLib.Actions[undoSt[i][0]](...undoSt[i][1]))
for(let i = 0; i < redoSt.length; i++) for(let i = 0; i < redoSt.length; i++)
redoStack.push(new HistoryLib.Actions[redoSt[i][0]](...redoSt[i][1])) redoStack.push(new JS.HistoryLib.Actions[redoSt[i][0]](...redoSt[i][1]))
undoCount = undoSt.length; undoCount = undoSt.length;
redoCount = redoSt.length; redoCount = redoSt.length;
objectLists.update() objectLists.update()
@ -110,7 +110,7 @@ Item {
Adds an instance of HistoryLib.Action to history. Adds an instance of HistoryLib.Action to history.
*/ */
function addToHistory(action) { function addToHistory(action) {
if(action instanceof HistoryLib.Action) { if(action instanceof JS.HistoryLib.Action) {
console.log("Added new entry to history: " + action.getReadableString()) console.log("Added new entry to history: " + action.getReadableString())
undoStack.push(action) undoStack.push(action)
undoCount++; undoCount++;

View file

@ -19,7 +19,6 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick import QtQuick
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/utils.mjs" as Utils
/*! /*!

View file

@ -19,7 +19,6 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import "../js/utils.mjs" as Utils
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting

View file

@ -18,8 +18,6 @@
import QtQuick import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
import "js/utils.mjs" as Utils
import "js/math/index.mjs" as MathLib
/*! /*!
\qmltype LogGraphCanvas \qmltype LogGraphCanvas

View file

@ -23,7 +23,7 @@ import QtQuick.Layouts 1.12
import QtQuick import QtQuick
// Auto loading all modules. // Auto loading all modules.
import "js/index.mjs" as ModulesAutoload import "js/index.mjs" as JS
import eu.ad5001.LogarithmPlotter.History 1.0 import eu.ad5001.LogarithmPlotter.History 1.0
import eu.ad5001.LogarithmPlotter.ObjectLists 1.0 import eu.ad5001.LogarithmPlotter.ObjectLists 1.0

View file

@ -20,9 +20,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../../js/history/index.mjs" as HistoryLib import "../../js/index.mjs" as JS
import "../../js/utils.mjs" as Utils
import "../../js/math/index.mjs" as MathLib
/*! /*!
\qmltype CustomPropertyList \qmltype CustomPropertyList
@ -77,12 +75,12 @@ Repeater {
height: 30 height: 30
label: propertyLabel label: propertyLabel
icon: `settings/custom/${propertyIcon}.svg` icon: `settings/custom/${propertyIcon}.svg`
defValue: Utils.simplifyExpression(obj[propertyName].toEditableString()) defValue: JS.Utils.simplifyExpression(obj[propertyName].toEditableString())
self: obj.name self: obj.name
variables: propertyType.variables variables: propertyType.variables
onChanged: function(newExpr) { onChanged: function(newExpr) {
if(obj[propertyName].toString() != newExpr.toString()) { if(obj[propertyName].toString() != newExpr.toString()) {
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], newExpr obj[propertyName], newExpr
)) ))
@ -117,7 +115,7 @@ Repeater {
onChanged: function(newValue) { onChanged: function(newValue) {
try { try {
var newValueParsed = { var newValueParsed = {
"Domain": () => MathLib.parseDomain(newValue), "Domain": () => JS.MathLib.parseDomain(newValue),
"string": () => newValue, "string": () => newValue,
"number": () => newValue, "number": () => newValue,
"int": () => newValue "int": () => newValue
@ -125,7 +123,7 @@ Repeater {
// Ensuring old and new values are different to prevent useless adding to history. // Ensuring old and new values are different to prevent useless adding to history.
if(obj[propertyName] != newValueParsed) { if(obj[propertyName] != newValueParsed) {
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], newValueParsed obj[propertyName], newValueParsed
)) ))
@ -170,7 +168,7 @@ Repeater {
return obj[propertyName] return obj[propertyName]
} }
onClicked: { onClicked: {
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], this.checked obj[propertyName], this.checked
)) ))
@ -211,7 +209,7 @@ Repeater {
if(selectedObj == null) { if(selectedObj == null) {
// Creating new object. // Creating new object.
selectedObj = Modules.Objects.createNewRegisteredObject(propertyType.objType) selectedObj = Modules.Objects.createNewRegisteredObject(propertyType.objType)
history.addToHistory(new HistoryLib.CreateNewObject(selectedObj.name, propertyType.objType, selectedObj.export())) history.addToHistory(new JS.HistoryLib.CreateNewObject(selectedObj.name, propertyType.objType, selectedObj.export()))
baseModel = Modules.Objects.getObjectsName(propertyType.objType).concat( baseModel = Modules.Objects.getObjectsName(propertyType.objType).concat(
isRealObject ? [qsTr("+ Create new %1").arg(Modules.Objects.types[propertyType.objType].displayType())] : isRealObject ? [qsTr("+ Create new %1").arg(Modules.Objects.types[propertyType.objType].displayType())] :
[]) [])
@ -221,14 +219,14 @@ Repeater {
//Modules.Objects.currentObjects[objType][objIndex].requiredBy = obj[propertyName].filter((obj) => obj.name != obj.name) //Modules.Objects.currentObjects[objType][objIndex].requiredBy = obj[propertyName].filter((obj) => obj.name != obj.name)
} }
obj.requiredBy = obj.requiredBy.filter((obj) => obj.name != obj.name) obj.requiredBy = obj.requiredBy.filter((obj) => obj.name != obj.name)
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], selectedObj obj[propertyName], selectedObj
)) ))
obj[propertyName] = selectedObj obj[propertyName] = selectedObj
} else if(baseModel[newIndex] != obj[propertyName]) { } else if(baseModel[newIndex] != obj[propertyName]) {
// Ensuring new property is different to not add useless history entries. // Ensuring new property is different to not add useless history entries.
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], baseModel[newIndex] obj[propertyName], baseModel[newIndex]
)) ))
@ -258,11 +256,10 @@ Repeater {
onChanged: { onChanged: {
var exported = exportModel() var exported = exportModel()
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], exported obj[propertyName], exported
)) ))
//Modules.Objects.currentObjects[objType][objIndex][propertyName] = exported
obj[propertyName] = exported obj[propertyName] = exported
root.changed() root.changed()
} }
@ -284,7 +281,7 @@ Repeater {
property string propertyName: modelData[0] property string propertyName: modelData[0]
property var propertyType: modelData[1] property var propertyType: modelData[1]
property string propertyLabel: qsTranslate('prop',propertyName) property string propertyLabel: qsTranslate('prop',propertyName)
property string propertyIcon: Utils.camelCase2readable(propertyName) property string propertyIcon: JS.Utils.camelCase2readable(propertyName)
sourceComponent: { sourceComponent: {
if(propertyName.startsWith('comment')) if(propertyName.startsWith('comment'))

View file

@ -22,9 +22,7 @@ import QtQuick.Dialogs as D
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
import "../../js/history/index.mjs" as HistoryLib import "../../js/index.mjs" as JS
import "../../js/utils.mjs" as Utils
import "../../js/math/index.mjs" as MathLib
/*! /*!
\qmltype Dialog \qmltype Dialog
@ -109,12 +107,12 @@ Popup.BaseDialog {
width: dlgProperties.width width: dlgProperties.width
value: objEditor.obj.name value: objEditor.obj.name
onChanged: function(newValue) { onChanged: function(newValue) {
let newName = Utils.parseName(newValue) let newName = JS.Utils.parseName(newValue)
if(newName != '' && objEditor.obj.name != newName) { if(newName != '' && objEditor.obj.name != newName) {
if(newName in Modules.Objects.currentObjectsByName) { if(newName in Modules.Objects.currentObjectsByName) {
invalidNameDialog.showDialog(newName) invalidNameDialog.showDialog(newName)
} else { } else {
history.addToHistory(new HistoryLib.NameChanged( history.addToHistory(new JS.HistoryLib.NameChanged(
objEditor.obj.name, objEditor.objType, newName objEditor.obj.name, objEditor.objType, newName
)) ))
Modules.Objects.renameObject(obj.name, newName) Modules.Objects.renameObject(obj.name, newName)

View file

@ -18,8 +18,8 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import "../js/history/index.mjs" as HistoryLib
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/index.mjs" as JS
/*! /*!
@ -104,7 +104,7 @@ Column {
onClicked: { onClicked: {
let newObj = Modules.Objects.createNewRegisteredObject(modelData) let newObj = Modules.Objects.createNewRegisteredObject(modelData)
history.addToHistory(new HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export())) history.addToHistory(new JS.HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export()))
objectLists.update() objectLists.update()
let hasXProp = newObj.constructor.properties().hasOwnProperty('x') let hasXProp = newObj.constructor.properties().hasOwnProperty('x')

View file

@ -21,7 +21,7 @@ import QtQuick.Dialogs
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Window import QtQuick.Window
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/history/index.mjs" as HistoryLib import "../js/index.mjs" as JS
/*! /*!
@ -72,7 +72,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 5 anchors.leftMargin: 5
onClicked: { onClicked: {
history.addToHistory(new HistoryLib.EditedVisibility( history.addToHistory(new JS.HistoryLib.EditedVisibility(
obj.name, obj.type, this.checked obj.name, obj.type, this.checked
)) ))
obj.visible = this.checked obj.visible = this.checked
@ -212,7 +212,7 @@ Item {
selectedColor: obj.color selectedColor: obj.color
title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name) title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
onAccepted: { onAccepted: {
history.addToHistory(new HistoryLib.ColorChanged( history.addToHistory(new JS.HistoryLib.ColorChanged(
obj.name, obj.type, obj.color, selectedColor.toString() obj.name, obj.type, obj.color, selectedColor.toString()
)) ))
obj.color = selectedColor.toString() obj.color = selectedColor.toString()
@ -231,7 +231,7 @@ Item {
// Object still exists // Object still exists
// Temporary fix for objects require not being propertly updated. // Temporary fix for objects require not being propertly updated.
object.requiredBy = [] object.requiredBy = []
history.addToHistory(new HistoryLib.DeleteObject( history.addToHistory(new JS.HistoryLib.DeleteObject(
object.name, object.type, object.export() object.name, object.type, object.export()
)) ))
Modules.Objects.deleteObject(object.name) Modules.Objects.deleteObject(object.name)

View file

@ -19,8 +19,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "js/math/index.mjs" as MathLib import "js/index.mjs" as JS
import "js/history/index.mjs" as HistoryLib
/*! /*!
\qmltype PickLocationOverlay \qmltype PickLocationOverlay
@ -116,7 +115,7 @@ Item {
let obj = Modules.Objects.currentObjectsByName[objName] let obj = Modules.Objects.currentObjectsByName[objName]
// Set values // Set values
if(parent.userPickX && parent.userPickY) { if(parent.userPickX && parent.userPickY) {
history.addToHistory(new HistoryLib.EditedPosition( history.addToHistory(new JS.HistoryLib.EditedPosition(
objName, objType, obj[propertyX], newValueX, obj[propertyY], newValueY objName, objType, obj[propertyX], newValueX, obj[propertyY], newValueY
)) ))
obj[propertyX] = newValueX obj[propertyX] = newValueX
@ -125,7 +124,7 @@ Item {
objectLists.update() objectLists.update()
pickerRoot.picked(obj) pickerRoot.picked(obj)
} else if(parent.userPickX) { } else if(parent.userPickX) {
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
objName, objType, propertyX, obj[propertyX], newValueX objName, objType, propertyX, obj[propertyX], newValueX
)) ))
obj[propertyX] = newValueX obj[propertyX] = newValueX
@ -133,7 +132,7 @@ Item {
objectLists.update() objectLists.update()
pickerRoot.picked(obj) pickerRoot.picked(obj)
} else if(parent.userPickY) { } else if(parent.userPickY) {
history.addToHistory(new HistoryLib.EditedProperty( history.addToHistory(new JS.HistoryLib.EditedProperty(
objName, objType, propertyY, obj[propertyY], newValueY objName, objType, propertyY, obj[propertyY], newValueY
)) ))
obj[propertyY] = newValueY obj[propertyY] = newValueY
@ -327,6 +326,6 @@ Item {
if(Modules.Objects.types[objType].properties()[propertyName] == 'number') if(Modules.Objects.types[objType].properties()[propertyName] == 'number')
return parseFloat(value) return parseFloat(value)
else else
return new MathLib.Expression(value) return new JS.MathLib.Expression(value)
} }
} }

View file

@ -20,8 +20,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/preferences/common.mjs" as S import "../js/index.mjs" as JS
import "../js/utils.mjs" as Utils
/*! /*!
\qmltype Preferences \qmltype Preferences
@ -77,7 +76,7 @@ Popup {
currentIndex: find(setting.value()) currentIndex: find(setting.value())
model: setting.defaultValues model: setting.defaultValues
onAccepted: function() { onAccepted: function() {
editText = Utils.parseName(editText, false) editText = JS.Utils.parseName(editText, false)
if(find(editText) === -1) model.append(editText) if(find(editText) === -1) model.append(editText)
setting.set(editText) setting.set(editText)
} }
@ -116,7 +115,7 @@ Popup {
height: 30 height: 30
label: setting.name label: setting.name
icon: `settings/${setting.icon}.svg` icon: `settings/${setting.icon}.svg`
defValue: Utils.simplifyExpression(setting.value()) defValue: JS.Utils.simplifyExpression(setting.value())
variables: setting.variables variables: setting.variables
allowGraphObjects: false allowGraphObjects: false
property string propertyName: setting.name property string propertyName: setting.name

View file

@ -20,9 +20,7 @@ import QtQuick.Controls
import QtQuick import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Popup 1.0 as P import eu.ad5001.LogarithmPlotter.Popup 1.0 as P
import "../js/math/index.mjs" as MathLib import "../js/index.mjs" as JS
import "../js/utils.mjs" as Utils
import "../js/parsing/parsing.mjs" as Parsing
/*! /*!
@ -319,9 +317,9 @@ Item {
width: parent.width width: parent.width
readonly property var identifierTokenTypes: [ readonly property var identifierTokenTypes: [
Parsing.TokenType.VARIABLE, JS.Parsing.TokenType.VARIABLE,
Parsing.TokenType.FUNCTION, JS.Parsing.TokenType.FUNCTION,
Parsing.TokenType.CONSTANT JS.Parsing.TokenType.CONSTANT
] ]
property var currentToken: generateTokenInformation(getTokenAt(editor.tokens, editor.cursorPosition)) property var currentToken: generateTokenInformation(getTokenAt(editor.tokens, editor.cursorPosition))
property var previousToken: generateTokenInformation(getPreviousToken(currentToken.token)) property var previousToken: generateTokenInformation(getPreviousToken(currentToken.token))
@ -346,7 +344,7 @@ Item {
'value': exists ? token.value : null, 'value': exists ? token.value : null,
'type': exists ? token.type : null, 'type': exists ? token.type : null,
'startPosition': exists ? token.startPosition : 0, 'startPosition': exists ? token.startPosition : 0,
'dot': exists ? (token.type == Parsing.TokenType.PUNCT && token.value == ".") : false, 'dot': exists ? (token.type == JS.Parsing.TokenType.PUNCT && token.value == ".") : false,
'identifier': exists ? identifierTokenTypes.includes(token.type) : false 'identifier': exists ? identifierTokenTypes.includes(token.type) : false
} }
} }
@ -385,7 +383,7 @@ Item {
*/ */
function getPreviousToken(token) { function getPreviousToken(token) {
let newToken = getTokenAt(editor.tokens, token.startPosition) let newToken = getTokenAt(editor.tokens, token.startPosition)
if(newToken != null && newToken.type == Parsing.TokenType.WHITESPACE) if(newToken != null && newToken.type == JS.Parsing.TokenType.WHITESPACE)
return getPreviousToken(newToken) return getPreviousToken(newToken)
return newToken return newToken
} }
@ -444,9 +442,9 @@ Item {
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
itemStartIndex: variablesList.itemStartIndex + variablesList.model.length itemStartIndex: variablesList.itemStartIndex + variablesList.model.length
itemSelected: parent.itemSelected itemSelected: parent.itemSelected
categoryItems: Parsing.CONSTANTS_LIST categoryItems: JS.Parsing.CONSTANTS_LIST
autocompleteGenerator: (item) => {return { autocompleteGenerator: (item) => {return {
'text': item, 'annotation': Parsing.CONSTANTS[item], 'text': item, 'annotation': JS.Parsing.CONSTANTS[item],
'autocomplete': item + " ", 'cursorFinalOffset': 0 'autocomplete': item + " ", 'cursorFinalOffset': 0
}} }}
baseText: parent.visible ? parent.currentToken.value : "" baseText: parent.visible ? parent.currentToken.value : ""
@ -459,9 +457,9 @@ Item {
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
itemStartIndex: constantsList.itemStartIndex + constantsList.model.length itemStartIndex: constantsList.itemStartIndex + constantsList.model.length
itemSelected: parent.itemSelected itemSelected: parent.itemSelected
categoryItems: Parsing.FUNCTIONS_LIST categoryItems: JS.Parsing.FUNCTIONS_LIST
autocompleteGenerator: (item) => {return { autocompleteGenerator: (item) => {return {
'text': item, 'annotation': Parsing.FUNCTIONS_USAGE[item].join(', '), 'text': item, 'annotation': JS.Parsing.FUNCTIONS_USAGE[item].join(', '),
'autocomplete': item+'()', 'cursorFinalOffset': -1 'autocomplete': item+'()', 'cursorFinalOffset': -1
}} }}
baseText: parent.visible ? parent.currentToken.value : "" baseText: parent.visible ? parent.currentToken.value : ""
@ -538,7 +536,7 @@ Item {
function parse(newExpression) { function parse(newExpression) {
let expr = null let expr = null
try { try {
expr = new MathLib.Expression(value.toString()) expr = new JS.MathLib.Expression(value.toString())
// Check if the expression is valid, throws error otherwise. // Check if the expression is valid, throws error otherwise.
if(!expr.allRequirementsFullfilled()) { if(!expr.allRequirementsFullfilled()) {
let undefVars = expr.undefinedVariables() let undefVars = expr.undefinedVariables()
@ -572,7 +570,7 @@ Item {
Generates a list of tokens from the given. Generates a list of tokens from the given.
*/ */
function tokens(text) { function tokens(text) {
let tokenizer = new Parsing.Tokenizer(new Parsing.Input(text), true, false) let tokenizer = new JS.Parsing.Tokenizer(new JS.Parsing.Input(text), true, false)
let tokenList = [] let tokenList = []
let token let token
while((token = tokenizer.next()) != null) while((token = tokenizer.next()) != null)
@ -605,28 +603,28 @@ Item {
let scheme = colorSchemes[Helper.getSettingInt("expression_editor.color_scheme")] let scheme = colorSchemes[Helper.getSettingInt("expression_editor.color_scheme")]
for(let token of tokenList) { for(let token of tokenList) {
switch(token.type) { switch(token.type) {
case Parsing.TokenType.VARIABLE: case JS.Parsing.TokenType.VARIABLE:
parsedText += `<font color="${scheme.VARIABLE}">${token.value}</font>` parsedText += `<font color="${scheme.VARIABLE}">${token.value}</font>`
break; break;
case Parsing.TokenType.CONSTANT: case JS.Parsing.TokenType.CONSTANT:
parsedText += `<font color="${scheme.CONSTANT}">${token.value}</font>` parsedText += `<font color="${scheme.CONSTANT}">${token.value}</font>`
break; break;
case Parsing.TokenType.FUNCTION: case JS.Parsing.TokenType.FUNCTION:
parsedText += `<font color="${scheme.FUNCTION}">${Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.FUNCTION}">${JS.Utils.escapeHTML(token.value)}</font>`
break; break;
case Parsing.TokenType.OPERATOR: case JS.Parsing.TokenType.OPERATOR:
parsedText += `<font color="${scheme.OPERATOR}">${Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.OPERATOR}">${JS.Utils.escapeHTML(token.value)}</font>`
break; break;
case Parsing.TokenType.NUMBER: case JS.Parsing.TokenType.NUMBER:
parsedText += `<font color="${scheme.NUMBER}">${Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.NUMBER}">${JS.Utils.escapeHTML(token.value)}</font>`
break; break;
case Parsing.TokenType.STRING: case JS.Parsing.TokenType.STRING:
parsedText += `<font color="${scheme.STRING}">${token.limitator}${Utils.escapeHTML(token.value)}${token.limitator}</font>` parsedText += `<font color="${scheme.STRING}">${token.limitator}${JS.Utils.escapeHTML(token.value)}${token.limitator}</font>`
break; break;
case Parsing.TokenType.WHITESPACE: case JS.Parsing.TokenType.WHITESPACE:
case Parsing.TokenType.PUNCT: case JS.Parsing.TokenType.PUNCT:
default: default:
parsedText += Utils.escapeHTML(token.value).replace(/ /g, '&nbsp;') parsedText += JS.Utils.escapeHTML(token.value).replace(/ /g, '&nbsp;')
break; break;
} }
} }

View file

@ -20,7 +20,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
import "js/utils.mjs" as Utils import "js/index.mjs" as JS
/*! /*!
\qmltype Settings \qmltype Settings
@ -330,7 +330,7 @@ ScrollView {
currentIndex: find(settings.xlabel) currentIndex: find(settings.xlabel)
editable: true editable: true
onAccepted: function(){ onAccepted: function(){
editText = Utils.parseName(editText, false) editText = JS.Utils.parseName(editText, false)
if (find(editText) === -1) model.append({text: editText}) if (find(editText) === -1) model.append({text: editText})
settings.xlabel = editText settings.xlabel = editText
settings.changed() settings.changed()
@ -359,7 +359,7 @@ ScrollView {
currentIndex: find(settings.ylabel) currentIndex: find(settings.ylabel)
editable: true editable: true
onAccepted: function(){ onAccepted: function(){
editText = Utils.parseName(editText, false) editText = JS.Utils.parseName(editText, false)
if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep}) if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep})
settings.ylabel = editText settings.ylabel = editText
settings.changed() settings.changed()

View file

@ -19,8 +19,6 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "js/math/index.mjs" as MathLib
import "js/history/index.mjs" as HistoryLib
/*! /*!
\qmltype ViewPositionChangeOverlay \qmltype ViewPositionChangeOverlay

View file

@ -1,17 +1,17 @@
/** /**
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions. * LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
* Copyright (C) 2021-2024 Ad5001 * Copyright (C) 2021-2024 Ad5001
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -25,3 +25,8 @@ import * as History from "./module/history.mjs"
import * as CanvasAPI from "./module/canvas.mjs" import * as CanvasAPI from "./module/canvas.mjs"
import * as IOAPI from "./module/io.mjs" import * as IOAPI from "./module/io.mjs"
import * as PreferencesAPI from "./module/preferences.mjs" import * as PreferencesAPI from "./module/preferences.mjs"
export * as MathLib from "./math/index.mjs"
export * as HistoryLib from "./history/index.mjs"
export * as Parsing from "./parsing/index.mjs"
export * as Utils from "./utils.mjs"

View file

@ -1,19 +1,23 @@
/** /*!
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions. * LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
* Copyright (C) 2021-2024 Ad5001 *
* @author Ad5001 <mail@ad5001.eu>
* @license GPL-3.0-or-later
* @copyright (C) 2021-2024 Ad5001
* @preserve
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
export const NUMBER = 0 export const NUMBER = 0

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as Reference from "reference.mjs" import * as Reference from "./reference.mjs"
import * as T from "./tokenizer.mjs" import * as T from "./tokenizer.mjs"
import InputExpression from "./common.mjs" import InputExpression from "./common.mjs"

View file

@ -17,7 +17,7 @@
*/ */
import * as Reference from "reference.mjs" import * as Reference from "./reference.mjs"
const WHITESPACES = " \t\n\r" const WHITESPACES = " \t\n\r"
const STRING_LIMITERS = '"\'`'; const STRING_LIMITERS = '"\'`';

View file

@ -78,7 +78,6 @@ def check_for_updates(current_version, window):
return return
def cb(show_alert, msg_text, update_available): def cb(show_alert, msg_text, update_available):
pass
if show_alert: if show_alert:
window.showAlert(msg_text) window.showAlert(msg_text)
if update_available: if update_available:

82
package-lock.json generated
View file

@ -15,7 +15,8 @@
"@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"install": "^0.13.0", "install": "^0.13.0",
"rollup": "^4.22.4" "rollup": "^4.22.4",
"rollup-plugin-cleanup": "^3.2.1"
} }
}, },
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {
@ -2476,6 +2477,29 @@
"@types/estree": "*" "@types/estree": "*"
} }
}, },
"node_modules/js-cleanup": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/js-cleanup/-/js-cleanup-1.2.0.tgz",
"integrity": "sha512-JeDD0yiiSt80fXzAVa/crrS0JDPQljyBG/RpOtaSbyDq03VHa9szJWMaWOYU/bcTn412uMN2MxApXq8v79cUiQ==",
"license": "MIT",
"dependencies": {
"magic-string": "^0.25.7",
"perf-regexes": "^1.0.1",
"skip-regex": "^1.0.2"
},
"engines": {
"node": "^10.14.2 || >=12.0.0"
}
},
"node_modules/js-cleanup/node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"license": "MIT",
"dependencies": {
"sourcemap-codec": "^1.4.8"
}
},
"node_modules/js-tokens": { "node_modules/js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -2549,6 +2573,15 @@
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/perf-regexes": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/perf-regexes/-/perf-regexes-1.0.1.tgz",
"integrity": "sha512-L7MXxUDtqr4PUaLFCDCXBfGV/6KLIuSEccizDI7JxT+c9x1G1v04BQ4+4oag84SHaCdrBgQAIs/Cqn+flwFPng==",
"license": "MIT",
"engines": {
"node": ">=6.14"
}
},
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
@ -2700,6 +2733,37 @@
"fsevents": "~2.3.2" "fsevents": "~2.3.2"
} }
}, },
"node_modules/rollup-plugin-cleanup": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-cleanup/-/rollup-plugin-cleanup-3.2.1.tgz",
"integrity": "sha512-zuv8EhoO3TpnrU8MX8W7YxSbO4gmOR0ny06Lm3nkFfq0IVKdBUtHwhVzY1OAJyNCIAdLiyPnOrU0KnO0Fri1GQ==",
"license": "MIT",
"dependencies": {
"js-cleanup": "^1.2.0",
"rollup-pluginutils": "^2.8.2"
},
"engines": {
"node": "^10.14.2 || >=12.0.0"
},
"peerDependencies": {
"rollup": ">=2.0"
}
},
"node_modules/rollup-pluginutils": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
"integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==",
"license": "MIT",
"dependencies": {
"estree-walker": "^0.6.1"
}
},
"node_modules/rollup-pluginutils/node_modules/estree-walker": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
"license": "MIT"
},
"node_modules/rollup/node_modules/@types/estree": { "node_modules/rollup/node_modules/@types/estree": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
@ -2744,6 +2808,15 @@
"randombytes": "^2.1.0" "randombytes": "^2.1.0"
} }
}, },
"node_modules/skip-regex": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/skip-regex/-/skip-regex-1.0.2.tgz",
"integrity": "sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA==",
"license": "MIT",
"engines": {
"node": ">=4.2"
}
},
"node_modules/smob": { "node_modules/smob": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz",
@ -2769,6 +2842,13 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"deprecated": "Please use @jridgewell/sourcemap-codec instead",
"license": "MIT"
},
"node_modules/supports-color": { "node_modules/supports-color": {
"version": "5.5.0", "version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",

View file

@ -19,6 +19,7 @@
"@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"install": "^0.13.0", "install": "^0.13.0",
"rollup": "^4.22.4" "rollup": "^4.22.4",
"rollup-plugin-cleanup": "^3.2.1"
} }
} }

View file

@ -19,6 +19,7 @@
import { nodeResolve } from "@rollup/plugin-node-resolve" import { nodeResolve } from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs" import commonjs from "@rollup/plugin-commonjs"
import { babel } from "@rollup/plugin-babel" import { babel } from "@rollup/plugin-babel"
import cleanup from "rollup-plugin-cleanup"
import terser from "@rollup/plugin-terser" import terser from "@rollup/plugin-terser"
const path = "LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js" const path = "LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js"
@ -34,6 +35,7 @@ export default {
plugins: [ plugins: [
nodeResolve({ browser: true }), nodeResolve({ browser: true }),
commonjs(), commonjs(),
cleanup({ comments: 'some' }),
babel({ babel({
babelHelpers: "bundled" babelHelpers: "bundled"
}), }),

View file

@ -43,7 +43,7 @@ def test_setup():
def test_map_source(): def test_map_source():
sourcemap_available = debug.SOURCEMAP_INDEX is not None sourcemap_available = debug.SOURCEMAP_INDEX is not None
if sourcemap_available: if sourcemap_available:
assert debug.map_javascript_source("js/index.mjs", 21) == ("js/module/interface.mjs", 21) assert debug.map_javascript_source("js/index.mjs", 22) == ("js/module/interface.mjs", 23)
assert debug.map_javascript_source("js/index.mjs", 100000) == ("js/index.mjs", 100000) # Too long, not found assert debug.map_javascript_source("js/index.mjs", 100000) == ("js/index.mjs", 100000) # Too long, not found
debug.SOURCEMAP_INDEX = None debug.SOURCEMAP_INDEX = None
assert debug.map_javascript_source("js/index.mjs", 21) == ("js/index.mjs", 21) assert debug.map_javascript_source("js/index.mjs", 21) == ("js/index.mjs", 21)