import type { SvgProps } from 'react-native-svg'; export type OverwriteKeys = { [K in keyof A]: K extends keyof B ? B[K] : A[K]; }; type IconNames = string; type SessionScopeRoleName = 'owner' | 'admin' | 'manager' | 'member' | 'guest'; type SessionScopeRole = { scope: string; scopeId: string; role: SessionScopeRoleName; }; type SessionData = { iat?: number; userId?: string; username?: string; hostname?: string; origin?: string; roles?: SessionScopeRole[]; }; type QueryPaging = { skip?: number; limit?: number; sort?: { [x: string]: 1 | -1; }; after?: { [x: string]: any; }; }; type QueryAfterFilter = { [x: string]: { $gte: any; } | { $lte: any; }; }; type YoukuohaoFile = { ownerType: 'scope' | 'app'; ownerId: string; userId: string; url: string; createTime: number; mime: string; signatureURL: string; }; type YoukuohaoApplicationType = 'public' | 'private'; type YoukuohaoApplicationTag = { tag: 'beta' | 'release' | 'alpha'; version: string; }; type YoukuohaoApplicationProperty = { appId: string; property: string; version: string | null | void; valueType: string; defaultValue: string; propertyType: string; }; type YoukuohaoApplicationPropertyValue = { appId: string; scopeId: string; property: string; value: string; }; type YoukuohaoApplication = { appId: string; appName: string; developerId: string; createTime: number; updateTime: number; type: YoukuohaoApplicationType; tags: YoukuohaoApplicationTag[]; props: YoukuohaoApplicationProperty[]; }; type YoukuohaoApplicationWithPropValues = YoukuohaoApplication & { propValues: YoukuohaoApplicationPropertyValue[]; }; type PromiseState = { result?: T; } & ({ state: 'pending'; } | { state: 'fulfilled'; result: T; } | { state: 'rejected'; error: Error; }); type PromiseValueWithNone = { state: 'none'; progress?: ProgressEvent; none: true; fulfilled: false; rejected: false; pending: false; result: undefined; } | { state: 'pending'; progress?: ProgressEvent; result: undefined; none: false; fulfilled: false; rejected: false; pending: true; } | { state: 'fulfilled'; progress?: ProgressEvent; result: Result; none: false; fulfilled: true; rejected: false; pending: false; } | { state: 'rejected'; progress?: ProgressEvent; result: Reason; none: false; fulfilled: false; rejected: true; pending: false; }; type PromiseValue = { state: 'pending'; result: undefined; fulfilled: false; rejected: false; pending: true; } | { state: 'fulfilled'; result: Result; fulfilled: true; rejected: false; pending: false; } | { state: 'rejected'; result: Reason; fulfilled: false; rejected: true; pending: false; }; type valueof = T[keyof T]; type Tokens = { accessToken: string; accessTokenExpire: number; refreshToken: string; refreshTokenExpire: number; }; type SessionState = { iat: number; userId: string | null; username: string | null; }; type AppVersionInfo = { version: string; icon: string; titles: { code: 'en' | 'ja' | 'zh'; value: string; }[]; createTime: number; mainURL: string; }; type AppTagName = 'release' | 'beta' | 'dev'; type AppTag = { tag: AppTagName; version: string; versionInfo: AppVersionInfo; }; type Application = { appName: string; developerId: string; appId: string; ID: string; tags: AppTag[] | void; icon: string; type: 'public' | 'private'; summary: any; }; type NavigationStyle = 'custom' | 'default'; /** * NavigationBarItemType * `default` is button */ type NavigationBarItemType = 'default' | 'menu'; type NavigationBarItem = { icon?: IconNames | any; key: string; title: string; itemType?: NavigationBarItemType; menus?: any[]; }; /** * TODO Migrate to Plain JSON */ type YoukuohaoApplicationPage = { isMenu?: boolean; pathname?: string; menuGroup?: string | null; role?: string | string[] | null; icon?: IconNames | null; /** * 右侧的按钮区域 */ rightBarButtonItems?: NavigationBarItem[]; /** * 路由路径 * 如果是菜单(isMenu),且没传pathname,这使用path作为降级机制。 */ path?: string | string[]; /** * 标题 * 就算titleType是segment,title依然是string */ title?: string; /** * TODO Migrate to URL string */ component?: any; /** * 默认值default */ titleType?: 'default' | 'segment'; titleSegmentItems?: string[]; titleSegmentTintColor?: string; titleSegmentTextTintColor?: string; /** * 风格,默认是 default */ headerStyle?: NavigationStyle; headerBarColor?: string; headerBarHeight?: number; contentBackgroundColor?: string; navigationBarColor?: string; exact?: boolean; /** * 是否支持编辑模式 */ editable?: boolean; searchable?: boolean; modalHeight?: number; modalWidth?: number; }; /** * TODO this should be a subset of JSON */ type YoukuohaoApplicationConfig = { contentBackgroundColor?: string | null; drawerBackgroundColor?: string | null; headerBarColor?: string; headerStyle?: NavigationStyle; pages?: YoukuohaoApplicationPage[]; /** * 是否隐藏侧栏 */ sidebarDisabled?: boolean; launch?: () => void; }; type AppMeta = YoukuohaoApplicationConfig & { error?: Error; app: Application; appName: string | null; AppComponent: any; mainURL: string | null; /** * TODO: 只需要传一个路由url即可,直接渲染对应的路由 */ navigationDetail: any | null; /** * 应用的背景颜色 */ contentBackgroundColor: string | null; drawerBackgroundColor: string | null; headerBarHeight: number; } & ({ scopeId: string; scopeName: string; } | { scopeId: null; scopeName: null; }); type NavigationPosition = 'top' | 'left'; type NavigationStackMode = 'modal' | 'default'; /** * TODO rename */ type ApplicationNavigatorStack = { initialUrl: string; mode: NavigationStackMode; }; type NavigationRoute = Required & { target: EventTarget; key: string; selectedSegmentIndex: number; index: number; params: { [x: string]: string; }; searching: boolean; isSearchBarVisible: boolean; editing: boolean; scrollTop: number; /** * 当前路由实际对应的绝对路径 * 因为如果路由路径(上面的path)是 string[]的话,即多个路径配置的话, * 就不具备唯一性了。 */ mountPath: string; pathname: string; }; type NavigationContainerState = { app: ApplicationState; navigationBarHeight: number; reset: (location: Location) => void; dispatchStacks: (action: { type: 'RESET' | 'PUSH' | 'POP'; payload?: any; }) => void; windowWidth: number; windowHeight: number; }; type NavigationDrawerMode = 'default' | 'sidebar'; type NavigationHeaderBarStyle = 'default' | 'custom'; type NavigationNavigateOption = any & { pathname: string; mode?: NavigationStackMode; editing?: boolean; title?: string; }; type NavigationNavigate = (pathname: string | NavigationNavigateOption) => void; type NavigationGoBack = (state?: any) => void; type NavigationReplace = (pathname: string | Location) => void; type NavigationSetParams = (params: { [x: string]: string; }) => void; /** * 使用useApplication hook拿到的返回值 */ type ApplicationState = AppMeta & { /** * what does it used for? */ iconSize: number; mountMatch: { url: string; path: string; }; }; type AppTitleLocale = { code: 'zh' | 'en' | 'ja'; locale?: 'zh' | 'en' | 'ja'; value: string; }; type AppProperty = { appId: string; title: AppTitleLocale[]; property: string; propertyType: string; version: string | null | void; locale: string | null | void; value: any; valueType: string; }; export type AppDeployDetail = { appId: string; appTag: string; hostname: string; mainURL: string; browserURL?: string; updateDate: Date; envKeys: string[]; }; export type IconProps = SvgProps & { size?: string | number; }; export type { AppProperty, AppVersionInfo, AppTagName, AppTag, Application, Tokens, SessionState, valueof, YoukuohaoFile, QueryAfterFilter, QueryPaging, SessionData, SessionScopeRoleName, SessionScopeRole, PromiseState, PromiseValue, PromiseValueWithNone, NavigationPosition, AppMeta, IconNames, ApplicationState, YoukuohaoApplication, YoukuohaoApplicationWithPropValues, YoukuohaoApplicationPage, YoukuohaoApplicationConfig, YoukuohaoApplicationType, YoukuohaoApplicationTag, YoukuohaoApplicationProperty, ApplicationNavigatorStack, NavigationRoute, NavigationContainerState, NavigationStackMode, NavigationHeaderBarStyle, NavigationDrawerMode, NavigationNavigate, NavigationReplace, NavigationSetParams, NavigationGoBack, NavigationNavigateOption, };