Merge remote-tracking branch 'origin/master' into refactoring-entities

This commit is contained in:
barsdeveloper
2024-05-21 15:52:34 +02:00
4 changed files with 19 additions and 26 deletions

17
dist/ueblueprint.js vendored
View File

@@ -2457,7 +2457,7 @@ class Parsernostrum {
}
/**
* @template {[Parsernostrum<any>, Parsernostrum<any>, ...Parsernostrum<any>[]]} P
* @template {Parsernostrum<any>[]} P
* @param {P} parsers
* @returns {Parsernostrum<AlternativeParser<UnwrapParser<P>>>}
*/
@@ -4476,10 +4476,10 @@ class ObjectReferenceEntity extends IEntity {
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
static fullReferenceSerializedGrammar = Parsernostrum.regArray(
new RegExp(
"(" + this.typeReference.getParser().regexp.source + ")"
+ `'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
'"(' + Grammar.Regex.InsideString.source + "?)"
+ "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"`
)
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
).map(([_full, type, path]) => new this({ type, path, _full }))
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v }))
static grammar = this.createGrammar()
@@ -4499,14 +4499,7 @@ class ObjectReferenceEntity extends IEntity {
static createGrammar() {
return Parsernostrum.alt(
Parsernostrum.seq(
Parsernostrum.str('"'),
Parsernostrum.alt(
this.fullReferenceSerializedGrammar,
this.typeReferenceGrammar,
),
Parsernostrum.str('"'),
).map(([_0, objectReference, _1]) => (objectReference._full = `"${objectReference._full}"`, objectReference)),
this.fullReferenceSerializedGrammar,
this.fullReferenceGrammar,
this.typeReferenceGrammar,
)

File diff suppressed because one or more lines are too long

View File

@@ -37,10 +37,10 @@ export default class ObjectReferenceEntity extends IEntity {
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
static fullReferenceSerializedGrammar = Parsernostrum.regArray(
new RegExp(
"(" + this.typeReference.getParser().regexp.source + ")"
+ `'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
'"(' + Grammar.Regex.InsideString.source + "?)"
+ "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"`
)
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
).map(([_full, type, path]) => new this({ type, path, _full }))
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v }))
static grammar = this.createGrammar()
@@ -60,14 +60,7 @@ export default class ObjectReferenceEntity extends IEntity {
static createGrammar() {
return Parsernostrum.alt(
Parsernostrum.seq(
Parsernostrum.str('"'),
Parsernostrum.alt(
this.fullReferenceSerializedGrammar,
this.typeReferenceGrammar,
),
Parsernostrum.str('"'),
).map(([_0, objectReference, _1]) => (objectReference._full = `"${objectReference._full}"`, objectReference)),
this.fullReferenceSerializedGrammar,
this.fullReferenceGrammar,
this.typeReferenceGrammar,
)

View File

@@ -370,6 +370,13 @@ test("ObjectReferenceEntity", () => {
path: "/Script/Engine.GameModeBase",
})
expect(serializer.write(reference)).toBe(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`)
reference = serializer.read(`"/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01"`)
expect(reference).toBeInstanceOf(ObjectReferenceEntity)
expect(reference).toMatchObject({
type: "/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01",
path: "",
})
})
test("PinEntity", () => {