@spcsn/taro-runtime 0.1.1 → 1.0.0

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 (110) hide show
  1. package/README.md +16 -39
  2. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
  12. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
  13. package/dist/bom/{URL.js → URL2.js} +39 -30
  14. package/dist/bom/URL2.js.map +1 -0
  15. package/dist/bom/document.d.ts +0 -1
  16. package/dist/bom/document.js +1 -54
  17. package/dist/bom/document.js.map +1 -1
  18. package/dist/bom/get-computed-style.js +8 -0
  19. package/dist/bom/get-computed-style.js.map +1 -0
  20. package/dist/bom/history.d.ts +1 -5
  21. package/dist/bom/history.js +53 -40
  22. package/dist/bom/history.js.map +1 -1
  23. package/dist/bom/location.d.ts +1 -11
  24. package/dist/bom/location.js +103 -93
  25. package/dist/bom/location.js.map +1 -1
  26. package/dist/bom/navigator.js +1 -2
  27. package/dist/bom/navigator.js.map +1 -1
  28. package/dist/bom/raf.d.ts +2 -2
  29. package/dist/bom/raf.js +2 -2
  30. package/dist/bom/raf.js.map +1 -1
  31. package/dist/bom/url-search-params.d.ts +14 -0
  32. package/dist/bom/{URLSearchParams.js → url-search-params.js} +26 -25
  33. package/dist/bom/url-search-params.js.map +1 -0
  34. package/dist/bom/{URL.d.ts → url.d.ts} +2 -6
  35. package/dist/bom/url.js +196 -0
  36. package/dist/bom/url.js.map +1 -0
  37. package/dist/bom/window.d.ts +3 -3
  38. package/dist/bom/window.js +3 -3
  39. package/dist/bom/window.js.map +1 -1
  40. package/dist/current.d.ts +3 -0
  41. package/dist/current.js +10 -1
  42. package/dist/current.js.map +1 -1
  43. package/dist/dom/anchor-element.js +17 -9
  44. package/dist/dom/anchor-element.js.map +1 -1
  45. package/dist/dom/class-list.js +2 -1
  46. package/dist/dom/class-list.js.map +1 -1
  47. package/dist/dom/document.js.map +1 -1
  48. package/dist/dom/element.js +9 -8
  49. package/dist/dom/element.js.map +1 -1
  50. package/dist/dom/event-target.js +2 -4
  51. package/dist/dom/event-target.js.map +1 -1
  52. package/dist/dom/event.d.ts +1 -1
  53. package/dist/dom/event.js +19 -28
  54. package/dist/dom/event.js.map +1 -1
  55. package/dist/dom/form.js +3 -2
  56. package/dist/dom/form.js.map +1 -1
  57. package/dist/dom/node.d.ts +4 -3
  58. package/dist/dom/node.js +23 -13
  59. package/dist/dom/node.js.map +1 -1
  60. package/dist/dom/root.js +4 -6
  61. package/dist/dom/root.js.map +1 -1
  62. package/dist/dom/{style_properties.js → style-properties.js} +2 -2
  63. package/dist/dom/{style_properties.js.map → style-properties.js.map} +1 -1
  64. package/dist/dom/style.js +1 -1
  65. package/dist/dom/style.js.map +1 -1
  66. package/dist/dom/text.d.ts +1 -1
  67. package/dist/dom/text.js.map +1 -1
  68. package/dist/dom/transfer.js.map +1 -1
  69. package/dist/dom/tree.js +1 -1
  70. package/dist/dom/tree.js.map +1 -1
  71. package/dist/dom-external/mutation-observer/implements.js +1 -1
  72. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  73. package/dist/dsl/common.js +45 -63
  74. package/dist/dsl/common.js.map +1 -1
  75. package/dist/env.js +2 -2
  76. package/dist/env.js.map +1 -1
  77. package/dist/hydrate.js +11 -8
  78. package/dist/hydrate.js.map +1 -1
  79. package/dist/index.cjs.d.ts +4 -4
  80. package/dist/index.cjs.js +670 -911
  81. package/dist/index.cjs.js.map +1 -1
  82. package/dist/index.d.ts +4 -4
  83. package/dist/index.js +6 -6
  84. package/dist/next-tick.js +1 -4
  85. package/dist/next-tick.js.map +1 -1
  86. package/dist/perf.d.ts +1 -1
  87. package/dist/perf.js +10 -6
  88. package/dist/perf.js.map +1 -1
  89. package/dist/polyfill/index.js +1 -6
  90. package/dist/polyfill/index.js.map +1 -1
  91. package/dist/runtime.esm.d.ts +4 -4
  92. package/dist/runtime.esm.js +669 -911
  93. package/dist/runtime.esm.js.map +1 -1
  94. package/dist/utils/cache.js.map +1 -1
  95. package/dist/utils/index.js +9 -6
  96. package/dist/utils/index.js.map +1 -1
  97. package/dist/utils/router.js +2 -1
  98. package/dist/utils/router.js.map +1 -1
  99. package/package.json +26 -20
  100. package/LICENSE +0 -174
  101. package/dist/bom/URL.js.map +0 -1
  102. package/dist/bom/URLSearchParams.d.ts +0 -1
  103. package/dist/bom/URLSearchParams.js.map +0 -1
  104. package/dist/bom/getComputedStyle.js +0 -9
  105. package/dist/bom/getComputedStyle.js.map +0 -1
  106. package/dist/polyfill/intersection-observer.js +0 -494
  107. package/dist/polyfill/intersection-observer.js.map +0 -1
  108. /package/dist/bom/{getComputedStyle.d.ts → get-computed-style.d.ts} +0 -0
  109. /package/dist/dom/{node_types.d.ts → node-types.d.ts} +0 -0
  110. /package/dist/dom/{style_properties.d.ts → style-properties.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { DEFAULT_COMPONENTS, EMPTY_OBJ, EventChannel, Events, Shortcuts, TT_SPECIFIC_COMPONENTS, controlledComponent, ensure, getComponentsAlias as getComponentsAlias$1, hooks, hooks as hooks$1, internalComponents, isArray, isEnableTTDom, isFunction, isNull, isNumber, isObject, isString, isUndefined, noop, toCamelCase, toDashed, warn } from "@spcsn/taro-shared";
1
+ import { EMPTY_OBJ, Events, Shortcuts, controlledComponent, ensure, getComponentsAlias as getComponentsAlias$1, hooks, hooks as hooks$1, internalComponents, isArray, isFunction, isNull, isNumber, isObject, isString, isUndefined, noop, toCamelCase, toDashed, warn } from "@spcsn/taro-shared";
2
2
  //#region src/constants/index.ts
3
3
  const PROPERTY_THRESHOLD = 2046;
4
4
  const TARO_RUNTIME = "Taro runtime";
@@ -109,7 +109,7 @@ var MutationObserverImpl = class {
109
109
  };
110
110
  /** Match two TaroNodes by sid. */
111
111
  const sidMatches = (observerTarget, target) => {
112
- return !!observerTarget && observerTarget.sid === target?.sid;
112
+ return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
113
113
  };
114
114
  const isConcerned = (record, options) => {
115
115
  const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
@@ -158,7 +158,7 @@ function recordMutation(record) {
158
158
  }
159
159
  //#endregion
160
160
  //#region src/dom-external/mutation-observer/index.ts
161
- var MutationObserver$1 = class {
161
+ var MutationObserver = class {
162
162
  constructor(callback) {
163
163
  if (ENABLE_MUTATION_OBSERVER) this.core = new MutationObserverImpl(callback);
164
164
  else {
@@ -184,6 +184,67 @@ var MutationObserver$1 = class {
184
184
  }
185
185
  };
186
186
  //#endregion
187
+ //#region \0@oxc-project+runtime@0.130.0/helpers/typeof.js
188
+ function _typeof(o) {
189
+ "@babel/helpers - typeof";
190
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
191
+ return typeof o;
192
+ } : function(o) {
193
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
194
+ }, _typeof(o);
195
+ }
196
+ //#endregion
197
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPrimitive.js
198
+ function toPrimitive(t, r) {
199
+ if ("object" != _typeof(t) || !t) return t;
200
+ var e = t[Symbol.toPrimitive];
201
+ if (void 0 !== e) {
202
+ var i = e.call(t, r || "default");
203
+ if ("object" != _typeof(i)) return i;
204
+ throw new TypeError("@@toPrimitive must return a primitive value.");
205
+ }
206
+ return ("string" === r ? String : Number)(t);
207
+ }
208
+ //#endregion
209
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPropertyKey.js
210
+ function toPropertyKey(t) {
211
+ var i = toPrimitive(t, "string");
212
+ return "symbol" == _typeof(i) ? i : i + "";
213
+ }
214
+ //#endregion
215
+ //#region \0@oxc-project+runtime@0.130.0/helpers/defineProperty.js
216
+ function _defineProperty(e, r, t) {
217
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
218
+ value: t,
219
+ enumerable: !0,
220
+ configurable: !0,
221
+ writable: !0
222
+ }) : e[r] = t, e;
223
+ }
224
+ //#endregion
225
+ //#region \0@oxc-project+runtime@0.130.0/helpers/objectSpread2.js
226
+ function ownKeys(e, r) {
227
+ var t = Object.keys(e);
228
+ if (Object.getOwnPropertySymbols) {
229
+ var o = Object.getOwnPropertySymbols(e);
230
+ r && (o = o.filter(function(r) {
231
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
232
+ })), t.push.apply(t, o);
233
+ }
234
+ return t;
235
+ }
236
+ function _objectSpread2(e) {
237
+ for (var r = 1; r < arguments.length; r++) {
238
+ var t = null != arguments[r] ? arguments[r] : {};
239
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
240
+ _defineProperty(e, r, t[r]);
241
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
242
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
243
+ });
244
+ }
245
+ return e;
246
+ }
247
+ //#endregion
187
248
  //#region src/utils/lodash.ts
188
249
  function throttle(fn, threshold = 250, scope) {
189
250
  let lastTime = 0;
@@ -219,12 +280,12 @@ const eventCenter = hooks$1.call("getEventCenter", Events);
219
280
  //#endregion
220
281
  //#region src/env.ts
221
282
  const env = {
222
- window: process.env.TARO_PLATFORM === "web" ? window : EMPTY_OBJ,
223
- document: process.env.TARO_PLATFORM === "web" ? document : EMPTY_OBJ
283
+ window: EMPTY_OBJ,
284
+ document: EMPTY_OBJ
224
285
  };
225
286
  //#endregion
226
- //#region src/bom/getComputedStyle.ts
227
- const taroGetComputedStyleProvider = process.env.TARO_PLATFORM === "web" ? env.window.getComputedStyle : function(element) {
287
+ //#region src/bom/get-computed-style.ts
288
+ const taroGetComputedStyleProvider = function(element) {
228
289
  return element.style;
229
290
  };
230
291
  //#endregion
@@ -251,71 +312,103 @@ var RuntimeCache = class {
251
312
  }
252
313
  };
253
314
  //#endregion
315
+ //#region \0@oxc-project+runtime@0.130.0/helpers/checkPrivateRedeclaration.js
316
+ function _checkPrivateRedeclaration(e, t) {
317
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
318
+ }
319
+ //#endregion
320
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateMethodInitSpec.js
321
+ function _classPrivateMethodInitSpec(e, a) {
322
+ _checkPrivateRedeclaration(e, a), a.add(e);
323
+ }
324
+ //#endregion
325
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldInitSpec.js
326
+ function _classPrivateFieldInitSpec(e, t, a) {
327
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
328
+ }
329
+ //#endregion
330
+ //#region \0@oxc-project+runtime@0.130.0/helpers/assertClassBrand.js
331
+ function _assertClassBrand(e, t, n) {
332
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
333
+ throw new TypeError("Private element is not present on this object");
334
+ }
335
+ //#endregion
336
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldSet2.js
337
+ function _classPrivateFieldSet2(s, a, r) {
338
+ return s.set(_assertClassBrand(s, a), r), r;
339
+ }
340
+ //#endregion
341
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldGet2.js
342
+ function _classPrivateFieldGet2(s, a) {
343
+ return s.get(_assertClassBrand(s, a));
344
+ }
345
+ //#endregion
254
346
  //#region src/bom/history.ts
255
347
  const cache$1 = new RuntimeCache("history");
348
+ var _location = /* @__PURE__ */ new WeakMap();
349
+ var _stack = /* @__PURE__ */ new WeakMap();
350
+ var _cur = /* @__PURE__ */ new WeakMap();
351
+ var _window$1 = /* @__PURE__ */ new WeakMap();
352
+ var _TaroHistory_brand = /* @__PURE__ */ new WeakSet();
256
353
  var TaroHistory = class extends Events {
257
354
  constructor(location, options) {
258
355
  super();
259
- this._stack = [];
260
- this._cur = 0;
261
- this._window = options.window;
262
- this._location = location;
263
- this._location.on("__record_history__", (href) => {
264
- this._cur++;
265
- this._stack = this._stack.slice(0, this._cur);
266
- this._stack.push({
356
+ _classPrivateMethodInitSpec(this, _TaroHistory_brand);
357
+ _classPrivateFieldInitSpec(this, _location, void 0);
358
+ _classPrivateFieldInitSpec(this, _stack, []);
359
+ _classPrivateFieldInitSpec(this, _cur, 0);
360
+ _classPrivateFieldInitSpec(this, _window$1, void 0);
361
+ _classPrivateFieldSet2(_window$1, this, options.window);
362
+ _classPrivateFieldSet2(_location, this, location);
363
+ _classPrivateFieldGet2(_location, this).on("__record_history__", (href) => {
364
+ var _this$cur;
365
+ _classPrivateFieldSet2(_cur, this, (_this$cur = _classPrivateFieldGet2(_cur, this), _this$cur++, _this$cur));
366
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this)));
367
+ _classPrivateFieldGet2(_stack, this).push({
267
368
  state: null,
268
369
  title: "",
269
370
  url: href
270
371
  });
271
372
  }, null);
272
- this._location.on("__reset_history__", (href) => {
273
- this._reset(href);
373
+ _classPrivateFieldGet2(_location, this).on("__reset_history__", (href) => {
374
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this, href);
274
375
  }, null);
275
376
  this.on("0", () => {
276
- this._reset();
377
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
277
378
  }, null);
278
379
  this.on("1", (pageId) => {
279
380
  cache$1.set(pageId, {
280
- location: this._location,
281
- stack: this._stack.slice(),
282
- cur: this._cur
381
+ location: _classPrivateFieldGet2(_location, this),
382
+ stack: _classPrivateFieldGet2(_stack, this).slice(),
383
+ cur: _classPrivateFieldGet2(_cur, this)
283
384
  });
284
385
  }, null);
285
386
  this.on("2", (pageId) => {
286
387
  if (cache$1.has(pageId)) {
287
388
  const ctx = cache$1.get(pageId);
288
- this._location = ctx.location;
289
- this._stack = ctx.stack;
290
- this._cur = ctx.cur;
389
+ _classPrivateFieldSet2(_location, this, ctx.location);
390
+ _classPrivateFieldSet2(_stack, this, ctx.stack);
391
+ _classPrivateFieldSet2(_cur, this, ctx.cur);
291
392
  }
292
393
  }, null);
293
394
  this.on("3", (pageId) => {
294
395
  cache$1.delete(pageId);
295
396
  }, null);
296
- this._reset();
297
- }
298
- _reset(href = "") {
299
- this._stack = [{
300
- state: null,
301
- title: "",
302
- url: href || this._location.href
303
- }];
304
- this._cur = 0;
397
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
305
398
  }
306
399
  get length() {
307
- return this._stack.length;
400
+ return _classPrivateFieldGet2(_stack, this).length;
308
401
  }
309
402
  get state() {
310
- return this._stack[this._cur].state;
403
+ return _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].state;
311
404
  }
312
405
  go(delta) {
313
406
  if (!isNumber(delta) || isNaN(delta)) return;
314
- let targetIdx = this._cur + delta;
407
+ let targetIdx = _classPrivateFieldGet2(_cur, this) + delta;
315
408
  targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
316
- this._cur = targetIdx;
317
- this._location.trigger("__set_href_without_history__", this._stack[this._cur].url);
318
- this._window.trigger("popstate", this._stack[this._cur]);
409
+ _classPrivateFieldSet2(_cur, this, targetIdx);
410
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].url);
411
+ _classPrivateFieldGet2(_window$1, this).trigger("popstate", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)]);
319
412
  }
