@tarojs/router 4.0.0-beta.1 → 4.0.0-beta.11
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 +14 -0
- package/dist/api.d.ts +7 -6
- package/dist/api.js +36 -20
- package/dist/events/resize.d.ts +2 -1
- package/dist/events/resize.js +15 -7
- package/dist/events/scroll.d.ts +2 -1
- package/dist/events/scroll.js +4 -1
- package/dist/history.d.ts +24 -5
- package/dist/history.js +18 -7
- package/dist/index.cjs.d.ts +49 -6
- package/dist/index.cjs.js +552 -235
- package/dist/index.d.ts +10 -4
- package/dist/index.esm.d.ts +49 -6
- package/dist/index.esm.js +511 -205
- package/dist/index.js +52 -4
- package/dist/navigationBar.d.ts +2 -0
- package/dist/navigationBar.js +27 -0
- package/dist/router/index.d.ts +4 -3
- package/dist/router/index.js +5 -2
- package/dist/router/mpa.d.ts +5 -3
- package/dist/router/mpa.js +22 -17
- package/dist/router/multi-page.d.ts +10 -6
- package/dist/router/multi-page.js +27 -43
- package/dist/router/navigation-bar.d.ts +32 -0
- package/dist/router/navigation-bar.js +209 -0
- package/dist/router/page.d.ts +13 -7
- package/dist/router/page.js +36 -45
- package/dist/router/spa.d.ts +5 -3
- package/dist/router/spa.js +40 -26
- package/dist/router/stack.d.ts +1 -1
- package/dist/router/stack.js +2 -1
- package/dist/style.d.ts +8 -2
- package/dist/style.js +65 -5
- package/dist/tabbar.d.ts +3 -1
- package/dist/tabbar.js +4 -3
- package/dist/utils/index.d.ts +3 -9
- package/dist/utils/index.js +5 -20
- package/dist/utils/navigate.d.ts +9 -5
- package/dist/utils/navigate.js +22 -38
- package/package.json +21 -11
- package/types/component.d.ts +5 -0
- package/types/taro.d.ts +8 -0
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { History } from "./history.js";
|
|
2
|
+
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
3
|
+
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
4
|
+
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
5
|
+
export * from "./api.js";
|
|
6
|
+
export * from "./history.js";
|
|
7
|
+
export { createMultiRouter } from "./router/mpa.js";
|
|
8
|
+
export { createRouter } from "./router/spa.js";
|
|
9
|
+
export * from "./utils/index.js";
|
|
10
|
+
export { handleAppMount, handleAppMountWithTabbar };
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
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';
|
|
1
5
|
import Taro from "@tarojs/taro";
|
|
2
|
-
import { History } from "history";
|
|
3
6
|
import { AppInstance } from "@tarojs/runtime";
|
|
4
|
-
import { MpaRouterConfig
|
|
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;
|
|
5
30
|
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
6
31
|
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
7
32
|
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
8
33
|
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
9
34
|
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
10
35
|
declare function getCurrentPages(): Taro.Page[];
|
|
11
|
-
declare let history: History;
|
|
12
36
|
// TODO 支持多路由 (APP 生命周期仅触发一次)
|
|
13
37
|
/** Note: 关于多页面应用
|
|
14
38
|
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
@@ -17,6 +41,25 @@ declare let history: History;
|
|
|
17
41
|
* - TabBar 会多次加载
|
|
18
42
|
* - 不支持路由动画
|
|
19
43
|
*/
|
|
20
|
-
declare function createMultiRouter(app: AppInstance, config: MpaRouterConfig, framework?: string): Promise<void>;
|
|
21
|
-
declare function createRouter(app: AppInstance, config: SpaRouterConfig, framework?: string): () => void;
|
|
22
|
-
|
|
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 handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
64
|
+
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
65
|
+
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, handleAppMount, handleAppMountWithTabbar };
|