@tarojs/runtime 4.0.0-beta.1 → 4.0.0-beta.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 (177) hide show
  1. package/LICENSE +14 -0
  2. package/dist/bom/URL.d.ts +54 -0
  3. package/dist/bom/URL.js +221 -0
  4. package/dist/bom/URL.js.map +1 -0
  5. package/dist/bom/URLSearchParams.d.ts +2 -0
  6. package/dist/bom/URLSearchParams.js +123 -0
  7. package/dist/bom/URLSearchParams.js.map +1 -0
  8. package/dist/bom/document.d.ts +3 -0
  9. package/dist/bom/document.js +39 -0
  10. package/dist/bom/document.js.map +1 -0
  11. package/dist/bom/getComputedStyle.d.ts +5 -0
  12. package/dist/bom/getComputedStyle.js +8 -0
  13. package/dist/bom/getComputedStyle.js.map +1 -0
  14. package/dist/bom/history.d.ts +32 -0
  15. package/dist/bom/history.js +121 -0
  16. package/dist/bom/history.js.map +1 -0
  17. package/dist/bom/location.d.ts +39 -0
  18. package/dist/bom/location.js +240 -0
  19. package/dist/bom/location.js.map +1 -0
  20. package/dist/bom/navigator.d.ts +2 -0
  21. package/dist/bom/navigator.js +24 -0
  22. package/dist/bom/navigator.js.map +1 -0
  23. package/dist/bom/raf.d.ts +4 -0
  24. package/dist/bom/raf.js +33 -0
  25. package/dist/bom/raf.js.map +1 -0
  26. package/dist/bom/window.d.ts +25 -0
  27. package/dist/bom/window.js +92 -0
  28. package/dist/bom/window.js.map +1 -0
  29. package/dist/constants/index.d.ts +60 -0
  30. package/dist/constants/index.js +63 -0
  31. package/dist/constants/index.js.map +1 -0
  32. package/dist/current.d.ts +19 -0
  33. package/dist/current.js +9 -0
  34. package/dist/current.js.map +1 -0
  35. package/dist/dom/anchor-element.d.ts +14 -0
  36. package/dist/dom/anchor-element.js +54 -0
  37. package/dist/dom/anchor-element.js.map +1 -0
  38. package/dist/dom/class-list.d.ts +17 -0
  39. package/dist/dom/class-list.js +92 -0
  40. package/dist/dom/class-list.js.map +1 -0
  41. package/dist/dom/document.d.ts +25 -0
  42. package/dist/dom/document.js +80 -0
  43. package/dist/dom/document.js.map +1 -0
  44. package/dist/dom/element.d.ts +40 -0
  45. package/dist/dom/element.js +315 -0
  46. package/dist/dom/element.js.map +1 -0
  47. package/dist/dom/event-source.d.ts +7 -0
  48. package/dist/dom/event-source.js +17 -0
  49. package/dist/dom/event-source.js.map +1 -0
  50. package/dist/dom/event-target.d.ts +8 -0
  51. package/dist/dom/event-target.js +78 -0
  52. package/dist/dom/event-target.js.map +1 -0
  53. package/dist/dom/event.d.ts +24 -0
  54. package/dist/dom/event.js +151 -0
  55. package/dist/dom/event.js.map +1 -0
  56. package/dist/dom/form.d.ts +10 -0
  57. package/dist/dom/form.js +38 -0
  58. package/dist/dom/form.js.map +1 -0
  59. package/dist/dom/node.d.ts +107 -0
  60. package/dist/dom/node.js +292 -0
  61. package/dist/dom/node.js.map +1 -0
  62. package/dist/dom/root.d.ts +16 -0
  63. package/dist/dom/root.js +169 -0
  64. package/dist/dom/root.js.map +1 -0
  65. package/dist/dom/style.d.ts +15 -0
  66. package/dist/dom/style.js +168 -0
  67. package/dist/dom/style.js.map +1 -0
  68. package/dist/dom/style_properties.d.ts +3 -0
  69. package/dist/dom/style_properties.js +186 -0
  70. package/dist/dom/style_properties.js.map +1 -0
  71. package/dist/dom/svg.d.ts +4 -0
  72. package/dist/dom/svg.js +8 -0
  73. package/dist/dom/svg.js.map +1 -0
  74. package/dist/dom/text.d.ts +15 -0
  75. package/dist/dom/text.js +41 -0
  76. package/dist/dom/text.js.map +1 -0
  77. package/dist/dom/transfer.d.ts +8 -0
  78. package/dist/dom/transfer.js +15 -0
  79. package/dist/dom/transfer.js.map +1 -0
  80. package/dist/dom/tree.d.ts +4 -0
  81. package/dist/dom/tree.js +38 -0
  82. package/dist/dom/tree.js.map +1 -0
  83. package/dist/dom-external/element.d.ts +4 -0
  84. package/dist/dom-external/element.js +29 -0
  85. package/dist/dom-external/element.js.map +1 -0
  86. package/dist/dom-external/index.d.ts +1 -0
  87. package/dist/dom-external/index.js +40 -0
  88. package/dist/dom-external/index.js.map +1 -0
  89. package/dist/dom-external/inner-html/html.d.ts +3 -0
  90. package/dist/dom-external/inner-html/html.js +28 -0
  91. package/dist/dom-external/inner-html/html.js.map +1 -0
  92. package/dist/dom-external/inner-html/parser.d.ts +25 -0
  93. package/dist/dom-external/inner-html/parser.js +216 -0
  94. package/dist/dom-external/inner-html/parser.js.map +1 -0
  95. package/dist/dom-external/inner-html/scaner.d.ts +30 -0
  96. package/dist/dom-external/inner-html/scaner.js +304 -0
  97. package/dist/dom-external/inner-html/scaner.js.map +1 -0
  98. package/dist/dom-external/inner-html/style.d.ts +27 -0
  99. package/dist/dom-external/inner-html/style.js +235 -0
  100. package/dist/dom-external/inner-html/style.js.map +1 -0
  101. package/dist/dom-external/inner-html/tags.d.ts +9 -0
  102. package/dist/dom-external/inner-html/tags.js +26 -0
  103. package/dist/dom-external/inner-html/tags.js.map +1 -0
  104. package/dist/dom-external/inner-html/utils.d.ts +2 -0
  105. package/dist/dom-external/inner-html/utils.js +12 -0
  106. package/dist/dom-external/inner-html/utils.js.map +1 -0
  107. package/dist/dom-external/mutation-observer/implements.d.ts +71 -0
  108. package/dist/dom-external/mutation-observer/implements.js +108 -0
  109. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  110. package/dist/dom-external/mutation-observer/index.d.ts +12 -0
  111. package/dist/dom-external/mutation-observer/index.js +35 -0
  112. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  113. package/dist/dom-external/node.d.ts +12 -0
  114. package/dist/dom-external/node.js +74 -0
  115. package/dist/dom-external/node.js.map +1 -0
  116. package/dist/dsl/common.d.ts +15 -0
  117. package/dist/dsl/common.js +332 -0
  118. package/dist/dsl/common.js.map +1 -0
  119. package/dist/emitter/emitter.d.ts +4 -0
  120. package/dist/emitter/emitter.js +7 -0
  121. package/dist/emitter/emitter.js.map +1 -0
  122. package/dist/env.d.ts +7 -0
  123. package/dist/env.js +9 -0
  124. package/dist/env.js.map +1 -0
  125. package/dist/hydrate.d.ts +11 -0
  126. package/dist/hydrate.js +84 -0
  127. package/dist/hydrate.js.map +1 -0
  128. package/dist/index-26658829.d.ts +23 -0
  129. package/dist/{runtime.cjs.d.ts → index.cjs.d.ts} +92 -89
  130. package/dist/{runtime.h5.js → index.cjs.js} +4251 -2493
  131. package/dist/index.cjs.js.map +1 -0
  132. package/dist/index.d.ts +33 -0
  133. package/dist/index.js +34 -0
  134. package/dist/index.js.map +1 -0
  135. package/dist/instance-4c64b022.d.ts +92 -0
  136. package/dist/next-tick.d.ts +3 -0
  137. package/dist/next-tick.js +47 -0
  138. package/dist/next-tick.js.map +1 -0
  139. package/dist/node_types-9ac5b4dd.d.ts +11 -0
  140. package/dist/options-4c64b022.d.ts +17 -0
  141. package/dist/options.d.ts +3 -0
  142. package/dist/options.js +7 -0
  143. package/dist/options.js.map +1 -0
  144. package/dist/perf.d.ts +7 -0
  145. package/dist/perf.js +28 -0
  146. package/dist/perf.js.map +1 -0
  147. package/dist/polyfill/array.d.ts +3 -0
  148. package/dist/polyfill/array.js +56 -0
  149. package/dist/polyfill/array.js.map +1 -0
  150. package/dist/polyfill/index.d.ts +2 -0
  151. package/dist/polyfill/index.js +34 -0
  152. package/dist/polyfill/index.js.map +1 -0
  153. package/dist/polyfill/intersection-observer.d.ts +2 -0
  154. package/dist/polyfill/intersection-observer.js +599 -0
  155. package/dist/polyfill/intersection-observer.js.map +1 -0
  156. package/dist/polyfill/object.d.ts +4 -0
  157. package/dist/polyfill/object.js +102 -0
  158. package/dist/polyfill/object.js.map +1 -0
  159. package/dist/record-32b054d8.d.ts +25 -0
  160. package/dist/runtime.esm.d.ts +92 -89
  161. package/dist/runtime.esm.js +4077 -3317
  162. package/dist/runtime.esm.js.map +1 -1
  163. package/dist/utils/cache.d.ts +13 -0
  164. package/dist/utils/cache.js +27 -0
  165. package/dist/utils/cache.js.map +1 -0
  166. package/dist/utils/index.d.ts +26 -0
  167. package/dist/utils/index.js +99 -0
  168. package/dist/utils/index.js.map +1 -0
  169. package/dist/utils/lodash.d.ts +2 -0
  170. package/dist/utils/lodash.js +22 -0
  171. package/dist/utils/lodash.js.map +1 -0
  172. package/dist/utils/router.d.ts +8 -0
  173. package/dist/utils/router.js +24 -0
  174. package/dist/utils/router.js.map +1 -0
  175. package/package.json +16 -11
  176. package/dist/runtime.cjs.js +0 -4628
  177. package/dist/runtime.h5.d.ts +0 -800