320
413
  back() {
321
414
  this.go(-1);
@@ -325,29 +418,37 @@ var TaroHistory = class extends Events {
325
418
  }
326
419
  pushState(state, title, url) {
327
420
  if (!url || !isString(url)) return;
328
- this._stack = this._stack.slice(0, this._cur + 1);
329
- this._stack.push({
421
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this) + 1));
422
+ _classPrivateFieldGet2(_stack, this).push({
330
423
  state,
331
424
  title,
332
425
  url
333
426
  });
334
- this._cur = this.length - 1;
335
- this._location.trigger("__set_href_without_history__", url);
427
+ _classPrivateFieldSet2(_cur, this, this.length - 1);
428
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
336
429
  }
337
430
  replaceState(state, title, url) {
338
431
  if (!url || !isString(url)) return;
339
- this._stack[this._cur] = {
432
+ _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)] = {
340
433
  state,
341
434
  title,
342
435
  url
343
436
  };
344
- this._location.trigger("__set_href_without_history__", url);
437
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
345
438
  }
346
439
  get cache() {
347
440
  return cache$1;
348
441
  }
349
442
  };
350
- const History = process.env.TARO_PLATFORM === "web" ? env.window.History : TaroHistory;
443
+ function _reset$1(href = "") {
444
+ _classPrivateFieldSet2(_stack, this, [{
445
+ state: null,
446
+ title: "",
447
+ url: href || _classPrivateFieldGet2(_location, this).href
448
+ }]);
449
+ _classPrivateFieldSet2(_cur, this, 0);
450
+ }
451
+ const History = TaroHistory;
351
452
  //#endregion
352
453
  //#region src/current.ts
