@tarojs/runtime 3.3.16 → 3.4.0-beta.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/bom/raf.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference types="node" />
2
1
  export declare let now: any;
3
- declare const raf: typeof requestAnimationFrame | ((callback: any) => NodeJS.Timeout);
2
+ declare const raf: typeof requestAnimationFrame;
4
3
  declare const caf: typeof cancelAnimationFrame;
5
4
  export { raf, caf };
@@ -1,18 +1 @@
1
- export declare const window: Window | {
2
- navigator: Navigator | {
3
- appCodeName: string;
4
- appName: string;
5
- appVersion: string;
6
- cookieEnabled: boolean;
7
- mimeTypes: never[];
8
- onLine: boolean;
9
- platform: string;
10
- plugins: never[];
11
- product: string;
12
- productSub: string;
13
- userAgent: string;
14
- vendor: string;
15
- vendorSub: string;
16
- };
17
- document: import("..").TaroDocumentInstance;
18
- };
1
+ export declare const window: any;
@@ -1,3 +1,32 @@
1
+ export declare const SID_TARO_ELEMENT = "0";
2
+ export declare const SID_TARO_ELEMENT_FACTORY = "1";
3
+ export declare const SID_TARO_TEXT = "2";
4
+ export declare const SID_TARO_TEXT_FACTORY = "3";
5
+ export declare const SID_TARO_NODE_IMPL = "4";
6
+ export declare const SID_TARO_ELEMENT_IMPL = "5";
7
+ export declare const SID_HOOKS = "6";
8
+ export declare const SID_ON_REMOVE_ATTRIBUTE = "7";
9
+ export declare const SID_GET_MINI_LIFECYCLE = "8";
10
+ export declare const SID_GET_LIFECYCLE = "9";
11
+ export declare const SID_GET_PATH_INDEX = "10";
12
+ export declare const SID_GET_EVENT_CENTER = "11";
13
+ export declare const SID_IS_BUBBLE_EVENTS = "12";
14
+ export declare const SID_GET_SPECIAL_NODES = "13";
15
+ export declare const SID_EVENT_CENTER = "14";
16
+ export declare const SID_MODIFY_MP_EVENT = "15";
17
+ export declare const SID_MODIFY_TARO_EVENT = "16";
18
+ export declare const SID_MODIFY_DISPATCH_EVENT = "17";
19
+ export declare const SID_BATCHED_EVENT_UPDATES = "18";
20
+ export declare const SID_MERGE_PAGE_INSTANCE = "19";
21
+ export declare const SID_CREATE_PULLDOWN_COMPONENT = "20";
22
+ export declare const SID_GET_DOM_NODE = "21";
23
+ export declare const SID_INIT_NATIVE_API = "22";
24
+ export declare const SID_MODIFY_HYDRATE_DATA = "23";
25
+ export declare const SID_MODIFY_SET_ATTR_PAYLOAD = "24";
26
+ export declare const SID_MODIFY_RM_ATTR_PAYLOAD = "25";
27
+ export declare const SID_ON_ADD_EVENT = "26";
28
+ export declare const SID_PATCH_ELEMENT = "27";
29
+ export declare const SID_MODIFY_PAGE_OBJECT = "28";
1
30
  declare const SERVICE_IDENTIFIER: {
2
31
  TaroElement: string;
3
32
  TaroElementFactory: string;
@@ -7,6 +36,7 @@ declare const SERVICE_IDENTIFIER: {
7
36
  TaroElementImpl: string;
8
37
  Hooks: string;
9
38
  onRemoveAttribute: string;
39
+ getMiniLifecycle: string;
10
40
  getLifecycle: string;
11
41
  getPathIndex: string;
12
42
  getEventCenter: string;
@@ -15,6 +45,7 @@ declare const SERVICE_IDENTIFIER: {
15
45
  eventCenter: string;
16
46
  modifyMpEvent: string;
17
47
  modifyTaroEvent: string;
48
+ modifyDispatchEvent: string;
18
49
  batchedEventUpdates: string;
19
50
  mergePageInstance: string;
20
51
  createPullDownComponent: string;
@@ -25,5 +56,6 @@ declare const SERVICE_IDENTIFIER: {
25
56
  modifyRmAttrPayload: string;
26
57
  onAddEvent: string;
27
58
  patchElement: string;
59
+ modifyPageObject: string;
28
60
  };
29
61
  export default SERVICE_IDENTIFIER;
@@ -38,3 +38,10 @@ export declare const SET_TIMEOUT = "setTimeout";
38
38
  export declare const CATCHMOVE = "catchMove";
39
39
  export declare const CATCH_VIEW = "catch-view";
40
40
  export declare const COMMENT = "comment";
41
+ export declare const ON_LOAD = "onLoad";
42
+ export declare const ON_READY = "onReady";
43
+ export declare const ON_SHOW = "onShow";
44
+ export declare const ON_HIDE = "onHide";
45
+ export declare const OPTIONS = "options";
46
+ export declare const EXTERNAL_CLASSES = "externalClasses";
47
+ export declare const BEHAVIORS = "behaviors";
@@ -1,2 +1,4 @@
1
1
  import { ContainerModule } from 'inversify';
2
+ import type { MiniLifecycle } from '../interface';
3
+ export declare const defaultMiniLifecycle: MiniLifecycle;
2
4
  export declare const DefaultHooksContainer: ContainerModule;
@@ -0,0 +1,15 @@
1
+ import { TaroDocumentInstance } from '../interface';
2
+ import type { Container } from 'inversify';
3
+ import type { IHooks, InstanceNamedFactory } from '../interface';
4
+ import type { TaroNodeImpl } from '../dom-external/node-impl';
5
+ import type { TaroElementImpl } from '../dom-external/element-impl';
6
+ interface IStore {
7
+ container: Container | null;
8
+ }
9
+ export declare const store: IStore;
10
+ export declare function getHooks(): IHooks;
11
+ export declare function getElementFactory(): InstanceNamedFactory;
12
+ export declare function getNodeImpl(): TaroNodeImpl;
13
+ export declare function getElementImpl(): TaroElementImpl;
14
+ export declare function getDocument(): TaroDocumentInstance;
15
+ export {};
@@ -1,15 +1,12 @@
1
1
  import { TaroElement } from '../dom/element';
2
- import { InstanceFactory, InstanceNamedFactory } from '../interface';
2
+ import { InstanceFactory } from '../interface';
3
3
  import type { FormElement } from '../dom/form';
4
4
  import type { TaroRootElement } from '../dom/root';
5
5
  import type { TaroText } from '../dom/text';
6
- import type { TaroNodeImpl } from '../dom-external/node-impl';
7
- import type { TaroElementImpl } from '../dom-external/element-impl';
8
- import type { Hooks } from '../hooks';
9
6
  export declare class TaroDocument extends TaroElement {
10
7
  private _getText;
11
8
  constructor(// eslint-disable-next-line @typescript-eslint/indent
12
- nodeImpl: TaroNodeImpl, getElement: InstanceNamedFactory, hooks: Hooks, elementImpl: TaroElementImpl, getText: InstanceFactory<TaroText>);
9
+ getText: InstanceFactory<TaroText>);
13
10
  createElement(type: string): TaroElement | TaroRootElement | FormElement;
14
11
  createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
15
12
  createTextNode(text: string): TaroText;
@@ -2,18 +2,14 @@ import { TaroNode } from './node';
2
2
  import { Style } from './style';
3
3
  import { ClassList } from './class-list';
4
4
  import type { TaroEvent } from './event';
5
- import type { Attributes, InstanceNamedFactory } from '../interface';
6
- import type { TaroNodeImpl } from '../dom-external/node-impl';
7
- import type { TaroElementImpl } from '../dom-external/element-impl';
8
- import type { Hooks } from '../hooks';
5
+ import type { Attributes } from '../interface';
9
6
  export declare class TaroElement extends TaroNode {
10
7
  tagName: string;
11
8
  props: Record<string, any>;
12
9
  style: Style;
13
10
  dataset: Record<string, unknown>;
14
11
  innerHTML: string;
15
- constructor(// eslint-disable-next-line @typescript-eslint/indent
16
- nodeImpl: TaroNodeImpl, getElement: InstanceNamedFactory, hooks: Hooks, elementImpl: TaroElementImpl);
12
+ constructor();
17
13
  private _stopPropagation;
18
14
  get id(): string;
19
15
  set id(val: string);
@@ -1,2 +1,7 @@
1
1
  import type { TaroNode } from './node';
2
- export declare const eventSource: Map<string | null | undefined, TaroNode>;
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 {};
@@ -2,8 +2,7 @@ import type { EventHandler, AddEventListenerOptions, IHooks } from '../interface
2
2
  export declare class TaroEventTarget {
3
3
  __handlers: Record<string, EventHandler[]>;
4
4
  hooks: IHooks;
5
- constructor(// eslint-disable-next-line @typescript-eslint/indent
6
- hooks: IHooks);
5
+ constructor();
7
6
  addEventListener(type: string, handler: EventHandler, options?: boolean | AddEventListenerOptions): void;
8
7
  removeEventListener(type: string, handler: EventHandler): void;
9
8
  isAnyEventBinded(): boolean;
@@ -1,25 +1,28 @@
1
1
  import { NodeType } from './node_types';
2
2
  import { TaroEventTarget } from './event-target';
3
- import type { UpdatePayload, InstanceNamedFactory } from '../interface';
3
+ 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
- import type { TaroNodeImpl } from '../dom-external/node-impl';
8
- import type { Hooks } from '../hooks';
7
+ interface RemoveChildOptions {
8
+ cleanRef?: boolean;
9
+ doUpdate?: boolean;
10
+ }
9
11
  export declare class TaroNode extends TaroEventTarget {
10
12
  uid: string;
13
+ sid: string;
11
14
  nodeType: NodeType;
12
15
  nodeName: string;
13
16
  parentNode: TaroNode | null;
14
17
  childNodes: TaroNode[];
15
- protected _getElement: InstanceNamedFactory;
16
- constructor(// eslint-disable-next-line @typescript-eslint/indent
17
- impl: TaroNodeImpl, getElement: InstanceNamedFactory, hooks: Hooks);
18
+ protected _getElement: import("../interface").InstanceNamedFactory;
19
+ constructor();
18
20
  private hydrate;
19
21
  /**
20
22
  * like jQuery's $.empty()
21
23
  */
22
24
  private _empty;
25
+ private updateChildNodes;
23
26
  protected get _root(): TaroRootElement | null;
24
27
  protected findIndex(refChild: TaroNode): number;
25
28
  get _path(): string;
@@ -33,15 +36,44 @@ export declare class TaroNode extends TaroEventTarget {
33
36
  * @TODO 等待完整 innerHTML 实现
34
37
  */
35
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
+ */
36
47
  insertBefore<T extends TaroNode>(newChild: T, refChild?: TaroNode | null, isReplace?: boolean): T;
37
- appendChild(child: TaroNode): void;
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
+ */
38
65
  replaceChild(newChild: TaroNode, oldChild: TaroNode): TaroNode | undefined;
39
- removeChild<T extends TaroNode>(child: T, isReplace?: boolean): T;
40
- remove(isReplace?: boolean): void;
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;
41
75
  hasChildNodes(): boolean;
42
76
  enqueueUpdate(payload: UpdatePayload): void;
43
- contains(node: TaroNode & {
44
- id?: string;
45
- }): boolean;
46
77
  get ownerDocument(): TaroDocument;
47
78
  }
79
+ export {};
@@ -1,18 +1,11 @@
1
1
  import { TaroElement } from './element';
2
- import type { Func, UpdatePayload, InstanceNamedFactory, MpInstance } from '../interface';
3
- import type { TaroNodeImpl } from '../dom-external/node-impl';
4
- import type { TaroElementImpl } from '../dom-external/element-impl';
5
- import type { Hooks } from '../hooks';
6
- import type { Events } from '../emitter/emitter';
2
+ import type { Func, UpdatePayload, MpInstance } from '../interface';
7
3
  export declare class TaroRootElement extends TaroElement {
8
- private pendingFlush;
9
4
  private updatePayloads;
10
5
  private updateCallbacks;
11
- private eventCenter;
12
6
  pendingUpdate: boolean;
13
7
  ctx: null | MpInstance;
14
- constructor(// eslint-disable-next-line @typescript-eslint/indent
15
- nodeImpl: TaroNodeImpl, getElement: InstanceNamedFactory, hooks: Hooks, elementImpl: TaroElementImpl, eventCenter: Events);
8
+ constructor();
16
9
  get _path(): string;
17
10
  protected get _root(): TaroRootElement;
18
11
  enqueueUpdate(payload: UpdatePayload): void;
@@ -1,13 +1,13 @@
1
1
  import { TaroNode } from './node';
2
- import type { TaroNodeImpl } from '../dom-external/node-impl';
3
- import type { InstanceNamedFactory } from '../interface';
4
- import type { Hooks } from '../hooks';
2
+ import { NodeType } from './node_types';
5
3
  export declare class TaroText extends TaroNode {
6
4
  _value: string;
7
- constructor(// eslint-disable-next-line @typescript-eslint/indent
8
- nodeImpl: TaroNodeImpl, getElement: InstanceNamedFactory, hooks: Hooks);
5
+ nodeType: NodeType;
6
+ nodeName: string;
9
7
  set textContent(text: string);
10
8
  get textContent(): string;
11
9
  set nodeValue(text: string);
12
10
  get nodeValue(): string;
11
+ set data(text: string);
12
+ get data(): string;
13
13
  }
@@ -1,3 +1,4 @@
1
1
  import type { Ctx } from '../interface';
2
- export declare function getBoundingClientRectImpl(): Promise<null>;
2
+ import type { TaroElement } from 'src/dom/element';
3
+ export declare function getBoundingClientRectImpl(this: TaroElement): Promise<null>;
3
4
  export declare function getTemplateContent(ctx: Ctx): string | undefined;
@@ -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
+ }
@@ -1,9 +1,12 @@
1
1
  import { GetDoc } from '../interface';
2
- import type { Ctx } from '../interface';
2
+ import type { TaroNode } from 'src/dom/node';
3
3
  export declare type IPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';
4
4
  /**
5
5
  * An implementation of `Element.insertAdjacentHTML()`
6
6
  * to support Vue 3 with a version of or greater than `vue@3.1.2`
7
7
  */
8
- export declare function insertAdjacentHTMLImpl(position: IPosition, html: string, getDoc: GetDoc): void;
9
- export declare function cloneNode(ctx: Ctx, getDoc: any, isDeep?: boolean): any;
8
+ export declare function insertAdjacentHTMLImpl(this: TaroNode, getDoc: GetDoc, position: IPosition, html: string): void;
9
+ export declare function cloneNode(this: TaroNode, getDoc: any, isDeep?: boolean): any;
10
+ export declare function contains(this: TaroNode, node: TaroNode & {
11
+ id?: string;
12
+ }): boolean;
@@ -5,7 +5,7 @@ import type { Instance, PageInstance, PageProps } from './instance';
5
5
  export declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
6
6
  export declare function getPageInstance(id: string): Instance | undefined;
7
7
  export declare function addLeadingSlash(path?: string): string;
8
- export declare function safeExecute(path: string, lifecycle: keyof PageInstance, ...args: unknown[]): any;
8
+ export declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
9
9
  export declare function stringify(obj?: Record<string, unknown>): string;
10
10
  export declare function getPath(id: string, options?: Record<string, unknown>): string;
11
11
  export declare function getOnReadyEventKey(path: string): string;
@@ -54,8 +54,8 @@ export interface PageLifeCycle extends Show {
54
54
  onShareTimeline?(): void;
55
55
  onAddToFavorites?(): void;
56
56
  eh?(event: MpEvent): void;
57
- onLoad(options: Record<string, unknown>, cb?: Func): void;
58
- onUnload(): void;
57
+ onLoad?(options: Record<string, unknown>, cb?: Func): void;
58
+ onUnload?(): void;
59
59
  }
60
60
  export interface PageInstance extends PageLifeCycle {
61
61
  data?: Record<string, unknown>;
package/dist/env.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export declare const isBrowser: boolean;
2
1
  export declare const doc: Document;
3
2
  export declare const win: Window;
package/dist/hooks.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import type { IHooks, OnRemoveAttribute, GetLifecycle, GetPathIndex, GetEventCenter, IsBubbleEvents, GetSpecialNodes, BatchedEventUpdates, MergePageInstance, CreatePullDownComponent, GetDOMNode, InitNativeApi, ModifySetAttrPayload, ModifyHydrateData, ModifyRmAttrPayload, MpEvent, OnAddEvent, patchElement } from './interface';
2
1
  import type { TaroElement } from './dom/element';
3
2
  import type { TaroEvent } from './dom/event';
3
+ import type { IHooks, OnRemoveAttribute, GetMiniLifecycle, GetLifecycle, GetPathIndex, GetEventCenter, ModifyMpEvent, ModifyTaroEvent, ModifyDispatchEvent, IsBubbleEvents, GetSpecialNodes, BatchedEventUpdates, MergePageInstance, CreatePullDownComponent, GetDOMNode, InitNativeApi, ModifySetAttrPayload, ModifyHydrateData, ModifyRmAttrPayload, MpEvent, OnAddEvent, PatchElement, ModifyPageObject } from './interface';
4
4
  export declare class Hooks implements IHooks {
5
+ getMiniLifecycle: GetMiniLifecycle;
6
+ getMiniLifecycleImpl(): import("./interface").MiniLifecycle;
5
7
  getLifecycle: GetLifecycle;
6
8
  getPathIndex: GetPathIndex;
7
9
  getEventCenter: GetEventCenter;
@@ -10,18 +12,21 @@ export declare class Hooks implements IHooks {
10
12
  onRemoveAttribute?: OnRemoveAttribute;
11
13
  batchedEventUpdates?: BatchedEventUpdates;
12
14
  mergePageInstance?: MergePageInstance;
15
+ modifyPageObject?: ModifyPageObject;
13
16
  createPullDownComponent?: CreatePullDownComponent;
14
17
  getDOMNode?: GetDOMNode;
15
18
  modifyHydrateData?: ModifyHydrateData;
16
19
  modifySetAttrPayload?: ModifySetAttrPayload;
17
20
  modifyRmAttrPayload?: ModifyRmAttrPayload;
18
21
  onAddEvent?: OnAddEvent;
19
- private modifyMpEventImpls?;
22
+ modifyMpEventImpls?: ModifyMpEvent[];
20
23
  modifyMpEvent(e: MpEvent): void;
21
- private modifyTaroEventImpls?;
24
+ modifyTaroEventImpls?: ModifyTaroEvent[];
22
25
  modifyTaroEvent(e: TaroEvent, element: TaroElement): void;
26
+ modifyDispatchEventImpls?: ModifyDispatchEvent[];
27
+ modifyDispatchEvent(e: TaroEvent, element: TaroElement): void;
23
28
  initNativeApiImpls?: InitNativeApi[];
24
29
  initNativeApi(taro: Record<string, any>): void;
25
- patchElementImpls?: patchElement[];
30
+ patchElementImpls?: PatchElement[];
26
31
  patchElement(element: TaroElement): void;
27
32
  }
package/dist/index.d.ts CHANGED
@@ -5,21 +5,19 @@ 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 { TaroEvent, createEvent } from './dom/event';
8
+ export { MutationObserver } from './dom-external/mutation-observer';
9
+ export { TaroEvent, createEvent, eventHandler } from './dom/event';
9
10
  export { createDocument, document } from './bom/document';
10
11
  export { window } from './bom/window';
11
12
  export { navigator } from './bom/navigator';
12
13
  export { default as container } from './container';
13
14
  export { default as processPluginHooks } from './container/plugin-hooks';
14
15
  export { default as SERVICE_IDENTIFIER } from './constants/identifiers';
15
- export { connectReactPage, createReactApp, createNativeComponentConfig } from './dsl/react';
16
- export { connectVuePage, createVueApp } from './dsl/vue';
17
- export { createVue3App } from './dsl/vue3';
16
+ export { addLeadingSlash, safeExecute } from './dsl/common';
18
17
  export * from './dsl/instance';
19
- export { createPageConfig, injectPageInstance, createComponentConfig, createRecursiveComponentConfig, stringify } from './dsl/common';
18
+ export { createPageConfig, injectPageInstance, createComponentConfig, createRecursiveComponentConfig, stringify, getPageInstance } from './dsl/common';
20
19
  export { Current, getCurrentInstance } from './current';
21
20
  export { Style } from './dom/style';
22
- export * from './dsl/hooks';
23
21
  export { options } from './options';
24
22
  export { nextTick } from './next-tick';
25
23
  export { hydrate } from './hydrate';
@@ -27,3 +25,5 @@ export * from './emitter/emitter';
27
25
  export { raf as requestAnimationFrame, caf as cancelAnimationFrame, now } from './bom/raf';
28
26
  export { getComputedStyle } from './bom/getComputedStyle';
29
27
  export * from './interface';
28
+ export { incrementId } from './utils';
29
+ export { eventSource } from './dom/event-source';
@@ -10,4 +10,5 @@ export interface TaroDocumentInstance extends TaroDocument {
10
10
  head: TaroElement;
11
11
  body: TaroElement;
12
12
  createEvent: typeof createEvent;
13
+ defaultView: any;
13
14
  }
@@ -4,6 +4,24 @@ import type { Func, MpEvent, EventHandler, UpdatePayload } from '../interface';
4
4
  import type { EventsType } from '../emitter/emitter';
5
5
  import type { TaroEvent } from '../dom/event';
6
6
  import type { TaroEventTarget } from '../dom/event-target';
7
+ export interface MiniLifecycle {
8
+ app: [
9
+ string,
10
+ string,
11
+ string /** onHide */
12
+ ];
13
+ page: [
14
+ string,
15
+ string,
16
+ string,
17
+ string,
18
+ string,
19
+ string[] /** others */
20
+ ];
21
+ }
22
+ export interface GetMiniLifecycle {
23
+ (defaultConfig: MiniLifecycle): MiniLifecycle;
24
+ }
7
25
  export interface GetLifecycle<Instance = any> {
8
26
  (instance: Instance, lifecyle: keyof PageInstance): Func | Array<Func> | undefined;
9
27
  }
@@ -28,6 +46,9 @@ export interface ModifyMpEvent {
28
46
  export interface ModifyTaroEvent {
29
47
  (event: TaroEvent, element: TaroElement): void;
30
48
  }
49
+ export interface ModifyDispatchEvent {
50
+ (event: TaroEvent, element: TaroElement): void;
51
+ }
31
52
  export interface BatchedEventUpdates {
32
53
  (cb: Func): void;
33
54
  }
@@ -56,10 +77,16 @@ export interface ModifyRmAttrPayload {
56
77
  export interface OnAddEvent<T extends TaroEventTarget = TaroEventTarget> {
57
78
  (type: string, handler: EventHandler, options: any, node: T): void;
58
79
  }
59
- export interface patchElement {
80
+ export interface PatchElement {
60
81
  (node: TaroElement): void;
61
82
  }
83
+ export interface ModifyPageObject {
84
+ (config: Record<any, any>): void;
85
+ }
62
86
  export interface IHooks {
87
+ /** 小程序端 App、Page 构造对象的生命周期方法名称 */
88
+ getMiniLifecycle: GetMiniLifecycle;
89
+ getMiniLifecycleImpl: () => MiniLifecycle;
63
90
  /** 解决 React 生命周期名称的兼容问题 */
64
91
  getLifecycle: GetLifecycle;
65
92
  /** 解决百度小程序的模版语法问题 */
@@ -74,16 +101,27 @@ export interface IHooks {
74
101
  * @multi-inject
75
102
  * 用于修改小程序原生事件对象
76
103
  **/
104
+ modifyMpEventImpls?: ModifyMpEvent[];
77
105
  modifyMpEvent: ModifyMpEvent;
78
106
  /**
79
107
  * @multi-inject
80
108
  * 用于修改 Taro DOM 事件对象
81
109
  **/
110
+ modifyTaroEventImpls?: ModifyTaroEvent[];
82
111
  modifyTaroEvent: ModifyTaroEvent;
112
+ /**
113
+ * @multi-inject
114
+ * 用于修改触发回调前的 Taro DOM 事件对象
115
+ * 比 modifyTaroEvent 稍晚,为了可以在 el.__handlers[event.type] 取得回调函数后再修改事件对象
116
+ **/
117
+ modifyDispatchEventImpls?: ModifyDispatchEvent[];
118
+ modifyDispatchEvent: ModifyDispatchEvent;
83
119
  /** 用于把 React 同一事件回调中的所有 setState 合并到同一个更新处理中 */
84
120
  batchedEventUpdates?: BatchedEventUpdates;
85
121
  /** 用于处理 React 中的小程序生命周期 hooks */
86
122
  mergePageInstance?: MergePageInstance;
123
+ /** 用于修改传递给小程序 Page 构造器的对象 */
124
+ modifyPageObject?: ModifyPageObject;
87
125
  /** H5 下拉刷新 wrapper */
88
126
  createPullDownComponent?: CreatePullDownComponent;
89
127
  /** H5 获取原生 DOM 对象 */
@@ -92,6 +130,7 @@ export interface IHooks {
92
130
  * @multi-inject
93
131
  * 挂载属性或 API 到 Taro 对象上
94
132
  **/
133
+ initNativeApiImpls?: InitNativeApi[];
95
134
  initNativeApi?: InitNativeApi;
96
135
  /**
97
136
  * @todo: mutiInject
@@ -117,6 +156,7 @@ export interface IHooks {
117
156
  * @todo: mutiInject
118
157
  * 给 TaroElement 实例注入属性或方法
119
158
  **/
120
- patchElement?: patchElement;
159
+ patchElementImpls?: PatchElement[];
160
+ patchElement?: PatchElement;
121
161
  }
122
162
  export {};
@@ -16,7 +16,8 @@ export interface MiniElementData {
16
16
  [Shortcuts.NodeName]: string;
17
17
  [Shortcuts.Class]?: string;
18
18
  [Shortcuts.Style]?: string;
19
- uid: string;
19
+ uid?: string;
20
+ sid: string;
20
21
  [key: string]: unknown;
21
22
  }
22
23
  interface MiniTextData {