Refactoring entities (#23)

* Still WIP

* WIP

* ArrayEntity parsing fixed

* Fix format text entity

* Tests for various entity classes and update entity class implementations

* More tests and fixed

* More entities fixed

* Simple entities serialization fixed

* Entities tests fixed

* Remove serialization bits

* Fix Function reference

* CustomProperties creating fixed

* WIP

* Better typing for grammars

* Decoding code fixes

* Fixing still

* Several fixes

* rename toString to serialize

* Several fixes

* More fixes

* Moving more stuff out of Utility

* Several fixes

* Fixing Linear color entity print

* Serialization fixes

* Fix serialization

* Method to compute grammar

* Renaming fix

* Fix array grammar and equality check

* Fix inlined keys

* Fix type

* Several serialization fixes

* Fix undefined dereference

* Several fixes

* More fixes and cleanup

* Fix keys quoting mechanism

* Fix natural number assignment

* Fix Int64 toString()

* Fix quoted keys for inlined arrays

* Fix PG pins

* Fix several test cases

* Types fixes

* New pin default value empty

* Fix non existing DefaultValue for variadic nodes

* Smaller fixes for crashes

* Fix link color when attached to knot

* Linking test and more reliability operations for adding pins

* Improve issue 18 test

* More tests and fixes

* Fix enum pin entity

* Remove failing test
This commit is contained in:
barsdeveloper
2024-09-08 11:46:36 +02:00
committed by GitHub
parent 31a07b992d
commit 23ee628e28
129 changed files with 8888 additions and 8584 deletions

132
types.js
View File

@@ -1,117 +1,45 @@
/**
* @template T
* @typedef {new (...args: any) => T} AnyConstructor
*/
/**
* @template {Attribute} T
* @typedef {AnyConstructor<T> & EntityConstructor | StringConstructor | NumberConstructor | BigIntConstructor
* | BooleanConstructor | ArrayConstructor | MirroredEntityConstructor<T>} AttributeConstructor
* @template {typeof import("./js/entity/IEntity.js").default} T
* @typedef {import("./js/entity/MirroredEntity.js").default<T>} MirroredEntity
*/
/**
* @typedef {[Number, Number]} Coordinates
* @typedef {IEntity | String | Number | BigInt | Boolean | Array} TerminalAttribute
* @typedef {TerminalAttribute | MirroredEntity<TerminalAttribute>} Attribute
* @typedef {(
* AttributeConstructor<Attribute> | AttributeConstructor<Attribute>[]
* | MirroredEntity<Attribute> | Union<any> | Union<any>[] | ComputedType
* )} AttributeTypeDescription
* @typedef {(entity: IEntity) => Attribute} ValueSupplier
*/
/**
* @template {Attribute} T
* @typedef {T extends String
* ? StringConstructor
* : T extends Number
* ? NumberConstructor
* : T extends BigInt
* ? BigIntConstructor
* : T extends Boolean
* ? BooleanConstructor
* : T extends Array
* ? ArrayConstructor
* : T extends MirroredEntity<infer R>
* ? MirroredEntityConstructor<R>
* : T extends IEntity
* ? AnyConstructor<T> & EntityConstructor
* : any
* } ConstructorType
*/
/**
* @template T
* @typedef {T extends AnyConstructor<infer R>
* ? R
* : T extends StringConstructor
* ? String
* : T extends NumberConstructor
* ? Number
* : T extends BigIntConstructor
* ? BigInt
* : T extends BooleanConstructor
* ? Boolean
* : T extends ArrayConstructor
* ? Array
* : any
* } ConstructedType
*/
/**
* @template T
* @typedef {T extends [infer A] ? DescribedType<A>
* : T extends [infer A, ...infer B] ? (DescribedType<A> | DescribedTypesFromArray<B>)
* : any
* } DescribedTypesFromArray
**/
/**
* @template T
* @typedef {T extends AnyConstructor<infer R>
* ? R
* : T extends StringConstructor
* ? String
* : T extends NumberConstructor
* ? Number
* : T extends BigIntConstructor
* ? BigInt
* : T extends BooleanConstructor
* ? Boolean
* : T extends Array<infer R>
* ? DescribedType<R>[]
* : T extends MirroredEntity<infer R>
* ? DescribedType<R>
* : T extends Union<infer R>
* ? DescribedTypesFromArray<R>
* : T
* } DescribedType
*/
/**
* @typedef {import("./js/entity/AttributeInfo.js").default} AttributeInfo
* @typedef {{ [key: String]: AttributeInfo }} AttributeDeclarations
*/
/**
* @typedef {CustomEvent<{ value: Coordinates }>} UEBDragEvent
*/
/** @typedef {typeof import("./js/entity/IEntity.js").default} IEntityConstructor */
/**
* @template T
* @typedef {{
* (value: Boolean): BooleanConstructor,
* (value: Number): NumberConstructor,
* (value: String): StringConstructor,
* (value: BigInt): BigIntConstructor,
* (value: T): typeof value.constructor,
* }} TypeGetter
* @typedef {T extends [infer A] ? InstanceType<A>
* : T extends [infer A, ...infer B] ? InstanceType<A> | UnionFromArray<B>
* : never
* } UnionFromArray
*/
/**
* @template {any[]} T
* @typedef {import("./js/entity/Union.js").default<T>} Union
* @template T
* @typedef {T extends import("./js/entity/AlternativesEntity.js").default<infer R extends any[]> ? Boolean
* : T extends import("./js/entity/ArrayEntity.js").default<infer R extends IEntityConstructor> ? ExtractType<R>
* : InstanceType<T>
* } ExtractType
*/
/**
* @typedef {typeof import("./js/Blueprint.js").default} BlueprintConstructor
* @typedef {typeof import("./js/element/IElement.js").default} IElementConstructor
* @typedef {typeof import("./js/element/LinkElement.js").default} LinkElementConstructor
* @typedef {typeof import("./js/element/NodeElement.js").default} NodeElementConstructor
* @typedef {typeof import("./js/element/PinElement.js").default} PinElementConstructor
* @typedef {typeof import("./js/element/WindowElement.js").default} WindowElementConstructor
* @typedef {typeof import("./js/entity/AlternativesEntity.js").default} AlternativesEntityConstructor
* @typedef {typeof import("./js/entity/IEntity.js").default} EntityConstructor
* @typedef {typeof import("./js/entity/ObjectEntity.js").default} ObjectEntityConstructor
*/
/**
* @template {IEntity} T
* @typedef {import("./js/entity/PinEntity.js").default<T>} PinEntity<T>
*/
/**
* @typedef {import ("./tests/fixtures/BlueprintFixture.js").default} BlueprintFixture
* @typedef {import("./js/Blueprint.js").default} Blueprint
* @typedef {import("./js/element/ColorHandlerElement.js").default} ColorHandlerElement
* @typedef {import("./js/element/ColorSliderElement.js").default} ColorSliderElement
@@ -130,13 +58,12 @@
* @typedef {import("./js/element/WindowElement.js").default} WindowElement
* @typedef {import("./js/entity/ByteEntity.js").default} ByteEntity
* @typedef {import("./js/entity/ColorChannelEntity.js").default} ColorChannelEntity
* @typedef {import("./js/entity/ComputedType.js").default} ComputedType
* @typedef {import("./js/entity/ComputedTypeEntity.js").default} ComputedTypeEntity
* @typedef {import("./js/entity/EnumDisplayValueEntity.js").default} EnumDisplayValueEntity
* @typedef {import("./js/entity/EnumEntity.js").default} EnumEntity
* @typedef {import("./js/entity/FormatTextEntity.js").default} FormatTextEntity
* @typedef {import("./js/entity/FunctionReferenceEntity.js").default} FunctionReferenceEntity
* @typedef {import("./js/entity/GuidEntity.js").default} GuidEntity
* @typedef {import("./js/entity/IdentifierEntity.js").default} IdentifierEntity
* @typedef {import("./js/entity/IEntity.js").default} IEntity
* @typedef {import("./js/entity/Integer64Entity.js").default} Integer64Entity
* @typedef {import("./js/entity/IntegerEntity.js").default} IntegerEntity
@@ -146,11 +73,11 @@
* @typedef {import("./js/entity/LocalizedTextEntity.js").default} LocalizedTextEntity
* @typedef {import("./js/entity/MacroGraphReferenceEntity.js").default} MacroGraphReferenceEntity
* @typedef {import("./js/entity/NaturalNumberEntity.js").default} NaturalNumberEntity
* @typedef {import("./js/entity/NullEntity.js").default} NullEntity
* @typedef {import("./js/entity/NumberEntity.js").default} NumberEntity
* @typedef {import("./js/entity/ObjectEntity.js").default} ObjectEntity
* @typedef {import("./js/entity/ObjectReferenceEntity.js").default} ObjectReferenceEntity
* @typedef {import("./js/entity/objects/KnotEntity.js").default} KnotEntity
* @typedef {import("./js/entity/PathSymbolEntity.js").default} PathSymbolEntity
* @typedef {import("./js/entity/PinEntity.js").default} PinEntity
* @typedef {import("./js/entity/PinReferenceEntity.js").default} PinReferenceEntity
* @typedef {import("./js/entity/PinTypeEntity.js").default} PinTypeEntity
* @typedef {import("./js/entity/RBSerializationVector2DEntity.js").default} RBSerializationVector2DEntity
@@ -158,6 +85,7 @@
* @typedef {import("./js/entity/SimpleSerializationRotatorEntity.js").default} SimpleSerializationRotatorEntity
* @typedef {import("./js/entity/SimpleSerializationVector2DEntity.js").default} SimpleSerializationVector2DEntity
* @typedef {import("./js/entity/SimpleSerializationVectorEntity.js").default} SimpleSerializationVectorEntity
* @typedef {import("./js/entity/StringEntity.js").default} StringEntity
* @typedef {import("./js/entity/SymbolEntity.js").default} SymbolEntity
* @typedef {import("./js/entity/TerminalTypeEntity.js").default} TerminalTypeEntity
* @typedef {import("./js/entity/UnknownKeysEntity.js").default} UnknownKeysEntity
@@ -173,6 +101,7 @@
* @typedef {import("./js/template/ColorSliderTemplate.js").default} ColorSliderTemplate
* @typedef {import("./js/template/IDraggableControlTemplate.js").default} IDraggableControlTemplate
* @typedef {import("./js/template/IDraggablePositionedTemplate.js").default} IDraggablePositionedTemplate
* @typedef {typeof import("./js/entity/ComputedTypeEntity.js").default} ComputedTypeEntityConstructor
* @typedef {import("./js/template/IDraggableTemplate.js").default} IDraggableTemplate
* @typedef {import("./js/template/IFromToPositionedTemplate.js").default} IFromToPositionedTemplate
* @typedef {import("./js/template/IResizeableTemplate.js").default} IResizeableTemplate
@@ -209,23 +138,10 @@
* @typedef {import("./js/template/SelectorTemplate.js").default} SelectorTemplate
* @typedef {import("./js/template/window/ColorPickerWindowTemplate.js").default} ColorPickerWindowTemplate
* @typedef {import("./js/template/window/WindowTemplate.js").default} WindowTemplate
* @typedef {import ("./tests/fixtures/BlueprintFixture.js").default} BlueprintFixture
* @typedef {import("lit").CSSResult} CSSResult
* @typedef {import("lit").PropertyValues} PropertyValues
* @typedef {import("lit").TemplateResult} TemplateResult
*/
/**
* @template {AttributeConstructor<Attribute>} T
* @typedef {import("./js/serialization/Serializer.js").default<T>} Serializer
*/
/**
* @template {Attribute} T
* @typedef {import("./js/entity/MirroredEntity.js").default<T>} MirroredEntity
*/
/**
* @template {Attribute} T
* @typedef {typeof import("./js/entity/MirroredEntity.js").default<T>} MirroredEntityConstructor
*/
/**
* @template T
* @typedef {{