@ubean/runtime 0.1.2 → 0.1.4
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/app-CDOvFfdJ.d.ts +210 -0
- package/dist/app-dx92OPRP.js +892 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.js +2 -0
- package/dist/define-app.d.ts +82 -0
- package/dist/define-app.js +44 -0
- package/dist/index.d.ts +393 -0
- package/dist/index.js +364 -0
- package/dist/view-transitions-DRrLaRHL.d.ts +12 -0
- package/package.json +6 -6
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as UbeanAppOptions, c as createUbeanApp, d as useRouter, f as useSeoMeta, i as UbeanAppInstance, l as createUbeanSSRApp, m as useViewTransition, n as Link, o as UbeanRouter, p as useUnheadHead, r as PageView, s as VueHeadClient, t as Head, u as usePage } from "./app-CDOvFfdJ.js";
|
|
2
|
+
export { Head, Link, PageView, UbeanAppInstance, UbeanAppOptions, UbeanRouter, type VueHeadClient, createUbeanApp, createUbeanSSRApp, useUnheadHead as useHead, usePage, useRouter, useSeoMeta, useViewTransition };
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as createUbeanSSRApp, c as useSeoMeta, i as createUbeanApp, l as useUnheadHead, n as Link, o as usePage, r as PageView, s as useRouter, t as Head, u as useViewTransition } from "./app-dx92OPRP.js";
|
|
2
|
+
export { Head, Link, PageView, createUbeanApp, createUbeanSSRApp, useUnheadHead as useHead, usePage, useRouter, useSeoMeta, useViewTransition };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { t as ViewTransitionOptions } from "./view-transitions-DRrLaRHL.js";
|
|
2
|
+
import { App, Component, Plugin } from "vue";
|
|
3
|
+
import { Router } from "vue-router";
|
|
4
|
+
import { PageHead } from "@ubean/types";
|
|
5
|
+
//#region src/define-app.d.ts
|
|
6
|
+
interface AppPluginConfig {
|
|
7
|
+
plugin: Plugin | [Plugin, ...any[]];
|
|
8
|
+
mode?: 'all' | 'client' | 'server';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Router 钩子配置 — 暴露 vue-router 的导航守卫注册入口。
|
|
12
|
+
*
|
|
13
|
+
* `setup(router)` 在 router 实例创建后、`app.use(router)` 之前调用,
|
|
14
|
+
* 因此守卫能拦截首次导航(包括 SSR 的初始 URL push)。
|
|
15
|
+
*
|
|
16
|
+
* Client 和 SSR 都会执行,适合做鉴权、埋点、进度条等逻辑。
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* defineApp({
|
|
21
|
+
* router: {
|
|
22
|
+
* setup(router) {
|
|
23
|
+
* router.beforeEach((to, from) => {
|
|
24
|
+
* if (to.meta.requiresAuth && !isAuthenticated()) {
|
|
25
|
+
* return '/login';
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* router.afterEach((to) => {
|
|
29
|
+
* analytics.track('page_view', { path: to.fullPath });
|
|
30
|
+
* });
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
interface RouterConfig {
|
|
37
|
+
/**
|
|
38
|
+
* 在 router 创建后、初始导航前调用。
|
|
39
|
+
* 用于注册 `beforeEach` / `beforeResolve` / `afterEach` 等守卫。
|
|
40
|
+
*
|
|
41
|
+
* 注意:setup 必须同步注册守卫(虽然守卫本身可以返回 Promise)。
|
|
42
|
+
* 不要在 setup 中执行异步操作(如请求 API),因为这会延迟首次导航。
|
|
43
|
+
*/
|
|
44
|
+
setup?: (router: Router) => void;
|
|
45
|
+
}
|
|
46
|
+
interface DefineAppOptions {
|
|
47
|
+
plugins?: Array<Plugin | [Plugin, ...any[]] | AppPluginConfig>;
|
|
48
|
+
globalComponents?: Record<string, Component>;
|
|
49
|
+
provides?: Record<string | symbol, unknown>;
|
|
50
|
+
head?: PageHead;
|
|
51
|
+
rootId?: string;
|
|
52
|
+
rootAttrs?: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* 路由钩子配置,用于注册 vue-router 的导航守卫。
|
|
55
|
+
* 在 Client 和 SSR 都会执行。
|
|
56
|
+
*/
|
|
57
|
+
router?: RouterConfig;
|
|
58
|
+
onAppCreated?: (app: App) => void | Promise<void>;
|
|
59
|
+
onClientReady?: (app: App) => void | Promise<void>;
|
|
60
|
+
errorComponent?: Component;
|
|
61
|
+
loadingComponent?: Component;
|
|
62
|
+
viewTransitions?: boolean | ViewTransitionOptions;
|
|
63
|
+
}
|
|
64
|
+
interface ResolvedAppConfig {
|
|
65
|
+
plugins: AppPluginConfig[];
|
|
66
|
+
globalComponents: Record<string, Component>;
|
|
67
|
+
provides: Record<string | symbol, unknown>;
|
|
68
|
+
head?: PageHead;
|
|
69
|
+
rootId: string;
|
|
70
|
+
rootAttrs: Record<string, string>;
|
|
71
|
+
router?: RouterConfig;
|
|
72
|
+
onAppCreated?: (app: App) => void | Promise<void>;
|
|
73
|
+
onClientReady?: (app: App) => void | Promise<void>;
|
|
74
|
+
errorComponent?: Component;
|
|
75
|
+
loadingComponent?: Component;
|
|
76
|
+
viewTransitions?: boolean | ViewTransitionOptions;
|
|
77
|
+
}
|
|
78
|
+
declare function defineApp(options: DefineAppOptions): ResolvedAppConfig;
|
|
79
|
+
declare function applyAppConfig(app: App, config: ResolvedAppConfig, mode: 'client' | 'server'): void;
|
|
80
|
+
declare function createDefaultAppConfig(): ResolvedAppConfig;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { AppPluginConfig, DefineAppOptions, ResolvedAppConfig, RouterConfig, applyAppConfig, createDefaultAppConfig, defineApp };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/define-app.ts
|
|
2
|
+
function defineApp(options) {
|
|
3
|
+
const plugins = [];
|
|
4
|
+
if (options.plugins) for (const p of options.plugins) if (Array.isArray(p)) plugins.push({
|
|
5
|
+
plugin: p,
|
|
6
|
+
mode: "all"
|
|
7
|
+
});
|
|
8
|
+
else if (typeof p === "object" && "plugin" in p) plugins.push(p);
|
|
9
|
+
else plugins.push({
|
|
10
|
+
plugin: p,
|
|
11
|
+
mode: "all"
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
plugins,
|
|
15
|
+
globalComponents: options.globalComponents || {},
|
|
16
|
+
provides: options.provides || {},
|
|
17
|
+
head: options.head,
|
|
18
|
+
rootId: options.rootId || "app",
|
|
19
|
+
rootAttrs: options.rootAttrs || {},
|
|
20
|
+
router: options.router,
|
|
21
|
+
onAppCreated: options.onAppCreated,
|
|
22
|
+
onClientReady: options.onClientReady,
|
|
23
|
+
errorComponent: options.errorComponent,
|
|
24
|
+
loadingComponent: options.loadingComponent,
|
|
25
|
+
viewTransitions: options.viewTransitions
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function applyAppConfig(app, config, mode) {
|
|
29
|
+
for (const { plugin, mode: pluginMode = "all" } of config.plugins) if (pluginMode === "all" || pluginMode === mode) if (Array.isArray(plugin)) app.use(plugin[0], ...plugin.slice(1));
|
|
30
|
+
else app.use(plugin);
|
|
31
|
+
for (const [name, comp] of Object.entries(config.globalComponents)) app.component(name, comp);
|
|
32
|
+
for (const [key, value] of Object.entries(config.provides)) app.provide(key, value);
|
|
33
|
+
}
|
|
34
|
+
function createDefaultAppConfig() {
|
|
35
|
+
return {
|
|
36
|
+
plugins: [],
|
|
37
|
+
globalComponents: {},
|
|
38
|
+
provides: {},
|
|
39
|
+
rootId: "app",
|
|
40
|
+
rootAttrs: {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { applyAppConfig, createDefaultAppConfig, defineApp };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { a as UbeanAppOptions, c as createUbeanApp, d as useRouter, f as useSeoMeta, g as createUbeanRouter, h as CreateUbeanRouterOptions, i as UbeanAppInstance, l as createUbeanSSRApp, m as useViewTransition, n as Link, p as useUnheadHead, r as PageView, s as VueHeadClient$1, t as Head, u as usePage } from "./app-CDOvFfdJ.js";
|
|
2
|
+
import { a as withViewTransition, i as useViewTransitionState, n as getNavigationType, r as supportsViewTransitions, t as ViewTransitionOptions } from "./view-transitions-DRrLaRHL.js";
|
|
3
|
+
import { AppPluginConfig, DefineAppOptions, ResolvedAppConfig, applyAppConfig, createDefaultAppConfig, defineApp } from "./define-app.js";
|
|
4
|
+
import { VueHeadClient, injectHead } from "@unhead/vue";
|
|
5
|
+
import { createHead as createClientHead } from "@unhead/vue/client";
|
|
6
|
+
import { createHead as createServerHead } from "@unhead/vue/server";
|
|
7
|
+
import { PageObject } from "@ubean/pages";
|
|
8
|
+
import { App, Component, ComputedRef, Ref } from "vue";
|
|
9
|
+
import { I18nConfig, LocaleChangeCallback, LocaleDefinition, LocaleMessages } from "@ubean/i18n";
|
|
10
|
+
import { Input, RouteMeta } from "@ubean/types";
|
|
11
|
+
import { DefineMetaResult, PageMeta } from "@ubean/routing";
|
|
12
|
+
import { LinkTag, MetaTag, SeoMetadata } from "@ubean/seo";
|
|
13
|
+
//#region src/client.d.ts
|
|
14
|
+
declare function getInitialPageData<T = Record<string, unknown>>(): PageObject<T> | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/head.d.ts
|
|
17
|
+
declare function useHeadInstance(): import("@unhead/vue").VueHeadClient;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/composables.d.ts
|
|
20
|
+
interface UbeanVueContext {
|
|
21
|
+
__ubean_router?: import('vue-router').Router;
|
|
22
|
+
__ubean_data_cache?: DataCacheStore;
|
|
23
|
+
}
|
|
24
|
+
interface LinkProps {
|
|
25
|
+
href: string;
|
|
26
|
+
replace?: boolean;
|
|
27
|
+
prefetch?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface DataCacheStore {
|
|
30
|
+
get: <T = unknown>(key: string | symbol) => T | undefined;
|
|
31
|
+
set: <T = unknown>(key: string | symbol, value: T, tags?: string[]) => void;
|
|
32
|
+
has: (key: string | symbol) => boolean;
|
|
33
|
+
invalidate: (keyOrTag: string | symbol) => number;
|
|
34
|
+
clear: () => void;
|
|
35
|
+
subscribe: (fn: () => void) => () => void;
|
|
36
|
+
getTimestamp: (key: string | symbol) => number | undefined;
|
|
37
|
+
}
|
|
38
|
+
declare function createDataCacheStore(): DataCacheStore;
|
|
39
|
+
interface UseAsyncDataOptions<T> {
|
|
40
|
+
key?: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
lazy?: boolean;
|
|
43
|
+
server?: boolean;
|
|
44
|
+
default?: () => T;
|
|
45
|
+
transform?: (input: unknown) => T;
|
|
46
|
+
}
|
|
47
|
+
interface UseAsyncDataReturn<T> {
|
|
48
|
+
data: {
|
|
49
|
+
value: T | undefined;
|
|
50
|
+
};
|
|
51
|
+
error: {
|
|
52
|
+
value: Error | null;
|
|
53
|
+
};
|
|
54
|
+
loading: {
|
|
55
|
+
value: boolean;
|
|
56
|
+
};
|
|
57
|
+
refresh: () => Promise<void>;
|
|
58
|
+
invalidate: () => void;
|
|
59
|
+
}
|
|
60
|
+
declare function createUseAsyncData(store: DataCacheStore): <T = unknown>(keyOrFetcher: string | (() => Promise<T>), fetcherOrOptions?: (() => Promise<T>) | UseAsyncDataOptions<T>, options?: UseAsyncDataOptions<T>) => UseAsyncDataReturn<T>;
|
|
61
|
+
declare function invalidateCache(store: DataCacheStore, keyOrTag: string): number;
|
|
62
|
+
declare function clearCache(store: DataCacheStore): void;
|
|
63
|
+
declare function defineDataKey(key: string): symbol;
|
|
64
|
+
declare function createLinkHandler(ctx: UbeanVueContext): {
|
|
65
|
+
getProps: () => {};
|
|
66
|
+
navigate(href: string, opts?: {
|
|
67
|
+
replace?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
prefetch(_href: string): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
declare function extractPageData<T = Record<string, unknown>>(): PageObject<T> | null;
|
|
72
|
+
declare function useServerData<T>(fetcher: () => Promise<T>): Promise<T>;
|
|
73
|
+
declare function getInvalidatedKeysForAction(actionName: string, invalidationMap: Record<string, Array<string | symbol>>, store: DataCacheStore): number;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/cache-views.d.ts
|
|
76
|
+
interface UseCacheViewsReturn {
|
|
77
|
+
/** Reactive list of cached route names — pass to `<keep-alive :include>`. */
|
|
78
|
+
cachedViews: ComputedRef<string[]>;
|
|
79
|
+
/** Reactive list of route names explicitly added to the cache. */
|
|
80
|
+
cachedViewNames: ComputedRef<string[]>;
|
|
81
|
+
/** Reactive list of route names excluded from cache — pass to `<keep-alive :exclude>`. */
|
|
82
|
+
excludedViews: ComputedRef<string[]>;
|
|
83
|
+
/** Whether page caching is globally enabled. */
|
|
84
|
+
enabled: ComputedRef<boolean>;
|
|
85
|
+
/** Enable page caching globally. */
|
|
86
|
+
enable: () => void;
|
|
87
|
+
/** Disable page caching globally (purges keep-alive immediately). */
|
|
88
|
+
disable: () => void;
|
|
89
|
+
/** Add a route name to the cache include list. */
|
|
90
|
+
add: (name: string) => void;
|
|
91
|
+
/** Remove a route name from the cache include list (prunes its instance). */
|
|
92
|
+
remove: (name: string) => void;
|
|
93
|
+
/** Whether a route name is currently in the cache include list. */
|
|
94
|
+
has: (name: string) => boolean;
|
|
95
|
+
/** Remove all route names from the cache include list. */
|
|
96
|
+
clear: () => void;
|
|
97
|
+
/** Add a route name to the cache exclude list (forces prune on next render). */
|
|
98
|
+
addExclude: (name: string) => void;
|
|
99
|
+
/** Remove a route name from the cache exclude list. */
|
|
100
|
+
removeExclude: (name: string) => void;
|
|
101
|
+
/** Whether a route name is currently in the cache exclude list. */
|
|
102
|
+
hasExclude: (name: string) => boolean;
|
|
103
|
+
/** Clear the cache exclude list. */
|
|
104
|
+
clearExclude: () => void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Composable for reactive access to the page cache store.
|
|
108
|
+
*
|
|
109
|
+
* Safe to call inside any component `setup()`; the returned computeds are
|
|
110
|
+
* tracked by the rendering effect so `<keep-alive :include>` stays in sync.
|
|
111
|
+
*/
|
|
112
|
+
declare function useCacheViews(): UseCacheViewsReturn;
|
|
113
|
+
/** Enable keep-alive caching for a specific page (by route name). */
|
|
114
|
+
declare function enablePageCache(name: string): void;
|
|
115
|
+
/** Disable keep-alive caching for a specific page (by route name). */
|
|
116
|
+
declare function disablePageCache(name: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Temporarily exclude a page from keep-alive (forces its cached instance
|
|
119
|
+
* to be pruned on next render). Pair with `includePageCache()` to restore.
|
|
120
|
+
*
|
|
121
|
+
* Useful for the "reload current page" pattern: push the route name into
|
|
122
|
+
* the exclude list, wait a tick, then remove it — the cached instance is
|
|
123
|
+
* pruned and the page remounts fresh on next render.
|
|
124
|
+
*/
|
|
125
|
+
declare function excludePageCache(name: string): void;
|
|
126
|
+
/** Remove a route name from the cache exclude list (restores caching). */
|
|
127
|
+
declare function includePageCache(name: string): void;
|
|
128
|
+
/** Whether a specific page is currently excluded from cache. */
|
|
129
|
+
declare function isPageExcluded(name: string): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Reload a cached page by temporarily excluding it from keep-alive.
|
|
132
|
+
*
|
|
133
|
+
* Pattern (mirrors `routeStore.resetRouteCache` in soybean-unify):
|
|
134
|
+
* 1. Push the route name into the exclude list (prunes cached instance).
|
|
135
|
+
* 2. Wait one tick (let `<keep-alive>` reconcile).
|
|
136
|
+
* 3. Remove the route name from the exclude list.
|
|
137
|
+
*
|
|
138
|
+
* The page's `definePage({ cache: true })` declaration (or a prior
|
|
139
|
+
* `enablePageCache(name)`) is still in effect, so the page will be re-cached
|
|
140
|
+
* on the next visit.
|
|
141
|
+
*
|
|
142
|
+
* @param name Route name. If omitted, uses the current route's name
|
|
143
|
+
* (requires a Vue component setup context — fall back to
|
|
144
|
+
* passing the name explicitly from outside Vue).
|
|
145
|
+
* @param delay Milliseconds to wait between exclude and include. Defaults
|
|
146
|
+
* to 50ms (matches soybean-unify's pattern).
|
|
147
|
+
*/
|
|
148
|
+
declare function resetRouteCache(name?: string, delay?: number): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Invalidate cached page instance(s).
|
|
151
|
+
*
|
|
152
|
+
* - With a `name`: removes that page from the cache (its instance is pruned
|
|
153
|
+
* on next navigation).
|
|
154
|
+
* - Without a `name`: clears all cached pages.
|
|
155
|
+
*
|
|
156
|
+
* Note: the page will be re-cached on next visit if its `definePage({ cache: true })`
|
|
157
|
+
* is still in effect or `enablePageCache(name)` is called again.
|
|
158
|
+
*/
|
|
159
|
+
declare function invalidatePageCache(name?: string): void;
|
|
160
|
+
/** Whether a specific page is currently cached. */
|
|
161
|
+
declare function isPageCached(name: string): boolean;
|
|
162
|
+
/** Whether page caching is globally enabled. */
|
|
163
|
+
declare function isCacheEnabled(): boolean;
|
|
164
|
+
/** Reactive ref of cached route names — for advanced use cases. */
|
|
165
|
+
declare function getCachedViewNames(): Ref<string[]>;
|
|
166
|
+
/** Reactive ref of excluded route names — for advanced use cases. */
|
|
167
|
+
declare function getExcludedViewNames(): Ref<string[]>;
|
|
168
|
+
/** Reactive ref of the global cache-enabled flag. */
|
|
169
|
+
declare function getCacheEnabled(): Ref<boolean>;
|
|
170
|
+
/**
|
|
171
|
+
* Seed the cache include list from route metadata.
|
|
172
|
+
*
|
|
173
|
+
* Called once during app bootstrap (`createUbeanApp`) to honor pages that
|
|
174
|
+
* declared `definePage({ cache: true })`. Routes without `meta.cache` are
|
|
175
|
+
* left untouched so runtime toggling remains possible.
|
|
176
|
+
*/
|
|
177
|
+
declare function initCachedViewsFromRoutes(routes: Array<{
|
|
178
|
+
name?: string | symbol;
|
|
179
|
+
meta?: {
|
|
180
|
+
cache?: boolean;
|
|
181
|
+
};
|
|
182
|
+
}>): void;
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/page-runtime.d.ts
|
|
185
|
+
interface UsePageTransitionReturn {
|
|
186
|
+
/** Reactive transition name. Empty string means "no transition". */
|
|
187
|
+
name: ComputedRef<string>;
|
|
188
|
+
/** Set the global transition name. Use '' or 'none' to disable. */
|
|
189
|
+
set: (name: string) => void;
|
|
190
|
+
/** Clear the global transition name (disables transitions). */
|
|
191
|
+
clear: () => void;
|
|
192
|
+
/** Whether a transition is currently configured. */
|
|
193
|
+
enabled: ComputedRef<boolean>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Composable for reactive access to the global page transition name.
|
|
197
|
+
*
|
|
198
|
+
* Used by `<PageView />` as the fallback transition name when neither the
|
|
199
|
+
* `transition` prop nor `route.meta.transition` is set.
|
|
200
|
+
*
|
|
201
|
+
* Layout components can also read this to display a settings UI:
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* const transition = usePageTransition();
|
|
205
|
+
* // transition.name.value === 'fade-slide'
|
|
206
|
+
* transition.set('zoom-fadein');
|
|
207
|
+
* transition.clear();
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
declare function usePageTransition(): UsePageTransitionReturn;
|
|
211
|
+
/** Imperatively set the global page transition name. */
|
|
212
|
+
declare function setPageTransition(name: string): void;
|
|
213
|
+
/** Imperatively clear the global page transition name (disables transitions). */
|
|
214
|
+
declare function clearPageTransition(): void;
|
|
215
|
+
/** Reactive ref of the global transition name — for advanced use cases. */
|
|
216
|
+
declare function getPageTransitionName(): Ref<string>;
|
|
217
|
+
interface UseReloadSignalReturn {
|
|
218
|
+
/** Reactive counter that increments on each `reloadPage()` call. */
|
|
219
|
+
counter: ComputedRef<number>;
|
|
220
|
+
/** Whether a reload is currently in progress. */
|
|
221
|
+
reloading: ComputedRef<boolean>;
|
|
222
|
+
/** Trigger a reload of the current page. */
|
|
223
|
+
reload: (routeName?: string, duration?: number) => Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Composable for reactive access to the page reload signal.
|
|
227
|
+
*
|
|
228
|
+
* `<PageView />` uses the returned `counter` as part of its render key, so
|
|
229
|
+
* each `reload()` call forces the current page to remount. Combined with
|
|
230
|
+
* `resetRouteCache()` (called internally), the cached keep-alive instance is
|
|
231
|
+
* pruned first, so the remount is fresh — equivalent to the
|
|
232
|
+
* `v-if="appStore.reloadSignal"` pattern in soybean-unify's layout-content.
|
|
233
|
+
*
|
|
234
|
+
* Usage from any component:
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* const { reload } = useReloadSignal();
|
|
238
|
+
* async function onReloadClick() {
|
|
239
|
+
* await reload(); // reloads the current page
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @param routeNameGetter Optional function returning the current route name.
|
|
244
|
+
* If provided, used to call `resetRouteCache(name)`.
|
|
245
|
+
* If omitted, `reload()` only bumps the counter.
|
|
246
|
+
*/
|
|
247
|
+
declare function useReloadSignal(routeNameGetter?: () => string | undefined | null): UseReloadSignalReturn;
|
|
248
|
+
/**
|
|
249
|
+
* Imperatively trigger a page reload.
|
|
250
|
+
*
|
|
251
|
+
* - `name`: route name to reload. If provided, the cached keep-alive instance
|
|
252
|
+
* is pruned first via `resetRouteCache(name)`. If omitted, only the reload
|
|
253
|
+
* counter is bumped (forces remount but does not prune cache).
|
|
254
|
+
* - `duration`: milliseconds to wait for transition/cleanup. Defaults to 300.
|
|
255
|
+
*/
|
|
256
|
+
declare function reloadPage(name?: string, duration?: number): Promise<void>;
|
|
257
|
+
/** Reactive ref of the reload counter — for advanced use cases. */
|
|
258
|
+
declare function getReloadCounter(): Ref<number>;
|
|
259
|
+
/** Whether a reload is currently in progress. */
|
|
260
|
+
declare function isReloading(): boolean;
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/page-macro.d.ts
|
|
263
|
+
declare function definePage(_meta: PageMeta): void;
|
|
264
|
+
declare function defineMeta(_meta: Partial<RouteMeta>): DefineMetaResult | void;
|
|
265
|
+
declare function defineMiddleware<_I extends Input>(_handler: any): void;
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/router-location.d.ts
|
|
268
|
+
interface RouteLocationRaw {
|
|
269
|
+
name?: string;
|
|
270
|
+
path?: string;
|
|
271
|
+
params?: Record<string, string | number>;
|
|
272
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
273
|
+
hash?: string;
|
|
274
|
+
}
|
|
275
|
+
type RouteLocation = string | RouteLocationRaw;
|
|
276
|
+
declare function resolveRoute(to: RouteLocation, routeMap?: Record<string, {
|
|
277
|
+
path: string;
|
|
278
|
+
route: string;
|
|
279
|
+
}>): string;
|
|
280
|
+
type TypedLinkProps = {
|
|
281
|
+
to?: RouteLocation;
|
|
282
|
+
href?: string;
|
|
283
|
+
replace?: boolean;
|
|
284
|
+
prefetch?: boolean;
|
|
285
|
+
as?: string;
|
|
286
|
+
activeClass?: string;
|
|
287
|
+
exactActiveClass?: string;
|
|
288
|
+
};
|
|
289
|
+
declare function isActiveRoute(currentPath: string, targetHref: string, exact?: boolean): boolean;
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/islands.d.ts
|
|
292
|
+
interface DomElement {
|
|
293
|
+
getAttribute(name: string): string | null;
|
|
294
|
+
setAttribute(name: string, value: string): void;
|
|
295
|
+
hasAttribute(name: string): boolean;
|
|
296
|
+
}
|
|
297
|
+
interface NodeListOf<T> {
|
|
298
|
+
forEach(callback: (value: T, key: number, parent: NodeListOf<T>) => void): void;
|
|
299
|
+
}
|
|
300
|
+
interface DomParentNode {
|
|
301
|
+
querySelectorAll(selector: string): NodeListOf<DomElement>;
|
|
302
|
+
}
|
|
303
|
+
interface IslandHydrateOptions {
|
|
304
|
+
getComponent?: (name: string) => Component | Promise<Component> | null;
|
|
305
|
+
appContext?: App;
|
|
306
|
+
onHydrated?: (el: DomElement, component: Component) => void;
|
|
307
|
+
}
|
|
308
|
+
interface IslandRecord {
|
|
309
|
+
el: DomElement;
|
|
310
|
+
id: string;
|
|
311
|
+
componentName: string;
|
|
312
|
+
directive: string;
|
|
313
|
+
mediaQuery?: string;
|
|
314
|
+
props: Record<string, unknown>;
|
|
315
|
+
}
|
|
316
|
+
declare function collectIslands(root?: DomParentNode): IslandRecord[];
|
|
317
|
+
declare function hydrateIsland(record: IslandRecord, component: Component, options?: IslandHydrateOptions): void;
|
|
318
|
+
interface HydrateIslandsOptions extends IslandHydrateOptions {
|
|
319
|
+
root?: DomParentNode;
|
|
320
|
+
components?: Record<string, Component | (() => Promise<Component>)>;
|
|
321
|
+
}
|
|
322
|
+
declare function hydrateIslands(options?: HydrateIslandsOptions): void;
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/i18n.d.ts
|
|
325
|
+
interface VueI18nInstance {
|
|
326
|
+
locale: {
|
|
327
|
+
value: string;
|
|
328
|
+
};
|
|
329
|
+
fallbackLocale: string;
|
|
330
|
+
availableLocales: string[];
|
|
331
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
332
|
+
setLocale: (locale: string) => void;
|
|
333
|
+
getLocale: () => string;
|
|
334
|
+
onLocaleChange: (callback: LocaleChangeCallback) => () => void;
|
|
335
|
+
getLocaleDir: (locale?: string) => 'ltr' | 'rtl';
|
|
336
|
+
getLocaleName: (locale?: string) => string | undefined;
|
|
337
|
+
localeDir: {
|
|
338
|
+
value: 'ltr' | 'rtl';
|
|
339
|
+
};
|
|
340
|
+
localeName: {
|
|
341
|
+
value: string | undefined;
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
declare function useI18n(): VueI18nInstance;
|
|
345
|
+
declare function defineLocale(definition: LocaleDefinition): LocaleDefinition;
|
|
346
|
+
declare function t(key: string, params?: Record<string, string | number>): string;
|
|
347
|
+
declare function setLocale(locale: string): void;
|
|
348
|
+
declare function getLocale(): string;
|
|
349
|
+
declare function onLocaleChange(callback: LocaleChangeCallback): () => void;
|
|
350
|
+
declare function getLocaleDir(locale?: string): 'ltr' | 'rtl';
|
|
351
|
+
declare function getLocaleName(locale?: string): string | undefined;
|
|
352
|
+
declare function getRegisteredLocales(): string[];
|
|
353
|
+
declare function detectLocale(acceptLanguage?: string): string;
|
|
354
|
+
declare function detectBrowserLocale(): string;
|
|
355
|
+
declare function addLocale(code: string, messages: LocaleMessages, options?: {
|
|
356
|
+
name?: string;
|
|
357
|
+
dir?: 'ltr' | 'rtl';
|
|
358
|
+
}): void;
|
|
359
|
+
declare function mergeLocale(code: string, messages: LocaleMessages): void;
|
|
360
|
+
declare function clearLocales(): void;
|
|
361
|
+
declare function getI18nConfig(): I18nConfig;
|
|
362
|
+
declare function setI18nConfig(config: Partial<I18nConfig>): void;
|
|
363
|
+
declare function localizePath(path: string, locale?: string): string;
|
|
364
|
+
declare function switchLocalePath(newLocale: string, currentPath?: string): string;
|
|
365
|
+
declare function getDefaultLocale(): string;
|
|
366
|
+
declare function extractLocaleFromPath(path: string): {
|
|
367
|
+
locale: string | null;
|
|
368
|
+
pathWithoutLocale: string;
|
|
369
|
+
};
|
|
370
|
+
declare function useSwitchLocalePath(): import("vue").ComputedRef<(newLocale: string) => any>;
|
|
371
|
+
declare function useLocalePath(): import("vue").ComputedRef<(path: string, locale?: string) => any>;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/index.d.ts
|
|
374
|
+
declare module 'vue-router' {
|
|
375
|
+
interface RouteMeta {
|
|
376
|
+
/** Whether this page is kept-alive (set by `definePage({ cache: true })`). */
|
|
377
|
+
cache?: boolean;
|
|
378
|
+
/** The page route name (set by ubean's virtual pages module). */
|
|
379
|
+
pageName?: string;
|
|
380
|
+
/** The layout name to use, or `false` to disable layout. */
|
|
381
|
+
layout?: string | false;
|
|
382
|
+
/** Whether authentication is required for this route. */
|
|
383
|
+
requiresAuth?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Page transition name (used by `<PageView>`). Falls back to the global
|
|
386
|
+
* `usePageTransition()` ref when not set. Set to empty string to disable
|
|
387
|
+
* transitions for this specific page.
|
|
388
|
+
*/
|
|
389
|
+
transition?: string;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
export { type AppPluginConfig, type CreateUbeanRouterOptions, type DataCacheStore, type DefineAppOptions, Head, type VueHeadClient as HeadClient, type HydrateIslandsOptions, type IslandHydrateOptions, type IslandRecord, Link, type LinkProps, type LinkTag, type MetaTag, PageView, type ResolvedAppConfig, type RouteLocation, type RouteLocationRaw, type SeoMetadata, type TypedLinkProps, type UbeanAppInstance, type UbeanAppOptions, type UbeanVueContext, type UseAsyncDataOptions, type UseAsyncDataReturn, type UseCacheViewsReturn, type UsePageTransitionReturn, type UseReloadSignalReturn, type ViewTransitionOptions, type VueHeadClient$1 as VueHeadClient, type VueI18nInstance, addLocale, applyAppConfig, clearCache, clearLocales, clearPageTransition, collectIslands, createClientHead, createDataCacheStore, createDefaultAppConfig, createLinkHandler, createServerHead, createUbeanApp, createUbeanRouter, createUbeanSSRApp, createUseAsyncData, defineApp, defineDataKey, defineLocale, defineMeta, defineMiddleware, definePage, detectBrowserLocale, detectLocale, disablePageCache, enablePageCache, excludePageCache, extractLocaleFromPath, extractPageData, getCacheEnabled, getCachedViewNames, getDefaultLocale, getExcludedViewNames, getI18nConfig, getInitialPageData, getInvalidatedKeysForAction, getLocale, getLocaleDir, getLocaleName, getNavigationType, getPageTransitionName, getRegisteredLocales, getReloadCounter, hydrateIsland, hydrateIslands, includePageCache, initCachedViewsFromRoutes, injectHead, invalidateCache, invalidatePageCache, isActiveRoute, isCacheEnabled, isPageCached, isPageExcluded, isReloading, localizePath, mergeLocale, onLocaleChange, reloadPage, resetRouteCache, resolveRoute, setI18nConfig, setLocale, setPageTransition, supportsViewTransitions, switchLocalePath, t, useCacheViews, useUnheadHead as useHead, useHeadInstance, useI18n, useLocalePath, usePage, usePageTransition, useReloadSignal, useRouter, useSeoMeta, useServerData, useSwitchLocalePath, useViewTransition, useViewTransitionState, withViewTransition };
|