@tarojs/runtime 3.7.0-alpha.2 → 3.7.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/runtime.cjs.d.ts +780 -0
  2. package/dist/runtime.cjs.js +4583 -0
  3. package/dist/runtime.esm.d.ts +153 -76
  4. package/dist/runtime.esm.js +198 -74
  5. package/dist/runtime.esm.js.map +1 -1
  6. package/dist/runtime.h5.d.ts +780 -0
  7. package/dist/runtime.h5.js +3349 -0
  8. package/package.json +11 -6
  9. package/dist/bom/URL.d.ts +0 -61
  10. package/dist/bom/URLSearchParams.d.ts +0 -14
  11. package/dist/bom/document.d.ts +0 -2
  12. package/dist/bom/getComputedStyle.d.ts +0 -3
  13. package/dist/bom/history.d.ts +0 -29
  14. package/dist/bom/location.d.ts +0 -36
  15. package/dist/bom/navigator.d.ts +0 -1
  16. package/dist/bom/raf.d.ts +0 -5
  17. package/dist/bom/window.d.ts +0 -4
  18. package/dist/constants/index.d.ts +0 -58
  19. package/dist/current.d.ts +0 -19
  20. package/dist/dom/anchor-element.d.ts +0 -13
  21. package/dist/dom/class-list.d.ts +0 -14
  22. package/dist/dom/custom-wrapper.d.ts +0 -4
  23. package/dist/dom/document.d.ts +0 -20
  24. package/dist/dom/element.d.ts +0 -38
  25. package/dist/dom/event-source.d.ts +0 -7
  26. package/dist/dom/event-target.d.ts +0 -7
  27. package/dist/dom/event.d.ts +0 -23
  28. package/dist/dom/form.d.ts +0 -7
  29. package/dist/dom/node.d.ts +0 -75
  30. package/dist/dom/node_types.d.ts +0 -10
  31. package/dist/dom/root.d.ts +0 -15
  32. package/dist/dom/style.d.ts +0 -14
  33. package/dist/dom/style_properties.d.ts +0 -3
  34. package/dist/dom/svg.d.ts +0 -3
  35. package/dist/dom/text.d.ts +0 -14
  36. package/dist/dom/tree.d.ts +0 -4
  37. package/dist/dom-external/element.d.ts +0 -3
  38. package/dist/dom-external/index.d.ts +0 -1
  39. package/dist/dom-external/inner-html/html.d.ts +0 -2
  40. package/dist/dom-external/inner-html/parser.d.ts +0 -25
  41. package/dist/dom-external/inner-html/scaner.d.ts +0 -30
  42. package/dist/dom-external/inner-html/style.d.ts +0 -27
  43. package/dist/dom-external/inner-html/tags.d.ts +0 -8
  44. package/dist/dom-external/inner-html/utils.d.ts +0 -1
  45. package/dist/dom-external/mutation-observer/implements.d.ts +0 -52
  46. package/dist/dom-external/mutation-observer/index.d.ts +0 -13
  47. package/dist/dom-external/mutation-observer/record.d.ts +0 -24
  48. package/dist/dom-external/node.d.ts +0 -11
  49. package/dist/dsl/common.d.ts +0 -16
  50. package/dist/dsl/instance.d.ts +0 -87
  51. package/dist/emitter/emitter.d.ts +0 -4
  52. package/dist/env.d.ts +0 -7
  53. package/dist/hydrate.d.ts +0 -10
  54. package/dist/index.d.ts +0 -30
  55. package/dist/interface/element.d.ts +0 -4
  56. package/dist/interface/event-target.d.ts +0 -10
  57. package/dist/interface/event.d.ts +0 -15
  58. package/dist/interface/hydrate.d.ts +0 -30
  59. package/dist/interface/index.d.ts +0 -7
  60. package/dist/interface/node.d.ts +0 -7
  61. package/dist/interface/options.d.ts +0 -16
  62. package/dist/interface/utils.d.ts +0 -2
  63. package/dist/next-tick.d.ts +0 -2
  64. package/dist/options.d.ts +0 -2
  65. package/dist/perf.d.ts +0 -7
  66. package/dist/utils/cache.d.ts +0 -12
  67. package/dist/utils/index.d.ts +0 -23
