Compare commits

...

2 Commits

Author SHA1 Message Date
anatawa12 a44c691c5c
chore: inline function 2025-04-07 13:36:09 +09:00
anatawa12 ebbf6651c9
fix: result path is not correct 2025-04-07 13:35:13 +09:00
2 changed files with 5 additions and 8 deletions

View File

@ -100,14 +100,15 @@ type WalkVueNode = RootNode | TemplateChildNode | SimpleExpressionNode;
*/
function walkVueElements<C extends {} | null>(nodes: WalkVueNode[], context: C, callback: (node: ElementNode, context: C) => C | undefined | void | false): void {
for (const node of nodes) {
let currentContext = context;
if (node.type === NodeTypes.COMPOUND_EXPRESSION) throw new Error("Unexpected COMPOUND_EXPRESSION");
if (node.type === NodeTypes.ELEMENT) {
const result = callback(node, context);
if (result === false) return;
if (result !== undefined) context = result;
if (result !== undefined) currentContext = result;
}
if ('children' in node) {
walkVueElements(node.children, context, callback);
walkVueElements(node.children, currentContext, callback);
}
}
}

View File

@ -17,13 +17,13 @@ export type SearchIndexItem = {
const rootMods = new Map(generated.map(item => [item.id, item]));
function walk(item: GeneratedSearchIndexItem) {
// link inlining here
for (const item of generated) {
if (item.inlining) {
for (const id of item.inlining) {
const inline = rootMods.get(id);
if (inline) {
inline.parentId = item.id;
rootMods.delete(id);
} else {
console.log('[Settings Search Index] Failed to inline', id);
}
@ -31,9 +31,5 @@ function walk(item: GeneratedSearchIndexItem) {
}
}
for (const item of generated) {
walk(item);
}
export const searchIndexes: SearchIndexItem[] = generated;