The WASM engine has no notion of focus or tab visibility. It re-renders because IntersectionObserver or ResizeObserver told it the element is visible again at some size, and that re-render discards the view -- taking set_depth() and per-node expansion with it, since neither lives in ViewConfig. Listening for window 'focus' was only a guess at when that happened, which is why the re-apply kept landing while the viewer was still detached from its table. Perspective's viewer captures the constructors at module-evaluation time (`var it=window.ResizeObserver; var st=window.IntersectionObserver`), so replacing them on window before that import puts us in front of every callback it gets. observerShim.js does exactly that and nothing else: the original callback runs first and unchanged, and we re-emit as a CustomEvent only when an entry's target is or contains a perspective-viewer. That has to be the first import in main.jsx or there is nothing left to intercept. focus/visibilitychange/pageshow stay as a backstop for the case where the shim could not be installed. ResizeObserver fires on every frame of a panel drag, so observer events trail by 150ms and act once the burst settles. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| vendor | ||
| .gitignore | ||
| eslint.config.js | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| vite.config.js | ||
React + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Oxc
- @vitejs/plugin-react-swc uses SWC
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the TS template for information on how to integrate TypeScript and typescript-eslint in your project.