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