@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/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,73 +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
|
-
#location;
|
|
259
|
-
#stack = [];
|
|
260
|
-
#cur = 0;
|
|
261
|
-
#window;
|
|
262
355
|
constructor(location, options) {
|
|
263
356
|
super();
|
|
264
|
-
this
|
|
265
|
-
this
|
|
266
|
-
this
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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({
|
|
270
369
|
state: null,
|
|
271
370
|
title: "",
|
|
272
371
|
url: href
|
|
273
372
|
});
|
|
274
373
|
}, null);
|
|
275
|
-
this
|
|
276
|
-
this
|
|
374
|
+
_classPrivateFieldGet2(_location, this).on("__reset_history__", (href) => {
|
|
375
|
+
_assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this, href);
|
|
277
376
|
}, null);
|
|
278
377
|
this.on("0", () => {
|
|
279
|
-
this
|
|
378
|
+
_assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
|
|
280
379
|
}, null);
|
|
281
380
|
this.on("1", (pageId) => {
|
|
282
381
|
cache$1.set(pageId, {
|
|
283
|
-
location: this
|
|
284
|
-
stack: this
|
|
285
|
-
cur: this
|
|
382
|
+
location: _classPrivateFieldGet2(_location, this),
|
|
383
|
+
stack: _classPrivateFieldGet2(_stack, this).slice(),
|
|
384
|
+
cur: _classPrivateFieldGet2(_cur, this)
|
|
286
385
|
});
|
|
287
386
|
}, null);
|
|
288
387
|
this.on("2", (pageId) => {
|
|
289
388
|
if (cache$1.has(pageId)) {
|
|
290
389
|
const ctx = cache$1.get(pageId);
|
|
291
|
-
this
|
|
292
|
-
this
|
|
293
|
-
this
|
|
390
|
+
_classPrivateFieldSet2(_location, this, ctx.location);
|
|
391
|
+
_classPrivateFieldSet2(_stack, this, ctx.stack);
|
|
392
|
+
_classPrivateFieldSet2(_cur, this, ctx.cur);
|
|
294
393
|
}
|
|
295
394
|
}, null);
|
|
296
395
|
this.on("3", (pageId) => {
|
|
297
396
|
cache$1.delete(pageId);
|
|
298
397
|
}, null);
|
|
299
|
-
this
|
|
300
|
-
}
|
|
301
|
-
#reset(href = "") {
|
|
302
|
-
this.#stack = [{
|
|
303
|
-
state: null,
|
|
304
|
-
title: "",
|
|
305
|
-
url: href || this.#location.href
|
|
306
|
-
}];
|
|
307
|
-
this.#cur = 0;
|
|
398
|
+
_assertClassBrand(_TaroHistory_brand, this, _reset$1).call(this);
|
|
308
399
|
}
|
|
309
400
|
get length() {
|
|
310
|
-
return this
|
|
401
|
+
return _classPrivateFieldGet2(_stack, this).length;
|
|
311
402
|
}
|
|
312
403
|
get state() {
|
|
313
|
-
return this
|
|
404
|
+
return _classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)].state;
|
|
314
405
|
}
|
|
315
406
|
go(delta) {
|
|
316
407
|
if (!(0, _spcsn_taro_shared.isNumber)(delta) || isNaN(delta)) return;
|
|
317
|
-
let targetIdx = this
|
|
408
|
+
let targetIdx = _classPrivateFieldGet2(_cur, this) + delta;
|
|
318
409
|
targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
|
|
319
|
-
this
|
|
320
|
-
this
|
|
321
|
-
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)]);
|
|
322
413
|
}
|
|
323
414
|
back() {
|
|
324
415
|
this.go(-1);
|
|
@@ -328,28 +419,36 @@ var TaroHistory = class extends _spcsn_taro_shared.Events {
|
|
|
328
419
|
}
|
|
329
420
|
pushState(state, title, url) {
|
|
330
421
|
if (!url || !(0, _spcsn_taro_shared.isString)(url)) return;
|
|
331
|
-
this
|
|
332
|
-
this
|
|
422
|
+
_classPrivateFieldSet2(_stack, this, _classPrivateFieldGet2(_stack, this).slice(0, _classPrivateFieldGet2(_cur, this) + 1));
|
|
423
|
+
_classPrivateFieldGet2(_stack, this).push({
|
|
333
424
|
state,
|
|
334
425
|
title,
|
|
335
426
|
url
|
|
336
427
|
});
|
|
337
|
-
this
|
|
338
|
-
this
|
|
428
|
+
_classPrivateFieldSet2(_cur, this, this.length - 1);
|
|
429
|
+
_classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
|
|
339
430
|
}
|
|
340
431
|
replaceState(state, title, url) {
|
|
341
432
|
if (!url || !(0, _spcsn_taro_shared.isString)(url)) return;
|
|
342
|
-
this
|
|
433
|
+
_classPrivateFieldGet2(_stack, this)[_classPrivateFieldGet2(_cur, this)] = {
|
|
343
434
|
state,
|
|
344
435
|
title,
|
|
345
436
|
url
|
|
346
437
|
};
|
|
347
|
-
this
|
|
438
|
+
_classPrivateFieldGet2(_location, this).trigger("__set_href_without_history__", url);
|
|
348
439
|
}
|
|
349
440
|
get cache() {
|
|
350
441
|
return cache$1;
|
|
351
442
|
}
|
|
352
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
|
+
}
|
|
353
452
|
const History = process.env.TARO_PLATFORM === "web" ? env.window.History : TaroHistory;
|
|
354
453
|
//#endregion
|
|
355
454
|
//#region src/current.ts
|
|
@@ -361,6 +460,7 @@ const Current = {
|
|
|
361
460
|
const getCurrentInstance = () => Current;
|
|
362
461
|
//#endregion
|
|
363
462
|
//#region src/bom/URLSearchParams.ts
|
|
463
|
+
var _dict;
|
|
364
464
|
const findReg = /[!'()~]|%20|%00/g;
|
|
365
465
|
const plusReg = /\+/g;
|
|
366
466
|
const replaceCharMap = {
|
|
@@ -389,11 +489,12 @@ function decode(str) {
|
|
|
389
489
|
function encode(str) {
|
|
390
490
|
return encodeURIComponent(str).replace(findReg, replacer);
|
|
391
491
|
}
|
|
392
|
-
const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : class {
|
|
393
|
-
#dict = Object.create(null);
|
|
492
|
+
const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSearchParams : (_dict = /* @__PURE__ */ new WeakMap(), class {
|
|
394
493
|
constructor(query) {
|
|
395
|
-
|
|
396
|
-
|
|
494
|
+
var _query;
|
|
495
|
+
_classPrivateFieldInitSpec(this, _dict, Object.create(null));
|
|
496
|
+
(_query = query) !== null && _query !== void 0 || (query = "");
|
|
497
|
+
const dict = _classPrivateFieldGet2(_dict, this);
|
|
397
498
|
if (typeof query === "string") {
|
|
398
499
|
if (query.charAt(0) === "?") query = query.slice(1);
|
|
399
500
|
for (let pairs = query.split("&"), i = 0, length = pairs.length; i < length; i++) {
|
|
@@ -414,30 +515,30 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
|
|
|
414
515
|
else for (const key in query) appendTo(dict, key, query[key]);
|
|
415
516
|
}
|
|
416
517
|
append(name, value) {
|
|
417
|
-
appendTo(this
|
|
518
|
+
appendTo(_classPrivateFieldGet2(_dict, this), name, value);
|
|
418
519
|
}
|
|
419
520
|
delete(name) {
|
|
420
|
-
delete this
|
|
521
|
+
delete _classPrivateFieldGet2(_dict, this)[name];
|
|
421
522
|
}
|
|
422
523
|
get(name) {
|
|
423
|
-
const dict = this
|
|
524
|
+
const dict = _classPrivateFieldGet2(_dict, this);
|
|
424
525
|
return name in dict ? dict[name][0] : null;
|
|
425
526
|
}
|
|
426
527
|
getAll(name) {
|
|
427
|
-
const dict = this
|
|
528
|
+
const dict = _classPrivateFieldGet2(_dict, this);
|
|
428
529
|
return name in dict ? dict[name].slice(0) : [];
|
|
429
530
|
}
|
|
430
531
|
has(name) {
|
|
431
|
-
return name in this
|
|
532
|
+
return name in _classPrivateFieldGet2(_dict, this);
|
|
432
533
|
}
|
|
433
534
|
keys() {
|
|
434
|
-
return Object.keys(this
|
|
535
|
+
return Object.keys(_classPrivateFieldGet2(_dict, this));
|
|
435
536
|
}
|
|
436
537
|
set(name, value) {
|
|
437
|
-
this
|
|
538
|
+
_classPrivateFieldGet2(_dict, this)[name] = ["" + value];
|
|
438
539
|
}
|
|
439
540
|
forEach(callback, thisArg) {
|
|
440
|
-
const dict = this
|
|
541
|
+
const dict = _classPrivateFieldGet2(_dict, this);
|
|
441
542
|
Object.getOwnPropertyNames(dict).forEach(function(name) {
|
|
442
543
|
dict[name].forEach(function(value) {
|
|
443
544
|
callback.call(thisArg, value, name, this);
|
|
@@ -448,7 +549,7 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
|
|
|
448
549
|
return {};
|
|
449
550
|
}
|
|
450
551
|
toString() {
|
|
451
|
-
const dict = this
|
|
552
|
+
const dict = _classPrivateFieldGet2(_dict, this);
|
|
452
553
|
const query = [];
|
|
453
554
|
for (const key in dict) {
|
|
454
555
|
const name = encode(key);
|
|
@@ -456,9 +557,15 @@ const URLSearchParams = process.env.TARO_PLATFORM === "web" ? env.window.URLSear
|
|
|
456
557
|
}
|
|
457
558
|
return query.join("&");
|
|
458
559
|
}
|
|
459
|
-
};
|
|
560
|
+
});
|
|
460
561
|
//#endregion
|
|
461
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();
|
|
462
569
|
var TaroURL = class {
|
|
463
570
|
static createObjectURL() {
|
|
464
571
|
throw new Error("Oops, not support URL.createObjectURL() in miniprogram.");
|
|
@@ -466,27 +573,27 @@ var TaroURL = class {
|
|
|
466
573
|
static revokeObjectURL() {
|
|
467
574
|
throw new Error("Oops, not support URL.revokeObjectURL() in miniprogram.");
|
|
468
575
|
}
|
|
469
|
-
#hash = "";
|
|
470
|
-
#hostname = "";
|
|
471
|
-
#pathname = "";
|
|
472
|
-
#port = "";
|
|
473
|
-
#protocol = "";
|
|
474
|
-
#search;
|
|
475
576
|
constructor(url, base) {
|
|
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);
|
|
476
583
|
if (!(0, _spcsn_taro_shared.isString)(url)) url = String(url);
|
|
477
584
|
const { hash, hostname, pathname, port, protocol, search } = parseUrlBase(url, base);
|
|
478
|
-
this
|
|
479
|
-
this
|
|
480
|
-
this
|
|
481
|
-
this
|
|
482
|
-
this
|
|
483
|
-
this
|
|
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));
|
|
484
591
|
}
|
|
485
592
|
get protocol() {
|
|
486
|
-
return this
|
|
593
|
+
return _classPrivateFieldGet2(_protocol, this);
|
|
487
594
|
}
|
|
488
595
|
set protocol(val) {
|
|
489
|
-
(0, _spcsn_taro_shared.isString)(val) && (this
|
|
596
|
+
(0, _spcsn_taro_shared.isString)(val) && _classPrivateFieldSet2(_protocol, this, val.trim());
|
|
490
597
|
}
|
|
491
598
|
get host() {
|
|
492
599
|
return this.hostname + (this.port ? ":" + this.port : "");
|
|
@@ -500,19 +607,19 @@ var TaroURL = class {
|
|
|
500
607
|
}
|
|
501
608
|
}
|
|
502
609
|
get hostname() {
|
|
503
|
-
return this
|
|
610
|
+
return _classPrivateFieldGet2(_hostname, this);
|
|
504
611
|
}
|
|
505
612
|
set hostname(val) {
|
|
506
|
-
val && (0, _spcsn_taro_shared.isString)(val) && (this
|
|
613
|
+
val && (0, _spcsn_taro_shared.isString)(val) && _classPrivateFieldSet2(_hostname, this, val.trim());
|
|
507
614
|
}
|
|
508
615
|
get port() {
|
|
509
|
-
return this
|
|
616
|
+
return _classPrivateFieldGet2(_port, this);
|
|
510
617
|
}
|
|
511
618
|
set port(val) {
|
|
512
|
-
(0, _spcsn_taro_shared.isString)(val) && (this
|
|
619
|
+
(0, _spcsn_taro_shared.isString)(val) && _classPrivateFieldSet2(_port, this, val.trim());
|
|
513
620
|
}
|
|
514
621
|
get pathname() {
|
|
515
|
-
return this
|
|
622
|
+
return _classPrivateFieldGet2(_pathname, this);
|
|
516
623
|
}
|
|
517
624
|
set pathname(val) {
|
|
518
625
|
if ((0, _spcsn_taro_shared.isString)(val)) {
|
|
@@ -520,28 +627,28 @@ var TaroURL = class {
|
|
|
520
627
|
const HEAD_REG = /^(\/|\.\/|\.\.\/)/;
|
|
521
628
|
let temp = val;
|
|
522
629
|
while (HEAD_REG.test(temp)) temp = temp.replace(HEAD_REG, "");
|
|
523
|
-
if (temp) this
|
|
524
|
-
else this
|
|
630
|
+
if (temp) _classPrivateFieldSet2(_pathname, this, "/" + temp);
|
|
631
|
+
else _classPrivateFieldSet2(_pathname, this, "/");
|
|
525
632
|
}
|
|
526
633
|
}
|
|
527
634
|
get search() {
|
|
528
|
-
const val = this
|
|
635
|
+
const val = _classPrivateFieldGet2(_search, this).toString();
|
|
529
636
|
return val.length === 0 || val.startsWith("?") ? val : `?${val}`;
|
|
530
637
|
}
|
|
531
638
|
set search(val) {
|
|
532
639
|
if ((0, _spcsn_taro_shared.isString)(val)) {
|
|
533
640
|
val = val.trim();
|
|
534
|
-
this
|
|
641
|
+
_classPrivateFieldSet2(_search, this, new URLSearchParams(val));
|
|
535
642
|
}
|
|
536
643
|
}
|
|
537
644
|
get hash() {
|
|
538
|
-
return this
|
|
645
|
+
return _classPrivateFieldGet2(_hash, this);
|
|
539
646
|
}
|
|
540
647
|
set hash(val) {
|
|
541
648
|
if ((0, _spcsn_taro_shared.isString)(val)) {
|
|
542
649
|
val = val.trim();
|
|
543
|
-
if (val) this
|
|
544
|
-
else this
|
|
650
|
+
if (val) _classPrivateFieldSet2(_hash, this, val.startsWith("#") ? val : `#${val}`);
|
|
651
|
+
else _classPrivateFieldSet2(_hash, this, "");
|
|
545
652
|
}
|
|
546
653
|
}
|
|
547
654
|
get href() {
|
|
@@ -572,7 +679,7 @@ var TaroURL = class {
|
|
|
572
679
|
}
|
|
573
680
|
}
|
|
574
681
|
get searchParams() {
|
|
575
|
-
return this
|
|
682
|
+
return _classPrivateFieldGet2(_search, this);
|
|
576
683
|
}
|
|
577
684
|
toString() {
|
|
578
685
|
return this.href;
|
|
@@ -643,23 +750,28 @@ function parseUrlBase(url, base) {
|
|
|
643
750
|
//#region src/bom/location.ts
|
|
644
751
|
const INIT_URL = "https://taro.com";
|
|
645
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();
|
|
646
757
|
var TaroLocation = class extends _spcsn_taro_shared.Events {
|
|
647
|
-
#url = new TaroURLProvider(INIT_URL);
|
|
648
|
-
#noCheckUrl = false;
|
|
649
|
-
#window;
|
|
650
758
|
constructor(options) {
|
|
651
759
|
super();
|
|
652
|
-
this
|
|
653
|
-
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);
|
|
654
766
|
this.on("__set_href_without_history__", (href) => {
|
|
655
|
-
this
|
|
656
|
-
const lastHash = this
|
|
657
|
-
this
|
|
658
|
-
if (lastHash !== this
|
|
659
|
-
this
|
|
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);
|
|
660
772
|
}, null);
|
|
661
773
|
this.on("0", () => {
|
|
662
|
-
this
|
|
774
|
+
_assertClassBrand(_TaroLocation_brand, this, _reset).call(this);
|
|
663
775
|
}, null);
|
|
664
776
|
this.on("1", (pageId) => {
|
|
665
777
|
cache.set(pageId, { lastHref: this.href });
|
|
@@ -667,145 +779,104 @@ var TaroLocation = class extends _spcsn_taro_shared.Events {
|
|
|
667
779
|
this.on("2", (pageId) => {
|
|
668
780
|
if (cache.has(pageId)) {
|
|
669
781
|
const ctx = cache.get(pageId);
|
|
670
|
-
this
|
|
671
|
-
this
|
|
672
|
-
this
|
|
782
|
+
_classPrivateFieldSet2(_noCheckUrl, this, true);
|
|
783
|
+
_classPrivateFieldGet2(_url, this).href = ctx.lastHref;
|
|
784
|
+
_classPrivateFieldSet2(_noCheckUrl, this, false);
|
|
673
785
|
}
|
|
674
786
|
}, null);
|
|
675
787
|
this.on("3", (pageId) => {
|
|
676
788
|
cache.delete(pageId);
|
|
677
789
|
}, null);
|
|
678
790
|
}
|
|
679
|
-
#reset() {
|
|
680
|
-
const router = getCurrentInstance().router;
|
|
681
|
-
if (router) {
|
|
682
|
-
const { path, params } = router;
|
|
683
|
-
const searchArr = Object.keys(params).map((key) => {
|
|
684
|
-
return `${key}=${params[key]}`;
|
|
685
|
-
});
|
|
686
|
-
const searchStr = searchArr.length > 0 ? "?" + searchArr.join("&") : "";
|
|
687
|
-
const url = `${INIT_URL}${path.startsWith("/") ? path : "/" + path}${searchStr}`;
|
|
688
|
-
this.#url = new TaroURLProvider(url);
|
|
689
|
-
this.trigger("__reset_history__", this.href);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
#getPreValue() {
|
|
693
|
-
return this.#url._toRaw();
|
|
694
|
-
}
|
|
695
|
-
#rollBack(href) {
|
|
696
|
-
this.#url.href = href;
|
|
697
|
-
}
|
|
698
|
-
#recordHistory() {
|
|
699
|
-
this.trigger("__record_history__", this.href);
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* 校验url的变化,是否需要更新history
|
|
703
|
-
*/
|
|
704
|
-
#checkUrlChange(preValue) {
|
|
705
|
-
if (this.#noCheckUrl) return false;
|
|
706
|
-
const { protocol, hostname, port, pathname, search, hash } = this.#url._toRaw();
|
|
707
|
-
if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
|
|
708
|
-
this.#rollBack(preValue.href);
|
|
709
|
-
return false;
|
|
710
|
-
}
|
|
711
|
-
if (pathname !== preValue.pathname) return true;
|
|
712
|
-
if (search !== preValue.search) return true;
|
|
713
|
-
if (hash !== preValue.hash) {
|
|
714
|
-
this.#window.trigger("hashchange");
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
this.#rollBack(preValue.href);
|
|
718
|
-
return false;
|
|
719
|
-
}
|
|
720
791
|
get protocol() {
|
|
721
|
-
return this
|
|
792
|
+
return _classPrivateFieldGet2(_url, this).protocol;
|
|
722
793
|
}
|
|
723
794
|
set protocol(val) {
|
|
724
795
|
if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http|https):$/i.test(val.trim())) return;
|
|
725
796
|
val = val.trim();
|
|
726
|
-
const preValue = this
|
|
727
|
-
this
|
|
728
|
-
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);
|
|
729
800
|
}
|
|
730
801
|
get host() {
|
|
731
|
-
return this
|
|
802
|
+
return _classPrivateFieldGet2(_url, this).host;
|
|
732
803
|
}
|
|
733
804
|
set host(val) {
|
|
734
805
|
if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
|
|
735
806
|
val = val.trim();
|
|
736
|
-
const preValue = this
|
|
737
|
-
this
|
|
738
|
-
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);
|
|
739
810
|
}
|
|
740
811
|
get hostname() {
|
|
741
|
-
return this
|
|
812
|
+
return _classPrivateFieldGet2(_url, this).hostname;
|
|
742
813
|
}
|
|
743
814
|
set hostname(val) {
|
|
744
815
|
if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
|
|
745
816
|
val = val.trim();
|
|
746
|
-
const preValue = this
|
|
747
|
-
this
|
|
748
|
-
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);
|
|
749
820
|
}
|
|
750
821
|
get port() {
|
|
751
|
-
return this
|
|
822
|
+
return _classPrivateFieldGet2(_url, this).port;
|
|
752
823
|
}
|
|
753
824
|
set port(val) {
|
|
754
825
|
const xVal = Number(val = val.trim());
|
|
755
826
|
if (!(0, _spcsn_taro_shared.isNumber)(xVal) || xVal <= 0) return;
|
|
756
|
-
const preValue = this
|
|
757
|
-
this
|
|
758
|
-
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);
|
|
759
830
|
}
|
|
760
831
|
get pathname() {
|
|
761
|
-
return this
|
|
832
|
+
return _classPrivateFieldGet2(_url, this).pathname;
|
|
762
833
|
}
|
|
763
834
|
set pathname(val) {
|
|
764
835
|
if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
|
|
765
836
|
val = val.trim();
|
|
766
|
-
const preValue = this
|
|
767
|
-
this
|
|
768
|
-
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);
|
|
769
840
|
}
|
|
770
841
|
get search() {
|
|
771
|
-
return this
|
|
842
|
+
return _classPrivateFieldGet2(_url, this).search;
|
|
772
843
|
}
|
|
773
844
|
set search(val) {
|
|
774
845
|
if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
|
|
775
846
|
val = val.trim();
|
|
776
847
|
val = val.startsWith("?") ? val : `?${val}`;
|
|
777
|
-
const preValue = this
|
|
778
|
-
this
|
|
779
|
-
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);
|
|
780
851
|
}
|
|
781
852
|
get hash() {
|
|
782
|
-
return this
|
|
853
|
+
return _classPrivateFieldGet2(_url, this).hash;
|
|
783
854
|
}
|
|
784
855
|
set hash(val) {
|
|
785
856
|
if (!val || !(0, _spcsn_taro_shared.isString)(val)) return;
|
|
786
857
|
val = val.trim();
|
|
787
858
|
val = val.startsWith("#") ? val : `#${val}`;
|
|
788
|
-
const preValue = this
|
|
789
|
-
this
|
|
790
|
-
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);
|
|
791
862
|
}
|
|
792
863
|
get href() {
|
|
793
|
-
return this
|
|
864
|
+
return _classPrivateFieldGet2(_url, this).href;
|
|
794
865
|
}
|
|
795
866
|
set href(val) {
|
|
796
867
|
if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
|
|
797
|
-
const preValue = this
|
|
798
|
-
this
|
|
799
|
-
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);
|
|
800
871
|
}
|
|
801
872
|
get origin() {
|
|
802
|
-
return this
|
|
873
|
+
return _classPrivateFieldGet2(_url, this).origin;
|
|
803
874
|
}
|
|
804
875
|
set origin(val) {
|
|
805
876
|
if (!val || !(0, _spcsn_taro_shared.isString)(val) || !/^(http:|https:)?\/\/.+/.test(val = val.trim())) return;
|
|
806
|
-
const preValue = this
|
|
807
|
-
this
|
|
808
|
-
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);
|
|
809
880
|
}
|
|
810
881
|
assign() {
|
|
811
882
|
(0, _spcsn_taro_shared.warn)(true, "小程序环境中调用location.assign()无效.");
|
|
@@ -823,6 +894,47 @@ var TaroLocation = class extends _spcsn_taro_shared.Events {
|
|
|
823
894
|
return cache;
|
|
824
895
|
}
|
|
825
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
|
+
}
|
|
826
938
|
const Location = process.env.TARO_PLATFORM === "web" ? env.window.Location : TaroLocation;
|
|
827
939
|
function generateFullUrl(val = "") {
|
|
828
940
|
const origin = INIT_URL;
|
|
@@ -889,7 +1001,7 @@ var TaroWindow = class extends _spcsn_taro_shared.Events {
|
|
|
889
1001
|
if (process.env.NODE_ENV !== "production") console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
|
|
890
1002
|
}
|
|
891
1003
|
});
|
|
892
|
-
this.Date
|
|
1004
|
+
this.Date || (this.Date = Date);
|
|
893
1005
|
this.location = new Location({ window: this });
|
|
894
1006
|
this.history = new History(this.location, { window: this });
|
|
895
1007
|
this.initEvent();
|
|
@@ -942,8 +1054,9 @@ const stripBasename = (path = "", prefix = "") => hasBasename(path, prefix) ? pa
|
|
|
942
1054
|
const stripTrailing = (str = "") => str.replace(/[?#][\s\S]*$/, "");
|
|
943
1055
|
const stripSuffix = (path = "", suffix = "") => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
|
|
944
1056
|
const getHomePage = (path = "", basename = "", customRoutes = {}, entryPagePath = "") => {
|
|
1057
|
+
var _Object$entries$find;
|
|
945
1058
|
const routePath = addLeadingSlash(stripBasename(path, basename));
|
|
946
|
-
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;
|
|
947
1060
|
return entryPagePath || (typeof alias === "string" ? alias : alias[0]) || basename;
|
|
948
1061
|
};
|
|
949
1062
|
const getCurrentPage = (routerMode = "hash", basename = "/") => {
|
|
@@ -995,8 +1108,11 @@ function isHasExtractProp(el) {
|
|
|
995
1108
|
* @param type 事件类型
|
|
996
1109
|
*/
|
|
997
1110
|
function isParentBound(node, type) {
|
|
998
|
-
while (node = node
|
|
999
|
-
|
|
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
|
+
}
|
|
1000
1116
|
return false;
|
|
1001
1117
|
}
|
|
1002
1118
|
function shortcutAttr(key) {
|
|
@@ -1010,11 +1126,10 @@ function shortcutAttr(key) {
|
|
|
1010
1126
|
const customWrapperCache = /* @__PURE__ */ new Map();
|
|
1011
1127
|
function extend(ctor, methodName, options) {
|
|
1012
1128
|
if ((0, _spcsn_taro_shared.isFunction)(options)) options = { value: options };
|
|
1013
|
-
Object.defineProperty(ctor.prototype, methodName, {
|
|
1129
|
+
Object.defineProperty(ctor.prototype, methodName, _objectSpread2({
|
|
1014
1130
|
configurable: true,
|
|
1015
|
-
enumerable: true
|
|
1016
|
-
|
|
1017
|
-
});
|
|
1131
|
+
enumerable: true
|
|
1132
|
+
}, options));
|
|
1018
1133
|
}
|
|
1019
1134
|
let componentsAlias$1;
|
|
1020
1135
|
function getComponentsAlias() {
|
|
@@ -1126,15 +1241,18 @@ let componentsAlias;
|
|
|
1126
1241
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
1127
1242
|
*/
|
|
1128
1243
|
function hydrate(node) {
|
|
1129
|
-
componentsAlias
|
|
1130
|
-
SPECIAL_NODES
|
|
1244
|
+
componentsAlias || (componentsAlias = getComponentsAlias());
|
|
1245
|
+
SPECIAL_NODES || (SPECIAL_NODES = _spcsn_taro_shared.hooks.call("getSpecialNodes"));
|
|
1131
1246
|
const nodeName = node.nodeName;
|
|
1132
1247
|
let compileModeName = null;
|
|
1133
|
-
if (isText(node))
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
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
|
+
}
|
|
1138
1256
|
const data = {
|
|
1139
1257
|
[_spcsn_taro_shared.Shortcuts.NodeName]: nodeName,
|
|
1140
1258
|
sid: node.sid
|
|
@@ -1196,10 +1314,7 @@ var TaroEventTarget = class {
|
|
|
1196
1314
|
handler.apply(this, arguments);
|
|
1197
1315
|
this.removeEventListener(type, wrapper);
|
|
1198
1316
|
};
|
|
1199
|
-
this.addEventListener(type, wrapper, {
|
|
1200
|
-
...options,
|
|
1201
|
-
once: false
|
|
1202
|
-
});
|
|
1317
|
+
this.addEventListener(type, wrapper, _objectSpread2(_objectSpread2({}, options), {}, { once: false }));
|
|
1203
1318
|
return;
|
|
1204
1319
|
}
|
|
1205
1320
|
process.env.NODE_ENV !== "production" && (0, _spcsn_taro_shared.warn)(isCapture, "Taro 暂未实现 event 的 capture 特性。");
|
|
@@ -1274,7 +1389,8 @@ var TaroNode = class TaroNode extends TaroEventTarget {
|
|
|
1274
1389
|
});
|
|
1275
1390
|
}
|
|
1276
1391
|
get _root() {
|
|
1277
|
-
|
|
1392
|
+
var _this$parentNode;
|
|
1393
|
+
return ((_this$parentNode = this.parentNode) === null || _this$parentNode === void 0 ? void 0 : _this$parentNode._root) || null;
|
|
1278
1394
|
}
|
|
1279
1395
|
findIndex(refChild) {
|
|
1280
1396
|
const index = this.childNodes.indexOf(refChild);
|
|
@@ -1292,15 +1408,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
|
|
|
1292
1408
|
}
|
|
1293
1409
|
get nextSibling() {
|
|
1294
1410
|
const parentNode = this.parentNode;
|
|
1295
|
-
return parentNode
|
|
1411
|
+
return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) + 1]) || null;
|
|
1296
1412
|
}
|
|
1297
1413
|
get previousSibling() {
|
|
1298
1414
|
const parentNode = this.parentNode;
|
|
1299
|
-
return parentNode
|
|
1415
|
+
return (parentNode === null || parentNode === void 0 ? void 0 : parentNode.childNodes[parentNode.findIndex(this) - 1]) || null;
|
|
1300
1416
|
}
|
|
1301
1417
|
get parentElement() {
|
|
1302
1418
|
const parentNode = this.parentNode;
|
|
1303
|
-
if (parentNode
|
|
1419
|
+
if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nodeType) === 1) return parentNode;
|
|
1304
1420
|
return null;
|
|
1305
1421
|
}
|
|
1306
1422
|
get firstChild() {
|
|
@@ -1426,13 +1542,15 @@ var TaroNode = class TaroNode extends TaroEventTarget {
|
|
|
1426
1542
|
return child;
|
|
1427
1543
|
}
|
|
1428
1544
|
remove(options) {
|
|
1429
|
-
|
|
1545
|
+
var _this$parentNode2;
|
|
1546
|
+
(_this$parentNode2 = this.parentNode) === null || _this$parentNode2 === void 0 || _this$parentNode2.removeChild(this, options);
|
|
1430
1547
|
}
|
|
1431
1548
|
hasChildNodes() {
|
|
1432
1549
|
return this.childNodes.length > 0;
|
|
1433
1550
|
}
|
|
1434
1551
|
enqueueUpdate(payload) {
|
|
1435
|
-
|
|
1552
|
+
var _this$_root;
|
|
1553
|
+
(_this$_root = this._root) === null || _this$_root === void 0 || _this$_root.enqueueUpdate(payload);
|
|
1436
1554
|
}
|
|
1437
1555
|
get ownerDocument() {
|
|
1438
1556
|
return env.document;
|
|
@@ -1950,7 +2068,7 @@ function returnTrue() {
|
|
|
1950
2068
|
}
|
|
1951
2069
|
function treeToArray(root, predict) {
|
|
1952
2070
|
const array = [];
|
|
1953
|
-
const filter = predict
|
|
2071
|
+
const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
|
|
1954
2072
|
let object = root;
|
|
1955
2073
|
while (object) {
|
|
1956
2074
|
if (object.nodeType === 1 && filter(object)) array.push(object);
|
|
@@ -2150,7 +2268,8 @@ var TaroElement = class TaroElement extends TaroNode {
|
|
|
2150
2268
|
}
|
|
2151
2269
|
}
|
|
2152
2270
|
getAttribute(qualifiedName) {
|
|
2153
|
-
|
|
2271
|
+
const attr = qualifiedName === "style" ? this.style.cssText : this.props[qualifiedName];
|
|
2272
|
+
return attr !== null && attr !== void 0 ? attr : "";
|
|
2154
2273
|
}
|
|
2155
2274
|
getElementsByTagName(tagName) {
|
|
2156
2275
|
return treeToArray(this, (el) => {
|
|
@@ -2252,14 +2371,12 @@ var TaroEvent = class {
|
|
|
2252
2371
|
get target() {
|
|
2253
2372
|
const cacheTarget = this.cacheTarget;
|
|
2254
2373
|
if (!cacheTarget) {
|
|
2255
|
-
|
|
2256
|
-
const
|
|
2257
|
-
const
|
|
2258
|
-
target.
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
};
|
|
2262
|
-
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];
|
|
2263
2380
|
this.cacheTarget = target;
|
|
2264
2381
|
return target;
|
|
2265
2382
|
} else return cacheTarget;
|
|
@@ -2267,16 +2384,17 @@ var TaroEvent = class {
|
|
|
2267
2384
|
get currentTarget() {
|
|
2268
2385
|
const cacheCurrentTarget = this.cacheCurrentTarget;
|
|
2269
2386
|
if (!cacheCurrentTarget) {
|
|
2387
|
+
var _this$mpEvent3, _currentTarget$datase, _this$mpEvent4, _this$mpEvent5, _this$mpEvent6;
|
|
2270
2388
|
const doc = env.document;
|
|
2271
|
-
const currentTarget = Object.create(this.mpEvent
|
|
2272
|
-
const element = doc.getElementById(currentTarget.dataset
|
|
2273
|
-
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);
|
|
2274
2392
|
if (element === null || element && element === targetElement) {
|
|
2275
2393
|
this.cacheCurrentTarget = this.target;
|
|
2276
2394
|
return this.target;
|
|
2277
2395
|
}
|
|
2278
2396
|
currentTarget.dataset = element.dataset;
|
|
2279
|
-
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];
|
|
2280
2398
|
this.cacheCurrentTarget = currentTarget;
|
|
2281
2399
|
return currentTarget;
|
|
2282
2400
|
} else return cacheCurrentTarget;
|
|
@@ -2293,7 +2411,7 @@ function createEvent(event, node) {
|
|
|
2293
2411
|
}, event);
|
|
2294
2412
|
for (const key in event) if (key === "currentTarget" || key === "target" || key === "type" || key === "timeStamp") continue;
|
|
2295
2413
|
else domEv[key] = event[key];
|
|
2296
|
-
if (domEv.type === "confirm" && node
|
|
2414
|
+
if (domEv.type === "confirm" && (node === null || node === void 0 ? void 0 : node.nodeName) === "input") domEv[KEY_CODE] = 13;
|
|
2297
2415
|
return domEv;
|
|
2298
2416
|
}
|
|
2299
2417
|
const eventsBatch = {};
|
|
@@ -2303,12 +2421,13 @@ function getEventCBResult(event) {
|
|
|
2303
2421
|
return result;
|
|
2304
2422
|
}
|
|
2305
2423
|
function eventHandler(event) {
|
|
2424
|
+
var _currentTarget$datase2, _event$detail;
|
|
2306
2425
|
event.type === void 0 && Object.defineProperty(event, "type", { value: event._type });
|
|
2307
|
-
event.detail === void 0 && Object.defineProperty(event, "detail", { value: event._detail || {
|
|
2308
|
-
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);
|
|
2309
2428
|
_spcsn_taro_shared.hooks.call("modifyMpEventImpl", event);
|
|
2310
2429
|
const currentTarget = event.currentTarget;
|
|
2311
|
-
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) || "";
|
|
2312
2431
|
const node = env.document.getElementById(id);
|
|
2313
2432
|
if (node) {
|
|
2314
2433
|
const dispatch = () => {
|
|
@@ -2328,7 +2447,7 @@ function eventHandler(event) {
|
|
|
2328
2447
|
dispatch();
|
|
2329
2448
|
});
|
|
2330
2449
|
return getEventCBResult(event);
|
|
2331
|
-
} else (eventsBatch[type]
|
|
2450
|
+
} else (eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
|
|
2332
2451
|
} else {
|
|
2333
2452
|
dispatch();
|
|
2334
2453
|
return getEventCBResult(event);
|
|
@@ -2347,7 +2466,8 @@ function eventHandlerTTDom(ele, listener, event) {
|
|
|
2347
2466
|
//#region src/dom/form.ts
|
|
2348
2467
|
var FormElement = class extends TaroElement {
|
|
2349
2468
|
get type() {
|
|
2350
|
-
|
|
2469
|
+
var _this$props$TYPE;
|
|
2470
|
+
return (_this$props$TYPE = this.props["type"]) !== null && _this$props$TYPE !== void 0 ? _this$props$TYPE : "";
|
|
2351
2471
|
}
|
|
2352
2472
|
set type(val) {
|
|
2353
2473
|
this.setAttribute(TYPE, val);
|
|
@@ -2370,8 +2490,10 @@ var FormElement = class extends TaroElement {
|
|
|
2370
2490
|
};
|
|
2371
2491
|
//#endregion
|
|
2372
2492
|
//#region src/perf.ts
|
|
2493
|
+
var _Performance_brand = /* @__PURE__ */ new WeakSet();
|
|
2373
2494
|
var Performance = class {
|
|
2374
2495
|
constructor() {
|
|
2496
|
+
_classPrivateMethodInitSpec(this, _Performance_brand);
|
|
2375
2497
|
this.recorder = /* @__PURE__ */ new Map();
|
|
2376
2498
|
}
|
|
2377
2499
|
start(id) {
|
|
@@ -2384,20 +2506,20 @@ var Performance = class {
|
|
|
2384
2506
|
if (!(prev >= 0)) return;
|
|
2385
2507
|
this.recorder.delete(id);
|
|
2386
2508
|
const time = now - prev;
|
|
2387
|
-
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)}`);
|
|
2388
2510
|
}
|
|
2389
2511
|
delayStop(id, delay = 500) {
|
|
2390
2512
|
if (!options.debug) return;
|
|
2391
2513
|
return debounce((now = Date.now(), cb) => {
|
|
2392
2514
|
this.stop(id, now);
|
|
2393
|
-
cb
|
|
2515
|
+
cb === null || cb === void 0 || cb();
|
|
2394
2516
|
}, delay);
|
|
2395
2517
|
}
|
|
2396
|
-
#parseTime(time) {
|
|
2397
|
-
const d = new Date(time);
|
|
2398
|
-
return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
|
|
2399
|
-
}
|
|
2400
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
|
+
}
|
|
2401
2523
|
const perf = new Performance();
|
|
2402
2524
|
//#endregion
|
|
2403
2525
|
//#region src/dom/root.ts
|
|
@@ -2477,10 +2599,7 @@ var TaroRootElement = class extends TaroElement {
|
|
|
2477
2599
|
const found = findCustomWrapper(this, dataPathArr);
|
|
2478
2600
|
if (found) {
|
|
2479
2601
|
const { customWrapper, splitedPath } = found;
|
|
2480
|
-
customWrapperMap.set(customWrapper, {
|
|
2481
|
-
...customWrapperMap.get(customWrapper) || {},
|
|
2482
|
-
[`i.${splitedPath}`]: data[p]
|
|
2483
|
-
});
|
|
2602
|
+
customWrapperMap.set(customWrapper, _objectSpread2(_objectSpread2({}, customWrapperMap.get(customWrapper) || {}), {}, { [`i.${splitedPath}`]: data[p] }));
|
|
2484
2603
|
} else normalUpdate[p] = data[p];
|
|
2485
2604
|
}
|
|
2486
2605
|
const customWrapperCount = customWrapperMap.size;
|
|
@@ -2558,31 +2677,39 @@ var TaroText = class extends TaroNode {
|
|
|
2558
2677
|
//#region src/dom/anchor-element.ts
|
|
2559
2678
|
var AnchorElement = class extends TaroElement {
|
|
2560
2679
|
get href() {
|
|
2561
|
-
|
|
2680
|
+
var _this$props$AnchorEle;
|
|
2681
|
+
return (_this$props$AnchorEle = this.props["href"]) !== null && _this$props$AnchorEle !== void 0 ? _this$props$AnchorEle : "";
|
|
2562
2682
|
}
|
|
2563
2683
|
set href(val) {
|
|
2564
2684
|
this.setAttribute("href", val);
|
|
2565
2685
|
}
|
|
2566
2686
|
get protocol() {
|
|
2567
|
-
|
|
2687
|
+
var _this$props$AnchorEle2;
|
|
2688
|
+
return (_this$props$AnchorEle2 = this.props["protocol"]) !== null && _this$props$AnchorEle2 !== void 0 ? _this$props$AnchorEle2 : "";
|
|
2568
2689
|
}
|
|
2569
2690
|
get host() {
|
|
2570
|
-
|
|
2691
|
+
var _this$props$AnchorEle3;
|
|
2692
|
+
return (_this$props$AnchorEle3 = this.props["host"]) !== null && _this$props$AnchorEle3 !== void 0 ? _this$props$AnchorEle3 : "";
|
|
2571
2693
|
}
|
|
2572
2694
|
get search() {
|
|
2573
|
-
|
|
2695
|
+
var _this$props$AnchorEle4;
|
|
2696
|
+
return (_this$props$AnchorEle4 = this.props["search"]) !== null && _this$props$AnchorEle4 !== void 0 ? _this$props$AnchorEle4 : "";
|
|
2574
2697
|
}
|
|
2575
2698
|
get hash() {
|
|
2576
|
-
|
|
2699
|
+
var _this$props$AnchorEle5;
|
|
2700
|
+
return (_this$props$AnchorEle5 = this.props["hash"]) !== null && _this$props$AnchorEle5 !== void 0 ? _this$props$AnchorEle5 : "";
|
|
2577
2701
|
}
|
|
2578
2702
|
get hostname() {
|
|
2579
|
-
|
|
2703
|
+
var _this$props$AnchorEle6;
|
|
2704
|
+
return (_this$props$AnchorEle6 = this.props["hostname"]) !== null && _this$props$AnchorEle6 !== void 0 ? _this$props$AnchorEle6 : "";
|
|
2580
2705
|
}
|
|
2581
2706
|
get port() {
|
|
2582
|
-
|
|
2707
|
+
var _this$props$AnchorEle7;
|
|
2708
|
+
return (_this$props$AnchorEle7 = this.props["port"]) !== null && _this$props$AnchorEle7 !== void 0 ? _this$props$AnchorEle7 : "";
|
|
2583
2709
|
}
|
|
2584
2710
|
get pathname() {
|
|
2585
|
-
|
|
2711
|
+
var _this$props$AnchorEle8;
|
|
2712
|
+
return (_this$props$AnchorEle8 = this.props["pathname"]) !== null && _this$props$AnchorEle8 !== void 0 ? _this$props$AnchorEle8 : "";
|
|
2586
2713
|
}
|
|
2587
2714
|
setAttribute(qualifiedName, value) {
|
|
2588
2715
|
if (qualifiedName === "href") {
|
|
@@ -2697,7 +2824,8 @@ function createDocument() {
|
|
|
2697
2824
|
return doc;
|
|
2698
2825
|
}
|
|
2699
2826
|
function createTTDomDocument() {
|
|
2700
|
-
|
|
2827
|
+
var _tt$getBuiltInCompone;
|
|
2828
|
+
const document = tt === null || tt === void 0 ? void 0 : tt.appDocument;
|
|
2701
2829
|
if (!document) throw new Error("tt.appDocument is not found");
|
|
2702
2830
|
const html = document.createElement(HTML);
|
|
2703
2831
|
const head = document.createElement(HEAD);
|
|
@@ -2714,7 +2842,7 @@ function createTTDomDocument() {
|
|
|
2714
2842
|
document.head = head;
|
|
2715
2843
|
document.body = body;
|
|
2716
2844
|
document.appElement = app;
|
|
2717
|
-
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);
|
|
2718
2846
|
if (Array.isArray(builtInComponents)) builtInComponents = new Set(builtInComponents);
|
|
2719
2847
|
else if (!(builtInComponents instanceof Set)) builtInComponents = new Set([..._spcsn_taro_shared.DEFAULT_COMPONENTS, ..._spcsn_taro_shared.TT_SPECIFIC_COMPONENTS]);
|
|
2720
2848
|
document.getElementById = function getElementById(id) {
|
|
@@ -2783,7 +2911,7 @@ function stringify(obj) {
|
|
|
2783
2911
|
}
|
|
2784
2912
|
function getPath(id, options) {
|
|
2785
2913
|
const idx = id.indexOf("?");
|
|
2786
|
-
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 } : {})}`;
|
|
2787
2915
|
else return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
|
|
2788
2916
|
}
|
|
2789
2917
|
function getOnReadyEventKey(path) {
|
|
@@ -2796,7 +2924,7 @@ function getOnHideEventKey(path) {
|
|
|
2796
2924
|
return path + ".onHide";
|
|
2797
2925
|
}
|
|
2798
2926
|
function createPageConfig(component, pageName, data, pageConfig) {
|
|
2799
|
-
const id = pageName
|
|
2927
|
+
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
2800
2928
|
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").page;
|
|
2801
2929
|
let pageElement = null;
|
|
2802
2930
|
let unmounting = false;
|
|
@@ -2918,9 +3046,11 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
2918
3046
|
};
|
|
2919
3047
|
});
|
|
2920
3048
|
SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
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) {
|
|
2924
3054
|
const id = target.id;
|
|
2925
3055
|
const element = env.document.getElementById(id);
|
|
2926
3056
|
if (element) target.dataset = element.dataset;
|
|
@@ -2934,13 +3064,14 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
2934
3064
|
return config;
|
|
2935
3065
|
}
|
|
2936
3066
|
function createComponentConfig(component, componentName, data) {
|
|
2937
|
-
const id = componentName
|
|
3067
|
+
const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
|
|
2938
3068
|
let componentElement = null;
|
|
2939
3069
|
const [ATTACHED, DETACHED] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").component;
|
|
2940
3070
|
const config = {
|
|
2941
3071
|
[ATTACHED]() {
|
|
3072
|
+
var _this$getPageId;
|
|
2942
3073
|
perf.start(PAGE_INIT);
|
|
2943
|
-
this.pageIdCache = this.getPageId
|
|
3074
|
+
this.pageIdCache = ((_this$getPageId = this.getPageId) === null || _this$getPageId === void 0 ? void 0 : _this$getPageId.call(this)) || pageId();
|
|
2944
3075
|
const path = getPath(id, { id: this.pageIdCache });
|
|
2945
3076
|
Current.app.mount(component, path, () => {
|
|
2946
3077
|
componentElement = env.document.getElementById(path);
|
|
@@ -2968,7 +3099,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
2968
3099
|
EXTERNAL_CLASSES,
|
|
2969
3100
|
BEHAVIORS
|
|
2970
3101
|
].forEach((key) => {
|
|
2971
|
-
|
|
3102
|
+
var _component$key;
|
|
3103
|
+
config[key] = (_component$key = component[key]) !== null && _component$key !== void 0 ? _component$key : _spcsn_taro_shared.EMPTY_OBJ;
|
|
2972
3104
|
});
|
|
2973
3105
|
return config;
|
|
2974
3106
|
}
|
|
@@ -2977,8 +3109,9 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
2977
3109
|
const [ATTACHED, DETACHED] = _spcsn_taro_shared.hooks.call("getMiniLifecycleImpl").component;
|
|
2978
3110
|
const lifeCycles = isCustomWrapper ? {
|
|
2979
3111
|
[ATTACHED]() {
|
|
3112
|
+
var _this$data$i, _this$props$i;
|
|
2980
3113
|
if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) return;
|
|
2981
|
-
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);
|
|
2982
3115
|
if ((0, _spcsn_taro_shared.isString)(componentId)) {
|
|
2983
3116
|
customWrapperCache.set(componentId, this);
|
|
2984
3117
|
const el = env.document.getElementById(componentId);
|
|
@@ -2986,8 +3119,9 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
2986
3119
|
}
|
|
2987
3120
|
},
|
|
2988
3121
|
[DETACHED]() {
|
|
3122
|
+
var _this$data$i2, _this$props$i2;
|
|
2989
3123
|
if (process.env.TARO_ENV === "tt" && (0, _spcsn_taro_shared.isEnableTTDom)()) return;
|
|
2990
|
-
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);
|
|
2991
3125
|
if ((0, _spcsn_taro_shared.isString)(componentId)) {
|
|
2992
3126
|
customWrapperCache.delete(componentId);
|
|
2993
3127
|
const el = env.document.getElementById(componentId);
|
|
@@ -2997,7 +3131,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
2997
3131
|
} : _spcsn_taro_shared.EMPTY_OBJ;
|
|
2998
3132
|
const extraOptions = {};
|
|
2999
3133
|
if (process.env.TARO_ENV === "jd") extraOptions.addGlobalClass = true;
|
|
3000
|
-
return _spcsn_taro_shared.hooks.call("modifyRecursiveComponentConfig", {
|
|
3134
|
+
return _spcsn_taro_shared.hooks.call("modifyRecursiveComponentConfig", _objectSpread2({
|
|
3001
3135
|
properties: {
|
|
3002
3136
|
i: {
|
|
3003
3137
|
type: Object,
|
|
@@ -3008,13 +3142,9 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
3008
3142
|
value: ""
|
|
3009
3143
|
}
|
|
3010
3144
|
},
|
|
3011
|
-
options: {
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
},
|
|
3015
|
-
methods: { eh: eventHandler },
|
|
3016
|
-
...lifeCycles
|
|
3017
|
-
}, { isCustomWrapper });
|
|
3145
|
+
options: _objectSpread2(_objectSpread2({}, extraOptions), {}, { virtualHost: !isCustomWrapper }),
|
|
3146
|
+
methods: { eh: eventHandler }
|
|
3147
|
+
}, lifeCycles), { isCustomWrapper });
|
|
3018
3148
|
}
|
|
3019
3149
|
//#endregion
|
|
3020
3150
|
//#region src/next-tick.ts
|
|
@@ -3037,10 +3167,12 @@ const nextTick = (cb, ctx) => {
|
|
|
3037
3167
|
*/
|
|
3038
3168
|
function next() {
|
|
3039
3169
|
const pageElement = env.document.getElementById(path);
|
|
3040
|
-
if (pageElement
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
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);
|
|
3044
3176
|
else if (Date.now() - beginTime > TIMEOUT) timerFunc();
|
|
3045
3177
|
else setTimeout(() => next(), 20);
|
|
3046
3178
|
}
|