mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-16 02:10:38 +08:00
Niagara and Metasound nodes WIP
* Keep track of entities * Fix renaming * Niagara variables wip * Several niagara decode and test * Move nodeTemplate code to dedicated file, self node added * Move node decoding functions to dedicated files * Move pin decoding logic to dedicated files * Accept space separated keys in objects * Build * Prevent a crash in case of incomplete object * Avoid creating objects unnecessarily * types formatting * Initial metasound style * Common pcg nodes colors * Fix string serialization * Metasound new styles and fixes * More metasound styles and colors * WIP * Several fixes * More tests and fixes * Clean gitignore
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import Parsernostrum from "parsernostrum"
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import AttributeInfo from "./AttributeInfo.js"
|
||||
@@ -7,11 +6,6 @@ import IEntity from "./IEntity.js"
|
||||
|
||||
export default class ObjectReferenceEntity extends IEntity {
|
||||
|
||||
static #quoteSymbols = [
|
||||
[`'"`, Grammar.Regex.InsideString.source],
|
||||
[`'`, Grammar.Regex.InsideSingleQuotedString.source],
|
||||
[`"`, Grammar.Regex.InsideString.source]
|
||||
]
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
type: new AttributeInfo({
|
||||
@@ -22,14 +16,15 @@ export default class ObjectReferenceEntity extends IEntity {
|
||||
default: "",
|
||||
serialized: true,
|
||||
}),
|
||||
delim: new AttributeInfo({
|
||||
_full: new AttributeInfo({
|
||||
ignored: true,
|
||||
}),
|
||||
}
|
||||
static quoted = Parsernostrum.regArray(new RegExp(
|
||||
this.#quoteSymbols.map(([delim, parser]) =>
|
||||
delim + "(" + parser + ")" + delim.split("").reverse().join("")).join("|")
|
||||
)).map(([_0, a, b, c]) => a ?? b ?? c)
|
||||
`'"(${Grammar.Regex.InsideString.source})"'`
|
||||
+ "|"
|
||||
+ `'(${Grammar.Regex.InsideSingleQuotedString.source})'`
|
||||
)).map(([_0, a, b]) => a ?? b)
|
||||
static path = this.quoted.getParser().parser.regexp.source + "|" + Grammar.Regex.Path.source
|
||||
static typeReference = Parsernostrum.reg(
|
||||
new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source)
|
||||
@@ -37,28 +32,32 @@ export default class ObjectReferenceEntity extends IEntity {
|
||||
static fullReferenceGrammar = Parsernostrum.regArray(
|
||||
new RegExp(
|
||||
"(" + this.typeReference.getParser().regexp.source + ")"
|
||||
+ /\s*/.source
|
||||
+ "(?:" + this.quoted.getParser().parser.regexp.source + ")"
|
||||
)
|
||||
).map(([_0, type, ...path]) => new this({
|
||||
type,
|
||||
path: path.find(v => v),
|
||||
delim: this.#quoteSymbols[path.findIndex(v => v)]?.[0] ?? "",
|
||||
}))
|
||||
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
|
||||
static fullReferenceSerializedGrammar = Parsernostrum.regArray(
|
||||
new RegExp(
|
||||
"(" + this.typeReference.getParser().regexp.source + ")"
|
||||
+ /\s*/.source
|
||||
+ `'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
|
||||
)
|
||||
).map(([_0, type, ...path]) => new this({
|
||||
type,
|
||||
path: path.find(v => v),
|
||||
delim: "'",
|
||||
}))
|
||||
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "" }))
|
||||
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
|
||||
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v }))
|
||||
static grammar = this.createGrammar()
|
||||
|
||||
constructor(values = {}) {
|
||||
if (values.constructor === String) {
|
||||
values = {
|
||||
path: values
|
||||
}
|
||||
}
|
||||
super(values)
|
||||
if (!values._full || values._full.length === 0) {
|
||||
this._full = `"${this.type + (this.path ? (`'${this.path}'`) : "")}"`
|
||||
}
|
||||
/** @type {String} */ this.type
|
||||
/** @type {String} */ this.path
|
||||
}
|
||||
|
||||
static createGrammar() {
|
||||
return Parsernostrum.alt(
|
||||
Parsernostrum.seq(
|
||||
@@ -68,33 +67,21 @@ export default class ObjectReferenceEntity extends IEntity {
|
||||
this.typeReferenceGrammar,
|
||||
),
|
||||
Parsernostrum.str('"'),
|
||||
).map(([_0, objectReference, _1]) => objectReference),
|
||||
this.fullReferenceGrammar.map(v => (Utility.objectSet(v, ["attributes", "type", "serialized"], false), v)),
|
||||
this.typeReferenceGrammar.map(v => (Utility.objectSet(v, ["attributes", "type", "serialized"], false), v)),
|
||||
).map(([_0, objectReference, _1]) => (objectReference._full = `"${objectReference._full}"`, objectReference)),
|
||||
this.fullReferenceGrammar,
|
||||
this.typeReferenceGrammar,
|
||||
)
|
||||
}
|
||||
|
||||
constructor(values = {}) {
|
||||
if (values.constructor === String) {
|
||||
values = {
|
||||
path: values
|
||||
}
|
||||
}
|
||||
super(values)
|
||||
/** @type {String} */ this.type
|
||||
/** @type {String} */ this.path
|
||||
/** @type {String} */ this.delim
|
||||
}
|
||||
|
||||
static createNoneInstance() {
|
||||
return new ObjectReferenceEntity({ type: "None", path: "" })
|
||||
}
|
||||
|
||||
getName() {
|
||||
return Utility.getNameFromPath(this.path.replace(/_C$/, ""))
|
||||
getName(dropCounter = false) {
|
||||
return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter)
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.type + (this.path ? (this.delim + this.path + this.delim.split("").reverse().join("")) : "")
|
||||
return this._full
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user