// 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.
import { createProcessData } from '../../core/lynx-data-processors.js';
export function setupLynxEnv() {
    if (!__LEPUS__) {
        let initData = {};
        let updateData = {};
        try {
            const params = lynxCoreInject
                ?.tt?._params;
            if (params) {
                initData = params.initData ?? {};
                updateData = params.updateData ?? {};
            }
        }
        catch { }
        lynx.__initData = { ...initData, ...updateData };
        lynx.registerDataProcessors = function () { };
    }
    if (__LEPUS__) {
        lynx.__initData = {
        /* available only in renderPage */
        };
        globalThis.SystemInfo =
            lynx.SystemInfo ?? {};
        lynx.triggerGlobalEventFromLepus = function (eventName, params) {
            __OnLifecycleEvent(['globalEventFromLepus', [eventName, params]]);
        };
        {
            // eslint-disable-next-line unicorn/consistent-function-scoping
            function __name(empty) {
                return `Native${empty}Modules`;
            }
            // TODO(hongzhiyuan.hzy): make sure this is run before any other code (especially code access `NativeModules`)
            // @ts-expect-error hack
            if (typeof globalThis[__name('')] === 'undefined') {
                // @ts-expect-error hack
                globalThis[__name('')] = undefined;
            }
        }
        lynx.registerDataProcessors = function (dataProcessorDefinition) {
            globalThis.processData = createProcessData(dataProcessorDefinition);
        };
        lynx.registerDataProcessors();
    }
}
//# sourceMappingURL=env.js.map