uni-shared.d.ts 25.5 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
import type { App } from 'vue';
fxy060608's avatar
fxy060608 已提交
2 3
import type { ComponentInternalInstance } from '@vue/runtime-core';
import { ComponentOptionsBase } from '@vue/runtime-core';
4
import type { ComponentPublicInstance } from '@vue/runtime-core';
fxy060608's avatar
fxy060608 已提交
5 6
import { ComponentPublicInstance as ComponentPublicInstance_2 } from 'vue';
import { createApp } from 'vue';
fxy060608's avatar
fxy060608 已提交
7
import { RendererNode } from '@vue/runtime-core';
fxy060608's avatar
fxy060608 已提交
8

fxy060608's avatar
fxy060608 已提交
9 10
export declare const ACTION_TYPE_ADD_EVENT = 8;

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

fxy060608's avatar
fxy060608 已提交
13 14 15 16 17 18 19 20 21 22
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 已提交
23 24
export declare const ACTION_TYPE_PAGE_SCROLL = 15;

fxy060608's avatar
fxy060608 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
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 已提交
41 42 43 44
typeof ACTION_TYPE_ADD_EVENT,
number,
string | number,
number
fxy060608's avatar
fxy060608 已提交
45 46
];

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

fxy060608's avatar
fxy060608 已提交
49 50
export declare function addLeadingSlash(str: string): string;

fxy060608's avatar
fxy060608 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64
/**
 * nodeId
 * event
 * wxsEvent
 * flag
 */
export declare type AddWxsEventAction = [
typeof ACTION_TYPE_ADD_WXS_EVENT,
number,
string | number,
string | number,
number
];

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

fxy060608's avatar
fxy060608 已提交
67 68
export declare const ATTR_CLASS = "class";

fxy060608's avatar
fxy060608 已提交
69 70
export declare const ATTR_INNER_HTML = "innerHTML";

fxy060608's avatar
fxy060608 已提交
71 72
export declare const ATTR_STYLE = "style";

fxy060608's avatar
fxy060608 已提交
73 74
export declare const ATTR_TEXT_CONTENT = "textContent";

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

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

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

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

83 84
export declare const BUILT_IN_TAG_NAMES: string[];

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

fxy060608's avatar
fxy060608 已提交
87 88 89
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 已提交
90

Q
qiang 已提交
91 92 93 94 95 96 97
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 已提交
98 99
export declare const COMPONENT_NAME_PREFIX = "VUni";

fxy060608's avatar
fxy060608 已提交
100 101 102
export declare const COMPONENT_PREFIX: string;

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

fxy060608's avatar
fxy060608 已提交
104 105 106 107
/**
 * nodeId
 * tag
 * parentNodeId
fxy060608's avatar
fxy060608 已提交
108
 * refNodeId
fxy060608's avatar
fxy060608 已提交
109 110 111
 * nodeJson
 */
export declare type CreateAction = [
fxy060608's avatar
fxy060608 已提交
112 113 114 115
typeof ACTION_TYPE_CREATE,
number,
string | number,
number,
fxy060608's avatar
fxy060608 已提交
116
number,
fxy060608's avatar
fxy060608 已提交
117
Partial<UniNodeJSON | UniNodeJSONMinify>?
fxy060608's avatar
fxy060608 已提交
118 119
];

fxy060608's avatar
fxy060608 已提交
120 121
export declare function createIsCustomElement(tags?: string[]): (tag: string) => boolean;

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

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

fxy060608's avatar
fxy060608 已提交
126 127
declare type CreateVueAppHook = (app: App) => void;

128 129
export declare function customizeEvent(str: string): string;

fxy060608's avatar
fxy060608 已提交
130 131
export declare const DATA_RE: RegExp;

fxy060608's avatar
fxy060608 已提交
132 133 134 135 136 137 138
/**
 * 需要手动传入 timer,主要是解决 App 平台的定制 timer
 * @param fn
 * @param delay
 * @param timer
 * @returns
 */
