uni-shared.d.ts 19.1 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3
import { ComponentInternalInstance } from 'vue';
import { ComponentOptionsBase } from 'vue';
import { ComponentPublicInstance } from 'vue';
fxy060608's avatar
fxy060608 已提交
4
import { RendererNode } from 'vue';
fxy060608's avatar
fxy060608 已提交
5

fxy060608's avatar
fxy060608 已提交
6 7
export declare const ACTION_TYPE_ADD_EVENT = 8;

fxy060608's avatar
fxy060608 已提交
8 9
export declare const ACTION_TYPE_ADD_WXS_EVENT = 12;

fxy060608's avatar
fxy060608 已提交
10 11 12 13 14 15 16 17 18 19
export declare const ACTION_TYPE_CREATE = 3;

export declare const ACTION_TYPE_EVENT = 20;

export declare const ACTION_TYPE_INSERT = 4;

export declare const ACTION_TYPE_PAGE_CREATE = 1;

export declare const ACTION_TYPE_PAGE_CREATED = 2;

fxy060608's avatar
fxy060608 已提交
20 21
export declare const ACTION_TYPE_PAGE_SCROLL = 15;

fxy060608's avatar
fxy060608 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
export declare const ACTION_TYPE_REMOVE = 5;

export declare const ACTION_TYPE_REMOVE_ATTRIBUTE = 7;

export declare const ACTION_TYPE_REMOVE_EVENT = 9;

export declare const ACTION_TYPE_SET_ATTRIBUTE = 6;

export declare const ACTION_TYPE_SET_TEXT = 10;

/**
 * nodeId
 * event
 * flag
 */
export declare type AddEventAction = [
fxy060608's avatar
fxy060608 已提交
38 39 40 41
typeof ACTION_TYPE_ADD_EVENT,
number,
string | number,
number
fxy060608's avatar
fxy060608 已提交
42 43
];

fxy060608's avatar
fxy060608 已提交
44
export declare function addFont(family: string, source: string, desc?: FontFaceDescriptors): Promise<void>;
fxy060608's avatar
fxy060608 已提交
45

fxy060608's avatar
fxy060608 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59
/**
 * nodeId
 * event
 * wxsEvent
 * flag
 */
export declare type AddWxsEventAction = [
typeof ACTION_TYPE_ADD_WXS_EVENT,
number,
string | number,
string | number,
number
];

fxy060608's avatar
fxy060608 已提交
60 61
export declare const ATTR_CHANGE_PREFIX = "change:";

fxy060608's avatar
fxy060608 已提交
62 63
export declare const ATTR_CLASS = "class";

fxy060608's avatar
fxy060608 已提交
64 65
export declare const ATTR_INNER_HTML = "innerHTML";

fxy060608's avatar
fxy060608 已提交
66 67
export declare const ATTR_STYLE = "style";

fxy060608's avatar
fxy060608 已提交
68 69
export declare const ATTR_TEXT_CONTENT = "textContent";

fxy060608's avatar
fxy060608 已提交
70 71
export declare const ATTR_V_OWNER_ID = ".vOwnerId";

fxy060608's avatar
fxy060608 已提交
72 73
export declare const ATTR_V_RENDERJS = ".vRenderjs";

fxy060608's avatar
fxy060608 已提交
74 75
export declare const ATTR_V_SHOW = ".vShow";

fxy060608's avatar
fxy060608 已提交
76 77
export declare const BACKGROUND_COLOR = "#f7f7f7";

fxy060608's avatar
fxy060608 已提交
78 79
export declare const BUILT_IN_TAGS: string[];

fxy060608's avatar
fxy060608 已提交
80 81 82
export declare function cache<T>(fn: (str: string) => T): (str: string) => T;

export declare function cacheStringFunction(fn: (string: string) => string): (str: string) => string;
fxy060608's avatar
fxy060608 已提交
83

Q
qiang 已提交
84 85 86 87 88 89 90
export declare function callOptions(options: Options, errMsg: string): void;

