@tarojs/runtime 3.7.0-alpha.1 → 3.7.0-alpha.3

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.
Files changed (67) hide show
  1. package/dist/runtime.cjs.d.ts +710 -0
  2. package/dist/runtime.cjs.js +4491 -0
  3. package/dist/runtime.esm.d.ts +15 -8
  4. package/dist/runtime.esm.js +127 -47
  5. package/dist/runtime.esm.js.map +1 -1
  6. package/dist/runtime.h5.d.ts +710 -0
  7. package/dist/runtime.h5.js +3249 -0
  8. package/package.json +11 -6
  9. package/dist/bom/URL.d.ts +0 -61
  10. package/dist/bom/URLSearchParams.d.ts +0 -14
  11. package/dist/bom/document.d.ts +0 -2
  12. package/dist/bom/getComputedStyle.d.ts +0 -3
  13. package/dist/bom/history.d.ts +0 -29
  14. package/dist/bom/location.d.ts +0 -36
  15. package/dist/bom/navigator.d.ts +0 -1
  16. package/dist/bom/raf.d.ts +0 -5
  17. package/dist/bom/window.d.ts +0 -4
  18. package/dist/constants/index.d.ts +0 -58
  19. package/dist/current.d.ts +0 -19
  20. package/dist/dom/anchor-element.d.ts +0 -13
  21. package/dist/dom/class-list.d.ts +0 -14
  22. package/dist/dom/custom-wrapper.d.ts +0 -4
  23. package/dist/dom/document.d.ts +0 -20
  24. package/dist/dom/element.d.ts +0 -38
  25. package/dist/dom/event-source.d.ts +0 -7
  26. package/dist/dom/event-target.d.ts +0 -7
  27. package/dist/dom/event.d.ts +0 -23
  28. package/dist/dom/form.d.ts +0 -7
  29. package/dist/dom/node.d.ts +0 -75
  30. package/dist/dom/node_types.d.ts +0 -10
  31. package/dist/dom/root.d.ts +0 -15
  32. package/dist/dom/style.d.ts +0 -14
  33. package/dist/dom/style_properties.d.ts +0 -3
  34. package/dist/dom/svg.d.ts +0 -3
  35. package/dist/dom/text.d.ts +0 -14
  36. package/dist/dom/tree.d.ts +0 -4
  37. package/dist/dom-external/element.d.ts +0 -3
  38. package/dist/dom-external/index.d.ts +0 -1
  39. package/dist/dom-external/inner-html/html.d.ts +0 -2
  40. package/dist/dom-external/inner-html/parser.d.ts +0 -25
  41. package/dist/dom-external/inner-html/scaner.d.ts +0 -30
  42. package/dist/dom-external/inner-html/style.d.ts +0 -27
  43. package/dist/dom-external/inner-html/tags.d.ts +0 -8
  44. package/dist/dom-external/inner-html/utils.d.ts +0 -1
  45. package/dist/dom-external/mutation-observer/implements.d.ts +0 -52
  46. package/dist/dom-external/mutation-observer/index.d.ts +0 -13
  47. package/dist/dom-external/mutation-observer/record.d.ts +0 -24
  48. package/dist/dom-external/node.d.ts +0 -11
  49. package/dist/dsl/common.d.ts +0 -16
  50. package/dist/dsl/instance.d.ts +0 -87
  51. package/dist/emitter/emitter.d.ts +0 -4
  52. package/dist/env.d.ts +0 -7
  53. package/dist/hydrate.d.ts +0 -10
  54. package/dist/index.d.ts +0 -30
  55. package/dist/interface/element.d.ts +0 -4
  56. package/dist/interface/event-target.d.ts +0 -10
  57. package/dist/interface/event.d.ts +0 -15
  58. package/dist/interface/hydrate.d.ts +0 -30
  59. package/dist/interface/index.d.ts +0 -7
  60. package/dist/interface/node.d.ts +0 -7
  61. package/dist/interface/options.d.ts +0 -16
  62. package/dist/interface/utils.d.ts +0 -2
  63. package/dist/next-tick.d.ts +0 -2
  64. package/dist/options.d.ts +0 -2
  65. package/dist/perf.d.ts +0 -7
  66. package/dist/utils/cache.d.ts +0 -12
  67. package/dist/utils/index.d.ts +0 -23
