@netrojs/vono 0.0.1
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 +21 -0
- package/README.md +768 -0
- package/client.ts +309 -0
- package/core.ts +151 -0
- package/dist/client.d.ts +199 -0
- package/dist/client.js +287 -0
- package/dist/core.d.ts +167 -0
- package/dist/core.js +96 -0
- package/dist/server.d.ts +212 -0
- package/dist/server.js +451 -0
- package/dist/types.d.ts +120 -0
- package/package.json +103 -0
- package/server.ts +590 -0
- package/types.ts +149 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { Hono, MiddlewareHandler, Context } from 'hono';
|
|
3
|
+
|
|
4
|
+
type HonoMiddleware = MiddlewareHandler;
|
|
5
|
+
type LoaderCtx = Context;
|
|
6
|
+
interface SEOMeta {
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
keywords?: string;
|
|
10
|
+
author?: string;
|
|
11
|
+
robots?: string;
|
|
12
|
+
canonical?: string;
|
|
13
|
+
themeColor?: string;
|
|
14
|
+
ogTitle?: string;
|
|
15
|
+
ogDescription?: string;
|
|
16
|
+
ogImage?: string;
|
|
17
|
+
ogImageAlt?: string;
|
|
18
|
+
ogUrl?: string;
|
|
19
|
+
ogType?: string;
|
|
20
|
+
ogSiteName?: string;
|
|
21
|
+
twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
22
|
+
twitterSite?: string;
|
|
23
|
+
twitterTitle?: string;
|
|
24
|
+
twitterDescription?: string;
|
|
25
|
+
twitterImage?: string;
|
|
26
|
+
/** Structured data injected as <script type="application/ld+json">. */
|
|
27
|
+
jsonLd?: Record<string, unknown> | Record<string, unknown>[];
|
|
28
|
+
}
|
|
29
|
+
type AsyncLoader = () => Promise<{
|
|
30
|
+
default: Component;
|
|
31
|
+
} | Component>;
|
|
32
|
+
interface PageDef<TData extends object = Record<string, never>> {
|
|
33
|
+
readonly __type: 'page';
|
|
34
|
+
path: string;
|
|
35
|
+
middleware?: HonoMiddleware[];
|
|
36
|
+
loader?: (c: LoaderCtx) => TData | Promise<TData>;
|
|
37
|
+
seo?: SEOMeta | ((data: TData, params: Record<string, string>) => SEOMeta);
|
|
38
|
+
/** Override or disable the app-level layout for this route. */
|
|
39
|
+
layout?: LayoutDef | false;
|
|
40
|
+
/**
|
|
41
|
+
* The Vue component to render for this route.
|
|
42
|
+
* Use () => import('./Page.vue') for automatic code splitting.
|
|
43
|
+
*/
|
|
44
|
+
component: Component | AsyncLoader;
|
|
45
|
+
}
|
|
46
|
+
interface GroupDef {
|
|
47
|
+
readonly __type: 'group';
|
|
48
|
+
prefix: string;
|
|
49
|
+
layout?: LayoutDef | false;
|
|
50
|
+
middleware?: HonoMiddleware[];
|
|
51
|
+
routes: Route[];
|
|
52
|
+
}
|
|
53
|
+
interface LayoutDef {
|
|
54
|
+
readonly __type: 'layout';
|
|
55
|
+
/** Vue layout component — must contain <slot /> for page content. */
|
|
56
|
+
component: Component;
|
|
57
|
+
}
|
|
58
|
+
interface ApiRouteDef {
|
|
59
|
+
readonly __type: 'api';
|
|
60
|
+
path: string;
|
|
61
|
+
register: (app: Hono, globalMiddleware: HonoMiddleware[]) => void;
|
|
62
|
+
}
|
|
63
|
+
type Route = PageDef<any> | GroupDef | ApiRouteDef;
|
|
64
|
+
interface AppConfig {
|
|
65
|
+
layout?: LayoutDef;
|
|
66
|
+
seo?: SEOMeta;
|
|
67
|
+
middleware?: HonoMiddleware[];
|
|
68
|
+
routes: Route[];
|
|
69
|
+
notFound?: Component;
|
|
70
|
+
htmlAttrs?: Record<string, string>;
|
|
71
|
+
/** Extra HTML injected into <head> (e.g. font preloads). */
|
|
72
|
+
head?: string;
|
|
73
|
+
}
|
|
74
|
+
interface ResolvedRoute {
|
|
75
|
+
fullPath: string;
|
|
76
|
+
page: PageDef<any>;
|
|
77
|
+
layout: LayoutDef | false | undefined;
|
|
78
|
+
middleware: HonoMiddleware[];
|
|
79
|
+
}
|
|
80
|
+
interface CompiledPath {
|
|
81
|
+
re: RegExp;
|
|
82
|
+
keys: string[];
|
|
83
|
+
}
|
|
84
|
+
type ClientMiddleware = (url: string, next: () => Promise<void>) => Promise<void>;
|
|
85
|
+
/** Custom request header that identifies an SPA navigation (JSON payload). */
|
|
86
|
+
declare const SPA_HEADER = "x-vono-spa";
|
|
87
|
+
/** window key for SSR-injected per-page loader data. */
|
|
88
|
+
declare const STATE_KEY = "__VONO_STATE__";
|
|
89
|
+
/** window key for SSR-injected URL params. */
|
|
90
|
+
declare const PARAMS_KEY = "__VONO_PARAMS__";
|
|
91
|
+
/** window key for SSR-injected SEO meta. */
|
|
92
|
+
declare const SEO_KEY = "__VONO_SEO__";
|
|
93
|
+
/**
|
|
94
|
+
* Vue provide/inject key for the reactive page-data object.
|
|
95
|
+
* Symbol.for() ensures the same reference across module instances (SSR safe).
|
|
96
|
+
*/
|
|
97
|
+
declare const DATA_KEY: unique symbol;
|
|
98
|
+
/**
|
|
99
|
+
* Extract the loader data type from a `PageDef` returned by `definePage()`.
|
|
100
|
+
*
|
|
101
|
+
* This enables you to define the data type exactly once — inferred from the
|
|
102
|
+
* loader — and import it into page components for `usePageData<T>()`.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // app/routes.ts
|
|
106
|
+
* export const homePage = definePage({
|
|
107
|
+
* path: '/',
|
|
108
|
+
* loader: async () => ({ title: 'Hello', count: 42 }),
|
|
109
|
+
* component: () => import('./pages/home.vue'),
|
|
110
|
+
* })
|
|
111
|
+
* export type HomeData = InferPageData<typeof homePage>
|
|
112
|
+
* // HomeData = { title: string; count: number }
|
|
113
|
+
*
|
|
114
|
+
* // app/pages/home.vue
|
|
115
|
+
* import type { HomeData } from '../routes'
|
|
116
|
+
* const data = usePageData<HomeData>()
|
|
117
|
+
*/
|
|
118
|
+
type InferPageData<T> = T extends PageDef<infer D> ? D : never;
|
|
119
|
+
|
|
120
|
+
export { type ApiRouteDef, type AppConfig, type AsyncLoader, type ClientMiddleware, type CompiledPath, DATA_KEY, type GroupDef, type HonoMiddleware, type InferPageData, type LayoutDef, type LoaderCtx, PARAMS_KEY, type PageDef, type ResolvedRoute, type Route, type SEOMeta, SEO_KEY, SPA_HEADER, STATE_KEY };
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@netrojs/vono",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Full-stack Hono + Vue 3 framework \u2014 Streaming SSR, SPA, code splitting, SEO, middleware",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Netro Solutions<info@netrosolutions.com>",
|
|
8
|
+
"homepage": "https://github.com/netrosolutions/vono",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/netrosolutions/vono.git",
|
|
12
|
+
"directory": "packages/vono"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/netrosolutions/vono/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"vono",
|
|
19
|
+
"hono",
|
|
20
|
+
"vue",
|
|
21
|
+
"vue3",
|
|
22
|
+
"fullstack",
|
|
23
|
+
"ssr",
|
|
24
|
+
"streaming",
|
|
25
|
+
"spa",
|
|
26
|
+
"seo",
|
|
27
|
+
"typescript",
|
|
28
|
+
"node",
|
|
29
|
+
"bun",
|
|
30
|
+
"deno",
|
|
31
|
+
"edge"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/core.d.ts",
|
|
37
|
+
"import": "./dist/core.js"
|
|
38
|
+
},
|
|
39
|
+
"./core": {
|
|
40
|
+
"types": "./dist/core.d.ts",
|
|
41
|
+
"import": "./dist/core.js"
|
|
42
|
+
},
|
|
43
|
+
"./server": {
|
|
44
|
+
"types": "./dist/server.d.ts",
|
|
45
|
+
"import": "./dist/server.js"
|
|
46
|
+
},
|
|
47
|
+
"./client": {
|
|
48
|
+
"types": "./dist/client.d.ts",
|
|
49
|
+
"import": "./dist/client.js"
|
|
50
|
+
},
|
|
51
|
+
"./vite": {
|
|
52
|
+
"types": "./dist/server.d.ts",
|
|
53
|
+
"import": "./dist/server.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"main": "./dist/core.js",
|
|
57
|
+
"types": "./dist/core.d.ts",
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"types.ts",
|
|
61
|
+
"core.ts",
|
|
62
|
+
"server.ts",
|
|
63
|
+
"client.ts",
|
|
64
|
+
"README.md",
|
|
65
|
+
"LICENSE"
|
|
66
|
+
],
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsup",
|
|
69
|
+
"build:watch": "tsup --watch",
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"clean": "rimraf dist",
|
|
72
|
+
"prepublishOnly": "npm run clean && npm run build && npm run typecheck"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"vue": ">=3.5.0",
|
|
76
|
+
"vue-router": ">=4.4.0",
|
|
77
|
+
"@vue/server-renderer": ">=3.5.0",
|
|
78
|
+
"hono": ">=4.0.0",
|
|
79
|
+
"vite": ">=6.0.0",
|
|
80
|
+
"@vitejs/plugin-vue": ">=5.0.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"vite": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"@vitejs/plugin-vue": {
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@hono/node-server": "^1.19.11",
|
|
92
|
+
"@types/node": "^22.0.0",
|
|
93
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
94
|
+
"@vue/server-renderer": "^3.5.30",
|
|
95
|
+
"hono": "^4.12.8",
|
|
96
|
+
"rimraf": "^6.1.3",
|
|
97
|
+
"tsup": "^8.5.1",
|
|
98
|
+
"typescript": "^5.9.3",
|
|
99
|
+
"vite": "^8.0.1",
|
|
100
|
+
"vue": "^3.5.30",
|
|
101
|
+
"vue-router": "^5.0.4"
|
|
102
|
+
}
|
|
103
|
+
}
|