Comparing version 0.18.0 to 0.19.0
@@ -92,3 +92,5 @@ "use strict"; | ||
const { compositeStates } = config.theme; | ||
Object.keys(compositeStates).map((pattern) => { | ||
Object.keys(compositeStates) | ||
.sort() | ||
.map((pattern) => { | ||
const regex = new RegExp(pattern, "iu"); | ||
@@ -117,5 +119,13 @@ const matches = []; | ||
}); | ||
state_map.forEach((value, key) => { | ||
emit_decl(key, value, accum); | ||
const sorted = Array.from(state_map.keys()).sort(); | ||
sorted | ||
.filter((key) => state_map.get(key).parent === null) | ||
.forEach((key) => { | ||
emit_decl(key, state_map.get(key), accum); | ||
}); | ||
sorted | ||
.filter((key) => state_map.get(key).parent !== null) | ||
.forEach((key) => { | ||
emit_decl(key, state_map.get(key), accum); | ||
}); | ||
return accum.lines.join("\n"); | ||
@@ -122,0 +132,0 @@ }; |
{ | ||
"name": "asl-puml", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "Generates a plant uml file from a valid JSON ASL file", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -115,36 +115,47 @@ import type { PumlBuilder, StateHints, StateName } from "./types"; | ||
const { compositeStates } = config.theme; | ||
Object.keys(compositeStates).map((pattern) => { | ||
const regex = new RegExp(pattern, "iu"); | ||
const matches: string[] = []; | ||
state_map.forEach((_value, key) => { | ||
if (accum.emitted.has(key)) { | ||
return; | ||
Object.keys(compositeStates) | ||
.sort() | ||
.map((pattern) => { | ||
const regex = new RegExp(pattern, "iu"); | ||
const matches: string[] = []; | ||
state_map.forEach((_value, key) => { | ||
if (accum.emitted.has(key)) { | ||
return; | ||
} | ||
if (regex.test(key)) { | ||
// this state matches a composite state regex | ||
// it should be grouped under the logical header | ||
matches.push(key); | ||
} | ||
}); | ||
if (matches.length > 0) { | ||
// the logical header has matches, emit them | ||
const compositeStateLabel = compositeStates[pattern]; | ||
must(compositeStateLabel, "missing state label", { pattern }); | ||
accum.lines.push( | ||
`state "${compositeStateLabel}" as compositeState${compositeStatesCounter} ##[dashed] {` | ||
); | ||
compositeStatesCounter += 1; | ||
matches.forEach((key) => { | ||
const value = state_map.get(key); | ||
must(value, "failed to find state name", { stateName: key }); | ||
emit_decl(key, value, accum); | ||
}); | ||
accum.lines.push("}"); | ||
} | ||
if (regex.test(key)) { | ||
// this state matches a composite state regex | ||
// it should be grouped under the logical header | ||
matches.push(key); | ||
} | ||
}); | ||
if (matches.length > 0) { | ||
// the logical header has matches, emit them | ||
const compositeStateLabel = compositeStates[pattern]; | ||
must(compositeStateLabel, "missing state label", { pattern }); | ||
accum.lines.push( | ||
`state "${compositeStateLabel}" as compositeState${compositeStatesCounter} ##[dashed] {` | ||
); | ||
compositeStatesCounter += 1; | ||
matches.forEach((key) => { | ||
const value = state_map.get(key); | ||
must(value, "failed to find state name", { stateName: key }); | ||
emit_decl(key, value, accum); | ||
}); | ||
accum.lines.push("}"); | ||
} | ||
}); | ||
state_map.forEach((value, key) => { | ||
emit_decl(key, value, accum); | ||
}); | ||
const sorted = Array.from(state_map.keys()).sort(); | ||
// emit containers first | ||
sorted | ||
.filter((key) => (state_map.get(key) as StateHints).parent === null) | ||
.forEach((key) => { | ||
emit_decl(key, state_map.get(key) as StateHints, accum); | ||
}); | ||
sorted | ||
.filter((key) => (state_map.get(key) as StateHints).parent !== null) | ||
.forEach((key) => { | ||
emit_decl(key, state_map.get(key) as StateHints, accum); | ||
}); | ||
return accum.lines.join("\n"); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117719
2160