export declare function callOptions(options: Options, data: {
    [key: string]: any;
    errMsg: string;
}): void;

fxy060608's avatar
fxy060608 已提交
91 92
export declare const COMPONENT_NAME_PREFIX = "VUni";

fxy060608's avatar
fxy060608 已提交
93 94 95
export declare const COMPONENT_PREFIX: string;

export declare const COMPONENT_SELECTOR_PREFIX = "uni-";
fxy060608's avatar
fxy060608 已提交
96

fxy060608's avatar
fxy060608 已提交
97 98 99 100
/**
 * nodeId
 * tag
 * parentNodeId
fxy060608's avatar
fxy060608 已提交
101
 * refNodeId
fxy060608's avatar
fxy060608 已提交
102 103 104
 * nodeJson
 */
export declare type CreateAction = [
fxy060608's avatar
fxy060608 已提交
105 106 107 108
typeof ACTION_TYPE_CREATE,
number,
string | number,
number,
fxy060608's avatar
fxy060608 已提交
109
number,
fxy060608's avatar
fxy060608 已提交
110
Partial<UniNodeJSON | UniNodeJSONMinify>?
fxy060608's avatar
fxy060608 已提交
111 112
];

fxy060608's avatar
fxy060608 已提交
113 114
export declare function createRpx2Unit(unit: string, unitRatio: number, unitPrecision: number): (val: string) => string;

fxy060608's avatar
fxy060608 已提交
115 116
export declare function createUniEvent(evt: Record<string, any>): UniEvent;

fxy060608's avatar
fxy060608 已提交
117 118
export declare const DATA_RE: RegExp;

fxy060608's avatar
fxy060608 已提交
119 120 121 122 123
export declare function debounce(fn: Function, delay: number): {
    (this: any): void;
    cancel(): void;
};

fxy060608's avatar
fxy060608 已提交
124 125 126 127 128 129 130 131 132 133 134
/**
 * Decode text using `decodeURIComponent`. Returns the original text if it
 * fails.
 *
 * @param text - string to decode
 * @returns decoded string
 */
export declare function decode(text: string | number): string;

export declare function decodedQuery(query?: Record<string, any>): Record<string, string>;

fxy060608's avatar
fxy060608 已提交
135 136 137 138 139 140
export declare const defaultMiniProgramRpx2Unit: {
    unit: string;
    unitRatio: number;
    unitPrecision: number;
};

fxy060608's avatar
fxy060608 已提交
141 142 143 144 145 146
export declare const defaultRpx2Unit: {
    unit: string;
    unitRatio: number;
    unitPrecision: number;
};

fxy060608's avatar
fxy060608 已提交
147
declare type DictArray = [number, number][];
fxy060608's avatar
fxy060608 已提交
148

fxy060608's avatar
fxy060608 已提交
149
export declare class EventChannel {
fxy060608's avatar
fxy060608 已提交
150
    id?: number;
fxy060608's avatar
fxy060608 已提交
151 152
    private listener;
    private emitCache;
fxy060608's avatar
fxy060608 已提交
153
    constructor(id?: number, events?: NavigateToOptionEvents);
fxy060608's avatar
fxy060608 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166
    emit(eventName: string, ...args: any[]): number | undefined;
    on(eventName: string, fn: EventChannelListener['fn']): void;
    once(eventName: string, fn: EventChannelListener['fn']): void;
    off(eventName: string, fn: EventChannelListener['fn']): void;
    _clearCache(eventName: string): void;
    _addListener(eventName: string, type: EventChannelListener['type'], fn: EventChannelListener['fn']): void;
}

declare interface EventChannelListener {
    type: 'on' | 'once';
    fn: (...args: any[]) => void;
}

fxy060608's avatar
fxy060608 已提交
167 168 169 170 171 172
export declare const EventModifierFlags: {
    stop: number;
    prevent: number;
    self: number;
};

fxy060608's avatar
fxy060608 已提交
173 174
export declare function formatAppLog(type: 'log' | 'info' | 'debug' | 'warn' | 'error', filename: string, ...args: unknown[]): void;

