wip: Handle backwards compatibility for passing parts as array
This was broken by some earlier changes, but not it's ok again
This commit is contained in:
parent
7f684d8c17
commit
681a1fc657
2 changed files with 10 additions and 4 deletions
|
@ -13,8 +13,12 @@ export default function Design(config, plugins = false, conditionalPlugins = fal
|
|||
if (Array.isArray(config.parts)) {
|
||||
const parts = {}
|
||||
for (const part of config.parts) {
|
||||
parts[part.name] = part
|
||||
config = addPartConfig(parts[part.name], config)
|
||||
if (typeof part === 'object') {
|
||||
parts[part.name] = part
|
||||
config = addPartConfig(parts[part.name], config)
|
||||
} else if (typeof part === 'string') {
|
||||
parts[part] = part
|
||||
} else throw("Part should be passed as a name of part config object")
|
||||
}
|
||||
config.parts = parts
|
||||
}
|
||||
|
|
|
@ -360,6 +360,8 @@ Pattern.prototype.draft = function () {
|
|||
* Handles pattern sampling
|
||||
*/
|
||||
Pattern.prototype.sample = function () {
|
||||
// Late-stage initialization
|
||||
this.init()
|
||||
if (this.settings.sample.type === 'option') {
|
||||
return this.sampleOption(this.settings.sample.option)
|
||||
} else if (this.settings.sample.type === 'measurement') {
|
||||
|
@ -756,8 +758,8 @@ Pattern.prototype.resolveDependencies = function (graph = this.dependencies) {
|
|||
}
|
||||
|
||||
// Include parts outside the dependency graph
|
||||
if (Array.isArray(this.config.parts)) {
|
||||
for (let part of this.config.parts) {
|
||||
if (typeof this.config.parts === 'object') {
|
||||
for (const part of Object.values(this.config.parts)) {
|
||||
if (typeof part === 'string' && typeof this.dependencies[part] === 'undefined') this.dependencies[part] = []
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue