Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function createFakeOpfsRoot

    • Build an in-memory OPFS root for cache tests.

      Models exactly the levels production walks, and nothing looser:

      • root.getDirectoryHandle(name) accepts only OPFS_NAMESPACE_DIR. Anything else throws — a store that reaches for a dataset directory at the origin root (the pre-namespace layout) fails every test that mounts it, not just the one asserting the layout. create: false before the namespace dir exists throws the platform NotFoundError, so OPFSStore.listAll on a cold origin is testable.
      • luxarDir.getDirectoryHandle(id, …) records id in datasetIds and returns FakeOpfsRoot.datasetDir; luxarDir.removeEntry(id, …) wipes it; luxarDir.entries() yields one [id, datasetDir] per recorded id (what listAll iterates).
      • The dataset dir is FLAT: every bucket getDirectoryHandle returns the dataset dir itself and files are keyed by name alone. Bucket names carry no information the tests need (a key's base64url file name is unique on its own), and the flat shape is what lets tests monkeypatch ONE handle's getFileHandle / removeEntry to inject faults at any depth.

      Both datasetDir and every handle it returns are plain objects with own-property methods, so tests may spread or reassign them freely.

      Parameters

      Returns FakeOpfsRoot