mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-05 15:17:32 +08:00
Guid => GuidEntity
This commit is contained in:
45
dist/ueblueprint.js
vendored
45
dist/ueblueprint.js
vendored
@@ -850,34 +850,30 @@ class Entity {
|
||||
}
|
||||
}
|
||||
|
||||
class Guid extends Primitive {
|
||||
class GuidEntity extends Entity {
|
||||
|
||||
static generateGuid(random) {
|
||||
static attributes = {
|
||||
value: String
|
||||
}
|
||||
|
||||
static generateGuid(random = true) {
|
||||
let values = new Uint32Array(4);
|
||||
if (random === true) {
|
||||
crypto.getRandomValues(values);
|
||||
}
|
||||
let result = "";
|
||||
let guid = "";
|
||||
values.forEach(n => {
|
||||
result += ('00000000' + n.toString(16).toUpperCase()).slice(-8);
|
||||
guid += ('00000000' + n.toString(16).toUpperCase()).slice(-8);
|
||||
});
|
||||
return result
|
||||
return new GuidEntity({ valud: guid })
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
super();
|
||||
// Using constructor equality and not instanceof in order to consider both primitives and objects
|
||||
if (guid?.constructor === Boolean) {
|
||||
guid = Guid.generateGuid(guid == true);
|
||||
}
|
||||
if (guid instanceof Guid) {
|
||||
guid = guid.value;
|
||||
}
|
||||
this.value = guid;
|
||||
getAttributes() {
|
||||
return GuidEntity.attributes
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value.toString()
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,7 +921,7 @@ class PinReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
objectName: PathSymbolEntity,
|
||||
pinGuid: Guid
|
||||
pinGuid: GuidEntity
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
@@ -936,7 +932,7 @@ class PinReferenceEntity extends Entity {
|
||||
class PinEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
PinId: Guid,
|
||||
PinId: GuidEntity,
|
||||
PinName: "",
|
||||
PinFriendlyName: new TypeInitialization(LocalizedTextEntity, false, null),
|
||||
PinToolTip: "",
|
||||
@@ -956,7 +952,7 @@ class PinEntity extends Entity {
|
||||
LinkedTo: [PinReferenceEntity],
|
||||
DefaultValue: "",
|
||||
AutogeneratedDefaultValue: "",
|
||||
PersistentGuid: Guid,
|
||||
PersistentGuid: GuidEntity,
|
||||
bHidden: false,
|
||||
bNotConnectable: false,
|
||||
bDefaultValueIsReadOnly: false,
|
||||
@@ -1070,7 +1066,7 @@ class VariableReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
MemberName: String,
|
||||
MemberGuid: Guid,
|
||||
MemberGuid: GuidEntity,
|
||||
bSelfContext: false
|
||||
}
|
||||
|
||||
@@ -1090,7 +1086,7 @@ class ObjectEntity extends Entity {
|
||||
TargetType: new TypeInitialization(ObjectReferenceEntity, false, null),
|
||||
NodePosX: 0,
|
||||
NodePosY: 0,
|
||||
NodeGuid: Guid,
|
||||
NodeGuid: GuidEntity,
|
||||
CustomProperties: [PinEntity]
|
||||
}
|
||||
|
||||
@@ -1323,7 +1319,7 @@ class Grammar {
|
||||
Integer = _ => P.regex(/[0-9]+/).map(v => new Integer(v)).desc("an integer")
|
||||
String = _ => P.regex(/(?:[^"\\]|\\")*/).wrap(P.string('"'), P.string('"')).desc('string (with possibility to escape the quote using \")')
|
||||
Word = _ => P.regex(/[a-zA-Z]+/).desc("a word")
|
||||
Guid = _ => P.regex(/[0-9a-zA-Z]{32}/).map(v => new Guid(v)).desc("32 digit hexadecimal (accepts all the letters for safety) value")
|
||||
Guid = _ => P.regex(/[0-9a-zA-Z]{32}/).map(v => new GuidEntity({ value: v })).desc("32 digit hexadecimal (accepts all the letters for safety) value")
|
||||
PathSymbolEntity = _ => P.regex(/[0-9a-zA-Z_]+/).map(v => new PathSymbolEntity({ value: v }))
|
||||
ReferencePath = r => P.seq(P.string("/"), r.PathSymbolEntity.map(v => v.toString()).sepBy1(P.string(".")).tieWith("."))
|
||||
.tie()
|
||||
@@ -1379,7 +1375,7 @@ class Grammar {
|
||||
return r.Integer
|
||||
case String:
|
||||
return r.String
|
||||
case Guid:
|
||||
case GuidEntity:
|
||||
return r.Guid
|
||||
case ObjectReferenceEntity:
|
||||
return r.Reference
|
||||
@@ -2224,6 +2220,7 @@ SerializerFactory.registerSerializer(
|
||||
: ""
|
||||
))
|
||||
);
|
||||
SerializerFactory.registerSerializer(PathSymbolEntity, new ToStringSerializer(PathSymbolEntity));
|
||||
SerializerFactory.registerSerializer(PathSymbolEntity, new ToStringSerializer(PathSymbolEntity));
|
||||
SerializerFactory.registerSerializer(GuidEntity, new ToStringSerializer(GuidEntity));
|
||||
|
||||
export { Blueprint, GraphLink, GraphNode };
|
||||
|
||||
Reference in New Issue
Block a user