@tarojs/runtime 3.6.22-nightly.0 → 3.6.22-nightly.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/LICENSE +7 -0
  2. package/dist/bom/URL.d.ts +7 -14
  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 -14
  6. package/dist/bom/URLSearchParams.js +123 -0
  7. package/dist/bom/URLSearchParams.js.map +1 -0
  8. package/dist/bom/document.d.ts +2 -1
  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 -3
  12. package/dist/bom/getComputedStyle.js +8 -0
  13. package/dist/bom/getComputedStyle.js.map +1 -0
  14. package/dist/bom/history.d.ts +11 -8
  15. package/dist/bom/history.js +121 -0
  16. package/dist/bom/history.js.map +1 -0
  17. package/dist/bom/location.d.ts +7 -4
  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 -1
  21. package/dist/bom/navigator.js +24 -0
  22. package/dist/bom/navigator.js.map +1 -0
  23. package/dist/bom/raf.d.ts +3 -4
  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 -4
  27. package/dist/bom/window.js +92 -0
  28. package/dist/bom/window.js.map +1 -0
  29. package/dist/constants/index.d.ts +52 -50
  30. package/dist/constants/index.js +63 -0
  31. package/dist/constants/index.js.map +1 -0
  32. package/dist/current.d.ts +5 -5
  33. package/dist/current.js +9 -0
  34. package/dist/current.js.map +1 -0
  35. package/dist/dom/anchor-element.d.ts +3 -2
  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 +3 -2
  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 +11 -6
  42. package/dist/dom/document.js +80 -0
  43. package/dist/dom/document.js.map +1 -0
  44. package/dist/dom/element.d.ts +8 -7
  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 +3 -3
  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 +3 -2
  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 +6 -5
  54. package/dist/dom/event.js +151 -0
  55. package/dist/dom/event.js.map +1 -0
  56. package/dist/dom/form.d.ts +4 -3
  57. package/dist/dom/form.js +38 -0
  58. package/dist/dom/form.js.map +1 -0
  59. package/dist/dom/node.d.ts +40 -9
  60. package/dist/dom/node.js +292 -0
  61. package/dist/dom/node.js.map +1 -0
  62. package/dist/dom/root.d.ts +6 -5
  63. package/dist/dom/root.js +169 -0
  64. package/dist/dom/root.js.map +1 -0
  65. package/dist/dom/style.d.ts +3 -2
  66. package/dist/dom/style.js +168 -0
  67. package/dist/dom/style.js.map +1 -0
  68. package/dist/dom/style_properties.js +186 -0
  69. package/dist/dom/style_properties.js.map +1 -0
  70. package/dist/dom/svg.d.ts +3 -2
  71. package/dist/dom/svg.js +8 -0
  72. package/dist/dom/svg.js.map +1 -0
  73. package/dist/dom/text.d.ts +4 -3
  74. package/dist/dom/text.js +41 -0
  75. package/dist/dom/text.js.map +1 -0
  76. package/dist/dom/transfer.d.ts +3 -2
  77. package/dist/dom/transfer.js +15 -0
  78. package/dist/dom/transfer.js.map +1 -0
  79. package/dist/dom/tree.d.ts +3 -3
  80. package/dist/dom/tree.js +38 -0
  81. package/dist/dom/tree.js.map +1 -0
  82. package/dist/dom-external/element.d.ts +4 -3
  83. package/dist/dom-external/element.js +29 -0
  84. package/dist/dom-external/element.js.map +1 -0
  85. package/dist/dom-external/index.js +38 -0
  86. package/dist/dom-external/index.js.map +1 -0
  87. package/dist/dom-external/inner-html/html.d.ts +3 -2
  88. package/dist/dom-external/inner-html/html.js +28 -0
  89. package/dist/dom-external/inner-html/html.js.map +1 -0
  90. package/dist/dom-external/inner-html/parser.d.ts +7 -7
  91. package/dist/dom-external/inner-html/parser.js +216 -0
  92. package/dist/dom-external/inner-html/parser.js.map +1 -0
  93. package/dist/dom-external/inner-html/scaner.d.ts +3 -3
  94. package/dist/dom-external/inner-html/scaner.js +304 -0
  95. package/dist/dom-external/inner-html/scaner.js.map +1 -0
  96. package/dist/dom-external/inner-html/style.d.ts +3 -3
  97. package/dist/dom-external/inner-html/style.js +235 -0
  98. package/dist/dom-external/inner-html/style.js.map +1 -0
  99. package/dist/dom-external/inner-html/tags.d.ts +6 -5
  100. package/dist/dom-external/inner-html/tags.js +26 -0
  101. package/dist/dom-external/inner-html/tags.js.map +1 -0
  102. package/dist/dom-external/inner-html/utils.d.ts +2 -1
  103. package/dist/dom-external/inner-html/utils.js +12 -0
  104. package/dist/dom-external/inner-html/utils.js.map +1 -0
  105. package/dist/dom-external/mutation-observer/implements.d.ts +25 -6
  106. package/dist/dom-external/mutation-observer/implements.js +108 -0
  107. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  108. package/dist/dom-external/mutation-observer/index.d.ts +5 -6
  109. package/dist/dom-external/mutation-observer/index.js +35 -0
  110. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  111. package/dist/dom-external/node.d.ts +6 -5
  112. package/dist/dom-external/node.js +74 -0
  113. package/dist/dom-external/node.js.map +1 -0
  114. package/dist/dsl/common.d.ts +16 -16
  115. package/dist/dsl/common.js +337 -0
  116. package/dist/dsl/common.js.map +1 -0
  117. package/dist/emitter/emitter.d.ts +2 -2
  118. package/dist/emitter/emitter.js +7 -0
  119. package/dist/emitter/emitter.js.map +1 -0
  120. package/dist/env.d.ts +2 -2
  121. package/dist/env.js +9 -0
  122. package/dist/env.js.map +1 -0
  123. package/dist/hydrate.d.ts +5 -4
  124. package/dist/hydrate.js +84 -0
  125. package/dist/hydrate.js.map +1 -0
  126. package/dist/index-26658829.d.ts +23 -0
  127. package/dist/index.cjs.d.ts +775 -0
  128. package/dist/index.cjs.js +4347 -0
  129. package/dist/index.cjs.js.map +1 -0
  130. package/dist/index.d.ts +30 -31
  131. package/dist/index.js +31 -0
  132. package/dist/index.js.map +1 -0
  133. package/dist/{dsl/instance.d.ts → instance-0f017c6e.d.ts} +19 -18
  134. package/dist/next-tick.d.ts +3 -2
  135. package/dist/next-tick.js +47 -0
  136. package/dist/next-tick.js.map +1 -0
  137. package/dist/node_modules/.pnpm/registry.npmjs.org_tslib@2.5.0/node_modules/tslib/tslib.es6.js +32 -0
  138. package/dist/node_modules/.pnpm/registry.npmjs.org_tslib@2.5.0/node_modules/tslib/tslib.es6.js.map +1 -0
  139. package/dist/{dom/node_types.d.ts → node_types-9ac5b4dd.d.ts} +2 -1
  140. package/dist/{interface/options.d.ts → options-0f017c6e.d.ts} +5 -4
  141. package/dist/options.d.ts +3 -2
  142. package/dist/options.js +7 -0
  143. package/dist/options.js.map +1 -0
  144. package/dist/perf.d.ts +2 -2
  145. package/dist/perf.js +28 -0
  146. package/dist/perf.js.map +1 -0
  147. package/dist/{dom-external/mutation-observer/record.d.ts → record-32b054d8.d.ts} +4 -3
  148. package/dist/runtime.esm.d.ts +82 -88
  149. package/dist/runtime.esm.js +360 -374
  150. package/dist/runtime.esm.js.map +1 -1
  151. package/dist/utils/cache.d.ts +2 -1
  152. package/dist/utils/cache.js +27 -0
  153. package/dist/utils/cache.js.map +1 -0
  154. package/dist/utils/index.d.ts +15 -15
  155. package/dist/utils/index.js +95 -0
  156. package/dist/utils/index.js.map +1 -0
  157. package/package.json +20 -10
  158. package/dist/interface/element.d.ts +0 -4
  159. package/dist/interface/event-target.d.ts +0 -10
  160. package/dist/interface/event.d.ts +0 -15
  161. package/dist/interface/hydrate.d.ts +0 -30
  162. package/dist/interface/index.d.ts +0 -7
  163. package/dist/interface/node.d.ts +0 -7
  164. package/dist/interface/utils.d.ts +0 -2
