@tarojs/router 4.0.0-beta.133 → 4.0.0-beta.134

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/README.md CHANGED
@@ -20,7 +20,7 @@ H5 端路由系统。
20
20
 
21
21
  #### `type`
22
22
 
23
- 框架类型,`react` | `vue` | `nerv` 三选一。
23
+ 框架类型,`react` | `vue` | `solid` | `preact` 四选一。
24
24
 
25
25
  #### `framework`
26
26
 
package/dist/index.cjs.js CHANGED
@@ -45,7 +45,7 @@ body {
45
45
  /**
46
46
  * 插入路由相关样式
47
47
  */
48
- function loadRouterStyle(enableTabBar, enableWindowScroll) {
48
+ function loadRouterStyle(enableTabBar, enableWindowScroll, enhanceAnimation) {
49
49
  const css = `
50
50
  .taro_router {
51
51
  position: relative;
@@ -73,11 +73,15 @@ ${enableTabBar ? `
73
73
  }
74
74
 
75
75
  ` : ''}
76
- .taro_page_shade:has(+.taro_page_stationed),
76
+ ${enhanceAnimation
77
+ ? `.taro_page_shade:has(+.taro_page_stationed),
77
78
  .taro_page_shade.taro_tabbar_page,
78
79
  .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) {
79
80
  display: none;
80
- }
81
+ }` : ` .taro_page_shade,
82
+ .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
83
+ display: none;
84
+ }`}
81
85
  `;
82
86
  addStyle(css);
83
87
  }
@@ -1272,7 +1276,7 @@ class PageHandler {
1272
1276
  this.pathname = exports.history.location.pathname;
1273
1277
  // Note: 注入页面样式
1274
1278
  this.animation && loadAnimateStyle(this.animationDuration);
1275
- loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll);
1279
+ loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll, this.router.enhanceAnimation);
1276
1280
  }
1277
1281
  onReady(page, onLoad = true) {
1278
1282
  var _a;
@@ -1396,7 +1400,7 @@ class PageHandler {
1396
1400
  }
1397
1401
  }
1398
1402
  hide(page, animation = false) {
1399
- var _a, _b, _c, _d, _e, _f, _g;
1403
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1400
1404
  if (!page)
1401
1405
  return;
1402
1406
  // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
@@ -1421,6 +1425,7 @@ class PageHandler {
1421
1425
  this.hideTimer = null;
1422
1426
  (_g = (_f = (_e = this.lastHidePage) === null || _e === void 0 ? void 0 : _e.classList) === null || _f === void 0 ? void 0 : _f.add) === null || _g === void 0 ? void 0 : _g.call(_f, 'taro_page_shade');
1423
1427
  }
1428
+ (_h = page.onHide) === null || _h === void 0 ? void 0 : _h.call(page);
1424
1429
  pageEl.classList.add('taro_page_shade');
1425
1430
  this.lastHidePage = pageEl;
1426
1431
  }
@@ -1707,7 +1712,7 @@ function handleAppMount(config, _, appId = config.appId || 'app') {
1707
1712
  app.id = appId;
1708
1713
  isPosition = false;
1709
1714
  }
1710
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
1715
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
1711
1716
  app.classList.add('taro_router');
1712
1717
  if (!isPosition)
1713
1718
  appWrapper.appendChild(app);
@@ -1721,7 +1726,7 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
1721
1726
  app.id = appId;
1722
1727
  isPosition = false;
1723
1728
  }
1724
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
1729
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
1725
1730
  app.classList.add('taro_router');
1726
1731
  const container = document.createElement('div');
1727
1732
  container.classList.add('taro-tabbar__container');
