// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
/**
 * Implements the IFR (Instant First-Frame Rendering) on main thread.
 */
import { __root } from '../../root.js';
import { profileEnd, profileStart } from '../debug/profile.js';
import { render as renderToString } from '../renderToOpcodes/index.js';
import { SnapshotInstance } from '../snapshot/snapshot.js';
function renderMainThread() {
    let opcodes;
    try {
        if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
            profileStart('ReactLynx::renderMainThread');
        }
        opcodes = renderToString(__root.__jsx, undefined, __root);
    }
    catch (e) {
        lynx.reportError(e);
        opcodes = [];
        __root.removeChildren();
    }
    finally {
        if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
            profileEnd();
        }
    }
    if (__ENABLE_SSR__) {
        __root.__opcodes = opcodes;
    }
}
export { renderMainThread };
//# sourceMappingURL=render.js.map