@tarojs/runtime 3.7.0-canary.6 → 3.8.0-canary.1

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 (177) hide show
  1. package/LICENSE +14 -0
  2. package/dist/bom/URL.d.ts +54 -0
  3. package/dist/bom/URL.js +221 -0
  4. package/dist/bom/URL.js.map +1 -0
  5. package/dist/bom/URLSearchParams.d.ts +2 -0
  6. package/dist/bom/URLSearchParams.js +131 -0
  7. package/dist/bom/URLSearchParams.js.map +1 -0
  8. package/dist/bom/document.d.ts +3 -0
  9. package/dist/bom/document.js +39 -0
  10. package/dist/bom/document.js.map +1 -0
  11. package/dist/bom/getComputedStyle.d.ts +5 -0
  12. package/dist/bom/getComputedStyle.js +8 -0
  13. package/dist/bom/getComputedStyle.js.map +1 -0
  14. package/dist/bom/history.d.ts +32 -0
  15. package/dist/bom/history.js +121 -0
  16. package/dist/bom/history.js.map +1 -0
  17. package/dist/bom/location.d.ts +39 -0
  18. package/dist/bom/location.js +240 -0
  19. package/dist/bom/location.js.map +1 -0
  20. package/dist/bom/navigator.d.ts +2 -0
  21. package/dist/bom/navigator.js +24 -0
  22. package/dist/bom/navigator.js.map +1 -0
  23. package/dist/bom/raf.d.ts +4 -0
  24. package/dist/bom/raf.js +33 -0
  25. package/dist/bom/raf.js.map +1 -0
  26. package/dist/bom/window.d.ts +25 -0
  27. package/dist/bom/window.js +92 -0
  28. package/dist/bom/window.js.map +1 -0
  29. package/dist/constants/index.d.ts +60 -0
  30. package/dist/constants/index.js +63 -0
  31. package/dist/constants/index.js.map +1 -0
  32. package/dist/current.d.ts +19 -0
  33. package/dist/current.js +9 -0
  34. package/dist/current.js.map +1 -0
  35. package/dist/dom/anchor-element.d.ts +14 -0
  36. package/dist/dom/anchor-element.js +54 -0
  37. package/dist/dom/anchor-element.js.map +1 -0
  38. package/dist/dom/class-list.d.ts +17 -0
  39. package/dist/dom/class-list.js +92 -0
  40. package/dist/dom/class-list.js.map +1 -0
  41. package/dist/dom/document.d.ts +25 -0
  42. package/dist/dom/document.js +80 -0
  43. package/dist/dom/document.js.map +1 -0
  44. package/dist/dom/element.d.ts +40 -0
  45. package/dist/dom/element.js +318 -0
  46. package/dist/dom/element.js.map +1 -0
  47. package/dist/dom/event-source.d.ts +7 -0
  48. package/dist/dom/event-source.js +17 -0
  49. package/dist/dom/event-source.js.map +1 -0
  50. package/dist/dom/event-target.d.ts +8 -0
  51. package/dist/dom/event-target.js +78 -0
  52. package/dist/dom/event-target.js.map +1 -0
  53. package/dist/dom/event.d.ts +24 -0
  54. package/dist/dom/event.js +152 -0
  55. package/dist/dom/event.js.map +1 -0
  56. package/dist/dom/form.d.ts +10 -0
  57. package/dist/dom/form.js +38 -0
  58. package/dist/dom/form.js.map +1 -0
  59. package/dist/dom/node.d.ts +107 -0
  60. package/dist/dom/node.js +292 -0
  61. package/dist/dom/node.js.map +1 -0
  62. package/dist/dom/root.d.ts +16 -0
  63. package/dist/dom/root.js +169 -0
  64. package/dist/dom/root.js.map +1 -0
  65. package/dist/dom/style.d.ts +15 -0
  66. package/dist/dom/style.js +168 -0
  67. package/dist/dom/style.js.map +1 -0
  68. package/dist/dom/style_properties.d.ts +3 -0
  69. package/dist/dom/style_properties.js +186 -0
  70. package/dist/dom/style_properties.js.map +1 -0
  71. package/dist/dom/svg.d.ts +4 -0
  72. package/dist/dom/svg.js +8 -0
  73. package/dist/dom/svg.js.map +1 -0
  74. package/dist/dom/text.d.ts +15 -0
  75. package/dist/dom/text.js +41 -0
  76. package/dist/dom/text.js.map +1 -0
  77. package/dist/dom/transfer.d.ts +8 -0
  78. package/dist/dom/transfer.js +15 -0
  79. package/dist/dom/transfer.js.map +1 -0
  80. package/dist/dom/tree.d.ts +4 -0
  81. package/dist/dom/tree.js +38 -0
  82. package/dist/dom/tree.js.map +1 -0
  83. package/dist/dom-external/element.d.ts +4 -0
  84. package/dist/dom-external/element.js +29 -0
  85. package/dist/dom-external/element.js.map +1 -0
  86. package/dist/dom-external/index.d.ts +1 -0
  87. package/dist/dom-external/index.js +38 -0
  88. package/dist/dom-external/index.js.map +1 -0
  89. package/dist/dom-external/inner-html/html.d.ts +3 -0
  90. package/dist/dom-external/inner-html/html.js +28 -0
  91. package/dist/dom-external/inner-html/html.js.map +1 -0
  92. package/dist/dom-external/inner-html/parser.d.ts +25 -0
  93. package/dist/dom-external/inner-html/parser.js +257 -0
  94. package/dist/dom-external/inner-html/parser.js.map +1 -0
  95. package/dist/dom-external/inner-html/scaner.d.ts +30 -0
  96. package/dist/dom-external/inner-html/scaner.js +304 -0
  97. package/dist/dom-external/inner-html/scaner.js.map +1 -0
  98. package/dist/dom-external/inner-html/style.d.ts +27 -0
  99. package/dist/dom-external/inner-html/style.js +235 -0
  100. package/dist/dom-external/inner-html/style.js.map +1 -0
  101. package/dist/dom-external/inner-html/tags.d.ts +14 -0
  102. package/dist/dom-external/inner-html/tags.js +41 -0
  103. package/dist/dom-external/inner-html/tags.js.map +1 -0
  104. package/dist/dom-external/inner-html/utils.d.ts +2 -0
  105. package/dist/dom-external/inner-html/utils.js +12 -0
  106. package/dist/dom-external/inner-html/utils.js.map +1 -0
  107. package/dist/dom-external/mutation-observer/implements.d.ts +71 -0
  108. package/dist/dom-external/mutation-observer/implements.js +108 -0
  109. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  110. package/dist/dom-external/mutation-observer/index.d.ts +12 -0
  111. package/dist/dom-external/mutation-observer/index.js +35 -0
  112. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  113. package/dist/dom-external/node.d.ts +12 -0
  114. package/dist/dom-external/node.js +75 -0
  115. package/dist/dom-external/node.js.map +1 -0
  116. package/dist/dsl/common.d.ts +15 -0
  117. package/dist/dsl/common.js +337 -0
  118. package/dist/dsl/common.js.map +1 -0
  119. package/dist/emitter/emitter.d.ts +4 -0
  120. package/dist/emitter/emitter.js +7 -0
  121. package/dist/emitter/emitter.js.map +1 -0
  122. package/dist/env.d.ts +7 -0
  123. package/dist/env.js +9 -0
  124. package/dist/env.js.map +1 -0
  125. package/dist/hydrate.d.ts +11 -0
  126. package/dist/hydrate.js +91 -0
  127. package/dist/hydrate.js.map +1 -0
  128. package/dist/index-26658829.d.ts +23 -0
  129. package/dist/{runtime.cjs.d.ts → index.cjs.d.ts} +95 -88
  130. package/dist/{runtime.h5.js → index.cjs.js} +2276 -438
  131. package/dist/index.cjs.js.map +1 -0
  132. package/dist/index.d.ts +34 -0
  133. package/dist/index.js +33 -0
  134. package/dist/index.js.map +1 -0
  135. package/dist/instance-0f017c6e.d.ts +95 -0
  136. package/dist/next-tick.d.ts +3 -0
  137. package/dist/next-tick.js +47 -0
  138. package/dist/next-tick.js.map +1 -0
  139. package/dist/node_types-9ac5b4dd.d.ts +11 -0
  140. package/dist/options-0f017c6e.d.ts +17 -0
  141. package/dist/options.d.ts +3 -0
  142. package/dist/options.js +7 -0
  143. package/dist/options.js.map +1 -0
  144. package/dist/perf.d.ts +7 -0
  145. package/dist/perf.js +28 -0
  146. package/dist/perf.js.map +1 -0
  147. package/dist/polyfill/array.d.ts +3 -0
  148. package/dist/polyfill/array.js +56 -0
  149. package/dist/polyfill/array.js.map +1 -0
  150. package/dist/polyfill/index.d.ts +2 -0
  151. package/dist/polyfill/index.js +34 -0
  152. package/dist/polyfill/index.js.map +1 -0
  153. package/dist/polyfill/intersection-observer.d.ts +2 -0
  154. package/dist/polyfill/intersection-observer.js +599 -0
  155. package/dist/polyfill/intersection-observer.js.map +1 -0
  156. package/dist/polyfill/object.d.ts +4 -0
  157. package/dist/polyfill/object.js +102 -0
  158. package/dist/polyfill/object.js.map +1 -0
  159. package/dist/record-32b054d8.d.ts +25 -0
  160. package/dist/runtime.esm.d.ts +95 -88
  161. package/dist/runtime.esm.js +1267 -427
  162. package/dist/runtime.esm.js.map +1 -1
  163. package/dist/utils/cache.d.ts +13 -0
  164. package/dist/utils/cache.js +27 -0
  165. package/dist/utils/cache.js.map +1 -0
  166. package/dist/utils/index.d.ts +24 -0
  167. package/dist/utils/index.js +95 -0
  168. package/dist/utils/index.js.map +1 -0
  169. package/dist/utils/lodash.d.ts +2 -0
  170. package/dist/utils/lodash.js +22 -0
  171. package/dist/utils/lodash.js.map +1 -0
  172. package/dist/utils/router.d.ts +8 -0
  173. package/dist/utils/router.js +24 -0
  174. package/dist/utils/router.js.map +1 -0
  175. package/package.json +16 -11
  176. package/dist/runtime.cjs.js +0 -4614
  177. package/dist/runtime.h5.d.ts +0 -781
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var shared = require('@tarojs/shared');
4
+ var tslib = require('tslib');
4
5
 
5
6
  const PROPERTY_THRESHOLD = 2046;
6
7
  const TARO_RUNTIME = 'Taro runtime';
@@ -39,6 +40,7 @@ const KEY_CODE = 'keyCode';
39
40
  const TOUCHMOVE = 'touchmove';
40
41
  const DATE = 'Date';
41
42
  const SET_TIMEOUT = 'setTimeout';
43
+ const COMPILE_MODE = 'compileMode';
42
44
  const CATCHMOVE = 'catchMove';
43
45
  const CATCH_VIEW = 'catch-view';
44
46
  const COMMENT = 'comment';
@@ -63,6 +65,54 @@ exports.CONTEXT_ACTIONS = void 0;
63
65
  })(exports.CONTEXT_ACTIONS || (exports.CONTEXT_ACTIONS = {}));
64
66
 
65
67
  const observers = [];
68
+ /**
69
+ * The MutationObserver provides the ability
70
+ * to watch for changes being made to the DOM tree.
71
+ * It will invoke a specified callback function
72
+ * when DOM changes occur.
73
+ * @see https://dom.spec.whatwg.org/#mutationobserver
74
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
75
+ */
76
+ class MutationObserverImpl {
77
+ constructor(callback) {
78
+ this.records = [];
79
+ this.callback = callback;
80
+ }
81
+ /**
82
+ * Configures the MutationObserver
83
+ * to begin receiving notifications
84
+ * through its callback function
85
+ * when DOM changes matching the given options occur.
86
+ *
87
+ * Options matching is to be implemented.
88
+ */
89
+ observe(target, options) {
90
+ this.disconnect();
91
+ this.target = target;
92
+ this.options = options || {};
93
+ observers.push(this);
94
+ }
95
+ /**
96
+ * Stop the MutationObserver instance
97
+ * from receiving further notifications
98
+ * until and unless observe() is called again.
99
+ */
100
+ disconnect() {
101
+ this.target = null;
102
+ const index = observers.indexOf(this);
103
+ if (index >= 0) {
104
+ observers.splice(index, 1);
105
+ }
106
+ }
107
+ /**
108
+ * Removes all pending notifications
109
+ * from the MutationObserver's notification queue
110
+ * and returns them in a new Array of MutationRecord objects.
111
+ */
112
+ takeRecords() {
113
+ return this.records.splice(0, this.records.length);
114
+ }
115
+ }
66
116
  /** Match two TaroNodes by sid. */
67
117
  const sidMatches = (observerTarget, target) => {
68
118
  return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
@@ -120,9 +170,12 @@ function recordMutation(record) {
120
170
  });
121
171
  }
122
172
 
