Normalize Ink graph choice targets

This commit is contained in:
Meta Vens 2026-05-31 12:02:24 +01:00
commit bfb6cc5baa
2 changed files with 20 additions and 4 deletions

12
dist/sai.js vendored
View file

@ -647,11 +647,19 @@
.toLowerCase();
}
function choiceTargetPath(choice) {
const target = choice?.targetPath;
if (!target) return "";
if (typeof target.componentsString === "string") return target.componentsString;
if (typeof target.toString === "function") return target.toString();
return String(target);
}
function availableTargets(story) {
return new Set(
story.currentChoices
.map((choice) => {
const target = choice?.targetPath?.componentsString;
const target = choiceTargetPath(choice);
return typeof target === "string" ? target.toLowerCase() : "";
})
.filter(Boolean),
@ -820,7 +828,7 @@
const lowerTarget = target.toLowerCase();
const choiceIndex = story.currentChoices.findIndex((choice) => {
const path = choice?.targetPath?.componentsString;
const path = choiceTargetPath(choice);
return typeof path === "string" && path.toLowerCase() === lowerTarget;
});
if (choiceIndex !== -1) {

View file

@ -647,11 +647,19 @@
.toLowerCase();
}
function choiceTargetPath(choice) {
const target = choice?.targetPath;
if (!target) return "";
if (typeof target.componentsString === "string") return target.componentsString;
if (typeof target.toString === "function") return target.toString();
return String(target);
}
function availableTargets(story) {
return new Set(
story.currentChoices
.map((choice) => {
const target = choice?.targetPath?.componentsString;
const target = choiceTargetPath(choice);
return typeof target === "string" ? target.toLowerCase() : "";
})
.filter(Boolean),
@ -820,7 +828,7 @@
const lowerTarget = target.toLowerCase();
const choiceIndex = story.currentChoices.findIndex((choice) => {
const path = choice?.targetPath?.componentsString;
const path = choiceTargetPath(choice);
return typeof path === "string" && path.toLowerCase() === lowerTarget;
});
if (choiceIndex !== -1) {