Q
qiang 已提交
139
export declare function debounce(fn: Function, delay: number, { clearTimeout, setTimeout }: Timer): {
fxy060608's avatar
fxy060608 已提交
140 141 142 143
    (this: any): void;
    cancel(): void;
};

fxy060608's avatar
fxy060608 已提交
144 145 146 147 148 149 150 151 152 153 154
/**
 * 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 已提交
155 156 157 158 159 160
export declare const defaultMiniProgramRpx2Unit: {
    unit: string;
    unitRatio: number;
    unitPrecision: number;
};

fxy060608's avatar
fxy060608 已提交
161 162 163 164 165 166
export declare const defaultNVueRpx2Unit: {
    unit: string;
    unitRatio: number;
    unitPrecision: number;
};

fxy060608's avatar
fxy060608 已提交
167 168 169 170 171 172
export declare const defaultRpx2Unit: {
    unit: string;
    unitRatio: number;
    unitPrecision: number;
};

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

fxy060608's avatar
fxy060608 已提交
175 176
export declare function dynamicSlotName(name: string): string;

fxy060608's avatar
fxy060608 已提交
177 178 179 180 181 182 183 184 185 186 187 188
export declare interface Emitter {
    e: Record<string, unknown>;
    on: (name: EventName, callback: EventCallback, ctx?: any) => this;
    once: (name: EventName, callback: EventCallback, ctx?: any) => this;
    emit: (name: EventName, ...args: any[]) => this;
    off: (name: EventName, callback?: EventCallback) => this;
}

export declare const Emitter: new () => Emitter;

declare type EventCallback = Function;

fxy060608's avatar
fxy060608 已提交
189
export declare class EventChannel {
fxy060608's avatar
fxy060608 已提交
190
    id?: number;
fxy060608's avatar
fxy060608 已提交
191 192
    private listener;
    private emitCache;
fxy060608's avatar
fxy060608 已提交
193
    constructor(id?: number, events?: NavigateToOptionEvents);
fxy060608's avatar
fxy060608 已提交
194 195 196 197 198 199 200 201 202 203 204 205 206
    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 已提交
207 208 209 210 211 212
export declare const EventModifierFlags: {
    stop: number;
    prevent: number;
    self: number;
};

fxy060608's avatar
fxy060608 已提交
213 214
declare type EventName = string;

fxy060608's avatar
fxy060608 已提交
215 216 217 218
export declare const forcePatchProp: (el: {
    nodeName: string;
}, key: string) => boolean;

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

D
DCloud_LXH 已提交
221 222 223 224 225
export declare function formatDateTime({ date, mode }: {
    date?: Date | undefined;
    mode?: string | undefined;
}): string;

fxy060608's avatar
fxy060608 已提交
226 227
export declare function formatH5Log(type: keyof Console, filename: string, ...args: unknown[]): void;

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

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

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

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

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

Q
qiang 已提交
238 239 240 241
declare interface HTMLElementWithDataset extends HTMLElement {
    __uniDataset?: Record<string, any>;
}

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

244
export declare const initCustomDatasetOnce: () => void;
Q
qiang 已提交
245

fxy060608's avatar
fxy060608 已提交
246 247 248 249
/**
 * nodeId
 * parentNodeId
 * refNodeId
fxy060608's avatar
fxy060608 已提交
250
 * nodeJson
fxy060608's avatar
fxy060608 已提交
251
 */
fxy060608's avatar
fxy060608 已提交
252 253 254 255 256 257 258
export declare type InsertAction = [
typeof ACTION_TYPE_INSERT,
number,
number,
number,
Partial<UniNodeJSON | UniNodeJSONMinify>?
];
fxy060608's avatar
fxy060608 已提交
259

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

fxy060608's avatar
fxy060608 已提交
262 263
export declare function invokeCreateVueAppHook(app: App): void;

fxy060608's avatar
fxy060608 已提交
264 265
export declare function isAppNativeTag(tag: string): boolean;

