@ubean/runtime 0.1.1 → 0.1.3

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.
@@ -0,0 +1,210 @@
1
+ import { t as ViewTransitionOptions } from "./view-transitions-DRrLaRHL.js";
2
+ import { VueHeadClient, useHead as useUnheadHead, useSeoMeta } from "@unhead/vue";
3
+ import { PageObject } from "@ubean/pages";
4
+ import { App, Component, PropType, VNode } from "vue";
5
+ import { RouteRecordRaw, Router, useRouter } from "vue-router";
6
+ //#region src/router.d.ts
7
+ interface CreateUbeanRouterOptions {
8
+ routes: RouteRecordRaw[];
9
+ ssr?: boolean;
10
+ initialUrl?: string;
11
+ base?: string;
12
+ /**
13
+ * 在 router 实例创建后、初始导航(SSR 的 `router.push(initialUrl)`)之前调用,
14
+ * 用于注册 `beforeEach` / `beforeResolve` / `afterEach` 等导航守卫。
15
+ *
16
+ * 守卫注册必须同步完成(守卫函数本身可以返回 Promise)。
17
+ * 不要在此处执行异步操作(如发起 API 请求),否则会阻塞首次导航。
18
+ *
19
+ * 该回调在 Client 和 SSR 环境都会执行。
20
+ */
21
+ setup?: (router: Router) => void;
22
+ }
23
+ declare function createUbeanRouter(options: CreateUbeanRouterOptions): Router;
24
+ //#endregion
25
+ //#region src/app.d.ts
26
+ interface UbeanAppOptions {
27
+ routes: RouteRecordRaw[];
28
+ resolveLayoutComponent: (name: string | false | null | undefined) => Promise<Component | null>;
29
+ defaultLayout?: string | null;
30
+ initialPage?: PageObject;
31
+ head?: VueHeadClient;
32
+ viewTransitions?: boolean | ViewTransitionOptions;
33
+ hydrate?: boolean;
34
+ /**
35
+ * 在 router 实例创建后、`app.use(router)` 之前调用,
36
+ * 用于注册 vue-router 的导航守卫(`beforeEach` / `beforeResolve` / `afterEach`)。
37
+ *
38
+ * Client 和 SSR 都会执行。守卫注册必须同步完成(守卫本身可返回 Promise)。
39
+ */
40
+ routerSetup?: (router: ReturnType<typeof createUbeanRouter>) => void;
41
+ }
42
+ interface UbeanAppInstance {
43
+ app: App;
44
+ router: ReturnType<typeof createUbeanRouter>;
45
+ head: VueHeadClient;
46
+ page: PageObject;
47
+ }
48
+ /**
49
+ * PageView — a globally-registered component that renders the matched route
50
+ * page, wrapped with `<Transition>` and `<KeepAlive>`.
51
+ *
52
+ * Layouts use `<PageView />` (instead of `<slot />`) to render the matched
53
+ * page. This follows vue-router's v-slot pattern, mirroring soybean-unify's
54
+ * `layouts/modules/layout-content/index.vue`:
55
+ *
56
+ * ```html
57
+ * <RouterView v-slot="{ Component, route }">
58
+ * <Transition :name="pageAnimateMode" mode="out-in">
59
+ * <KeepAlive :include="cachedRoutes" :exclude="excludeCachedRoutes">
60
+ * <component :is="Component" v-if="reloadSignal" :key="tabId" />
61
+ * </KeepAlive>
62
+ * </Transition>
63
+ * </RouterView>
64
+ * ```
65
+ *
66
+ * In ubean, the equivalents are:
67
+ * - `pageAnimateMode` → global `usePageTransition()` ref + `transition` prop + `route.meta.transition`
68
+ * - `cachedRoutes` / `excludeCachedRoutes` → `useCacheViews().cachedViews` / `excludedViews`
69
+ * - `reloadSignal` → `useReloadSignal().counter` (incremented by `reloadPage()`)
70
+ * - `tabId` → `reloadKey` prop + reload counter (forces remount when changed)
71
+ *
72
+ * Props:
73
+ * - `transition`: transition name (string) or `false` to disable.
74
+ * Priority: prop > `route.meta.transition` > global `usePageTransition()`.
75
+ * - `reloadKey`: a reactive key — changing it forces remount (reload).
76
+ * When omitted, falls back to `route.fullPath` + global reload counter.
77
+ * - `mode`: Vue `<Transition>` mode. Defaults to `'out-in'`.
78
+ *
79
+ * On SSR, KeepAlive and Transition are skipped (client-only concepts).
80
+ */
81
+ declare const PageView: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
82
+ transition: {
83
+ type: (StringConstructor | BooleanConstructor)[];
84
+ default: undefined;
85
+ };
86
+ reloadKey: {
87
+ type: (StringConstructor | NumberConstructor)[];
88
+ default: undefined;
89
+ };
90
+ mode: {
91
+ type: PropType<"out-in" | "in-out" | "default">;
92
+ default: string;
93
+ };
94
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
95
+ [key: string]: any;
96
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
97
+ transition: {
98
+ type: (StringConstructor | BooleanConstructor)[];
99
+ default: undefined;
100
+ };
101
+ reloadKey: {
102
+ type: (StringConstructor | NumberConstructor)[];
103
+ default: undefined;
104
+ };
105
+ mode: {
106
+ type: PropType<"out-in" | "in-out" | "default">;
107
+ default: string;
108
+ };
109
+ }>> & Readonly<{}>, {
110
+ transition: string | boolean;
111
+ reloadKey: string | number;
112
+ mode: "out-in" | "in-out" | "default";
113
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
114
+ declare const Link: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
115
+ to: {
116
+ type: PropType<string | Record<string, unknown>>;
117
+ default: undefined;
118
+ };
119
+ href: {
120
+ type: StringConstructor;
121
+ default: undefined;
122
+ };
123
+ replace: {
124
+ type: BooleanConstructor;
125
+ default: boolean;
126
+ };
127
+ prefetch: {
128
+ type: BooleanConstructor;
129
+ default: boolean;
130
+ };
131
+ activeClass: {
132
+ type: StringConstructor;
133
+ default: string;
134
+ };
135
+ exactActiveClass: {
136
+ type: StringConstructor;
137
+ default: string;
138
+ };
139
+ noActiveClass: {
140
+ type: BooleanConstructor;
141
+ default: boolean;
142
+ };
143
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
144
+ [key: string]: any;
145
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
146
+ to: {
147
+ type: PropType<string | Record<string, unknown>>;
148
+ default: undefined;
149
+ };
150
+ href: {
151
+ type: StringConstructor;
152
+ default: undefined;
153
+ };
154
+ replace: {
155
+ type: BooleanConstructor;
156
+ default: boolean;
157
+ };
158
+ prefetch: {
159
+ type: BooleanConstructor;
160
+ default: boolean;
161
+ };
162
+ activeClass: {
163
+ type: StringConstructor;
164
+ default: string;
165
+ };
166
+ exactActiveClass: {
167
+ type: StringConstructor;
168
+ default: string;
169
+ };
170
+ noActiveClass: {
171
+ type: BooleanConstructor;
172
+ default: boolean;
173
+ };
174
+ }>> & Readonly<{}>, {
175
+ to: string | Record<string, unknown>;
176
+ href: string;
177
+ replace: boolean;
178
+ prefetch: boolean;
179
+ activeClass: string;
180
+ exactActiveClass: string;
181
+ noActiveClass: boolean;
182
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
183
+ declare const Head: import("vue").DefineComponent;
184
+ declare function createUbeanApp(options: UbeanAppOptions): UbeanAppInstance;
185
+ declare function createUbeanSSRApp(initialPage: PageObject, options: Omit<UbeanAppOptions, 'initialPage'>): {
186
+ app: App<Element>;
187
+ router: import("vue-router")._RouterClassic;
188
+ head: VueHeadClient;
189
+ };
190
+ declare function usePage<T = Record<string, unknown>>(): PageObject<T>;
191
+ interface UbeanRouter {
192
+ push: (url: string, opts?: {
193
+ replace?: boolean;
194
+ }) => Promise<unknown>;
195
+ replace: (url: string) => Promise<unknown>;
196
+ back: () => void;
197
+ forward: () => void;
198
+ refresh: () => void;
199
+ readonly current: ReturnType<typeof useRouter>['currentRoute']['value'];
200
+ readonly navigating: boolean;
201
+ [key: string]: unknown;
202
+ }
203
+ declare function useRouter$1(): UbeanRouter;
204
+ declare function useViewTransition(): {
205
+ enabled: boolean;
206
+ supports: boolean;
207
+ options: ViewTransitionOptions;
208
+ };
209
+ //#endregion
210
+ export { UbeanAppOptions as a, createUbeanApp as c, useRouter$1 as d, useSeoMeta as f, createUbeanRouter as g, CreateUbeanRouterOptions as h, UbeanAppInstance as i, createUbeanSSRApp as l, useViewTransition as m, Link as n, UbeanRouter as o, useUnheadHead as p, PageView as r, VueHeadClient as s, Head as t, usePage as u };