@tarojs/runtime 3.7.0-alpha.2 → 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 +20 -13
  4. package/dist/runtime.esm.js +133 -53
  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
@@ -6,17 +6,19 @@ import { Component as Vue3Component } from "@vue/runtime-core";
6
6
  import { Component, ComponentClass } from "react";
7
7
  import { CombinedVueInstance } from "vue/types/vue";
8
8
  declare let document: any;
9
- declare class ClassList extends Set<string> {
9
+ declare class ClassList {
10
10
  private el;
11
+ private tokenList;
11
12
  constructor(className: string, el: TaroElement);
12
13
  get value(): string;
13
- add(s: string): this;
14
14
  get length(): number;
15
- remove(s: string): void;
16
- toggle(s: string): void;
17
- replace(s1: string, s2: string): void;
18
- contains(s: string): boolean;
15
+ add(): void;
16
+ remove(): void;
17
+ contains(token: string): boolean;
18
+ toggle(token: string, force: boolean): boolean;
19
+ replace(token: string, replacement_token: string): void;
19
20
  toString(): string;
21
+ private checkTokenIsValid;
20
22
  private _update;
21
23
  }
22
24
  interface Attributes {
@@ -129,6 +131,8 @@ declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroE
129
131
  // 小程序的事件代理回调函数
130
132
  declare function eventHandler(event: MpEvent): any;
131
133
  declare class FormElement extends TaroElement {
134
+ get type(): string;
135
+ set type(val: string);
132
136
  get value(): string | boolean | number | any[];
133
137
  set value(val: string | boolean | number | any[]);
134
138
  dispatchEvent(event: TaroEvent): boolean;
@@ -405,7 +409,7 @@ declare class History extends Events {
405
409
  constructor(location: LocationType.Location, options: Options$0);
406
410
  /* public property */
407
411
  get length(): number;
408
- get state(): HistoryState;
412
+ get state(): Record<string, any> | null;
409
413
  /* public method */
410
414
  go(delta: number): void;
411
415
  back(): void;
@@ -578,7 +582,7 @@ declare class MutationObserver {
578
582
  takeRecords(): MutationRecord[];
579
583
  static record(record: MutationRecord): void;
580
584
  }
581
- interface Instance<T> extends Component<T>, Show, PageInstance {
585
+ interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
582
586
  tid?: string;
583
587
  $forceUpdate?(): void;
584
588
  $nextTick?(cb: () => void): void;
@@ -587,7 +591,7 @@ interface Instance<T> extends Component<T>, Show, PageInstance {
587
591
  interface VueAppInstance extends ComponentOptions<VueCtor> {
588
592
  $options: AppInstance;
589
593
  }
590
- type VueInstance<M, P> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
594
+ type VueInstance<M = Record<string, any>, P = Record<string, any>> = CombinedVueInstance<VueCtor, Record<string, any>, M, P, Record<never, any>> & VueInternal;
591
595
  interface VueInternal {
592
596
  _render(): VNode;
593
597
  _update(vnode: VNode, hyrate: boolean): void;
@@ -595,13 +599,13 @@ interface VueInternal {
595
599
  interface PageProps {
596
600
  tid?: string;
597
601
  }
598
- interface ReactPageComponent<T> extends ComponentClass<T>, PageInstance {
602
+ interface ReactPageComponent<T = PageProps> extends ComponentClass<T>, PageInstance {
599
603
  }
600
- interface ReactPageInstance<T> extends Component<T>, PageInstance {
604
+ interface ReactPageInstance<T = PageProps> extends Component<T>, PageInstance {
601
605
  componentDidShow?(): void;
602
606
  componentDidHide?(): void;
603
607
  }
604
- interface ReactAppInstance<T> extends Component<T>, AppInstance {
608
+ interface ReactAppInstance<T = AppInstance> extends Component<T>, AppInstance {
605
609
  }
606
610
  interface PageLifeCycle extends Show {
607
611
  eh?(event: MpEvent): void;
@@ -639,6 +643,8 @@ interface PageInstance extends PageLifeCycle {
639
643
  path?: string;
640
644
  /** 页面的组件选项 */
641
645
  options?: Record<string, unknown>;
646
+ /** 页面渲染引擎类型 */
647
+ renderer?: "webview" | "skyline";
642
648
  }
643
649
  interface Show {
644
650
  componentDidShow?(): void;
@@ -686,6 +692,7 @@ declare function removePageInstance(id: string): void;
686
692
  declare function addLeadingSlash(path?: string): string;
687
693
  declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
688
694
  declare function stringify(obj?: Record<string, unknown>): string;
695
+ declare function getPath(id: string, options?: Record<string, unknown>): string;
689
696
  declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
690
697
  declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
691
698
  declare function createRecursiveComponentConfig(componentName?: string): any;
@@ -700,4 +707,4 @@ declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
700
707
  declare const options: Options;
701
708
  declare const incrementId: () => () => string;
702
709
  export { hooks } from '@tarojs/shared';
703
- 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, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
710
+ 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, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
@@ -283,46 +283,90 @@ function getComponentsAlias() {
283
283
  return componentsAlias$1;
284
284
  }
285
285
 
286
- class ClassList extends Set {
286
+ class ClassList {
287
287
  constructor(className, el) {
288
- super();
289
- className.trim().split(/\s+/).forEach(super.add.bind(this));
288
+ this.tokenList = [];
290
289
  this.el = el;
290
+ className.trim().split(/\s+/).forEach(token => this.tokenList.push(token));
291
291
  }
292
292
  get value() {
293
- return [...this].filter(v => v !== '').join(' ');
294
- }
295
- add(s) {
296
- super.add(s);
297
- this._update();
298
- return this;
293
+ return this.toString();
299
294
  }
300
295
  get length() {
301
- return this.size;
296
+ return this.tokenList.length;
297
+ }
298
+ add() {
299
+ let index = 0;
300
+ let updated = false;
301
+ const tokens = arguments;
302
+ const length = tokens.length;
303
+ const tokenList = this.tokenList;
304
+ do {
305
+ const token = tokens[index];
306
+ if (this.checkTokenIsValid(token) && !~tokenList.indexOf(token)) {
307
+ tokenList.push(token);
308
+ updated = true;
309
+ }
310
+ } while (++index < length);
311
+ if (updated) {
312
+ this._update();
313
+ }
314
+ }
315
+ remove() {
316
+ let i = 0;
317
+ let updated = false;
318
+ const tokens = arguments;
319
+ const length = tokens.length;
320
+ const tokenList = this.tokenList;
321
+ do {
322
+ const token = tokens[i] + '';
323
+ if (!this.checkTokenIsValid(token))
324
+ continue;
325
+ const index = tokenList.indexOf(token);
326
+ if (~tokenList.indexOf(token)) {
327
+ tokenList.splice(index, 1);
328
+ updated = true;
329
+ }
330
+ } while (++i < length);
331
+ if (updated) {
332
+ this._update();
333
+ }
302
334
  }
303
- remove(s) {
304
- super.delete(s);
305
- this._update();
335
+ contains(token) {
336
+ if (!this.checkTokenIsValid(token))
337
+ return false;
338
+ return !!~this.tokenList.indexOf(token);
306
339
  }
307
- toggle(s) {
308
- if (super.has(s)) {
309
- super.delete(s);
340
+ toggle(token, force) {
341
+ const result = this.contains(token);
342
+ const method = result ? force !== true && 'remove' : force !== false && 'add';
343
+ if (method) {
344
+ // @ts-ignore
345
+ this[method](token);
346
+ }
347
+ if (force === true || force === false) {
348
+ return force;
310
349
  }
311
350
  else {
312
- super.add(s);
351
+ return !result;
313
352
  }
314
- this._update();
315
- }
316
- replace(s1, s2) {
317
- super.delete(s1);
318
- super.add(s2);
319
- this._update();
320
353
  }
321
- contains(s) {
322
- return super.has(s);
354
+ replace(token, replacement_token) {
355
+ if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token))
356
+ return;
357
+ const index = this.tokenList.indexOf(token);
358
+ if (~index) {
359
+ this.tokenList.splice(index, 1, replacement_token);
360
+ this._update();
361
+ }
323
362
  }
324
363
  toString() {
325
- return this.value;
364
+ return this.tokenList.filter(v => v !== '').join(' ');
365
+ }
366
+ checkTokenIsValid(token) {
367
+ if (token === '' || /\s/.test(token))
368
+ return false;
369
+ return true;
326
370
  }
327
371
  _update() {
328
372
  this.el.className = this.value;
@@ -803,7 +847,8 @@ const styleProperties = [
803
847
  'widows',
804
848
  'width',
805
849
  'zIndex',
806
- 'pointerEvents'
850
+ 'pointerEvents',
851
+ 'aspectRatio'
807
852
  /** 非常用 style */
808
853
  // 'azimuth',
809
854
  // 'backfaceVisibility',
@@ -971,10 +1016,12 @@ function setStyle(newVal, styleKey) {
971
1016
  }
972
1017
  !this._pending && enqueueUpdate(this);
973
1018
  }
974
- function initStyle(ctor) {
1019
+ function initStyle(ctor, styleProperties) {
975
1020
  const properties = {};
976
1021
  for (let i = 0; i < styleProperties.length; i++) {
977
1022
  const styleKey = styleProperties[i];
1023
+ if (ctor[styleKey])
1024
+ return;
978
1025
  properties[styleKey] = {
979
1026
  get() {
980
1027
  const val = this._value[styleKey];
@@ -1085,7 +1132,17 @@ class Style {
1085
1132
  return value;
1086
1133
  }
1087
1134
  }
1088
- initStyle(Style);
1135
+ initStyle(Style, styleProperties);
1136
+ hooks.tap('injectNewStyleProperties', (newStyleProperties) => {
1137
+ if (isArray(newStyleProperties)) {
1138
+ initStyle(Style, newStyleProperties);
1139
+ }
1140
+ else {
1141
+ if (typeof newStyleProperties !== 'string')
1142
+ return;
1143
+ initStyle(Style, [newStyleProperties]);
1144
+ }
1145
+ });
1089
1146
 
1090
1147
  function returnTrue() {
1091
1148
  return true;
@@ -1104,7 +1161,9 @@ function treeToArray(root, predict) {
1104
1161
  }
1105
1162
  function following(el, root) {
1106
1163
  const firstChild = el.firstChild;
1107
- if (firstChild) {
1164
+ const isElmentTypeValid = el.nodeType === 1 /* NodeType.ELEMENT_NODE */ || el.nodeType === 9 /* NodeType.DOCUMENT_NODE */;
1165
+ // 如果当前 el 不是 element 或 document 元素,则可以直接不递归他的子元素了
1166
+ if (firstChild && isElmentTypeValid) {
1108
1167
  return firstChild;
1109
1168
  }
1110
1169
  let current = el;
@@ -1345,10 +1404,10 @@ class TaroElement extends TaroNode {
1345
1404
  });
1346
1405
  }
1347
1406
  getElementsByClassName(className) {
1407
+ const classNames = className.trim().split(/\s+/);
1348
1408
  return treeToArray(this, (el) => {
1349
1409
  const classList = el.classList;
1350
- const classNames = className.trim().split(/\s+/);
1351
- return classNames.every(c => classList.has(c));
1410
+ return classNames.every(c => classList.contains(c));
1352
1411
  });
1353
1412
  }
1354
1413
  dispatchEvent(event) {
@@ -2458,7 +2517,8 @@ function eventHandler(event) {
2458
2517
  const dispatch = () => {
2459
2518
  const e = createEvent(event, node);
2460
2519
  hooks.call('modifyTaroEvent', e, node);
2461
- node.dispatchEvent(e);
2520
+ hooks.call('dispatchTaroEvent', e, node);
2521
+ hooks.call('dispatchTaroEventFinish', e, node);
2462
2522
  };
2463
2523
  if (hooks.isExist('batchedEventUpdates')) {
2464
2524
  const type = event.type;
@@ -2488,6 +2548,13 @@ function eventHandler(event) {
2488
2548
  }
2489
2549
 
2490
2550
  class FormElement extends TaroElement {
2551
+ get type() {
2552
+ var _a;
2553
+ return (_a = this.props[TYPE]) !== null && _a !== void 0 ? _a : '';
2554
+ }
2555
+ set type(val) {
2556
+ this.setAttribute(TYPE, val);
2557
+ }
2491
2558
  get value() {
2492
2559
  // eslint-disable-next-line dot-notation
2493
2560
  const val = this.props[VALUE];
@@ -2594,7 +2661,7 @@ class TaroRootElement extends TaroElement {
2594
2661
  }
2595
2662
  performUpdate(initRender = false, prerender) {
2596
2663
  this.pendingUpdate = true;
2597
- const ctx = this.ctx;
2664
+ const ctx = hooks.call('proxyToRaw', this.ctx);
2598
2665
  setTimeout(() => {
2599
2666
  const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;
2600
2667
  perf.start(setDataMark);
@@ -2747,6 +2814,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2747
2814
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2748
2815
  PERFORMANCE OF THIS SOFTWARE.
2749
2816
  ***************************************************************************** */
2817
+ /* global Reflect, Promise */
2818
+
2750
2819
 
2751
2820
  function __classPrivateFieldGet(receiver, state, kind, f) {
2752
2821
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -2879,6 +2948,12 @@ _URLSearchParams_dict = new WeakMap();
2879
2948
 
2880
2949
  var _URL_hash, _URL_hostname, _URL_pathname, _URL_port, _URL_protocol, _URL_search;
2881
2950
  class URL {
2951
+ static createObjectURL() {
2952
+ throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
2953
+ }
2954
+ static revokeObjectURL() {
2955
+ throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
2956
+ }
2882
2957
  constructor(url, base) {
2883
2958
  /* private property */
2884
2959
  _URL_hash.set(this, '');
@@ -2898,12 +2973,6 @@ class URL {
2898
2973
  __classPrivateFieldSet(this, _URL_protocol, protocol, "f");
2899
2974
  __classPrivateFieldSet(this, _URL_search, new URLSearchParams(search), "f");
2900
2975
  }
2901
- static createObjectURL() {
2902
- throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
2903
- }
2904
- static revokeObjectURL() {
2905
- throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
2906
- }
2907
2976
  /* public property */
2908
2977
  get protocol() {
2909
2978
  return __classPrivateFieldGet(this, _URL_protocol, "f");
@@ -3333,7 +3402,7 @@ class History extends Events {
3333
3402
  return __classPrivateFieldGet(this, _History_stack, "f").length;
3334
3403
  }
3335
3404
  get state() {
3336
- return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")];
3405
+ return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].state;
3337
3406
  }
3338
3407
  /* public method */
3339
3408
  go(delta) {
@@ -3829,7 +3898,7 @@ function getOnHideEventKey(path) {
3829
3898
  function createPageConfig(component, pageName, data, pageConfig) {
3830
3899
  // 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
3831
3900
  const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
3832
- const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = hooks.call('getMiniLifecycleImpl').page;
3901
+ const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES,] = hooks.call('getMiniLifecycleImpl').page;
3833
3902
  let pageElement = null;
3834
3903
  let unmounting = false;
3835
3904
  let prepareMountList = [];
@@ -3964,7 +4033,8 @@ function createPageConfig(component, pageName, data, pageConfig) {
3964
4033
  var _a;
3965
4034
  if (component[lifecycle] ||
3966
4035
  ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a[lifecycle]) ||
3967
- component[lifecycle.replace(/^on/, 'enable')]) {
4036
+ component[lifecycle.replace(/^on/, 'enable')] ||
4037
+ (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig[lifecycle.replace(/^on/, 'enable')])) {
3968
4038
  config[lifecycle] = function (...args) {
3969
4039
  var _a;
3970
4040
  const target = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.target;
@@ -4076,18 +4146,27 @@ function createRecursiveComponentConfig(componentName) {
4076
4146
  } }, lifeCycles);
4077
4147
  }
4078
4148
 
4149
+ const TIMEOUT = 100;
4079
4150
  const nextTick = (cb, ctx) => {
4080
- var _a, _b, _c;
4151
+ const beginTime = Date.now();
4081
4152
  const router = Current.router;
4082
4153
  const timerFunc = () => {
4083
4154
  setTimeout(function () {
4084
4155
  ctx ? cb.call(ctx) : cb();
4085
4156
  }, 1);
4086
4157
  };
4087
- if (router !== null) {
4088
- let pageElement = null;
4089
- const path = router.$taroPath;
4090
- pageElement = env.document.getElementById(path);
4158
+ if (router === null)
4159
+ return timerFunc();
4160
+ const path = router.$taroPath;
4161
+ /**
4162
+ * 三种情况
4163
+ * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms
4164
+ * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车
4165
+ * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。
4166
+ */
4167
+ function next() {
4168
+ var _a, _b, _c;
4169
+ const pageElement = env.document.getElementById(path);
4091
4170
  if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
4092
4171
  if (isWebPlatform()) {
4093
4172
  // eslint-disable-next-line dot-notation
@@ -4099,14 +4178,15 @@ const nextTick = (cb, ctx) => {
4099
4178
  pageElement.enqueueUpdateCallback(cb, ctx);
4100
4179
  }
4101
4180
  }
4102
- else {
4181
+ else if (Date.now() - beginTime > TIMEOUT) {
4103
4182
  timerFunc();
4104
4183
  }
4184
+ else {
4185
+ setTimeout(() => next(), 20);
4186
+ }
4105
4187
  }
4106
- else {
4107
- timerFunc();
4108
- }
4188
+ next();
4109
4189
  };
4110
4190
 
4111
- export { Current, FormElement, History, Location, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URL, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
4191
+ export { Current, FormElement, History, Location, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URL, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
4112
4192
  //# sourceMappingURL=runtime.esm.js.map