fxy060608's avatar
fxy060608 已提交
266 267
export declare function isAppNVueNativeTag(tag: string): boolean;

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

270 271
export declare function isComponentInternalInstance(vm: unknown): vm is ComponentInternalInstance;

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

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

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

fxy060608's avatar
fxy060608 已提交
278
export declare function isMiniProgramNativeTag(tag: string): boolean;
fxy060608's avatar
fxy060608 已提交
279

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

fxy060608's avatar
fxy060608 已提交
282 283
export declare function isRootImmediateHook(name: string): boolean;

fxy060608's avatar
fxy060608 已提交
284 285
export declare interface IUniPageNode {
    pageId: number;
fxy060608's avatar
fxy060608 已提交
286
    pageNode: IUniPageNode | null;
fxy060608's avatar
fxy060608 已提交
287
    isUnmounted: boolean;
fxy060608's avatar
fxy060608 已提交
288 289
    genId: () => number;
    push: (...args: any[]) => void;
fxy060608's avatar
fxy060608 已提交
290
    onCreate: (thisNode: UniNode, nodeName: string | number) => UniNode;
fxy060608's avatar
fxy060608 已提交
291 292
    onInsertBefore: (thisNode: UniNode, newChild: UniNode, refChild: UniNode | null) => UniNode;
    onRemoveChild: (oldChild: UniNode) => UniNode;
fxy060608's avatar
fxy060608 已提交
293
    onAddEvent: (thisNode: UniNode, name: string, flag: number) => void;
fxy060608's avatar
fxy060608 已提交
294
    onAddWxsEvent: (thisNode: UniNode, name: string, wxsEvent: string, flag: number) => void;
fxy060608's avatar
fxy060608 已提交
295
    onRemoveEvent: (thisNode: UniNode, name: string) => void;
fxy060608's avatar
fxy060608 已提交
296 297 298 299
    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 已提交
300 301
}

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

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

306 307 308 309 310 311
export declare const MINI_PROGRAM_PAGE_RUNTIME_HOOKS: {
    readonly onPageScroll: 1;
    readonly onShareAppMessage: number;
    readonly onShareTimeline: number;
};

fxy060608's avatar
fxy060608 已提交
312 313
export declare const NAVBAR_HEIGHT = 44;

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

fxy060608's avatar
fxy060608 已提交
316 317 318 319 320 321 322 323
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 已提交
324 325
export declare function normalizeDataset(el: Element): any;

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

fxy060608's avatar
fxy060608 已提交
328 329
export declare function normalizeTarget(el: HTMLElement): {
    id: string;
Q
qiang 已提交
330
    dataset: DOMStringMap & Record<string, any>;
fxy060608's avatar
fxy060608 已提交
331 332 333 334
    offsetTop: number;
    offsetLeft: number;
};

fxy060608's avatar
fxy060608 已提交
335 336 337 338 339 340 341 342 343
export declare interface NVue {
    config: NVueConfigAPI;
    document: NVueDocument;
    requireModule: (name: string) => Record<string, unknown> | void;
    supports: (condition: string) => boolean | void;
    isRegisteredModule: (name: string, method?: string) => boolean;
    isRegisteredComponent: (name: string) => boolean;
}

fxy060608's avatar
fxy060608 已提交
344 345
export declare const NVUE_BUILT_IN_TAGS: string[];

fxy060608's avatar
fxy060608 已提交
346 347
export declare const NVUE_U_BUILT_IN_TAGS: string[];

fxy060608's avatar
fxy060608 已提交
348 349 350 351 352 353 354 355 356 357 358 359 360
export declare interface NVueConfigAPI {
    bundleUrl: string;
    bundleType: string;
    env: NVueEnvironment;
}

export declare interface NVueDocument {
    id: string;
    URL: string;
    taskCenter: NVueTaskCenter;
    open: () => void;
    close: () => void;
    createElement: (tagName: string, props?: Record<string, unknown>) => NVueElement;
fxy060608's avatar
fxy060608 已提交
361
    createText: (text: string) => Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
362 363 364 365 366 367 368 369 370 371 372
    createComment: (text: string) => Record<string, unknown>;
    fireEvent: (type: string) => void;
    destroy: () => void;
}

