@tarojs/runtime 3.5.0-theta.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bom/document.d.ts +2 -0
- package/dist/bom/getComputedStyle.d.ts +3 -0
- package/dist/bom/navigator.d.ts +1 -0
- package/dist/bom/raf.d.ts +5 -0
- package/dist/bom/window.d.ts +2 -0
- package/dist/constants/index.d.ts +47 -0
- package/dist/current.d.ts +19 -0
- package/dist/dom/class-list.d.ts +14 -0
- package/dist/dom/document.d.ts +20 -0
- package/dist/dom/element.d.ts +38 -0
- package/dist/dom/event-source.d.ts +7 -0
- package/dist/dom/event-target.d.ts +7 -0
- package/dist/dom/event.d.ts +22 -0
- package/dist/dom/form.d.ts +7 -0
- package/dist/dom/node.d.ts +75 -0
- package/dist/dom/node_types.d.ts +10 -0
- package/dist/dom/root.d.ts +15 -0
- package/dist/dom/style.d.ts +14 -0
- package/dist/dom/style_properties.d.ts +3 -0
- package/dist/dom/svg.d.ts +3 -0
- package/dist/dom/text.d.ts +14 -0
- package/dist/dom/tree.d.ts +4 -0
- package/dist/dom-external/element.d.ts +3 -0
- package/dist/dom-external/index.d.ts +1 -0
- package/dist/dom-external/inner-html/html.d.ts +2 -0
- package/dist/dom-external/inner-html/parser.d.ts +25 -0
- package/dist/dom-external/inner-html/scaner.d.ts +30 -0
- package/dist/dom-external/inner-html/style.d.ts +27 -0
- package/dist/dom-external/inner-html/tags.d.ts +8 -0
- package/dist/dom-external/inner-html/utils.d.ts +1 -0
- package/dist/dom-external/mutation-observer/implements.d.ts +52 -0
- package/dist/dom-external/mutation-observer/index.d.ts +13 -0
- package/dist/dom-external/mutation-observer/record.d.ts +24 -0
- package/dist/dom-external/node.d.ts +11 -0
- package/dist/dsl/common.d.ts +15 -0
- package/dist/dsl/instance.d.ts +85 -0
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/env.d.ts +7 -0
- package/dist/hydrate.d.ts +10 -0
- package/dist/index.d.ts +26 -0
- package/dist/interface/element.d.ts +4 -0
- package/dist/interface/event-target.d.ts +10 -0
- package/dist/interface/event.d.ts +15 -0
- package/dist/interface/hydrate.d.ts +30 -0
- package/dist/interface/index.d.ts +7 -0
- package/dist/interface/node.d.ts +7 -0
- package/dist/interface/options.d.ts +16 -0
- package/dist/interface/utils.d.ts +2 -0
- package/dist/next-tick.d.ts +2 -0
- package/dist/options.d.ts +2 -0
- package/dist/perf.d.ts +7 -0
- package/dist/runtime.esm.d.ts +28 -28
- package/dist/runtime.esm.js +87 -70
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/index.d.ts +23 -0
- package/package.json +6 -6
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Component as Vue3Component } from '@vue/runtime-core';
|
|
2
|
+
import type { Component, ComponentClass } from 'react';
|
|
3
|
+
import VueCtor, { ComponentOptions, VNode } from 'vue';
|
|
4
|
+
import type { CombinedVueInstance } from 'vue/types/vue';
|
|
5
|
+
import type { TaroElement } from '../dom/element';
|
|
6
|
+
import type { Func, MpEvent } from '../interface';
|
|
7
|
+
export interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
|
|
8
|
+
tid?: string;
|
|
9
|
+
$forceUpdate?(): void;
|
|
10
|
+
$nextTick?(cb: () => void): void;
|
|
11
|
+
$options: Instance;
|
|
12
|
+
}
|
|
13
|
+
export interface VueAppInstance extends ComponentOptions<VueCtor> {
|
|
14
|
+
$options: AppInstance;
|
|
15
|
+
}
|
|
16
|
+
export declare type VueInstance<M = Record<string, any>, P = Record<string, any>> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
|
|
17
|
+
interface VueInternal {
|
|
18
|
+
_render(): VNode;
|
|
19
|
+
_update(vnode: VNode, hyrate: boolean): void;
|
|
20
|
+
}
|
|
21
|
+
export interface PageProps {
|
|
22
|
+
tid?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ReactPageComponent<T = PageProps> extends ComponentClass<T>, PageInstance {
|
|
25
|
+
}
|
|
26
|
+
export interface ReactPageInstance<T = PageProps> extends Component<T>, PageInstance {
|
|
27
|
+
componentDidShow?(): void;
|
|
28
|
+
componentDidHide?(): void;
|
|
29
|
+
}
|
|
30
|
+
export interface ReactAppInstance<T = AppInstance> extends Component<T>, AppInstance {
|
|
31
|
+
}
|
|
32
|
+
export interface PageLifeCycle extends Show {
|
|
33
|
+
eh?(event: MpEvent): void;
|
|
34
|
+
onAddToFavorites?(): void;
|
|
35
|
+
onLoad?(options: Record<string, unknown>, cb?: Func): void;
|
|
36
|
+
onOptionMenuClick?(): void;
|
|
37
|
+
onPageScroll?(obj: {
|
|
38
|
+
scrollTop: number;
|
|
39
|
+
}): void;
|
|
40
|
+
onPullDownRefresh?(): void;
|
|
41
|
+
onPullIntercept?(): void;
|
|
42
|
+
onPopMenuClick?(): void;
|
|
43
|
+
onReachBottom?(): void;
|
|
44
|
+
onReady?(): void;
|
|
45
|
+
onResize?(options: unknown): void;
|
|
46
|
+
onSaveExitState?(): void;
|
|
47
|
+
onShareAppMessage?(obj: {
|
|
48
|
+
from: string;
|
|
49
|
+
target?: TaroElement;
|
|
50
|
+
webViewUrl: string;
|
|
51
|
+
}): void;
|
|
52
|
+
onShareTimeline?(): void;
|
|
53
|
+
onTabItemTap?(obj: {
|
|
54
|
+
index: string;
|
|
55
|
+
pagePath: string;
|
|
56
|
+
text: string;
|
|
57
|
+
}): void;
|
|
58
|
+
onTitleClick?(): void;
|
|
59
|
+
onUnload?(): void;
|
|
60
|
+
}
|
|
61
|
+
export interface PageInstance extends PageLifeCycle {
|
|
62
|
+
/** 页面的初始数据 */
|
|
63
|
+
data?: Record<string, unknown>;
|
|
64
|
+
/** 页面路径 */
|
|
65
|
+
path?: string;
|
|
66
|
+
/** 页面的组件选项 */
|
|
67
|
+
options?: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
interface Show {
|
|
70
|
+
componentDidShow?(): void;
|
|
71
|
+
componentDidHide?(): void;
|
|
72
|
+
onShow?(): void;
|
|
73
|
+
onHide?(): void;
|
|
74
|
+
}
|
|
75
|
+
export interface AppInstance extends Show {
|
|
76
|
+
componentDidShow?(options?: Record<string, unknown>): void;
|
|
77
|
+
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
|
|
78
|
+
onError?(error: string): void;
|
|
79
|
+
onLaunch?(options?: Record<string, unknown>): void;
|
|
80
|
+
onPageNotFound?(res: any): void;
|
|
81
|
+
onShow?(options?: Record<string, unknown>): void;
|
|
82
|
+
unmount?(id: string, cb?: () => void): void;
|
|
83
|
+
taroGlobalData?: Record<any, any>;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TaroElement } from './dom/element';
|
|
2
|
+
import type { TaroText } from './dom/text';
|
|
3
|
+
import type { MiniData } from './interface';
|
|
4
|
+
/**
|
|
5
|
+
* React also has a fancy function's name for this: `hydrate()`.
|
|
6
|
+
* You may have been heard `hydrate` as a SSR-related function,
|
|
7
|
+
* actually, `hydrate` basicly do the `render()` thing, but ignore some properties,
|
|
8
|
+
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hydrate(node: TaroElement | TaroText): MiniData;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import './dom-external';
|
|
2
|
+
export { hooks } from '@tarojs/shared';
|
|
3
|
+
export { document } from './bom/document';
|
|
4
|
+
export { getComputedStyle } from './bom/getComputedStyle';
|
|
5
|
+
export { nav as navigator } from './bom/navigator';
|
|
6
|
+
export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf';
|
|
7
|
+
export { window } from './bom/window';
|
|
8
|
+
export { TaroElement } from './dom/element';
|
|
9
|
+
export { createEvent, eventHandler, TaroEvent } from './dom/event';
|
|
10
|
+
export { FormElement } from './dom/form';
|
|
11
|
+
export { TaroNode } from './dom/node';
|
|
12
|
+
export { TaroRootElement } from './dom/root';
|
|
13
|
+
export { Style } from './dom/style';
|
|
14
|
+
export { SVGElement } from './dom/svg';
|
|
15
|
+
export { TaroText } from './dom/text';
|
|
16
|
+
export { MutationObserver } from './dom-external/mutation-observer';
|
|
17
|
+
export { Current, getCurrentInstance } from './current';
|
|
18
|
+
export { eventSource } from './dom/event-source';
|
|
19
|
+
export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, safeExecute, stringify } from './dsl/common';
|
|
20
|
+
export * from './emitter/emitter';
|
|
21
|
+
export { hydrate } from './hydrate';
|
|
22
|
+
export { nextTick } from './next-tick';
|
|
23
|
+
export { options } from './options';
|
|
24
|
+
export { incrementId } from './utils';
|
|
25
|
+
export * from './dsl/instance';
|
|
26
|
+
export * from './interface';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface EventOptions {
|
|
2
|
+
bubbles: boolean;
|
|
3
|
+
cancelable: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare type Target = Record<string, unknown> & {
|
|
6
|
+
dataset: Record<string, unknown>;
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
export interface MpEvent {
|
|
10
|
+
type: string;
|
|
11
|
+
detail: Record<string, unknown>;
|
|
12
|
+
target: Target;
|
|
13
|
+
currentTarget: Target;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Shortcuts } from '@tarojs/shared';
|
|
2
|
+
import type { PageConfig } from '@tarojs/taro';
|
|
3
|
+
export interface MpInstance {
|
|
4
|
+
config: PageConfig;
|
|
5
|
+
setData: (data: unknown, cb: () => void) => void;
|
|
6
|
+
route?: string;
|
|
7
|
+
__route__: string;
|
|
8
|
+
$taroParams?: Record<string, unknown>;
|
|
9
|
+
$taroPath: string;
|
|
10
|
+
__data__: any;
|
|
11
|
+
data: any;
|
|
12
|
+
exitState?: any;
|
|
13
|
+
selectComponent: (selector: string) => any;
|
|
14
|
+
}
|
|
15
|
+
export interface MiniElementData {
|
|
16
|
+
[Shortcuts.Childnodes]?: MiniData[];
|
|
17
|
+
[Shortcuts.NodeName]: string;
|
|
18
|
+
[Shortcuts.Class]?: string;
|
|
19
|
+
[Shortcuts.Style]?: string;
|
|
20
|
+
uid?: string;
|
|
21
|
+
sid: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
interface MiniTextData {
|
|
25
|
+
[Shortcuts.Text]: string;
|
|
26
|
+
[Shortcuts.NodeName]: string;
|
|
27
|
+
}
|
|
28
|
+
export declare type MiniData = MiniElementData | MiniTextData;
|
|
29
|
+
export declare type HydratedData = () => MiniData | MiniData[];
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HydratedData } from './index';
|
|
2
|
+
export declare type UpdatePayloadValue = string | boolean | HydratedData;
|
|
3
|
+
export declare type DataTree = Record<string, UpdatePayloadValue | ReturnType<HydratedData>>;
|
|
4
|
+
export interface UpdatePayload {
|
|
5
|
+
path: string;
|
|
6
|
+
value: UpdatePayloadValue;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TaroElement } from '../dom/element';
|
|
2
|
+
import type { TaroText } from '../dom/text';
|
|
3
|
+
import type { Element, Text } from '../dom-external/inner-html/parser';
|
|
4
|
+
export interface Options {
|
|
5
|
+
prerender: boolean;
|
|
6
|
+
debug: boolean;
|
|
7
|
+
html?: {
|
|
8
|
+
skipElements: Set<string>;
|
|
9
|
+
voidElements: Set<string>;
|
|
10
|
+
closingElements: Set<string>;
|
|
11
|
+
transformText?: (taroText: TaroText, text: Text) => TaroText;
|
|
12
|
+
transformElement?: (taroElement: TaroElement, element: Element) => TaroElement;
|
|
13
|
+
renderHTMLTag: boolean;
|
|
14
|
+
};
|
|
15
|
+
miniGlobal?: any;
|
|
16
|
+
}
|
package/dist/perf.d.ts
ADDED
package/dist/runtime.esm.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ interface UpdatePayload {
|
|
|
69
69
|
}
|
|
70
70
|
// Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
|
|
71
71
|
declare class TaroEvent {
|
|
72
|
+
private cacheTarget;
|
|
73
|
+
private cacheCurrentTarget;
|
|
72
74
|
type: string;
|
|
73
75
|
bubbles: boolean;
|
|
74
76
|
cancelable: boolean;
|
|
@@ -316,13 +318,13 @@ declare class TaroElement extends TaroNode {
|
|
|
316
318
|
static extend(methodName: string, options: Func | Record<string, any>): void;
|
|
317
319
|
}
|
|
318
320
|
declare function getComputedStyle(element: TaroElement): Style;
|
|
319
|
-
declare const
|
|
321
|
+
declare const nav: any;
|
|
320
322
|
// https://github.com/myrne/performance-now
|
|
321
323
|
declare let now: () => number;
|
|
322
324
|
// https://gist.github.com/paulirish/1579671
|
|
323
325
|
// https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
|
|
324
|
-
declare const
|
|
325
|
-
declare const
|
|
326
|
+
declare const _raf: typeof requestAnimationFrame | ((callback: any) => NodeJS.Timeout);
|
|
327
|
+
declare const _caf: typeof cancelAnimationFrame;
|
|
326
328
|
declare let window: any;
|
|
327
329
|
// for Vue3
|
|
328
330
|
declare class SVGElement extends TaroElement {
|
|
@@ -411,7 +413,7 @@ declare class MutationObserver {
|
|
|
411
413
|
takeRecords(): MutationRecord[];
|
|
412
414
|
static record(record: MutationRecord): void;
|
|
413
415
|
}
|
|
414
|
-
interface Instance<T
|
|
416
|
+
interface Instance<T> extends Component<T>, Show, PageInstance {
|
|
415
417
|
tid?: string;
|
|
416
418
|
$forceUpdate?(): void;
|
|
417
419
|
$nextTick?(cb: () => void): void;
|
|
@@ -420,7 +422,7 @@ interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInst
|
|
|
420
422
|
interface VueAppInstance extends ComponentOptions<VueCtor> {
|
|
421
423
|
$options: AppInstance;
|
|
422
424
|
}
|
|
423
|
-
type VueInstance<M
|
|
425
|
+
type VueInstance<M, P> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
|
|
424
426
|
interface VueInternal {
|
|
425
427
|
_render(): VNode;
|
|
426
428
|
_update(vnode: VNode, hyrate: boolean): void;
|
|
@@ -428,41 +430,41 @@ interface VueInternal {
|
|
|
428
430
|
interface PageProps {
|
|
429
431
|
tid?: string;
|
|
430
432
|
}
|
|
431
|
-
interface ReactPageComponent<T
|
|
433
|
+
interface ReactPageComponent<T> extends ComponentClass<T>, PageInstance {
|
|
432
434
|
}
|
|
433
|
-
interface ReactPageInstance<T
|
|
435
|
+
interface ReactPageInstance<T> extends Component<T>, PageInstance {
|
|
434
436
|
componentDidShow?(): void;
|
|
435
437
|
componentDidHide?(): void;
|
|
436
438
|
}
|
|
437
|
-
interface ReactAppInstance<T
|
|
439
|
+
interface ReactAppInstance<T> extends Component<T>, AppInstance {
|
|
438
440
|
}
|
|
439
441
|
interface PageLifeCycle extends Show {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
eh?(event: MpEvent): void;
|
|
443
|
+
onAddToFavorites?(): void;
|
|
444
|
+
onLoad?(options: Record<string, unknown>, cb?: Func): void;
|
|
445
|
+
onOptionMenuClick?(): void;
|
|
442
446
|
onPageScroll?(obj: {
|
|
443
447
|
scrollTop: number;
|
|
444
448
|
}): void;
|
|
449
|
+
onPullDownRefresh?(): void;
|
|
450
|
+
onPullIntercept?(): void;
|
|
451
|
+
onPopMenuClick?(): void;
|
|
452
|
+
onReachBottom?(): void;
|
|
453
|
+
onReady?(): void;
|
|
454
|
+
onResize?(options: unknown): void;
|
|
455
|
+
onSaveExitState?(): void;
|
|
445
456
|
onShareAppMessage?(obj: {
|
|
446
457
|
from: string;
|
|
447
458
|
target?: TaroElement;
|
|
448
459
|
webViewUrl: string;
|
|
449
460
|
}): void;
|
|
450
|
-
|
|
461
|
+
onShareTimeline?(): void;
|
|
451
462
|
onTabItemTap?(obj: {
|
|
452
463
|
index: string;
|
|
453
464
|
pagePath: string;
|
|
454
465
|
text: string;
|
|
455
466
|
}): void;
|
|
456
467
|
onTitleClick?(): void;
|
|
457
|
-
onOptionMenuClick?(): void;
|
|
458
|
-
onPopMenuClick?(): void;
|
|
459
|
-
onReady?(): void;
|
|
460
|
-
onPullIntercept?(): void;
|
|
461
|
-
onShareTimeline?(): void;
|
|
462
|
-
onAddToFavorites?(): void;
|
|
463
|
-
onSaveExitState?(): void;
|
|
464
|
-
eh?(event: MpEvent): void;
|
|
465
|
-
onLoad?(options: Record<string, unknown>, cb?: Func): void;
|
|
466
468
|
onUnload?(): void;
|
|
467
469
|
}
|
|
468
470
|
interface PageInstance extends PageLifeCycle {
|
|
@@ -480,15 +482,13 @@ interface Show {
|
|
|
480
482
|
onHide?(): void;
|
|
481
483
|
}
|
|
482
484
|
interface AppInstance extends Show {
|
|
483
|
-
onLaunch?(options?: Record<string, unknown>): void;
|
|
484
|
-
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
|
|
485
|
-
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: () => void): void;
|
|
486
485
|
componentDidShow?(options?: Record<string, unknown>): void;
|
|
487
|
-
|
|
488
|
-
unmount?(id: string): void;
|
|
489
|
-
unmount?(id: string, cb: () => void): void;
|
|
486
|
+
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
|
|
490
487
|
onError?(error: string): void;
|
|
488
|
+
onLaunch?(options?: Record<string, unknown>): void;
|
|
491
489
|
onPageNotFound?(res: any): void;
|
|
490
|
+
onShow?(options?: Record<string, unknown>): void;
|
|
491
|
+
unmount?(id: string, cb?: () => void): void;
|
|
492
492
|
taroGlobalData?: Record<any, any>;
|
|
493
493
|
}
|
|
494
494
|
interface Router {
|
|
@@ -530,8 +530,8 @@ type EventsType = typeof Events;
|
|
|
530
530
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
531
531
|
*/
|
|
532
532
|
declare function hydrate(node: TaroElement | TaroText): MiniData;
|
|
533
|
-
declare const nextTick: (cb: Func, ctx?: Record<string, any>
|
|
533
|
+
declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
|
|
534
534
|
declare const options: Options;
|
|
535
535
|
declare const incrementId: () => () => string;
|
|
536
536
|
export { hooks } from '@tarojs/shared';
|
|
537
|
-
export { document, getComputedStyle, navigator,
|
|
537
|
+
export { document, getComputedStyle, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options, Func, Ctx };
|