@spcsn/taro-runtime 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +174 -0
  2. package/README.md +49 -0
  3. package/dist/bom/URL.d.ts +51 -0
  4. package/dist/bom/URL.js +188 -0
  5. package/dist/bom/URL.js.map +1 -0
  6. package/dist/bom/URLSearchParams.d.ts +1 -0
  7. package/dist/bom/URLSearchParams.js +103 -0
  8. package/dist/bom/URLSearchParams.js.map +1 -0
  9. package/dist/bom/document.d.ts +3 -0
  10. package/dist/bom/document.js +93 -0
  11. package/dist/bom/document.js.map +1 -0
  12. package/dist/bom/getComputedStyle.d.ts +4 -0
  13. package/dist/bom/getComputedStyle.js +9 -0
  14. package/dist/bom/getComputedStyle.js.map +1 -0
  15. package/dist/bom/history.d.ts +30 -0
  16. package/dist/bom/history.js +108 -0
  17. package/dist/bom/history.js.map +1 -0
  18. package/dist/bom/location.d.ts +37 -0
  19. package/dist/bom/location.js +200 -0
  20. package/dist/bom/location.js.map +1 -0
  21. package/dist/bom/navigator.d.ts +1 -0
  22. package/dist/bom/navigator.js +22 -0
  23. package/dist/bom/navigator.js.map +1 -0
  24. package/dist/bom/raf.d.ts +4 -0
  25. package/dist/bom/raf.js +28 -0
  26. package/dist/bom/raf.js.map +1 -0
  27. package/dist/bom/window.d.ts +23 -0
  28. package/dist/bom/window.js +74 -0
  29. package/dist/bom/window.js.map +1 -0
  30. package/dist/constants/index.d.ts +57 -0
  31. package/dist/constants/index.js +63 -0
  32. package/dist/constants/index.js.map +1 -0
  33. package/dist/current.d.ts +19 -0
  34. package/dist/current.js +11 -0
  35. package/dist/current.js.map +1 -0
  36. package/dist/dom/anchor-element.d.ts +13 -0
  37. package/dist/dom/anchor-element.js +42 -0
  38. package/dist/dom/anchor-element.js.map +1 -0
  39. package/dist/dom/class-list.d.ts +16 -0
  40. package/dist/dom/class-list.js +79 -0
  41. package/dist/dom/class-list.js.map +1 -0
  42. package/dist/dom/document.d.ts +21 -0
  43. package/dist/dom/document.js +74 -0
  44. package/dist/dom/document.js.map +1 -0
  45. package/dist/dom/element.d.ts +39 -0
  46. package/dist/dom/element.js +261 -0
  47. package/dist/dom/element.js.map +1 -0
  48. package/dist/dom/event-source.d.ts +7 -0
  49. package/dist/dom/event-source.js +18 -0
  50. package/dist/dom/event-source.js.map +1 -0
  51. package/dist/dom/event-target.d.ts +8 -0
  52. package/dist/dom/event-target.js +72 -0
  53. package/dist/dom/event-target.js.map +1 -0
  54. package/dist/dom/event.d.ts +24 -0
  55. package/dist/dom/event.js +124 -0
  56. package/dist/dom/event.js.map +1 -0
  57. package/dist/dom/form.d.ts +9 -0
  58. package/dist/dom/form.js +30 -0
  59. package/dist/dom/form.js.map +1 -0
  60. package/dist/dom/node.d.ts +76 -0
  61. package/dist/dom/node.js +213 -0
  62. package/dist/dom/node.js.map +1 -0
  63. package/dist/dom/node_types.d.ts +10 -0
  64. package/dist/dom/root.d.ts +16 -0
  65. package/dist/dom/root.js +127 -0
  66. package/dist/dom/root.js.map +1 -0
  67. package/dist/dom/style.d.ts +14 -0
  68. package/dist/dom/style.js +138 -0
  69. package/dist/dom/style.js.map +1 -0
  70. package/dist/dom/style_properties.d.ts +3 -0
  71. package/dist/dom/style_properties.js +374 -0
  72. package/dist/dom/style_properties.js.map +1 -0
  73. package/dist/dom/svg.d.ts +3 -0
  74. package/dist/dom/svg.js +7 -0
  75. package/dist/dom/svg.js.map +1 -0
  76. package/dist/dom/text.d.ts +14 -0
  77. package/dist/dom/text.js +43 -0
  78. package/dist/dom/text.js.map +1 -0
  79. package/dist/dom/transfer.d.ts +7 -0
  80. package/dist/dom/transfer.js +16 -0
  81. package/dist/dom/transfer.js.map +1 -0
  82. package/dist/dom/tree.d.ts +4 -0
  83. package/dist/dom/tree.js +31 -0
  84. package/dist/dom/tree.js.map +1 -0
  85. package/dist/dom-external/element.d.ts +3 -0
  86. package/dist/dom-external/index.d.ts +1 -0
  87. package/dist/dom-external/mutation-observer/implements.d.ts +52 -0
  88. package/dist/dom-external/mutation-observer/implements.js +101 -0
  89. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  90. package/dist/dom-external/mutation-observer/index.d.ts +13 -0
  91. package/dist/dom-external/mutation-observer/index.js +32 -0
  92. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  93. package/dist/dom-external/mutation-observer/record.d.ts +24 -0
  94. package/dist/dom-external/node.d.ts +5 -0
  95. package/dist/dsl/common.d.ts +14 -0
  96. package/dist/dsl/common.js +278 -0
  97. package/dist/dsl/common.js.map +1 -0
  98. package/dist/dsl/instance.d.ts +92 -0
  99. package/dist/emitter/emitter.d.ts +4 -0
  100. package/dist/emitter/emitter.js +7 -0
  101. package/dist/emitter/emitter.js.map +1 -0
  102. package/dist/env.d.ts +7 -0
  103. package/dist/env.js +10 -0
  104. package/dist/env.js.map +1 -0
  105. package/dist/hydrate.d.ts +10 -0
  106. package/dist/hydrate.js +62 -0
  107. package/dist/hydrate.js.map +1 -0
  108. package/dist/index.cjs.d.ts +35 -0
  109. package/dist/index.cjs.js +3776 -0
  110. package/dist/index.cjs.js.map +1 -0
  111. package/dist/index.d.ts +35 -0
  112. package/dist/index.js +34 -0
  113. package/dist/interface/animate.d.ts +81 -0
  114. package/dist/interface/element.d.ts +4 -0
  115. package/dist/interface/event-target.d.ts +11 -0
  116. package/dist/interface/event.d.ts +15 -0
  117. package/dist/interface/hydrate.d.ts +30 -0
  118. package/dist/interface/index.d.ts +8 -0
  119. package/dist/interface/node.d.ts +7 -0
  120. package/dist/interface/options.d.ts +5 -0
  121. package/dist/interface/utils.d.ts +2 -0
  122. package/dist/next-tick.d.ts +2 -0
  123. package/dist/next-tick.js +35 -0
  124. package/dist/next-tick.js.map +1 -0
  125. package/dist/options.d.ts +2 -0
  126. package/dist/options.js +9 -0
  127. package/dist/options.js.map +1 -0
  128. package/dist/perf.d.ts +9 -0
  129. package/dist/perf.js +36 -0
  130. package/dist/perf.js.map +1 -0
  131. package/dist/polyfill/array.d.ts +2 -0
  132. package/dist/polyfill/array.js +36 -0
  133. package/dist/polyfill/array.js.map +1 -0
  134. package/dist/polyfill/index.d.ts +2 -0
  135. package/dist/polyfill/index.js +20 -0
  136. package/dist/polyfill/index.js.map +1 -0
  137. package/dist/polyfill/intersection-observer.d.ts +1 -0
  138. package/dist/polyfill/intersection-observer.js +494 -0
  139. package/dist/polyfill/intersection-observer.js.map +1 -0
  140. package/dist/polyfill/object.d.ts +3 -0
  141. package/dist/polyfill/object.js +63 -0
  142. package/dist/polyfill/object.js.map +1 -0
  143. package/dist/runtime.esm.d.ts +35 -0
  144. package/dist/runtime.esm.js +3644 -0
  145. package/dist/runtime.esm.js.map +1 -0
  146. package/dist/utils/cache.d.ts +12 -0
  147. package/dist/utils/cache.js +26 -0
  148. package/dist/utils/cache.js.map +1 -0
  149. package/dist/utils/index.d.ts +25 -0
  150. package/dist/utils/index.js +82 -0
  151. package/dist/utils/index.js.map +1 -0
  152. package/dist/utils/lodash.d.ts +2 -0
  153. package/dist/utils/lodash.js +33 -0
  154. package/dist/utils/lodash.js.map +1 -0
  155. package/dist/utils/router.d.ts +7 -0
  156. package/dist/utils/router.js +19 -0
  157. package/dist/utils/router.js.map +1 -0
  158. package/package.json +45 -0
