@tarojs/runtime 4.1.0-alpha.1 → 4.1.0-alpha.2

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