D
DCloud_LXH 已提交
175 176 177 178 179
export declare function formatDateTime({ date, mode }: {
    date?: Date | undefined;
    mode?: string | undefined;
}): string;

fxy060608's avatar
fxy060608 已提交
180 181
export declare function formatLog(module: string, ...args: any[]): string;

Q
qiang 已提交
182
export declare function getCustomDataset(el: HTMLElement | HTMLElementWithDataset): DOMStringMap & Record<string, any>;
Q
qiang 已提交
183

fxy060608's avatar
fxy060608 已提交
184 185
export declare function getDataByPath(obj: Record<string | number, any>, path: string): unknown;

fxy060608's avatar
fxy060608 已提交
186 187
export declare function getEnvLocale(): string;

fxy060608's avatar
fxy060608 已提交
188 189
export declare function getLen(str?: string): number;

fxy060608's avatar
fxy060608 已提交
190 191
export declare function getValueByDataPath(obj: any, path: string): unknown;

Q
qiang 已提交
192 193 194 195
declare interface HTMLElementWithDataset extends HTMLElement {
    __uniDataset?: Record<string, any>;
}

fxy060608's avatar
fxy060608 已提交
196 197
export declare const I18N_JSON_DELIMITERS: [string, string];

Q
qiang 已提交
198
export declare function initCustomDataset(): void;
Q
qiang 已提交
199

fxy060608's avatar
fxy060608 已提交
200 201 202 203 204 205 206
/**
 * nodeId
 * parentNodeId
 * refNodeId
 */
export declare type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, number];

fxy060608's avatar
fxy060608 已提交
207 208
export declare const invokeArrayFns: (fns: Function[], arg?: any) => any;

fxy060608's avatar
fxy060608 已提交
209 210
export declare function isBuiltInComponent(tag: string): boolean;

fxy060608's avatar
fxy060608 已提交
211 212
export declare function isComponentTag(tag: string): boolean;

fxy060608's avatar
fxy060608 已提交
213
export declare function isCustomElement(_tag: string): boolean;
fxy060608's avatar
fxy060608 已提交
214

fxy060608's avatar
fxy060608 已提交
215
export declare function isH5CustomElement(tag: string): boolean;
fxy060608's avatar
fxy060608 已提交
216

fxy060608's avatar
fxy060608 已提交
217
export declare function isH5NativeTag(tag: string): boolean;
fxy060608's avatar
fxy060608 已提交
218

fxy060608's avatar
fxy060608 已提交
219
export declare function isNativeTag(tag: string): boolean;
fxy060608's avatar
fxy060608 已提交
220

fxy060608's avatar
fxy060608 已提交
221
export declare function isRootHook(name: string): boolean;
fxy060608's avatar
fxy060608 已提交
222

fxy060608's avatar
fxy060608 已提交
223 224
export declare interface IUniPageNode {
    pageId: number;
fxy060608's avatar
fxy060608 已提交
225
    pageNode: IUniPageNode | null;
fxy060608's avatar
fxy060608 已提交
226
    isUnmounted: boolean;
fxy060608's avatar
fxy060608 已提交
227 228
    genId: () => number;
    push: (...args: any[]) => void;
fxy060608's avatar
fxy060608 已提交
229
    onCreate: (thisNode: UniNode, nodeName: string | number) => UniNode;
fxy060608's avatar
fxy060608 已提交
230 231
    onInsertBefore: (thisNode: UniNode, newChild: UniNode, refChild: UniNode | null) => UniNode;
    onRemoveChild: (oldChild: UniNode) => UniNode;
fxy060608's avatar
fxy060608 已提交
232
    onAddEvent: (thisNode: UniNode, name: string, flag: number) => void;
fxy060608's avatar
fxy060608 已提交
233
    onAddWxsEvent: (thisNode: UniNode, name: string, wxsEvent: string, flag: number) => void;
fxy060608's avatar
fxy060608 已提交
234
    onRemoveEvent: (thisNode: UniNode, name: string) => void;
fxy060608's avatar
fxy060608 已提交
235 236 237 238
    onSetAttribute: (thisNode: UniNode, qualifiedName: string, value: unknown) => void;
    onRemoveAttribute: (thisNode: UniNode, qualifiedName: string) => void;
    onTextContent: (thisNode: UniNode, text: string) => void;
    onNodeValue: (thisNode: UniNode, val: string | null) => void;
fxy060608's avatar
fxy060608 已提交
239 240
}

