@tarojs/router 4.0.1 → 4.0.3-alpah.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/LICENSE +8 -8
- package/README.md +1 -1
- package/dist/api.d.ts +6 -7
- package/dist/events/resize.d.ts +2 -3
- package/dist/events/scroll.d.ts +2 -3
- package/dist/history.d.ts +10 -8
- package/dist/index.cjs.js +31 -17
- package/dist/index.d.ts +9 -10
- package/dist/index.esm.js +29 -15
- package/dist/index.js +2 -2
- package/dist/navigationBar.d.ts +2 -3
- package/dist/router/index.d.ts +3 -5
- package/dist/router/mpa.d.ts +4 -5
- package/dist/router/mpa.js +2 -2
- package/dist/router/multi-page.d.ts +8 -8
- package/dist/router/multi-page.js +15 -1
- package/dist/router/navigation-bar.d.ts +3 -3
- package/dist/router/page.d.ts +8 -9
- package/dist/router/spa.d.ts +4 -5
- package/dist/router/spa.js +10 -10
- package/dist/router/stack.d.ts +2 -2
- package/dist/style.d.ts +4 -5
- package/dist/tabbar.d.ts +2 -3
- package/dist/tabbar.js +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/navigate.d.ts +6 -7
- package/package.json +19 -30
- package/dist/index.cjs.d.ts +0 -66
- package/dist/index.esm.d.ts +0 -66
package/LICENSE
CHANGED
|
@@ -154,15 +154,8 @@ See `/LICENSE` for details of the license.
|
|
|
154
154
|
|
|
155
155
|
==================
|
|
156
156
|
|
|
157
|
-
MIT (stencil-vue2-output-target):
|
|
158
|
-
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
|
-
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
|
-
See `/LICENSE` for details of the license.
|
|
161
|
-
|
|
162
|
-
==================
|
|
163
|
-
|
|
164
157
|
MIT (weui):
|
|
165
|
-
The following files embed [
|
|
158
|
+
The following files embed [weui](https://github.com/Tencent/weui) MIT:
|
|
166
159
|
`/packages/taro-components/src/components/*.scss`
|
|
167
160
|
See `/LICENSE.txt` for details of the license.
|
|
168
161
|
|
|
@@ -172,3 +165,10 @@ Apache-2.0 (intersection-observer):
|
|
|
172
165
|
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
173
166
|
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
174
167
|
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
MIT (babel-plugin-jsx-dom-expressions):
|
|
172
|
+
The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
|
|
173
|
+
`/packages/babel-plugin-transform-solid-jsx/src/*`
|
|
174
|
+
See `/LICENSE` for details of the license.
|
package/README.md
CHANGED
package/dist/api.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Taro from '@tarojs/taro';
|
|
2
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
3
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
4
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
5
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
6
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
7
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
8
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages };
|
|
2
|
+
export declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
3
|
+
export declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
4
|
+
export declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
5
|
+
export declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
6
|
+
export declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
7
|
+
export declare function getCurrentPages(): Taro.Page[];
|
package/dist/events/resize.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
2
|
-
declare function bindPageResize(page: PageInstance): void;
|
|
3
|
-
export { bindPageResize };
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
|
+
export declare function bindPageResize(page: PageInstance): void;
|
package/dist/events/scroll.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
2
|
-
declare function bindPageScroll(page: PageInstance, scrollEl: HTMLElement | Window, distance?: number): void;
|
|
3
|
-
export { bindPageScroll };
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
|
+
export declare function bindPageScroll(page: PageInstance, scrollEl: HTMLElement | Window, distance?: number): void;
|
package/dist/history.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Action, createBrowserHistory, createHashHistory } from 'history';
|
|
2
|
+
import type { IH5RouterConfig } from '@tarojs/taro/types/compile';
|
|
3
|
+
import type { Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from 'history';
|
|
4
|
+
import type { StateEvent } from '../types/history';
|
|
5
|
+
export declare let history: History;
|
|
4
6
|
declare class MpaHistory implements History {
|
|
5
7
|
action: Action;
|
|
6
8
|
get location(): Location;
|
|
@@ -17,8 +19,8 @@ declare class MpaHistory implements History {
|
|
|
17
19
|
replaceState: globalThis.History['replaceState'];
|
|
18
20
|
eventState(action: Required<StateEvent>['action']): (data: any, unused: string, url?: string | URL | null) => any;
|
|
19
21
|
}
|
|
20
|
-
declare function setHistory(h: History, base?: string): void;
|
|
21
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
22
|
-
|
|
23
|
-
declare function
|
|
24
|
-
export
|
|
22
|
+
export declare function setHistory(h: History, base?: string): void;
|
|
23
|
+
export declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
24
|
+
export { createBrowserHistory, createHashHistory };
|
|
25
|
+
export declare function setHistoryMode(mode?: IH5RouterConfig['mode'], base?: string): void;
|
|
26
|
+
export declare function prependBasename(url?: string): string;
|
package/dist/index.cjs.js
CHANGED
|
@@ -225,7 +225,7 @@ function initNavigationBar(config, container) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
function initTabbar(config, history) {
|
|
228
|
-
if (config.tabBar == null) {
|
|
228
|
+
if (config.tabBar == null || config.tabBar.custom) {
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
// TODO: custom-tab-bar
|
|
@@ -794,6 +794,7 @@ class MultiPageHandler {
|
|
|
794
794
|
this.onReady(page, true);
|
|
795
795
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
796
796
|
this.bindPageEvents(page, pageConfig);
|
|
797
|
+
this.triggerRouterChange();
|
|
797
798
|
});
|
|
798
799
|
}
|
|
799
800
|
getPageContainer(page) {
|
|
@@ -821,6 +822,19 @@ class MultiPageHandler {
|
|
|
821
822
|
bindPageScroll(page, scrollEl, distance);
|
|
822
823
|
bindPageResize(page);
|
|
823
824
|
}
|
|
825
|
+
triggerRouterChange() {
|
|
826
|
+
/**
|
|
827
|
+
* @tarojs/runtime 中生命周期跑在 promise 中,所以这里需要 setTimeout 延迟事件调用
|
|
828
|
+
* TODO 考虑将生命周期返回 Promise,用于处理相关事件调用顺序
|
|
829
|
+
*/
|
|
830
|
+
setTimeout(() => {
|
|
831
|
+
runtime.eventCenter.trigger('__afterTaroRouterChange', {
|
|
832
|
+
toLocation: {
|
|
833
|
+
path: this.pathname
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}, 0);
|
|
837
|
+
}
|
|
824
838
|
}
|
|
825
839
|
|
|
826
840
|
const createStampId$1 = runtime.incrementId();
|
|
@@ -834,8 +848,8 @@ const launchStampId$1 = createStampId$1();
|
|
|
834
848
|
* - 不支持路由动画
|
|
835
849
|
*/
|
|
836
850
|
function createMultiRouter(history, app, config, framework) {
|
|
837
|
-
var _a, _b, _c, _d, _e, _f;
|
|
838
851
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
852
|
+
var _a, _b, _c, _d, _e, _f;
|
|
839
853
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
840
854
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
841
855
|
}
|
|
@@ -843,7 +857,7 @@ function createMultiRouter(history, app, config, framework) {
|
|
|
843
857
|
RouterConfig.config = config;
|
|
844
858
|
const handler = new MultiPageHandler(config, history);
|
|
845
859
|
const launchParam = {
|
|
846
|
-
path: config.pageName,
|
|
860
|
+
path: config.pageName, // 多页面模式没新开一个页面相当于重启,所以直接使用当前页面路径
|
|
847
861
|
query: handler.getQuery(launchStampId$1),
|
|
848
862
|
scene: 0,
|
|
849
863
|
shareTicket: '',
|
|
@@ -1510,11 +1524,11 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1510
1524
|
runtime.eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
1511
1525
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
1512
1526
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
1513
|
-
const render = (
|
|
1514
|
-
var
|
|
1527
|
+
const render = (_c) => tslib.__awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
1528
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1515
1529
|
// Note: 由于下面有异步加载操作 先不要在这里去设置 handler.pathname
|
|
1516
1530
|
const currentPathname = decodeURI(location.pathname);
|
|
1517
|
-
if ((
|
|
1531
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
1518
1532
|
window.scrollTo(0, 0);
|
|
1519
1533
|
runtime.eventCenter.trigger('__taroRouterChange', {
|
|
1520
1534
|
toLocation: {
|
|
@@ -1538,7 +1552,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1538
1552
|
path: currentPathname,
|
|
1539
1553
|
query: handler.getQuery(createStampId()),
|
|
1540
1554
|
};
|
|
1541
|
-
(
|
|
1555
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
1542
1556
|
runtime.eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
1543
1557
|
}
|
|
1544
1558
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -1555,10 +1569,10 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1555
1569
|
// context.pathname 在 universal-router 被处理过了,是发起资源请求的时候传入的 pathname,即 await router.resolve(routerPath) 这个 routerPath
|
|
1556
1570
|
handler.pathname = context.pathname;
|
|
1557
1571
|
const { pathname, pageConfig } = handler;
|
|
1558
|
-
let enablePullDownRefresh = ((
|
|
1559
|
-
let navigationStyle = ((
|
|
1560
|
-
let navigationBarTextStyle = ((
|
|
1561
|
-
let navigationBarBackgroundColor = ((
|
|
1572
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
1573
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
1574
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
1575
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
1562
1576
|
if (pageConfig) {
|
|
1563
1577
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
1564
1578
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
@@ -1575,7 +1589,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1575
1589
|
}
|
|
1576
1590
|
runtime.eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
1577
1591
|
const currentPage = runtime.Current.page;
|
|
1578
|
-
const methodName = (
|
|
1592
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
1579
1593
|
const cacheTabs = stacks.getTabs();
|
|
1580
1594
|
let shouldLoad = false;
|
|
1581
1595
|
stacks.method = '';
|
|
@@ -1642,7 +1656,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1642
1656
|
shouldLoad = true;
|
|
1643
1657
|
}
|
|
1644
1658
|
if (shouldLoad || stacks.length < 1) {
|
|
1645
|
-
const el = (
|
|
1659
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
1646
1660
|
const loadConfig = Object.assign({}, pageConfig);
|
|
1647
1661
|
const stacksIndex = stacks.length;
|
|
1648
1662
|
delete loadConfig['path'];
|
|
@@ -1698,7 +1712,7 @@ function handleAppMount(config, _, appId = config.appId || 'app') {
|
|
|
1698
1712
|
app.id = appId;
|
|
1699
1713
|
isPosition = false;
|
|
1700
1714
|
}
|
|
1701
|
-
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);
|
|
1702
1716
|
app.classList.add('taro_router');
|
|
1703
1717
|
if (!isPosition)
|
|
1704
1718
|
appWrapper.appendChild(app);
|
|
@@ -1712,7 +1726,7 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
|
|
|
1712
1726
|
app.id = appId;
|
|
1713
1727
|
isPosition = false;
|
|
1714
1728
|
}
|
|
1715
|
-
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);
|
|
1716
1730
|
app.classList.add('taro_router');
|
|
1717
1731
|
const container = document.createElement('div');
|
|
1718
1732
|
container.classList.add('taro-tabbar__container');
|
|
@@ -1731,11 +1745,11 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
|
|
|
1731
1745
|
initNavigationBar(config, container);
|
|
1732
1746
|
}
|
|
1733
1747
|
|
|
1734
|
-
Object.defineProperty(exports,
|
|
1748
|
+
Object.defineProperty(exports, "createBrowserHistory", {
|
|
1735
1749
|
enumerable: true,
|
|
1736
1750
|
get: function () { return history.createBrowserHistory; }
|
|
1737
1751
|
});
|
|
1738
|
-
Object.defineProperty(exports,
|
|
1752
|
+
Object.defineProperty(exports, "createHashHistory", {
|
|
1739
1753
|
enumerable: true,
|
|
1740
1754
|
get: function () { return history.createHashHistory; }
|
|
1741
1755
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { History } from
|
|
2
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export { handleAppMount, handleAppMountWithTabbar };
|
|
1
|
+
import type { History } from 'history';
|
|
2
|
+
import type { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
3
|
+
export * from './api';
|
|
4
|
+
export * from './history';
|
|
5
|
+
export { createMultiRouter } from './router/mpa';
|
|
6
|
+
export { createRouter } from './router/spa';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
export declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
9
|
+
export declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -224,7 +224,7 @@ function initNavigationBar(config, container) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
function initTabbar(config, history) {
|
|
227
|
-
if (config.tabBar == null) {
|
|
227
|
+
if (config.tabBar == null || config.tabBar.custom) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
// TODO: custom-tab-bar
|
|
@@ -793,6 +793,7 @@ class MultiPageHandler {
|
|
|
793
793
|
this.onReady(page, true);
|
|
794
794
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
795
795
|
this.bindPageEvents(page, pageConfig);
|
|
796
|
+
this.triggerRouterChange();
|
|
796
797
|
});
|
|
797
798
|
}
|
|
798
799
|
getPageContainer(page) {
|
|
@@ -820,6 +821,19 @@ class MultiPageHandler {
|
|
|
820
821
|
bindPageScroll(page, scrollEl, distance);
|
|
821
822
|
bindPageResize(page);
|
|
822
823
|
}
|
|
824
|
+
triggerRouterChange() {
|
|
825
|
+
/**
|
|
826
|
+
* @tarojs/runtime 中生命周期跑在 promise 中,所以这里需要 setTimeout 延迟事件调用
|
|
827
|
+
* TODO 考虑将生命周期返回 Promise,用于处理相关事件调用顺序
|
|
828
|
+
*/
|
|
829
|
+
setTimeout(() => {
|
|
830
|
+
eventCenter.trigger('__afterTaroRouterChange', {
|
|
831
|
+
toLocation: {
|
|
832
|
+
path: this.pathname
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
}, 0);
|
|
836
|
+
}
|
|
823
837
|
}
|
|
824
838
|
|
|
825
839
|
const createStampId$1 = incrementId();
|
|
@@ -833,8 +847,8 @@ const launchStampId$1 = createStampId$1();
|
|
|
833
847
|
* - 不支持路由动画
|
|
834
848
|
*/
|
|
835
849
|
function createMultiRouter(history, app, config, framework) {
|
|
836
|
-
var _a, _b, _c, _d, _e, _f;
|
|
837
850
|
return __awaiter(this, void 0, void 0, function* () {
|
|
851
|
+
var _a, _b, _c, _d, _e, _f;
|
|
838
852
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
839
853
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
840
854
|
}
|
|
@@ -842,7 +856,7 @@ function createMultiRouter(history, app, config, framework) {
|
|
|
842
856
|
RouterConfig.config = config;
|
|
843
857
|
const handler = new MultiPageHandler(config, history);
|
|
844
858
|
const launchParam = {
|
|
845
|
-
path: config.pageName,
|
|
859
|
+
path: config.pageName, // 多页面模式没新开一个页面相当于重启,所以直接使用当前页面路径
|
|
846
860
|
query: handler.getQuery(launchStampId$1),
|
|
847
861
|
scene: 0,
|
|
848
862
|
shareTicket: '',
|
|
@@ -1509,11 +1523,11 @@ function createRouter(history, app, config, framework) {
|
|
|
1509
1523
|
eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
1510
1524
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
1511
1525
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
1512
|
-
const render = (
|
|
1513
|
-
var
|
|
1526
|
+
const render = (_c) => __awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
1527
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1514
1528
|
// Note: 由于下面有异步加载操作 先不要在这里去设置 handler.pathname
|
|
1515
1529
|
const currentPathname = decodeURI(location.pathname);
|
|
1516
|
-
if ((
|
|
1530
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
1517
1531
|
window.scrollTo(0, 0);
|
|
1518
1532
|
eventCenter.trigger('__taroRouterChange', {
|
|
1519
1533
|
toLocation: {
|
|
@@ -1537,7 +1551,7 @@ function createRouter(history, app, config, framework) {
|
|
|
1537
1551
|
path: currentPathname,
|
|
1538
1552
|
query: handler.getQuery(createStampId()),
|
|
1539
1553
|
};
|
|
1540
|
-
(
|
|
1554
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
1541
1555
|
eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
1542
1556
|
}
|
|
1543
1557
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -1554,10 +1568,10 @@ function createRouter(history, app, config, framework) {
|
|
|
1554
1568
|
// context.pathname 在 universal-router 被处理过了,是发起资源请求的时候传入的 pathname,即 await router.resolve(routerPath) 这个 routerPath
|
|
1555
1569
|
handler.pathname = context.pathname;
|
|
1556
1570
|
const { pathname, pageConfig } = handler;
|
|
1557
|
-
let enablePullDownRefresh = ((
|
|
1558
|
-
let navigationStyle = ((
|
|
1559
|
-
let navigationBarTextStyle = ((
|
|
1560
|
-
let navigationBarBackgroundColor = ((
|
|
1571
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
1572
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
1573
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
1574
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
1561
1575
|
if (pageConfig) {
|
|
1562
1576
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
1563
1577
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
@@ -1574,7 +1588,7 @@ function createRouter(history, app, config, framework) {
|
|
|
1574
1588
|
}
|
|
1575
1589
|
eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
1576
1590
|
const currentPage = Current.page;
|
|
1577
|
-
const methodName = (
|
|
1591
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
1578
1592
|
const cacheTabs = stacks.getTabs();
|
|
1579
1593
|
let shouldLoad = false;
|
|
1580
1594
|
stacks.method = '';
|
|
@@ -1641,7 +1655,7 @@ function createRouter(history, app, config, framework) {
|
|
|
1641
1655
|
shouldLoad = true;
|
|
1642
1656
|
}
|
|
1643
1657
|
if (shouldLoad || stacks.length < 1) {
|
|
1644
|
-
const el = (
|
|
1658
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
1645
1659
|
const loadConfig = Object.assign({}, pageConfig);
|
|
1646
1660
|
const stacksIndex = stacks.length;
|
|
1647
1661
|
delete loadConfig['path'];
|
|
@@ -1697,7 +1711,7 @@ function handleAppMount(config, _, appId = config.appId || 'app') {
|
|
|
1697
1711
|
app.id = appId;
|
|
1698
1712
|
isPosition = false;
|
|
1699
1713
|
}
|
|
1700
|
-
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);
|
|
1701
1715
|
app.classList.add('taro_router');
|
|
1702
1716
|
if (!isPosition)
|
|
1703
1717
|
appWrapper.appendChild(app);
|
|
@@ -1711,7 +1725,7 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
|
|
|
1711
1725
|
app.id = appId;
|
|
1712
1726
|
isPosition = false;
|
|
1713
1727
|
}
|
|
1714
|
-
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);
|
|
1715
1729
|
app.classList.add('taro_router');
|
|
1716
1730
|
const container = document.createElement('div');
|
|
1717
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');
|
package/dist/navigationBar.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
2
|
-
declare function initNavigationBar(config: SpaRouterConfig | MpaRouterConfig, container: HTMLElement): void;
|
|
3
|
-
export { initNavigationBar };
|
|
1
|
+
import type { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
2
|
+
export declare function initNavigationBar(config: SpaRouterConfig | MpaRouterConfig, container: HTMLElement): void;
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../../types/router';
|
|
2
|
-
declare class RouterConfig {
|
|
1
|
+
import type { MpaRouterConfig, SpaRouterConfig } from '../../types/router';
|
|
2
|
+
export declare class RouterConfig {
|
|
3
3
|
private static __config;
|
|
4
4
|
static set config(e: SpaRouterConfig | MpaRouterConfig);
|
|
5
5
|
static get config(): SpaRouterConfig | MpaRouterConfig;
|
|
6
6
|
static get pages(): string[];
|
|
7
|
-
static get router(): import("
|
|
7
|
+
static get router(): import("../../types/router").Router;
|
|
8
8
|
static get mode(): "hash" | "browser" | "multi";
|
|
9
9
|
static get customRoutes(): Record<string, string | string[]>;
|
|
10
|
-
// 这个方法不考虑 basename 和 customRoutes,只判断原始的 url 是否在 pages 中
|
|
11
10
|
static isPage(url?: string): boolean;
|
|
12
11
|
}
|
|
13
|
-
export { RouterConfig };
|
package/dist/router/mpa.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AppInstance } from '@tarojs/runtime';
|
|
2
|
-
import { History } from
|
|
3
|
-
import { MpaRouterConfig } from '../../types/router';
|
|
1
|
+
import type { AppInstance } from '@tarojs/runtime';
|
|
2
|
+
import type { History } from 'history';
|
|
3
|
+
import type { MpaRouterConfig } from '../../types/router';
|
|
4
4
|
/** Note: 关于多页面应用
|
|
5
5
|
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
6
6
|
* - app.onPageNotFound 事件不支持
|
|
@@ -8,5 +8,4 @@ import { MpaRouterConfig } from '../../types/router';
|
|
|
8
8
|
* - TabBar 会多次加载
|
|
9
9
|
* - 不支持路由动画
|
|
10
10
|
*/
|
|
11
|
-
declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig, framework?: string): Promise<void>;
|
|
12
|
-
export { createMultiRouter };
|
|
11
|
+
export declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig, framework?: string): Promise<void>;
|
package/dist/router/mpa.js
CHANGED
|
@@ -16,8 +16,8 @@ const launchStampId = createStampId();
|
|
|
16
16
|
* - 不支持路由动画
|
|
17
17
|
*/
|
|
18
18
|
function createMultiRouter(history, app, config, framework) {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
21
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
22
22
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ function createMultiRouter(history, app, config, framework) {
|
|
|
25
25
|
RouterConfig.config = config;
|
|
26
26
|
const handler = new MultiPageHandler(config, history);
|
|
27
27
|
const launchParam = {
|
|
28
|
-
path: config.pageName,
|
|
28
|
+
path: config.pageName, // 多页面模式没新开一个页面相当于重启,所以直接使用当前页面路径
|
|
29
29
|
query: handler.getQuery(launchStampId),
|
|
30
30
|
scene: 0,
|
|
31
31
|
shareTicket: '',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
2
|
-
import { PageConfig } from '@tarojs/taro';
|
|
3
|
-
import { History } from
|
|
4
|
-
import { MpaRouterConfig, Route } from '../../types/router';
|
|
5
|
-
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
|
+
import type { PageConfig } from '@tarojs/taro';
|
|
3
|
+
import type { History } from 'history';
|
|
4
|
+
import type { MpaRouterConfig, Route } from '../../types/router';
|
|
5
|
+
export default class MultiPageHandler {
|
|
6
6
|
history: History;
|
|
7
7
|
protected config: MpaRouterConfig;
|
|
8
8
|
constructor(config: MpaRouterConfig, history: History);
|
|
9
9
|
get appId(): string;
|
|
10
|
-
get router(): import("
|
|
10
|
+
get router(): import("../../types/router").Router;
|
|
11
11
|
get routerMode(): "hash" | "browser" | "multi";
|
|
12
12
|
get customRoutes(): Record<string, string | string[]>;
|
|
13
13
|
get tabBarList(): import("@tarojs/taro").TabBarItem[];
|
|
@@ -27,7 +27,7 @@ declare class MultiPageHandler {
|
|
|
27
27
|
onReady(page: PageInstance, onLoad?: boolean): void;
|
|
28
28
|
load(page: PageInstance, pageConfig?: Route): void;
|
|
29
29
|
getPageContainer(page?: PageInstance | null): HTMLElement | null;
|
|
30
|
-
getScrollingElement(page?: PageInstance | null):
|
|
30
|
+
getScrollingElement(page?: PageInstance | null): (Window & typeof globalThis) | HTMLElement;
|
|
31
31
|
bindPageEvents(page: PageInstance, config?: Partial<PageConfig>): void;
|
|
32
|
+
triggerRouterChange(): void;
|
|
32
33
|
}
|
|
33
|
-
export { MultiPageHandler as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addLeadingSlash, stripBasename, Current } from '@tarojs/runtime';
|
|
1
|
+
import { addLeadingSlash, stripBasename, Current, eventCenter } from '@tarojs/runtime';
|
|
2
2
|
import queryString from 'query-string';
|
|
3
3
|
import { bindPageResize } from '../events/resize.js';
|
|
4
4
|
import { bindPageScroll } from '../events/scroll.js';
|
|
@@ -106,6 +106,7 @@ class MultiPageHandler {
|
|
|
106
106
|
this.onReady(page, true);
|
|
107
107
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
108
108
|
this.bindPageEvents(page, pageConfig);
|
|
109
|
+
this.triggerRouterChange();
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
getPageContainer(page) {
|
|
@@ -133,6 +134,19 @@ class MultiPageHandler {
|
|
|
133
134
|
bindPageScroll(page, scrollEl, distance);
|
|
134
135
|
bindPageResize(page);
|
|
135
136
|
}
|
|
137
|
+
triggerRouterChange() {
|
|
138
|
+
/**
|
|
139
|
+
* @tarojs/runtime 中生命周期跑在 promise 中,所以这里需要 setTimeout 延迟事件调用
|
|
140
|
+
* TODO 考虑将生命周期返回 Promise,用于处理相关事件调用顺序
|
|
141
|
+
*/
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
eventCenter.trigger('__afterTaroRouterChange', {
|
|
144
|
+
toLocation: {
|
|
145
|
+
path: this.pathname
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}, 0);
|
|
149
|
+
}
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
export { MultiPageHandler as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PageHandler from
|
|
1
|
+
import type PageHandler from './page';
|
|
2
2
|
interface NavigationBarCache {
|
|
3
3
|
backgroundColor?: string;
|
|
4
4
|
fontColor?: string;
|
|
@@ -6,7 +6,7 @@ interface NavigationBarCache {
|
|
|
6
6
|
show?: boolean;
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
export default class NavigationBarHandler {
|
|
10
10
|
pageContext: PageHandler;
|
|
11
11
|
navigationBarElement: HTMLElement;
|
|
12
12
|
cache: Record<string, NavigationBarCache>;
|
|
@@ -33,4 +33,4 @@ declare class NavigationBarHandler {
|
|
|
33
33
|
fnBtnToggleToNone(): void;
|
|
34
34
|
setNavigationBarVisible(show?: any): void;
|
|
35
35
|
}
|
|
36
|
-
export {
|
|
36
|
+
export {};
|
package/dist/router/page.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import NavigationBarHandler from
|
|
2
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
3
|
-
import { PageConfig, RouterAnimate } from '@tarojs/taro';
|
|
4
|
-
import { History } from
|
|
5
|
-
import { Route, SpaRouterConfig } from '../../types/router';
|
|
6
|
-
|
|
1
|
+
import NavigationBarHandler from './navigation-bar';
|
|
2
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
3
|
+
import type { PageConfig, RouterAnimate } from '@tarojs/taro';
|
|
4
|
+
import type { History } from 'history';
|
|
5
|
+
import type { Route, SpaRouterConfig } from '../../types/router';
|
|
6
|
+
export default class PageHandler {
|
|
7
7
|
history: History;
|
|
8
8
|
config: SpaRouterConfig;
|
|
9
9
|
protected readonly defaultAnimation: RouterAnimate;
|
|
@@ -17,7 +17,7 @@ declare class PageHandler {
|
|
|
17
17
|
constructor(config: SpaRouterConfig, history: History);
|
|
18
18
|
get currentPage(): string;
|
|
19
19
|
get appId(): string;
|
|
20
|
-
get router(): import("
|
|
20
|
+
get router(): import("../../types/router").Router;
|
|
21
21
|
get routerMode(): "hash" | "browser" | "multi";
|
|
22
22
|
get customRoutes(): Record<string, string | string[]>;
|
|
23
23
|
get routes(): Route[];
|
|
@@ -47,8 +47,7 @@ declare class PageHandler {
|
|
|
47
47
|
hide(page?: PageInstance | null, animation?: boolean): void;
|
|
48
48
|
addAnimation(pageEl?: HTMLElement | null, first?: boolean): void;
|
|
49
49
|
getPageContainer(page?: PageInstance | null): HTMLElement | null;
|
|
50
|
-
getScrollingElement(page?: PageInstance | null):
|
|
50
|
+
getScrollingElement(page?: PageInstance | null): (Window & typeof globalThis) | HTMLElement;
|
|
51
51
|
bindPageEvents(page: PageInstance, config?: Partial<PageConfig>): void;
|
|
52
52
|
triggerRouterChange(): void;
|
|
53
53
|
}
|
|
54
|
-
export { PageHandler as default };
|
package/dist/router/spa.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AppInstance } from '@tarojs/runtime';
|
|
2
|
-
import { History } from
|
|
3
|
-
import { SpaRouterConfig } from '../../types/router';
|
|
4
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig, framework?: string): () => void;
|
|
5
|
-
export { createRouter };
|
|
1
|
+
import type { AppInstance } from '@tarojs/runtime';
|
|
2
|
+
import type { History } from 'history';
|
|
3
|
+
import type { SpaRouterConfig } from '../../types/router';
|
|
4
|
+
export declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig, framework?: string): () => void;
|
package/dist/router/spa.js
CHANGED
|
@@ -42,11 +42,11 @@ function createRouter(history, app, config, framework) {
|
|
|
42
42
|
eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
43
43
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
44
44
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
45
|
-
const render = (
|
|
46
|
-
var
|
|
45
|
+
const render = (_c) => __awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
46
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
47
47
|
// Note: 由于下面有异步加载操作 先不要在这里去设置 handler.pathname
|
|
48
48
|
const currentPathname = decodeURI(location.pathname);
|
|
49
|
-
if ((
|
|
49
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
50
50
|
window.scrollTo(0, 0);
|
|
51
51
|
eventCenter.trigger('__taroRouterChange', {
|
|
52
52
|
toLocation: {
|
|
@@ -70,7 +70,7 @@ function createRouter(history, app, config, framework) {
|
|
|
70
70
|
path: currentPathname,
|
|
71
71
|
query: handler.getQuery(createStampId()),
|
|
72
72
|
};
|
|
73
|
-
(
|
|
73
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
74
74
|
eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
75
75
|
}
|
|
76
76
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -87,10 +87,10 @@ function createRouter(history, app, config, framework) {
|
|
|
87
87
|
// context.pathname 在 universal-router 被处理过了,是发起资源请求的时候传入的 pathname,即 await router.resolve(routerPath) 这个 routerPath
|
|
88
88
|
handler.pathname = context.pathname;
|
|
89
89
|
const { pathname, pageConfig } = handler;
|
|
90
|
-
let enablePullDownRefresh = ((
|
|
91
|
-
let navigationStyle = ((
|
|
92
|
-
let navigationBarTextStyle = ((
|
|
93
|
-
let navigationBarBackgroundColor = ((
|
|
90
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
91
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
92
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
93
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
94
94
|
if (pageConfig) {
|
|
95
95
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
96
96
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
@@ -107,7 +107,7 @@ function createRouter(history, app, config, framework) {
|
|
|
107
107
|
}
|
|
108
108
|
eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
109
109
|
const currentPage = Current.page;
|
|
110
|
-
const methodName = (
|
|
110
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
111
111
|
const cacheTabs = stacks.getTabs();
|
|
112
112
|
let shouldLoad = false;
|
|
113
113
|
stacks.method = '';
|
|
@@ -174,7 +174,7 @@ function createRouter(history, app, config, framework) {
|
|
|
174
174
|
shouldLoad = true;
|
|
175
175
|
}
|
|
176
176
|
if (shouldLoad || stacks.length < 1) {
|
|
177
|
-
const el = (
|
|
177
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
178
178
|
const loadConfig = Object.assign({}, pageConfig);
|
|
179
179
|
const stacksIndex = stacks.length;
|
|
180
180
|
delete loadConfig['path'];
|
package/dist/router/stack.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
2
|
declare class Stacks {
|
|
3
3
|
stacks: PageInstance[];
|
|
4
4
|
backDelta: number;
|
|
@@ -23,4 +23,4 @@ declare class Stacks {
|
|
|
23
23
|
removeTab(path: string): void;
|
|
24
24
|
}
|
|
25
25
|
declare const stacks: Stacks;
|
|
26
|
-
export
|
|
26
|
+
export default stacks;
|
package/dist/style.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 插入页面动画需要的样式
|
|
3
3
|
*/
|
|
4
|
-
declare function loadAnimateStyle(ms?: number): void;
|
|
4
|
+
export declare function loadAnimateStyle(ms?: number): void;
|
|
5
5
|
/**
|
|
6
6
|
* 插入路由相关样式
|
|
7
7
|
*/
|
|
8
|
-
declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean, enhanceAnimation?: boolean): void;
|
|
8
|
+
export declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean, enhanceAnimation?: boolean): void;
|
|
9
9
|
/**
|
|
10
10
|
* 插入导航栏相关的样式
|
|
11
11
|
*/
|
|
12
|
-
declare function loadNavigationBarStyle(): void;
|
|
13
|
-
declare function addStyle(css: any): void;
|
|
14
|
-
export { loadAnimateStyle, loadRouterStyle, loadNavigationBarStyle, addStyle };
|
|
12
|
+
export declare function loadNavigationBarStyle(): void;
|
|
13
|
+
export declare function addStyle(css: any): void;
|
package/dist/tabbar.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { AppConfig } from '@tarojs/taro';
|
|
2
|
-
import { History } from
|
|
3
|
-
declare function initTabbar(config: AppConfig, history: History): void;
|
|
4
|
-
export { initTabbar };
|
|
2
|
+
import type { History } from 'history';
|
|
3
|
+
export declare function initTabbar(config: AppConfig, history: History): void;
|
package/dist/tabbar.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineCustomElementTaroTabbar } from '@tarojs/components/dist/component
|
|
|
2
2
|
import { initTabBarApis } from '@tarojs/taro';
|
|
3
3
|
|
|
4
4
|
function initTabbar(config, history) {
|
|
5
|
-
if (config.tabBar == null) {
|
|
5
|
+
if (config.tabBar == null || config.tabBar.custom) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
// TODO: custom-tab-bar
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ declare class RoutesAlias {
|
|
|
6
6
|
getAlias: (url?: string) => string;
|
|
7
7
|
getAll: (url?: string) => string[];
|
|
8
8
|
}
|
|
9
|
-
declare const routesAlias: RoutesAlias;
|
|
10
|
-
export
|
|
11
|
-
export * from "./navigate.js";
|
|
9
|
+
export declare const routesAlias: RoutesAlias;
|
|
10
|
+
export * from './navigate';
|
package/dist/utils/navigate.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
declare const isWeixin: () => boolean;
|
|
2
|
-
declare const isDingTalk: () => boolean;
|
|
3
|
-
declare function setMpaTitle(title: string): void;
|
|
4
|
-
declare function setTitle(title: string): void;
|
|
5
|
-
declare function setNavigationBarStyle(option: {
|
|
1
|
+
export declare const isWeixin: () => boolean;
|
|
2
|
+
export declare const isDingTalk: () => boolean;
|
|
3
|
+
export declare function setMpaTitle(title: string): void;
|
|
4
|
+
export declare function setTitle(title: string): void;
|
|
5
|
+
export declare function setNavigationBarStyle(option: {
|
|
6
6
|
backgroundColor: string;
|
|
7
7
|
frontColor: string;
|
|
8
8
|
}): void;
|
|
9
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
10
|
-
export { isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading };
|
|
9
|
+
export declare function setNavigationBarLoading(loading: boolean): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/router",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3-alpah.2",
|
|
4
4
|
"description": "Taro-router",
|
|
5
|
+
"author": "O2Team",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"browser": "dist/index.js",
|
|
6
8
|
"main:h5": "dist/index.esm.js",
|
|
7
9
|
"main": "dist/index.js",
|
|
@@ -20,47 +22,34 @@
|
|
|
20
22
|
"keywords": [
|
|
21
23
|
"router"
|
|
22
24
|
],
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">= 18"
|
|
27
|
+
},
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"dingtalk-jsapi": "~2.15.2",
|
|
27
|
-
"history": "^5.
|
|
30
|
+
"history": "^5.3.0",
|
|
28
31
|
"mobile-detect": "^1.4.2",
|
|
29
|
-
"query-string": "^
|
|
32
|
+
"query-string": "^9.0.0",
|
|
30
33
|
"tslib": "^2.6.2",
|
|
31
|
-
"universal-router": "^
|
|
34
|
+
"universal-router": "^9.2.0"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"jest": "^29.3.1",
|
|
39
|
-
"jest-cli": "^29.3.1",
|
|
40
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
41
|
-
"jsdom": "^21.1.0",
|
|
42
|
-
"rollup": "^3.8.1",
|
|
43
|
-
"rollup-plugin-node-externals": "^5.0.0",
|
|
44
|
-
"rollup-plugin-ts": "^3.0.2",
|
|
45
|
-
"ts-jest": "^29.0.5",
|
|
46
|
-
"typescript": "^4.7.4",
|
|
47
|
-
"@tarojs/taro": "4.0.1",
|
|
48
|
-
"@tarojs/shared": "4.0.1",
|
|
49
|
-
"@tarojs/runtime": "4.0.1"
|
|
37
|
+
"@tarojs/components": "4.0.3-alpah.2",
|
|
38
|
+
"@tarojs/runtime": "4.0.3-alpah.2",
|
|
39
|
+
"@tarojs/shared": "4.0.3-alpah.2",
|
|
40
|
+
"@tarojs/taro": "4.0.3-alpah.2"
|
|
50
41
|
},
|
|
51
42
|
"peerDependencies": {
|
|
52
|
-
"@tarojs/runtime": "4.0.
|
|
53
|
-
"@tarojs/taro": "4.0.
|
|
54
|
-
"@tarojs/shared": "4.0.
|
|
43
|
+
"@tarojs/runtime": "4.0.3-alpah.2",
|
|
44
|
+
"@tarojs/taro": "4.0.3-alpah.2",
|
|
45
|
+
"@tarojs/shared": "4.0.3-alpah.2"
|
|
55
46
|
},
|
|
56
47
|
"scripts": {
|
|
48
|
+
"prod": "pnpm run build",
|
|
57
49
|
"prebuild": "pnpm run clean",
|
|
58
50
|
"build": "pnpm run rollup --environment NODE_ENV:production",
|
|
59
|
-
"clean": "rimraf ./dist",
|
|
51
|
+
"clean": "rimraf --impl=move-remove ./dist",
|
|
60
52
|
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
|
|
61
|
-
"rollup": "rollup --config rollup.config.
|
|
62
|
-
"test": "cross-env NODE_ENV=jest jest",
|
|
63
|
-
"test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent",
|
|
64
|
-
"test:dev": "cross-env NODE_ENV=jest jest --watch"
|
|
53
|
+
"rollup": "rollup --config rollup.config.mts --configPlugin typescript"
|
|
65
54
|
}
|
|
66
55
|
}
|
package/dist/index.cjs.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Action, createBrowserHistory, createHashHistory, Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from "history";
|
|
2
|
-
import { IH5RouterConfig } from "@tarojs/taro/types/compile";
|
|
3
|
-
import { StateEvent } from "../types/history";
|
|
4
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
5
|
-
import Taro from "@tarojs/taro";
|
|
6
|
-
import { AppInstance } from "@tarojs/runtime";
|
|
7
|
-
import { MpaRouterConfig as MpaRouterConfig$0 } from "../../types/router";
|
|
8
|
-
import { SpaRouterConfig as SpaRouterConfig$0 } from "../../types/router";
|
|
9
|
-
declare let history: History;
|
|
10
|
-
declare class MpaHistory implements History {
|
|
11
|
-
action: Action;
|
|
12
|
-
get location(): Location;
|
|
13
|
-
createHref(_to: To): string;
|
|
14
|
-
parseUrl(to: Partial<Path>): string;
|
|
15
|
-
push(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
16
|
-
replace(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
17
|
-
go(delta: number): void;
|
|
18
|
-
back: () => void;
|
|
19
|
-
forward: () => void;
|
|
20
|
-
listen(listener: Listener): () => void;
|
|
21
|
-
block(_blocker: Blocker): () => void;
|
|
22
|
-
pushState: globalThis.History["pushState"];
|
|
23
|
-
replaceState: globalThis.History["replaceState"];
|
|
24
|
-
eventState(action: Required<StateEvent>["action"]): (data: any, unused: string, url?: string | URL | null) => any;
|
|
25
|
-
}
|
|
26
|
-
declare function setHistory(h: History, base?: string): void;
|
|
27
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
28
|
-
declare function setHistoryMode(mode?: IH5RouterConfig["mode"], base?: string): void;
|
|
29
|
-
declare function prependBasename(url?: string): string;
|
|
30
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
31
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
32
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
33
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
34
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
35
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
36
|
-
// TODO 支持多路由 (APP 生命周期仅触发一次)
|
|
37
|
-
/** Note: 关于多页面应用
|
|
38
|
-
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
39
|
-
* - app.onPageNotFound 事件不支持
|
|
40
|
-
* - 应用生命周期可能多次触发
|
|
41
|
-
* - TabBar 会多次加载
|
|
42
|
-
* - 不支持路由动画
|
|
43
|
-
*/
|
|
44
|
-
declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig$0, framework?: string): Promise<void>;
|
|
45
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig$0, framework?: string): () => void;
|
|
46
|
-
declare class RoutesAlias {
|
|
47
|
-
conf: Array<string[]>;
|
|
48
|
-
set(customRoutes?: Record<string, string | string[]>): void;
|
|
49
|
-
getConfig: (url?: string) => string[];
|
|
50
|
-
getOrigin: (url?: string) => string;
|
|
51
|
-
getAlias: (url?: string) => string;
|
|
52
|
-
getAll: (url?: string) => string[];
|
|
53
|
-
}
|
|
54
|
-
declare const routesAlias: RoutesAlias;
|
|
55
|
-
declare const isWeixin: () => boolean;
|
|
56
|
-
declare const isDingTalk: () => boolean;
|
|
57
|
-
declare function setMpaTitle(title: string): void;
|
|
58
|
-
declare function setTitle(title: string): void;
|
|
59
|
-
declare function setNavigationBarStyle(option: {
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
frontColor: string;
|
|
62
|
-
}): void;
|
|
63
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
64
|
-
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
65
|
-
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
66
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading, handleAppMount, handleAppMountWithTabbar };
|
package/dist/index.esm.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Action, createBrowserHistory, createHashHistory, Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from "history";
|
|
2
|
-
import { IH5RouterConfig } from "@tarojs/taro/types/compile";
|
|
3
|
-
import { StateEvent } from "../types/history";
|
|
4
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
5
|
-
import Taro from "@tarojs/taro";
|
|
6
|
-
import { AppInstance } from "@tarojs/runtime";
|
|
7
|
-
import { MpaRouterConfig as MpaRouterConfig$0 } from "../../types/router";
|
|
8
|
-
import { SpaRouterConfig as SpaRouterConfig$0 } from "../../types/router";
|
|
9
|
-
declare let history: History;
|
|
10
|
-
declare class MpaHistory implements History {
|
|
11
|
-
action: Action;
|
|
12
|
-
get location(): Location;
|
|
13
|
-
createHref(_to: To): string;
|
|
14
|
-
parseUrl(to: Partial<Path>): string;
|
|
15
|
-
push(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
16
|
-
replace(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
17
|
-
go(delta: number): void;
|
|
18
|
-
back: () => void;
|
|
19
|
-
forward: () => void;
|
|
20
|
-
listen(listener: Listener): () => void;
|
|
21
|
-
block(_blocker: Blocker): () => void;
|
|
22
|
-
pushState: globalThis.History["pushState"];
|
|
23
|
-
replaceState: globalThis.History["replaceState"];
|
|
24
|
-
eventState(action: Required<StateEvent>["action"]): (data: any, unused: string, url?: string | URL | null) => any;
|
|
25
|
-
}
|
|
26
|
-
declare function setHistory(h: History, base?: string): void;
|
|
27
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
28
|
-
declare function setHistoryMode(mode?: IH5RouterConfig["mode"], base?: string): void;
|
|
29
|
-
declare function prependBasename(url?: string): string;
|
|
30
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
31
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
32
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
33
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
34
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
35
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
36
|
-
// TODO 支持多路由 (APP 生命周期仅触发一次)
|
|
37
|
-
/** Note: 关于多页面应用
|
|
38
|
-
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
39
|
-
* - app.onPageNotFound 事件不支持
|
|
40
|
-
* - 应用生命周期可能多次触发
|
|
41
|
-
* - TabBar 会多次加载
|
|
42
|
-
* - 不支持路由动画
|
|
43
|
-
*/
|
|
44
|
-
declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig$0, framework?: string): Promise<void>;
|
|
45
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig$0, framework?: string): () => void;
|
|
46
|
-
declare class RoutesAlias {
|
|
47
|
-
conf: Array<string[]>;
|
|
48
|
-
set(customRoutes?: Record<string, string | string[]>): void;
|
|
49
|
-
getConfig: (url?: string) => string[];
|
|
50
|
-
getOrigin: (url?: string) => string;
|
|
51
|
-
getAlias: (url?: string) => string;
|
|
52
|
-
getAll: (url?: string) => string[];
|
|
53
|
-
}
|
|
54
|
-
declare const routesAlias: RoutesAlias;
|
|
55
|
-
declare const isWeixin: () => boolean;
|
|
56
|
-
declare const isDingTalk: () => boolean;
|
|
57
|
-
declare function setMpaTitle(title: string): void;
|
|
58
|
-
declare function setTitle(title: string): void;
|
|
59
|
-
declare function setNavigationBarStyle(option: {
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
frontColor: string;
|
|
62
|
-
}): void;
|
|
63
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
64
|
-
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
65
|
-
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
66
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading, handleAppMount, handleAppMountWithTabbar };
|