This commit is contained in:
barsdeveloper
2024-12-16 00:44:10 +02:00
parent e405a7245d
commit c0032fed76
8 changed files with 373 additions and 263 deletions

282
dist/ueblueprint.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -142,7 +142,10 @@ export default class ObjectEntity extends IEntity {
ScriptVariables: ArrayEntity.flagInlined().of(ScriptVariableEntity),
Node: MirroredEntity.of(ObjectReferenceEntity),
ExportedNodes: StringEntity,
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(),
CustomProperties: ArrayEntity
.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity))
.withDefault()
.flagSilent(),
}
static customPropertyGrammar = P.seq(
P.reg(/CustomProperties\s+/),
@@ -367,16 +370,41 @@ export default class ObjectEntity extends IEntity {
? outputIndex++
: i
})
const reference = this.ExportPath?.valueOf()
if (reference?.path.endsWith(this.Name?.toString())) {
// Mirror name part of the object in ExportPath
const exportPath = this.ExportPath?.valueOf()
if (exportPath?.path.endsWith(this.Name?.toString())) {
const mirroredEntity = /** @type {typeof ObjectEntity} */(this.constructor).attributes.ExportPath
const objectReferenceEntity = /** @type {typeof ObjectReferenceEntity} */(mirroredEntity.type)
const nameLength = this.Name.valueOf().length
this.ExportPath = new mirroredEntity(() => new objectReferenceEntity(
reference.type,
reference.path.substring(0, reference.path.length - nameLength) + this.Name,
reference.full,
))
const prefix = exportPath.path.substring(0, exportPath.path.length - this.Name.toString().length)
this.ExportPath = new mirroredEntity(
() => new (mirroredEntity.type)(exportPath.type, prefix + this.Name.toString(), exportPath.full)
)
}
// Mirror name part of the nested object in ExportPath
if (this.Name) {
for (const k of Object.keys(this)) {
if (!k.startsWith(Configuration.subObjectAttributeNamePrefix)) {
continue
}
/** @type {ObjectEntity} */
const subObject = this[k]
if (!subObject.ExportPath?.valueOf().path.includes(this.Name.toString())) {
continue
}
const originalExportPath = subObject.ExportPath.valueOf()
const position = originalExportPath.path.indexOf(this.Name.toString())
const prefix = originalExportPath.path.substring(0, position)
const suffix = originalExportPath.path.substring(position + this.Name.toString().length)
const mirroredEntity = /** @type {typeof ObjectEntity} */(subObject.constructor).attributes.ExportPath
subObject.ExportPath = new mirroredEntity(
() => new (mirroredEntity.type)(
originalExportPath.type,
prefix + (this.Name ?? "").toString() + suffix,
originalExportPath.full
)
)
}
}
}
@@ -666,9 +694,10 @@ export default class ObjectEntity extends IEntity {
attributeSeparator = Self.attributeSeparator,
wrap = Self.wrap,
) {
const isSelfOverriden = Self !== this.constructor
const deeperIndentation = indentation + Configuration.indentation
const initial_trailing = this.trailing
this.trailing = false
this.trailing = true
const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap)
this.trailing = initial_trailing
let result = indentation + "Begin Object"
@@ -696,21 +725,21 @@ export default class ObjectEntity extends IEntity {
? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}`
: ""
)
+ (content ? attributeSeparator + content : "")
+ attributeSeparator
+ content
+ (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true
? this.getCustomproperties()
.map(pin =>
attributeSeparator
+ deeperIndentation
deeperIndentation
+ printKey("CustomProperties ")
+ pin.serialize(insideString)
+ attributeSeparator
)
.join("")
: ""
)
+ attributeSeparator
+ indentation + "End Object"
+ (this.trailing ? attributeSeparator : "")
+ (isSelfOverriden && Self.trailing || this.trailing ? attributeSeparator : "")
return result
}
}

View File

@@ -29,27 +29,27 @@ export default class ObjectReferenceEntity extends IEntity {
this.#path = value
}
#full
#serializer
get full() {
return this.#full
return this.#serializer
}
set full(value) {
this.#full = value
this.#serializer = value
}
#name = ""
/** @param {(t: String, p: String) => String} full */
/** @param {(t: String, p: String) => String} serializer */
constructor(
type = "None",
path = "",
full = type.includes("/") || path
serializer = type.includes("/") || path
? (t, p) => `"${t + (p ? (`'${p}'`) : "")}"`
: (t, p) => t) {
super()
this.#type = type
this.#path = path
this.#full = full
this.#serializer = serializer
}
/** @returns {P<ObjectReferenceEntity>} */

View File

@@ -143,7 +143,9 @@ export default class PinTemplate extends ITemplate {
}
isInputRendered() {
return this.element.isInput() && !this.element.entity.PinType.bIsReference?.valueOf()
return this.element.isInput()
&& !this.element.entity.bDefaultValueIsIgnored?.valueOf()
&& !this.element.entity.PinType.bIsReference?.valueOf()
}
renderInput() {

View File

@@ -26,10 +26,10 @@
"homepage": "https://github.com/barsdeveloper/ueblueprint#readme",
"devDependencies": {
"@playwright/test": "1.49",
"@rollup/plugin-commonjs": "^25",
"@rollup/plugin-node-resolve": "^15",
"@rollup/plugin-commonjs": "^28",
"@rollup/plugin-node-resolve": "^16",
"@rollup/plugin-terser": "^0",
"concurrently": "^8",
"concurrently": "^9",
"http-server": "^14",
"rollup": "^4 || ^3 || ^2",
"rollup-plugin-copy": "^3",
@@ -38,7 +38,7 @@
"terser": "^5"
},
"dependencies": {
"lit": "^2",
"lit": "^3",
"parsernostrum": "^1"
}
}

View File

@@ -38,9 +38,9 @@ test("Issue 27", async ({ blueprintPage }) => {
CustomProperties Pin (PinId=424DC49B456B27D825A8F690E6CAA096,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent="/Script/Engine.BlueprintGeneratedClass'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment_C'",MemberName="CustomEvent",MemberGuid=8955D806490FF62840F229BD64AC0F8B),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_AssignDelegate_0 3C0089524CDDA9E63853BEA28156FACD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`)
const eventNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(0)
const knotNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(2)
const assignNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(1)
const eventNode = blueprintPage.blueprintLocator.locator("ueb-node").nth(0)
const knotNode = blueprintPage.blueprintLocator.locator("ueb-node").nth(2)
const assignNode = blueprintPage.blueprintLocator.locator("ueb-node").nth(1)
const pin1 = eventNode.locator("ueb-pin").nth(0)
const pin2A = knotNode.locator("ueb-pin").nth(0)
const pin2B = knotNode.locator("ueb-pin").nth(1)
@@ -49,5 +49,5 @@ test("Issue 27", async ({ blueprintPage }) => {
expect(await pin2A.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await pin2B.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await pin3.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
})

File diff suppressed because one or more lines are too long