import type { ComponentType } from 'react';
import { createToken } from '@tinkoff/dippy';
import type { Action, Command, TramvaiAction } from '@tramvai/core';
import type { INITIAL_APP_STATE_TOKEN } from '@tramvai/tokens-common';
import type { StoreClass } from '@tramvai/state';
import type {
ChildAppLoader,
ChildAppDiManager,
ChildAppPreloadManager,
ChildAppCommandLineRunner,
ChildAppRequestConfig,
WrapperProps,
RootStateSubscription,
ChildAppStateManager,
ChildAppFinalConfig,
ChildAppRenderManager,
ChildAppResolutionConfig,
ResolutionConfig,
} from './types';
export * from './types';
const multiOptions = { multi: true } as const;
export const commandLineListTokens = {
customerStart: createToken<Command>('child-app customer_start', multiOptions),
resolveUserDeps: createToken<Command>('child-app resolve_user_deps', multiOptions),
resolvePageDeps: createToken<Command>('child-app resolve_page_deps', multiOptions),
clear: createToken<Command>('child-app clear', multiOptions),
spaTransition: createToken<Command>('child-app spa_transition', multiOptions),
afterSpaTransition: createToken<Command>('child-app after_spa_transition', multiOptions),
};
export const CHILD_APP_RESOLUTION_CONFIGS_TOKEN = createToken<
| ChildAppResolutionConfig
| ChildAppResolutionConfig[]
| (() =>
| ChildAppResolutionConfig
| ChildAppResolutionConfig[]
| Promise<ChildAppResolutionConfig>
| Promise<ChildAppResolutionConfig[]>)
>('child-app resolve configs', multiOptions);
export const CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN = createToken<{
resolve(config: ChildAppRequestConfig): ResolutionConfig | undefined;
init(): Promise<void>;
}>('child-app resolution config manager');
export const CHILD_APP_RESOLVE_CONFIG_TOKEN = createToken<
(config: ChildAppRequestConfig) => ChildAppFinalConfig | undefined
>('child-app resolve external config');
export const CHILD_APP_RESOLVE_BASE_URL_TOKEN = createToken<string | undefined>(
'child-app resolve external base url'
);
export const CHILD_APP_PRELOAD_MANAGER_TOKEN = createToken<ChildAppPreloadManager>(
'child-app preload manager'
);
export const CHILD_APP_INTERNAL_CONFIG_TOKEN = createToken<ChildAppFinalConfig>(
'child-app current config'
);
export const CHILD_APP_INTERNAL_ACTION_TOKEN = createToken<
Action | TramvaiAction<any[], any, any> | (Action | TramvaiAction<any[], any, any>)[]
>('child-app action', multiOptions);
export const CHILD_APP_INTERNAL_ROOT_STATE_SUBSCRIPTION_TOKEN = createToken<RootStateSubscription>(
'child-app root state subscription',
multiOptions
);
export const CHILD_APP_INTERNAL_ROOT_STATE_ALLOWED_STORE_TOKEN = createToken<StoreClass | string>(
'child-app root state allowed store',
multiOptions
);
export const CHILD_APP_INTERNAL_ROOT_DI_BORROW_TOKEN = createToken<any>(
'child-app root di borrow',
multiOptions
);
export const IS_CHILD_APP_DI_TOKEN = createToken<boolean>('child-app isChildApp Di');
export const CHILD_APP_SINGLETON_DI_MANAGER_TOKEN = createToken<ChildAppDiManager>(
'child-app singleton di manager'
);
export const CHILD_APP_DI_MANAGER_TOKEN = createToken<ChildAppDiManager>('child-app di manager');
export const CHILD_APP_RENDER_MANAGER_TOKEN = createToken<ChildAppRenderManager>(
'child-app render manager'
);
export const CHILD_APP_STATE_MANAGER_TOKEN =
createToken<ChildAppStateManager>('child-app state manager');
export const CHILD_APP_LOADER_TOKEN = createToken<ChildAppLoader>('child-app loader');
export const CHILD_APP_COMMAND_LINE_RUNNER_TOKEN = createToken<ChildAppCommandLineRunner>(
'child-app command runner'
);
export const CHILD_APP_COMMON_INITIAL_STATE_TOKEN = createToken<
Record<string, typeof INITIAL_APP_STATE_TOKEN>
>('child-app initialAppState');
export const CHILD_APP_INTERNAL_RENDER_TOKEN =
createToken<ComponentType<WrapperProps<any>>>('child-app render');