export declare interface NVueElement {
    nodeType: number;
    nodeId: string;
    type: string;
    ref: string;
    text?: string;
fxy060608's avatar
fxy060608 已提交
373
    attr: Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
374
    styleSheet: Record<string, Record<string, Record<string, unknown>>>;
fxy060608's avatar
fxy060608 已提交
375
    classList: string[];
fxy060608's avatar
fxy060608 已提交
376 377 378 379 380 381 382 383 384 385
    parentNode: NVueElement | null;
    children: Array<NVueElement>;
    previousSibling: NVueElement | null;
    nextSibling: NVueElement | null;
    appendChild: (node: NVueElement) => void;
    removeChild: (node: NVueElement, preserved?: boolean) => void;
    insertBefore: (node: NVueElement, before: NVueElement) => void;
    insertAfter: (node: NVueElement, after: NVueElement) => void;
    setAttr: (key: string, value: any, silent?: boolean) => void;
    setAttrs: (attrs: Record<string, unknown>, silent?: boolean) => void;
fxy060608's avatar
fxy060608 已提交
386
    setClassList: (classList: string[]) => void;
fxy060608's avatar
fxy060608 已提交
387 388
    setStyle: (key: string, value: any, silent?: boolean) => void;
    setStyles: (attrs: Record<string, unknown>, silent?: boolean) => void;
fxy060608's avatar
fxy060608 已提交
389
    setStyleSheet: (styleSheet: Record<string, Record<string, Record<string, unknown>>>) => void;
fxy060608's avatar
fxy060608 已提交
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
    addEvent: (type: string, handler: Function, args?: Array<any>) => void;
    removeEvent: (type: string) => void;
    fireEvent: (type: string) => void;
    destroy: () => void;
}

export declare interface NVueEnvironment {
    platform: string;
    osName: string;
    osVersion: string;
    appName: string;
    appVersion: string;
    deviceModel: string;
    deviceWidth: number;
    deviceHeight: number;
    scale: number;
    userAgent?: string;
    dpr?: number;
    rem?: number;
}

export declare interface NVueInstanceContext {
fxy060608's avatar
fxy060608 已提交
412
    Vue: Vue_2;
fxy060608's avatar
fxy060608 已提交
413 414 415 416 417 418
}

export declare interface NVueInstanceOption {
    instanceId: string;
    config: NVueConfigAPI;
    document?: NVueDocument;
fxy060608's avatar
fxy060608 已提交
419
    Vue?: Vue_2;
fxy060608's avatar
fxy060608 已提交
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
    app?: ComponentPublicInstance_2;
    data?: Record<string, unknown>;
}

export declare interface NVueRuntimeContext {
    nvue: NVue;
    service: Record<string, unknown>;
    BroadcastChannel?: Function;
    SharedObject: Record<string, unknown>;
}

export declare interface NVueTaskCenter {
    instanceId: string;
    callbackManager: unknown;
    send: (type: string, params: Record<string, unknown>, args: any[], options?: Record<string, unknown>) => void;
    registerHook: (componentId: string, type: string, hook: string, fn: Function) => void;
    updateData: (componentId: string, data: Record<string, unknown> | void, callback?: Function) => void;
}

fxy060608's avatar
fxy060608 已提交
439 440 441 442 443 444 445 446 447 448 449 450
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";

fxy060608's avatar
fxy060608 已提交
451 452
export declare const ON_INIT = "onInit";

453 454
export declare const ON_KEYBOARD_HEIGHT_CHANGE = "onKeyboardHeightChange";

fxy060608's avatar
fxy060608 已提交
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
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 已提交
477 478
export declare const ON_REACH_BOTTOM_DISTANCE = 50;

fxy060608's avatar
fxy060608 已提交
479 480 481 482
export declare const ON_READY = "onReady";

