Refactor jsdoc types (#16)

* WIP

* Fix type 1

* Missing types info

* Some fixes

* Several types refactoring and fixes

* WIP

* Fix grammar
This commit is contained in:
barsdeveloper
2023-09-22 22:56:33 +02:00
committed by GitHub
parent 78c62ee59a
commit fdd86ce5de
78 changed files with 413 additions and 1010 deletions

605
dist/ueblueprint.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -5,13 +5,6 @@ import LinkElement from "./element/LinkElement.js"
import NodeElement from "./element/NodeElement.js"
import Utility from "./Utility.js"
/**
* @typedef {import("./element/PinElement.js").default} PinElement
* @typedef {import("./entity/PinReferenceEntity.js").default} PinReferenceEntity
* @typedef {import("./template/node/CommentNodeTemplate.js").default} CommentNodeTemplate
* @typedef {typeof Blueprint} BlueprintConstructor
*/
/** @extends {IElement<Object, BlueprintTemplate>} */
export default class Blueprint extends IElement {
@@ -203,14 +196,14 @@ export default class Blueprint extends IElement {
getViewportSize() {
return [
this.template.viewportElement.clientWidth,
this.template.viewportElement.clientHeight
this.template.viewportElement.clientHeight,
]
}
getScrollMax() {
return [
this.template.viewportElement.scrollWidth - this.template.viewportElement.clientWidth,
this.template.viewportElement.scrollHeight - this.template.viewportElement.clientHeight
this.template.viewportElement.scrollHeight - this.template.viewportElement.clientHeight,
]
}
@@ -412,8 +405,8 @@ export default class Blueprint extends IElement {
for (const element of graphElements) {
element.blueprint = this
if (element instanceof NodeElement && !this.nodes.includes(element)) {
const nodeName = element.entity.getObjectName()
const homonymNode = this.nodes.find(node => node.entity.getObjectName() == nodeName)
const name = element.entity.getObjectName()
const homonymNode = this.nodes.find(node => node.entity.getObjectName() == name)
if (homonymNode) {
// Inserted node keeps tha name and the homonym nodes is renamed
let name = homonymNode.entity.getObjectName(true)
@@ -421,9 +414,9 @@ export default class Blueprint extends IElement {
do {
++this.#nodeNameCounter[name]
} while (this.nodes.find(node =>
node.entity.getObjectName() == Configuration.nodeName(name, this.#nodeNameCounter[name])
node.entity.getObjectName() == Configuration.nodeTitle(name, this.#nodeNameCounter[name])
))
homonymNode.rename(Configuration.nodeName(name, this.#nodeNameCounter[name]))
homonymNode.rename(Configuration.nodeTitle(name, this.#nodeNameCounter[name]))
}
this.nodes.push(element)
element.addEventListener(Configuration.removeEventName, removeEventHandler)

View File

@@ -1,10 +1,5 @@
import { css } from "lit"
/**
* @typedef {import("./entity/ObjectEntity.js").default} ObjectEntity
* @typedef {import("./entity/ObjectReferenceEntity.js").default} ObjectReferenceEntity
*/
export default class Configuration {
static nodeColors = {
black: css`20, 20, 20`,
@@ -86,7 +81,7 @@ export default class Configuration {
static mouseWheelZoomThreshold = 80
static nodeDragEventName = "ueb-node-drag"
static nodeDragGeneralEventName = "ueb-node-drag-general"
static nodeName = (name, counter) => `${name}_${counter}`
static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeRadius = 8 // px
static nodeReflowEventName = "ueb-node-reflow"
static paths = {

View File

@@ -3,23 +3,6 @@ import Configuration from "./Configuration.js"
import MirroredEntity from "./entity/MirroredEntity.js"
import Union from "./entity/Union.js"
/**
* @typedef {import("./Blueprint.js").default} Blueprint
* @typedef {import("./entity/IEntity.js").AnyValue} AnyValue
* @typedef {import("./entity/IEntity.js").AttributeInformation} AttributeInformation
* @typedef {import("./entity/IEntity.js").default} IEntity
* @typedef {import("./entity/IEntity.js").EntityConstructor} EntityConstructor
* @typedef {import("./entity/LinearColorEntity.js").default} LinearColorEntity
*/
/**
* @template {AnyValue} T
* @typedef {import("./entity/IEntity.js").AnyValueConstructor<T>} AnyValueConstructor
*/
/**
* @template T
* @typedef {import("./entity/IEntity.js").TypeGetter<T>} TypeGetter
*/
export default class Utility {
static booleanConverter = {
@@ -233,20 +216,24 @@ export default class Utility {
}
/**
* @param {null | AnyValue | AttributeInformation} value
* @template {AnyValue} T
* @param {T} value
* @returns {SimpleValueType<T>}
*/
static getType(value) {
if (value === null) {
return null
}
if (value?.constructor === Object && /** @type {AttributeInformation} */(value)?.type instanceof Function) {
// @ts-expect-error
return /** @type {AttributeInformation} */(value).type
}
return /** @type {AnyValueConstructor<any>} */(value?.constructor)
return /** @type {SimpleValueType<any>} */(value?.constructor)
}
/**
* @template {new (...args: any) => any} C
* @template {SimpleValue} V
* @template {SimpleValueType<V>} C
* @param {C} type
* @returns {value is InstanceType<C>}
*/
@@ -257,8 +244,8 @@ export default class Utility {
return (acceptNull && value === null) || value instanceof type || value?.constructor === type
}
/** @param {AnyValue} value */
static sanitize(value, targetType = /** @type {AnyValueConstructor<typeof value>} */(value?.constructor)) {
/** @param {AnyValue | Object} value */
static sanitize(value, targetType = /** @type {SimpleValueType<typeof value>} */(value?.constructor)) {
if (targetType instanceof Array) {
targetType = targetType[0]
}
@@ -283,7 +270,7 @@ export default class Utility {
? BigInt(/** @type {Number} */(value))
: new /** @type {EntityConstructor} */(targetType)(value)
}
if (value instanceof Boolean || value instanceof Number || value instanceof String || value instanceof BigInt) {
if (value instanceof Boolean || value instanceof Number || value instanceof String) {
value = value.valueOf() // Get the relative primitive value
}
return value

View File

@@ -1,16 +1,11 @@
/**
* @typedef {import("./IElement.js").default} IElement
* @typedef {new (...args) => IElement} ElementConstructor
*/
export default class ElementFactory {
/** @type {Map<String, ElementConstructor>} */
/** @type {Map<String, AnyConstructor<IElement>>} */
static #elementConstructors = new Map()
/**
* @param {String} tagName
* @param {ElementConstructor} entityConstructor
* @param {AnyConstructor<IElement>} entityConstructor
*/
static registerElement(tagName, entityConstructor) {
ElementFactory.#elementConstructors.set(tagName, entityConstructor)

View File

@@ -1,11 +1,5 @@
import IDraggableElement from "./IDraggableElement.js"
/**
* @typedef {import("../element/WindowElement.js").default} WindowElement
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../template/IDraggableControlTemplate.js").default} IDraggableControlTemplate
*/
/**
* @template {IEntity} T
* @template {IDraggableControlTemplate} U

View File

@@ -2,15 +2,6 @@ import Configuration from "../Configuration.js"
import IElement from "./IElement.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../template/IDraggableTemplate.js").default} IDraggableTemplate
* @typedef {CustomEvent<{
* value: [Number, Number]
* }>} DragEvent
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {IEntity} T
* @template {IDraggableTemplate} U

View File

@@ -2,16 +2,8 @@ import { LitElement } from "lit"
import Configuration from "../Configuration.js"
/**
* @typedef {import("../Blueprint.js").default} Blueprint
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../input/IInput.js").default} IInput
* @typedef {import("../template/ITemplate.js").default} ITemplate
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {IEntity} T
* @template {ITemplate} U
* @template {IEntity} EntityT
* @template {ITemplate} TemplateT
*/
export default class IElement extends LitElement {
@@ -24,7 +16,7 @@ export default class IElement extends LitElement {
this.#blueprint = v
}
/** @type {T} */
/** @type {EntityT} */
#entity
get entity() {
return this.#entity
@@ -33,7 +25,7 @@ export default class IElement extends LitElement {
this.#entity = entity
}
/** @type {U} */
/** @type {TemplateT} */
#template
get template() {
return this.#template
@@ -46,8 +38,8 @@ export default class IElement extends LitElement {
inputObjects = []
/**
* @param {T} entity
* @param {U} template
* @param {EntityT} entity
* @param {TemplateT} template
*/
initialize(entity, template) {
this.requestUpdate()

View File

@@ -1,14 +1,9 @@
import IElement from "./IElement.js"
/**
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../template/ITemplate.js").default} ITemplate
*/
/**
* @template {IEntity} T
* @template {ITemplate} U
* @extends {IElement<T, U>}
* @template {IEntity} EntityT
* @template {ITemplate} TemplateT
* @extends {IElement<EntityT, TemplateT>}
*/
export default class IFromToPositionedElement extends IElement {

View File

@@ -3,15 +3,9 @@ import IDraggableElement from "./IDraggableElement.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../element/IDraggableElement.js").DragEvent} DragEvent
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../template/ISelectableDraggableTemplate.js").default} ISelectableDraggableTemplate
*/
/**
* @template {IEntity} T
* @template {ISelectableDraggableTemplate} U
* @extends {IDraggableElement<T, U>}
* @template {IEntity} EntityT
* @template {ISelectableDraggableTemplate} TemplateT
* @extends {IDraggableElement<EntityT, TemplateT>}
*/
export default class ISelectableDraggableElement extends IDraggableElement {
@@ -25,7 +19,7 @@ export default class ISelectableDraggableElement extends IDraggableElement {
},
}
/** @param {DragEvent} e */
/** @param {UEBDragEvent} e */
dragHandler = e => this.addLocation(...e.detail.value)
constructor() {

View File

@@ -5,13 +5,6 @@ import LinkTemplate from "../template/LinkTemplate.js"
import SVGIcon from "../SVGIcon.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../element/IDraggableElement.js").DragEvent} DragEvent
* @typedef {import("./PinElement.js").default} PinElement
* @typedef {import("lit").TemplateResult<1>} TemplateResult
* @typedef {typeof LinkElement} LinkElementConstructor
*/
/** @extends {IFromToPositionedElement<Object, LinkTemplate>} */
export default class LinkElement extends IFromToPositionedElement {
@@ -60,9 +53,9 @@ export default class LinkElement extends IFromToPositionedElement {
}
#nodeDeleteHandler = () => this.remove()
/** @param {DragEvent} e */
/** @param {UEBDragEvent} e */
#nodeDragSourceHandler = e => this.addSourceLocation(...e.detail.value)
/** @param {DragEvent} e */
/** @param {UEBDragEvent} e */
#nodeDragDestinatonHandler = e => this.addDestinationLocation(...e.detail.value)
#nodeReflowSourceHandler = e => this.setSourceLocation()
#nodeReflowDestinatonHandler = e => this.setDestinationLocation()
@@ -98,6 +91,7 @@ export default class LinkElement extends IFromToPositionedElement {
* @param {PinElement} source
* @param {PinElement?} destination
*/
// @ts-expect-error
initialize(source, destination) {
super.initialize({}, new LinkTemplate())
if (source) {

View File

@@ -14,14 +14,6 @@ import VariableAccessNodeTemplate from "../template/node/VariableAccessNodeTempl
import VariableConversionNodeTemplate from "../template/node/VariableConversionNodeTemplate.js"
import VariableOperationNodeTemplate from "../template/node/VariableOperationNodeTemplate.js"
/**
* @typedef {import("./IDraggableElement.js").DragEvent} DragEvent
* @typedef {import("./IElement.js").default} IElement
* @typedef {import("../entity/ObjectReferenceEntity.js").default} ObjectReferenceEntity
* @typedef {import("./PinElement.js").default} PinElement
* @typedef {typeof NodeElement} NodeElementConstructor
*/
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
export default class NodeElement extends ISelectableDraggableElement {
@@ -32,9 +24,9 @@ export default class NodeElement extends ISelectableDraggableElement {
attribute: "data-type",
reflect: true,
},
nodeName: {
nodeTitle: {
type: String,
attribute: "data-name",
attribute: "data-title",
reflect: true,
},
advancedPinDisplay: {
@@ -84,7 +76,7 @@ export default class NodeElement extends ISelectableDraggableElement {
/** @type {NodeElement[]} */
boundComments = []
#commentDragged = false
/** @param {DragEvent} e */
/** @param {UEBDragEvent} e */
#commentDragHandler = e => {
// If selected, it will already drag, also must check if under nested comments, it must drag just once
if (!this.selected && !this.#commentDragged) {
@@ -211,7 +203,7 @@ export default class NodeElement extends ISelectableDraggableElement {
super.initialize(entity, template)
this.#pins = this.template.createPinElements()
this.typePath = this.entity.getType()
this.nodeName = this.entity.getObjectName()
this.nodeTitle = this.entity.getObjectName()
this.advancedPinDisplay = this.entity.AdvancedPinDisplay?.toString()
this.enabledState = this.entity.EnabledState
this.nodeDisplayName = this.getNodeDisplayName()
@@ -305,7 +297,7 @@ export default class NodeElement extends ISelectableDraggableElement {
}
}
this.entity.Name = name
this.nodeName = this.entity.Name
this.nodeTitle = this.entity.Name
}
getPinElements() {

View File

@@ -21,18 +21,6 @@ import Utility from "../Utility.js"
import Vector2DPinTemplate from "../template/pin/Vector2DPinTemplate.js"
import VectorPinTemplate from "../template/pin/VectorPinTemplate.js"
/**
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
* @typedef {import("./LinkElement.js").LinkElementConstructor} LinkElementConstructor
* @typedef {import("./NodeElement.js").default} NodeElement
* @typedef {import("lit").CSSResult} CSSResult
* @typedef {typeof PinElement} PinElementConstructor
*/
/**
* @template T
* @typedef {import("parsimmon").Success<T>} Success
*/
/**
* @template {AnyValue} T
* @extends {IElement<PinEntity<T>, PinTemplate>}
@@ -114,10 +102,7 @@ export default class PinElement extends IElement {
/** @type {NodeElement} */
nodeElement
/**
* @param {PinEntity<any>} pinEntity
* @return {new () => PinTemplate}
*/
/** @param {PinEntity<any>} pinEntity */
static getTypeTemplate(pinEntity) {
if (pinEntity.PinType.ContainerType?.toString() === "Array") {
return PinTemplate
@@ -128,16 +113,12 @@ export default class PinElement extends IElement {
if (pinEntity.getType() === "exec") {
return ExecPinTemplate
}
let result
if (pinEntity.isInput()) {
result = PinElement.#inputPinTemplates[pinEntity.getType()]
}
return result ?? PinTemplate
return (pinEntity.isInput() ? PinElement.#inputPinTemplates[pinEntity.getType()] : PinTemplate) ?? PinTemplate
}
static newObject(
entity = new PinEntity(),
template = new (PinElement.getTypeTemplate(entity))(),
template = /** @type {PinTemplate} */(new (PinElement.getTypeTemplate(entity))()),
nodeElement = undefined
) {
const result = new PinElement()
@@ -147,7 +128,7 @@ export default class PinElement extends IElement {
initialize(
entity = /** @type {PinEntity<T>} */(new PinEntity()),
template = new (PinElement.getTypeTemplate(entity))(),
template = /** @type {PinTemplate} */(new (PinElement.getTypeTemplate(entity))()),
nodeElement = undefined
) {
this.nodeElement = nodeElement

View File

@@ -2,8 +2,6 @@ import FastSelectionModel from "../selection/FastSelectionModel.js"
import IFromToPositionedElement from "./IFromToPositionedElement.js"
import SelectorTemplate from "../template/SelectorTemplate.js"
/** @typedef {import("../Blueprint.js").BlueprintConstructor} BlueprintConstructor */
/** @extends {IFromToPositionedElement<Object, SelectorTemplate>} */
export default class SelectorElement extends IFromToPositionedElement {

View File

@@ -3,8 +3,6 @@ import Configuration from "../Configuration.js"
import IDraggableElement from "./IDraggableElement.js"
import WindowTemplate from "../template/window/WindowTemplate.js"
/** @typedef {typeof WindowElement} WindowElementConstructor */
/**
* @template {WindowTemplate} T
* @extends {IDraggableElement<Object, T>}

View File

@@ -1,7 +1,5 @@
import IEntity from "./IEntity.js"
/** @typedef {import("./ObjectEntity.js").default} ObjectEntity */
export default class Base64ObjectsEncoded extends IEntity {
static attributes = {

View File

@@ -1,5 +1,3 @@
/** @typedef {import("./IEntity.js").default} IEntity */
export default class ComputedType {
#f

View File

@@ -5,44 +5,6 @@ import SerializerFactory from "../serialization/SerializerFactory.js"
import Union from "./Union.js"
import Utility from "../Utility.js"
/**
* @template {AnyValue} T
* @typedef {(new (...any) => T) | StringConstructor | NumberConstructor | BigIntConstructor | BooleanConstructor
* | ArrayConstructor} AnyValueConstructor
*/
/**
* @typedef {IEntity | MirroredEntity | String | Number | BigInt | Boolean} AnySimpleValue
* @typedef {AnySimpleValue | AnySimpleValue[]} AnyValue
* @typedef {(entity: IEntity) => AnyValue} ValueSupplier
* @typedef {AnyValueConstructor<AnyValue> | AnyValueConstructor<AnyValue>[] | Union | Union[] | ComputedType | MirroredEntity} AttributeType
* @typedef {{
* type?: AttributeType,
* default?: AnyValue | ValueSupplier,
* nullable?: Boolean,
* ignored?: Boolean,
* serialized?: Boolean,
* expected?: Boolean,
* inlined?: Boolean,
* quoted?: Boolean,
* predicate?: (value: AnyValue) => Boolean,
* }} AttributeInformation
* @typedef {{
* [key: String]: AttributeInformation
* }} AttributeDeclarations
* @typedef {typeof IEntity} EntityConstructor
*/
/**
* @template T
* @typedef {{
* (value: Boolean): BooleanConstructor,
* (value: Number): NumberConstructor,
* (value: String): StringConstructor,
* (value: BigInt): BigIntConstructor,
* (value: T): typeof value.constructor,
* }} TypeGetter
*/
export default class IEntity extends Serializable {
/** @type {String | Union<String[]>} */
@@ -65,7 +27,7 @@ export default class IEntity extends Serializable {
constructor(values = {}, suppressWarns = false) {
super()
/** @type {String} */ this.lookbehind
const Self = /** @type {EntityConstructor} */(this.constructor)
const Self = /** @type {typeof IEntity} */(this.constructor)
let attributes = Self.attributes
if (values.attributes) {
attributes = { ...Self.attributes }
@@ -166,7 +128,7 @@ export default class IEntity extends Serializable {
.getSerializer(defaultType)
.read(/** @type {String} */(value))
}
assignAttribute(Utility.sanitize(value, /** @type {AnyValueConstructor<*>} */(defaultType)))
assignAttribute(Utility.sanitize(value, /** @type {AnyConstructor<*>} */(defaultType)))
continue // We have a value, need nothing more
}
if (Object.hasOwn(attribute, "default")) { // Accept also explicit undefined

View File

@@ -19,14 +19,14 @@ export default class IntegerEntity extends IEntity {
return Grammar.integer.map(v => new this(v))
}
/** @param {Number | AttributeInformation} value */
constructor(value = 0) {
if (value.constructor !== Object) {
// @ts-expect-error
value = {
super(value.constructor === Object
? value
: {
value: value,
}
}
super(value)
)
/** @type {Number} */ this.value
}

View File

@@ -1,9 +1,3 @@
/**
* @typedef {import("./IEntity.js").default} IEntity
* @typedef {import("./IEntity.js").EntityConstructor} EntityConstructor
*/
export default class MirroredEntity {
static attributes = {

View File

@@ -18,8 +18,6 @@ import UnknownPinEntity from "./UnknownPinEntity.js"
import Utility from "../Utility.js"
import VariableReferenceEntity from "./VariableReferenceEntity.js"
/** @typedef {import("./VectorEntity.js").default} VectorEntity */
export default class ObjectEntity extends IEntity {
static #keyName = {
@@ -305,7 +303,7 @@ export default class ObjectEntity extends IEntity {
},
CustomProperties: {
type: [new Union(PinEntity, UnknownPinEntity)],
},
}
}
static {
this.cleanupAttributes(this.attributes)
@@ -316,7 +314,7 @@ export default class ObjectEntity extends IEntity {
Parsimmon.regex(/CustomProperties\s+/),
Grammar.grammarFor(
undefined,
(this.attributes.CustomProperties ?? ObjectEntity.attributes.CustomProperties).type[0]
this.attributes.CustomProperties.type[0]
),
).map(([_0, pin]) => values => {
if (!values.CustomProperties) {
@@ -382,7 +380,7 @@ export default class ObjectEntity extends IEntity {
Parsimmon.regex(/\s+End\s+Object/),
)
.map(([_0, attributes, _2]) => {
let values = {}
const values = {}
attributes.forEach(attributeSetter => attributeSetter(values))
return new this(values)
})
@@ -390,6 +388,7 @@ export default class ObjectEntity extends IEntity {
/** @param {String} value */
static keyName(value) {
/** @type {String} */
let result = ObjectEntity.#keyName[value]
if (result) {
return result
@@ -400,7 +399,7 @@ export default class ObjectEntity extends IEntity {
}
const match = value.match(/NumPad([a-zA-Z]+)/)
if (match) {
result = Utility.numberFromText(match[1])
result = Utility.numberFromText(match[1]).toString()
if (result) {
return "Num " + result
}
@@ -410,10 +409,10 @@ export default class ObjectEntity extends IEntity {
static getMultipleObjectsGrammar() {
return Parsimmon.seq(
Parsimmon.optWhitespace,
this.grammar,
this.createGrammar(),
Parsimmon.seq(
Parsimmon.whitespace,
this.grammar,
this.createGrammar(),
)
.map(([_0, object]) => object)
.many(),

View File

@@ -12,10 +12,10 @@ export default class PathSymbolEntity extends IEntity {
static {
this.cleanupAttributes(this.attributes)
}
static #grammar = Grammar.symbol.map(v => new PathSymbolEntity(v))
static grammar = this.createGrammar()
static createGrammar() {
return PathSymbolEntity.#grammar
return Grammar.symbol.map(v => new this(v))
}
constructor(values) {

View File

@@ -23,12 +23,6 @@ import Utility from "../Utility.js"
import Vector2DEntity from "./Vector2DEntity.js"
import VectorEntity from "./VectorEntity.js"
/**
* @typedef {import("./IEntity.js").AnyValue} AnyValue
* @typedef {import("./ObjectEntity.js").default} ObjectEntity
* @typedef {import("lit").CSSResult} CSSResult
*/
/** @template {AnyValue} T */
export default class PinEntity extends IEntity {

View File

@@ -1,7 +1,5 @@
import Configuration from "../Configuration.js"
/** @typedef {import("../Blueprint.js").default} Blueprint */
/** @template {Element} T */
export default class IInput {

View File

@@ -1,7 +1,3 @@
import IInput from "./IInput"
/** @typedef {import("../Blueprint.js").default} Blueprint */
export default class InputCombination {
constructor() { }

View File

@@ -2,8 +2,6 @@ import ElementFactory from "../../element/ElementFactory.js"
import IInput from "../IInput.js"
import ObjectSerializer from "../../serialization/ObjectSerializer.js"
/** @typedef {import("../../element/NodeElement.js").NodeElementConstructor} NodeElementConstructor */
export default class Paste extends IInput {
static #serializer = new ObjectSerializer()

View File

@@ -2,8 +2,6 @@ import KeyboardShortcut from "./KeyboardShortcut.js"
import Shortcuts from "../../Shortcuts.js"
import Zoom from "../mouse/Zoom.js"
/** @typedef {import("../../Blueprint.js").default} Blueprint */
export default class KeyboardEnableZoom extends KeyboardShortcut {
/** @type {Zoom} */

View File

@@ -2,8 +2,6 @@ import Configuration from "../../Configuration.js"
import IInput from "../IInput.js"
import KeyBindingEntity from "../../entity/KeyBindingEntity.js"
/** @typedef {import("../../Blueprint.js").default} Blueprint */
/**
* @template {Element} T
* @extends IInput<T>

View File

@@ -3,11 +3,6 @@ import IDraggableElement from "../../element/IDraggableElement.js"
import IPointing from "./IPointing.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../Blueprint.js").default} Blueprint
* @typedef {import("../../element/IElement.js").default} IElement
*/
/**
* @template {IElement} T
* @extends {IPointing<T>}

View File

@@ -1,8 +1,6 @@
import IInput from "../IInput.js"
import Utility from "../../Utility.js"
/** @typedef {import("../keyboard/KeyboardShortcut.js").default} KeyboardShortcut */
/**
* @template {Element} T
* @extends {IInput<T>}

View File

@@ -1,11 +1,6 @@
import Configuration from "../../Configuration.js"
import IPointing from "./IPointing.js"
/**
* @typedef {import("../../Blueprint.js").default} Blueprint
* @typedef {import("../keyboard/KeyboardShortcut.js").default} KeyboardShortcut
*/
/**
* @template {Element} T
* @extends {IPointing<T>}

View File

@@ -1,7 +1,5 @@
import MouseMoveDraggable from "./MouseMoveDraggable.js"
/** @typedef {import("../../Blueprint.js").default} Blueprint */
export default class MouseClickDrag extends MouseMoveDraggable {
#onClicked

View File

@@ -2,14 +2,6 @@ import Configuration from "../../Configuration.js"
import ElementFactory from "../../element/ElementFactory.js"
import IMouseClickDrag from "./IMouseClickDrag.js"
/**
* @typedef {import("../../Blueprint.js").default} Blueprint
* @typedef {import("../../element/LinkElement.js").default} LinkElement
* @typedef {import("../../element/LinkElement.js").LinkElementConstructor} LinkElementConstructor
* @typedef {import("../../element/PinElement.js").default} PinElement
* @typedef {import("../../template/pin/KnotPinTemplate.js").default} KnotPinTemplate
*/
/** @extends IMouseClickDrag<PinElement> */
export default class MouseCreateLink extends IMouseClickDrag {

View File

@@ -1,9 +1,5 @@
import IMouseClickDrag from "./IMouseClickDrag.js"
/**
* @typedef {import("../../element/IDraggableElement.js").default} IDraggableElement
*/
/**
* @template {IDraggableElement} T
* @extends {IMouseClickDrag<T>}

View File

@@ -1,10 +1,6 @@
import IMouseClickDrag from "./IMouseClickDrag.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../element/IDraggableElement.js").default} IDraggableElement
*/
/**
* @template {IDraggableElement} T
* @extends {IMouseClickDrag<T>}

View File

@@ -1,10 +1,5 @@
import MouseMoveDraggable from "./MouseMoveDraggable.js"
/**
* @typedef {import("../../element/NodeElement.js").default} NodeElement
* @typedef {import("../../template/node/CommentNodeTemplate.js").default} CommentNodeTemplate
*/
/** @extends {MouseMoveDraggable<NodeElement>} */
export default class MouseMoveNodes extends MouseMoveDraggable {

View File

@@ -1,7 +1,5 @@
import IPointing from "./IPointing.js"
/** @typedef {import("../../Blueprint.js").default} Blueprint */
export default class MouseWheel extends IPointing {
static #ignoreEvent =

View File

@@ -1,12 +1,7 @@
import Serializer from "./Serializer.js"
/**
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<*>} AnyValueConstructor
*/
/**
* @template {AnyValue} T
* @template {SimpleValueType<SimpleValue>} T
* @extends {Serializer<T>}
*/
export default class CustomSerializer extends Serializer {
@@ -14,8 +9,8 @@ export default class CustomSerializer extends Serializer {
#objectWriter
/**
* @param {(v: T, insideString: Boolean) => String} objectWriter
* @param {AnyValueConstructor} entityType
* @param {(v: ConstructedType<T>, insideString: Boolean) => String} objectWriter
* @param {T} entityType
*/
constructor(objectWriter, entityType) {
super(entityType)
@@ -23,7 +18,7 @@ export default class CustomSerializer extends Serializer {
}
/**
* @param {T} entity
* @param {ConstructedType<T>} entity
* @param {Boolean} insideString
* @returns {String}
*/

View File

@@ -6,17 +6,6 @@ import Serializable from "./Serializable.js"
import Union from "../entity/Union.js"
import Utility from "../Utility.js"
/**
* @typedef {import ("../entity/IEntity").AnyValue} AnyValue
* @typedef {import ("../entity/IEntity").AttributeType} AttributeType
* @typedef {import ("../entity/IEntity").AttributeInformation} AttributeInformation
* @typedef {import ("../entity/IEntity").EntityConstructor} EntityConstructor
*/
/**
* @template {AnyValue} T
* @typedef {import ("../entity/IEntity").AnyValueConstructor<T>} AnyValueConstructor
*/
let P = Parsimmon
export default class Grammar {
@@ -133,9 +122,10 @@ export default class Grammar {
}
/**
* @param {AttributeType} type
* @returns {Parsimmon.Parser<any>}
*/
* @template {SimpleValueType<SimpleValue>} T
* @param {T} type
* @returns {Parsimmon.Parser<ConstructedType<T>>}
*/
static grammarFor(
attribute,
type = attribute?.constructor === Object
@@ -181,7 +171,6 @@ export default class Grammar {
break
default:
if (type?.prototype instanceof Serializable) {
// @ts-expect-error
return /** @type {typeof Serializable} */(type).grammar
}
}
@@ -202,8 +191,8 @@ export default class Grammar {
}
/**
* @template {AnyValue} T
* @param {AnyValueConstructor<T>} entityType
* @template {SimpleValueType<SimpleValue>} T
* @param {T} entityType
* @param {String[]} key
* @returns {AttributeInformation}
*/
@@ -256,7 +245,7 @@ export default class Grammar {
/**
* @template {IEntity} T
* @param {new (...args: any) => T} entityType
* @param {AnyConstructor<T> & EntityConstructor} entityType
* @param {Boolean | Number} acceptUnknownKeys Number to specify the limit or true, to let it be a reasonable value
* @returns {Parsimmon.Parser<T>}
*/

View File

@@ -5,6 +5,7 @@ import PinEntity from "../entity/PinEntity.js"
import Serializer from "./Serializer.js"
import SerializerFactory from "./SerializerFactory.js"
/** @extends Serializer<ObjectEntityConstructor> */
export default class ObjectSerializer extends Serializer {
constructor(entityType = ObjectEntity) {

View File

@@ -3,32 +3,22 @@ import IEntity from "../entity/IEntity.js"
import SerializerFactory from "./SerializerFactory.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
* @typedef {import("../entity/IEntity.js").EntityConstructor} EntityConstructor
*/
/**
* @template {AnyValue} T
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<T>} AnyValueConstructor
*/
/** @template {AnyValue} T */
/** @template {SimpleValueType<SimpleValue>} T */
export default class Serializer {
/** @type {(v: String) => String} */
static same = v => v
/** @type {(entity: AnyValue, serialized: String) => String} */
/** @type {(entity: SimpleValue, serialized: String) => String} */
static notWrapped = (entity, serialized) => serialized
/** @type {(entity: AnyValue, serialized: String) => String} */
/** @type {(entity: SimpleValue, serialized: String) => String} */
static bracketsWrapped = (entity, serialized) => `(${serialized})`
/** @param {AnyValueConstructor<T>} entityType */
/** @param {T} entityType */
constructor(
entityType,
/** @type {(entity: T, serialized: String) => String} */
/** @type {(entity: ConstructedType<T>, serialized: String) => String} */
wrap = (entity, serialized) => serialized,
attributeSeparator = ",",
trailingSeparator = false,
@@ -45,13 +35,13 @@ export default class Serializer {
/**
* @param {String} value
* @returns {T}
* @returns {ConstructedType<T>}
*/
read(value) {
return this.doRead(value.trim())
}
/** @param {T} value */
/** @param {ConstructedType<T>} value */
write(value, insideString = false) {
// @ts-expect-error
return this.doWrite(value, insideString)
@@ -59,7 +49,7 @@ export default class Serializer {
/**
* @param {String} value
* @returns {T}
* @returns {ConstructedType<T>}
*/
doRead(value) {
let grammar = Grammar.grammarFor(undefined, this.entityType)
@@ -71,7 +61,7 @@ export default class Serializer {
}
/**
* @param {T & IEntity} entity
* @param {ConstructedType<T> & IEntity} entity
* @param {Boolean} insideString
* @returns {String}
*/
@@ -152,7 +142,6 @@ export default class Serializer {
}
showProperty(entity, key) {
// @ts-expect-error
const attribute = /** @type {EntityConstructor} */(this.entityType).attributes[key]
if (attribute?.constructor === Object && attribute.ignored) {
return false

View File

@@ -1,38 +1,22 @@
/**
* @typedef {import("../entity/IEntity.js").default} IEntity
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
*/
/**
* @template {AnyValue} T
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<T>} AnyValueConstructor
*/
/**
* @template {AnyValue} T
* @typedef {import("./Serializer.js").default<T>} Serializer
*/
export default class SerializerFactory {
/** @type {Map<AnyValueConstructor<AnyValue>, Serializer<AnyValue>>} */
static #serializers = new Map()
/**
* @template {AnyValue} T
* @param {AnyValueConstructor<T>} entity
* @template {SimpleValueType<SimpleValue>} T
* @param {T} type
* @param {Serializer<T>} object
*/
static registerSerializer(entity, object) {
SerializerFactory.#serializers.set(entity, object)
static registerSerializer(type, object) {
SerializerFactory.#serializers.set(type, object)
}
/**
* @template {AnyValue} T
* @param {new (...any) => T} entity
* @returns {Serializer<T>}
* @template {SimpleValueType<any>} T
* @param {T} type
* @returns {Serializer<ConstructedType<T>>}
*/
static getSerializer(entity) {
// @ts-expect-error
return SerializerFactory.#serializers.get(entity)
static getSerializer(type) {
return SerializerFactory.#serializers.get(type)
}
}

View File

@@ -2,23 +2,18 @@ import Serializer from "./Serializer.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<*>} AnyValueConstructor
*/
/**
* @template {AnyValue} T
* @template {SimpleValueType<SimpleValue>} T
* @extends {Serializer<T>}
*/
export default class ToStringSerializer extends Serializer {
/** @param {AnyValueConstructor} entityType */
/** @param {T} entityType */
constructor(entityType) {
super(entityType)
}
/**
* @param {T} entity
* @param {ConstructedType<T>} entity
* @param {Boolean} insideString
*/
doWrite(entity, insideString, indentation = "") {

View File

@@ -39,8 +39,6 @@ import VariableReferenceEntity from "../entity/VariableReferenceEntity.js"
import Vector2DEntity from "../entity/Vector2DEntity.js"
import VectorEntity from "../entity/VectorEntity.js"
/** @typedef {import("../entity/IEntity.js").AnySimpleValue} AnySimpleValue */
Grammar.unknownValue =
Parsimmon.alt(
// Remember to keep the order, otherwise parsing might fail
@@ -78,7 +76,6 @@ export default function initializeSerializerFactory() {
SerializerFactory.registerSerializer(
Array,
new CustomSerializer(
/** @param {AnySimpleValue[]} array */
(array, insideString) =>
`(${array
.map(v =>
@@ -253,9 +250,7 @@ export default function initializeSerializerFactory() {
String,
new CustomSerializer(
(value, insideString) => insideString
// @ts-expect-error
? Utility.escapeString(value)
// @ts-expect-error
: `"${Utility.escapeString(value)}"`,
String
)

View File

@@ -14,14 +14,6 @@ import Unfocus from "../input/mouse/Unfocus.js"
import Utility from "../Utility.js"
import Zoom from "../input/mouse/Zoom.js"
/**
* @typedef {import("../Blueprint.js").default} Blueprint
* @typedef {import("../element/PinElement.js").default} PinElement
* @typedef {import("../element/SelectorElement.js").default} SelectorElement
* @typedef {import("../entity/PinReferenceEntity.js").default} PinReferenceEntity
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/** @extends ITemplate<Blueprint> */
export default class BlueprintTemplate extends ITemplate {
@@ -226,7 +218,7 @@ export default class BlueprintTemplate extends ITemplate {
/** @param {PinReferenceEntity} pinReference */
getPin(pinReference) {
return /** @type {PinElement} */(this.blueprint.querySelector(
`ueb-node[data-name="${pinReference.objectName}"] ueb-pin[data-id="${pinReference.pinGuid}"]`
`ueb-node[data-title="${pinReference.objectName}"] ueb-pin[data-id="${pinReference.pinGuid}"]`
))
}

View File

@@ -1,8 +1,6 @@
import IDraggableControlTemplate from "./IDraggableControlTemplate.js"
import Utility from "../Utility.js"
/** @typedef {import("../element/ColorHandlerElement.js").default} ColorHandlerElement */
/** @extends {IDraggableControlTemplate<ColorHandlerElement>} */
export default class ColorHandlerTemplate extends IDraggableControlTemplate {

View File

@@ -1,8 +1,6 @@
import IDraggableControlTemplate from "./IDraggableControlTemplate.js"
import Utility from "../Utility.js"
/** @typedef {import("../element/ColorHandlerElement.js").default} ColorHandlerElement */
/** @extends {IDraggableControlTemplate<ColorHandlerElement>} */
export default class ColorSliderTemplate extends IDraggableControlTemplate {

View File

@@ -1,11 +1,6 @@
import IDraggableTemplate from "./IDraggableTemplate.js"
import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable.js"
/**
* @typedef {import("../element/IDraggableElement.js").default} IDraggableElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {IDraggableElement} T
* @extends {IDraggableTemplate<T>}

View File

@@ -1,10 +1,5 @@
import IDraggableTemplate from "./IDraggableTemplate.js"
/**
* @typedef {import("../element/IDraggableElement.js").default} IDraggableElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {IDraggableElement} T
* @extends {IDraggableTemplate<T>}

View File

@@ -3,8 +3,6 @@ import ITemplate from "./ITemplate.js"
import KeyboardShortcut from "../input/keyboard/KeyboardShortcut.js"
import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable.js"
/** @typedef {import("../element/IDraggableElement.js").default} IDraggableElement */
/**
* @template {IDraggableElement} T
* @extends {ITemplate<T>}

View File

@@ -1,10 +1,5 @@
import ITemplate from "./ITemplate.js"
/**
* @typedef {import("../element/IFromToPositionedElement.js").default} IFromToPositionedElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {IFromToPositionedElement} T
* @extends {ITemplate<T>}

View File

@@ -1,11 +1,6 @@
import MouseClickDrag from "../input/mouse/MouseClickDrag.js"
import NodeTemplate from "./node/NodeTemplate.js"
/**
* @typedef {import("../element/NodeElement.js").default} NodeElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
export default class IResizeableTemplate extends NodeTemplate {
#THandler = document.createElement("div")

View File

@@ -1,12 +1,6 @@
import IDraggablePositionedTemplate from "./IDraggablePositionedTemplate.js"
import MouseMoveNodes from "../input/mouse/MouseMoveNodes.js"
/**
* @typedef {import("../element/NodeElement.js").default} NodeElement
* @typedef {import("../input/mouse/MouseMoveDraggable.js").default} MouseMoveDraggable
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {NodeElement} T
* @extends {IDraggablePositionedTemplate<T>}

View File

@@ -1,15 +1,9 @@
import { html } from "lit"
/**
* @typedef {import("../element/IElement.js").default} IElement
* @typedef {import("../input/IInput.js").default} IInput
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/** @template {IElement} T */
/** @template {IElement} ElementT */
export default class ITemplate {
/** @type {T} */
/** @type {ElementT} */
element
get blueprint() {
@@ -22,7 +16,7 @@ export default class ITemplate {
return this.#inputObjects
}
/** @param {T} element */
/** @param {ElementT} element */
initialize(element) {
this.element = element
}

View File

@@ -9,15 +9,6 @@ import MouseDbClick from "../input/mouse/MouseDbClick.js"
import Shortcuts from "../Shortcuts.js"
import Utility from "../Utility.js"
/**
* @typedef {import("../element/LinkElement.js").default} LinkElement
* @typedef {import("../element/LinkElement.js").LinkElementConstructor} LinkElementConstructor
* @typedef {import("../element/NodeElement.js").NodeElementConstructor} NodeElementConstructor
* @typedef {import("./node/KnotNodeTemplate.js").default} KnotNodeTemplate
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/** @extends {IFromToPositionedTemplate<LinkElement>} */
export default class LinkTemplate extends IFromToPositionedTemplate {

View File

@@ -1,7 +1,5 @@
import IFromToPositionedTemplate from "./IFromToPositionedTemplate.js"
/** @typedef {import("../element/SelectorElement.js").default} SelectorElement */
/** @extends IFromToPositionedTemplate<SelectorElement> */
export default class SelectorTemplate extends IFromToPositionedTemplate {
}

View File

@@ -3,11 +3,6 @@ import Configuration from "../../Configuration.js"
import IResizeableTemplate from "../IResizeableTemplate.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../element/NodeElement.js").default} NodeElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
export default class CommentNodeTemplate extends IResizeableTemplate {
#selectableAreaHeight = 0

View File

@@ -4,11 +4,6 @@ import ElementFactory from "../../element/ElementFactory.js"
import MinimalPinTemplate from "../pin/MinimalPinTemplate.js"
import NodeTemplate from "./NodeTemplate.js"
/**
* @typedef {import("../../element/PinElement.js").PinElementConstructor} PinElementConstructor
* @typedef {import("lit").PropertyValues} PropertyValues
*/
export default class EventNodeTemplate extends NodeTemplate {
static nodeStyleClasses = [...super.nodeStyleClasses, "ueb-node-style-event"]

View File

@@ -4,12 +4,6 @@ import ElementFactory from "../../element/ElementFactory.js"
import KnotPinTemplate from "../pin/KnotPinTemplate.js"
import NodeTemplate from "./NodeTemplate.js"
/**
* @typedef {import("../../element/NodeElement.js").default} NodeElement
* @typedef {import("../../element/PinElement.js").default} PinElement
* @typedef {import("../../element/PinElement.js").PinElementConstructor} PinElementConstructor
*/
export default class KnotNodeTemplate extends NodeTemplate {
static #traversedPin = new Set()

View File

@@ -4,19 +4,9 @@ import ISelectableDraggableTemplate from "../ISelectableDraggableTemplate.js"
import SVGIcon from "../../SVGIcon.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../element/NodeElement.js").default} NodeElement
* @typedef {import("../../element/PinElement.js").default} PinElement
* @typedef {import("../../element/PinElement.js").PinElementConstructor} PinElementConstructor
* @typedef {import("../../entity/PinEntity.js").default} PinEntity
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/** @extends {ISelectableDraggableTemplate<NodeElement>} */
export default class NodeTemplate extends ISelectableDraggableTemplate {
/** @typedef {typeof NodeTemplate} NodeTemplateConstructor */
static nodeStyleClasses = ["ueb-node-style-default"]
#hasSubtitle = false

View File

@@ -1,8 +1,6 @@
import Configuration from "../../Configuration.js"
import VariableManagementNodeTemplate from "./VariableMangementNodeTemplate.js"
/** @typedef {import("../../element/NodeElement.js").default} NodeElement */
export default class VariableAccessNodeTemplate extends VariableManagementNodeTemplate {
/** @param {NodeElement} element */

View File

@@ -3,11 +3,6 @@ import ElementFactory from "../../element/ElementFactory.js"
import NodeTemplate from "./NodeTemplate.js"
import SVGIcon from "../../SVGIcon.js"
/**
* @typedef {import("../../element/NodeElement.js").default} NodeElement
* @typedef {import("../../element/PinElement.js").PinElementConstructor} PinElementConstructor
*/
export default class VariableManagementNodeTemplate extends NodeTemplate {
#hasInput = false

View File

@@ -2,8 +2,6 @@ import { html } from "lit"
import MouseIgnore from "../../input/mouse/MouseIgnore.js"
import PinTemplate from "./PinTemplate.js"
/** @typedef {import("lit").PropertyValues} PropertyValues */
/** @extends PinTemplate<Boolean> */
export default class BoolPinTemplate extends PinTemplate {

View File

@@ -2,11 +2,6 @@ import { html } from "lit"
import ITemplate from "../ITemplate.js"
import MouseIgnore from "../../input/mouse/MouseIgnore.js"
/**
* @typedef {import ("../../element/DropdownElement.js").default} DropdownElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/** @extends {ITemplate<DropdownElement>} */
export default class DropdownTemplate extends ITemplate {

View File

@@ -3,17 +3,6 @@ import Configuration from "../../Configuration.js"
import IInputPinTemplate from "./IInputPinTemplate.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../element/DropdownElement.js").default} DropdownElement
* @typedef {import("../../element/PinElement.js").AnyValue} AnyValue
* @typedef {import("../../entity/EnumEntity.js").default} EnumEntity
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template {AnyValue} T
* @typedef {import("../../element/PinElement.js").default<T>} PinElement
*/
/** @extends IInputPinTemplate<EnumEntity> */
export default class EnumPinTemplate extends IInputPinTemplate {

View File

@@ -3,10 +3,8 @@ import Configuration from "../../Configuration.js"
import PinTemplate from "./PinTemplate.js"
import Utility from "../../Utility.js"
/** @typedef {import("lit").PropertyValues} PropertyValues */
/**
* @template T
* @template {AnyValue} T
* @extends PinTemplate<T>
*/
export default class IInputPinTemplate extends PinTemplate {

View File

@@ -1,7 +1,7 @@
import IInputPinTemplate from "./IInputPinTemplate.js"
/**
* @template T
* @template {AnyValue} T
* @extends IInputPinTemplate<T>
*/
export default class INumericPinTemplate extends IInputPinTemplate {

View File

@@ -1,11 +1,6 @@
import ITemplate from "../ITemplate.js"
import MouseIgnore from "../../input/mouse/MouseIgnore.js"
/**
* @typedef {import ("../../element/InputElement").default} InputElement
* @typedef {import ("lit").PropertyValues} PropertyValues
*/
/** @extends {ITemplate<InputElement>} */
export default class InputTemplate extends ITemplate {

View File

@@ -1,8 +1,6 @@
import { html } from "lit"
import INumericPinTemplate from "./INumericPinTemplate.js"
/** @typedef {import("../../entity/IntegerEntity.js").default} IntegerEntity */
/** @extends INumericPinTemplate<IntegerEntity> */
export default class IntPinTemplate extends INumericPinTemplate {

View File

@@ -2,11 +2,6 @@ import { html } from "lit"
import MinimalPinTemplate from "./MinimalPinTemplate.js"
import Utility from "../../Utility.js"
/**
* @typedef {import("../../entity/PinEntity.js").default} KnotEntity
* @typedef {import("../node/KnotNodeTemplate.js").default} KnotNodeTemplate
*/
/** @extends MinimalPinTemplate<KnotEntity> */
export default class KnotPinTemplate extends MinimalPinTemplate {

View File

@@ -4,12 +4,6 @@ import Configuration from "../../Configuration.js"
import ElementFactory from "../../element/ElementFactory.js"
import PinTemplate from "./PinTemplate.js"
/**
* @typedef {import("../../element/WindowElement.js").default} WindowElement
* @typedef {import("../../element/WindowElement.js").WindowElementConstructor} WindowElementConstructor
* @typedef {import("../../entity/LinearColorEntity.js").default} LinearColorEntity
*/
/** @extends PinTemplate<LinearColorEntity> */
export default class LinearColorPinTemplate extends PinTemplate {

View File

@@ -1,15 +1,9 @@
import { html } from "lit"
import PinTemplate from "./PinTemplate.js"
/** @typedef {import("../../entity/IEntity.js").AnyValue} AnyValue */
/**
* @template {AnyValue} T
* @typedef {import("../../element/PinElement.js").default<T>} PinElement
*/
/**
* @template {AnyValue} T
* @extends PinTemplate<PinElement<T>>
* @extends PinTemplate<T>
*/
export default class MinimalPinTemplate extends PinTemplate {

View File

@@ -8,16 +8,12 @@ import VariableConversionNodeTemplate from "../node/VariableConversionNodeTempla
import VariableOperationNodeTemplate from "../node/VariableOperationNodeTemplate.js"
/**
* @typedef {import("../../input/IInput.js").default} IInput
* @typedef {import("lit").PropertyValues} PropertyValues
*/
/**
* @template T
* @template {AnyValue} T
* @typedef {import("../../element/PinElement.js").default<T>} PinElement
*/
/**
* @template T
* @template {AnyValue} T
* @extends ITemplate<PinElement<T>>
*/
export default class PinTemplate extends ITemplate {

View File

@@ -3,9 +3,7 @@ import INumericPinTemplate from "./INumericPinTemplate.js"
import RotatorEntity from "../../entity/RotatorEntity.js"
import Utility from "../../Utility.js"
/** @typedef {import("../../entity/RotatorEntity.js").default} Rotator */
/** @extends INumericPinTemplate<Rotator> */
/** @extends INumericPinTemplate<RotatorEntity> */
export default class RotatorPinTemplate extends INumericPinTemplate {
#getR() {

View File

@@ -7,11 +7,6 @@ import LinearColorEntity from "../../entity/LinearColorEntity.js"
import Utility from "../../Utility.js"
import WindowTemplate from "./WindowTemplate.js"
/**
* @typedef {import("../../element/WindowElement.js").default} WindowElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
export default class ColorPickerWindowTemplate extends WindowTemplate {
/** @type {ColorHandlerElement} */ #wheelHandler

View File

@@ -4,8 +4,6 @@ import IDraggablePositionedTemplate from "../IDraggablePositionedTemplate.js"
import MouseMoveDraggable from "../../input/mouse/MouseMoveDraggable.js"
import SVGIcon from "../../SVGIcon.js"
/** @typedef {import("../../element/WindowElement.js").default} WindowElement */
/** @extends {IDraggablePositionedTemplate<WindowElement>} */
export default class WindowTemplate extends IDraggablePositionedTemplate {

204
js/types.js Normal file
View File

@@ -0,0 +1,204 @@
/**
* @template T
* @typedef {new (...args: any) => T} AnyConstructor
*/
/**
* @typedef {IEntity | String | Number | BigInt | Boolean | Array | MirroredEntity} SimpleValue
* @typedef {SimpleValue | Union | Union[]} AnyValue
* @typedef {SimpleValueType<SimpleValue> | SimpleValueType<SimpleValue>[] | MirroredEntity | Union | Union[] | ComputedType} AttributeType
* @typedef {(entity: IEntity) => AnyValue} ValueSupplier
*/
/**
* @template {SimpleValue} T
* @typedef {AnyConstructor<T> & EntityConstructor | StringConstructor | NumberConstructor | BigIntConstructor
* | BooleanConstructor | ArrayConstructor | MirroredEntityConstructor} SimpleValueType
*/
/**
* @template {SimpleValue} 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
* ? MirroredEntityConstructor
* : T extends IEntity
* ? AnyConstructor<T> & EntityConstructor
* : any
* } ConstructorType
*/
/**
* @template T
* @typedef {T extends StringConstructor
* ? String
* : T extends NumberConstructor
* ? Number
* : T extends BigIntConstructor
* ? BigInt
* : T extends BooleanConstructor
* ? Boolean
* : T extends ArrayConstructor
* ? Array
* : T extends MirroredEntity
* ? MirroredEntity
* : T extends AnyConstructor<infer R>
* ? R
* : any
* } ConstructedType
*/
/**
* @typedef {{
* type?: AttributeType,
* default?: AnyValue | ValueSupplier,
* nullable?: Boolean,
* ignored?: Boolean,
* serialized?: Boolean,
* expected?: Boolean,
* inlined?: Boolean,
* quoted?: Boolean,
* predicate?: (value: AnyValue) => Boolean,
* }} AttributeInformation
* @typedef {{ [key: String]: AttributeInformation }} AttributeDeclarations
*/
/**
* @typedef {CustomEvent<{ value: [Number, Number] }>} UEBDragEvent
*/
/**
* @template T
* @typedef {{
* (value: Boolean): BooleanConstructor,
* (value: Number): NumberConstructor,
* (value: String): StringConstructor,
* (value: BigInt): BigIntConstructor,
* (value: T): typeof value.constructor,
* }} TypeGetter
*/
/**
* @typedef {typeof import("./Blueprint.js").default} BlueprintConstructor
* @typedef {typeof import("./element/LinkElement.js").default} LinkElementConstructor
* @typedef {typeof import("./element/NodeElement.js").default} NodeElementConstructor
* @typedef {typeof import("./element/PinElement.js").default} PinElementConstructor
* @typedef {typeof import("./element/WindowElement.js").default} WindowElementConstructor
* @typedef {typeof import("./entity/IEntity.js").default} EntityConstructor
* @typedef {typeof import("./entity/MirroredEntity.js").default} MirroredEntityConstructor
* @typedef {typeof import("./entity/ObjectEntity.js").default} ObjectEntityConstructor
*/
/**
* @typedef {import("./Blueprint.js").default} Blueprint
* @typedef {import("./element/ColorHandlerElement.js").default} ColorHandlerElement
* @typedef {import("./element/ColorSliderElement.js").default} ColorSliderElement
* @typedef {import("./element/DropdownElement.js").default} DropdownElement
* @typedef {import("./element/ElementFactory.js").default} ElementFactory
* @typedef {import("./element/IDraggableControlElement.js").default} IDraggableControlElement
* @typedef {import("./element/IDraggableElement.js").default} IDraggableElement
* @typedef {import("./element/IElement.js").default} IElement
* @typedef {import("./element/IFromToPositionedElement.js").default} IFromToPositionedElement
* @typedef {import("./element/InputElement.js").default} InputElement
* @typedef {import("./element/ISelectableDraggableElement.js").default} ISelectableDraggableElement
* @typedef {import("./element/LinkElement.js").default} LinkElement
* @typedef {import("./element/NodeElement.js").default} NodeElement
* @typedef {import("./element/PinElement.js").default} PinElement
* @typedef {import("./element/SelectorElement.js").default} SelectorElement
* @typedef {import("./element/WindowElement.js").default} WindowElement
* @typedef {import("./entity/Base64ObjectsEncoded.js").default} Base64ObjectsEncoded
* @typedef {import("./entity/ByteEntity.js").default} ByteEntity
* @typedef {import("./entity/ColorChannelEntity.js").default} ColorChannelEntity
* @typedef {import("./entity/ComputedType.js").default} ComputedType
* @typedef {import("./entity/EnumDisplayValueEntity.js").default} EnumDisplayValueEntity
* @typedef {import("./entity/EnumEntity.js").default} EnumEntity
* @typedef {import("./entity/FormatTextEntity.js").default} FormatTextEntity
* @typedef {import("./entity/FunctionReferenceEntity.js").default} FunctionReferenceEntity
* @typedef {import("./entity/GuidEntity.js").default} GuidEntity
* @typedef {import("./entity/IdentifierEntity.js").default} IdentifierEntity
* @typedef {import("./entity/IEntity.js").default} IEntity
* @typedef {import("./entity/Integer64Entity.js").default} Integer64Entity
* @typedef {import("./entity/IntegerEntity.js").default} IntegerEntity
* @typedef {import("./entity/InvariantTextEntity.js").default} InvariantTextEntity
* @typedef {import("./entity/KeyBindingEntity.js").default} KeyBindingEntity
* @typedef {import("./entity/LinearColorEntity.js").default} LinearColorEntity
* @typedef {import("./entity/LocalizedTextEntity.js").default} LocalizedTextEntity
* @typedef {import("./entity/MacroGraphReferenceEntity.js").default} MacroGraphReferenceEntity
* @typedef {import("./entity/MirroredEntity.js").default} MirroredEntity
* @typedef {import("./entity/NaturalNumberEntity.js").default} NaturalNumberEntity
* @typedef {import("./entity/ObjectEntity.js").default} ObjectEntity
* @typedef {import("./entity/ObjectReferenceEntity.js").default} ObjectReferenceEntity
* @typedef {import("./entity/objects/KnotEntity.js").default} KnotEntity
* @typedef {import("./entity/PathSymbolEntity.js").default} PathSymbolEntity
* @typedef {import("./entity/PinEntity.js").default} PinEntity
* @typedef {import("./entity/PinReferenceEntity.js").default} PinReferenceEntity
* @typedef {import("./entity/PinTypeEntity.js").default} PinTypeEntity
* @typedef {import("./entity/RotatorEntity.js").default} RotatorEntity
* @typedef {import("./entity/SimpleSerializationRotatorEntity.js").default} SimpleSerializationRotatorEntity
* @typedef {import("./entity/SimpleSerializationVector2DEntity.js").default} SimpleSerializationVector2DEntity
* @typedef {import("./entity/SimpleSerializationVectorEntity.js").default} SimpleSerializationVectorEntity
* @typedef {import("./entity/SymbolEntity.js").default} SymbolEntity
* @typedef {import("./entity/TerminalTypeEntity.js").default} TerminalTypeEntity
* @typedef {import("./entity/Union.js").default} Union
* @typedef {import("./entity/UnknownKeysEntity.js").default} UnknownKeysEntity
* @typedef {import("./entity/UnknownPinEntity.js").default} UnknownPinEntity
* @typedef {import("./entity/VariableReferenceEntity.js").default} VariableReferenceEntity
* @typedef {import("./entity/Vector2DEntity.js").default} Vector2DEntity
* @typedef {import("./entity/VectorEntity.js").default} VectorEntity
* @typedef {import("./input/IInput.js").default} IInput
* @typedef {import("./template/BlueprintTemplate.js").default} BlueprintTemplate
* @typedef {import("./template/ColorHandlerTemplate.js").default} ColorHandlerTemplate
* @typedef {import("./template/ColorSliderTemplate.js").default} ColorSliderTemplate
* @typedef {import("./template/IDraggableControlTemplate.js").default} IDraggableControlTemplate
* @typedef {import("./template/IDraggablePositionedTemplate.js").default} IDraggablePositionedTemplate
* @typedef {import("./template/IDraggableTemplate.js").default} IDraggableTemplate
* @typedef {import("./template/IFromToPositionedTemplate.js").default} IFromToPositionedTemplate
* @typedef {import("./template/IResizeableTemplate.js").default} IResizeableTemplate
* @typedef {import("./template/ISelectableDraggableTemplate.js").default} ISelectableDraggableTemplate
* @typedef {import("./template/ITemplate.js").default} ITemplate
* @typedef {import("./template/LinkTemplate.js").default} LinkTemplate
* @typedef {import("./template/node/CommentNodeTemplate.js").default} CommentNodeTemplate
* @typedef {import("./template/node/EventNodeTemplate.js").default} EventNodeTemplate
* @typedef {import("./template/node/KnotNodeTemplate.js").default} KnotNodeTemplate
* @typedef {import("./template/node/NodeTemplate.js").default} NodeTemplate
* @typedef {import("./template/node/VariableAccessNodeTemplate.js").default} VariableAccessNodeTemplate
* @typedef {import("./template/node/VariableConversionNodeTemplate.js").default} VariableConversionNodeTemplate
* @typedef {import("./template/node/VariableMangementNodeTemplate.js").default} VariableMangementNodeTemplate
* @typedef {import("./template/node/VariableOperationNodeTemplate.js").default} VariableOperationNodeTemplate
* @typedef {import("./template/pin/BoolPinTemplate.js").default} BoolPinTemplate
* @typedef {import("./template/pin/DropdownTemplate.js").default} DropdownTemplate
* @typedef {import("./template/pin/EnumPinTemplate.js").default} EnumPinTemplate
* @typedef {import("./template/pin/ExecPinTemplate.js").default} ExecPinTemplate
* @typedef {import("./template/pin/IInputPinTemplate.js").default} IInputPinTemplate
* @typedef {import("./template/pin/InputTemplate.js").default} InputTemplate
* @typedef {import("./template/pin/Int64PinTemplate.js").default} Int64PinTemplate
* @typedef {import("./template/pin/IntPinTemplate.js").default} IntPinTemplate
* @typedef {import("./template/pin/INumericPinTemplate.js").default} INumericPinTemplate
* @typedef {import("./template/pin/KnotPinTemplate.js").default} KnotPinTemplate
* @typedef {import("./template/pin/LinearColorPinTemplate.js").default} LinearColorPinTemplate
* @typedef {import("./template/pin/MinimalPinTemplate.js").default} MinimalPinTemplate
* @typedef {import("./template/pin/NamePinTemplate.js").default} NamePinTemplate
* @typedef {import("./template/pin/RealPinTemplate.js").default} RealPinTemplate
* @typedef {import("./template/pin/ReferencePinTemplate.js").default} ReferencePinTemplate
* @typedef {import("./template/pin/RotatorPinTemplate.js").default} RotatorPinTemplate
* @typedef {import("./template/pin/StringPinTemplate.js").default} StringPinTemplate
* @typedef {import("./template/pin/Vector2DPinTemplate.js").default} Vector2DPinTemplate
* @typedef {import("./template/pin/VectorPinTemplate.js").default} VectorPinTemplate
* @typedef {import("./template/SelectorTemplate.js").default} SelectorTemplate
* @typedef {import("./template/window/ColorPickerWindowTemplate.js").default} ColorPickerWindowTemplate
* @typedef {import("./template/window/WindowTemplate.js").default} WindowTemplate
* @typedef {import("./input/keyboard/KeyboardShortcut.js").default} KeyboardShortcut
* @typedef {import("lit").CSSResult} CSSResult
* @typedef {import("lit").PropertyValues} PropertyValues
* @typedef {import("lit").TemplateResult} TemplateResult
*/
/**
* @template {SimpleValueType<SimpleValue>} T
* @typedef {import("./serialization/Serializer.js").default<T>} Serializer
*/
/**
* @template T
* @typedef {import("parsimmon").Success} Success
*/