Merge pull request #24468 from overleaf/mj-client-side-references

[web] Perform ARS on client-side

GitOrigin-RevId: 19703c82758cae450fe52463ad9612d3a2383ba0
This commit is contained in:
Mathias Jakobsen
2025-09-03 08:05:41 +00:00
committed by Copybot
parent f6820ed794
commit ed0c4c447e
21 changed files with 3040 additions and 26 deletions
@@ -0,0 +1,24 @@
import { ReferenceIndex } from './reference-index'
import { Changes } from './types'
export default class BasicReferenceIndex extends ReferenceIndex {
fileIndex: Map<string, Set<string>> = new Map()
updateIndex({ updates, deletes }: Changes): Set<string> {
for (const path of deletes) {
this.fileIndex.delete(path)
}
for (const { path, content } of updates) {
const fileReferences: Set<string> = new Set()
const entries = this.parseEntries(content)
for (const entry of entries) {
fileReferences.add(entry.EntryKey)
}
this.fileIndex.set(path, fileReferences)
}
this.keys = new Set(
this.fileIndex.values().flatMap(entry => Array.from(entry))
)
return this.keys
}
}