package/dist/index.esm.js CHANGED
@@ -44,7 +44,7 @@ body {
44
44
  /**
45
45
  * 插入路由相关样式
46
46
  */
47
- function loadRouterStyle(enableTabBar, enableWindowScroll) {
47
+ function loadRouterStyle(enableTabBar, enableWindowScroll, enhanceAnimation) {
48
48
  const css = `
49
49
  .taro_router {
50
50
  position: relative;
@@ -72,11 +72,15 @@ ${enableTabBar ? `
72
72
  }
73
73
 
74
74
  ` : ''}
75
- .taro_page_shade:has(+.taro_page_stationed),
75
+ ${enhanceAnimation
76
+ ? `.taro_page_shade:has(+.taro_page_stationed),
76
77
  .taro_page_shade.taro_tabbar_page,
77
78
  .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) {
78
79
  display: none;
79
- }
80
+ }` : ` .taro_page_shade,
81
+ .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
82
+ display: none;
83
+ }`}
80
84
  `;
81
85
  addStyle(css);
82
86
  }
@@ -1271,7 +1275,7 @@ class PageHandler {
1271
1275
  this.pathname = history.location.pathname;
1272
1276
  // Note: 注入页面样式
1273
1277
  this.animation && loadAnimateStyle(this.animationDuration);
1274
- loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll);
1278
+ loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll, this.router.enhanceAnimation);
1275
1279
  }
1276
1280
  onReady(page, onLoad = true) {
1277
1281
  var _a;
@@ -1395,7 +1399,7 @@ class PageHandler {
1395
1399
  }
1396
1400
  }
1397
1401
  hide(page, animation = false) {
1398
- var _a, _b, _c, _d, _e, _f, _g;
1402
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1399
1403
  if (!page)
1400
1404
  return;
1401
1405
  // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
@@ -1420,6 +1424,7 @@ class PageHandler {
1420
1424
  this.hideTimer = null;
1421
1425
  (_g = (_f = (_e = this.lastHidePage) === null || _e === void 0 ? void 0 : _e.classList) === null || _f === void 0 ? void 0 : _f.add) === null || _g === void 0 ? void 0 : _g.call(_f, 'taro_page_shade');
1422
1426
  }
1427
+ (_h = page.onHide) === null || _h === void 0 ? void 0 : _h.call(page);
1423
1428
  pageEl.classList.add('taro_page_shade');
1424
1429
  this.lastHidePage = pageEl;
1425
1430
  }
@@ -1706,7 +1711,7 @@ function handleAppMount(config, _, appId = config.appId || 'app') {
1706
1711
  app.id = appId;
1707
1712
  isPosition = false;
1708
1713
  }
1709
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
1714
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
1710
1715
  app.classList.add('taro_router');
1711
1716
  if (!isPosition)
1712
1717
  appWrapper.appendChild(app);
@@ -1720,7 +1725,7 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
1720
1725
  app.id = appId;
1721
1726
  isPosition = false;
1722
1727
  }
1723
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
1728
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
1724
1729
  app.classList.add('taro_router');
1725
1730
  const container = document.createElement('div');
1726
1731
  container.classList.add('taro-tabbar__container');
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ function handleAppMount(config, _, appId = config.appId || 'app') {
16
16
  app.id = appId;
17
17
  isPosition = false;
18
18
  }
19
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
19
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
20
20
  app.classList.add('taro_router');
21
21
  if (!isPosition)
22
22
  appWrapper.appendChild(app);
@@ -30,7 +30,7 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
30
30
  app.id = appId;
31
31
  isPosition = false;
32
32
  }
33
- const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
33
+ const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
34
34
  app.classList.add('taro_router');
35
35
  const container = document.createElement('div');
36
36
  container.classList.add('taro-tabbar__container');
@@ -123,7 +123,7 @@ class PageHandler {
123
123
  this.pathname = history.location.pathname;
124
124
  // Note: 注入页面样式
125
125
  this.animation && loadAnimateStyle(this.animationDuration);
126
- loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll);
126
+ loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll, this.router.enhanceAnimation);
127
127
  }
128
128
  onReady(page, onLoad = true) {
129
129
  var _a;
@@ -247,7 +247,7 @@ class PageHandler {
247
247
  }
248
248
  }
