feat: scaffold workspace with search, fetch, and extract packages

This commit is contained in:
2026-08-08 10:43:00 +08:00
parent 405602a943
commit 1de559c321
30 changed files with 1381 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import type { TTSMod, TTSObject } from '@tts/shared';
import { markParent, traverseMod } from './traverse.js';
/**
* Flatten all objects in a save into an array.
* Ensures parent links are set before returning.
*/
export function flattenObjects(mod: TTSMod): TTSObject[] {
for (const state of mod.ObjectStates) {
markParent(state);
}
return [...traverseMod(mod)];
}
/**
* Filter objects by a predicate (name, GUID, type, etc.).
*/
export function filterObjects(
mod: TTSMod,
predicate: (o: TTSObject) => boolean,
): TTSObject[] {
return flattenObjects(mod).filter(predicate);
}
/**
* Find a single object by GUID.
*/
export function findObject(mod: TTSMod, guid: string): TTSObject | undefined {
return flattenObjects(mod).find((o) => o.GUID === guid);
}
export { markParent, traverseMod } from './traverse.js';