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