123
- class MutationObserver {
173
+ let MutationObserver$1 = class MutationObserver {
124
174
  constructor(callback) {
125
- {
175
+ if (ENABLE_MUTATION_OBSERVER) {
176
+ this.core = new MutationObserverImpl(callback);
177
+ }
178
+ else {
126
179
  if (process.env.NODE_ENV !== 'production') {
127
180
  console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
128
181
  }
@@ -145,6 +198,26 @@ class MutationObserver {
145
198
  static record(record) {
146
199
  recordMutation(record);
147
200
  }
201
+ };
202
+
203
+ function throttle(fn, threshold = 250, scope) {
204
+ let lastTime = 0;
205
+ let deferTimer;
206
+ return function (...args) {
207
+ const context = scope || this;
208
+ const now = Date.now();
209
+ if (now - lastTime > threshold) {
210
+ fn.apply(this, args);
211
+ lastTime = now;
212
+ }
213
+ else {
214
+ clearTimeout(deferTimer);
215
+ deferTimer = setTimeout(() => {
216
+ lastTime = now;
217
+ fn.apply(context, args);
218
+ }, threshold);
219
+ }
220
+ };
148
221
  }
149
222
 
150
223
  const incrementId = () => {
@@ -343,8 +416,8 @@ class EventSource extends Map {
343
416
  const eventSource = new EventSource();
344
417
 
345
418
  const env = {
346
- window: window ,
347
- document: document
419
+ window: process.env.TARO_PLATFORM === 'web' ? window : shared.EMPTY_OBJ,
420
+ document: process.env.TARO_PLATFORM === 'web' ? document : shared.EMPTY_OBJ
348
421
  };
349
422
 
350
423
  let SPECIAL_NODES;
@@ -357,15 +430,12 @@ let componentsAlias;
357
430
  */
358
431
  function hydrate(node) {
359
432
  var _a;
360
- if (!componentsAlias) {
361
- // 初始化 componentsAlias
362
- componentsAlias = getComponentsAlias();
363
- }
364
- if (!SPECIAL_NODES) {
365
- // 初始化 SPECIAL_NODES
366
- SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
367
- }
433
+ // 初始化 componentsAlias
434
+ componentsAlias || (componentsAlias = getComponentsAlias());
435
+ // 初始化 SPECIAL_NODES
436
+ SPECIAL_NODES || (SPECIAL_NODES = shared.hooks.call('getSpecialNodes'));
368
437
  const nodeName = node.nodeName;
438
+ let compileModeName = null;
369
439
  if (isText(node)) {
370
440
  return {
371
441
  sid: node.sid,
@@ -393,22 +463,22 @@ function hydrate(node) {
393
463
  prop !== CLASS &&
394
464
  prop !== STYLE &&
395
465
  prop !== ID &&
396
- propInCamelCase !== CATCHMOVE) {
466
+ propInCamelCase !== CATCHMOVE &&
467
+ propInCamelCase !== COMPILE_MODE) {
397
468
  data[propInCamelCase] = props[prop];
398
469
  }
399
- if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
470
+ if (process.env.TARO_ENV !== 'swan' &&
471
+ nodeName === VIEW &&
472
+ propInCamelCase === CATCHMOVE &&
473
+ props[prop] !== false) {
400
474
  data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
401
475
  }
476
+ if (propInCamelCase === COMPILE_MODE) {
477
+ compileModeName = props[prop];
478
+ }
402
479
  }
403
- let { childNodes } = node;
404
- // 过滤 comment 节点
405
- childNodes = childNodes.filter(node => !isComment(node));
406
- if (childNodes.length > 0) {
407
- data["cn" /* Shortcuts.Childnodes */] = childNodes.map(hydrate);
408
- }
409
- else {
410
- data["cn" /* Shortcuts.Childnodes */] = [];
411
- }
480
+ // Children
481
+ data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
412
482
  if (node.className !== '') {
413
483
  data["cl" /* Shortcuts.Class */] = node.className;
414
484
  }
@@ -428,6 +498,9 @@ function hydrate(node) {
428
498
  }
429
499
  }
430
500
  }
501
+ if (compileModeName !== null) {
502
+ data["nn" /* Shortcuts.NodeName */] = compileModeName;
503
+ }
431
504
  const resData = shared.hooks.call('transferHydrateData', data, node, componentAlias);
432
505
  return resData || data;
433
506
  }
@@ -605,7 +678,7 @@ class TaroNode extends TaroEventTarget {
605
678
  this.updateChildNodes();
606
679
  }
607
680
  // @Todo: appendChild 会多触发一次
608
- MutationObserver.record({
681
+ MutationObserver$1.record({
609
682
  type: "childList" /* MutationRecordType.CHILD_LIST */,
610
683
  target: this,
611
684
  removedNodes,
@@ -690,7 +763,7 @@ class TaroNode extends TaroEventTarget {
690
763
  }
691
764
  }
692
765
  }
693
- MutationObserver.record({
766
+ MutationObserver$1.record({
694
767
  type: "childList" /* MutationRecordType.CHILD_LIST */,
695
768
  target: this,
696
769
  addedNodes: [newChild],
@@ -746,7 +819,7 @@ class TaroNode extends TaroEventTarget {
746
819
  if (cleanRef !== false && doUpdate !== false) {
747
820
  // appendChild/replaceChild/insertBefore 不应该触发
748
821
  // @Todo: 但其实如果 newChild 的父节点是另一颗子树的节点,应该是要触发的
749
- MutationObserver.record({
822
+ MutationObserver$1.record({
750
823
  type: "childList" /* MutationRecordType.CHILD_LIST */,
751
824
  target: this,
752
825
  removedNodes: [child],
@@ -972,7 +1045,7 @@ combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
972
1045
  combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
973
1046
 
974
1047
  function recordCss(obj) {
975
- MutationObserver.record({
1048
+ MutationObserver$1.record({
976
1049
  type: "attributes" /* MutationRecordType.ATTRIBUTES */,
977
1050
  target: obj._element,
978
1051
  attributeName: 'style',
@@ -1253,7 +1326,7 @@ class TaroElement extends TaroNode {
1253
1326
  process.env.NODE_ENV !== 'production' && shared.warn(shared.isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
1254
1327
  const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
1255
1328
  if (qualifiedName !== STYLE) {
1256
- MutationObserver.record({
1329
+ MutationObserver$1.record({
1257
1330
  target: this,
1258
1331
  type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1259
1332
  attributeName: qualifiedName,
@@ -1325,7 +1398,7 @@ class TaroElement extends TaroNode {
1325
1398
  }
1326
1399
  removeAttribute(qualifiedName) {
1327
1400
  const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded();
1328
- MutationObserver.record({
1401
+ MutationObserver$1.record({
1329
1402
  target: this,
1330
1403
  type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1331
1404
  attributeName: qualifiedName,
@@ -1418,7 +1491,10 @@ class TaroElement extends TaroNode {
1418
1491
  event.defaultPrevented = true;
1419
1492
  }
1420
1493
  if (!shared.isUndefined(result) && event.mpEvent) {
1421
- event.mpEvent[EVENT_CALLBACK_RESULT] = result;
1494
+ const res = shared.hooks.call('modifyTaroEventReturn', this, event, result);
1495
+ if (res) {
1496
+ event.mpEvent[EVENT_CALLBACK_RESULT] = result;
1497
+ }
1422
1498
  }
1423
1499
  if (event._end && event._stop) {
1424
1500
  break;
@@ -1476,6 +1552,547 @@ const options = {
1476
1552
  debug: false
1477
1553
  };
1478
1554
 
1555
+ function initPosition() {
1556
+ return {
1557
+ index: 0,
1558
+ column: 0,
1559
+ line: 0
1560
+ };
1561
+ }
1562
+ function feedPosition(position, str, len) {
1563
+ const start = position.index;
1564
+ const end = position.index = start + len;
1565
+ for (let i = start; i < end; i++) {
1566
+ const char = str.charAt(i);
1567
+ if (char === '\n') {
1568
+ position.line++;
1569
+ position.column = 0;
1570
+ }
1571
+ else {
1572
+ position.column++;
1573
+ }
1574
+ }
1575
+ }
1576
+ function jumpPosition(position, str, end) {
1577
+ const len = end - position.index;
1578
+ return feedPosition(position, str, len);
1579
+ }
1580
+ function copyPosition(position) {
1581
+ return {
1582
+ index: position.index,
1583
+ line: position.line,
1584
+ column: position.column
1585
+ };
1586
+ }
1587
+ const whitespace = /\s/;
1588
+ function isWhitespaceChar(char) {
1589
+ return whitespace.test(char);
1590
+ }
1591
+ const equalSign = /=/;
1592
+ function isEqualSignChar(char) {
1593
+ return equalSign.test(char);
1594
+ }
1595
+ function shouldBeIgnore(tagName) {
1596
+ const name = tagName.toLowerCase();
1597
+ if (options.html.skipElements.has(name)) {
1598
+ return true;
1599
+ }
1600
+ return false;
1601
+ }
1602
+ const alphanumeric = /[A-Za-z0-9]/;
1603
+ function findTextEnd(str, index) {
1604
+ while (true) {
1605
+ const textEnd = str.indexOf('<', index);
1606
+ if (textEnd === -1) {
1607
+ return textEnd;
1608
+ }
1609
+ const char = str.charAt(textEnd + 1);
1610
+ if (char === '/' || char === '!' || alphanumeric.test(char)) {
1611
+ return textEnd;
1612
+ }
1613
+ index = textEnd + 1;
1614
+ }
1615
+ }
1616
+ function isWordEnd(cursor, wordBegin, html) {
1617
+ if (!isWhitespaceChar(html.charAt(cursor)))
1618
+ return false;
1619
+ const len = html.length;
1620
+ // backwrad
1621
+ for (let i = cursor - 1; i > wordBegin; i--) {
1622
+ const char = html.charAt(i);
1623
+ if (!isWhitespaceChar(char)) {
1624
+ if (isEqualSignChar(char))
1625
+ return false;
1626
+ break;
1627
+ }
1628
+ }
1629
+ // forward
1630
+ for (let i = cursor + 1; i < len; i++) {
1631
+ const char = html.charAt(i);
1632
+ if (!isWhitespaceChar(char)) {
1633
+ if (isEqualSignChar(char))
1634
+ return false;
1635
+ return true;
1636
+ }
1637
+ }
1638
+ }
1639
+ class Scaner {
1640
+ constructor(html) {
1641
+ this.tokens = [];
1642
+ this.position = initPosition();
1643
+ this.html = html;
1644
+ }
1645
+ scan() {
1646
+ const { html, position } = this;
1647
+ const len = html.length;
1648
+ while (position.index < len) {
1649
+ const start = position.index;
1650
+ this.scanText();
1651
+ if (position.index === start) {
1652
+ const isComment = html.startsWith('!--', start + 1);
1653
+ if (isComment) {
1654
+ this.scanComment();
1655
+ }
1656
+ else {
1657
+ const tagName = this.scanTag();
1658
+ if (shouldBeIgnore(tagName)) {
1659
+ this.scanSkipTag(tagName);
1660
+ }
1661
+ }
1662
+ }
1663
+ }
1664
+ return this.tokens;
1665
+ }
1666
+ scanText() {
1667
+ const type = 'text';
1668
+ const { html, position } = this;
1669
+ let textEnd = findTextEnd(html, position.index);
1670
+ if (textEnd === position.index) {
1671
+ return;
1672
+ }
1673
+ if (textEnd === -1) {
1674
+ textEnd = html.length;
1675
+ }
1676
+ const start = copyPosition(position);
1677
+ const content = html.slice(position.index, textEnd);
1678
+ jumpPosition(position, html, textEnd);
1679
+ const end = copyPosition(position);
1680
+ this.tokens.push({ type, content, position: { start, end } });
1681
+ }
1682
+ scanComment() {
1683
+ const type = 'comment';
1684
+ const { html, position } = this;
1685
+ const start = copyPosition(position);
1686
+ feedPosition(position, html, 4); // "<!--".length
1687
+ let contentEnd = html.indexOf('-->', position.index);
1688
+ let commentEnd = contentEnd + 3; // "-->".length
1689
+ if (contentEnd === -1) {
1690
+ contentEnd = commentEnd = html.length;
1691
+ }
1692
+ const content = html.slice(position.index, contentEnd);
1693
+ jumpPosition(position, html, commentEnd);
1694
+ this.tokens.push({
1695
+ type,
1696
+ content,
1697
+ position: {
1698
+ start,
1699
+ end: copyPosition(position)
1700
+ }
1701
+ });
1702
+ }
1703
+ scanTag() {
1704
+ this.scanTagStart();
1705
+ const tagName = this.scanTagName();
1706
+ this.scanAttrs();
1707
+ this.scanTagEnd();
1708
+ return tagName;
1709
+ }
1710
+ scanTagStart() {
1711
+ const type = 'tag-start';
1712
+ const { html, position } = this;
1713
+ const secondChar = html.charAt(position.index + 1);
1714
+ const close = secondChar === '/';
1715
+ const start = copyPosition(position);
1716
+ feedPosition(position, html, close ? 2 : 1);
1717
+ this.tokens.push({ type, close, position: { start } });
1718
+ }
1719
+ scanTagEnd() {
1720
+ const type = 'tag-end';
1721
+ const { html, position } = this;
1722
+ const firstChar = html.charAt(position.index);
1723
+ const close = firstChar === '/';
1724
+ feedPosition(position, html, close ? 2 : 1);
1725
+ const end = copyPosition(position);
1726
+ this.tokens.push({ type, close, position: { end } });
1727
+ }
1728
+ scanTagName() {
1729
+ const type = 'tag';
1730
+ const { html, position } = this;
1731
+ const len = html.length;
1732
+ let start = position.index;
1733
+ while (start < len) {
1734
+ const char = html.charAt(start);
1735
+ const isTagChar = !(isWhitespaceChar(char) || char === '/' || char === '>');
1736
+ if (isTagChar)
1737
+ break;
1738
+ start++;
1739
+ }
1740
+ let end = start + 1;
1741
+ while (end < len) {
1742
+ const char = html.charAt(end);
1743
+ const isTagChar = !(isWhitespaceChar(char) || char === '/' || char === '>');
1744
+ if (!isTagChar)
1745
+ break;
1746
+ end++;
1747
+ }
1748
+ jumpPosition(position, html, end);
1749
+ const tagName = html.slice(start, end);
1750
+ this.tokens.push({
1751
+ type,
1752
+ content: tagName
1753
+ });
1754
+ return tagName;
1755
+ }
1756
+ scanAttrs() {
1757
+ const { html, position, tokens } = this;
1758
+ let cursor = position.index;
1759
+ let quote = null; // null, single-, or double-quote
1760
+ let wordBegin = cursor; // index of word start
1761
+ const words = []; // "key", "key=value", "key='value'", etc
1762
+ const len = html.length;
1763
+ while (cursor < len) {
1764
+ const char = html.charAt(cursor);
1765
+ if (quote) {
1766
+ const isQuoteEnd = char === quote;
1767
+ if (isQuoteEnd) {
1768
+ quote = null;
1769
+ }
1770
+ cursor++;
1771
+ continue;
1772
+ }
1773
+ const isTagEnd = char === '/' || char === '>';
1774
+ if (isTagEnd) {
1775
+ if (cursor !== wordBegin) {
1776
+ words.push(html.slice(wordBegin, cursor));
1777
+ }
1778
+ break;
1779
+ }
1780
+ if (isWordEnd(cursor, wordBegin, html)) {
1781
+ if (cursor !== wordBegin) {
1782
+ words.push(html.slice(wordBegin, cursor));
1783
+ }
1784
+ wordBegin = cursor + 1;
1785
+ cursor++;
1786
+ continue;
1787
+ }
1788
+ const isQuoteStart = char === '\'' || char === '"';
1789
+ if (isQuoteStart) {
1790
+ quote = char;
1791
+ cursor++;
1792
+ continue;
1793
+ }
1794
+ cursor++;
1795
+ }
1796
+ jumpPosition(position, html, cursor);
1797
+ const wLen = words.length;
1798
+ const type = 'attribute';
1799
+ for (let i = 0; i < wLen; i++) {
1800
+ const word = words[i];
1801
+ const isNotPair = word.includes('=');
1802
+ if (isNotPair) {
1803
+ const secondWord = words[i + 1];
1804
+ if (secondWord && secondWord.startsWith('=')) {
1805
+ if (secondWord.length > 1) {
1806
+ const newWord = word + secondWord;
1807
+ tokens.push({ type, content: newWord });
1808
+ i += 1;
1809
+ continue;
1810
+ }
1811
+ const thirdWord = words[i + 2];
1812
+ i += 1;
1813
+ if (thirdWord) {
1814
+ const newWord = word + '=' + thirdWord;
1815
+ tokens.push({ type, content: newWord });
1816
+ i += 1;
1817
+ continue;
1818
+ }
1819
+ }
1820
+ }
1821
+ if (word.endsWith('=')) {
1822
+ const secondWord = words[i + 1];
1823
+ if (secondWord && !secondWord.includes('=')) {
1824
+ const newWord = word + secondWord;
1825
+ tokens.push({ type, content: newWord });
1826
+ i += 1;
1827
+ continue;
1828
+ }
1829
+ const newWord = word.slice(0, -1);
1830
+ tokens.push({ type, content: newWord });
1831
+ continue;
1832
+ }
1833
+ tokens.push({ type, content: word });
1834
+ }
1835
+ }
1836
+ scanSkipTag(tagName) {
1837
+ const { html, position } = this;
1838
+ const safeTagName = tagName.toLowerCase();
1839
+ const len = html.length;
1840
+ while (position.index < len) {
1841
+ const nextTag = html.indexOf('</', position.index);
1842
+ if (nextTag === -1) {
1843
+ this.scanText();
1844
+ break;
1845
+ }
1846
+ jumpPosition(position, html, nextTag);
1847
+ const name = this.scanTag();
1848
+ if (safeTagName === name.toLowerCase()) {
1849
+ break;
1850
+ }
1851
+ }
1852
+ }
1853
+ }
1854
+
1855
+ function unquote(str) {
1856
+ const car = str.charAt(0);
1857
+ const end = str.length - 1;
1858
+ const isQuoteStart = car === '"' || car === "'";
1859
+ if (isQuoteStart && car === str.charAt(end)) {
1860
+ return str.slice(1, end);
1861
+ }
1862
+ return str;
1863
+ }
1864
+
1865
+ const LEFT_BRACKET = '{';
1866
+ const RIGHT_BRACKET = '}';
1867
+ const CLASS_SELECTOR = '.';
1868
+ const ID_SELECTOR = '#';
1869
+ const CHILD_COMBINATOR = '>';
1870
+ const GENERAL_SIBLING_COMBINATOR = '~';
1871
+ const ADJACENT_SIBLING_COMBINATOR = '+';
1872
+ class StyleTagParser {
1873
+ constructor() {
1874
+ this.styles = [];
1875
+ }
1876
+ extractStyle(src) {
1877
+ const REG_STYLE = /<style\s?[^>]*>((.|\n|\s)+?)<\/style>/g;
1878
+ let html = src;
1879
+ // let html = src.replace(/\n/g, '')
1880
+ html = html.replace(REG_STYLE, (_, $1) => {
1881
+ const style = $1.trim();
1882
+ this.stringToSelector(style);
1883
+ return '';
1884
+ });
1885
+ return html.trim();
1886
+ }
1887
+ stringToSelector(style) {
1888
+ let lb = style.indexOf(LEFT_BRACKET);
1889
+ while (lb > -1) {
1890
+ const rb = style.indexOf(RIGHT_BRACKET);
1891
+ const selectors = style.slice(0, lb).trim();
1892
+ let content = style.slice(lb + 1, rb);
1893
+ content = content.replace(/:(.*);/g, function (_, $1) {
1894
+ const t = $1.trim().replace(/ +/g, '+++');
1895
+ return `:${t};`;
1896
+ });
1897
+ content = content.replace(/ /g, '');
1898
+ content = content.replace(/\+\+\+/g, ' ');
1899
+ if (!(/;$/.test(content))) {
1900
+ content += ';';
1901
+ }
1902
+ selectors.split(',').forEach(src => {
1903
+ const selectorList = this.parseSelector(src);
1904
+ this.styles.push({
1905
+ content,
1906
+ selectorList
1907
+ });
1908
+ });
1909
+ style = style.slice(rb + 1);
1910
+ lb = style.indexOf(LEFT_BRACKET);
1911
+ }
1912
+ // console.log('res this.styles: ', this.styles)
1913
+ }
1914
+ parseSelector(src) {
1915
+ const list = src
1916
+ .trim()
1917
+ .replace(/ *([>~+]) */g, ' $1')
1918
+ .replace(/ +/g, ' ')
1919
+ .replace(/\[\s*([^[\]=\s]+)\s*=\s*([^[\]=\s]+)\s*\]/g, '[$1=$2]')
1920
+ .split(' ');
1921
+ const selectors = list.map(item => {
1922
+ const firstChar = item.charAt(0);
1923
+ const selector = {
1924
+ isChild: firstChar === CHILD_COMBINATOR,
1925
+ isGeneralSibling: firstChar === GENERAL_SIBLING_COMBINATOR,
1926
+ isAdjacentSibling: firstChar === ADJACENT_SIBLING_COMBINATOR,
1927
+ tag: null,
1928
+ id: null,
1929
+ class: [],
1930
+ attrs: []
1931
+ };
1932
+ item = item.replace(/^[>~+]/, '');
1933
+ // 属性选择器
1934
+ item = item.replace(/\[(.+?)\]/g, function (_, $1) {
1935
+ const [key, value] = $1.split('=');
1936
+ const all = $1.indexOf('=') === -1;
1937
+ const attr = {
1938
+ all,
1939
+ key,
1940
+ value: all ? null : value
1941
+ };
1942
+ selector.attrs.push(attr);
1943
+ return '';
1944
+ });
1945
+ item = item.replace(/([.#][A-Za-z0-9-_]+)/g, function (_, $1) {
1946
+ if ($1[0] === ID_SELECTOR) {
1947
+ // id 选择器
1948
+ selector.id = $1.substr(1);
1949
+ }
1950
+ else if ($1[0] === CLASS_SELECTOR) {
1951
+ // class 选择器
1952
+ selector.class.push($1.substr(1));
1953
+ }
1954
+ return '';
1955
+ });
1956
+ // 标签选择器
1957
+ if (item !== '') {
1958
+ selector.tag = item;
1959
+ }
1960
+ return selector;
1961
+ });
1962
+ return selectors;
1963
+ }
1964
+ matchStyle(tagName, el, list) {
1965
+ const res = sortStyles(this.styles).reduce((str, { content, selectorList }, i) => {
1966
+ let idx = list[i];
1967
+ let selector = selectorList[idx];
1968
+ const nextSelector = selectorList[idx + 1];
1969
+ if ((nextSelector === null || nextSelector === void 0 ? void 0 : nextSelector.isGeneralSibling) || (nextSelector === null || nextSelector === void 0 ? void 0 : nextSelector.isAdjacentSibling)) {
1970
+ selector = nextSelector;
1971
+ idx += 1;
1972
+ list[i] += 1;
1973
+ }
1974
+ let isMatch = this.matchCurrent(tagName, el, selector);
1975
+ if (isMatch && selector.isGeneralSibling) {
1976
+ let prev = getPreviousElement(el);
1977
+ while (prev) {
1978
+ if (prev.h5tagName && this.matchCurrent(prev.h5tagName, prev, selectorList[idx - 1])) {
1979
+ isMatch = true;
1980
+ break;
1981
+ }
1982
+ prev = getPreviousElement(prev);
1983
+ isMatch = false;
1984
+ }
1985
+ }
1986
+ if (isMatch && selector.isAdjacentSibling) {
1987
+ const prev = getPreviousElement(el);
1988
+ if (!prev || !prev.h5tagName) {
1989
+ isMatch = false;
1990
+ }
1991
+ else {
1992
+ const isSiblingMatch = this.matchCurrent(prev.h5tagName, prev, selectorList[idx - 1]);
1993
+ if (!isSiblingMatch) {
1994
+ isMatch = false;
1995
+ }
1996
+ }
1997
+ }
1998
+ if (isMatch) {
1999
+ if (idx === selectorList.length - 1) {
2000
+ return str + content;
2001
+ }
2002
+ else if (idx < selectorList.length - 1) {
2003
+ list[i] += 1;
2004
+ }
2005
+ }
2006
+ else {
2007
+ // 直接子代组合器: >
2008
+ if (selector.isChild && idx > 0) {
2009
+ list[i] -= 1;
2010
+ if (this.matchCurrent(tagName, el, selectorList[list[i]])) {
2011
+ list[i] += 1;
2012
+ }
2013
+ }
2014
+ }
2015
+ return str;
2016
+ }, '');
2017
+ return res;
2018
+ }
2019
+ matchCurrent(tagName, el, selector) {
2020
+ // 标签选择器
2021
+ if (selector.tag && selector.tag !== tagName)
2022
+ return false;
2023
+ // id 选择器
2024
+ if (selector.id && selector.id !== el.id)
2025
+ return false;
2026
+ // class 选择器
2027
+ if (selector.class.length) {
2028
+ const classList = el.className.split(' ');
2029
+ for (let i = 0; i < selector.class.length; i++) {
2030
+ const cls = selector.class[i];
2031
+ if (classList.indexOf(cls) === -1) {
2032
+ return false;
2033
+ }
2034
+ }
2035
+ }
2036
+ // 属性选择器
2037
+ if (selector.attrs.length) {
2038
+ for (let i = 0; i < selector.attrs.length; i++) {
2039
+ const { all, key, value } = selector.attrs[i];
2040
+ if (all && !el.hasAttribute(key)) {
2041
+ return false;
2042
+ }
2043
+ else {
2044
+ const attr = el.getAttribute(key);
2045
+ if (attr !== unquote(value || '')) {
2046
+ return false;
2047
+ }
2048
+ }
2049
+ }
2050
+ }
2051
+ return true;
2052
+ }
2053
+ }
2054
+ function getPreviousElement(el) {
2055
+ const parent = el.parentElement;
2056
+ if (!parent)
2057
+ return null;
2058
+ const prev = el.previousSibling;
2059
+ if (!prev)
2060
+ return null;
2061
+ if (prev.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
2062
+ return prev;
2063
+ }
2064
+ else {
2065
+ return getPreviousElement(prev);
2066
+ }
2067
+ }
2068
+ // 根据 css selector 权重排序: 权重大的靠后
2069
+ // @WARN 不考虑伪类
2070
+ // https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance#specificity_2
2071
+ function sortStyles(styles) {
2072
+ return styles.sort((s1, s2) => {
2073
+ const hundreds1 = getHundredsWeight(s1.selectorList);
2074
+ const hundreds2 = getHundredsWeight(s2.selectorList);
2075
+ if (hundreds1 !== hundreds2)
2076
+ return hundreds1 - hundreds2;
2077
+ const tens1 = getTensWeight(s1.selectorList);
2078
+ const tens2 = getTensWeight(s2.selectorList);
2079
+ if (tens1 !== tens2)
2080
+ return tens1 - tens2;
2081
+ const ones1 = getOnesWeight(s1.selectorList);
2082
+ const ones2 = getOnesWeight(s2.selectorList);
2083
+ return ones1 - ones2;
2084
+ });
2085
+ }
2086
+ function getHundredsWeight(selectors) {
2087
+ return selectors.reduce((pre, cur) => pre + (cur.id ? 1 : 0), 0);
2088
+ }
2089
+ function getTensWeight(selectors) {
2090
+ return selectors.reduce((pre, cur) => pre + cur.class.length + cur.attrs.length, 0);
2091
+ }
2092
+ function getOnesWeight(selectors) {
2093
+ return selectors.reduce((pre, cur) => pre + (cur.tag ? 1 : 0), 0);
2094
+ }
2095
+
1479
2096
  function makeMap(str, expectsLowerCase) {
1480
2097
  const map = Object.create(null);
1481
2098
  const list = str.split(',');
@@ -1484,15 +2101,282 @@ function makeMap(str, expectsLowerCase) {
1484
2101
  }
1485
2102
  return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
1486
2103
  }
2104
+ const specialMiniElements = {
2105
+ img: 'image',
2106
+ iframe: 'web-view'
2107
+ };
2108
+ const specialElements = new Map([
2109
+ ['a', {
2110
+ mapName(props) {
2111
+ if (props.as && shared.isString(props.as))
2112
+ return props.as.toLowerCase();
2113
+ return !props.href || shared.isString(props.href) && (/^javascript/.test(props.href)) ? 'view' : 'navigator';
2114
+ }
2115
+ }],
2116
+ ]);
2117
+ const getSpecialElementMapping = (tag, expectsLowerCase = true) => {
2118
+ tag = expectsLowerCase ? tag.toLowerCase() : tag;
2119
+ return specialElements.get(tag);
2120
+ };
1487
2121
  const internalCompsList = Object.keys(shared.internalComponents)
1488
2122
  .map(i => i.toLowerCase())
1489
2123
  .join(',');
1490
2124
  // https://developers.weixin.qq.com/miniprogram/dev/component
1491
- makeMap(internalCompsList, true);
2125
+ const isMiniElements = makeMap(internalCompsList, true);
1492
2126
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
1493
- makeMap('a,i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true);
2127
+ const isInlineElements = makeMap('i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true);
1494
2128
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
1495
- makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true);
2129
+ const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true);
2130
+ // specialElements
2131
+ const isSpecialElements = makeMap('a', true);
2132
+
2133
+ const closingTagAncestorBreakers = {
2134
+ li: ['ul', 'ol', 'menu'],
2135
+ dt: ['dl'],
2136
+ dd: ['dl'],
2137
+ tbody: ['table'],
2138
+ thead: ['table'],
2139
+ tfoot: ['table'],
2140
+ tr: ['table'],
2141
+ td: ['table']
2142
+ };
2143
+ function hasTerminalParent(tagName, stack) {
2144
+ const tagParents = closingTagAncestorBreakers[tagName];
2145
+ if (tagParents) {
2146
+ let currentIndex = stack.length - 1;
2147
+ while (currentIndex >= 0) {
2148
+ const parentTagName = stack[currentIndex].tagName;
2149
+ if (parentTagName === tagName) {
2150
+ break;
2151
+ }
2152
+ if (tagParents && tagParents.includes(parentTagName)) {
2153
+ return true;
2154
+ }
2155
+ currentIndex--;
2156
+ }
2157
+ }
2158
+ return false;
2159
+ }
2160
+ /**
2161
+ * 将属性数组转换为属性对象
2162
+ * @param attributes 字符串数组,包含属性信息
2163
+ * @returns 属性对象,键为属性名,值为属性值或true
2164
+ */
2165
+ function attributesArray2Props(attributes) {
2166
+ const props = {};
2167
+ for (let i = 0; i < attributes.length; i++) {
2168
+ const attr = attributes[i];
2169
+ const [key, value] = splitEqual(attr);
2170
+ props[key] = value == null ? true : unquote(value);
2171
+ }
2172
+ return props;
2173
+ }
2174
+ function getTagName(tag, attributes) {
2175
+ if (options.html.renderHTMLTag) {
2176
+ return tag;
2177
+ }
2178
+ if (specialMiniElements[tag]) {
2179
+ return specialMiniElements[tag];
2180
+ }
2181
+ else if (isMiniElements(tag)) {
2182
+ return tag;
2183
+ }
2184
+ else if (isBlockElements(tag)) {
2185
+ return 'view';
2186
+ }
2187
+ else if (isInlineElements(tag)) {
2188
+ return 'text';
2189
+ }
2190
+ else if (isSpecialElements(tag)) {
2191
+ // if it's special tag, the real tag is determined by the config mapping
2192
+ const mapping = getSpecialElementMapping(tag);
2193
+ const props = attributesArray2Props(attributes);
2194
+ if (mapping) {
2195
+ return mapping.mapName(props);
2196
+ }
2197
+ }
2198
+ return 'view';
2199
+ }
2200
+ function splitEqual(str) {
2201
+ const sep = '=';
2202
+ const idx = str.indexOf(sep);
2203
+ if (idx === -1)
2204
+ return [str];
2205
+ const key = str.slice(0, idx).trim();
2206
+ const value = str.slice(idx + sep.length).trim();
2207
+ return [key, value];
2208
+ }
2209
+ function format(children, document, styleOptions, parent) {
2210
+ return children
2211
+ .filter(child => {
2212
+ // 过滤注释和空文本节点
2213
+ if (child.type === 'comment') {
2214
+ return false;
2215
+ }
2216
+ else if (child.type === 'text') {
2217
+ return child.content !== '';
2218
+ }
2219
+ return true;
2220
+ })
2221
+ .map((child) => {
2222
+ // 文本节点
2223
+ if (child.type === 'text') {
2224
+ let text = document.createTextNode(child.content);
2225
+ if (shared.isFunction(options.html.transformText)) {
2226
+ text = options.html.transformText(text, child);
2227
+ }
2228
+ parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
2229
+ return text;
2230
+ }
2231
+ // img标签,把width和height写入style,删除原有的width、height和style属性
2232
+ if (child.tagName === 'img') {
2233
+ let styleText = '';
2234
+ const toBeRemovedIndexs = [];
2235
+ for (let i = 0; i < child.attributes.length; i++) {
2236
+ const attr = child.attributes[i];
2237
+ const [key, value] = splitEqual(attr);
2238
+ if (key === 'width' || key === 'height') {
2239
+ styleText += `${key}:${value};`;
2240
+ toBeRemovedIndexs.push(i);
2241
+ }
2242
+ else if (key === 'style') {
2243
+ styleText = `${styleText}${value};`;
2244
+ toBeRemovedIndexs.push(i);
2245
+ }
2246
+ }
2247
+ child.attributes = child.attributes.filter((_, index) => !toBeRemovedIndexs.includes(index));
2248
+ child.attributes.push(`style=${styleText.replace(/['"]/g, '')}`);
2249
+ }
2250
+ const el = document.createElement(getTagName(child.tagName, child.attributes));
2251
+ el.h5tagName = child.tagName;
2252
+ parent === null || parent === void 0 ? void 0 : parent.appendChild(el);
2253
+ if (!options.html.renderHTMLTag) {
2254
+ el.className = `h5-${child.tagName}`;
2255
+ }
2256
+ for (let i = 0; i < child.attributes.length; i++) {
2257
+ const attr = child.attributes[i];
2258
+ const [key, value] = splitEqual(attr);
2259
+ if (key === 'class') {
2260
+ el.className += ' ' + unquote(value);
2261
+ }
2262
+ else if (key[0] === 'o' && key[1] === 'n') {
2263
+ continue;
2264
+ }
2265
+ else {
2266
+ el.setAttribute(key, value == null ? true : unquote(value));
2267
+ }
2268
+ }
2269
+ const { styleTagParser, descendantList } = styleOptions;
2270
+ const list = descendantList.slice();
2271
+ const style = styleTagParser.matchStyle(child.tagName, el, list);
2272
+ el.setAttribute('style', style + el.style.cssText);
2273
+ // console.log('style, ', style)
2274
+ format(child.children, document, {
2275
+ styleTagParser,
2276
+ descendantList: list
2277
+ }, el);
2278
+ if (shared.isFunction(options.html.transformElement)) {
2279
+ return options.html.transformElement(el, child);
2280
+ }
2281
+ return el;
2282
+ });
2283
+ }
2284
+ function parser(html, document) {
2285
+ const styleTagParser = new StyleTagParser();
2286
+ html = styleTagParser.extractStyle(html);
2287
+ const tokens = new Scaner(html).scan();
2288
+ const root = { tagName: '', children: [], type: 'element', attributes: [] };
2289
+ const state = { tokens, options, cursor: 0, stack: [root] };
2290
+ parse(state);
2291
+ return format(root.children, document, {
2292
+ styleTagParser,
2293
+ descendantList: Array(styleTagParser.styles.length).fill(0)
2294
+ });
2295
+ }
2296
+ function parse(state) {
2297
+ const { tokens, stack } = state;
2298
+ let { cursor } = state;
2299
+ const len = tokens.length;
2300
+ let nodes = stack[stack.length - 1].children;
2301
+ while (cursor < len) {
2302
+ const token = tokens[cursor];
2303
+ if (token.type !== 'tag-start') {
2304
+ // comment or text
2305
+ nodes.push(token);
2306
+ cursor++;
2307
+ continue;
2308
+ }
2309
+ const tagToken = tokens[++cursor];
2310
+ cursor++;
2311
+ const tagName = tagToken.content.toLowerCase();
2312
+ if (token.close) {
2313
+ let index = stack.length;
2314
+ let shouldRewind = false;
2315
+ while (--index > -1) {
2316
+ if (stack[index].tagName === tagName) {
2317
+ shouldRewind = true;
2318
+ break;
2319
+ }
2320
+ }
2321
+ while (cursor < len) {
2322
+ const endToken = tokens[cursor];
2323
+ if (endToken.type !== 'tag-end')
2324
+ break;
2325
+ cursor++;
2326
+ }
2327
+ if (shouldRewind) {
2328
+ stack.splice(index);
2329
+ break;
2330
+ }
2331
+ else {
2332
+ continue;
2333
+ }
2334
+ }
2335
+ const isClosingTag = options.html.closingElements.has(tagName);
2336
+ let shouldRewindToAutoClose = isClosingTag;
2337
+ if (shouldRewindToAutoClose) {
2338
+ shouldRewindToAutoClose = !hasTerminalParent(tagName, stack);
2339
+ }
2340
+ if (shouldRewindToAutoClose) {
2341
+ let currentIndex = stack.length - 1;
2342
+ while (currentIndex > 0) {
2343
+ if (tagName === stack[currentIndex].tagName) {
2344
+ stack.splice(currentIndex);
2345
+ const previousIndex = currentIndex - 1;
2346
+ nodes = stack[previousIndex].children;
2347
+ break;
2348
+ }
2349
+ currentIndex = currentIndex - 1;
2350
+ }
2351
+ }
2352
+ const attributes = [];
2353
+ let attrToken;
2354
+ while (cursor < len) {
2355
+ attrToken = tokens[cursor];
2356
+ if (attrToken.type === 'tag-end')
2357
+ break;
2358
+ attributes.push(attrToken.content);
2359
+ cursor++;
2360
+ }
2361
+ cursor++;
2362
+ const children = [];
2363
+ const element = {
2364
+ type: 'element',
2365
+ tagName: tagToken.content,
2366
+ attributes,
2367
+ children
2368
+ };
2369
+ nodes.push(element);
2370
+ const hasChildren = !(attrToken.close || options.html.voidElements.has(tagName));
2371
+ if (hasChildren) {
2372
+ stack.push({ tagName, children });
2373
+ const innerState = { tokens, cursor, stack };
2374
+ parse(innerState);
2375
+ cursor = innerState.cursor;
2376
+ }
2377
+ }
2378
+ state.cursor = cursor;
2379
+ }
1496
2380
 
1497
2381
  options.html = {
1498
2382
  skipElements: new Set(['style', 'script']),
@@ -1507,24 +2391,159 @@ options.html = {
1507
2391
  ]),
1508
2392
  renderHTMLTag: false
1509
2393
  };
1510
-
1511
- // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
1512
- class TaroEvent {
1513
- constructor(type, opts, event) {
1514
- this._stop = false;
1515
- this._end = false;
1516
- this.defaultPrevented = false;
1517
- // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
1518
- this.button = 0;
1519
- // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
1520
- // here use hi-res timestamp
1521
- this.timeStamp = Date.now();
1522
- this.type = type.toLowerCase();
1523
- this.mpEvent = event;
1524
- this.bubbles = Boolean(opts && opts.bubbles);
1525
- this.cancelable = Boolean(opts && opts.cancelable);
2394
+ function setInnerHTML(element, html) {
2395
+ while (element.firstChild) {
2396
+ element.removeChild(element.firstChild);
1526
2397
  }
1527
- stopPropagation() {
2398
+ const children = parser(html, element.ownerDocument);
2399
+ for (let i = 0; i < children.length; i++) {
2400
+ element.appendChild(children[i]);
2401
+ }
2402
+ }
2403
+
2404
+ function getBoundingClientRectImpl() {
2405
+ if (!options.miniGlobal)
2406
+ return Promise.resolve(null);
2407
+ return new Promise(resolve => {
2408
+ const query = options.miniGlobal.createSelectorQuery();
2409
+ query.select(`#${this.uid}`).boundingClientRect(res => {
2410
+ resolve(res);
2411
+ }).exec();
2412
+ });
2413
+ }
2414
+ function getTemplateContent(ctx) {
2415
+ if (ctx.nodeName === 'template') {
2416
+ const document = ctx.ownerDocument;
2417
+ const content = document.createElement(DOCUMENT_FRAGMENT);
2418
+ content.childNodes = ctx.childNodes;
2419
+ ctx.childNodes = [content];
2420
+ content.parentNode = ctx;
2421
+ content.childNodes.forEach(nodes => {
2422
+ nodes.parentNode = content;
2423
+ });
2424
+ return content;
2425
+ }
2426
+ }
2427
+
2428
+ /**
2429
+ * An implementation of `Element.insertAdjacentHTML()`
2430
+ * to support Vue 3 with a version of or greater than `vue@3.1.2`
2431
+ */
2432
+ function insertAdjacentHTML(position, html) {
2433
+ var _a, _b;
2434
+ const parsedNodes = parser(html, this.ownerDocument);
2435
+ for (let i = 0; i < parsedNodes.length; i++) {
2436
+ const n = parsedNodes[i];
2437
+ switch (position) {
2438
+ case 'beforebegin':
2439
+ (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(n, this);
2440
+ break;
2441
+ case 'afterbegin':
2442
+ if (this.hasChildNodes()) {
2443
+ this.insertBefore(n, this.childNodes[0]);
2444
+ }
2445
+ else {
2446
+ this.appendChild(n);
2447
+ }
2448
+ break;
2449
+ case 'beforeend':
2450
+ this.appendChild(n);
2451
+ break;
2452
+ case 'afterend':
2453
+ (_b = this.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(n);
2454
+ break;
2455
+ }
2456
+ }
2457
+ }
2458
+ function cloneNode(isDeep = false) {
2459
+ const document = this.ownerDocument;
2460
+ let newNode;
2461
+ if (this.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
2462
+ newNode = document.createElement(this.nodeName);
2463
+ }
2464
+ else if (this.nodeType === 3 /* NodeType.TEXT_NODE */) {
2465
+ newNode = document.createTextNode('');
2466
+ }
2467
+ for (const key in this) {
2468
+ const value = this[key];
2469
+ // eslint-disable-next-line valid-typeof
2470
+ if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {
2471
+ newNode[key] = Object.assign({}, value);
2472
+ }
2473
+ else if (key === '_value') {
2474
+ newNode[key] = value;
2475
+ }
2476
+ else if (key === STYLE) {
2477
+ newNode.style._value = Object.assign({}, value._value);
2478
+ newNode.style._usedStyleProp = new Set(Array.from(value._usedStyleProp));
2479
+ }
2480
+ }
2481
+ if (isDeep) {
2482
+ newNode.childNodes = this.childNodes.map(node => node.cloneNode(true));
2483
+ }
2484
+ return newNode;
2485
+ }
2486
+ function contains(node) {
2487
+ let isContains = false;
2488
+ this.childNodes.some(childNode => {
2489
+ const { uid } = childNode;
2490
+ if (uid === node.uid || uid === node.id || childNode.contains(node)) {
2491
+ isContains = true;
2492
+ return true;
2493
+ }
2494
+ });
2495
+ return isContains;
2496
+ }
2497
+
2498
+ if (process.env.TARO_PLATFORM !== 'web') {
2499
+ if (ENABLE_INNER_HTML) {
2500
+ TaroNode.extend('innerHTML', {
2501
+ set(html) {
2502
+ setInnerHTML.call(this, this, html);
2503
+ },
2504
+ get() {
2505
+ return '';
2506
+ }
2507
+ });
2508
+ if (ENABLE_ADJACENT_HTML) {
2509
+ TaroNode.extend('insertAdjacentHTML', insertAdjacentHTML);
2510
+ }
2511
+ }
2512
+ if (ENABLE_CLONE_NODE) {
2513
+ TaroNode.extend('cloneNode', cloneNode);
2514
+ }
2515
+ if (ENABLE_CONTAINS) {
2516
+ TaroNode.extend('contains', contains);
2517
+ }
2518
+ if (ENABLE_SIZE_APIS) {
2519
+ TaroElement.extend('getBoundingClientRect', getBoundingClientRectImpl);
2520
+ }
2521
+ if (ENABLE_TEMPLATE_CONTENT) {
2522
+ TaroElement.extend('content', {
2523
+ get() {
2524
+ return getTemplateContent(this);
2525
+ }
2526
+ });
2527
+ }
2528
+ }
2529
+
2530
+ // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
2531
+ class TaroEvent {
2532
+ constructor(type, opts, event) {
2533
+ this._stop = false;
2534
+ this._end = false;
2535
+ this.defaultPrevented = false;
2536
+ // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
2537
+ this.button = 0;
2538
+ // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
2539
+ // here use hi-res timestamp
2540
+ this.timeStamp = Date.now();
2541
+ this.type = type.toLowerCase();
2542
+ this.mpEvent = event;
2543
+ this.bubbles = Boolean(opts && opts.bubbles);
2544
+ this.cancelable = Boolean(opts && opts.cancelable);
2545
+ }
2546
+ stopPropagation() {
1528
2547
  this._stop = true;
1529
2548
  }
1530
2549
  stopImmediatePropagation() {
@@ -1534,14 +2553,15 @@ class TaroEvent {
1534
2553
  this.defaultPrevented = true;
1535
2554
  }
1536
2555
  get target() {
1537
- var _a, _b, _c, _d;
2556
+ var _a, _b, _c, _d, _e;
1538
2557
  const cacheTarget = this.cacheTarget;
1539
2558
  if (!cacheTarget) {
1540
2559
  const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2560
+ const currentEle = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
1541
2561
  // Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
1542
- const element = env.document.getElementById(((_b = target.targetDataset) === null || _b === void 0 ? void 0 : _b.sid) || ((_c = target.dataset) === null || _c === void 0 ? void 0 : _c.sid) || target.id || null);
1543
- target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
1544
- for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
2562
+ const element = env.document.getElementById(((_c = target.targetDataset) === null || _c === void 0 ? void 0 : _c.sid) || ((_d = target.dataset) === null || _d === void 0 ? void 0 : _d.sid) || target.id || null);
2563
+ target.dataset = Object.assign(Object.assign({}, (currentEle !== null ? currentEle.dataset : shared.EMPTY_OBJ)), (element !== null ? element.dataset : shared.EMPTY_OBJ));
2564
+ for (const key in (_e = this.mpEvent) === null || _e === void 0 ? void 0 : _e.detail) {
1545
2565
  target[key] = this.mpEvent.detail[key];
1546
2566
  }
1547
2567
  this.cacheTarget = target;
@@ -1877,7 +2897,7 @@ class TaroText extends TaroNode {
1877
2897
  this._value = value;
1878
2898
  }
1879
2899
  set textContent(text) {
1880
- MutationObserver.record({
2900
+ MutationObserver$1.record({
1881
2901
  target: this,
1882
2902
  type: "characterData" /* MutationRecordType.CHARACTER_DATA */,
1883
2903
  oldValue: this._value
@@ -1905,37 +2925,7 @@ class TaroText extends TaroNode {
1905
2925
  }
1906
2926
  }
1907
2927
 
1908
- /******************************************************************************
1909
- Copyright (c) Microsoft Corporation.
1910
-
1911
- Permission to use, copy, modify, and/or distribute this software for any
1912
- purpose with or without fee is hereby granted.
1913
-
1914
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1915
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1916
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1917
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1918
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1919
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1920
- PERFORMANCE OF THIS SOFTWARE.
1921
- ***************************************************************************** */
1922
- /* global Reflect, Promise */
1923
-
1924
-
1925
- function __classPrivateFieldGet(receiver, state, kind, f) {
1926
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1927
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1928
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1929
- }
1930
-
1931
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
1932
- if (kind === "m") throw new TypeError("Private method is not writable");
1933
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1934
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1935
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1936
- }
1937
-
1938
- var _URLSearchParams_dict;
2928
+ var _dict, _a;
1939
2929
  const findReg = /[!'()~]|%20|%00/g;
1940
2930
  const plusReg = /\+/g;
1941
2931
  const replaceCharMap = {
@@ -1966,93 +2956,102 @@ function decode(str) {
1966
2956
  function encode(str) {
1967
2957
  return encodeURIComponent(str).replace(findReg, replacer);
1968
2958
  }
1969
- class URLSearchParams {
1970
- constructor(query) {
1971
- _URLSearchParams_dict.set(this, Object.create(null));
1972
- query !== null && query !== void 0 ? query : (query = '');
1973
- const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
1974
- if (typeof query === 'string') {
1975
- if (query.charAt(0) === '?') {
1976
- query = query.slice(1);
1977
- }
1978
- for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
1979
- const value = pairs[i];
1980
- const index = value.indexOf('=');
1981
- if (index > -1) {
1982
- appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
1983
- }
1984
- else if (value.length) {
1985
- appendTo(dict, decode(value), '');
2959
+ const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : (_a = class {
2960
+ constructor(query) {
2961
+ _dict.set(this, Object.create(null));
2962
+ query !== null && query !== void 0 ? query : (query = '');
2963
+ const dict = tslib.__classPrivateFieldGet(this, _dict, "f");
2964
+ if (typeof query === 'string') {
2965
+ if (query.charAt(0) === '?') {
2966
+ query = query.slice(1);
1986
2967
  }
1987
- }
1988
- }
1989
- else {
1990
- if (shared.isArray(query)) {
1991
- for (let i = 0, length = query.length; i < length; i++) {
1992
- const value = query[i];
1993
- appendTo(dict, value[0], value[1]);
2968
+ for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
2969
+ const value = pairs[i];
2970
+ const index = value.indexOf('=');
2971
+ // 针对不规范的 url 参数做容错处理,如:word=你%好
2972
+ try {
2973
+ if (index > -1) {
2974
+ appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
2975
+ }
2976
+ else if (value.length) {
2977
+ appendTo(dict, decode(value), '');
2978
+ }
2979
+ }
2980
+ catch (err) {
2981
+ if (process.env.NODE_ENV !== 'production') {
2982
+ console.warn(`[Taro warn] URL 参数 ${value} decode 异常`);
2983
+ }
2984
+ }
1994
2985
  }
1995
2986
  }
1996
- else if (query.forEach) {
1997
- query.forEach(addEach, dict);
1998
- }
1999
2987
  else {
2000
- for (const key in query) {
2001
- appendTo(dict, key, query[key]);
2988
+ if (shared.isArray(query)) {
2989
+ for (let i = 0, length = query.length; i < length; i++) {
2990
+ const value = query[i];
2991
+ appendTo(dict, value[0], value[1]);
2992
+ }
2993
+ }
2994
+ else if (query.forEach) {
2995
+ query.forEach(addEach, dict);
2996
+ }
2997
+ else {
2998
+ for (const key in query) {
2999
+ appendTo(dict, key, query[key]);
3000
+ }
2002
3001
  }
2003
3002
  }
2004
3003
  }
2005
- }
2006
- append(name, value) {
2007
- appendTo(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"), name, value);
2008
- }
2009
- delete(name) {
2010
- delete __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name];
2011
- }
2012
- get(name) {
2013
- const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2014
- return name in dict ? dict[name][0] : null;
2015
- }
2016
- getAll(name) {
2017
- const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2018
- return name in dict ? dict[name].slice(0) : [];
2019
- }
2020
- has(name) {
2021
- return name in __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2022
- }
2023
- keys() {
2024
- return Object.keys(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"));
2025
- }
2026
- set(name, value) {
2027
- __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name] = ['' + value];
2028
- }
2029
- forEach(callback, thisArg) {
2030
- const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2031
- Object.getOwnPropertyNames(dict).forEach(function (name) {
2032
- dict[name].forEach(function (value) {
2033
- callback.call(thisArg, value, name, this);
3004
+ append(name, value) {
3005
+ appendTo(tslib.__classPrivateFieldGet(this, _dict, "f"), name, value);
3006
+ }
3007
+ delete(name) {
3008
+ delete tslib.__classPrivateFieldGet(this, _dict, "f")[name];
3009
+ }
3010
+ get(name) {
3011
+ const dict = tslib.__classPrivateFieldGet(this, _dict, "f");
3012
+ return name in dict ? dict[name][0] : null;
3013
+ }
3014
+ getAll(name) {
3015
+ const dict = tslib.__classPrivateFieldGet(this, _dict, "f");
3016
+ return name in dict ? dict[name].slice(0) : [];
3017
+ }
3018
+ has(name) {
3019
+ return name in tslib.__classPrivateFieldGet(this, _dict, "f");
3020
+ }
3021
+ keys() {
3022
+ return Object.keys(tslib.__classPrivateFieldGet(this, _dict, "f"));
3023
+ }
3024
+ set(name, value) {
3025
+ tslib.__classPrivateFieldGet(this, _dict, "f")[name] = ['' + value];
3026
+ }
3027
+ forEach(callback, thisArg) {
3028
+ const dict = tslib.__classPrivateFieldGet(this, _dict, "f");
3029
+ Object.getOwnPropertyNames(dict).forEach(function (name) {
3030
+ dict[name].forEach(function (value) {
3031
+ callback.call(thisArg, value, name, this);
3032
+ }, this);
2034
3033
  }, this);
2035
- }, this);
2036
- }
2037
- toJSON() {
2038
- return {};
2039
- }
2040
- toString() {
2041
- const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2042
- const query = [];
2043
- for (const key in dict) {
2044
- const name = encode(key);
2045
- for (let i = 0, value = dict[key]; i < value.length; i++) {
2046
- query.push(name + '=' + encode(value[i]));
3034
+ }
3035
+ toJSON() {
3036
+ return {};
3037
+ }
3038
+ toString() {
3039
+ const dict = tslib.__classPrivateFieldGet(this, _dict, "f");
3040
+ const query = [];
3041
+ for (const key in dict) {
3042
+ const name = encode(key);
3043
+ for (let i = 0, value = dict[key]; i < value.length; i++) {
3044
+ query.push(name + '=' + encode(value[i]));
3045
+ }
2047
3046
  }
3047
+ return query.join('&');
2048
3048
  }
2049
- return query.join('&');
2050
- }
2051
- }
2052
- _URLSearchParams_dict = new WeakMap();
3049
+ },
3050
+ _dict = new WeakMap(),
3051
+ _a);
2053
3052
 
2054
- var _URL_hash, _URL_hostname, _URL_pathname, _URL_port, _URL_protocol, _URL_search;
2055
- class URL {
3053
+ var _TaroURL_hash, _TaroURL_hostname, _TaroURL_pathname, _TaroURL_port, _TaroURL_protocol, _TaroURL_search;
3054
+ class TaroURL {
2056
3055
  static createObjectURL() {
2057
3056
  throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
2058
3057
  }
@@ -2061,29 +3060,29 @@ class URL {
2061
3060
  }
2062
3061
  constructor(url, base) {
2063
3062
  /* private property */
2064
- _URL_hash.set(this, '');
2065
- _URL_hostname.set(this, '');
2066
- _URL_pathname.set(this, '');
2067
- _URL_port.set(this, '');
2068
- _URL_protocol.set(this, '');
2069
- _URL_search.set(this, void 0);
3063
+ _TaroURL_hash.set(this, '');
3064
+ _TaroURL_hostname.set(this, '');
3065
+ _TaroURL_pathname.set(this, '');
3066
+ _TaroURL_port.set(this, '');
3067
+ _TaroURL_protocol.set(this, '');
3068
+ _TaroURL_search.set(this, void 0);
2070
3069
  if (!shared.isString(url))
2071
3070
  url = String(url);
2072
3071
  const parseResult = parseUrlBase(url, base);
2073
3072
  const { hash, hostname, pathname, port, protocol, search } = parseResult;
2074
- __classPrivateFieldSet(this, _URL_hash, hash, "f");
2075
- __classPrivateFieldSet(this, _URL_hostname, hostname, "f");
2076
- __classPrivateFieldSet(this, _URL_pathname, pathname || '/', "f");
2077
- __classPrivateFieldSet(this, _URL_port, port, "f");
2078
- __classPrivateFieldSet(this, _URL_protocol, protocol, "f");
2079
- __classPrivateFieldSet(this, _URL_search, new URLSearchParams(search), "f");
3073
+ tslib.__classPrivateFieldSet(this, _TaroURL_hash, hash, "f");
3074
+ tslib.__classPrivateFieldSet(this, _TaroURL_hostname, hostname, "f");
3075
+ tslib.__classPrivateFieldSet(this, _TaroURL_pathname, pathname || '/', "f");
3076
+ tslib.__classPrivateFieldSet(this, _TaroURL_port, port, "f");
3077
+ tslib.__classPrivateFieldSet(this, _TaroURL_protocol, protocol, "f");
3078
+ tslib.__classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(search), "f");
2080
3079
  }
2081
3080
  /* public property */
2082
3081
  get protocol() {
2083
- return __classPrivateFieldGet(this, _URL_protocol, "f");
3082
+ return tslib.__classPrivateFieldGet(this, _TaroURL_protocol, "f");
2084
3083
  }
2085
3084
  set protocol(val) {
2086
- shared.isString(val) && (__classPrivateFieldSet(this, _URL_protocol, val.trim(), "f"));
3085
+ shared.isString(val) && (tslib.__classPrivateFieldSet(this, _TaroURL_protocol, val.trim(), "f"));
2087
3086
  }
2088
3087
  get host() {
2089
3088
  return this.hostname + (this.port ? ':' + this.port : '');
@@ -2097,19 +3096,19 @@ class URL {
2097
3096
  }
2098
3097
  }
2099
3098
  get hostname() {
2100
- return __classPrivateFieldGet(this, _URL_hostname, "f");
3099
+ return tslib.__classPrivateFieldGet(this, _TaroURL_hostname, "f");
2101
3100
  }
2102
3101
  set hostname(val) {
2103
- val && shared.isString(val) && (__classPrivateFieldSet(this, _URL_hostname, val.trim(), "f"));
3102
+ val && shared.isString(val) && (tslib.__classPrivateFieldSet(this, _TaroURL_hostname, val.trim(), "f"));
2104
3103
  }
2105
3104
  get port() {
2106
- return __classPrivateFieldGet(this, _URL_port, "f");
3105
+ return tslib.__classPrivateFieldGet(this, _TaroURL_port, "f");
2107
3106
  }
2108
3107
  set port(val) {
2109
- shared.isString(val) && (__classPrivateFieldSet(this, _URL_port, val.trim(), "f"));
3108
+ shared.isString(val) && (tslib.__classPrivateFieldSet(this, _TaroURL_port, val.trim(), "f"));
2110
3109
  }
2111
3110
  get pathname() {
2112
- return __classPrivateFieldGet(this, _URL_pathname, "f");
3111
+ return tslib.__classPrivateFieldGet(this, _TaroURL_pathname, "f");
2113
3112
  }
2114
3113
  set pathname(val) {
2115
3114
  if (shared.isString(val)) {
@@ -2120,31 +3119,31 @@ class URL {
2120
3119
  temp = temp.replace(HEAD_REG, '');
2121
3120
  }
2122
3121
  if (temp)
2123
- __classPrivateFieldSet(this, _URL_pathname, '/' + temp, "f");
3122
+ tslib.__classPrivateFieldSet(this, _TaroURL_pathname, '/' + temp, "f");
2124
3123
  else
2125
- __classPrivateFieldSet(this, _URL_pathname, '/', "f");
3124
+ tslib.__classPrivateFieldSet(this, _TaroURL_pathname, '/', "f");
2126
3125
  }
2127
3126
  }
2128
3127
  get search() {
2129
- const val = __classPrivateFieldGet(this, _URL_search, "f").toString();
3128
+ const val = tslib.__classPrivateFieldGet(this, _TaroURL_search, "f").toString();
2130
3129
  return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`;
2131
3130
  }
2132
3131
  set search(val) {
2133
3132
  if (shared.isString(val)) {
2134
3133
  val = val.trim();
2135
- __classPrivateFieldSet(this, _URL_search, new URLSearchParams(val), "f");
3134
+ tslib.__classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(val), "f");
2136
3135
  }
2137
3136
  }
2138
3137
  get hash() {
2139
- return __classPrivateFieldGet(this, _URL_hash, "f");
3138
+ return tslib.__classPrivateFieldGet(this, _TaroURL_hash, "f");
2140
3139
  }
2141
3140
  set hash(val) {
2142
3141
  if (shared.isString(val)) {
2143
3142
  val = val.trim();
2144
3143
  if (val)
2145
- __classPrivateFieldSet(this, _URL_hash, val.startsWith('#') ? val : `#${val}`, "f");
3144
+ tslib.__classPrivateFieldSet(this, _TaroURL_hash, val.startsWith('#') ? val : `#${val}`, "f");
2146
3145
  else
2147
- __classPrivateFieldSet(this, _URL_hash, '', "f");
3146
+ tslib.__classPrivateFieldSet(this, _TaroURL_hash, '', "f");
2148
3147
  }
2149
3148
  }
2150
3149
  get href() {
@@ -2175,7 +3174,7 @@ class URL {
2175
3174
  }
2176
3175
  }
2177
3176
  get searchParams() {
2178
- return __classPrivateFieldGet(this, _URL_search, "f");
3177
+ return tslib.__classPrivateFieldGet(this, _TaroURL_search, "f");
2179
3178
  }
2180
3179
  // public method
2181
3180
  toString() {
@@ -2199,7 +3198,8 @@ class URL {
2199
3198
  };
2200
3199
  }
2201
3200
  }
2202
- _URL_hash = new WeakMap(), _URL_hostname = new WeakMap(), _URL_pathname = new WeakMap(), _URL_port = new WeakMap(), _URL_protocol = new WeakMap(), _URL_search = new WeakMap();
3201
+ _TaroURL_hash = new WeakMap(), _TaroURL_hostname = new WeakMap(), _TaroURL_pathname = new WeakMap(), _TaroURL_port = new WeakMap(), _TaroURL_protocol = new WeakMap(), _TaroURL_search = new WeakMap();
3202
+ const URL = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL;
2203
3203
  function parseUrl(url = '') {
2204
3204
  const result = {
2205
3205
  href: '',
@@ -2390,49 +3390,42 @@ class TaroDocument extends TaroElement {
2390
3390
  }
2391
3391
  }
2392
3392
 
2393
- exports.document = void 0;
2394
- if (process.env.TARO_ENV && !true) {
2395
- /* eslint-disable no-inner-declarations */
2396
- function createDocument() {
2397
- /**
2398
- * <document>
2399
- * <html>
2400
- * <head></head>
2401
- * <body>
2402
- * <container>
2403
- * <app id="app" />
2404
- * </container>
2405
- * </body>
2406
- * </html>
2407
- * </document>
2408
- */
2409
- const doc = new TaroDocument();
2410
- const documentCreateElement = doc.createElement.bind(doc);
2411
- const html = documentCreateElement(HTML);
2412
- const head = documentCreateElement(HEAD);
2413
- const body = documentCreateElement(BODY);
2414
- const app = documentCreateElement(APP);
2415
- app.id = APP;
2416
- const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
2417
- doc.appendChild(html);
2418
- html.appendChild(head);
2419
- html.appendChild(body);
2420
- body.appendChild(container);
2421
- container.appendChild(app);
2422
- doc.documentElement = html;
2423
- doc.head = head;
2424
- doc.body = body;
2425
- return doc;
2426
- }
2427
- exports.document = env.document = createDocument();
2428
- }
2429
- else {
2430
- exports.document = env.document;
3393
+ function createDocument() {
3394
+ /**
3395
+ * <document>
3396
+ * <html>
3397
+ * <head></head>
3398
+ * <body>
3399
+ * <container>
3400
+ * <app id="app" />
3401
+ * </container>
3402
+ * </body>
3403
+ * </html>
3404
+ * </document>
3405
+ */
3406
+ const doc = new TaroDocument();
3407
+ const documentCreateElement = doc.createElement.bind(doc);
3408
+ const html = documentCreateElement(HTML);
3409
+ const head = documentCreateElement(HEAD);
3410
+ const body = documentCreateElement(BODY);
3411
+ const app = documentCreateElement(APP);
3412
+ app.id = APP;
3413
+ const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
3414
+ doc.appendChild(html);
3415
+ html.appendChild(head);
3416
+ html.appendChild(body);
3417
+ body.appendChild(container);
3418
+ container.appendChild(app);
3419
+ doc.documentElement = html;
3420
+ doc.head = head;
3421
+ doc.body = body;
3422
+ return doc;
2431
3423
  }
3424
+ const document$1 = process.env.TARO_PLATFORM === 'web' ? env.document : (env.document = createDocument());
2432
3425
 
2433
- function getComputedStyle(element) {
3426
+ const getComputedStyle = process.env.TARO_PLATFORM === 'web' ? env.window.getComputedStyle : function (element) {
2434
3427
  return element.style;
2435
- }
3428
+ };
2436
3429
 
2437
3430
  const eventCenter = shared.hooks.call('getEventCenter', shared.Events);
2438
3431
 
@@ -2461,72 +3454,72 @@ class RuntimeCache {
2461
3454
  }
2462
3455
  }
2463
3456
 
2464
- var _History_instances, _History_location, _History_stack, _History_cur, _History_window, _History_reset;
3457
+ var _TaroHistory_instances, _TaroHistory_location, _TaroHistory_stack, _TaroHistory_cur, _TaroHistory_window, _TaroHistory_reset;
2465
3458
  const cache$1 = new RuntimeCache('history');
2466
- class History extends shared.Events {
3459
+ class TaroHistory extends shared.Events {
2467
3460
  constructor(location, options) {
2468
3461
  super();
2469
- _History_instances.add(this);
3462
+ _TaroHistory_instances.add(this);
2470
3463
  /* private property */
2471
- _History_location.set(this, void 0);
2472
- _History_stack.set(this, []);
2473
- _History_cur.set(this, 0);
2474
- _History_window.set(this, void 0);
2475
- __classPrivateFieldSet(this, _History_window, options.window, "f");
2476
- __classPrivateFieldSet(this, _History_location, location, "f");
2477
- __classPrivateFieldGet(this, _History_location, "f").on('__record_history__', (href) => {
3464
+ _TaroHistory_location.set(this, void 0);
3465
+ _TaroHistory_stack.set(this, []);
3466
+ _TaroHistory_cur.set(this, 0);
3467
+ _TaroHistory_window.set(this, void 0);
3468
+ tslib.__classPrivateFieldSet(this, _TaroHistory_window, options.window, "f");
3469
+ tslib.__classPrivateFieldSet(this, _TaroHistory_location, location, "f");
3470
+ tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").on('__record_history__', (href) => {
2478
3471
  var _a;
2479
- __classPrivateFieldSet(this, _History_cur, (_a = __classPrivateFieldGet(this, _History_cur, "f"), _a++, _a), "f");
2480
- __classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f")), "f");
2481
- __classPrivateFieldGet(this, _History_stack, "f").push({
3472
+ tslib.__classPrivateFieldSet(this, _TaroHistory_cur, (_a = tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f"), _a++, _a), "f");
3473
+ tslib.__classPrivateFieldSet(this, _TaroHistory_stack, tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")), "f");
3474
+ tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
2482
3475
  state: null,
2483
3476
  title: '',
2484
3477
  url: href
2485
3478
  });
2486
3479
  }, null);
2487
- __classPrivateFieldGet(this, _History_location, "f").on('__reset_history__', (href) => {
2488
- __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
3480
+ tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").on('__reset_history__', (href) => {
3481
+ tslib.__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this, href);
2489
3482
  }, null);
2490
3483
  // 切换上下文行为
2491
3484
  this.on(exports.CONTEXT_ACTIONS.INIT, () => {
2492
- __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
3485
+ tslib.__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
2493
3486
  }, null);
2494
3487
  this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2495
3488
  cache$1.set(pageId, {
2496
- location: __classPrivateFieldGet(this, _History_location, "f"),
2497
- stack: __classPrivateFieldGet(this, _History_stack, "f").slice(),
2498
- cur: __classPrivateFieldGet(this, _History_cur, "f")
3489
+ location: tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f"),
3490
+ stack: tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(),
3491
+ cur: tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")
2499
3492
  });
2500
3493
  }, null);
2501
3494
  this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
2502
3495
  if (cache$1.has(pageId)) {
2503
3496
  const ctx = cache$1.get(pageId);
2504
- __classPrivateFieldSet(this, _History_location, ctx.location, "f");
2505
- __classPrivateFieldSet(this, _History_stack, ctx.stack, "f");
2506
- __classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
3497
+ tslib.__classPrivateFieldSet(this, _TaroHistory_location, ctx.location, "f");
3498
+ tslib.__classPrivateFieldSet(this, _TaroHistory_stack, ctx.stack, "f");
3499
+ tslib.__classPrivateFieldSet(this, _TaroHistory_cur, ctx.cur, "f");
2507
3500
  }
2508
3501
  }, null);
2509
3502
  this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
2510
3503
  cache$1.delete(pageId);
2511
3504
  }, null);
2512
- __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
3505
+ tslib.__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
2513
3506
  }
2514
3507
  /* public property */
2515
3508
  get length() {
2516
- return __classPrivateFieldGet(this, _History_stack, "f").length;
3509
+ return tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").length;
2517
3510
  }
2518
3511
  get state() {
2519
- return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].state;
3512
+ return tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f")[tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")].state;
2520
3513
  }
2521
3514
  /* public method */
2522
3515
  go(delta) {
2523
3516
  if (!shared.isNumber(delta) || isNaN(delta))
2524
3517
  return;
2525
- let targetIdx = __classPrivateFieldGet(this, _History_cur, "f") + delta;
3518
+ let targetIdx = tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f") + delta;
2526
3519
  targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
2527
- __classPrivateFieldSet(this, _History_cur, targetIdx, "f");
2528
- __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].url);
2529
- __classPrivateFieldGet(this, _History_window, "f").trigger('popstate', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")]);
3520
+ tslib.__classPrivateFieldSet(this, _TaroHistory_cur, targetIdx, "f");
3521
+ tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f")[tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")].url);
3522
+ tslib.__classPrivateFieldGet(this, _TaroHistory_window, "f").trigger('popstate', tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f")[tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")]);
2530
3523
  }
2531
3524
  back() {
2532
3525
  this.go(-1);
@@ -2537,40 +3530,41 @@ class History extends shared.Events {
2537
3530
  pushState(state, title, url) {
2538
3531
  if (!url || !shared.isString(url))
2539
3532
  return;
2540
- __classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f") + 1), "f");
2541
- __classPrivateFieldGet(this, _History_stack, "f").push({
3533
+ tslib.__classPrivateFieldSet(this, _TaroHistory_stack, tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f") + 1), "f");
3534
+ tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
2542
3535
  state,
2543
3536
  title,
2544
3537
  url
2545
3538
  });
2546
- __classPrivateFieldSet(this, _History_cur, this.length - 1, "f");
2547
- __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
3539
+ tslib.__classPrivateFieldSet(this, _TaroHistory_cur, this.length - 1, "f");
3540
+ tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
2548
3541
  }
2549
3542
  replaceState(state, title, url) {
2550
3543
  if (!url || !shared.isString(url))
2551
3544
  return;
2552
- __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")] = {
3545
+ tslib.__classPrivateFieldGet(this, _TaroHistory_stack, "f")[tslib.__classPrivateFieldGet(this, _TaroHistory_cur, "f")] = {
2553
3546
  state,
2554
3547
  title,
2555
3548
  url
2556
3549
  };
2557
- __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
3550
+ tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
2558
3551
  }
2559
3552
  // For debug
2560
3553
  get cache() {
2561
3554
  return cache$1;
2562
3555
  }
2563
3556
  }
2564
- _History_location = new WeakMap(), _History_stack = new WeakMap(), _History_cur = new WeakMap(), _History_window = new WeakMap(), _History_instances = new WeakSet(), _History_reset = function _History_reset(href = '') {
2565
- __classPrivateFieldSet(this, _History_stack, [
3557
+ _TaroHistory_location = new WeakMap(), _TaroHistory_stack = new WeakMap(), _TaroHistory_cur = new WeakMap(), _TaroHistory_window = new WeakMap(), _TaroHistory_instances = new WeakSet(), _TaroHistory_reset = function _TaroHistory_reset(href = '') {
3558
+ tslib.__classPrivateFieldSet(this, _TaroHistory_stack, [
2566
3559
  {
2567
3560
  state: null,
2568
3561
  title: '',
2569
- url: href || __classPrivateFieldGet(this, _History_location, "f").href
3562
+ url: href || tslib.__classPrivateFieldGet(this, _TaroHistory_location, "f").href
2570
3563
  }
2571
3564
  ], "f");
2572
- __classPrivateFieldSet(this, _History_cur, 0, "f");
3565
+ tslib.__classPrivateFieldSet(this, _TaroHistory_cur, 0, "f");
2573
3566
  };
3567
+ const History = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory;
2574
3568
 
2575
3569
  const Current = {
2576
3570
  app: null,
@@ -2579,31 +3573,31 @@ const Current = {
2579
3573
  };
2580
3574
  const getCurrentInstance = () => Current;
2581
3575
 
2582
- var _Location_instances, _Location_url, _Location_noCheckUrl, _Location_window, _Location_reset, _Location_getPreValue, _Location_rollBack, _Location_recordHistory, _Location_checkUrlChange;
3576
+ var _TaroLocation_instances, _TaroLocation_url, _TaroLocation_noCheckUrl, _TaroLocation_window, _TaroLocation_reset, _TaroLocation_getPreValue, _TaroLocation_rollBack, _TaroLocation_recordHistory, _TaroLocation_checkUrlChange;
2583
3577
  const INIT_URL = 'https://taro.com';
2584
3578
  const cache = new RuntimeCache('location');
2585
- class Location extends shared.Events {
3579
+ class TaroLocation extends shared.Events {
2586
3580
  constructor(options) {
2587
3581
  super();
2588
- _Location_instances.add(this);
3582
+ _TaroLocation_instances.add(this);
2589
3583
  /* private property */
2590
- _Location_url.set(this, new URL(INIT_URL));
2591
- _Location_noCheckUrl.set(this, false);
2592
- _Location_window.set(this, void 0);
2593
- __classPrivateFieldSet(this, _Location_window, options.window, "f");
2594
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
3584
+ _TaroLocation_url.set(this, new URL(INIT_URL));
3585
+ _TaroLocation_noCheckUrl.set(this, false);
3586
+ _TaroLocation_window.set(this, void 0);
3587
+ tslib.__classPrivateFieldSet(this, _TaroLocation_window, options.window, "f");
3588
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
2595
3589
  this.on('__set_href_without_history__', (href) => {
2596
- __classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
2597
- const lastHash = __classPrivateFieldGet(this, _Location_url, "f").hash;
2598
- __classPrivateFieldGet(this, _Location_url, "f").href = generateFullUrl(href);
2599
- if (lastHash !== __classPrivateFieldGet(this, _Location_url, "f").hash) {
2600
- __classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
3590
+ tslib.__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
3591
+ const lastHash = tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
3592
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").href = generateFullUrl(href);
3593
+ if (lastHash !== tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hash) {
3594
+ tslib.__classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
2601
3595
  }
2602
- __classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
3596
+ tslib.__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
2603
3597
  }, null);
2604
3598
  // 切换上下文行为
2605
3599
  this.on(exports.CONTEXT_ACTIONS.INIT, () => {
2606
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
3600
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
2607
3601
  }, null);
2608
3602
  this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2609
3603
  cache.set(pageId, {
@@ -2614,9 +3608,9 @@ class Location extends shared.Events {
2614
3608
  // 数据恢复时,不需要执行跳转
2615
3609
  if (cache.has(pageId)) {
2616
3610
  const ctx = cache.get(pageId);
2617
- __classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
2618
- __classPrivateFieldGet(this, _Location_url, "f").href = ctx.lastHref;
2619
- __classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
3611
+ tslib.__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
3612
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").href = ctx.lastHref;
3613
+ tslib.__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
2620
3614
  }
2621
3615
  }, null);
2622
3616
  this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
@@ -2625,81 +3619,81 @@ class Location extends shared.Events {
2625
3619
  }
2626
3620
  /* public property */
2627
3621
  get protocol() {
2628
- return __classPrivateFieldGet(this, _Location_url, "f").protocol;
3622
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").protocol;
2629
3623
  }
2630
3624
  set protocol(val) {
2631
3625
  const REG = /^(http|https):$/i;
2632
3626
  if (!val || !shared.isString(val) || !REG.test(val.trim()))
2633
3627
  return;
2634
3628
  val = val.trim();
2635
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2636
- __classPrivateFieldGet(this, _Location_url, "f").protocol = val;
2637
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2638
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3629
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3630
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").protocol = val;
3631
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3632
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2639
3633
  }
2640
3634
  get host() {
2641
- return __classPrivateFieldGet(this, _Location_url, "f").host;
3635
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").host;
2642
3636
  }
2643
3637
  set host(val) {
2644
3638
  if (!val || !shared.isString(val))
2645
3639
  return;
2646
3640
  val = val.trim();
2647
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2648
- __classPrivateFieldGet(this, _Location_url, "f").host = val;
2649
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2650
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3641
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3642
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").host = val;
3643
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3644
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2651
3645
  }
2652
3646
  get hostname() {
2653
- return __classPrivateFieldGet(this, _Location_url, "f").hostname;
3647
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hostname;
2654
3648
  }
2655
3649
  set hostname(val) {
2656
3650
  if (!val || !shared.isString(val))
2657
3651
  return;
2658
3652
  val = val.trim();
2659
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2660
- __classPrivateFieldGet(this, _Location_url, "f").hostname = val;
2661
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2662
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3653
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3654
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hostname = val;
3655
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3656
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2663
3657
  }
2664
3658
  get port() {
2665
- return __classPrivateFieldGet(this, _Location_url, "f").port;
3659
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").port;
2666
3660
  }
2667
3661
  set port(val) {
2668
3662
  const xVal = Number((val = val.trim()));
2669
3663
  if (!shared.isNumber(xVal) || xVal <= 0)
2670
3664
  return;
2671
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2672
- __classPrivateFieldGet(this, _Location_url, "f").port = val;
2673
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2674
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3665
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3666
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").port = val;
3667
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3668
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2675
3669
  }
2676
3670
  get pathname() {
2677
- return __classPrivateFieldGet(this, _Location_url, "f").pathname;
3671
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").pathname;
2678
3672
  }
2679
3673
  set pathname(val) {
2680
3674
  if (!val || !shared.isString(val))
2681
3675
  return;
2682
3676
  val = val.trim();
2683
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2684
- __classPrivateFieldGet(this, _Location_url, "f").pathname = val;
2685
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2686
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3677
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3678
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").pathname = val;
3679
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3680
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2687
3681
  }
2688
3682
  get search() {
2689
- return __classPrivateFieldGet(this, _Location_url, "f").search;
3683
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").search;
2690
3684
  }
2691
3685
  set search(val) {
2692
3686
  if (!val || !shared.isString(val))
2693
3687
  return;
2694
3688
  val = val.trim();
2695
3689
  val = val.startsWith('?') ? val : `?${val}`;
2696
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2697
- __classPrivateFieldGet(this, _Location_url, "f").search = val;
2698
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2699
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3690
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3691
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").search = val;
3692
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3693
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2700
3694
  }
2701
3695
  get hash() {
2702
- return __classPrivateFieldGet(this, _Location_url, "f").hash;
3696
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
2703
3697
  }
2704
3698
  // 小程序的navigateTo存在截断hash字符串的问题
2705
3699
  set hash(val) {
@@ -2707,34 +3701,34 @@ class Location extends shared.Events {
2707
3701
  return;
2708
3702
  val = val.trim();
2709
3703
  val = val.startsWith('#') ? val : `#${val}`;
2710
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2711
- __classPrivateFieldGet(this, _Location_url, "f").hash = val;
2712
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2713
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3704
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3705
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").hash = val;
3706
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3707
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2714
3708
  }
2715
3709
  get href() {
2716
- return __classPrivateFieldGet(this, _Location_url, "f").href;
3710
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").href;
2717
3711
  }
2718
3712
  set href(val) {
2719
3713
  const REG = /^(http:|https:)?\/\/.+/;
2720
3714
  if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
2721
3715
  return;
2722
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2723
- __classPrivateFieldGet(this, _Location_url, "f").href = val;
2724
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2725
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3716
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3717
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").href = val;
3718
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3719
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2726
3720
  }
2727
3721
  get origin() {
2728
- return __classPrivateFieldGet(this, _Location_url, "f").origin;
3722
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").origin;
2729
3723
  }
2730
3724
  set origin(val) {
2731
3725
  const REG = /^(http:|https:)?\/\/.+/;
2732
3726
  if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
2733
3727
  return;
2734
- const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2735
- __classPrivateFieldGet(this, _Location_url, "f").origin = val;
2736
- if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2737
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
3728
+ const preValue = tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3729
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").origin = val;
3730
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3731
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
2738
3732
  }
2739
3733
  /* public method */
2740
3734
  assign() {
@@ -2754,7 +3748,7 @@ class Location extends shared.Events {
2754
3748
  return cache;
2755
3749
  }
2756
3750
  }
2757
- _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_window = new WeakMap(), _Location_instances = new WeakSet(), _Location_reset = function _Location_reset() {
3751
+ _TaroLocation_url = new WeakMap(), _TaroLocation_noCheckUrl = new WeakMap(), _TaroLocation_window = new WeakMap(), _TaroLocation_instances = new WeakSet(), _TaroLocation_reset = function _TaroLocation_reset() {
2758
3752
  const Current = getCurrentInstance();
2759
3753
  const router = Current.router;
2760
3754
  if (router) {
@@ -2764,23 +3758,23 @@ _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_w
2764
3758
  });
2765
3759
  const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
2766
3760
  const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
2767
- __classPrivateFieldSet(this, _Location_url, new URL(url), "f");
3761
+ tslib.__classPrivateFieldSet(this, _TaroLocation_url, new URL(url), "f");
2768
3762
  this.trigger('__reset_history__', this.href);
2769
3763
  }
2770
- }, _Location_getPreValue = function _Location_getPreValue() {
2771
- return __classPrivateFieldGet(this, _Location_url, "f")._toRaw();
2772
- }, _Location_rollBack = function _Location_rollBack(href) {
2773
- __classPrivateFieldGet(this, _Location_url, "f").href = href;
2774
- }, _Location_recordHistory = function _Location_recordHistory() {
3764
+ }, _TaroLocation_getPreValue = function _TaroLocation_getPreValue() {
3765
+ return tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
3766
+ }, _TaroLocation_rollBack = function _TaroLocation_rollBack(href) {
3767
+ tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f").href = href;
3768
+ }, _TaroLocation_recordHistory = function _TaroLocation_recordHistory() {
2775
3769
  this.trigger('__record_history__', this.href);
2776
- }, _Location_checkUrlChange = function _Location_checkUrlChange(preValue) {
2777
- if (__classPrivateFieldGet(this, _Location_noCheckUrl, "f")) {
3770
+ }, _TaroLocation_checkUrlChange = function _TaroLocation_checkUrlChange(preValue) {
3771
+ if (tslib.__classPrivateFieldGet(this, _TaroLocation_noCheckUrl, "f")) {
2778
3772
  return false;
2779
3773
  }
2780
- const { protocol, hostname, port, pathname, search, hash } = __classPrivateFieldGet(this, _Location_url, "f")._toRaw();
3774
+ const { protocol, hostname, port, pathname, search, hash } = tslib.__classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
2781
3775
  // 跨域三要素不允许修改
2782
3776
  if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
2783
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue.href);
3777
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
2784
3778
  return false;
2785
3779
  }
2786
3780
  // pathname
@@ -2793,12 +3787,13 @@ _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_w
2793
3787
  }
2794
3788
  // hashchange
2795
3789
  if (hash !== preValue.hash) {
2796
- __classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
3790
+ tslib.__classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
2797
3791
  return true;
2798
3792
  }
2799
- __classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue.href);
3793
+ tslib.__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
2800
3794
  return false;
2801
3795
  };
3796
+ const Location = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation;
2802
3797
  function generateFullUrl(val = '') {
2803
3798
  const origin = INIT_URL;
2804
3799
  if (/^[/?#]/.test(val)) {
@@ -2807,7 +3802,25 @@ function generateFullUrl(val = '') {
2807
3802
  return val;
2808
3803
  }
2809
3804
 
2810
- const nav = env.window.navigator ;
3805
+ const machine = 'Macintosh';
3806
+ const arch = 'Intel Mac OS X 10_14_5';
3807
+ const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
3808
+ const msg = '(' + machine + '; ' + arch + ') ' + engine;
3809
+ const nav = process.env.TARO_PLATFORM === 'web' ? env.window.navigator : {
3810
+ appCodeName: 'Mozilla',
3811
+ appName: 'Netscape',
3812
+ appVersion: '5.0 ' + msg,
3813
+ cookieEnabled: true,
3814
+ mimeTypes: [],
3815
+ onLine: true,
3816
+ platform: 'MacIntel',
3817
+ plugins: [],
3818
+ product: 'Taro',
3819
+ productSub: '20030107',
3820
+ userAgent: 'Mozilla/5.0 ' + msg,
3821
+ vendor: 'Joyent',
3822
+ vendorSub: ''
3823
+ };
2811
3824
 
2812
3825
  // https://github.com/myrne/performance-now
2813
3826
  exports.now = void 0;
@@ -2840,95 +3853,110 @@ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame
2840
3853
  clearTimeout(seed);
2841
3854
  };
2842
3855
 
2843
- exports.window = void 0;
2844
- if (process.env.TARO_ENV && !true) {
2845
- class Window extends shared.Events {
2846
- constructor() {
2847
- super();
2848
- this.navigator = nav;
2849
- this.requestAnimationFrame = _raf;
2850
- this.cancelAnimationFrame = _caf;
2851
- this.getComputedStyle = getComputedStyle;
2852
- const globalProperties = [
2853
- ...Object.getOwnPropertyNames(global || {}),
2854
- ...Object.getOwnPropertySymbols(global || {})
2855
- ];
2856
- globalProperties.forEach(property => {
2857
- if (property === 'atob' || property === 'document')
2858
- return;
2859
- if (!Object.prototype.hasOwnProperty.call(this, property)) {
2860
- // 防止小程序环境下,window 上的某些 get 属性在赋值时报错
2861
- try {
2862
- this[property] = global[property];
2863
- }
2864
- catch (e) {
2865
- if (process.env.NODE_ENV !== 'production') {
2866
- console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
2867
- }
3856
+ class TaroWindow extends shared.Events {
3857
+ constructor() {
3858
+ super();
3859
+ this.navigator = nav;
3860
+ this.requestAnimationFrame = _raf;
3861
+ this.cancelAnimationFrame = _caf;
3862
+ this.getComputedStyle = getComputedStyle;
3863
+ const globalProperties = [
3864
+ ...Object.getOwnPropertyNames(global || {}),
3865
+ ...Object.getOwnPropertySymbols(global || {})
3866
+ ];
3867
+ globalProperties.forEach(property => {
3868
+ if (property === 'atob' || property === 'document')
3869
+ return;
3870
+ if (!Object.prototype.hasOwnProperty.call(this, property)) {
3871
+ // 防止小程序环境下,window 上的某些 get 属性在赋值时报错
3872
+ try {
3873
+ this[property] = global[property];
3874
+ }
3875
+ catch (e) {
3876
+ if (process.env.NODE_ENV !== 'production') {
3877
+ console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
2868
3878
  }
2869
3879
  }
2870
- });
2871
- this.Date || (this.Date = Date);
2872
- // 应用启动时,提供给需要读取历史信息的库使用
2873
- this.location = new Location({ window: this });
2874
- this.history = new History(this.location, { window: this });
2875
- this.initEvent();
2876
- }
2877
- initEvent() {
2878
- const _location = this.location;
2879
- const _history = this.history;
2880
- this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
2881
- // 页面onload,为该页面建立新的上下文信息
2882
- _location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
2883
- }, null);
2884
- this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
2885
- // 页面onshow,恢复当前页面的上下文信息
2886
- _location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
2887
- _history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
2888
- }, null);
2889
- this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2890
- // 页面onhide,缓存当前页面的上下文信息
2891
- _location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
2892
- _history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
2893
- }, null);
2894
- this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
2895
- // 页面onunload,清除当前页面的上下文信息
2896
- _location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
2897
- _history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
2898
- }, null);
2899
- }
2900
- get document() {
2901
- return env.document;
2902
- }
2903
- addEventListener(event, callback) {
2904
- if (!shared.isString(event))
2905
- return;
2906
- this.on(event, callback, null);
2907
- }
2908
- removeEventListener(event, callback) {
2909
- if (!shared.isString(event))
2910
- return;
2911
- this.off(event, callback, null);
2912
- }
2913
- setTimeout(...args) {
2914
- return setTimeout(...args);
2915
- }
2916
- clearTimeout(...args) {
2917
- return clearTimeout(...args);
2918
- }
3880
+ }
3881
+ });
3882
+ this.Date || (this.Date = Date);
3883
+ // 应用启动时,提供给需要读取历史信息的库使用
3884
+ this.location = new Location({ window: this });
3885
+ // @ts-ignore
3886
+ this.history = new History(this.location, { window: this });
3887
+ this.initEvent();
3888
+ }
3889
+ initEvent() {
3890
+ const _location = this.location;
3891
+ const _history = this.history;
3892
+ this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
3893
+ // 页面onload,为该页面建立新的上下文信息
3894
+ _location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
3895
+ }, null);
3896
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
3897
+ // 页面onshow,恢复当前页面的上下文信息
3898
+ _location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
3899
+ _history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
3900
+ }, null);
3901
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
3902
+ // 页面onhide,缓存当前页面的上下文信息
3903
+ _location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
3904
+ _history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
3905
+ }, null);
3906
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
3907
+ // 页面onunload,清除当前页面的上下文信息
3908
+ _location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
3909
+ _history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
3910
+ }, null);
3911
+ }
3912
+ get document() {
3913
+ return env.document;
3914
+ }
3915
+ addEventListener(event, callback) {
3916
+ if (!shared.isString(event))
3917
+ return;
3918
+ this.on(event, callback, null);
3919
+ }
3920
+ removeEventListener(event, callback) {
3921
+ if (!shared.isString(event))
3922
+ return;
3923
+ this.off(event, callback, null);
3924
+ }
3925
+ setTimeout(...args) {
3926
+ return setTimeout(...args);
3927
+ }
3928
+ clearTimeout(...args) {
3929
+ return clearTimeout(...args);
2919
3930
  }
2920
- exports.window = env.window = new Window();
2921
- }
2922
- else {
2923
- exports.window = env.window;
2924
3931
  }
2925
- const location = exports.window.location;
2926
- const history = exports.window.history;
3932
+ const window$1 = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow());
3933
+ const location = window$1.location;
3934
+ const history = window$1.history;
2927
3935
 
2928
3936
  // for Vue3
2929
3937
  class SVGElement extends TaroElement {
2930
3938
  }
2931
3939
 
3940
+ // export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
3941
+ // export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
3942
+ const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);
3943
+ const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path) || path === prefix;
3944
+ const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substring(prefix.length) : path;
3945
+ const stripTrailing = (str = '') => str.replace(/[?#][\s\S]*$/, '');
3946
+ const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
3947
+ const getHomePage = (path = '', basename = '', customRoutes = {}, entryPagePath = '') => {
3948
+ var _a;
3949
+ const routePath = addLeadingSlash(stripBasename(path, basename));
3950
+ const alias = ((_a = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _a === void 0 ? void 0 : _a[1]) || routePath;
3951
+ return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename;
3952
+ };
3953
+ const getCurrentPage = (routerMode = 'hash', basename = '/') => {
3954
+ const pagePath = routerMode === 'hash'
3955
+ ? location.hash.slice(1).split('?')[0]
3956
+ : location.pathname;
3957
+ return addLeadingSlash(stripBasename(pagePath, basename));
3958
+ };
3959
+
2932
3960
  /* eslint-disable dot-notation */
2933
3961
  const instances = new Map();
2934
3962
  const pageId = incrementId();
@@ -2942,12 +3970,6 @@ function getPageInstance(id) {
2942
3970
  function removePageInstance(id) {
2943
3971
  instances.delete(id);
2944
3972
  }
2945
- function addLeadingSlash(path) {
2946
- if (path == null) {
2947
- return '';
2948
- }
2949
- return path.charAt(0) === '/' ? path : '/' + path;
2950
- }
2951
3973
  function safeExecute(path, lifecycle, ...args) {
2952
3974
  const instance = instances.get(path);
2953
3975
  if (instance == null) {
@@ -2974,9 +3996,12 @@ function stringify(obj) {
2974
3996
  }
2975
3997
  function getPath(id, options) {
2976
3998
  const idx = id.indexOf('?');
2977
- {
3999
+ if (process.env.TARO_PLATFORM === 'web') {
2978
4000
  return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
2979
4001
  }
4002
+ else {
4003
+ return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
4004
+ }
2980
4005
  }
2981
4006
  function getOnReadyEventKey(path) {
2982
4007
  return path + '.' + ON_READY;
@@ -2995,7 +4020,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
2995
4020
  let unmounting = false;
2996
4021
  let prepareMountList = [];
2997
4022
  function setCurrentRouter(page) {
2998
- const router = page.$taroPath ;
4023
+ const router = process.env.TARO_PLATFORM === 'web' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
2999
4024
  Current.router = {
3000
4025
  params: page.$taroParams,
3001
4026
  path: addLeadingSlash(router),
@@ -3019,7 +4044,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
3019
4044
  // this.$taroPath 是页面唯一标识
3020
4045
  const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
3021
4046
  const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
3022
- {
4047
+ if (process.env.TARO_PLATFORM === 'web') {
3023
4048
  config.path = $taroPath;
3024
4049
  }
3025
4050
  // this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
@@ -3027,13 +4052,21 @@ function createPageConfig(component, pageName, data, pageConfig) {
3027
4052
  this.$taroParams = uniqueOptions;
3028
4053
  }
3029
4054
  setCurrentRouter(this);
4055
+ // 初始化当前页面的上下文信息
4056
+ if (process.env.TARO_PLATFORM !== 'web') {
4057
+ window$1.trigger(exports.CONTEXT_ACTIONS.INIT, $taroPath);
4058
+ }
3030
4059
  const mount = () => {
3031
4060
  Current.app.mount(component, $taroPath, () => {
3032
4061
  pageElement = env.document.getElementById($taroPath);
3033
4062
  shared.ensure(pageElement !== null, '没有找到页面实例。');
3034
4063
  safeExecute($taroPath, ON_LOAD, this.$taroParams);
3035
4064
  loadResolver();
3036
- {
4065
+ if (process.env.TARO_PLATFORM !== 'web') {
4066
+ pageElement.ctx = this;
4067
+ pageElement.performUpdate(true, cb);
4068
+ }
4069
+ else {
3037
4070
  shared.isFunction(cb) && cb();
3038
4071
  }
3039
4072
  });
@@ -3047,6 +4080,10 @@ function createPageConfig(component, pageName, data, pageConfig) {
3047
4080
  },
3048
4081
  [ONUNLOAD]() {
3049
4082
  const $taroPath = this.$taroPath;
4083
+ // 销毁当前页面的上下文信息
4084
+ if (process.env.TARO_PLATFORM !== 'web') {
4085
+ window$1.trigger(exports.CONTEXT_ACTIONS.DESTORY, $taroPath);
4086
+ }
3050
4087
  // 触发onUnload生命周期
3051
4088
  safeExecute($taroPath, ONUNLOAD);
3052
4089
  unmounting = true;
@@ -3077,6 +4114,10 @@ function createPageConfig(component, pageName, data, pageConfig) {
3077
4114
  // 设置 Current 的 page 和 router
3078
4115
  Current.page = this;
3079
4116
  setCurrentRouter(this);
4117
+ // 恢复上下文信息
4118
+ if (process.env.TARO_PLATFORM !== 'web') {
4119
+ window$1.trigger(exports.CONTEXT_ACTIONS.RECOVER, this.$taroPath);
4120
+ }
3080
4121
  // 触发生命周期
3081
4122
  safeExecute(this.$taroPath, ON_SHOW, options);
3082
4123
  // 通过事件触发子组件的生命周期
@@ -3084,6 +4125,10 @@ function createPageConfig(component, pageName, data, pageConfig) {
3084
4125
  });
3085
4126
  },
3086
4127
  [ONHIDE]() {
4128
+ // 缓存当前页面上下文信息
4129
+ if (process.env.TARO_PLATFORM !== 'web') {
4130
+ window$1.trigger(exports.CONTEXT_ACTIONS.RESTORE, this.$taroPath);
4131
+ }
3087
4132
  // 设置 Current 的 page 和 router
3088
4133
  if (Current.page === this) {
3089
4134
  Current.page = null;
@@ -3095,6 +4140,11 @@ function createPageConfig(component, pageName, data, pageConfig) {
3095
4140
  eventCenter.trigger(getOnHideEventKey(id));
3096
4141
  }
3097
4142
  };
4143
+ if (process.env.TARO_PLATFORM === 'web') {
4144
+ config.getOpenerEventChannel = () => {
4145
+ return shared.EventChannel.pageChannel;
4146
+ };
4147
+ }
3098
4148
  LIFECYCLES.forEach((lifecycle) => {
3099
4149
  let isDefer = false;
3100
4150
  lifecycle = lifecycle.replace(/^defer:/, () => {
@@ -3154,6 +4204,10 @@ function createComponentConfig(component, componentName, data) {
3154
4204
  shared.ensure(componentElement !== null, '没有找到组件实例。');
3155
4205
  this.$taroInstances = instances.get(path);
3156
4206
  safeExecute(path, ON_LOAD);
4207
+ if (process.env.TARO_PLATFORM !== 'web') {
4208
+ componentElement.ctx = this;
4209
+ componentElement.performUpdate(true);
4210
+ }
3157
4211
  });
3158
4212
  },
3159
4213
  [DETACHED]() {
@@ -3248,12 +4302,15 @@ const nextTick = (cb, ctx) => {
3248
4302
  var _a, _b, _c;
3249
4303
  const pageElement = env.document.getElementById(path);
3250
4304
  if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
3251
- {
4305
+ if (process.env.TARO_PLATFORM === 'web') {
3252
4306
  // eslint-disable-next-line dot-notation
3253
4307
  (_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
3254
4308
  timerFunc();
3255
4309
  })) !== null && _c !== void 0 ? _c : timerFunc();
3256
4310
  }
4311
+ else {
4312
+ pageElement.enqueueUpdateCallback(cb, ctx);
4313
+ }
3257
4314
  }
3258
4315
  else if (Date.now() - beginTime > TIMEOUT) {
3259
4316
  timerFunc();
@@ -3265,6 +4322,776 @@ const nextTick = (cb, ctx) => {
3265
4322
  next();
3266
4323
  };
3267
4324
 
4325
+ function handleArrayFindPolyfill() {
4326
+ if (!shared.isFunction(Array.prototype.find)) {
4327
+ Object.defineProperty(Array.prototype, 'find', {
4328
+ value(predicate) {
4329
+ if (this == null) {
4330
+ throw new TypeError('"this" is null or not defined');
4331
+ }
4332
+ const o = Object(this);
4333
+ const len = o.length >>> 0;
4334
+ if (!shared.isFunction(predicate)) {
4335
+ throw new TypeError('predicate must be a function');
4336
+ }
4337
+ const thisArg = arguments[1];
4338
+ let k = 0;
4339
+ while (k < len) {
4340
+ const kValue = o[k];
4341
+ if (predicate.call(thisArg, kValue, k, o)) {
4342
+ return kValue;
4343
+ }
4344
+ k++;
4345
+ }
4346
+ return undefined;
4347
+ }
4348
+ });
4349
+ }
4350
+ }
4351
+ function handleArrayIncludesPolyfill() {
4352
+ if (!shared.isFunction(Array.prototype.includes)) {
4353
+ Object.defineProperty(Array.prototype, 'includes', {
4354
+ value(searchElement, fromIndex) {
4355
+ if (this == null) {
4356
+ throw new TypeError('"this" is null or not defined');
4357
+ }
4358
+ const o = Object(this);
4359
+ const len = o.length >>> 0;
4360
+ if (len === 0) {
4361
+ return false;
4362
+ }
4363
+ const n = fromIndex | 0;
4364
+ let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
4365
+ while (k < len) {
4366
+ if (o[k] === searchElement) {
4367
+ return true;
4368
+ }
4369
+ k++;
4370
+ }
4371
+ return false;
4372
+ }
4373
+ });
4374
+ }
4375
+ }
4376
+
4377
+ /* eslint-disable eqeqeq */
4378
+ function handleIntersectionObserverPolyfill() {
4379
+ // Exit early if all IntersectionObserver and IntersectionObserverEntry
4380
+ // features are natively supported.
4381
+ if ('IntersectionObserver' in window &&
4382
+ 'IntersectionObserverEntry' in window &&
4383
+ 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
4384
+ if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
4385
+ // Minimal polyfill for Edge 15's lack of `isIntersecting`
4386
+ // See: https://github.com/w3c/IntersectionObserver/issues/211
4387
+ Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
4388
+ get: function () {
4389
+ return this.intersectionRatio > 0;
4390
+ }
4391
+ });
4392
+ }
4393
+ }
4394
+ else {
4395
+ handleIntersectionObserverObjectPolyfill();
4396
+ }
4397
+ }
4398
+ function handleIntersectionObserverObjectPolyfill() {
4399
+ const document = window.document;
4400
+ /**
4401
+ * Creates the global IntersectionObserverEntry constructor.
4402
+ * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
4403
+ * @param {Object} entry A dictionary of instance properties.
4404
+ * @constructor
4405
+ */
4406
+ function IntersectionObserverEntry(entry) {
4407
+ this.time = entry.time;
4408
+ this.target = entry.target;
4409
+ this.rootBounds = entry.rootBounds;
4410
+ this.boundingClientRect = entry.boundingClientRect;
4411
+ this.intersectionRect = entry.intersectionRect || getEmptyRect();
4412
+ this.isIntersecting = !!entry.intersectionRect;
4413
+ // Calculates the intersection ratio.
4414
+ const targetRect = this.boundingClientRect;
4415
+ const targetArea = targetRect.width * targetRect.height;
4416
+ const intersectionRect = this.intersectionRect;
4417
+ const intersectionArea = intersectionRect.width * intersectionRect.height;
4418
+ // Sets intersection ratio.
4419
+ if (targetArea) {
4420
+ // Round the intersection ratio to avoid floating point math issues:
4421
+ // https://github.com/w3c/IntersectionObserver/issues/324
4422
+ this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
4423
+ }
4424
+ else {
4425
+ // If area is zero and is intersecting, sets to 1, otherwise to 0
4426
+ this.intersectionRatio = this.isIntersecting ? 1 : 0;
4427
+ }
4428
+ }
4429
+ /**
4430
+ * Creates the global IntersectionObserver constructor.
4431
+ * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
4432
+ * @param {Function} callback The function to be invoked after intersection
4433
+ * changes have queued. The function is not invoked if the queue has
4434
+ * been emptied by calling the `takeRecords` method.
4435
+ * @param {Object=} opt_options Optional configuration options.
4436
+ * @constructor
4437
+ */
4438
+ function IntersectionObserver(callback, options = {}) {
4439
+ if (!shared.isFunction(callback)) {
4440
+ throw new Error('callback must be a function');
4441
+ }
4442
+ if (options.root && options.root.nodeType != 1) {
4443
+ throw new Error('root must be an Element');
4444
+ }
4445
+ // Binds and throttles `this._checkForIntersections`.
4446
+ this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
4447
+ // Private properties.
4448
+ this._callback = callback;
4449
+ this._observationTargets = [];
4450
+ this._queuedEntries = [];
4451
+ this._rootMarginValues = this._parseRootMargin(options.rootMargin);
4452
+ // Public properties.
4453
+ this.thresholds = this._initThresholds(options.threshold);
4454
+ this.root = options.root || null;
4455
+ this.rootMargin = this._rootMarginValues.map(function (margin) {
4456
+ return margin.value + margin.unit;
4457
+ }).join(' ');
4458
+ }
4459
+ /**
4460
+ * The minimum interval within which the document will be checked for
4461
+ * intersection changes.
4462
+ */
4463
+ IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
4464
+ /**
4465
+ * The frequency in which the polyfill polls for intersection changes.
4466
+ * this can be updated on a per instance basis and must be set prior to
4467
+ * calling `observe` on the first target.
4468
+ */
4469
+ IntersectionObserver.prototype.POLL_INTERVAL = null;
4470
+ /**
4471
+ * Use a mutation observer on the root element
4472
+ * to detect intersection changes.
4473
+ */
4474
+ IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
4475
+ /**
4476
+ * Starts observing a target element for intersection changes based on
4477
+ * the thresholds values.
4478
+ * @param {Element} target The DOM element to observe.
4479
+ */
4480
+ IntersectionObserver.prototype.observe = function (target) {
4481
+ const isTargetAlreadyObserved = this._observationTargets.some(function (item) {
4482
+ return item.element == target;
4483
+ });
4484
+ if (isTargetAlreadyObserved)
4485
+ return;
4486
+ if (!(target && target.nodeType == 1)) {
4487
+ throw new Error('target must be an Element');
4488
+ }
4489
+ this._registerInstance();
4490
+ this._observationTargets.push({ element: target, entry: null });
4491
+ this._monitorIntersections();
4492
+ this._checkForIntersections();
4493
+ };
4494
+ /**
4495
+ * Stops observing a target element for intersection changes.
4496
+ * @param {Element} target The DOM element to observe.
4497
+ */
4498
+ IntersectionObserver.prototype.unobserve = function (target) {
4499
+ this._observationTargets =
4500
+ this._observationTargets.filter(function (item) {
4501
+ return item.element != target;
4502
+ });
4503
+ if (!this._observationTargets.length) {
4504
+ this._unmonitorIntersections();
4505
+ this._unregisterInstance();
4506
+ }
4507
+ };
4508
+ /**
4509
+ * Stops observing all target elements for intersection changes.
4510
+ */
4511
+ IntersectionObserver.prototype.disconnect = function () {
4512
+ this._observationTargets = [];
4513
+ this._unmonitorIntersections();
4514
+ this._unregisterInstance();
4515
+ };
4516
+ /**
4517
+ * Returns any queue entries that have not yet been reported to the
4518
+ * callback and clears the queue. This can be used in conjunction with the
4519
+ * callback to obtain the absolute most up-to-date intersection information.
4520
+ * @return {Array} The currently queued entries.
4521
+ */
4522
+ IntersectionObserver.prototype.takeRecords = function () {
4523
+ const records = this._queuedEntries.slice();
4524
+ this._queuedEntries = [];
4525
+ return records;
4526
+ };
4527
+ /**
4528
+ * Accepts the threshold value from the user configuration object and
4529
+ * returns a sorted array of unique threshold values. If a value is not
4530
+ * between 0 and 1 and error is thrown.
4531
+ * @private
4532
+ * @param {Array|number=} opt_threshold An optional threshold value or
4533
+ * a list of threshold values, defaulting to [0].
4534
+ * @return {Array} A sorted list of unique and valid threshold values.
4535
+ */
4536
+ IntersectionObserver.prototype._initThresholds = function (opt_threshold) {
4537
+ let threshold = opt_threshold || [0];
4538
+ if (!Array.isArray(threshold))
4539
+ threshold = [threshold];
4540
+ return threshold.sort().filter(function (t, i, a) {
4541
+ if (!shared.isNumber(t) || isNaN(t) || t < 0 || t > 1) {
4542
+ throw new Error('threshold must be a number between 0 and 1 inclusively');
4543
+ }
4544
+ return t !== a[i - 1];
4545
+ });
4546
+ };
4547
+ /**
4548
+ * Accepts the rootMargin value from the user configuration object
4549
+ * and returns an array of the four margin values as an object containing
4550
+ * the value and unit properties. If any of the values are not properly
4551
+ * formatted or use a unit other than px or %, and error is thrown.
4552
+ * @private
4553
+ * @param {string=} opt_rootMargin An optional rootMargin value,
4554
+ * defaulting to '0px'.
4555
+ * @return {Array<Object>} An array of margin objects with the keys
4556
+ * value and unit.
4557
+ */
4558
+ IntersectionObserver.prototype._parseRootMargin = function (opt_rootMargin) {
4559
+ const marginString = opt_rootMargin || '0px';
4560
+ const margins = marginString.split(/\s+/).map(function (margin) {
4561
+ const parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
4562
+ if (!parts) {
4563
+ throw new Error('rootMargin must be specified in pixels or percent');
4564
+ }
4565
+ return { value: parseFloat(parts[1]), unit: parts[2] };
4566
+ });
4567
+ // Handles shorthand.
4568
+ margins[1] = margins[1] || margins[0];
4569
+ margins[2] = margins[2] || margins[0];
4570
+ margins[3] = margins[3] || margins[1];
4571
+ return margins;
4572
+ };
4573
+ /**
4574
+ * Starts polling for intersection changes if the polling is not already
4575
+ * happening, and if the page's visibility state is visible.
4576
+ * @private
4577
+ */
4578
+ IntersectionObserver.prototype._monitorIntersections = function () {
4579
+ if (!this._monitoringIntersections) {
4580
+ this._monitoringIntersections = true;
4581
+ // If a poll interval is set, use polling instead of listening to
4582
+ // resize and scroll events or DOM mutations.
4583
+ if (this.POLL_INTERVAL) {
4584
+ this._monitoringInterval = setInterval(this._checkForIntersections, this.POLL_INTERVAL);
4585
+ }
4586
+ else {
4587
+ addEvent(window, 'resize', this._checkForIntersections, true);
4588
+ addEvent(document, 'scroll', this._checkForIntersections, true);
4589
+ if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in window) {
4590
+ this._domObserver = new MutationObserver(this._checkForIntersections);
4591
+ this._domObserver.observe(document, {
4592
+ attributes: true,
4593
+ childList: true,
4594
+ characterData: true,
4595
+ subtree: true
4596
+ });
4597
+ }
4598
+ }
4599
+ }
4600
+ };
4601
+ /**
4602
+ * Stops polling for intersection changes.
4603
+ * @private
4604
+ */
4605
+ IntersectionObserver.prototype._unmonitorIntersections = function () {
4606
+ if (this._monitoringIntersections) {
4607
+ this._monitoringIntersections = false;
4608
+ clearInterval(this._monitoringInterval);
4609
+ this._monitoringInterval = null;
4610
+ removeEvent(window, 'resize', this._checkForIntersections, true);
4611
+ removeEvent(document, 'scroll', this._checkForIntersections, true);
4612
+ if (this._domObserver) {
4613
+ this._domObserver.disconnect();
4614
+ this._domObserver = null;
4615
+ }
4616
+ }
4617
+ };
4618
+ /**
4619
+ * Scans each observation target for intersection changes and adds them
4620
+ * to the internal entries queue. If new entries are found, it
4621
+ * schedules the callback to be invoked.
4622
+ * @private
4623
+ */
4624
+ IntersectionObserver.prototype._checkForIntersections = function () {
4625
+ const rootIsInDom = this._rootIsInDom();
4626
+ const rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
4627
+ this._observationTargets.forEach(function (item) {
4628
+ const target = item.element;
4629
+ const targetRect = getBoundingClientRect(target);
4630
+ const rootContainsTarget = this._rootContainsTarget(target);
4631
+ const oldEntry = item.entry;
4632
+ const intersectionRect = rootIsInDom && rootContainsTarget &&
4633
+ this._computeTargetAndRootIntersection(target, rootRect);
4634
+ const newEntry = item.entry = new IntersectionObserverEntry({
4635
+ time: now(),
4636
+ target: target,
4637
+ boundingClientRect: targetRect,
4638
+ rootBounds: rootRect,
4639
+ intersectionRect: intersectionRect,
4640
+ intersectionRatio: -1,
4641
+ isIntersecting: false,
4642
+ });
4643
+ if (!oldEntry) {
4644
+ this._queuedEntries.push(newEntry);
4645
+ }
4646
+ else if (rootIsInDom && rootContainsTarget) {
4647
+ // If the new entry intersection ratio has crossed any of the
4648
+ // thresholds, add a new entry.
4649
+ if (this._hasCrossedThreshold(oldEntry, newEntry)) {
4650
+ this._queuedEntries.push(newEntry);
4651
+ }
4652
+ }
4653
+ else {
4654
+ // If the root is not in the DOM or target is not contained within
4655
+ // root but the previous entry for this target had an intersection,
4656
+ // add a new record indicating removal.
4657
+ if (oldEntry && oldEntry.isIntersecting) {
4658
+ this._queuedEntries.push(newEntry);
4659
+ }
4660
+ }
4661
+ }, this);
4662
+ if (this._queuedEntries.length) {
4663
+ this._callback(this.takeRecords(), this);
4664
+ }
4665
+ };
4666
+ /**
4667
+ * Accepts a target and root rect computes the intersection between then
4668
+ * following the algorithm in the spec.
4669
+ * TODO(philipwalton): at this time clip-path is not considered.
4670
+ * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
4671
+ * @param {Element} target The target DOM element
4672
+ * @param {Object} rootRect The bounding rect of the root after being
4673
+ * expanded by the rootMargin value.
4674
+ * @return {?Object} The final intersection rect object or undefined if no
4675
+ * intersection is found.
4676
+ * @private
4677
+ */
4678
+ IntersectionObserver.prototype._computeTargetAndRootIntersection = function (target, rootRect) {
4679
+ // If the element isn't displayed, an intersection can't happen.
4680
+ if (window.getComputedStyle(target).display === 'none')
4681
+ return;
4682
+ const targetRect = getBoundingClientRect(target);
4683
+ let intersectionRect = targetRect;
4684
+ let parent = getParentNode(target);
4685
+ let atRoot = false;
4686
+ while (!atRoot) {
4687
+ let parentRect = null;
4688
+ const parentComputedStyle = parent.nodeType == 1 ?
4689
+ window.getComputedStyle(parent) : {};
4690
+ // If the parent isn't displayed, an intersection can't happen.
4691
+ if (parentComputedStyle.display === 'none')
4692
+ return;
4693
+ if (parent == this.root || parent == document) {
4694
+ atRoot = true;
4695
+ parentRect = rootRect;
4696
+ }
4697
+ else {
4698
+ // If the element has a non-visible overflow, and it's not the <body>
4699
+ // or <html> element, update the intersection rect.
4700
+ // Note: <body> and <html> cannot be clipped to a rect that's not also
4701
+ // the document rect, so no need to compute a new intersection.
4702
+ if (parent != document.body &&
4703
+ parent != document.documentElement &&
4704
+ parentComputedStyle.overflow != 'visible') {
4705
+ parentRect = getBoundingClientRect(parent);
4706
+ }
4707
+ }
4708
+ // If either of the above conditionals set a new parentRect,
4709
+ // calculate new intersection data.
4710
+ if (parentRect) {
4711
+ intersectionRect = computeRectIntersection(parentRect, intersectionRect);
4712
+ if (!intersectionRect)
4713
+ break;
4714
+ }
4715
+ parent = getParentNode(parent);
4716
+ }
4717
+ return intersectionRect;
4718
+ };
4719
+ /**
4720
+ * Returns the root rect after being expanded by the rootMargin value.
4721
+ * @return {Object} The expanded root rect.
4722
+ * @private
4723
+ */
4724
+ IntersectionObserver.prototype._getRootRect = function () {
4725
+ let rootRect;
4726
+ if (this.root) {
4727
+ rootRect = getBoundingClientRect(this.root);
4728
+ }
4729
+ else {
4730
+ // Use <html>/<body> instead of window since scroll bars affect size.
4731
+ const html = document.documentElement;
4732
+ const body = document.body;
4733
+ rootRect = {
4734
+ top: 0,
4735
+ left: 0,
4736
+ right: html.clientWidth || body.clientWidth,
4737
+ width: html.clientWidth || body.clientWidth,
4738
+ bottom: html.clientHeight || body.clientHeight,
4739
+ height: html.clientHeight || body.clientHeight
4740
+ };
4741
+ }
4742
+ return this._expandRectByRootMargin(rootRect);
4743
+ };
4744
+ /**
4745
+ * Accepts a rect and expands it by the rootMargin value.
4746
+ * @param {Object} rect The rect object to expand.
4747
+ * @return {Object} The expanded rect.
4748
+ * @private
4749
+ */
4750
+ IntersectionObserver.prototype._expandRectByRootMargin = function (rect) {
4751
+ const margins = this._rootMarginValues.map(function (margin, i) {
4752
+ return margin.unit === 'px' ? margin.value :
4753
+ margin.value * (i % 2 ? rect.width : rect.height) / 100;
4754
+ });
4755
+ const newRect = {
4756
+ top: rect.top - margins[0],
4757
+ right: rect.right + margins[1],
4758
+ bottom: rect.bottom + margins[2],
4759
+ left: rect.left - margins[3]
4760
+ };
4761
+ newRect.width = newRect.right - newRect.left;
4762
+ newRect.height = newRect.bottom - newRect.top;
4763
+ return newRect;
4764
+ };
4765
+ /**
4766
+ * Accepts an old and new entry and returns true if at least one of the
4767
+ * threshold values has been crossed.
4768
+ * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
4769
+ * particular target element or null if no previous entry exists.
4770
+ * @param {IntersectionObserverEntry} newEntry The current entry for a
4771
+ * particular target element.
4772
+ * @return {boolean} Returns true if a any threshold has been crossed.
4773
+ * @private
4774
+ */
4775
+ IntersectionObserver.prototype._hasCrossedThreshold =
4776
+ function (oldEntry, newEntry) {
4777
+ // To make comparing easier, an entry that has a ratio of 0
4778
+ // but does not actually intersect is given a value of -1
4779
+ const oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
4780
+ const newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
4781
+ // Ignore unchanged ratios
4782
+ if (oldRatio === newRatio)
4783
+ return;
4784
+ for (let i = 0; i < this.thresholds.length; i++) {
4785
+ const threshold = this.thresholds[i];
4786
+ // Return true if an entry matches a threshold or if the new ratio
4787
+ // and the old ratio are on the opposite sides of a threshold.
4788
+ if (threshold == oldRatio || threshold == newRatio ||
4789
+ threshold < oldRatio !== threshold < newRatio) {
4790
+ return true;
4791
+ }
4792
+ }
4793
+ };
4794
+ /**
4795
+ * Returns whether or not the root element is an element and is in the DOM.
4796
+ * @return {boolean} True if the root element is an element and is in the DOM.
4797
+ * @private
4798
+ */
4799
+ IntersectionObserver.prototype._rootIsInDom = function () {
4800
+ return !this.root || containsDeep(document, this.root);
4801
+ };
4802
+ /**
4803
+ * Returns whether or not the target element is a child of root.
4804
+ * @param {Element} target The target element to check.
4805
+ * @return {boolean} True if the target element is a child of root.
4806
+ * @private
4807
+ */
4808
+ IntersectionObserver.prototype._rootContainsTarget = function (target) {
4809
+ return containsDeep(this.root || document, target);
4810
+ };
4811
+ /**
4812
+ * Adds the instance to the global IntersectionObserver registry if it isn't
4813
+ * already present.
4814
+ * @private
4815
+ */
4816
+ IntersectionObserver.prototype._registerInstance = function () {
4817
+ };
4818
+ /**
4819
+ * Removes the instance from the global IntersectionObserver registry.
4820
+ * @private
4821
+ */
4822
+ IntersectionObserver.prototype._unregisterInstance = function () {
4823
+ };
4824
+ /**
4825
+ * Returns the result of the performance.now() method or null in browsers
4826
+ * that don't support the API.
4827
+ * @return {number} The elapsed time since the page was requested.
4828
+ */
4829
+ function now() {
4830
+ return window.performance && performance.now && performance.now();
4831
+ }
4832
+ /**
4833
+ * Adds an event handler to a DOM node ensuring cross-browser compatibility.
4834
+ * @param {Node} node The DOM node to add the event handler to.
4835
+ * @param {string} event The event name.
4836
+ * @param {Function} fn The event handler to add.
4837
+ * @param {boolean} opt_useCapture Optionally adds the even to the capture
4838
+ * phase. Note: this only works in modern browsers.
4839
+ */
4840
+ function addEvent(node, event, fn, opt_useCapture) {
4841
+ if (shared.isFunction(node.addEventListener)) {
4842
+ node.addEventListener(event, fn, opt_useCapture || false);
4843
+ }
4844
+ else if (shared.isFunction(node.attachEvent)) {
4845
+ node.attachEvent('on' + event, fn);
4846
+ }
4847
+ }
4848
+ /**
4849
+ * Removes a previously added event handler from a DOM node.
4850
+ * @param {Node} node The DOM node to remove the event handler from.
4851
+ * @param {string} event The event name.
4852
+ * @param {Function} fn The event handler to remove.
4853
+ * @param {boolean} opt_useCapture If the event handler was added with this
4854
+ * flag set to true, it should be set to true here in order to remove it.
4855
+ */
4856
+ function removeEvent(node, event, fn, opt_useCapture) {
4857
+ if (shared.isFunction(node.removeEventListener)) {
4858
+ node.removeEventListener(event, fn, opt_useCapture || false);
4859
+ }
4860
+ else if (shared.isFunction(node.detatchEvent)) {
4861
+ node.detatchEvent('on' + event, fn);
4862
+ }
4863
+ }
4864
+ /**
4865
+ * Returns the intersection between two rect objects.
4866
+ * @param {Object} rect1 The first rect.
4867
+ * @param {Object} rect2 The second rect.
4868
+ * @return {?Object} The intersection rect or undefined if no intersection
4869
+ * is found.
4870
+ */
4871
+ function computeRectIntersection(rect1, rect2) {
4872
+ const top = Math.max(rect1.top, rect2.top);
4873
+ const bottom = Math.min(rect1.bottom, rect2.bottom);
4874
+ const left = Math.max(rect1.left, rect2.left);
4875
+ const right = Math.min(rect1.right, rect2.right);
4876
+ const width = right - left;
4877
+ const height = bottom - top;
4878
+ return (width >= 0 && height >= 0) && {
4879
+ top: top,
4880
+ bottom: bottom,
4881
+ left: left,
4882
+ right: right,
4883
+ width: width,
4884
+ height: height
4885
+ };
4886
+ }
4887
+ /**
4888
+ * Shims the native getBoundingClientRect for compatibility with older IE.
4889
+ * @param {Element} el The element whose bounding rect to get.
4890
+ * @return {Object} The (possibly shimmed) rect of the element.
4891
+ */
4892
+ function getBoundingClientRect(el) {
4893
+ let rect;
4894
+ try {
4895
+ rect = el.getBoundingClientRect();
4896
+ }
4897
+ catch (err) {
4898
+ // Ignore Windows 7 IE11 "Unspecified error"
4899
+ // https://github.com/w3c/IntersectionObserver/pull/205
4900
+ }
4901
+ if (!rect)
4902
+ return getEmptyRect();
4903
+ // Older IE
4904
+ if (!(rect.width && rect.height)) {
4905
+ rect = {
4906
+ top: rect.top,
4907
+ right: rect.right,
4908
+ bottom: rect.bottom,
4909
+ left: rect.left,
4910
+ width: rect.right - rect.left,
4911
+ height: rect.bottom - rect.top
4912
+ };
4913
+ }
4914
+ return rect;
4915
+ }
4916
+ /**
4917
+ * Returns an empty rect object. An empty rect is returned when an element
4918
+ * is not in the DOM.
4919
+ * @return {Object} The empty rect.
4920
+ */
4921
+ function getEmptyRect() {
4922
+ return {
4923
+ top: 0,
4924
+ bottom: 0,
4925
+ left: 0,
4926
+ right: 0,
4927
+ width: 0,
4928
+ height: 0
4929
+ };
4930
+ }
4931
+ /**
4932
+ * Checks to see if a parent element contains a child element (including inside
4933
+ * shadow DOM).
4934
+ * @param {Node} parent The parent element.
4935
+ * @param {Node} child The child element.
4936
+ * @return {boolean} True if the parent node contains the child node.
4937
+ */
4938
+ function containsDeep(parent, child) {
4939
+ let node = child;
4940
+ while (node) {
4941
+ if (node == parent)
4942
+ return true;
4943
+ node = getParentNode(node);
4944
+ }
4945
+ return false;
4946
+ }
4947
+ /**
4948
+ * Gets the parent node of an element or its host element if the parent node
4949
+ * is a shadow root.
4950
+ * @param {Node} node The node whose parent to get.
4951
+ * @return {Node|null} The parent node or null if no parent exists.
4952
+ */
4953
+ function getParentNode(node) {
4954
+ const parent = node.parentNode;
4955
+ if (parent && parent.nodeType == 11 && parent.host) {
4956
+ // If the parent is a shadow root, return the host element.
4957
+ return parent.host;
4958
+ }
4959
+ if (parent && parent.assignedSlot) {
4960
+ // If the parent is distributed in a <slot>, return the parent of a slot.
4961
+ return parent.assignedSlot.parentNode;
4962
+ }
4963
+ return parent;
4964
+ }
4965
+ // Exposes the constructors globally.
4966
+ window.IntersectionObserver = IntersectionObserver;
4967
+ window.IntersectionObserverEntry = IntersectionObserverEntry;
4968
+ }
4969
+
4970
+ function handleObjectAssignPolyfill() {
4971
+ if (!shared.isFunction(Object.assign)) {
4972
+ // Must be writable: true, enumerable: false, configurable: true
4973
+ Object.assign = function (target) {
4974
+ if (target == null) { // TypeError if undefined or null
4975
+ throw new TypeError('Cannot convert undefined or null to object');
4976
+ }
4977
+ const to = Object(target);
4978
+ for (let index = 1; index < arguments.length; index++) {
4979
+ const nextSource = arguments[index];
4980
+ if (nextSource != null) { // Skip over if undefined or null
4981
+ for (const nextKey in nextSource) {
4982
+ // Avoid bugs when hasOwnProperty is shadowed
4983
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
4984
+ to[nextKey] = nextSource[nextKey];
4985
+ }
4986
+ }
4987
+ }
4988
+ }
4989
+ return to;
4990
+ };
4991
+ }
4992
+ }
4993
+ function handleObjectEntriesPolyfill() {
4994
+ if (!shared.isFunction(Object.entries)) {
4995
+ // Must be writable: true, enumerable: false, configurable: true
4996
+ Object.entries = function (obj) {
4997
+ if (obj == null) { // TypeError if undefined or null
4998
+ throw new TypeError('Cannot convert undefined or null to object');
4999
+ }
5000
+ const to = [];
5001
+ if (obj != null) { // Skip over if undefined or null
5002
+ for (const key in obj) {
5003
+ // Avoid bugs when hasOwnProperty is shadowed
5004
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
5005
+ to.push([key, obj[key]]);
5006
+ }
5007
+ }
5008
+ }
5009
+ return to;
5010
+ };
5011
+ }
5012
+ }
5013
+ function handleObjectDefinePropertyPolyfill() {
5014
+ if (!shared.isFunction(Object.defineProperties)) {
5015
+ Object.defineProperties = function (obj, properties) {
5016
+ function convertToDescriptor(desc) {
5017
+ function hasProperty(obj, prop) {
5018
+ return Object.prototype.hasOwnProperty.call(obj, prop);
5019
+ }
5020
+ if (!shared.isObject(desc)) {
5021
+ throw new TypeError('bad desc');
5022
+ }
5023
+ const d = {};
5024
+ if (hasProperty(desc, 'enumerable'))
5025
+ d.enumerable = !!desc.enumerable;
5026
+ if (hasProperty(desc, 'configurable')) {
5027
+ d.configurable = !!desc.configurable;
5028
+ }
5029
+ if (hasProperty(desc, 'value'))
5030
+ d.value = desc.value;
5031
+ if (hasProperty(desc, 'writable'))
5032
+ d.writable = !!desc.writable;
5033
+ if (hasProperty(desc, 'get')) {
5034
+ const g = desc.get;
5035
+ if (!shared.isFunction(g) && !shared.isUndefined(g)) {
5036
+ throw new TypeError('bad get');
5037
+ }
5038
+ d.get = g;
5039
+ }
5040
+ if (hasProperty(desc, 'set')) {
5041
+ const s = desc.set;
5042
+ if (!shared.isFunction(s) && !shared.isUndefined(s)) {
5043
+ throw new TypeError('bad set');
5044
+ }
5045
+ d.set = s;
5046
+ }
5047
+ if (('get' in d || 'set' in d) && ('value' in d || 'writable' in d)) {
5048
+ throw new TypeError('identity-confused descriptor');
5049
+ }
5050
+ return d;
5051
+ }
5052
+ if (!shared.isObject(obj))
5053
+ throw new TypeError('bad obj');
5054
+ properties = Object(properties);
5055
+ const keys = Object.keys(properties);
5056
+ const descs = [];
5057
+ for (let i = 0; i < keys.length; i++) {
5058
+ descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);
5059
+ }
5060
+ for (let i = 0; i < descs.length; i++) {
5061
+ Object.defineProperty(obj, descs[i][0], descs[i][1]);
5062
+ }
5063
+ return obj;
5064
+ };
5065
+ }
5066
+ }
5067
+
5068
+ function handlePolyfill() {
5069
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {
5070
+ handleObjectAssignPolyfill();
5071
+ }
5072
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {
5073
+ handleObjectEntriesPolyfill();
5074
+ }
5075
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {
5076
+ handleObjectDefinePropertyPolyfill();
5077
+ }
5078
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {
5079
+ handleArrayFindPolyfill();
5080
+ }
5081
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {
5082
+ handleArrayIncludesPolyfill();
5083
+ }
5084
+ // Exit early if we're not running in a browser.
5085
+ if (process.env.TARO_PLATFORM === 'web' && shared.isObject(window)) {
5086
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {
5087
+ handleIntersectionObserverPolyfill();
5088
+ }
5089
+ }
5090
+ }
5091
+ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') {
5092
+ handlePolyfill();
5093
+ }
5094
+
3268
5095
  Object.defineProperty(exports, 'Events', {
3269
5096
  enumerable: true,
3270
5097
  get: function () { return shared.Events; }
@@ -3282,6 +5109,7 @@ exports.CATCH_VIEW = CATCH_VIEW;
3282
5109
  exports.CHANGE = CHANGE;
3283
5110
  exports.CLASS = CLASS;
3284
5111
  exports.COMMENT = COMMENT;
5112
+ exports.COMPILE_MODE = COMPILE_MODE;
3285
5113
  exports.CONFIRM = CONFIRM;
3286
5114
  exports.CONTAINER = CONTAINER;
3287
5115
  exports.CURRENT_TARGET = CURRENT_TARGET;
@@ -3303,7 +5131,7 @@ exports.ID = ID;
3303
5131
  exports.INPUT = INPUT;
3304
5132
  exports.KEY_CODE = KEY_CODE;
3305
5133
  exports.Location = Location;
3306
- exports.MutationObserver = MutationObserver;
5134
+ exports.MutationObserver = MutationObserver$1;
3307
5135
  exports.OBJECT = OBJECT;
3308
5136
  exports.ON_HIDE = ON_HIDE;
3309
5137
  exports.ON_LOAD = ON_LOAD;
@@ -3342,17 +5170,22 @@ exports.createComponentConfig = createComponentConfig;
3342
5170
  exports.createEvent = createEvent;
3343
5171
  exports.createPageConfig = createPageConfig;
3344
5172
  exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
5173
+ exports.document = document$1;
3345
5174
  exports.env = env;
3346
5175
  exports.eventCenter = eventCenter;
3347
5176
  exports.eventHandler = eventHandler;
3348
5177
  exports.eventSource = eventSource;
3349
5178
  exports.getComputedStyle = getComputedStyle;
3350
5179
  exports.getCurrentInstance = getCurrentInstance;
5180
+ exports.getCurrentPage = getCurrentPage;
5181
+ exports.getHomePage = getHomePage;
3351
5182
  exports.getOnHideEventKey = getOnHideEventKey;
3352
5183
  exports.getOnReadyEventKey = getOnReadyEventKey;
3353
5184
  exports.getOnShowEventKey = getOnShowEventKey;
3354
5185
  exports.getPageInstance = getPageInstance;
3355
5186
  exports.getPath = getPath;
5187
+ exports.handlePolyfill = handlePolyfill;
5188
+ exports.hasBasename = hasBasename;
3356
5189
  exports.history = history;
3357
5190
  exports.hydrate = hydrate;
3358
5191
  exports.incrementId = incrementId;
@@ -3367,3 +5200,8 @@ exports.removePageInstance = removePageInstance;
3367
5200
  exports.requestAnimationFrame = _raf;
3368
5201
  exports.safeExecute = safeExecute;
3369
5202
  exports.stringify = stringify;
5203
+ exports.stripBasename = stripBasename;
5204
+ exports.stripSuffix = stripSuffix;
5205
+ exports.stripTrailing = stripTrailing;
5206
+ exports.window = window$1;
5207
+ //# sourceMappingURL=index.cjs.js.map