pub(crate) fn new(shell: String, root_id: &str, path_prefix: &str) -> Self {
        let mut head_before_boundary = Vec::new();
        let mut scripts_before_boundary = Vec::new();

        // Inject a global variable to identify whether we are testing (picked up by app
        // shell to trigger helper DOM events)
        if env::var("PERSEUS_TESTING").is_ok() {
            scripts_before_boundary.push("window.__PERSEUS_TESTING = true;".into());
        }

        // This script stores all user-provided clicks in a JS array, blocking them
        // until the app has loaded, at which time they'll all be re-emitted.
        // This *can* improve user experience in some cases, and it's available
        // as a feature flag. Clicks on links are deliberately exempted from
        // this, because they can be resolved by the browser without needing
        // interactivity (it'll be slower, but instant navigation is generally a
        // better experience).
        //
        // This feature is heavily opinionated, and should not be enabled by default.
        //
        // This is injected directly, rather than through a separate JS file, in
        // order to ensure it captures *all* user interactions from the moment the
        // user can see the page. In this case, we actually want to block.
        #[cfg(feature = "suspended-interaction")]
        let suspend_script = r#"
        window.__PERSEUS_SUSPENDED = true;
        window.__PERSEUS_SUSPENDED_EVENTS = [];

        const clickHandler = (ev) => {{
            if (window.__PERSEUS_SUSPENDED && ev.target.tagName !== "A") {{
                ev.preventDefault();
                ev.stopPropagation();
                window.__PERSEUS_SUSPENDED_EVENTS.push(ev);
            }}
        }};

        document.addEventListener("click", clickHandler, true);
        document.addEventListener("__perseus_loaded", () => {{
            window.__PERSEUS_SUSPENDED = false;
            for (const ev of window.__PERSEUS_SUSPENDED_EVENTS) {{
                ev.target.dispatchEvent(ev);
            }}
            document.removeEventListener("click", clickHandler);
        }});
        "#;
        #[cfg(not(feature = "suspended-interaction"))]
        let suspend_script = "";
        // Define the script that will load the Wasm bundle (inlined to avoid
        // unnecessary extra requests) If we're using the `wasm2js` feature,
        // this will try to load a JS version instead (expected to be at
        // `/.perseus/bundle.wasm.js`)
        //
        // Note: because we're using binary bundles, we don't need to import
        // a `main` function or the like, `init()` just works
        //
        // Using a `Promise` to wait for the render config to resolve means we
        // avoid blocking the main thread, so failures will just leave the page
        // uninteractive, rather than unresponsive.
        #[cfg(not(feature = "wasm2js"))]
        let load_wasm_bundle = format!(
            r#"
        import init from "{path_prefix}/.perseus/bundle.js";
        async function main() {{
            new Promise((resolve) => {{
                const checker = () => {{
                    if (window.__PERSEUS_RENDER_CFG !== undefined) {{
                        resolve();
                    }} else {{
                        setTimeout(checker, 10);
                    }}
                }};
                checker();
            }}).then(async () => {{
                await init("{path_prefix}/.perseus/bundle.wasm");
            }});
        }}
        main();

        {suspend_script}
        "#,
            path_prefix = path_prefix
        );
        #[cfg(feature = "wasm2js")]
        let load_wasm_bundle = format!(
            r#"
        import init from "{path_prefix}/.perseus/bundle.js";
        async function main() {{
            new Promise((resolve) => {{
                const checker = () => {{
                    if (window.__PERSEUS_RENDER_CFG !== undefined) {{
                        resolve();
                    }} else {{
                        setTimeout(checker, 10);
                    }}
                }};
                checker();
            }}).then(async () => {{
                await init("{path_prefix}/.perseus/bundle.wasm");
            }});
        }}
        main();

        {suspend_script}
        "#,
            path_prefix = path_prefix
        );
        scripts_before_boundary.push(load_wasm_bundle);

        // If we're in development, pass through the host/port of the reload server if
        // we're using it We'll depend on the `PERSEUS_USE_RELOAD_SERVER`
        // environment variable here, which is set by the CLI's controller process, not
        // the user That way, we won't do this if the reload server doesn't
        // exist
        #[cfg(debug_assertions)]
        if env::var("PERSEUS_USE_RELOAD_SERVER").is_ok() {
            let host =
                env::var("PERSEUS_RELOAD_SERVER_HOST").unwrap_or_else(|_| "localhost".to_string());
            let port =
                env::var("PERSEUS_RELOAD_SERVER_PORT").unwrap_or_else(|_| "3100".to_string());
            scripts_before_boundary
                .push(format!("window.__PERSEUS_RELOAD_SERVER_HOST = '{}';", host));
            scripts_before_boundary
                .push(format!("window.__PERSEUS_RELOAD_SERVER_PORT = '{}';", port));
        }

        // Add in the `<base>` element at the very top so that it applies to everything
        // in the HTML shell Otherwise any stylesheets loaded before it won't
        // work properly We add a trailing `/` to the base URL (https://stackoverflow.com/a/26043021)
        // Note that it's already had any pre-existing ones stripped away
        let base = format!(r#"<base href="{}/" />"#, path_prefix);
        head_before_boundary.push(base);

        Self {
            shell,
            head_before_boundary,
            scripts_before_boundary,
            head_after_boundary: Vec::new(),
            scripts_after_boundary: Vec::new(),
            before_content: Vec::new(),
            after_content: Vec::new(),
            content: "".into(),
            root_id: root_id.into(),
            path_prefix: path_prefix.into(),
            // Assume until we know otherwise
            locale: "xx-XX".to_string(),
        }
    }
Initializes the HTML shell by interpolating necessary scripts into it
and adding the render configuration.
packages/perseus/src/server/html_shell.rs