mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 17:51:51 +02:00
[web] Perform ARS on client-side GitOrigin-RevId: 19703c82758cae450fe52463ad9612d3a2383ba0
25 lines
750 B
TypeScript
25 lines
750 B
TypeScript
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
|
|
}
|
|
}
|