* Build a dynamic tag → app ID mapping from extracted apps. * Each tag found in an app's content is mapped to that app's ID.
(apps: AppEntry[])
| 551 | * Each tag found in an app's content is mapped to that app's ID. |
| 552 | */ |
| 553 | function buildTagAppMap(apps: AppEntry[]): Record<string, string[]> { |
| 554 | const map: Record<string, string[]> = {}; |
| 555 | for (const app of apps) { |
| 556 | for (const tag of app.tags) { |
| 557 | const name = tag.name.includes('/') ? tag.name.split('/') : [tag.name]; |
| 558 | for (const n of name) { |
| 559 | if (!map[n]) map[n] = []; |
| 560 | if (!map[n].includes(app.id)) map[n].push(app.id); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | return map; |
| 565 | } |
| 566 | |
| 567 | function matchScriptToApp( |
| 568 | regexTags: string[], |