mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
chore(core): update core helpers/interfaces
This commit is contained in:
@ -3,7 +3,7 @@ export function isDef(s: any): boolean { return s !== undefined && s !== null; }
|
|||||||
|
|
||||||
export function isUndef(s: any): boolean { return s === undefined; }
|
export function isUndef(s: any): boolean { return s === undefined; }
|
||||||
|
|
||||||
export function isArray(val: any): val is Array<any> { return (!!val) && (val.constructor === Array); }
|
export function isArray(val: any): val is Array<any> { return Array.isArray(val); }
|
||||||
|
|
||||||
export function isObject(val: any): val is Object { return typeof val === 'object'; }
|
export function isObject(val: any): val is Object { return typeof val === 'object'; }
|
||||||
|
|
||||||
@ -19,10 +19,6 @@ export function isStringOrNumber(s: any): s is (string | number) {
|
|||||||
return isString(s) || isNumber(s);
|
return isString(s) || isNumber(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toCamelCase(str: string) {
|
|
||||||
return str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toDashCase(str: string) {
|
export function toDashCase(str: string) {
|
||||||
return str.replace(/([A-Z])/g, (g) => '-' + g[0].toLowerCase());
|
return str.replace(/([A-Z])/g, (g) => '-' + g[0].toLowerCase());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,8 @@ export interface IonicControllerLoaded {
|
|||||||
|
|
||||||
export interface IonicGlobal {
|
export interface IonicGlobal {
|
||||||
staticDir?: string;
|
staticDir?: string;
|
||||||
components?: LoadComponents;
|
components?: LoadComponentData[];
|
||||||
loadComponents?: (coreVersion: number, bundleId: string, modulesImporterFn: ModulesImporterFn, cmp0?: ComponentModeData, cmp1?: ComponentModeData, cmp2?: ComponentModeData) => void;
|
defineComponents?: (coreVersion: number, bundleId: string, modulesImporterFn: ModulesImporterFn, cmp0?: ComponentModeData, cmp1?: ComponentModeData, cmp2?: ComponentModeData) => void;
|
||||||
eventNameFn?: (eventName: string) => string;
|
eventNameFn?: (eventName: string) => string;
|
||||||
config?: Object;
|
config?: Object;
|
||||||
loadController?: (ctrlName: string, ctrl: any) => any;
|
loadController?: (ctrlName: string, ctrl: any) => any;
|
||||||
@ -198,51 +198,80 @@ export interface DomControllerCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface LoadComponents {
|
export interface LoadComponentData {
|
||||||
[tag: string]: any[];
|
/**
|
||||||
|
* tag name (ion-badge)
|
||||||
|
*/
|
||||||
|
[0]: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map of the modes and bundle ids
|
||||||
|
*/
|
||||||
|
[1]: {
|
||||||
|
[modeCode: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
[2]: any[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bundle priority
|
||||||
|
*/
|
||||||
|
[3]: LoadPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type LoadPriority = number;
|
||||||
|
|
||||||
|
|
||||||
export interface ComponentModeData {
|
export interface ComponentModeData {
|
||||||
/**
|
/**
|
||||||
* tag name (ion-badge)
|
* tag name (ion-badge)
|
||||||
*/
|
*/
|
||||||
[0]: string;
|
[0]: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* props
|
||||||
|
*/
|
||||||
|
[1]: any[][];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* methods
|
* methods
|
||||||
*/
|
*/
|
||||||
[1]: MethodMeta[];
|
[2]: MethodMeta[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* states
|
* states
|
||||||
*/
|
*/
|
||||||
[2]: StateMeta[];
|
[3]: StateMeta[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* listeners
|
* listeners
|
||||||
*/
|
*/
|
||||||
[3]: ComponentListenersData[];
|
[4]: ComponentListenersData[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* watchers
|
* watchers
|
||||||
*/
|
*/
|
||||||
[4]: ComponentWatchersData[];
|
[5]: ComponentWatchersData[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shadow
|
* shadow
|
||||||
*/
|
*/
|
||||||
[5]: boolean;
|
[6]: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mode name (ios, md, wp)
|
* mode code, which is a number that'll
|
||||||
|
* map to a mode name later (ios, md, wp)
|
||||||
*/
|
*/
|
||||||
[6]: number;
|
[7]: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* component mode styles
|
* component mode styles
|
||||||
*/
|
*/
|
||||||
[7]: string;
|
[8]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,6 +342,8 @@ export interface PropOptions {
|
|||||||
export interface PropMeta {
|
export interface PropMeta {
|
||||||
propName?: string;
|
propName?: string;
|
||||||
propType?: any;
|
propType?: any;
|
||||||
|
attrName?: string;
|
||||||
|
attrCase?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -387,21 +418,18 @@ export interface ComponentMeta {
|
|||||||
listeners?: ListenMeta[];
|
listeners?: ListenMeta[];
|
||||||
watchers?: WatchMeta[];
|
watchers?: WatchMeta[];
|
||||||
states?: StateMeta[];
|
states?: StateMeta[];
|
||||||
modes: ModeMeta[];
|
modes?: {[modeCode: string]: ModeMeta};
|
||||||
shadow?: boolean;
|
shadow?: boolean;
|
||||||
namedSlots?: string[];
|
namedSlots?: string[];
|
||||||
obsAttrs?: string[];
|
|
||||||
componentModule?: any;
|
componentModule?: any;
|
||||||
priority?: 'high'|'low';
|
priority?: LoadPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface ModeMeta {
|
export interface ModeMeta {
|
||||||
modeName?: string;
|
|
||||||
bundleId?: string;
|
bundleId?: string;
|
||||||
styles?: string;
|
styles?: string;
|
||||||
styleUrls?: string[];
|
styleUrls?: string[];
|
||||||
styleElm?: HTMLElement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -467,8 +495,8 @@ export interface ComponentRegistry {
|
|||||||
|
|
||||||
export interface ProxyElement extends HTMLElement {
|
export interface ProxyElement extends HTMLElement {
|
||||||
connectedCallback: () => void;
|
connectedCallback: () => void;
|
||||||
attributeChangedCallback: (attrName: string, oldVal: string, newVal: string, namespace: string) => void;
|
attributeChangedCallback?: (attrName: string, oldVal: string, newVal: string, namespace: string) => void;
|
||||||
disconnectedCallback: () => void;
|
disconnectedCallback?: () => void;
|
||||||
|
|
||||||
$queueUpdate: () => void;
|
$queueUpdate: () => void;
|
||||||
$initLoadComponent: () => void;
|
$initLoadComponent: () => void;
|
||||||
@ -483,14 +511,11 @@ export interface ProxyElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type QueueHandlerId = number;
|
|
||||||
|
|
||||||
|
|
||||||
export type Side = 'left' | 'right' | 'start' | 'end';
|
export type Side = 'left' | 'right' | 'start' | 'end';
|
||||||
|
|
||||||
|
|
||||||
export interface RendererApi {
|
export interface RendererApi {
|
||||||
(oldVnode: VNode | Element, vnode: VNode, hostContentNodes?: HostContentNodes): VNode;
|
(oldVnode: VNode | Element, vnode: VNode, hostContentNodes?: HostContentNodes, isSsrHydrated?: boolean): VNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -540,11 +565,13 @@ export interface VNodeData {
|
|||||||
|
|
||||||
|
|
||||||
export interface PlatformApi {
|
export interface PlatformApi {
|
||||||
registerComponents: (components: LoadComponents) => ComponentMeta[];
|
registerComponents: (components?: LoadComponentData[]) => ComponentMeta[];
|
||||||
defineComponent: (tag: string, constructor: Function) => void;
|
defineComponent: (tag: string, constructor: Function) => void;
|
||||||
getComponentMeta: (tag: string) => ComponentMeta;
|
getComponentMeta: (tag: string) => ComponentMeta;
|
||||||
loadBundle: (bundleId: string, priority: string, cb: Function) => void;
|
loadBundle: (bundleId: string, priority: LoadPriority, cb: Function) => void;
|
||||||
queue: QueueApi;
|
queue: QueueApi;
|
||||||
|
css?: {[cmpModeId: string]: string};
|
||||||
|
isServer?: boolean;
|
||||||
|
|
||||||
isElement: (node: Node) => node is Element;
|
isElement: (node: Node) => node is Element;
|
||||||
isText: (node: Node) => node is Text;
|
isText: (node: Node) => node is Text;
|
||||||
@ -562,12 +589,14 @@ export interface PlatformApi {
|
|||||||
$tagName: (elm: Element) => string;
|
$tagName: (elm: Element) => string;
|
||||||
$setTextContent: (node: Node, text: string | null) => void;
|
$setTextContent: (node: Node, text: string | null) => void;
|
||||||
$getTextContent: (node: Node) => string | null;
|
$getTextContent: (node: Node) => string | null;
|
||||||
$getAttribute: (elm: Element, attrName: string) => string;
|
$getAttribute: (elm: any, attrName: string) => string;
|
||||||
|
$setAttribute: (elm: any, attrName: string, attrValue: any) => void;
|
||||||
|
$removeAttribute: (elm: any, attrName: string) => void;
|
||||||
|
$setClass: (elm: any, cssClassName: string, shouldAddCssClassName: boolean) => void;
|
||||||
$attachComponent: (elm: Element, cmpMeta: ComponentMeta, instance: Component) => void;
|
$attachComponent: (elm: Element, cmpMeta: ComponentMeta, instance: Component) => void;
|
||||||
$tmpDisconnected: boolean;
|
$tmpDisconnected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface PlatformConfig {
|
export interface PlatformConfig {
|
||||||
name: string;
|
name: string;
|
||||||
isMatch?: {(url: string, userAgent: string): boolean};
|
isMatch?: {(url: string, userAgent: string): boolean};
|
||||||
@ -577,9 +606,34 @@ export interface PlatformConfig {
|
|||||||
|
|
||||||
export interface ServerInitConfig {
|
export interface ServerInitConfig {
|
||||||
staticDir: string;
|
staticDir: string;
|
||||||
|
sys?: UniversalSys;
|
||||||
config?: Object;
|
config?: Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface HydrateConfig {
|
||||||
|
req?: any;
|
||||||
|
url?: string;
|
||||||
|
referrer?: string;
|
||||||
|
userAgent?: string;
|
||||||
|
cookie?: string;
|
||||||
|
config?: Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface UniversalSys {
|
||||||
|
fs?: {
|
||||||
|
readdirSync?(path: string | Buffer): string[];
|
||||||
|
readFileSync?(filename: string, encoding: string): string;
|
||||||
|
statSync?(path: string | Buffer): {
|
||||||
|
isDirectory?(): boolean;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
path?: {
|
||||||
|
join?: (...paths: string[]) => string;
|
||||||
|
};
|
||||||
|
isValidComponent?: (fileName: string) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Animation {
|
export interface Animation {
|
||||||
new(elm?: Node|Node[]|NodeList): Animation;
|
new(elm?: Node|Node[]|NodeList): Animation;
|
||||||
@ -668,3 +722,8 @@ export interface IdleDeadline {
|
|||||||
export interface IdleOptions {
|
export interface IdleOptions {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface BundleCallbacks {
|
||||||
|
[bundleId: string]: Function[];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user