fxy060608's avatar
fxy060608 已提交
241 242
export declare const JSON_PROTOCOL = "json://";

fxy060608's avatar
fxy060608 已提交
243 244
export declare const LINEFEED = "\n";

fxy060608's avatar
fxy060608 已提交
245 246
export declare const NAVBAR_HEIGHT = 44;

fxy060608's avatar
fxy060608 已提交
247 248
declare type NavigateToOptionEvents = Record<string, (...args: any[]) => void>;

fxy060608's avatar
fxy060608 已提交
249 250 251 252 253 254 255 256
export declare const NODE_TYPE_COMMENT = 8;

export declare const NODE_TYPE_ELEMENT = 1;

export declare const NODE_TYPE_PAGE = 0;

export declare const NODE_TYPE_TEXT = 3;

fxy060608's avatar
fxy060608 已提交
257 258
export declare function normalizeDataset(el: Element): any;

fxy060608's avatar
fxy060608 已提交
259 260
export declare function normalizeEventType(type: string, options?: AddEventListenerOptions): string;

fxy060608's avatar
fxy060608 已提交
261 262
export declare function normalizeTarget(el: HTMLElement): {
    id: string;
Q
qiang 已提交
263
    dataset: DOMStringMap & Record<string, any>;
fxy060608's avatar
fxy060608 已提交
264 265 266 267
    offsetTop: number;
    offsetLeft: number;
};

fxy060608's avatar
fxy060608 已提交
268 269 270 271 272 273 274 275 276 277 278 279
export declare const ON_ADD_TO_FAVORITES = "onAddToFavorites";

export declare const ON_APP_ENTER_BACKGROUND = "onAppEnterBackground";

export declare const ON_APP_ENTER_FOREGROUND = "onAppEnterForeground";

export declare const ON_BACK_PRESS = "onBackPress";

export declare const ON_ERROR = "onError";

export declare const ON_HIDE = "onHide";

280 281
export declare const ON_KEYBOARD_HEIGHT_CHANGE = "onKeyboardHeightChange";

fxy060608's avatar
fxy060608 已提交
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
export declare const ON_LAUNCH = "onLaunch";

export declare const ON_LOAD = "onLoad";

export declare const ON_NAVIGATION_BAR_BUTTON_TAP = "onNavigationBarButtonTap";

export declare const ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = "onNavigationBarSearchInputChanged";

export declare const ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = "onNavigationBarSearchInputClicked";

export declare const ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = "onNavigationBarSearchInputConfirmed";

export declare const ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = "onNavigationBarSearchInputFocusChanged";

export declare const ON_PAGE_NOT_FOUND = "onPageNotFound";

export declare const ON_PAGE_SCROLL = "onPageScroll";

export declare const ON_PULL_DOWN_REFRESH = "onPullDownRefresh";

export declare const ON_REACH_BOTTOM = "onReachBottom";

fxy060608's avatar
fxy060608 已提交
304 305
export declare const ON_REACH_BOTTOM_DISTANCE = 50;

fxy060608's avatar
fxy060608 已提交
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
export declare const ON_READY = "onReady";

export declare const ON_RESIZE = "onResize";

export declare const ON_SHARE_APP_MESSAGE = "onShareAppMessage";

export declare const ON_SHARE_TIMELINE = "onShareTimeline";

export declare const ON_SHOW = "onShow";

export declare const ON_TAB_ITEM_TAP = "onTabItemTap";

export declare const ON_THEME_CHANGE = "onThemeChange";

