Mergin better performance branch

This commit is contained in:
barsdeveloper
2022-09-04 14:33:22 +02:00
parent 47c15fbf8d
commit 715dee6a5a
97 changed files with 2725 additions and 2833 deletions

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
import ObjectReferenceEntity from "./ObjectReferenceEntity"
@@ -9,10 +7,4 @@ export default class FunctionReferenceEntity extends IEntity {
MemberParent: ObjectReferenceEntity,
MemberName: "",
}
constructor(options = {}) {
super(options)
/** @type {ObjectReferenceEntity} */ this.MemberParent
/** @type {String} */ this.MemberName
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class GuidEntity extends IEntity {
@@ -20,11 +18,6 @@ export default class GuidEntity extends IEntity {
return new GuidEntity({ value: guid })
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
}
valueOf() {
return this.value
}

View File

@@ -1,12 +1,11 @@
// @ts-check
import ISerializable from "./ISerializable"
import Observable from "../Observable"
import TypeInitialization from "./TypeInitialization"
import Utility from "../Utility"
export default class IEntity extends ISerializable {
export default class IEntity extends Observable {
static attributes = {}
#showAsString = false
constructor(values) {
super()
@@ -53,7 +52,7 @@ export default class IEntity extends ISerializable {
}
if (defaultValue instanceof TypeInitialization) {
if (!defaultValue.showDefault) {
target[property] = undefined // Declare undefined to preserve the order or attributes
target[property] = undefined // Declare undefined to preserve the order of attributes
continue
}
defaultValue = defaultValue.value
@@ -68,7 +67,6 @@ export default class IEntity extends ISerializable {
target[property] = TypeInitialization.sanitize(defaultValue, defaultType)
}
}
// @ts-expect-error
const attributes = this.constructor.attributes
if (values.constructor !== Object && Object.getOwnPropertyNames(attributes).length == 1) {
// Where there is just one attribute, option can be the value of that attribute
@@ -78,4 +76,15 @@ export default class IEntity extends ISerializable {
}
defineAllAttributes(this, attributes, values)
}
isShownAsString() {
return this.#showAsString
}
/**
* @param {Boolean} v
*/
setShowAsString(v) {
this.#showAsString = v
}
}

View File

@@ -1,15 +0,0 @@
export default class ISerializable {
#showAsString = false
isShownAsString() {
return this.#showAsString
}
/**
* @param {Boolean} v
*/
setShowAsString(v) {
this.#showAsString = v
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class IdentifierEntity extends IEntity {
@@ -8,9 +6,9 @@ export default class IdentifierEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
static attributeConverter = {
fromAttribute: (value, type) => new IdentifierEntity(value),
toAttribute: (value, type) => value.toString()
}
valueOf() {

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class IntegerEntity extends IEntity {

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class InvariantTextEntity extends IEntity {
@@ -8,9 +6,4 @@ export default class InvariantTextEntity extends IEntity {
static attributes = {
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IdentifierEntity from "./IdentifierEntity"
import IEntity from "./IEntity"
@@ -21,11 +19,5 @@ export default class KeyBindingEntity extends IEntity {
options.bAlt = options.bAlt ?? false
options.bCmd = options.bCmd ?? false
super(options)
/** @type {String} */ this.ActionName
/** @type {Boolean} */ this.bShift
/** @type {Boolean} */ this.bCtrl
/** @type {Boolean} */ this.bAlt
/** @type {Boolean} */ this.bCmd
/** @type {IdentifierEntity} */ this.Key
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class LinearColorEntity extends IEntity {
@@ -10,35 +8,4 @@ export default class LinearColorEntity extends IEntity {
B: Number,
A: Number,
}
constructor(options = {}) {
super(options)
/** @type {Number} */ this.R
/** @type {Number} */ this.G
/** @type {Number} */ this.B
/** @type {Number} */ this.A
}
/**
* @param {Number} number
*/
static numberToString(number) {
return Math.round(number * 255).toString(16)
}
static fromString(value) {
return new LinearColorEntity({
R: parseInt(value.substr(0, 2), 16) / 255,
G: parseInt(value.substr(2, 2), 16) / 255,
B: parseInt(value.substr(4, 2), 16) / 255,
A: parseInt(value.substr(6, 2), 16) / 255,
})
}
toString() {
return "#" + LinearColorEntity.numberToString(this.R)
+ LinearColorEntity.numberToString(this.G)
+ LinearColorEntity.numberToString(this.B)
+ LinearColorEntity.numberToString(this.A)
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class LocalizedTextEntity extends IEntity {
@@ -10,11 +8,4 @@ export default class LocalizedTextEntity extends IEntity {
key: String,
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.namespace
/** @type {String} */ this.key
/** @type {String} */ this.value
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IntegerEntity from "./IntegerEntity"
import Utility from "../Utility"

View File

@@ -1,6 +1,3 @@
// @ts-check
import Utility from "../Utility"
import FunctionReferenceEntity from "./FunctionReferenceEntity"
import GuidEntity from "./GuidEntity"
import IdentifierEntity from "./IdentifierEntity"
@@ -9,6 +6,7 @@ import IntegerEntity from "./IntegerEntity"
import ObjectReferenceEntity from "./ObjectReferenceEntity"
import PinEntity from "./PinEntity"
import TypeInitialization from "./TypeInitialization"
import Utility from "../Utility"
import VariableReferenceEntity from "./VariableReferenceEntity"
export default class ObjectEntity extends IEntity {
@@ -33,25 +31,6 @@ export default class ObjectEntity extends IEntity {
static nameRegex = /(\w+)_(\d+)/
constructor(options = {}) {
super(options)
/** @type {ObjectReferenceEntity} */ this.Class
/** @type {String} */ this.Name
/** @type {Boolean?} */ this.bIsPureFunc
/** @type {VariableReferenceEntity?} */ this.VariableReference
/** @type {FunctionReferenceEntity?} */ this.FunctionReference
/** @type {FunctionReferenceEntity?} */ this.EventReference
/** @type {ObjectReferenceEntity?} */ this.TargetType
/** @type {IntegerEntity} */ this.NodePosX
/** @type {IntegerEntity} */ this.NodePosY
/** @type {IdentifierEntity?} */ this.AdvancedPinDisplay
/** @type {IdentifierEntity?} */ this.EnabledState
/** @type {GuidEntity} */ this.NodeGuid
/** @type {IntegerEntity?} */ this.ErrorType
/** @type {String?} */ this.ErrorMsg
/** @type {PinEntity[]} */ this.CustomProperties
}
getObjectName(dropCounter = false) {
if (dropCounter) {
return this.getNameAndCounter()[0]
@@ -67,6 +46,7 @@ export default class ObjectEntity extends IEntity {
if (result && result.length == 3) {
return [result[1], parseInt(result[2])]
}
return ["", 0]
}
getDisplayName() {

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class ObjectReferenceEntity extends IEntity {
@@ -8,10 +6,4 @@ export default class ObjectReferenceEntity extends IEntity {
type: String,
path: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.type
/** @type {String} */ this.path
}
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
export default class PathSymbolEntity extends IEntity {
@@ -8,11 +6,6 @@ export default class PathSymbolEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.value
}
valueOf() {
return this.value
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
import LinearColorEntity from "./LinearColorEntity"
@@ -44,44 +42,14 @@ export default class PinEntity extends IEntity {
bOrphanedPin: false,
}
constructor(options = {}) {
super(options)
/** @type {GuidEntity} */ this.PinId
/** @type {String} */ this.PinName
/** @type {LocalizedTextEntity} */ this.PinFriendlyName
/** @type {String} */ this.PinToolTip
/** @type {String} */ this.Direction
/**
* @type {{
* PinCategory: String,
* PinSubCategory: String,
* PinSubCategoryObject: ObjectReferenceEntity,
* PinSubCategoryMemberReference: any,
* PinValueType: String,
* ContainerType: ObjectReferenceEntity,
* bIsReference: Boolean,
* bIsConst: Boolean,
* bIsWeakPointer: Boolean,
* bIsUObjectWrapper: Boolean,
* }}
*/ this.PinType
/** @type {PinReferenceEntity[]} */ this.LinkedTo
/** @type {String | LinearColorEntity} */ this.DefaultValue
/** @type {String} */ this.AutogeneratedDefaultValue
/** @type {ObjectReferenceEntity} */ this.DefaultObject
/** @type {GuidEntity} */ this.PersistentGuid
/** @type {Boolean} */ this.bHidden
/** @type {Boolean} */ this.bNotConnectable
/** @type {Boolean} */ this.bDefaultValueIsReadOnly
/** @type {Boolean} */ this.bDefaultValueIsIgnored
/** @type {Boolean} */ this.bAdvancedView
/** @type {Boolean} */ this.bOrphanedPin
}
getDefaultValue() {
return this.DefaultValue ?? ""
}
isHidden() {
return this.bHidden
}
isInput() {
return !this.bHidden && this.Direction != "EGPD_Output"
}
@@ -102,7 +70,6 @@ export default class PinEntity extends IEntity {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const linkFound = this.LinkedTo?.find(pinReferenceEntity => {
// @ts-ignore
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
@@ -121,12 +88,9 @@ export default class PinEntity extends IEntity {
* @param {PinEntity} targetPinEntity
*/
unlinkFrom(targetObjectName, targetPinEntity) {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const indexElement = this.LinkedTo.findIndex(pinReferenceEntity => {
// @ts-expect-error
const indexElement = this.LinkedTo?.findIndex(pinReferenceEntity => {
return pinReferenceEntity.objectName == targetObjectName
&& pinReferenceEntity.pinGuid == targetPinEntity.PinId
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
if (indexElement >= 0) {
if (this.LinkedTo.length == 1) {

View File

@@ -1,5 +1,3 @@
// @ts-check
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
import PathSymbolEntity from "./PathSymbolEntity"
@@ -10,10 +8,4 @@ export default class PinReferenceEntity extends IEntity {
objectName: PathSymbolEntity,
pinGuid: GuidEntity,
}
constructor(options = {}) {
super(options)
/** @type {PathSymbolEntity} */ this.objectName
/** @type {GuidEntity} */ this.pinGuid
}
}

View File

@@ -1,14 +1,5 @@
// @ts-check
/**
* @typedef {import("../entity/IEntity").default} IEntity
* @typedef {(new (object?: Object) => IEntity) | StringConstructor | NumberConstructor | BooleanConstructor} Constructor
* @typedef {Constructor|Constructor[]} AcceptedType
*/
export default class SerializedType {
/** @type {(Constructor|Array<Constructor>)[]} */
#types
get types() {
return this.#types
@@ -17,9 +8,6 @@ export default class SerializedType {
this.#types = v
}
/**
* @param {...AcceptedType} acceptedTypes
*/
constructor(...acceptedTypes) {
this.#types = acceptedTypes
}

View File

@@ -1,5 +1,3 @@
// @ts-check
import SerializedType from "./SerializedType"
/**

View File

@@ -1,5 +1,3 @@
// @ts-check
import IEntity from "./IEntity"
import GuidEntity from "./GuidEntity"
@@ -10,11 +8,4 @@ export default class VariableReferenceEntity extends IEntity {
MemberGuid: GuidEntity,
bSelfContext: false,
}
constructor(options = {}) {
super(options)
/** @type {String} */ this.MemberName
/** @type {GuidEntity} */ this.MemberGuid
/** @type {Boolean} */ this.bSelfContext
}
}