@@ -0,0 +1,3349 @@
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 CATCHMOVE = 'catchMove';
43
+ const CATCH_VIEW = 'catch-view';
44
+ const COMMENT = 'comment';
45
+ const ON_LOAD = 'onLoad';
46
+ const ON_READY = 'onReady';
47
+ const ON_SHOW = 'onShow';
48
+ const ON_HIDE = 'onHide';
49
+ const OPTIONS = 'options';
50
+ const EXTERNAL_CLASSES = 'externalClasses';
51
+ const EVENT_CALLBACK_RESULT = 'e_result';
52
+ const BEHAVIORS = 'behaviors';
53
+ const A = 'a';
54
+ /**
55
+ * 页面上下文切换时的行为
56
+ */
57
+ exports.CONTEXT_ACTIONS = void 0;
58
+ (function (CONTEXT_ACTIONS) {
59
+ CONTEXT_ACTIONS["INIT"] = "0";
60
+ CONTEXT_ACTIONS["RESTORE"] = "1";
61
+ CONTEXT_ACTIONS["RECOVER"] = "2";
62
+ CONTEXT_ACTIONS["DESTORY"] = "3";
63
+ })(exports.CONTEXT_ACTIONS || (exports.CONTEXT_ACTIONS = {}));
64
+
65
+ const observers = [];
66
+ /** Match two TaroNodes by sid. */
67
+ const sidMatches = (observerTarget, target) => {
68
+ return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
69
+ };
70
+ const isConcerned = (record, options) => {
71
+ const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
72
+ switch (record.type) {
73
+ case "characterData" /* MutationRecordType.CHARACTER_DATA */:
74
+ if (characterData) {
75
+ if (!characterDataOldValue)
76
+ record.oldValue = null;
77
+ return true;
78
+ }
79
+ return false;
80
+ case "attributes" /* MutationRecordType.ATTRIBUTES */:
81
+ if (attributes) {
82
+ if (!attributeOldValue)
83
+ record.oldValue = null;
84
+ return true;
85
+ }
86
+ return false;
87
+ case "childList" /* MutationRecordType.CHILD_LIST */:
88
+ if (childList) {
89
+ return true;
90
+ }
91
+ return false;
92
+ }
93
+ };
94
+ let pendingMuatations = false;
95
+ function logMutation(observer, record) {
96
+ observer.records.push(record);
97
+ if (!pendingMuatations) {
98
+ pendingMuatations = true;
99
+ Promise
100
+ .resolve()
101
+ .then(() => {
102
+ pendingMuatations = false;
103
+ observers.forEach(observer => {
104
+ return observer.callback(observer.takeRecords());
105
+ });
106
+ });
107
+ }
108
+ }
109
+ function recordMutation(record) {
110
+ observers.forEach(observer => {
111
+ const { options } = observer;
112
+ for (let t = record.target; t; t = t.parentNode) {
113
+ if (sidMatches(observer.target, t) && isConcerned(record, options)) {
114
+ logMutation(observer, record);
115
+ break;
116
+ }
117
+ if (!options.subtree)
118
+ break;
119
+ }
120
+ });
121
+ }
122
+
123
+ class MutationObserver {
124
+ constructor(callback) {
125
+ {
126
+ if (process.env.NODE_ENV !== 'production') {
127
+ console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.enableMutationObserver: true\'');
128
+ }
129
+ this.core = {
130
+ observe: shared.noop,
131
+ disconnect: shared.noop,
132
+ takeRecords: shared.noop
133
+ };
134
+ }
135
+ }
136
+ observe(...args) {
137
+ this.core.observe(...args);
138
+ }
139
+ disconnect() {
140
+ this.core.disconnect();
141
+ }
142
+ takeRecords() {
143
+ return this.core.takeRecords();
144
+ }
145
+ static record(record) {
146
+ recordMutation(record);
147
+ }
148
+ }
149
+
150
+ const incrementId = () => {
151
+ const chatCodes = [];
152
+ // A-Z
153
+ for (let i = 65; i <= 90; i++) {
154
+ chatCodes.push(i);
155
+ }
156
+ // a-z
157
+ for (let i = 97; i <= 122; i++) {
158
+ chatCodes.push(i);
159
+ }
160
+ const chatCodesLen = chatCodes.length - 1;
161
+ const list = [0, 0];
162
+ return () => {
163
+ const target = list.map(item => chatCodes[item]);
164
+ const res = String.fromCharCode(...target);
165
+ let tailIdx = list.length - 1;
166
+ list[tailIdx]++;
167
+ while (list[tailIdx] > chatCodesLen) {
168
+ list[tailIdx] = 0;
169
+ tailIdx = tailIdx - 1;
170
+ if (tailIdx < 0) {
171
+ list.push(0);
172
+ break;
173
+ }
174
+ list[tailIdx]++;
175
+ }
176
+ return res;
177
+ };
178
+ };
179
+ function isElement(node) {
180
+ return node.nodeType === 1 /* NodeType.ELEMENT_NODE */;
181
+ }
182
+ function isText(node) {
183
+ return node.nodeType === 3 /* NodeType.TEXT_NODE */;
184
+ }
185
+ function isComment(node) {
186
+ return node.nodeName === COMMENT;
187
+ }
188
+ function isHasExtractProp(el) {
189
+ const res = Object.keys(el.props).find(prop => {
190
+ return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));
191
+ });
192
+ return Boolean(res);
193
+ }
194
+ /**
195
+ * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
196
+ * @param node 当前组件
197
+ * @param type 事件类型
198
+ */
199
+ function isParentBinded(node, type) {
200
+ var _a;
201
+ let res = false;
202
+ while ((node === null || node === void 0 ? void 0 : node.parentElement) && node.parentElement._path !== ROOT_STR) {
203
+ if ((_a = node.parentElement.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
204
+ res = true;
205
+ break;
206
+ }
207
+ node = node.parentElement;
208
+ }
209
+ return res;
210
+ }
211
+ function shortcutAttr(key) {
212
+ switch (key) {
213
+ case STYLE:
214
+ return "st" /* Shortcuts.Style */;
215
+ case ID:
216
+ return UID;
217
+ case CLASS:
218
+ return "cl" /* Shortcuts.Class */;
219
+ default:
220
+ return key;
221
+ }
222
+ }
223
+ const customWrapperCache = new Map();
224
+ function extend(ctor, methodName, options) {
225
+ if (shared.isFunction(options)) {
226
+ options = {
227
+ value: options
228
+ };
229
+ }
230
+ Object.defineProperty(ctor.prototype, methodName, Object.assign({ configurable: true, enumerable: true }, options));
231
+ }
232
+ let componentsAlias$1;
233
+ function getComponentsAlias() {
234
+ if (!componentsAlias$1) {
235
+ componentsAlias$1 = shared.getComponentsAlias(shared.internalComponents);
236
+ }
237
+ return componentsAlias$1;
238
+ }
239
+
240
+ class ClassList {
241
+ constructor(className, el) {
242
+ this.tokenList = [];
243
+ this.el = el;
244
+ className.trim().split(/\s+/).forEach(token => this.tokenList.push(token));
245
+ }
246
+ get value() {
247
+ return this.toString();
248
+ }
249
+ get length() {
250
+ return this.tokenList.length;
251
+ }
252
+ add() {
253
+ let index = 0;
254
+ let updated = false;
255
+ const tokens = arguments;
256
+ const length = tokens.length;
257
+ const tokenList = this.tokenList;
258
+ do {
259
+ const token = tokens[index];
260
+ if (this.checkTokenIsValid(token) && !~tokenList.indexOf(token)) {
261
+ tokenList.push(token);
262
+ updated = true;
263
+ }
264
+ } while (++index < length);
265
+ if (updated) {
266
+ this._update();
267
+ }
268
+ }
269
+ remove() {
270
+ let i = 0;
271
+ let updated = false;
272
+ const tokens = arguments;
273
+ const length = tokens.length;
274
+ const tokenList = this.tokenList;
275
+ do {
276
+ const token = tokens[i] + '';
277
+ if (!this.checkTokenIsValid(token))
278
+ continue;
279
+ const index = tokenList.indexOf(token);
280
+ if (~tokenList.indexOf(token)) {
281
+ tokenList.splice(index, 1);
282
+ updated = true;
283
+ }
284
+ } while (++i < length);
285
+ if (updated) {
286
+ this._update();
287
+ }
288
+ }
289
+ contains(token) {
290
+ if (!this.checkTokenIsValid(token))
291
+ return false;
292
+ return !!~this.tokenList.indexOf(token);
293
+ }
294
+ toggle(token, force) {
295
+ const result = this.contains(token);
296
+ const method = result ? force !== true && 'remove' : force !== false && 'add';
297
+ if (method) {
298
+ // @ts-ignore
299
+ this[method](token);
300
+ }
301
+ if (force === true || force === false) {
302
+ return force;
303
+ }
304
+ else {
305
+ return !result;
306
+ }
307
+ }
308
+ replace(token, replacement_token) {
309
+ if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token))
310
+ return;
311
+ const index = this.tokenList.indexOf(token);
312
+ if (~index) {
313
+ this.tokenList.splice(index, 1, replacement_token);
314
+ this._update();
315
+ }
316
+ }
317
+ toString() {
318
+ return this.tokenList.filter(v => v !== '').join(' ');
319
+ }
320
+ checkTokenIsValid(token) {
321
+ if (token === '' || /\s/.test(token))
322
+ return false;
323
+ return true;
324
+ }
325
+ _update() {
326
+ this.el.className = this.value;
327
+ }
328
+ }
329
+
330
+ class EventSource extends Map {
331
+ removeNode(child) {
332
+ const { sid, uid } = child;
333
+ this.delete(sid);
334
+ if (uid !== sid && uid)
335
+ this.delete(uid);
336
+ }
337
+ removeNodeTree(child) {
338
+ this.removeNode(child);
339
+ const { childNodes } = child;
340
+ childNodes.forEach(node => this.removeNodeTree(node));
341
+ }
342
+ }
343
+ const eventSource = new EventSource();
344
+
345
+ const env = {
346
+ window: window ,
347
+ document: document
348
+ };
349
+
350
+ let SPECIAL_NODES;
351
+ let componentsAlias;
352
+ /**
353
+ * React also has a fancy function's name for this: `hydrate()`.
354
+ * You may have been heard `hydrate` as a SSR-related function,
355
+ * actually, `hydrate` basicly do the `render()` thing, but ignore some properties,
356
+ * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
357
+ */
358
+ function hydrate(node) {
359
+ var _a;
360
+ if (!componentsAlias) {
361
+ // 初始化 componentsAlias
362
+ componentsAlias = getComponentsAlias();
363
+ }
364
+ if (!SPECIAL_NODES) {
365
+ // 初始化 SPECIAL_NODES
366
+ SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
367
+ }
368
+ const nodeName = node.nodeName;
369
+ if (isText(node)) {
370
+ return {
371
+ ["v" /* Shortcuts.Text */]: node.nodeValue,
372
+ ["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
373
+ };
374
+ }
375
+ const data = {
376
+ ["nn" /* Shortcuts.NodeName */]: nodeName,
377
+ sid: node.sid
378
+ };
379
+ if (node.uid !== node.sid) {
380
+ data.uid = node.uid;
381
+ }
382
+ if (!node.isAnyEventBinded() && SPECIAL_NODES.indexOf(nodeName) > -1) {
383
+ data["nn" /* Shortcuts.NodeName */] = `static-${nodeName}`;
384
+ if (nodeName === VIEW && !isHasExtractProp(node)) {
385
+ data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
386
+ }
387
+ }
388
+ const { props } = node;
389
+ for (const prop in props) {
390
+ const propInCamelCase = shared.toCamelCase(prop);
391
+ if (!prop.startsWith('data-') && // 在 node.dataset 的数据
392
+ prop !== CLASS &&
393
+ prop !== STYLE &&
394
+ prop !== ID &&
395
+ propInCamelCase !== CATCHMOVE) {
396
+ data[propInCamelCase] = props[prop];
397
+ }
398
+ if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
399
+ data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
400
+ }
401
+ }
402
+ let { childNodes } = node;
403
+ // 过滤 comment 节点
404
+ childNodes = childNodes.filter(node => !isComment(node));
405
+ if (childNodes.length > 0) {
406
+ data["cn" /* Shortcuts.Childnodes */] = childNodes.map(hydrate);
407
+ }
408
+ else {
409
+ data["cn" /* Shortcuts.Childnodes */] = [];
410
+ }
411
+ if (node.className !== '') {
412
+ data["cl" /* Shortcuts.Class */] = node.className;
413
+ }
414
+ const cssText = node.cssText;
415
+ if (cssText !== '' && nodeName !== 'swiper-item') {
416
+ data["st" /* Shortcuts.Style */] = cssText;
417
+ }
418
+ shared.hooks.call('modifyHydrateData', data);
419
+ const nn = data["nn" /* Shortcuts.NodeName */];
420
+ const componentAlias = componentsAlias[nn];
421
+ if (componentAlias) {
422
+ data["nn" /* Shortcuts.NodeName */] = componentAlias._num;
423
+ for (const prop in data) {
424
+ if (prop in componentAlias) {
425
+ data[componentAlias[prop]] = data[prop];
426
+ delete data[prop];
427
+ }
428
+ }
429
+ }
430
+ return data;
431
+ }
432
+
433
+ class TaroEventTarget {
434
+ constructor() {
435
+ this.__handlers = {};
436
+ }
437
+ addEventListener(type, handler, options) {
438
+ type = type.toLowerCase();
439
+ shared.hooks.call('onAddEvent', type, handler, options, this);
440
+ if (type === 'regionchange') {
441
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
442
+ this.addEventListener('begin', handler, options);
443
+ this.addEventListener('end', handler, options);
444
+ return;
445
+ }
446
+ let isCapture = Boolean(options);
447
+ let isOnce = false;
448
+ if (shared.isObject(options)) {
449
+ isCapture = Boolean(options.capture);
450
+ isOnce = Boolean(options.once);
451
+ }
452
+ if (isOnce) {
453
+ const wrapper = function () {
454
+ handler.apply(this, arguments); // this 指向 Element
455
+ this.removeEventListener(type, wrapper);
456
+ };
457
+ this.addEventListener(type, wrapper, Object.assign(Object.assign({}, options), { once: false }));
458
+ return;
459
+ }
460
+ process.env.NODE_ENV !== 'production' && shared.warn(isCapture, 'Taro 暂未实现 event 的 capture 特性。');
461
+ // 某些框架,如 PReact 有委托的机制,handler 始终是同一个函数
462
+ // 这会导致多层停止冒泡失败:view -> view(handler.stop = false) -> view(handler.stop = true)
463
+ // 这样解决:view -> view(handlerA.stop = false) -> view(handlerB.stop = false)
464
+ // 因此每次绑定事件都新建一个函数,如果带来了性能问题,可以把这段逻辑抽取到 PReact 插件中。
465
+ const oldHandler = handler;
466
+ handler = function () {
467
+ return oldHandler.apply(this, arguments); // this 指向 Element
468
+ };
469
+ handler.oldHandler = oldHandler;
470
+ const handlers = this.__handlers[type];
471
+ if (shared.isArray(handlers)) {
472
+ handlers.push(handler);
473
+ }
474
+ else {
475
+ this.__handlers[type] = [handler];
476
+ }
477
+ }
478
+ removeEventListener(type, handler) {
479
+ type = type.toLowerCase();
480
+ if (type === 'regionchange') {
481
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
482
+ this.removeEventListener('begin', handler);
483
+ this.removeEventListener('end', handler);
484
+ return;
485
+ }
486
+ if (!handler) {
487
+ return;
488
+ }
489
+ const handlers = this.__handlers[type];
490
+ if (!shared.isArray(handlers)) {
491
+ return;
492
+ }
493
+ const index = handlers.findIndex(item => {
494
+ if (item === handler || item.oldHandler === handler)
495
+ return true;
496
+ });
497
+ process.env.NODE_ENV !== 'production' && shared.warn(index === -1, `事件: '${type}' 没有注册在 DOM 中,因此不会被移除。`);
498
+ handlers.splice(index, 1);
499
+ }
500
+ isAnyEventBinded() {
501
+ const handlers = this.__handlers;
502
+ const isAnyEventBinded = Object.keys(handlers).find(key => handlers[key].length);
503
+ return Boolean(isAnyEventBinded);
504
+ }
505
+ }
506
+
507
+ const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
508
+ const nodeId = incrementId();
509
+ class TaroNode extends TaroEventTarget {
510
+ constructor() {
511
+ super();
512
+ this.parentNode = null;
513
+ this.childNodes = [];
514
+ this.hydrate = (node) => () => hydrate(node);
515
+ this.uid = '_' + nodeId(); // dom 节点 id,开发者可修改
516
+ this.sid = this.uid; // dom 节点全局唯一 id,不可被修改
517
+ eventSource.set(this.sid, this);
518
+ }
519
+ updateChildNodes(isClean) {
520
+ const cleanChildNodes = () => [];
521
+ const rerenderChildNodes = () => {
522
+ const childNodes = this.childNodes.filter(node => !isComment(node));
523
+ return childNodes.map(hydrate);
524
+ };
525
+ this.enqueueUpdate({
526
+ path: `${this._path}.${CHILDNODES}`,
527
+ value: isClean ? cleanChildNodes : rerenderChildNodes
528
+ });
529
+ }
530
+ updateSingleChild(index) {
531
+ this.childNodes.forEach((child, childIndex) => {
532
+ if (isComment(child))
533
+ return;
534
+ if (index && childIndex < index)
535
+ return;
536
+ this.enqueueUpdate({
537
+ path: child._path,
538
+ value: this.hydrate(child)
539
+ });
540
+ });
541
+ }
542
+ get _root() {
543
+ var _a;
544
+ return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
545
+ }
546
+ findIndex(refChild) {
547
+ const index = this.childNodes.indexOf(refChild);
548
+ shared.ensure(index !== -1, 'The node to be replaced is not a child of this node.');
549
+ return index;
550
+ }
551
+ get _path() {
552
+ const parentNode = this.parentNode;
553
+ if (parentNode) {
554
+ // 计算路径时,先过滤掉 comment 节点
555
+ const list = parentNode.childNodes.filter(node => !isComment(node));
556
+ const indexOfNode = list.indexOf(this);
557
+ const index = shared.hooks.call('getPathIndex', indexOfNode);
558
+ return `${parentNode._path}.${CHILDNODES}.${index}`;
559
+ }
560
+ return '';
561
+ }
562
+ get nextSibling() {
563
+ const parentNode = this.parentNode;
564
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) + 1]) || null;
565
+ }
566
+ get previousSibling() {
567
+ const parentNode = this.parentNode;
568
+ return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) - 1]) || null;
569
+ }
570
+ get parentElement() {
571
+ const parentNode = this.parentNode;
572
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeType) === 1 /* NodeType.ELEMENT_NODE */) {
573
+ return parentNode;
574
+ }
575
+ return null;
576
+ }
577
+ get firstChild() {
578
+ return this.childNodes[0] || null;
579
+ }
580
+ get lastChild() {
581
+ const childNodes = this.childNodes;
582
+ return childNodes[childNodes.length - 1] || null;
583
+ }
584
+ /**
585
+ * @textContent 目前只能置空子元素
586
+ * @TODO 等待完整 innerHTML 实现
587
+ */
588
+ // eslint-disable-next-line accessor-pairs
589
+ set textContent(text) {
590
+ const removedNodes = this.childNodes.slice();
591
+ const addedNodes = [];
592
+ // Handle old children' data structure & ref
593
+ while (this.firstChild) {
594
+ this.removeChild(this.firstChild, { doUpdate: false });
595
+ }
596
+ if (text === '') {
597
+ this.updateChildNodes(true);
598
+ }
599
+ else {
600
+ const newText = env.document.createTextNode(text);
601
+ addedNodes.push(newText);
602
+ this.appendChild(newText);
603
+ this.updateChildNodes();
604
+ }
605
+ // @Todo: appendChild 会多触发一次
606
+ MutationObserver.record({
607
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
608
+ target: this,
609
+ removedNodes,
610
+ addedNodes
611
+ });
612
+ }
613
+ /**
614
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
615
+ * @scenario
616
+ * [A,B,C]
617
+ * 1. insert D before C, D has no parent
618
+ * 2. insert D before C, D has the same parent of C
619
+ * 3. insert D before C, D has the different parent of C
620
+ */
621
+ insertBefore(newChild, refChild, isReplace) {
622
+ if (newChild.nodeName === DOCUMENT_FRAGMENT) {
623
+ newChild.childNodes.reduceRight((previousValue, currentValue) => {
624
+ this.insertBefore(currentValue, previousValue);
625
+ return currentValue;
626
+ }, refChild);
627
+ return newChild;
628
+ }
629
+ // Parent release newChild
630
+ // - cleanRef: false (No need to clean eventSource, because newChild is about to be inserted)
631
+ // - update: true (Need to update parent.childNodes, because parent.childNodes is reordered)
632
+ newChild.remove({ cleanRef: false });
633
+ let index = 0;
634
+ // Data structure
635
+ newChild.parentNode = this;
636
+ if (refChild) {
637
+ // insertBefore & replaceChild
638
+ index = this.findIndex(refChild);
639
+ this.childNodes.splice(index, 0, newChild);
640
+ }
641
+ else {
642
+ // appendChild
643
+ this.childNodes.push(newChild);
644
+ }
645
+ const childNodesLength = this.childNodes.length;
646
+ // Serialization
647
+ if (this._root) {
648
+ if (!refChild) {
649
+ // appendChild
650
+ const isOnlyChild = childNodesLength === 1;
651
+ if (isOnlyChild) {
652
+ this.updateChildNodes();
653
+ }
654
+ else {
655
+ this.enqueueUpdate({
656
+ path: newChild._path,
657
+ value: this.hydrate(newChild)
658
+ });
659
+ }
660
+ }
661
+ else if (isReplace) {
662
+ // replaceChild
663
+ this.enqueueUpdate({
664
+ path: newChild._path,
665
+ value: this.hydrate(newChild)
666
+ });
667
+ }
668
+ else {
669
+ // insertBefore 有两种更新模式
670
+ // 比方说有 A B C 三个节点,现在要在 C 前插入 D
671
+ // 1. 插入 D,然后更新整个父节点的 childNodes 数组
672
+ // setData({ cn: [A, B, D, C] })
673
+ // 2. 插入 D,然后更新 D 以及 D 之后每个节点的数据
674
+ // setData ({
675
+ // cn.[2]: D,
676
+ // cn.[3]: C,
677
+ // })
678
+ // 由于微信解析 ’cn.[2]‘ 这些路径的时候也需要消耗时间,
679
+ // 所以根据 insertBefore 插入的位置来做不同的处理
680
+ const mark = childNodesLength * 2 / 3;
681
+ if (mark > index) {
682
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 前,则为了避免解析路径消耗过多的时间,采用第一种方式
683
+ this.updateChildNodes();
684
+ }
685
+ else {
686
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 之后,则采用第二种方式,避免 childNodes 的全量更新
687
+ this.updateSingleChild(index);
688
+ }
689
+ }
690
+ }
691
+ MutationObserver.record({
692
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
693
+ target: this,
694
+ addedNodes: [newChild],
695
+ removedNodes: isReplace
696
+ ? [refChild] /** replaceChild */
697
+ : [],
698
+ nextSibling: isReplace
699
+ ? refChild.nextSibling /** replaceChild */
700
+ : (refChild || null),
701
+ previousSibling: newChild.previousSibling
702
+ });
703
+ return newChild;
704
+ }
705
+ /**
706
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/appendChild
707
+ * @scenario
708
+ * [A,B,C]
709
+ * 1. append C, C has no parent
710
+ * 2. append C, C has the same parent of B
711
+ * 3. append C, C has the different parent of B
712
+ */
713
+ appendChild(newChild) {
714
+ return this.insertBefore(newChild);
715
+ }
716
+ /**
717
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
718
+ * @scenario
719
+ * [A,B,C]
720
+ * 1. replace B with C, C has no parent
721
+ * 2. replace B with C, C has no parent, C has the same parent of B
722
+ * 3. replace B with C, C has no parent, C has the different parent of B
723
+ */
724
+ replaceChild(newChild, oldChild) {
725
+ if (oldChild.parentNode !== this)
726
+ return;
727
+ // Insert the newChild
728
+ this.insertBefore(newChild, oldChild, true);
729
+ // Destroy the oldChild
730
+ // - cleanRef: true (Need to clean eventSource, because the oldChild was detached from the DOM tree)
731
+ // - update: false (No need to update parent.childNodes, because replace will not cause the parent.childNodes being reordered)
732
+ oldChild.remove({ doUpdate: false });
733
+ return oldChild;
734
+ }
735
+ /**
736
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/removeChild
737
+ * @scenario
738
+ * [A,B,C]
739
+ * 1. remove A or B
740
+ * 2. remove C
741
+ */
742
+ removeChild(child, options = {}) {
743
+ const { cleanRef, doUpdate } = options;
744
+ if (cleanRef !== false && doUpdate !== false) {
745
+ // appendChild/replaceChild/insertBefore 不应该触发
746
+ // @Todo: 但其实如果 newChild 的父节点是另一颗子树的节点,应该是要触发的
747
+ MutationObserver.record({
748
+ type: "childList" /* MutationRecordType.CHILD_LIST */,
749
+ target: this,
750
+ removedNodes: [child],
751
+ nextSibling: child.nextSibling,
752
+ previousSibling: child.previousSibling
753
+ });
754
+ }
755
+ // Data Structure
756
+ const index = this.findIndex(child);
757
+ this.childNodes.splice(index, 1);
758
+ child.parentNode = null;
759
+ // Set eventSource
760
+ if (cleanRef !== false) {
761
+ eventSource.removeNodeTree(child);
762
+ }
763
+ // Serialization
764
+ if (this._root && doUpdate !== false) {
765
+ this.updateChildNodes();
766
+ }
767
+ return child;
768
+ }
769
+ remove(options) {
770
+ var _a;
771
+ (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this, options);
772
+ }
773
+ hasChildNodes() {
774
+ return this.childNodes.length > 0;
775
+ }
776
+ enqueueUpdate(payload) {
777
+ var _a;
778
+ (_a = this._root) === null || _a === void 0 ? void 0 : _a.enqueueUpdate(payload);
779
+ }
780
+ get ownerDocument() {
781
+ return env.document;
782
+ }
783
+ static extend(methodName, options) {
784
+ extend(TaroNode, methodName, options);
785
+ }
786
+ }
787
+
788
+ /*
789
+ *
790
+ * https://www.w3.org/Style/CSS/all-properties.en.html
791
+ */
792
+ const WEBKIT = 'webkit';
793
+ const styleProperties = [
794
+ 'all',
795
+ 'appearance',
796
+ 'blockOverflow',
797
+ 'blockSize',
798
+ 'bottom',
799
+ 'clear',
800
+ 'contain',
801
+ 'content',
802
+ 'continue',
803
+ 'cursor',
804
+ 'direction',
805
+ 'display',
806
+ 'filter',
807
+ 'float',
808
+ 'gap',
809
+ 'height',
810
+ 'inset',
811
+ 'isolation',
812
+ 'left',
813
+ 'letterSpacing',
814
+ 'lightingColor',
815
+ 'markerSide',
816
+ 'mixBlendMode',
817
+ 'opacity',
818
+ 'order',
819
+ 'position',
820
+ 'quotes',
821
+ 'resize',
822
+ 'right',
823
+ 'rowGap',
824
+ 'tabSize',
825
+ 'tableLayout',
826
+ 'top',
827
+ 'userSelect',
828
+ 'verticalAlign',
829
+ 'visibility',
830
+ 'voiceFamily',
831
+ 'volume',
832
+ 'whiteSpace',
833
+ 'widows',
834
+ 'width',
835
+ 'zIndex',
836
+ 'pointerEvents',
837
+ 'aspectRatio'
838
+ /** 非常用 style */
839
+ // 'azimuth',
840
+ // 'backfaceVisibility',
841
+ // 'baselineShift',
842
+ // 'captionSide',
843
+ // 'chains',
844
+ // 'dominantBaseline',
845
+ // 'elevation',
846
+ // 'emptyCells',
847
+ // 'forcedColorAdjust',
848
+ // 'glyphOrientationVertical',
849
+ // 'hangingPunctuation',
850
+ // 'hyphenateCharacter',
851
+ // 'hyphens',
852
+ // 'imageOrientation',
853
+ // 'imageResolution',
854
+ // 'orphans',
855
+ // 'playDuring',
856
+ // 'pointerEvents',
857
+ // 'regionFragment',
858
+ // 'richness',
859
+ // 'running',
860
+ // 'scrollBehavior',
861
+ // 'speechRate',
862
+ // 'stress',
863
+ // 'stringSet',
864
+ // 'unicodeBidi',
865
+ // 'willChange',
866
+ // 'writingMode',
867
+ ];
868
+ // 减少文件体积
869
+ function combine(prefix, list, excludeSelf) {
870
+ !excludeSelf && styleProperties.push(prefix);
871
+ list.forEach(item => {
872
+ styleProperties.push(prefix + item);
873
+ if (prefix === WEBKIT) {
874
+ styleProperties.push('Webkit' + item);
875
+ }
876
+ });
877
+ }
878
+ const color = 'Color';
879
+ const style = 'Style';
880
+ const width = 'Width';
881
+ const image = 'Image';
882
+ const size = 'Size';
883
+ const color_style_width = [color, style, width];
884
+ const fitlength_fitwidth_image = ['FitLength', 'FitWidth', image];
885
+ const fitlength_fitwidth_image_radius = [...fitlength_fitwidth_image, 'Radius'];
886
+ const color_style_width_fitlength_fitwidth_image = [...color_style_width, ...fitlength_fitwidth_image];
887
+ const endRadius_startRadius = ['EndRadius', 'StartRadius'];
888
+ const bottom_left_right_top = ['Bottom', 'Left', 'Right', 'Top'];
889
+ const end_start = ['End', 'Start'];
890
+ const content_items_self = ['Content', 'Items', 'Self'];
891
+ const blockSize_height_inlineSize_width = ['BlockSize', 'Height', 'InlineSize', width];
892
+ const after_before = ['After', 'Before'];
893
+ combine('borderBlock', color_style_width);
894
+ combine('borderBlockEnd', color_style_width);
895
+ combine('borderBlockStart', color_style_width);
896
+ combine('outline', [...color_style_width, 'Offset']);
897
+ combine('border', [...color_style_width, 'Boundary', 'Break', 'Collapse', 'Radius', 'Spacing']);
898
+ combine('borderFit', ['Length', width]);
899
+ combine('borderInline', color_style_width);
900
+ combine('borderInlineEnd', color_style_width);
901
+ combine('borderInlineStart', color_style_width);
902
+ combine('borderLeft', color_style_width_fitlength_fitwidth_image);
903
+ combine('borderRight', color_style_width_fitlength_fitwidth_image);
904
+ combine('borderTop', color_style_width_fitlength_fitwidth_image);
905
+ combine('borderBottom', color_style_width_fitlength_fitwidth_image);
906
+ combine('textDecoration', [color, style, 'Line']);
907
+ combine('textEmphasis', [color, style, 'Position']);
908
+ combine('scrollMargin', bottom_left_right_top);
909
+ combine('scrollPadding', bottom_left_right_top);
910
+ combine('padding', bottom_left_right_top);
911
+ combine('margin', [...bottom_left_right_top, 'Trim']);
912
+ combine('scrollMarginBlock', end_start);
913
+ combine('scrollMarginInline', end_start);
914
+ combine('scrollPaddingBlock', end_start);
915
+ combine('scrollPaddingInline', end_start);
916
+ combine('gridColumn', end_start);
917
+ combine('gridRow', end_start);
918
+ combine('insetBlock', end_start);
919
+ combine('insetInline', end_start);
920
+ combine('marginBlock', end_start);
921
+ combine('marginInline', end_start);
922
+ combine('paddingBlock', end_start);
923
+ combine('paddingInline', end_start);
924
+ combine('pause', after_before);
925
+ combine('cue', after_before);
926
+ combine('mask', ['Clip', 'Composite', image, 'Mode', 'Origin', 'Position', 'Repeat', size, 'Type']);
927
+ combine('borderImage', ['Outset', 'Repeat', 'Slice', 'Source', 'Transform', width]);
928
+ combine('maskBorder', ['Mode', 'Outset', 'Repeat', 'Slice', 'Source', width]);
929
+ combine('font', ['Family', 'FeatureSettings', 'Kerning', 'LanguageOverride', 'MaxSize', 'MinSize', 'OpticalSizing', 'Palette', size, 'SizeAdjust', 'Stretch', style, 'Weight', 'VariationSettings']);
930
+ combine('transform', ['Box', 'Origin', style]);
931
+ combine('background', [color, image, 'Attachment', 'BlendMode', 'Clip', 'Origin', 'Position', 'Repeat', size]);
932
+ combine('listStyle', [image, 'Position', 'Type']);
933
+ combine('scrollSnap', ['Align', 'Stop', 'Type']);
934
+ combine('grid', ['Area', 'AutoColumns', 'AutoFlow', 'AutoRows']);
935
+ combine('gridTemplate', ['Areas', 'Columns', 'Rows']);
936
+ combine('overflow', ['Block', 'Inline', 'Wrap', 'X', 'Y']);
937
+ combine('transition', ['Delay', 'Duration', 'Property', 'TimingFunction']);
938
+ combine('color', ['Adjust', 'InterpolationFilters', 'Scheme']);
939
+ combine('textAlign', ['All', 'Last']);
940
+ combine('page', ['BreakAfter', 'BreakBefore', 'BreakInside']);
941
+ combine('animation', ['Delay', 'Direction', 'Duration', 'FillMode', 'IterationCount', 'Name', 'PlayState', 'TimingFunction']);
942
+ combine('flex', ['Basis', 'Direction', 'Flow', 'Grow', 'Shrink', 'Wrap']);
943
+ combine('offset', [...after_before, ...end_start, 'Anchor', 'Distance', 'Path', 'Position', 'Rotate']);
944
+ combine('perspective', ['Origin']);
945
+ combine('clip', ['Path', 'Rule']);
946
+ combine('flow', ['From', 'Into']);
947
+ combine('align', ['Content', 'Items', 'Self'], true);
948
+ combine('alignment', ['Adjust', 'Baseline'], true);
949
+ combine('borderStart', endRadius_startRadius, true);
950
+ combine('borderEnd', endRadius_startRadius, true);
951
+ combine('borderCorner', ['Fit', image, 'ImageTransform'], true);
952
+ combine('borderTopLeft', fitlength_fitwidth_image_radius, true);
953
+ combine('borderTopRight', fitlength_fitwidth_image_radius, true);
954
+ combine('borderBottomLeft', fitlength_fitwidth_image_radius, true);
955
+ combine('borderBottomRight', fitlength_fitwidth_image_radius, true);
956
+ combine('column', ['s', 'Count', 'Fill', 'Gap', 'Rule', 'RuleColor', 'RuleStyle', 'RuleWidth', 'Span', width], true);
957
+ combine('break', [...after_before, 'Inside'], true);
958
+ combine('wrap', [...after_before, 'Flow', 'Inside', 'Through'], true);
959
+ combine('justify', content_items_self, true);
960
+ combine('place', content_items_self, true);
961
+ combine('max', [...blockSize_height_inlineSize_width, 'Lines'], true);
962
+ combine('min', blockSize_height_inlineSize_width, true);
963
+ combine('line', ['Break', 'Clamp', 'Grid', 'Height', 'Padding', 'Snap'], true);
964
+ combine('inline', ['BoxAlign', size, 'Sizing'], true);
965
+ combine('text', ['CombineUpright', 'GroupAlign', 'Height', 'Indent', 'Justify', 'Orientation', 'Overflow', 'Shadow', 'SpaceCollapse', 'SpaceTrim', 'Spacing', 'Transform', 'UnderlinePosition', 'Wrap'], true);
966
+ combine('shape', ['ImageThreshold', 'Inside', 'Margin', 'Outside'], true);
967
+ combine('word', ['Break', 'Spacing', 'Wrap'], true);
968
+ combine('object', ['Fit', 'Position'], true);
969
+ combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
970
+ combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
971
+
972
+ function recordCss(obj) {
973
+ MutationObserver.record({
974
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
975
+ target: obj._element,
976
+ attributeName: 'style',
977
+ oldValue: obj.cssText
978
+ });
979
+ }
980
+ function enqueueUpdate(obj) {
981
+ const element = obj._element;
982
+ if (element._root) {
983
+ element.enqueueUpdate({
984
+ path: `${element._path}.${"st" /* Shortcuts.Style */}`,
985
+ value: obj.cssText
986
+ });
987
+ }
988
+ }
989
+ function setStyle(newVal, styleKey) {
990
+ process.env.NODE_ENV !== 'production' && shared.warn(shared.isString(newVal) && newVal.length > PROPERTY_THRESHOLD, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
991
+ const old = this[styleKey];
992
+ if (old === newVal)
993
+ return;
994
+ !this._pending && recordCss(this);
995
+ if (shared.isNull(newVal) || shared.isUndefined(newVal)) {
996
+ this._usedStyleProp.delete(styleKey);
997
+ delete this._value[styleKey];
998
+ }
999
+ else {
1000
+ this._usedStyleProp.add(styleKey);
1001
+ this._value[styleKey] = newVal;
1002
+ }
1003
+ !this._pending && enqueueUpdate(this);
1004
+ }
1005
+ function initStyle(ctor, styleProperties) {
1006
+ const properties = {};
1007
+ for (let i = 0; i < styleProperties.length; i++) {
1008
+ const styleKey = styleProperties[i];
1009
+ if (ctor[styleKey])
1010
+ return;
1011
+ properties[styleKey] = {
1012
+ get() {
1013
+ const val = this._value[styleKey];
1014
+ return shared.isNull(val) || shared.isUndefined(val) ? '' : val;
1015
+ },
1016
+ set(newVal) {
1017
+ setStyle.call(this, newVal, styleKey);
1018
+ }
1019
+ };
1020
+ }
1021
+ Object.defineProperties(ctor.prototype, properties);
1022
+ }
1023
+ function isCssVariable(propertyName) {
1024
+ return /^--/.test(propertyName);
1025
+ }
1026
+ class Style {
1027
+ constructor(element) {
1028
+ this._element = element;
1029
+ this._usedStyleProp = new Set();
1030
+ this._value = {};
1031
+ }
1032
+ setCssVariables(styleKey) {
1033
+ this.hasOwnProperty(styleKey) || Object.defineProperty(this, styleKey, {
1034
+ enumerable: true,
1035
+ configurable: true,
1036
+ get: () => {
1037
+ return this._value[styleKey] || '';
1038
+ },
1039
+ set: (newVal) => {
1040
+ setStyle.call(this, newVal, styleKey);
1041
+ }
1042
+ });
1043
+ }
1044
+ get cssText() {
1045
+ if (!this._usedStyleProp.size)
1046
+ return '';
1047
+ const texts = [];
1048
+ this._usedStyleProp.forEach(key => {
1049
+ const val = this[key];
1050
+ if (shared.isNull(val) || shared.isUndefined(val))
1051
+ return;
1052
+ let styleName = isCssVariable(key) ? key : shared.toDashed(key);
1053
+ if (styleName.indexOf('webkit') === 0 || styleName.indexOf('Webkit') === 0) {
1054
+ styleName = `-${styleName}`;
1055
+ }
1056
+ texts.push(`${styleName}: ${val};`);
1057
+ });
1058
+ return texts.join(' ');
1059
+ }
1060
+ set cssText(str) {
1061
+ this._pending = true;
1062
+ recordCss(this);
1063
+ this._usedStyleProp.forEach(prop => {
1064
+ this.removeProperty(prop);
1065
+ });
1066
+ if (str === '' || shared.isUndefined(str) || shared.isNull(str)) {
1067
+ this._pending = false;
1068
+ enqueueUpdate(this);
1069
+ return;
1070
+ }
1071
+ const rules = str.split(';');
1072
+ for (let i = 0; i < rules.length; i++) {
1073
+ const rule = rules[i].trim();
1074
+ if (rule === '') {
1075
+ continue;
1076
+ }
1077
+ // 可能存在 'background: url(http:x/y/z)' 的情况
1078
+ const [propName, ...valList] = rule.split(':');
1079
+ const val = valList.join(':');
1080
+ if (shared.isUndefined(val)) {
1081
+ continue;
1082
+ }
1083
+ this.setProperty(propName.trim(), val.trim());
1084
+ }
1085
+ this._pending = false;
1086
+ enqueueUpdate(this);
1087
+ }
1088
+ setProperty(propertyName, value) {
1089
+ if (propertyName[0] === '-') {
1090
+ // 支持 webkit 属性或 css 变量
1091
+ this.setCssVariables(propertyName);
1092
+ }
1093
+ else {
1094
+ propertyName = shared.toCamelCase(propertyName);
1095
+ }
1096
+ if (shared.isNull(value) || shared.isUndefined(value)) {
1097
+ this.removeProperty(propertyName);
1098
+ }
1099
+ else {
1100
+ this[propertyName] = value;
1101
+ }
1102
+ }
1103
+ removeProperty(propertyName) {
1104
+ propertyName = shared.toCamelCase(propertyName);
1105
+ if (!this._usedStyleProp.has(propertyName)) {
1106
+ return '';
1107
+ }
1108
+ const value = this[propertyName];
1109
+ this[propertyName] = undefined;
1110
+ return value;
1111
+ }
1112
+ getPropertyValue(propertyName) {
1113
+ propertyName = shared.toCamelCase(propertyName);
1114
+ const value = this[propertyName];
1115
+ if (!value) {
1116
+ return '';
1117
+ }
1118
+ return value;
1119
+ }
1120
+ }
1121
+ initStyle(Style, styleProperties);
1122
+ shared.hooks.tap('injectNewStyleProperties', (newStyleProperties) => {
1123
+ if (shared.isArray(newStyleProperties)) {
1124
+ initStyle(Style, newStyleProperties);
1125
+ }
1126
+ else {
1127
+ if (typeof newStyleProperties !== 'string')
1128
+ return;
1129
+ initStyle(Style, [newStyleProperties]);
1130
+ }
1131
+ });
1132
+
1133
+ function returnTrue() {
1134
+ return true;
1135
+ }
1136
+ function treeToArray(root, predict) {
1137
+ const array = [];
1138
+ const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
1139
+ let object = root;
1140
+ while (object) {
1141
+ if (object.nodeType === 1 /* NodeType.ELEMENT_NODE */ && filter(object)) {
1142
+ array.push(object);
1143
+ }
1144
+ object = following(object, root);
1145
+ }
1146
+ return array;
1147
+ }
1148
+ function following(el, root) {
1149
+ const firstChild = el.firstChild;
1150
+ const isElmentTypeValid = el.nodeType === 1 /* NodeType.ELEMENT_NODE */ || el.nodeType === 9 /* NodeType.DOCUMENT_NODE */;
1151
+ // 如果当前 el 不是 element 或 document 元素,则可以直接不递归他的子元素了
1152
+ if (firstChild && isElmentTypeValid) {
1153
+ return firstChild;
1154
+ }
1155
+ let current = el;
1156
+ do {
1157
+ if (current === root) {
1158
+ return null;
1159
+ }
1160
+ const nextSibling = current.nextSibling;
1161
+ if (nextSibling) {
1162
+ return nextSibling;
1163
+ }
1164
+ current = current.parentElement;
1165
+ } while (current);
1166
+ return null;
1167
+ }
1168
+
1169
+ class TaroElement extends TaroNode {
1170
+ constructor() {
1171
+ super();
1172
+ this.props = {};
1173
+ this.dataset = shared.EMPTY_OBJ;
1174
+ this.nodeType = 1 /* NodeType.ELEMENT_NODE */;
1175
+ this.style = new Style(this);
1176
+ shared.hooks.call('patchElement', this);
1177
+ }
1178
+ _stopPropagation(event) {
1179
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1180
+ let target = this;
1181
+ // eslint-disable-next-line no-cond-assign
1182
+ while ((target = target.parentNode)) {
1183
+ const listeners = target.__handlers[event.type];
1184
+ if (!shared.isArray(listeners)) {
1185
+ continue;
1186
+ }
1187
+ for (let i = listeners.length; i--;) {
1188
+ const l = listeners[i];
1189
+ l._stop = true;
1190
+ }
1191
+ }
1192
+ }
1193
+ get id() {
1194
+ return this.getAttribute(ID);
1195
+ }
1196
+ set id(val) {
1197
+ this.setAttribute(ID, val);
1198
+ }
1199
+ get className() {
1200
+ return this.getAttribute(CLASS) || '';
1201
+ }
1202
+ set className(val) {
1203
+ this.setAttribute(CLASS, val);
1204
+ }
1205
+ get cssText() {
1206
+ return this.getAttribute(STYLE) || '';
1207
+ }
1208
+ get classList() {
1209
+ return new ClassList(this.className, this);
1210
+ }
1211
+ get children() {
1212
+ return this.childNodes.filter(isElement);
1213
+ }
1214
+ get attributes() {
1215
+ const props = this.props;
1216
+ const propKeys = Object.keys(props);
1217
+ const style = this.style.cssText;
1218
+ const attrs = propKeys.map(key => ({ name: key, value: props[key] }));
1219
+ return attrs.concat(style ? { name: STYLE, value: style } : []);
1220
+ }
1221
+ get textContent() {
1222
+ let text = '';
1223
+ const childNodes = this.childNodes;
1224
+ for (let i = 0; i < childNodes.length; i++) {
1225
+ text += childNodes[i].textContent;
1226
+ }
1227
+ return text;
1228
+ }
1229
+ set textContent(text) {
1230
+ super.textContent = text;
1231
+ }
1232
+ hasAttribute(qualifiedName) {
1233
+ return !shared.isUndefined(this.props[qualifiedName]);
1234
+ }
1235
+ hasAttributes() {
1236
+ return this.attributes.length > 0;
1237
+ }
1238
+ get focus() {
1239
+ return function () {
1240
+ this.setAttribute(FOCUS, true);
1241
+ };
1242
+ }
1243
+ // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579
1244
+ set focus(value) {
1245
+ this.setAttribute(FOCUS, value);
1246
+ }
1247
+ blur() {
1248
+ this.setAttribute(FOCUS, false);
1249
+ }
1250
+ setAttribute(qualifiedName, value) {
1251
+ process.env.NODE_ENV !== 'production' && shared.warn(shared.isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
1252
+ const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
1253
+ if (qualifiedName !== STYLE) {
1254
+ MutationObserver.record({
1255
+ target: this,
1256
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1257
+ attributeName: qualifiedName,
1258
+ oldValue: this.getAttribute(qualifiedName)
1259
+ });
1260
+ }
1261
+ switch (qualifiedName) {
1262
+ case STYLE:
1263
+ this.style.cssText = value;
1264
+ break;
1265
+ case ID:
1266
+ if (this.uid !== this.sid) {
1267
+ // eventSource[sid] 永远保留,直到组件卸载
1268
+ // eventSource[uid] 可变
1269
+ eventSource.delete(this.uid);
1270
+ }
1271
+ value = String(value);
1272
+ this.props[qualifiedName] = this.uid = value;
1273
+ eventSource.set(value, this);
1274
+ break;
1275
+ default:
1276
+ this.props[qualifiedName] = value;
1277
+ if (qualifiedName.startsWith('data-')) {
1278
+ if (this.dataset === shared.EMPTY_OBJ) {
1279
+ this.dataset = Object.create(null);
1280
+ }
1281
+ this.dataset[shared.toCamelCase(qualifiedName.replace(/^data-/, ''))] = value;
1282
+ }
1283
+ break;
1284
+ }
1285
+ // Serialization
1286
+ if (!this._root)
1287
+ return;
1288
+ const componentsAlias = getComponentsAlias();
1289
+ const _alias = componentsAlias[this.nodeName];
1290
+ const viewAlias = componentsAlias[VIEW]._num;
1291
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
1292
+ const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
1293
+ const _path = this._path;
1294
+ qualifiedName = shortcutAttr(qualifiedName);
1295
+ const qualifiedNameInCamelCase = shared.toCamelCase(qualifiedName);
1296
+ const payload = {
1297
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1298
+ value: shared.isFunction(value) ? () => value : value
1299
+ };
1300
+ shared.hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias);
1301
+ if (_alias) {
1302
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1303
+ payload.path = `${_path}.${shared.toCamelCase(qualifiedNameAlias)}`;
1304
+ }
1305
+ this.enqueueUpdate(payload);
1306
+ if (this.nodeName === VIEW) {
1307
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1308
+ // catchMove = true: catch-view
1309
+ // catchMove = false: view or static-view
1310
+ this.enqueueUpdate({
1311
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1312
+ value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
1313
+ });
1314
+ }
1315
+ else if (isPureView && isHasExtractProp(this)) {
1316
+ // pure-view => static-view
1317
+ this.enqueueUpdate({
1318
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1319
+ value: staticViewAlias
1320
+ });
1321
+ }
1322
+ }
1323
+ }
1324
+ removeAttribute(qualifiedName) {
1325
+ const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded();
1326
+ MutationObserver.record({
1327
+ target: this,
1328
+ type: "attributes" /* MutationRecordType.ATTRIBUTES */,
1329
+ attributeName: qualifiedName,
1330
+ oldValue: this.getAttribute(qualifiedName)
1331
+ });
1332
+ if (qualifiedName === STYLE) {
1333
+ this.style.cssText = '';
1334
+ }
1335
+ else {
1336
+ const isInterrupt = shared.hooks.call('onRemoveAttribute', this, qualifiedName);
1337
+ if (isInterrupt) {
1338
+ return;
1339
+ }
1340
+ if (!this.props.hasOwnProperty(qualifiedName)) {
1341
+ return;
1342
+ }
1343
+ delete this.props[qualifiedName];
1344
+ }
1345
+ // Serialization
1346
+ if (!this._root)
1347
+ return;
1348
+ const componentsAlias = getComponentsAlias();
1349
+ const _alias = componentsAlias[this.nodeName];
1350
+ const viewAlias = componentsAlias[VIEW]._num;
1351
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
1352
+ const pureViewAlias = componentsAlias[PURE_VIEW]._num;
1353
+ const _path = this._path;
1354
+ qualifiedName = shortcutAttr(qualifiedName);
1355
+ const qualifiedNameInCamelCase = shared.toCamelCase(qualifiedName);
1356
+ const payload = {
1357
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1358
+ value: ''
1359
+ };
1360
+ shared.hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias);
1361
+ if (_alias) {
1362
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1363
+ payload.path = `${_path}.${shared.toCamelCase(qualifiedNameAlias)}`;
1364
+ }
1365
+ this.enqueueUpdate(payload);
1366
+ if (this.nodeName === VIEW) {
1367
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1368
+ // catch-view => view or static-view or pure-view
1369
+ this.enqueueUpdate({
1370
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1371
+ value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
1372
+ });
1373
+ }
1374
+ else if (isStaticView && !isHasExtractProp(this)) {
1375
+ // static-view => pure-view
1376
+ this.enqueueUpdate({
1377
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
1378
+ value: pureViewAlias
1379
+ });
1380
+ }
1381
+ }
1382
+ }
1383
+ getAttribute(qualifiedName) {
1384
+ const attr = qualifiedName === STYLE ? this.style.cssText : this.props[qualifiedName];
1385
+ return attr !== null && attr !== void 0 ? attr : '';
1386
+ }
1387
+ getElementsByTagName(tagName) {
1388
+ return treeToArray(this, (el) => {
1389
+ return el.nodeName === tagName || (tagName === '*' && this !== el);
1390
+ });
1391
+ }
1392
+ getElementsByClassName(className) {
1393
+ const classNames = className.trim().split(/\s+/);
1394
+ return treeToArray(this, (el) => {
1395
+ const classList = el.classList;
1396
+ return classNames.every(c => classList.contains(c));
1397
+ });
1398
+ }
1399
+ dispatchEvent(event) {
1400
+ const cancelable = event.cancelable;
1401
+ const listeners = this.__handlers[event.type];
1402
+ if (!shared.isArray(listeners)) {
1403
+ return false;
1404
+ }
1405
+ for (let i = listeners.length; i--;) {
1406
+ const listener = listeners[i];
1407
+ let result;
1408
+ if (listener._stop) {
1409
+ listener._stop = false;
1410
+ }
1411
+ else {
1412
+ shared.hooks.call('modifyDispatchEvent', event, this);
1413
+ result = listener.call(this, event);
1414
+ }
1415
+ if ((result === false || event._end) && cancelable) {
1416
+ event.defaultPrevented = true;
1417
+ }
1418
+ if (!shared.isUndefined(result) && event.mpEvent) {
1419
+ event.mpEvent[EVENT_CALLBACK_RESULT] = result;
1420
+ }
1421
+ if (event._end && event._stop) {
1422
+ break;
1423
+ }
1424
+ }
1425
+ if (event._stop) {
1426
+ this._stopPropagation(event);
1427
+ }
1428
+ else {
1429
+ event._stop = true;
1430
+ }
1431
+ return listeners != null;
1432
+ }
1433
+ addEventListener(type, handler, options) {
1434
+ const name = this.nodeName;
1435
+ const SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
1436
+ let sideEffect = true;
1437
+ if (shared.isObject(options) && options.sideEffect === false) {
1438
+ sideEffect = false;
1439
+ delete options.sideEffect;
1440
+ }
1441
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1442
+ const componentsAlias = getComponentsAlias();
1443
+ const alias = componentsAlias[name]._num;
1444
+ this.enqueueUpdate({
1445
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
1446
+ value: alias
1447
+ });
1448
+ }
1449
+ super.addEventListener(type, handler, options);
1450
+ }
1451
+ removeEventListener(type, handler, sideEffect = true) {
1452
+ super.removeEventListener(type, handler);
1453
+ const name = this.nodeName;
1454
+ const SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
1455
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1456
+ const componentsAlias = getComponentsAlias();
1457
+ const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
1458
+ const valueAlias = componentsAlias[value]._num;
1459
+ this.enqueueUpdate({
1460
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
1461
+ value: valueAlias
1462
+ });
1463
+ }
1464
+ }
1465
+ static extend(methodName, options) {
1466
+ extend(TaroElement, methodName, options);
1467
+ }
1468
+ }
1469
+
1470
+ const options = {
1471
+ prerender: true,
1472
+ debug: false
1473
+ };
1474
+
1475
+ function makeMap(str, expectsLowerCase) {
1476
+ const map = Object.create(null);
1477
+ const list = str.split(',');
1478
+ for (let i = 0; i < list.length; i++) {
1479
+ map[list[i]] = true;
1480
+ }
1481
+ return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
1482
+ }
1483
+ const internalCompsList = Object.keys(shared.internalComponents)
1484
+ .map(i => i.toLowerCase())
1485
+ .join(',');
1486
+ // https://developers.weixin.qq.com/miniprogram/dev/component
1487
+ makeMap(internalCompsList, true);
1488
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
1489
+ 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);
1490
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
1491
+ 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);
1492
+
1493
+ options.html = {
1494
+ skipElements: new Set(['style', 'script']),
1495
+ voidElements: new Set([
1496
+ '!doctype', 'area', 'base', 'br', 'col', 'command',
1497
+ 'embed', 'hr', 'img', 'input', 'keygen', 'link',
1498
+ 'meta', 'param', 'source', 'track', 'wbr'
1499
+ ]),
1500
+ closingElements: new Set([
1501
+ 'html', 'head', 'body', 'p', 'dt', 'dd', 'li', 'option',
1502
+ 'thead', 'th', 'tbody', 'tr', 'td', 'tfoot', 'colgroup'
1503
+ ]),
1504
+ renderHTMLTag: false
1505
+ };
1506
+
1507
+ // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
1508
+ class TaroEvent {
1509
+ constructor(type, opts, event) {
1510
+ this._stop = false;
1511
+ this._end = false;
1512
+ this.defaultPrevented = false;
1513
+ // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
1514
+ this.button = 0;
1515
+ // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
1516
+ // here use hi-res timestamp
1517
+ this.timeStamp = Date.now();
1518
+ this.type = type.toLowerCase();
1519
+ this.mpEvent = event;
1520
+ this.bubbles = Boolean(opts && opts.bubbles);
1521
+ this.cancelable = Boolean(opts && opts.cancelable);
1522
+ }
1523
+ stopPropagation() {
1524
+ this._stop = true;
1525
+ }
1526
+ stopImmediatePropagation() {
1527
+ this._end = this._stop = true;
1528
+ }
1529
+ preventDefault() {
1530
+ this.defaultPrevented = true;
1531
+ }
1532
+ get target() {
1533
+ var _a, _b, _c, _d;
1534
+ const cacheTarget = this.cacheTarget;
1535
+ if (!cacheTarget) {
1536
+ const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
1537
+ // Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
1538
+ 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);
1539
+ target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
1540
+ for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
1541
+ target[key] = this.mpEvent.detail[key];
1542
+ }
1543
+ this.cacheTarget = target;
1544
+ return target;
1545
+ }
1546
+ else {
1547
+ return cacheTarget;
1548
+ }
1549
+ }
1550
+ get currentTarget() {
1551
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1552
+ const cacheCurrentTarget = this.cacheCurrentTarget;
1553
+ if (!cacheCurrentTarget) {
1554
+ const doc = env.document;
1555
+ const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
1556
+ const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
1557
+ 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);
1558
+ if (element === null || (element && element === targetElement)) {
1559
+ this.cacheCurrentTarget = this.target;
1560
+ return this.target;
1561
+ }
1562
+ currentTarget.dataset = element.dataset;
1563
+ for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
1564
+ currentTarget[key] = this.mpEvent.detail[key];
1565
+ }
1566
+ this.cacheCurrentTarget = currentTarget;
1567
+ return currentTarget;
1568
+ }
1569
+ else {
1570
+ return cacheCurrentTarget;
1571
+ }
1572
+ }
1573
+ }
1574
+ function createEvent(event, node) {
1575
+ if (typeof event === 'string') {
1576
+ // For Vue3 using document.createEvent
1577
+ return new TaroEvent(event, { bubbles: true, cancelable: true });
1578
+ }
1579
+ const domEv = new TaroEvent(event.type, { bubbles: true, cancelable: true }, event);
1580
+ for (const key in event) {
1581
+ if (key === CURRENT_TARGET || key === TARGET || key === TYPE || key === TIME_STAMP) {
1582
+ continue;
1583
+ }
1584
+ else {
1585
+ domEv[key] = event[key];
1586
+ }
1587
+ }
1588
+ if (domEv.type === CONFIRM && (node === null || node === void 0 ? void 0 : node.nodeName) === INPUT) {
1589
+ // eslint-disable-next-line dot-notation
1590
+ domEv[KEY_CODE] = 13;
1591
+ }
1592
+ return domEv;
1593
+ }
1594
+ const eventsBatch = {};
1595
+ function getEventCBResult(event) {
1596
+ const result = event[EVENT_CALLBACK_RESULT];
1597
+ if (!shared.isUndefined(result)) {
1598
+ delete event[EVENT_CALLBACK_RESULT];
1599
+ }
1600
+ return result;
1601
+ }
1602
+ // 小程序的事件代理回调函数
1603
+ function eventHandler(event) {
1604
+ var _a, _b;
1605
+ // Note: ohos 上事件没有设置 type、detail 类型 setter 方法,且部分事件(例如 load 等)缺失 target 导致事件错误
1606
+ event.type === undefined && Object.defineProperty(event, 'type', {
1607
+ value: event._type // ohos only
1608
+ });
1609
+ event.detail === undefined && Object.defineProperty(event, 'detail', {
1610
+ value: event._detail || Object.assign({}, event) // ohos only
1611
+ });
1612
+ event.currentTarget = event.currentTarget || event.target || Object.assign({}, event);
1613
+ shared.hooks.call('modifyMpEventImpl', event);
1614
+ const currentTarget = event.currentTarget;
1615
+ 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) || '';
1616
+ const node = env.document.getElementById(id);
1617
+ if (node) {
1618
+ const dispatch = () => {
1619
+ const e = createEvent(event, node);
1620
+ shared.hooks.call('modifyTaroEvent', e, node);
1621
+ shared.hooks.call('dispatchTaroEvent', e, node);
1622
+ shared.hooks.call('dispatchTaroEventFinish', e, node);
1623
+ };
1624
+ if (shared.hooks.isExist('batchedEventUpdates')) {
1625
+ const type = event.type;
1626
+ if (!shared.hooks.call('isBubbleEvents', type) ||
1627
+ !isParentBinded(node, type) ||
1628
+ (type === TOUCHMOVE && !!node.props.catchMove)) {
1629
+ // 最上层组件统一 batchUpdate
1630
+ shared.hooks.call('batchedEventUpdates', () => {
1631
+ if (eventsBatch[type]) {
1632
+ eventsBatch[type].forEach(fn => fn());
1633
+ delete eventsBatch[type];
1634
+ }
1635
+ dispatch();
1636
+ });
1637
+ return getEventCBResult(event);
1638
+ }
1639
+ else {
1640
+ // 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
1641
+ (eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
1642
+ }
1643
+ }
1644
+ else {
1645
+ dispatch();
1646
+ return getEventCBResult(event);
1647
+ }
1648
+ }
1649
+ }
1650
+
1651
+ class FormElement extends TaroElement {
1652
+ get type() {
1653
+ var _a;
1654
+ return (_a = this.props[TYPE]) !== null && _a !== void 0 ? _a : '';
1655
+ }
1656
+ set type(val) {
1657
+ this.setAttribute(TYPE, val);
1658
+ }
1659
+ get value() {
1660
+ // eslint-disable-next-line dot-notation
1661
+ const val = this.props[VALUE];
1662
+ return val == null ? '' : val;
1663
+ }
1664
+ set value(val) {
1665
+ this.setAttribute(VALUE, val);
1666
+ }
1667
+ dispatchEvent(event) {
1668
+ if (event.mpEvent) {
1669
+ const val = event.mpEvent.detail.value;
1670
+ if (event.type === CHANGE) {
1671
+ this.props.value = val;
1672
+ }
1673
+ else if (event.type === INPUT) {
1674
+ // Web 规范中表单组件的 value 应该跟着输入改变
1675
+ // 只是改 this.props.value 的话不会进行 setData,因此这里修改 this.value。
1676
+ // 只测试了 React、Vue、Vue3 input 组件的 onInput 事件,onChange 事件不确定有没有副作用,所以暂不修改。
1677
+ this.value = val;
1678
+ }
1679
+ }
1680
+ return super.dispatchEvent(event);
1681
+ }
1682
+ }
1683
+
1684
+ class Performance {
1685
+ constructor() {
1686
+ this.recorder = new Map();
1687
+ }
1688
+ start(id) {
1689
+ if (!options.debug) {
1690
+ return;
1691
+ }
1692
+ this.recorder.set(id, Date.now());
1693
+ }
1694
+ stop(id) {
1695
+ if (!options.debug) {
1696
+ return;
1697
+ }
1698
+ const now = Date.now();
1699
+ const prev = this.recorder.get(id);
1700
+ this.recorder.delete(id);
1701
+ const time = now - prev;
1702
+ // eslint-disable-next-line no-console
1703
+ console.log(`${id} 时长: ${time}ms`);
1704
+ }
1705
+ }
1706
+ const perf = new Performance();
1707
+
1708
+ function findCustomWrapper(root, dataPathArr) {
1709
+ // ['root', 'cn', '[0]'] remove 'root' => ['cn', '[0]']
1710
+ const list = dataPathArr.slice(1);
1711
+ let currentData = root;
1712
+ let customWrapper;
1713
+ let splitedPath = '';
1714
+ list.some((item, i) => {
1715
+ const key = item
1716
+ // '[0]' => '0'
1717
+ .replace(/^\[(.+)\]$/, '$1')
1718
+ // 'cn' => 'childNodes'
1719
+ .replace(/\bcn\b/g, 'childNodes');
1720
+ currentData = currentData[key];
1721
+ if (shared.isArray(currentData)) {
1722
+ currentData = currentData.filter(el => !isComment(el));
1723
+ }
1724
+ if (shared.isUndefined(currentData))
1725
+ return true;
1726
+ if (currentData.nodeName === CUSTOM_WRAPPER) {
1727
+ const res = customWrapperCache.get(currentData.sid);
1728
+ if (res) {
1729
+ customWrapper = res;
1730
+ splitedPath = dataPathArr.slice(i + 2).join('.');
1731
+ }
1732
+ }
1733
+ });
1734
+ if (customWrapper) {
1735
+ return {
1736
+ customWrapper,
1737
+ splitedPath
1738
+ };
1739
+ }
1740
+ }
1741
+ class TaroRootElement extends TaroElement {
1742
+ constructor() {
1743
+ super();
1744
+ this.updatePayloads = [];
1745
+ this.updateCallbacks = [];
1746
+ this.pendingUpdate = false;
1747
+ this.ctx = null;
1748
+ this.nodeName = ROOT_STR;
1749
+ this.tagName = ROOT_STR.toUpperCase();
1750
+ }
1751
+ get _path() {
1752
+ return ROOT_STR;
1753
+ }
1754
+ get _root() {
1755
+ return this;
1756
+ }
1757
+ enqueueUpdate(payload) {
1758
+ this.updatePayloads.push(payload);
1759
+ if (!this.pendingUpdate && this.ctx) {
1760
+ this.performUpdate();
1761
+ }
1762
+ }
1763
+ performUpdate(initRender = false, prerender) {
1764
+ this.pendingUpdate = true;
1765
+ const ctx = shared.hooks.call('proxyToRaw', this.ctx);
1766
+ setTimeout(() => {
1767
+ const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;
1768
+ perf.start(setDataMark);
1769
+ const data = Object.create(null);
1770
+ const resetPaths = new Set(initRender
1771
+ ? ['root.cn.[0]', 'root.cn[0]']
1772
+ : []);
1773
+ while (this.updatePayloads.length > 0) {
1774
+ const { path, value } = this.updatePayloads.shift();
1775
+ if (path.endsWith("cn" /* Shortcuts.Childnodes */)) {
1776
+ resetPaths.add(path);
1777
+ }
1778
+ data[path] = value;
1779
+ }
1780
+ for (const path in data) {
1781
+ resetPaths.forEach(p => {
1782
+ // 已经重置了数组,就不需要分别再设置了
1783
+ if (path.includes(p) && path !== p) {
1784
+ delete data[path];
1785
+ }
1786
+ });
1787
+ const value = data[path];
1788
+ if (shared.isFunction(value)) {
1789
+ data[path] = value();
1790
+ }
1791
+ }
1792
+ // 预渲染
1793
+ if (shared.isFunction(prerender))
1794
+ return prerender(data);
1795
+ // 正常渲染
1796
+ this.pendingUpdate = false;
1797
+ let normalUpdate = {};
1798
+ const customWrapperMap = new Map();
1799
+ if (initRender) {
1800
+ // 初次渲染,使用页面级别的 setData
1801
+ normalUpdate = data;
1802
+ }
1803
+ else {
1804
+ // 更新渲染,区分 CustomWrapper 与页面级别的 setData
1805
+ for (const p in data) {
1806
+ const dataPathArr = p.split('.');
1807
+ const found = findCustomWrapper(this, dataPathArr);
1808
+ if (found) {
1809
+ // 此项数据使用 CustomWrapper 去更新
1810
+ const { customWrapper, splitedPath } = found;
1811
+ // 合并同一个 customWrapper 的相关更新到一次 setData 中
1812
+ customWrapperMap.set(customWrapper, Object.assign(Object.assign({}, (customWrapperMap.get(customWrapper) || {})), { [`i.${splitedPath}`]: data[p] }));
1813
+ }
1814
+ else {
1815
+ // 此项数据使用页面去更新
1816
+ normalUpdate[p] = data[p];
1817
+ }
1818
+ }
1819
+ }
1820
+ const customWrapperCount = customWrapperMap.size;
1821
+ const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;
1822
+ const updateArrLen = customWrapperCount + (isNeedNormalUpdate ? 1 : 0);
1823
+ let executeTime = 0;
1824
+ const cb = () => {
1825
+ if (++executeTime === updateArrLen) {
1826
+ perf.stop(setDataMark);
1827
+ this.flushUpdateCallback();
1828
+ initRender && perf.stop(PAGE_INIT);
1829
+ }
1830
+ };
1831
+ // custom-wrapper setData
1832
+ if (customWrapperCount) {
1833
+ customWrapperMap.forEach((data, ctx) => {
1834
+ if (process.env.NODE_ENV !== 'production' && options.debug) {
1835
+ // eslint-disable-next-line no-console
1836
+ console.log('custom wrapper setData: ', data);
1837
+ }
1838
+ ctx.setData(data, cb);
1839
+ });
1840
+ }
1841
+ // page setData
1842
+ if (isNeedNormalUpdate) {
1843
+ if (process.env.NODE_ENV !== 'production' && options.debug) {
1844
+ // eslint-disable-next-line no-console
1845
+ console.log('page setData:', normalUpdate);
1846
+ }
1847
+ ctx.setData(normalUpdate, cb);
1848
+ }
1849
+ }, 0);
1850
+ }
1851
+ enqueueUpdateCallback(cb, ctx) {
1852
+ this.updateCallbacks.push(() => {
1853
+ ctx ? cb.call(ctx) : cb();
1854
+ });
1855
+ }
1856
+ flushUpdateCallback() {
1857
+ const updateCallbacks = this.updateCallbacks;
1858
+ if (!updateCallbacks.length)
1859
+ return;
1860
+ const copies = updateCallbacks.slice(0);
1861
+ this.updateCallbacks.length = 0;
1862
+ for (let i = 0; i < copies.length; i++) {
1863
+ copies[i]();
1864
+ }
1865
+ }
1866
+ }
1867
+
1868
+ class TaroText extends TaroNode {
1869
+ constructor(value) {
1870
+ super();
1871
+ this.nodeType = 3 /* NodeType.TEXT_NODE */;
1872
+ this.nodeName = '#text';
1873
+ this._value = value;
1874
+ }
1875
+ set textContent(text) {
1876
+ MutationObserver.record({
1877
+ target: this,
1878
+ type: "characterData" /* MutationRecordType.CHARACTER_DATA */,
1879
+ oldValue: this._value
1880
+ });
1881
+ this._value = text;
1882
+ this.enqueueUpdate({
1883
+ path: `${this._path}.${"v" /* Shortcuts.Text */}`,
1884
+ value: text
1885
+ });
1886
+ }
1887
+ get textContent() {
1888
+ return this._value;
1889
+ }
1890
+ set nodeValue(text) {
1891
+ this.textContent = text;
1892
+ }
1893
+ get nodeValue() {
1894
+ return this._value;
1895
+ }
1896
+ set data(text) {
1897
+ this.textContent = text;
1898
+ }
1899
+ get data() {
1900
+ return this._value;
1901
+ }
1902
+ }
1903
+
1904
+ /******************************************************************************
1905
+ Copyright (c) Microsoft Corporation.
1906
+
1907
+ Permission to use, copy, modify, and/or distribute this software for any
1908
+ purpose with or without fee is hereby granted.
1909
+
1910
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1911
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1912
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1913
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1914
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1915
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1916
+ PERFORMANCE OF THIS SOFTWARE.
1917
+ ***************************************************************************** */
1918
+ /* global Reflect, Promise */
1919
+
1920
+
1921
+ function __classPrivateFieldGet(receiver, state, kind, f) {
1922
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1923
+ 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");
1924
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1925
+ }
1926
+
1927
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
1928
+ if (kind === "m") throw new TypeError("Private method is not writable");
1929
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1930
+ 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");
1931
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1932
+ }
1933
+
1934
+ var _URLSearchParams_dict;
1935
+ const findReg = /[!'()~]|%20|%00/g;
1936
+ const plusReg = /\+/g;
1937
+ const replaceCharMap = {
1938
+ '!': '%21',
1939
+ "'": '%27',
1940
+ '(': '%28',
1941
+ ')': '%29',
1942
+ '~': '%7E',
1943
+ '%20': '+',
1944
+ '%00': '\x00',
1945
+ };
1946
+ function replacer(match) {
1947
+ return replaceCharMap[match];
1948
+ }
1949
+ function appendTo(dict, name, value) {
1950
+ const res = shared.isArray(value) ? value.join(',') : value;
1951
+ if (name in dict)
1952
+ dict[name].push(res);
1953
+ else
1954
+ dict[name] = [res];
1955
+ }
1956
+ function addEach(value, key) {
1957
+ appendTo(this, key, value);
1958
+ }
1959
+ function decode(str) {
1960
+ return decodeURIComponent(str.replace(plusReg, ' '));
1961
+ }
1962
+ function encode(str) {
1963
+ return encodeURIComponent(str).replace(findReg, replacer);
1964
+ }
1965
+ class URLSearchParams {
1966
+ constructor(query) {
1967
+ _URLSearchParams_dict.set(this, Object.create(null));
1968
+ query !== null && query !== void 0 ? query : (query = '');
1969
+ const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
1970
+ if (typeof query === 'string') {
1971
+ if (query.charAt(0) === '?') {
1972
+ query = query.slice(1);
1973
+ }
1974
+ for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
1975
+ const value = pairs[i];
1976
+ const index = value.indexOf('=');
1977
+ if (index > -1) {
1978
+ appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
1979
+ }
1980
+ else if (value.length) {
1981
+ appendTo(dict, decode(value), '');
1982
+ }
1983
+ }
1984
+ }
1985
+ else {
1986
+ if (shared.isArray(query)) {
1987
+ for (let i = 0, length = query.length; i < length; i++) {
1988
+ const value = query[i];
1989
+ appendTo(dict, value[0], value[1]);
1990
+ }
1991
+ }
1992
+ else if (query.forEach) {
1993
+ query.forEach(addEach, dict);
1994
+ }
1995
+ else {
1996
+ for (const key in query) {
1997
+ appendTo(dict, key, query[key]);
1998
+ }
1999
+ }
2000
+ }
2001
+ }
2002
+ append(name, value) {
2003
+ appendTo(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"), name, value);
2004
+ }
2005
+ delete(name) {
2006
+ delete __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name];
2007
+ }
2008
+ get(name) {
2009
+ const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2010
+ return name in dict ? dict[name][0] : null;
2011
+ }
2012
+ getAll(name) {
2013
+ const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2014
+ return name in dict ? dict[name].slice(0) : [];
2015
+ }
2016
+ has(name) {
2017
+ return name in __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2018
+ }
2019
+ keys() {
2020
+ return Object.keys(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"));
2021
+ }
2022
+ set(name, value) {
2023
+ __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name] = ['' + value];
2024
+ }
2025
+ forEach(callback, thisArg) {
2026
+ const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2027
+ Object.getOwnPropertyNames(dict).forEach(function (name) {
2028
+ dict[name].forEach(function (value) {
2029
+ callback.call(thisArg, value, name, this);
2030
+ }, this);
2031
+ }, this);
2032
+ }
2033
+ toJSON() {
2034
+ return {};
2035
+ }
2036
+ toString() {
2037
+ const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
2038
+ const query = [];
2039
+ for (const key in dict) {
2040
+ const name = encode(key);
2041
+ for (let i = 0, value = dict[key]; i < value.length; i++) {
2042
+ query.push(name + '=' + encode(value[i]));
2043
+ }
2044
+ }
2045
+ return query.join('&');
2046
+ }
2047
+ }
2048
+ _URLSearchParams_dict = new WeakMap();
2049
+
2050
+ var _URL_hash, _URL_hostname, _URL_pathname, _URL_port, _URL_protocol, _URL_search;
2051
+ class URL {
2052
+ static createObjectURL() {
2053
+ throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
2054
+ }
2055
+ static revokeObjectURL() {
2056
+ throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
2057
+ }
2058
+ constructor(url, base) {
2059
+ /* private property */
2060
+ _URL_hash.set(this, '');
2061
+ _URL_hostname.set(this, '');
2062
+ _URL_pathname.set(this, '');
2063
+ _URL_port.set(this, '');
2064
+ _URL_protocol.set(this, '');
2065
+ _URL_search.set(this, void 0);
2066
+ if (!shared.isString(url))
2067
+ url = String(url);
2068
+ const parseResult = parseUrlBase(url, base);
2069
+ const { hash, hostname, pathname, port, protocol, search } = parseResult;
2070
+ __classPrivateFieldSet(this, _URL_hash, hash, "f");
2071
+ __classPrivateFieldSet(this, _URL_hostname, hostname, "f");
2072
+ __classPrivateFieldSet(this, _URL_pathname, pathname || '/', "f");
2073
+ __classPrivateFieldSet(this, _URL_port, port, "f");
2074
+ __classPrivateFieldSet(this, _URL_protocol, protocol, "f");
2075
+ __classPrivateFieldSet(this, _URL_search, new URLSearchParams(search), "f");
2076
+ }
2077
+ /* public property */
2078
+ get protocol() {
2079
+ return __classPrivateFieldGet(this, _URL_protocol, "f");
2080
+ }
2081
+ set protocol(val) {
2082
+ shared.isString(val) && (__classPrivateFieldSet(this, _URL_protocol, val.trim(), "f"));
2083
+ }
2084
+ get host() {
2085
+ return this.hostname + (this.port ? ':' + this.port : '');
2086
+ }
2087
+ set host(val) {
2088
+ if (val && shared.isString(val)) {
2089
+ val = val.trim();
2090
+ const { hostname, port } = parseUrl(`//${val}`);
2091
+ this.hostname = hostname;
2092
+ this.port = port;
2093
+ }
2094
+ }
2095
+ get hostname() {
2096
+ return __classPrivateFieldGet(this, _URL_hostname, "f");
2097
+ }
2098
+ set hostname(val) {
2099
+ val && shared.isString(val) && (__classPrivateFieldSet(this, _URL_hostname, val.trim(), "f"));
2100
+ }
2101
+ get port() {
2102
+ return __classPrivateFieldGet(this, _URL_port, "f");
2103
+ }
2104
+ set port(val) {
2105
+ shared.isString(val) && (__classPrivateFieldSet(this, _URL_port, val.trim(), "f"));
2106
+ }
2107
+ get pathname() {
2108
+ return __classPrivateFieldGet(this, _URL_pathname, "f");
2109
+ }
2110
+ set pathname(val) {
2111
+ if (shared.isString(val)) {
2112
+ val = val.trim();
2113
+ const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
2114
+ let temp = val;
2115
+ while (HEAD_REG.test(temp)) {
2116
+ temp = temp.replace(HEAD_REG, '');
2117
+ }
2118
+ if (temp)
2119
+ __classPrivateFieldSet(this, _URL_pathname, '/' + temp, "f");
2120
+ else
2121
+ __classPrivateFieldSet(this, _URL_pathname, '/', "f");
2122
+ }
2123
+ }
2124
+ get search() {
2125
+ const val = __classPrivateFieldGet(this, _URL_search, "f").toString();
2126
+ return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`;
2127
+ }
2128
+ set search(val) {
2129
+ if (shared.isString(val)) {
2130
+ val = val.trim();
2131
+ __classPrivateFieldSet(this, _URL_search, new URLSearchParams(val), "f");
2132
+ }
2133
+ }
2134
+ get hash() {
2135
+ return __classPrivateFieldGet(this, _URL_hash, "f");
2136
+ }
2137
+ set hash(val) {
2138
+ if (shared.isString(val)) {
2139
+ val = val.trim();
2140
+ if (val)
2141
+ __classPrivateFieldSet(this, _URL_hash, val.startsWith('#') ? val : `#${val}`, "f");
2142
+ else
2143
+ __classPrivateFieldSet(this, _URL_hash, '', "f");
2144
+ }
2145
+ }
2146
+ get href() {
2147
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
2148
+ }
2149
+ set href(val) {
2150
+ if (val && shared.isString(val)) {
2151
+ val = val.trim();
2152
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
2153
+ this.protocol = protocol;
2154
+ this.hostname = hostname;
2155
+ this.pathname = pathname;
2156
+ this.port = port;
2157
+ this.hash = hash;
2158
+ this.search = search;
2159
+ }
2160
+ }
2161
+ get origin() {
2162
+ return `${this.protocol}//${this.host}`;
2163
+ }
2164
+ set origin(val) {
2165
+ if (val && shared.isString(val)) {
2166
+ val = val.trim();
2167
+ const { protocol, hostname, port } = parseUrl(val);
2168
+ this.protocol = protocol;
2169
+ this.hostname = hostname;
2170
+ this.port = port;
2171
+ }
2172
+ }
2173
+ get searchParams() {
2174
+ return __classPrivateFieldGet(this, _URL_search, "f");
2175
+ }
2176
+ // public method
2177
+ toString() {
2178
+ return this.href;
2179
+ }
2180
+ toJSON() {
2181
+ return this.toString();
2182
+ }
2183
+ // convenient for deconstructor
2184
+ _toRaw() {
2185
+ return {
2186
+ protocol: this.protocol,
2187
+ port: this.port,
2188
+ host: this.host,
2189
+ hostname: this.hostname,
2190
+ pathname: this.pathname,
2191
+ hash: this.hash,
2192
+ search: this.search,
2193
+ origin: this.origin,
2194
+ href: this.href,
2195
+ };
2196
+ }
2197
+ }
2198
+ _URL_hash = new WeakMap(), _URL_hostname = new WeakMap(), _URL_pathname = new WeakMap(), _URL_port = new WeakMap(), _URL_protocol = new WeakMap(), _URL_search = new WeakMap();
2199
+ function parseUrl(url = '') {
2200
+ const result = {
2201
+ href: '',
2202
+ origin: '',
2203
+ protocol: '',
2204
+ hostname: '',
2205
+ host: '',
2206
+ port: '',
2207
+ pathname: '',
2208
+ search: '',
2209
+ hash: ''
2210
+ };
2211
+ if (!url || !shared.isString(url))
2212
+ return result;
2213
+ url = url.trim();
2214
+ const PATTERN = /^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/;
2215
+ const matches = url.match(PATTERN);
2216
+ if (!matches)
2217
+ return result;
2218
+ // TODO: username & password ?
2219
+ result.protocol = matches[1] || 'https:';
2220
+ result.hostname = matches[6] || 'taro.com';
2221
+ result.port = matches[8] || '';
2222
+ result.pathname = matches[9] || '/';
2223
+ result.search = matches[10] || '';
2224
+ result.hash = matches[12] || '';
2225
+ result.href = url;
2226
+ result.origin = result.protocol + '//' + result.hostname;
2227
+ result.host = result.hostname + (result.port ? `:${result.port}` : '');
2228
+ return result;
2229
+ }
2230
+ function parseUrlBase(url, base) {
2231
+ const VALID_URL = /^(https?:)\/\//i;
2232
+ let fullUrl = '';
2233
+ let parsedBase = null;
2234
+ if (!shared.isUndefined(base)) {
2235
+ base = String(base).trim();
2236
+ if (!VALID_URL.test(base))
2237
+ throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
2238
+ parsedBase = parseUrl(base);
2239
+ }
2240
+ url = String(url).trim();
2241
+ if (VALID_URL.test(url)) {
2242
+ fullUrl = url;
2243
+ }
2244
+ else if (parsedBase) {
2245
+ if (url) {
2246
+ if (url.startsWith('//')) {
2247
+ fullUrl = parsedBase.protocol + url;
2248
+ }
2249
+ else {
2250
+ fullUrl = parsedBase.origin + (url.startsWith('/') ? url : `/${url}`);
2251
+ }
2252
+ }
2253
+ else {
2254
+ fullUrl = parsedBase.href;
2255
+ }
2256
+ }
2257
+ else {
2258
+ throw new TypeError(`Failed to construct 'URL': Invalid URL`);
2259
+ }
2260
+ return parseUrl(fullUrl);
2261
+ }
2262
+
2263
+ class AnchorElement extends TaroElement {
2264
+ get href() {
2265
+ var _a;
2266
+ return (_a = this.props["href" /* AnchorElementAttrs.HREF */]) !== null && _a !== void 0 ? _a : '';
2267
+ }
2268
+ set href(val) {
2269
+ this.setAttribute("href" /* AnchorElementAttrs.HREF */, val);
2270
+ }
2271
+ get protocol() {
2272
+ var _a;
2273
+ return (_a = this.props["protocol" /* AnchorElementAttrs.PROTOCOL */]) !== null && _a !== void 0 ? _a : '';
2274
+ }
2275
+ get host() {
2276
+ var _a;
2277
+ return (_a = this.props["host" /* AnchorElementAttrs.HOST */]) !== null && _a !== void 0 ? _a : '';
2278
+ }
2279
+ get search() {
2280
+ var _a;
2281
+ return (_a = this.props["search" /* AnchorElementAttrs.SEARCH */]) !== null && _a !== void 0 ? _a : '';
2282
+ }
2283
+ get hash() {
2284
+ var _a;
2285
+ return (_a = this.props["hash" /* AnchorElementAttrs.HASH */]) !== null && _a !== void 0 ? _a : '';
2286
+ }
2287
+ get hostname() {
2288
+ var _a;
2289
+ return (_a = this.props["hostname" /* AnchorElementAttrs.HOSTNAME */]) !== null && _a !== void 0 ? _a : '';
2290
+ }
2291
+ get port() {
2292
+ var _a;
2293
+ return (_a = this.props["port" /* AnchorElementAttrs.PORT */]) !== null && _a !== void 0 ? _a : '';
2294
+ }
2295
+ get pathname() {
2296
+ var _a;
2297
+ return (_a = this.props["pathname" /* AnchorElementAttrs.PATHNAME */]) !== null && _a !== void 0 ? _a : '';
2298
+ }
2299
+ setAttribute(qualifiedName, value) {
2300
+ if (qualifiedName === "href" /* AnchorElementAttrs.HREF */) {
2301
+ const willSetAttr = parseUrl(value);
2302
+ for (const k in willSetAttr) {
2303
+ super.setAttribute(k, willSetAttr[k]);
2304
+ }
2305
+ }
2306
+ else {
2307
+ super.setAttribute(qualifiedName, value);
2308
+ }
2309
+ }
2310
+ }
2311
+
2312
+ class TaroDocument extends TaroElement {
2313
+ constructor() {
2314
+ super();
2315
+ this.createEvent = createEvent;
2316
+ this.nodeType = 9 /* NodeType.DOCUMENT_NODE */;
2317
+ this.nodeName = DOCUMENT_ELEMENT_NAME;
2318
+ }
2319
+ createElement(type) {
2320
+ const nodeName = type.toLowerCase();
2321
+ let element;
2322
+ switch (true) {
2323
+ case nodeName === ROOT_STR:
2324
+ element = new TaroRootElement();
2325
+ return element;
2326
+ case shared.controlledComponent.has(nodeName):
2327
+ element = new FormElement();
2328
+ break;
2329
+ case nodeName === A:
2330
+ element = new AnchorElement();
2331
+ break;
2332
+ default:
2333
+ element = new TaroElement();
2334
+ break;
2335
+ }
2336
+ element.nodeName = nodeName;
2337
+ element.tagName = type.toUpperCase();
2338
+ return element;
2339
+ }
2340
+ // an ugly fake createElementNS to deal with @vue/runtime-dom's
2341
+ // support mounting app to svg container since vue@3.0.8
2342
+ createElementNS(_svgNS, type) {
2343
+ return this.createElement(type);
2344
+ }
2345
+ createTextNode(text) {
2346
+ return new TaroText(text);
2347
+ }
2348
+ getElementById(id) {
2349
+ const el = eventSource.get(id);
2350
+ return shared.isUndefined(el) ? null : el;
2351
+ }
2352
+ querySelector(query) {
2353
+ // 为了 Vue3 的乞丐版实现
2354
+ if (/^#/.test(query)) {
2355
+ return this.getElementById(query.slice(1));
2356
+ }
2357
+ return null;
2358
+ }
2359
+ querySelectorAll() {
2360
+ // fake hack
2361
+ return [];
2362
+ }
2363
+ // @TODO: @PERF: 在 hydrate 移除掉空的 node
2364
+ createComment() {
2365
+ const textnode = new TaroText('');
2366
+ textnode.nodeName = COMMENT;
2367
+ return textnode;
2368
+ }
2369
+ get defaultView() {
2370
+ return env.window;
2371
+ }
2372
+ }
2373
+
2374
+ exports.document = void 0;
2375
+ if (process.env.TARO_ENV && !true) {
2376
+ /* eslint-disable no-inner-declarations */
2377
+ function createDocument() {
2378
+ /**
2379
+ * <document>
2380
+ * <html>
2381
+ * <head></head>
2382
+ * <body>
2383
+ * <container>
2384
+ * <app id="app" />
2385
+ * </container>
2386
+ * </body>
2387
+ * </html>
2388
+ * </document>
2389
+ */
2390
+ const doc = new TaroDocument();
2391
+ const documentCreateElement = doc.createElement.bind(doc);
2392
+ const html = documentCreateElement(HTML);
2393
+ const head = documentCreateElement(HEAD);
2394
+ const body = documentCreateElement(BODY);
2395
+ const app = documentCreateElement(APP);
2396
+ app.id = APP;
2397
+ const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
2398
+ doc.appendChild(html);
2399
+ html.appendChild(head);
2400
+ html.appendChild(body);
2401
+ body.appendChild(container);
2402
+ container.appendChild(app);
2403
+ doc.documentElement = html;
2404
+ doc.head = head;
2405
+ doc.body = body;
2406
+ return doc;
2407
+ }
2408
+ exports.document = env.document = createDocument();
2409
+ }
2410
+ else {
2411
+ exports.document = env.document;
2412
+ }
2413
+
2414
+ function getComputedStyle(element) {
2415
+ return element.style;
2416
+ }
2417
+
2418
+ const eventCenter = shared.hooks.call('getEventCenter', shared.Events);
2419
+
2420
+ /**
2421
+ * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
2422
+ */
2423
+ class RuntimeCache {
2424
+ constructor(name) {
2425
+ this.cache = new Map();
2426
+ this.name = name;
2427
+ }
2428
+ has(identifier) {
2429
+ return this.cache.has(identifier);
2430
+ }
2431
+ set(identifier, ctx) {
2432
+ if (identifier && ctx) {
2433
+ this.cache.set(identifier, ctx);
2434
+ }
2435
+ }
2436
+ get(identifier) {
2437
+ if (this.has(identifier))
2438
+ return this.cache.get(identifier);
2439
+ }
2440
+ delete(identifier) {
2441
+ this.cache.delete(identifier);
2442
+ }
2443
+ }
2444
+
2445
+ var _History_instances, _History_location, _History_stack, _History_cur, _History_window, _History_reset;
2446
+ const cache$1 = new RuntimeCache('history');
2447
+ class History extends shared.Events {
2448
+ constructor(location, options) {
2449
+ super();
2450
+ _History_instances.add(this);
2451
+ /* private property */
2452
+ _History_location.set(this, void 0);
2453
+ _History_stack.set(this, []);
2454
+ _History_cur.set(this, 0);
2455
+ _History_window.set(this, void 0);
2456
+ __classPrivateFieldSet(this, _History_window, options.window, "f");
2457
+ __classPrivateFieldSet(this, _History_location, location, "f");
2458
+ __classPrivateFieldGet(this, _History_location, "f").on('__record_history__', (href) => {
2459
+ var _a;
2460
+ __classPrivateFieldSet(this, _History_cur, (_a = __classPrivateFieldGet(this, _History_cur, "f"), _a++, _a), "f");
2461
+ __classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f")), "f");
2462
+ __classPrivateFieldGet(this, _History_stack, "f").push({
2463
+ state: null,
2464
+ title: '',
2465
+ url: href
2466
+ });
2467
+ }, null);
2468
+ __classPrivateFieldGet(this, _History_location, "f").on('__reset_history__', (href) => {
2469
+ __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
2470
+ }, null);
2471
+ // 切换上下文行为
2472
+ this.on(exports.CONTEXT_ACTIONS.INIT, () => {
2473
+ __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
2474
+ }, null);
2475
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2476
+ cache$1.set(pageId, {
2477
+ location: __classPrivateFieldGet(this, _History_location, "f"),
2478
+ stack: __classPrivateFieldGet(this, _History_stack, "f").slice(),
2479
+ cur: __classPrivateFieldGet(this, _History_cur, "f")
2480
+ });
2481
+ }, null);
2482
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
2483
+ if (cache$1.has(pageId)) {
2484
+ const ctx = cache$1.get(pageId);
2485
+ __classPrivateFieldSet(this, _History_location, ctx.location, "f");
2486
+ __classPrivateFieldSet(this, _History_stack, ctx.stack, "f");
2487
+ __classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
2488
+ }
2489
+ }, null);
2490
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
2491
+ cache$1.delete(pageId);
2492
+ }, null);
2493
+ __classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
2494
+ }
2495
+ /* public property */
2496
+ get length() {
2497
+ return __classPrivateFieldGet(this, _History_stack, "f").length;
2498
+ }
2499
+ get state() {
2500
+ return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].state;
2501
+ }
2502
+ /* public method */
2503
+ go(delta) {
2504
+ if (!shared.isNumber(delta) || isNaN(delta))
2505
+ return;
2506
+ let targetIdx = __classPrivateFieldGet(this, _History_cur, "f") + delta;
2507
+ targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
2508
+ __classPrivateFieldSet(this, _History_cur, targetIdx, "f");
2509
+ __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].url);
2510
+ __classPrivateFieldGet(this, _History_window, "f").trigger('popstate', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")]);
2511
+ }
2512
+ back() {
2513
+ this.go(-1);
2514
+ }
2515
+ forward() {
2516
+ this.go(1);
2517
+ }
2518
+ pushState(state, title, url) {
2519
+ if (!url || !shared.isString(url))
2520
+ return;
2521
+ __classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f") + 1), "f");
2522
+ __classPrivateFieldGet(this, _History_stack, "f").push({
2523
+ state,
2524
+ title,
2525
+ url
2526
+ });
2527
+ __classPrivateFieldSet(this, _History_cur, this.length - 1, "f");
2528
+ __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
2529
+ }
2530
+ replaceState(state, title, url) {
2531
+ if (!url || !shared.isString(url))
2532
+ return;
2533
+ __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")] = {
2534
+ state,
2535
+ title,
2536
+ url
2537
+ };
2538
+ __classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
2539
+ }
2540
+ // For debug
2541
+ get cache() {
2542
+ return cache$1;
2543
+ }
2544
+ }
2545
+ _History_location = new WeakMap(), _History_stack = new WeakMap(), _History_cur = new WeakMap(), _History_window = new WeakMap(), _History_instances = new WeakSet(), _History_reset = function _History_reset(href = '') {
2546
+ __classPrivateFieldSet(this, _History_stack, [
2547
+ {
2548
+ state: null,
2549
+ title: '',
2550
+ url: href || __classPrivateFieldGet(this, _History_location, "f").href
2551
+ }
2552
+ ], "f");
2553
+ __classPrivateFieldSet(this, _History_cur, 0, "f");
2554
+ };
2555
+
2556
+ const Current = {
2557
+ app: null,
2558
+ router: null,
2559
+ page: null
2560
+ };
2561
+ const getCurrentInstance = () => Current;
2562
+
2563
+ var _Location_instances, _Location_url, _Location_noCheckUrl, _Location_window, _Location_reset, _Location_getPreValue, _Location_rollBack, _Location_recordHistory, _Location_checkUrlChange;
2564
+ const INIT_URL = 'https://taro.com';
2565
+ const cache = new RuntimeCache('location');
2566
+ class Location extends shared.Events {
2567
+ constructor(options) {
2568
+ super();
2569
+ _Location_instances.add(this);
2570
+ /* private property */
2571
+ _Location_url.set(this, new URL(INIT_URL));
2572
+ _Location_noCheckUrl.set(this, false);
2573
+ _Location_window.set(this, void 0);
2574
+ __classPrivateFieldSet(this, _Location_window, options.window, "f");
2575
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
2576
+ this.on('__set_href_without_history__', (href) => {
2577
+ __classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
2578
+ const lastHash = __classPrivateFieldGet(this, _Location_url, "f").hash;
2579
+ __classPrivateFieldGet(this, _Location_url, "f").href = generateFullUrl(href);
2580
+ if (lastHash !== __classPrivateFieldGet(this, _Location_url, "f").hash) {
2581
+ __classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
2582
+ }
2583
+ __classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
2584
+ }, null);
2585
+ // 切换上下文行为
2586
+ this.on(exports.CONTEXT_ACTIONS.INIT, () => {
2587
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
2588
+ }, null);
2589
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2590
+ cache.set(pageId, {
2591
+ lastHref: this.href,
2592
+ });
2593
+ }, null);
2594
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
2595
+ // 数据恢复时,不需要执行跳转
2596
+ if (cache.has(pageId)) {
2597
+ const ctx = cache.get(pageId);
2598
+ __classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
2599
+ __classPrivateFieldGet(this, _Location_url, "f").href = ctx.lastHref;
2600
+ __classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
2601
+ }
2602
+ }, null);
2603
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
2604
+ cache.delete(pageId);
2605
+ }, null);
2606
+ }
2607
+ /* public property */
2608
+ get protocol() {
2609
+ return __classPrivateFieldGet(this, _Location_url, "f").protocol;
2610
+ }
2611
+ set protocol(val) {
2612
+ const REG = /^(http|https):$/i;
2613
+ if (!val || !shared.isString(val) || !REG.test(val.trim()))
2614
+ return;
2615
+ val = val.trim();
2616
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2617
+ __classPrivateFieldGet(this, _Location_url, "f").protocol = val;
2618
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2619
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2620
+ }
2621
+ get host() {
2622
+ return __classPrivateFieldGet(this, _Location_url, "f").host;
2623
+ }
2624
+ set host(val) {
2625
+ if (!val || !shared.isString(val))
2626
+ return;
2627
+ val = val.trim();
2628
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2629
+ __classPrivateFieldGet(this, _Location_url, "f").host = val;
2630
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2631
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2632
+ }
2633
+ get hostname() {
2634
+ return __classPrivateFieldGet(this, _Location_url, "f").hostname;
2635
+ }
2636
+ set hostname(val) {
2637
+ if (!val || !shared.isString(val))
2638
+ return;
2639
+ val = val.trim();
2640
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2641
+ __classPrivateFieldGet(this, _Location_url, "f").hostname = val;
2642
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2643
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2644
+ }
2645
+ get port() {
2646
+ return __classPrivateFieldGet(this, _Location_url, "f").port;
2647
+ }
2648
+ set port(val) {
2649
+ const xVal = Number((val = val.trim()));
2650
+ if (!shared.isNumber(xVal) || xVal <= 0)
2651
+ return;
2652
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2653
+ __classPrivateFieldGet(this, _Location_url, "f").port = val;
2654
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2655
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2656
+ }
2657
+ get pathname() {
2658
+ return __classPrivateFieldGet(this, _Location_url, "f").pathname;
2659
+ }
2660
+ set pathname(val) {
2661
+ if (!val || !shared.isString(val))
2662
+ return;
2663
+ val = val.trim();
2664
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2665
+ __classPrivateFieldGet(this, _Location_url, "f").pathname = val;
2666
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2667
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2668
+ }
2669
+ get search() {
2670
+ return __classPrivateFieldGet(this, _Location_url, "f").search;
2671
+ }
2672
+ set search(val) {
2673
+ if (!val || !shared.isString(val))
2674
+ return;
2675
+ val = val.trim();
2676
+ val = val.startsWith('?') ? val : `?${val}`;
2677
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2678
+ __classPrivateFieldGet(this, _Location_url, "f").search = val;
2679
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2680
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2681
+ }
2682
+ get hash() {
2683
+ return __classPrivateFieldGet(this, _Location_url, "f").hash;
2684
+ }
2685
+ // 小程序的navigateTo存在截断hash字符串的问题
2686
+ set hash(val) {
2687
+ if (!val || !shared.isString(val))
2688
+ return;
2689
+ val = val.trim();
2690
+ val = val.startsWith('#') ? val : `#${val}`;
2691
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2692
+ __classPrivateFieldGet(this, _Location_url, "f").hash = val;
2693
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2694
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2695
+ }
2696
+ get href() {
2697
+ return __classPrivateFieldGet(this, _Location_url, "f").href;
2698
+ }
2699
+ set href(val) {
2700
+ const REG = /^(http:|https:)?\/\/.+/;
2701
+ if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
2702
+ return;
2703
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2704
+ __classPrivateFieldGet(this, _Location_url, "f").href = val;
2705
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2706
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2707
+ }
2708
+ get origin() {
2709
+ return __classPrivateFieldGet(this, _Location_url, "f").origin;
2710
+ }
2711
+ set origin(val) {
2712
+ const REG = /^(http:|https:)?\/\/.+/;
2713
+ if (!val || !shared.isString(val) || !REG.test((val = val.trim())))
2714
+ return;
2715
+ const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
2716
+ __classPrivateFieldGet(this, _Location_url, "f").origin = val;
2717
+ if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
2718
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
2719
+ }
2720
+ /* public method */
2721
+ assign() {
2722
+ shared.warn(true, '小程序环境中调用location.assign()无效.');
2723
+ }
2724
+ reload() {
2725
+ shared.warn(true, '小程序环境中调用location.reload()无效.');
2726
+ }
2727
+ replace(url) {
2728
+ this.trigger('__set_href_without_history__', url);
2729
+ }
2730
+ toString() {
2731
+ return this.href;
2732
+ }
2733
+ // For debug
2734
+ get cache() {
2735
+ return cache;
2736
+ }
2737
+ }
2738
+ _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_window = new WeakMap(), _Location_instances = new WeakSet(), _Location_reset = function _Location_reset() {
2739
+ const Current = getCurrentInstance();
2740
+ const router = Current.router;
2741
+ if (router) {
2742
+ const { path, params } = router;
2743
+ const searchArr = Object.keys(params).map((key) => {
2744
+ return `${key}=${params[key]}`;
2745
+ });
2746
+ const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
2747
+ const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
2748
+ __classPrivateFieldSet(this, _Location_url, new URL(url), "f");
2749
+ this.trigger('__reset_history__', this.href);
2750
+ }
2751
+ }, _Location_getPreValue = function _Location_getPreValue() {
2752
+ return __classPrivateFieldGet(this, _Location_url, "f")._toRaw();
2753
+ }, _Location_rollBack = function _Location_rollBack(href) {
2754
+ __classPrivateFieldGet(this, _Location_url, "f").href = href;
2755
+ }, _Location_recordHistory = function _Location_recordHistory() {
2756
+ this.trigger('__record_history__', this.href);
2757
+ }, _Location_checkUrlChange = function _Location_checkUrlChange(preValue) {
2758
+ if (__classPrivateFieldGet(this, _Location_noCheckUrl, "f")) {
2759
+ return false;
2760
+ }
2761
+ const { protocol, hostname, port, pathname, search, hash } = __classPrivateFieldGet(this, _Location_url, "f")._toRaw();
2762
+ // 跨域三要素不允许修改
2763
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
2764
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue.href);
2765
+ return false;
2766
+ }
2767
+ // pathname
2768
+ if (pathname !== preValue.pathname) {
2769
+ return true;
2770
+ }
2771
+ // search
2772
+ if (search !== preValue.search) {
2773
+ return true;
2774
+ }
2775
+ // hashchange
2776
+ if (hash !== preValue.hash) {
2777
+ __classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
2778
+ return true;
2779
+ }
2780
+ __classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue.href);
2781
+ return false;
2782
+ };
2783
+ function generateFullUrl(val = '') {
2784
+ const origin = INIT_URL;
2785
+ if (/^[/?#]/.test(val)) {
2786
+ return origin + val;
2787
+ }
2788
+ return val;
2789
+ }
2790
+
2791
+ const nav = env.window.navigator ;
2792
+
2793
+ // https://github.com/myrne/performance-now
2794
+ exports.now = void 0;
2795
+ (function () {
2796
+ let loadTime;
2797
+ if ((typeof performance !== 'undefined' && performance !== null) && performance.now) {
2798
+ exports.now = () => performance.now();
2799
+ }
2800
+ else if (Date.now) {
2801
+ loadTime = Date.now();
2802
+ exports.now = () => Date.now() - loadTime;
2803
+ }
2804
+ else {
2805
+ loadTime = new Date().getTime();
2806
+ exports.now = () => new Date().getTime() - loadTime;
2807
+ }
2808
+ })();
2809
+ let lastTime = 0;
2810
+ // https://gist.github.com/paulirish/1579671
2811
+ // https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
2812
+ const _raf = typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame !== null ? requestAnimationFrame : function (callback) {
2813
+ const _now = exports.now();
2814
+ const nextTime = Math.max(lastTime + 16, _now); // First time will execute it immediately but barely noticeable and performance is gained.
2815
+ return setTimeout(function () { callback(lastTime = nextTime); }, nextTime - _now);
2816
+ };
2817
+ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame !== null
2818
+ ? cancelAnimationFrame
2819
+ : function (seed) {
2820
+ // fix https://github.com/NervJS/taro/issues/7749
2821
+ clearTimeout(seed);
2822
+ };
2823
+
2824
+ exports.window = void 0;
2825
+ if (process.env.TARO_ENV && !true) {
2826
+ class Window extends shared.Events {
2827
+ constructor() {
2828
+ super();
2829
+ this.navigator = nav;
2830
+ this.requestAnimationFrame = _raf;
2831
+ this.cancelAnimationFrame = _caf;
2832
+ this.getComputedStyle = getComputedStyle;
2833
+ const globalProperties = [
2834
+ ...Object.getOwnPropertyNames(global || {}),
2835
+ ...Object.getOwnPropertySymbols(global || {})
2836
+ ];
2837
+ globalProperties.forEach(property => {
2838
+ if (property === 'atob' || property === 'document')
2839
+ return;
2840
+ if (!Object.prototype.hasOwnProperty.call(this, property)) {
2841
+ // 防止小程序环境下,window 上的某些 get 属性在赋值时报错
2842
+ try {
2843
+ this[property] = global[property];
2844
+ }
2845
+ catch (e) {
2846
+ if (process.env.NODE_ENV !== 'production') {
2847
+ console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
2848
+ }
2849
+ }
2850
+ }
2851
+ });
2852
+ this.Date || (this.Date = Date);
2853
+ // 应用启动时,提供给需要读取历史信息的库使用
2854
+ this.location = new Location({ window: this });
2855
+ this.history = new History(this.location, { window: this });
2856
+ this.initEvent();
2857
+ }
2858
+ initEvent() {
2859
+ const _location = this.location;
2860
+ const _history = this.history;
2861
+ this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
2862
+ // 页面onload,为该页面建立新的上下文信息
2863
+ _location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
2864
+ }, null);
2865
+ this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
2866
+ // 页面onshow,恢复当前页面的上下文信息
2867
+ _location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
2868
+ _history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
2869
+ }, null);
2870
+ this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
2871
+ // 页面onhide,缓存当前页面的上下文信息
2872
+ _location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
2873
+ _history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
2874
+ }, null);
2875
+ this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
2876
+ // 页面onunload,清除当前页面的上下文信息
2877
+ _location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
2878
+ _history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
2879
+ }, null);
2880
+ }
2881
+ get document() {
2882
+ return env.document;
2883
+ }
2884
+ addEventListener(event, callback) {
2885
+ if (!shared.isString(event))
2886
+ return;
2887
+ this.on(event, callback, null);
2888
+ }
2889
+ removeEventListener(event, callback) {
2890
+ if (!shared.isString(event))
2891
+ return;
2892
+ this.off(event, callback, null);
2893
+ }
2894
+ setTimeout(...args) {
2895
+ return setTimeout(...args);
2896
+ }
2897
+ clearTimeout(...args) {
2898
+ return clearTimeout(...args);
2899
+ }
2900
+ }
2901
+ exports.window = env.window = new Window();
2902
+ }
2903
+ else {
2904
+ exports.window = env.window;
2905
+ }
2906
+ const location = exports.window.location;
2907
+ const history = exports.window.history;
2908
+
2909
+ // for Vue3
2910
+ class SVGElement extends TaroElement {
2911
+ }
2912
+
2913
+ /* eslint-disable dot-notation */
2914
+ const instances = new Map();
2915
+ const pageId = incrementId();
2916
+ function injectPageInstance(inst, id) {
2917
+ shared.hooks.call('mergePageInstance', instances.get(id), inst);
2918
+ instances.set(id, inst);
2919
+ }
2920
+ function getPageInstance(id) {
2921
+ return instances.get(id);
2922
+ }
2923
+ function removePageInstance(id) {
2924
+ instances.delete(id);
2925
+ }
2926
+ function addLeadingSlash(path) {
2927
+ if (path == null) {
2928
+ return '';
2929
+ }
2930
+ return path.charAt(0) === '/' ? path : '/' + path;
2931
+ }
2932
+ function safeExecute(path, lifecycle, ...args) {
2933
+ const instance = instances.get(path);
2934
+ if (instance == null) {
2935
+ return;
2936
+ }
2937
+ const func = shared.hooks.call('getLifecycle', instance, lifecycle);
2938
+ if (shared.isArray(func)) {
2939
+ const res = func.map(fn => fn.apply(instance, args));
2940
+ return res[0];
2941
+ }
2942
+ if (!shared.isFunction(func)) {
2943
+ return;
2944
+ }
2945
+ return func.apply(instance, args);
2946
+ }
2947
+ function stringify(obj) {
2948
+ if (obj == null) {
2949
+ return '';
2950
+ }
2951
+ const path = Object.keys(obj).map((key) => {
2952
+ return key + '=' + obj[key];
2953
+ }).join('&');
2954
+ return path === '' ? path : '?' + path;
2955
+ }
2956
+ function getPath(id, options) {
2957
+ const idx = id.indexOf('?');
2958
+ {
2959
+ return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
2960
+ }
2961
+ }
2962
+ function getOnReadyEventKey(path) {
2963
+ return path + '.' + ON_READY;
2964
+ }
2965
+ function getOnShowEventKey(path) {
2966
+ return path + '.' + ON_SHOW;
2967
+ }
2968
+ function getOnHideEventKey(path) {
2969
+ return path + '.' + ON_HIDE;
2970
+ }
2971
+ function createPageConfig(component, pageName, data, pageConfig) {
2972
+ // 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
2973
+ const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
2974
+ const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES,] = shared.hooks.call('getMiniLifecycleImpl').page;
2975
+ let pageElement = null;
2976
+ let unmounting = false;
2977
+ let prepareMountList = [];
2978
+ function setCurrentRouter(page) {
2979
+ const router = page.$taroPath ;
2980
+ Current.router = {
2981
+ params: page.$taroParams,
2982
+ path: addLeadingSlash(router),
2983
+ $taroPath: page.$taroPath,
2984
+ onReady: getOnReadyEventKey(id),
2985
+ onShow: getOnShowEventKey(id),
2986
+ onHide: getOnHideEventKey(id)
2987
+ };
2988
+ if (!shared.isUndefined(page.exitState)) {
2989
+ Current.router.exitState = page.exitState;
2990
+ }
2991
+ }
2992
+ let loadResolver;
2993
+ let hasLoaded;
2994
+ const config = {
2995
+ [ONLOAD](options = {}, cb) {
2996
+ hasLoaded = new Promise(resolve => { loadResolver = resolve; });
2997
+ perf.start(PAGE_INIT);
2998
+ Current.page = this;
2999
+ this.config = pageConfig || {};
3000
+ // this.$taroPath 是页面唯一标识
3001
+ const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
3002
+ const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
3003
+ {
3004
+ config.path = $taroPath;
3005
+ }
3006
+ // this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
3007
+ if (this.$taroParams == null) {
3008
+ this.$taroParams = uniqueOptions;
3009
+ }
3010
+ setCurrentRouter(this);
3011
+ const mount = () => {
3012
+ Current.app.mount(component, $taroPath, () => {
3013
+ pageElement = env.document.getElementById($taroPath);
3014
+ shared.ensure(pageElement !== null, '没有找到页面实例。');
3015
+ safeExecute($taroPath, ON_LOAD, this.$taroParams);
3016
+ loadResolver();
3017
+ {
3018
+ shared.isFunction(cb) && cb();
3019
+ }
3020
+ });
3021
+ };
3022
+ if (unmounting) {
3023
+ prepareMountList.push(mount);
3024
+ }
3025
+ else {
3026
+ mount();
3027
+ }
3028
+ },
3029
+ [ONUNLOAD]() {
3030
+ const $taroPath = this.$taroPath;
3031
+ // 触发onUnload生命周期
3032
+ safeExecute($taroPath, ONUNLOAD);
3033
+ unmounting = true;
3034
+ Current.app.unmount($taroPath, () => {
3035
+ unmounting = false;
3036
+ instances.delete($taroPath);
3037
+ if (pageElement) {
3038
+ pageElement.ctx = null;
3039
+ pageElement = null;
3040
+ }
3041
+ if (prepareMountList.length) {
3042
+ prepareMountList.forEach(fn => fn());
3043
+ prepareMountList = [];
3044
+ }
3045
+ });
3046
+ },
3047
+ [ONREADY]() {
3048
+ hasLoaded.then(() => {
3049
+ // 触发生命周期
3050
+ safeExecute(this.$taroPath, ON_READY);
3051
+ // 通过事件触发子组件的生命周期
3052
+ _raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
3053
+ this.onReady.called = true;
3054
+ });
3055
+ },
3056
+ [ONSHOW](options = {}) {
3057
+ hasLoaded.then(() => {
3058
+ // 设置 Current 的 page 和 router
3059
+ Current.page = this;
3060
+ setCurrentRouter(this);
3061
+ // 触发生命周期
3062
+ safeExecute(this.$taroPath, ON_SHOW, options);
3063
+ // 通过事件触发子组件的生命周期
3064
+ _raf(() => eventCenter.trigger(getOnShowEventKey(id)));
3065
+ });
3066
+ },
3067
+ [ONHIDE]() {
3068
+ // 设置 Current 的 page 和 router
3069
+ if (Current.page === this) {
3070
+ Current.page = null;
3071
+ Current.router = null;
3072
+ }
3073
+ // 触发生命周期
3074
+ safeExecute(this.$taroPath, ON_HIDE);
3075
+ // 通过事件触发子组件的生命周期
3076
+ eventCenter.trigger(getOnHideEventKey(id));
3077
+ }
3078
+ };
3079
+ LIFECYCLES.forEach((lifecycle) => {
3080
+ let isDefer = false;
3081
+ lifecycle = lifecycle.replace(/^defer:/, () => {
3082
+ isDefer = true;
3083
+ return '';
3084
+ });
3085
+ config[lifecycle] = function () {
3086
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
3087
+ if (isDefer) {
3088
+ hasLoaded.then(exec);
3089
+ }
3090
+ else {
3091
+ return exec();
3092
+ }
3093
+ };
3094
+ });
3095
+ // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
3096
+ SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
3097
+ var _a;
3098
+ if (component[lifecycle] ||
3099
+ ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a[lifecycle]) ||
3100
+ component[lifecycle.replace(/^on/, 'enable')] ||
3101
+ (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig[lifecycle.replace(/^on/, 'enable')])) {
3102
+ config[lifecycle] = function (...args) {
3103
+ var _a;
3104
+ const target = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.target;
3105
+ if (target === null || target === void 0 ? void 0 : target.id) {
3106
+ const id = target.id;
3107
+ const element = env.document.getElementById(id);
3108
+ if (element) {
3109
+ target.dataset = element.dataset;
3110
+ }
3111
+ }
3112
+ return safeExecute(this.$taroPath, lifecycle, ...args);
3113
+ };
3114
+ }
3115
+ });
3116
+ config.eh = eventHandler;
3117
+ if (!shared.isUndefined(data)) {
3118
+ config.data = data;
3119
+ }
3120
+ shared.hooks.call('modifyPageObject', config);
3121
+ return config;
3122
+ }
3123
+ function createComponentConfig(component, componentName, data) {
3124
+ const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
3125
+ let componentElement = null;
3126
+ const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
3127
+ const config = {
3128
+ [ATTACHED]() {
3129
+ var _a;
3130
+ perf.start(PAGE_INIT);
3131
+ this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
3132
+ const path = getPath(id, { id: this.pageIdCache });
3133
+ Current.app.mount(component, path, () => {
3134
+ componentElement = env.document.getElementById(path);
3135
+ shared.ensure(componentElement !== null, '没有找到组件实例。');
3136
+ this.$taroInstances = instances.get(path);
3137
+ safeExecute(path, ON_LOAD);
3138
+ });
3139
+ },
3140
+ [DETACHED]() {
3141
+ const path = getPath(id, { id: this.pageIdCache });
3142
+ Current.app.unmount(path, () => {
3143
+ instances.delete(path);
3144
+ if (componentElement) {
3145
+ componentElement.ctx = null;
3146
+ }
3147
+ });
3148
+ },
3149
+ methods: {
3150
+ eh: eventHandler
3151
+ }
3152
+ };
3153
+ if (!shared.isUndefined(data)) {
3154
+ config.data = data;
3155
+ }
3156
+ [OPTIONS, EXTERNAL_CLASSES, BEHAVIORS].forEach(key => {
3157
+ var _a;
3158
+ config[key] = (_a = component[key]) !== null && _a !== void 0 ? _a : shared.EMPTY_OBJ;
3159
+ });
3160
+ return config;
3161
+ }
3162
+ function createRecursiveComponentConfig(componentName) {
3163
+ const isCustomWrapper = componentName === CUSTOM_WRAPPER;
3164
+ const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
3165
+ const lifeCycles = isCustomWrapper
3166
+ ? {
3167
+ [ATTACHED]() {
3168
+ var _a, _b;
3169
+ 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);
3170
+ if (shared.isString(componentId)) {
3171
+ customWrapperCache.set(componentId, this);
3172
+ const el = env.document.getElementById(componentId);
3173
+ if (el) {
3174
+ el.ctx = this;
3175
+ }
3176
+ }
3177
+ },
3178
+ [DETACHED]() {
3179
+ var _a, _b;
3180
+ 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);
3181
+ if (shared.isString(componentId)) {
3182
+ customWrapperCache.delete(componentId);
3183
+ const el = env.document.getElementById(componentId);
3184
+ if (el) {
3185
+ el.ctx = null;
3186
+ }
3187
+ }
3188
+ }
3189
+ }
3190
+ : shared.EMPTY_OBJ;
3191
+ return Object.assign({ properties: {
3192
+ i: {
3193
+ type: Object,
3194
+ value: {
3195
+ ["nn" /* Shortcuts.NodeName */]: shared.getComponentsAlias(shared.internalComponents)[VIEW]._num
3196
+ }
3197
+ },
3198
+ l: {
3199
+ type: String,
3200
+ value: ''
3201
+ }
3202
+ }, options: {
3203
+ addGlobalClass: true,
3204
+ virtualHost: !isCustomWrapper
3205
+ }, methods: {
3206
+ eh: eventHandler
3207
+ } }, lifeCycles);
3208
+ }
3209
+
3210
+ const TIMEOUT = 100;
3211
+ const nextTick = (cb, ctx) => {
3212
+ const beginTime = Date.now();
3213
+ const router = Current.router;
3214
+ const timerFunc = () => {
3215
+ setTimeout(function () {
3216
+ ctx ? cb.call(ctx) : cb();
3217
+ }, 1);
3218
+ };
3219
+ if (router === null)
3220
+ return timerFunc();
3221
+ const path = router.$taroPath;
3222
+ /**
3223
+ * 三种情况
3224
+ * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms
3225
+ * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车
3226
+ * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。
3227
+ */
3228
+ function next() {
3229
+ var _a, _b, _c;
3230
+ const pageElement = env.document.getElementById(path);
3231
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
3232
+ {
3233
+ // eslint-disable-next-line dot-notation
3234
+ (_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
3235
+ timerFunc();
3236
+ })) !== null && _c !== void 0 ? _c : timerFunc();
3237
+ }
3238
+ }
3239
+ else if (Date.now() - beginTime > TIMEOUT) {
3240
+ timerFunc();
3241
+ }
3242
+ else {
3243
+ setTimeout(() => next(), 20);
3244
+ }
3245
+ }
3246
+ next();
3247
+ };
3248
+
3249
+ Object.defineProperty(exports, 'Events', {
3250
+ enumerable: true,
3251
+ get: function () { return shared.Events; }
3252
+ });
3253
+ Object.defineProperty(exports, 'hooks', {
3254
+ enumerable: true,
3255
+ get: function () { return shared.hooks; }
3256
+ });
3257
+ exports.A = A;
3258
+ exports.APP = APP;
3259
+ exports.BEHAVIORS = BEHAVIORS;
3260
+ exports.BODY = BODY;
3261
+ exports.CATCHMOVE = CATCHMOVE;
3262
+ exports.CATCH_VIEW = CATCH_VIEW;
3263
+ exports.CHANGE = CHANGE;
3264
+ exports.CLASS = CLASS;
3265
+ exports.COMMENT = COMMENT;
3266
+ exports.CONFIRM = CONFIRM;
3267
+ exports.CONTAINER = CONTAINER;
3268
+ exports.CURRENT_TARGET = CURRENT_TARGET;
3269
+ exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
3270
+ exports.Current = Current;
3271
+ exports.DATASET = DATASET;
3272
+ exports.DATE = DATE;
3273
+ exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
3274
+ exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
3275
+ exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
3276
+ exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
3277
+ exports.FOCUS = FOCUS;
3278
+ exports.FormElement = FormElement;
3279
+ exports.HEAD = HEAD;
3280
+ exports.HOOKS_APP_ID = HOOKS_APP_ID;
3281
+ exports.HTML = HTML;
3282
+ exports.History = History;
3283
+ exports.ID = ID;
3284
+ exports.INPUT = INPUT;
3285
+ exports.KEY_CODE = KEY_CODE;
3286
+ exports.Location = Location;
3287
+ exports.MutationObserver = MutationObserver;
3288
+ exports.OBJECT = OBJECT;
3289
+ exports.ON_HIDE = ON_HIDE;
3290
+ exports.ON_LOAD = ON_LOAD;
3291
+ exports.ON_READY = ON_READY;
3292
+ exports.ON_SHOW = ON_SHOW;
3293
+ exports.OPTIONS = OPTIONS;
3294
+ exports.PAGE_INIT = PAGE_INIT;
3295
+ exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
3296
+ exports.PROPS = PROPS;
3297
+ exports.PURE_VIEW = PURE_VIEW;
3298
+ exports.ROOT_STR = ROOT_STR;
3299
+ exports.SET_DATA = SET_DATA;
3300
+ exports.SET_TIMEOUT = SET_TIMEOUT;
3301
+ exports.STATIC_VIEW = STATIC_VIEW;
3302
+ exports.STYLE = STYLE;
3303
+ exports.SVGElement = SVGElement;
3304
+ exports.Style = Style;
3305
+ exports.TARGET = TARGET;
3306
+ exports.TARO_RUNTIME = TARO_RUNTIME;
3307
+ exports.TIME_STAMP = TIME_STAMP;
3308
+ exports.TOUCHMOVE = TOUCHMOVE;
3309
+ exports.TYPE = TYPE;
3310
+ exports.TaroElement = TaroElement;
3311
+ exports.TaroEvent = TaroEvent;
3312
+ exports.TaroNode = TaroNode;
3313
+ exports.TaroRootElement = TaroRootElement;
3314
+ exports.TaroText = TaroText;
3315
+ exports.UID = UID;
3316
+ exports.URL = URL;
3317
+ exports.URLSearchParams = URLSearchParams;
3318
+ exports.VALUE = VALUE;
3319
+ exports.VIEW = VIEW;
3320
+ exports.addLeadingSlash = addLeadingSlash;
3321
+ exports.cancelAnimationFrame = _caf;
3322
+ exports.createComponentConfig = createComponentConfig;
3323
+ exports.createEvent = createEvent;
3324
+ exports.createPageConfig = createPageConfig;
3325
+ exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
3326
+ exports.env = env;
3327
+ exports.eventCenter = eventCenter;
3328
+ exports.eventHandler = eventHandler;
3329
+ exports.eventSource = eventSource;
3330
+ exports.getComputedStyle = getComputedStyle;
3331
+ exports.getCurrentInstance = getCurrentInstance;
3332
+ exports.getOnHideEventKey = getOnHideEventKey;
3333
+ exports.getOnReadyEventKey = getOnReadyEventKey;
3334
+ exports.getOnShowEventKey = getOnShowEventKey;
3335
+ exports.getPageInstance = getPageInstance;
3336
+ exports.getPath = getPath;
3337
+ exports.history = history;
3338
+ exports.hydrate = hydrate;
3339
+ exports.incrementId = incrementId;
3340
+ exports.injectPageInstance = injectPageInstance;
3341
+ exports.location = location;
3342
+ exports.navigator = nav;
3343
+ exports.nextTick = nextTick;
3344
+ exports.options = options;
3345
+ exports.parseUrl = parseUrl;
3346
+ exports.removePageInstance = removePageInstance;
3347
+ exports.requestAnimationFrame = _raf;
3348
+ exports.safeExecute = safeExecute;
3349
+ exports.stringify = stringify;