export declare const ON_UNHANDLE_REJECTION = "onUnhandledRejection";

export declare const ON_UNLOAD = "onUnload";

export declare const ON_WEB_INVOKE_APP_SERVICE = "onWebInvokeAppService";

fxy060608's avatar
fxy060608 已提交
326 327
export declare const ON_WXS_INVOKE_CALL_METHOD = "onWxsInvokeCallMethod";

fxy060608's avatar
fxy060608 已提交
328
export declare function once<T extends (...args: any[]) => any>(fn: T, ctx?: unknown): T;
fxy060608's avatar
fxy060608 已提交
329

Q
qiang 已提交
330 331 332 333 334 335
declare interface Options {
    success?: (res: any) => void;
    fail?: (res: any) => void;
    complete?: (res: any) => void;
}

fxy060608's avatar
fxy060608 已提交
336
export declare type PageAction = PageCreateAction | PageCreatedAction | PageUpdateAction | PageScrollAction;
fxy060608's avatar
fxy060608 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361

export declare type PageCreateAction = [typeof ACTION_TYPE_PAGE_CREATE, PageCreateData];

export declare type PageCreatedAction = [typeof ACTION_TYPE_PAGE_CREATED];

export declare interface PageCreateData extends PageNodeOptions {
}

export declare interface PageNodeOptions {
    css: boolean;
    route: string;
    version: number;
    locale: string;
    platform: string;
    pixelRatio: number;
    windowWidth: number;
    disableScroll: boolean;
    onPageScroll: boolean;
    onPageReachBottom: boolean;
    onReachBottomDistance: number;
    statusbarHeight: number;
    windowTop: number;
    windowBottom: number;
}

fxy060608's avatar
fxy060608 已提交
362 363 364 365 366
/**
 * onReachBottomDistance
 */
export declare type PageScrollAction = [typeof ACTION_TYPE_PAGE_SCROLL, number];

fxy060608's avatar
fxy060608 已提交
367
export declare type PageUpdateAction = CreateAction | InsertAction | RemoveAction | AddEventAction | AddWxsEventAction | RemoveEventAction | SetAttributeAction | RemoveAttributeAction | SetTextAction;
fxy060608's avatar
fxy060608 已提交
368

fxy060608's avatar
fxy060608 已提交
369 370
export declare function parseEventName(name: string): [string, EventListenerOptions | undefined];

fxy060608's avatar
fxy060608 已提交
371 372 373 374 375 376 377 378 379
/**
 * https://github.com/vuejs/vue-router-next/blob/master/src/query.ts
 * @internal
 *
 * @param search - search string to parse
 * @returns a query object
 */
export declare function parseQuery(search: string): Record<string, any>;

fxy060608's avatar
fxy060608 已提交
380 381 382 383 384
export declare function parseUrl(url: string): {
    path: string;
    query: Record<string, any>;
};

fxy060608's avatar
fxy060608 已提交
385 386 387 388
export declare function passive(passive: boolean): {
    passive: boolean;
};

fxy060608's avatar
fxy060608 已提交
389 390
export declare const PLUS_RE: RegExp;

fxy060608's avatar
fxy060608 已提交
391 392
export declare function plusReady(callback: () => void): void;

fxy060608's avatar
fxy060608 已提交
393 394
export declare const PRIMARY_COLOR = "#007aff";

fxy060608's avatar
fxy060608 已提交
395 396 397 398 399 400 401 402 403 404
/**
 * nodeId
 */
export declare type RemoveAction = [typeof ACTION_TYPE_REMOVE, number];

/**
 * nodeId
 * name
 */
export declare type RemoveAttributeAction = [
fxy060608's avatar
fxy060608 已提交
405 406 407
typeof ACTION_TYPE_REMOVE_ATTRIBUTE,
number,
string | number
fxy060608's avatar
fxy060608 已提交
408 409 410 411 412 413 414
];

/**
 * nodeId
 * event
 */