@@ -0,0 +1,3776 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _spcsn_taro_shared = require("@spcsn/taro-shared");
3
+ //#region src/constants/index.ts
4
+ const PROPERTY_THRESHOLD = 2046;
5
+ const TARO_RUNTIME = "Taro runtime";
6
+ const HOOKS_APP_ID = "taro-app";
7
+ const SET_DATA = "小程序 setData";
8
+ const PAGE_INIT = "页面初始化";
9
+ const ROOT_STR = "root";
10
+ const HTML = "html";
11
+ const HEAD = "head";
12
+ const BODY = "body";
13
+ const APP = "app";
14
+ const CONTAINER = "container";
15
+ const DOCUMENT_ELEMENT_NAME = "#document";
16
+ const DOCUMENT_FRAGMENT = "document-fragment";
17
+ const ID = "id";
18
+ const UID = "uid";
19
+ const CLASS = "class";
20
+ const STYLE = "style";
21
+ const FOCUS = "focus";
22
+ const VIEW = "view";
23
+ const STATIC_VIEW = "static-view";
24
+ const PURE_VIEW = "pure-view";
25
+ const CLICK_VIEW = "click-view";
26
+ const PROPS = "props";
27
+ const DATASET = "dataset";
28
+ const OBJECT = "object";
29
+ const VALUE = "value";
30
+ const INPUT = "input";
31
+ const CHANGE = "change";
32
+ const CUSTOM_WRAPPER = "custom-wrapper";
33
+ const TARGET = "target";
34
+ const CURRENT_TARGET = "currentTarget";
35
+ const TYPE = "type";
36
+ const CONFIRM = "confirm";
37
+ const TIME_STAMP = "timeStamp";
38
+ const KEY_CODE = "keyCode";
39
+ const TOUCHMOVE = "touchmove";
40
+ const DATE = "Date";
41
+ const SET_TIMEOUT = "setTimeout";
42
+ const COMPILE_MODE = "compileMode";
43
+ const CATCHMOVE = "catchMove";
44
+ const CATCH_VIEW = "catch-view";
45
+ const COMMENT = "comment";
46
+ const ON_LOAD = "onLoad";
47
+ const ON_READY = "onReady";
48
+ const ON_SHOW = "onShow";
49
+ const ON_HIDE = "onHide";
50
+ const OPTIONS = "options";
51
+ const EXTERNAL_CLASSES = "externalClasses";
52
+ const EVENT_CALLBACK_RESULT = "e_result";
53
+ const BEHAVIORS = "behaviors";
54
+ const A = "a";
55
+ let CONTEXT_ACTIONS = /* @__PURE__ */ function(CONTEXT_ACTIONS) {
56
+ CONTEXT_ACTIONS["INIT"] = "0";
57
+ CONTEXT_ACTIONS["RESTORE"] = "1";
58
+ CONTEXT_ACTIONS["RECOVER"] = "2";
59
+ CONTEXT_ACTIONS["DESTROY"] = "3";
60
+ return CONTEXT_ACTIONS;
61
+ }({});
62
+ //#endregion
63
+ //#region src/dom-external/mutation-observer/implements.ts
64
+ const observers = [];
65
+ /**
66
+ * The MutationObserver provides the ability
67
+ * to watch for changes being made to the DOM tree.
68
+ * It will invoke a specified callback function
69
+ * when DOM changes occur.
70
+ * @see https://dom.spec.whatwg.org/#mutationobserver
71
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
72
+ */
73
+ var MutationObserverImpl = class {
74
+ constructor(callback) {
75
+ this.records = [];
76
+ this.callback = callback;
77
+ }
78
+ /**
79
+ * Configures the MutationObserver
80
+ * to begin receiving notifications
81
+ * through its callback function
82
+ * when DOM changes matching the given options occur.
83
+ *
84
+ * Options matching is to be implemented.
85
+ */
86
+ observe(target, options) {
87
+ this.disconnect();
88
+ this.target = target;
89
+ this.options = options || {};
90
+ observers.push(this);
91
+ }
92
+ /**
93
+ * Stop the MutationObserver instance
94
+ * from receiving further notifications
95
+ * until and unless observe() is called again.
96
+ */
97
+ disconnect() {
98
+ this.target = null;
99
+ const index = observers.indexOf(this);
100
+ if (index >= 0) observers.splice(index, 1);
101
+ }
102
+ /**
103
+ * Removes all pending notifications
104
+ * from the MutationObserver's notification queue
105
+ * and returns them in a new Array of MutationRecord objects.
106
+ */
107
+ takeRecords() {
108
+ return this.records.splice(0, this.records.length);
109
+ }
110
+ };
111
+ /** Match two TaroNodes by sid. */
112
+ const sidMatches = (observerTarget, target) => {
113
+ return !!observerTarget && observerTarget.sid === target?.sid;
114
+ };
115
+ const isConcerned = (record, options) => {
116
+ const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
117
+ switch (record.type) {
118
+ case "characterData":
119
+ if (characterData) {
120
+ if (!characterDataOldValue) record.oldValue = null;
121
+ return true;
122
+ }
123
+ return false;
124
+ case "attributes":
125
+ if (attributes) {
126
+ if (!attributeOldValue) record.oldValue = null;
127
+ return true;
128
+ }
129
+ return false;
130
+ case "childList":
131
+ if (childList) return true;
132
+ return false;
133
+ }
134
+ };
135
+ let pendingMuatations = false;
136
+ function logMutation(observer, record) {
137
+ observer.records.push(record);
138
+ if (!pendingMuatations) {
139
+ pendingMuatations = true;
140
+ Promise.resolve().then(() => {
141
+ pendingMuatations = false;
142
+ observers.forEach((observer) => {
143
+ return observer.callback(observer.takeRecords());
144
+ });
145
+ });
146
+ }
147
+ }
148
+ function recordMutation(record) {
149
+ observers.forEach((observer) => {
150
+ const { options } = observer;
151
+ for (let t = record.target; t; t = t.parentNode) {
152
+ if (sidMatches(observer.target, t) && isConcerned(record, options)) {
153
+ logMutation(observer, record);
154
+ break;
155
+ }
156
+ if (!options.subtree) break;
157
+ }
158
+ });
159
+ }
160
+ //#endregion
161
+ //#region src/dom-external/mutation-observer/index.ts
162
+ var MutationObserver$1 = class {
163
+ constructor(callback) {
164
+ if (ENABLE_MUTATION_OBSERVER) this.core = new MutationObserverImpl(callback);
165
+ else {
166
+ if (process.env.NODE_ENV !== "production") console.warn("[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 'mini.runtime.enableMutationObserver: true'");
167
+ this.core = {
168
+ observe: _spcsn_taro_shared.noop,
169
+ disconnect: _spcsn_taro_shared.noop,
170
+ takeRecords: _spcsn_taro_shared.noop
171
+ };
172
+ }
173
+ }
174
+ observe(...args) {
175
+ this.core.observe(...args);
176
+ }
177
+ disconnect() {
178
+ this.core.disconnect();
179
+ }
180
+ takeRecords() {
181
+ return this.core.takeRecords();
182
+ }
183
+ static record(record) {
184
+ recordMutation(record);
185
+ }
186
+ };
187
+ //#endregion
188
+ //#region src/utils/lodash.ts
189
+ function throttle(fn, threshold = 250, scope) {
190
+ let lastTime = 0;
191
+ let deferTimer;
192
+ return function(...args) {
193
+ const context = scope || this;
194
+ const now = Date.now();
195
+ if (now - lastTime > threshold) {
196
+ fn.apply(this, args);
197
+ lastTime = now;
198
+ } else {
199
+ clearTimeout(deferTimer);
200
+ deferTimer = setTimeout(() => {
201
+ lastTime = now;
202
+ fn.apply(context, args);
203
+ }, threshold);
204
+ }
205
+ };
206
+ }
207
+ function debounce(fn, ms = 250, scope) {
208
+ let timer;
209
+ return function(...args) {
210
+ const context = scope || this;
211
+ clearTimeout(timer);
212
+ timer = setTimeout(function() {
213
+ fn.apply(context, args);
214
+ }, ms);
215
+ };
216
+ }
217
+ //#endregion
218
+ //#region src/emitter/emitter.ts
219
+ const eventCenter = _spcsn_taro_shared.hooks.call("getEventCenter", _spcsn_taro_shared.Events);
220
+ //#endregion
221
+ //#region src/env.ts
222
+ const env = {
223
+ window: process.env.TARO_PLATFORM === "web" ? window : _spcsn_taro_shared.EMPTY_OBJ,
224
+ document: process.env.TARO_PLATFORM === "web" ? document : _spcsn_taro_shared.EMPTY_OBJ
225
+ };
226
+ //#endregion
227
+ //#region src/bom/getComputedStyle.ts
228
+ const taroGetComputedStyleProvider = process.env.TARO_PLATFORM === "web" ? env.window.getComputedStyle : function(element) {
229
+ return element.style;
230
+ };
231
+ //#endregion
232
+ //#region src/utils/cache.ts
233
+ /**
234
+ * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
235
+ */
236
+ var RuntimeCache = class {
237
+ constructor(name) {
238
+ this.cache = /* @__PURE__ */ new Map();
239
+ this.name = name;
240
+ }
241
+ has(identifier) {
242
+ return this.cache.has(identifier);
243
+ }
244
+ set(identifier, ctx) {
245
+ if (identifier && ctx) this.cache.set(identifier, ctx);
246
+ }
247
+ get(identifier) {
248
+ if (this.has(identifier)) return this.cache.get(identifier);
249
+ }
250
+ delete(identifier) {
251
+ this.cache.delete(identifier);
252
+ }
253
+ };
254
+ //#endregion
255
+ //#region src/bom/history.ts
256
+ const cache$1 = new RuntimeCache("history");
257
+ var TaroHistory = class extends _spcsn_taro_shared.Events {
258
+ #location;
259
+ #stack = [];
260
+ #cur = 0;
261
+ #window;
262
+ constructor(location, options) {
263
+ super();
264
+ this.#window = options.window;
265
+ this.#location = location;
266
+ this.#location.on("__record_history__", (href) => {
267
+ this.#cur++;
268
+ this.#stack = this.#stack.slice(0, this.#cur);
269
+ this.#stack.push({
270
+ state: null,
271
+ title: "",
272
+ url: href
273
+ });
274
+ }, null);
275
+ this.#location.on("__reset_history__", (href) => {
276
+ this.#reset(href);
277
+ }, null);
278
+ this.on("0", () => {
279
+ this.#reset();
280
+ }, null);
281
+ this.on("1", (pageId) => {
282
+ cache$1.set(pageId, {
283
+ location: this.#location,
284
+ stack: this.#stack.slice(),
285
+ cur: this.#cur
286
+ });
287
+ }, null);
288
+ this.on("2", (pageId) => {
289
+ if (cache$1.has(pageId)) {
290
+ const ctx = cache$1.get(pageId);
291
+ this.#location = ctx.location;
292
+ this.#stack = ctx.stack;
293
+ this.#cur = ctx.cur;
294
+ }
295
+ }, null);
296
+ this.on("3", (pageId) => {
297
+ cache$1.delete(pageId);
298
+ }, null);
299
+ this.#reset();
300
+ }
301
+ #reset(href = "") {
302
+ this.#stack = [{
303
+ state: null,
304
+ title: "",
305
+ url: href || this.#location.href
306
+ }];
307
+ this.#cur = 0;
308
+ }
309
+ get length() {
310
+ return this.#stack.length;
311
+ }
312
+ get state() {
313
+ return this.#stack[this.#cur].state;
314
+ }
315
+ go(delta) {
316
+ if (!(0, _spcsn_taro_shared.isNumber)(delta) || isNaN(delta)) return;
317
+ let targetIdx = this.#cur + delta;
318
+ targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
319
+ this.#cur = targetIdx;
320
+ this.#location.trigger("__set_href_without_history__", this.#stack[this.#cur].url);
321
+ this.#window.trigger("popstate", this.#stack[this.#cur]);
322
+ }
323
+ back() {
324
+ this.go(-1);
325
+ }
326
+ forward() {
327
+ this.go(1);
328
+ }
329
+ pushState(state, title, url) {
330
+ if (!url || !(0, _spcsn_taro_shared.isString)(url)) return;
331
+ this.#stack = this.#stack.slice(0, this.#cur + 1);
332
+ this.#stack.push({
333
+ state,
334
+ title,
335
+ url
336
+ });
337
+ this.#cur = this.length - 1;
338
+ this.#location.trigger("__set_href_without_history__", url);
339
+ }
340
+ replaceState(state, title, url) {
341
+ if (!url || !(0, _spcsn_taro_shared.isString)(url)) return;
342
+ this.#stack[this.#cur] = {
343
+ state,
344
+ title,
345
+ url
346
+ };
347
+ this.#location.trigger("__set_href_without_history__", url);
348
+ }
349
+ get cache() {
350
+ return cache$1;
351
+ }
352
+ };
353
+ const History = process.env.TARO_PLATFORM === "web" ? env.window.History : TaroHistory;
354
+ //#endregion
355
+ //#region src/current.ts
356
+ const Current = {
357
+ app: null,
358
+ router: null,
359
+ page: null
360
+ };
361
+ const getCurrentInstance = () => Current;
362
+ //#endregion
363
+ //#region src/bom/URLSearchParams.ts
364
+ const findReg = /[!'()~]|%20|%00/g;
365
+ const plusReg = /\+/g;
366
+ const replaceCharMap = {
367
+ "!": "%21",
368
+ "'": "%27",
369
+ "(": "%28",
370
+ ")": "%29",
371
+ "~": "%7E",
372
+ "%20": "+",
373
+ "%00": "\0"
374
+ };
375
+ function replacer(match) {
376
+ return replaceCharMap[match];
377
+ }
378
+ function appendTo(dict, name, value) {
379
+ const res = (0, _spcsn_taro_shared.isArray)(value) ? value.join(",") : value;
380
+ if (name in dict) dict[name].push(res);
381
+ else dict[name] = [res];
382
+ }
383
+ function addEach(value, key) {
384
+ appendTo(this, key, value);
385
+ }
386
+ function decode(str) {
387
+ return decodeURIComponent(str.replace(plusReg, " "));
388
+ }
389
+ function encode(str) {
390
+ return encodeURIComponent(str).replace(findReg, replacer);
391
+ }
392
+ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : class {
393
+ #dict = Object.create(null);
394
+ constructor(query) {
395
+ query ??= "";
396
+ const dict = this.#dict;
397
+ if (typeof query === "string") {
398
+ if (query.charAt(0) === "?") query = query.slice(1);
399
+ for (let pairs = query.split("&"), i = 0, length = pairs.length; i < length; i++) {
400
+ const value = pairs[i];
401
+ const index = value.indexOf("=");
402
+ try {
403
+ if (index > -1) appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
404
+ else if (value.length) appendTo(dict, decode(value), "");
405
+ } catch (err) {
406
+ if (process.env.NODE_ENV !== "production") console.warn(`[Taro warn] URL 参数 ${value} decode 异常`);
407
+ }
408
+ }
409
+ } else if ((0, _spcsn_taro_shared.isArray)(query)) for (let i = 0, length = query.length; i < length; i++) {
410
+ const value = query[i];
411
+ appendTo(dict, value[0], value[1]);
412
+ }
413
+ else if (query.forEach) query.forEach(addEach, dict);
414
+ else for (const key in query) appendTo(dict, key, query[key]);
415
+ }
416
+ append(name, value) {
417
+ appendTo(this.#dict, name, value);
418
+ }
419
+ delete(name) {
420
+ delete this.#dict[name];
421
+ }
422
+ get(name) {
423
+ const dict = this.#dict;
424
+ return name in dict ? dict[name][0] : null;
425
+ }
426
+ getAll(name) {
427
+ const dict = this.#dict;
428
+ return name in dict ? dict[name].slice(0) : [];
429
+ }
430
+ has(name) {
431
+ return name in this.#dict;
432
+ }
433
+ keys() {
434
+ return Object.keys(this.#dict);
435
+ }
436
+ set(name, value) {
437
+ this.#dict[name] = ["" + value];
438
+ }
439
+ forEach(callback, thisArg) {
440
+ const dict = this.#dict;
441
+ Object.getOwnPropertyNames(dict).forEach(function(name) {
442
+ dict[name].forEach(function(value) {
443
+ callback.call(thisArg, value, name, this);
444
+ }, this);
445
+ }, this);
446
+ }
447
+ toJSON() {
448
+ return {};
449
+ }
450
+ toString() {
451
+ const dict = this.#dict;
452
+ const query = [];
453
+ for (const key in dict) {
454
+ const name = encode(key);
455
+ for (let i = 0, value = dict[key]; i < value.length; i++) query.push(name + "=" + encode(value[i]));
456
+ }
457
+ return query.join("&");
458
+ }
459
+ };
460
+ //#endregion
461
+ //#region src/bom/URL.ts
462
+ var TaroURL = class {
463
+ static createObjectURL() {
464
+ throw new Error("Oops, not support URL.createObjectURL() in miniprogram.");
465
+ }
466
+ static revokeObjectURL() {
467
+ throw new Error("Oops, not support URL.revokeObjectURL() in miniprogram.");
468
+ }
469
+ #hash = "";
470
+ #hostname = "";
471
+ #pathname = "";
472
+ #port = "";
473
+ #protocol = "";
474
+ #search;
475
+ constructor(url, base) {
476
+ if (!(0, _spcsn_taro_shared.isString)(url)) url = String(url);
477
+ const { hash, hostname, pathname, port, protocol, search } = parseUrlBase(url, base);
478
+ this.#hash = hash;
479
+ this.#hostname = hostname;
480
+ this.#pathname = pathname || "/";
481
+ this.#port = port;
482
+ this.#protocol = protocol;
483
+ this.#search = new URLSearchParams(search);
484
+ }
485
+ get protocol() {
486
+ return this.#protocol;
487
+ }
488
+ set protocol(val) {
489
+ (0, _spcsn_taro_shared.isString)(val) && (this.#protocol = val.trim());
490
+ }
491
+ get host() {
492
+ return this.hostname + (this.port ? ":" + this.port : "");
493
+ }
494
+ set host(val) {
495
+ if (val && (0, _spcsn_taro_shared.isString)(val)) {
496
+ val = val.trim();
497
+ const { hostname, port } = parseUrl(`//${val}`);
498
+ this.hostname = hostname;
499
+ this.port = port;
500
+ }
501
+ }
502
+ get hostname() {
503
+ return this.#hostname;
504
+ }
505
+ set hostname(val) {
506
+ val && (0, _spcsn_taro_shared.isString)(val) && (this.#hostname = val.trim());
507
+ }
508
+ get port() {
509
+ return this.#port;
510
+ }
511
+ set port(val) {
512
+ (0, _spcsn_taro_shared.isString)(val) && (this.#port = val.trim());
513
+ }
514
+ get pathname() {
515
+ return this.#pathname;
516
+ }
517
+ set pathname(val) {
518
+ if ((0, _spcsn_taro_shared.isString)(val)) {
519
+ val = val.trim();
520
+ const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
521
+ let temp = val;
522
+ while (HEAD_REG.test(temp)) temp = temp.replace(HEAD_REG, "");
523
+ if (temp) this.#pathname = "/" + temp;
524
+ else this.#pathname = "/";
525
+ }
526
+ }
527
+ get search() {
528
+ const val = this.#search.toString();
529
+ return val.length === 0 || val.startsWith("?") ? val : `?${val}`;
530
+ }
531
+ set search(val) {
532
+ if ((0, _spcsn_taro_shared.isString)(val)) {
533
+ val = val.trim();
534
+ this.#search = new URLSearchParams(val);
535
+ }
536
+ }
537
+ get hash() {
538
+ return this.#hash;
539
+ }
540
+ set hash(val) {
541
+ if ((0, _spcsn_taro_shared.isString)(val)) {
542
+ val = val.trim();
543
+ if (val) this.#hash = val.startsWith("#") ? val : `#${val}`;
544
+ else this.#hash = "";
545
+ }
546
+ }
547
+ get href() {
548
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
549
+ }
550
+ set href(val) {
551
+ if (val && (0, _spcsn_taro_shared.isString)(val)) {
552
+ val = val.trim();
553
+ const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
554
+ this.protocol = protocol;
555
+ this.hostname = hostname;
556
+ this.pathname = pathname;
557
+ this.port = port;
558
+ this.hash = hash;
559
+ this.search = search;
560
+ }
561
+ }
562
+ get origin() {
563
+ return `${this.protocol}//${this.host}`;
564
+ }
565
+ set origin(val) {
566
+ if (val && (0, _spcsn_taro_shared.isString)(val)) {
567
+ val = val.trim();
568
+ const { protocol, hostname, port } = parseUrl(val);
569
+ this.protocol = protocol;
570
+ this.hostname = hostname;
571
+ this.port = port;
572
+ }
573
+ }
574
+ get searchParams() {
575
+ return this.#search;
576
+ }
577
+ toString() {
578
+ return this.href;
579
+ }
580
+ toJSON() {
581
+ return this.toString();
582
+ }
583
+ _toRaw() {
584
+ return {
585
+ protocol: this.protocol,
586
+ port: this.port,
587
+ host: this.host,
588
+ hostname: this.hostname,
589
+ pathname: this.pathname,
590
+ hash: this.hash,
591
+ search: this.search,
592
+ origin: this.origin,
593
+ href: this.href
594
+ };
595
+ }
596
+ };
597
+ const TaroURLProvider = process.env.TARO_PLATFORM === "web" ? env.window.URL : TaroURL;
598
+ function parseUrl(url = "") {
599
+ const result = {
600
+ href: "",
601
+ origin: "",
602
+ protocol: "",
603
+ hostname: "",
604
+ host: "",
605
+ port: "",
606
+ pathname: "",
607
+ search: "",
608
+ hash: ""
609
+ };
610
+ if (!url || !(0, _spcsn_taro_shared.isString)(url)) return result;
611
+ url = url.trim();
612
+ const matches = url.match(/^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/);
613
+ if (!matches) return result;
614
+ result.protocol = matches[1] || "https:";
615
+ result.hostname = matches[6] || "taro.com";
616
+ result.port = matches[8] || "";
617
+ result.pathname = matches[9] || "/";
618
+ result.search = matches[10] || "";
619
+ result.hash = matches[12] || "";
620
+ result.href = url;
621
+ result.origin = result.protocol + "//" + result.hostname + (result.port ? `:${result.port}` : "");
622
+ result.host = result.hostname + (result.port ? `:${result.port}` : "");
623
+ return result;
624
+ }
625
+ function parseUrlBase(url, base) {
626
+ const VALID_URL = /^(https?:)\/\//i;
627
+ let fullUrl = "";
628
+ let parsedBase = null;
629
+ if (!(0, _spcsn_taro_shared.isUndefined)(base)) {
630
+ base = String(base).trim();
631
+ if (!VALID_URL.test(base)) throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
632
+ parsedBase = parseUrl(base);
633
+ }
634
+ url = String(url).trim();
635
+ if (VALID_URL.test(url)) fullUrl = url;
636
+ else if (parsedBase) if (url) if (url.startsWith("//")) fullUrl = parsedBase.protocol + url;
637
+ else fullUrl = parsedBase.origin + (url.startsWith("/") ? url : `/${url}`);
638
+ else fullUrl = parsedBase.href;
639
+ else throw new TypeError(`Failed to construct 'URL': Invalid URL`);
640
+ return parseUrl(fullUrl);
641
+ }
642
+ //#endregion
643
+ //#region src/bom/location.ts
644
+ const INIT_URL = "https://taro.com";
645
+ const cache = new RuntimeCache("location");
646
+ var TaroLocation = class extends _spcsn_taro_shared.Events {
647
+ #url = new TaroURLProvider(INIT_URL);
648
+ #noCheckUrl = false;
649
+ #window;
650
+ constructor(options) {
651
+ super();
652
+ this.#window = options.window;
653
+ this.#reset();
654
+ this.on("__set_href_without_history__", (href) => {
655
+ this.#noCheckUrl = true;
656
+ const lastHash = this.#url.hash;
657
+ this.#url.href = generateFullUrl(href);
658
+ if (lastHash !== this.#url.hash) this.#window.trigger("hashchange");
659
+ this.#noCheckUrl = false;
660
+ }, null);
661
+ this.on("0", () => {
662
+ this.#reset();
663
+ }, null);
664
+ this.on("1", (pageId) => {
665
+ cache.set(pageId, { lastHref: this.href });
666
+ }, null);
667
+ this.on("2", (pageId) => {
668
+ if (cache.has(pageId)) {
669
+ const ctx = cache.get(pageId);
670
+ this.#noCheckUrl = true;
671
+ this.#url.href = ctx.lastHref;
672
+ this.#noCheckUrl = false;
673
+ }
674
+ }, null);
675
+ this.on("3", (pageId) => {
676
+ cache.delete(pageId);
677
+ }, null);
678
+ }
679
+ #reset() {
680
+ const router = getCurrentInstance().router;
681
+ if (router) {
682
+ const { path, params } = router;
683
+ const searchArr = Object.keys(params).map((key) => {
684
+ return `${key}=${params[key]}`;
685
+ });
686
+ const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
687
+ const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
688
+ this.#url = new TaroURLProvider(url);
689
+ this.trigger("__reset_history__", this.href);
690
+ }
691
+ }
692
+ #getPreValue() {
693
+ return this.#url._toRaw();
694
+ }
695
+ #rollBack(href) {
696
+ this.#url.href = href;
697
+ }
698
+ #recordHistory() {
699
+ this.trigger("__record_history__", this.href);
700
+ }
701
+ /**
702
+ * 校验url的变化,是否需要更新history
703
+ */
704
+ #checkUrlChange(preValue) {
705
+ if (this.#noCheckUrl) return false;
706
+ const { protocol, hostname, port, pathname, search, hash } = this.#url._toRaw();
707
+ if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
708
+ this.#rollBack(preValue.href);
709
+ return false;
710
+ }
711
+ if (pathname !== preValue.pathname) return true;
712
+ if (search !== preValue.search) return true;
713
+ if (hash !== preValue.hash) {
714
+ this.#window.trigger("hashchange");
715
+ return true;
716
+ }
717
+ this.#rollBack(preValue.href);
718
+ return false;
719
+ }
720
+ get protocol() {
721
+ return this.#url.protocol;
722
+ }
723
+ set protocol(val) {
724
+ if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http|https):$/i.test(val.trim())) return;
725
+ val = val.trim();
726
+ const preValue = this.#getPreValue();
727
+ this.#url.protocol = val;
728
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
729
+ }
730
+ get host() {
731
+ return this.#url.host;
732
+ }
733
+ set host(val) {
734
+ if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
735
+ val = val.trim();
736
+ const preValue = this.#getPreValue();
737
+ this.#url.host = val;
738
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
739
+ }
740
+ get hostname() {
741
+ return this.#url.hostname;
742
+ }
743
+ set hostname(val) {
744
+ if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
745
+ val = val.trim();
746
+ const preValue = this.#getPreValue();
747
+ this.#url.hostname = val;
748
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
749
+ }
750
+ get port() {
751
+ return this.#url.port;
752
+ }
753
+ set port(val) {
754
+ const xVal = Number(val = val.trim());
755
+ if (!(0, _spcsn_taro_shared.isNumber)(xVal) || xVal <= 0) return;
756
+ const preValue = this.#getPreValue();
757
+ this.#url.port = val;
758
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
759
+ }
760
+ get pathname() {
761
+ return this.#url.pathname;
762
+ }
763
+ set pathname(val) {
764
+ if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
765
+ val = val.trim();
766
+ const preValue = this.#getPreValue();
767
+ this.#url.pathname = val;
768
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
769
+ }
770
+ get search() {
771
+ return this.#url.search;
772
+ }
773
+ set search(val) {
774
+ if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
775
+ val = val.trim();
776
+ val = val.startsWith("?") ? val : `?${val}`;
777
+ const preValue = this.#getPreValue();
778
+ this.#url.search = val;
779
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
780
+ }
781
+ get hash() {
782
+ return this.#url.hash;
783
+ }
784
+ set hash(val) {
785
+ if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
786
+ val = val.trim();
787
+ val = val.startsWith("#") ? val : `#${val}`;
788
+ const preValue = this.#getPreValue();
789
+ this.#url.hash = val;
790
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
791
+ }
792
+ get href() {
793
+ return this.#url.href;
794
+ }
795
+ set href(val) {
796
+ if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
797
+ const preValue = this.#getPreValue();
798
+ this.#url.href = val;
799
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
800
+ }
801
+ get origin() {
802
+ return this.#url.origin;
803
+ }
804
+ set origin(val) {
805
+ if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
806
+ const preValue = this.#getPreValue();
807
+ this.#url.origin = val;
808
+ if (this.#checkUrlChange(preValue)) this.#recordHistory();
809
+ }
810
+ assign() {
811
+ (0, _spcsn_taro_shared.warn)(true, "小程序环境中调用location.assign()无效.");
812
+ }
813
+ reload() {
814
+ (0, _spcsn_taro_shared.warn)(true, "小程序环境中调用location.reload()无效.");
815
+ }
816
+ replace(url) {
817
+ this.trigger("__set_href_without_history__", url);
818
+ }
819
+ toString() {
820
+ return this.href;
821
+ }
822
+ get cache() {
823
+ return cache;
824
+ }
825
+ };
826
+ const Location = process.env.TARO_PLATFORM === "web" ? env.window.Location : TaroLocation;
827
+ function generateFullUrl(val = "") {
828
+ const origin = INIT_URL;
829
+ if (/^[/?#]/.test(val)) return origin + val;
830
+ return val;
831
+ }
832
+ //#endregion
833
+ //#region src/bom/navigator.ts
834
+ const msg = "(Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36";
835
+ const nav = process.env.TARO_PLATFORM === "web" ? env.window.navigator : {
836
+ appCodeName: "Mozilla",
837
+ appName: "Netscape",
838
+ appVersion: "5.0 " + msg,
839
+ cookieEnabled: true,
840
+ mimeTypes: [],
841
+ onLine: true,
842
+ platform: "MacIntel",
843
+ plugins: [],
844
+ product: "Taro",
845
+ productSub: "20030107",
846
+ userAgent: "Mozilla/5.0 " + msg,
847
+ vendor: "Joyent",
848
+ vendorSub: ""
849
+ };
850
+ //#endregion
851
+ //#region src/bom/raf.ts
852
+ let now;
853
+ (function() {
854
+ let loadTime;
855
+ if (typeof performance !== "undefined" && performance !== null && performance.now) now = () => performance.now();
856
+ else if (Date.now) {
857
+ loadTime = Date.now();
858
+ now = () => Date.now() - loadTime;
859
+ } else {
860
+ loadTime = (/* @__PURE__ */ new Date()).getTime();
861
+ now = () => (/* @__PURE__ */ new Date()).getTime() - loadTime;
862
+ }
863
+ })();
864
+ let lastTime = 0;
865
+ const _raf = process.env.TARO_PLATFORM === "web" ? requestAnimationFrame : function(callback) {
866
+ const _now = now();
867
+ const nextTime = Math.max(lastTime + 16, _now);
868
+ return setTimeout(function() {
869
+ callback(lastTime = nextTime);
870
+ }, nextTime - _now);
871
+ };
872
+ const _caf = process.env.TARO_PLATFORM === "web" ? cancelAnimationFrame : function(seed) {
873
+ clearTimeout(seed);
874
+ };
875
+ //#endregion
876
+ //#region src/bom/window.ts
877
+ var TaroWindow = class extends _spcsn_taro_shared.Events {
878
+ constructor() {
879
+ super();
880
+ this.navigator = nav;
881
+ this.requestAnimationFrame = _raf;
882
+ this.cancelAnimationFrame = _caf;
883
+ this.getComputedStyle = taroGetComputedStyleProvider;
884
+ [...Object.getOwnPropertyNames(global || {}), ...Object.getOwnPropertySymbols(global || {})].forEach((property) => {
885
+ if (property === "atob" || property === "document") return;
886
+ if (!Object.prototype.hasOwnProperty.call(this, property)) try {
887
+ this[property] = global[property];
888
+ } catch (e) {
889
+ if (process.env.NODE_ENV !== "production") console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
890
+ }
891
+ });
892
+ this.Date ||= Date;
893
+ this.location = new Location({ window: this });
894
+ this.history = new History(this.location, { window: this });
895
+ this.initEvent();
896
+ }
897
+ initEvent() {
898
+ const _location = this.location;
899
+ const _history = this.history;
900
+ this.on("0", (pageId) => {
901
+ _location.trigger("0", pageId);
902
+ }, null);
903
+ this.on("2", (pageId) => {
904
+ _location.trigger("2", pageId);
905
+ _history.trigger("2", pageId);
906
+ }, null);
907
+ this.on("1", (pageId) => {
908
+ _location.trigger("1", pageId);
909
+ _history.trigger("1", pageId);
910
+ }, null);
911
+ this.on("3", (pageId) => {
912
+ _location.trigger("3", pageId);
913
+ _history.trigger("3", pageId);
914
+ }, null);
915
+ }
916
+ get document() {
917
+ return env.document;
918
+ }
919
+ addEventListener(event, callback) {
920
+ if (!(0, _spcsn_taro_shared.isString)(event)) return;
921
+ this.on(event, callback, null);
922
+ }
923
+ removeEventListener(event, callback) {
924
+ if (!(0, _spcsn_taro_shared.isString)(event)) return;
925
+ this.off(event, callback, null);
926
+ }
927
+ setTimeout(...args) {
928
+ return setTimeout(...args);
929
+ }
930
+ clearTimeout(...args) {
931
+ return clearTimeout(...args);
932
+ }
933
+ };
934
+ const taroWindowProvider = process.env.TARO_PLATFORM === "web" ? env.window : env.window = new TaroWindow();
935
+ const taroLocationProvider = taroWindowProvider.location;
936
+ const taroHistoryProvider = taroWindowProvider.history;
937
+ //#endregion
938
+ //#region src/utils/router.ts
939
+ const addLeadingSlash = (url = "") => url.charAt(0) === "/" ? url : "/" + url;
940
+ const hasBasename = (path = "", prefix = "") => new RegExp("^" + prefix + "(\\/|\\?|#|$)", "i").test(path) || path === prefix;
941
+ const stripBasename = (path = "", prefix = "") => hasBasename(path, prefix) ? path.substring(prefix.length) : path;
942
+ const stripTrailing = (str = "") => str.replace(/[?#][\s\S]*$/, "");
943
+ const stripSuffix = (path = "", suffix = "") => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
944
+ const getHomePage = (path = "", basename = "", customRoutes = {}, entryPagePath = "") => {
945
+ const routePath = addLeadingSlash(stripBasename(path, basename));
946
+ const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;
947
+ return entryPagePath || (typeof alias === "string" ? alias : alias[0]) || basename;
948
+ };
949
+ const getCurrentPage = (routerMode = "hash", basename = "/") => {
950
+ return addLeadingSlash(stripBasename(routerMode === "hash" ? taroLocationProvider.hash.slice(1).split("?")[0] : taroLocationProvider.pathname, basename));
951
+ };
952
+ //#endregion
953
+ //#region src/utils/index.ts
954
+ const incrementId = () => {
955
+ const chatCodes = [];
956
+ for (let i = 65; i <= 90; i++) chatCodes.push(i);
957
+ for (let i = 97; i <= 122; i++) chatCodes.push(i);
958
+ const chatCodesLen = chatCodes.length - 1;
959
+ const list = [0, 0];
960
+ return () => {
961
+ const target = list.map((item) => chatCodes[item]);
962
+ const res = String.fromCharCode(...target);
963
+ let tailIdx = list.length - 1;
964
+ list[tailIdx]++;
965
+ while (list[tailIdx] > chatCodesLen) {
966
+ list[tailIdx] = 0;
967
+ tailIdx = tailIdx - 1;
968
+ if (tailIdx < 0) {
969
+ list.push(0);
970
+ break;
971
+ }
972
+ list[tailIdx]++;
973
+ }
974
+ return res;
975
+ };
976
+ };
977
+ function isElement(node) {
978
+ return node.nodeType === 1;
979
+ }
980
+ function isText(node) {
981
+ return node.nodeType === 3;
982
+ }
983
+ function isComment(node) {
984
+ return node.nodeName === COMMENT;
985
+ }
986
+ function isHasExtractProp(el) {
987
+ const res = Object.keys(el.props).find((prop) => {
988
+ return !(/^(class|style|id)$/.test(prop) || prop.startsWith("data-"));
989
+ });
990
+ return Boolean(res);
991
+ }
992
+ /**
993
+ * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
994
+ * @param node 当前组件
995
+ * @param type 事件类型
996
+ */
997
+ function isParentBound(node, type) {
998
+ while (node = node?.parentElement || null) if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
999
+ else if (node.__handlers[type]?.length) return true;
1000
+ return false;
1001
+ }
1002
+ function shortcutAttr(key) {
1003
+ switch (key) {
1004
+ case STYLE: return _spcsn_taro_shared.Shortcuts.Style;
1005
+ case "id": return "uid";
1006
+ case CLASS: return _spcsn_taro_shared.Shortcuts.Class;
1007
+ default: return key;
1008
+ }
1009
+ }
1010
+ const customWrapperCache = /* @__PURE__ */ new Map();
1011
+ function extend(ctor, methodName, options) {
1012
+ if ((0, _spcsn_taro_shared.isFunction)(options)) options = { value: options };
1013
+ Object.defineProperty(ctor.prototype, methodName, {
1014
+ configurable: true,
1015
+ enumerable: true,
1016
+ ...options
1017
+ });
1018
+ }
1019
+ let componentsAlias$1;
1020
+ function getComponentsAlias() {
1021
+ if (!componentsAlias$1) componentsAlias$1 = (0, _spcsn_taro_shared.getComponentsAlias)(_spcsn_taro_shared.internalComponents);
1022
+ return componentsAlias$1;
1023
+ }
1024
+ function convertNumber2PX(value) {
1025
+ return value + "px";
1026
+ }
1027
+ //#endregion
1028
+ //#region src/dom/class-list.ts
1029
+ var ClassList = class {
1030
+ constructor(className, el) {
1031
+ this.tokenList = [];
1032
+ this.el = el;
1033
+ className.trim().split(/\s+/).forEach((token) => this.tokenList.push(token));
1034
+ }
1035
+ get value() {
1036
+ return this.toString();
1037
+ }
1038
+ get length() {
1039
+ return this.tokenList.length;
1040
+ }
1041
+ add() {
1042
+ let index = 0;
1043
+ let updated = false;
1044
+ const tokens = arguments;
1045
+ const length = tokens.length;
1046
+ const tokenList = this.tokenList;
1047
+ do {
1048
+ const token = tokens[index];
1049
+ if (this.checkTokenIsValid(token) && !~tokenList.indexOf(token)) {
1050
+ tokenList.push(token);
1051
+ updated = true;
1052
+ }
1053
+ } while (++index < length);
1054
+ if (updated) this._update();
1055
+ }
1056
+ remove() {
1057
+ let i = 0;
1058
+ let updated = false;
1059
+ const tokens = arguments;
1060
+ const length = tokens.length;
1061
+ const tokenList = this.tokenList;
1062
+ do {
1063
+ const token = tokens[i] + "";
1064
+ if (!this.checkTokenIsValid(token)) continue;
1065
+ const index = tokenList.indexOf(token);
1066
+ if (~tokenList.indexOf(token)) {
1067
+ tokenList.splice(index, 1);
1068
+ updated = true;
1069
+ }
1070
+ } while (++i < length);
1071
+ if (updated) this._update();
1072
+ }
1073
+ contains(token) {
1074
+ if (!this.checkTokenIsValid(token)) return false;
1075
+ return !!~this.tokenList.indexOf(token);
1076
+ }
1077
+ toggle(token, force) {
1078
+ const result = this.contains(token);
1079
+ const method = result ? force !== true && "remove" : force !== false && "add";
1080
+ if (method) this[method](token);
1081
+ if (force === true || force === false) return force;
1082
+ else return !result;
1083
+ }
1084
+ replace(token, replacement_token) {
1085
+ if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token)) return;
1086
+ const index = this.tokenList.indexOf(token);
1087
+ if (~index) {
1088
+ this.tokenList.splice(index, 1, replacement_token);
1089
+ this._update();
1090
+ }
1091
+ }
1092
+ toString() {
1093
+ return this.tokenList.filter((v) => v !== "").join(" ");
1094
+ }
1095
+ checkTokenIsValid(token) {
1096
+ if (token === "" || /\s/.test(token)) return false;
1097
+ return true;
1098
+ }
1099
+ _update() {
1100
+ this.el.className = this.value;
1101
+ }
1102
+ };
1103
+ //#endregion
1104
+ //#region src/dom/event-source.ts
1105
+ var EventSource = class extends Map {
1106
+ removeNode(child) {
1107
+ const { sid, uid } = child;
1108
+ this.delete(sid);
1109
+ if (uid !== sid && uid) this.delete(uid);
1110
+ }
1111
+ removeNodeTree(child) {
1112
+ this.removeNode(child);
1113
+ const { childNodes } = child;
1114
+ childNodes.forEach((node) => this.removeNodeTree(node));
1115
+ }
1116
+ };
1117
+ const eventSource = new EventSource();
1118
+ //#endregion
1119
+ //#region src/hydrate.ts
1120
+ let SPECIAL_NODES;
1121
+ let componentsAlias;
1122
+ /**
1123
+ * React also has a fancy function's name for this: `hydrate()`.
1124
+ * You may have been heard `hydrate` as a SSR-related function,
1125
+ * actually, `hydrate` basicly do the `render()` thing, but ignore some properties,
1126
+ * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
1127
+ */
1128
+ function hydrate(node) {
1129
+ componentsAlias ||= getComponentsAlias();
1130
+ SPECIAL_NODES ||= _spcsn_taro_shared.hooks.call("getSpecialNodes");
1131
+ const nodeName = node.nodeName;
1132
+ let compileModeName = null;
1133
+ if (isText(node)) return {
1134
+ sid: node.sid,
1135
+ [_spcsn_taro_shared.Shortcuts.Text]: node.nodeValue,
1136
+ [_spcsn_taro_shared.Shortcuts.NodeName]: componentsAlias[nodeName]?._num || "8"
1137
+ };
1138
+ const data = {
1139
+ [_spcsn_taro_shared.Shortcuts.NodeName]: nodeName,
1140
+ sid: node.sid
1141
+ };
1142
+ if (node.uid !== node.sid) data.uid = node.uid;
1143
+ if (SPECIAL_NODES.indexOf(nodeName) > -1) {
1144
+ if (!node.isAnyEventBinded()) {
1145
+ data[_spcsn_taro_shared.Shortcuts.NodeName] = `static-${nodeName}`;
1146
+ if (nodeName === "view" && !isHasExtractProp(node)) data[_spcsn_taro_shared.Shortcuts.NodeName] = PURE_VIEW;
1147
+ }
1148
+ if (nodeName === "view" && node.isOnlyClickBinded() && !isHasExtractProp(node)) data[_spcsn_taro_shared.Shortcuts.NodeName] = CLICK_VIEW;
1149
+ }
1150
+ const { props } = node;
1151
+ for (const prop in props) {
1152
+ const propInCamelCase = (0, _spcsn_taro_shared.toCamelCase)(prop);
1153
+ if (!prop.startsWith("data-") && prop !== "class" && prop !== "style" && prop !== "id" && propInCamelCase !== "catchMove" && propInCamelCase !== "compileMode") data[propInCamelCase] = props[prop];
1154
+ if (process.env.TARO_ENV !== "swan" && nodeName === "view" && propInCamelCase === "catchMove" && props[prop] !== false) data[_spcsn_taro_shared.Shortcuts.NodeName] = CATCH_VIEW;
1155
+ if (propInCamelCase === "compileMode") compileModeName = props[prop];
1156
+ }
1157
+ data[_spcsn_taro_shared.Shortcuts.Childnodes] = node.childNodes.filter((node) => !isComment(node)).map(hydrate);
1158
+ if (node.className !== "") data[_spcsn_taro_shared.Shortcuts.Class] = node.className;
1159
+ const cssText = node.cssText;
1160
+ if (cssText !== "" && nodeName !== "swiper-item") data[_spcsn_taro_shared.Shortcuts.Style] = cssText;
1161
+ _spcsn_taro_shared.hooks.call("modifyHydrateData", data, node);
1162
+ const nn = data[_spcsn_taro_shared.Shortcuts.NodeName];
1163
+ const componentAlias = componentsAlias[nn];
1164
+ if (componentAlias) {
1165
+ data[_spcsn_taro_shared.Shortcuts.NodeName] = componentAlias._num;
1166
+ for (const prop in data) if (prop in componentAlias) {
1167
+ data[componentAlias[prop]] = data[prop];
1168
+ delete data[prop];
1169
+ }
1170
+ }
1171
+ if (compileModeName !== null) data[_spcsn_taro_shared.Shortcuts.NodeName] = compileModeName;
1172
+ return _spcsn_taro_shared.hooks.call("transferHydrateData", data, node, componentAlias) || data;
1173
+ }
1174
+ //#endregion
1175
+ //#region src/dom/event-target.ts
1176
+ var TaroEventTarget = class {
1177
+ constructor() {
1178
+ this.__handlers = {};
1179
+ }
1180
+ addEventListener(type, handler, options) {
1181
+ type = type.toLowerCase();
1182
+ _spcsn_taro_shared.hooks.call("onAddEvent", type, handler, options, this);
1183
+ if (type === "regionchange") {
1184
+ this.addEventListener("begin", handler, options);
1185
+ this.addEventListener("end", handler, options);
1186
+ return;
1187
+ }
1188
+ let isCapture = Boolean(options);
1189
+ let isOnce = false;
1190
+ if ((0, _spcsn_taro_shared.isObject)(options)) {
1191
+ isCapture = Boolean(options.capture);
1192
+ isOnce = Boolean(options.once);
1193
+ }
1194
+ if (isOnce) {
1195
+ const wrapper = function() {
1196
+ handler.apply(this, arguments);
1197
+ this.removeEventListener(type, wrapper);
1198
+ };
1199
+ this.addEventListener(type, wrapper, {
1200
+ ...options,
1201
+ once: false
1202
+ });
1203
+ return;
1204
+ }
1205
+ process.env.NODE_ENV !== "production" && (0, _spcsn_taro_shared.warn)(isCapture, "Taro 暂未实现 event 的 capture 特性。");
1206
+ const oldHandler = handler;
1207
+ handler = function() {
1208
+ return oldHandler.apply(this, arguments);
1209
+ };
1210
+ handler.oldHandler = oldHandler;
1211
+ const handlers = this.__handlers[type];
1212
+ if ((0, _spcsn_taro_shared.isArray)(handlers)) handlers.push(handler);
1213
+ else this.__handlers[type] = [handler];
1214
+ }
1215
+ removeEventListener(type, handler) {
1216
+ type = type.toLowerCase();
1217
+ if (type === "regionchange") {
1218
+ this.removeEventListener("begin", handler);
1219
+ this.removeEventListener("end", handler);
1220
+ return;
1221
+ }
1222
+ if (!handler) return;
1223
+ const handlers = this.__handlers[type];
1224
+ if (!(0, _spcsn_taro_shared.isArray)(handlers)) return;
1225
+ const index = handlers.findIndex((item) => {
1226
+ if (item === handler || item.oldHandler === handler) return true;
1227
+ });
1228
+ process.env.NODE_ENV !== "production" && (0, _spcsn_taro_shared.warn)(index === -1, `事件: '${type}' 没有注册在 DOM 中,因此不会被移除。`);
1229
+ handlers.splice(index, 1);
1230
+ }
1231
+ isAnyEventBinded() {
1232
+ const handlers = this.__handlers;
1233
+ const isAnyEventBinded = Object.keys(handlers).find((key) => handlers[key].length);
1234
+ return Boolean(isAnyEventBinded);
1235
+ }
1236
+ isOnlyClickBinded() {
1237
+ const handlers = this.__handlers;
1238
+ const isOnlyClickBinded = handlers.tap && Object.keys(handlers).length === 1;
1239
+ return Boolean(isOnlyClickBinded);
1240
+ }
1241
+ };
1242
+ //#endregion
1243
+ //#region src/dom/node.ts
1244
+ const CHILDNODES = _spcsn_taro_shared.Shortcuts.Childnodes;
1245
+ const nodeId = incrementId();
1246
+ var TaroNode = class TaroNode extends TaroEventTarget {
1247
+ constructor() {
1248
+ super();
1249
+ this.parentNode = null;
1250
+ this.childNodes = [];
1251
+ this.hydrate = (node) => () => hydrate(node);
1252
+ this.uid = "_" + nodeId();
1253
+ this.sid = this.uid;
1254
+ eventSource.set(this.sid, this);
1255
+ }
1256
+ updateChildNodes(isClean) {
1257
+ const cleanChildNodes = () => [];
1258
+ const rerenderChildNodes = () => {
1259
+ return this.childNodes.filter((node) => !isComment(node)).map(hydrate);
1260
+ };
1261
+ this.enqueueUpdate({
1262
+ path: `${this._path}.${CHILDNODES}`,
1263
+ value: isClean ? cleanChildNodes : rerenderChildNodes
1264
+ });
1265
+ }
1266
+ updateSingleChild(index) {
1267
+ this.childNodes.forEach((child, childIndex) => {
1268
+ if (isComment(child)) return;
1269
+ if (index && childIndex < index) return;
1270
+ this.enqueueUpdate({
1271
+ path: child._path,
1272
+ value: this.hydrate(child)
1273
+ });
1274
+ });
1275
+ }
1276
+ get _root() {
1277
+ return this.parentNode?._root || null;
1278
+ }
1279
+ findIndex(refChild) {
1280
+ const index = this.childNodes.indexOf(refChild);
1281
+ (0, _spcsn_taro_shared.ensure)(index !== -1, "The node to be replaced is not a child of this node.");
1282
+ return index;
1283
+ }
1284
+ get _path() {
1285
+ const parentNode = this.parentNode;
1286
+ if (parentNode) {
1287
+ const indexOfNode = parentNode.childNodes.filter((node) => !isComment(node)).indexOf(this);
1288
+ const index = _spcsn_taro_shared.hooks.call("getPathIndex", indexOfNode);
1289
+ return `${parentNode._path}.${CHILDNODES}.${index}`;
1290
+ }
1291
+ return "";
1292
+ }
1293
+ get nextSibling() {
1294
+ const parentNode = this.parentNode;
1295
+ return parentNode?.childNodes[parentNode.findIndex(this) + 1] || null;
1296
+ }
1297
+ get previousSibling() {
1298
+ const parentNode = this.parentNode;
1299
+ return parentNode?.childNodes[parentNode.findIndex(this) - 1] || null;
1300
+ }
1301
+ get parentElement() {
1302
+ const parentNode = this.parentNode;
1303
+ if (parentNode?.nodeType === 1) return parentNode;
1304
+ return null;
1305
+ }
1306
+ get firstChild() {
1307
+ return this.childNodes[0] || null;
1308
+ }
1309
+ get lastChild() {
1310
+ const childNodes = this.childNodes;
1311
+ return childNodes[childNodes.length - 1] || null;
1312
+ }
1313
+ /**
1314
+ * @textContent 目前只能置空子元素
1315
+ * @TODO 等待完整 innerHTML 实现
1316
+ */
1317
+ set textContent(text) {
1318
+ const removedNodes = this.childNodes.slice();
1319
+ const addedNodes = [];
1320
+ while (this.firstChild) this.removeChild(this.firstChild, { doUpdate: false });
1321
+ if (text === "") this.updateChildNodes(true);
1322
+ else {
1323
+ const newText = env.document.createTextNode(text);
1324
+ addedNodes.push(newText);
1325
+ this.appendChild(newText);
1326
+ this.updateChildNodes();
1327
+ }
1328
+ MutationObserver$1.record({
1329
+ type: "childList",
1330
+ target: this,
1331
+ removedNodes,
1332
+ addedNodes
1333
+ });
1334
+ }
1335
+ /**
1336
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
1337
+ * @scenario
1338
+ * [A,B,C]
1339
+ * 1. insert D before C, D has no parent
1340
+ * 2. insert D before C, D has the same parent of C
1341
+ * 3. insert D before C, D has the different parent of C
1342
+ */
1343
+ insertBefore(newChild, refChild, isReplace) {
1344
+ if (newChild.nodeName === "document-fragment") {
1345
+ newChild.childNodes.reduceRight((previousValue, currentValue) => {
1346
+ this.insertBefore(currentValue, previousValue);
1347
+ return currentValue;
1348
+ }, refChild);
1349
+ return newChild;
1350
+ }
1351
+ newChild.remove({ cleanRef: false });
1352
+ let index = 0;
1353
+ newChild.parentNode = this;
1354
+ if (refChild) {
1355
+ index = this.findIndex(refChild);
1356
+ this.childNodes.splice(index, 0, newChild);
1357
+ } else this.childNodes.push(newChild);
1358
+ const childNodesLength = this.childNodes.length;
1359
+ if (this._root) if (!refChild) if (childNodesLength === 1) this.updateChildNodes();
1360
+ else this.enqueueUpdate({
1361
+ path: newChild._path,
1362
+ value: this.hydrate(newChild)
1363
+ });
1364
+ else if (isReplace) this.enqueueUpdate({
1365
+ path: newChild._path,
1366
+ value: this.hydrate(newChild)
1367
+ });
1368
+ else if (childNodesLength * 2 / 3 > index) this.updateChildNodes();
1369
+ else this.updateSingleChild(index);
1370
+ MutationObserver$1.record({
1371
+ type: "childList",
1372
+ target: this,
1373
+ addedNodes: [newChild],
1374
+ removedNodes: isReplace ? [refChild] : [],
1375
+ nextSibling: isReplace ? refChild.nextSibling : refChild || null,
1376
+ previousSibling: newChild.previousSibling
1377
+ });
1378
+ return newChild;
1379
+ }
1380
+ /**
1381
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/appendChild
1382
+ * @scenario
1383
+ * [A,B,C]
1384
+ * 1. append C, C has no parent
1385
+ * 2. append C, C has the same parent of B
1386
+ * 3. append C, C has the different parent of B
1387
+ */
1388
+ appendChild(newChild) {
1389
+ return this.insertBefore(newChild);
1390
+ }
1391
+ /**
1392
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
1393
+ * @scenario
1394
+ * [A,B,C]
1395
+ * 1. replace B with C, C has no parent
1396
+ * 2. replace B with C, C has no parent, C has the same parent of B
1397
+ * 3. replace B with C, C has no parent, C has the different parent of B
1398
+ */
1399
+ replaceChild(newChild, oldChild) {
1400
+ if (oldChild.parentNode !== this) return;
1401
+ this.insertBefore(newChild, oldChild, true);
1402
+ oldChild.remove({ doUpdate: false });
1403
+ return oldChild;
1404
+ }
1405
+ /**
1406
+ * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/removeChild
1407
+ * @scenario
1408
+ * [A,B,C]
1409
+ * 1. remove A or B
1410
+ * 2. remove C
1411
+ */
1412
+ removeChild(child, options = {}) {
1413
+ const { cleanRef, doUpdate } = options;
1414
+ if (cleanRef !== false && doUpdate !== false) MutationObserver$1.record({
1415
+ type: "childList",
1416
+ target: this,
1417
+ removedNodes: [child],
1418
+ nextSibling: child.nextSibling,
1419
+ previousSibling: child.previousSibling
1420
+ });
1421
+ const index = this.findIndex(child);
1422
+ this.childNodes.splice(index, 1);
1423
+ child.parentNode = null;
1424
+ if (cleanRef !== false) eventSource.removeNodeTree(child);
1425
+ if (this._root && doUpdate !== false) this.updateChildNodes();
1426
+ return child;
1427
+ }
1428
+ remove(options) {
1429
+ this.parentNode?.removeChild(this, options);
1430
+ }
1431
+ hasChildNodes() {
1432
+ return this.childNodes.length > 0;
1433
+ }
1434
+ enqueueUpdate(payload) {
1435
+ this._root?.enqueueUpdate(payload);
1436
+ }
1437
+ get ownerDocument() {
1438
+ return env.document;
1439
+ }
1440
+ static extend(methodName, options) {
1441
+ extend(TaroNode, methodName, options);
1442
+ }
1443
+ };
1444
+ //#endregion
1445
+ //#region src/dom/style_properties.ts
1446
+ const WEBKIT = "webkit";
1447
+ const styleProperties = [
1448
+ "all",
1449
+ "appearance",
1450
+ "backdropFilter",
1451
+ "blockOverflow",
1452
+ "blockSize",
1453
+ "bottom",
1454
+ "clear",
1455
+ "contain",
1456
+ "content",
1457
+ "continue",
1458
+ "cursor",
1459
+ "direction",
1460
+ "display",
1461
+ "filter",
1462
+ "float",
1463
+ "gap",
1464
+ "height",
1465
+ "inset",
1466
+ "isolation",
1467
+ "left",
1468
+ "letterSpacing",
1469
+ "lightingColor",
1470
+ "markerSide",
1471
+ "mixBlendMode",
1472
+ "opacity",
1473
+ "order",
1474
+ "position",
1475
+ "quotes",
1476
+ "resize",
1477
+ "right",
1478
+ "rowGap",
1479
+ "tabSize",
1480
+ "tableLayout",
1481
+ "top",
1482
+ "userSelect",
1483
+ "verticalAlign",
1484
+ "visibility",
1485
+ "voiceFamily",
1486
+ "volume",
1487
+ "whiteSpace",
1488
+ "widows",
1489
+ "width",
1490
+ "zIndex",
1491
+ "pointerEvents",
1492
+ "aspectRatio"
1493
+ ];
1494
+ function combine(prefix, list, excludeSelf) {
1495
+ !excludeSelf && styleProperties.push(prefix);
1496
+ list.forEach((item) => {
1497
+ styleProperties.push(prefix + item);
1498
+ if (prefix === WEBKIT) styleProperties.push("Webkit" + item);
1499
+ });
1500
+ }
1501
+ const color = "Color";
1502
+ const style = "Style";
1503
+ const width = "Width";
1504
+ const image = "Image";
1505
+ const size = "Size";
1506
+ const color_style_width = [
1507
+ color,
1508
+ style,
1509
+ width
1510
+ ];
1511
+ const fitlength_fitwidth_image = [
1512
+ "FitLength",
1513
+ "FitWidth",
1514
+ image
1515
+ ];
1516
+ const fitlength_fitwidth_image_radius = [...fitlength_fitwidth_image, "Radius"];
1517
+ const color_style_width_fitlength_fitwidth_image = [...color_style_width, ...fitlength_fitwidth_image];
1518
+ const endRadius_startRadius = ["EndRadius", "StartRadius"];
1519
+ const bottom_left_right_top = [
1520
+ "Bottom",
1521
+ "Left",
1522
+ "Right",
1523
+ "Top"
1524
+ ];
1525
+ const end_start = ["End", "Start"];
1526
+ const content_items_self = [
1527
+ "Content",
1528
+ "Items",
1529
+ "Self"
1530
+ ];
1531
+ const blockSize_height_inlineSize_width = [
1532
+ "BlockSize",
1533
+ "Height",
1534
+ "InlineSize",
1535
+ width
1536
+ ];
1537
+ const after_before = ["After", "Before"];
1538
+ combine("borderBlock", color_style_width);
1539
+ combine("borderBlockEnd", color_style_width);
1540
+ combine("borderBlockStart", color_style_width);
1541
+ combine("outline", [...color_style_width, "Offset"]);
1542
+ combine("border", [
1543
+ ...color_style_width,
1544
+ "Boundary",
1545
+ "Break",
1546
+ "Collapse",
1547
+ "Radius",
1548
+ "Spacing"
1549
+ ]);
1550
+ combine("borderFit", ["Length", width]);
1551
+ combine("borderInline", color_style_width);
1552
+ combine("borderInlineEnd", color_style_width);
1553
+ combine("borderInlineStart", color_style_width);
1554
+ combine("borderLeft", color_style_width_fitlength_fitwidth_image);
1555
+ combine("borderRight", color_style_width_fitlength_fitwidth_image);
1556
+ combine("borderTop", color_style_width_fitlength_fitwidth_image);
1557
+ combine("borderBottom", color_style_width_fitlength_fitwidth_image);
1558
+ combine("textDecoration", [
1559
+ color,
1560
+ style,
1561
+ "Line"
1562
+ ]);
1563
+ combine("textEmphasis", [
1564
+ color,
1565
+ style,
1566
+ "Position"
1567
+ ]);
1568
+ combine("scrollMargin", bottom_left_right_top);
1569
+ combine("scrollPadding", bottom_left_right_top);
1570
+ combine("padding", bottom_left_right_top);
1571
+ combine("margin", [...bottom_left_right_top, "Trim"]);
1572
+ combine("scrollMarginBlock", end_start);
1573
+ combine("scrollMarginInline", end_start);
1574
+ combine("scrollPaddingBlock", end_start);
1575
+ combine("scrollPaddingInline", end_start);
1576
+ combine("gridColumn", end_start);
1577
+ combine("gridRow", end_start);
1578
+ combine("insetBlock", end_start);
1579
+ combine("insetInline", end_start);
1580
+ combine("marginBlock", end_start);
1581
+ combine("marginInline", end_start);
1582
+ combine("paddingBlock", end_start);
1583
+ combine("paddingInline", end_start);
1584
+ combine("pause", after_before);
1585
+ combine("cue", after_before);
1586
+ combine("mask", [
1587
+ "Clip",
1588
+ "Composite",
1589
+ image,
1590
+ "Mode",
1591
+ "Origin",
1592
+ "Position",
1593
+ "Repeat",
1594
+ size,
1595
+ "Type"
1596
+ ]);
1597
+ combine("borderImage", [
1598
+ "Outset",
1599
+ "Repeat",
1600
+ "Slice",
1601
+ "Source",
1602
+ "Transform",
1603
+ width
1604
+ ]);
1605
+ combine("maskBorder", [
1606
+ "Mode",
1607
+ "Outset",
1608
+ "Repeat",
1609
+ "Slice",
1610
+ "Source",
1611
+ width
1612
+ ]);
1613
+ combine("font", [
1614
+ "Family",
1615
+ "FeatureSettings",
1616
+ "Kerning",
1617
+ "LanguageOverride",
1618
+ "MaxSize",
1619
+ "MinSize",
1620
+ "OpticalSizing",
1621
+ "Palette",
1622
+ size,
1623
+ "SizeAdjust",
1624
+ "Stretch",
1625
+ style,
1626
+ "Weight",
1627
+ "VariationSettings"
1628
+ ]);
1629
+ combine("transform", [
1630
+ "Box",
1631
+ "Origin",
1632
+ style
1633
+ ]);
1634
+ combine("background", [
1635
+ color,
1636
+ image,
1637
+ "Attachment",
1638
+ "BlendMode",
1639
+ "Clip",
1640
+ "Origin",
1641
+ "Position",
1642
+ "Repeat",
1643
+ size
1644
+ ]);
1645
+ combine("listStyle", [
1646
+ image,
1647
+ "Position",
1648
+ "Type"
1649
+ ]);
1650
+ combine("scrollSnap", [
1651
+ "Align",
1652
+ "Stop",
1653
+ "Type"
1654
+ ]);
1655
+ combine("grid", [
1656
+ "Area",
1657
+ "AutoColumns",
1658
+ "AutoFlow",
1659
+ "AutoRows"
1660
+ ]);
1661
+ combine("gridTemplate", [
1662
+ "Areas",
1663
+ "Columns",
1664
+ "Rows"
1665
+ ]);
1666
+ combine("overflow", [
1667
+ "Block",
1668
+ "Inline",
1669
+ "Wrap",
1670
+ "X",
1671
+ "Y"
1672
+ ]);
1673
+ combine("transition", [
1674
+ "Delay",
1675
+ "Duration",
1676
+ "Property",
1677
+ "TimingFunction"
1678
+ ]);
1679
+ combine("color", [
1680
+ "Adjust",
1681
+ "InterpolationFilters",
1682
+ "Scheme"
1683
+ ]);
1684
+ combine("textAlign", ["All", "Last"]);
1685
+ combine("page", [
1686
+ "BreakAfter",
1687
+ "BreakBefore",
1688
+ "BreakInside"
1689
+ ]);
1690
+ combine("animation", [
1691
+ "Delay",
1692
+ "Direction",
1693
+ "Duration",
1694
+ "FillMode",
1695
+ "IterationCount",
1696
+ "Name",
1697
+ "PlayState",
1698
+ "TimingFunction"
1699
+ ]);
1700
+ combine("flex", [
1701
+ "Basis",
1702
+ "Direction",
1703
+ "Flow",
1704
+ "Grow",
1705
+ "Shrink",
1706
+ "Wrap"
1707
+ ]);
1708
+ combine("offset", [
1709
+ ...after_before,
1710
+ ...end_start,
1711
+ "Anchor",
1712
+ "Distance",
1713
+ "Path",
1714
+ "Position",
1715
+ "Rotate"
1716
+ ]);
1717
+ combine("perspective", ["Origin"]);
1718
+ combine("clip", ["Path", "Rule"]);
1719
+ combine("flow", ["From", "Into"]);
1720
+ combine("align", [
1721
+ "Content",
1722
+ "Items",
1723
+ "Self"
1724
+ ], true);
1725
+ combine("alignment", ["Adjust", "Baseline"], true);
1726
+ combine("borderStart", endRadius_startRadius, true);
1727
+ combine("borderEnd", endRadius_startRadius, true);
1728
+ combine("borderCorner", [
1729
+ "Fit",
1730
+ image,
1731
+ "ImageTransform"
1732
+ ], true);
1733
+ combine("borderTopLeft", fitlength_fitwidth_image_radius, true);
1734
+ combine("borderTopRight", fitlength_fitwidth_image_radius, true);
1735
+ combine("borderBottomLeft", fitlength_fitwidth_image_radius, true);
1736
+ combine("borderBottomRight", fitlength_fitwidth_image_radius, true);
1737
+ combine("column", [
1738
+ "s",
1739
+ "Count",
1740
+ "Fill",
1741
+ "Gap",
1742
+ "Rule",
1743
+ "RuleColor",
1744
+ "RuleStyle",
1745
+ "RuleWidth",
1746
+ "Span",
1747
+ width
1748
+ ], true);
1749
+ combine("break", [...after_before, "Inside"], true);
1750
+ combine("wrap", [
1751
+ ...after_before,
1752
+ "Flow",
1753
+ "Inside",
1754
+ "Through"
1755
+ ], true);
1756
+ combine("justify", content_items_self, true);
1757
+ combine("place", content_items_self, true);
1758
+ combine("max", [...blockSize_height_inlineSize_width, "Lines"], true);
1759
+ combine("min", blockSize_height_inlineSize_width, true);
1760
+ combine("line", [
1761
+ "Break",
1762
+ "Clamp",
1763
+ "Grid",
1764
+ "Height",
1765
+ "Padding",
1766
+ "Snap"
1767
+ ], true);
1768
+ combine("inline", [
1769
+ "BoxAlign",
1770
+ size,
1771
+ "Sizing"
1772
+ ], true);
1773
+ combine("text", [
1774
+ "CombineUpright",
1775
+ "GroupAlign",
1776
+ "Height",
1777
+ "Indent",
1778
+ "Justify",
1779
+ "Orientation",
1780
+ "Overflow",
1781
+ "Shadow",
1782
+ "SpaceCollapse",
1783
+ "SpaceTrim",
1784
+ "Spacing",
1785
+ "Transform",
1786
+ "UnderlinePosition",
1787
+ "Wrap"
1788
+ ], true);
1789
+ combine("shape", [
1790
+ "ImageThreshold",
1791
+ "Inside",
1792
+ "Margin",
1793
+ "Outside"
1794
+ ], true);
1795
+ combine("word", [
1796
+ "Break",
1797
+ "Spacing",
1798
+ "Wrap"
1799
+ ], true);
1800
+ combine("object", ["Fit", "Position"], true);
1801
+ combine("box", [
1802
+ "DecorationBreak",
1803
+ "Shadow",
1804
+ "Sizing",
1805
+ "Snap"
1806
+ ], true);
1807
+ combine(WEBKIT, [
1808
+ "LineClamp",
1809
+ "BoxOrient",
1810
+ "TextFillColor",
1811
+ "TextStroke",
1812
+ "TextStrokeColor",
1813
+ "TextStrokeWidth"
1814
+ ], true);
1815
+ //#endregion
1816
+ //#region src/dom/style.ts
1817
+ function recordCss(obj) {
1818
+ MutationObserver$1.record({
1819
+ type: "attributes",
1820
+ target: obj._element,
1821
+ attributeName: "style",
1822
+ oldValue: obj.cssText
1823
+ });
1824
+ }
1825
+ function enqueueUpdate(obj) {
1826
+ const element = obj._element;
1827
+ if (element._root) element.enqueueUpdate({
1828
+ path: `${element._path}.${_spcsn_taro_shared.Shortcuts.Style}`,
1829
+ value: obj.cssText
1830
+ });
1831
+ }
1832
+ function setStyle(newVal, styleKey) {
1833
+ process.env.NODE_ENV !== "production" && (0, _spcsn_taro_shared.warn)((0, _spcsn_taro_shared.isString)(newVal) && newVal.length > 2046, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
1834
+ if (this[styleKey] === newVal) return;
1835
+ !this._pending && recordCss(this);
1836
+ if ((0, _spcsn_taro_shared.isNull)(newVal) || (0, _spcsn_taro_shared.isUndefined)(newVal) || newVal === "") {
1837
+ this._usedStyleProp.delete(styleKey);
1838
+ delete this._value[styleKey];
1839
+ } else {
1840
+ this._usedStyleProp.add(styleKey);
1841
+ this._value[styleKey] = newVal;
1842
+ }
1843
+ !this._pending && enqueueUpdate(this);
1844
+ }
1845
+ function initStyle(ctor, styleProperties) {
1846
+ const properties = {};
1847
+ for (let i = 0; i < styleProperties.length; i++) {
1848
+ const styleKey = styleProperties[i];
1849
+ if (ctor[styleKey]) return;
1850
+ properties[styleKey] = {
1851
+ get() {
1852
+ const val = this._value[styleKey];
1853
+ return (0, _spcsn_taro_shared.isNull)(val) || (0, _spcsn_taro_shared.isUndefined)(val) ? "" : val;
1854
+ },
1855
+ set(newVal) {
1856
+ setStyle.call(this, newVal, styleKey);
1857
+ }
1858
+ };
1859
+ }
1860
+ Object.defineProperties(ctor.prototype, properties);
1861
+ }
1862
+ function isCssVariable(propertyName) {
1863
+ return /^--/.test(propertyName);
1864
+ }
1865
+ var Style = class {
1866
+ constructor(element) {
1867
+ this._element = element;
1868
+ this._usedStyleProp = /* @__PURE__ */ new Set();
1869
+ this._value = {};
1870
+ }
1871
+ setCssVariables(styleKey) {
1872
+ this.hasOwnProperty(styleKey) || Object.defineProperty(this, styleKey, {
1873
+ enumerable: true,
1874
+ configurable: true,
1875
+ get: () => {
1876
+ return this._value[styleKey] || "";
1877
+ },
1878
+ set: (newVal) => {
1879
+ setStyle.call(this, newVal, styleKey);
1880
+ }
1881
+ });
1882
+ }
1883
+ get cssText() {
1884
+ if (!this._usedStyleProp.size) return "";
1885
+ const texts = [];
1886
+ this._usedStyleProp.forEach((key) => {
1887
+ const val = this[key];
1888
+ if ((0, _spcsn_taro_shared.isNull)(val) || (0, _spcsn_taro_shared.isUndefined)(val)) return;
1889
+ let styleName = isCssVariable(key) ? key : (0, _spcsn_taro_shared.toDashed)(key);
1890
+ if (styleName.indexOf("webkit") === 0 || styleName.indexOf("Webkit") === 0) styleName = `-${styleName}`;
1891
+ texts.push(`${styleName}: ${val};`);
1892
+ });
1893
+ return texts.join(" ");
1894
+ }
1895
+ set cssText(str) {
1896
+ this._pending = true;
1897
+ recordCss(this);
1898
+ this._usedStyleProp.forEach((prop) => {
1899
+ this.removeProperty(prop);
1900
+ });
1901
+ if (str === "" || (0, _spcsn_taro_shared.isUndefined)(str) || (0, _spcsn_taro_shared.isNull)(str)) {
1902
+ this._pending = false;
1903
+ enqueueUpdate(this);
1904
+ return;
1905
+ }
1906
+ const rules = str.split(";");
1907
+ for (let i = 0; i < rules.length; i++) {
1908
+ const rule = rules[i].trim();
1909
+ if (rule === "") continue;
1910
+ const [propName, ...valList] = rule.split(":");
1911
+ const val = valList.join(":");
1912
+ if ((0, _spcsn_taro_shared.isUndefined)(val)) continue;
1913
+ this.setProperty(propName.trim(), val.trim());
1914
+ }
1915
+ this._pending = false;
1916
+ enqueueUpdate(this);
1917
+ }
1918
+ setProperty(propertyName, value) {
1919
+ if (propertyName[0] === "-") this.setCssVariables(propertyName);
1920
+ else propertyName = (0, _spcsn_taro_shared.toCamelCase)(propertyName);
1921
+ if ((0, _spcsn_taro_shared.isNull)(value) || (0, _spcsn_taro_shared.isUndefined)(value)) this.removeProperty(propertyName);
1922
+ else this[propertyName] = value;
1923
+ }
1924
+ removeProperty(propertyName) {
1925
+ propertyName = (0, _spcsn_taro_shared.toCamelCase)(propertyName);
1926
+ if (!this._usedStyleProp.has(propertyName)) return "";
1927
+ const value = this[propertyName];
1928
+ this[propertyName] = void 0;
1929
+ return value;
1930
+ }
1931
+ getPropertyValue(propertyName) {
1932
+ propertyName = (0, _spcsn_taro_shared.toCamelCase)(propertyName);
1933
+ const value = this[propertyName];
1934
+ if (!value) return "";
1935
+ return value;
1936
+ }
1937
+ };
1938
+ initStyle(Style, styleProperties);
1939
+ _spcsn_taro_shared.hooks.tap("injectNewStyleProperties", (newStyleProperties) => {
1940
+ if ((0, _spcsn_taro_shared.isArray)(newStyleProperties)) initStyle(Style, newStyleProperties);
1941
+ else {
1942
+ if (typeof newStyleProperties !== "string") return;
1943
+ initStyle(Style, [newStyleProperties]);
1944
+ }
1945
+ });
1946
+ //#endregion
1947
+ //#region src/dom/tree.ts
1948
+ function returnTrue() {
1949
+ return true;
1950
+ }
1951
+ function treeToArray(root, predict) {
1952
+ const array = [];
1953
+ const filter = predict ?? returnTrue;
1954
+ let object = root;
1955
+ while (object) {
1956
+ if (object.nodeType === 1 && filter(object)) array.push(object);
1957
+ object = following(object, root);
1958
+ }
1959
+ return array;
1960
+ }
1961
+ function following(el, root) {
1962
+ const firstChild = el.firstChild;
1963
+ const isElmentTypeValid = el.nodeType === 1 || el.nodeType === 9;
1964
+ if (firstChild && isElmentTypeValid) return firstChild;
1965
+ let current = el;
1966
+ do {
1967
+ if (current === root) return null;
1968
+ const nextSibling = current.nextSibling;
1969
+ if (nextSibling) return nextSibling;
1970
+ current = current.parentElement;
1971
+ } while (current);
1972
+ return null;
1973
+ }
1974
+ //#endregion
1975
+ //#region src/dom/element.ts
1976
+ var TaroElement = class TaroElement extends TaroNode {
1977
+ constructor() {
1978
+ super();
1979
+ this.props = {};
1980
+ this.dataset = _spcsn_taro_shared.EMPTY_OBJ;
1981
+ this.nodeType = 1;
1982
+ this.style = new Style(this);
1983
+ _spcsn_taro_shared.hooks.call("patchElement", this);
1984
+ }
1985
+ _stopPropagation(event) {
1986
+ let target = this;
1987
+ while (target = target.parentNode) {
1988
+ const listeners = target.__handlers[event.type];
1989
+ if (!(0, _spcsn_taro_shared.isArray)(listeners)) continue;
1990
+ for (let i = listeners.length; i--;) {
1991
+ const l = listeners[i];
1992
+ l._stop = true;
1993
+ }
1994
+ }
1995
+ }
1996
+ get id() {
1997
+ return this.getAttribute("id");
1998
+ }
1999
+ set id(val) {
2000
+ this.setAttribute("id", val);
2001
+ }
2002
+ get className() {
2003
+ return this.getAttribute("class") || "";
2004
+ }
2005
+ set className(val) {
2006
+ this.setAttribute(CLASS, val);
2007
+ }
2008
+ get cssText() {
2009
+ return this.getAttribute("style") || "";
2010
+ }
2011
+ get classList() {
2012
+ return new ClassList(this.className, this);
2013
+ }
2014
+ get children() {
2015
+ return this.childNodes.filter(isElement);
2016
+ }
2017
+ get attributes() {
2018
+ const props = this.props;
2019
+ const propKeys = Object.keys(props);
2020
+ const style = this.style.cssText;
2021
+ return propKeys.map((key) => ({
2022
+ name: key,
2023
+ value: props[key]
2024
+ })).concat(style ? {
2025
+ name: STYLE,
2026
+ value: style
2027
+ } : []);
2028
+ }
2029
+ get textContent() {
2030
+ let text = "";
2031
+ const childNodes = this.childNodes;
2032
+ for (let i = 0; i < childNodes.length; i++) text += childNodes[i].textContent;
2033
+ return text;
2034
+ }
2035
+ set textContent(text) {
2036
+ super.textContent = text;
2037
+ }
2038
+ hasAttribute(qualifiedName) {
2039
+ return !(0, _spcsn_taro_shared.isUndefined)(this.props[qualifiedName]);
2040
+ }
2041
+ hasAttributes() {
2042
+ return this.attributes.length > 0;
2043
+ }
2044
+ get focus() {
2045
+ return function() {
2046
+ this.setAttribute(FOCUS, true);
2047
+ };
2048
+ }
2049
+ set focus(value) {
2050
+ this.setAttribute(FOCUS, value);
2051
+ }
2052
+ blur() {
2053
+ this.setAttribute(FOCUS, false);
2054
+ }
2055
+ setAttribute(qualifiedName, value) {
2056
+ process.env.NODE_ENV !== "production" && (0, _spcsn_taro_shared.warn)((0, _spcsn_taro_shared.isString)(value) && value.length > 2046, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
2057
+ const isPureView = this.nodeName === "view" && !isHasExtractProp(this) && !this.isAnyEventBinded();
2058
+ if (qualifiedName !== "style") MutationObserver$1.record({
2059
+ target: this,
2060
+ type: "attributes",
2061
+ attributeName: qualifiedName,
2062
+ oldValue: this.getAttribute(qualifiedName)
2063
+ });
2064
+ switch (qualifiedName) {
2065
+ case STYLE:
2066
+ this.style.cssText = value;
2067
+ break;
2068
+ case "id":
2069
+ if (this.uid !== this.sid) eventSource.delete(this.uid);
2070
+ value = String(value);
2071
+ this.props[qualifiedName] = this.uid = value;
2072
+ eventSource.set(value, this);
2073
+ break;
2074
+ default:
2075
+ this.props[qualifiedName] = value;
2076
+ if (qualifiedName.startsWith("data-")) {
2077
+ if (this.dataset === _spcsn_taro_shared.EMPTY_OBJ) this.dataset = Object.create(null);
2078
+ this.dataset[(0, _spcsn_taro_shared.toCamelCase)(qualifiedName.replace(/^data-/, ""))] = value;
2079
+ }
2080
+ break;
2081
+ }
2082
+ if (!this._root) return;
2083
+ const componentsAlias = getComponentsAlias();
2084
+ const _alias = componentsAlias[this.nodeName];
2085
+ const viewAlias = componentsAlias[VIEW]._num;
2086
+ const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
2087
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
2088
+ const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
2089
+ const _path = this._path;
2090
+ qualifiedName = shortcutAttr(qualifiedName);
2091
+ const qualifiedNameInCamelCase = (0, _spcsn_taro_shared.toCamelCase)(qualifiedName);
2092
+ const payload = {
2093
+ path: `${_path}.${qualifiedNameInCamelCase}`,
2094
+ value: (0, _spcsn_taro_shared.isFunction)(value) ? () => value : value
2095
+ };
2096
+ _spcsn_taro_shared.hooks.call("modifySetAttrPayload", this, qualifiedName, payload, componentsAlias);
2097
+ if (_alias) payload.path = `${_path}.${(0, _spcsn_taro_shared.toCamelCase)(_alias[qualifiedNameInCamelCase] || qualifiedName)}`;
2098
+ this.enqueueUpdate(payload);
2099
+ if (this.nodeName === "view") {
2100
+ if (qualifiedNameInCamelCase === "catchMove") this.enqueueUpdate({
2101
+ path: `${_path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2102
+ value: value ? catchViewAlias : this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : this.isAnyEventBinded() ? viewAlias : staticViewAlias
2103
+ });
2104
+ else if (isPureView && isHasExtractProp(this)) this.enqueueUpdate({
2105
+ path: `${_path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2106
+ value: staticViewAlias
2107
+ });
2108
+ }
2109
+ }
2110
+ removeAttribute(qualifiedName) {
2111
+ const isStaticView = this.nodeName === "view" && isHasExtractProp(this) && !this.isAnyEventBinded();
2112
+ MutationObserver$1.record({
2113
+ target: this,
2114
+ type: "attributes",
2115
+ attributeName: qualifiedName,
2116
+ oldValue: this.getAttribute(qualifiedName)
2117
+ });
2118
+ if (qualifiedName === "style") this.style.cssText = "";
2119
+ else {
2120
+ if (_spcsn_taro_shared.hooks.call("onRemoveAttribute", this, qualifiedName)) return;
2121
+ if (!this.props.hasOwnProperty(qualifiedName)) return;
2122
+ delete this.props[qualifiedName];
2123
+ }
2124
+ if (!this._root) return;
2125
+ const componentsAlias = getComponentsAlias();
2126
+ const _alias = componentsAlias[this.nodeName];
2127
+ const viewAlias = componentsAlias[VIEW]._num;
2128
+ const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
2129
+ const pureViewAlias = componentsAlias[PURE_VIEW]._num;
2130
+ const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
2131
+ const _path = this._path;
2132
+ qualifiedName = shortcutAttr(qualifiedName);
2133
+ const qualifiedNameInCamelCase = (0, _spcsn_taro_shared.toCamelCase)(qualifiedName);
2134
+ const payload = {
2135
+ path: `${_path}.${qualifiedNameInCamelCase}`,
2136
+ value: ""
2137
+ };
2138
+ _spcsn_taro_shared.hooks.call("modifyRmAttrPayload", this, qualifiedName, payload, componentsAlias);
2139
+ if (_alias) payload.path = `${_path}.${(0, _spcsn_taro_shared.toCamelCase)(_alias[qualifiedNameInCamelCase] || qualifiedName)}`;
2140
+ this.enqueueUpdate(payload);
2141
+ if (this.nodeName === "view") {
2142
+ if (qualifiedNameInCamelCase === "catchMove") this.enqueueUpdate({
2143
+ path: `${_path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2144
+ value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : this.isAnyEventBinded() ? viewAlias : isHasExtractProp(this) ? staticViewAlias : pureViewAlias
2145
+ });
2146
+ else if (isStaticView && !isHasExtractProp(this)) this.enqueueUpdate({
2147
+ path: `${_path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2148
+ value: pureViewAlias
2149
+ });
2150
+ }
2151
+ }
2152
+ getAttribute(qualifiedName) {
2153
+ return (qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName]) ?? "";
2154
+ }
2155
+ getElementsByTagName(tagName) {
2156
+ return treeToArray(this, (el) => {
2157
+ return el.nodeName === tagName || tagName === "*" && this !== el;
2158
+ });
2159
+ }
2160
+ getElementsByClassName(className) {
2161
+ const classNames = className.trim().split(/\s+/);
2162
+ return treeToArray(this, (el) => {
2163
+ const classList = el.classList;
2164
+ return classNames.every((c) => classList.contains(c));
2165
+ });
2166
+ }
2167
+ dispatchEvent(event) {
2168
+ const cancelable = event.cancelable;
2169
+ const listeners = this.__handlers[event.type];
2170
+ if (!(0, _spcsn_taro_shared.isArray)(listeners)) return false;
2171
+ for (let i = listeners.length; i--;) {
2172
+ const listener = listeners[i];
2173
+ let result;
2174
+ if (listener._stop) listener._stop = false;
2175
+ else {
2176
+ _spcsn_taro_shared.hooks.call("modifyDispatchEvent", event, this);
2177
+ result = listener.call(this, event);
2178
+ }
2179
+ if ((result === false || event._end) && cancelable) event.defaultPrevented = true;
2180
+ if (!(0, _spcsn_taro_shared.isUndefined)(result) && event.mpEvent) {
2181
+ if (_spcsn_taro_shared.hooks.call("modifyTaroEventReturn", this, event, result)) event.mpEvent[EVENT_CALLBACK_RESULT] = result;
2182
+ }
2183
+ if (event._end && event._stop) break;
2184
+ }
2185
+ if (event._stop) this._stopPropagation(event);
2186
+ return listeners != null;
2187
+ }
2188
+ addEventListener(type, handler, options) {
2189
+ const name = this.nodeName;
2190
+ const SPECIAL_NODES = _spcsn_taro_shared.hooks.call("getSpecialNodes");
2191
+ let sideEffect = true;
2192
+ if ((0, _spcsn_taro_shared.isObject)(options) && options.sideEffect === false) {
2193
+ sideEffect = false;
2194
+ delete options.sideEffect;
2195
+ }
2196
+ _spcsn_taro_shared.hooks.call("modifyAddEventListener", this, sideEffect, getComponentsAlias);
2197
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
2198
+ const alias = getComponentsAlias()[name]._num;
2199
+ this.enqueueUpdate({
2200
+ path: `${this._path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2201
+ value: alias
2202
+ });
2203
+ }
2204
+ super.addEventListener(type, handler, options);
2205
+ }
2206
+ removeEventListener(type, handler, sideEffect = true) {
2207
+ super.removeEventListener(type, handler);
2208
+ const name = this.nodeName;
2209
+ const SPECIAL_NODES = _spcsn_taro_shared.hooks.call("getSpecialNodes");
2210
+ _spcsn_taro_shared.hooks.call("modifyRemoveEventListener", this, sideEffect, getComponentsAlias);
2211
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
2212
+ const valueAlias = getComponentsAlias()[isHasExtractProp(this) ? `static-${name}` : `pure-${name}`]._num;
2213
+ this.enqueueUpdate({
2214
+ path: `${this._path}.${_spcsn_taro_shared.Shortcuts.NodeName}`,
2215
+ value: valueAlias
2216
+ });
2217
+ }
2218
+ }
2219
+ static extend(methodName, options) {
2220
+ extend(TaroElement, methodName, options);
2221
+ }
2222
+ };
2223
+ //#endregion
2224
+ //#region src/options.ts
2225
+ const options = {
2226
+ prerender: true,
2227
+ debug: false
2228
+ };
2229
+ //#endregion
2230
+ //#region src/dom/event.ts
2231
+ var TaroEvent = class {
2232
+ constructor(type, opts, event) {
2233
+ this._stop = false;
2234
+ this._end = false;
2235
+ this.defaultPrevented = false;
2236
+ this.button = 0;
2237
+ this.timeStamp = Date.now();
2238
+ this.type = type.toLowerCase();
2239
+ this.mpEvent = event;
2240
+ this.bubbles = Boolean(opts && opts.bubbles);
2241
+ this.cancelable = Boolean(opts && opts.cancelable);
2242
+ }
2243
+ stopPropagation() {
2244
+ this._stop = true;
2245
+ }
2246
+ stopImmediatePropagation() {
2247
+ this._end = this._stop = true;
2248
+ }
2249
+ preventDefault() {
2250
+ this.defaultPrevented = true;
2251
+ }
2252
+ get target() {
2253
+ const cacheTarget = this.cacheTarget;
2254
+ if (!cacheTarget) {
2255
+ const target = Object.create(this.mpEvent?.target || null);
2256
+ const currentEle = env.document.getElementById(target.dataset?.sid || target.id || null);
2257
+ const element = env.document.getElementById(target.targetDataset?.sid || target.dataset?.sid || target.id || null);
2258
+ target.dataset = {
2259
+ ...currentEle !== null ? currentEle.dataset : _spcsn_taro_shared.EMPTY_OBJ,
2260
+ ...element !== null ? element.dataset : _spcsn_taro_shared.EMPTY_OBJ
2261
+ };
2262
+ for (const key in this.mpEvent?.detail) target[key] = this.mpEvent.detail[key];
2263
+ this.cacheTarget = target;
2264
+ return target;
2265
+ } else return cacheTarget;
2266
+ }
2267
+ get currentTarget() {
2268
+ const cacheCurrentTarget = this.cacheCurrentTarget;
2269
+ if (!cacheCurrentTarget) {
2270
+ const doc = env.document;
2271
+ const currentTarget = Object.create(this.mpEvent?.currentTarget || null);
2272
+ const element = doc.getElementById(currentTarget.dataset?.sid || currentTarget.id || null);
2273
+ const targetElement = doc.getElementById(this.mpEvent?.target?.dataset?.sid || this.mpEvent?.target?.id || null);
2274
+ if (element === null || element && element === targetElement) {
2275
+ this.cacheCurrentTarget = this.target;
2276
+ return this.target;
2277
+ }
2278
+ currentTarget.dataset = element.dataset;
2279
+ for (const key in this.mpEvent?.detail) currentTarget[key] = this.mpEvent.detail[key];
2280
+ this.cacheCurrentTarget = currentTarget;
2281
+ return currentTarget;
2282
+ } else return cacheCurrentTarget;
2283
+ }
2284
+ };
2285
+ function createEvent(event, node) {
2286
+ if (typeof event === "string") return new TaroEvent(event, {
2287
+ bubbles: true,
2288
+ cancelable: true
2289
+ });
2290
+ const domEv = new TaroEvent(event.type, {
2291
+ bubbles: true,
2292
+ cancelable: true
2293
+ }, event);
2294
+ for (const key in event) if (key === "currentTarget" || key === "target" || key === "type" || key === "timeStamp") continue;
2295
+ else domEv[key] = event[key];
2296
+ if (domEv.type === "confirm" && node?.nodeName === "input") domEv[KEY_CODE] = 13;
2297
+ return domEv;
2298
+ }
2299
+ const eventsBatch = {};
2300
+ function getEventCBResult(event) {
2301
+ const result = event[EVENT_CALLBACK_RESULT];
2302
+ if (!(0, _spcsn_taro_shared.isUndefined)(result)) delete event[EVENT_CALLBACK_RESULT];
2303
+ return result;
2304
+ }
2305
+ function eventHandler(event) {
2306
+ event.type === void 0 && Object.defineProperty(event, "type", { value: event._type });
2307
+ event.detail === void 0 && Object.defineProperty(event, "detail", { value: event._detail || { ...event } });
2308
+ event.currentTarget = event.currentTarget || event.target || { ...event };
2309
+ _spcsn_taro_shared.hooks.call("modifyMpEventImpl", event);
2310
+ const currentTarget = event.currentTarget;
2311
+ const id = currentTarget.dataset?.sid || currentTarget.id || event.detail?.id || "";
2312
+ const node = env.document.getElementById(id);
2313
+ if (node) {
2314
+ const dispatch = () => {
2315
+ const e = createEvent(event, node);
2316
+ _spcsn_taro_shared.hooks.call("modifyTaroEvent", e, node);
2317
+ _spcsn_taro_shared.hooks.call("dispatchTaroEvent", e, node);
2318
+ _spcsn_taro_shared.hooks.call("dispatchTaroEventFinish", e, node);
2319
+ };
2320
+ if (_spcsn_taro_shared.hooks.isExist("batchedEventUpdates")) {
2321
+ const type = event.type;
2322
+ if (!_spcsn_taro_shared.hooks.call("isBubbleEvents", type) || !isParentBound(node, type) || type === "touchmove" && !!node.props.catchMove) {
2323
+ _spcsn_taro_shared.hooks.call("batchedEventUpdates", () => {
2324
+ if (eventsBatch[type]) {
2325
+ eventsBatch[type].forEach((fn) => fn());
2326
+ delete eventsBatch[type];
2327
+ }
2328
+ dispatch();
2329
+ });
2330
+ return getEventCBResult(event);
2331
+ } else (eventsBatch[type] ||= []).push(dispatch);
2332
+ } else {
2333
+ dispatch();
2334
+ return getEventCBResult(event);
2335
+ }
2336
+ }
2337
+ }
2338
+ function eventHandlerTTDom(ele, listener, event) {
2339
+ Object.assign(event, {
2340
+ mpEvent: event,
2341
+ bubbles: true,
2342
+ cancelable: true
2343
+ });
2344
+ listener(event, ele);
2345
+ }
2346
+ //#endregion
2347
+ //#region src/dom/form.ts
2348
+ var FormElement = class extends TaroElement {
2349
+ get type() {
2350
+ return this.props["type"] ?? "";
2351
+ }
2352
+ set type(val) {
2353
+ this.setAttribute(TYPE, val);
2354
+ }
2355
+ get value() {
2356
+ const val = this.props[VALUE];
2357
+ return val == null ? "" : val;
2358
+ }
2359
+ set value(val) {
2360
+ this.setAttribute(VALUE, val);
2361
+ }
2362
+ dispatchEvent(event) {
2363
+ if (event.mpEvent) {
2364
+ const val = event.mpEvent.detail.value;
2365
+ if (event.type === "change") this.props.value = val;
2366
+ else if (event.type === "input") this.value = val;
2367
+ }
2368
+ return super.dispatchEvent(event);
2369
+ }
2370
+ };
2371
+ //#endregion
2372
+ //#region src/perf.ts
2373
+ var Performance = class {
2374
+ constructor() {
2375
+ this.recorder = /* @__PURE__ */ new Map();
2376
+ }
2377
+ start(id) {
2378
+ if (!options.debug) return;
2379
+ this.recorder.set(id, Date.now());
2380
+ }
2381
+ stop(id, now = Date.now()) {
2382
+ if (!options.debug) return;
2383
+ const prev = this.recorder.get(id);
2384
+ if (!(prev >= 0)) return;
2385
+ this.recorder.delete(id);
2386
+ const time = now - prev;
2387
+ console.log(`${id} 时长: ${time}ms 开始时间:${this.#parseTime(prev)} 结束时间:${this.#parseTime(now)}`);
2388
+ }
2389
+ delayStop(id, delay = 500) {
2390
+ if (!options.debug) return;
2391
+ return debounce((now = Date.now(), cb) => {
2392
+ this.stop(id, now);
2393
+ cb?.();
2394
+ }, delay);
2395
+ }
2396
+ #parseTime(time) {
2397
+ const d = new Date(time);
2398
+ return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
2399
+ }
2400
+ };
2401
+ const perf = new Performance();
2402
+ //#endregion
2403
+ //#region src/dom/root.ts
2404
+ function findCustomWrapper(root, dataPathArr) {
2405
+ const list = dataPathArr.slice(1);
2406
+ let currentData = root;
2407
+ let customWrapper;
2408
+ let splitedPath = "";
2409
+ list.some((item, i) => {
2410
+ const key = item.replace(/^\[(.+)\]$/, "$1").replace(/\bcn\b/g, "childNodes");
2411
+ currentData = currentData[key];
2412
+ if ((0, _spcsn_taro_shared.isArray)(currentData)) currentData = currentData.filter((el) => !isComment(el));
2413
+ if ((0, _spcsn_taro_shared.isUndefined)(currentData)) return true;
2414
+ if (currentData.nodeName === "custom-wrapper") {
2415
+ const res = customWrapperCache.get(currentData.sid);
2416
+ if (res) {
2417
+ customWrapper = res;
2418
+ splitedPath = dataPathArr.slice(i + 2).join(".");
2419
+ }
2420
+ }
2421
+ });
2422
+ if (customWrapper) return {
2423
+ customWrapper,
2424
+ splitedPath
2425
+ };
2426
+ }
2427
+ var TaroRootElement = class extends TaroElement {
2428
+ constructor() {
2429
+ super();
2430
+ this.updatePayloads = [];
2431
+ this.updateCallbacks = [];
2432
+ this.pendingUpdate = false;
2433
+ this.ctx = null;
2434
+ this.nodeName = ROOT_STR;
2435
+ this.tagName = ROOT_STR.toUpperCase();
2436
+ }
2437
+ get _path() {
2438
+ return ROOT_STR;
2439
+ }
2440
+ get _root() {
2441
+ return this;
2442
+ }
2443
+ scheduleTask(fn) {
2444
+ setTimeout(fn);
2445
+ }
2446
+ enqueueUpdate(payload) {
2447
+ this.updatePayloads.push(payload);
2448
+ if (!this.pendingUpdate && this.ctx) this.performUpdate();
2449
+ }
2450
+ performUpdate(initRender = false, prerender) {
2451
+ this.pendingUpdate = true;
2452
+ const ctx = _spcsn_taro_shared.hooks.call("proxyToRaw", this.ctx);
2453
+ this.scheduleTask(() => {
2454
+ const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;
2455
+ perf.start(setDataMark);
2456
+ const data = Object.create(null);
2457
+ const resetPaths = new Set(initRender ? ["root.cn.[0]", "root.cn[0]"] : []);
2458
+ while (this.updatePayloads.length > 0) {
2459
+ const { path, value } = this.updatePayloads.shift();
2460
+ if (path.endsWith(_spcsn_taro_shared.Shortcuts.Childnodes)) resetPaths.add(path);
2461
+ data[path] = value;
2462
+ }
2463
+ for (const path in data) {
2464
+ resetPaths.forEach((p) => {
2465
+ if (path.includes(p) && path !== p) delete data[path];
2466
+ });
2467
+ const value = data[path];
2468
+ if ((0, _spcsn_taro_shared.isFunction)(value)) data[path] = value();
2469
+ }
2470
+ if ((0, _spcsn_taro_shared.isFunction)(prerender)) return prerender(data);
2471
+ this.pendingUpdate = false;
2472
+ let normalUpdate = {};
2473
+ const customWrapperMap = /* @__PURE__ */ new Map();
2474
+ if (initRender) normalUpdate = data;
2475
+ else for (const p in data) {
2476
+ const dataPathArr = p.split(".");
2477
+ const found = findCustomWrapper(this, dataPathArr);
2478
+ if (found) {
2479
+ const { customWrapper, splitedPath } = found;
2480
+ customWrapperMap.set(customWrapper, {
2481
+ ...customWrapperMap.get(customWrapper) || {},
2482
+ [`i.${splitedPath}`]: data[p]
2483
+ });
2484
+ } else normalUpdate[p] = data[p];
2485
+ }
2486
+ const customWrapperCount = customWrapperMap.size;
2487
+ const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;
2488
+ const updateArrLen = customWrapperCount + (isNeedNormalUpdate ? 1 : 0);
2489
+ let executeTime = 0;
2490
+ const cb = () => {
2491
+ if (++executeTime === updateArrLen) {
2492
+ perf.stop(setDataMark);
2493
+ this.flushUpdateCallback();
2494
+ initRender && perf.stop("页面初始化");
2495
+ }
2496
+ };
2497
+ if (customWrapperCount) customWrapperMap.forEach((data, ctx) => {
2498
+ if (process.env.NODE_ENV !== "production" && options.debug) console.log("custom wrapper setData: ", data);
2499
+ ctx.setData(data, cb);
2500
+ });
2501
+ if (isNeedNormalUpdate) {
2502
+ if (process.env.NODE_ENV !== "production" && options.debug) console.log("page setData:", normalUpdate);
2503
+ ctx.setData(normalUpdate, cb);
2504
+ }
2505
+ });
2506
+ }
2507
+ enqueueUpdateCallback(cb, ctx) {
2508
+ this.updateCallbacks.push(() => {
2509
+ ctx ? cb.call(ctx) : cb();
2510
+ });
2511
+ }
2512
+ flushUpdateCallback() {
2513
+ const updateCallbacks = this.updateCallbacks;
2514
+ if (!updateCallbacks.length) return;
2515
+ const copies = updateCallbacks.slice(0);
2516
+ this.updateCallbacks.length = 0;
2517
+ for (let i = 0; i < copies.length; i++) copies[i]();
2518
+ }
2519
+ };
2520
+ //#endregion
2521
+ //#region src/dom/text.ts
2522
+ var TaroText = class extends TaroNode {
2523
+ constructor(value) {
2524
+ super();
2525
+ this.nodeType = 3;
2526
+ this.nodeName = "#text";
2527
+ this._value = value;
2528
+ }
2529
+ set textContent(text) {
2530
+ MutationObserver$1.record({
2531
+ target: this,
2532
+ type: "characterData",
2533
+ oldValue: this._value
2534
+ });
2535
+ this._value = text;
2536
+ this.enqueueUpdate({
2537
+ path: `${this._path}.${_spcsn_taro_shared.Shortcuts.Text}`,
2538
+ value: text
2539
+ });
2540
+ }
2541
+ get textContent() {
2542
+ return this._value;
2543
+ }
2544
+ set nodeValue(text) {
2545
+ this.textContent = text;
2546
+ }
2547
+ get nodeValue() {
2548
+ return this._value;
2549
+ }
2550
+ set data(text) {
2551
+ this.textContent = text;
2552
+ }
2553
+ get data() {
2554
+ return this._value;
2555
+ }
2556
+ };
2557
+ //#endregion
2558
+ //#region src/dom/anchor-element.ts
2559
+ var AnchorElement = class extends TaroElement {
2560
+ get href() {
2561
+ return this.props["href"] ?? "";
2562
+ }
2563
+ set href(val) {
2564
+ this.setAttribute("href", val);
2565
+ }
2566
+ get protocol() {
2567
+ return this.props["protocol"] ?? "";
2568
+ }
2569
+ get host() {
2570
+ return this.props["host"] ?? "";
2571
+ }
2572
+ get search() {
2573
+ return this.props["search"] ?? "";
2574
+ }
2575
+ get hash() {
2576
+ return this.props["hash"] ?? "";
2577
+ }
2578
+ get hostname() {
2579
+ return this.props["hostname"] ?? "";
2580
+ }
2581
+ get port() {
2582
+ return this.props["port"] ?? "";
2583
+ }
2584
+ get pathname() {
2585
+ return this.props["pathname"] ?? "";
2586
+ }
2587
+ setAttribute(qualifiedName, value) {
2588
+ if (qualifiedName === "href") {
2589
+ const willSetAttr = parseUrl(value);
2590
+ for (const k in willSetAttr) super.setAttribute(k, willSetAttr[k]);
2591
+ } else super.setAttribute(qualifiedName, value);
2592
+ }
2593
+ };
2594
+ //#endregion
2595
+ //#region src/dom/transfer.ts
2596
+ var TransferElement = class extends TaroElement {
2597
+ constructor(dataName) {
2598
+ super();
2599
+ this.dataName = dataName;
2600
+ this.isTransferElement = true;
2601
+ }
2602
+ get _path() {
2603
+ return this.dataName;
2604
+ }
2605
+ };
2606
+ //#endregion
2607
+ //#region src/dom/document.ts
2608
+ var TaroDocument = class extends TaroElement {
2609
+ constructor() {
2610
+ super();
2611
+ this.createEvent = createEvent;
2612
+ this.nodeType = 9;
2613
+ this.nodeName = DOCUMENT_ELEMENT_NAME;
2614
+ }
2615
+ createElement(type) {
2616
+ const nodeName = type.toLowerCase();
2617
+ let element;
2618
+ switch (true) {
2619
+ case nodeName === ROOT_STR:
2620
+ element = new TaroRootElement();
2621
+ return element;
2622
+ case _spcsn_taro_shared.controlledComponent.has(nodeName):
2623
+ element = new FormElement();
2624
+ break;
2625
+ case nodeName === "a":
2626
+ element = new AnchorElement();
2627
+ break;
2628
+ case nodeName === "page-meta":
2629
+ case nodeName === "navigation-bar":
2630
+ element = new TransferElement((0, _spcsn_taro_shared.toCamelCase)(nodeName));
2631
+ break;
2632
+ default:
2633
+ element = new TaroElement();
2634
+ break;
2635
+ }
2636
+ element.nodeName = nodeName;
2637
+ element.tagName = type.toUpperCase();
2638
+ return element;
2639
+ }
2640
+ createElementNS(_svgNS, type) {
2641
+ return this.createElement(type);
2642
+ }
2643
+ createTextNode(text) {
2644
+ return new TaroText(text);
2645
+ }
2646
+ getElementById(id) {
2647
+ const el = eventSource.get(id);
2648
+ return (0, _spcsn_taro_shared.isUndefined)(el) ? null : el;
2649
+ }
2650
+ querySelector(query) {
2651
+ if (/^#/.test(query)) return this.getElementById(query.slice(1));
2652
+ return null;
2653
+ }
2654
+ querySelectorAll() {
2655
+ return [];
2656
+ }
2657
+ createComment() {
2658
+ const textnode = new TaroText("");
2659
+ textnode.nodeName = COMMENT;
2660
+ return textnode;
2661
+ }
2662
+ get defaultView() {
2663
+ return env.window;
2664
+ }
2665
+ };
2666
+ //#endregion
2667
+ //#region src/bom/document.ts
2668
+ function createDocument() {
2669
+ /**
2670
+ * <document>
2671
+ * <html>
2672
+ * <head></head>
2673
+ * <body>
2674
+ * <container>
2675
+ * <app id="app" />
2676
+ * </container>
2677
+ * </body>
2678
+ * </html>
2679
+ * </document>
2680
+ */
2681
+ const doc = new TaroDocument();
2682
+ const documentCreateElement = doc.createElement.bind(doc);
2683
+ const html = documentCreateElement(HTML);
2684
+ const head = documentCreateElement(HEAD);
2685
+ const body = documentCreateElement(BODY);
2686
+ const app = documentCreateElement("app");
2687
+ app.id = "app";
2688
+ const container = documentCreateElement(CONTAINER);
2689
+ doc.appendChild(html);
2690
+ html.appendChild(head);
2691
+ html.appendChild(body);
2692
+ body.appendChild(container);
2693
+ container.appendChild(app);
2694
+ doc.documentElement = html;
2695
+ doc.head = head;
2696
+ doc.body = body;
2697
+ return doc;
2698
+ }
2699
+ function createTTDomDocument() {
2700
+ const document = tt?.appDocument;
2701
+ if (!document) throw new Error("tt.appDocument is not found");
2702
+ const html = document.createElement(HTML);
2703
+ const head = document.createElement(HEAD);
2704
+ const body = document.createElement(BODY);
2705
+ const app = document.createElement("app");
2706
+ app.id = "app";
2707
+ const container = document.createElement(CONTAINER);
2708
+ const emptyFunction = () => {};
2709
+ document.childNodes.push(html);
2710
+ html.childNodes.push(head, body);
2711
+ body.childNodes.push(container);
2712
+ container.childNodes.push(app);
2713
+ document.documentElement = html;
2714
+ document.head = head;
2715
+ document.body = body;
2716
+ document.appElement = app;
2717
+ let builtInComponents = tt?.getBuiltInComponents?.();
2718
+ if (Array.isArray(builtInComponents)) builtInComponents = new Set(builtInComponents);
2719
+ else if (!(builtInComponents instanceof Set)) builtInComponents = new Set([..._spcsn_taro_shared.DEFAULT_COMPONENTS, ..._spcsn_taro_shared.TT_SPECIFIC_COMPONENTS]);
2720
+ document.getElementById = function getElementById(id) {
2721
+ if (id === "app") return app;
2722
+ else return Object.getPrototypeOf(this).getElementById.call(this, id);
2723
+ };
2724
+ document.getLastPage = function getLastPage() {
2725
+ let last;
2726
+ for (const v of this._pageDocumentMap.values()) last = v;
2727
+ return last;
2728
+ };
2729
+ document.createElement = function(type, ...args) {
2730
+ if (type === "root") return this.getLastPage();
2731
+ else {
2732
+ const el = builtInComponents.has(type) ? Object.getPrototypeOf(this).createElement.call(this, type, ...args) : Object.getPrototypeOf(this).createNativeComponent.call(this, type, { __tt__inner__options__: { name: type } });
2733
+ el.setAttribute("class", "");
2734
+ const originalSetAttribute = el.setAttribute.bind(el);
2735
+ const originalRemoveAttribute = el.removeAttribute.bind(el);
2736
+ el.setAttribute = function(name, value) {
2737
+ const result = originalSetAttribute(name, value);
2738
+ if (name === "catchMove" && value) el.addEventListener("catchtouchmove", emptyFunction);
2739
+ return result;
2740
+ };
2741
+ el.removeAttribute = function(name) {
2742
+ const oldValue = el.getAttribute(name);
2743
+ if (name === "catchMove" && oldValue) el.removeEventListener("catchtouchmove", emptyFunction);
2744
+ return originalRemoveAttribute(name);
2745
+ };
2746
+ return el;
2747
+ }
2748
+ };
2749
+ return document;
2750
+ }
2751
+ const taroDocumentProvider = process.env.TARO_PLATFORM === "web" ? env.document : env.document = (0, _spcsn_taro_shared.isEnableTTDom)() ? createTTDomDocument() : createDocument();
2752
+ //#endregion
2753
+ //#region src/dom/svg.ts
2754
+ var SVGElement = class extends TaroElement {};
2755
+ //#endregion
2756
+ //#region src/dsl/common.ts
2757
+ const instances = /* @__PURE__ */ new Map();
2758
+ const pageId = incrementId();
2759
+ function injectPageInstance(inst, id) {
2760
+ _spcsn_taro_shared.hooks.call("mergePageInstance", instances.get(id), inst);
2761
+ instances.set(id, inst);
2762
+ }
2763
+ function getPageInstance(id) {
2764
+ return instances.get(id);
2765
+ }
2766
+ function removePageInstance(id) {
2767
+ instances.delete(id);
2768
+ }
2769
+ function safeExecute(path, lifecycle, ...args) {
2770
+ const instance = instances.get(path);
2771
+ if (instance == null) return;
2772
+ const func = _spcsn_taro_shared.hooks.call("getLifecycle", instance, lifecycle);
2773
+ if ((0, _spcsn_taro_shared.isArray)(func)) return func.map((fn) => fn.apply(instance, args))[0];
2774
+ if (!(0, _spcsn_taro_shared.isFunction)(func)) return;
2775
+ return func.apply(instance, args);
2776
+ }
2777
+ function stringify(obj) {
2778
+ if (obj == null) return "";
2779
+ const path = Object.keys(obj).map((key) => {
2780
+ return key + "=" + obj[key];
2781
+ }).join("&");
2782
+ return path === "" ? path : "?" + path;
2783
+ }
2784
+ function getPath(id, options) {
2785
+ const idx = id.indexOf("?");
2786
+ if (process.env.TARO_PLATFORM === "web") return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options?.stamp ? { stamp: options.stamp } : {})}`;
2787
+ else return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
2788
+ }
2789
+ function getOnReadyEventKey(path) {
2790
+ return path + ".onReady";
2791
+ }
2792
+ function getOnShowEventKey(path) {
2793
+ return path + ".onShow";
2794
+ }
2795
+ function getOnHideEventKey(path) {
2796
+ return path + ".onHide";
2797
+ }
2798
+ function createPageConfig(component, pageName, data, pageConfig) {
2799
+ const id = pageName ?? `taro_page_${pageId()}`;
2800
+ const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").page;
2801
+ let pageElement = null;
2802
+ let unmounting = false;
2803
+ let prepareMountList = [];
2804
+ function setCurrentRouter(page) {
2805
+ const router = process.env.TARO_PLATFORM === "web" ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
2806
+ Current.router = {
2807
+ params: page.$taroParams,
2808
+ path: addLeadingSlash(router),
2809
+ $taroPath: page.$taroPath,
2810
+ onReady: getOnReadyEventKey(id),
2811
+ onShow: getOnShowEventKey(id),
2812
+ onHide: getOnHideEventKey(id)
2813
+ };
2814
+ if (!(0, _spcsn_taro_shared.isUndefined)(page.exitState)) Current.router.exitState = page.exitState;
2815
+ }
2816
+ let loadResolver;
2817
+ let hasLoaded;
2818
+ const config = {
2819
+ [ONLOAD](options = {}, cb) {
2820
+ hasLoaded = new Promise((resolve) => {
2821
+ loadResolver = resolve;
2822
+ });
2823
+ perf.start(PAGE_INIT);
2824
+ Current.page = this;
2825
+ this.config = pageConfig || {};
2826
+ const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
2827
+ const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
2828
+ if (process.env.TARO_PLATFORM === "web") config.path = $taroPath;
2829
+ if (this.$taroParams == null) this.$taroParams = uniqueOptions;
2830
+ setCurrentRouter(this);
2831
+ if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("0", $taroPath);
2832
+ const mount = () => {
2833
+ Current.app.mount(component, $taroPath, () => {
2834
+ if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) pageElement = env.document.getPageDocumentById(this.__webviewId__);
2835
+ else pageElement = env.document.getElementById($taroPath);
2836
+ (0, _spcsn_taro_shared.ensure)(pageElement !== null, "没有找到页面实例。");
2837
+ safeExecute($taroPath, ON_LOAD, this.$taroParams);
2838
+ loadResolver();
2839
+ if (process.env.TARO_PLATFORM !== "web") {
2840
+ pageElement.ctx = this;
2841
+ if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) pageElement.sync();
2842
+ else pageElement.performUpdate(true, cb);
2843
+ } else (0, _spcsn_taro_shared.isFunction)(cb) && cb();
2844
+ });
2845
+ };
2846
+ if (unmounting) prepareMountList.push(mount);
2847
+ else mount();
2848
+ },
2849
+ [ONUNLOAD]() {
2850
+ const $taroPath = this.$taroPath;
2851
+ if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("3", $taroPath);
2852
+ safeExecute($taroPath, ONUNLOAD);
2853
+ unmounting = true;
2854
+ Current.app.unmount($taroPath, () => {
2855
+ unmounting = false;
2856
+ instances.delete($taroPath);
2857
+ if (pageElement) {
2858
+ pageElement.ctx = null;
2859
+ pageElement = null;
2860
+ }
2861
+ if (prepareMountList.length) {
2862
+ prepareMountList.forEach((fn) => fn());
2863
+ prepareMountList = [];
2864
+ }
2865
+ });
2866
+ },
2867
+ [ONREADY]() {
2868
+ hasLoaded.then(() => {
2869
+ safeExecute(this.$taroPath, ON_READY);
2870
+ _raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
2871
+ this.onReady.called = true;
2872
+ });
2873
+ },
2874
+ [ONSHOW](options = {}) {
2875
+ hasLoaded.then(() => {
2876
+ Current.page = this;
2877
+ setCurrentRouter(this);
2878
+ if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("2", this.$taroPath);
2879
+ safeExecute(this.$taroPath, ON_SHOW, options);
2880
+ _raf(() => eventCenter.trigger(getOnShowEventKey(id)));
2881
+ });
2882
+ },
2883
+ [ONHIDE]() {
2884
+ if (process.env.TARO_PLATFORM !== "web") taroWindowProvider.trigger("1", this.$taroPath);
2885
+ if (Current.page === this) {
2886
+ Current.page = null;
2887
+ Current.router = null;
2888
+ }
2889
+ safeExecute(this.$taroPath, ON_HIDE);
2890
+ eventCenter.trigger(getOnHideEventKey(id));
2891
+ }
2892
+ };
2893
+ if (process.env.TARO_PLATFORM === "web") config.getOpenerEventChannel = () => {
2894
+ return _spcsn_taro_shared.EventChannel.pageChannel;
2895
+ };
2896
+ const isSWAN = process.env.TARO_ENV === "swan";
2897
+ LIFECYCLES.forEach((lifecycle) => {
2898
+ let isDefer = false;
2899
+ let isEvent = false;
2900
+ lifecycle = lifecycle.replace(/^defer:/, () => {
2901
+ isDefer = true;
2902
+ return "";
2903
+ });
2904
+ lifecycle = lifecycle.replace(/^events:/, () => {
2905
+ isEvent = true;
2906
+ return "";
2907
+ });
2908
+ if (isEvent && process.env.TARO_ENV === "alipay") {
2909
+ if (!config.events) config.events = {};
2910
+ config.events[lifecycle] = function() {
2911
+ return safeExecute(this.$taroPath, lifecycle, ...arguments);
2912
+ };
2913
+ } else config[lifecycle] = function() {
2914
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
2915
+ if (isSWAN) return exec();
2916
+ if (isDefer) hasLoaded.then(exec);
2917
+ else return exec();
2918
+ };
2919
+ });
2920
+ SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
2921
+ if (component[lifecycle] || component.prototype?.[lifecycle] || component[lifecycle.replace(/^on/, "enable")] || pageConfig?.[lifecycle.replace(/^on/, "enable")]) config[lifecycle] = function(...args) {
2922
+ const target = args[0]?.target;
2923
+ if (target?.id) {
2924
+ const id = target.id;
2925
+ const element = env.document.getElementById(id);
2926
+ if (element) target.dataset = element.dataset;
2927
+ }
2928
+ return safeExecute(this.$taroPath, lifecycle, ...args);
2929
+ };
2930
+ });
2931
+ config.eh = eventHandler;
2932
+ if (!(0, _spcsn_taro_shared.isUndefined)(data)) config.data = data;
2933
+ _spcsn_taro_shared.hooks.call("modifyPageObject", config);
2934
+ return config;
2935
+ }
2936
+ function createComponentConfig(component, componentName, data) {
2937
+ const id = componentName ?? `taro_component_${pageId()}`;
2938
+ let componentElement = null;
2939
+ const [ATTACHED, DETACHED] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").component;
2940
+ const config = {
2941
+ [ATTACHED]() {
2942
+ perf.start(PAGE_INIT);
2943
+ this.pageIdCache = this.getPageId?.() || pageId();
2944
+ const path = getPath(id, { id: this.pageIdCache });
2945
+ Current.app.mount(component, path, () => {
2946
+ componentElement = env.document.getElementById(path);
2947
+ (0, _spcsn_taro_shared.ensure)(componentElement !== null, "没有找到组件实例。");
2948
+ this.$taroInstances = instances.get(path);
2949
+ safeExecute(path, ON_LOAD);
2950
+ if (process.env.TARO_PLATFORM !== "web") {
2951
+ componentElement.ctx = this;
2952
+ if (process.env.TARO_ENV !== "tt" || !(0, _spcsn_taro_shared.isEnableTTDom)()) componentElement.performUpdate(true);
2953
+ }
2954
+ });
2955
+ },
2956
+ [DETACHED]() {
2957
+ const path = getPath(id, { id: this.pageIdCache });
2958
+ Current.app.unmount(path, () => {
2959
+ instances.delete(path);
2960
+ if (componentElement) componentElement.ctx = null;
2961
+ });
2962
+ },
2963
+ methods: { eh: eventHandler }
2964
+ };
2965
+ if (!(0, _spcsn_taro_shared.isUndefined)(data)) config.data = data;
2966
+ [
2967
+ OPTIONS,
2968
+ EXTERNAL_CLASSES,
2969
+ BEHAVIORS
2970
+ ].forEach((key) => {
2971
+ config[key] = component[key] ?? _spcsn_taro_shared.EMPTY_OBJ;
2972
+ });
2973
+ return config;
2974
+ }
2975
+ function createRecursiveComponentConfig(componentName) {
2976
+ const isCustomWrapper = componentName === CUSTOM_WRAPPER;
2977
+ const [ATTACHED, DETACHED] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").component;
2978
+ const lifeCycles = isCustomWrapper ? {
2979
+ [ATTACHED]() {
2980
+ if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) return;
2981
+ const componentId = this.data.i?.sid || this.props.i?.sid;
2982
+ if ((0, _spcsn_taro_shared.isString)(componentId)) {
2983
+ customWrapperCache.set(componentId, this);
2984
+ const el = env.document.getElementById(componentId);
2985
+ if (el) el.ctx = this;
2986
+ }
2987
+ },
2988
+ [DETACHED]() {
2989
+ if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) return;
2990
+ const componentId = this.data.i?.sid || this.props.i?.sid;
2991
+ if ((0, _spcsn_taro_shared.isString)(componentId)) {
2992
+ customWrapperCache.delete(componentId);
2993
+ const el = env.document.getElementById(componentId);
2994
+ if (el) el.ctx = null;
2995
+ }
2996
+ }
2997
+ } : _spcsn_taro_shared.EMPTY_OBJ;
2998
+ const extraOptions = {};
2999
+ if (process.env.TARO_ENV === "jd") extraOptions.addGlobalClass = true;
3000
+ return _spcsn_taro_shared.hooks.call("modifyRecursiveComponentConfig", {
3001
+ properties: {
3002
+ i: {
3003
+ type: Object,
3004
+ value: { [_spcsn_taro_shared.Shortcuts.NodeName]: (0, _spcsn_taro_shared.getComponentsAlias)(_spcsn_taro_shared.internalComponents)[VIEW]._num }
3005
+ },
3006
+ l: {
3007
+ type: String,
3008
+ value: ""
3009
+ }
3010
+ },
3011
+ options: {
3012
+ ...extraOptions,
3013
+ virtualHost: !isCustomWrapper
3014
+ },
3015
+ methods: { eh: eventHandler },
3016
+ ...lifeCycles
3017
+ }, { isCustomWrapper });
3018
+ }
3019
+ //#endregion
3020
+ //#region src/next-tick.ts
3021
+ const TIMEOUT = 100;
3022
+ const nextTick = (cb, ctx) => {
3023
+ const beginTime = Date.now();
3024
+ const router = Current.router;
3025
+ const timerFunc = () => {
3026
+ setTimeout(function() {
3027
+ ctx ? cb.call(ctx) : cb();
3028
+ }, 1);
3029
+ };
3030
+ if (router === null) return timerFunc();
3031
+ const path = router.$taroPath;
3032
+ /**
3033
+ * 三种情况
3034
+ * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms
3035
+ * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车
3036
+ * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。
3037
+ */
3038
+ function next() {
3039
+ const pageElement = env.document.getElementById(path);
3040
+ if (pageElement?.pendingUpdate) if (process.env.TARO_PLATFORM === "web") pageElement.firstChild?.["componentOnReady"]?.().then(() => {
3041
+ timerFunc();
3042
+ }) ?? timerFunc();
3043
+ else pageElement.enqueueUpdateCallback(cb, ctx);
3044
+ else if (Date.now() - beginTime > TIMEOUT) timerFunc();
3045
+ else setTimeout(() => next(), 20);
3046
+ }
3047
+ next();
3048
+ };
3049
+ //#endregion
3050
+ //#region src/polyfill/array.ts
3051
+ function handleArrayFindPolyfill() {
3052
+ if (!(0, _spcsn_taro_shared.isFunction)(Array.prototype.find)) Object.defineProperty(Array.prototype, "find", { value(predicate) {
3053
+ if (this == null) throw new TypeError("\"this\" is null or not defined");
3054
+ const o = Object(this);
3055
+ const len = o.length >>> 0;
3056
+ if (!(0, _spcsn_taro_shared.isFunction)(predicate)) throw new TypeError("predicate must be a function");
3057
+ const thisArg = arguments[1];
3058
+ let k = 0;
3059
+ while (k < len) {
3060
+ const kValue = o[k];
3061
+ if (predicate.call(thisArg, kValue, k, o)) return kValue;
3062
+ k++;
3063
+ }
3064
+ } });
3065
+ }
3066
+ function handleArrayIncludesPolyfill() {
3067
+ if (!(0, _spcsn_taro_shared.isFunction)(Array.prototype.includes)) Object.defineProperty(Array.prototype, "includes", { value(searchElement, fromIndex) {
3068
+ if (this == null) throw new TypeError("\"this\" is null or not defined");
3069
+ const o = Object(this);
3070
+ const len = o.length >>> 0;
3071
+ if (len === 0) return false;
3072
+ const n = fromIndex | 0;
3073
+ let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
3074
+ while (k < len) {
3075
+ if (o[k] === searchElement) return true;
3076
+ k++;
3077
+ }
3078
+ return false;
3079
+ } });
3080
+ }
3081
+ //#endregion
3082
+ //#region src/polyfill/intersection-observer.ts
3083
+ function handleIntersectionObserverPolyfill() {
3084
+ if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
3085
+ if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", { get: function() {
3086
+ return this.intersectionRatio > 0;
3087
+ } });
3088
+ } else handleIntersectionObserverObjectPolyfill();
3089
+ }
3090
+ function handleIntersectionObserverObjectPolyfill() {
3091
+ const document = window.document;
3092
+ /**
3093
+ * An IntersectionObserver registry. This registry exists to hold a strong
3094
+ * reference to IntersectionObserver instances currently observing a target
3095
+ * element. Without this registry, instances without another reference may be
3096
+ * garbage collected.
3097
+ */
3098
+ const registry = [];
3099
+ /**
3100
+ * Creates the global IntersectionObserverEntry constructor.
3101
+ * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
3102
+ * @param {Object} entry A dictionary of instance properties.
3103
+ * @constructor
3104
+ */
3105
+ function IntersectionObserverEntry(entry) {
3106
+ this.time = entry.time;
3107
+ this.target = entry.target;
3108
+ this.rootBounds = entry.rootBounds;
3109
+ this.boundingClientRect = entry.boundingClientRect;
3110
+ this.intersectionRect = entry.intersectionRect || getEmptyRect();
3111
+ this.isIntersecting = !!entry.intersectionRect;
3112
+ const targetRect = this.boundingClientRect;
3113
+ const targetArea = targetRect.width * targetRect.height;
3114
+ const intersectionRect = this.intersectionRect;
3115
+ const intersectionArea = intersectionRect.width * intersectionRect.height;
3116
+ if (targetArea) this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
3117
+ else this.intersectionRatio = this.isIntersecting ? 1 : 0;
3118
+ }
3119
+ /**
3120
+ * Creates the global IntersectionObserver constructor.
3121
+ * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
3122
+ * @param {Function} callback The function to be invoked after intersection
3123
+ * changes have queued. The function is not invoked if the queue has
3124
+ * been emptied by calling the `takeRecords` method.
3125
+ * @param {Object=} opt_options Optional configuration options.
3126
+ * @constructor
3127
+ */
3128
+ function IntersectionObserver(callback, options = {}) {
3129
+ if (!(0, _spcsn_taro_shared.isFunction)(callback)) throw new Error("callback must be a function");
3130
+ if (options.root && options.root.nodeType != 1) throw new Error("root must be an Element");
3131
+ this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
3132
+ this._callback = callback;
3133
+ this._observationTargets = [];
3134
+ this._queuedEntries = [];
3135
+ this._rootMarginValues = this._parseRootMargin(options.rootMargin);
3136
+ this.thresholds = this._initThresholds(options.threshold);
3137
+ this.root = options.root || null;
3138
+ this.rootMargin = this._rootMarginValues.map(function(margin) {
3139
+ return margin.value + margin.unit;
3140
+ }).join(" ");
3141
+ }
3142
+ /**
3143
+ * The minimum interval within which the document will be checked for
3144
+ * intersection changes.
3145
+ */
3146
+ IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
3147
+ /**
3148
+ * The frequency in which the polyfill polls for intersection changes.
3149
+ * this can be updated on a per instance basis and must be set prior to
3150
+ * calling `observe` on the first target.
3151
+ */
3152
+ IntersectionObserver.prototype.POLL_INTERVAL = null;
3153
+ /**
3154
+ * Use a mutation observer on the root element
3155
+ * to detect intersection changes.
3156
+ */
3157
+ IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
3158
+ /**
3159
+ * Starts observing a target element for intersection changes based on
3160
+ * the thresholds values.
3161
+ * @param {Element} target The DOM element to observe.
3162
+ */
3163
+ IntersectionObserver.prototype.observe = function(target) {
3164
+ if (this._observationTargets.some(function(item) {
3165
+ return item.element == target;
3166
+ })) return;
3167
+ if (!(target && target.nodeType == 1)) throw new Error("target must be an Element");
3168
+ this._registerInstance();
3169
+ this._observationTargets.push({
3170
+ element: target,
3171
+ entry: null
3172
+ });
3173
+ this._monitorIntersections();
3174
+ this._checkForIntersections();
3175
+ };
3176
+ /**
3177
+ * Stops observing a target element for intersection changes.
3178
+ * @param {Element} target The DOM element to observe.
3179
+ */
3180
+ IntersectionObserver.prototype.unobserve = function(target) {
3181
+ this._observationTargets = this._observationTargets.filter(function(item) {
3182
+ return item.element != target;
3183
+ });
3184
+ if (!this._observationTargets.length) {
3185
+ this._unmonitorIntersections();
3186
+ this._unregisterInstance();
3187
+ }
3188
+ };
3189
+ /**
3190
+ * Stops observing all target elements for intersection changes.
3191
+ */
3192
+ IntersectionObserver.prototype.disconnect = function() {
3193
+ this._observationTargets = [];
3194
+ this._unmonitorIntersections();
3195
+ this._unregisterInstance();
3196
+ };
3197
+ /**
3198
+ * Returns any queue entries that have not yet been reported to the
3199
+ * callback and clears the queue. This can be used in conjunction with the
3200
+ * callback to obtain the absolute most up-to-date intersection information.
3201
+ * @return {Array} The currently queued entries.
3202
+ */
3203
+ IntersectionObserver.prototype.takeRecords = function() {
3204
+ const records = this._queuedEntries.slice();
3205
+ this._queuedEntries = [];
3206
+ return records;
3207
+ };
3208
+ /**
3209
+ * Accepts the threshold value from the user configuration object and
3210
+ * returns a sorted array of unique threshold values. If a value is not
3211
+ * between 0 and 1 and error is thrown.
3212
+ * @private
3213
+ * @param {Array|number=} opt_threshold An optional threshold value or
3214
+ * a list of threshold values, defaulting to [0].
3215
+ * @return {Array} A sorted list of unique and valid threshold values.
3216
+ */
3217
+ IntersectionObserver.prototype._initThresholds = function(opt_threshold) {
3218
+ let threshold = opt_threshold || [0];
3219
+ if (!Array.isArray(threshold)) threshold = [threshold];
3220
+ return threshold.sort().filter(function(t, i, a) {
3221
+ if (!(0, _spcsn_taro_shared.isNumber)(t) || isNaN(t) || t < 0 || t > 1) throw new Error("threshold must be a number between 0 and 1 inclusively");
3222
+ return t !== a[i - 1];
3223
+ });
3224
+ };
3225
+ /**
3226
+ * Accepts the rootMargin value from the user configuration object
3227
+ * and returns an array of the four margin values as an object containing
3228
+ * the value and unit properties. If any of the values are not properly
3229
+ * formatted or use a unit other than px or %, and error is thrown.
3230
+ * @private
3231
+ * @param {string=} opt_rootMargin An optional rootMargin value,
3232
+ * defaulting to '0px'.
3233
+ * @return {Array<Object>} An array of margin objects with the keys
3234
+ * value and unit.
3235
+ */
3236
+ IntersectionObserver.prototype._parseRootMargin = function(opt_rootMargin) {
3237
+ const margins = (opt_rootMargin || "0px").split(/\s+/).map(function(margin) {
3238
+ const parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
3239
+ if (!parts) throw new Error("rootMargin must be specified in pixels or percent");
3240
+ return {
3241
+ value: parseFloat(parts[1]),
3242
+ unit: parts[2]
3243
+ };
3244
+ });
3245
+ margins[1] = margins[1] || margins[0];
3246
+ margins[2] = margins[2] || margins[0];
3247
+ margins[3] = margins[3] || margins[1];
3248
+ return margins;
3249
+ };
3250
+ /**
3251
+ * Starts polling for intersection changes if the polling is not already
3252
+ * happening, and if the page's visibility state is visible.
3253
+ * @private
3254
+ */
3255
+ IntersectionObserver.prototype._monitorIntersections = function() {
3256
+ if (!this._monitoringIntersections) {
3257
+ this._monitoringIntersections = true;
3258
+ if (this.POLL_INTERVAL) this._monitoringInterval = setInterval(this._checkForIntersections, this.POLL_INTERVAL);
3259
+ else {
3260
+ addEvent(window, "resize", this._checkForIntersections, true);
3261
+ addEvent(document, "scroll", this._checkForIntersections, true);
3262
+ if (this.USE_MUTATION_OBSERVER && "MutationObserver" in window) {
3263
+ this._domObserver = new MutationObserver(this._checkForIntersections);
3264
+ this._domObserver.observe(document, {
3265
+ attributes: true,
3266
+ childList: true,
3267
+ characterData: true,
3268
+ subtree: true
3269
+ });
3270
+ }
3271
+ }
3272
+ }
3273
+ };
3274
+ /**
3275
+ * Stops polling for intersection changes.
3276
+ * @private
3277
+ */
3278
+ IntersectionObserver.prototype._unmonitorIntersections = function() {
3279
+ if (this._monitoringIntersections) {
3280
+ this._monitoringIntersections = false;
3281
+ clearInterval(this._monitoringInterval);
3282
+ this._monitoringInterval = null;
3283
+ removeEvent(window, "resize", this._checkForIntersections, true);
3284
+ removeEvent(document, "scroll", this._checkForIntersections, true);
3285
+ if (this._domObserver) {
3286
+ this._domObserver.disconnect();
3287
+ this._domObserver = null;
3288
+ }
3289
+ }
3290
+ };
3291
+ /**
3292
+ * Scans each observation target for intersection changes and adds them
3293
+ * to the internal entries queue. If new entries are found, it
3294
+ * schedules the callback to be invoked.
3295
+ * @private
3296
+ */
3297
+ IntersectionObserver.prototype._checkForIntersections = function() {
3298
+ const rootIsInDom = this._rootIsInDom();
3299
+ const rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
3300
+ this._observationTargets.forEach(function(item) {
3301
+ const target = item.element;
3302
+ const targetRect = getBoundingClientRect(target);
3303
+ const rootContainsTarget = this._rootContainsTarget(target);
3304
+ const oldEntry = item.entry;
3305
+ const intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, rootRect);
3306
+ const newEntry = item.entry = new IntersectionObserverEntry({
3307
+ time: now(),
3308
+ target,
3309
+ boundingClientRect: targetRect,
3310
+ rootBounds: rootRect,
3311
+ intersectionRect,
3312
+ intersectionRatio: -1,
3313
+ isIntersecting: false
3314
+ });
3315
+ if (!oldEntry) this._queuedEntries.push(newEntry);
3316
+ else if (rootIsInDom && rootContainsTarget) {
3317
+ if (this._hasCrossedThreshold(oldEntry, newEntry)) this._queuedEntries.push(newEntry);
3318
+ } else if (oldEntry && oldEntry.isIntersecting) this._queuedEntries.push(newEntry);
3319
+ }, this);
3320
+ if (this._queuedEntries.length) this._callback(this.takeRecords(), this);
3321
+ };
3322
+ /**
3323
+ * Accepts a target and root rect computes the intersection between then
3324
+ * following the algorithm in the spec.
3325
+ * TODO(philipwalton): at this time clip-path is not considered.
3326
+ * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
3327
+ * @param {Element} target The target DOM element
3328
+ * @param {Object} rootRect The bounding rect of the root after being
3329
+ * expanded by the rootMargin value.
3330
+ * @return {?Object} The final intersection rect object or undefined if no
3331
+ * intersection is found.
3332
+ * @private
3333
+ */
3334
+ IntersectionObserver.prototype._computeTargetAndRootIntersection = function(target, rootRect) {
3335
+ if (window.getComputedStyle(target).display === "none") return;
3336
+ let intersectionRect = getBoundingClientRect(target);
3337
+ let parent = getParentNode(target);
3338
+ let atRoot = false;
3339
+ while (!atRoot) {
3340
+ let parentRect = null;
3341
+ const parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
3342
+ if (parentComputedStyle.display === "none") return;
3343
+ if (parent == this.root || parent == document) {
3344
+ atRoot = true;
3345
+ parentRect = rootRect;
3346
+ } else if (parent != document.body && parent != document.documentElement && parentComputedStyle.overflow != "visible") parentRect = getBoundingClientRect(parent);
3347
+ if (parentRect) {
3348
+ intersectionRect = computeRectIntersection(parentRect, intersectionRect);
3349
+ if (!intersectionRect) break;
3350
+ }
3351
+ parent = getParentNode(parent);
3352
+ }
3353
+ return intersectionRect;
3354
+ };
3355
+ /**
3356
+ * Returns the root rect after being expanded by the rootMargin value.
3357
+ * @return {Object} The expanded root rect.
3358
+ * @private
3359
+ */
3360
+ IntersectionObserver.prototype._getRootRect = function() {
3361
+ let rootRect;
3362
+ if (this.root) rootRect = getBoundingClientRect(this.root);
3363
+ else {
3364
+ const html = document.documentElement;
3365
+ const body = document.body;
3366
+ rootRect = {
3367
+ top: 0,
3368
+ left: 0,
3369
+ right: html.clientWidth || body.clientWidth,
3370
+ width: html.clientWidth || body.clientWidth,
3371
+ bottom: html.clientHeight || body.clientHeight,
3372
+ height: html.clientHeight || body.clientHeight
3373
+ };
3374
+ }
3375
+ return this._expandRectByRootMargin(rootRect);
3376
+ };
3377
+ /**
3378
+ * Accepts a rect and expands it by the rootMargin value.
3379
+ * @param {Object} rect The rect object to expand.
3380
+ * @return {Object} The expanded rect.
3381
+ * @private
3382
+ */
3383
+ IntersectionObserver.prototype._expandRectByRootMargin = function(rect) {
3384
+ const margins = this._rootMarginValues.map(function(margin, i) {
3385
+ return margin.unit === "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
3386
+ });
3387
+ const newRect = {
3388
+ top: rect.top - margins[0],
3389
+ right: rect.right + margins[1],
3390
+ bottom: rect.bottom + margins[2],
3391
+ left: rect.left - margins[3]
3392
+ };
3393
+ newRect.width = newRect.right - newRect.left;
3394
+ newRect.height = newRect.bottom - newRect.top;
3395
+ return newRect;
3396
+ };
3397
+ /**
3398
+ * Accepts an old and new entry and returns true if at least one of the
3399
+ * threshold values has been crossed.
3400
+ * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
3401
+ * particular target element or null if no previous entry exists.
3402
+ * @param {IntersectionObserverEntry} newEntry The current entry for a
3403
+ * particular target element.
3404
+ * @return {boolean} Returns true if a any threshold has been crossed.
3405
+ * @private
3406
+ */
3407
+ IntersectionObserver.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
3408
+ const oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
3409
+ const newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
3410
+ if (oldRatio === newRatio) return;
3411
+ for (let i = 0; i < this.thresholds.length; i++) {
3412
+ const threshold = this.thresholds[i];
3413
+ if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) return true;
3414
+ }
3415
+ };
3416
+ /**
3417
+ * Returns whether or not the root element is an element and is in the DOM.
3418
+ * @return {boolean} True if the root element is an element and is in the DOM.
3419
+ * @private
3420
+ */
3421
+ IntersectionObserver.prototype._rootIsInDom = function() {
3422
+ return !this.root || containsDeep(document, this.root);
3423
+ };
3424
+ /**
3425
+ * Returns whether or not the target element is a child of root.
3426
+ * @param {Element} target The target element to check.
3427
+ * @return {boolean} True if the target element is a child of root.
3428
+ * @private
3429
+ */
3430
+ IntersectionObserver.prototype._rootContainsTarget = function(target) {
3431
+ return containsDeep(this.root || document, target);
3432
+ };
3433
+ /**
3434
+ * Adds the instance to the global IntersectionObserver registry if it isn't
3435
+ * already present.
3436
+ * @private
3437
+ */
3438
+ IntersectionObserver.prototype._registerInstance = function() {
3439
+ if (registry.indexOf(this) < 0) registry.push(this);
3440
+ };
3441
+ /**
3442
+ * Removes the instance from the global IntersectionObserver registry.
3443
+ * @private
3444
+ */
3445
+ IntersectionObserver.prototype._unregisterInstance = function() {
3446
+ const index = registry.indexOf(this);
3447
+ if (index != -1) registry.splice(index, 1);
3448
+ };
3449
+ /**
3450
+ * Returns the result of the performance.now() method or null in browsers
3451
+ * that don't support the API.
3452
+ * @return {number} The elapsed time since the page was requested.
3453
+ */
3454
+ function now() {
3455
+ return window.performance && performance.now && performance.now();
3456
+ }
3457
+ /**
3458
+ * Adds an event handler to a DOM node ensuring cross-browser compatibility.
3459
+ * @param {Node} node The DOM node to add the event handler to.
3460
+ * @param {string} event The event name.
3461
+ * @param {Function} fn The event handler to add.
3462
+ * @param {boolean} opt_useCapture Optionally adds the even to the capture
3463
+ * phase. Note: this only works in modern browsers.
3464
+ */
3465
+ function addEvent(node, event, fn, opt_useCapture) {
3466
+ if ((0, _spcsn_taro_shared.isFunction)(node.addEventListener)) node.addEventListener(event, fn, opt_useCapture || false);
3467
+ else if ((0, _spcsn_taro_shared.isFunction)(node.attachEvent)) node.attachEvent("on" + event, fn);
3468
+ }
3469
+ /**
3470
+ * Removes a previously added event handler from a DOM node.
3471
+ * @param {Node} node The DOM node to remove the event handler from.
3472
+ * @param {string} event The event name.
3473
+ * @param {Function} fn The event handler to remove.
3474
+ * @param {boolean} opt_useCapture If the event handler was added with this
3475
+ * flag set to true, it should be set to true here in order to remove it.
3476
+ */
3477
+ function removeEvent(node, event, fn, opt_useCapture) {
3478
+ if ((0, _spcsn_taro_shared.isFunction)(node.removeEventListener)) node.removeEventListener(event, fn, opt_useCapture || false);
3479
+ else if ((0, _spcsn_taro_shared.isFunction)(node.detatchEvent)) node.detatchEvent("on" + event, fn);
3480
+ }
3481
+ /**
3482
+ * Returns the intersection between two rect objects.
3483
+ * @param {Object} rect1 The first rect.
3484
+ * @param {Object} rect2 The second rect.
3485
+ * @return {?Object} The intersection rect or undefined if no intersection
3486
+ * is found.
3487
+ */
3488
+ function computeRectIntersection(rect1, rect2) {
3489
+ const top = Math.max(rect1.top, rect2.top);
3490
+ const bottom = Math.min(rect1.bottom, rect2.bottom);
3491
+ const left = Math.max(rect1.left, rect2.left);
3492
+ const right = Math.min(rect1.right, rect2.right);
3493
+ const width = right - left;
3494
+ const height = bottom - top;
3495
+ return width >= 0 && height >= 0 && {
3496
+ top,
3497
+ bottom,
3498
+ left,
3499
+ right,
3500
+ width,
3501
+ height
3502
+ };
3503
+ }
3504
+ /**
3505
+ * Shims the native getBoundingClientRect for compatibility with older IE.
3506
+ * @param {Element} el The element whose bounding rect to get.
3507
+ * @return {Object} The (possibly shimmed) rect of the element.
3508
+ */
3509
+ function getBoundingClientRect(el) {
3510
+ let rect;
3511
+ try {
3512
+ rect = el.getBoundingClientRect();
3513
+ } catch (err) {}
3514
+ if (!rect) return getEmptyRect();
3515
+ if (!(rect.width && rect.height)) rect = {
3516
+ top: rect.top,
3517
+ right: rect.right,
3518
+ bottom: rect.bottom,
3519
+ left: rect.left,
3520
+ width: rect.right - rect.left,
3521
+ height: rect.bottom - rect.top
3522
+ };
3523
+ return rect;
3524
+ }
3525
+ /**
3526
+ * Returns an empty rect object. An empty rect is returned when an element
3527
+ * is not in the DOM.
3528
+ * @return {Object} The empty rect.
3529
+ */
3530
+ function getEmptyRect() {
3531
+ return {
3532
+ top: 0,
3533
+ bottom: 0,
3534
+ left: 0,
3535
+ right: 0,
3536
+ width: 0,
3537
+ height: 0
3538
+ };
3539
+ }
3540
+ /**
3541
+ * Checks to see if a parent element contains a child element (including inside
3542
+ * shadow DOM).
3543
+ * @param {Node} parent The parent element.
3544
+ * @param {Node} child The child element.
3545
+ * @return {boolean} True if the parent node contains the child node.
3546
+ */
3547
+ function containsDeep(parent, child) {
3548
+ let node = child;
3549
+ while (node) {
3550
+ if (node == parent) return true;
3551
+ node = getParentNode(node);
3552
+ }
3553
+ return false;
3554
+ }
3555
+ /**
3556
+ * Gets the parent node of an element or its host element if the parent node
3557
+ * is a shadow root.
3558
+ * @param {Node} node The node whose parent to get.
3559
+ * @return {Node|null} The parent node or null if no parent exists.
3560
+ */
3561
+ function getParentNode(node) {
3562
+ const parent = node.parentNode;
3563
+ if (parent && parent.nodeType == 11 && parent.host) return parent.host;
3564
+ if (parent && parent.assignedSlot) return parent.assignedSlot.parentNode;
3565
+ return parent;
3566
+ }
3567
+ window.IntersectionObserver = IntersectionObserver;
3568
+ window.IntersectionObserverEntry = IntersectionObserverEntry;
3569
+ }
3570
+ //#endregion
3571
+ //#region src/polyfill/object.ts
3572
+ function handleObjectAssignPolyfill() {
3573
+ if (!(0, _spcsn_taro_shared.isFunction)(Object.assign)) Object.assign = function(target) {
3574
+ if (target == null) throw new TypeError("Cannot convert undefined or null to object");
3575
+ const to = Object(target);
3576
+ for (let index = 1; index < arguments.length; index++) {
3577
+ const nextSource = arguments[index];
3578
+ if (nextSource != null) {
3579
+ for (const nextKey in nextSource) if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) to[nextKey] = nextSource[nextKey];
3580
+ }
3581
+ }
3582
+ return to;
3583
+ };
3584
+ }
3585
+ function handleObjectEntriesPolyfill() {
3586
+ if (!(0, _spcsn_taro_shared.isFunction)(Object.entries)) Object.entries = function(obj) {
3587
+ if (obj == null) throw new TypeError("Cannot convert undefined or null to object");
3588
+ const to = [];
3589
+ if (obj != null) {
3590
+ for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) to.push([key, obj[key]]);
3591
+ }
3592
+ return to;
3593
+ };
3594
+ }
3595
+ function handleObjectDefinePropertyPolyfill() {
3596
+ if (!(0, _spcsn_taro_shared.isFunction)(Object.defineProperties)) Object.defineProperties = function(obj, properties) {
3597
+ function convertToDescriptor(desc) {
3598
+ function hasProperty(obj, prop) {
3599
+ return Object.prototype.hasOwnProperty.call(obj, prop);
3600
+ }
3601
+ if (!(0, _spcsn_taro_shared.isObject)(desc)) throw new TypeError("bad desc");
3602
+ const d = {};
3603
+ if (hasProperty(desc, "enumerable")) d.enumerable = !!desc.enumerable;
3604
+ if (hasProperty(desc, "configurable")) d.configurable = !!desc.configurable;
3605
+ if (hasProperty(desc, "value")) d.value = desc.value;
3606
+ if (hasProperty(desc, "writable")) d.writable = !!desc.writable;
3607
+ if (hasProperty(desc, "get")) {
3608
+ const g = desc.get;
3609
+ if (!(0, _spcsn_taro_shared.isFunction)(g) && !(0, _spcsn_taro_shared.isUndefined)(g)) throw new TypeError("bad get");
3610
+ d.get = g;
3611
+ }
3612
+ if (hasProperty(desc, "set")) {
3613
+ const s = desc.set;
3614
+ if (!(0, _spcsn_taro_shared.isFunction)(s) && !(0, _spcsn_taro_shared.isUndefined)(s)) throw new TypeError("bad set");
3615
+ d.set = s;
3616
+ }
3617
+ if (("get" in d || "set" in d) && ("value" in d || "writable" in d)) throw new TypeError("identity-confused descriptor");
3618
+ return d;
3619
+ }
3620
+ if (!(0, _spcsn_taro_shared.isObject)(obj)) throw new TypeError("bad obj");
3621
+ properties = Object(properties);
3622
+ const keys = Object.keys(properties);
3623
+ const descs = [];
3624
+ for (let i = 0; i < keys.length; i++) descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);
3625
+ for (let i = 0; i < descs.length; i++) Object.defineProperty(obj, descs[i][0], descs[i][1]);
3626
+ return obj;
3627
+ };
3628
+ }
3629
+ //#endregion
3630
+ //#region src/polyfill/index.ts
3631
+ function handlePolyfill() {
3632
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.assign") handleObjectAssignPolyfill();
3633
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.entries") handleObjectEntriesPolyfill();
3634
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.defineProperty") handleObjectDefinePropertyPolyfill();
3635
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.find") handleArrayFindPolyfill();
3636
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.includes") handleArrayIncludesPolyfill();
3637
+ if (process.env.TARO_PLATFORM === "web" && (0, _spcsn_taro_shared.isObject)(window)) {
3638
+ if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "IntersectionObserver") handleIntersectionObserverPolyfill();
3639
+ }
3640
+ }
3641
+ if (process.env.SUPPORT_TARO_POLYFILL !== "disabled" && process.env.TARO_PLATFORM !== "web") handlePolyfill();
3642
+ //#endregion
3643
+ exports.A = A;
3644
+ exports.APP = APP;
3645
+ exports.BEHAVIORS = BEHAVIORS;
3646
+ exports.BODY = BODY;
3647
+ exports.CATCHMOVE = CATCHMOVE;
3648
+ exports.CATCH_VIEW = CATCH_VIEW;
3649
+ exports.CHANGE = CHANGE;
3650
+ exports.CLASS = CLASS;
3651
+ exports.CLICK_VIEW = CLICK_VIEW;
3652
+ exports.COMMENT = COMMENT;
3653
+ exports.COMPILE_MODE = COMPILE_MODE;
3654
+ exports.CONFIRM = CONFIRM;
3655
+ exports.CONTAINER = CONTAINER;
3656
+ exports.CONTEXT_ACTIONS = CONTEXT_ACTIONS;
3657
+ exports.CURRENT_TARGET = CURRENT_TARGET;
3658
+ exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
3659
+ exports.Current = Current;
3660
+ exports.DATASET = DATASET;
3661
+ exports.DATE = DATE;
3662
+ exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
3663
+ exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
3664
+ exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
3665
+ exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
3666
+ exports.Events = _spcsn_taro_shared.Events;
3667
+ exports.FOCUS = FOCUS;
3668
+ exports.FormElement = FormElement;
3669
+ exports.HEAD = HEAD;
3670
+ exports.HOOKS_APP_ID = HOOKS_APP_ID;
3671
+ exports.HTML = HTML;
3672
+ exports.History = History;
3673
+ exports.ID = ID;
3674
+ exports.INPUT = INPUT;
3675
+ exports.KEY_CODE = KEY_CODE;
3676
+ exports.Location = Location;
3677
+ exports.MutationObserver = MutationObserver$1;
3678
+ exports.OBJECT = OBJECT;
3679
+ exports.ON_HIDE = ON_HIDE;
3680
+ exports.ON_LOAD = ON_LOAD;
3681
+ exports.ON_READY = ON_READY;
3682
+ exports.ON_SHOW = ON_SHOW;
3683
+ exports.OPTIONS = OPTIONS;
3684
+ exports.PAGE_INIT = PAGE_INIT;
3685
+ exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
3686
+ exports.PROPS = PROPS;
3687
+ exports.PURE_VIEW = PURE_VIEW;
3688
+ exports.ROOT_STR = ROOT_STR;
3689
+ exports.SET_DATA = SET_DATA;
3690
+ exports.SET_TIMEOUT = SET_TIMEOUT;
3691
+ exports.STATIC_VIEW = STATIC_VIEW;
3692
+ exports.STYLE = STYLE;
3693
+ exports.SVGElement = SVGElement;
3694
+ exports.Style = Style;
3695
+ exports.TARGET = TARGET;
3696
+ exports.TARO_RUNTIME = TARO_RUNTIME;
3697
+ exports.TIME_STAMP = TIME_STAMP;
3698
+ exports.TOUCHMOVE = TOUCHMOVE;
3699
+ exports.TYPE = TYPE;
3700
+ exports.TaroElement = TaroElement;
3701
+ exports.TaroEvent = TaroEvent;
3702
+ exports.TaroNode = TaroNode;
3703
+ exports.TaroRootElement = TaroRootElement;
3704
+ exports.TaroText = TaroText;
3705
+ exports.UID = UID;
3706
+ exports.URL = TaroURLProvider;
3707
+ exports.URLSearchParams = URLSearchParams;
3708
+ exports.VALUE = VALUE;
3709
+ exports.VIEW = VIEW;
3710
+ exports.addLeadingSlash = addLeadingSlash;
3711
+ exports.cancelAnimationFrame = _caf;
3712
+ exports.convertNumber2PX = convertNumber2PX;
3713
+ exports.createComponentConfig = createComponentConfig;
3714
+ exports.createEvent = createEvent;
3715
+ exports.createPageConfig = createPageConfig;
3716
+ exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
3717
+ exports.customWrapperCache = customWrapperCache;
3718
+ exports.debounce = debounce;
3719
+ exports.document = taroDocumentProvider;
3720
+ exports.env = env;
3721
+ exports.eventCenter = eventCenter;
3722
+ exports.eventHandler = eventHandler;
3723
+ exports.eventHandlerTTDom = eventHandlerTTDom;
3724
+ exports.eventSource = eventSource;
3725
+ exports.extend = extend;
3726
+ exports.getComponentsAlias = getComponentsAlias;
3727
+ exports.getComputedStyle = taroGetComputedStyleProvider;
3728
+ exports.getCurrentInstance = getCurrentInstance;
3729
+ exports.getCurrentPage = getCurrentPage;
3730
+ exports.getHomePage = getHomePage;
3731
+ exports.getOnHideEventKey = getOnHideEventKey;
3732
+ exports.getOnReadyEventKey = getOnReadyEventKey;
3733
+ exports.getOnShowEventKey = getOnShowEventKey;
3734
+ exports.getPageInstance = getPageInstance;
3735
+ exports.getPath = getPath;
3736
+ exports.handlePolyfill = handlePolyfill;
3737
+ exports.hasBasename = hasBasename;
3738
+ exports.history = taroHistoryProvider;
3739
+ Object.defineProperty(exports, "hooks", {
3740
+ enumerable: true,
3741
+ get: function() {
3742
+ return _spcsn_taro_shared.hooks;
3743
+ }
3744
+ });
3745
+ exports.hydrate = hydrate;
3746
+ exports.incrementId = incrementId;
3747
+ exports.injectPageInstance = injectPageInstance;
3748
+ exports.isComment = isComment;
3749
+ exports.isElement = isElement;
3750
+ exports.isHasExtractProp = isHasExtractProp;
3751
+ exports.isParentBound = isParentBound;
3752
+ exports.isText = isText;
3753
+ exports.location = taroLocationProvider;
3754
+ exports.navigator = nav;
3755
+ exports.nextTick = nextTick;
3756
+ Object.defineProperty(exports, "now", {
3757
+ enumerable: true,
3758
+ get: function() {
3759
+ return now;
3760
+ }
3761
+ });
3762
+ exports.options = options;
3763
+ exports.parseUrl = parseUrl;
3764
+ exports.perf = perf;
3765
+ exports.removePageInstance = removePageInstance;
3766
+ exports.requestAnimationFrame = _raf;
3767
+ exports.safeExecute = safeExecute;
3768
+ exports.shortcutAttr = shortcutAttr;
3769
+ exports.stringify = stringify;
3770
+ exports.stripBasename = stripBasename;
3771
+ exports.stripSuffix = stripSuffix;
3772
+ exports.stripTrailing = stripTrailing;
3773
+ exports.throttle = throttle;
3774
+ exports.window = taroWindowProvider;
3775
+
3776
+ //# sourceMappingURL=index.cjs.js.map