export declare const ON_RESIZE = "onResize";

fxy060608's avatar
fxy060608 已提交
483 484
export declare const ON_SAVE_EXIT_STATE = "onSaveExitState";

fxy060608's avatar
fxy060608 已提交
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
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 已提交
501 502
export declare const ON_WXS_INVOKE_CALL_METHOD = "onWxsInvokeCallMethod";

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

fxy060608's avatar
fxy060608 已提交
505 506 507 508 509
/**
 * 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
 */
export declare function onCreateVueApp(hook: CreateVueAppHook): void;

Q
qiang 已提交
510 511 512 513 514 515
declare interface Options {
    success?: (res: any) => void;
    fail?: (res: any) => void;
    complete?: (res: any) => void;
}

fxy060608's avatar
fxy060608 已提交
516
export declare type PageAction = PageCreateAction | PageCreatedAction | PageUpdateAction | PageScrollAction;
fxy060608's avatar
fxy060608 已提交
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541

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 已提交
542 543 544 545 546
/**
 * onReachBottomDistance
 */
export declare type PageScrollAction = [typeof ACTION_TYPE_PAGE_SCROLL, number];

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

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

fxy060608's avatar
fxy060608 已提交
551 552
export declare function parseNVueDataset(attr?: Record<string, unknown>): Record<string, unknown>;

fxy060608's avatar
fxy060608 已提交
553 554 555 556 557 558 559 560 561
/**
 * 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 已提交
562 563 564 565 566
export declare function parseUrl(url: string): {
    path: string;
    query: Record<string, any>;
};

fxy060608's avatar
fxy060608 已提交
567 568 569 570
export declare function passive(passive: boolean): {
    passive: boolean;
};

fxy060608's avatar
fxy060608 已提交
571 572
export declare const PLUS_RE: RegExp;

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

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

fxy060608's avatar
fxy060608 已提交
577 578 579 580 581 582 583 584 585 586
/**
 * nodeId
 */
export declare type RemoveAction = [typeof ACTION_TYPE_REMOVE, number];

/**
 * nodeId
 * name
 */
export declare type RemoveAttributeAction = [
fxy060608's avatar
fxy060608 已提交
587 588 589
typeof ACTION_TYPE_REMOVE_ATTRIBUTE,
number,
string | number
fxy060608's avatar
fxy060608 已提交
590 591 592 593 594 595 596
];

/**
 * nodeId
 * event
 */
export declare type RemoveEventAction = [
fxy060608's avatar
fxy060608 已提交
597 598 599
typeof ACTION_TYPE_REMOVE_EVENT,
number,
string | number
fxy060608's avatar
fxy060608 已提交
600 601
];

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

fxy060608's avatar
fxy060608 已提交
604 605
export declare const RENDERJS_MODULES = "renderjsModules";

606 607
export declare function resolveComponentInstance(instance?: ComponentInternalInstance | ComponentPublicInstance): ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | undefined;

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

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

fxy060608's avatar
fxy060608 已提交
612 613
export declare const RESPONSIVE_MIN_WIDTH = 768;

fxy060608's avatar
fxy060608 已提交
614 615
export declare type Rpx2UnitOptions = typeof defaultRpx2Unit;

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

fxy060608's avatar
fxy060608 已提交
618 619
export declare const SCHEME_RE: RegExp;

D
DCloud_LXH 已提交
620
declare function scrollTo_2(scrollTop: number | string, duration: number, isH5?: boolean): void;
fxy060608's avatar
fxy060608 已提交
621 622
export { scrollTo_2 as scrollTo }

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

fxy060608's avatar
fxy060608 已提交
625 626 627 628 629 630
/**
 * nodeId
 * name
 * value
 */
export declare type SetAttributeAction = [
fxy060608's avatar
fxy060608 已提交
631 632 633 634
typeof ACTION_TYPE_SET_ATTRIBUTE,
number,
string | number,
unknown | number
fxy060608's avatar
fxy060608 已提交
635 636 637 638 639 640
];