@@ -1,800 +0,0 @@
1
- import { Shortcuts, Events } from "@tarojs/shared";
2
- import { PageConfig } from "@tarojs/taro";
3
- import VueCtor from "vue";
4
- import { ComponentOptions, VNode } from "vue";
5
- import { Component as Vue3Component } from "@vue/runtime-core";
6
- import { Component, ComponentClass } from "react";
7
- import { CombinedVueInstance } from "vue/types/vue";
8
- declare class ClassList {
9
- private el;
10
- private tokenList;
11
- constructor(className: string, el: TaroElement);
12
- get value(): string;
13
- get length(): number;
14
- add(): void;
15
- remove(): void;
16
- contains(token: string): boolean;
17
- toggle(token: string, force: boolean): boolean;
18
- replace(token: string, replacement_token: string): void;
19
- toString(): string;
20
- private checkTokenIsValid;
21
- private _update;
22
- }
23
- interface Attributes {
24
- name: string;
25
- value: string;
26
- }
27
- interface EventOptions {
28
- bubbles: boolean;
29
- cancelable: boolean;
30
- }
31
- type Target = Record<string, unknown> & {
32
- dataset: Record<string, unknown>;
33
- id: string;
34
- };
35
- interface MpEvent {
36
- type: string;
37
- detail: Record<string, unknown>;
38
- target: Target;
39
- currentTarget: Target;
40
- }
41
- interface EventListenerOptions {
42
- capture?: boolean;
43
- }
44
- interface AddEventListenerOptions extends EventListenerOptions {
45
- once?: boolean;
46
- passive?: boolean;
47
- }
48
- interface EventHandler<T = any, R = void> {
49
- (...args: T[]): R;
50
- _stop?: boolean;
51
- }
52
- interface MpInstance {
53
- config: PageConfig;
54
- setData: (data: unknown, cb: () => void) => void;
55
- route?: string;
56
- __route__: string;
57
- $taroParams?: Record<string, unknown>;
58
- $taroPath: string;
59
- __data__: any;
60
- data: any;
61
- exitState?: any;
62
- selectComponent: (selector: string) => any;
63
- }
64
- interface MiniElementData {
65
- [Shortcuts.Childnodes]?: MiniData[];
66
- [Shortcuts.NodeName]: string;
67
- [Shortcuts.Class]?: string;
68
- [Shortcuts.Style]?: string;
69
- uid?: string;
70
- sid: string;
71
- [key: string]: unknown;
72
- }
73
- interface MiniTextData {
74
- [Shortcuts.Text]: string;
75
- [Shortcuts.NodeName]: string;
76
- }
77
- type MiniData = MiniElementData | MiniTextData;
78
- type HydratedData = () => MiniData | MiniData[];
79
- type UpdatePayloadValue = string | boolean | HydratedData;
80
- type DataTree = Record<string, UpdatePayloadValue | ReturnType<HydratedData>>;
81
- interface UpdatePayload {
82
- path: string;
83
- value: UpdatePayloadValue;
84
- }
85
- declare const enum NodeType {
86
- ELEMENT_NODE = 1,
87
- ATTRIBUTE_NODE = 2,
88
- TEXT_NODE = 3,
89
- CDATA_SECTION_NODE = 4,
90
- ENTITY_REFERENCE_NODE = 5,
91
- COMMENT_NODE = 6,
92
- PROCESSING_INSTRUCTION_NODE = 7,
93
- DOCUMENT_NODE = 9
94
- }
95
- declare class TaroText extends TaroNode {
96
- _value: string;
97
- nodeType: NodeType;
98
- nodeName: string;
99
- constructor(value: any);
100
- set textContent(text: string);
101
- get textContent(): string;
102
- set nodeValue(text: string);
103
- get nodeValue(): string;
104
- set data(text: string);
105
- get data(): string;
106
- }
107
- interface Node {
108
- type: string;
109
- }
110
- interface Comment extends Node {
111
- type: "comment";
112
- content: string;
113
- }
114
- interface Text extends Node {
115
- type: "text";
116
- content: string;
117
- }
118
- interface Element extends Node {
119
- type: "element";
120
- tagName: string;
121
- children: ChildNode[];
122
- attributes: string[];
123
- }
124
- type ChildNode = Comment | Text | Element;
125
- interface Options {
126
- prerender: boolean;
127
- debug: boolean;
128
- html?: {
129
- skipElements: Set<string>;
130
- voidElements: Set<string>;
131
- closingElements: Set<string>;
132
- transformText?: (taroText: TaroText, text: Text) => TaroText;
133
- transformElement?: (taroElement: TaroElement, element: Element) => TaroElement;
134
- renderHTMLTag: boolean;
135
- };
136
- miniGlobal?: any;
137
- }
138
- type Func = (...args: any[]) => any;
139
- type Ctx = Record<string, any>;
140
- declare class TaroEventTarget {
141
- __handlers: Record<string, EventHandler[]>;
142
- addEventListener(type: string, handler: EventHandler, options?: boolean | AddEventListenerOptions): void;
143
- removeEventListener(type: string, handler: EventHandler): void;
144
- isAnyEventBinded(): boolean;
145
- }
146
- declare class TaroRootElement extends TaroElement {
147
- private updatePayloads;
148
- private updateCallbacks;
149
- pendingUpdate: boolean;
150
- ctx: null | MpInstance;
151
- constructor();
152
- get _path(): string;
153
- get _root(): TaroRootElement;
154
- enqueueUpdate(payload: UpdatePayload): void;
155
- performUpdate(initRender?: boolean, prerender?: Func): void;
156
- enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
157
- flushUpdateCallback(): void;
158
- }
159
- interface RemoveChildOptions {
160
- cleanRef?: boolean;
161
- doUpdate?: boolean;
162
- }
163
- declare class TaroNode extends TaroEventTarget {
164
- uid: string;
165
- sid: string;
166
- nodeType: NodeType;
167
- nodeName: string;
168
- parentNode: TaroNode | null;
169
- childNodes: TaroNode[];
170
- constructor();
171
- private hydrate;
172
- private updateChildNodes;
173
- private updateSingleChild;
174
- get _root(): TaroRootElement | null;
175
- protected findIndex(refChild: TaroNode): number;
176
- get _path(): string;
177
- get nextSibling(): TaroNode | null;
178
- get previousSibling(): TaroNode | null;
179
- get parentElement(): TaroElement | null;
180
- get firstChild(): TaroNode | null;
181
- get lastChild(): TaroNode | null;
182
- /**
183
- * @textContent 目前只能置空子元素
184
- * @TODO 等待完整 innerHTML 实现
185
- */
186
- // eslint-disable-next-line accessor-pairs
187
- set textContent(text: string);
188
- /**
189
- * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
190
- * @scenario
191
- * [A,B,C]
192
- * 1. insert D before C, D has no parent
193
- * 2. insert D before C, D has the same parent of C
194
- * 3. insert D before C, D has the different parent of C
195
- */
196
- insertBefore<T extends TaroNode>(newChild: T, refChild?: TaroNode | null, isReplace?: boolean): T;
197
- /**
198
- * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/appendChild
199
- * @scenario
200
- * [A,B,C]
201
- * 1. append C, C has no parent
202
- * 2. append C, C has the same parent of B
203
- * 3. append C, C has the different parent of B
204
- */
205
- appendChild(newChild: TaroNode): TaroNode;
206
- /**
207
- * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
208
- * @scenario
209
- * [A,B,C]
210
- * 1. replace B with C, C has no parent
211
- * 2. replace B with C, C has no parent, C has the same parent of B
212
- * 3. replace B with C, C has no parent, C has the different parent of B
213
- */
214
- replaceChild(newChild: TaroNode, oldChild: TaroNode): TaroNode | undefined;
215
- /**
216
- * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/removeChild
217
- * @scenario
218
- * [A,B,C]
219
- * 1. remove A or B
220
- * 2. remove C
221
- */
222
- removeChild<T extends TaroNode>(child: T, options?: RemoveChildOptions): T;
223
- remove(options?: RemoveChildOptions): void;
224
- hasChildNodes(): boolean;
225
- enqueueUpdate(payload: UpdatePayload): void;
226
- get ownerDocument(): TaroDocument;
227
- static extend(methodName: string, options: Func | Record<string, any>): void;
228
- }
229
- declare class Style {
230
- _pending: boolean;
231
- _usedStyleProp: Set<string>;
232
- _value: Partial<CSSStyleDeclaration>;
233
- _element: TaroElement;
234
- constructor(element: TaroElement);
235
- private setCssVariables;
236
- get cssText(): string;
237
- set cssText(str: string);
238
- setProperty(propertyName: string, value?: string | null): void;
239
- removeProperty(propertyName: string): string;
240
- getPropertyValue(propertyName: string): any;
241
- }
242
- // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
243
- declare class TaroEvent {
244
- private cacheTarget;
245
- private cacheCurrentTarget;
246
- type: string;
247
- bubbles: boolean;
248
- cancelable: boolean;
249
- _stop: boolean;
250
- _end: boolean;
251
- defaultPrevented: boolean;
252
- // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
253
- button: number;
254
- // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
255
- // here use hi-res timestamp
256
- timeStamp: number;
257
- mpEvent: MpEvent | undefined;
258
- constructor(type: string, opts: EventOptions, event?: MpEvent);
259
- stopPropagation(): void;
260
- stopImmediatePropagation(): void;
261
- preventDefault(): void;
262
- get target(): any;
263
- get currentTarget(): any;
264
- }
265
- declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
266
- // 小程序的事件代理回调函数
267
- declare function eventHandler(event: MpEvent): any;
268
- declare class TaroElement extends TaroNode {
269
- ctx?: any;
270
- tagName: string;
271
- props: Record<string, any>;
272
- style: Style;
273
- dataset: Record<string, unknown>;
274
- innerHTML: string;
275
- constructor();
276
- private _stopPropagation;
277
- get id(): string;
278
- set id(val: string);
279
- get className(): string;
280
- set className(val: string);
281
- get cssText(): string;
282
- get classList(): ClassList;
283
- get children(): TaroElement[];
284
- get attributes(): Attributes[];
285
- get textContent(): string;
286
- set textContent(text: string);
287
- hasAttribute(qualifiedName: string): boolean;
288
- hasAttributes(): boolean;
289
- get focus(): () => void;
290
- // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579
291
- set focus(value: () => void);
292
- blur(): void;
293
- setAttribute(qualifiedName: string, value: any): void;
294
- removeAttribute(qualifiedName: string): void;
295
- getAttribute(qualifiedName: string): string;
296
- getElementsByTagName(tagName: string): TaroElement[];
297
- getElementsByClassName(className: string): TaroElement[];
298
- dispatchEvent(event: TaroEvent): boolean;
299
- addEventListener(type: any, handler: any, options: any): void;
300
- removeEventListener(type: any, handler: any, sideEffect?: boolean): void;
301
- static extend(methodName: string, options: Func | Record<string, any>): void;
302
- }
303
- declare class FormElement extends TaroElement {
304
- get type(): string;
305
- set type(val: string);
306
- get value(): string | boolean | number | any[];
307
- set value(val: string | boolean | number | any[]);
308
- dispatchEvent(event: TaroEvent): boolean;
309
- }
310
- declare class TaroDocument extends TaroElement {
311
- documentElement: TaroElement;
312
- head: TaroElement;
313
- body: TaroElement;
314
- createEvent: typeof createEvent;
315
- constructor();
316
- createElement(type: string): TaroElement | TaroRootElement | FormElement;
317
- // an ugly fake createElementNS to deal with @vue/runtime-dom's
318
- // support mounting app to svg container since vue@3.0.8
319
- createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
320
- createTextNode(text: string): TaroText;
321
- getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
322
- querySelector<T extends TaroElement>(query: string): T | null;
323
- querySelectorAll(): never[];
324
- // @TODO: @PERF: 在 hydrate 移除掉空的 node
325
- createComment(): TaroText;
326
- get defaultView(): any;
327
- }
328
- interface Env {
329
- window: any;
330
- document: TaroDocument;
331
- }
332
- declare const env: Env;
333
- declare let document: any;
334
- declare function getComputedStyle(element: TaroElement): Style;
335
- declare const eventCenter: Events;
336
- type EventsType = typeof Events;
337
- /**
338
- * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
339
- */
340
- declare class RuntimeCache<T> {
341
- name: string;
342
- cache: Map<string, T>;
343
- constructor(name: string);
344
- has(identifier: string): boolean;
345
- set(identifier: string, ctx: T): void;
346
- get(identifier: string): T | undefined;
347
- delete(identifier: string): void;
348
- }
349
- declare namespace LocationType {
350
- const eventCenter: Events;
351
- type EventsType = typeof Events;
352
- /**
353
- * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
354
- */
355
- class RuntimeCache<T> {
356
- name: string;
357
- cache: Map<string, T>;
358
- constructor(name: string);
359
- has(identifier: string): boolean;
360
- set(identifier: string, ctx: T): void;
361
- get(identifier: string): T | undefined;
362
- delete(identifier: string): void;
363
- }
364
- type Options = {
365
- window: any;
366
- };
367
- type LocationContext = {
368
- lastHref: string;
369
- };
370
- class Location extends Events {
371
- #private;
372
- constructor(options: Options);
373
- /* public property */
374
- get protocol(): string;
375
- set protocol(val: string);
376
- get host(): string;
377
- set host(val: string);
378
- get hostname(): string;
379
- set hostname(val: string);
380
- get port(): string;
381
- set port(val: string);
382
- get pathname(): string;
383
- set pathname(val: string);
384
- get search(): string;
385
- set search(val: string);
386
- get hash(): string;
387
- // 小程序的navigateTo存在截断hash字符串的问题
388
- set hash(val: string);
389
- get href(): string;
390
- set href(val: string);
391
- get origin(): string;
392
- set origin(val: string);
393
- /* public method */
394
- assign(): void;
395
- reload(): void;
396
- replace(url: string): void;
397
- toString(): string;
398
- // For debug
399
- get cache(): RuntimeCache<LocationContext>;
400
- }
401
- }
402
- interface HistoryState {
403
- state: Record<string, any> | null;
404
- title: string;
405
- url: string;
406
- }
407
- type Options$0 = {
408
- window: any;
409
- };
410
- type HistoryContext = {
411
- location: LocationType.Location;
412
- stack: HistoryState[];
413
- cur: number;
414
- };
415
- declare class History extends Events {
416
- #private;
417
- constructor(location: LocationType.Location, options: Options$0);
418
- /* public property */
419
- get length(): number;
420
- get state(): Record<string, any> | null;
421
- /* public method */
422
- go(delta: number): void;
423
- back(): void;
424
- forward(): void;
425
- pushState(state: any, title: string, url: string): void;
426
- replaceState(state: any, title: string, url: string): void;
427
- // For debug
428
- get cache(): RuntimeCache<HistoryContext>;
429
- }
430
- declare const nav: any;
431
- // https://github.com/myrne/performance-now
432
- declare let now: () => number;
433
- // https://gist.github.com/paulirish/1579671
434
- // https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
435
- declare const _raf: typeof requestAnimationFrame | ((callback: any) => NodeJS.Timeout);
436
- declare const _caf: typeof cancelAnimationFrame;
437
- declare class URLSearchParams {
438
- #private;
439
- constructor(query: any);
440
- append(name: string, value: string): void;
441
- delete(name: string): void;
442
- get(name: string): any;
443
- getAll(name: string): any;
444
- has(name: string): boolean;
445
- keys(): string[];
446
- set(name: string, value: string): void;
447
- forEach(callback: any, thisArg: any): void;
448
- toJSON(): {};
449
- toString(): string;
450
- }
451
- declare class URL {
452
- #private;
453
- static createObjectURL(): void;
454
- static revokeObjectURL(): void;
455
- constructor(url: string, base?: string);
456
- /* public property */
457
- get protocol(): string;
458
- set protocol(val: string);
459
- get host(): string;
460
- set host(val: string);
461
- get hostname(): string;
462
- set hostname(val: string);
463
- get port(): string;
464
- set port(val: string);
465
- get pathname(): string;
466
- set pathname(val: string);
467
- get search(): string;
468
- set search(val: string);
469
- get hash(): string;
470
- set hash(val: string);
471
- get href(): string;
472
- set href(val: string);
473
- get origin(): string;
474
- set origin(val: string);
475
- get searchParams(): URLSearchParams;
476
- // public method
477
- toString(): string;
478
- toJSON(): string;
479
- // convenient for deconstructor
480
- _toRaw(): {
481
- protocol: string;
482
- port: string;
483
- host: string;
484
- hostname: string;
485
- pathname: string;
486
- hash: string;
487
- search: string;
488
- origin: string;
489
- href: string;
490
- };
491
- }
492
- declare function parseUrl(url?: string): {
493
- href: string;
494
- origin: string;
495
- protocol: string;
496
- hostname: string;
497
- host: string;
498
- port: string;
499
- pathname: string;
500
- search: string;
501
- hash: string;
502
- };
503
- declare let window: any;
504
- declare const location: any;
505
- declare const history: any;
506
- // for Vue3
507
- declare class SVGElement extends TaroElement {
508
- }
509
- /**
510
- * A MutationRecord represents an individual DOM mutation.
511
- * It is the object that is passed to MutationObserver's callback.
512
- * @see https://dom.spec.whatwg.org/#interface-mutationrecord
513
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord
514
- */
515
- interface MutationRecord {
516
- readonly target: TaroNode;
517
- readonly addedNodes?: TaroNode[];
518
- readonly removedNodes?: TaroNode[];
519
- readonly previousSibling?: TaroNode | null;
520
- readonly nextSibling?: TaroNode | null;
521
- readonly attributeName?: string | null;
522
- readonly attributeNamespace?: string | null;
523
- oldValue?: string | null;
524
- // extended
525
- readonly type: MutationRecordType;
526
- readonly value?: string | null;
527
- }
528
- declare const enum MutationRecordType {
529
- ATTRIBUTES = "attributes",
530
- CHARACTER_DATA = "characterData",
531
- CHILD_LIST = "childList"
532
- }
533
- type MutationCallback = (mutations: MutationRecord[]) => any;
534
- /**
535
- * @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit
536
- */
537
- interface MutationObserverInit {
538
- attributeFilter?: string[];
539
- attributeOldValue?: boolean;
540
- attributes?: boolean;
541
- characterData?: boolean;
542
- characterDataOldValue?: boolean;
543
- childList?: boolean;
544
- subtree?: boolean;
545
- }
546
- /**
547
- * The MutationObserver provides the ability
548
- * to watch for changes being made to the DOM tree.
549
- * It will invoke a specified callback function
550
- * when DOM changes occur.
551
- * @see https://dom.spec.whatwg.org/#mutationobserver
552
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
553
- */
554
- declare class MutationObserverImpl {
555
- callback: MutationCallback;
556
- target: TaroNode | null;
557
- options: MutationObserverInit;
558
- records: MutationRecord[];
559
- constructor(callback: MutationCallback);
560
- /**
561
- * Configures the MutationObserver
562
- * to begin receiving notifications
563
- * through its callback function
564
- * when DOM changes matching the given options occur.
565
- *
566
- * Options matching is to be implemented.
567
- */
568
- observe(target: TaroNode, options?: MutationObserverInit): void;
569
- /**
570
- * Stop the MutationObserver instance
571
- * from receiving further notifications
572
- * until and unless observe() is called again.
573
- */
574
- disconnect(): void;
575
- /**
576
- * Removes all pending notifications
577
- * from the MutationObserver's notification queue
578
- * and returns them in a new Array of MutationRecord objects.
579
- */
580
- takeRecords(): MutationRecord[];
581
- }
582
- declare class MutationObserver {
583
- core: Pick<MutationObserverImpl, "observe" | "disconnect" | "takeRecords">;
584
- constructor(callback: MutationCallback);
585
- observe(...args: [
586
- TaroNode,
587
- MutationObserverInit?
588
- ]): void;
589
- disconnect(): void;
590
- takeRecords(): MutationRecord[];
591
- static record(record: MutationRecord): void;
592
- }
593
- declare const PROPERTY_THRESHOLD = 2046;
594
- declare const TARO_RUNTIME = "Taro runtime";
595
- declare const HOOKS_APP_ID = "taro-app";
596
- declare const SET_DATA = "\u5C0F\u7A0B\u5E8F setData";
597
- declare const PAGE_INIT = "\u9875\u9762\u521D\u59CB\u5316";
598
- declare const ROOT_STR = "root";
599
- declare const HTML = "html";
600
- declare const HEAD = "head";
601
- declare const BODY = "body";
602
- declare const APP = "app";
603
- declare const CONTAINER = "container";
604
- declare const DOCUMENT_ELEMENT_NAME = "#document";
605
- declare const DOCUMENT_FRAGMENT = "document-fragment";
606
- declare const ID = "id";
607
- declare const UID = "uid";
608
- declare const CLASS = "class";
609
- declare const STYLE = "style";
610
- declare const FOCUS = "focus";
611
- declare const VIEW = "view";
612
- declare const STATIC_VIEW = "static-view";
613
- declare const PURE_VIEW = "pure-view";
614
- declare const PROPS = "props";
615
- declare const DATASET = "dataset";
616
- declare const OBJECT = "object";
617
- declare const VALUE = "value";
618
- declare const INPUT = "input";
619
- declare const CHANGE = "change";
620
- declare const CUSTOM_WRAPPER = "custom-wrapper";
621
- declare const TARGET = "target";
622
- declare const CURRENT_TARGET = "currentTarget";
623
- declare const TYPE = "type";
624
- declare const CONFIRM = "confirm";
625
- declare const TIME_STAMP = "timeStamp";
626
- declare const KEY_CODE = "keyCode";
627
- declare const TOUCHMOVE = "touchmove";
628
- declare const DATE = "Date";
629
- declare const SET_TIMEOUT = "setTimeout";
630
- declare const COMPILE_MODE = "compileMode";
631
- declare const CATCHMOVE = "catchMove";
632
- declare const CATCH_VIEW = "catch-view";
633
- declare const COMMENT = "comment";
634
- declare const ON_LOAD = "onLoad";
635
- declare const ON_READY = "onReady";
636
- declare const ON_SHOW = "onShow";
637
- declare const ON_HIDE = "onHide";
638
- declare const OPTIONS = "options";
639
- declare const EXTERNAL_CLASSES = "externalClasses";
640
- declare const EVENT_CALLBACK_RESULT = "e_result";
641
- declare const BEHAVIORS = "behaviors";
642
- declare const A = "a";
643
- /**
644
- * 页面上下文切换时的行为
645
- */
646
- declare enum CONTEXT_ACTIONS {
647
- INIT = "0",
648
- RESTORE = "1",
649
- RECOVER = "2",
650
- DESTORY = "3"
651
- }
652
- interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
653
- tid?: string;
654
- node?: TaroElement;
655
- $forceUpdate?(): void;
656
- $nextTick?(cb: () => void): void;
657
- $options: Instance;
658
- }
659
- interface VueAppInstance extends ComponentOptions<VueCtor> {
660
- $options: AppInstance;
661
- }
662
- type VueInstance<M = Record<string, any>, P = Record<string, any>> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
663
- interface VueInternal {
664
- _render(): VNode;
665
- _update(vnode: VNode, hyrate: boolean): void;
666
- }
667
- interface PageProps {
668
- tid?: string;
669
- }
670
- interface ReactPageComponent<T = PageProps> extends ComponentClass<T>, PageInstance {
671
- }
672
- interface ReactPageInstance<T = PageProps> extends Component<T>, PageInstance {
673
- componentDidShow?(): void;
674
- componentDidHide?(): void;
675
- }
676
- interface ReactAppInstance<T = AppInstance> extends Component<T>, AppInstance {
677
- }
678
- interface PageLifeCycle extends Show {
679
- eh?(event: MpEvent): void;
680
- onAddToFavorites?(): void;
681
- onLoad?(options: Record<string, unknown>, cb?: Func): void;
682
- onOptionMenuClick?(): void;
683
- onPageScroll?(obj: {
684
- scrollTop: number;
685
- }): void;
686
- onPullDownRefresh?(): void;
687
- onPullIntercept?(): void;
688
- onPopMenuClick?(): void;
689
- onReachBottom?(): void;
690
- onReady?(): void;
691
- onResize?(options: unknown): void;
692
- onSaveExitState?(): void;
693
- onShareAppMessage?(obj: {
694
- from: string;
695
- target?: TaroElement;
696
- webViewUrl: string;
697
- }): void;
698
- onShareTimeline?(): void;
699
- onTabItemTap?(obj: {
700
- index: string;
701
- pagePath: string;
702
- text: string;
703
- }): void;
704
- onTitleClick?(): void;
705
- onUnload?(): void;
706
- }
707
- interface PageInstance extends PageLifeCycle {
708
- /** 页面的初始数据 */
709
- data?: Record<string, unknown>;
710
- /** 页面路径 */
711
- path?: string;
712
- /** 页面的组件选项 */
713
- options?: Record<string, unknown>;
714
- /** 页面渲染引擎类型 */
715
- renderer?: "webview" | "skyline";
716
- }
717
- interface Show {
718
- componentDidShow?(): void;
719
- componentDidHide?(): void;
720
- onShow?(): void;
721
- onHide?(): void;
722
- }
723
- interface AppInstance extends Show {
724
- componentDidShow?(options?: Record<string, unknown>): void;
725
- mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
726
- mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
727
- onError?(error: string): void;
728
- onLaunch?(options?: Record<string, unknown>): void;
729
- onPageNotFound?(res: any): void;
730
- onUnhandledRejection?(error: any): void;
731
- onShow?(options?: Record<string, unknown>): void;
732
- unmount?(id: string, cb?: () => void): void;
733
- taroGlobalData?: Record<any, any>;
734
- config?: Record<any, any>;
735
- }
736
- interface Router {
737
- params: Record<string, unknown>;
738
- path: string;
739
- $taroPath: string;
740
- onReady: string;
741
- onHide: string;
742
- onShow: string;
743
- exitState?: any;
744
- }
745
- interface Current {
746
- app: AppInstance | null;
747
- router: Router | null;
748
- page: PageInstance | null;
749
- preloadData?: any;
750
- }
751
- declare const Current: Current;
752
- declare const getCurrentInstance: () => Current;
753
- interface IEventSource extends Map<string | undefined | null, TaroNode> {
754
- removeNode(child: TaroNode): void;
755
- removeNodeTree(child: TaroNode): void;
756
- }
757
- declare const eventSource: IEventSource;
758
- declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
759
- declare function getPageInstance(id: string): Instance | undefined;
760
- declare function removePageInstance(id: string): void;
761
- declare function addLeadingSlash(path?: string): string;
762
- declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
763
- declare function stringify(obj?: Record<string, unknown>): string;
764
- declare function getPath(id: string, options?: Record<string, unknown>): string;
765
- declare function getOnReadyEventKey(path: string): string;
766
- declare function getOnShowEventKey(path: string): string;
767
- declare function getOnHideEventKey(path: string): string;
768
- declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
769
- declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
770
- declare function createRecursiveComponentConfig(componentName?: string): any;
771
- /**
772
- * React also has a fancy function's name for this: `hydrate()`.
773
- * You may have been heard `hydrate` as a SSR-related function,
774
- * actually, `hydrate` basicly do the `render()` thing, but ignore some properties,
775
- * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
776
- */
777
- declare function hydrate(node: TaroElement | TaroText): MiniData;
778
- declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
779
- declare const options: Options;
780
- declare const incrementId: () => () => string;
781
- declare function isElement(node: TaroNode): node is TaroElement;
782
- declare function isText(node: TaroNode): node is TaroText;
783
- declare function isComment(node: TaroNode): boolean;
784
- declare function isHasExtractProp(el: TaroElement): boolean;
785
- /**
786
- * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
787
- * @param node 当前组件
788
- * @param type 事件类型
789
- */
790
- declare function isParentBinded(node: TaroElement | null, type: string): boolean;
791
- declare function shortcutAttr(key: string): string;
792
- declare const customWrapperCache: Map<string, Record<string, any>>;
793
- interface Ctor {
794
- new (...args: any[]): any;
795
- }
796
- declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
797
- declare function getComponentsAlias(): any;
798
- declare function convertNumber2PX(value: number): string;
799
- export { hooks } from '@tarojs/shared';
800
- export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, COMPILE_MODE, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };