@spcsn/taro-runtime 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
  12. package/dist/bom/URL.d.ts +1 -6
  13. package/dist/bom/URL.js +36 -26
  14. package/dist/bom/URL.js.map +1 -1
  15. package/dist/bom/URLSearchParams.js +18 -14
  16. package/dist/bom/URLSearchParams.js.map +1 -1
  17. package/dist/bom/document.js +3 -2
  18. package/dist/bom/document.js.map +1 -1
  19. package/dist/bom/history.d.ts +1 -5
  20. package/dist/bom/history.js +52 -38
  21. package/dist/bom/history.js.map +1 -1
  22. package/dist/bom/location.d.ts +1 -11
  23. package/dist/bom/location.js +101 -90
  24. package/dist/bom/location.js.map +1 -1
  25. package/dist/bom/window.js +1 -1
  26. package/dist/bom/window.js.map +1 -1
  27. package/dist/dom/anchor-element.js +16 -8
  28. package/dist/dom/anchor-element.js.map +1 -1
  29. package/dist/dom/class-list.js.map +1 -1
  30. package/dist/dom/document.js.map +1 -1
  31. package/dist/dom/element.js +2 -1
  32. package/dist/dom/element.js.map +1 -1
  33. package/dist/dom/event-target.js +2 -4
  34. package/dist/dom/event-target.js.map +1 -1
  35. package/dist/dom/event.js +18 -17
  36. package/dist/dom/event.js.map +1 -1
  37. package/dist/dom/form.js +2 -1
  38. package/dist/dom/form.js.map +1 -1
  39. package/dist/dom/node.js +9 -6
  40. package/dist/dom/node.js.map +1 -1
  41. package/dist/dom/root.js +2 -4
  42. package/dist/dom/root.js.map +1 -1
  43. package/dist/dom/text.js.map +1 -1
  44. package/dist/dom/transfer.js.map +1 -1
  45. package/dist/dom/tree.js +1 -1
  46. package/dist/dom/tree.js.map +1 -1
  47. package/dist/dom-external/mutation-observer/implements.js +1 -1
  48. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  49. package/dist/dsl/common.js +21 -18
  50. package/dist/dsl/common.js.map +1 -1
  51. package/dist/hydrate.js +10 -7
  52. package/dist/hydrate.js.map +1 -1
  53. package/dist/index.cjs.js +392 -256
  54. package/dist/index.cjs.js.map +1 -1
  55. package/dist/next-tick.js +6 -4
  56. package/dist/next-tick.js.map +1 -1
  57. package/dist/perf.d.ts +1 -1
  58. package/dist/perf.js +10 -6
  59. package/dist/perf.js.map +1 -1
  60. package/dist/runtime.esm.js +392 -256
  61. package/dist/runtime.esm.js.map +1 -1
  62. package/dist/utils/cache.js.map +1 -1
  63. package/dist/utils/index.js +9 -6
  64. package/dist/utils/index.js.map +1 -1
  65. package/dist/utils/router.js +2 -1
  66. package/dist/utils/router.js.map +1 -1
  67. package/package.json +2 -2
@@ -109,7 +109,7 @@ var MutationObserverImpl = class {
109
109
  };
110
110
  /** Match two TaroNodes by sid. */
111
111
  const sidMatches = (observerTarget, target) => {
112
- return !!observerTarget && observerTarget.sid === target?.sid;
112
+ return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
113
113
  };
114
114
  const isConcerned = (record, options) => {
115
115
  const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
@@ -184,6 +184,67 @@ var MutationObserver$1 = class {
184
184
  }
185
185
  };
186
186
  //#endregion
187
+ //#region \0@oxc-project+runtime@0.130.0/helpers/typeof.js
188
+ function _typeof(o) {
189
+ "@babel/helpers - typeof";
190
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
191
+ return typeof o;
192
+ } : function(o) {
193
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
194
+ }, _typeof(o);
195
+ }
196
+ //#endregion
197
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPrimitive.js
198
+ function toPrimitive(t, r) {
199
+ if ("object" != _typeof(t) || !t) return t;
200
+ var e = t[Symbol.toPrimitive];
201
+ if (void 0 !== e) {
202
+ var i = e.call(t, r || "default");
203
+ if ("object" != _typeof(i)) return i;
204
+ throw new TypeError("@@toPrimitive must return a primitive value.");
205
+ }
206
+ return ("string" === r ? String : Number)(t);
207
+ }
208
+ //#endregion
209
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPropertyKey.js
210
+ function toPropertyKey(t) {
211
+ var i = toPrimitive(t, "string");
212
+ return "symbol" == _typeof(i) ? i : i + "";
213
+ }
214
+ //#endregion
215
+ //#region \0@oxc-project+runtime@0.130.0/helpers/defineProperty.js
216
+ function _defineProperty(e, r, t) {
217
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
218
+ value: t,
219
+ enumerable: !0,
220
+ configurable: !0,
221
+ writable: !0
222
+ }) : e[r] = t, e;
223
+ }
224
+ //#endregion
225
+ //#region \0@oxc-project+runtime@0.130.0/helpers/objectSpread2.js
226
+ function ownKeys(e, r) {
227
+ var t = Object.keys(e);
228
+ if (Object.getOwnPropertySymbols) {
229
+ var o = Object.getOwnPropertySymbols(e);
230
+ r && (o = o.filter(function(r) {
231
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
232
+ })), t.push.apply(t, o);
233
+ }
234
+ return t;
235
+ }
236
+ function _objectSpread2(e) {
237
+ for (var r = 1; r < arguments.length; r++) {
238
+ var t = null != arguments[r] ? arguments[r] : {};
239
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
240
+ _defineProperty(e, r, t[r]);
241
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
242
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
243
+ });
244
+ }
245
+ return e;
246
+ }
247
+ //#endregion
187
248
  //#region src/utils/lodash.ts
188
249
  function throttle(fn, threshold = 250, scope) {
189
250
  let lastTime = 0;
@@ -251,71 +312,103 @@ var RuntimeCache = class {
251
312
  }
252
313
  };
253
314
  //#endregion
315
+ //#region \0@oxc-project+runtime@0.130.0/helpers/checkPrivateRedeclaration.js
316
+ function _checkPrivateRedeclaration(e, t) {
317
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
318
+ }
319
+ //#endregion
320
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateMethodInitSpec.js
321
+ function _classPrivateMethodInitSpec(e, a) {
322
+ _checkPrivateRedeclaration(e, a), a.add(e);
323
+ }
324
+ //#endregion
325
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldInitSpec.js
326
+ function _classPrivateFieldInitSpec(e, t, a) {
327
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
328
+ }
329
+ //#endregion
330
+ //#region \0@oxc-project+runtime@0.130.0/helpers/assertClassBrand.js
331
+ function _assertClassBrand(e, t, n) {
332
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
333
+ throw new TypeError("Private element is not present on this object");
334
+ }
335
+ //#endregion
336
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldSet2.js
337
+ function _classPrivateFieldSet2(s, a, r) {
338
+ return s.set(_assertClassBrand(s, a), r), r;
339
+ }
340
+ //#endregion
341
+ //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateFieldGet2.js
342
+ function _classPrivateFieldGet2(s, a) {
343
+ return s.get(_assertClassBrand(s, a));
344
+ }
345
+ //#endregion
254
346
  //#region src/bom/history.ts
255
347
  const cache$1 = new RuntimeCache("history");
348
+ var _location = /* @__PURE__ */ new WeakMap();
349
+ var _stack = /* @__PURE__ */ new WeakMap();
350
+ var _cur = /* @__PURE__ */ new WeakMap();
351
+ var _window$1 = /* @__PURE__ */ new WeakMap();
352
+ var _TaroHistory_brand = /* @__PURE__ */ new WeakSet();
256
353
  var TaroHistory = class extends Events {
257
354
  constructor(location, options) {
258
355
  super();
259
- this._stack = [];
260
- this._cur = 0;
261
- this._window = options.window;
262
- this._location = location;
263
- this._location.on("__record_history__", (href) => {
264
- this._cur++;
265
- this._stack = this._stack.slice(0, this._cur);
266
- this._stack.push({
356
+ _classPrivateMethodInitSpec(this, _TaroHistory_brand);
357
+ _classPrivateFieldInitSpec(this, _location, void 0);
358
+ _classPrivateFieldInitSpec(this, _stack, []);
359
+ _classPrivateFieldInitSpec(this, _cur, 0);
360
+ _classPrivateFieldInitSpec(this, _window$1, void 0);
361
+ _classPrivateFieldSet2(_window$1, this, options.window);
362
+ _classPrivateFieldSet2(_location, this, location);
363
+ _classPrivateFieldGet2(_location, this).on("__record_history__", (href) => {
364
+ var _this$cur;
365
+ _classPrivateFieldSet2(_cur, this, (_this$cur = _classPrivateFieldGet2(_cur, this), _this$cur++, _this$cur));
366
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this)));
367
+ _classPrivateFieldGet2(_stack, this).push({
267
368
  state: null,
268
369
  title: "",
269
370
  url: href
270
371
  });
271
372
  }, null);
272
- this._location.on("__reset_history__", (href) => {
273
- this._reset(href);
373
+ _classPrivateFieldGet2(_location, this).on("__reset_history__", (href) => {
374
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this, href);
274
375
  }, null);
275
376
  this.on("0", () => {
276
- this._reset();
377
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
277
378
  }, null);
278
379
  this.on("1", (pageId) => {
279
380
  cache$1.set(pageId, {
280
- location: this._location,
281
- stack: this._stack.slice(),
282
- cur: this._cur
381
+ location: _classPrivateFieldGet2(_location, this),
382
+ stack: _classPrivateFieldGet2(_stack, this).slice(),
383
+ cur: _classPrivateFieldGet2(_cur, this)
283
384
  });
284
385
  }, null);
285
386
  this.on("2", (pageId) => {
286
387
  if (cache$1.has(pageId)) {
287
388
  const ctx = cache$1.get(pageId);
288
- this._location = ctx.location;
289
- this._stack = ctx.stack;
290
- this._cur = ctx.cur;
389
+ _classPrivateFieldSet2(_location, this, ctx.location);
390
+ _classPrivateFieldSet2(_stack, this, ctx.stack);
391
+ _classPrivateFieldSet2(_cur, this, ctx.cur);
291
392
  }
292
393
  }, null);
293
394
  this.on("3", (pageId) => {
294
395
  cache$1.delete(pageId);
295
396
  }, null);
296
- this._reset();
297
- }
298
- _reset(href = "") {
299
- this._stack = [{
300
- state: null,
301
- title: "",
302
- url: href || this._location.href
303
- }];
304
- this._cur = 0;
397
+ _assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
305
398
  }
306
399
  get length() {
307
- return this._stack.length;
400
+ return _classPrivateFieldGet2(_stack, this).length;
308
401
  }
309
402
  get state() {
310
- return this._stack[this._cur].state;
403
+ return _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].state;
311
404
  }
312
405
  go(delta) {
313
406
  if (!isNumber(delta) || isNaN(delta)) return;
314
- let targetIdx = this._cur + delta;
407
+ let targetIdx = _classPrivateFieldGet2(_cur, this) + delta;
315
408
  targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
316
- this._cur = targetIdx;
317
- this._location.trigger("__set_href_without_history__", this._stack[this._cur].url);
318
- this._window.trigger("popstate", this._stack[this._cur]);
409
+ _classPrivateFieldSet2(_cur, this, targetIdx);
410
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].url);
411
+ _classPrivateFieldGet2(_window$1, this).trigger("popstate", _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)]);
319
412
  }
320
413
  back() {
321
414
  this.go(-1);
@@ -325,28 +418,36 @@ var TaroHistory = class extends Events {
325
418
  }
326
419
  pushState(state, title, url) {
327
420
  if (!url || !isString(url)) return;
328
- this._stack = this._stack.slice(0, this._cur + 1);
329
- this._stack.push({
421
+ _classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this) + 1));
422
+ _classPrivateFieldGet2(_stack, this).push({
330
423
  state,
331
424
  title,
332
425
  url
333
426
  });
334
- this._cur = this.length - 1;
335
- this._location.trigger("__set_href_without_history__", url);
427
+ _classPrivateFieldSet2(_cur, this, this.length - 1);
428
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
336
429
  }
337
430
  replaceState(state, title, url) {
338
431
  if (!url || !isString(url)) return;
339
- this._stack[this._cur] = {
432
+ _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)] = {
340
433
  state,
341
434
  title,
342
435
  url
343
436
  };
344
- this._location.trigger("__set_href_without_history__", url);
437
+ _classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
345
438
  }
346
439
  get cache() {
347
440
  return cache$1;
348
441
  }
349
442
  };
443
+ function _reset$1(href = "") {
444
+ _classPrivateFieldSet2(_stack, this, [{
445
+ state: null,
446
+ title: "",
447
+ url: href || _classPrivateFieldGet2(_location, this).href
448
+ }]);
449
+ _classPrivateFieldSet2(_cur, this, 0);
450
+ }
350
451
  const History = process.env.TARO_PLATFORM === "web" ? env.window.History : TaroHistory;
351
452
  //#endregion
352
453
  //#region src/current.ts
@@ -358,6 +459,7 @@ const Current = {
358
459
  const getCurrentInstance = () => Current;
359
460
  //#endregion
360
461
  //#region src/bom/URLSearchParams.ts
462
+ var _dict;
361
463
  const findReg = /[!'()~]|%20|%00/g;
362
464
  const plusReg = /\+/g;
363
465
  const replaceCharMap = {
@@ -386,11 +488,12 @@ function decode(str) {
386
488
  function encode(str) {
387
489
  return encodeURIComponent(str).replace(findReg, replacer);
388
490
  }
389
- const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : class {
491
+ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : (_dict = /* @__PURE__ */ new WeakMap(), class {
390
492
  constructor(query) {
391
- this._dict = Object.create(null);
392
- query ??= "";
393
- const dict = this._dict;
493
+ var _query;
494
+ _classPrivateFieldInitSpec(this, _dict, Object.create(null));
495
+ (_query = query) !== null && _query !== void 0 || (query = "");
496
+ const dict = _classPrivateFieldGet2(_dict, this);
394
497
  if (typeof query === "string") {
395
498
  if (query.charAt(0) === "?") query = query.slice(1);
396
499
  for (let pairs = query.split("&"), i = 0, length = pairs.length; i < length; i++) {
@@ -411,30 +514,30 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
411
514
  else for (const key in query) appendTo(dict, key, query[key]);
412
515
  }
413
516
  append(name, value) {
414
- appendTo(this._dict, name, value);
517
+ appendTo(_classPrivateFieldGet2(_dict, this), name, value);
415
518
  }
416
519
  delete(name) {
417
- delete this._dict[name];
520
+ delete _classPrivateFieldGet2(_dict, this)[name];
418
521
  }
419
522
  get(name) {
420
- const dict = this._dict;
523
+ const dict = _classPrivateFieldGet2(_dict, this);
421
524
  return name in dict ? dict[name][0] : null;
422
525
  }
423
526
  getAll(name) {
424
- const dict = this._dict;
527
+ const dict = _classPrivateFieldGet2(_dict, this);
425
528
  return name in dict ? dict[name].slice(0) : [];
426
529
  }
427
530
  has(name) {
428
- return name in this._dict;
531
+ return name in _classPrivateFieldGet2(_dict, this);
429
532
  }
430
533
  keys() {
431
- return Object.keys(this._dict);
534
+ return Object.keys(_classPrivateFieldGet2(_dict, this));
432
535
  }
433
536
  set(name, value) {
434
- this._dict[name] = ["" + value];
537
+ _classPrivateFieldGet2(_dict, this)[name] = ["" + value];
435
538
  }
436
539
  forEach(callback, thisArg) {
437
- const dict = this._dict;
540
+ const dict = _classPrivateFieldGet2(_dict, this);
438
541
  Object.getOwnPropertyNames(dict).forEach(function(name) {
439
542
  dict[name].forEach(function(value) {
440
543
  callback.call(thisArg, value, name, this);
@@ -445,7 +548,7 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
445
548
  return {};
446
549
  }
447
550
  toString() {
448
- const dict = this._dict;
551
+ const dict = _classPrivateFieldGet2(_dict, this);
449
552
  const query = [];
450
553
  for (const key in dict) {
451
554
  const name = encode(key);
@@ -453,9 +556,15 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
453
556
  }
454
557
  return query.join("&");
455
558
  }
456
- };
559
+ });
457
560
  //#endregion
458
561
  //#region src/bom/URL.ts
562
+ var _hash = /* @__PURE__ */ new WeakMap();
563
+ var _hostname = /* @__PURE__ */ new WeakMap();
564
+ var _pathname = /* @__PURE__ */ new WeakMap();
565
+ var _port = /* @__PURE__ */ new WeakMap();
566
+ var _protocol = /* @__PURE__ */ new WeakMap();
567
+ var _search = /* @__PURE__ */ new WeakMap();
459
568
  var TaroURL = class {
460
569
  static createObjectURL() {
461
570
  throw new Error("Oops, not support URL.createObjectURL() in miniprogram.");
@@ -464,25 +573,26 @@ var TaroURL = class {
464
573
  throw new Error("Oops, not support URL.revokeObjectURL() in miniprogram.");
465
574
  }
466
575
  constructor(url, base) {
467
- this._hash = "";
468
- this._hostname = "";
469
- this._pathname = "";
470
- this._port = "";
471
- this._protocol = "";
576
+ _classPrivateFieldInitSpec(this, _hash, "");
577
+ _classPrivateFieldInitSpec(this, _hostname, "");
578
+ _classPrivateFieldInitSpec(this, _pathname, "");
579
+ _classPrivateFieldInitSpec(this, _port, "");
580
+ _classPrivateFieldInitSpec(this, _protocol, "");
581
+ _classPrivateFieldInitSpec(this, _search, void 0);
472
582
  if (!isString(url)) url = String(url);
473
583
  const { hash, hostname, pathname, port, protocol, search } = parseUrlBase(url, base);
474
- this._hash = hash;
475
- this._hostname = hostname;
476
- this._pathname = pathname || "/";
477
- this._port = port;
478
- this._protocol = protocol;
479
- this._search = new URLSearchParams(search);
584
+ _classPrivateFieldSet2(_hash, this, hash);
585
+ _classPrivateFieldSet2(_hostname, this, hostname);
586
+ _classPrivateFieldSet2(_pathname, this, pathname || "/");
587
+ _classPrivateFieldSet2(_port, this, port);
588
+ _classPrivateFieldSet2(_protocol, this, protocol);
589
+ _classPrivateFieldSet2(_search, this, new URLSearchParams(search));
480
590
  }
481
591
  get protocol() {
482
- return this._protocol;
592
+ return _classPrivateFieldGet2(_protocol, this);
483
593
  }
484
594
  set protocol(val) {
485
- isString(val) && (this._protocol = val.trim());
595
+ isString(val) && _classPrivateFieldSet2(_protocol, this, val.trim());
486
596
  }
487
597
  get host() {
488
598
  return this.hostname + (this.port ? ":" + this.port : "");
@@ -496,19 +606,19 @@ var TaroURL = class {
496
606
  }
497
607
  }
498
608
  get hostname() {
499
- return this._hostname;
609
+ return _classPrivateFieldGet2(_hostname, this);
500
610
  }
501
611
  set hostname(val) {
502
- val && isString(val) && (this._hostname = val.trim());
612
+ val && isString(val) && _classPrivateFieldSet2(_hostname, this, val.trim());
503
613
  }
504
614
  get port() {
505
- return this._port;
615
+ return _classPrivateFieldGet2(_port, this);
506
616
  }
507
617
  set port(val) {
508
- isString(val) && (this._port = val.trim());
618
+ isString(val) && _classPrivateFieldSet2(_port, this, val.trim());
509
619
  }
510
620
  get pathname() {
511
- return this._pathname;
621
+ return _classPrivateFieldGet2(_pathname, this);
512
622
  }
513
623
  set pathname(val) {
514
624
  if (isString(val)) {
@@ -516,28 +626,28 @@ var TaroURL = class {
516
626
  const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
517
627
  let temp = val;
518
628
  while (HEAD_REG.test(temp)) temp = temp.replace(HEAD_REG, "");
519
- if (temp) this._pathname = "/" + temp;
520
- else this._pathname = "/";
629
+ if (temp) _classPrivateFieldSet2(_pathname, this, "/" + temp);
630
+ else _classPrivateFieldSet2(_pathname, this, "/");
521
631
  }
522
632
  }
523
633
  get search() {
524
- const val = this._search.toString();
634
+ const val = _classPrivateFieldGet2(_search, this).toString();
525
635
  return val.length === 0 || val.startsWith("?") ? val : `?${val}`;
526
636
  }
527
637
  set search(val) {
528
638
  if (isString(val)) {
529
639
  val = val.trim();
530
- this._search = new URLSearchParams(val);
640
+ _classPrivateFieldSet2(_search, this, new URLSearchParams(val));
531
641
  }
532
642
  }
533
643
  get hash() {
534
- return this._hash;
644
+ return _classPrivateFieldGet2(_hash, this);
535
645
  }
536
646
  set hash(val) {
537
647
  if (isString(val)) {
538
648
  val = val.trim();
539
- if (val) this._hash = val.startsWith("#") ? val : `#${val}`;
540
- else this._hash = "";
649
+ if (val) _classPrivateFieldSet2(_hash, this, val.startsWith("#") ? val : `#${val}`);
650
+ else _classPrivateFieldSet2(_hash, this, "");
541
651
  }
542
652
  }
543
653
  get href() {
@@ -568,7 +678,7 @@ var TaroURL = class {
568
678
  }
569
679
  }
570
680
  get searchParams() {
571
- return this._search;
681
+ return _classPrivateFieldGet2(_search, this);
572
682
  }
573
683
  toString() {
574
684
  return this.href;
@@ -639,22 +749,28 @@ function parseUrlBase(url, base) {
639
749
  //#region src/bom/location.ts
640
750
  const INIT_URL = "https://taro.com";
641
751
  const cache = new RuntimeCache("location");
752
+ var _url = /* @__PURE__ */ new WeakMap();
753
+ var _noCheckUrl = /* @__PURE__ */ new WeakMap();
754
+ var _window = /* @__PURE__ */ new WeakMap();
755
+ var _TaroLocation_brand = /* @__PURE__ */ new WeakSet();
642
756
  var TaroLocation = class extends Events {
643
757
  constructor(options) {
644
758
  super();
645
- this._url = new TaroURLProvider(INIT_URL);
646
- this._noCheckUrl = false;
647
- this._window = options.window;
648
- this._reset();
759
+ _classPrivateMethodInitSpec(this, _TaroLocation_brand);
760
+ _classPrivateFieldInitSpec(this, _url, new TaroURLProvider(INIT_URL));
761
+ _classPrivateFieldInitSpec(this, _noCheckUrl, false);
762
+ _classPrivateFieldInitSpec(this, _window, void 0);
763
+ _classPrivateFieldSet2(_window, this, options.window);
764
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
649
765
  this.on("__set_href_without_history__", (href) => {
650
- this._noCheckUrl = true;
651
- const lastHash = this._url.hash;
652
- this._url.href = generateFullUrl(href);
653
- if (lastHash !== this._url.hash) this._window.trigger("hashchange");
654
- this._noCheckUrl = false;
766
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
767
+ const lastHash = _classPrivateFieldGet2(_url, this).hash;
768
+ _classPrivateFieldGet2(_url, this).href = generateFullUrl(href);
769
+ if (lastHash !== _classPrivateFieldGet2(_url, this).hash) _classPrivateFieldGet2(_window, this).trigger("hashchange");
770
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
655
771
  }, null);
656
772
  this.on("0", () => {
657
- this._reset();
773
+ _assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
658
774
  }, null);
659
775
  this.on("1", (pageId) => {
660
776
  cache.set(pageId, { lastHref: this.href });
@@ -662,145 +778,104 @@ var TaroLocation = class extends Events {
662
778
  this.on("2", (pageId) => {
663
779
  if (cache.has(pageId)) {
664
780
  const ctx = cache.get(pageId);
665
- this._noCheckUrl = true;
666
- this._url.href = ctx.lastHref;
667
- this._noCheckUrl = false;
781
+ _classPrivateFieldSet2(_noCheckUrl, this, true);
782
+ _classPrivateFieldGet2(_url, this).href = ctx.lastHref;
783
+ _classPrivateFieldSet2(_noCheckUrl, this, false);
668
784
  }
669
785
  }, null);
670
786
  this.on("3", (pageId) => {
671
787
  cache.delete(pageId);
672
788
  }, null);
673
789
  }
674
- _reset() {
675
- const router = getCurrentInstance().router;
676
- if (router) {
677
- const { path, params } = router;
678
- const searchArr = Object.keys(params).map((key) => {
679
- return `${key}=${params[key]}`;
680
- });
681
- const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
682
- const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
683
- this._url = new TaroURLProvider(url);
684
- this.trigger("__reset_history__", this.href);
685
- }
686
- }
687
- _getPreValue() {
688
- return this._url._toRaw();
689
- }
690
- _rollBack(href) {
691
- this._url.href = href;
692
- }
693
- _recordHistory() {
694
- this.trigger("__record_history__", this.href);
695
- }
696
- /**
697
- * 校验url的变化,是否需要更新history
698
- */
699
- _checkUrlChange(preValue) {
700
- if (this._noCheckUrl) return false;
701
- const { protocol, hostname, port, pathname, search, hash } = this._url._toRaw();
702
- if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
703
- this._rollBack(preValue.href);
704
- return false;
705
- }
706
- if (pathname !== preValue.pathname) return true;
707
- if (search !== preValue.search) return true;
708
- if (hash !== preValue.hash) {
709
- this._window.trigger("hashchange");
710
- return true;
711
- }
712
- this._rollBack(preValue.href);
713
- return false;
714
- }
715
790
  get protocol() {
716
- return this._url.protocol;
791
+ return _classPrivateFieldGet2(_url, this).protocol;
717
792
  }
718
793
  set protocol(val) {
719
794
  if (!val || !isString(val) || !/^(http|https):$/i.test(val.trim())) return;
720
795
  val = val.trim();
721
- const preValue = this._getPreValue();
722
- this._url.protocol = val;
723
- if (this._checkUrlChange(preValue)) this._recordHistory();
796
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
797
+ _classPrivateFieldGet2(_url, this).protocol = val;
798
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
724
799
  }
725
800
  get host() {
726
- return this._url.host;
801
+ return _classPrivateFieldGet2(_url, this).host;
727
802
  }
728
803
  set host(val) {
729
804
  if (!val || !isString(val)) return;
730
805
  val = val.trim();
731
- const preValue = this._getPreValue();
732
- this._url.host = val;
733
- if (this._checkUrlChange(preValue)) this._recordHistory();
806
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
807
+ _classPrivateFieldGet2(_url, this).host = val;
808
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
734
809
  }
735
810
  get hostname() {
736
- return this._url.hostname;
811
+ return _classPrivateFieldGet2(_url, this).hostname;
737
812
  }
738
813
  set hostname(val) {
739
814
  if (!val || !isString(val)) return;
740
815
  val = val.trim();
741
- const preValue = this._getPreValue();
742
- this._url.hostname = val;
743
- if (this._checkUrlChange(preValue)) this._recordHistory();
816
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
817
+ _classPrivateFieldGet2(_url, this).hostname = val;
818
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
744
819
  }
745
820
  get port() {
746
- return this._url.port;
821
+ return _classPrivateFieldGet2(_url, this).port;
747
822
  }
748
823
  set port(val) {
749
824
  const xVal = Number(val = val.trim());
750
825
  if (!isNumber(xVal) || xVal <= 0) return;
751
- const preValue = this._getPreValue();
752
- this._url.port = val;
753
- if (this._checkUrlChange(preValue)) this._recordHistory();
826
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
827
+ _classPrivateFieldGet2(_url, this).port = val;
828
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
754
829
  }
755
830
  get pathname() {
756
- return this._url.pathname;
831
+ return _classPrivateFieldGet2(_url, this).pathname;
757
832
  }
758
833
  set pathname(val) {
759
834
  if (!val || !isString(val)) return;
760
835
  val = val.trim();
761
- const preValue = this._getPreValue();
762
- this._url.pathname = val;
763
- if (this._checkUrlChange(preValue)) this._recordHistory();
836
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
837
+ _classPrivateFieldGet2(_url, this).pathname = val;
838
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
764
839
  }
765
840
  get search() {
766
- return this._url.search;
841
+ return _classPrivateFieldGet2(_url, this).search;
767
842
  }
768
843
  set search(val) {
769
844
  if (!val || !isString(val)) return;
770
845
  val = val.trim();
771
846
  val = val.startsWith("?") ? val : `?${val}`;
772
- const preValue = this._getPreValue();
773
- this._url.search = val;
774
- if (this._checkUrlChange(preValue)) this._recordHistory();
847
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
848
+ _classPrivateFieldGet2(_url, this).search = val;
849
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
775
850
  }
776
851
  get hash() {
777
- return this._url.hash;
852
+ return _classPrivateFieldGet2(_url, this).hash;
778
853
  }
779
854
  set hash(val) {
780
855
  if (!val || !isString(val)) return;
781
856
  val = val.trim();
782
857
  val = val.startsWith("#") ? val : `#${val}`;
783
- const preValue = this._getPreValue();
784
- this._url.hash = val;
785
- if (this._checkUrlChange(preValue)) this._recordHistory();
858
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
859
+ _classPrivateFieldGet2(_url, this).hash = val;
860
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
786
861
  }
787
862
  get href() {
788
- return this._url.href;
863
+ return _classPrivateFieldGet2(_url, this).href;
789
864
  }
790
865
  set href(val) {
791
866
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
792
- const preValue = this._getPreValue();
793
- this._url.href = val;
794
- if (this._checkUrlChange(preValue)) this._recordHistory();
867
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
868
+ _classPrivateFieldGet2(_url, this).href = val;
869
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
795
870
  }
796
871
  get origin() {
797
- return this._url.origin;
872
+ return _classPrivateFieldGet2(_url, this).origin;
798
873
  }
799
874
  set origin(val) {
800
875
  if (!val || !isString(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
801
- const preValue = this._getPreValue();
802
- this._url.origin = val;
803
- if (this._checkUrlChange(preValue)) this._recordHistory();
876
+ const preValue = _assertClassBrand(_TaroLocation_brand, this, _getPreValue).call(this);
877
+ _classPrivateFieldGet2(_url, this).origin = val;
878
+ if (_assertClassBrand(_TaroLocation_brand, this, _checkUrlChange).call(this, preValue)) _assertClassBrand(_TaroLocation_brand, this, _recordHistory).call(this);
804
879
  }
805
880
  assign() {
806
881
  warn(true, "小程序环境中调用location.assign()无效.");
@@ -818,6 +893,47 @@ var TaroLocation = class extends Events {
818
893
  return cache;
819
894
  }
820
895
  };
896
+ function _reset() {
897
+ const router = getCurrentInstance().router;
898
+ if (router) {
899
+ const { path, params } = router;
900
+ const searchArr = Object.keys(params).map((key) => {
901
+ return `${key}=${params[key]}`;
902
+ });
903
+ const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
904
+ const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
905
+ _classPrivateFieldSet2(_url, this, new TaroURLProvider(url));
906
+ this.trigger("__reset_history__", this.href);
907
+ }
908
+ }
909
+ function _getPreValue() {
910
+ return _classPrivateFieldGet2(_url, this)._toRaw();
911
+ }
912
+ function _rollBack(href) {
913
+ _classPrivateFieldGet2(_url, this).href = href;
914
+ }
915
+ function _recordHistory() {
916
+ this.trigger("__record_history__", this.href);
917
+ }
918
+ /**
919
+ * 校验url的变化,是否需要更新history
920
+ */
921
+ function _checkUrlChange(preValue) {
922
+ if (_classPrivateFieldGet2(_noCheckUrl, this)) return false;
923
+ const { protocol, hostname, port, pathname, search, hash } = _classPrivateFieldGet2(_url, this)._toRaw();
924
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
925
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
926
+ return false;
927
+ }
928
+ if (pathname !== preValue.pathname) return true;
929
+ if (search !== preValue.search) return true;
930
+ if (hash !== preValue.hash) {
931
+ _classPrivateFieldGet2(_window, this).trigger("hashchange");
932
+ return true;
933
+ }
934
+ _assertClassBrand(_TaroLocation_brand, this, _rollBack).call(this, preValue.href);
935
+ return false;
936
+ }
821
937
  const Location = process.env.TARO_PLATFORM === "web" ? env.window.Location : TaroLocation;
822
938
  function generateFullUrl(val = "") {
823
939
  const origin = INIT_URL;
@@ -884,7 +1000,7 @@ var TaroWindow = class extends Events {
884
1000
  console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
885
1001
  }
886
1002
  });
887
- this.Date ||= Date;
1003
+ this.Date || (this.Date = Date);
888
1004
  this.location = new Location({ window: this });
889
1005
  this.history = new History(this.location, { window: this });
890
1006
  this.initEvent();
@@ -937,8 +1053,9 @@ const stripBasename = (path = "", prefix = "") => hasBasename(path, prefix) ? pa
937
1053
  const stripTrailing = (str = "") => str.replace(/[?#][\s\S]*$/, "");
938
1054
  const stripSuffix = (path = "", suffix = "") => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
939
1055
  const getHomePage = (path = "", basename = "", customRoutes = {}, entryPagePath = "") => {
1056
+ var _Object$entries$find;
940
1057
  const routePath = addLeadingSlash(stripBasename(path, basename));
941
- const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;
1058
+ const alias = ((_Object$entries$find = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1]) || routePath;
942
1059
  return entryPagePath || (typeof alias === "string" ? alias : alias[0]) || basename;
943
1060
  };
944
1061
  const getCurrentPage = (routerMode = "hash", basename = "/") => {
@@ -990,8 +1107,11 @@ function isHasExtractProp(el) {
990
1107
  * @param type 事件类型
991
1108
  */
992
1109
  function isParentBound(node, type) {
993
- while (node = node?.parentElement || null) if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
994
- else if (node.__handlers[type]?.length) return true;
1110
+ while (node = (node === null || node === void 0 ? void 0 : node.parentElement) || null) {
1111
+ var _node$__handlers$type;
1112
+ if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
1113
+ else if ((_node$__handlers$type = node.__handlers[type]) === null || _node$__handlers$type === void 0 ? void 0 : _node$__handlers$type.length) return true;
1114
+ }
995
1115
  return false;
996
1116
  }
997
1117
  function shortcutAttr(key) {
@@ -1005,11 +1125,10 @@ function shortcutAttr(key) {
1005
1125
  const customWrapperCache = /* @__PURE__ */ new Map();
1006
1126
  function extend(ctor, methodName, options) {
1007
1127
  if (isFunction(options)) options = { value: options };
1008
- Object.defineProperty(ctor.prototype, methodName, {
1128
+ Object.defineProperty(ctor.prototype, methodName, _objectSpread2({
1009
1129
  configurable: true,
1010
- enumerable: true,
1011
- ...options
1012
- });
1130
+ enumerable: true
1131
+ }, options));
1013
1132
  }
1014
1133
  let componentsAlias$1;
1015
1134
  function getComponentsAlias() {
@@ -1121,15 +1240,18 @@ let componentsAlias;
1121
1240
  * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
1122
1241
  */
1123
1242
  function hydrate(node) {
1124
- componentsAlias ||= getComponentsAlias();
1125
- SPECIAL_NODES ||= hooks$1.call("getSpecialNodes");
1243
+ componentsAlias || (componentsAlias = getComponentsAlias());
1244
+ SPECIAL_NODES || (SPECIAL_NODES = hooks$1.call("getSpecialNodes"));
1126
1245
  const nodeName = node.nodeName;
1127
1246
  let compileModeName = null;
1128
- if (isText(node)) return {
1129
- sid: node.sid,
1130
- [Shortcuts.Text]: node.nodeValue,
1131
- [Shortcuts.NodeName]: componentsAlias[nodeName]?._num || "8"
1132
- };
1247
+ if (isText(node)) {
1248
+ var _componentsAlias$node;
1249
+ return {
1250
+ sid: node.sid,
1251
+ [Shortcuts.Text]: node.nodeValue,
1252
+ [Shortcuts.NodeName]: ((_componentsAlias$node = componentsAlias[nodeName]) === null || _componentsAlias$node === void 0 ? void 0 : _componentsAlias$node._num) || "8"
1253
+ };
1254
+ }
1133
1255
  const data = {
1134
1256
  [Shortcuts.NodeName]: nodeName,
1135
1257
  sid: node.sid
@@ -1191,10 +1313,7 @@ var TaroEventTarget = class {
1191
1313
  handler.apply(this, arguments);
1192
1314
  this.removeEventListener(type, wrapper);
1193
1315
  };
1194
- this.addEventListener(type, wrapper, {
1195
- ...options,
1196
- once: false
1197
- });
1316
+ this.addEventListener(type, wrapper, _objectSpread2(_objectSpread2({}, options), {}, { once: false }));
1198
1317
  return;
1199
1318
  }
1200
1319
  warn(isCapture, "Taro 暂未实现 event 的 capture 特性。");
@@ -1269,7 +1388,8 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1269
1388
  });
1270
1389
  }
1271
1390
  get _root() {
1272
- return this.parentNode?._root || null;
1391
+ var _this$parentNode;
1392
+ return ((_this$parentNode = this.parentNode) === null || _this$parentNode === void 0 ? void 0 : _this$parentNode._root) || null;
1273
1393
  }
1274
1394
  findIndex(refChild) {
1275
1395
  const index = this.childNodes.indexOf(refChild);
@@ -1287,15 +1407,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1287
1407
  }
1288
1408
  get nextSibling() {
1289
1409
  const parentNode = this.parentNode;
1290
- return parentNode?.childNodes[parentNode.findIndex(this) + 1] || null;
1410
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) + 1]) || null;
1291
1411
  }
1292
1412
  get previousSibling() {
1293
1413
  const parentNode = this.parentNode;
1294
- return parentNode?.childNodes[parentNode.findIndex(this) - 1] || null;
1414
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) - 1]) || null;
1295
1415
  }
1296
1416
  get parentElement() {
1297
1417
  const parentNode = this.parentNode;
1298
- if (parentNode?.nodeType === 1) return parentNode;
1418
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeType) === 1) return parentNode;
1299
1419
  return null;
1300
1420
  }
1301
1421
  get firstChild() {
@@ -1421,13 +1541,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
1421
1541
  return child;
1422
1542
  }
1423
1543
  remove(options) {
1424
- this.parentNode?.removeChild(this, options);
1544
+ var _this$parentNode2;
1545
+ (_this$parentNode2 = this.parentNode) === null || _this$parentNode2 === void 0 || _this$parentNode2.removeChild(this, options);
1425
1546
  }
1426
1547
  hasChildNodes() {
1427
1548
  return this.childNodes.length > 0;
1428
1549
  }
1429
1550
  enqueueUpdate(payload) {
1430
- this._root?.enqueueUpdate(payload);
1551
+ var _this$_root;
1552
+ (_this$_root = this._root) === null || _this$_root === void 0 || _this$_root.enqueueUpdate(payload);
1431
1553
  }
1432
1554
  get ownerDocument() {
1433
1555
  return env.document;
@@ -1945,7 +2067,7 @@ function returnTrue() {
1945
2067
  }
1946
2068
  function treeToArray(root, predict) {
1947
2069
  const array = [];
1948
- const filter = predict ?? returnTrue;
2070
+ const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
1949
2071
  let object = root;
1950
2072
  while (object) {
1951
2073
  if (object.nodeType === 1 && filter(object)) array.push(object);
@@ -2145,7 +2267,8 @@ var TaroElement = class TaroElement extends TaroNode {
2145
2267
  }
2146
2268
  }
2147
2269
  getAttribute(qualifiedName) {
2148
- return (qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName]) ?? "";
2270
+ const attr = qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName];
2271
+ return attr !== null && attr !== void 0 ? attr : "";
2149
2272
  }
2150
2273
  getElementsByTagName(tagName) {
2151
2274
  return treeToArray(this, (el) => {
@@ -2247,14 +2370,12 @@ var TaroEvent = class {
2247
2370
  get target() {
2248
2371
  const cacheTarget = this.cacheTarget;
2249
2372
  if (!cacheTarget) {
2250
- const target = Object.create(this.mpEvent?.target || null);
2251
- const currentEle = env.document.getElementById(target.dataset?.sid || target.id || null);
2252
- const element = env.document.getElementById(target.targetDataset?.sid || target.dataset?.sid || target.id || null);
2253
- target.dataset = {
2254
- ...currentEle !== null ? currentEle.dataset : EMPTY_OBJ,
2255
- ...element !== null ? element.dataset : EMPTY_OBJ
2256
- };
2257
- for (const key in this.mpEvent?.detail) target[key] = this.mpEvent.detail[key];
2373
+ var _this$mpEvent, _target$dataset, _target$targetDataset, _target$dataset2, _this$mpEvent2;
2374
+ const target = Object.create(((_this$mpEvent = this.mpEvent) === null || _this$mpEvent === void 0 ? void 0 : _this$mpEvent.target) || null);
2375
+ const currentEle = env.document.getElementById(((_target$dataset = target.dataset) === null || _target$dataset === void 0 ? void 0 : _target$dataset.sid) || target.id || null);
2376
+ 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);
2377
+ target.dataset = _objectSpread2(_objectSpread2({}, currentEle !== null ? currentEle.dataset : EMPTY_OBJ), element !== null ? element.dataset : EMPTY_OBJ);
2378
+ for (const key in (_this$mpEvent2 = this.mpEvent) === null || _this$mpEvent2 === void 0 ? void 0 : _this$mpEvent2.detail) target[key] = this.mpEvent.detail[key];
2258
2379
  this.cacheTarget = target;
2259
2380
  return target;
2260
2381
  } else return cacheTarget;
@@ -2262,16 +2383,17 @@ var TaroEvent = class {
2262
2383
  get currentTarget() {
2263
2384
  const cacheCurrentTarget = this.cacheCurrentTarget;
2264
2385
  if (!cacheCurrentTarget) {
2386
+ var _this$mpEvent3, _currentTarget$datase, _this$mpEvent4, _this$mpEvent5, _this$mpEvent6;
2265
2387
  const doc = env.document;
2266
- const currentTarget = Object.create(this.mpEvent?.currentTarget || null);
2267
- const element = doc.getElementById(currentTarget.dataset?.sid || currentTarget.id || null);
2268
- const targetElement = doc.getElementById(this.mpEvent?.target?.dataset?.sid || this.mpEvent?.target?.id || null);
2388
+ const currentTarget = Object.create(((_this$mpEvent3 = this.mpEvent) === null || _this$mpEvent3 === void 0 ? void 0 : _this$mpEvent3.currentTarget) || null);
2389
+ const element = doc.getElementById(((_currentTarget$datase = currentTarget.dataset) === null || _currentTarget$datase === void 0 ? void 0 : _currentTarget$datase.sid) || currentTarget.id || null);
2390
+ const targetElement = doc.getElementById(((_this$mpEvent4 = this.mpEvent) === null || _this$mpEvent4 === void 0 || (_this$mpEvent4 = _this$mpEvent4.target) === null || _this$mpEvent4 === void 0 || (_this$mpEvent4 = _this$mpEvent4.dataset) === null || _this$mpEvent4 === void 0 ? void 0 : _this$mpEvent4.sid) || ((_this$mpEvent5 = this.mpEvent) === null || _this$mpEvent5 === void 0 || (_this$mpEvent5 = _this$mpEvent5.target) === null || _this$mpEvent5 === void 0 ? void 0 : _this$mpEvent5.id) || null);
2269
2391
  if (element === null || element && element === targetElement) {
2270
2392
  this.cacheCurrentTarget = this.target;
2271
2393
  return this.target;
2272
2394
  }
2273
2395
  currentTarget.dataset = element.dataset;
2274
- for (const key in this.mpEvent?.detail) currentTarget[key] = this.mpEvent.detail[key];
2396
+ for (const key in (_this$mpEvent6 = this.mpEvent) === null || _this$mpEvent6 === void 0 ? void 0 : _this$mpEvent6.detail) currentTarget[key] = this.mpEvent.detail[key];
2275
2397
  this.cacheCurrentTarget = currentTarget;
2276
2398
  return currentTarget;
2277
2399
  } else return cacheCurrentTarget;
@@ -2288,7 +2410,7 @@ function createEvent(event, node) {
2288
2410
  }, event);
2289
2411
  for (const key in event) if (key === "currentTarget" || key === "target" || key === "type" || key === "timeStamp") continue;
2290
2412
  else domEv[key] = event[key];
2291
- if (domEv.type === "confirm" && node?.nodeName === "input") domEv[KEY_CODE] = 13;
2413
+ if (domEv.type === "confirm" && (node === null || node === void 0 ? void 0 : node.nodeName) === "input") domEv[KEY_CODE] = 13;
2292
2414
  return domEv;
2293
2415
  }
2294
2416
  const eventsBatch = {};
@@ -2298,12 +2420,13 @@ function getEventCBResult(event) {
2298
2420
  return result;
2299
2421
  }
2300
2422
  function eventHandler(event) {
2423
+ var _currentTarget$datase2, _event$detail;
2301
2424
  event.type === void 0 && Object.defineProperty(event, "type", { value: event._type });
2302
- event.detail === void 0 && Object.defineProperty(event, "detail", { value: event._detail || { ...event } });
2303
- event.currentTarget = event.currentTarget || event.target || { ...event };
2425
+ event.detail === void 0 && Object.defineProperty(event, "detail", { value: event._detail || _objectSpread2({}, event) });
2426
+ event.currentTarget = event.currentTarget || event.target || _objectSpread2({}, event);
2304
2427
  hooks$1.call("modifyMpEventImpl", event);
2305
2428
  const currentTarget = event.currentTarget;
2306
- const id = currentTarget.dataset?.sid || currentTarget.id || event.detail?.id || "";
2429
+ const id = ((_currentTarget$datase2 = currentTarget.dataset) === null || _currentTarget$datase2 === void 0 ? void 0 : _currentTarget$datase2.sid) || currentTarget.id || ((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.id) || "";
2307
2430
  const node = env.document.getElementById(id);
2308
2431
  if (node) {
2309
2432
  const dispatch = () => {
@@ -2323,7 +2446,7 @@ function eventHandler(event) {
2323
2446
  dispatch();
2324
2447
  });
2325
2448
  return getEventCBResult(event);
2326
- } else (eventsBatch[type] ||= []).push(dispatch);
2449
+ } else (eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
2327
2450
  } else {
2328
2451
  dispatch();
2329
2452
  return getEventCBResult(event);
@@ -2342,7 +2465,8 @@ function eventHandlerTTDom(ele, listener, event) {
2342
2465
  //#region src/dom/form.ts
2343
2466
  var FormElement = class extends TaroElement {
2344
2467
  get type() {
2345
- return this.props["type"] ?? "";
2468
+ var _this$props$TYPE;
2469
+ return (_this$props$TYPE = this.props["type"]) !== null && _this$props$TYPE !== void 0 ? _this$props$TYPE : "";
2346
2470
  }
2347
2471
  set type(val) {
2348
2472
  this.setAttribute(TYPE, val);
@@ -2365,8 +2489,10 @@ var FormElement = class extends TaroElement {
2365
2489
  };
2366
2490
  //#endregion
2367
2491
  //#region src/perf.ts
2492
+ var _Performance_brand = /* @__PURE__ */ new WeakSet();
2368
2493
  var Performance = class {
2369
2494
  constructor() {
2495
+ _classPrivateMethodInitSpec(this, _Performance_brand);
2370
2496
  this.recorder = /* @__PURE__ */ new Map();
2371
2497
  }
2372
2498
  start(id) {
@@ -2379,20 +2505,20 @@ var Performance = class {
2379
2505
  if (!(prev >= 0)) return;
2380
2506
  this.recorder.delete(id);
2381
2507
  const time = now - prev;
2382
- console.log(`${id} 时长: ${time}ms 开始时间:${this.parseTime(prev)} 结束时间:${this.parseTime(now)}`);
2508
+ console.log(`${id} 时长: ${time}ms 开始时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, prev)} 结束时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, now)}`);
2383
2509
  }
2384
2510
  delayStop(id, delay = 500) {
2385
2511
  if (!options.debug) return;
2386
2512
  return debounce((now = Date.now(), cb) => {
2387
2513
  this.stop(id, now);
2388
- cb?.();
2514
+ cb === null || cb === void 0 || cb();
2389
2515
  }, delay);
2390
2516
  }
2391
- parseTime(time) {
2392
- const d = new Date(time);
2393
- return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
2394
- }
2395
2517
  };
2518
+ function _parseTime(time) {
2519
+ const d = new Date(time);
2520
+ return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
2521
+ }
2396
2522
  const perf = new Performance();
2397
2523
  //#endregion
2398
2524
  //#region src/dom/root.ts
@@ -2472,10 +2598,7 @@ var TaroRootElement = class extends TaroElement {
2472
2598
  const found = findCustomWrapper(this, dataPathArr);
2473
2599
  if (found) {
2474
2600
  const { customWrapper, splitedPath } = found;
2475
- customWrapperMap.set(customWrapper, {
2476
- ...customWrapperMap.get(customWrapper) || {},
2477
- [`i.${splitedPath}`]: data[p]
2478
- });
2601
+ customWrapperMap.set(customWrapper, _objectSpread2(_objectSpread2({}, customWrapperMap.get(customWrapper) || {}), {}, { [`i.${splitedPath}`]: data[p] }));
2479
2602
  } else normalUpdate[p] = data[p];
2480
2603
  }
2481
2604
  const customWrapperCount = customWrapperMap.size;
@@ -2553,31 +2676,39 @@ var TaroText = class extends TaroNode {
2553
2676
  //#region src/dom/anchor-element.ts
2554
2677
  var AnchorElement = class extends TaroElement {
2555
2678
  get href() {
2556
- return this.props["href"] ?? "";
2679
+ var _this$props$AnchorEle;
2680
+ return (_this$props$AnchorEle = this.props["href"]) !== null && _this$props$AnchorEle !== void 0 ? _this$props$AnchorEle : "";
2557
2681
  }
2558
2682
  set href(val) {
2559
2683
  this.setAttribute("href", val);
2560
2684
  }
2561
2685
  get protocol() {
2562
- return this.props["protocol"] ?? "";
2686
+ var _this$props$AnchorEle2;
2687
+ return (_this$props$AnchorEle2 = this.props["protocol"]) !== null && _this$props$AnchorEle2 !== void 0 ? _this$props$AnchorEle2 : "";
2563
2688
  }
2564
2689
  get host() {
2565
- return this.props["host"] ?? "";
2690
+ var _this$props$AnchorEle3;
2691
+ return (_this$props$AnchorEle3 = this.props["host"]) !== null && _this$props$AnchorEle3 !== void 0 ? _this$props$AnchorEle3 : "";
2566
2692
  }
2567
2693
  get search() {
2568
- return this.props["search"] ?? "";
2694
+ var _this$props$AnchorEle4;
2695
+ return (_this$props$AnchorEle4 = this.props["search"]) !== null && _this$props$AnchorEle4 !== void 0 ? _this$props$AnchorEle4 : "";
2569
2696
  }
2570
2697
  get hash() {
2571
- return this.props["hash"] ?? "";
2698
+ var _this$props$AnchorEle5;
2699
+ return (_this$props$AnchorEle5 = this.props["hash"]) !== null && _this$props$AnchorEle5 !== void 0 ? _this$props$AnchorEle5 : "";
2572
2700
  }
2573
2701
  get hostname() {
2574
- return this.props["hostname"] ?? "";
2702
+ var _this$props$AnchorEle6;
2703
+ return (_this$props$AnchorEle6 = this.props["hostname"]) !== null && _this$props$AnchorEle6 !== void 0 ? _this$props$AnchorEle6 : "";
2575
2704
  }
2576
2705
  get port() {
2577
- return this.props["port"] ?? "";
2706
+ var _this$props$AnchorEle7;
2707
+ return (_this$props$AnchorEle7 = this.props["port"]) !== null && _this$props$AnchorEle7 !== void 0 ? _this$props$AnchorEle7 : "";
2578
2708
  }
2579
2709
  get pathname() {
2580
- return this.props["pathname"] ?? "";
2710
+ var _this$props$AnchorEle8;
2711
+ return (_this$props$AnchorEle8 = this.props["pathname"]) !== null && _this$props$AnchorEle8 !== void 0 ? _this$props$AnchorEle8 : "";
2581
2712
  }
2582
2713
  setAttribute(qualifiedName, value) {
2583
2714
  if (qualifiedName === "href") {
@@ -2692,7 +2823,8 @@ function createDocument() {
2692
2823
  return doc;
2693
2824
  }
2694
2825
  function createTTDomDocument() {
2695
- const document = tt?.appDocument;
2826
+ var _tt$getBuiltInCompone;
2827
+ const document = tt === null || tt === void 0 ? void 0 : tt.appDocument;
2696
2828
  if (!document) throw new Error("tt.appDocument is not found");
2697
2829
  const html = document.createElement(HTML);
2698
2830
  const head = document.createElement(HEAD);
@@ -2709,7 +2841,7 @@ function createTTDomDocument() {
2709
2841
  document.head = head;
2710
2842
  document.body = body;
2711
2843
  document.appElement = app;
2712
- let builtInComponents = tt?.getBuiltInComponents?.();
2844
+ let builtInComponents = tt === null || tt === void 0 || (_tt$getBuiltInCompone = tt.getBuiltInComponents) === null || _tt$getBuiltInCompone === void 0 ? void 0 : _tt$getBuiltInCompone.call(tt);
2713
2845
  if (Array.isArray(builtInComponents)) builtInComponents = new Set(builtInComponents);
2714
2846
  else if (!(builtInComponents instanceof Set)) builtInComponents = new Set([...DEFAULT_COMPONENTS, ...TT_SPECIFIC_COMPONENTS]);
2715
2847
  document.getElementById = function getElementById(id) {
@@ -2778,7 +2910,7 @@ function stringify(obj) {
2778
2910
  }
2779
2911
  function getPath(id, options) {
2780
2912
  const idx = id.indexOf("?");
2781
- if (process.env.TARO_PLATFORM === "web") return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options?.stamp ? { stamp: options.stamp } : {})}`;
2913
+ if (process.env.TARO_PLATFORM === "web") return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
2782
2914
  else return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
2783
2915
  }
2784
2916
  function getOnReadyEventKey(path) {
@@ -2791,7 +2923,7 @@ function getOnHideEventKey(path) {
2791
2923
  return path + ".onHide";
2792
2924
  }
2793
2925
  function createPageConfig(component, pageName, data, pageConfig) {
2794
- const id = pageName ?? `taro_page_${pageId()}`;
2926
+ const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
2795
2927
  const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = hooks$1.call("getMiniLifecycleImpl").page;
2796
2928
  let pageElement = null;
2797
2929
  let unmounting = false;
@@ -2913,9 +3045,11 @@ function createPageConfig(component, pageName, data, pageConfig) {
2913
3045
  };
2914
3046
  });
2915
3047
  SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
2916
- if (component[lifecycle] || component.prototype?.[lifecycle] || component[lifecycle.replace(/^on/, "enable")] || pageConfig?.[lifecycle.replace(/^on/, "enable")]) config[lifecycle] = function(...args) {
2917
- const target = args[0]?.target;
2918
- if (target?.id) {
3048
+ var _component$prototype;
3049
+ 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) {
3050
+ var _args$;
3051
+ const target = (_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.target;
3052
+ if (target === null || target === void 0 ? void 0 : target.id) {
2919
3053
  const id = target.id;
2920
3054
  const element = env.document.getElementById(id);
2921
3055
  if (element) target.dataset = element.dataset;
@@ -2929,13 +3063,14 @@ function createPageConfig(component, pageName, data, pageConfig) {
2929
3063
  return config;
2930
3064
  }
2931
3065
  function createComponentConfig(component, componentName, data) {
2932
- const id = componentName ?? `taro_component_${pageId()}`;
3066
+ const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
2933
3067
  let componentElement = null;
2934
3068
  const [ATTACHED, DETACHED] = hooks$1.call("getMiniLifecycleImpl").component;
2935
3069
  const config = {
2936
3070
  [ATTACHED]() {
3071
+ var _this$getPageId;
2937
3072
  perf.start(PAGE_INIT);
2938
- this.pageIdCache = this.getPageId?.() || pageId();
3073
+ this.pageIdCache = ((_this$getPageId = this.getPageId) === null || _this$getPageId === void 0 ? void 0 : _this$getPageId.call(this)) || pageId();
2939
3074
  const path = getPath(id, { id: this.pageIdCache });
2940
3075
  Current.app.mount(component, path, () => {
2941
3076
  componentElement = env.document.getElementById(path);
@@ -2963,7 +3098,8 @@ function createComponentConfig(component, componentName, data) {
2963
3098
  EXTERNAL_CLASSES,
2964
3099
  BEHAVIORS
2965
3100
  ].forEach((key) => {
2966
- config[key] = component[key] ?? EMPTY_OBJ;
3101
+ var _component$key;
3102
+ config[key] = (_component$key = component[key]) !== null && _component$key !== void 0 ? _component$key : EMPTY_OBJ;
2967
3103
  });
2968
3104
  return config;
2969
3105
  }
@@ -2972,8 +3108,9 @@ function createRecursiveComponentConfig(componentName) {
2972
3108
  const [ATTACHED, DETACHED] = hooks$1.call("getMiniLifecycleImpl").component;
2973
3109
  const lifeCycles = isCustomWrapper ? {
2974
3110
  [ATTACHED]() {
3111
+ var _this$data$i, _this$props$i;
2975
3112
  if (process.env.TARO_ENV === "tt" && isEnableTTDom()) return;
2976
- const componentId = this.data.i?.sid || this.props.i?.sid;
3113
+ const componentId = ((_this$data$i = this.data.i) === null || _this$data$i === void 0 ? void 0 : _this$data$i.sid) || ((_this$props$i = this.props.i) === null || _this$props$i === void 0 ? void 0 : _this$props$i.sid);
2977
3114
  if (isString(componentId)) {
2978
3115
  customWrapperCache.set(componentId, this);
2979
3116
  const el = env.document.getElementById(componentId);
@@ -2981,8 +3118,9 @@ function createRecursiveComponentConfig(componentName) {
2981
3118
  }
2982
3119
  },
2983
3120
  [DETACHED]() {
3121
+ var _this$data$i2, _this$props$i2;
2984
3122
  if (process.env.TARO_ENV === "tt" && isEnableTTDom()) return;
2985
- const componentId = this.data.i?.sid || this.props.i?.sid;
3123
+ const componentId = ((_this$data$i2 = this.data.i) === null || _this$data$i2 === void 0 ? void 0 : _this$data$i2.sid) || ((_this$props$i2 = this.props.i) === null || _this$props$i2 === void 0 ? void 0 : _this$props$i2.sid);
2986
3124
  if (isString(componentId)) {
2987
3125
  customWrapperCache.delete(componentId);
2988
3126
  const el = env.document.getElementById(componentId);
@@ -2992,7 +3130,7 @@ function createRecursiveComponentConfig(componentName) {
2992
3130
  } : EMPTY_OBJ;
2993
3131
  const extraOptions = {};
2994
3132
  if (process.env.TARO_ENV === "jd") extraOptions.addGlobalClass = true;
2995
- return hooks$1.call("modifyRecursiveComponentConfig", {
3133
+ return hooks$1.call("modifyRecursiveComponentConfig", _objectSpread2({
2996
3134
  properties: {
2997
3135
  i: {
2998
3136
  type: Object,
@@ -3003,13 +3141,9 @@ function createRecursiveComponentConfig(componentName) {
3003
3141
  value: ""
3004
3142
  }
3005
3143
  },
3006
- options: {
3007
- ...extraOptions,
3008
- virtualHost: !isCustomWrapper
3009
- },
3010
- methods: { eh: eventHandler },
3011
- ...lifeCycles
3012
- }, { isCustomWrapper });
3144
+ options: _objectSpread2(_objectSpread2({}, extraOptions), {}, { virtualHost: !isCustomWrapper }),
3145
+ methods: { eh: eventHandler }
3146
+ }, lifeCycles), { isCustomWrapper });
3013
3147
  }
3014
3148
  //#endregion
3015
3149
  //#region src/next-tick.ts
@@ -3032,10 +3166,12 @@ const nextTick = (cb, ctx) => {
3032
3166
  */
3033
3167
  function next() {
3034
3168
  const pageElement = env.document.getElementById(path);
3035
- if (pageElement?.pendingUpdate) if (process.env.TARO_PLATFORM === "web") pageElement.firstChild?.["componentOnReady"]?.().then(() => {
3036
- timerFunc();
3037
- }) ?? timerFunc();
3038
- else pageElement.enqueueUpdateCallback(cb, ctx);
3169
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) if (process.env.TARO_PLATFORM === "web") {
3170
+ var _pageElement$firstChi, _pageElement$firstChi2, _pageElement$firstChi3;
3171
+ (_pageElement$firstChi = (_pageElement$firstChi2 = pageElement.firstChild) === null || _pageElement$firstChi2 === void 0 || (_pageElement$firstChi3 = _pageElement$firstChi2["componentOnReady"]) === null || _pageElement$firstChi3 === void 0 ? void 0 : _pageElement$firstChi3.call(_pageElement$firstChi2).then(() => {
3172
+ timerFunc();
3173
+ })) !== null && _pageElement$firstChi !== void 0 || timerFunc();
3174
+ } else pageElement.enqueueUpdateCallback(cb, ctx);
3039
3175
  else if (Date.now() - beginTime > TIMEOUT) timerFunc();
3040
3176
  else setTimeout(() => next(), 20);
3041
3177
  }