export declare type RemoveEventAction = [
fxy060608's avatar
fxy060608 已提交
415 416 417
typeof ACTION_TYPE_REMOVE_EVENT,
number,
string | number
fxy060608's avatar
fxy060608 已提交
418 419
];

fxy060608's avatar
fxy060608 已提交
420 421
export declare function removeLeadingSlash(str: string): string;

fxy060608's avatar
fxy060608 已提交
422 423
export declare const RENDERJS_MODULES = "renderjsModules";

fxy060608's avatar
fxy060608 已提交
424 425
export declare function resolveOwnerEl(instance: ComponentInternalInstance): RendererNode | null;

fxy060608's avatar
fxy060608 已提交
426 427
export declare function resolveOwnerVm(vm: ComponentInternalInstance): ComponentPublicInstance<    {}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | undefined;

fxy060608's avatar
fxy060608 已提交
428 429
export declare const RESPONSIVE_MIN_WIDTH = 768;

fxy060608's avatar
fxy060608 已提交
430 431
export declare type Rpx2UnitOptions = typeof defaultRpx2Unit;

fxy060608's avatar
fxy060608 已提交
432 433
export declare const sanitise: (val: unknown) => any;

fxy060608's avatar
fxy060608 已提交
434 435
export declare const SCHEME_RE: RegExp;

fxy060608's avatar
fxy060608 已提交
436 437 438
declare function scrollTo_2(scrollTop: number | string, duration: number): void;
export { scrollTo_2 as scrollTo }

fxy060608's avatar
fxy060608 已提交
439 440
export declare const SELECTED_COLOR = "#0062cc";

fxy060608's avatar
fxy060608 已提交
441 442 443 444 445 446
/**
 * nodeId
 * name
 * value
 */
export declare type SetAttributeAction = [
fxy060608's avatar
fxy060608 已提交
447 448 449 450
typeof ACTION_TYPE_SET_ATTRIBUTE,
number,
string | number,
unknown | number
fxy060608's avatar
fxy060608 已提交
451 452 453 454 455 456
];

/**
 * nodeId
 * text
 */
fxy060608's avatar
fxy060608 已提交
457
export declare type SetTextAction = [
fxy060608's avatar
fxy060608 已提交
458 459 460
typeof ACTION_TYPE_SET_TEXT,
number,
string | number
fxy060608's avatar
fxy060608 已提交
461
];
fxy060608's avatar
fxy060608 已提交
462

fxy060608's avatar
fxy060608 已提交
463 464 465 466 467 468
export declare function stringifyQuery(obj?: Record<string, any>, encodeStr?: typeof encodeURIComponent): string;

export declare const TABBAR_HEIGHT = 50;

export declare const TAGS: string[];

fxy060608's avatar
fxy060608 已提交
469 470 471 472 473 474
export declare const UNI_SSR = "__uniSSR";

export declare const UNI_SSR_DATA = "data";

export declare const UNI_SSR_GLOBAL_DATA = "globalData";

fxy060608's avatar
fxy060608 已提交
475 476
export declare const UNI_SSR_STORE = "store";

fxy060608's avatar
fxy060608 已提交
477 478
export declare const UNI_SSR_TITLE = "title";