@@ -1,27 +0,0 @@
1
- import type { ParsedTaroElement } from './parser';
2
- interface ISelector {
3
- isChild: boolean;
4
- isGeneralSibling: boolean;
5
- isAdjacentSibling: boolean;
6
- tag: string | null;
7
- id: string | null;
8
- class: string[];
9
- attrs: {
10
- all: boolean;
11
- key: string;
12
- value?: string | null;
13
- }[];
14
- }
15
- interface IStyle {
16
- content: string;
17
- selectorList: ISelector[];
18
- }
19
- export default class StyleTagParser {
20
- styles: IStyle[];
21
- extractStyle(src: string): string;
22
- stringToSelector(style: string): void;
23
- parseSelector(src: string): ISelector[];
24
- matchStyle(tagName: string, el: ParsedTaroElement, list: number[]): string;
25
- matchCurrent(tagName: string, el: ParsedTaroElement, selector: ISelector): boolean;
26
- }
27
- export {};
@@ -1,8 +0,0 @@
1
- export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;
2
- export declare const specialMiniElements: {
3
- img: string;
4
- iframe: string;
5
- };
6
- export declare const isMiniElements: (key: string) => boolean;
7
- export declare const isInlineElements: (key: string) => boolean;
8
- export declare const isBlockElements: (key: string) => boolean;
@@ -1 +0,0 @@
1
- export declare function unquote(str: string): string;
@@ -1,52 +0,0 @@
1
- import type { TaroNode } from '../../dom/node';
2
- import type { MutationRecord } from './record';
3
- export 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;
@@ -1,13 +0,0 @@
1
- import { MutationObserverImpl } from './implements';
2
- import { MutationRecord, MutationRecordType } from './record';
3
- import type { TaroNode } from '../../dom/node';
4
- import type { MutationCallback, MutationObserverInit } from './implements';
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
- }
13
- export { MutationRecordType };
@@ -1,24 +0,0 @@
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,11 +0,0 @@
1
- import type { TaroNode } from '../dom/node';
2
- export type IPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';
3
- /**
4
- * An implementation of `Element.insertAdjacentHTML()`
5
- * to support Vue 3 with a version of or greater than `vue@3.1.2`
6
- */
7
- export declare function insertAdjacentHTML(this: TaroNode, position: IPosition, html: string): void;
8
- export declare function cloneNode(this: TaroNode, isDeep?: boolean): any;
9
- export declare function contains(this: TaroNode, node: TaroNode & {
10
- id?: string;
11
- }): boolean;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import type { PageConfig } from '@tarojs/taro';
3
- import type { Instance, PageInstance, PageProps } from './instance';
4
- export declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
5
- export declare function getPageInstance(id: string): Instance | undefined;
6
- export declare function removePageInstance(id: string): void;
7
- export declare function addLeadingSlash(path?: string): string;
8
- export declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
9
- export declare function stringify(obj?: Record<string, unknown>): string;
10
- export declare function getPath(id: string, options?: Record<string, unknown>): string;
11
- export declare function getOnReadyEventKey(path: string): string;
12
- export declare function getOnShowEventKey(path: string): string;
13
- export declare function getOnHideEventKey(path: string): string;
14
- export declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
15
- export declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
16
- export declare function createRecursiveComponentConfig(componentName?: string): any;
@@ -1,87 +0,0 @@
1
- import VueCtor, { ComponentOptions, VNode } from 'vue';
2
- import type { Component as Vue3Component } from '@vue/runtime-core';
3
- import type { Component, ComponentClass } from 'react';
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 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
- onUnhandledRejection?(error: any): void;
82
- onShow?(options?: Record<string, unknown>): void;
83
- unmount?(id: string, cb?: () => void): void;
84
- taroGlobalData?: Record<any, any>;
85
- config?: Record<any, any>;
86
- }
87
- export {};
@@ -1,4 +0,0 @@
1
- import { Events } from '@tarojs/shared';
2
- declare const eventCenter: Events;
3
- export type EventsType = typeof Events;
4
- export { eventCenter, Events };
package/dist/env.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { TaroDocument } from './dom/document';
2
- interface Env {
3
- window: any;
4
- document: TaroDocument;
5
- }
6
- declare const env: Env;
7
- export default env;
package/dist/hydrate.d.ts DELETED
@@ -1,10 +0,0 @@
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 DELETED
@@ -1,30 +0,0 @@
1
- import './dom-external';
2
- export { hooks } from '@tarojs/shared';
3
- export { document } from './bom/document';
4
- export { getComputedStyle } from './bom/getComputedStyle';
5
- export { History } from './bom/history';
6
- export { Location } from './bom/location';
7
- export { nav as navigator } from './bom/navigator';
8
- export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf';
9
- export { parseUrl, URL } from './bom/URL';
10
- export { URLSearchParams } from './bom/URLSearchParams';
11
- export { history, location, window } from './bom/window';
12
- export { TaroElement } from './dom/element';
13
- export { createEvent, eventHandler, TaroEvent } from './dom/event';
14
- export { FormElement } from './dom/form';
15
- export { TaroNode } from './dom/node';
16
- export { TaroRootElement } from './dom/root';
17
- export { Style } from './dom/style';
18
- export { SVGElement } from './dom/svg';
19
- export { TaroText } from './dom/text';
20
- export { MutationObserver } from './dom-external/mutation-observer';
21
- export { Current, getCurrentInstance } from './current';
22
- export { eventSource } from './dom/event-source';
23
- export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, removePageInstance, safeExecute, stringify } from './dsl/common';
24
- export * from './emitter/emitter';
25
- export { hydrate } from './hydrate';
26
- export { nextTick } from './next-tick';
27
- export { options } from './options';
28
- export { incrementId } from './utils';
29
- export * from './dsl/instance';
30
- export * from './interface';
@@ -1,4 +0,0 @@
1
- export interface Attributes {
2
- name: string;
3
- value: string;
4
- }
@@ -1,10 +0,0 @@
1
- export interface EventListenerOptions {
2
- capture?: boolean;
3
- }
4
- export interface AddEventListenerOptions extends EventListenerOptions {
5
- once?: boolean;
6
- passive?: boolean;
7
- }
8
- export interface EventHandler extends Function {
9
- _stop?: boolean;
10
- }
@@ -1,15 +0,0 @@
1
- export interface EventOptions {
2
- bubbles: boolean;
3
- cancelable: boolean;
4
- }
5
- 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 {};
@@ -1,30 +0,0 @@
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 type MiniData = MiniElementData | MiniTextData;
29
- export type HydratedData = () => MiniData | MiniData[];
30
- export {};
@@ -1,7 +0,0 @@
1
- export * from './element';
2
- export * from './event';
3
- export * from './event-target';
4
- export * from './hydrate';
5
- export * from './node';
6
- export * from './options';
7
- export * from './utils';
@@ -1,7 +0,0 @@
1
- import { HydratedData } from './index';
2
- export type UpdatePayloadValue = string | boolean | HydratedData;
3
- export type DataTree = Record<string, UpdatePayloadValue | ReturnType<HydratedData>>;
4
- export interface UpdatePayload {
5
- path: string;
6
- value: UpdatePayloadValue;
7
- }
@@ -1,16 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export type Func = (...args: any[]) => any;
2
- export type Ctx = Record<string, any>;
@@ -1,2 +0,0 @@
1
- import type { Func } from './interface';
2
- export declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
package/dist/options.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Options } from './interface';
2
- export declare const options: Options;
package/dist/perf.d.ts DELETED
@@ -1,7 +0,0 @@
1
- declare class Performance {
2
- private recorder;
3
- start(id: string): void;
4
- stop(id: string): void;
5
- }
6
- export declare const perf: Performance;
7
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
3
- */
4
- export declare class RuntimeCache<T> {
5
- name: string;
6
- cache: Map<string, T>;
7
- constructor(name: string);
8
- has(identifier: string): boolean;
9
- set(identifier: string, ctx: T): void;
10
- get(identifier: string): T | undefined;
11
- delete(identifier: string): void;
12
- }
@@ -1,23 +0,0 @@
1
- import { Func } from '../interface';
2
- import type { TaroElement } from '../dom/element';
3
- import type { TaroNode } from '../dom/node';
4
- import type { TaroText } from '../dom/text';
5
- export declare const incrementId: () => () => string;
6
- export declare function isElement(node: TaroNode): node is TaroElement;
7
- export declare function isText(node: TaroNode): node is TaroText;
8
- export declare function isComment(node: TaroNode): boolean;
9
- export declare function isHasExtractProp(el: TaroElement): boolean;
10
- /**
11
- * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
12
- * @param node 当前组件
13
- * @param type 事件类型
14
- */
15
- export declare function isParentBinded(node: TaroElement | null, type: string): boolean;
16
- export declare function shortcutAttr(key: string): string;
17
- export declare const customWrapperCache: Map<string, Record<string, any>>;
18
- interface Ctor {
19
- new (...args: any[]): any;
20
- }
21
- export declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
22
- export declare function getComponentsAlias(): any;
23
- export {};