Files
dioxus/packages/interpreter/src/ts/initialize_streaming.ts
T
Evan AlmloffandJonathan Kelley d41ab3a756 Fix hydration of suspense fragments that contain text nodes (#3287)
* Fix hydration of suspense fragments that contain text nodes

* fix release builds

* disable link deduplication

* restore meta tag deduplication

* Add a test for the failed hydration case

* make changes to the document trait non-breaking

* remove info log from server future hook

* restore default implementation - this was also a breaking change

* fix semver breakage

* clean up server_future

* Cleanup unused code

* fix clippy

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2025-01-07 19:47:23 -08:00

22 lines
709 B
TypeScript

import "./hydrate_types";
// Chunks may load before the wasm has loaded and the callback to hydrate the dom is registered. We queue up hydration ids and data until the wasm is ready
window.hydrate_queue = [];
// @ts-ignore
window.dx_hydrate = (
id: number[],
data: string,
debug_types: string[] | null,
debug_locations: string[] | null
) => {
// First convert the base64 encoded string to a Uint8Array
const decoded = atob(data);
const bytes = Uint8Array.from(decoded, (c) => c.charCodeAt(0));
if (window.hydration_callback) {
window.hydration_callback(id, bytes, debug_types, debug_locations);
} else {
window.hydrate_queue.push([id, bytes, debug_types, debug_locations]);
}
};