fxy060608's avatar
fxy060608 已提交
479 480
export declare class UniBaseNode extends UniNode {
    attributes: Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
481
    style: null | string | Record<string, string | string[]>;
fxy060608's avatar
fxy060608 已提交
482
    vShow: null | boolean;
fxy060608's avatar
fxy060608 已提交
483
    protected _html: string | null;
fxy060608's avatar
fxy060608 已提交
484
    constructor(nodeType: UniNodeType, nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
485 486 487 488 489 490 491 492 493
    get className(): string;
    set className(val: string);
    get innerHTML(): string;
    set innerHTML(html: string);
    addEventListener(type: string, listener: UniEventListener, options?: AddEventListenerOptions): void;
    removeEventListener(type: string, callback: UniEventListener, options?: EventListenerOptions): void;
    getAttribute(qualifiedName: string): unknown;
    removeAttribute(qualifiedName: string): void;
    setAttribute(qualifiedName: string, value: unknown): void;
fxy060608's avatar
fxy060608 已提交
494
    toJSON({ attr, normalize, }?: {
fxy060608's avatar
fxy060608 已提交
495 496
        attr?: boolean;
        children?: boolean;
fxy060608's avatar
fxy060608 已提交
497
        normalize?: (val: any, includeValue?: boolean) => any | number;
fxy060608's avatar
fxy060608 已提交
498
    }): Partial<UniNodeJSON>;
fxy060608's avatar
fxy060608 已提交
499 500 501
}

export declare class UniCommentNode extends UniNode {
fxy060608's avatar
fxy060608 已提交
502 503 504 505 506 507 508 509
    constructor(text: string, container: UniElement | IUniPageNode);
    toJSON(opts?: {
        attr?: boolean;
    }): {
        i?: undefined;
    } | {
        i: number;
    };
fxy060608's avatar
fxy060608 已提交
510 511 512 513 514 515
}

declare type UniCSSStyleDeclarationJSON = string | null | Record<string, string | string[]> | [string, Record<string, string | string[]>];

export declare class UniElement extends UniBaseNode {
    tagName: string;
fxy060608's avatar
fxy060608 已提交
516
    constructor(nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
517 518 519 520 521 522 523
}

export declare class UniEvent {
    type: string;
    bubbles: boolean;
    cancelable: boolean;
    defaultPrevented: boolean;
fxy060608's avatar
fxy060608 已提交
524
    detail?: Record<string, any>;
fxy060608's avatar
fxy060608 已提交
525 526 527 528 529 530 531 532 533 534 535
    timeStamp: number;
    _stop: boolean;
    _end: boolean;
    constructor(type: string, opts: UniEventOptions);
    preventDefault(): void;
    stopImmediatePropagation(): void;
    stopPropagation(): void;
}

export declare interface UniEventListener {
    (evt: UniEvent): void;
fxy060608's avatar
fxy060608 已提交
536
    modifiers?: string[];
fxy060608's avatar
fxy060608 已提交
537
    wxsEvent?: string;
fxy060608's avatar
fxy060608 已提交
538 539 540 541 542 543 544 545
}

declare interface UniEventOptions {
    bubbles: boolean;
    cancelable: boolean;
}

declare class UniEventTarget {
fxy060608's avatar
fxy060608 已提交
546
    listeners: Record<string, UniEventListener[]>;
fxy060608's avatar
fxy060608 已提交
547 548
    dispatchEvent(evt: UniEvent): boolean;
    addEventListener(type: string, listener: UniEventListener, options?: AddEventListenerOptions): void;
fxy060608's avatar
fxy060608 已提交
549
    removeEventListener(type: string, callback: UniEventListener, options?: AddEventListenerOptions): void;
fxy060608's avatar
fxy060608 已提交
550 551 552 553 554 555 556
}

export declare class UniInputElement extends UniElement {
    get value(): string | number;
    set value(val: string | number);
}

fxy060608's avatar
fxy060608 已提交
557 558
export declare const UniLifecycleHooks: readonly ["onShow", "onHide", "onLaunch", "onError", "onThemeChange", "onPageNotFound", "onUnhandledRejection", "onLoad", "onReady", "onUnload", "onResize", "onBackPress", "onPageScroll", "onTabItemTap", "onReachBottom", "onPullDownRefresh", "onShareTimeline", "onAddToFavorites", "onShareAppMessage", "onNavigationBarButtonTap", "onNavigationBarSearchInputClicked", "onNavigationBarSearchInputChanged", "onNavigationBarSearchInputConfirmed", "onNavigationBarSearchInputFocusChanged"];

fxy060608's avatar
fxy060608 已提交
559 560 561 562 563 564 565
export declare class UniNode extends UniEventTarget {
    nodeId?: number;
    nodeType: UniNodeType;
    nodeName: string;
    childNodes: UniNode[];
    pageNode: IUniPageNode | null;
    parentNode: UniNode | null;
fxy060608's avatar
fxy060608 已提交
566
    __vueParentComponent?: ComponentInternalInstance;
fxy060608's avatar
fxy060608 已提交
567
    protected _text: string | null;
fxy060608's avatar
fxy060608 已提交
568
    constructor(nodeType: UniNodeType, nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
569 570 571
    get firstChild(): UniNode | null;
    get lastChild(): UniNode | null;
    get nextSibling(): UniNode | null;
fxy060608's avatar
fxy060608 已提交
572 573
    get nodeValue(): string | null;
    set nodeValue(_val: string | null);
fxy060608's avatar
fxy060608 已提交
574 575 576 577
    get textContent(): string;
    set textContent(text: string);
    get parentElement(): UniElement | null;
    get previousSibling(): UniNode | null;
fxy060608's avatar
fxy060608 已提交
578
    appendChild(newChild: UniNode): UniNode;
fxy060608's avatar
fxy060608 已提交
579
    cloneNode(deep?: boolean): UniNode;
fxy060608's avatar
fxy060608 已提交
580 581
    insertBefore(newChild: UniNode, refChild: UniNode | null): UniNode;
    removeChild(oldChild: UniNode): UniNode;
fxy060608's avatar
fxy060608 已提交
582 583 584 585 586 587 588 589 590 591
}

export declare interface UniNodeJSON {
    /**
     * nodeId
     */
    i: number;
    /**
     * nodeName
     */
fxy060608's avatar
fxy060608 已提交
592
    n: string | number;
fxy060608's avatar
fxy060608 已提交
593 594 595 596
    /**
     * attributes
     */
    a: Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
597 598 599 600
    /**
     * listeners
     */
    e: Record<string, number>;
fxy060608's avatar
fxy060608 已提交
601 602 603 604
    /**
     * wxs listeners
     */
    w: Record<string, [string, number]>;
fxy060608's avatar
fxy060608 已提交
605 606 607
    /**
     * style
     */
fxy060608's avatar
fxy060608 已提交
608
    s?: UniCSSStyleDeclarationJSON;
fxy060608's avatar
fxy060608 已提交
609 610 611 612 613 614
    /**
     * text
     */
    t?: string;
}

fxy060608's avatar
fxy060608 已提交
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
declare interface UniNodeJSONMinify {
    /**
     * nodeId
     */
    i: number;
    /**
     * nodeName
     */
    n: string | number;
    /**
     * attributes
     */
    a: DictArray;
    /**
     * listeners
     */
    e: DictArray;
fxy060608's avatar
fxy060608 已提交
632 633 634 635
    /**
     * wxs listeners
     */
    w: [number, [number, number]][];
fxy060608's avatar
fxy060608 已提交
636 637 638 639 640 641 642 643 644 645
    /**
     * style
     */
    s?: DictArray;
    /**
     * text
     */
    t?: number;
}

fxy060608's avatar
fxy060608 已提交
646 647 648 649 650 651
declare type UniNodeType = typeof NODE_TYPE_PAGE | typeof NODE_TYPE_ELEMENT | typeof NODE_TYPE_TEXT | typeof NODE_TYPE_COMMENT;

export declare class UniTextAreaElement extends UniInputElement {
}

export declare class UniTextNode extends UniBaseNode {
fxy060608's avatar
fxy060608 已提交
652
    constructor(text: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
653 654 655 656
    get nodeValue(): string;
    set nodeValue(text: string);
}

fxy060608's avatar
fxy060608 已提交
657 658
export declare function updateElementStyle(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;

fxy060608's avatar
fxy060608 已提交
659 660
export declare const WEB_INVOKE_APPSERVICE = "WEB_INVOKE_APPSERVICE";

fxy060608's avatar
fxy060608 已提交
661 662
export declare const WXS_MODULES = "wxsModules";

fxy060608's avatar
fxy060608 已提交
663 664
export declare const WXS_PROTOCOL = "wxs://";

fxy060608's avatar
fxy060608 已提交
665
export { }