Release 0.0.14

This commit is contained in:
2026-04-20 22:10:47 +00:00
parent c217761792
commit ec986287e4
3 changed files with 42 additions and 15 deletions

View File

@@ -141,6 +141,12 @@ function resolveSourceTrail(document, candidatePath = []) {
return trail;
}
if (document.documentName === "Playlist") {
const soundNode = resolvePlaylistSoundTrail(document, path);
if (soundNode) trail.push(soundNode);
return trail;
}
if (document.documentName === "Scene") {
const sceneTrail = resolveSceneTrail(document, path);
if (sceneTrail.length) trail.push(...sceneTrail);
@@ -150,14 +156,25 @@ function resolveSourceTrail(document, candidatePath = []) {
}
function resolveActorItemTrail(actor, path) {
if ((path[0] !== "items") || !Number.isInteger(path[1])) return null;
const itemData = actor.items?.contents?.[path[1]] ?? actor.toObject?.().items?.[path[1]] ?? null;
const itemIndex = findEmbeddedIndex(path, "items");
if (itemIndex == null) return null;
const itemData = actor.items?.contents?.[itemIndex] ?? actor.toObject?.().items?.[itemIndex] ?? null;
const itemId = itemData?.id ?? itemData?._id ?? null;
if (!itemId) return null;
const itemName = itemData?.name ?? `Item ${itemId}`;
return createTrailNode(`${actor.uuid}.Item.${itemId}`, itemName);
}
function resolvePlaylistSoundTrail(playlist, path) {
const soundIndex = findEmbeddedIndex(path, "sounds");
if (soundIndex == null) return null;
const soundData = playlist.sounds?.contents?.[soundIndex] ?? playlist.toObject?.().sounds?.[soundIndex] ?? null;
const soundId = soundData?.id ?? soundData?._id ?? null;
if (!soundId) return null;
const soundName = soundData?.name ?? `PlaylistSound ${soundId}`;
return createTrailNode(`${playlist.uuid}.PlaylistSound.${soundId}`, soundName);
}
function resolveSceneTrail(scene, path) {
if ((path[0] !== "tokens") || !Number.isInteger(path[1])) return [];
const token = scene.tokens?.contents?.[path[1]] ?? scene.toObject?.().tokens?.[path[1]] ?? null;
@@ -180,12 +197,10 @@ function resolveSceneTrail(scene, path) {
}
function extractTokenItemPath(path) {
if ((path[2] === "actorData") && (path[3] === "items") && Number.isInteger(path[4])) {
return { itemIndex: path[4] };
}
if ((path[2] === "delta") && (path[3] === "items") && Number.isInteger(path[4])) {
return { itemIndex: path[4] };
}
const actorDataIndex = findEmbeddedIndex(path.slice(2), "items");
if ((path[2] === "actorData") && (actorDataIndex != null)) return { itemIndex: actorDataIndex };
const deltaIndex = findEmbeddedIndex(path.slice(2), "items");
if ((path[2] === "delta") && (deltaIndex != null)) return { itemIndex: deltaIndex };
return null;
}
@@ -199,3 +214,10 @@ function resolveTokenItemData(tokenData, itemIndex) {
function createTrailNode(uuid, label) {
return { uuid, label };
}
function findEmbeddedIndex(path, segment) {
const index = path.indexOf(segment);
if (index === -1) return null;
const candidate = path[index + 1];
return Number.isInteger(candidate) ? candidate : null;
}