@@ -0,0 +1,4347 @@
1
+ 'use strict';
2
+
3
+ var shared = require('@tarojs/shared');
4
+
5
+ const PROPERTY_THRESHOLD = 2046;
6
+ const TARO_RUNTIME = 'Taro runtime';
7
+ const HOOKS_APP_ID = 'taro-app';
8
+ const SET_DATA = '小程序 setData';
9
+ const PAGE_INIT = '页面初始化';
10
+ const ROOT_STR = 'root';
11
+ const HTML = 'html';
12
+ const HEAD = 'head';
13
+ const BODY = 'body';
14
+ const APP = 'app';
15
+ const CONTAINER = 'container';
16
+ const DOCUMENT_ELEMENT_NAME = '#document';
17
+ const DOCUMENT_FRAGMENT = 'document-fragment';
18
+ const ID = 'id';
19
+ const UID = 'uid';
20
+ const CLASS = 'class';
21
+ const STYLE = 'style';
22
+ const FOCUS = 'focus';
23
+ const VIEW = 'view';
24
+ const STATIC_VIEW = 'static-view';
25
+ const PURE_VIEW = 'pure-view';
26
+ const PROPS = 'props';
27
+ const DATASET = 'dataset';
28
+ const OBJECT = 'object';
29
+ const VALUE = 'value';
30
+ const INPUT = 'input';
31
+ const CHANGE = 'change';
32
+ const CUSTOM_WRAPPER = 'custom-wrapper';
33
+ const TARGET = 'target';
34
+ const CURRENT_TARGET = 'currentTarget';
35
+ const TYPE = 'type';
36
+ const CONFIRM = 'confirm';
37
+ const TIME_STAMP = 'timeStamp';
38
+ const KEY_CODE = 'keyCode';
39
+ const TOUCHMOVE = 'touchmove';
40
+ const DATE = 'Date';
41
+ const SET_TIMEOUT = 'setTimeout';
42
+ const COMPILE_MODE = 'compileMode';
43
+ const CATCHMOVE = 'catchMove';
44
+ const CATCH_VIEW = 'catch-view';
45
+ const COMMENT = 'comment';
46
+ const ON_LOAD = 'onLoad';
47
+ const ON_READY = 'onReady';
48
+ const ON_SHOW = 'onShow';
49
+ const ON_HIDE = 'onHide';
50
+ const OPTIONS = 'options';
51
+ const EXTERNAL_CLASSES = 'externalClasses';
52
+ const EVENT_CALLBACK_RESULT = 'e_result';
53
+ const BEHAVIORS = 'behaviors';
54
+ const A = 'a';
55
+ /**
56
+ * 页面上下文切换时的行为
57
+ */
58
+ exports.CONTEXT_ACTIONS = void 0;
59
+ (function (CONTEXT_ACTIONS) {
60
+ CONTEXT_ACTIONS["INIT"] = "0";
61
+ CONTEXT_ACTIONS["RESTORE"] = "1";
62
+ CONTEXT_ACTIONS["RECOVER"] = "2";
63
+ CONTEXT_ACTIONS["DESTORY"] = "3";
64
+ })(exports.CONTEXT_ACTIONS || (exports.CONTEXT_ACTIONS = {}));
65
+
66
+ const observers = [];
67
+ /**
68
+ * The MutationObserver provides the ability
69
+ * to watch for changes being made to the DOM tree.
70
+ * It will invoke a specified callback function
71
+ * when DOM changes occur.
72
+ * @see https://dom.spec.whatwg.org/#mutationobserver
73
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
74
+ */
75
+ class MutationObserverImpl {
76
+ constructor(callback) {
77
+ this.records = [];
78
+ this.callback = callback;
79
+ }
80
+ /**
81
+ * Configures the MutationObserver
82
+ * to begin receiving notifications
83
+ * through its callback function
84
+ * when DOM changes matching the given options occur.
85
+ *
86
+ * Options matching is to be implemented.
87
+ */
88
+ observe(target, options) {
89
+ this.disconnect();
90
+ this.target = target;
91
+ this.options = options || {};
92
+ observers.push(this);
93
+ }
94
+ /**
95
+ * Stop the MutationObserver instance
96
+ * from receiving further notifications
97
+ * until and unless observe() is called again.
98
+ */
99
+ disconnect() {
100
+ this.target = null;
101
+ const index = observers.indexOf(this);
102
+ if (index >= 0) {
103
+ observers.splice(index, 1);
104
+ }
105
+ }
106
+ /**
107
+ * Removes all pending notifications
108
+ * from the MutationObserver's notification queue
109
+ * and returns them in a new Array of MutationRecord objects.
110
+ */
111
+ takeRecords() {
112
+ return this.records.splice(0, this.records.length);
113
+ }
114
+ }
115
+ /** Match two TaroNodes by sid. */
116
+ const sidMatches = (observerTarget, target) => {
117
+ return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
118
+ };
119
+ const isConcerned = (record, options) => {
120
+ const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
121
+ switch (record.type) {
122
+ case "characterData" /* MutationRecordType.CHARACTER_DATA */:
123
+ if (characterData) {
124
+ if (!characterDataOldValue)
125
+ record.oldValue = null;
126
+ return true;
127
+ }
128
+ return false;
129
+ case "attributes" /* MutationRecordType.ATTRIBUTES */:
130
+ if (attributes) {
131
+ if (!attributeOldValue)
132
+ record.oldValue = null;
133
+ return true;
134
+ }
135
+ return false;
136
+ case "childList" /* MutationRecordType.CHILD_LIST */:
137
+ if (childList) {
138
+ return true;
139
+ }
140
+ return false;
141
+ }
142
+ };
143
+ let pendingMuatations = false;
144
+ function logMutation(observer, record) {
145
+ observer.records.push(record);
146
+ if (!pendingMuatations) {
147
+ pendingMuatations = true;
148
+ Promise
149
+ .resolve()
150
+ .then(() => {
151
+ pendingMuatations = false;
152
+ observers.forEach(observer => {
153
+ return observer.callback(observer.takeRecords());
154
+ });
155
+ });
156
+ }
157
+ }
158
+ function recordMutation(record) {
159
+ observers.forEach(observer => {
160
+ const { options } = observer;
161
+ for (let t = record.target; t; t = t.parentNode) {
162
+ if (sidMatches(observer.target, t) && isConcerned(record, options)) {
163
+ logMutation(observer, record);
164
+ break;
165
+ }
166
+ if (!options.subtree)
167
+ break;
168
+ }
169
+ });
170
+ }
171
+
172
+ class MutationObserver {
173
+ constructor(callback) {
174
+ if (ENABLE_MUTATION_OBSERVER) {
175
+ this.core = new MutationObserverImpl(callback);
176
+ }
177
+ else {
178
+ if (process.env.NODE_ENV !== 'production') {
179
+ console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
180
+ }
181
+ this.core = {
182
+ observe: shared.noop,
183
+ disconnect: shared.noop,
184
+ takeRecords: shared.noop
185
+ };
186
+ }
187
+ }
188
+ observe(...args) {
189
+ this.core.observe(...args);
190
+ }
191
+ disconnect() {
192
+ this.core.disconnect();
193
+ }
194
+ takeRecords() {
195
+ return this.core.takeRecords();
196
+ }
197
+ static record(record) {
198
+ recordMutation(record);
199
+ }
200
+ }
201
+
202
+ const incrementId = () => {
203
+ const chatCodes = [];
204
+ // A-Z
205
+ for (let i = 65; i <= 90; i++) {
206
+ chatCodes.push(i);
207
+ }
208
+ // a-z
209
+ for (let i = 97; i <= 122; i++) {
210
+ chatCodes.push(i);
211
+ }
212
+ const chatCodesLen = chatCodes.length - 1;
213
+ const list = [0, 0];
214
+ return () => {
215
+ const target = list.map(item => chatCodes[item]);
216
+ const res = String.fromCharCode(...target);
217
+ let tailIdx = list.length - 1;
218
+ list[tailIdx]++;
219
+ while (list[tailIdx] > chatCodesLen) {
220
+ list[tailIdx] = 0;
221
+ tailIdx = tailIdx - 1;
222
+ if (tailIdx < 0) {
223
+ list.push(0);
224
+ break;
225
+ }
226
+ list[tailIdx]++;
227
+ }
228
+ return res;
229
+ };
230
+ };
231
+ function isElement(node) {
232
+ return node.nodeType === 1 /* NodeType.ELEMENT_NODE */;
233
+ }
234
+ function isText(node) {
235
+ return node.nodeType === 3 /* NodeType.TEXT_NODE */;
236
+ }
237
+ function isComment(node) {
238
+ return node.nodeName === COMMENT;
239
+ }
240
+ function isHasExtractProp(el) {
241
+ const res = Object.keys(el.props).find(prop => {
242
+ return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));
243
+ });
244
+ return Boolean(res);
245
+ }
246
+ /**
247
+ * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
248
+ * @param node 当前组件
249
+ * @param type 事件类型
250
+ */
251
+ function isParentBinded(node, type) {
252
+ var _a;
253
+ while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
254
+ if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
255
+ return false;
256
+ }
257
+ else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
258
+ return true;
259
+ }
260
+ }
261
+ return false;
262
+ }
263
+ function shortcutAttr(key) {
264
+ switch (key) {
265
+ case STYLE:
266
+ return "st" /* Shortcuts.Style */;
267
+ case ID:
268
+ return UID;
269
+ case CLASS:
270
+ return "cl" /* Shortcuts.Class */;
271
+ default:
272
+ return key;
273
+ }
274
+ }
275
+ const customWrapperCache = new Map();
276
+ function extend(ctor, methodName, options) {
277
+ if (shared.isFunction(options)) {
278
+ options = {
279
+ value: options
280
+ };
281
+ }
282
+ Object.defineProperty(ctor.prototype, methodName, Object.assign({ configurable: true, enumerable: true }, options));
283
+ }
284
+ let componentsAlias$1;
285
+ function getComponentsAlias() {
286
+ if (!componentsAlias$1) {
287
+ componentsAlias$1 = shared.getComponentsAlias(shared.internalComponents);
288
+ }
289
+ return componentsAlias$1;
290
+ }
291
+
292
+ class ClassList {
293
+ constructor(className, el) {
294
+ this.tokenList = [];
295
+ this.el = el;
296
+ className.trim().split(/\s+/).forEach(token => this.tokenList.push(token));
297
+ }
298
+ get value() {
299
+ return this.toString();
300
+ }
301
+ get length() {
302
+ return this.tokenList.length;
303
+ }
304
+ add() {
305
+ let index = 0;
306
+ let updated = false;
307
+ const tokens = arguments;
308
+ const length = tokens.length;
309
+ const tokenList = this.tokenList;
310
+ do {
311
+ const token = tokens[index];
312
+ if (this.checkTokenIsValid(token) && !~tokenList.indexOf(token)) {
313
+ tokenList.push(token);
314
+ updated = true;
315
+ }
316
+ } while (++index < length);
317
+ if (updated) {
318
+ this._update();
319
+ }
320
+ }
321
+ remove() {
322
+ let i = 0;
323
+ let updated = false;
324
+ const tokens = arguments;
325
+ const length = tokens.length;
326
+ const tokenList = this.tokenList;
327
+ do {
328
+ const token = tokens[i] + '';
329
+ if (!this.checkTokenIsValid(token))
330
+ continue;
331
+ const index = tokenList.indexOf(token);
332
+ if (~tokenList.indexOf(token)) {
333
+ tokenList.splice(index, 1);
334
+ updated = true;
335
+ }
336
+ } while (++i < length);
337
+ if (updated) {
338
+ this._update();
339
+ }
340
+ }
341
+ contains(token) {
342
+ if (!this.checkTokenIsValid(token))
343
+ return false;
344
+ return !!~this.tokenList.indexOf(token);
345
+ }
346
+ toggle(token, force) {
347
+ const result = this.contains(token);
348
+ const method = result ? force !== true && 'remove' : force !== false && 'add';
349
+ if (method) {
350
+ // @ts-ignore
351
+ this[method](token);
352
+ }
353
+ if (force === true || force === false) {
354
+ return force;
355
+ }
356
+ else {
357
+ return !result;
358
+ }
359
+ }
360
+ replace(token, replacement_token) {
361
+ if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token))
362
+ return;
363
+ const index = this.tokenList.indexOf(token);
364
+ if (~index) {
365
+ this.tokenList.splice(index, 1, replacement_token);
366
+ this._update();
367
+ }
368
+ }
369
+ toString() {
370
+ return this.tokenList.filter(v => v !== '').join(' ');
371
+ }
372
+ checkTokenIsValid(token) {
373
+ if (token === '' || /\s/.test(token))
374
+ return false;
375
+ return true;
376
+ }
377
+ _update() {
378
+ this.el.className = this.value;
379
+ }
380
+ }
381
+
382
+ class EventSource extends Map {
383
+ removeNode(child) {
384
+ const { sid, uid } = child;
385
+ this.delete(sid);
386
+ if (uid !== sid && uid)
387
+ this.delete(uid);
388
+ }
389
+ removeNodeTree(child) {
390
+ this.removeNode(child);
391
+ const { childNodes } = child;
392
+ childNodes.forEach(node => this.removeNodeTree(node));
393
+ }
394
+ }
395
+ const eventSource = new EventSource();
396
+
397
+ const env = {
398
+ window: process.env.TARO_PLATFORM === 'web' ? window : shared.EMPTY_OBJ,
399
+ document: process.env.TARO_PLATFORM === 'web' ? document : shared.EMPTY_OBJ
400
+ };
401
+
402
+ let SPECIAL_NODES;
403
+ let componentsAlias;
404
+ /**
405
+ * React also has a fancy function's name for this: `hydrate()`.
406
+ * You may have been heard `hydrate` as a SSR-related function,
407
+ * actually, `hydrate` basicly do the `render()` thing, but ignore some properties,
408
+ * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
409
+ */
410
+ function hydrate(node) {
411
+ var _a;
412
+ // 初始化 componentsAlias
413
+ componentsAlias || (componentsAlias = getComponentsAlias());
414
+ // 初始化 SPECIAL_NODES
415
+ SPECIAL_NODES || (SPECIAL_NODES = shared.hooks.call('getSpecialNodes'));
416
+ const nodeName = node.nodeName;
417
+ if (isText(node)) {
418
+ return {
419
+ sid: node.sid,
420
+ ["v" /* Shortcuts.Text */]: node.nodeValue,
421
+ ["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
422
+ };
423
+ }
424
+ const data = {
425
+ ["nn" /* Shortcuts.NodeName */]: nodeName,
426
+ sid: node.sid
427
+ };
428
+ if (node.uid !== node.sid) {
429
+ data.uid = node.uid;
430
+ }
431
+ if (!node.isAnyEventBinded() && SPECIAL_NODES.indexOf(nodeName) > -1) {
432
+ data["nn" /* Shortcuts.NodeName */] = `static-${nodeName}`;
433
+ if (nodeName === VIEW && !isHasExtractProp(node)) {
434
+ data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
435
+ }
436
+ }
437
+ const { props } = node;
438
+ for (const prop in props) {
439
+ const propInCamelCase = shared.toCamelCase(prop);
440
+ if (!prop.startsWith('data-') && // 在 node.dataset 的数据
441
+ prop !== CLASS &&
442
+ prop !== STYLE &&
443
+ prop !== ID &&
444
+ propInCamelCase !== CATCHMOVE &&
445
+ propInCamelCase !== COMPILE_MODE) {
446
+ data[propInCamelCase] = props[prop];
447
+ }
448
+ if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
449
+ data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
450
+ }
451
+ if (propInCamelCase === COMPILE_MODE) {
452
+ data["nn" /* Shortcuts.NodeName */] = props[prop];
453
+ }
454
+ }
455
+ // Children
456
+ data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
457
+ if (node.className !== '') {
458
+ data["cl" /* Shortcuts.Class */] = node.className;
459
+ }
460
+ const cssText = node.cssText;
461
+ if (cssText !== '' && nodeName !== 'swiper-item') {
462
+ data["st" /* Shortcuts.Style */] = cssText;
463
+ }
464
+ shared.hooks.call('modifyHydrateData', data, node);
465
+ const nn = data["nn" /* Shortcuts.NodeName */];
466
+ const componentAlias = componentsAlias[nn];
467
+ if (componentAlias) {
468
+ data["nn" /* Shortcuts.NodeName */] = componentAlias._num;
469
+ for (const prop in data) {
470
+ if (prop in componentAlias) {
471
+ data[componentAlias[prop]] = data[prop];
472
+ delete data[prop];
473
+ }
474
+ }
475
+ }
476
+ const resData = shared.hooks.call('transferHydrateData', data, node, componentAlias);
477
+ return resData || data;
478
+ }
479
+
480
+ class TaroEventTarget {
481
+ constructor() {
482
+ this.__handlers = {};
483
+ }
484
+ addEventListener(type, handler, options) {
485
+ type = type.toLowerCase();
486
+ shared.hooks.call('onAddEvent', type, handler, options, this);
487
+ if (type === 'regionchange') {
488
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
489
+ this.addEventListener('begin', handler, options);
490
+ this.addEventListener('end', handler, options);
491
+ return;
492
+ }
493
+ let isCapture = Boolean(options);
494
+ let isOnce = false;
495
+ if (shared.isObject(options)) {
496
+ isCapture = Boolean(options.capture);
497
+ isOnce = Boolean(options.once);
498
+ }
499
+ if (isOnce) {
500
+ const wrapper = function () {
501
+ handler.apply(this, arguments); // this 指向 Element
502
+ this.removeEventListener(type, wrapper);
503
+ };
504
+ this.addEventListener(type, wrapper, Object.assign(Object.assign({}, options), { once: false }));
505
+ return;
506
+ }
507
+ process.env.NODE_ENV !== 'production' && shared.warn(isCapture, 'Taro 暂未实现 event 的 capture 特性。');
508
+ // 某些框架,如 PReact 有委托的机制,handler 始终是同一个函数
509
+ // 这会导致多层停止冒泡失败:view -> view(handler.stop = false) -> view(handler.stop = true)
510
+ // 这样解决:view -> view(handlerA.stop = false) -> view(handlerB.stop = false)
511
+ // 因此每次绑定事件都新建一个函数,如果带来了性能问题,可以把这段逻辑抽取到 PReact 插件中。
512
+ const oldHandler = handler;
513
+ handler = function () {
514
+ return oldHandler.apply(this, arguments); // this 指向 Element
515
+ };
516
+ handler.oldHandler = oldHandler;
517
+ const handlers = this.__handlers[type];
518
+ if (shared.isArray(handlers)) {
519
+ handlers.push(handler);
520
+ }
521
+ else {
522
+ this.__handlers[type] = [handler];
523
+ }
524
+ }
525
+ removeEventListener(type, handler) {
526
+ type = type.toLowerCase();
527
+ if (type === 'regionchange') {
528
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
529
+ this.removeEventListener('begin', handler);
530
+ this.removeEventListener('end', handler);
531
+ return;
532
+ }
533
+ if (!handler) {
534
+ return;
535
+ }
536
+ const handlers = this.__handlers[type];
537
+ if (!shared.isArray(handlers)) {
538
+ return;
539
+ }
540
+ const index = handlers.findIndex(item => {
541
+ if (item === handler || item.oldHandler === handler)
542
+ return true;
543
+ });
544
+ process.env.NODE_ENV !== 'production' && shared.warn(index === -1, `事件: '${type}' 没有注册在 DOM 中,因此不会被移除。`);
545
+ handlers.splice(index, 1);
546
+ }
547
+ isAnyEventBinded() {
548
+ const handlers = this.__handlers;
549
+ const isAnyEventBinded = Object.keys(handlers).find(key => handlers[key].length);
550
+ return Boolean(isAnyEventBinded);
551
+ }
552
+ }
553
+
554
+ const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
555
+ const nodeId = incrementId();
556
+ class TaroNode extends TaroEventTarget {
557
+ constructor() {
558
+ super();
559
+ this.parentNode = null;
560
+ this.childNodes = [];
561
+ this.hydrate = (node) => () => hydrate(node);
562
+ this.uid = '_' + nodeId(); // dom 节点 id,开发者可修改
563
+ this.sid = this.uid; // dom 节点全局唯一 id,不可被修改
564
+ eventSource.set(this.sid, this);
565
+ }
566
+ updateChildNodes(isClean) {
567
+ const cleanChildNodes = () => [];
568
+ const rerenderChildNodes = () => {
569
+ const childNodes = this.childNodes.filter(node => !isComment(node));
570
+ return childNodes.map(hydrate);
571
+ };
572
+ this.enqueueUpdate({
573
+ path: `${this._path}.${CHILDNODES}`,
574
+ value: isClean ? cleanChildNodes : rerenderChildNodes
575
+ });
576
+ }
577
+ updateSingleChild(index) {
578
+ this.childNodes.forEach((child, childIndex) => {
579
+ if (isComment(child))
580
+ return;
581
+ if (index && childIndex < index)
582
+ return;
583
+ this.enqueueUpdate({
584
+ path: child._path,
585
+ value: this.hydrate(child)
586
+ });
587
+ });
588
+ }
589
+ get _root() {
590
+ var _a;
591
+ return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
592
+ }
593
+ findIndex(refChild) {
594
+ const index = this.childNodes.indexOf(refChild);
595
+ shared.ensure(index !== -1, 'The node to be replaced is not a child of this node.');
596
+ return index;
597
+ }
598
+ get _path() {
599
+ const parentNode = this.parentNode;
600
+ if (parentNode) {
601
+ // 计算路径时,先过滤掉 comment 节点
602
+ const list = parentNode.childNodes.filter(node => !isComment(node));
603
+ const indexOfNode = list.indexOf(this);
604
+ const index = shared.hooks.call('getPathIndex', indexOfNode);
605
+ return `${parentNode._path}.${CHILDNODES}.${index}`;
606
+ }
607
+ return '';
608
+ }
609
+ get nextSibling() {
610
+ const parentNode = this.parentNode;
611
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) + 1]) || null;
612
+ }
613
+ get previousSibling() {
614
+ const parentNode = this.parentNode;
615
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) - 1]) || null;
616
+ }
617
+ get parentElement() {
618
+ const parentNode = this.parentNode;
619
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeType) === 1 /* NodeType.ELEMENT_NODE */) {
620
+ return parentNode;
621
+ }
622
+ return null;
623
+ }
624
+ get firstChild() {
625
+ return this.childNodes[0] || null;
626
+ }
627
+ get lastChild() {
628
+ const childNodes = this.childNodes;
629
+ return childNodes[childNodes.length - 1] || null;
630
+ }
631
+ /**
632
+ * @textContent 目前只能置空子元素
633
+ * @TODO 等待完整 innerHTML 实现
634
+ */
635
+ // eslint-disable-next-line accessor-pairs
636
+ set textContent(text) {
637
+ const removedNodes = this.childNodes.slice();
638
+ const addedNodes = [];
639
+ // Handle old children' data structure & ref
640
+ while (this.firstChild) {
641
+ this.removeChild(this.firstChild, { doUpdate: false });
642
+ }
643
+ if (text === '') {
644
+ this.updateChildNodes(true);
645
+ }
646
+ else {
647
+ const newText = env.document.createTextNode(text);
648
+ addedNodes.push(newText);
649
+ this.appendChild(newText);
650
+ this.updateChildNodes();
651
+ }
652
+ // @Todo: appendChild 会多触发一次
653
+ MutationObserver.record({
654
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
655
+ target: this,
656
+ removedNodes,
657
+ addedNodes
658
+ });
659
+ }
660
+ /**
661
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
662
+ * @scenario
663
+ * [A,B,C]
664
+ * 1. insert D before C, D has no parent
665
+ * 2. insert D before C, D has the same parent of C
666
+ * 3. insert D before C, D has the different parent of C
667
+ */
668
+ insertBefore(newChild, refChild, isReplace) {
669
+ if (newChild.nodeName === DOCUMENT_FRAGMENT) {
670
+ newChild.childNodes.reduceRight((previousValue, currentValue) => {
671
+ this.insertBefore(currentValue, previousValue);
672
+ return currentValue;
673
+ }, refChild);
674
+ return newChild;
675
+ }
676
+ // Parent release newChild
677
+ // - cleanRef: false (No need to clean eventSource, because newChild is about to be inserted)
678
+ // - update: true (Need to update parent.childNodes, because parent.childNodes is reordered)
679
+ newChild.remove({ cleanRef: false });
680
+ let index = 0;
681
+ // Data structure
682
+ newChild.parentNode = this;
683
+ if (refChild) {
684
+ // insertBefore & replaceChild
685
+ index = this.findIndex(refChild);
686
+ this.childNodes.splice(index, 0, newChild);
687
+ }
688
+ else {
689
+ // appendChild
690
+ this.childNodes.push(newChild);
691
+ }
692
+ const childNodesLength = this.childNodes.length;
693
+ // Serialization
694
+ if (this._root) {
695
+ if (!refChild) {
696
+ // appendChild
697
+ const isOnlyChild = childNodesLength === 1;
698
+ if (isOnlyChild) {
699
+ this.updateChildNodes();
700
+ }
701
+ else {
702
+ this.enqueueUpdate({
703
+ path: newChild._path,
704
+ value: this.hydrate(newChild)
705
+ });
706
+ }
707
+ }
708
+ else if (isReplace) {
709
+ // replaceChild
710
+ this.enqueueUpdate({
711
+ path: newChild._path,
712
+ value: this.hydrate(newChild)
713
+ });
714
+ }
715
+ else {
716
+ // insertBefore 有两种更新模式
717
+ // 比方说有 A B C 三个节点,现在要在 C 前插入 D
718
+ // 1. 插入 D,然后更新整个父节点的 childNodes 数组
719
+ // setData({ cn: [A, B, D, C] })
720
+ // 2. 插入 D,然后更新 D 以及 D 之后每个节点的数据
721
+ // setData ({
722
+ // cn.[2]: D,
723
+ // cn.[3]: C,
724
+ // })
725
+ // 由于微信解析 ’cn.[2]‘ 这些路径的时候也需要消耗时间,
726
+ // 所以根据 insertBefore 插入的位置来做不同的处理
727
+ const mark = childNodesLength * 2 / 3;
728
+ if (mark > index) {
729
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 前,则为了避免解析路径消耗过多的时间,采用第一种方式
730
+ this.updateChildNodes();
731
+ }
732
+ else {
733
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 之后,则采用第二种方式,避免 childNodes 的全量更新
734
+ this.updateSingleChild(index);
735
+ }
736
+ }
737
+ }
738
+ MutationObserver.record({
739
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
740
+ target: this,
741
+ addedNodes: [newChild],
742
+ removedNodes: isReplace
743
+ ? [refChild] /** replaceChild */
744
+ : [],
745
+ nextSibling: isReplace
746
+ ? refChild.nextSibling /** replaceChild */
747
+ : (refChild || null),
748
+ previousSibling: newChild.previousSibling
749
+ });
750
+ return newChild;
751
+ }
752
+ /**
753
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/appendChild
754
+ * @scenario
755
+ * [A,B,C]
756
+ * 1. append C, C has no parent
757
+ * 2. append C, C has the same parent of B
758
+ * 3. append C, C has the different parent of B
759
+ */
760
+ appendChild(newChild) {
761
+ return this.insertBefore(newChild);
762
+ }
763
+ /**
764
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
765
+ * @scenario
766
+ * [A,B,C]
767
+ * 1. replace B with C, C has no parent
768
+ * 2. replace B with C, C has no parent, C has the same parent of B
769
+ * 3. replace B with C, C has no parent, C has the different parent of B
770
+ */
771
+ replaceChild(newChild, oldChild) {
772
+ if (oldChild.parentNode !== this)
773
+ return;
774
+ // Insert the newChild
775
+ this.insertBefore(newChild, oldChild, true);
776
+ // Destroy the oldChild
777
+ // - cleanRef: true (Need to clean eventSource, because the oldChild was detached from the DOM tree)
778
+ // - update: false (No need to update parent.childNodes, because replace will not cause the parent.childNodes being reordered)
779
+ oldChild.remove({ doUpdate: false });
780
+ return oldChild;
781
+ }
782
+ /**
783
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/removeChild
784
+ * @scenario
785
+ * [A,B,C]
786
+ * 1. remove A or B
787
+ * 2. remove C
788
+ */
789
+ removeChild(child, options = {}) {
790
+ const { cleanRef, doUpdate } = options;
791
+ if (cleanRef !== false && doUpdate !== false) {
792
+ // appendChild/replaceChild/insertBefore 不应该触发
793
+ // @Todo: 但其实如果 newChild 的父节点是另一颗子树的节点,应该是要触发的
794
+ MutationObserver.record({
795
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
796
+ target: this,
797
+ removedNodes: [child],
798
+ nextSibling: child.nextSibling,
799
+ previousSibling: child.previousSibling
800
+ });
801
+ }
802
+ // Data Structure
803
+ const index = this.findIndex(child);
804
+ this.childNodes.splice(index, 1);
805
+ child.parentNode = null;
806
+ // Set eventSource
807
+ if (cleanRef !== false) {
808
+ eventSource.removeNodeTree(child);
809
+ }
810
+ // Serialization
811
+ if (this._root && doUpdate !== false) {
812
+ this.updateChildNodes();
813
+ }
814
+ return child;
815
+ }
816
+ remove(options) {
817
+ var _a;
818
+ (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this, options);
819
+ }
820
+ hasChildNodes() {
821
+ return this.childNodes.length > 0;
822
+ }
823
+ enqueueUpdate(payload) {
824
+ var _a;
825
+ (_a = this._root) === null || _a === void 0 ? void 0 : _a.enqueueUpdate(payload);
826
+ }
827
+ get ownerDocument() {
828
+ return env.document;
829
+ }
830
+ static extend(methodName, options) {
831
+ extend(TaroNode, methodName, options);
832
+ }
833
+ }
834
+
835
+ /*
836
+ *
837
+ * https://www.w3.org/Style/CSS/all-properties.en.html
838
+ */
839
+ const WEBKIT = 'webkit';
840
+ const styleProperties = [
841
+ 'all',
842
+ 'appearance',
843
+ 'blockOverflow',
844
+ 'blockSize',
845
+ 'bottom',
846
+ 'clear',
847
+ 'contain',
848
+ 'content',
849
+ 'continue',
850
+ 'cursor',
851
+ 'direction',
852
+ 'display',
853
+ 'filter',
854
+ 'float',
855
+ 'gap',
856
+ 'height',
857
+ 'inset',
858
+ 'isolation',
859
+ 'left',
860
+ 'letterSpacing',
861
+ 'lightingColor',
862
+ 'markerSide',
863
+ 'mixBlendMode',
864
+ 'opacity',
865
+ 'order',
866
+ 'position',
867
+ 'quotes',
868
+ 'resize',
869
+ 'right',
870
+ 'rowGap',
871
+ 'tabSize',
872
+ 'tableLayout',
873
+ 'top',
874
+ 'userSelect',
875
+ 'verticalAlign',
876
+ 'visibility',
877
+ 'voiceFamily',
878
+ 'volume',
879
+ 'whiteSpace',
880
+ 'widows',
881
+ 'width',
882
+ 'zIndex',
883
+ 'pointerEvents',
884
+ 'aspectRatio'
885
+ /** 非常用 style */
886
+ // 'azimuth',
887
+ // 'backfaceVisibility',
888
+ // 'baselineShift',
889
+ // 'captionSide',
890
+ // 'chains',
891
+ // 'dominantBaseline',
892
+ // 'elevation',
893
+ // 'emptyCells',
894
+ // 'forcedColorAdjust',
895
+ // 'glyphOrientationVertical',
896
+ // 'hangingPunctuation',
897
+ // 'hyphenateCharacter',
898
+ // 'hyphens',
899
+ // 'imageOrientation',
900
+ // 'imageResolution',
901
+ // 'orphans',
902
+ // 'playDuring',
903
+ // 'pointerEvents',
904
+ // 'regionFragment',
905
+ // 'richness',
906
+ // 'running',
907
+ // 'scrollBehavior',
908
+ // 'speechRate',
909
+ // 'stress',
910
+ // 'stringSet',
911
+ // 'unicodeBidi',
912
+ // 'willChange',
913
+ // 'writingMode',
914
+ ];
915
+ // 减少文件体积
916
+ function combine(prefix, list, excludeSelf) {
917
+ !excludeSelf && styleProperties.push(prefix);
918
+ list.forEach(item => {
919
+ styleProperties.push(prefix + item);
920
+ if (prefix === WEBKIT) {
921
+ styleProperties.push('Webkit' + item);
922
+ }
923
+ });
924
+ }
925
+ const color = 'Color';
926
+ const style = 'Style';
927
+ const width = 'Width';
928
+ const image = 'Image';
929
+ const size = 'Size';
930
+ const color_style_width = [color, style, width];
931
+ const fitlength_fitwidth_image = ['FitLength', 'FitWidth', image];
932
+ const fitlength_fitwidth_image_radius = [...fitlength_fitwidth_image, 'Radius'];
933
+ const color_style_width_fitlength_fitwidth_image = [...color_style_width, ...fitlength_fitwidth_image];
934
+ const endRadius_startRadius = ['EndRadius', 'StartRadius'];
935
+ const bottom_left_right_top = ['Bottom', 'Left', 'Right', 'Top'];
936
+ const end_start = ['End', 'Start'];
937
+ const content_items_self = ['Content', 'Items', 'Self'];
938
+ const blockSize_height_inlineSize_width = ['BlockSize', 'Height', 'InlineSize', width];
939
+ const after_before = ['After', 'Before'];
940
+ combine('borderBlock', color_style_width);
941
+ combine('borderBlockEnd', color_style_width);
942
+ combine('borderBlockStart', color_style_width);
943
+ combine('outline', [...color_style_width, 'Offset']);
944
+ combine('border', [...color_style_width, 'Boundary', 'Break', 'Collapse', 'Radius', 'Spacing']);
945
+ combine('borderFit', ['Length', width]);
946
+ combine('borderInline', color_style_width);
947
+ combine('borderInlineEnd', color_style_width);
948
+ combine('borderInlineStart', color_style_width);
949
+ combine('borderLeft', color_style_width_fitlength_fitwidth_image);
950
+ combine('borderRight', color_style_width_fitlength_fitwidth_image);
951
+ combine('borderTop', color_style_width_fitlength_fitwidth_image);
952
+ combine('borderBottom', color_style_width_fitlength_fitwidth_image);
953
+ combine('textDecoration', [color, style, 'Line']);
954
+ combine('textEmphasis', [color, style, 'Position']);
955
+ combine('scrollMargin', bottom_left_right_top);
956
+ combine('scrollPadding', bottom_left_right_top);
957
+ combine('padding', bottom_left_right_top);
958
+ combine('margin', [...bottom_left_right_top, 'Trim']);
959
+ combine('scrollMarginBlock', end_start);
960
+ combine('scrollMarginInline', end_start);
961
+ combine('scrollPaddingBlock', end_start);
962
+ combine('scrollPaddingInline', end_start);
963
+ combine('gridColumn', end_start);
964
+ combine('gridRow', end_start);
965
+ combine('insetBlock', end_start);
966
+ combine('insetInline', end_start);
967
+ combine('marginBlock', end_start);
968
+ combine('marginInline', end_start);
969
+ combine('paddingBlock', end_start);
970
+ combine('paddingInline', end_start);
971
+ combine('pause', after_before);
972
+ combine('cue', after_before);
973
+ combine('mask', ['Clip', 'Composite', image, 'Mode', 'Origin', 'Position', 'Repeat', size, 'Type']);
974
+ combine('borderImage', ['Outset', 'Repeat', 'Slice', 'Source', 'Transform', width]);
975
+ combine('maskBorder', ['Mode', 'Outset', 'Repeat', 'Slice', 'Source', width]);
976
+ combine('font', ['Family', 'FeatureSettings', 'Kerning', 'LanguageOverride', 'MaxSize', 'MinSize', 'OpticalSizing', 'Palette', size, 'SizeAdjust', 'Stretch', style, 'Weight', 'VariationSettings']);
977
+ combine('transform', ['Box', 'Origin', style]);
978
+ combine('background', [color, image, 'Attachment', 'BlendMode', 'Clip', 'Origin', 'Position', 'Repeat', size]);
979
+ combine('listStyle', [image, 'Position', 'Type']);
980
+ combine('scrollSnap', ['Align', 'Stop', 'Type']);
981
+ combine('grid', ['Area', 'AutoColumns', 'AutoFlow', 'AutoRows']);
982
+ combine('gridTemplate', ['Areas', 'Columns', 'Rows']);
983
+ combine('overflow', ['Block', 'Inline', 'Wrap', 'X', 'Y']);
984
+ combine('transition', ['Delay', 'Duration', 'Property', 'TimingFunction']);
985
+ combine('color', ['Adjust', 'InterpolationFilters', 'Scheme']);
986
+ combine('textAlign', ['All', 'Last']);
987
+ combine('page', ['BreakAfter', 'BreakBefore', 'BreakInside']);
988
+ combine('animation', ['Delay', 'Direction', 'Duration', 'FillMode', 'IterationCount', 'Name', 'PlayState', 'TimingFunction']);
989
+ combine('flex', ['Basis', 'Direction', 'Flow', 'Grow', 'Shrink', 'Wrap']);
990
+ combine('offset', [...after_before, ...end_start, 'Anchor', 'Distance', 'Path', 'Position', 'Rotate']);
991
+ combine('perspective', ['Origin']);
992
+ combine('clip', ['Path', 'Rule']);
993
+ combine('flow', ['From', 'Into']);
994
+ combine('align', ['Content', 'Items', 'Self'], true);
995
+ combine('alignment', ['Adjust', 'Baseline'], true);
996
+ combine('borderStart', endRadius_startRadius, true);
997
+ combine('borderEnd', endRadius_startRadius, true);
998
+ combine('borderCorner', ['Fit', image, 'ImageTransform'], true);
999
+ combine('borderTopLeft', fitlength_fitwidth_image_radius, true);
1000
+ combine('borderTopRight', fitlength_fitwidth_image_radius, true);
1001
+ combine('borderBottomLeft', fitlength_fitwidth_image_radius, true);
1002
+ combine('borderBottomRight', fitlength_fitwidth_image_radius, true);
1003
+ combine('column', ['s', 'Count', 'Fill', 'Gap', 'Rule', 'RuleColor', 'RuleStyle', 'RuleWidth', 'Span', width], true);
1004
+ combine('break', [...after_before, 'Inside'], true);
1005
+ combine('wrap', [...after_before, 'Flow', 'Inside', 'Through'], true);
1006
+ combine('justify', content_items_self, true);
1007
+ combine('place', content_items_self, true);
1008
+ combine('max', [...blockSize_height_inlineSize_width, 'Lines'], true);
1009
+ combine('min', blockSize_height_inlineSize_width, true);
1010
+ combine('line', ['Break', 'Clamp', 'Grid', 'Height', 'Padding', 'Snap'], true);
1011
+ combine('inline', ['BoxAlign', size, 'Sizing'], true);
1012
+ combine('text', ['CombineUpright', 'GroupAlign', 'Height', 'Indent', 'Justify', 'Orientation', 'Overflow', 'Shadow', 'SpaceCollapse', 'SpaceTrim', 'Spacing', 'Transform', 'UnderlinePosition', 'Wrap'], true);
1013
+ combine('shape', ['ImageThreshold', 'Inside', 'Margin', 'Outside'], true);
1014
+ combine('word', ['Break', 'Spacing', 'Wrap'], true);
1015
+ combine('object', ['Fit', 'Position'], true);
1016
+ combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
1017
+ combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
1018
+
1019
+ function recordCss(obj) {
1020
+ MutationObserver.record({
1021
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1022
+ target: obj._element,
1023
+ attributeName: 'style',
1024
+ oldValue: obj.cssText
1025
+ });
1026
+ }
1027
+ function enqueueUpdate(obj) {
1028
+ const element = obj._element;
1029
+ if (element._root) {
1030
+ element.enqueueUpdate({
1031
+ path: `${element._path}.${"st" /* Shortcuts.Style */}`,
1032
+ value: obj.cssText
1033
+ });
1034
+ }
1035
+ }
1036
+ function setStyle(newVal, styleKey) {
1037
+ process.env.NODE_ENV !== 'production' && shared.warn(shared.isString(newVal) && newVal.length > PROPERTY_THRESHOLD, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
1038
+ const old = this[styleKey];
1039
+ if (old === newVal)
1040
+ return;
1041
+ !this._pending && recordCss(this);
1042
+ if (shared.isNull(newVal) || shared.isUndefined(newVal) || newVal === '') {
1043
+ this._usedStyleProp.delete(styleKey);
1044
+ delete this._value[styleKey];
1045
+ }
1046
+ else {
1047
+ this._usedStyleProp.add(styleKey);
1048
+ this._value[styleKey] = newVal;
1049
+ }
1050
+ !this._pending && enqueueUpdate(this);
1051
+ }
1052
+ function initStyle(ctor, styleProperties) {
1053
+ const properties = {};
1054
+ for (let i = 0; i < styleProperties.length; i++) {
1055
+ const styleKey = styleProperties[i];
1056
+ if (ctor[styleKey])
1057
+ return;
1058
+ properties[styleKey] = {
1059
+ get() {
1060
+ const val = this._value[styleKey];
1061
+ return shared.isNull(val) || shared.isUndefined(val) ? '' : val;
1062
+ },
1063
+ set(newVal) {
1064
+ setStyle.call(this, newVal, styleKey);
1065
+ }
1066
+ };
1067
+ }
1068
+ Object.defineProperties(ctor.prototype, properties);
1069
+ }
1070
+ function isCssVariable(propertyName) {
1071
+ return /^--/.test(propertyName);
1072
+ }
1073
+ class Style {
1074
+ constructor(element) {
1075
+ this._element = element;
1076
+ this._usedStyleProp = new Set();
1077
+ this._value = {};
1078
+ }
1079
+ setCssVariables(styleKey) {
1080
+ this.hasOwnProperty(styleKey) || Object.defineProperty(this, styleKey, {
1081
+ enumerable: true,
1082
+ configurable: true,
1083
+ get: () => {
1084
+ return this._value[styleKey] || '';
1085
+ },
1086
+ set: (newVal) => {
1087
+ setStyle.call(this, newVal, styleKey);
1088
+ }
1089
+ });
1090
+ }
1091
+ get cssText() {
1092
+ if (!this._usedStyleProp.size)
1093
+ return '';
1094
+ const texts = [];
1095
+ this._usedStyleProp.forEach(key => {
1096
+ const val = this[key];
1097
+ if (shared.isNull(val) || shared.isUndefined(val))
1098
+ return;
1099
+ let styleName = isCssVariable(key) ? key : shared.toDashed(key);
1100
+ if (styleName.indexOf('webkit') === 0 || styleName.indexOf('Webkit') === 0) {
1101
+ styleName = `-${styleName}`;
1102
+ }
1103
+ texts.push(`${styleName}: ${val};`);
1104
+ });
1105
+ return texts.join(' ');
1106
+ }
1107
+ set cssText(str) {
1108
+ this._pending = true;
1109
+ recordCss(this);
1110
+ this._usedStyleProp.forEach(prop => {
1111
+ this.removeProperty(prop);
1112
+ });
1113
+ if (str === '' || shared.isUndefined(str) || shared.isNull(str)) {
1114
+ this._pending = false;
1115
+ enqueueUpdate(this);
1116
+ return;
1117
+ }
1118
+ const rules = str.split(';');
1119
+ for (let i = 0; i < rules.length; i++) {
1120
+ const rule = rules[i].trim();
1121
+ if (rule === '') {
1122
+ continue;
1123
+ }
1124
+ // 可能存在 'background: url(http:x/y/z)' 的情况
1125
+ const [propName, ...valList] = rule.split(':');
1126
+ const val = valList.join(':');
1127
+ if (shared.isUndefined(val)) {
1128
+ continue;
1129
+ }
1130
+ this.setProperty(propName.trim(), val.trim());
1131
+ }
1132
+ this._pending = false;
1133
+ enqueueUpdate(this);
1134
+ }
1135
+ setProperty(propertyName, value) {
1136
+ if (propertyName[0] === '-') {
1137
+ // 支持 webkit 属性或 css 变量
1138
+ this.setCssVariables(propertyName);
1139
+ }
1140
+ else {
1141
+ propertyName = shared.toCamelCase(propertyName);
1142
+ }
1143
+ if (shared.isNull(value) || shared.isUndefined(value)) {
1144
+ this.removeProperty(propertyName);
1145
+ }
1146
+ else {
1147
+ this[propertyName] = value;
1148
+ }
1149
+ }
1150
+ removeProperty(propertyName) {
1151
+ propertyName = shared.toCamelCase(propertyName);
1152
+ if (!this._usedStyleProp.has(propertyName)) {
1153
+ return '';
1154
+ }
1155
+ const value = this[propertyName];
1156
+ this[propertyName] = undefined;
1157
+ return value;
1158
+ }
1159
+ getPropertyValue(propertyName) {
1160
+ propertyName = shared.toCamelCase(propertyName);
1161
+ const value = this[propertyName];
1162
+ if (!value) {
1163
+ return '';
1164
+ }
1165
+ return value;
1166
+ }
1167
+ }
1168
+ initStyle(Style, styleProperties);
1169
+ shared.hooks.tap('injectNewStyleProperties', (newStyleProperties) => {
1170
+ if (shared.isArray(newStyleProperties)) {
1171
+ initStyle(Style, newStyleProperties);
1172
+ }
1173
+ else {
1174
+ if (typeof newStyleProperties !== 'string')
1175
+ return;
1176
+ initStyle(Style, [newStyleProperties]);
1177
+ }
1178
+ });
1179
+
1180
+ function returnTrue() {
1181
+ return true;
1182
+ }
1183
+ function treeToArray(root, predict) {
1184
+ const array = [];
1185
+ const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
1186
+ let object = root;
1187
+ while (object) {
1188
+ if (object.nodeType === 1 /* NodeType.ELEMENT_NODE */ && filter(object)) {
1189
+ array.push(object);
1190
+ }
1191
+ object = following(object, root);
1192
+ }
1193
+ return array;
1194
+ }
1195
+ function following(el, root) {
1196
+ const firstChild = el.firstChild;
1197
+ const isElmentTypeValid = el.nodeType === 1 /* NodeType.ELEMENT_NODE */ || el.nodeType === 9 /* NodeType.DOCUMENT_NODE */;
1198
+ // 如果当前 el 不是 element 或 document 元素,则可以直接不递归他的子元素了
1199
+ if (firstChild && isElmentTypeValid) {
1200
+ return firstChild;
1201
+ }
1202
+ let current = el;
1203
+ do {
1204
+ if (current === root) {
1205
+ return null;
1206
+ }
1207
+ const nextSibling = current.nextSibling;
1208
+ if (nextSibling) {
1209
+ return nextSibling;
1210
+ }
1211
+ current = current.parentElement;
1212
+ } while (current);
1213
+ return null;
1214
+ }
1215
+
1216
+ class TaroElement extends TaroNode {
1217
+ constructor() {
1218
+ super();
1219
+ this.props = {};
1220
+ this.dataset = shared.EMPTY_OBJ;
1221
+ this.nodeType = 1 /* NodeType.ELEMENT_NODE */;
1222
+ this.style = new Style(this);
1223
+ shared.hooks.call('patchElement', this);
1224
+ }
1225
+ _stopPropagation(event) {
1226
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1227
+ let target = this;
1228
+ // eslint-disable-next-line no-cond-assign
1229
+ while ((target = target.parentNode)) {
1230
+ const listeners = target.__handlers[event.type];
1231
+ if (!shared.isArray(listeners)) {
1232
+ continue;
1233
+ }
1234
+ for (let i = listeners.length; i--;) {
1235
+ const l = listeners[i];
1236
+ l._stop = true;
1237
+ }
1238
+ }
1239
+ }
1240
+ get id() {
1241
+ return this.getAttribute(ID);
1242
+ }
1243
+ set id(val) {
1244
+ this.setAttribute(ID, val);
1245
+ }
1246
+ get className() {
1247
+ return this.getAttribute(CLASS) || '';
1248
+ }
1249
+ set className(val) {
1250
+ this.setAttribute(CLASS, val);
1251
+ }
1252
+ get cssText() {
1253
+ return this.getAttribute(STYLE) || '';
1254
+ }
1255
+ get classList() {
1256
+ return new ClassList(this.className, this);
1257
+ }
1258
+ get children() {
1259
+ return this.childNodes.filter(isElement);
1260
+ }
1261
+ get attributes() {
1262
+ const props = this.props;
1263
+ const propKeys = Object.keys(props);
1264
+ const style = this.style.cssText;
1265
+ const attrs = propKeys.map(key => ({ name: key, value: props[key] }));
1266
+ return attrs.concat(style ? { name: STYLE, value: style } : []);
1267
+ }
1268
+ get textContent() {
1269
+ let text = '';
1270
+ const childNodes = this.childNodes;
1271
+ for (let i = 0; i < childNodes.length; i++) {
1272
+ text += childNodes[i].textContent;
1273
+ }
1274
+ return text;
1275
+ }
1276
+ set textContent(text) {
1277
+ super.textContent = text;
1278
+ }
1279
+ hasAttribute(qualifiedName) {
1280
+ return !shared.isUndefined(this.props[qualifiedName]);
1281
+ }
1282
+ hasAttributes() {
1283
+ return this.attributes.length > 0;
1284
+ }
1285
+ get focus() {
1286
+ return function () {
1287
+ this.setAttribute(FOCUS, true);
1288
+ };
1289
+ }
1290
+ // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579
1291
+ set focus(value) {
1292
+ this.setAttribute(FOCUS, value);
1293
+ }
1294
+ blur() {
1295
+ this.setAttribute(FOCUS, false);
1296
+ }
1297
+ setAttribute(qualifiedName, value) {
1298
+ process.env.NODE_ENV !== 'production' && shared.warn(shared.isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
1299
+ const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
1300
+ if (qualifiedName !== STYLE) {
1301
+ MutationObserver.record({
1302
+ target: this,
1303
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1304
+ attributeName: qualifiedName,
1305
+ oldValue: this.getAttribute(qualifiedName)
1306
+ });
1307
+ }
1308
+ switch (qualifiedName) {
1309
+ case STYLE:
1310
+ this.style.cssText = value;
1311
+ break;
1312
+ case ID:
1313
+ if (this.uid !== this.sid) {
1314
+ // eventSource[sid] 永远保留,直到组件卸载
1315
+ // eventSource[uid] 可变
1316
+ eventSource.delete(this.uid);
1317
+ }
1318
+ value = String(value);
1319
+ this.props[qualifiedName] = this.uid = value;
1320
+ eventSource.set(value, this);
1321
+ break;
1322
+ default:
1323
+ this.props[qualifiedName] = value;
1324
+ if (qualifiedName.startsWith('data-')) {
1325
+ if (this.dataset === shared.EMPTY_OBJ) {
1326
+ this.dataset = Object.create(null);
1327
+ }
1328
+ this.dataset[shared.toCamelCase(qualifiedName.replace(/^data-/, ''))] = value;
1329
+ }
1330
+ break;
1331
+ }
1332
+ // Serialization
1333
+ if (!this._root)
1334
+ return;
1335
+ const componentsAlias = getComponentsAlias();
1336
+ const _alias = componentsAlias[this.nodeName];
1337
+ const viewAlias = componentsAlias[VIEW]._num;
1338
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
1339
+ const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
1340
+ const _path = this._path;
1341
+ qualifiedName = shortcutAttr(qualifiedName);
1342
+ const qualifiedNameInCamelCase = shared.toCamelCase(qualifiedName);
1343
+ const payload = {
1344
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1345
+ value: shared.isFunction(value) ? () => value : value
1346
+ };
1347
+ shared.hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias);
1348
+ if (_alias) {
1349
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1350
+ payload.path = `${_path}.${shared.toCamelCase(qualifiedNameAlias)}`;
1351
+ }
1352
+ this.enqueueUpdate(payload);
1353
+ if (this.nodeName === VIEW) {
1354
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1355
+ // catchMove = true: catch-view
1356
+ // catchMove = false: view or static-view
1357
+ this.enqueueUpdate({
1358
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1359
+ value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
1360
+ });
1361
+ }
1362
+ else if (isPureView && isHasExtractProp(this)) {
1363
+ // pure-view => static-view
1364
+ this.enqueueUpdate({
1365
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1366
+ value: staticViewAlias
1367
+ });
1368
+ }
1369
+ }
1370
+ }
1371
+ removeAttribute(qualifiedName) {
1372
+ const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded();
1373
+ MutationObserver.record({
1374
+ target: this,
1375
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1376
+ attributeName: qualifiedName,
1377
+ oldValue: this.getAttribute(qualifiedName)
1378
+ });
1379
+ if (qualifiedName === STYLE) {
1380
+ this.style.cssText = '';
1381
+ }
1382
+ else {
1383
+ const isInterrupt = shared.hooks.call('onRemoveAttribute', this, qualifiedName);
1384
+ if (isInterrupt) {
1385
+ return;
1386
+ }
1387
+ if (!this.props.hasOwnProperty(qualifiedName)) {
1388
+ return;
1389
+ }
1390
+ delete this.props[qualifiedName];
1391
+ }
1392
+ // Serialization
1393
+ if (!this._root)
1394
+ return;
1395
+ const componentsAlias = getComponentsAlias();
1396
+ const _alias = componentsAlias[this.nodeName];
1397
+ const viewAlias = componentsAlias[VIEW]._num;
1398
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
1399
+ const pureViewAlias = componentsAlias[PURE_VIEW]._num;
1400
+ const _path = this._path;
1401
+ qualifiedName = shortcutAttr(qualifiedName);
1402
+ const qualifiedNameInCamelCase = shared.toCamelCase(qualifiedName);
1403
+ const payload = {
1404
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1405
+ value: ''
1406
+ };
1407
+ shared.hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias);
1408
+ if (_alias) {
1409
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1410
+ payload.path = `${_path}.${shared.toCamelCase(qualifiedNameAlias)}`;
1411
+ }
1412
+ this.enqueueUpdate(payload);
1413
+ if (this.nodeName === VIEW) {
1414
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1415
+ // catch-view => view or static-view or pure-view
1416
+ this.enqueueUpdate({
1417
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1418
+ value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
1419
+ });
1420
+ }
1421
+ else if (isStaticView && !isHasExtractProp(this)) {
1422
+ // static-view => pure-view
1423
+ this.enqueueUpdate({
1424
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1425
+ value: pureViewAlias
1426
+ });
1427
+ }
1428
+ }
1429
+ }
1430
+ getAttribute(qualifiedName) {
1431
+ const attr = qualifiedName === STYLE ? this.style.cssText : this.props[qualifiedName];
1432
+ return attr !== null && attr !== void 0 ? attr : '';
1433
+ }
1434
+ getElementsByTagName(tagName) {
1435
+ return treeToArray(this, (el) => {
1436
+ return el.nodeName === tagName || (tagName === '*' && this !== el);
1437
+ });
1438
+ }
1439
+ getElementsByClassName(className) {
1440
+ const classNames = className.trim().split(/\s+/);
1441
+ return treeToArray(this, (el) => {
1442
+ const classList = el.classList;
1443
+ return classNames.every(c => classList.contains(c));
1444
+ });
1445
+ }
1446
+ dispatchEvent(event) {
1447
+ const cancelable = event.cancelable;
1448
+ const listeners = this.__handlers[event.type];
1449
+ if (!shared.isArray(listeners)) {
1450
+ return false;
1451
+ }
1452
+ for (let i = listeners.length; i--;) {
1453
+ const listener = listeners[i];
1454
+ let result;
1455
+ if (listener._stop) {
1456
+ listener._stop = false;
1457
+ }
1458
+ else {
1459
+ shared.hooks.call('modifyDispatchEvent', event, this);
1460
+ result = listener.call(this, event);
1461
+ }
1462
+ if ((result === false || event._end) && cancelable) {
1463
+ event.defaultPrevented = true;
1464
+ }
1465
+ if (!shared.isUndefined(result) && event.mpEvent) {
1466
+ const res = shared.hooks.call('modifyTaroEventReturn', this, event, result);
1467
+ if (res) {
1468
+ event.mpEvent[EVENT_CALLBACK_RESULT] = result;
1469
+ }
1470
+ }
1471
+ if (event._end && event._stop) {
1472
+ break;
1473
+ }
1474
+ }
1475
+ if (event._stop) {
1476
+ this._stopPropagation(event);
1477
+ }
1478
+ else {
1479
+ event._stop = true;
1480
+ }
1481
+ return listeners != null;
1482
+ }
1483
+ addEventListener(type, handler, options) {
1484
+ const name = this.nodeName;
1485
+ const SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
1486
+ let sideEffect = true;
1487
+ if (shared.isObject(options) && options.sideEffect === false) {
1488
+ sideEffect = false;
1489
+ delete options.sideEffect;
1490
+ }
1491
+ shared.hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias);
1492
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1493
+ const componentsAlias = getComponentsAlias();
1494
+ const alias = componentsAlias[name]._num;
1495
+ this.enqueueUpdate({
1496
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
1497
+ value: alias
1498
+ });
1499
+ }
1500
+ super.addEventListener(type, handler, options);
1501
+ }
1502
+ removeEventListener(type, handler, sideEffect = true) {
1503
+ super.removeEventListener(type, handler);
1504
+ const name = this.nodeName;
1505
+ const SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
1506
+ shared.hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
1507
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1508
+ const componentsAlias = getComponentsAlias();
1509
+ const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
1510
+ const valueAlias = componentsAlias[value]._num;
1511
+ this.enqueueUpdate({
1512
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
1513
+ value: valueAlias
1514
+ });
1515
+ }
1516
+ }
1517
+ static extend(methodName, options) {
1518
+ extend(TaroElement, methodName, options);
1519
+ }
1520
+ }
1521
+
1522
+ const options = {
1523
+ prerender: true,
1524
+ debug: false
1525
+ };
1526
+
1527
+ function initPosition() {
1528
+ return {
1529
+ index: 0,
1530
+ column: 0,
1531
+ line: 0
1532
+ };
1533
+ }
1534
+ function feedPosition(position, str, len) {
1535
+ const start = position.index;
1536
+ const end = position.index = start + len;
1537
+ for (let i = start; i < end; i++) {
1538
+ const char = str.charAt(i);
1539
+ if (char === '\n') {
1540
+ position.line++;
1541
+ position.column = 0;
1542
+ }
1543
+ else {
1544
+ position.column++;
1545
+ }
1546
+ }
1547
+ }
1548
+ function jumpPosition(position, str, end) {
1549
+ const len = end - position.index;
1550
+ return feedPosition(position, str, len);
1551
+ }
1552
+ function copyPosition(position) {
1553
+ return {
1554
+ index: position.index,
1555
+ line: position.line,
1556
+ column: position.column
1557
+ };
1558
+ }
1559
+ const whitespace = /\s/;
1560
+ function isWhitespaceChar(char) {
1561
+ return whitespace.test(char);
1562
+ }
1563
+ const equalSign = /=/;
1564
+ function isEqualSignChar(char) {
1565
+ return equalSign.test(char);
1566
+ }
1567
+ function shouldBeIgnore(tagName) {
1568
+ const name = tagName.toLowerCase();
1569
+ if (options.html.skipElements.has(name)) {
1570
+ return true;
1571
+ }
1572
+ return false;
1573
+ }
1574
+ const alphanumeric = /[A-Za-z0-9]/;
1575
+ function findTextEnd(str, index) {
1576
+ while (true) {
1577
+ const textEnd = str.indexOf('<', index);
1578
+ if (textEnd === -1) {
1579
+ return textEnd;
1580
+ }
1581
+ const char = str.charAt(textEnd + 1);
1582
+ if (char === '/' || char === '!' || alphanumeric.test(char)) {
1583
+ return textEnd;
1584
+ }
1585
+ index = textEnd + 1;
1586
+ }
1587
+ }
1588
+ function isWordEnd(cursor, wordBegin, html) {
1589
+ if (!isWhitespaceChar(html.charAt(cursor)))
1590
+ return false;
1591
+ const len = html.length;
1592
+ // backwrad
1593
+ for (let i = cursor - 1; i > wordBegin; i--) {
1594
+ const char = html.charAt(i);
1595
+ if (!isWhitespaceChar(char)) {
1596
+ if (isEqualSignChar(char))
1597
+ return false;
1598
+ break;
1599
+ }
1600
+ }
1601
+ // forward
1602
+ for (let i = cursor + 1; i < len; i++) {
1603
+ const char = html.charAt(i);
1604
+ if (!isWhitespaceChar(char)) {
1605
+ if (isEqualSignChar(char))
1606
+ return false;
1607
+ return true;
1608
+ }
1609
+ }
1610
+ }
1611
+ class Scaner {
1612
+ constructor(html) {
1613
+ this.tokens = [];
1614
+ this.position = initPosition();
1615
+ this.html = html;
1616
+ }
1617
+ scan() {
1618
+ const { html, position } = this;
1619
+ const len = html.length;
1620
+ while (position.index < len) {
1621
+ const start = position.index;
1622
+ this.scanText();
1623
+ if (position.index === start) {
1624
+ const isComment = html.startsWith('!--', start + 1);
1625
+ if (isComment) {
1626
+ this.scanComment();
1627
+ }
1628
+ else {
1629
+ const tagName = this.scanTag();
1630
+ if (shouldBeIgnore(tagName)) {
1631
+ this.scanSkipTag(tagName);
1632
+ }
1633
+ }
1634
+ }
1635
+ }
1636
+ return this.tokens;
1637
+ }
1638
+ scanText() {
1639
+ const type = 'text';
1640
+ const { html, position } = this;
1641
+ let textEnd = findTextEnd(html, position.index);
1642
+ if (textEnd === position.index) {
1643
+ return;
1644
+ }
1645
+ if (textEnd === -1) {
1646
+ textEnd = html.length;
1647
+ }
1648
+ const start = copyPosition(position);
1649
+ const content = html.slice(position.index, textEnd);
1650
+ jumpPosition(position, html, textEnd);
1651
+ const end = copyPosition(position);
1652
+ this.tokens.push({ type, content, position: { start, end } });
1653
+ }
1654
+ scanComment() {
1655
+ const type = 'comment';
1656
+ const { html, position } = this;
1657
+ const start = copyPosition(position);
1658
+ feedPosition(position, html, 4); // "<!--".length
1659
+ let contentEnd = html.indexOf('-->', position.index);
1660
+ let commentEnd = contentEnd + 3; // "-->".length
1661
+ if (contentEnd === -1) {
1662
+ contentEnd = commentEnd = html.length;
1663
+ }
1664
+ const content = html.slice(position.index, contentEnd);
1665
+ jumpPosition(position, html, commentEnd);
1666
+ this.tokens.push({
1667
+ type,
1668
+ content,
1669
+ position: {
1670
+ start,
1671
+ end: copyPosition(position)
1672
+ }
1673
+ });
1674
+ }
1675
+ scanTag() {
1676
+ this.scanTagStart();
1677
+ const tagName = this.scanTagName();
1678
+ this.scanAttrs();
1679
+ this.scanTagEnd();
1680
+ return tagName;
1681
+ }
1682
+ scanTagStart() {
1683
+ const type = 'tag-start';
1684
+ const { html, position } = this;
1685
+ const secondChar = html.charAt(position.index + 1);
1686
+ const close = secondChar === '/';
1687
+ const start = copyPosition(position);
1688
+ feedPosition(position, html, close ? 2 : 1);
1689
+ this.tokens.push({ type, close, position: { start } });
1690
+ }
1691
+ scanTagEnd() {
1692
+ const type = 'tag-end';
1693
+ const { html, position } = this;
1694
+ const firstChar = html.charAt(position.index);
1695
+ const close = firstChar === '/';
1696
+ feedPosition(position, html, close ? 2 : 1);
1697
+ const end = copyPosition(position);
1698
+ this.tokens.push({ type, close, position: { end } });
1699
+ }
1700
+ scanTagName() {
1701
+ const type = 'tag';
1702
+ const { html, position } = this;
1703
+ const len = html.length;
1704
+ let start = position.index;
1705
+ while (start < len) {
1706
+ const char = html.charAt(start);
1707
+ const isTagChar = !(isWhitespaceChar(char) || char === '/' || char === '>');
1708
+ if (isTagChar)
1709
+ break;
1710
+ start++;
1711
+ }
1712
+ let end = start + 1;
1713
+ while (end < len) {
1714
+ const char = html.charAt(end);
1715
+ const isTagChar = !(isWhitespaceChar(char) || char === '/' || char === '>');
1716
+ if (!isTagChar)
1717
+ break;
1718
+ end++;
1719
+ }
1720
+ jumpPosition(position, html, end);
1721
+ const tagName = html.slice(start, end);
1722
+ this.tokens.push({
1723
+ type,
1724
+ content: tagName
1725
+ });
1726
+ return tagName;
1727
+ }
1728
+ scanAttrs() {
1729
+ const { html, position, tokens } = this;
1730
+ let cursor = position.index;
1731
+ let quote = null; // null, single-, or double-quote
1732
+ let wordBegin = cursor; // index of word start
1733
+ const words = []; // "key", "key=value", "key='value'", etc
1734
+ const len = html.length;
1735
+ while (cursor < len) {
1736
+ const char = html.charAt(cursor);
1737
+ if (quote) {
1738
+ const isQuoteEnd = char === quote;
1739
+ if (isQuoteEnd) {
1740
+ quote = null;
1741
+ }
1742
+ cursor++;
1743
+ continue;
1744
+ }
1745
+ const isTagEnd = char === '/' || char === '>';
1746
+ if (isTagEnd) {
1747
+ if (cursor !== wordBegin) {
1748
+ words.push(html.slice(wordBegin, cursor));
1749
+ }
1750
+ break;
1751
+ }
1752
+ if (isWordEnd(cursor, wordBegin, html)) {
1753
+ if (cursor !== wordBegin) {
1754
+ words.push(html.slice(wordBegin, cursor));
1755
+ }
1756
+ wordBegin = cursor + 1;
1757
+ cursor++;
1758
+ continue;
1759
+ }
1760
+ const isQuoteStart = char === '\'' || char === '"';
1761
+ if (isQuoteStart) {
1762
+ quote = char;
1763
+ cursor++;
1764
+ continue;
1765
+ }
1766
+ cursor++;
1767
+ }
1768
+ jumpPosition(position, html, cursor);
1769
+ const wLen = words.length;
1770
+ const type = 'attribute';
1771
+ for (let i = 0; i < wLen; i++) {
1772
+ const word = words[i];
1773
+ const isNotPair = word.includes('=');
1774
+ if (isNotPair) {
1775
+ const secondWord = words[i + 1];
1776
+ if (secondWord && secondWord.startsWith('=')) {
1777
+ if (secondWord.length > 1) {
1778
+ const newWord = word + secondWord;
1779
+ tokens.push({ type, content: newWord });
1780
+ i += 1;
1781
+ continue;
1782
+ }
1783
+ const thirdWord = words[i + 2];
1784
+ i += 1;
1785
+ if (thirdWord) {
1786
+ const newWord = word + '=' + thirdWord;
1787
+ tokens.push({ type, content: newWord });
1788
+ i += 1;
1789
+ continue;
1790
+ }
1791
+ }
1792
+ }
1793
+ if (word.endsWith('=')) {
1794
+ const secondWord = words[i + 1];
1795
+ if (secondWord && !secondWord.includes('=')) {
1796
+ const newWord = word + secondWord;
1797
+ tokens.push({ type, content: newWord });
1798
+ i += 1;
1799
+ continue;
1800
+ }
1801
+ const newWord = word.slice(0, -1);
1802
+ tokens.push({ type, content: newWord });
1803
+ continue;
1804
+ }
1805
+ tokens.push({ type, content: word });
1806
+ }
1807
+ }
1808
+ scanSkipTag(tagName) {
1809
+ const { html, position } = this;
1810
+ const safeTagName = tagName.toLowerCase();
1811
+ const len = html.length;
1812
+ while (position.index < len) {
1813
+ const nextTag = html.indexOf('</', position.index);
1814
+ if (nextTag === -1) {
1815
+ this.scanText();
1816
+ break;
1817
+ }
1818
+ jumpPosition(position, html, nextTag);
1819
+ const name = this.scanTag();
1820
+ if (safeTagName === name.toLowerCase()) {
1821
+ break;
1822
+ }
1823
+ }
1824
+ }
1825
+ }
1826
+
1827
+ function unquote(str) {
1828
+ const car = str.charAt(0);
1829
+ const end = str.length - 1;
1830
+ const isQuoteStart = car === '"' || car === "'";
1831
+ if (isQuoteStart && car === str.charAt(end)) {
1832
+ return str.slice(1, end);
1833
+ }
1834
+ return str;
1835
+ }
1836
+
1837
+ const LEFT_BRACKET = '{';
1838
+ const RIGHT_BRACKET = '}';
1839
+ const CLASS_SELECTOR = '.';
1840
+ const ID_SELECTOR = '#';
1841
+ const CHILD_COMBINATOR = '>';
1842
+ const GENERAL_SIBLING_COMBINATOR = '~';
1843
+ const ADJACENT_SIBLING_COMBINATOR = '+';
1844
+ class StyleTagParser {
1845
+ constructor() {
1846
+ this.styles = [];
1847
+ }
1848
+ extractStyle(src) {
1849
+ const REG_STYLE = /<style\s?[^>]*>((.|\n|\s)+?)<\/style>/g;
1850
+ let html = src;
1851
+ // let html = src.replace(/\n/g, '')
1852
+ html = html.replace(REG_STYLE, (_, $1) => {
1853
+ const style = $1.trim();
1854
+ this.stringToSelector(style);
1855
+ return '';
1856
+ });
1857
+ return html.trim();
1858
+ }
1859
+ stringToSelector(style) {
1860
+ let lb = style.indexOf(LEFT_BRACKET);
1861
+ while (lb > -1) {
1862
+ const rb = style.indexOf(RIGHT_BRACKET);
1863
+ const selectors = style.slice(0, lb).trim();
1864
+ let content = style.slice(lb + 1, rb);
1865
+ content = content.replace(/:(.*);/g, function (_, $1) {
1866
+ const t = $1.trim().replace(/ +/g, '+++');
1867
+ return `:${t};`;
1868
+ });
1869
+ content = content.replace(/ /g, '');
1870
+ content = content.replace(/\+\+\+/g, ' ');
1871
+ if (!(/;$/.test(content))) {
1872
+ content += ';';
1873
+ }
1874
+ selectors.split(',').forEach(src => {
1875
+ const selectorList = this.parseSelector(src);
1876
+ this.styles.push({
1877
+ content,
1878
+ selectorList
1879
+ });
1880
+ });
1881
+ style = style.slice(rb + 1);
1882
+ lb = style.indexOf(LEFT_BRACKET);
1883
+ }
1884
+ // console.log('res this.styles: ', this.styles)
1885
+ }
1886
+ parseSelector(src) {
1887
+ const list = src
1888
+ .trim()
1889
+ .replace(/ *([>~+]) */g, ' $1')
1890
+ .replace(/ +/g, ' ')
1891
+ .replace(/\[\s*([^[\]=\s]+)\s*=\s*([^[\]=\s]+)\s*\]/g, '[$1=$2]')
1892
+ .split(' ');
1893
+ const selectors = list.map(item => {
1894
+ const firstChar = item.charAt(0);
1895
+ const selector = {
1896
+ isChild: firstChar === CHILD_COMBINATOR,
1897
+ isGeneralSibling: firstChar === GENERAL_SIBLING_COMBINATOR,
1898
+ isAdjacentSibling: firstChar === ADJACENT_SIBLING_COMBINATOR,
1899
+ tag: null,
1900
+ id: null,
1901
+ class: [],
1902
+ attrs: []
1903
+ };
1904
+ item = item.replace(/^[>~+]/, '');
1905
+ // 属性选择器
1906
+ item = item.replace(/\[(.+?)\]/g, function (_, $1) {
1907
+ const [key, value] = $1.split('=');
1908
+ const all = $1.indexOf('=') === -1;
1909
+ const attr = {
1910
+ all,
1911
+ key,
1912
+ value: all ? null : value
1913
+ };
1914
+ selector.attrs.push(attr);
1915
+ return '';
1916
+ });
1917
+ item = item.replace(/([.#][A-Za-z0-9-_]+)/g, function (_, $1) {
1918
+ if ($1[0] === ID_SELECTOR) {
1919
+ // id 选择器
1920
+ selector.id = $1.substr(1);
1921
+ }
1922
+ else if ($1[0] === CLASS_SELECTOR) {
1923
+ // class 选择器
1924
+ selector.class.push($1.substr(1));
1925
+ }
1926
+ return '';
1927
+ });
1928
+ // 标签选择器
1929
+ if (item !== '') {
1930
+ selector.tag = item;
1931
+ }
1932
+ return selector;
1933
+ });
1934
+ return selectors;
1935
+ }
1936
+ matchStyle(tagName, el, list) {
1937
+ const res = sortStyles(this.styles).reduce((str, { content, selectorList }, i) => {
1938
+ let idx = list[i];
1939
+ let selector = selectorList[idx];
1940
+ const nextSelector = selectorList[idx + 1];
1941
+ if ((nextSelector === null || nextSelector === void 0 ? void 0 : nextSelector.isGeneralSibling) || (nextSelector === null || nextSelector === void 0 ? void 0 : nextSelector.isAdjacentSibling)) {
1942
+ selector = nextSelector;
1943
+ idx += 1;
1944
+ list[i] += 1;
1945
+ }
1946
+ let isMatch = this.matchCurrent(tagName, el, selector);
1947
+ if (isMatch && selector.isGeneralSibling) {
1948
+ let prev = getPreviousElement(el);
1949
+ while (prev) {
1950
+ if (prev.h5tagName && this.matchCurrent(prev.h5tagName, prev, selectorList[idx - 1])) {
1951
+ isMatch = true;
1952
+ break;
1953
+ }
1954
+ prev = getPreviousElement(prev);
1955
+ isMatch = false;
1956
+ }
1957
+ }
1958
+ if (isMatch && selector.isAdjacentSibling) {
1959
+ const prev = getPreviousElement(el);
1960
+ if (!prev || !prev.h5tagName) {
1961
+ isMatch = false;
1962
+ }
1963
+ else {
1964
+ const isSiblingMatch = this.matchCurrent(prev.h5tagName, prev, selectorList[idx - 1]);
1965
+ if (!isSiblingMatch) {
1966
+ isMatch = false;
1967
+ }
1968
+ }
1969
+ }
1970
+ if (isMatch) {
1971
+ if (idx === selectorList.length - 1) {
1972
+ return str + content;
1973
+ }
1974
+ else if (idx < selectorList.length - 1) {
1975
+ list[i] += 1;
1976
+ }
1977
+ }
1978
+ else {
1979
+ // 直接子代组合器: >
1980
+ if (selector.isChild && idx > 0) {
1981
+ list[i] -= 1;
1982
+ if (this.matchCurrent(tagName, el, selectorList[list[i]])) {
1983
+ list[i] += 1;
1984
+ }
1985
+ }
1986
+ }
1987
+ return str;
1988
+ }, '');
1989
+ return res;
1990
+ }
1991
+ matchCurrent(tagName, el, selector) {
1992
+ // 标签选择器
1993
+ if (selector.tag && selector.tag !== tagName)
1994
+ return false;
1995
+ // id 选择器
1996
+ if (selector.id && selector.id !== el.id)
1997
+ return false;
1998
+ // class 选择器
1999
+ if (selector.class.length) {
2000
+ const classList = el.className.split(' ');
2001
+ for (let i = 0; i < selector.class.length; i++) {
2002
+ const cls = selector.class[i];
2003
+ if (classList.indexOf(cls) === -1) {
2004
+ return false;
2005
+ }
2006
+ }
2007
+ }
2008
+ // 属性选择器
2009
+ if (selector.attrs.length) {
2010
+ for (let i = 0; i < selector.attrs.length; i++) {
2011
+ const { all, key, value } = selector.attrs[i];
2012
+ if (all && !el.hasAttribute(key)) {
2013
+ return false;
2014
+ }
2015
+ else {
2016
+ const attr = el.getAttribute(key);
2017
+ if (attr !== unquote(value || '')) {
2018
+ return false;
2019
+ }
2020
+ }
2021
+ }
2022
+ }
2023
+ return true;
2024
+ }
2025
+ }
2026
+ function getPreviousElement(el) {
2027
+ const parent = el.parentElement;
2028
+ if (!parent)
2029
+ return null;
2030
+ const prev = el.previousSibling;
2031
+ if (!prev)
2032
+ return null;
2033
+ if (prev.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
2034
+ return prev;
2035
+ }
2036
+ else {
2037
+ return getPreviousElement(prev);
2038
+ }
2039
+ }
2040
+ // 根据 css selector 权重排序: 权重大的靠后
2041
+ // @WARN 不考虑伪类
2042
+ // https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance#specificity_2
2043
+ function sortStyles(styles) {
2044
+ return styles.sort((s1, s2) => {
2045
+ const hundreds1 = getHundredsWeight(s1.selectorList);
2046
+ const hundreds2 = getHundredsWeight(s2.selectorList);
2047
+ if (hundreds1 !== hundreds2)
2048
+ return hundreds1 - hundreds2;
2049
+ const tens1 = getTensWeight(s1.selectorList);
2050
+ const tens2 = getTensWeight(s2.selectorList);
2051
+ if (tens1 !== tens2)
2052
+ return tens1 - tens2;
2053
+ const ones1 = getOnesWeight(s1.selectorList);
2054
+ const ones2 = getOnesWeight(s2.selectorList);
2055
+ return ones1 - ones2;
2056
+ });
2057
+ }
2058
+ function getHundredsWeight(selectors) {
2059
+ return selectors.reduce((pre, cur) => pre + (cur.id ? 1 : 0), 0);
2060
+ }
2061
+ function getTensWeight(selectors) {
2062
+ return selectors.reduce((pre, cur) => pre + cur.class.length + cur.attrs.length, 0);
2063
+ }
2064
+ function getOnesWeight(selectors) {
2065
+ return selectors.reduce((pre, cur) => pre + (cur.tag ? 1 : 0), 0);
2066
+ }
2067
+
2068
+ function makeMap(str, expectsLowerCase) {
2069
+ const map = Object.create(null);
2070
+ const list = str.split(',');
2071
+ for (let i = 0; i < list.length; i++) {
2072
+ map[list[i]] = true;
2073
+ }
2074
+ return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
2075
+ }
2076
+ const specialMiniElements = {
2077
+ img: 'image',
2078
+ iframe: 'web-view'
2079
+ };
2080
+ const internalCompsList = Object.keys(shared.internalComponents)
2081
+ .map(i => i.toLowerCase())
2082
+ .join(',');
2083
+ // https://developers.weixin.qq.com/miniprogram/dev/component
2084
+ const isMiniElements = makeMap(internalCompsList, true);
2085
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
2086
+ const isInlineElements = 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);
2087
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
2088
+ 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);
2089
+
2090
+ const closingTagAncestorBreakers = {
2091
+ li: ['ul', 'ol', 'menu'],
2092
+ dt: ['dl'],
2093
+ dd: ['dl'],
2094
+ tbody: ['table'],
2095
+ thead: ['table'],
2096
+ tfoot: ['table'],
2097
+ tr: ['table'],
2098
+ td: ['table']
2099
+ };
2100
+ function hasTerminalParent(tagName, stack) {
2101
+ const tagParents = closingTagAncestorBreakers[tagName];
2102
+ if (tagParents) {
2103
+ let currentIndex = stack.length - 1;
2104
+ while (currentIndex >= 0) {
2105
+ const parentTagName = stack[currentIndex].tagName;
2106
+ if (parentTagName === tagName) {
2107
+ break;
2108
+ }
2109
+ if (tagParents && tagParents.includes(parentTagName)) {
2110
+ return true;
2111
+ }
2112
+ currentIndex--;
2113
+ }
2114
+ }
2115
+ return false;
2116
+ }
2117
+ function getTagName(tag) {
2118
+ if (options.html.renderHTMLTag) {
2119
+ return tag;
2120
+ }
2121
+ if (specialMiniElements[tag]) {
2122
+ return specialMiniElements[tag];
2123
+ }
2124
+ else if (isMiniElements(tag)) {
2125
+ return tag;
2126
+ }
2127
+ else if (isBlockElements(tag)) {
2128
+ return 'view';
2129
+ }
2130
+ else if (isInlineElements(tag)) {
2131
+ return 'text';
2132
+ }
2133
+ return 'view';
2134
+ }
2135
+ function splitEqual(str) {
2136
+ const sep = '=';
2137
+ const idx = str.indexOf(sep);
2138
+ if (idx === -1)
2139
+ return [str];
2140
+ const key = str.slice(0, idx).trim();
2141
+ const value = str.slice(idx + sep.length).trim();
2142
+ return [key, value];
2143
+ }
2144
+ function format(children, document, styleOptions, parent) {
2145
+ return children
2146
+ .filter(child => {
2147
+ // 过滤注释和空文本节点
2148
+ if (child.type === 'comment') {
2149
+ return false;
2150
+ }
2151
+ else if (child.type === 'text') {
2152
+ return child.content !== '';
2153
+ }
2154
+ return true;
2155
+ })
2156
+ .map((child) => {
2157
+ // 文本节点
2158
+ if (child.type === 'text') {
2159
+ let text = document.createTextNode(child.content);
2160
+ if (shared.isFunction(options.html.transformText)) {
2161
+ text = options.html.transformText(text, child);
2162
+ }
2163
+ parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
2164
+ return text;
2165
+ }
2166
+ const el = document.createElement(getTagName(child.tagName));
2167
+ el.h5tagName = child.tagName;
2168
+ parent === null || parent === void 0 ? void 0 : parent.appendChild(el);
2169
+ if (!options.html.renderHTMLTag) {
2170
+ el.className = `h5-${child.tagName}`;
2171
+ }
2172
+ for (let i = 0; i < child.attributes.length; i++) {
2173
+ const attr = child.attributes[i];
2174
+ const [key, value] = splitEqual(attr);
2175
+ if (key === 'class') {
2176
+ el.className += ' ' + unquote(value);
2177
+ }
2178
+ else if (key[0] === 'o' && key[1] === 'n') {
2179
+ continue;
2180
+ }
2181
+ else {
2182
+ el.setAttribute(key, value == null ? true : unquote(value));
2183
+ }
2184
+ }
2185
+ const { styleTagParser, descendantList } = styleOptions;
2186
+ const list = descendantList.slice();
2187
+ const style = styleTagParser.matchStyle(child.tagName, el, list);
2188
+ el.setAttribute('style', style + el.style.cssText);
2189
+ // console.log('style, ', style)
2190
+ format(child.children, document, {
2191
+ styleTagParser,
2192
+ descendantList: list
2193
+ }, el);
2194
+ if (shared.isFunction(options.html.transformElement)) {
2195
+ return options.html.transformElement(el, child);
2196
+ }
2197
+ return el;
2198
+ });
2199
+ }
2200
+ function parser(html, document) {
2201
+ const styleTagParser = new StyleTagParser();
2202
+ html = styleTagParser.extractStyle(html);
2203
+ const tokens = new Scaner(html).scan();
2204
+ const root = { tagName: '', children: [], type: 'element', attributes: [] };
2205
+ const state = { tokens, options, cursor: 0, stack: [root] };
2206
+ parse(state);
2207
+ return format(root.children, document, {
2208
+ styleTagParser,
2209
+ descendantList: Array(styleTagParser.styles.length).fill(0)
2210
+ });
2211
+ }
2212
+ function parse(state) {
2213
+ const { tokens, stack } = state;
2214
+ let { cursor } = state;
2215
+ const len = tokens.length;
2216
+ let nodes = stack[stack.length - 1].children;
2217
+ while (cursor < len) {
2218
+ const token = tokens[cursor];
2219
+ if (token.type !== 'tag-start') {
2220
+ // comment or text
2221
+ nodes.push(token);
2222
+ cursor++;
2223
+ continue;
2224
+ }
2225
+ const tagToken = tokens[++cursor];
2226
+ cursor++;
2227
+ const tagName = tagToken.content.toLowerCase();
2228
+ if (token.close) {
2229
+ let index = stack.length;
2230
+ let shouldRewind = false;
2231
+ while (--index > -1) {
2232
+ if (stack[index].tagName === tagName) {
2233
+ shouldRewind = true;
2234
+ break;
2235
+ }
2236
+ }
2237
+ while (cursor < len) {
2238
+ const endToken = tokens[cursor];
2239
+ if (endToken.type !== 'tag-end')
2240
+ break;
2241
+ cursor++;
2242
+ }
2243
+ if (shouldRewind) {
2244
+ stack.splice(index);
2245
+ break;
2246
+ }
2247
+ else {
2248
+ continue;
2249
+ }
2250
+ }
2251
+ const isClosingTag = options.html.closingElements.has(tagName);
2252
+ let shouldRewindToAutoClose = isClosingTag;
2253
+ if (shouldRewindToAutoClose) {
2254
+ shouldRewindToAutoClose = !hasTerminalParent(tagName, stack);
2255
+ }
2256
+ if (shouldRewindToAutoClose) {
2257
+ let currentIndex = stack.length - 1;
2258
+ while (currentIndex > 0) {
2259
+ if (tagName === stack[currentIndex].tagName) {
2260
+ stack.splice(currentIndex);
2261
+ const previousIndex = currentIndex - 1;
2262
+ nodes = stack[previousIndex].children;
2263
+ break;
2264
+ }
2265
+ currentIndex = currentIndex - 1;
2266
+ }
2267
+ }
2268
+ const attributes = [];
2269
+ let attrToken;
2270
+ while (cursor < len) {
2271
+ attrToken = tokens[cursor];
2272
+ if (attrToken.type === 'tag-end')
2273
+ break;
2274
+ attributes.push(attrToken.content);
2275
+ cursor++;
2276
+ }
2277
+ cursor++;
2278
+ const children = [];
2279
+ const element = {
2280
+ type: 'element',
2281
+ tagName: tagToken.content,
2282
+ attributes,
2283
+ children
2284
+ };
2285
+ nodes.push(element);
2286
+ const hasChildren = !(attrToken.close || options.html.voidElements.has(tagName));
2287
+ if (hasChildren) {
2288
+ stack.push({ tagName, children });
2289
+ const innerState = { tokens, cursor, stack };
2290
+ parse(innerState);
2291
+ cursor = innerState.cursor;
2292
+ }
2293
+ }
2294
+ state.cursor = cursor;
2295
+ }
2296
+
2297
+ options.html = {
2298
+ skipElements: new Set(['style', 'script']),
2299
+ voidElements: new Set([
2300
+ '!doctype', 'area', 'base', 'br', 'col', 'command',
2301
+ 'embed', 'hr', 'img', 'input', 'keygen', 'link',
2302
+ 'meta', 'param', 'source', 'track', 'wbr'
2303
+ ]),
2304
+ closingElements: new Set([
2305
+ 'html', 'head', 'body', 'p', 'dt', 'dd', 'li', 'option',
2306
+ 'thead', 'th', 'tbody', 'tr', 'td', 'tfoot', 'colgroup'
2307
+ ]),
2308
+ renderHTMLTag: false
2309
+ };
2310
+ function setInnerHTML(element, html) {
2311
+ while (element.firstChild) {
2312
+ element.removeChild(element.firstChild);
2313
+ }
2314
+ const children = parser(html, element.ownerDocument);
2315
+ for (let i = 0; i < children.length; i++) {
2316
+ element.appendChild(children[i]);
2317
+ }
2318
+ }
2319
+
2320
+ function getBoundingClientRectImpl() {
2321
+ if (!options.miniGlobal)
2322
+ return Promise.resolve(null);
2323
+ return new Promise(resolve => {
2324
+ const query = options.miniGlobal.createSelectorQuery();
2325
+ query.select(`#${this.uid}`).boundingClientRect(res => {
2326
+ resolve(res);
2327
+ }).exec();
2328
+ });
2329
+ }
2330
+ function getTemplateContent(ctx) {
2331
+ if (ctx.nodeName === 'template') {
2332
+ const document = ctx.ownerDocument;
2333
+ const content = document.createElement(DOCUMENT_FRAGMENT);
2334
+ content.childNodes = ctx.childNodes;
2335
+ ctx.childNodes = [content];
2336
+ content.parentNode = ctx;
2337
+ content.childNodes.forEach(nodes => {
2338
+ nodes.parentNode = content;
2339
+ });
2340
+ return content;
2341
+ }
2342
+ }
2343
+
2344
+ /**
2345
+ * An implementation of `Element.insertAdjacentHTML()`
2346
+ * to support Vue 3 with a version of or greater than `vue@3.1.2`
2347
+ */
2348
+ function insertAdjacentHTML(position, html) {
2349
+ var _a, _b;
2350
+ const parsedNodes = parser(html, this.ownerDocument);
2351
+ for (let i = 0; i < parsedNodes.length; i++) {
2352
+ const n = parsedNodes[i];
2353
+ switch (position) {
2354
+ case 'beforebegin':
2355
+ (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(n, this);
2356
+ break;
2357
+ case 'afterbegin':
2358
+ if (this.hasChildNodes()) {
2359
+ this.insertBefore(n, this.childNodes[0]);
2360
+ }
2361
+ else {
2362
+ this.appendChild(n);
2363
+ }
2364
+ break;
2365
+ case 'beforeend':
2366
+ this.appendChild(n);
2367
+ break;
2368
+ case 'afterend':
2369
+ (_b = this.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(n);
2370
+ break;
2371
+ }
2372
+ }
2373
+ }
2374
+ function cloneNode(isDeep = false) {
2375
+ const document = this.ownerDocument;
2376
+ let newNode;
2377
+ if (this.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
2378
+ newNode = document.createElement(this.nodeName);
2379
+ }
2380
+ else if (this.nodeType === 3 /* NodeType.TEXT_NODE */) {
2381
+ newNode = document.createTextNode('');
2382
+ }
2383
+ for (const key in this) {
2384
+ const value = this[key];
2385
+ if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {
2386
+ newNode[key] = Object.assign({}, value);
2387
+ }
2388
+ else if (key === '_value') {
2389
+ newNode[key] = value;
2390
+ }
2391
+ else if (key === STYLE) {
2392
+ newNode.style._value = Object.assign({}, value._value);
2393
+ newNode.style._usedStyleProp = new Set(Array.from(value._usedStyleProp));
2394
+ }
2395
+ }
2396
+ if (isDeep) {
2397
+ newNode.childNodes = this.childNodes.map(node => node.cloneNode(true));
2398
+ }
2399
+ return newNode;
2400
+ }
2401
+ function contains(node) {
2402
+ let isContains = false;
2403
+ this.childNodes.some(childNode => {
2404
+ const { uid } = childNode;
2405
+ if (uid === node.uid || uid === node.id || childNode.contains(node)) {
2406
+ isContains = true;
2407
+ return true;
2408
+ }
2409
+ });
2410
+ return isContains;
2411
+ }
2412
+
2413
+ if (process.env.TARO_PLATFORM !== 'web') {
2414
+ if (ENABLE_INNER_HTML) {
2415
+ TaroNode.extend('innerHTML', {
2416
+ set(html) {
2417
+ setInnerHTML.call(this, this, html);
2418
+ },
2419
+ get() {
2420
+ return '';
2421
+ }
2422
+ });
2423
+ if (ENABLE_ADJACENT_HTML) {
2424
+ TaroNode.extend('insertAdjacentHTML', insertAdjacentHTML);
2425
+ }
2426
+ }
2427
+ if (ENABLE_CLONE_NODE) {
2428
+ TaroNode.extend('cloneNode', cloneNode);
2429
+ }
2430
+ if (ENABLE_CONTAINS) {
2431
+ TaroNode.extend('contains', contains);
2432
+ }
2433
+ if (ENABLE_SIZE_APIS) {
2434
+ TaroElement.extend('getBoundingClientRect', getBoundingClientRectImpl);
2435
+ }
2436
+ if (ENABLE_TEMPLATE_CONTENT) {
2437
+ TaroElement.extend('content', {
2438
+ get() {
2439
+ return getTemplateContent(this);
2440
+ }
2441
+ });
2442
+ }
2443
+ }
2444
+
2445
+ // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
2446
+ class TaroEvent {
2447
+ constructor(type, opts, event) {
2448
+ this._stop = false;
2449
+ this._end = false;
2450
+ this.defaultPrevented = false;
2451
+ // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
2452
+ this.button = 0;
2453
+ // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
2454
+ // here use hi-res timestamp
2455
+ this.timeStamp = Date.now();
2456
+ this.type = type.toLowerCase();
2457
+ this.mpEvent = event;
2458
+ this.bubbles = Boolean(opts && opts.bubbles);
2459
+ this.cancelable = Boolean(opts && opts.cancelable);
2460
+ }
2461
+ stopPropagation() {
2462
+ this._stop = true;
2463
+ }
2464
+ stopImmediatePropagation() {
2465
+ this._end = this._stop = true;
2466
+ }
2467
+ preventDefault() {
2468
+ this.defaultPrevented = true;
2469
+ }
2470
+ get target() {
2471
+ var _a, _b, _c, _d;
2472
+ const cacheTarget = this.cacheTarget;
2473
+ if (!cacheTarget) {
2474
+ const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2475
+ // Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
2476
+ 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);
2477
+ target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
2478
+ for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
2479
+ target[key] = this.mpEvent.detail[key];
2480
+ }
2481
+ this.cacheTarget = target;
2482
+ return target;
2483
+ }
2484
+ else {
2485
+ return cacheTarget;
2486
+ }
2487
+ }
2488
+ get currentTarget() {
2489
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2490
+ const cacheCurrentTarget = this.cacheCurrentTarget;
2491
+ if (!cacheCurrentTarget) {
2492
+ const doc = env.document;
2493
+ const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2494
+ const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
2495
+ const targetElement = doc.getElementById(((_e = (_d = (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.sid) || ((_g = (_f = this.mpEvent) === null || _f === void 0 ? void 0 : _f.target) === null || _g === void 0 ? void 0 : _g.id) || null);
2496
+ if (element === null || (element && element === targetElement)) {
2497
+ this.cacheCurrentTarget = this.target;
2498
+ return this.target;
2499
+ }
2500
+ currentTarget.dataset = element.dataset;
2501
+ for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
2502
+ currentTarget[key] = this.mpEvent.detail[key];
2503
+ }
2504
+ this.cacheCurrentTarget = currentTarget;
2505
+ return currentTarget;
2506
+ }
2507
+ else {
2508
+ return cacheCurrentTarget;
2509
+ }
2510
+ }
2511
+ }
2512
+ function createEvent(event, node) {
2513
+ if (typeof event === 'string') {
2514
+ // For Vue3 using document.createEvent
2515
+ return new TaroEvent(event, { bubbles: true, cancelable: true });
2516
+ }
2517
+ const domEv = new TaroEvent(event.type, { bubbles: true, cancelable: true }, event);
2518
+ for (const key in event) {
2519
+ if (key === CURRENT_TARGET || key === TARGET || key === TYPE || key === TIME_STAMP) {
2520
+ continue;
2521
+ }
2522
+ else {
2523
+ domEv[key] = event[key];
2524
+ }
2525
+ }
2526
+ if (domEv.type === CONFIRM && (node === null || node === void 0 ? void 0 : node.nodeName) === INPUT) {
2527
+ // eslint-disable-next-line dot-notation
2528
+ domEv[KEY_CODE] = 13;
2529
+ }
2530
+ return domEv;
2531
+ }
2532
+ const eventsBatch = {};
2533
+ function getEventCBResult(event) {
2534
+ const result = event[EVENT_CALLBACK_RESULT];
2535
+ if (!shared.isUndefined(result)) {
2536
+ delete event[EVENT_CALLBACK_RESULT];
2537
+ }
2538
+ return result;
2539
+ }
2540
+ // 小程序的事件代理回调函数
2541
+ function eventHandler(event) {
2542
+ var _a, _b;
2543
+ // Note: ohos 上事件没有设置 type、detail 类型 setter 方法,且部分事件(例如 load 等)缺失 target 导致事件错误
2544
+ event.type === undefined && Object.defineProperty(event, 'type', {
2545
+ value: event._type // ohos only
2546
+ });
2547
+ event.detail === undefined && Object.defineProperty(event, 'detail', {
2548
+ value: event._detail || Object.assign({}, event) // ohos only
2549
+ });
2550
+ event.currentTarget = event.currentTarget || event.target || Object.assign({}, event);
2551
+ shared.hooks.call('modifyMpEventImpl', event);
2552
+ const currentTarget = event.currentTarget;
2553
+ const id = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a.sid /** sid */) || currentTarget.id /** uid */ || ((_b = event.detail) === null || _b === void 0 ? void 0 : _b.id) || '';
2554
+ const node = env.document.getElementById(id);
2555
+ if (node) {
2556
+ const dispatch = () => {
2557
+ const e = createEvent(event, node);
2558
+ shared.hooks.call('modifyTaroEvent', e, node);
2559
+ shared.hooks.call('dispatchTaroEvent', e, node);
2560
+ shared.hooks.call('dispatchTaroEventFinish', e, node);
2561
+ };
2562
+ if (shared.hooks.isExist('batchedEventUpdates')) {
2563
+ const type = event.type;
2564
+ if (!shared.hooks.call('isBubbleEvents', type) ||
2565
+ !isParentBinded(node, type) ||
2566
+ (type === TOUCHMOVE && !!node.props.catchMove)) {
2567
+ // 最上层组件统一 batchUpdate
2568
+ shared.hooks.call('batchedEventUpdates', () => {
2569
+ if (eventsBatch[type]) {
2570
+ eventsBatch[type].forEach(fn => fn());
2571
+ delete eventsBatch[type];
2572
+ }
2573
+ dispatch();
2574
+ });
2575
+ return getEventCBResult(event);
2576
+ }
2577
+ else {
2578
+ // 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
2579
+ (eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
2580
+ }
2581
+ }
2582
+ else {
2583
+ dispatch();
2584
+ return getEventCBResult(event);
2585
+ }
2586
+ }
2587
+ }
2588
+
2589
+ class FormElement extends TaroElement {
2590
+ get type() {
2591
+ var _a;
2592
+ return (_a = this.props[TYPE]) !== null && _a !== void 0 ? _a : '';
2593
+ }
2594
+ set type(val) {
2595
+ this.setAttribute(TYPE, val);
2596
+ }
2597
+ get value() {
2598
+ // eslint-disable-next-line dot-notation
2599
+ const val = this.props[VALUE];
2600
+ return val == null ? '' : val;
2601
+ }
2602
+ set value(val) {
2603
+ this.setAttribute(VALUE, val);
2604
+ }
2605
+ dispatchEvent(event) {
2606
+ if (event.mpEvent) {
2607
+ const val = event.mpEvent.detail.value;
2608
+ if (event.type === CHANGE) {
2609
+ this.props.value = val;
2610
+ }
2611
+ else if (event.type === INPUT) {
2612
+ // Web 规范中表单组件的 value 应该跟着输入改变
2613
+ // 只是改 this.props.value 的话不会进行 setData,因此这里修改 this.value。
2614
+ // 只测试了 React、Vue、Vue3 input 组件的 onInput 事件,onChange 事件不确定有没有副作用,所以暂不修改。
2615
+ this.value = val;
2616
+ }
2617
+ }
2618
+ return super.dispatchEvent(event);
2619
+ }
2620
+ }
2621
+
2622
+ class Performance {
2623
+ constructor() {
2624
+ this.recorder = new Map();
2625
+ }
2626
+ start(id) {
2627
+ if (!options.debug) {
2628
+ return;
2629
+ }
2630
+ this.recorder.set(id, Date.now());
2631
+ }
2632
+ stop(id) {
2633
+ if (!options.debug) {
2634
+ return;
2635
+ }
2636
+ const now = Date.now();
2637
+ const prev = this.recorder.get(id);
2638
+ this.recorder.delete(id);
2639
+ const time = now - prev;
2640
+ // eslint-disable-next-line no-console
2641
+ console.log(`${id} 时长: ${time}ms`);
2642
+ }
2643
+ }
2644
+ const perf = new Performance();
2645
+
2646
+ function findCustomWrapper(root, dataPathArr) {
2647
+ // ['root', 'cn', '[0]'] remove 'root' => ['cn', '[0]']
2648
+ const list = dataPathArr.slice(1);
2649
+ let currentData = root;
2650
+ let customWrapper;
2651
+ let splitedPath = '';
2652
+ list.some((item, i) => {
2653
+ const key = item
2654
+ // '[0]' => '0'
2655
+ .replace(/^\[(.+)\]$/, '$1')
2656
+ // 'cn' => 'childNodes'
2657
+ .replace(/\bcn\b/g, 'childNodes');
2658
+ currentData = currentData[key];
2659
+ if (shared.isArray(currentData)) {
2660
+ currentData = currentData.filter(el => !isComment(el));
2661
+ }
2662
+ if (shared.isUndefined(currentData))
2663
+ return true;
2664
+ if (currentData.nodeName === CUSTOM_WRAPPER) {
2665
+ const res = customWrapperCache.get(currentData.sid);
2666
+ if (res) {
2667
+ customWrapper = res;
2668
+ splitedPath = dataPathArr.slice(i + 2).join('.');
2669
+ }
2670
+ }
2671
+ });
2672
+ if (customWrapper) {
2673
+ return {
2674
+ customWrapper,
2675
+ splitedPath
2676
+ };
2677
+ }
2678
+ }
2679
+ class TaroRootElement extends TaroElement {
2680
+ constructor() {
2681
+ super();
2682
+ this.updatePayloads = [];
2683
+ this.updateCallbacks = [];
2684
+ this.pendingUpdate = false;
2685
+ this.ctx = null;
2686
+ this.nodeName = ROOT_STR;
2687
+ this.tagName = ROOT_STR.toUpperCase();
2688
+ }
2689
+ get _path() {
2690
+ return ROOT_STR;
2691
+ }
2692
+ get _root() {
2693
+ return this;
2694
+ }
2695
+ enqueueUpdate(payload) {
2696
+ this.updatePayloads.push(payload);
2697
+ if (!this.pendingUpdate && this.ctx) {
2698
+ this.performUpdate();
2699
+ }
2700
+ }
2701
+ performUpdate(initRender = false, prerender) {
2702
+ this.pendingUpdate = true;
2703
+ const ctx = shared.hooks.call('proxyToRaw', this.ctx);
2704
+ setTimeout(() => {
2705
+ const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;
2706
+ perf.start(setDataMark);
2707
+ const data = Object.create(null);
2708
+ const resetPaths = new Set(initRender
2709
+ ? ['root.cn.[0]', 'root.cn[0]']
2710
+ : []);
2711
+ while (this.updatePayloads.length > 0) {
2712
+ const { path, value } = this.updatePayloads.shift();
2713
+ if (path.endsWith("cn" /* Shortcuts.Childnodes */)) {
2714
+ resetPaths.add(path);
2715
+ }
2716
+ data[path] = value;
2717
+ }
2718
+ for (const path in data) {
2719
+ resetPaths.forEach(p => {
2720
+ // 已经重置了数组,就不需要分别再设置了
2721
+ if (path.includes(p) && path !== p) {
2722
+ delete data[path];
2723
+ }
2724
+ });
2725
+ const value = data[path];
2726
+ if (shared.isFunction(value)) {
2727
+ data[path] = value();
2728
+ }
2729
+ }
2730
+ // 预渲染
2731
+ if (shared.isFunction(prerender))
2732
+ return prerender(data);
2733
+ // 正常渲染
2734
+ this.pendingUpdate = false;
2735
+ let normalUpdate = {};
2736
+ const customWrapperMap = new Map();
2737
+ if (initRender) {
2738
+ // 初次渲染,使用页面级别的 setData
2739
+ normalUpdate = data;
2740
+ }
2741
+ else {
2742
+ // 更新渲染,区分 CustomWrapper 与页面级别的 setData
2743
+ for (const p in data) {
2744
+ const dataPathArr = p.split('.');
2745
+ const found = findCustomWrapper(this, dataPathArr);
2746
+ if (found) {
2747
+ // 此项数据使用 CustomWrapper 去更新
2748
+ const { customWrapper, splitedPath } = found;
2749
+ // 合并同一个 customWrapper 的相关更新到一次 setData 中
2750
+ customWrapperMap.set(customWrapper, Object.assign(Object.assign({}, (customWrapperMap.get(customWrapper) || {})), { [`i.${splitedPath}`]: data[p] }));
2751
+ }
2752
+ else {
2753
+ // 此项数据使用页面去更新
2754
+ normalUpdate[p] = data[p];
2755
+ }
2756
+ }
2757
+ }
2758
+ const customWrapperCount = customWrapperMap.size;
2759
+ const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;
2760
+ const updateArrLen = customWrapperCount + (isNeedNormalUpdate ? 1 : 0);
2761
+ let executeTime = 0;
2762
+ const cb = () => {
2763
+ if (++executeTime === updateArrLen) {
2764
+ perf.stop(setDataMark);
2765
+ this.flushUpdateCallback();
2766
+ initRender && perf.stop(PAGE_INIT);
2767
+ }
2768
+ };
2769
+ // custom-wrapper setData
2770
+ if (customWrapperCount) {
2771
+ customWrapperMap.forEach((data, ctx) => {
2772
+ if (process.env.NODE_ENV !== 'production' && options.debug) {
2773
+ // eslint-disable-next-line no-console
2774
+ console.log('custom wrapper setData: ', data);
2775
+ }
2776
+ ctx.setData(data, cb);
2777
+ });
2778
+ }
2779
+ // page setData
2780
+ if (isNeedNormalUpdate) {
2781
+ if (process.env.NODE_ENV !== 'production' && options.debug) {
2782
+ // eslint-disable-next-line no-console
2783
+ console.log('page setData:', normalUpdate);
2784
+ }
2785
+ ctx.setData(normalUpdate, cb);
2786
+ }
2787
+ }, 0);
2788
+ }
2789
+ enqueueUpdateCallback(cb, ctx) {
2790
+ this.updateCallbacks.push(() => {
2791
+ ctx ? cb.call(ctx) : cb();
2792
+ });
2793
+ }
2794
+ flushUpdateCallback() {
2795
+ const updateCallbacks = this.updateCallbacks;
2796
+ if (!updateCallbacks.length)
2797
+ return;
2798
+ const copies = updateCallbacks.slice(0);
2799
+ this.updateCallbacks.length = 0;
2800
+ for (let i = 0; i < copies.length; i++) {
2801
+ copies[i]();
2802
+ }
2803
+ }
2804
+ }
2805
+
2806
+ class TaroText extends TaroNode {
2807
+ constructor(value) {
2808
+ super();
2809
+ this.nodeType = 3 /* NodeType.TEXT_NODE */;
2810
+ this.nodeName = '#text';
2811
+ this._value = value;
2812
+ }
2813
+ set textContent(text) {
2814
+ MutationObserver.record({
2815
+ target: this,
2816
+ type: "characterData" /* MutationRecordType.CHARACTER_DATA */,
2817
+ oldValue: this._value
2818
+ });
2819
+ this._value = text;
2820
+ this.enqueueUpdate({
2821
+ path: `${this._path}.${"v" /* Shortcuts.Text */}`,
2822
+ value: text
2823
+ });
2824
+ }
2825
+ get textContent() {
2826
+ return this._value;
2827
+ }
2828
+ set nodeValue(text) {
2829
+ this.textContent = text;
2830
+ }
2831
+ get nodeValue() {
2832
+ return this._value;
2833
+ }
2834
+ set data(text) {
2835
+ this.textContent = text;
2836
+ }
2837
+ get data() {
2838
+ return this._value;
2839
+ }
2840
+ }
2841
+
2842
+ /******************************************************************************
2843
+ Copyright (c) Microsoft Corporation.
2844
+
2845
+ Permission to use, copy, modify, and/or distribute this software for any
2846
+ purpose with or without fee is hereby granted.
2847
+
2848
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2849
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2850
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2851
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2852
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2853
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2854
+ PERFORMANCE OF THIS SOFTWARE.
2855
+ ***************************************************************************** */
2856
+ /* global Reflect, Promise */
2857
+
2858
+
2859
+ function __classPrivateFieldGet(receiver, state, kind, f) {
2860
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2861
+ 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");
2862
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2863
+ }
2864
+
2865
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
2866
+ if (kind === "m") throw new TypeError("Private method is not writable");
2867
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2868
+ 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");
2869
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2870
+ }
2871
+
2872
+ var _dict, _a;
2873
+ const findReg = /[!'()~]|%20|%00/g;
2874
+ const plusReg = /\+/g;
2875
+ const replaceCharMap = {
2876
+ '!': '%21',
2877
+ "'": '%27',
2878
+ '(': '%28',
2879
+ ')': '%29',
2880
+ '~': '%7E',
2881
+ '%20': '+',
2882
+ '%00': '\x00',
2883
+ };
2884
+ function replacer(match) {
2885
+ return replaceCharMap[match];
2886
+ }
2887
+ function appendTo(dict, name, value) {
2888
+ const res = shared.isArray(value) ? value.join(',') : value;
2889
+ if (name in dict)
2890
+ dict[name].push(res);
2891
+ else
2892
+ dict[name] = [res];
2893
+ }
2894
+ function addEach(value, key) {
2895
+ appendTo(this, key, value);
2896
+ }
2897
+ function decode(str) {
2898
+ return decodeURIComponent(str.replace(plusReg, ' '));
2899
+ }
2900
+ function encode(str) {
2901
+ return encodeURIComponent(str).replace(findReg, replacer);
2902
+ }
2903
+ const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : (_a = class {
2904
+ constructor(query) {
2905
+ _dict.set(this, Object.create(null));
2906
+ query !== null && query !== void 0 ? query : (query = '');
2907
+ const dict = __classPrivateFieldGet(this, _dict, "f");
2908
+ if (typeof query === 'string') {
2909
+ if (query.charAt(0) === '?') {
2910
+ query = query.slice(1);
2911
+ }
2912
+ for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
2913
+ const value = pairs[i];
2914
+ const index = value.indexOf('=');
2915
+ if (index > -1) {
2916
+ appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
2917
+ }
2918
+ else if (value.length) {
2919
+ appendTo(dict, decode(value), '');
2920
+ }
2921
+ }
2922
+ }
2923
+ else {
2924
+ if (shared.isArray(query)) {
2925
+ for (let i = 0, length = query.length; i < length; i++) {
2926
+ const value = query[i];
2927
+ appendTo(dict, value[0], value[1]);
2928
+ }
2929
+ }
2930
+ else if (query.forEach) {
2931
+ query.forEach(addEach, dict);
2932
+ }
2933
+ else {
2934
+ for (const key in query) {
2935
+ appendTo(dict, key, query[key]);
2936
+ }
2937
+ }
2938
+ }
2939
+ }
2940
+ append(name, value) {
2941
+ appendTo(__classPrivateFieldGet(this, _dict, "f"), name, value);
2942
+ }
2943
+ delete(name) {
2944
+ delete __classPrivateFieldGet(this, _dict, "f")[name];
2945
+ }
2946
+ get(name) {
2947
+ const dict = __classPrivateFieldGet(this, _dict, "f");
2948
+ return name in dict ? dict[name][0] : null;
2949
+ }
2950
+ getAll(name) {
2951
+ const dict = __classPrivateFieldGet(this, _dict, "f");
2952
+ return name in dict ? dict[name].slice(0) : [];
2953
+ }
2954
+ has(name) {
2955
+ return name in __classPrivateFieldGet(this, _dict, "f");
2956
+ }
2957
+ keys() {
2958
+ return Object.keys(__classPrivateFieldGet(this, _dict, "f"));
2959
+ }
2960
+ set(name, value) {
2961
+ __classPrivateFieldGet(this, _dict, "f")[name] = ['' + value];
2962
+ }
2963
+ forEach(callback, thisArg) {
2964
+ const dict = __classPrivateFieldGet(this, _dict, "f");
2965
+ Object.getOwnPropertyNames(dict).forEach(function (name) {
2966
+ dict[name].forEach(function (value) {
2967
+ callback.call(thisArg, value, name, this);
2968
+ }, this);
2969
+ }, this);
2970
+ }
2971
+ toJSON() {
2972
+ return {};
2973
+ }
2974
+ toString() {
2975
+ const dict = __classPrivateFieldGet(this, _dict, "f");
2976
+ const query = [];
2977
+ for (const key in dict) {
2978
+ const name = encode(key);
2979
+ for (let i = 0, value = dict[key]; i < value.length; i++) {
2980
+ query.push(name + '=' + encode(value[i]));
2981
+ }
2982
+ }
2983
+ return query.join('&');
2984
+ }
2985
+ },
2986
+ _dict = new WeakMap(),
2987
+ _a);
2988
+
2989
+ var _TaroURL_hash, _TaroURL_hostname, _TaroURL_pathname, _TaroURL_port, _TaroURL_protocol, _TaroURL_search;
2990
+ class TaroURL {
2991
+ static createObjectURL() {
2992
+ throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
2993
+ }
2994
+ static revokeObjectURL() {
2995
+ throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
2996
+ }
2997
+ constructor(url, base) {
2998
+ /* private property */
2999
+ _TaroURL_hash.set(this, '');
3000
+ _TaroURL_hostname.set(this, '');
3001
+ _TaroURL_pathname.set(this, '');
3002
+ _TaroURL_port.set(this, '');
3003
+ _TaroURL_protocol.set(this, '');
3004
+ _TaroURL_search.set(this, void 0);
3005
+ if (!shared.isString(url))
3006
+ url = String(url);
3007
+ const parseResult = parseUrlBase(url, base);
3008
+ const { hash, hostname, pathname, port, protocol, search } = parseResult;
3009
+ __classPrivateFieldSet(this, _TaroURL_hash, hash, "f");
3010
+ __classPrivateFieldSet(this, _TaroURL_hostname, hostname, "f");
3011
+ __classPrivateFieldSet(this, _TaroURL_pathname, pathname || '/', "f");
3012
+ __classPrivateFieldSet(this, _TaroURL_port, port, "f");
3013
+ __classPrivateFieldSet(this, _TaroURL_protocol, protocol, "f");
3014
+ __classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(search), "f");
3015
+ }
3016
+ /* public property */
3017
+ get protocol() {
3018
+ return __classPrivateFieldGet(this, _TaroURL_protocol, "f");
3019
+ }
3020
+ set protocol(val) {
3021
+ shared.isString(val) && (__classPrivateFieldSet(this, _TaroURL_protocol, val.trim(), "f"));
3022
+ }
3023
+ get host() {
3024
+ return this.hostname + (this.port ? ':' + this.port : '');
3025
+ }
3026
+ set host(val) {
3027
+ if (val && shared.isString(val)) {
3028
+ val = val.trim();
3029
+ const { hostname, port } = parseUrl(`//${val}`);
3030
+ this.hostname = hostname;
3031
+ this.port = port;
3032
+ }
3033
+ }
3034
+ get hostname() {
3035
+ return __classPrivateFieldGet(this, _TaroURL_hostname, "f");
3036
+ }
3037
+ set hostname(val) {
3038
+ val && shared.isString(val) && (__classPrivateFieldSet(this, _TaroURL_hostname, val.trim(), "f"));
3039
+ }
3040
+ get port() {
3041
+ return __classPrivateFieldGet(this, _TaroURL_port, "f");
3042
+ }
3043
+ set port(val) {
3044
+ shared.isString(val) && (__classPrivateFieldSet(this, _TaroURL_port, val.trim(), "f"));
3045
+ }
3046
+ get pathname() {
3047
+ return __classPrivateFieldGet(this, _TaroURL_pathname, "f");
3048
+ }
3049
+ set pathname(val) {
3050
+ if (shared.isString(val)) {
3051
+ val = val.trim();
3052
+ const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
3053
+ let temp = val;
3054
+ while (HEAD_REG.test(temp)) {
3055
+ temp = temp.replace(HEAD_REG, '');
3056
+ }
3057
+ if (temp)
3058
+ __classPrivateFieldSet(this, _TaroURL_pathname, '/' + temp, "f");
3059
+ else
3060
+ __classPrivateFieldSet(this, _TaroURL_pathname, '/', "f");
3061
+ }
3062
+ }
3063
+ get search() {
3064
+ const val = __classPrivateFieldGet(this, _TaroURL_search, "f").toString();
3065
+ return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`;
3066
+ }
3067
+ set search(val) {
3068
+ if (shared.isString(val)) {
3069
+ val = val.trim();
3070
+ __classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(val), "f");
3071
+ }
3072
+ }
3073
+ get hash() {
3074
+ return __classPrivateFieldGet(this, _TaroURL_hash, "f");
3075
+ }
3076
+ set hash(val) {
3077
+ if (shared.isString(val)) {
3078
+ val = val.trim();
3079
+ if (val)
3080
+ __classPrivateFieldSet(this, _TaroURL_hash, val.startsWith('#') ? val : `#${val}`, "f");
3081
+ else
3082
+ __classPrivateFieldSet(this, _TaroURL_hash, '', "f");
3083
+ }
3084
+ }
3085
+ get href() {
3086
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
3087
+ }
3088
+ set href(val) {
3089
+ if (val && shared.isString(val)) {
3090
+ val = val.trim();
3091
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
3092
+ this.protocol = protocol;
3093
+ this.hostname = hostname;
3094
+ this.pathname = pathname;
3095
+ this.port = port;
3096
+ this.hash = hash;
3097
+ this.search = search;
3098
+ }
3099
+ }
3100
+ get origin() {
3101
+ return `${this.protocol}//${this.host}`;
3102
+ }
3103
+ set origin(val) {
3104
+ if (val && shared.isString(val)) {
3105
+ val = val.trim();
3106
+ const { protocol, hostname, port } = parseUrl(val);
3107
+ this.protocol = protocol;
3108
+ this.hostname = hostname;
3109
+ this.port = port;
3110
+ }
3111
+ }
3112
+ get searchParams() {
3113
+ return __classPrivateFieldGet(this, _TaroURL_search, "f");
3114
+ }
3115
+ // public method
3116
+ toString() {
3117
+ return this.href;
3118
+ }
3119
+ toJSON() {
3120
+ return this.toString();
3121
+ }
3122
+ // convenient for deconstructor
3123
+ _toRaw() {
3124
+ return {
3125
+ protocol: this.protocol,
3126
+ port: this.port,
3127
+ host: this.host,
3128
+ hostname: this.hostname,
3129
+ pathname: this.pathname,
3130
+ hash: this.hash,
3131
+ search: this.search,
3132
+ origin: this.origin,
3133
+ href: this.href,
3134
+ };
3135
+ }
3136
+ }
3137
+ _TaroURL_hash = new WeakMap(), _TaroURL_hostname = new WeakMap(), _TaroURL_pathname = new WeakMap(), _TaroURL_port = new WeakMap(), _TaroURL_protocol = new WeakMap(), _TaroURL_search = new WeakMap();
3138
+ const URL = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL;
3139
+ function parseUrl(url = '') {
3140
+ const result = {
3141
+ href: '',
3142
+ origin: '',
3143
+ protocol: '',
3144
+ hostname: '',
3145
+ host: '',
3146
+ port: '',
3147
+ pathname: '',
3148
+ search: '',
3149
+ hash: ''
3150
+ };
3151
+ if (!url || !shared.isString(url))
3152
+ return result;
3153
+ url = url.trim();
3154
+ const PATTERN = /^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/;
3155
+ const matches = url.match(PATTERN);
3156
+ if (!matches)
3157
+ return result;
3158
+ // TODO: username & password ?
3159
+ result.protocol = matches[1] || 'https:';
3160
+ result.hostname = matches[6] || 'taro.com';
3161
+ result.port = matches[8] || '';
3162
+ result.pathname = matches[9] || '/';
3163
+ result.search = matches[10] || '';
3164
+ result.hash = matches[12] || '';
3165
+ result.href = url;
3166
+ result.origin = result.protocol + '//' + result.hostname;
3167
+ result.host = result.hostname + (result.port ? `:${result.port}` : '');
3168
+ return result;
3169
+ }
3170
+ function parseUrlBase(url, base) {
3171
+ const VALID_URL = /^(https?:)\/\//i;
3172
+ let fullUrl = '';
3173
+ let parsedBase = null;
3174
+ if (!shared.isUndefined(base)) {
3175
+ base = String(base).trim();
3176
+ if (!VALID_URL.test(base))
3177
+ throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
3178
+ parsedBase = parseUrl(base);
3179
+ }
3180
+ url = String(url).trim();
3181
+ if (VALID_URL.test(url)) {
3182
+ fullUrl = url;
3183
+ }
3184
+ else if (parsedBase) {
3185
+ if (url) {
3186
+ if (url.startsWith('//')) {
3187
+ fullUrl = parsedBase.protocol + url;
3188
+ }
3189
+ else {
3190
+ fullUrl = parsedBase.origin + (url.startsWith('/') ? url : `/${url}`);
3191
+ }
3192
+ }
3193
+ else {
3194
+ fullUrl = parsedBase.href;
3195
+ }
3196
+ }
3197
+ else {
3198
+ throw new TypeError(`Failed to construct 'URL': Invalid URL`);
3199
+ }
3200
+ return parseUrl(fullUrl);
3201
+ }
3202
+
3203
+ class AnchorElement extends TaroElement {
3204
+ get href() {
3205
+ var _a;
3206
+ return (_a = this.props["href" /* AnchorElementAttrs.HREF */]) !== null && _a !== void 0 ? _a : '';
3207
+ }
3208
+ set href(val) {
3209
+ this.setAttribute("href" /* AnchorElementAttrs.HREF */, val);
3210
+ }
3211
+ get protocol() {
3212
+ var _a;
3213
+ return (_a = this.props["protocol" /* AnchorElementAttrs.PROTOCOL */]) !== null && _a !== void 0 ? _a : '';
3214
+ }
3215
+ get host() {
3216
+ var _a;
3217
+ return (_a = this.props["host" /* AnchorElementAttrs.HOST */]) !== null && _a !== void 0 ? _a : '';
3218
+ }
3219
+ get search() {
3220
+ var _a;
3221
+ return (_a = this.props["search" /* AnchorElementAttrs.SEARCH */]) !== null && _a !== void 0 ? _a : '';
3222
+ }
3223
+ get hash() {
3224
+ var _a;
3225
+ return (_a = this.props["hash" /* AnchorElementAttrs.HASH */]) !== null && _a !== void 0 ? _a : '';
3226
+ }
3227
+ get hostname() {
3228
+ var _a;
3229
+ return (_a = this.props["hostname" /* AnchorElementAttrs.HOSTNAME */]) !== null && _a !== void 0 ? _a : '';
3230
+ }
3231
+ get port() {
3232
+ var _a;
3233
+ return (_a = this.props["port" /* AnchorElementAttrs.PORT */]) !== null && _a !== void 0 ? _a : '';
3234
+ }
3235
+ get pathname() {
3236
+ var _a;
3237
+ return (_a = this.props["pathname" /* AnchorElementAttrs.PATHNAME */]) !== null && _a !== void 0 ? _a : '';
3238
+ }
3239
+ setAttribute(qualifiedName, value) {
3240
+ if (qualifiedName === "href" /* AnchorElementAttrs.HREF */) {
3241
+ const willSetAttr = parseUrl(value);
3242
+ for (const k in willSetAttr) {
3243
+ super.setAttribute(k, willSetAttr[k]);
3244
+ }
3245
+ }
3246
+ else {
3247
+ super.setAttribute(qualifiedName, value);
3248
+ }
3249
+ }
3250
+ }
3251
+
3252
+ class TransferElement extends TaroElement {
3253
+ constructor(dataName) {
3254
+ super();
3255
+ this.dataName = dataName;
3256
+ this.isTransferElement = true;
3257
+ }
3258
+ get _path() {
3259
+ return this.dataName;
3260
+ }
3261
+ }
3262
+
3263
+ class TaroDocument extends TaroElement {
3264
+ constructor() {
3265
+ super();
3266
+ this.createEvent = createEvent;
3267
+ this.nodeType = 9 /* NodeType.DOCUMENT_NODE */;
3268
+ this.nodeName = DOCUMENT_ELEMENT_NAME;
3269
+ }
3270
+ createElement(type) {
3271
+ const nodeName = type.toLowerCase();
3272
+ let element;
3273
+ switch (true) {
3274
+ case nodeName === ROOT_STR:
3275
+ element = new TaroRootElement();
3276
+ return element;
3277
+ case shared.controlledComponent.has(nodeName):
3278
+ element = new FormElement();
3279
+ break;
3280
+ case nodeName === A:
3281
+ element = new AnchorElement();
3282
+ break;
3283
+ case nodeName === 'page-meta':
3284
+ case nodeName === 'navigation-bar':
3285
+ element = new TransferElement(shared.toCamelCase(nodeName));
3286
+ break;
3287
+ default:
3288
+ element = new TaroElement();
3289
+ break;
3290
+ }
3291
+ element.nodeName = nodeName;
3292
+ element.tagName = type.toUpperCase();
3293
+ return element;
3294
+ }
3295
+ // an ugly fake createElementNS to deal with @vue/runtime-dom's
3296
+ // support mounting app to svg container since vue@3.0.8
3297
+ createElementNS(_svgNS, type) {
3298
+ return this.createElement(type);
3299
+ }
3300
+ createTextNode(text) {
3301
+ return new TaroText(text);
3302
+ }
3303
+ getElementById(id) {
3304
+ const el = eventSource.get(id);
3305
+ return shared.isUndefined(el) ? null : el;
3306
+ }
3307
+ querySelector(query) {
3308
+ // 为了 Vue3 的乞丐版实现
3309
+ if (/^#/.test(query)) {
3310
+ return this.getElementById(query.slice(1));
3311
+ }
3312
+ return null;
3313
+ }
3314
+ querySelectorAll() {
3315
+ // fake hack
3316
+ return [];
3317
+ }
3318
+ // @TODO: @PERF: 在 hydrate 移除掉空的 node
3319
+ createComment() {
3320
+ const textnode = new TaroText('');
3321
+ textnode.nodeName = COMMENT;
3322
+ return textnode;
3323
+ }
3324
+ get defaultView() {
3325
+ return env.window;
3326
+ }
3327
+ }
3328
+
3329
+ function createDocument() {
3330
+ /**
3331
+ * <document>
3332
+ * <html>
3333
+ * <head></head>
3334
+ * <body>
3335
+ * <container>
3336
+ * <app id="app" />
3337
+ * </container>
3338
+ * </body>
3339
+ * </html>
3340
+ * </document>
3341
+ */
3342
+ const doc = new TaroDocument();
3343
+ const documentCreateElement = doc.createElement.bind(doc);
3344
+ const html = documentCreateElement(HTML);
3345
+ const head = documentCreateElement(HEAD);
3346
+ const body = documentCreateElement(BODY);
3347
+ const app = documentCreateElement(APP);
3348
+ app.id = APP;
3349
+ const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
3350
+ doc.appendChild(html);
3351
+ html.appendChild(head);
3352
+ html.appendChild(body);
3353
+ body.appendChild(container);
3354
+ container.appendChild(app);
3355
+ doc.documentElement = html;
3356
+ doc.head = head;
3357
+ doc.body = body;
3358
+ return doc;
3359
+ }
3360
+ const document$1 = process.env.TARO_PLATFORM === 'web' ? env.document : createDocument();
3361
+
3362
+ const getComputedStyle = process.env.TARO_PLATFORM === 'web' ? env.window.getComputedStyle : function (element) {
3363
+ return element.style;
3364
+ };
3365
+
3366
+ const eventCenter = shared.hooks.call('getEventCenter', shared.Events);
3367
+
3368
+ /**
3369
+ * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
3370
+ */
3371
+ class RuntimeCache {
3372
+ constructor(name) {
3373
+ this.cache = new Map();
3374
+ this.name = name;
3375
+ }
3376
+ has(identifier) {
3377
+ return this.cache.has(identifier);
3378
+ }
3379
+ set(identifier, ctx) {
3380
+ if (identifier && ctx) {
3381
+ this.cache.set(identifier, ctx);
3382
+ }
3383
+ }
3384
+ get(identifier) {
3385
+ if (this.has(identifier))
3386
+ return this.cache.get(identifier);
3387
+ }
3388
+ delete(identifier) {
3389
+ this.cache.delete(identifier);
3390
+ }
3391
+ }
3392
+
3393
+ var _TaroHistory_instances, _TaroHistory_location, _TaroHistory_stack, _TaroHistory_cur, _TaroHistory_window, _TaroHistory_reset;
3394
+ const cache$1 = new RuntimeCache('history');
3395
+ class TaroHistory extends shared.Events {
3396
+ constructor(location, options) {
3397
+ super();
3398
+ _TaroHistory_instances.add(this);
3399
+ /* private property */
3400
+ _TaroHistory_location.set(this, void 0);
3401
+ _TaroHistory_stack.set(this, []);
3402
+ _TaroHistory_cur.set(this, 0);
3403
+ _TaroHistory_window.set(this, void 0);
3404
+ __classPrivateFieldSet(this, _TaroHistory_window, options.window, "f");
3405
+ __classPrivateFieldSet(this, _TaroHistory_location, location, "f");
3406
+ __classPrivateFieldGet(this, _TaroHistory_location, "f").on('__record_history__', (href) => {
3407
+ var _a;
3408
+ __classPrivateFieldSet(this, _TaroHistory_cur, (_a = __classPrivateFieldGet(this, _TaroHistory_cur, "f"), _a++, _a), "f");
3409
+ __classPrivateFieldSet(this, _TaroHistory_stack, __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, __classPrivateFieldGet(this, _TaroHistory_cur, "f")), "f");
3410
+ __classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
3411
+ state: null,
3412
+ title: '',
3413
+ url: href
3414
+ });
3415
+ }, null);
3416
+ __classPrivateFieldGet(this, _TaroHistory_location, "f").on('__reset_history__', (href) => {
3417
+ __classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this, href);
3418
+ }, null);
3419
+ // 切换上下文行为
3420
+ this.on(exports.CONTEXT_ACTIONS.INIT, () => {
3421
+ __classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
3422
+ }, null);
3423
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
3424
+ cache$1.set(pageId, {
3425
+ location: __classPrivateFieldGet(this, _TaroHistory_location, "f"),
3426
+ stack: __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(),
3427
+ cur: __classPrivateFieldGet(this, _TaroHistory_cur, "f")
3428
+ });
3429
+ }, null);
3430
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
3431
+ if (cache$1.has(pageId)) {
3432
+ const ctx = cache$1.get(pageId);
3433
+ __classPrivateFieldSet(this, _TaroHistory_location, ctx.location, "f");
3434
+ __classPrivateFieldSet(this, _TaroHistory_stack, ctx.stack, "f");
3435
+ __classPrivateFieldSet(this, _TaroHistory_cur, ctx.cur, "f");
3436
+ }
3437
+ }, null);
3438
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
3439
+ cache$1.delete(pageId);
3440
+ }, null);
3441
+ __classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
3442
+ }
3443
+ /* public property */
3444
+ get length() {
3445
+ return __classPrivateFieldGet(this, _TaroHistory_stack, "f").length;
3446
+ }
3447
+ get state() {
3448
+ return __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")].state;
3449
+ }
3450
+ /* public method */
3451
+ go(delta) {
3452
+ if (!shared.isNumber(delta) || isNaN(delta))
3453
+ return;
3454
+ let targetIdx = __classPrivateFieldGet(this, _TaroHistory_cur, "f") + delta;
3455
+ targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
3456
+ __classPrivateFieldSet(this, _TaroHistory_cur, targetIdx, "f");
3457
+ __classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")].url);
3458
+ __classPrivateFieldGet(this, _TaroHistory_window, "f").trigger('popstate', __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")]);
3459
+ }
3460
+ back() {
3461
+ this.go(-1);
3462
+ }
3463
+ forward() {
3464
+ this.go(1);
3465
+ }
3466
+ pushState(state, title, url) {
3467
+ if (!url || !shared.isString(url))
3468
+ return;
3469
+ __classPrivateFieldSet(this, _TaroHistory_stack, __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, __classPrivateFieldGet(this, _TaroHistory_cur, "f") + 1), "f");
3470
+ __classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
3471
+ state,
3472
+ title,
3473
+ url
3474
+ });
3475
+ __classPrivateFieldSet(this, _TaroHistory_cur, this.length - 1, "f");
3476
+ __classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
3477
+ }
3478
+ replaceState(state, title, url) {
3479
+ if (!url || !shared.isString(url))
3480
+ return;
3481
+ __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")] = {
3482
+ state,
3483
+ title,
3484
+ url
3485
+ };
3486
+ __classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
3487
+ }
3488
+ // For debug
3489
+ get cache() {
3490
+ return cache$1;
3491
+ }
3492
+ }
3493
+ _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 = '') {
3494
+ __classPrivateFieldSet(this, _TaroHistory_stack, [
3495
+ {
3496
+ state: null,
3497
+ title: '',
3498
+ url: href || __classPrivateFieldGet(this, _TaroHistory_location, "f").href
3499
+ }
3500
+ ], "f");
3501
+ __classPrivateFieldSet(this, _TaroHistory_cur, 0, "f");
3502
+ };
3503
+ const History = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory;
3504
+
3505
+ const Current = {
3506
+ app: null,
3507
+ router: null,
3508
+ page: null
3509
+ };
3510
+ const getCurrentInstance = () => Current;
3511
+
3512
+ var _TaroLocation_instances, _TaroLocation_url, _TaroLocation_noCheckUrl, _TaroLocation_window, _TaroLocation_reset, _TaroLocation_getPreValue, _TaroLocation_rollBack, _TaroLocation_recordHistory, _TaroLocation_checkUrlChange;
3513
+ const INIT_URL = 'https://taro.com';
3514
+ const cache = new RuntimeCache('location');
3515
+ class TaroLocation extends shared.Events {
3516
+ constructor(options) {
3517
+ super();
3518
+ _TaroLocation_instances.add(this);
3519
+ /* private property */
3520
+ _TaroLocation_url.set(this, new URL(INIT_URL));
3521
+ _TaroLocation_noCheckUrl.set(this, false);
3522
+ _TaroLocation_window.set(this, void 0);
3523
+ __classPrivateFieldSet(this, _TaroLocation_window, options.window, "f");
3524
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
3525
+ this.on('__set_href_without_history__', (href) => {
3526
+ __classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
3527
+ const lastHash = __classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
3528
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").href = generateFullUrl(href);
3529
+ if (lastHash !== __classPrivateFieldGet(this, _TaroLocation_url, "f").hash) {
3530
+ __classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
3531
+ }
3532
+ __classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
3533
+ }, null);
3534
+ // 切换上下文行为
3535
+ this.on(exports.CONTEXT_ACTIONS.INIT, () => {
3536
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
3537
+ }, null);
3538
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
3539
+ cache.set(pageId, {
3540
+ lastHref: this.href,
3541
+ });
3542
+ }, null);
3543
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
3544
+ // 数据恢复时,不需要执行跳转
3545
+ if (cache.has(pageId)) {
3546
+ const ctx = cache.get(pageId);
3547
+ __classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
3548
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").href = ctx.lastHref;
3549
+ __classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
3550
+ }
3551
+ }, null);
3552
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
3553
+ cache.delete(pageId);
3554
+ }, null);
3555
+ }
3556
+ /* public property */
3557
+ get protocol() {
3558
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").protocol;
3559
+ }
3560
+ set protocol(val) {
3561
+ const REG = /^(http|https):$/i;
3562
+ if (!val || !shared.isString(val) || !REG.test(val.trim()))
3563
+ return;
3564
+ val = val.trim();
3565
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3566
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").protocol = val;
3567
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3568
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3569
+ }
3570
+ get host() {
3571
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").host;
3572
+ }
3573
+ set host(val) {
3574
+ if (!val || !shared.isString(val))
3575
+ return;
3576
+ val = val.trim();
3577
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3578
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").host = val;
3579
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3580
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3581
+ }
3582
+ get hostname() {
3583
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").hostname;
3584
+ }
3585
+ set hostname(val) {
3586
+ if (!val || !shared.isString(val))
3587
+ return;
3588
+ val = val.trim();
3589
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3590
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").hostname = val;
3591
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3592
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3593
+ }
3594
+ get port() {
3595
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").port;
3596
+ }
3597
+ set port(val) {
3598
+ const xVal = Number((val = val.trim()));
3599
+ if (!shared.isNumber(xVal) || xVal <= 0)
3600
+ return;
3601
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3602
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").port = val;
3603
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3604
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3605
+ }
3606
+ get pathname() {
3607
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").pathname;
3608
+ }
3609
+ set pathname(val) {
3610
+ if (!val || !shared.isString(val))
3611
+ return;
3612
+ val = val.trim();
3613
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3614
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").pathname = val;
3615
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3616
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3617
+ }
3618
+ get search() {
3619
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").search;
3620
+ }
3621
+ set search(val) {
3622
+ if (!val || !shared.isString(val))
3623
+ return;
3624
+ val = val.trim();
3625
+ val = val.startsWith('?') ? val : `?${val}`;
3626
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3627
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").search = val;
3628
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3629
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3630
+ }
3631
+ get hash() {
3632
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
3633
+ }
3634
+ // 小程序的navigateTo存在截断hash字符串的问题
3635
+ set hash(val) {
3636
+ if (!val || !shared.isString(val))
3637
+ return;
3638
+ val = val.trim();
3639
+ val = val.startsWith('#') ? val : `#${val}`;
3640
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3641
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").hash = val;
3642
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3643
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3644
+ }
3645
+ get href() {
3646
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").href;
3647
+ }
3648
+ set href(val) {
3649
+ const REG = /^(http:|https:)?\/\/.+/;
3650
+ if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
3651
+ return;
3652
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3653
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").href = val;
3654
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3655
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3656
+ }
3657
+ get origin() {
3658
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f").origin;
3659
+ }
3660
+ set origin(val) {
3661
+ const REG = /^(http:|https:)?\/\/.+/;
3662
+ if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
3663
+ return;
3664
+ const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
3665
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").origin = val;
3666
+ if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
3667
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
3668
+ }
3669
+ /* public method */
3670
+ assign() {
3671
+ shared.warn(true, '小程序环境中调用location.assign()无效.');
3672
+ }
3673
+ reload() {
3674
+ shared.warn(true, '小程序环境中调用location.reload()无效.');
3675
+ }
3676
+ replace(url) {
3677
+ this.trigger('__set_href_without_history__', url);
3678
+ }
3679
+ toString() {
3680
+ return this.href;
3681
+ }
3682
+ // For debug
3683
+ get cache() {
3684
+ return cache;
3685
+ }
3686
+ }
3687
+ _TaroLocation_url = new WeakMap(), _TaroLocation_noCheckUrl = new WeakMap(), _TaroLocation_window = new WeakMap(), _TaroLocation_instances = new WeakSet(), _TaroLocation_reset = function _TaroLocation_reset() {
3688
+ const Current = getCurrentInstance();
3689
+ const router = Current.router;
3690
+ if (router) {
3691
+ const { path, params } = router;
3692
+ const searchArr = Object.keys(params).map((key) => {
3693
+ return `${key}=${params[key]}`;
3694
+ });
3695
+ const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
3696
+ const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
3697
+ __classPrivateFieldSet(this, _TaroLocation_url, new URL(url), "f");
3698
+ this.trigger('__reset_history__', this.href);
3699
+ }
3700
+ }, _TaroLocation_getPreValue = function _TaroLocation_getPreValue() {
3701
+ return __classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
3702
+ }, _TaroLocation_rollBack = function _TaroLocation_rollBack(href) {
3703
+ __classPrivateFieldGet(this, _TaroLocation_url, "f").href = href;
3704
+ }, _TaroLocation_recordHistory = function _TaroLocation_recordHistory() {
3705
+ this.trigger('__record_history__', this.href);
3706
+ }, _TaroLocation_checkUrlChange = function _TaroLocation_checkUrlChange(preValue) {
3707
+ if (__classPrivateFieldGet(this, _TaroLocation_noCheckUrl, "f")) {
3708
+ return false;
3709
+ }
3710
+ const { protocol, hostname, port, pathname, search, hash } = __classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
3711
+ // 跨域三要素不允许修改
3712
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
3713
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
3714
+ return false;
3715
+ }
3716
+ // pathname
3717
+ if (pathname !== preValue.pathname) {
3718
+ return true;
3719
+ }
3720
+ // search
3721
+ if (search !== preValue.search) {
3722
+ return true;
3723
+ }
3724
+ // hashchange
3725
+ if (hash !== preValue.hash) {
3726
+ __classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
3727
+ return true;
3728
+ }
3729
+ __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
3730
+ return false;
3731
+ };
3732
+ const Location = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation;
3733
+ function generateFullUrl(val = '') {
3734
+ const origin = INIT_URL;
3735
+ if (/^[/?#]/.test(val)) {
3736
+ return origin + val;
3737
+ }
3738
+ return val;
3739
+ }
3740
+
3741
+ const machine = 'Macintosh';
3742
+ const arch = 'Intel Mac OS X 10_14_5';
3743
+ const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
3744
+ const msg = '(' + machine + '; ' + arch + ') ' + engine;
3745
+ const nav = process.env.TARO_PLATFORM === 'web' ? env.window.navigator : {
3746
+ appCodeName: 'Mozilla',
3747
+ appName: 'Netscape',
3748
+ appVersion: '5.0 ' + msg,
3749
+ cookieEnabled: true,
3750
+ mimeTypes: [],
3751
+ onLine: true,
3752
+ platform: 'MacIntel',
3753
+ plugins: [],
3754
+ product: 'Taro',
3755
+ productSub: '20030107',
3756
+ userAgent: 'Mozilla/5.0 ' + msg,
3757
+ vendor: 'Joyent',
3758
+ vendorSub: ''
3759
+ };
3760
+
3761
+ // https://github.com/myrne/performance-now
3762
+ exports.now = void 0;
3763
+ (function () {
3764
+ let loadTime;
3765
+ if ((typeof performance !== 'undefined' && performance !== null) && performance.now) {
3766
+ exports.now = () => performance.now();
3767
+ }
3768
+ else if (Date.now) {
3769
+ loadTime = Date.now();
3770
+ exports.now = () => Date.now() - loadTime;
3771
+ }
3772
+ else {
3773
+ loadTime = new Date().getTime();
3774
+ exports.now = () => new Date().getTime() - loadTime;
3775
+ }
3776
+ })();
3777
+ let lastTime = 0;
3778
+ // https://gist.github.com/paulirish/1579671
3779
+ // https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
3780
+ const _raf = typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame !== null ? requestAnimationFrame : function (callback) {
3781
+ const _now = exports.now();
3782
+ const nextTime = Math.max(lastTime + 16, _now); // First time will execute it immediately but barely noticeable and performance is gained.
3783
+ return setTimeout(function () { callback(lastTime = nextTime); }, nextTime - _now);
3784
+ };
3785
+ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame !== null
3786
+ ? cancelAnimationFrame
3787
+ : function (seed) {
3788
+ // fix https://github.com/NervJS/taro/issues/7749
3789
+ clearTimeout(seed);
3790
+ };
3791
+
3792
+ class TaroWindow extends shared.Events {
3793
+ constructor() {
3794
+ super();
3795
+ this.navigator = nav;
3796
+ this.requestAnimationFrame = _raf;
3797
+ this.cancelAnimationFrame = _caf;
3798
+ this.getComputedStyle = getComputedStyle;
3799
+ const globalProperties = [
3800
+ ...Object.getOwnPropertyNames(global || {}),
3801
+ ...Object.getOwnPropertySymbols(global || {})
3802
+ ];
3803
+ globalProperties.forEach(property => {
3804
+ if (property === 'atob' || property === 'document')
3805
+ return;
3806
+ if (!Object.prototype.hasOwnProperty.call(this, property)) {
3807
+ // 防止小程序环境下,window 上的某些 get 属性在赋值时报错
3808
+ try {
3809
+ this[property] = global[property];
3810
+ }
3811
+ catch (e) {
3812
+ if (process.env.NODE_ENV !== 'production') {
3813
+ console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
3814
+ }
3815
+ }
3816
+ }
3817
+ });
3818
+ this.Date || (this.Date = Date);
3819
+ // 应用启动时,提供给需要读取历史信息的库使用
3820
+ this.location = new Location({ window: this });
3821
+ // @ts-ignore
3822
+ this.history = new History(this.location, { window: this });
3823
+ this.initEvent();
3824
+ }
3825
+ initEvent() {
3826
+ const _location = this.location;
3827
+ const _history = this.history;
3828
+ this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
3829
+ // 页面onload,为该页面建立新的上下文信息
3830
+ _location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
3831
+ }, null);
3832
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
3833
+ // 页面onshow,恢复当前页面的上下文信息
3834
+ _location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
3835
+ _history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
3836
+ }, null);
3837
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
3838
+ // 页面onhide,缓存当前页面的上下文信息
3839
+ _location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
3840
+ _history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
3841
+ }, null);
3842
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
3843
+ // 页面onunload,清除当前页面的上下文信息
3844
+ _location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
3845
+ _history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
3846
+ }, null);
3847
+ }
3848
+ get document() {
3849
+ return env.document;
3850
+ }
3851
+ addEventListener(event, callback) {
3852
+ if (!shared.isString(event))
3853
+ return;
3854
+ this.on(event, callback, null);
3855
+ }
3856
+ removeEventListener(event, callback) {
3857
+ if (!shared.isString(event))
3858
+ return;
3859
+ this.off(event, callback, null);
3860
+ }
3861
+ setTimeout(...args) {
3862
+ return setTimeout(...args);
3863
+ }
3864
+ clearTimeout(...args) {
3865
+ return clearTimeout(...args);
3866
+ }
3867
+ }
3868
+ const window$1 = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window || new TaroWindow());
3869
+ const location = window$1.location;
3870
+ const history = window$1.history;
3871
+
3872
+ // for Vue3
3873
+ class SVGElement extends TaroElement {
3874
+ }
3875
+
3876
+ /* eslint-disable dot-notation */
3877
+ const instances = new Map();
3878
+ const pageId = incrementId();
3879
+ function injectPageInstance(inst, id) {
3880
+ shared.hooks.call('mergePageInstance', instances.get(id), inst);
3881
+ instances.set(id, inst);
3882
+ }
3883
+ function getPageInstance(id) {
3884
+ return instances.get(id);
3885
+ }
3886
+ function removePageInstance(id) {
3887
+ instances.delete(id);
3888
+ }
3889
+ function addLeadingSlash(path) {
3890
+ if (path == null) {
3891
+ return '';
3892
+ }
3893
+ return path.charAt(0) === '/' ? path : '/' + path;
3894
+ }
3895
+ function safeExecute(path, lifecycle, ...args) {
3896
+ const instance = instances.get(path);
3897
+ if (instance == null) {
3898
+ return;
3899
+ }
3900
+ const func = shared.hooks.call('getLifecycle', instance, lifecycle);
3901
+ if (shared.isArray(func)) {
3902
+ const res = func.map(fn => fn.apply(instance, args));
3903
+ return res[0];
3904
+ }
3905
+ if (!shared.isFunction(func)) {
3906
+ return;
3907
+ }
3908
+ return func.apply(instance, args);
3909
+ }
3910
+ function stringify(obj) {
3911
+ if (obj == null) {
3912
+ return '';
3913
+ }
3914
+ const path = Object.keys(obj).map((key) => {
3915
+ return key + '=' + obj[key];
3916
+ }).join('&');
3917
+ return path === '' ? path : '?' + path;
3918
+ }
3919
+ function getPath(id, options) {
3920
+ const idx = id.indexOf('?');
3921
+ if (process.env.TARO_PLATFORM === 'web') {
3922
+ return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
3923
+ }
3924
+ else {
3925
+ return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
3926
+ }
3927
+ }
3928
+ function getOnReadyEventKey(path) {
3929
+ return path + '.' + ON_READY;
3930
+ }
3931
+ function getOnShowEventKey(path) {
3932
+ return path + '.' + ON_SHOW;
3933
+ }
3934
+ function getOnHideEventKey(path) {
3935
+ return path + '.' + ON_HIDE;
3936
+ }
3937
+ function createPageConfig(component, pageName, data, pageConfig) {
3938
+ // 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
3939
+ const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
3940
+ const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES,] = shared.hooks.call('getMiniLifecycleImpl').page;
3941
+ let pageElement = null;
3942
+ let unmounting = false;
3943
+ let prepareMountList = [];
3944
+ function setCurrentRouter(page) {
3945
+ const router = process.env.TARO_PLATFORM === 'web' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
3946
+ Current.router = {
3947
+ params: page.$taroParams,
3948
+ path: addLeadingSlash(router),
3949
+ $taroPath: page.$taroPath,
3950
+ onReady: getOnReadyEventKey(id),
3951
+ onShow: getOnShowEventKey(id),
3952
+ onHide: getOnHideEventKey(id)
3953
+ };
3954
+ if (!shared.isUndefined(page.exitState)) {
3955
+ Current.router.exitState = page.exitState;
3956
+ }
3957
+ }
3958
+ let loadResolver;
3959
+ let hasLoaded;
3960
+ const config = {
3961
+ [ONLOAD](options = {}, cb) {
3962
+ hasLoaded = new Promise(resolve => { loadResolver = resolve; });
3963
+ perf.start(PAGE_INIT);
3964
+ Current.page = this;
3965
+ this.config = pageConfig || {};
3966
+ // this.$taroPath 是页面唯一标识
3967
+ const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
3968
+ const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
3969
+ if (process.env.TARO_PLATFORM === 'web') {
3970
+ config.path = $taroPath;
3971
+ }
3972
+ // this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
3973
+ if (this.$taroParams == null) {
3974
+ this.$taroParams = uniqueOptions;
3975
+ }
3976
+ setCurrentRouter(this);
3977
+ // 初始化当前页面的上下文信息
3978
+ if (process.env.TARO_PLATFORM !== 'web') {
3979
+ window$1.trigger(exports.CONTEXT_ACTIONS.INIT, $taroPath);
3980
+ }
3981
+ const mount = () => {
3982
+ Current.app.mount(component, $taroPath, () => {
3983
+ pageElement = env.document.getElementById($taroPath);
3984
+ shared.ensure(pageElement !== null, '没有找到页面实例。');
3985
+ safeExecute($taroPath, ON_LOAD, this.$taroParams);
3986
+ loadResolver();
3987
+ if (process.env.TARO_PLATFORM !== 'web') {
3988
+ pageElement.ctx = this;
3989
+ pageElement.performUpdate(true, cb);
3990
+ }
3991
+ else {
3992
+ shared.isFunction(cb) && cb();
3993
+ }
3994
+ });
3995
+ };
3996
+ if (unmounting) {
3997
+ prepareMountList.push(mount);
3998
+ }
3999
+ else {
4000
+ mount();
4001
+ }
4002
+ },
4003
+ [ONUNLOAD]() {
4004
+ const $taroPath = this.$taroPath;
4005
+ // 销毁当前页面的上下文信息
4006
+ if (process.env.TARO_PLATFORM !== 'web') {
4007
+ window$1.trigger(exports.CONTEXT_ACTIONS.DESTORY, $taroPath);
4008
+ }
4009
+ // 触发onUnload生命周期
4010
+ safeExecute($taroPath, ONUNLOAD);
4011
+ unmounting = true;
4012
+ Current.app.unmount($taroPath, () => {
4013
+ unmounting = false;
4014
+ instances.delete($taroPath);
4015
+ if (pageElement) {
4016
+ pageElement.ctx = null;
4017
+ pageElement = null;
4018
+ }
4019
+ if (prepareMountList.length) {
4020
+ prepareMountList.forEach(fn => fn());
4021
+ prepareMountList = [];
4022
+ }
4023
+ });
4024
+ },
4025
+ [ONREADY]() {
4026
+ hasLoaded.then(() => {
4027
+ // 触发生命周期
4028
+ safeExecute(this.$taroPath, ON_READY);
4029
+ // 通过事件触发子组件的生命周期
4030
+ _raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
4031
+ this.onReady.called = true;
4032
+ });
4033
+ },
4034
+ [ONSHOW](options = {}) {
4035
+ hasLoaded.then(() => {
4036
+ // 设置 Current 的 page 和 router
4037
+ Current.page = this;
4038
+ setCurrentRouter(this);
4039
+ // 恢复上下文信息
4040
+ if (process.env.TARO_PLATFORM !== 'web') {
4041
+ window$1.trigger(exports.CONTEXT_ACTIONS.RECOVER, this.$taroPath);
4042
+ }
4043
+ // 触发生命周期
4044
+ safeExecute(this.$taroPath, ON_SHOW, options);
4045
+ // 通过事件触发子组件的生命周期
4046
+ _raf(() => eventCenter.trigger(getOnShowEventKey(id)));
4047
+ });
4048
+ },
4049
+ [ONHIDE]() {
4050
+ // 缓存当前页面上下文信息
4051
+ if (process.env.TARO_PLATFORM !== 'web') {
4052
+ window$1.trigger(exports.CONTEXT_ACTIONS.RESTORE, this.$taroPath);
4053
+ }
4054
+ // 设置 Current 的 page 和 router
4055
+ if (Current.page === this) {
4056
+ Current.page = null;
4057
+ Current.router = null;
4058
+ }
4059
+ // 触发生命周期
4060
+ safeExecute(this.$taroPath, ON_HIDE);
4061
+ // 通过事件触发子组件的生命周期
4062
+ eventCenter.trigger(getOnHideEventKey(id));
4063
+ }
4064
+ };
4065
+ LIFECYCLES.forEach((lifecycle) => {
4066
+ let isDefer = false;
4067
+ lifecycle = lifecycle.replace(/^defer:/, () => {
4068
+ isDefer = true;
4069
+ return '';
4070
+ });
4071
+ config[lifecycle] = function () {
4072
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4073
+ if (isDefer) {
4074
+ hasLoaded.then(exec);
4075
+ }
4076
+ else {
4077
+ return exec();
4078
+ }
4079
+ };
4080
+ });
4081
+ // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
4082
+ SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
4083
+ var _a;
4084
+ if (component[lifecycle] ||
4085
+ ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a[lifecycle]) ||
4086
+ component[lifecycle.replace(/^on/, 'enable')] ||
4087
+ (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig[lifecycle.replace(/^on/, 'enable')])) {
4088
+ config[lifecycle] = function (...args) {
4089
+ var _a;
4090
+ const target = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.target;
4091
+ if (target === null || target === void 0 ? void 0 : target.id) {
4092
+ const id = target.id;
4093
+ const element = env.document.getElementById(id);
4094
+ if (element) {
4095
+ target.dataset = element.dataset;
4096
+ }
4097
+ }
4098
+ return safeExecute(this.$taroPath, lifecycle, ...args);
4099
+ };
4100
+ }
4101
+ });
4102
+ config.eh = eventHandler;
4103
+ if (!shared.isUndefined(data)) {
4104
+ config.data = data;
4105
+ }
4106
+ shared.hooks.call('modifyPageObject', config);
4107
+ return config;
4108
+ }
4109
+ function createComponentConfig(component, componentName, data) {
4110
+ const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
4111
+ let componentElement = null;
4112
+ const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
4113
+ const config = {
4114
+ [ATTACHED]() {
4115
+ var _a;
4116
+ perf.start(PAGE_INIT);
4117
+ this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
4118
+ const path = getPath(id, { id: this.pageIdCache });
4119
+ Current.app.mount(component, path, () => {
4120
+ componentElement = env.document.getElementById(path);
4121
+ shared.ensure(componentElement !== null, '没有找到组件实例。');
4122
+ this.$taroInstances = instances.get(path);
4123
+ safeExecute(path, ON_LOAD);
4124
+ if (process.env.TARO_PLATFORM !== 'web') {
4125
+ componentElement.ctx = this;
4126
+ componentElement.performUpdate(true);
4127
+ }
4128
+ });
4129
+ },
4130
+ [DETACHED]() {
4131
+ const path = getPath(id, { id: this.pageIdCache });
4132
+ Current.app.unmount(path, () => {
4133
+ instances.delete(path);
4134
+ if (componentElement) {
4135
+ componentElement.ctx = null;
4136
+ }
4137
+ });
4138
+ },
4139
+ methods: {
4140
+ eh: eventHandler
4141
+ }
4142
+ };
4143
+ if (!shared.isUndefined(data)) {
4144
+ config.data = data;
4145
+ }
4146
+ [OPTIONS, EXTERNAL_CLASSES, BEHAVIORS].forEach(key => {
4147
+ var _a;
4148
+ config[key] = (_a = component[key]) !== null && _a !== void 0 ? _a : shared.EMPTY_OBJ;
4149
+ });
4150
+ return config;
4151
+ }
4152
+ function createRecursiveComponentConfig(componentName) {
4153
+ const isCustomWrapper = componentName === CUSTOM_WRAPPER;
4154
+ const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
4155
+ const lifeCycles = isCustomWrapper
4156
+ ? {
4157
+ [ATTACHED]() {
4158
+ var _a, _b;
4159
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4160
+ if (shared.isString(componentId)) {
4161
+ customWrapperCache.set(componentId, this);
4162
+ const el = env.document.getElementById(componentId);
4163
+ if (el) {
4164
+ el.ctx = this;
4165
+ }
4166
+ }
4167
+ },
4168
+ [DETACHED]() {
4169
+ var _a, _b;
4170
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4171
+ if (shared.isString(componentId)) {
4172
+ customWrapperCache.delete(componentId);
4173
+ const el = env.document.getElementById(componentId);
4174
+ if (el) {
4175
+ el.ctx = null;
4176
+ }
4177
+ }
4178
+ }
4179
+ }
4180
+ : shared.EMPTY_OBJ;
4181
+ return shared.hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
4182
+ i: {
4183
+ type: Object,
4184
+ value: {
4185
+ ["nn" /* Shortcuts.NodeName */]: shared.getComponentsAlias(shared.internalComponents)[VIEW]._num
4186
+ }
4187
+ },
4188
+ l: {
4189
+ type: String,
4190
+ value: ''
4191
+ }
4192
+ }, options: {
4193
+ addGlobalClass: true,
4194
+ virtualHost: !isCustomWrapper
4195
+ }, methods: {
4196
+ eh: eventHandler
4197
+ } }, lifeCycles), { isCustomWrapper });
4198
+ }
4199
+
4200
+ const TIMEOUT = 100;
4201
+ const nextTick = (cb, ctx) => {
4202
+ const beginTime = Date.now();
4203
+ const router = Current.router;
4204
+ const timerFunc = () => {
4205
+ setTimeout(function () {
4206
+ ctx ? cb.call(ctx) : cb();
4207
+ }, 1);
4208
+ };
4209
+ if (router === null)
4210
+ return timerFunc();
4211
+ const path = router.$taroPath;
4212
+ /**
4213
+ * 三种情况
4214
+ * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms
4215
+ * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车
4216
+ * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。
4217
+ */
4218
+ function next() {
4219
+ var _a, _b, _c;
4220
+ const pageElement = env.document.getElementById(path);
4221
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
4222
+ if (process.env.TARO_PLATFORM === 'web') {
4223
+ // eslint-disable-next-line dot-notation
4224
+ (_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
4225
+ timerFunc();
4226
+ })) !== null && _c !== void 0 ? _c : timerFunc();
4227
+ }
4228
+ else {
4229
+ pageElement.enqueueUpdateCallback(cb, ctx);
4230
+ }
4231
+ }
4232
+ else if (Date.now() - beginTime > TIMEOUT) {
4233
+ timerFunc();
4234
+ }
4235
+ else {
4236
+ setTimeout(() => next(), 20);
4237
+ }
4238
+ }
4239
+ next();
4240
+ };
4241
+
4242
+ Object.defineProperty(exports, 'Events', {
4243
+ enumerable: true,
4244
+ get: function () { return shared.Events; }
4245
+ });
4246
+ Object.defineProperty(exports, 'hooks', {
4247
+ enumerable: true,
4248
+ get: function () { return shared.hooks; }
4249
+ });
4250
+ exports.A = A;
4251
+ exports.APP = APP;
4252
+ exports.BEHAVIORS = BEHAVIORS;
4253
+ exports.BODY = BODY;
4254
+ exports.CATCHMOVE = CATCHMOVE;
4255
+ exports.CATCH_VIEW = CATCH_VIEW;
4256
+ exports.CHANGE = CHANGE;
4257
+ exports.CLASS = CLASS;
4258
+ exports.COMMENT = COMMENT;
4259
+ exports.COMPILE_MODE = COMPILE_MODE;
4260
+ exports.CONFIRM = CONFIRM;
4261
+ exports.CONTAINER = CONTAINER;
4262
+ exports.CURRENT_TARGET = CURRENT_TARGET;
4263
+ exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
4264
+ exports.Current = Current;
4265
+ exports.DATASET = DATASET;
4266
+ exports.DATE = DATE;
4267
+ exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
4268
+ exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
4269
+ exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
4270
+ exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
4271
+ exports.FOCUS = FOCUS;
4272
+ exports.FormElement = FormElement;
4273
+ exports.HEAD = HEAD;
4274
+ exports.HOOKS_APP_ID = HOOKS_APP_ID;
4275
+ exports.HTML = HTML;
4276
+ exports.History = History;
4277
+ exports.ID = ID;
4278
+ exports.INPUT = INPUT;
4279
+ exports.KEY_CODE = KEY_CODE;
4280
+ exports.Location = Location;
4281
+ exports.MutationObserver = MutationObserver;
4282
+ exports.OBJECT = OBJECT;
4283
+ exports.ON_HIDE = ON_HIDE;
4284
+ exports.ON_LOAD = ON_LOAD;
4285
+ exports.ON_READY = ON_READY;
4286
+ exports.ON_SHOW = ON_SHOW;
4287
+ exports.OPTIONS = OPTIONS;
4288
+ exports.PAGE_INIT = PAGE_INIT;
4289
+ exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
4290
+ exports.PROPS = PROPS;
4291
+ exports.PURE_VIEW = PURE_VIEW;
4292
+ exports.ROOT_STR = ROOT_STR;
4293
+ exports.SET_DATA = SET_DATA;
4294
+ exports.SET_TIMEOUT = SET_TIMEOUT;
4295
+ exports.STATIC_VIEW = STATIC_VIEW;
4296
+ exports.STYLE = STYLE;
4297
+ exports.SVGElement = SVGElement;
4298
+ exports.Style = Style;
4299
+ exports.TARGET = TARGET;
4300
+ exports.TARO_RUNTIME = TARO_RUNTIME;
4301
+ exports.TIME_STAMP = TIME_STAMP;
4302
+ exports.TOUCHMOVE = TOUCHMOVE;
4303
+ exports.TYPE = TYPE;
4304
+ exports.TaroElement = TaroElement;
4305
+ exports.TaroEvent = TaroEvent;
4306
+ exports.TaroNode = TaroNode;
4307
+ exports.TaroRootElement = TaroRootElement;
4308
+ exports.TaroText = TaroText;
4309
+ exports.UID = UID;
4310
+ exports.URL = URL;
4311
+ exports.URLSearchParams = URLSearchParams;
4312
+ exports.VALUE = VALUE;
4313
+ exports.VIEW = VIEW;
4314
+ exports.addLeadingSlash = addLeadingSlash;
4315
+ exports.cancelAnimationFrame = _caf;
4316
+ exports.createComponentConfig = createComponentConfig;
4317
+ exports.createEvent = createEvent;
4318
+ exports.createPageConfig = createPageConfig;
4319
+ exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
4320
+ exports.document = document$1;
4321
+ exports.env = env;
4322
+ exports.eventCenter = eventCenter;
4323
+ exports.eventHandler = eventHandler;
4324
+ exports.eventSource = eventSource;
4325
+ exports.getComputedStyle = getComputedStyle;
4326
+ exports.getCurrentInstance = getCurrentInstance;
4327
+ exports.getOnHideEventKey = getOnHideEventKey;
4328
+ exports.getOnReadyEventKey = getOnReadyEventKey;
4329
+ exports.getOnShowEventKey = getOnShowEventKey;
4330
+ exports.getPageInstance = getPageInstance;
4331
+ exports.getPath = getPath;
4332
+ exports.history = history;
4333
+ exports.hydrate = hydrate;
4334
+ exports.incrementId = incrementId;
4335
+ exports.injectPageInstance = injectPageInstance;
4336
+ exports.isHasExtractProp = isHasExtractProp;
4337
+ exports.location = location;
4338
+ exports.navigator = nav;
4339
+ exports.nextTick = nextTick;
4340
+ exports.options = options;
4341
+ exports.parseUrl = parseUrl;
4342
+ exports.removePageInstance = removePageInstance;
4343
+ exports.requestAnimationFrame = _raf;
4344
+ exports.safeExecute = safeExecute;
4345
+ exports.stringify = stringify;
4346
+ exports.window = window$1;
4347
+ //# sourceMappingURL=index.cjs.js.map