Refactor `Document` and `ResolvedDocument` for interior mutability
Description of change
This refactors WasmDocument to use Rc<RefCell> internally to reduce clones and for interior mutability when accessed from WasmResolvedDocument.
The WasmDocument API should be unchanged in terms of usage; WasmResolvedDocument on the other hand has several breaking changes listed below.
TODO
Links to any relevant issues
See discussion #603.
Type of change
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [ ] Enhancement (a non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Fix
How the change has been tested
Describe the tests that you ran to verify your changes. Make sure to provide instructions for the maintainer as well as any relevant configurations.
TODO TODO
Change checklist
TODO TODO
- [ ] I have followed the contribution guidelines for this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
There are concerns that peppering the code with Rc<RefCell> may worsen challenges around memory management with wasm-bindgen, since it's unclear if we benefit from garbage collection with --weak-refs and even then it's a bit hazy. Particularly for objects like WasmDocument which are not expected to live for the entire life of the program (unlike the Client for instance), this may not be the best idea for now...
ResolvedDocument is to be removed with the legacy bindings.