iportal
Version:
web-portal
204 lines (185 loc) • 5.08 kB
text/typescript
import { Module } from './Module'
import { Application } from './Application'
import { Animate } from './Animate'
type FilterOptional<T> = Pick<
T,
Exclude<
{
[K in keyof T]: T extends Record<K, T[K]> ? K : never
}[keyof T],
undefined
>
>
type FilterNotOptional<T> = Pick<
T,
Exclude<
{
[K in keyof T]: T extends Record<K, T[K]> ? never : K
}[keyof T],
undefined
>
>
type PartialEither<T, K extends keyof any> = { [P in Exclude<keyof FilterOptional<T>, K>]-?: T[P] } &
{ [P in Exclude<keyof FilterNotOptional<T>, K>]?: T[P] } &
{ [P in Extract<keyof T, K>]?: undefined }
type Object = {
[name: string]: any
}
type EitherOr<O extends Object, L extends string, R extends string> = (
PartialEither<Pick<O, L | R>, L> |
PartialEither<Pick<O, L | R>, R>
) & Omit<O, L | R>
type ModuleRel = 'module' | 'frameworks' | 'system'
type animationFunction = (e: TransformAnimateEvent) => void | Promise<boolean>
type animationConfig = string | boolean | Array<string> | [animationFunction, animationFunction]
type ApplicationSafeAreaValue = string | Array<string>
type GlobalCSSVariables = { [key: string]: string }
declare interface ModuleStatus {
init: boolean
preload: boolean
prefetch: boolean
prerender: boolean
}
declare interface ModuleElements {
container: HTMLElement
}
declare interface ModuleResources {
script?: Array<string>
image?: Array<string>
worker?: Array<string>
video?: Array<string>
audio?: Array<string>
font?: Array<string>
style?: Array<string>
}
declare interface ModuleManifest {
config: ModuleConfig
resources?: ModuleResources
components?: ((w: Window) => CustomElementConstructor)[]
events?: ModuleEvents
}
declare interface ModuleTouchBorder {
topHolder: HTMLElement
rightHolder: HTMLElement
bottomHolder: HTMLElement
leftHolder: HTMLElement
mainHolder: HTMLElement
}
declare interface ModuleConfig {
title?: string
rel?: ModuleRel
level?: number
source?: EitherOr<{
src?: string
html?: string
}, 'src' , 'html'>,
render?: (target: HTMLElement) => void
timeout?: number
prerender?: Array<string>
free?: boolean
animation?: animationConfig
background?: boolean | 'auto'
singleFlow?: boolean
singleLock?: boolean
index?: string
preindex?: string
limit?: number
notFind?: string
color?: string
portal?: boolean
capture?: string | ((resolve: {
pathname: string
origin: string
host: string
hash: string
href: string
search: string
port: string
searchParams: URLSearchParams
}, url: string) => boolean)
transient?: boolean
allowHosts?: Array<string>
mediaGuard?: boolean
safeArea?: ApplicationSafeAreaValue
holdBack?: (backoutCount: number) => boolean
moduleManifestProcess?: (config: ModuleManifest) => ModuleManifest
globalCSSVariables?: GlobalCSSVariables
touchBorder?: (borders: ModuleTouchBorder, module: Module, application: Application) => void
apply?: Array<'smart-setTimeout' | 'smart-setInterval' | 'link-in-new-window' | 'tap-highlight' | ['tap-highlight', string]>
inject?: (w: Window, m: Module) => void
sandbox?: 'allow-same-origin' | 'allow-scripts' | 'allow-forms' | 'allow-modals' | 'allow-orientation-lock' | 'allow-popups' | 'allow-pointer-lock' | 'allow-popups-to-escape-sandbox' | 'allow-presentation' | 'allow-top-navigation' | 'allow-top-navigation-by-user-activation' | 'allow-downloads-without-user-activation' | 'allow-storage-access-by-user-activation' | 'allow-top-navigation-by-user-activation' | string
}
declare interface ModuleEvents {
transformStart: () => void | boolean
transformEnd: () => void
start: () => void
load: () => void
loadError: () => void
preload: () => void
destroy: () => void
}
declare interface TransformAnimateEvent {
x: number
y: number
in: Animate
out: Animate
view: Array<HTMLElement>
width: number
height: number
viewport: Array<HTMLElement>
modules: Array<Module>
reverse: boolean
direction: number
backset: number
origin: string | Array<number>
attach: string | Array<number>
touches: TransformActionOrigin | undefined
historyDirection: number
callback: Function
}
declare interface TransformOptions {
index: string
defaultIndex: string
singleFlow?: boolean
singleLock?: boolean
notFound?: string
limit?: number
exists?: boolean
defaultAnimation?: animationConfig,
holdBack?: ModuleConfig['holdBack']
}
declare interface PopState {
id: string
title: string
time: Date
search: string
historyIndex: number
}
declare interface TransformActionOrigin {
x: number,
y: number
}
declare interface ServiceWorkerInstallConfig {
swPathUrl?: string
scope?: string
source?: Array<string>
}
export {
PopState,
TransformOptions,
TransformAnimateEvent,
TransformActionOrigin,
Animate,
ModuleStatus,
ModuleElements,
ModuleResources,
ModuleManifest,
ModuleEvents,
ModuleConfig,
Module,
Application,
ServiceWorkerInstallConfig,
ApplicationSafeAreaValue,
GlobalCSSVariables,
EitherOr
}