vinojs 0.1.1 → 0.1.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/dist/{factory-AHIdhfy4.d.mts → factory-CVT0-OZw.d.mts} +60 -16
- package/dist/{factory-AHIdhfy4.d.mts.map → factory-CVT0-OZw.d.mts.map} +1 -1
- package/dist/factory.d.mts +2 -2
- package/dist/factory.mjs +136 -18
- package/dist/factory.mjs.map +1 -1
- package/dist/vino.d.mts +2 -2
- package/dist/vino.d.mts.map +1 -1
- package/dist/vino.mjs +4 -1
- package/dist/vino.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as PageConfig, c as VinoHtml, n as DataLoader, o as PageProps } from "./types-CQITdkpF.mjs";
|
|
2
|
-
import { Context, Env } from "hono";
|
|
2
|
+
import { Context, Env, Hono } from "hono";
|
|
3
3
|
//#region src/vino/defineServerFn.d.ts
|
|
4
4
|
declare const SERVER_FN_KIND: "vino:server-fn";
|
|
5
5
|
type ServerFnHandler<T = unknown, E extends Env = Env> = (c: Context<E, string>) => T | Promise<T>;
|
|
@@ -110,34 +110,78 @@ declare const definePage: DefinePageFn;
|
|
|
110
110
|
declare const defineServerPage: DefinePageFn;
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/vino/factory.d.ts
|
|
113
|
+
/** Initialize every app created by `factory.createApp()`, and pages from `definePage`. */
|
|
114
|
+
type InitApp<E extends Env = Env> = (app: Hono<E>) => void;
|
|
115
|
+
type HonoCtorOptions = NonNullable<ConstructorParameters<typeof Hono>[0]>;
|
|
116
|
+
interface FactoryOptions<E extends Env = Env> {
|
|
117
|
+
initApp?: InitApp<E>;
|
|
118
|
+
defaultAppOptions?: HonoCtorOptions;
|
|
119
|
+
}
|
|
120
|
+
/** `initApp` stamped onto a `definePage` / `defineServerFn` result. */
|
|
121
|
+
declare function readBoundInitApp(value: unknown): InitApp | undefined;
|
|
122
|
+
declare function readPageModuleInitApp(pageDefault: unknown, data?: unknown): InitApp | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Run a factory `initApp`'s `app.use()` middleware on the current context.
|
|
125
|
+
* Skips if this `initApp` already ran on `c` (e.g. via `createApp()`).
|
|
126
|
+
* Params and `c.set` stay on the same context so page loaders still see them.
|
|
127
|
+
*/
|
|
128
|
+
declare function applyInitApp(initApp: InitApp | undefined, c: Context, next: () => Promise<Response>): Promise<Response>;
|
|
113
129
|
declare class Factory<E extends Env = Env> {
|
|
114
|
-
|
|
130
|
+
private initApp?;
|
|
131
|
+
private defaultAppOptions?;
|
|
132
|
+
constructor(init?: FactoryOptions<E>);
|
|
133
|
+
/**
|
|
134
|
+
* Create a Hono app typed with this factory's `Env`.
|
|
135
|
+
* Runs `initApp` (if provided) before returning, so middleware is registered
|
|
136
|
+
* before you call `mountVino(app)`.
|
|
137
|
+
*/
|
|
138
|
+
createApp: (options?: HonoCtorOptions) => Hono<E>;
|
|
139
|
+
/** Same as `definePage`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
115
140
|
definePage: DefinePageFn<E>;
|
|
116
|
-
/** Same as `defineServerPage`, with `c` typed as `Context<E
|
|
141
|
+
/** Same as `defineServerPage`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
117
142
|
defineServerPage: DefinePageFn<E>;
|
|
118
|
-
/** Same as `defineServerFn`, with `c` typed as `Context<E
|
|
143
|
+
/** Same as `defineServerFn`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
119
144
|
defineServerFn: DefineServerFnFn<E>;
|
|
120
145
|
}
|
|
121
146
|
/**
|
|
122
|
-
* Create a factory that binds `Env` onto page and
|
|
147
|
+
* Create a factory that binds `Env` onto page helpers and `createApp()`.
|
|
123
148
|
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
149
|
+
* Pages keep the `initApp` of the factory that defined them, so a blog factory
|
|
150
|
+
* can set `c.var.db` only for `blogFactory.definePage` routes while the root
|
|
151
|
+
* app still uses the global factory.
|
|
126
152
|
*
|
|
127
153
|
* @example
|
|
128
154
|
* // src/factory.ts
|
|
129
|
-
*
|
|
130
|
-
*
|
|
155
|
+
* export const factory = createFactory<Env>({
|
|
156
|
+
* initApp: (app) => {
|
|
157
|
+
* app.use(async (c, next) => {
|
|
158
|
+
* c.set("db", drizzle(c.env.DB))
|
|
159
|
+
* await next()
|
|
160
|
+
* })
|
|
161
|
+
* },
|
|
162
|
+
* })
|
|
163
|
+
* export const blogFactory = createFactory<BlogEnv>({
|
|
164
|
+
* initApp: (app) => {
|
|
165
|
+
* app.use(async (c, next) => {
|
|
166
|
+
* c.set("posts", createPosts(c.env.BLOG_DB))
|
|
167
|
+
* await next()
|
|
168
|
+
* })
|
|
169
|
+
* },
|
|
170
|
+
* })
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // src/server.ts
|
|
174
|
+
* const app = factory.createApp()
|
|
175
|
+
* mountVino(app)
|
|
131
176
|
*
|
|
132
177
|
* @example
|
|
133
|
-
* // src/pages/
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* data: (c) => ({ title: c.env.TITLE }),
|
|
178
|
+
* // src/pages/blog/[slug].tsx
|
|
179
|
+
* export default blogFactory.definePage({
|
|
180
|
+
* data: (c) => c.var.posts.get(c.req.param("slug")),
|
|
137
181
|
* render: ({ data }) => <h1>{data.title}</h1>,
|
|
138
182
|
* })
|
|
139
183
|
*/
|
|
140
|
-
declare
|
|
184
|
+
declare function createFactory<E extends Env = Env>(options?: FactoryOptions<E>): Factory<E>;
|
|
141
185
|
//#endregion
|
|
142
|
-
export { ServerFnHandler as _,
|
|
143
|
-
//# sourceMappingURL=factory-
|
|
186
|
+
export { defineServerFn as C, ServerFnHandler as S, readServerFn as T, isPageDefinition as _, createFactory as a, DefineServerFnFn as b, DefinePageFn as c, PageDataFn as d, PageDefinition as f, isClientPageDefinition as g, defineServerPage as h, applyInitApp as i, DefinePageOptions as l, definePage as m, FactoryOptions as n, readBoundInitApp as o, PageRender as p, InitApp as r, readPageModuleInitApp as s, Factory as t, InferDefinePageOptions as u, isServerPageDefinition as v, isServerFn as w, ServerFn as x, resolvePageRender as y };
|
|
187
|
+
//# sourceMappingURL=factory-CVT0-OZw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory-
|
|
1
|
+
{"version":3,"file":"factory-CVT0-OZw.d.mts","names":[],"sources":["../src/vino/defineServerFn.ts","../src/vino/definePage.ts","../src/vino/factory.ts"],"mappings":";;;cAEa;KAED,gBAAgB,aAAa,UAAU,MAAM,QACvD,GAAG,QAAQ,eACR,IAAI,QAAQ;;;;KAKL,SAAS,aAAa,UAAU,MAAM,OAAO,gBAAgB,GAAG;WACjE,aAAa;;;;;;KAOZ,iBAAiB,UAAU,MAAM,QAAQ,GAAG,IAAI,gBAAgB,GAAG,OAAO,SAAS,GAAG;iBAElF,WAAW,iBAAiB,SAAS;iBAIrC,aAAa,iBAAiB;;;;;;;;;;;;;;;;;;;iBAgC9B,eAAe,GAAG,UAAU,MAAM,KAAK,IAAI,gBAAgB,GAAG,KAAK,SAAS,GAAG;;;cCrDlF;cACA;KAED,WAAW,mBAAmB,OAAO,UAAU,UAAU;KAEzD,WAAW,UAAU,MAAM,OAAO,WAAW,KAAK,kBAAkB;UAE/D,kBAAkB,gBAAgB,UAAU,MAAM;;EAEjE,SAAS,WAAW;EACpB,OAAO,WAAW;;EAElB,OAAO,WAAW,KAAK,SAAS,MAAM;EACtC,SAAS;;;KAIC,uBACV,cAAc,2BACd,OAAO,QAAQ,WAAW;EAE1B,OAAO;EACP,SAAS;;EAEL,QAAQ,WAAW;EAAO,OAAO,WAAW;;EAC5C,MAAM,WAAW;EAAO,SAAS,WAAW;;;;;;UAOjC,aAAa,UAAU,MAAM;GAC3C,gBAAgB,MAAM,WAAW,QAAQ,eAAe;GACxD,UAAU,WAAW,IACpB,SAAS,uBAAuB,KAC/B,eAAe,QAAQ,WAAW;GACpC,gBAAgB,SAAS,kBAAkB,MAAM,KAAK,eAAe;;UAGvD,eAAe;WACrB,aAAa,mBAAmB;WAChC;WACA,QAAQ,WAAW;WACnB,OAAO,aAAa,SAAS;WAC7B,SAAS;;iBAGJ,iBAAiB,iBAAiB,SAAS;iBAS3C,uBAAuB,iBAAiB,SAAS;iBAIjD,uBAAuB,iBAAiB,SAAS;iBAQjD,kBAAkB,iBAAiB;;;;;;;;;;;;;;;;;;;;;cAoDtC,YAA0G;;;;;;;cAQ1G,kBAA6H;;;;KC7G9H,QAAQ,UAAU,MAAM,QAAQ,KAAK,KAAK;KAEjD,kBAAkB,YAAY,6BAA6B;UAG/C,eAAe,UAAU,MAAM;EAC9C,UAAU,QAAQ;EAClB,oBAAoB;;;iBAiBN,iBAAiB,iBAAiB;iBAKlC,sBAAsB,sBAAsB,iBAAiB;;;;;;iBAiCvD,aACpB,SAAS,qBACT,GAAG,SACH,YAAY,QAAQ,YACnB,QAAQ;cAoBE,QAAQ,UAAU,MAAM;UAC3B;UACA;EAEI,YAAA,OAAO,eAAe;;;;;;EAUlC,YAAa,UAAU,oBAAkB,KAAK;;EAkB9C,YAAY,aAAa;;EAIzB,kBAAkB,aAAa;;EAI/B,gBAAgB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CnB,cAAc,UAAU,MAAM,KAAK,UAAU,eAAe,KAAK,QAAQ"}
|
package/dist/factory.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { Factory, createFactory };
|
|
1
|
+
import { a as createFactory, i as applyInitApp, n as FactoryOptions, o as readBoundInitApp, r as InitApp, s as readPageModuleInitApp, t as Factory } from "./factory-CVT0-OZw.mjs";
|
|
2
|
+
export { Factory, FactoryOptions, InitApp, applyInitApp, createFactory, readBoundInitApp, readPageModuleInitApp };
|
package/dist/factory.mjs
CHANGED
|
@@ -1,35 +1,153 @@
|
|
|
1
|
-
import { n as defineServerPage, t as definePage } from "./definePage--9Pz7rHs.mjs";
|
|
1
|
+
import { n as defineServerPage, o as readPageDefinition, t as definePage } from "./definePage--9Pz7rHs.mjs";
|
|
2
2
|
import { r as defineServerFn } from "./defineServerFn-H-bz7xBX.mjs";
|
|
3
|
+
import { Hono } from "hono";
|
|
3
4
|
//#region src/vino/factory.ts
|
|
5
|
+
/**
|
|
6
|
+
* Factory helper for Vino, analogous to `hono/factory`.
|
|
7
|
+
*
|
|
8
|
+
* Bind `Env` once so `definePage` / `defineServerPage` / `defineServerFn` type
|
|
9
|
+
* `c` without blocking inference of loader return data. `createApp()` builds a
|
|
10
|
+
* Hono instance with that `Env`. Each factory's `initApp` also runs for pages
|
|
11
|
+
* defined with that factory, so multiple Envs can share one mounted app.
|
|
12
|
+
*/
|
|
13
|
+
const boundInit = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const appliedInit = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
const middlewareCache = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function storedInitApp(initApp) {
|
|
17
|
+
return initApp;
|
|
18
|
+
}
|
|
19
|
+
function bindInitApp(value, initApp) {
|
|
20
|
+
if (initApp) boundInit.set(value, initApp);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** `initApp` stamped onto a `definePage` / `defineServerFn` result. */
|
|
24
|
+
function readBoundInitApp(value) {
|
|
25
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
26
|
+
return boundInit.get(value);
|
|
27
|
+
}
|
|
28
|
+
function readPageModuleInitApp(pageDefault, data) {
|
|
29
|
+
return readBoundInitApp(pageDefault) ?? readBoundInitApp(data ?? readPageDefinition(pageDefault)?.data);
|
|
30
|
+
}
|
|
31
|
+
function markInitApplied(c, initApp) {
|
|
32
|
+
let set = appliedInit.get(c);
|
|
33
|
+
if (!set) {
|
|
34
|
+
set = /* @__PURE__ */ new Set();
|
|
35
|
+
appliedInit.set(c, set);
|
|
36
|
+
}
|
|
37
|
+
set.add(initApp);
|
|
38
|
+
}
|
|
39
|
+
function isInitApplied(c, initApp) {
|
|
40
|
+
return appliedInit.get(c)?.has(initApp) ?? false;
|
|
41
|
+
}
|
|
42
|
+
function middlewareFromInitApp(initApp) {
|
|
43
|
+
let list = middlewareCache.get(initApp);
|
|
44
|
+
if (!list) {
|
|
45
|
+
const app = new Hono();
|
|
46
|
+
initApp(app);
|
|
47
|
+
list = app.routes.filter((route) => route.method === "ALL").map((route) => route.handler);
|
|
48
|
+
middlewareCache.set(initApp, list);
|
|
49
|
+
}
|
|
50
|
+
return list;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Run a factory `initApp`'s `app.use()` middleware on the current context.
|
|
54
|
+
* Skips if this `initApp` already ran on `c` (e.g. via `createApp()`).
|
|
55
|
+
* Params and `c.set` stay on the same context so page loaders still see them.
|
|
56
|
+
*/
|
|
57
|
+
async function applyInitApp(initApp, c, next) {
|
|
58
|
+
if (!initApp || isInitApplied(c, initApp)) return next();
|
|
59
|
+
markInitApplied(c, initApp);
|
|
60
|
+
const handlers = middlewareFromInitApp(initApp);
|
|
61
|
+
if (handlers.length === 0) return next();
|
|
62
|
+
let response;
|
|
63
|
+
const run = async (i) => {
|
|
64
|
+
const handler = handlers[i];
|
|
65
|
+
if (!handler) {
|
|
66
|
+
response = await next();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const out = await handler(c, () => run(i + 1));
|
|
70
|
+
if (out instanceof Response) response = out;
|
|
71
|
+
};
|
|
72
|
+
await run(0);
|
|
73
|
+
return response ?? c.res;
|
|
74
|
+
}
|
|
4
75
|
var Factory = class {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
76
|
+
initApp;
|
|
77
|
+
defaultAppOptions;
|
|
78
|
+
constructor(init) {
|
|
79
|
+
this.initApp = init?.initApp;
|
|
80
|
+
this.defaultAppOptions = init?.defaultAppOptions;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a Hono app typed with this factory's `Env`.
|
|
84
|
+
* Runs `initApp` (if provided) before returning, so middleware is registered
|
|
85
|
+
* before you call `mountVino(app)`.
|
|
86
|
+
*/
|
|
87
|
+
createApp = (options) => {
|
|
88
|
+
const app = new Hono(options && this.defaultAppOptions ? {
|
|
89
|
+
...this.defaultAppOptions,
|
|
90
|
+
...options
|
|
91
|
+
} : options ?? this.defaultAppOptions);
|
|
92
|
+
if (this.initApp) {
|
|
93
|
+
const initApp = this.initApp;
|
|
94
|
+
app.use(async (c, next) => {
|
|
95
|
+
markInitApplied(c, initApp);
|
|
96
|
+
await next();
|
|
97
|
+
});
|
|
98
|
+
initApp(app);
|
|
99
|
+
}
|
|
100
|
+
return app;
|
|
101
|
+
};
|
|
102
|
+
/** Same as `definePage`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
103
|
+
definePage = ((page) => bindInitApp(definePage(page), storedInitApp(this.initApp)));
|
|
104
|
+
/** Same as `defineServerPage`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
105
|
+
defineServerPage = ((page) => bindInitApp(defineServerPage(page), storedInitApp(this.initApp)));
|
|
106
|
+
/** Same as `defineServerFn`, with `c` typed as `Context<E>` and this factory's `initApp`. */
|
|
107
|
+
defineServerFn = ((fn) => bindInitApp(defineServerFn(fn), storedInitApp(this.initApp)));
|
|
11
108
|
};
|
|
12
109
|
/**
|
|
13
|
-
* Create a factory that binds `Env` onto page and
|
|
110
|
+
* Create a factory that binds `Env` onto page helpers and `createApp()`.
|
|
14
111
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
112
|
+
* Pages keep the `initApp` of the factory that defined them, so a blog factory
|
|
113
|
+
* can set `c.var.db` only for `blogFactory.definePage` routes while the root
|
|
114
|
+
* app still uses the global factory.
|
|
17
115
|
*
|
|
18
116
|
* @example
|
|
19
117
|
* // src/factory.ts
|
|
20
|
-
*
|
|
21
|
-
*
|
|
118
|
+
* export const factory = createFactory<Env>({
|
|
119
|
+
* initApp: (app) => {
|
|
120
|
+
* app.use(async (c, next) => {
|
|
121
|
+
* c.set("db", drizzle(c.env.DB))
|
|
122
|
+
* await next()
|
|
123
|
+
* })
|
|
124
|
+
* },
|
|
125
|
+
* })
|
|
126
|
+
* export const blogFactory = createFactory<BlogEnv>({
|
|
127
|
+
* initApp: (app) => {
|
|
128
|
+
* app.use(async (c, next) => {
|
|
129
|
+
* c.set("posts", createPosts(c.env.BLOG_DB))
|
|
130
|
+
* await next()
|
|
131
|
+
* })
|
|
132
|
+
* },
|
|
133
|
+
* })
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // src/server.ts
|
|
137
|
+
* const app = factory.createApp()
|
|
138
|
+
* mountVino(app)
|
|
22
139
|
*
|
|
23
140
|
* @example
|
|
24
|
-
* // src/pages/
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* data: (c) => ({ title: c.env.TITLE }),
|
|
141
|
+
* // src/pages/blog/[slug].tsx
|
|
142
|
+
* export default blogFactory.definePage({
|
|
143
|
+
* data: (c) => c.var.posts.get(c.req.param("slug")),
|
|
28
144
|
* render: ({ data }) => <h1>{data.title}</h1>,
|
|
29
145
|
* })
|
|
30
146
|
*/
|
|
31
|
-
|
|
147
|
+
function createFactory(options) {
|
|
148
|
+
return new Factory(options);
|
|
149
|
+
}
|
|
32
150
|
//#endregion
|
|
33
|
-
export { Factory, createFactory };
|
|
151
|
+
export { Factory, applyInitApp, createFactory, readBoundInitApp, readPageModuleInitApp };
|
|
34
152
|
|
|
35
153
|
//# sourceMappingURL=factory.mjs.map
|
package/dist/factory.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","names":["definePageImpl","defineServerPageImpl","defineServerFnImpl"],"sources":["../src/vino/factory.ts"],"sourcesContent":["/**\n * Factory helper for Vino, analogous to `hono/factory`.\n *\n * Bind `Env` once so `definePage` / `defineServerPage` / `defineServerFn` type\n * `c` without blocking inference of loader return data.\n */\n\nimport type { Env } from \"hono\";\nimport {\n definePage as definePageImpl,\n defineServerPage as defineServerPageImpl,\n type DefinePageFn,\n} from \"./definePage.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"factory.mjs","names":["definePageImpl","defineServerPageImpl","defineServerFnImpl"],"sources":["../src/vino/factory.ts"],"sourcesContent":["/**\n * Factory helper for Vino, analogous to `hono/factory`.\n *\n * Bind `Env` once so `definePage` / `defineServerPage` / `defineServerFn` type\n * `c` without blocking inference of loader return data. `createApp()` builds a\n * Hono instance with that `Env`. Each factory's `initApp` also runs for pages\n * defined with that factory, so multiple Envs can share one mounted app.\n */\n\nimport { Hono } from \"hono\";\nimport type { Context, Env } from \"hono\";\nimport {\n definePage as definePageImpl,\n defineServerPage as defineServerPageImpl,\n readPageDefinition,\n type DefinePageFn,\n} from \"./definePage.ts\";\nimport {\n defineServerFn as defineServerFnImpl,\n type DefineServerFnFn,\n type ServerFnHandler,\n} from \"./defineServerFn.ts\";\n\n/** Initialize every app created by `factory.createApp()`, and pages from `definePage`. */\nexport type InitApp<E extends Env = Env> = (app: Hono<E>) => void;\n\ntype HonoCtorOptions = NonNullable<ConstructorParameters<typeof Hono>[0]>;\ntype InitMiddleware = (c: Context, next: () => Promise<void>) => Promise<unknown>;\n\nexport interface FactoryOptions<E extends Env = Env> {\n initApp?: InitApp<E>;\n defaultAppOptions?: HonoCtorOptions;\n}\n\nconst boundInit = new WeakMap<object, InitApp>();\nconst appliedInit = new WeakMap<Context, Set<InitApp>>();\nconst middlewareCache = new WeakMap<InitApp, InitMiddleware[]>();\n\nfunction storedInitApp<E extends Env>(initApp: InitApp<E> | undefined): InitApp | undefined {\n return initApp as unknown as InitApp | undefined;\n}\n\nfunction bindInitApp<T extends object>(value: T, initApp?: InitApp): T {\n if (initApp) boundInit.set(value, initApp);\n return value;\n}\n\n/** `initApp` stamped onto a `definePage` / `defineServerFn` result. */\nexport function readBoundInitApp(value: unknown): InitApp | undefined {\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) return undefined;\n return boundInit.get(value);\n}\n\nexport function readPageModuleInitApp(pageDefault: unknown, data?: unknown): InitApp | undefined {\n return readBoundInitApp(pageDefault) ?? readBoundInitApp(data ?? readPageDefinition(pageDefault)?.data);\n}\n\nfunction markInitApplied(c: Context, initApp: InitApp): void {\n let set = appliedInit.get(c);\n if (!set) {\n set = new Set();\n appliedInit.set(c, set);\n }\n set.add(initApp);\n}\n\nfunction isInitApplied(c: Context, initApp: InitApp): boolean {\n return appliedInit.get(c)?.has(initApp) ?? false;\n}\n\nfunction middlewareFromInitApp(initApp: InitApp): InitMiddleware[] {\n let list = middlewareCache.get(initApp);\n if (!list) {\n const app = new Hono();\n initApp(app);\n list = app.routes.filter((route) => route.method === \"ALL\").map((route) => route.handler as InitMiddleware);\n middlewareCache.set(initApp, list);\n }\n return list;\n}\n\n/**\n * Run a factory `initApp`'s `app.use()` middleware on the current context.\n * Skips if this `initApp` already ran on `c` (e.g. via `createApp()`).\n * Params and `c.set` stay on the same context so page loaders still see them.\n */\nexport async function applyInitApp(\n initApp: InitApp | undefined,\n c: Context,\n next: () => Promise<Response>,\n): Promise<Response> {\n if (!initApp || isInitApplied(c, initApp)) return next();\n markInitApplied(c, initApp);\n const handlers = middlewareFromInitApp(initApp);\n if (handlers.length === 0) return next();\n\n let response: Response | undefined;\n const run = async (i: number): Promise<void> => {\n const handler = handlers[i];\n if (!handler) {\n response = await next();\n return;\n }\n const out = await handler(c, () => run(i + 1));\n if (out instanceof Response) response = out;\n };\n await run(0);\n return response ?? c.res;\n}\n\nexport class Factory<E extends Env = Env> {\n private initApp?: InitApp<E>;\n private defaultAppOptions?: HonoCtorOptions;\n\n constructor(init?: FactoryOptions<E>) {\n this.initApp = init?.initApp;\n this.defaultAppOptions = init?.defaultAppOptions;\n }\n\n /**\n * Create a Hono app typed with this factory's `Env`.\n * Runs `initApp` (if provided) before returning, so middleware is registered\n * before you call `mountVino(app)`.\n */\n createApp = (options?: HonoCtorOptions): Hono<E> => {\n const app = new Hono<E>(\n options && this.defaultAppOptions\n ? { ...this.defaultAppOptions, ...options }\n : (options ?? this.defaultAppOptions),\n );\n if (this.initApp) {\n const initApp = this.initApp;\n app.use(async (c, next) => {\n markInitApplied(c, initApp as unknown as InitApp);\n await next();\n });\n initApp(app);\n }\n return app;\n };\n\n /** Same as `definePage`, with `c` typed as `Context<E>` and this factory's `initApp`. */\n definePage: DefinePageFn<E> = ((page: never) =>\n bindInitApp(definePageImpl(page), storedInitApp(this.initApp))) as DefinePageFn<E>;\n\n /** Same as `defineServerPage`, with `c` typed as `Context<E>` and this factory's `initApp`. */\n defineServerPage: DefinePageFn<E> = ((page: never) =>\n bindInitApp(defineServerPageImpl(page), storedInitApp(this.initApp))) as DefinePageFn<E>;\n\n /** Same as `defineServerFn`, with `c` typed as `Context<E>` and this factory's `initApp`. */\n defineServerFn: DefineServerFnFn<E> = ((fn: ServerFnHandler<never, E>) =>\n bindInitApp(defineServerFnImpl(fn), storedInitApp(this.initApp))) as DefineServerFnFn<E>;\n}\n\n/**\n * Create a factory that binds `Env` onto page helpers and `createApp()`.\n *\n * Pages keep the `initApp` of the factory that defined them, so a blog factory\n * can set `c.var.db` only for `blogFactory.definePage` routes while the root\n * app still uses the global factory.\n *\n * @example\n * // src/factory.ts\n * export const factory = createFactory<Env>({\n * initApp: (app) => {\n * app.use(async (c, next) => {\n * c.set(\"db\", drizzle(c.env.DB))\n * await next()\n * })\n * },\n * })\n * export const blogFactory = createFactory<BlogEnv>({\n * initApp: (app) => {\n * app.use(async (c, next) => {\n * c.set(\"posts\", createPosts(c.env.BLOG_DB))\n * await next()\n * })\n * },\n * })\n *\n * @example\n * // src/server.ts\n * const app = factory.createApp()\n * mountVino(app)\n *\n * @example\n * // src/pages/blog/[slug].tsx\n * export default blogFactory.definePage({\n * data: (c) => c.var.posts.get(c.req.param(\"slug\")),\n * render: ({ data }) => <h1>{data.title}</h1>,\n * })\n */\nexport function createFactory<E extends Env = Env>(options?: Fact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oViteOptions, i as ManifestPage, l as VinoManifest, o as PageProps, r as LayoutProps, s as RenderMode, t as CreateVinoOptions, u as VinoPayload } from "./types-CQITdkpF.mjs";
|
|
2
2
|
import { wrapComponent, wrapModule } from "./component-wrap.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { C as defineServerFn, S as ServerFnHandler, T as readServerFn, _ as isPageDefinition, a as createFactory, b as DefineServerFnFn, c as DefinePageFn, d as PageDataFn, f as PageDefinition, g as isClientPageDefinition, h as defineServerPage, l as DefinePageOptions, m as definePage, n as FactoryOptions, p as PageRender, r as InitApp, t as Factory, u as InferDefinePageOptions, v as isServerPageDefinition, w as isServerFn, x as ServerFn, y as resolvePageRender } from "./factory-CVT0-OZw.mjs";
|
|
4
4
|
import { Env, Hono, Schema } from "hono";
|
|
5
5
|
import { BlankSchema } from "hono/types";
|
|
6
6
|
//#region src/vino/createVino.d.ts
|
|
@@ -41,5 +41,5 @@ declare const COMPONENT_TAG = "vino-component";
|
|
|
41
41
|
declare const NAV_HEADER = "X-Vino-Nav";
|
|
42
42
|
declare const SHELL_HEADER = "X-Vino-Shell";
|
|
43
43
|
//#endregion
|
|
44
|
-
export { COMPONENT_TAG, type CreateVinoOptions, type DefinePageFn, type DefinePageOptions, type DefineServerFnFn, Factory, type InferDefinePageOptions, type LayoutProps, type ManifestPage, NAV_HEADER, PAGE_SLOT_ID, PAYLOAD_SCRIPT_ID, type PageConfig, type PageDataFn, type PageDefinition, type PageProps, type PageRender, type RenderMode, SHELL_HEADER, type ServerFn, type ServerFnHandler, type VinoManifest, type VinoPayload, type VinoViteOptions, applyParams, compileFilePath, createFactory, createVino, definePage, defineServerFn, defineServerPage, isClientPageDefinition, isPageDefinition, isServerFn, isServerPageDefinition, mountVino, readServerFn, resolvePageRender, wrapComponent, wrapModule };
|
|
44
|
+
export { COMPONENT_TAG, type CreateVinoOptions, type DefinePageFn, type DefinePageOptions, type DefineServerFnFn, Factory, type FactoryOptions, type InferDefinePageOptions, type InitApp, type LayoutProps, type ManifestPage, NAV_HEADER, PAGE_SLOT_ID, PAYLOAD_SCRIPT_ID, type PageConfig, type PageDataFn, type PageDefinition, type PageProps, type PageRender, type RenderMode, SHELL_HEADER, type ServerFn, type ServerFnHandler, type VinoManifest, type VinoPayload, type VinoViteOptions, applyParams, compileFilePath, createFactory, createVino, definePage, defineServerFn, defineServerPage, isClientPageDefinition, isPageDefinition, isServerFn, isServerPageDefinition, mountVino, readServerFn, resolvePageRender, wrapComponent, wrapModule };
|
|
45
45
|
//# sourceMappingURL=vino.d.mts.map
|
package/dist/vino.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vino.d.mts","names":[],"sources":["../src/vino/createVino.ts","../src/vino/compile.ts","../src/vino/constants.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"vino.d.mts","names":[],"sources":["../src/vino/createVino.ts","../src/vino/compile.ts","../src/vino/constants.ts"],"mappings":";;;;;;;;;;iBAqGgB,UAAU,UAAU,KAAK,UAAU,QAAQ,yBAAyB,KAAK,KAAK,GAAG,GAAG,WAAW,UAAS,oBAAyB,KAAK,GAAG,GAAG;;;;;;iBAc5I,WAAW,UAAU,MAAM,KAAK,UAAU,SAAS,aAAa,+BAA+B,UAAS,oBAAyB,KAAK,GAAG,GAAG;;;UCnH3I;;EAEf;;EAEA;EACA;EACA;EACA;;;;;;;iBAoBc,gBAAgB,uBAAuB;iBA8DvC,YAAY,cAAc,QAAQ;;;cCzFrC;cACA;cACA;cAKA;cACA"}
|
package/dist/vino.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { c as PAGE_SLOT_ID, l as PAYLOAD_SCRIPT_ID, o as NAV_HEADER, t as COMPON
|
|
|
2
2
|
import { a as isServerPageDefinition, i as isPageDefinition, n as defineServerPage, r as isClientPageDefinition, s as resolvePageRender, t as definePage } from "./definePage--9Pz7rHs.mjs";
|
|
3
3
|
import { c as loadMergedData, r as compileFilePath, s as loadMergedConfig, t as applyParams } from "./compile-glNMkyyx.mjs";
|
|
4
4
|
import { a as readServerFn, i as isServerFn, r as defineServerFn } from "./defineServerFn-H-bz7xBX.mjs";
|
|
5
|
-
import { Factory, createFactory } from "./factory.mjs";
|
|
5
|
+
import { Factory, applyInitApp, createFactory, readPageModuleInitApp } from "./factory.mjs";
|
|
6
6
|
import { wrapComponent, wrapModule } from "./component-wrap.mjs";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
import { jsxDEV } from "hono/jsx/jsx-dev-runtime";
|
|
@@ -130,6 +130,9 @@ function resolveRenderMode(c) {
|
|
|
130
130
|
}
|
|
131
131
|
async function handlePage(c, page) {
|
|
132
132
|
const pageMod = await page.loadPage();
|
|
133
|
+
return applyInitApp(readPageModuleInitApp(pageMod.default), c, () => handlePageBody(c, page, pageMod));
|
|
134
|
+
}
|
|
135
|
+
async function handlePageBody(c, page, pageMod) {
|
|
133
136
|
if (isHonoApp(pageMod.default)) return pageMod.default.fetch(c.req.raw, c.env, c.executionCtx);
|
|
134
137
|
const method = c.req.method;
|
|
135
138
|
const named = pageMod[method];
|
package/dist/vino.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vino.mjs","names":["jsx","jsx","assetsIsDev","manifest","virtualManifest"],"sources":["../src/vino/render.ts","../src/vino/createVino.ts"],"sourcesContent":["import { Hono } from \"hono\";\nimport type { Context } from \"hono\";\nimport type { Child } from \"hono/jsx\";\nimport { jsxDEV as jsx } from \"hono/jsx/jsx-dev-runtime\";\nimport { jsxRenderer } from \"hono/jsx-renderer\";\nimport { PAGE_SLOT_ID, PAYLOAD_SCRIPT_ID } from \"./constants.ts\";\nimport type { ManifestPage, PageConfig, PageModule, RenderMode, VinoPayload } from \"./types.ts\";\n\nfunction DefaultLayout(props: { children?: Child }) {\n return jsx(\"html\", {\n children: [\n jsx(\"head\", {\n children: [\n jsx(\"meta\", { charset: \"utf-8\" }),\n jsx(\"meta\", { name: \"viewport\", content: \"width=device-width, initial-scale=1\" }),\n ],\n }),\n jsx(\"body\", { children: props.children }),\n ],\n });\n}\n\nexport function isHonoApp(value: unknown): value is Hono {\n return value instanceof Hono;\n}\n\nfunction payloadScript(payload: VinoPayload): string {\n const json = JSON.stringify(payload).replaceAll(\"<\", \"\\\\u003c\");\n return `<script id=\"${PAYLOAD_SCRIPT_ID}\" type=\"application/json\">${json}</script>`;\n}\n\nexport function injectDocument(\n html: string,\n payload: VinoPayload,\n isDev: boolean,\n scriptSrc: string,\n): string {\n const vite = isDev ? `<script type=\"module\" src=\"/@vite/client\"></script>` : \"\";\n const client = `<script type=\"module\" src=\"${scriptSrc}\"></script>`;\n const inject = `${vite}${payloadScript(payload)}${client}`;\n if (html.includes(\"</body>\")) return html.replace(\"</body>\", `${inject}</body>`);\n if (html.includes(\"</html>\")) return html.replace(\"</html>\", `${inject}</html>`);\n return `<!DOCTYPE html>${html}${inject}`;\n}\n\nasync function ensureJsxRenderer(c: Context): Promise<void> {\n await jsxRenderer(undefined, { docType: true })(c, async () => {});\n}\n\nfunction needsPageSlot(page: ManifestPage, config: PageConfig, mode: RenderMode): boolean {\n if (mode === \"shell\" || mode === \"content\") return true;\n if (page.isClientPage) return true;\n if (config.clientRouting === true) return true;\n if (config.prerender === \"partial\") return true;\n return false;\n}\n\nfunction emptySlot(): Child {\n return jsx(\"div\", { id: PAGE_SLOT_ID });\n}\n\nfunction wrapSlot(children: Child): Child {\n return jsx(\"div\", { id: PAGE_SLOT_ID, children });\n}\n\nfunction buildPayload(options: {\n page: ManifestPage;\n params: Record<string, string>;\n data: unknown;\n config: PageConfig;\n mode: RenderMode;\n requestPath?: string;\n title?: string;\n}): VinoPayload {\n const { page, params, data, config, mode, requestPath, title } = options;\n const path = requestPath ?? (page.path === \"\" ? \"/\" : page.path);\n return {\n path,\n params,\n data,\n clientRouting: config.clientRouting === true,\n clientPage: page.isClientPage ? page.path : null,\n partial: mode === \"shell\",\n title,\n };\n}\n\nexport async function renderPageHtml(options: {\n c: Context;\n page: ManifestPage;\n pageMod: PageModule;\n pageNode?: Child | null;\n data: unknown;\n params: Record<string, string>;\n config: PageConfig;\n isDev: boolean;\n clientScriptSrc: string;\n mode?: RenderMode;\n title?: string;\n}): Promise<{ html: string; payload: VinoPayload }> {\n const {\n c,\n page,\n pageNode = null,\n data,\n params,\n config,\n isDev,\n clientScriptSrc,\n mode = \"full\",\n title,\n } = options;\n\n const payload = buildPayload({\n page,\n params,\n data,\n config,\n mode,\n requestPath: c.req.path,\n title,\n });\n\n if (mode === \"content\") {\n if (pageNode == null) throw new Error(\"content render requires pageNode\");\n const node = wrapSlot(pageNode);\n await ensureJsxRenderer(c);\n const rendered = await c.render(node as never);\n let html = await rendered.text();\n html = html.replace(/^<!DOCTYPE html>/i, \"\");\n html = `${html}${payloadScript(payload)}`;\n return { html, payload };\n }\n\n let node: Child = mode === \"shell\" ? emptySlot() : (pageNode as Child);\n if (mode !== \"shell\" && needsPageSlot(page, config, mode)) {\n node = wrapSlot(node);\n }\n\n const layouts = await Promise.all(page.loadLayouts.map((load) => load()));\n for (const layout of [...layouts].reverse()) {\n const Layout = layout.default;\n node = jsx(Layout, { data, params, children: node });\n }\n if (layouts.length === 0) {\n node = jsx(DefaultLayout, { children: node });\n }\n\n await ensureJsxRenderer(c);\n const rendered = await c.render(node as never);\n let html = await rendered.text();\n\n html = injectDocument(html, payload, isDev, clientScriptSrc);\n if (!html.startsWith(\"<!\")) html = `<!DOCTYPE html>${html}`;\n return { html, payload };\n}\n","import { Hono } from \"hono\";\nimport type { Context, Env, Schema } from \"hono\";\nimport type { BlankSchema } from \"hono/types\";\nimport { jsxDEV as jsx } from \"hono/jsx/jsx-dev-runtime\";\nimport { manifest as virtualManifest } from \"virtual:vino/manifest\";\nimport { isDev as assetsIsDev, clientScriptSrc } from \"virtual:vino/assets\";\nimport { NAV_HEADER, SHELL_HEADER } from \"./constants.ts\";\nimport { loadMergedConfig, loadMergedData } from \"./config.ts\";\nimport { resolvePageRender } from \"./definePage.ts\";\nimport { isHonoApp, renderPageHtml } from \"./render.ts\";\nimport type { CreateVinoOptions, ManifestPage, PageModule, RenderMode } from \"./types.ts\";\n\ntype AppContext = Context;\n\nfunction requestParams(c: AppContext): Record<string, string> {\n try {\n return c.req.param();\n } catch {\n return {};\n }\n}\n\nfunction pageFromModule(pageMod: PageModule, data: unknown, params: Record<string, string>) {\n const Page = resolvePageRender(pageMod.default);\n if (Page) return jsx(Page, { data, params });\n return pageMod.default as never;\n}\n\nfunction resolveRenderMode(c: AppContext): RenderMode {\n if (c.req.header(SHELL_HEADER)) return \"shell\";\n if (c.req.header(NAV_HEADER)) return \"content\";\n return \"full\";\n}\n\nasync function handlePage(c: AppContext, page: ManifestPage): Promise<Response> {\n const pageMod = await page.loadPage();\n if (isHonoApp(pageMod.default)) {\n return pageMod.default.fetch(c.req.raw, c.env, c.executionCtx);\n }\n\n const method = c.req.method;\n const named = pageMod[method];\n const hasPage = Boolean(resolvePageRender(pageMod.default));\n const mode = resolveRenderMode(c);\n\n if (typeof named === \"function\" && (method !== \"GET\" || !hasPage)) {\n const result: unknown = await (named as (ctx: AppContext) => unknown)(c);\n if (result instanceof Response) return result;\n if (method === \"GET\" || method === \"HEAD\") {\n const config = loadMergedConfig(page, pageMod);\n const params = requestParams(c);\n const data = mode === \"shell\" ? undefined : await loadMergedData(page, c, pageMod);\n const { html } = await renderPageHtml({\n c,\n page,\n pageMod,\n pageNode: mode === \"shell\" ? null : (result as never),\n data,\n params,\n config,\n isDev: assetsIsDev,\n clientScriptSrc,\n mode,\n });\n return c.html(html);\n }\n return c.json(result as never);\n }\n\n if (method !== \"GET\" && method !== \"HEAD\") {\n return c.text(\"Method Not Allowed\", 405);\n }\n\n const config = loadMergedConfig(page, pageMod);\n const params = requestParams(c);\n const data = mode === \"shell\" ? undefined : await loadMergedData(page, c, pageMod);\n const pageNode = mode === \"shell\" ? null : pageFromModule(pageMod, data, params);\n const { html } = await renderPageHtml({\n c,\n page,\n pageMod,\n pageNode: pageNode,\n data,\n params,\n config,\n isDev: assetsIsDev,\n clientScriptSrc,\n mode,\n });\n return c.html(html);\n}\n\n/**\n * Mount filesystem pages from the Vite-generated manifest onto a user-owned Hono app.\n * Extra API routes should be registered on `app` before calling this.\n */\nexport function mountVino<E extends Env, S extends Schema, BasePath extends string>(app: Hono<E, S, BasePath>, options: CreateVinoOptions = {}): Hono<E, S, BasePath> {\n const manifest = options.manifest ?? virtualManifest;\n for (const page of manifest.pages) {\n app.get(page.pattern, (c) => handlePage(c as AppContext, page));\n }\n\n return app;\n}\n\n/**\n * Create a new Vino app. Returns a Hono app with the Vino pages mounted.\n * @param options - The options for the Vino app.\n * @returns A Hono app with the Vino pages mounted.\n */\nexport function createVino<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = \"/\">(options: CreateVinoOptions = {}): Hono<E, S, BasePath> {\n const app = new Hono<E, S, BasePath>();\n return mountVino(app, options);\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAS,cAAc,OAA6B;CAClD,OAAOA,OAAI,QAAQ,EACjB,UAAU,CACRA,OAAI,QAAQ,EACV,UAAU,CACRA,OAAI,QAAQ,EAAE,SAAS,QAAQ,CAAC,GAChCA,OAAI,QAAQ;EAAE,MAAM;EAAY,SAAS;CAAsC,CAAC,CAClF,EACF,CAAC,GACDA,OAAI,QAAQ,EAAE,UAAU,MAAM,SAAS,CAAC,CAC1C,EACF,CAAC;AACH;AAEA,SAAgB,UAAU,OAA+B;CACvD,OAAO,iBAAiB;AAC1B;AAEA,SAAS,cAAc,SAA8B;CACnD,MAAM,OAAO,KAAK,UAAU,OAAO,CAAC,CAAC,WAAW,KAAK,SAAS;CAC9D,OAAO,eAAe,kBAAkB,4BAA4B,KAAK;AAC3E;AAEA,SAAgB,eACd,MACA,SACA,OACA,WACQ;CACR,MAAM,OAAO,QAAQ,yDAAwD;CAC7E,MAAM,SAAS,8BAA8B,UAAU;CACvD,MAAM,SAAS,GAAG,OAAO,cAAc,OAAO,IAAI;CAClD,IAAI,KA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EACA;CACF,CAAC;CACD,OAAO,EAAE,KAAK,IAAI;AACpB;;;;;AAMA,SAAgB,UAAoE,KAA2B,UAA6B,CAAC,GAAyB;CACpK,MAAMC,aAAW,QAAQ,YAAYC;CACrC,KAAK,MAAM,QAAQD,WAAS,OAC1B,IAAI,IAAI,KAAK,UAAU,MAAM,WAAW,GAAiB,IAAI,CAAC;CAGhE,OAAO;AACT;;;;;;AAOA,SAAgB,WAA+F,UAA6B,CAAC,GAAyB;CAEpK,OAAO,UAAU,IADD,KACG,GAAG,OAAO;AAC/B"}
|
|
1
|
+
{"version":3,"file":"vino.mjs","names":["jsx","jsx","assetsIsDev","manifest","virtualManifest"],"sources":["../src/vino/render.ts","../src/vino/createVino.ts"],"sourcesContent":["import { Hono } from \"hono\";\nimport type { Context } from \"hono\";\nimport type { Child } from \"hono/jsx\";\nimport { jsxDEV as jsx } from \"hono/jsx/jsx-dev-runtime\";\nimport { jsxRenderer } from \"hono/jsx-renderer\";\nimport { PAGE_SLOT_ID, PAYLOAD_SCRIPT_ID } from \"./constants.ts\";\nimport type { ManifestPage, PageConfig, PageModule, RenderMode, VinoPayload } from \"./types.ts\";\n\nfunction DefaultLayout(props: { children?: Child }) {\n return jsx(\"html\", {\n children: [\n jsx(\"head\", {\n children: [\n jsx(\"meta\", { charset: \"utf-8\" }),\n jsx(\"meta\", { name: \"viewport\", content: \"width=device-width, initial-scale=1\" }),\n ],\n }),\n jsx(\"body\", { children: props.children }),\n ],\n });\n}\n\nexport function isHonoApp(value: unknown): value is Hono {\n return value instanceof Hono;\n}\n\nfunction payloadScript(payload: VinoPayload): string {\n const json = JSON.stringify(payload).replaceAll(\"<\", \"\\\\u003c\");\n return `<script id=\"${PAYLOAD_SCRIPT_ID}\" type=\"application/json\">${json}</script>`;\n}\n\nexport function injectDocument(\n html: string,\n payload: VinoPayload,\n isDev: boolean,\n scriptSrc: string,\n): string {\n const vite = isDev ? `<script type=\"module\" src=\"/@vite/client\"></script>` : \"\";\n const client = `<script type=\"module\" src=\"${scriptSrc}\"></script>`;\n const inject = `${vite}${payloadScript(payload)}${client}`;\n if (html.includes(\"</body>\")) return html.replace(\"</body>\", `${inject}</body>`);\n if (html.includes(\"</html>\")) return html.replace(\"</html>\", `${inject}</html>`);\n return `<!DOCTYPE html>${html}${inject}`;\n}\n\nasync function ensureJsxRenderer(c: Context): Promise<void> {\n await jsxRenderer(undefined, { docType: true })(c, async () => {});\n}\n\nfunction needsPageSlot(page: ManifestPage, config: PageConfig, mode: RenderMode): boolean {\n if (mode === \"shell\" || mode === \"content\") return true;\n if (page.isClientPage) return true;\n if (config.clientRouting === true) return true;\n if (config.prerender === \"partial\") return true;\n return false;\n}\n\nfunction emptySlot(): Child {\n return jsx(\"div\", { id: PAGE_SLOT_ID });\n}\n\nfunction wrapSlot(children: Child): Child {\n return jsx(\"div\", { id: PAGE_SLOT_ID, children });\n}\n\nfunction buildPayload(options: {\n page: ManifestPage;\n params: Record<string, string>;\n data: unknown;\n config: PageConfig;\n mode: RenderMode;\n requestPath?: string;\n title?: string;\n}): VinoPayload {\n const { page, params, data, config, mode, requestPath, title } = options;\n const path = requestPath ?? (page.path === \"\" ? \"/\" : page.path);\n return {\n path,\n params,\n data,\n clientRouting: config.clientRouting === true,\n clientPage: page.isClientPage ? page.path : null,\n partial: mode === \"shell\",\n title,\n };\n}\n\nexport async function renderPageHtml(options: {\n c: Context;\n page: ManifestPage;\n pageMod: PageModule;\n pageNode?: Child | null;\n data: unknown;\n params: Record<string, string>;\n config: PageConfig;\n isDev: boolean;\n clientScriptSrc: string;\n mode?: RenderMode;\n title?: string;\n}): Promise<{ html: string; payload: VinoPayload }> {\n const {\n c,\n page,\n pageNode = null,\n data,\n params,\n config,\n isDev,\n clientScriptSrc,\n mode = \"full\",\n title,\n } = options;\n\n const payload = buildPayload({\n page,\n params,\n data,\n config,\n mode,\n requestPath: c.req.path,\n title,\n });\n\n if (mode === \"content\") {\n if (pageNode == null) throw new Error(\"content render requires pageNode\");\n const node = wrapSlot(pageNode);\n await ensureJsxRenderer(c);\n const rendered = await c.render(node as never);\n let html = await rendered.text();\n html = html.replace(/^<!DOCTYPE html>/i, \"\");\n html = `${html}${payloadScript(payload)}`;\n return { html, payload };\n }\n\n let node: Child = mode === \"shell\" ? emptySlot() : (pageNode as Child);\n if (mode !== \"shell\" && needsPageSlot(page, config, mode)) {\n node = wrapSlot(node);\n }\n\n const layouts = await Promise.all(page.loadLayouts.map((load) => load()));\n for (const layout of [...layouts].reverse()) {\n const Layout = layout.default;\n node = jsx(Layout, { data, params, children: node });\n }\n if (layouts.length === 0) {\n node = jsx(DefaultLayout, { children: node });\n }\n\n await ensureJsxRenderer(c);\n const rendered = await c.render(node as never);\n let html = await rendered.text();\n\n html = injectDocument(html, payload, isDev, clientScriptSrc);\n if (!html.startsWith(\"<!\")) html = `<!DOCTYPE html>${html}`;\n return { html, payload };\n}\n","import { Hono } from \"hono\";\nimport type { Context, Env, Schema } from \"hono\";\nimport type { BlankSchema } from \"hono/types\";\nimport { jsxDEV as jsx } from \"hono/jsx/jsx-dev-runtime\";\nimport { manifest as virtualManifest } from \"virtual:vino/manifest\";\nimport { isDev as assetsIsDev, clientScriptSrc } from \"virtual:vino/assets\";\nimport { NAV_HEADER, SHELL_HEADER } from \"./constants.ts\";\nimport { loadMergedConfig, loadMergedData } from \"./config.ts\";\nimport { resolvePageRender } from \"./definePage.ts\";\nimport { applyInitApp, readPageModuleInitApp } from \"./factory.ts\";\nimport { isHonoApp, renderPageHtml } from \"./render.ts\";\nimport type { CreateVinoOptions, ManifestPage, PageModule, RenderMode } from \"./types.ts\";\n\ntype AppContext = Context;\n\nfunction requestParams(c: AppContext): Record<string, string> {\n try {\n return c.req.param();\n } catch {\n return {};\n }\n}\n\nfunction pageFromModule(pageMod: PageModule, data: unknown, params: Record<string, string>) {\n const Page = resolvePageRender(pageMod.default);\n if (Page) return jsx(Page, { data, params });\n return pageMod.default as never;\n}\n\nfunction resolveRenderMode(c: AppContext): RenderMode {\n if (c.req.header(SHELL_HEADER)) return \"shell\";\n if (c.req.header(NAV_HEADER)) return \"content\";\n return \"full\";\n}\n\nasync function handlePage(c: AppContext, page: ManifestPage): Promise<Response> {\n const pageMod = await page.loadPage();\n return applyInitApp(readPageModuleInitApp(pageMod.default), c, () => handlePageBody(c, page, pageMod));\n}\n\nasync function handlePageBody(c: AppContext, page: ManifestPage, pageMod: PageModule): Promise<Response> {\n if (isHonoApp(pageMod.default)) {\n return pageMod.default.fetch(c.req.raw, c.env, c.executionCtx);\n }\n\n const method = c.req.method;\n const named = pageMod[method];\n const hasPage = Boolean(resolvePageRender(pageMod.default));\n const mode = resolveRenderMode(c);\n\n if (typeof named === \"function\" && (method !== \"GET\" || !hasPage)) {\n const result: unknown = await (named as (ctx: AppContext) => unknown)(c);\n if (result instanceof Response) return result;\n if (method === \"GET\" || method === \"HEAD\") {\n const config = loadMergedConfig(page, pageMod);\n const params = requestParams(c);\n const data = mode === \"shell\" ? undefined : await loadMergedData(page, c, pageMod);\n const { html } = await renderPageHtml({\n c,\n page,\n pageMod,\n pageNode: mode === \"shell\" ? null : (result as never),\n data,\n params,\n config,\n isDev: assetsIsDev,\n clientScriptSrc,\n mode,\n });\n return c.html(html);\n }\n return c.json(result as never);\n }\n\n if (method !== \"GET\" && method !== \"HEAD\") {\n return c.text(\"Method Not Allowed\", 405);\n }\n\n const config = loadMergedConfig(page, pageMod);\n const params = requestParams(c);\n const data = mode === \"shell\" ? undefined : await loadMergedData(page, c, pageMod);\n const pageNode = mode === \"shell\" ? null : pageFromModule(pageMod, data, params);\n const { html } = await renderPageHtml({\n c,\n page,\n pageMod,\n pageNode: pageNode,\n data,\n params,\n config,\n isDev: assetsIsDev,\n clientScriptSrc,\n mode,\n });\n return c.html(html);\n}\n\n/**\n * Mount filesystem pages from the Vite-generated manifest onto a user-owned Hono app.\n * Extra API routes should be registered on `app` before calling this.\n */\nexport function mountVino<E extends Env, S extends Schema, BasePath extends string>(app: Hono<E, S, BasePath>, options: CreateVinoOptions = {}): Hono<E, S, BasePath> {\n const manifest = options.manifest ?? virtualManifest;\n for (const page of manifest.pages) {\n app.get(page.pattern, (c) => handlePage(c as AppContext, page));\n }\n\n return app;\n}\n\n/**\n * Create a new Vino app. Returns a Hono app with the Vino pages mounted.\n * @param options - The options for the Vino app.\n * @returns A Hono app with the Vino pages mounted.\n */\nexport function createVino<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = \"/\">(options: CreateVinoOptions = {}): Hono<E, S, BasePath> {\n const app = new Hono<E, S, BasePath>();\n return mountVino(app, options);\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAS,cAAc,OAA6B;CAClD,OAAOA,OAAI,QAAQ,EACjB,UAAU,CACRA,OAAI,QAAQ,EACV,UAAU,CACRA,OAAI,QAAQ,EAAE,SAAS,QAAQ,CAAC,GAChCA,OAAI,QAAQ;EAAE,MAAM;EAAY,SAAS;CAAsC,CAAC,CAClF,EACF,CAAC,GACDA,OAAI,QAAQ,EAAE,UAAU,MAAM,SAAS,CAAC,CAC1C,EACF,CAAC;AACH;AAEA,SAAgB,UAAU,OAA+B;CACvD,OAAO,iBAAiB;AAC1B;AAEA,SAAS,cAAc,SAA8B;CACnD,MAAM,OAAO,KAAK,UAAU,OAAO,CAAC,CAAC,WAAW,KAAK,SAAS;CAC9D,OAAO,eAAe,kBAAkB,4BAA4B,KAAK;AAC3E;AAEA,SAAgB,eACd,MACA,SACA,OACA,WACQ;CACR,MAAM,OAAO,QAAQ,yDAAwD;CAC7E,MAAM,SAAS,8BAA8B,UAAU;CACvD,MAAM,SAAS,GAAG,OAAO,cAAc,OAAO,IAAI;CAClD,IAAI,KAAK,SAAS,SAAS,GAAG,OAAO,KAAK,QAAQ,WAAW,GAAG,OAAO,QAAQ;CAC/E,IAAI,KAAK,SAAS,SAAS,GAAG,OAAO,KAAK,QAAQ,WAAW,GAAG,OAAO,QAAQ;CAC/E,OAAO,kBAAkB,OAAO;AAClC;AAEA,eAAe,kBAAkB,GAA2B;CA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