/**
 * nodeId
 * text
 */
fxy060608's avatar
fxy060608 已提交
641
export declare type SetTextAction = [
fxy060608's avatar
fxy060608 已提交
642 643 644
typeof ACTION_TYPE_SET_TEXT,
number,
string | number
fxy060608's avatar
fxy060608 已提交
645
];
fxy060608's avatar
fxy060608 已提交
646

fxy060608's avatar
fxy060608 已提交
647 648
export declare const SLOT_DEFAULT_NAME = "d";

fxy060608's avatar
fxy060608 已提交
649 650 651 652 653 654
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 已提交
655 656 657 658 659
declare interface Timer {
    setTimeout: Function;
    clearTimeout: Function;
}

fxy060608's avatar
fxy060608 已提交
660 661 662 663 664 665
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 已提交
666 667
export declare const UNI_SSR_STORE = "store";

fxy060608's avatar
fxy060608 已提交
668 669
export declare const UNI_SSR_TITLE = "title";

fxy060608's avatar
fxy060608 已提交
670 671
export declare const UNI_STORAGE_LOCALE = "UNI_LOCALE";

fxy060608's avatar
fxy060608 已提交
672 673
export declare class UniBaseNode extends UniNode {
    attributes: Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
674
    style: null | string | Record<string, string | string[]>;
fxy060608's avatar
fxy060608 已提交
675
    vShow: null | boolean;
fxy060608's avatar
fxy060608 已提交
676
    protected _html: string | null;
fxy060608's avatar
fxy060608 已提交
677
    constructor(nodeType: UniNodeType, nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
678 679 680 681 682 683 684 685 686
    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 已提交
687
    toJSON({ attr, normalize, }?: {
fxy060608's avatar
fxy060608 已提交
688 689
        attr?: boolean;
        children?: boolean;
fxy060608's avatar
fxy060608 已提交
690
        normalize?: (val: any, includeValue?: boolean) => any | number;
fxy060608's avatar
fxy060608 已提交
691
    }): Partial<UniNodeJSON>;
fxy060608's avatar
fxy060608 已提交
692 693 694
}

export declare class UniCommentNode extends UniNode {
fxy060608's avatar
fxy060608 已提交
695 696 697 698 699 700 701 702
    constructor(text: string, container: UniElement | IUniPageNode);
    toJSON(opts?: {
        attr?: boolean;
    }): {
        i?: undefined;
    } | {
        i: number;
    };
fxy060608's avatar
fxy060608 已提交
703 704 705 706 707 708
}

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 已提交
709
    constructor(nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
710 711 712 713 714 715 716
}

export declare class UniEvent {
    type: string;
    bubbles: boolean;
    cancelable: boolean;
    defaultPrevented: boolean;
fxy060608's avatar
fxy060608 已提交
717
    detail?: Record<string, any>;
fxy060608's avatar
fxy060608 已提交
718 719 720 721 722 723 724 725 726 727 728
    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 已提交
729
    modifiers?: string[];
fxy060608's avatar
fxy060608 已提交
730
    wxsEvent?: string;
fxy060608's avatar
fxy060608 已提交
731 732 733 734 735 736 737 738
}

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

declare class UniEventTarget {
fxy060608's avatar
fxy060608 已提交
739
    listeners: Record<string, UniEventListener[]>;
fxy060608's avatar
fxy060608 已提交
740 741
    dispatchEvent(evt: UniEvent): boolean;
    addEventListener(type: string, listener: UniEventListener, options?: AddEventListenerOptions): void;
fxy060608's avatar
fxy060608 已提交
742
    removeEventListener(type: string, callback: UniEventListener, options?: AddEventListenerOptions): void;
fxy060608's avatar
fxy060608 已提交
743 744 745 746 747 748 749
}

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

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

fxy060608's avatar
fxy060608 已提交
752 753 754 755 756 757 758
export declare class UniNode extends UniEventTarget {
    nodeId?: number;
    nodeType: UniNodeType;
    nodeName: string;
    childNodes: UniNode[];
    pageNode: IUniPageNode | null;
    parentNode: UniNode | null;
fxy060608's avatar
fxy060608 已提交
759
    __vueParentComponent?: ComponentInternalInstance;
fxy060608's avatar
fxy060608 已提交
760
    protected _text: string | null;
fxy060608's avatar
fxy060608 已提交
761
    constructor(nodeType: UniNodeType, nodeName: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
762 763 764
    get firstChild(): UniNode | null;
    get lastChild(): UniNode | null;
    get nextSibling(): UniNode | null;
fxy060608's avatar
fxy060608 已提交
765 766
    get nodeValue(): string | null;
    set nodeValue(_val: string | null);
fxy060608's avatar
fxy060608 已提交
767 768 769 770
    get textContent(): string;
    set textContent(text: string);
    get parentElement(): UniElement | null;
    get previousSibling(): UniNode | null;
fxy060608's avatar
fxy060608 已提交
771
    appendChild(newChild: UniNode): UniNode;
fxy060608's avatar
fxy060608 已提交
772
    cloneNode(deep?: boolean): UniNode;
fxy060608's avatar
fxy060608 已提交
773 774
    insertBefore(newChild: UniNode, refChild: UniNode | null): UniNode;
    removeChild(oldChild: UniNode): UniNode;
fxy060608's avatar
fxy060608 已提交
775 776 777 778 779 780 781 782 783 784
}

export declare interface UniNodeJSON {
    /**
     * nodeId
     */
    i: number;
    /**
     * nodeName
     */
fxy060608's avatar
fxy060608 已提交
785
    n: string | number;
fxy060608's avatar
fxy060608 已提交
786 787 788 789
    /**
     * attributes
     */
    a: Record<string, unknown>;
fxy060608's avatar
fxy060608 已提交
790 791 792 793
    /**
     * listeners
     */
    e: Record<string, number>;
fxy060608's avatar
fxy060608 已提交
794 795 796 797
    /**
     * wxs listeners
     */
    w: Record<string, [string, number]>;
fxy060608's avatar
fxy060608 已提交
798 799 800
    /**
     * style
     */
fxy060608's avatar
fxy060608 已提交
801
    s?: UniCSSStyleDeclarationJSON;
fxy060608's avatar
fxy060608 已提交
802 803 804 805 806 807
    /**
     * text
     */
    t?: string;
}

fxy060608's avatar
fxy060608 已提交
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
declare interface UniNodeJSONMinify {
    /**
     * nodeId
     */
    i: number;
    /**
     * nodeName
     */
    n: string | number;
    /**
     * attributes
     */
    a: DictArray;
    /**
     * listeners
     */
    e: DictArray;
fxy060608's avatar
fxy060608 已提交
825 826 827 828
    /**
     * wxs listeners
     */
    w: [number, [number, number]][];
fxy060608's avatar
fxy060608 已提交
829 830 831 832 833 834 835 836 837 838
    /**
     * style
     */
    s?: DictArray;
    /**
     * text
     */
    t?: number;
}

fxy060608's avatar
fxy060608 已提交
839 840 841 842 843 844
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 已提交
845
    constructor(text: string, container: UniElement | IUniPageNode);
fxy060608's avatar
fxy060608 已提交
846 847 848 849
    get nodeValue(): string;
    set nodeValue(text: string);
}

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

fxy060608's avatar
fxy060608 已提交
852
declare interface Vue_2 {
fxy060608's avatar
fxy060608 已提交
853 854
    createApp: typeof createApp;
}
fxy060608's avatar
fxy060608 已提交
855
export { Vue_2 as Vue }
fxy060608's avatar
fxy060608 已提交
856

fxy060608's avatar
fxy060608 已提交
857 858
export declare const WEB_INVOKE_APPSERVICE = "WEB_INVOKE_APPSERVICE";

fxy060608's avatar
fxy060608 已提交
859 860
export declare const WXS_MODULES = "wxsModules";

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

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