Comparing version 0.19.0 to 0.20.0
@@ -44,4 +44,9 @@ "use strict"; | ||
Object.keys(states).forEach((stateName) => { | ||
var _a, _b, _c; | ||
const json = states[stateName]; | ||
(0, must_1.must)(json, "failed to find state name", { stateName }); | ||
const matchedStyle = (_b = (_a = config.theme.stateStyles) === null || _a === void 0 ? void 0 : _a.find((style) => { | ||
const regex = new RegExp(style.pattern, "ui"); | ||
return regex.test(stateName); | ||
})) !== null && _b !== void 0 ? _b : null; | ||
state_map.set(stateName, { | ||
@@ -52,2 +57,3 @@ parent: null, | ||
json, | ||
description: (_c = matchedStyle === null || matchedStyle === void 0 ? void 0 : matchedStyle.description) !== null && _c !== void 0 ? _c : null, | ||
}); | ||
@@ -54,0 +60,0 @@ id += 1; |
@@ -37,2 +37,5 @@ { | ||
"type": "boolean" | ||
}, | ||
"description": { | ||
"type": "string" | ||
} | ||
@@ -39,0 +42,0 @@ }, |
@@ -23,2 +23,3 @@ "use strict"; | ||
accum.emitted.add(stateName); | ||
const isContainer = ["Map", "Parallel"].indexOf(hints.json.Type) !== -1; | ||
const stateDecl = `state "${(0, word_wrap_1.default)(stateName, { | ||
@@ -29,4 +30,3 @@ indent: "", | ||
trim: false, | ||
})}" as state${hints.id}${(_b = hints === null || hints === void 0 ? void 0 : hints.stereotype) !== null && _b !== void 0 ? _b : ""}`; | ||
const isContainer = ["Map", "Parallel"].indexOf(hints.json.Type) !== -1; | ||
})}" as state${hints.id}${(_b = hints === null || hints === void 0 ? void 0 : hints.stereotype) !== null && _b !== void 0 ? _b : ""}${!isContainer && hints.description ? `: ${hints.description}` : ""}`; | ||
const brace = isContainer ? " {" : ""; | ||
@@ -55,2 +55,7 @@ accum.lines.push(`${stateDecl}${brace}`); | ||
accum.lines.push("}"); | ||
if (hints === null || hints === void 0 ? void 0 : hints.description) { | ||
accum.lines.push(`note left of state${hints.id}`); | ||
accum.lines.push(` ${hints.description}\n`); | ||
accum.lines.push(`end note`); | ||
} | ||
} | ||
@@ -57,0 +62,0 @@ const comment = (_c = hints.json.Comment) !== null && _c !== void 0 ? _c : null; |
@@ -9,2 +9,3 @@ import type { Color, CompensationConfig, Config, LineConfig, NoteConfig, StateConfig, StateStyle } from "./generated/config"; | ||
deadPath?: boolean; | ||
description?: string | null; | ||
} | ||
@@ -11,0 +12,0 @@ export type StateName = string; |
{ | ||
"name": "asl-puml", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "Generates a plant uml file from a valid JSON ASL file", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -57,2 +57,7 @@ import { JSONPath } from "jsonpath-plus"; | ||
must(json, "failed to find state name", { stateName }); | ||
const matchedStyle = | ||
config.theme.stateStyles?.find((style) => { | ||
const regex = new RegExp(style.pattern, "ui"); | ||
return regex.test(stateName); | ||
}) ?? null; | ||
state_map.set(stateName, { | ||
@@ -63,2 +68,3 @@ parent: null, | ||
json, | ||
description: matchedStyle?.description ?? null, | ||
}); | ||
@@ -65,0 +71,0 @@ id += 1; |
@@ -37,2 +37,5 @@ { | ||
"type": "boolean" | ||
}, | ||
"description": { | ||
"type": "string" | ||
} | ||
@@ -39,0 +42,0 @@ }, |
@@ -24,2 +24,3 @@ import type { PumlBuilder, StateHints, StateName } from "./types"; | ||
accum.emitted.add(stateName); | ||
const isContainer = ["Map", "Parallel"].indexOf(hints.json.Type) !== -1; | ||
const stateDecl = `state "${wordwrap(stateName, { | ||
@@ -30,4 +31,7 @@ indent: "", | ||
trim: false, | ||
})}" as state${hints.id}${hints?.stereotype ?? ""}`; | ||
const isContainer = ["Map", "Parallel"].indexOf(hints.json.Type) !== -1; | ||
})}" as state${hints.id}${hints?.stereotype ?? ""}${ | ||
// add the description to the state declaration if present and not a container. | ||
// puml doesn't support descriptions on composite states | ||
!isContainer && hints.description ? `: ${hints.description}` : "" | ||
}`; | ||
const brace = isContainer ? " {" : ""; | ||
@@ -59,2 +63,7 @@ accum.lines.push(`${stateDecl}${brace}`); | ||
accum.lines.push("}"); | ||
if (hints?.description) { | ||
accum.lines.push(`note left of state${hints.id}`); | ||
accum.lines.push(` ${hints.description}\n`); | ||
accum.lines.push(`end note`); | ||
} | ||
} | ||
@@ -61,0 +70,0 @@ |
@@ -73,2 +73,3 @@ /* eslint-disable */ | ||
deadPath?: boolean; | ||
description?: string; | ||
} |
@@ -18,2 +18,3 @@ import type { | ||
deadPath?: boolean; | ||
description?: string | null; | ||
} | ||
@@ -20,0 +21,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
120157
2195