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