249
249
  hide(page, animation = false) {
250
- var _a, _b, _c, _d, _e, _f, _g;
250
+ var _a, _b, _c, _d, _e, _f, _g, _h;
251
251
  if (!page)
252
252
  return;
253
253
  // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
@@ -272,6 +272,7 @@ class PageHandler {
272
272
  this.hideTimer = null;
273
273
  (_g = (_f = (_e = this.lastHidePage) === null || _e === void 0 ? void 0 : _e.classList) === null || _f === void 0 ? void 0 : _f.add) === null || _g === void 0 ? void 0 : _g.call(_f, 'taro_page_shade');
274
274
  }
275
+ (_h = page.onHide) === null || _h === void 0 ? void 0 : _h.call(page);
275
276
  pageEl.classList.add('taro_page_shade');
276
277
  this.lastHidePage = pageEl;
277
278
  }
package/dist/style.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare function loadAnimateStyle(ms?: number): void;
5
5
  /**
6
6
  * 插入路由相关样式
7
7
  */
8
- export declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean): void;
8
+ export declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean, enhanceAnimation?: boolean): void;
9
9
  /**
10
10
  * 插入导航栏相关的样式
11
11
  */
package/dist/style.js CHANGED
@@ -34,7 +34,7 @@ body {
34
34
  /**
35
35
  * 插入路由相关样式
36
36
  */
37
- function loadRouterStyle(enableTabBar, enableWindowScroll) {
37
+ function loadRouterStyle(enableTabBar, enableWindowScroll, enhanceAnimation) {
38
38
  const css = `
39
39
  .taro_router {
40
40
  position: relative;
@@ -62,11 +62,15 @@ ${enableTabBar ? `
62
62
  }
63
63
 
64
64
  ` : ''}
65
- .taro_page_shade:has(+.taro_page_stationed),
65
+ ${enhanceAnimation
66
+ ? `.taro_page_shade:has(+.taro_page_stationed),
66
67
  .taro_page_shade.taro_tabbar_page,
67
68
  .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) {
68
69
  display: none;
69
- }
70
+ }` : ` .taro_page_shade,
71
+ .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
72
+ display: none;
73
+ }`}
70
74
  `;
71
75
  addStyle(css);
72
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/router",
3
- "version": "4.0.0-beta.133",
3
+ "version": "4.0.0-beta.134",
4
4
  "description": "Taro-router",
5
5
  "author": "O2Team",
6
6
  "license": "MIT",
@@ -34,15 +34,15 @@
34
34
  "universal-router": "^9.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@tarojs/runtime": "4.0.0-beta.133",
38
- "@tarojs/taro": "4.0.0-beta.133",
39
- "@tarojs/components": "4.0.0-beta.133",
40
- "@tarojs/shared": "4.0.0-beta.133"
37
+ "@tarojs/components": "4.0.0-beta.134",
38
+ "@tarojs/runtime": "4.0.0-beta.134",
39
+ "@tarojs/taro": "4.0.0-beta.134",
40
+ "@tarojs/shared": "4.0.0-beta.134"
41
41
  },
42
42
  "peerDependencies": {
43
- "@tarojs/taro": "4.0.0-beta.133",
44
- "@tarojs/shared": "4.0.0-beta.133",
45
- "@tarojs/runtime": "4.0.0-beta.133"
43
+ "@tarojs/runtime": "4.0.0-beta.134",
44
+ "@tarojs/taro": "4.0.0-beta.134",
45
+ "@tarojs/shared": "4.0.0-beta.134"
46
46
  },
47
47
  "scripts": {
48
48
  "prod": "pnpm run build",
package/types/router.d.ts CHANGED
@@ -12,6 +12,8 @@ export interface Router {
12
12
  customRoutes?: Record<string, string | string[]>
13
13
  pathname: string
14
14
  forcePath?: string
15
+ /** 加上这个参数,可以解决返回页面的时候白屏的问题,但是某些不支持 :has() 选择器的浏览器会有问题 */
16
+ enhanceAnimation?: boolean
15
17
  }
16
18
 
17
19
  export interface SpaRouterConfig extends AppConfig {