353
454
  const Current = {
@@ -355,9 +456,18 @@ const Current = {
355
456
  router: null,
356
457
  page: null
357
458
  };
459
+ const appReadyCallbacks = [];
460
+ function setCurrentApp(app) {
461
+ Current.app = app;
462
+ while (appReadyCallbacks.length) appReadyCallbacks.shift()(app);
463
+ }
464
+ function whenAppReady(callback) {
465
+ if (Current.app) callback(Current.app);
466
+ else appReadyCallbacks.push(callback);
467
+ }
358
468
  const getCurrentInstance = () => Current;
359
469
  //#endregion
360
- //#region src/bom/URLSearchParams.ts
470
+ //#region src/bom/url-search-params.ts
361
471
  const findReg = /[!'()~]|%20|%00/g;
362
472
  const plusReg = /\+/g;
363
473
  const replaceCharMap = {
@@ -377,20 +487,19 @@ function appendTo(dict, name, value) {
377
487
  if (name in dict) dict[name].push(res);
378
488
  else dict[name] = [res];
379
489
  }
380
- function addEach(value, key) {
381
- appendTo(this, key, value);
382
- }
383
490
  function decode(str) {
384
491
  return decodeURIComponent(str.replace(plusReg, " "));
385
492
  }
386
493
  function encode(str) {
387
494
  return encodeURIComponent(str).replace(findReg, replacer);
388
495
  }
389
- const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : class {
496
+ var _dict = /* @__PURE__ */ new WeakMap();
497
+ var URLSearchParams = class {
390
498
  constructor(query) {
391
- this._dict = Object.create(null);
392
- query ??= "";
393
- const dict = this._dict;
499
+ var _query;
500
+ _classPrivateFieldInitSpec(this, _dict, Object.create(null));
501
+ (_query = query) !== null && _query !== void 0 || (query = "");
502
+ const dict = _classPrivateFieldGet2(_dict, this);
394
503
  if (typeof query === "string") {
395
504
  if (query.charAt(0) === "?") query = query.slice(1);
396
505
  for (let pairs = query.split("&"), i = 0, length = pairs.length; i < length; i++) {
@@ -407,45 +516,46 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
407
516
  const value = query[i];
408
517
  appendTo(dict, value[0], value[1]);
409
518
  }
410
- else if (query.forEach) query.forEach(addEach, dict);
519
+ else if (query.forEach) query.forEach((value, key) => appendTo(dict, key, value));
411
520
  else for (const key in query) appendTo(dict, key, query[key]);
412
521
  }
413
522
  append(name, value) {
414
- appendTo(this._dict, name, value);
523
+ appendTo(_classPrivateFieldGet2(_dict, this), name, value);
415
524
  }
416
525
  delete(name) {
417
- delete this._dict[name];
526
+ delete _classPrivateFieldGet2(_dict, this)[name];
418
527
  }
419
528
  get(name) {
420
- const dict = this._dict;
529
+ const dict = _classPrivateFieldGet2(_dict, this);
421
530
  return name in dict ? dict[name][0] : null;
422
531
  }
423
532
  getAll(name) {
424
- const dict = this._dict;
533
+ const dict = _classPrivateFieldGet2(_dict, this);
425
534
  return name in dict ? dict[name].slice(0) : [];
426
535
  }
427
536
  has(name) {
428
- return name in this._dict;
537
+ return name in _classPrivateFieldGet2(_dict, this);
429
538
  }
430
539
  keys() {
431
- return Object.keys(this._dict);
540
+ return Object.keys(_classPrivateFieldGet2(_dict, this));
432
541
  }
433
542
  set(name, value) {
434
- this._dict[name] = ["" + value];
543
+ _classPrivateFieldGet2(_dict, this)[name] = ["" + value];
435
544
  }
436
545
  forEach(callback, thisArg) {
437
- const dict = this._dict;
438
- Object.getOwnPropertyNames(dict).forEach(function(name) {
439
- dict[name].forEach(function(value) {
440
- callback.call(thisArg, value, name, this);
441
- }, this);
442
- }, this);
546
+ const dict = _classPrivateFieldGet2(_dict, this);
547
+ const searchParams = this;
548
+ Object.getOwnPropertyNames(dict).forEach((name) => {
549
+ dict[name].forEach((value) => {
550
+ callback.call(thisArg, value, name, searchParams);
551
+ });
552
+ });
443
553
  }
444
554
  toJSON() {
445
555
  return {};
446
556
  }
447
557
  toString() {
448
- const dict = this._dict;
558
+ const dict = _classPrivateFieldGet2(_dict, this);
449
559
  const query = [];
450
560
  for (const key in dict) {
451
561
  const name = encode(key);
@@ -455,8 +565,14 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
455
565
  }
456
566
  };
457
567
  //#endregion
458
- //#region src/bom/URL.ts
459
- var TaroURL = class {
568
+ //#region src/bom/url.ts
569
+ var _hash$1 = /* @__PURE__ */ new WeakMap();
570
+ var _hostname$1 = /* @__PURE__ */ new WeakMap();
571
+ var _pathname$1 = /* @__PURE__ */ new WeakMap();
572
+ var _port$1 = /* @__PURE__ */ new WeakMap();
573
+ var _protocol$1 = /* @__PURE__ */ new WeakMap();
574
+ var _search$1 = /* @__PURE__ */ new WeakMap();
575
+ var TaroURL$1 = class {
460
576
  static createObjectURL() {
461
577
  throw new Error("Oops, not support URL.createObjectURL() in miniprogram.");
462
578
  }
@@ -464,25 +580,26 @@ var TaroURL = class {
464
580
  throw new Error("Oops, not support URL.revokeObjectURL() in miniprogram.");
465
581
  }
466
582
  constructor(url, base) {
467
- this._hash = "";
468
- this._hostname = "";
469
- this._pathname = "";
470
- this._port = "";
471
- this._protocol = "";
583
+ _classPrivateFieldInitSpec(this, _hash$1, "");
584
+ _classPrivateFieldInitSpec(this, _hostname$1, "");
585
+ _classPrivateFieldInitSpec(this, _pathname$1, "");
586
+ _classPrivateFieldInitSpec(this, _port$1, "");
587
+ _classPrivateFieldInitSpec(this, _protocol$1, "");
588
+ _classPrivateFieldInitSpec(this, _search$1, void 0);
472
589
  if (!isString(url)) url = String(url);
473
- const { hash, hostname, pathname, port, protocol, search } = parseUrlBase(url, base);
474
- this._hash = hash;
475
- this._hostname = hostname;
476
- this._pathname = pathname || "/";
477
- this._port = port;
478
- this._protocol = protocol;
479
- this._search = new URLSearchParams(search);
590
+ const { hash, hostname, pathname, port, protocol, search } = parseUrlBase$1(url, base);
591
+ _classPrivateFieldSet2(_hash$1, this, hash);
592
+ _classPrivateFieldSet2(_hostname$1, this, hostname);
593
+ _classPrivateFieldSet2(_pathname$1, this, pathname || "/");
594
+ _classPrivateFieldSet2(_port$1, this, port);
595
+ _classPrivateFieldSet2(_protocol$1, this, protocol);
596
+ _classPrivateFieldSet2(_search$1, this, new URLSearchParams(search));
480
597
  }
481
598
  get protocol() {
482
- return this._protocol;
599
+ return _classPrivateFieldGet2(_protocol$1, this);
483
600
  }
484
601
  set protocol(val) {
485
- isString(val) && (this._protocol = val.trim());
602
+ isString(val) && _classPrivateFieldSet2(_protocol$1, this, val.trim());
486
603
  }
487
604
  get host() {
488
605
  return this.hostname + (this.port ? ":" + this.port : "");
@@ -490,25 +607,25 @@ var TaroURL = class {
490
607
  set host(val) {
491
608
  if (val && isString(val)) {
492
609
  val = val.trim();
493
- const { hostname, port } = parseUrl(`//${val}`);
610
+ const { hostname, port } = parseUrl$1(`//${val}`);
494
611
  this.hostname = hostname;
495
612
  this.port = port;
496
613
  }
497
614
  }
498
615
  get hostname() {
499
- return this._hostname;
616
+ return _classPrivateFieldGet2(_hostname$1, this);
500
617
  }
501
618
  set hostname(val) {
502
- val && isString(val) && (this._hostname = val.trim());
619
+ val && isString(val) && _classPrivateFieldSet2(_hostname$1, this, val.trim());
503
620
  }
504
621
  get port() {
505
- return this._port;
622
+ return _classPrivateFieldGet2(_port$1, this);
506
623
  }
507
624
  set port(val) {
508
- isString(val) && (this._port = val.trim());
625
+ isString(val) && _classPrivateFieldSet2(_port$1, this, val.trim());
509
626
  }
510
627
  get pathname() {
511
- return this._pathname;
628
+ return _classPrivateFieldGet2(_pathname$1, this);
512
629
  }
513
630
  set pathname(val) {
514
631
  if (isString(val)) {
@@ -516,28 +633,28 @@ var TaroURL = class {
516
633
  const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
517
634
  let temp = val;
518
635
  while (HEAD_REG.test(temp)) temp = temp.replace(HEAD_REG, "");
519
- if (temp) this._pathname = "/" + temp;
520
- else this._pathname = "/";
636
+ if (temp) _classPrivateFieldSet2(_pathname$1, this, "/" + temp);
637
+ else _classPrivateFieldSet2(_pathname$1, this, "/");
521
638
  }
522
639
  }
523
640
  get search() {
524
- const val = this._search.toString();
641
+ const val = _classPrivateFieldGet2(_search$1, this).toString();
525
642
  return val.length === 0 || val.startsWith("?") ? val : `?${val}`;
526
643
  }
527
644
  set search(val) {
528
645
  if (isString(val)) {
529
646
  val = val.trim();
530
- this._search = new URLSearchParams(val);
647
+ _classPrivateFieldSet2(_search$1, this, new URLSearchParams(val));
531
648
  }
532
649
  }
533
650
  get hash() {
534
- return this._hash;
651
+ return _classPrivateFieldGet2(_hash$1, this);
535
652
  }
536
653
  set hash(val) {
537
654
  if (isString(val)) {
538
655
  val = val.trim();
539
- if (val) this._hash = val.startsWith("#") ? val : `#${val}`;
540
- else this._hash = "";
656
+ if (val) _classPrivateFieldSet2(_hash$1, this, val.startsWith("#") ? val : `#${val}`);
657
+ else _classPrivateFieldSet2(_hash$1, this, "");
541
658
  }
542
659
  }
543
660
  get href() {
@@ -546,7 +663,7 @@ var TaroURL = class {
546
663
  set href(val) {
547
664
  if (val && isString(val)) {
548
665
  val = val.trim();
549
- const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
666
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl$1(val);
550
667
  this.protocol = protocol;
551
668
  this.hostname = hostname;
552
669
  this.pathname = pathname;
@@ -561,14 +678,14 @@ var TaroURL = class {
561
678
  set origin(val) {
562
679
  if (val && isString(val)) {
563
680
  val = val.trim();
564
- const { protocol, hostname, port } = parseUrl(val);
681
+ const { protocol, hostname, port } = parseUrl$1(val);
565
682
  this.protocol = protocol;
566
683
  this.hostname = hostname;
567
684
  this.port = port;
568
685
  }
569
686
  }
570
687
  get searchParams() {
571
- return this._search;
688
+ return _classPrivateFieldGet2(_search$1, this);
572
689
  }
573
690
  toString() {
574
691
  return this.href;
@@ -590,8 +707,8 @@ var TaroURL = class {
590
707
  };
591
708
  }
592
709
  };
593
- const TaroURLProvider = process.env.TARO_PLATFORM === "web" ? env.window.URL : TaroURL;
594
- function parseUrl(url = "") {
710
+ const TaroURLProvider$1 = TaroURL$1;
711
+ function parseUrl$1(url = "") {
595
712
  const result = {
596
713
  href: "",
597
714
  origin: "",
@@ -618,14 +735,14 @@ function parseUrl(url = "") {
618
735
  result.host = result.hostname + (result.port ? `:${result.port}` : "");
619
736
  return result;
620
737
  }
621
- function parseUrlBase(url, base) {
738
+ function parseUrlBase$1(url, base) {
622
739
  const VALID_URL = /^(https?:)\/\//i;
623
740
  let fullUrl = "";
624
741
  let parsedBase = null;
625
742
  if (!isUndefined(base)) {
626
743
  base = String(base).trim();
627
744
  if (!VALID_URL.test(base)) throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
628
- parsedBase = parseUrl(base);
745
+ parsedBase = parseUrl$1(base);
629
746
  }
630
747
  url = String(url).trim();
631
748
  if (VALID_URL.test(url)) fullUrl = url;
@@ -633,28 +750,34 @@ function parseUrlBase(url, base) {
633
750
  else fullUrl = parsedBase.origin + (url.startsWith("/") ? url : `/${url}`);
634
751
  else fullUrl = parsedBase.href;
635
752
  else throw new TypeError(`Failed to construct 'URL': Invalid URL`);
636
- return parseUrl(fullUrl);
753
+ return parseUrl$1(fullUrl);
637
754
  }
638
755
  //#endregion
639
756
  //#region src/bom/location.ts
640
757
  const INIT_URL = "https://taro.com";
641
758
  const cache = new RuntimeCache("location");
759
+ var _url = /* @__PURE__ */ new WeakMap();
760
+ var _noCheckUrl = /* @__PURE__ */ new WeakMap();
761
+ var _window = /* @__PURE__ */ new WeakMap();
762
+ var _TaroLocation_brand = /* @__PURE__ */ new WeakSet();
642
763
  var TaroLocation = class extends Events {
643
764
  constructor(options) {
644
765
  super();
645
- this._url = new TaroURLProvider(INIT_URL);
646
- this._noCheckUrl = false;
647
- this._window = options.window;
648
- this._reset();
766
+ _classPrivateMethodInitSpec(this, _TaroLocation_brand);
767
+ _classPrivateFieldInitSpec(this, _url, new TaroURLProvider$1(INIT_URL));
768
+ _classPrivateFieldInitSpec(this, _noCheckUrl, false);
769
+ _classPrivateFieldInitSpec(this, _window, void 0);
770
+ _classPrivateFieldSet2(_window, this, options.window);
771
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
649
772
  this.on("__set_href_without_history__", (href) => {
650
- this._noCheckUrl = true;
651
- const lastHash = this._url.hash;
652
- this._url.href = generateFullUrl(href);
653
- if (lastHash !== this._url.hash) this._window.trigger("hashchange");
654
- this._noCheckUrl = false;
773
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
774
+ const lastHash = _classPrivateFieldGet2(_url, this).hash;
775
+ _classPrivateFieldGet2(_url, this).href = generateFullUrl(href);
776
+ if (lastHash !== _classPrivateFieldGet2(_url, this).hash) _classPrivateFieldGet2(_window, this).trigger("hashchange");
777
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
655
778
  }, null);
656
779
  this.on("0", () => {
657
- this._reset();
780
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
658
781
  }, null);
659
782
  this.on("1", (pageId) => {
660
783
  cache.set(pageId, { lastHref: this.href });
@@ -662,145 +785,104 @@ var TaroLocation = class extends Events {
662
785
  this.on("2", (pageId) => {
663
786
  if (cache.has(pageId)) {
664
787
  const ctx = cache.get(pageId);
665
- this._noCheckUrl = true;
666
- this._url.href = ctx.lastHref;
667
- this._noCheckUrl = false;
788
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
789
+ _classPrivateFieldGet2(_url, this).href = ctx.lastHref;
790
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
668
791
  }
669
792
  }, null);
670
793
  this.on("3", (pageId) => {
671
794
  cache.delete(pageId);
672
795
  }, null);
673
796
  }
674
- _reset() {
675
- const router = getCurrentInstance().router;
676
- if (router) {
677
- const { path, params } = router;
678
- const searchArr = Object.keys(params).map((key) => {
679
- return `${key}=${params[key]}`;
680
- });
681
- const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
682
- const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
683
- this._url = new TaroURLProvider(url);
684
- this.trigger("__reset_history__", this.href);
685
- }
686
- }
687
- _getPreValue() {
688
- return this._url._toRaw();
689
- }
690
- _rollBack(href) {
691
- this._url.href = href;
692
- }
693
- _recordHistory() {
694
- this.trigger("__record_history__", this.href);
695
- }
696
- /**
697
- * 校验url的变化,是否需要更新history
698
- */
699
- _checkUrlChange(preValue) {
700
- if (this._noCheckUrl) return false;
701
- const { protocol, hostname, port, pathname, search, hash } = this._url._toRaw();
702
- if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
703
- this._rollBack(preValue.href);
704
- return false;
705
- }
706
- if (pathname !== preValue.pathname) return true;
707
- if (search !== preValue.search) return true;
708
- if (hash !== preValue.hash) {
709
- this._window.trigger("hashchange");
710
- return true;
711
- }
712
- this._rollBack(preValue.href);
713
- return false;
714
- }
715
797
  get protocol() {
716
- return this._url.protocol;
798
+ return _classPrivateFieldGet2(_url, this).protocol;
717
799
  }
718
800
  set protocol(val) {
719
801
  if (!val || !isString(val) || !/^(http|https):$/i.test(val.trim())) return;
720
802
  val = val.trim();
721
- const preValue = this._getPreValue();
722
- this._url.protocol = val;
723
- if (this._checkUrlChange(preValue)) this._recordHistory();
803
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
804
+ _classPrivateFieldGet2(_url, this).protocol = val;
805
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
724
806
  }
725
807
  get host() {
726
- return this._url.host;
808
+ return _classPrivateFieldGet2(_url, this).host;
727
809
  }
728
810
  set host(val) {
729
811
  if (!val || !isString(val)) return;
730
812
  val = val.trim();
731
- const preValue = this._getPreValue();
732
- this._url.host = val;
733
- if (this._checkUrlChange(preValue)) this._recordHistory();
813
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
814
+ _classPrivateFieldGet2(_url, this).host = val;
815
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
734
816
  }
735
817
  get hostname() {
736
- return this._url.hostname;
818
+ return _classPrivateFieldGet2(_url, this).hostname;
737
819
  }
738
820
  set hostname(val) {
739
821
  if (!val || !isString(val)) return;
740
822
  val = val.trim();
741
- const preValue = this._getPreValue();
742
- this._url.hostname = val;
743
- if (this._checkUrlChange(preValue)) this._recordHistory();
823
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
824
+ _classPrivateFieldGet2(_url, this).hostname = val;
825
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
744
826
  }
745
827
  get port() {
746
- return this._url.port;
828
+ return _classPrivateFieldGet2(_url, this).port;
747
829
  }
748
830
  set port(val) {
749
831
  const xVal = Number(val = val.trim());
750
832
  if (!isNumber(xVal) || xVal <= 0) return;
751
- const preValue = this._getPreValue();
752
- this._url.port = val;
753
- if (this._checkUrlChange(preValue)) this._recordHistory();
833
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
834
+ _classPrivateFieldGet2(_url, this).port = val;
835
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
754
836
  }
755
837
  get pathname() {
756
- return this._url.pathname;
838
+ return _classPrivateFieldGet2(_url, this).pathname;
757
839
  }
758
840
  set pathname(val) {
759
841
  if (!val || !isString(val)) return;
760
842
  val = val.trim();
761
- const preValue = this._getPreValue();
762
- this._url.pathname = val;
763
- if (this._checkUrlChange(preValue)) this._recordHistory();
843
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
844
+ _classPrivateFieldGet2(_url, this).pathname = val;
845
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
764
846
  }
765
847
  get search() {
766
- return this._url.search;
848
+ return _classPrivateFieldGet2(_url, this).search;
767
849
  }
768
850
  set search(val) {
769
851
  if (!val || !isString(val)) return;
770
852
  val = val.trim();
771
853
  val = val.startsWith("?") ? val : `?${val}`;
772
- const preValue = this._getPreValue();
773
- this._url.search = val;
774
- if (this._checkUrlChange(preValue)) this._recordHistory();
854
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
855
+ _classPrivateFieldGet2(_url, this).search = val;
856
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
775
857
  }
776
858
  get hash() {
777
- return this._url.hash;
859
+ return _classPrivateFieldGet2(_url, this).hash;
778
860
  }
779
861
  set hash(val) {
780
862
  if (!val || !isString(val)) return;
781
863
  val = val.trim();
782
864
  val = val.startsWith("#") ? val : `#${val}`;
783
- const preValue = this._getPreValue();
784
- this._url.hash = val;
785
- if (this._checkUrlChange(preValue)) this._recordHistory();
865
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
866
+ _classPrivateFieldGet2(_url, this).hash = val;
867
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
786
868
  }
787
869
  get href() {
788
- return this._url.href;
870
+ return _classPrivateFieldGet2(_url, this).href;
789
871
  }
790
872
  set href(val) {
791
873
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
792
- const preValue = this._getPreValue();
793
- this._url.href = val;
794
- if (this._checkUrlChange(preValue)) this._recordHistory();
874
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
875
+ _classPrivateFieldGet2(_url, this).href = val;
876
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
795
877
  }
796
878
  get origin() {
797
- return this._url.origin;
879
+ return _classPrivateFieldGet2(_url, this).origin;
798
880
  }
799
881
  set origin(val) {
800
882
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
801
- const preValue = this._getPreValue();
802
- this._url.origin = val;
803
- if (this._checkUrlChange(preValue)) this._recordHistory();
883
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
884
+ _classPrivateFieldGet2(_url, this).origin = val;
885
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
804
886
  }
805
887
  assign() {
806
888
  warn(true, "小程序环境中调用location.assign()无效.");
@@ -818,7 +900,48 @@ var TaroLocation = class extends Events {
818
900
  return cache;
819
901
  }
820
902
  };
821
- const Location = process.env.TARO_PLATFORM === "web" ? env.window.Location : TaroLocation;
903
+ function _reset() {
904
+ const router = getCurrentInstance().router;
905
+ if (router) {
906
+ const { path, params } = router;
907
+ const searchArr = Object.keys(params).map((key) => {
908
+ return `${key}=${params[key]}`;
909
+ });
910
+ const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
911
+ const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
912
+ _classPrivateFieldSet2(_url, this, new TaroURLProvider$1(url));
913
+ this.trigger("__reset_history__", this.href);
914
+ }
915
+ }
916
+ function _getPreValue() {
917
+ return _classPrivateFieldGet2(_url, this)._toRaw();
918
+ }
919
+ function _rollBack(href) {
920
+ _classPrivateFieldGet2(_url, this).href = href;
921
+ }
922
+ function _recordHistory() {
923
+ this.trigger("__record_history__", this.href);
924
+ }
925
+ /**
926
+ * 校验url的变化,是否需要更新history
927
+ */
928
+ function _checkUrlChange(preValue) {
929
+ if (_classPrivateFieldGet2(_noCheckUrl, this)) return false;
930
+ const { protocol, hostname, port, pathname, search, hash } = _classPrivateFieldGet2(_url, this)._toRaw();
931
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
932
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
933
+ return false;
934
+ }
935
+ if (pathname !== preValue.pathname) return true;
936
+ if (search !== preValue.search) return true;
937
+ if (hash !== preValue.hash) {
938
+ _classPrivateFieldGet2(_window, this).trigger("hashchange");
939
+ return true;
940
+ }
941
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
942
+ return false;
943
+ }
944
+ const Location = TaroLocation;
822
945
  function generateFullUrl(val = "") {
823
946
  const origin = INIT_URL;
824
947
  if (/^[/?#]/.test(val)) return origin + val;
@@ -827,7 +950,7 @@ function generateFullUrl(val = "") {
827
950
  //#endregion
828
951
  //#region src/bom/navigator.ts
829
952
  const msg = "(Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36";
830
- const nav = process.env.TARO_PLATFORM === "web" ? env.window.navigator : {
953
+ const nav = {
831
954
  appCodeName: "Mozilla",
832
955
  appName: "Netscape",
833
956
  appVersion: "5.0 " + msg,
@@ -857,14 +980,14 @@ let now;
857
980
  }
858
981
  })();
859
982
  let lastTime = 0;
860
- const _raf = process.env.TARO_PLATFORM === "web" ? requestAnimationFrame : function(callback) {
983
+ const _raf = function(callback) {
861
984
  const _now = now();
862
985
  const nextTime = Math.max(lastTime + 16, _now);
863
986
  return setTimeout(function() {
864
987
  callback(lastTime = nextTime);
865
988
  }, nextTime - _now);
866
989
  };
867
- const _caf = process.env.TARO_PLATFORM === "web" ? cancelAnimationFrame : function(seed) {
990
+ const _caf = function(seed) {
868
991
  clearTimeout(seed);
869
992
  };
870
993
  //#endregion
@@ -884,7 +1007,7 @@ var TaroWindow = class extends Events {
884
1007
  console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
885
1008
  }
886
1009
  });
887
- this.Date ||= Date;
1010
+ this.Date || (this.Date = Date);
888
1011
  this.location = new Location({ window: this });
889
1012
  this.history = new History(this.location, { window: this });
890
1013
  this.initEvent();
@@ -926,7 +1049,7 @@ var TaroWindow = class extends Events {
926
1049
  return clearTimeout(...args);
927
1050
  }
928
1051
  };
929
- const taroWindowProvider = process.env.TARO_PLATFORM === "web" ? env.window : env.window = new TaroWindow();
1052
+ const taroWindowProvider = env.window = new TaroWindow();
930
1053
  const taroLocationProvider = taroWindowProvider.location;
931
1054
  const taroHistoryProvider = taroWindowProvider.history;
932
1055
  //#endregion
@@ -937,8 +1060,9 @@ const stripBasename = (path = "", prefix = "") => hasBasename(path, prefix) ? pa
937
1060
  const stripTrailing = (str = "") => str.replace(/[?#][\s\S]*$/, "");
938
1061
  const stripSuffix = (path = "", suffix = "") => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
939
1062
  const getHomePage = (path = "", basename = "", customRoutes = {}, entryPagePath = "") => {
1063
+ var _Object$entries$find;
940
1064
  const routePath = addLeadingSlash(stripBasename(path, basename));
941
- const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;
1065
+ const alias = ((_Object$entries$find = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1]) || routePath;
942
1066
  return entryPagePath || (typeof alias === "string" ? alias : alias[0]) || basename;
943
1067
  };
944
1068
  const getCurrentPage = (routerMode = "hash", basename = "/") => {
@@ -990,8 +1114,11 @@ function isHasExtractProp(el) {
990
1114
  * @param type 事件类型
991
1115
  */
992
1116
  function isParentBound(node, type) {
993
- while (node = node?.parentElement || null) if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
994
- else if (node.__handlers[type]?.length) return true;
1117
+ while (node = (node === null || node === void 0 ? void 0 : node.parentElement) || null) {
1118
+ var _node$__handlers$type;
1119
+ if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
1120
+ else if ((_node$__handlers$type = node.__handlers[type]) === null || _node$__handlers$type === void 0 ? void 0 : _node$__handlers$type.length) return true;
1121
+ }
995
1122
  return false;
996
1123
  }
997
1124
  function shortcutAttr(key) {
@@ -1005,11 +1132,10 @@ function shortcutAttr(key) {
1005
1132
  const customWrapperCache = /* @__PURE__ */ new Map();
1006
1133
  function extend(ctor, methodName, options) {
1007
1134
  if (isFunction(options)) options = { value: options };
1008
- Object.defineProperty(ctor.prototype, methodName, {
1135
+ Object.defineProperty(ctor.prototype, methodName, _objectSpread2({
1009
1136
  configurable: true,
1010
- enumerable: true,
1011
- ...options
1012
- });
1137
+ enumerable: true
1138
+ }, options));
1013
1139
  }
1014
1140
  let componentsAlias$1;
1015
1141
  function getComponentsAlias() {
@@ -1072,7 +1198,8 @@ var ClassList = class {
1072
1198
  toggle(token, force) {
1073
1199
  const result = this.contains(token);
1074
1200
  const method = result ? force !== true && "remove" : force !== false && "add";
1075
- if (method) this[method](token);
1201
+ if (method === "add") this.add(token);
1202
+ if (method === "remove") this.remove(token);
1076
1203
  if (force === true || force === false) return force;
1077
1204
  else return !result;
1078
1205
  }
@@ -1121,15 +1248,18 @@ let componentsAlias;
1121
1248
  * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
1122
1249
  */
1123
1250
  function hydrate(node) {
1124
- componentsAlias ||= getComponentsAlias();
1125
- SPECIAL_NODES ||= hooks$1.call("getSpecialNodes");
1251
+ componentsAlias || (componentsAlias = getComponentsAlias());
1252
+ SPECIAL_NODES || (SPECIAL_NODES = hooks$1.call("getSpecialNodes"));
1126
1253
  const nodeName = node.nodeName;
1127
1254
  let compileModeName = null;
1128
- if (isText(node)) return {
1129
- sid: node.sid,
1130
- [Shortcuts.Text]: node.nodeValue,
1131
- [Shortcuts.NodeName]: componentsAlias[nodeName]?._num || "8"
1132
- };
1255
+ if (isText(node)) {
1256
+ var _componentsAlias$node;
1257
+ return {
1258
+ sid: node.sid,
1259
+ [Shortcuts.Text]: node.nodeValue,
1260
+ [Shortcuts.NodeName]: ((_componentsAlias$node = componentsAlias[nodeName]) === null || _componentsAlias$node === void 0 ? void 0 : _componentsAlias$node._num) || "8"
1261
+ };
1262
+ }
1133
1263
  const data = {
1134
1264
  [Shortcuts.NodeName]: nodeName,
1135
1265
  sid: node.sid
@@ -1146,7 +1276,7 @@ function hydrate(node) {
1146
1276
  for (const prop in props) {
1147
1277
  const propInCamelCase = toCamelCase(prop);
1148
1278
  if (!prop.startsWith("data-") && prop !== "class" && prop !== "style" && prop !== "id" && propInCamelCase !== "catchMove" && propInCamelCase !== "compileMode") data[propInCamelCase] = props[prop];
1149
- if (process.env.TARO_ENV !== "swan" && nodeName === "view" && propInCamelCase === "catchMove" && props[prop] !== false) data[Shortcuts.NodeName] = CATCH_VIEW;
1279
+ if (nodeName === "view" && propInCamelCase === "catchMove" && props[prop] !== false) data[Shortcuts.NodeName] = CATCH_VIEW;
1150
1280
  if (propInCamelCase === "compileMode") compileModeName = props[prop];
1151
1281
  }
1152
1282
  data[Shortcuts.Childnodes] = node.childNodes.filter((node) => !isComment(node)).map(hydrate);
@@ -1191,10 +1321,7 @@ var TaroEventTarget = class {
1191
1321
  handler.apply(this, arguments);
1192
1322
  this.removeEventListener(type, wrapper);
1193
1323
  };
1194
- this.addEventListener(type, wrapper, {
1195
- ...options,
1196
- once: false
1197
- });
1324
+ this.addEventListener(type, wrapper, _objectSpread2(_objectSpread2({}, options), {}, { once: false }));
1198
1325
  return;
1199
1326
  }
1200
1327
  warn(isCapture, "Taro 暂未实现 event 的 capture 特性。");
@@ -1251,7 +1378,7 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1251
1378
  updateChildNodes(isClean) {
1252
1379
  const cleanChildNodes = () => [];
1253
1380
  const rerenderChildNodes = () => {
1254
- return this.childNodes.filter((node) => !isComment(node)).map(hydrate);
1381
+ return this.childNodes.filter((node) => !isComment(node)).map((childNode) => hydrate(childNode));
1255
1382
  };
1256
1383
  this.enqueueUpdate({
1257
1384
  path: `${this._path}.${CHILDNODES}`,
@@ -1269,7 +1396,8 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1269
1396
  });
1270
1397
  }
1271
1398
  get _root() {
1272
- return this.parentNode?._root || null;
1399
+ var _this$parentNode;
1400
+ return ((_this$parentNode = this.parentNode) === null || _this$parentNode === void 0 ? void 0 : _this$parentNode._root) || null;
1273
1401
  }
1274
1402
  findIndex(refChild) {
1275
1403
  const index = this.childNodes.indexOf(refChild);
@@ -1287,15 +1415,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1287
1415
  }
1288
1416
  get nextSibling() {
1289
1417
  const parentNode = this.parentNode;
1290
- return parentNode?.childNodes[parentNode.findIndex(this) + 1] || null;
1418
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) + 1]) || null;
1291
1419
  }
1292
1420
  get previousSibling() {
1293
1421
  const parentNode = this.parentNode;
1294
- return parentNode?.childNodes[parentNode.findIndex(this) - 1] || null;
1422
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) - 1]) || null;
1295
1423
  }
1296
1424
  get parentElement() {
1297
1425
  const parentNode = this.parentNode;
1298
- if (parentNode?.nodeType === 1) return parentNode;
1426
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeType) === 1) return parentNode;
1299
1427
  return null;
1300
1428
  }
1301
1429
  get firstChild() {
@@ -1305,9 +1433,11 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1305
1433
  const childNodes = this.childNodes;
1306
1434
  return childNodes[childNodes.length - 1] || null;
1307
1435
  }
1436
+ get textContent() {
1437
+ return this.childNodes.map((childNode) => childNode.textContent).join("");
1438
+ }
1308
1439
  /**
1309
- * @textContent 目前只能置空子元素
1310
- * @TODO 等待完整 innerHTML 实现
1440
+ * @textContent 当前实现会用纯文本节点替换全部子节点。
1311
1441
  */
1312
1442
  set textContent(text) {
1313
1443
  const removedNodes = this.childNodes.slice();
@@ -1316,11 +1446,12 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1316
1446
  if (text === "") this.updateChildNodes(true);
1317
1447
  else {
1318
1448
  const newText = env.document.createTextNode(text);
1449
+ newText.parentNode = this;
1450
+ this.childNodes.push(newText);
1319
1451
  addedNodes.push(newText);
1320
- this.appendChild(newText);
1321
1452
  this.updateChildNodes();
1322
1453
  }
1323
- MutationObserver$1.record({
1454
+ MutationObserver.record({
1324
1455
  type: "childList",
1325
1456
  target: this,
1326
1457
  removedNodes,
@@ -1343,7 +1474,11 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1343
1474
  }, refChild);
1344
1475
  return newChild;
1345
1476
  }
1346
- newChild.remove({ cleanRef: false });
1477
+ const previousParentNode = newChild.parentNode;
1478
+ newChild.remove({
1479
+ cleanRef: false,
1480
+ recordMutation: !!previousParentNode && previousParentNode !== this
1481
+ });
1347
1482
  let index = 0;
1348
1483
  newChild.parentNode = this;
1349
1484
  if (refChild) {
@@ -1362,7 +1497,7 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1362
1497
  });
1363
1498
  else if (childNodesLength * 2 / 3 > index) this.updateChildNodes();
1364
1499
  else this.updateSingleChild(index);
1365
- MutationObserver$1.record({
1500
+ MutationObserver.record({
1366
1501
  type: "childList",
1367
1502
  target: this,
1368
1503
  addedNodes: [newChild],
@@ -1405,8 +1540,8 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1405
1540
  * 2. remove C
1406
1541
  */
1407
1542
  removeChild(child, options = {}) {
1408
- const { cleanRef, doUpdate } = options;
1409
- if (cleanRef !== false && doUpdate !== false) MutationObserver$1.record({
1543
+ const { cleanRef, doUpdate, recordMutation } = options;
1544
+ if (cleanRef !== false && doUpdate !== false || recordMutation) MutationObserver.record({
1410
1545
  type: "childList",
1411
1546
  target: this,
1412
1547
  removedNodes: [child],
@@ -1421,13 +1556,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1421
1556
  return child;
1422
1557
  }
1423
1558
  remove(options) {
1424
- this.parentNode?.removeChild(this, options);
1559
+ var _this$parentNode2;
1560
+ (_this$parentNode2 = this.parentNode) === null || _this$parentNode2 === void 0 || _this$parentNode2.removeChild(this, options);
1425
1561
  }
1426
1562
  hasChildNodes() {
1427
1563
  return this.childNodes.length > 0;
1428
1564
  }
1429
1565
  enqueueUpdate(payload) {
1430
- this._root?.enqueueUpdate(payload);
1566
+ var _this$_root;
1567
+ (_this$_root = this._root) === null || _this$_root === void 0 || _this$_root.enqueueUpdate(payload);
1431
1568
  }
1432
1569
  get ownerDocument() {
1433
1570
  return env.document;
@@ -1437,7 +1574,7 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1437
1574
  }
1438
1575
  };
1439
1576
  //#endregion
1440
- //#region src/dom/style_properties.ts
1577
+ //#region src/dom/style-properties.ts
1441
1578
  const WEBKIT = "webkit";
1442
1579
  const styleProperties = [
1443
1580
  "all",
@@ -1810,7 +1947,7 @@ combine(WEBKIT, [
1810
1947
  //#endregion
1811
1948
  //#region src/dom/style.ts
1812
1949
  function recordCss(obj) {
1813
- MutationObserver$1.record({
1950
+ MutationObserver.record({
1814
1951
  type: "attributes",
1815
1952
  target: obj._element,
1816
1953
  attributeName: "style",
@@ -1945,7 +2082,7 @@ function returnTrue() {
1945
2082
  }
1946
2083
  function treeToArray(root, predict) {
1947
2084
  const array = [];
1948
- const filter = predict ?? returnTrue;
2085
+ const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
1949
2086
  let object = root;
1950
2087
  while (object) {
1951
2088
  if (object.nodeType === 1 && filter(object)) array.push(object);
@@ -1978,14 +2115,14 @@ var TaroElement = class TaroElement extends TaroNode {
1978
2115
  hooks$1.call("patchElement", this);
1979
2116
  }
1980
2117
  _stopPropagation(event) {
1981
- let target = this;
1982
- while (target = target.parentNode) {
1983
- const listeners = target.__handlers[event.type];
1984
- if (!isArray(listeners)) continue;
1985
- for (let i = listeners.length; i--;) {
1986
- const l = listeners[i];
1987
- l._stop = true;
2118
+ let parentNode = this.parentNode;
2119
+ while (parentNode) {
2120
+ const listeners = parentNode.__handlers[event.type];
2121
+ if (isArray(listeners)) for (let i = listeners.length; i--;) {
2122
+ const listener = listeners[i];
2123
+ listener._stop = true;
1988
2124
  }
2125
+ parentNode = parentNode.parentNode;
1989
2126
  }
1990
2127
  }
1991
2128
  get id() {
@@ -2050,7 +2187,7 @@ var TaroElement = class TaroElement extends TaroNode {
2050
2187
  setAttribute(qualifiedName, value) {
2051
2188
  warn(isString(value) && value.length > 2046, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
2052
2189
  const isPureView = this.nodeName === "view" && !isHasExtractProp(this) && !this.isAnyEventBinded();
2053
- if (qualifiedName !== "style") MutationObserver$1.record({
2190
+ if (qualifiedName !== "style") MutationObserver.record({
2054
2191
  target: this,
2055
2192
  type: "attributes",
2056
2193
  attributeName: qualifiedName,
@@ -2104,7 +2241,7 @@ var TaroElement = class TaroElement extends TaroNode {
2104
2241
  }
2105
2242
  removeAttribute(qualifiedName) {
2106
2243
  const isStaticView = this.nodeName === "view" && isHasExtractProp(this) && !this.isAnyEventBinded();
2107
- MutationObserver$1.record({
2244
+ MutationObserver.record({
2108
2245
  target: this,
2109
2246
  type: "attributes",
2110
2247
  attributeName: qualifiedName,
@@ -2145,7 +2282,8 @@ var TaroElement = class TaroElement extends TaroNode {
2145
2282
  }
2146
2283
  }
2147
2284
  getAttribute(qualifiedName) {
2148
- return (qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName]) ?? "";
2285
+ const attr = qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName];
2286
+ return attr !== null && attr !== void 0 ? attr : "";
2149
2287
  }
2150
2288
  getElementsByTagName(tagName) {
2151
2289
  return treeToArray(this, (el) => {
@@ -2247,14 +2385,12 @@ var TaroEvent = class {
2247
2385
  get target() {
2248
2386
  const cacheTarget = this.cacheTarget;
2249
2387
  if (!cacheTarget) {
2250
- const target = Object.create(this.mpEvent?.target || null);
2251
- const currentEle = env.document.getElementById(target.dataset?.sid || target.id || null);
2252
- const element = env.document.getElementById(target.targetDataset?.sid || target.dataset?.sid || target.id || null);
2253
- target.dataset = {
2254
- ...currentEle !== null ? currentEle.dataset : EMPTY_OBJ,
2255
- ...element !== null ? element.dataset : EMPTY_OBJ
2256
- };
2257
- for (const key in this.mpEvent?.detail) target[key] = this.mpEvent.detail[key];
2388
+ var _this$mpEvent, _target$dataset, _target$targetDataset, _target$dataset2, _this$mpEvent2;
2389
+ const target = Object.create(((_this$mpEvent = this.mpEvent) === null || _this$mpEvent === void 0 ? void 0 : _this$mpEvent.target) || null);
2390
+ const currentEle = env.document.getElementById(((_target$dataset = target.dataset) === null || _target$dataset === void 0 ? void 0 : _target$dataset.sid) || target.id || null);
2391
+ const element = env.document.getElementById(((_target$targetDataset = target.targetDataset) === null || _target$targetDataset === void 0 ? void 0 : _target$targetDataset.sid) || ((_target$dataset2 = target.dataset) === null || _target$dataset2 === void 0 ? void 0 : _target$dataset2.sid) || target.id || null);
2392
+ target.dataset = _objectSpread2(_objectSpread2({}, currentEle !== null ? currentEle.dataset : EMPTY_OBJ), element !== null ? element.dataset : EMPTY_OBJ);
2393
+ for (const key in (_this$mpEvent2 = this.mpEvent) === null || _this$mpEvent2 === void 0 ? void 0 : _this$mpEvent2.detail) target[key] = this.mpEvent.detail[key];
2258
2394
  this.cacheTarget = target;
2259
2395
  return target;
2260
2396
  } else return cacheTarget;
@@ -2262,16 +2398,17 @@ var TaroEvent = class {
2262
2398
  get currentTarget() {
2263
2399
  const cacheCurrentTarget = this.cacheCurrentTarget;
2264
2400
  if (!cacheCurrentTarget) {
2401
+ var _this$mpEvent3, _currentTarget$datase, _this$mpEvent4, _this$mpEvent5, _this$mpEvent6;
2265
2402
  const doc = env.document;
2266
- const currentTarget = Object.create(this.mpEvent?.currentTarget || null);
2267
- const element = doc.getElementById(currentTarget.dataset?.sid || currentTarget.id || null);
2268
- const targetElement = doc.getElementById(this.mpEvent?.target?.dataset?.sid || this.mpEvent?.target?.id || null);
2403
+ const currentTarget = Object.create(((_this$mpEvent3 = this.mpEvent) === null || _this$mpEvent3 === void 0 ? void 0 : _this$mpEvent3.currentTarget) || null);
2404
+ const element = doc.getElementById(((_currentTarget$datase = currentTarget.dataset) === null || _currentTarget$datase === void 0 ? void 0 : _currentTarget$datase.sid) || currentTarget.id || null);
2405
+ const targetElement = doc.getElementById(((_this$mpEvent4 = this.mpEvent) === null || _this$mpEvent4 === void 0 || (_this$mpEvent4 = _this$mpEvent4.target) === null || _this$mpEvent4 === void 0 || (_this$mpEvent4 = _this$mpEvent4.dataset) === null || _this$mpEvent4 === void 0 ? void 0 : _this$mpEvent4.sid) || ((_this$mpEvent5 = this.mpEvent) === null || _this$mpEvent5 === void 0 || (_this$mpEvent5 = _this$mpEvent5.target) === null || _this$mpEvent5 === void 0 ? void 0 : _this$mpEvent5.id) || null);
2269
2406
  if (element === null || element && element === targetElement) {
2270
2407
  this.cacheCurrentTarget = this.target;
2271
2408
  return this.target;
2272
2409
  }
2273
2410
  currentTarget.dataset = element.dataset;
2274
- for (const key in this.mpEvent?.detail) currentTarget[key] = this.mpEvent.detail[key];
2411
+ for (const key in (_this$mpEvent6 = this.mpEvent) === null || _this$mpEvent6 === void 0 ? void 0 : _this$mpEvent6.detail) currentTarget[key] = this.mpEvent.detail[key];
2275
2412
  this.cacheCurrentTarget = currentTarget;
2276
2413
  return currentTarget;
2277
2414
  } else return cacheCurrentTarget;
@@ -2288,7 +2425,7 @@ function createEvent(event, node) {
2288
2425
  }, event);
2289
2426
  for (const key in event) if (key === "currentTarget" || key === "target" || key === "type" || key === "timeStamp") continue;
2290
2427
  else domEv[key] = event[key];
2291
- if (domEv.type === "confirm" && node?.nodeName === "input") domEv[KEY_CODE] = 13;
2428
+ if (domEv.type === "confirm" && (node === null || node === void 0 ? void 0 : node.nodeName) === "input") domEv.keyCode = 13;
2292
2429
  return domEv;
2293
2430
  }
2294
2431
  const eventsBatch = {};
@@ -2298,12 +2435,11 @@ function getEventCBResult(event) {
2298
2435
  return result;
2299
2436
  }
2300
2437
  function eventHandler(event) {
2301
- event.type === void 0 && Object.defineProperty(event, "type", { value: event._type });
2302
- event.detail === void 0 && Object.defineProperty(event, "detail", { value: event._detail || { ...event } });
2303
- event.currentTarget = event.currentTarget || event.target || { ...event };
2438
+ var _currentTarget$datase2, _event$detail;
2439
+ event.currentTarget = event.currentTarget || event.target || _objectSpread2({}, event);
2304
2440
  hooks$1.call("modifyMpEventImpl", event);
2305
2441
  const currentTarget = event.currentTarget;
2306
- const id = currentTarget.dataset?.sid || currentTarget.id || event.detail?.id || "";
2442
+ const id = ((_currentTarget$datase2 = currentTarget.dataset) === null || _currentTarget$datase2 === void 0 ? void 0 : _currentTarget$datase2.sid) || currentTarget.id || ((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.id) || "";
2307
2443
  const node = env.document.getElementById(id);
2308
2444
  if (node) {
2309
2445
  const dispatch = () => {
@@ -2323,32 +2459,25 @@ function eventHandler(event) {
2323
2459
  dispatch();
2324
2460
  });
2325
2461
  return getEventCBResult(event);
2326
- } else (eventsBatch[type] ||= []).push(dispatch);
2462
+ } else (eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
2327
2463
  } else {
2328
2464
  dispatch();
2329
2465
  return getEventCBResult(event);
2330
2466
  }
2331
2467
  }
2332
2468
  }
2333
- function eventHandlerTTDom(ele, listener, event) {
2334
- Object.assign(event, {
2335
- mpEvent: event,
2336
- bubbles: true,
2337
- cancelable: true
2338
- });
2339
- listener(event, ele);
2340
- }
2341
2469
  //#endregion
2342
2470
  //#region src/dom/form.ts
2343
2471
  var FormElement = class extends TaroElement {
2344
2472
  get type() {
2345
- return this.props["type"] ?? "";
2473
+ var _this$props$TYPE;
2474
+ return (_this$props$TYPE = this.props["type"]) !== null && _this$props$TYPE !== void 0 ? _this$props$TYPE : "";
2346
2475
  }
2347
2476
  set type(val) {
2348
2477
  this.setAttribute(TYPE, val);
2349
2478
  }
2350
2479
  get value() {
2351
- const val = this.props[VALUE];
2480
+ const val = this.props.value;
2352
2481
  return val == null ? "" : val;
2353
2482
  }
2354
2483
  set value(val) {
@@ -2365,8 +2494,10 @@ var FormElement = class extends TaroElement {
2365
2494
  };
2366
2495
  //#endregion
2367
2496
  //#region src/perf.ts
2497
+ var _Performance_brand = /* @__PURE__ */ new WeakSet();
2368
2498
  var Performance = class {
2369
2499
  constructor() {
2500
+ _classPrivateMethodInitSpec(this, _Performance_brand);
2370
2501
  this.recorder = /* @__PURE__ */ new Map();
2371
2502
  }
2372
2503
  start(id) {
@@ -2379,20 +2510,20 @@ var Performance = class {
2379
2510
  if (!(prev >= 0)) return;
2380
2511
  this.recorder.delete(id);
2381
2512
  const time = now - prev;
2382
- console.log(`${id} 时长: ${time}ms 开始时间:${this.parseTime(prev)} 结束时间:${this.parseTime(now)}`);
2513
+ process.stdout.write(`${id} 时长: ${time}ms 开始时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, prev)} 结束时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, now)}\n`);
2383
2514
  }
2384
2515
  delayStop(id, delay = 500) {
2385
2516
  if (!options.debug) return;
2386
2517
  return debounce((now = Date.now(), cb) => {
2387
2518
  this.stop(id, now);
2388
- cb?.();
2519
+ cb === null || cb === void 0 || cb();
2389
2520
  }, delay);
2390
2521
  }
2391
- parseTime(time) {
2392
- const d = new Date(time);
2393
- return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
2394
- }
2395
2522
  };
2523
+ function _parseTime(time) {
2524
+ const d = new Date(time);
2525
+ return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
2526
+ }
2396
2527
  const perf = new Performance();
2397
2528
  //#endregion
2398
2529
  //#region src/dom/root.ts
@@ -2472,10 +2603,7 @@ var TaroRootElement = class extends TaroElement {
2472
2603
  const found = findCustomWrapper(this, dataPathArr);
2473
2604
  if (found) {
2474
2605
  const { customWrapper, splitedPath } = found;
2475
- customWrapperMap.set(customWrapper, {
2476
- ...customWrapperMap.get(customWrapper) || {},
2477
- [`i.${splitedPath}`]: data[p]
2478
- });
2606
+ customWrapperMap.set(customWrapper, _objectSpread2(_objectSpread2({}, customWrapperMap.get(customWrapper) || {}), {}, { [`i.${splitedPath}`]: data[p] }));
2479
2607
  } else normalUpdate[p] = data[p];
2480
2608
  }
2481
2609
  const customWrapperCount = customWrapperMap.size;
@@ -2490,11 +2618,11 @@ var TaroRootElement = class extends TaroElement {
2490
2618
  }
2491
2619
  };
2492
2620
  if (customWrapperCount) customWrapperMap.forEach((data, ctx) => {
2493
- if (options.debug) console.log("custom wrapper setData: ", data);
2621
+ if (options.debug) globalThis.console.log("custom wrapper setData: ", data);
2494
2622
  ctx.setData(data, cb);
2495
2623
  });
2496
2624
  if (isNeedNormalUpdate) {
2497
- if (options.debug) console.log("page setData:", normalUpdate);
2625
+ if (options.debug) globalThis.console.log("page setData:", normalUpdate);
2498
2626
  ctx.setData(normalUpdate, cb);
2499
2627
  }
2500
2628
  });
@@ -2522,7 +2650,7 @@ var TaroText = class extends TaroNode {
2522
2650
  this._value = value;
2523
2651
  }
2524
2652
  set textContent(text) {
2525
- MutationObserver$1.record({
2653
+ MutationObserver.record({
2526
2654
  target: this,
2527
2655
  type: "characterData",
2528
2656
  oldValue: this._value
@@ -2550,34 +2678,230 @@ var TaroText = class extends TaroNode {
2550
2678
  }
2551
2679
  };
2552
2680
  //#endregion
2681
+ //#region src/bom/URL.ts
2682
+ var _hash = /* @__PURE__ */ new WeakMap();
2683
+ var _hostname = /* @__PURE__ */ new WeakMap();
2684
+ var _pathname = /* @__PURE__ */ new WeakMap();
2685
+ var _port = /* @__PURE__ */ new WeakMap();
2686
+ var _protocol = /* @__PURE__ */ new WeakMap();
2687
+ var _search = /* @__PURE__ */ new WeakMap();
2688
+ var TaroURL = class {
2689
+ static createObjectURL() {
2690
+ throw new Error("Oops, not support URL.createObjectURL() in miniprogram.");
2691
+ }
2692
+ static revokeObjectURL() {
2693
+ throw new Error("Oops, not support URL.revokeObjectURL() in miniprogram.");
2694
+ }
2695
+ constructor(url, base) {
2696
+ _classPrivateFieldInitSpec(this, _hash, "");
2697
+ _classPrivateFieldInitSpec(this, _hostname, "");
2698
+ _classPrivateFieldInitSpec(this, _pathname, "");
2699
+ _classPrivateFieldInitSpec(this, _port, "");
2700
+ _classPrivateFieldInitSpec(this, _protocol, "");
2701
+ _classPrivateFieldInitSpec(this, _search, void 0);
2702
+ if (!isString(url)) url = String(url);
2703
+ const { hash, hostname, pathname, port, protocol, search } = parseUrlBase(url, base);
2704
+ _classPrivateFieldSet2(_hash, this, hash);
2705
+ _classPrivateFieldSet2(_hostname, this, hostname);
2706
+ _classPrivateFieldSet2(_pathname, this, pathname || "/");
2707
+ _classPrivateFieldSet2(_port, this, port);
2708
+ _classPrivateFieldSet2(_protocol, this, protocol);
2709
+ _classPrivateFieldSet2(_search, this, new URLSearchParams(search));
2710
+ }
2711
+ get protocol() {
2712
+ return _classPrivateFieldGet2(_protocol, this);
2713
+ }
2714
+ set protocol(val) {
2715
+ isString(val) && _classPrivateFieldSet2(_protocol, this, val.trim());
2716
+ }
2717
+ get host() {
2718
+ return this.hostname + (this.port ? ":" + this.port : "");
2719
+ }
2720
+ set host(val) {
2721
+ if (val && isString(val)) {
2722
+ val = val.trim();
2723
+ const { hostname, port } = parseUrl(`//${val}`);
2724
+ this.hostname = hostname;
2725
+ this.port = port;
2726
+ }
2727
+ }
2728
+ get hostname() {
2729
+ return _classPrivateFieldGet2(_hostname, this);
2730
+ }
2731
+ set hostname(val) {
2732
+ val && isString(val) && _classPrivateFieldSet2(_hostname, this, val.trim());
2733
+ }
2734
+ get port() {
2735
+ return _classPrivateFieldGet2(_port, this);
2736
+ }
2737
+ set port(val) {
2738
+ isString(val) && _classPrivateFieldSet2(_port, this, val.trim());
2739
+ }
2740
+ get pathname() {
2741
+ return _classPrivateFieldGet2(_pathname, this);
2742
+ }
2743
+ set pathname(val) {
2744
+ if (isString(val)) {
2745
+ val = val.trim();
2746
+ const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
2747
+ let temp = val;
2748
+ while (HEAD_REG.test(temp)) temp = temp.replace(HEAD_REG, "");
2749
+ if (temp) _classPrivateFieldSet2(_pathname, this, "/" + temp);
2750
+ else _classPrivateFieldSet2(_pathname, this, "/");
2751
+ }
2752
+ }
2753
+ get search() {
2754
+ const val = _classPrivateFieldGet2(_search, this).toString();
2755
+ return val.length === 0 || val.startsWith("?") ? val : `?${val}`;
2756
+ }
2757
+ set search(val) {
2758
+ if (isString(val)) {
2759
+ val = val.trim();
2760
+ _classPrivateFieldSet2(_search, this, new URLSearchParams(val));
2761
+ }
2762
+ }
2763
+ get hash() {
2764
+ return _classPrivateFieldGet2(_hash, this);
2765
+ }
2766
+ set hash(val) {
2767
+ if (isString(val)) {
2768
+ val = val.trim();
2769
+ if (val) _classPrivateFieldSet2(_hash, this, val.startsWith("#") ? val : `#${val}`);
2770
+ else _classPrivateFieldSet2(_hash, this, "");
2771
+ }
2772
+ }
2773
+ get href() {
2774
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
2775
+ }
2776
+ set href(val) {
2777
+ if (val && isString(val)) {
2778
+ val = val.trim();
2779
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
2780
+ this.protocol = protocol;
2781
+ this.hostname = hostname;
2782
+ this.pathname = pathname;
2783
+ this.port = port;
2784
+ this.hash = hash;
2785
+ this.search = search;
2786
+ }
2787
+ }
2788
+ get origin() {
2789
+ return `${this.protocol}//${this.host}`;
2790
+ }
2791
+ set origin(val) {
2792
+ if (val && isString(val)) {
2793
+ val = val.trim();
2794
+ const { protocol, hostname, port } = parseUrl(val);
2795
+ this.protocol = protocol;
2796
+ this.hostname = hostname;
2797
+ this.port = port;
2798
+ }
2799
+ }
2800
+ get searchParams() {
2801
+ return _classPrivateFieldGet2(_search, this);
2802
+ }
2803
+ toString() {
2804
+ return this.href;
2805
+ }
2806
+ toJSON() {
2807
+ return this.toString();
2808
+ }
2809
+ _toRaw() {
2810
+ return {
2811
+ protocol: this.protocol,
2812
+ port: this.port,
2813
+ host: this.host,
2814
+ hostname: this.hostname,
2815
+ pathname: this.pathname,
2816
+ hash: this.hash,
2817
+ search: this.search,
2818
+ origin: this.origin,
2819
+ href: this.href
2820
+ };
2821
+ }
2822
+ };
2823
+ const TaroURLProvider = TaroURL;
2824
+ function parseUrl(url = "") {
2825
+ const result = {
2826
+ href: "",
2827
+ origin: "",
2828
+ protocol: "",
2829
+ hostname: "",
2830
+ host: "",
2831
+ port: "",
2832
+ pathname: "",
2833
+ search: "",
2834
+ hash: ""
2835
+ };
2836
+ if (!url || !isString(url)) return result;
2837
+ url = url.trim();
2838
+ const matches = url.match(/^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/);
2839
+ if (!matches) return result;
2840
+ result.protocol = matches[1] || "https:";
2841
+ result.hostname = matches[6] || "taro.com";
2842
+ result.port = matches[8] || "";
2843
+ result.pathname = matches[9] || "/";
2844
+ result.search = matches[10] || "";
2845
+ result.hash = matches[12] || "";
2846
+ result.href = url;
2847
+ result.origin = result.protocol + "//" + result.hostname + (result.port ? `:${result.port}` : "");
2848
+ result.host = result.hostname + (result.port ? `:${result.port}` : "");
2849
+ return result;
2850
+ }
2851
+ function parseUrlBase(url, base) {
2852
+ const VALID_URL = /^(https?:)\/\//i;
2853
+ let fullUrl = "";
2854
+ let parsedBase = null;
2855
+ if (!isUndefined(base)) {
2856
+ base = String(base).trim();
2857
+ if (!VALID_URL.test(base)) throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
2858
+ parsedBase = parseUrl(base);
2859
+ }
2860
+ url = String(url).trim();
2861
+ if (VALID_URL.test(url)) fullUrl = url;
2862
+ else if (parsedBase) if (url) if (url.startsWith("//")) fullUrl = parsedBase.protocol + url;
2863
+ else fullUrl = parsedBase.origin + (url.startsWith("/") ? url : `/${url}`);
2864
+ else fullUrl = parsedBase.href;
2865
+ else throw new TypeError(`Failed to construct 'URL': Invalid URL`);
2866
+ return parseUrl(fullUrl);
2867
+ }
2868
+ //#endregion
2553
2869
  //#region src/dom/anchor-element.ts
2554
2870
  var AnchorElement = class extends TaroElement {
2555
2871
  get href() {
2556
- return this.props["href"] ?? "";
2872
+ var _this$props$AnchorEle;
2873
+ return (_this$props$AnchorEle = this.props["href"]) !== null && _this$props$AnchorEle !== void 0 ? _this$props$AnchorEle : "";
2557
2874
  }
2558
2875
  set href(val) {
2559
2876
  this.setAttribute("href", val);
2560
2877
  }
2561
2878
  get protocol() {
2562
- return this.props["protocol"] ?? "";
2879
+ var _this$props$AnchorEle2;
2880
+ return (_this$props$AnchorEle2 = this.props["protocol"]) !== null && _this$props$AnchorEle2 !== void 0 ? _this$props$AnchorEle2 : "";
2563
2881
  }
2564
2882
  get host() {
2565
- return this.props["host"] ?? "";
2883
+ var _this$props$AnchorEle3;
2884
+ return (_this$props$AnchorEle3 = this.props["host"]) !== null && _this$props$AnchorEle3 !== void 0 ? _this$props$AnchorEle3 : "";
2566
2885
  }
2567
2886
  get search() {
2568
- return this.props["search"] ?? "";
2887
+ var _this$props$AnchorEle4;
2888
+ return (_this$props$AnchorEle4 = this.props["search"]) !== null && _this$props$AnchorEle4 !== void 0 ? _this$props$AnchorEle4 : "";
2569
2889
  }
2570
2890
  get hash() {
2571
- return this.props["hash"] ?? "";
2891
+ var _this$props$AnchorEle5;
2892
+ return (_this$props$AnchorEle5 = this.props["hash"]) !== null && _this$props$AnchorEle5 !== void 0 ? _this$props$AnchorEle5 : "";
2572
2893
  }
2573
2894
  get hostname() {
2574
- return this.props["hostname"] ?? "";
2895
+ var _this$props$AnchorEle6;
2896
+ return (_this$props$AnchorEle6 = this.props["hostname"]) !== null && _this$props$AnchorEle6 !== void 0 ? _this$props$AnchorEle6 : "";
2575
2897
  }
2576
2898
  get port() {
2577
- return this.props["port"] ?? "";
2899
+ var _this$props$AnchorEle7;
2900
+ return (_this$props$AnchorEle7 = this.props["port"]) !== null && _this$props$AnchorEle7 !== void 0 ? _this$props$AnchorEle7 : "";
2578
2901
  }
2579
2902
  get pathname() {
2580
- return this.props["pathname"] ?? "";
2903
+ var _this$props$AnchorEle8;
2904
+ return (_this$props$AnchorEle8 = this.props["pathname"]) !== null && _this$props$AnchorEle8 !== void 0 ? _this$props$AnchorEle8 : "";
2581
2905
  }
2582
2906
  setAttribute(qualifiedName, value) {
2583
2907
  if (qualifiedName === "href") {
@@ -2691,59 +3015,7 @@ function createDocument() {
2691
3015
  doc.body = body;
2692
3016
  return doc;
2693
3017
  }
2694
- function createTTDomDocument() {
2695
- const document = tt?.appDocument;
2696
- if (!document) throw new Error("tt.appDocument is not found");
2697
- const html = document.createElement(HTML);
2698
- const head = document.createElement(HEAD);
2699
- const body = document.createElement(BODY);
2700
- const app = document.createElement("app");
2701
- app.id = "app";
2702
- const container = document.createElement(CONTAINER);
2703
- const emptyFunction = () => {};
2704
- document.childNodes.push(html);
2705
- html.childNodes.push(head, body);
2706
- body.childNodes.push(container);
2707
- container.childNodes.push(app);
2708
- document.documentElement = html;
2709
- document.head = head;
2710
- document.body = body;
2711
- document.appElement = app;
2712
- let builtInComponents = tt?.getBuiltInComponents?.();
2713
- if (Array.isArray(builtInComponents)) builtInComponents = new Set(builtInComponents);
2714
- else if (!(builtInComponents instanceof Set)) builtInComponents = new Set([...DEFAULT_COMPONENTS, ...TT_SPECIFIC_COMPONENTS]);
2715
- document.getElementById = function getElementById(id) {
2716
- if (id === "app") return app;
2717
- else return Object.getPrototypeOf(this).getElementById.call(this, id);
2718
- };
2719
- document.getLastPage = function getLastPage() {
2720
- let last;
2721
- for (const v of this._pageDocumentMap.values()) last = v;
2722
- return last;
2723
- };
2724
- document.createElement = function(type, ...args) {
2725
- if (type === "root") return this.getLastPage();
2726
- else {
2727
- const el = builtInComponents.has(type) ? Object.getPrototypeOf(this).createElement.call(this, type, ...args) : Object.getPrototypeOf(this).createNativeComponent.call(this, type, { __tt__inner__options__: { name: type } });
2728
- el.setAttribute("class", "");
2729
- const originalSetAttribute = el.setAttribute.bind(el);
2730
- const originalRemoveAttribute = el.removeAttribute.bind(el);
2731
- el.setAttribute = function(name, value) {
2732
- const result = originalSetAttribute(name, value);
2733
- if (name === "catchMove" && value) el.addEventListener("catchtouchmove", emptyFunction);
2734
- return result;
2735
- };
2736
- el.removeAttribute = function(name) {
2737
- const oldValue = el.getAttribute(name);
2738
- if (name === "catchMove" && oldValue) el.removeEventListener("catchtouchmove", emptyFunction);
2739
- return originalRemoveAttribute(name);
2740
- };
2741
- return el;
2742
- }
2743
- };
2744
- return document;
2745
- }
2746
- const taroDocumentProvider = process.env.TARO_PLATFORM === "web" ? env.document : env.document = isEnableTTDom() ? createTTDomDocument() : createDocument();
3018
+ const taroDocumentProvider = env.document = createDocument();
2747
3019
  //#endregion
2748
3020
  //#region src/dom/svg.ts
2749
3021
  var SVGElement = class extends TaroElement {};
@@ -2778,8 +3050,7 @@ function stringify(obj) {
2778
3050
  }
2779
3051
  function getPath(id, options) {
2780
3052
  const idx = id.indexOf("?");
2781
- if (process.env.TARO_PLATFORM === "web") return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options?.stamp ? { stamp: options.stamp } : {})}`;
2782
- else return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
3053
+ return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
2783
3054
  }
2784
3055
  function getOnReadyEventKey(path) {
2785
3056
  return path + ".onReady";
@@ -2791,13 +3062,13 @@ function getOnHideEventKey(path) {
2791
3062
  return path + ".onHide";
2792
3063
  }
2793
3064
  function createPageConfig(component, pageName, data, pageConfig) {
2794
- const id = pageName ?? `taro_page_${pageId()}`;
3065
+ const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
2795
3066
  const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = hooks$1.call("getMiniLifecycleImpl").page;
2796
3067
  let pageElement = null;
2797
3068
  let unmounting = false;
2798
3069
  let prepareMountList = [];
2799
3070
  function setCurrentRouter(page) {
2800
- const router = process.env.TARO_PLATFORM === "web" ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
3071
+ const router = page.route || page.__route__ || page.$taroPath;
2801
3072
  Current.router = {
2802
3073
  params: page.$taroParams,
2803
3074
  path: addLeadingSlash(router),
@@ -2820,33 +3091,28 @@ function createPageConfig(component, pageName, data, pageConfig) {
2820
3091
  this.config = pageConfig || {};
2821
3092
  const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
2822
3093
  const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
2823
- if (process.env.TARO_PLATFORM === "web") config.path = $taroPath;
2824
3094
  if (this.$taroParams == null) this.$taroParams = uniqueOptions;
2825
3095
  setCurrentRouter(this);
2826
- if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("0", $taroPath);
3096
+ taroWindowProvider.trigger("0", $taroPath);
2827
3097
  const mount = () => {
2828
- Current.app.mount(component, $taroPath, () => {
2829
- if (process.env.TARO_ENV === "tt" && isEnableTTDom()) pageElement = env.document.getPageDocumentById(this.__webviewId__);
2830
- else pageElement = env.document.getElementById($taroPath);
3098
+ whenAppReady((app) => app.mount(component, $taroPath, () => {
3099
+ pageElement = env.document.getElementById($taroPath);
2831
3100
  ensure(pageElement !== null, "没有找到页面实例。");
2832
3101
  safeExecute($taroPath, ON_LOAD, this.$taroParams);
2833
3102
  loadResolver();
2834
- if (process.env.TARO_PLATFORM !== "web") {
2835
- pageElement.ctx = this;
2836
- if (process.env.TARO_ENV === "tt" && isEnableTTDom()) pageElement.sync();
2837
- else pageElement.performUpdate(true, cb);
2838
- } else isFunction(cb) && cb();
2839
- });
3103
+ pageElement.ctx = this;
3104
+ pageElement.performUpdate(true, cb);
3105
+ }));
2840
3106
  };
2841
3107
  if (unmounting) prepareMountList.push(mount);
2842
3108
  else mount();
2843
3109
  },
2844
3110
  [ONUNLOAD]() {
2845
3111
  const $taroPath = this.$taroPath;
2846
- if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("3", $taroPath);
3112
+ taroWindowProvider.trigger("3", $taroPath);
2847
3113
  safeExecute($taroPath, ONUNLOAD);
2848
3114
  unmounting = true;
2849
- Current.app.unmount($taroPath, () => {
3115
+ whenAppReady((app) => app.unmount($taroPath, () => {
2850
3116
  unmounting = false;
2851
3117
  instances.delete($taroPath);
2852
3118
  if (pageElement) {
@@ -2857,26 +3123,26 @@ function createPageConfig(component, pageName, data, pageConfig) {
2857
3123
  prepareMountList.forEach((fn) => fn());
2858
3124
  prepareMountList = [];
2859
3125
  }
2860
- });
3126
+ }));
2861
3127
  },
2862
3128
  [ONREADY]() {
2863
3129
  hasLoaded.then(() => {
2864
3130
  safeExecute(this.$taroPath, ON_READY);
2865
3131
  _raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
2866
- this.onReady.called = true;
3132
+ this[ONREADY].called = true;
2867
3133
  });
2868
3134
  },
2869
3135
  [ONSHOW](options = {}) {
2870
3136
  hasLoaded.then(() => {
2871
3137
  Current.page = this;
2872
3138
  setCurrentRouter(this);
2873
- if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("2", this.$taroPath);
3139
+ taroWindowProvider.trigger("2", this.$taroPath);
2874
3140
  safeExecute(this.$taroPath, ON_SHOW, options);
2875
3141
  _raf(() => eventCenter.trigger(getOnShowEventKey(id)));
2876
3142
  });
2877
3143
  },
2878
3144
  [ONHIDE]() {
2879
- if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("1", this.$taroPath);
3145
+ taroWindowProvider.trigger("1", this.$taroPath);
2880
3146
  if (Current.page === this) {
2881
3147
  Current.page = null;
2882
3148
  Current.router = null;
@@ -2885,10 +3151,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
2885
3151
  eventCenter.trigger(getOnHideEventKey(id));
2886
3152
  }
2887
3153
  };
2888
- if (process.env.TARO_PLATFORM === "web") config.getOpenerEventChannel = () => {
2889
- return EventChannel.pageChannel;
2890
- };
2891
- const isSWAN = process.env.TARO_ENV === "swan";
2892
3154
  LIFECYCLES.forEach((lifecycle) => {
2893
3155
  let isDefer = false;
2894
3156
  let isEvent = false;
@@ -2900,22 +3162,19 @@ function createPageConfig(component, pageName, data, pageConfig) {
2900
3162
  isEvent = true;
2901
3163
  return "";
2902
3164
  });
2903
- if (isEvent && process.env.TARO_ENV === "alipay") {
2904
- if (!config.events) config.events = {};
2905
- config.events[lifecycle] = function() {
2906
- return safeExecute(this.$taroPath, lifecycle, ...arguments);
2907
- };
2908
- } else config[lifecycle] = function() {
2909
- const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
2910
- if (isSWAN) return exec();
3165
+ if (isEvent) return;
3166
+ config[lifecycle] = function(...args) {
3167
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...args);
2911
3168
  if (isDefer) hasLoaded.then(exec);
2912
3169
  else return exec();
2913
3170
  };
2914
3171
  });
2915
3172
  SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
2916
- if (component[lifecycle] || component.prototype?.[lifecycle] || component[lifecycle.replace(/^on/, "enable")] || pageConfig?.[lifecycle.replace(/^on/, "enable")]) config[lifecycle] = function(...args) {
2917
- const target = args[0]?.target;
2918
- if (target?.id) {
3173
+ var _component$prototype;
3174
+ if (component[lifecycle] || ((_component$prototype = component.prototype) === null || _component$prototype === void 0 ? void 0 : _component$prototype[lifecycle]) || component[lifecycle.replace(/^on/, "enable")] || (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig[lifecycle.replace(/^on/, "enable")])) config[lifecycle] = function(...args) {
3175
+ var _args$;
3176
+ const target = (_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.target;
3177
+ if (target === null || target === void 0 ? void 0 : target.id) {
2919
3178
  const id = target.id;
2920
3179
  const element = env.document.getElementById(id);
2921
3180
  if (element) target.dataset = element.dataset;
@@ -2929,31 +3188,30 @@ function createPageConfig(component, pageName, data, pageConfig) {
2929
3188
  return config;
2930
3189
  }
2931
3190
  function createComponentConfig(component, componentName, data) {
2932
- const id = componentName ?? `taro_component_${pageId()}`;
3191
+ const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
2933
3192
  let componentElement = null;
2934
3193
  const [ATTACHED, DETACHED] = hooks$1.call("getMiniLifecycleImpl").component;
2935
3194
  const config = {
2936
3195
  [ATTACHED]() {
3196
+ var _this$getPageId;
2937
3197
  perf.start(PAGE_INIT);
2938
- this.pageIdCache = this.getPageId?.() || pageId();
3198
+ this.pageIdCache = ((_this$getPageId = this.getPageId) === null || _this$getPageId === void 0 ? void 0 : _this$getPageId.call(this)) || pageId();
2939
3199
  const path = getPath(id, { id: this.pageIdCache });
2940
- Current.app.mount(component, path, () => {
3200
+ whenAppReady((app) => app.mount(component, path, () => {
2941
3201
  componentElement = env.document.getElementById(path);
2942
3202
  ensure(componentElement !== null, "没有找到组件实例。");
2943
3203
  this.$taroInstances = instances.get(path);
2944
3204
  safeExecute(path, ON_LOAD);
2945
- if (process.env.TARO_PLATFORM !== "web") {
2946
- componentElement.ctx = this;
2947
- if (process.env.TARO_ENV !== "tt" || !isEnableTTDom()) componentElement.performUpdate(true);
2948
- }
2949
- });
3205
+ componentElement.ctx = this;
3206
+ componentElement.performUpdate(true);
3207
+ }));
2950
3208
  },
2951
3209
  [DETACHED]() {
2952
3210
  const path = getPath(id, { id: this.pageIdCache });
2953
- Current.app.unmount(path, () => {
3211
+ whenAppReady((app) => app.unmount(path, () => {
2954
3212
  instances.delete(path);
2955
3213
  if (componentElement) componentElement.ctx = null;
2956
- });
3214
+ }));
2957
3215
  },
2958
3216
  methods: { eh: eventHandler }
2959
3217
  };
@@ -2963,7 +3221,8 @@ function createComponentConfig(component, componentName, data) {
2963
3221
  EXTERNAL_CLASSES,
2964
3222
  BEHAVIORS
2965
3223
  ].forEach((key) => {
2966
- config[key] = component[key] ?? EMPTY_OBJ;
3224
+ var _component$key;
3225
+ config[key] = (_component$key = component[key]) !== null && _component$key !== void 0 ? _component$key : EMPTY_OBJ;
2967
3226
  });
2968
3227
  return config;
2969
3228
  }
@@ -2972,8 +3231,8 @@ function createRecursiveComponentConfig(componentName) {
2972
3231
  const [ATTACHED, DETACHED] = hooks$1.call("getMiniLifecycleImpl").component;
2973
3232
  const lifeCycles = isCustomWrapper ? {
2974
3233
  [ATTACHED]() {
2975
- if (process.env.TARO_ENV === "tt" && isEnableTTDom()) return;
2976
- const componentId = this.data.i?.sid || this.props.i?.sid;
3234
+ var _this$data$i, _this$props$i;
3235
+ const componentId = ((_this$data$i = this.data.i) === null || _this$data$i === void 0 ? void 0 : _this$data$i.sid) || ((_this$props$i = this.props.i) === null || _this$props$i === void 0 ? void 0 : _this$props$i.sid);
2977
3236
  if (isString(componentId)) {
2978
3237
  customWrapperCache.set(componentId, this);
2979
3238
  const el = env.document.getElementById(componentId);
@@ -2981,8 +3240,8 @@ function createRecursiveComponentConfig(componentName) {
2981
3240
  }
2982
3241
  },
2983
3242
  [DETACHED]() {
2984
- if (process.env.TARO_ENV === "tt" && isEnableTTDom()) return;
2985
- const componentId = this.data.i?.sid || this.props.i?.sid;
3243
+ var _this$data$i2, _this$props$i2;
3244
+ const componentId = ((_this$data$i2 = this.data.i) === null || _this$data$i2 === void 0 ? void 0 : _this$data$i2.sid) || ((_this$props$i2 = this.props.i) === null || _this$props$i2 === void 0 ? void 0 : _this$props$i2.sid);
2986
3245
  if (isString(componentId)) {
2987
3246
  customWrapperCache.delete(componentId);
2988
3247
  const el = env.document.getElementById(componentId);
@@ -2990,9 +3249,7 @@ function createRecursiveComponentConfig(componentName) {
2990
3249
  }
2991
3250
  }
2992
3251
  } : EMPTY_OBJ;
2993
- const extraOptions = {};
2994
- if (process.env.TARO_ENV === "jd") extraOptions.addGlobalClass = true;
2995
- return hooks$1.call("modifyRecursiveComponentConfig", {
3252
+ return hooks$1.call("modifyRecursiveComponentConfig", _objectSpread2({
2996
3253
  properties: {
2997
3254
  i: {
2998
3255
  type: Object,
@@ -3003,13 +3260,9 @@ function createRecursiveComponentConfig(componentName) {
3003
3260
  value: ""
3004
3261
  }
3005
3262
  },
3006
- options: {
3007
- ...extraOptions,
3008
- virtualHost: !isCustomWrapper
3009
- },
3010
- methods: { eh: eventHandler },
3011
- ...lifeCycles
3012
- }, { isCustomWrapper });
3263
+ options: { virtualHost: !isCustomWrapper },
3264
+ methods: { eh: eventHandler }
3265
+ }, lifeCycles), { isCustomWrapper });
3013
3266
  }
3014
3267
  //#endregion
3015
3268
  //#region src/next-tick.ts
@@ -3032,10 +3285,7 @@ const nextTick = (cb, ctx) => {
3032
3285
  */
3033
3286
  function next() {
3034
3287
  const pageElement = env.document.getElementById(path);
3035
- if (pageElement?.pendingUpdate) if (process.env.TARO_PLATFORM === "web") pageElement.firstChild?.["componentOnReady"]?.().then(() => {
3036
- timerFunc();
3037
- }) ?? timerFunc();
3038
- else pageElement.enqueueUpdateCallback(cb, ctx);
3288
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) pageElement.enqueueUpdateCallback(cb, ctx);
3039
3289
  else if (Date.now() - beginTime > TIMEOUT) timerFunc();
3040
3290
  else setTimeout(() => next(), 20);
3041
3291
  }
@@ -3074,495 +3324,6 @@ function handleArrayIncludesPolyfill() {
3074
3324
  } });
3075
3325
  }
3076
3326
  //#endregion
3077
- //#region src/polyfill/intersection-observer.ts
3078
- function handleIntersectionObserverPolyfill() {
3079
- if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
3080
- if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", { get: function() {
3081
- return this.intersectionRatio > 0;
3082
- } });
3083
- } else handleIntersectionObserverObjectPolyfill();
3084
- }
3085
- function handleIntersectionObserverObjectPolyfill() {
3086
- const document = window.document;
3087
- /**
3088
- * An IntersectionObserver registry. This registry exists to hold a strong
3089
- * reference to IntersectionObserver instances currently observing a target
3090
- * element. Without this registry, instances without another reference may be
3091
- * garbage collected.
3092
- */
3093
- const registry = [];
3094
- /**
3095
- * Creates the global IntersectionObserverEntry constructor.
3096
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
3097
- * @param {Object} entry A dictionary of instance properties.
3098
- * @constructor
3099
- */
3100
- function IntersectionObserverEntry(entry) {
3101
- this.time = entry.time;
3102
- this.target = entry.target;
3103
- this.rootBounds = entry.rootBounds;
3104
- this.boundingClientRect = entry.boundingClientRect;
3105
- this.intersectionRect = entry.intersectionRect || getEmptyRect();
3106
- this.isIntersecting = !!entry.intersectionRect;
3107
- const targetRect = this.boundingClientRect;
3108
- const targetArea = targetRect.width * targetRect.height;
3109
- const intersectionRect = this.intersectionRect;
3110
- const intersectionArea = intersectionRect.width * intersectionRect.height;
3111
- if (targetArea) this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
3112
- else this.intersectionRatio = this.isIntersecting ? 1 : 0;
3113
- }
3114
- /**
3115
- * Creates the global IntersectionObserver constructor.
3116
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
3117
- * @param {Function} callback The function to be invoked after intersection
3118
- * changes have queued. The function is not invoked if the queue has
3119
- * been emptied by calling the `takeRecords` method.
3120
- * @param {Object=} opt_options Optional configuration options.
3121
- * @constructor
3122
- */
3123
- function IntersectionObserver(callback, options = {}) {
3124
- if (!isFunction(callback)) throw new Error("callback must be a function");
3125
- if (options.root && options.root.nodeType != 1) throw new Error("root must be an Element");
3126
- this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
3127
- this._callback = callback;
3128
- this._observationTargets = [];
3129
- this._queuedEntries = [];
3130
- this._rootMarginValues = this._parseRootMargin(options.rootMargin);
3131
- this.thresholds = this._initThresholds(options.threshold);
3132
- this.root = options.root || null;
3133
- this.rootMargin = this._rootMarginValues.map(function(margin) {
3134
- return margin.value + margin.unit;
3135
- }).join(" ");
3136
- }
3137
- /**
3138
- * The minimum interval within which the document will be checked for
3139
- * intersection changes.
3140
- */
3141
- IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
3142
- /**
3143
- * The frequency in which the polyfill polls for intersection changes.
3144
- * this can be updated on a per instance basis and must be set prior to
3145
- * calling `observe` on the first target.
3146
- */
3147
- IntersectionObserver.prototype.POLL_INTERVAL = null;
3148
- /**
3149
- * Use a mutation observer on the root element
3150
- * to detect intersection changes.
3151
- */
3152
- IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
3153
- /**
3154
- * Starts observing a target element for intersection changes based on
3155
- * the thresholds values.
3156
- * @param {Element} target The DOM element to observe.
3157
- */
3158
- IntersectionObserver.prototype.observe = function(target) {
3159
- if (this._observationTargets.some(function(item) {
3160
- return item.element == target;
3161
- })) return;
3162
- if (!(target && target.nodeType == 1)) throw new Error("target must be an Element");
3163
- this._registerInstance();
3164
- this._observationTargets.push({
3165
- element: target,
3166
- entry: null
3167
- });
3168
- this._monitorIntersections();
3169
- this._checkForIntersections();
3170
- };
3171
- /**
3172
- * Stops observing a target element for intersection changes.
3173
- * @param {Element} target The DOM element to observe.
3174
- */
3175
- IntersectionObserver.prototype.unobserve = function(target) {
3176
- this._observationTargets = this._observationTargets.filter(function(item) {
3177
- return item.element != target;
3178
- });
3179
- if (!this._observationTargets.length) {
3180
- this._unmonitorIntersections();
3181
- this._unregisterInstance();
3182
- }
3183
- };
3184
- /**
3185
- * Stops observing all target elements for intersection changes.
3186
- */
3187
- IntersectionObserver.prototype.disconnect = function() {
3188
- this._observationTargets = [];
3189
- this._unmonitorIntersections();
3190
- this._unregisterInstance();
3191
- };
3192
- /**
3193
- * Returns any queue entries that have not yet been reported to the
3194
- * callback and clears the queue. This can be used in conjunction with the
3195
- * callback to obtain the absolute most up-to-date intersection information.
3196
- * @return {Array} The currently queued entries.
3197
- */
3198
- IntersectionObserver.prototype.takeRecords = function() {
3199
- const records = this._queuedEntries.slice();
3200
- this._queuedEntries = [];
3201
- return records;
3202
- };
3203
- /**
3204
- * Accepts the threshold value from the user configuration object and
3205
- * returns a sorted array of unique threshold values. If a value is not
3206
- * between 0 and 1 and error is thrown.
3207
- * @private
3208
- * @param {Array|number=} opt_threshold An optional threshold value or
3209
- * a list of threshold values, defaulting to [0].
3210
- * @return {Array} A sorted list of unique and valid threshold values.
3211
- */
3212
- IntersectionObserver.prototype._initThresholds = function(opt_threshold) {
3213
- let threshold = opt_threshold || [0];
3214
- if (!Array.isArray(threshold)) threshold = [threshold];
3215
- return threshold.sort().filter(function(t, i, a) {
3216
- if (!isNumber(t) || isNaN(t) || t < 0 || t > 1) throw new Error("threshold must be a number between 0 and 1 inclusively");
3217
- return t !== a[i - 1];
3218
- });
3219
- };
3220
- /**
3221
- * Accepts the rootMargin value from the user configuration object
3222
- * and returns an array of the four margin values as an object containing
3223
- * the value and unit properties. If any of the values are not properly
3224
- * formatted or use a unit other than px or %, and error is thrown.
3225
- * @private
3226
- * @param {string=} opt_rootMargin An optional rootMargin value,
3227
- * defaulting to '0px'.
3228
- * @return {Array<Object>} An array of margin objects with the keys
3229
- * value and unit.
3230
- */
3231
- IntersectionObserver.prototype._parseRootMargin = function(opt_rootMargin) {
3232
- const margins = (opt_rootMargin || "0px").split(/\s+/).map(function(margin) {
3233
- const parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
3234
- if (!parts) throw new Error("rootMargin must be specified in pixels or percent");
3235
- return {
3236
- value: parseFloat(parts[1]),
3237
- unit: parts[2]
3238
- };
3239
- });
3240
- margins[1] = margins[1] || margins[0];
3241
- margins[2] = margins[2] || margins[0];
3242
- margins[3] = margins[3] || margins[1];
3243
- return margins;
3244
- };
3245
- /**
3246
- * Starts polling for intersection changes if the polling is not already
3247
- * happening, and if the page's visibility state is visible.
3248
- * @private
3249
- */
3250
- IntersectionObserver.prototype._monitorIntersections = function() {
3251
- if (!this._monitoringIntersections) {
3252
- this._monitoringIntersections = true;
3253
- if (this.POLL_INTERVAL) this._monitoringInterval = setInterval(this._checkForIntersections, this.POLL_INTERVAL);
3254
- else {
3255
- addEvent(window, "resize", this._checkForIntersections, true);
3256
- addEvent(document, "scroll", this._checkForIntersections, true);
3257
- if (this.USE_MUTATION_OBSERVER && "MutationObserver" in window) {
3258
- this._domObserver = new MutationObserver(this._checkForIntersections);
3259
- this._domObserver.observe(document, {
3260
- attributes: true,
3261
- childList: true,
3262
- characterData: true,
3263
- subtree: true
3264
- });
3265
- }
3266
- }
3267
- }
3268
- };
3269
- /**
3270
- * Stops polling for intersection changes.
3271
- * @private
3272
- */
3273
- IntersectionObserver.prototype._unmonitorIntersections = function() {
3274
- if (this._monitoringIntersections) {
3275
- this._monitoringIntersections = false;
3276
- clearInterval(this._monitoringInterval);
3277
- this._monitoringInterval = null;
3278
- removeEvent(window, "resize", this._checkForIntersections, true);
3279
- removeEvent(document, "scroll", this._checkForIntersections, true);
3280
- if (this._domObserver) {
3281
- this._domObserver.disconnect();
3282
- this._domObserver = null;
3283
- }
3284
- }
3285
- };
3286
- /**
3287
- * Scans each observation target for intersection changes and adds them
3288
- * to the internal entries queue. If new entries are found, it
3289
- * schedules the callback to be invoked.
3290
- * @private
3291
- */
3292
- IntersectionObserver.prototype._checkForIntersections = function() {
3293
- const rootIsInDom = this._rootIsInDom();
3294
- const rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
3295
- this._observationTargets.forEach(function(item) {
3296
- const target = item.element;
3297
- const targetRect = getBoundingClientRect(target);
3298
- const rootContainsTarget = this._rootContainsTarget(target);
3299
- const oldEntry = item.entry;
3300
- const intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, rootRect);
3301
- const newEntry = item.entry = new IntersectionObserverEntry({
3302
- time: now(),
3303
- target,
3304
- boundingClientRect: targetRect,
3305
- rootBounds: rootRect,
3306
- intersectionRect,
3307
- intersectionRatio: -1,
3308
- isIntersecting: false
3309
- });
3310
- if (!oldEntry) this._queuedEntries.push(newEntry);
3311
- else if (rootIsInDom && rootContainsTarget) {
3312
- if (this._hasCrossedThreshold(oldEntry, newEntry)) this._queuedEntries.push(newEntry);
3313
- } else if (oldEntry && oldEntry.isIntersecting) this._queuedEntries.push(newEntry);
3314
- }, this);
3315
- if (this._queuedEntries.length) this._callback(this.takeRecords(), this);
3316
- };
3317
- /**
3318
- * Accepts a target and root rect computes the intersection between then
3319
- * following the algorithm in the spec.
3320
- * TODO(philipwalton): at this time clip-path is not considered.
3321
- * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
3322
- * @param {Element} target The target DOM element
3323
- * @param {Object} rootRect The bounding rect of the root after being
3324
- * expanded by the rootMargin value.
3325
- * @return {?Object} The final intersection rect object or undefined if no
3326
- * intersection is found.
3327
- * @private
3328
- */
3329
- IntersectionObserver.prototype._computeTargetAndRootIntersection = function(target, rootRect) {
3330
- if (window.getComputedStyle(target).display === "none") return;
3331
- let intersectionRect = getBoundingClientRect(target);
3332
- let parent = getParentNode(target);
3333
- let atRoot = false;
3334
- while (!atRoot) {
3335
- let parentRect = null;
3336
- const parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
3337
- if (parentComputedStyle.display === "none") return;
3338
- if (parent == this.root || parent == document) {
3339
- atRoot = true;
3340
- parentRect = rootRect;
3341
- } else if (parent != document.body && parent != document.documentElement && parentComputedStyle.overflow != "visible") parentRect = getBoundingClientRect(parent);
3342
- if (parentRect) {
3343
- intersectionRect = computeRectIntersection(parentRect, intersectionRect);
3344
- if (!intersectionRect) break;
3345
- }
3346
- parent = getParentNode(parent);
3347
- }
3348
- return intersectionRect;
3349
- };
3350
- /**
3351
- * Returns the root rect after being expanded by the rootMargin value.
3352
- * @return {Object} The expanded root rect.
3353
- * @private
3354
- */
3355
- IntersectionObserver.prototype._getRootRect = function() {
3356
- let rootRect;
3357
- if (this.root) rootRect = getBoundingClientRect(this.root);
3358
- else {
3359
- const html = document.documentElement;
3360
- const body = document.body;
3361
- rootRect = {
3362
- top: 0,
3363
- left: 0,
3364
- right: html.clientWidth || body.clientWidth,
3365
- width: html.clientWidth || body.clientWidth,
3366
- bottom: html.clientHeight || body.clientHeight,
3367
- height: html.clientHeight || body.clientHeight
3368
- };
3369
- }
3370
- return this._expandRectByRootMargin(rootRect);
3371
- };
3372
- /**
3373
- * Accepts a rect and expands it by the rootMargin value.
3374
- * @param {Object} rect The rect object to expand.
3375
- * @return {Object} The expanded rect.
3376
- * @private
3377
- */
3378
- IntersectionObserver.prototype._expandRectByRootMargin = function(rect) {
3379
- const margins = this._rootMarginValues.map(function(margin, i) {
3380
- return margin.unit === "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
3381
- });
3382
- const newRect = {
3383
- top: rect.top - margins[0],
3384
- right: rect.right + margins[1],
3385
- bottom: rect.bottom + margins[2],
3386
- left: rect.left - margins[3]
3387
- };
3388
- newRect.width = newRect.right - newRect.left;
3389
- newRect.height = newRect.bottom - newRect.top;
3390
- return newRect;
3391
- };
3392
- /**
3393
- * Accepts an old and new entry and returns true if at least one of the
3394
- * threshold values has been crossed.
3395
- * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
3396
- * particular target element or null if no previous entry exists.
3397
- * @param {IntersectionObserverEntry} newEntry The current entry for a
3398
- * particular target element.
3399
- * @return {boolean} Returns true if a any threshold has been crossed.
3400
- * @private
3401
- */
3402
- IntersectionObserver.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
3403
- const oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
3404
- const newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
3405
- if (oldRatio === newRatio) return;
3406
- for (let i = 0; i < this.thresholds.length; i++) {
3407
- const threshold = this.thresholds[i];
3408
- if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) return true;
3409
- }
3410
- };
3411
- /**
3412
- * Returns whether or not the root element is an element and is in the DOM.
3413
- * @return {boolean} True if the root element is an element and is in the DOM.
3414
- * @private
3415
- */
3416
- IntersectionObserver.prototype._rootIsInDom = function() {
3417
- return !this.root || containsDeep(document, this.root);
3418
- };
3419
- /**
3420
- * Returns whether or not the target element is a child of root.
3421
- * @param {Element} target The target element to check.
3422
- * @return {boolean} True if the target element is a child of root.
3423
- * @private
3424
- */
3425
- IntersectionObserver.prototype._rootContainsTarget = function(target) {
3426
- return containsDeep(this.root || document, target);
3427
- };
3428
- /**
3429
- * Adds the instance to the global IntersectionObserver registry if it isn't
3430
- * already present.
3431
- * @private
3432
- */
3433
- IntersectionObserver.prototype._registerInstance = function() {
3434
- if (registry.indexOf(this) < 0) registry.push(this);
3435
- };
3436
- /**
3437
- * Removes the instance from the global IntersectionObserver registry.
3438
- * @private
3439
- */
3440
- IntersectionObserver.prototype._unregisterInstance = function() {
3441
- const index = registry.indexOf(this);
3442
- if (index != -1) registry.splice(index, 1);
3443
- };
3444
- /**
3445
- * Returns the result of the performance.now() method or null in browsers
3446
- * that don't support the API.
3447
- * @return {number} The elapsed time since the page was requested.
3448
- */
3449
- function now() {
3450
- return window.performance && performance.now && performance.now();
3451
- }
3452
- /**
3453
- * Adds an event handler to a DOM node ensuring cross-browser compatibility.
3454
- * @param {Node} node The DOM node to add the event handler to.
3455
- * @param {string} event The event name.
3456
- * @param {Function} fn The event handler to add.
3457
- * @param {boolean} opt_useCapture Optionally adds the even to the capture
3458
- * phase. Note: this only works in modern browsers.
3459
- */
3460
- function addEvent(node, event, fn, opt_useCapture) {
3461
- if (isFunction(node.addEventListener)) node.addEventListener(event, fn, opt_useCapture || false);
3462
- else if (isFunction(node.attachEvent)) node.attachEvent("on" + event, fn);
3463
- }
3464
- /**
3465
- * Removes a previously added event handler from a DOM node.
3466
- * @param {Node} node The DOM node to remove the event handler from.
3467
- * @param {string} event The event name.
3468
- * @param {Function} fn The event handler to remove.
3469
- * @param {boolean} opt_useCapture If the event handler was added with this
3470
- * flag set to true, it should be set to true here in order to remove it.
3471
- */
3472
- function removeEvent(node, event, fn, opt_useCapture) {
3473
- if (isFunction(node.removeEventListener)) node.removeEventListener(event, fn, opt_useCapture || false);
3474
- else if (isFunction(node.detatchEvent)) node.detatchEvent("on" + event, fn);
3475
- }
3476
- /**
3477
- * Returns the intersection between two rect objects.
3478
- * @param {Object} rect1 The first rect.
3479
- * @param {Object} rect2 The second rect.
3480
- * @return {?Object} The intersection rect or undefined if no intersection
3481
- * is found.
3482
- */
3483
- function computeRectIntersection(rect1, rect2) {
3484
- const top = Math.max(rect1.top, rect2.top);
3485
- const bottom = Math.min(rect1.bottom, rect2.bottom);
3486
- const left = Math.max(rect1.left, rect2.left);
3487
- const right = Math.min(rect1.right, rect2.right);
3488
- const width = right - left;
3489
- const height = bottom - top;
3490
- return width >= 0 && height >= 0 && {
3491
- top,
3492
- bottom,
3493
- left,
3494
- right,
3495
- width,
3496
- height
3497
- };
3498
- }
3499
- /**
3500
- * Shims the native getBoundingClientRect for compatibility with older IE.
3501
- * @param {Element} el The element whose bounding rect to get.
3502
- * @return {Object} The (possibly shimmed) rect of the element.
3503
- */
3504
- function getBoundingClientRect(el) {
3505
- let rect;
3506
- try {
3507
- rect = el.getBoundingClientRect();
3508
- } catch (err) {}
3509
- if (!rect) return getEmptyRect();
3510
- if (!(rect.width && rect.height)) rect = {
3511
- top: rect.top,
3512
- right: rect.right,
3513
- bottom: rect.bottom,
3514
- left: rect.left,
3515
- width: rect.right - rect.left,
3516
- height: rect.bottom - rect.top
3517
- };
3518
- return rect;
3519
- }
3520
- /**
3521
- * Returns an empty rect object. An empty rect is returned when an element
3522
- * is not in the DOM.
3523
- * @return {Object} The empty rect.
3524
- */
3525
- function getEmptyRect() {
3526
- return {
3527
- top: 0,
3528
- bottom: 0,
3529
- left: 0,
3530
- right: 0,
3531
- width: 0,
3532
- height: 0
3533
- };
3534
- }
3535
- /**
3536
- * Checks to see if a parent element contains a child element (including inside
3537
- * shadow DOM).
3538
- * @param {Node} parent The parent element.
3539
- * @param {Node} child The child element.
3540
- * @return {boolean} True if the parent node contains the child node.
3541
- */
3542
- function containsDeep(parent, child) {
3543
- let node = child;
3544
- while (node) {
3545
- if (node == parent) return true;
3546
- node = getParentNode(node);
3547
- }
3548
- return false;
3549
- }
3550
- /**
3551
- * Gets the parent node of an element or its host element if the parent node
3552
- * is a shadow root.
3553
- * @param {Node} node The node whose parent to get.
3554
- * @return {Node|null} The parent node or null if no parent exists.
3555
- */
3556
- function getParentNode(node) {
3557
- const parent = node.parentNode;
3558
- if (parent && parent.nodeType == 11 && parent.host) return parent.host;
3559
- if (parent && parent.assignedSlot) return parent.assignedSlot.parentNode;
3560
- return parent;
3561
- }
3562
- window.IntersectionObserver = IntersectionObserver;
3563
- window.IntersectionObserverEntry = IntersectionObserverEntry;
3564
- }
3565
- //#endregion
3566
3327
  //#region src/polyfill/object.ts
3567
3328
  function handleObjectAssignPolyfill() {
3568
3329
  if (!isFunction(Object.assign)) Object.assign = function(target) {
@@ -3629,12 +3390,9 @@ function handlePolyfill() {
3629
3390
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.defineProperty") handleObjectDefinePropertyPolyfill();
3630
3391
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.find") handleArrayFindPolyfill();
3631
3392
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.includes") handleArrayIncludesPolyfill();
3632
- if (process.env.TARO_PLATFORM === "web" && isObject(window)) {
3633
- if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "IntersectionObserver") handleIntersectionObserverPolyfill();
3634
- }
3635
3393
  }
3636
- if (process.env.SUPPORT_TARO_POLYFILL !== "disabled" && process.env.TARO_PLATFORM !== "web") handlePolyfill();
3394
+ if (process.env.SUPPORT_TARO_POLYFILL !== "disabled") handlePolyfill();
3637
3395
  //#endregion
3638
- export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, Events, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver$1 as MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventHandlerTTDom, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hooks, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
3396
+ export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, Events, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hooks, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, setCurrentApp, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, whenAppReady, taroWindowProvider as window };
3639
3397
 
3640
3398
  //# sourceMappingURL=runtime.esm.js.map