@tarojs/runtime 3.5.0-canary.0 → 3.5.0-canary.1
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/dom/event-source.d.ts +6 -1
- package/dist/dom/node.d.ts +41 -3
- package/dist/dom-external/mutation-observer/implements.d.ts +52 -0
- package/dist/dom-external/mutation-observer/index.d.ts +12 -0
- package/dist/dom-external/mutation-observer/record.d.ts +24 -0
- package/dist/dsl/common.d.ts +1 -22
- package/dist/dsl/instance.d.ts +10 -8
- package/dist/index.d.ts +2 -0
- package/dist/interface/hydrate.d.ts +2 -1
- package/dist/runtime.esm.js +413 -122
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +4 -4
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { TaroNode } from './node';
|
|
2
|
-
|
|
2
|
+
interface IEventSource extends Map<string | undefined | null, TaroNode> {
|
|
3
|
+
removeNode(child: TaroNode): void;
|
|
4
|
+
removeNodeTree(child: TaroNode): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const eventSource: IEventSource;
|
|
7
|
+
export {};
|
package/dist/dom/node.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ import type { UpdatePayload } from '../interface';
|
|
|
4
4
|
import type { TaroDocument } from './document';
|
|
5
5
|
import type { TaroRootElement } from './root';
|
|
6
6
|
import type { TaroElement } from './element';
|
|
7
|
+
interface RemoveChildOptions {
|
|
8
|
+
cleanRef?: boolean;
|
|
9
|
+
doUpdate?: boolean;
|
|
10
|
+
}
|
|
7
11
|
export declare class TaroNode extends TaroEventTarget {
|
|
8
12
|
uid: string;
|
|
13
|
+
sid: string;
|
|
9
14
|
nodeType: NodeType;
|
|
10
15
|
nodeName: string;
|
|
11
16
|
parentNode: TaroNode | null;
|
|
@@ -17,6 +22,7 @@ export declare class TaroNode extends TaroEventTarget {
|
|
|
17
22
|
* like jQuery's $.empty()
|
|
18
23
|
*/
|
|
19
24
|
private _empty;
|
|
25
|
+
private updateChildNodes;
|
|
20
26
|
protected get _root(): TaroRootElement | null;
|
|
21
27
|
protected findIndex(refChild: TaroNode): number;
|
|
22
28
|
get _path(): string;
|
|
@@ -30,12 +36,44 @@ export declare class TaroNode extends TaroEventTarget {
|
|
|
30
36
|
* @TODO 等待完整 innerHTML 实现
|
|
31
37
|
*/
|
|
32
38
|
set textContent(text: string);
|
|
39
|
+
/**
|
|
40
|
+
* @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
|
|
41
|
+
* @scenario
|
|
42
|
+
* [A,B,C]
|
|
43
|
+
* 1. insert D before C, D has no parent
|
|
44
|
+
* 2. insert D before C, D has the same parent of C
|
|
45
|
+
* 3. insert D before C, D has the different parent of C
|
|
46
|
+
*/
|
|
33
47
|
insertBefore<T extends TaroNode>(newChild: T, refChild?: TaroNode | null, isReplace?: boolean): T;
|
|
34
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/appendChild
|
|
50
|
+
* @scenario
|
|
51
|
+
* [A,B,C]
|
|
52
|
+
* 1. append C, C has no parent
|
|
53
|
+
* 2. append C, C has the same parent of B
|
|
54
|
+
* 3. append C, C has the different parent of B
|
|
55
|
+
*/
|
|
56
|
+
appendChild(newChild: TaroNode): TaroNode;
|
|
57
|
+
/**
|
|
58
|
+
* @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
|
|
59
|
+
* @scenario
|
|
60
|
+
* [A,B,C]
|
|
61
|
+
* 1. replace B with C, C has no parent
|
|
62
|
+
* 2. replace B with C, C has no parent, C has the same parent of B
|
|
63
|
+
* 3. replace B with C, C has no parent, C has the different parent of B
|
|
64
|
+
*/
|
|
35
65
|
replaceChild(newChild: TaroNode, oldChild: TaroNode): TaroNode | undefined;
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/removeChild
|
|
68
|
+
* @scenario
|
|
69
|
+
* [A,B,C]
|
|
70
|
+
* 1. remove A or B
|
|
71
|
+
* 2. remove C
|
|
72
|
+
*/
|
|
73
|
+
removeChild<T extends TaroNode>(child: T, options?: RemoveChildOptions): T;
|
|
74
|
+
remove(options?: RemoveChildOptions): void;
|
|
38
75
|
hasChildNodes(): boolean;
|
|
39
76
|
enqueueUpdate(payload: UpdatePayload): void;
|
|
40
77
|
get ownerDocument(): TaroDocument;
|
|
41
78
|
}
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { TaroNode } from '../../dom/node';
|
|
2
|
+
import type { MutationRecord } from './record';
|
|
3
|
+
export declare type MutationCallback = (mutations: MutationRecord[]) => any;
|
|
4
|
+
/**
|
|
5
|
+
* @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit
|
|
6
|
+
*/
|
|
7
|
+
export interface MutationObserverInit {
|
|
8
|
+
attributeFilter?: string[];
|
|
9
|
+
attributeOldValue?: boolean;
|
|
10
|
+
attributes?: boolean;
|
|
11
|
+
characterData?: boolean;
|
|
12
|
+
characterDataOldValue?: boolean;
|
|
13
|
+
childList?: boolean;
|
|
14
|
+
subtree?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The MutationObserver provides the ability
|
|
18
|
+
* to watch for changes being made to the DOM tree.
|
|
19
|
+
* It will invoke a specified callback function
|
|
20
|
+
* when DOM changes occur.
|
|
21
|
+
* @see https://dom.spec.whatwg.org/#mutationobserver
|
|
22
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
23
|
+
*/
|
|
24
|
+
export declare class MutationObserverImpl {
|
|
25
|
+
callback: MutationCallback;
|
|
26
|
+
target: TaroNode | null;
|
|
27
|
+
options: MutationObserverInit;
|
|
28
|
+
records: MutationRecord[];
|
|
29
|
+
constructor(callback: MutationCallback);
|
|
30
|
+
/**
|
|
31
|
+
* Configures the MutationObserver
|
|
32
|
+
* to begin receiving notifications
|
|
33
|
+
* through its callback function
|
|
34
|
+
* when DOM changes matching the given options occur.
|
|
35
|
+
*
|
|
36
|
+
* Options matching is to be implemented.
|
|
37
|
+
*/
|
|
38
|
+
observe(target: TaroNode, options?: MutationObserverInit): void;
|
|
39
|
+
/**
|
|
40
|
+
* Stop the MutationObserver instance
|
|
41
|
+
* from receiving further notifications
|
|
42
|
+
* until and unless observe() is called again.
|
|
43
|
+
*/
|
|
44
|
+
disconnect(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes all pending notifications
|
|
47
|
+
* from the MutationObserver's notification queue
|
|
48
|
+
* and returns them in a new Array of MutationRecord objects.
|
|
49
|
+
*/
|
|
50
|
+
takeRecords(): MutationRecord[];
|
|
51
|
+
}
|
|
52
|
+
export declare function recordMutation(record: MutationRecord): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MutationObserverImpl } from './implements';
|
|
2
|
+
import { MutationRecord } from './record';
|
|
3
|
+
import type { MutationCallback, MutationObserverInit } from './implements';
|
|
4
|
+
import type { TaroNode } from '../../dom/node';
|
|
5
|
+
export declare class MutationObserver {
|
|
6
|
+
core: Pick<MutationObserverImpl, 'observe' | 'disconnect' | 'takeRecords'>;
|
|
7
|
+
constructor(callback: MutationCallback);
|
|
8
|
+
observe(...args: [TaroNode, MutationObserverInit?]): void;
|
|
9
|
+
disconnect(): void;
|
|
10
|
+
takeRecords(): MutationRecord[];
|
|
11
|
+
static record(record: MutationRecord): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TaroNode } from '../../dom/node';
|
|
2
|
+
/**
|
|
3
|
+
* A MutationRecord represents an individual DOM mutation.
|
|
4
|
+
* It is the object that is passed to MutationObserver's callback.
|
|
5
|
+
* @see https://dom.spec.whatwg.org/#interface-mutationrecord
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord
|
|
7
|
+
*/
|
|
8
|
+
export interface MutationRecord {
|
|
9
|
+
readonly target: TaroNode;
|
|
10
|
+
readonly addedNodes?: TaroNode[];
|
|
11
|
+
readonly removedNodes?: TaroNode[];
|
|
12
|
+
readonly previousSibling?: TaroNode | null;
|
|
13
|
+
readonly nextSibling?: TaroNode | null;
|
|
14
|
+
readonly attributeName?: string | null;
|
|
15
|
+
readonly attributeNamespace?: string | null;
|
|
16
|
+
oldValue?: string | null;
|
|
17
|
+
readonly type: MutationRecordType;
|
|
18
|
+
readonly value?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const enum MutationRecordType {
|
|
21
|
+
ATTRIBUTES = "attributes",
|
|
22
|
+
CHARACTER_DATA = "characterData",
|
|
23
|
+
CHILD_LIST = "childList"
|
|
24
|
+
}
|
package/dist/dsl/common.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { eventHandler } from '../dom/event';
|
|
3
2
|
import type { PageConfig } from '@tarojs/taro';
|
|
4
3
|
import type { Instance, PageInstance, PageProps } from './instance';
|
|
5
4
|
export declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
|
|
@@ -13,24 +12,4 @@ export declare function getOnShowEventKey(path: string): string;
|
|
|
13
12
|
export declare function getOnHideEventKey(path: string): string;
|
|
14
13
|
export declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
|
|
15
14
|
export declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
|
|
16
|
-
export declare function createRecursiveComponentConfig(componentName?: string):
|
|
17
|
-
properties: {
|
|
18
|
-
i: {
|
|
19
|
-
type: ObjectConstructor;
|
|
20
|
-
value: {
|
|
21
|
-
nn: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
l: {
|
|
25
|
-
type: StringConstructor;
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
options: {
|
|
30
|
-
addGlobalClass: boolean;
|
|
31
|
-
virtualHost: boolean;
|
|
32
|
-
};
|
|
33
|
-
methods: {
|
|
34
|
-
eh: typeof eventHandler;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
15
|
+
export declare function createRecursiveComponentConfig(componentName?: string): any;
|
package/dist/dsl/instance.d.ts
CHANGED
|
@@ -21,13 +21,13 @@ interface VueInternal {
|
|
|
21
21
|
export interface PageProps {
|
|
22
22
|
tid?: string;
|
|
23
23
|
}
|
|
24
|
-
export interface ReactPageComponent<T = PageProps> extends ComponentClass<T>,
|
|
24
|
+
export interface ReactPageComponent<T = PageProps> extends ComponentClass<T>, PageInstance {
|
|
25
25
|
}
|
|
26
|
-
export interface ReactPageInstance<T = PageProps> extends Component<T>,
|
|
26
|
+
export interface ReactPageInstance<T = PageProps> extends Component<T>, PageInstance {
|
|
27
27
|
componentDidShow?(): void;
|
|
28
28
|
componentDidHide?(): void;
|
|
29
29
|
}
|
|
30
|
-
export interface ReactAppInstance<T = AppInstance> extends Component<T>,
|
|
30
|
+
export interface ReactAppInstance<T = AppInstance> extends Component<T>, AppInstance {
|
|
31
31
|
}
|
|
32
32
|
export interface PageLifeCycle extends Show {
|
|
33
33
|
onPullDownRefresh?(): void;
|
|
@@ -63,15 +63,17 @@ export interface PageInstance extends PageLifeCycle {
|
|
|
63
63
|
options?: Record<string, unknown>;
|
|
64
64
|
}
|
|
65
65
|
interface Show {
|
|
66
|
-
componentDidShow?(
|
|
67
|
-
componentDidHide?(
|
|
68
|
-
onShow?(
|
|
69
|
-
onHide?(
|
|
66
|
+
componentDidShow?(): void;
|
|
67
|
+
componentDidHide?(): void;
|
|
68
|
+
onShow?(): void;
|
|
69
|
+
onHide?(): void;
|
|
70
70
|
}
|
|
71
71
|
export interface AppInstance extends Show {
|
|
72
|
-
onLaunch?(options?: string): void;
|
|
72
|
+
onLaunch?(options?: Record<string, unknown>): void;
|
|
73
73
|
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
|
|
74
74
|
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: () => void): void;
|
|
75
|
+
componentDidShow?(options?: Record<string, unknown>): void;
|
|
76
|
+
onShow?(options?: Record<string, unknown>): void;
|
|
75
77
|
unmount?(id: string): void;
|
|
76
78
|
unmount?(id: string, cb: () => void): void;
|
|
77
79
|
onPageNotFound?(res: any): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { TaroElement } from './dom/element';
|
|
|
5
5
|
export { TaroRootElement } from './dom/root';
|
|
6
6
|
export { FormElement } from './dom/form';
|
|
7
7
|
export { SVGElement } from './dom/svg';
|
|
8
|
+
export { MutationObserver } from './dom-external/mutation-observer';
|
|
8
9
|
export { TaroEvent, createEvent, eventHandler } from './dom/event';
|
|
9
10
|
export { createDocument, document } from './bom/document';
|
|
10
11
|
export { window } from './bom/window';
|
|
@@ -25,3 +26,4 @@ export { raf as requestAnimationFrame, caf as cancelAnimationFrame, now } from '
|
|
|
25
26
|
export { getComputedStyle } from './bom/getComputedStyle';
|
|
26
27
|
export * from './interface';
|
|
27
28
|
export { incrementId } from './utils';
|
|
29
|
+
export { eventSource } from './dom/event-source';
|