revojs 0.1.46 → 0.1.47
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/commands/index.mjs +1 -1
- package/dist/{index-BaqVUbna.d.mts → index-nxflReVm.d.mts} +14 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +12 -1
- package/dist/kit/index.d.mts +1 -1
- package/dist/{package-CHq5U5yh.mjs → package-DSa1C_1a.mjs} +1 -1
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/index.mjs +18 -4
- package/package.json +1 -1
- package/src/types/assets.d.ts +7 -0
package/dist/commands/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as version, t as name } from "../package-
|
|
2
|
+
import { n as version, t as name } from "../package-DSa1C_1a.mjs";
|
|
3
3
|
import { defineCommand, runMain } from "citty";
|
|
4
4
|
//#region src/commands/run/index.ts
|
|
5
5
|
var run_default = defineCommand({ setup() {} });
|
|
@@ -191,6 +191,14 @@ declare const mimeTypes: Record<string, string>;
|
|
|
191
191
|
type Environment = typeof CLIENT | typeof SERVER;
|
|
192
192
|
type Virtual = (environment: Environment) => undefined | string | Promise<string>;
|
|
193
193
|
type Content = () => string | Promise<string>;
|
|
194
|
+
interface Asset {
|
|
195
|
+
type: string;
|
|
196
|
+
name: string;
|
|
197
|
+
relative: string;
|
|
198
|
+
entityTag: string;
|
|
199
|
+
lastModified: string;
|
|
200
|
+
size: number;
|
|
201
|
+
}
|
|
194
202
|
interface Template {
|
|
195
203
|
tagName: string;
|
|
196
204
|
attributes: Record<string, string>;
|
|
@@ -230,4 +238,9 @@ declare const CLOSE_HOOK: Descriptor<() => void>;
|
|
|
230
238
|
//#region src/client/index.d.ts
|
|
231
239
|
declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
|
|
232
240
|
//#endregion
|
|
233
|
-
|
|
241
|
+
//#region src/middleware/index.d.ts
|
|
242
|
+
declare function createStaticMiddleware<T>(resolve: (path: string | URL) => T | Promise<T>): {
|
|
243
|
+
fetch(scope: Scope, next: (() => Result) | undefined): Promise<void | Response>;
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
export { defineMiddleware as $, PARAMETER as A, useUrl as At, RouterContext as B, Mergeable as Bt, Node as C, useCookies as Ct, OPTIONAL_WILDCARD_MATCH as D, useRouter as Dt, OPTIONAL_WILDCARD as E, useQuery as Et, Radix as F, Hookable as Ft, States as G, Success as Gt, STATES as H, Primitive as Ht, ResponseConfig as I, InferInput as It, WILDCARD_MATCH as J, isFailure as Jt, StatusCode as K, defineContext as Kt, Result as L, InferOutput as Lt, ParameterNode as M, Context as Mt, PathNode as N, Descriptor as Nt, OptionalParameterNode as O, useServer as Ot, ROUTER_CONTEXT as P, Failure as Pt, createServer as Q, Route as R, Invoke as Rt, MimeType as S, useBody as St, OPTIONAL_PARAMETER_MATCH as T, useParameters as Tt, Server as U, Schema as Ut, SERVER_CONTEXT as V, Output as Vt, ServerContext as W, Scope as Wt, cookiePriorities as X, parseSchema as Xt, WildcardNode as Y, mergeObjects as Yt, cookieSameSites as Z, CookiePriority as _, sendResponse as _t, CLIENT as a, isClient as at, HttpMethod as b, setState as bt, Content as c, mimeTypes as ct, Module as d, sendCreated as dt, defineRoute as et, SERVER as f, sendForbidden as ft, CookieOptions as g, sendRedirect as gt, Virtual as h, sendOk as ht, Asset as i, invoke as it, PARAMETER_MATCH as j, withQuery as jt, OptionalWildcardNode as k, useSetCookies as kt, DevelopmentConfig as l, parseCookiePair as lt, Template as m, sendNotFound as mt, $fetch as n, getState as nt, CLOSE_HOOK as o, isServer as ot, Source as p, sendNoContent as pt, WILDCARD as q, defineHook as qt, App as r, httpMethods as rt, Config as s, mimeType as st, createStaticMiddleware as t, encodings as tt, Environment as u, sendBadRequest as ut, CookieSameSite as v, sendUnauthorized as vt, OPTIONAL_PARAMETER as w, useHeaders as wt, Middleware as x, statusCodes as xt, Encoding as y, setCookie as yt, Router as z, Issue as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { $fetch, App, CLIENT, CLOSE_HOOK, Config, Content, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, Hookable, HttpMethod, InferInput, InferOutput, Invoke, Issue, Mergeable, Middleware, MimeType, Module, Node, OPTIONAL_PARAMETER, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD, OPTIONAL_WILDCARD_MATCH, OptionalParameterNode, OptionalWildcardNode, Output, PARAMETER, PARAMETER_MATCH, ParameterNode, PathNode, Primitive, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, Success, Template, Virtual, WILDCARD, WILDCARD_MATCH, WildcardNode, cookiePriorities, cookieSameSites, createServer, defineContext, defineHook, defineMiddleware, defineRoute, encodings, getState, httpMethods, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseCookiePair, parseSchema, sendBadRequest, sendCreated, sendForbidden, sendNoContent, sendNotFound, sendOk, sendRedirect, sendResponse, sendUnauthorized, setCookie, setState, statusCodes, useBody, useCookies, useHeaders, useParameters, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
|
1
|
+
import { $ as defineMiddleware, A as PARAMETER, At as useUrl, B as RouterContext, Bt as Mergeable, C as Node, Ct as useCookies, D as OPTIONAL_WILDCARD_MATCH, Dt as useRouter, E as OPTIONAL_WILDCARD, Et as useQuery, F as Radix, Ft as Hookable, G as States, Gt as Success, H as STATES, Ht as Primitive, I as ResponseConfig, It as InferInput, J as WILDCARD_MATCH, Jt as isFailure, K as StatusCode, Kt as defineContext, L as Result, Lt as InferOutput, M as ParameterNode, Mt as Context, N as PathNode, Nt as Descriptor, O as OptionalParameterNode, Ot as useServer, P as ROUTER_CONTEXT, Pt as Failure, Q as createServer, R as Route, Rt as Invoke, S as MimeType, St as useBody, T as OPTIONAL_PARAMETER_MATCH, Tt as useParameters, U as Server, Ut as Schema, V as SERVER_CONTEXT, Vt as Output, W as ServerContext, Wt as Scope, X as cookiePriorities, Xt as parseSchema, Y as WildcardNode, Yt as mergeObjects, Z as cookieSameSites, _ as CookiePriority, _t as sendResponse, a as CLIENT, at as isClient, b as HttpMethod, bt as setState, c as Content, ct as mimeTypes, d as Module, dt as sendCreated, et as defineRoute, f as SERVER, ft as sendForbidden, g as CookieOptions, gt as sendRedirect, h as Virtual, ht as sendOk, i as Asset, it as invoke, j as PARAMETER_MATCH, jt as withQuery, k as OptionalWildcardNode, kt as useSetCookies, l as DevelopmentConfig, lt as parseCookiePair, m as Template, mt as sendNotFound, n as $fetch, nt as getState, o as CLOSE_HOOK, ot as isServer, p as Source, pt as sendNoContent, q as WILDCARD, qt as defineHook, r as App, rt as httpMethods, s as Config, st as mimeType, t as createStaticMiddleware, tt as encodings, u as Environment, ut as sendBadRequest, v as CookieSameSite, vt as sendUnauthorized, w as OPTIONAL_PARAMETER, wt as useHeaders, x as Middleware, xt as statusCodes, y as Encoding, yt as setCookie, z as Router, zt as Issue } from "./index-nxflReVm.mjs";
|
|
2
|
+
export { $fetch, App, Asset, CLIENT, CLOSE_HOOK, Config, Content, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, Hookable, HttpMethod, InferInput, InferOutput, Invoke, Issue, Mergeable, Middleware, MimeType, Module, Node, OPTIONAL_PARAMETER, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD, OPTIONAL_WILDCARD_MATCH, OptionalParameterNode, OptionalWildcardNode, Output, PARAMETER, PARAMETER_MATCH, ParameterNode, PathNode, Primitive, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, Success, Template, Virtual, WILDCARD, WILDCARD_MATCH, WildcardNode, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, getState, httpMethods, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseCookiePair, parseSchema, sendBadRequest, sendCreated, sendForbidden, sendNoContent, sendNotFound, sendOk, sendRedirect, sendResponse, sendUnauthorized, setCookie, setState, statusCodes, useBody, useCookies, useHeaders, useParameters, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $ as useHeaders, A as encodings, B as sendCreated, C as WILDCARD, D as createServer, E as cookieSameSites, F as isServer, G as sendRedirect, H as sendNoContent, I as mimeType, J as setCookie, K as sendResponse, L as mimeTypes, M as httpMethods, N as invoke, O as defineMiddleware, P as isClient, Q as useCookies, R as parseCookiePair, S as STATES, T as cookiePriorities, U as sendNotFound, V as sendForbidden, W as sendOk, X as statusCodes, Y as setState, Z as useBody, _ as PARAMETER_MATCH, a as Hookable, at as useUrl, b as Router, c as defineHook, d as parseSchema, et as useParameters, f as OPTIONAL_PARAMETER, g as PARAMETER, h as OPTIONAL_WILDCARD_MATCH, i as SERVER, it as useSetCookies, j as getState, k as defineRoute, l as isFailure, m as OPTIONAL_WILDCARD, n as CLIENT, nt as useRouter, o as Scope, ot as withQuery, p as OPTIONAL_PARAMETER_MATCH, q as sendUnauthorized, r as CLOSE_HOOK, rt as useServer, s as defineContext, t as App, tt as useQuery, u as mergeObjects, v as ROUTER_CONTEXT, w as WILDCARD_MATCH, x as SERVER_CONTEXT, y as Radix, z as sendBadRequest } from "./app-DqEq3uwt.mjs";
|
|
2
|
+
import assets from "#assets";
|
|
2
3
|
//#region src/client/index.ts
|
|
3
4
|
async function $fetch(scope, input, options) {
|
|
4
5
|
let response;
|
|
@@ -41,4 +42,14 @@ async function $fetch(scope, input, options) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
|
-
|
|
45
|
+
//#region src/middleware/index.ts
|
|
46
|
+
function createStaticMiddleware(resolve) {
|
|
47
|
+
return defineMiddleware({ async fetch(scope, next) {
|
|
48
|
+
const { pathname } = useUrl(scope);
|
|
49
|
+
const asset = assets[pathname];
|
|
50
|
+
if (asset) return sendOk(scope, await resolve(asset.relative), { headers: new Headers({ "Content-Type": asset.type }) });
|
|
51
|
+
return next?.();
|
|
52
|
+
} });
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { $fetch, App, CLIENT, CLOSE_HOOK, Hookable, OPTIONAL_PARAMETER, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD, OPTIONAL_WILDCARD_MATCH, PARAMETER, PARAMETER_MATCH, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, WILDCARD, WILDCARD_MATCH, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, getState, httpMethods, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseCookiePair, parseSchema, sendBadRequest, sendCreated, sendForbidden, sendNoContent, sendNotFound, sendOk, sendRedirect, sendResponse, sendUnauthorized, setCookie, setState, statusCodes, useBody, useCookies, useHeaders, useParameters, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/kit/index.d.mts
CHANGED
package/dist/vite/index.d.mts
CHANGED
package/dist/vite/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { N as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, u as mergeObjects, x as SERVER_CONTEXT } from "../app-DqEq3uwt.mjs";
|
|
2
|
-
import { n as version, t as name } from "../package-
|
|
1
|
+
import { I as mimeType, N as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, u as mergeObjects, x as SERVER_CONTEXT } from "../app-DqEq3uwt.mjs";
|
|
2
|
+
import { n as version, t as name } from "../package-DSa1C_1a.mjs";
|
|
3
3
|
import { addTemplate, addTypes, addVirtual, useKit } from "../kit/index.mjs";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, posix, resolve, win32 } from "path";
|
|
5
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
5
|
+
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
6
6
|
import { cwd } from "process";
|
|
7
7
|
import { globSync } from "tinyglobby";
|
|
8
8
|
import { isRunnableDevEnvironment, mergeConfig } from "vite";
|
|
@@ -227,7 +227,6 @@ async function revojs(config) {
|
|
|
227
227
|
environments: {
|
|
228
228
|
...app.config.client && { ["client"]: {
|
|
229
229
|
consumer: "client",
|
|
230
|
-
resolve: { noExternal: true },
|
|
231
230
|
build: {
|
|
232
231
|
rolldownOptions: { input: app.config.client },
|
|
233
232
|
outDir: "./dist/public",
|
|
@@ -270,6 +269,21 @@ async function revojs(config) {
|
|
|
270
269
|
}
|
|
271
270
|
},
|
|
272
271
|
configResolved(config) {
|
|
272
|
+
addVirtual(app, "assets", () => {
|
|
273
|
+
const client = config.environments[CLIENT].build.outDir;
|
|
274
|
+
return `export default { ${globSync("**/*", { cwd: client }).reduce((assets, path) => {
|
|
275
|
+
const meta = statSync(join(client, path));
|
|
276
|
+
assets.push({
|
|
277
|
+
type: mimeType(path),
|
|
278
|
+
name: path,
|
|
279
|
+
relative: `./public/${path}`,
|
|
280
|
+
entityTag: `W/"${meta.size.toString(16)}-${Math.floor(meta.mtimeMs).toString(16)}"`,
|
|
281
|
+
lastModified: meta.mtime.toJSON(),
|
|
282
|
+
size: meta.size
|
|
283
|
+
});
|
|
284
|
+
return assets;
|
|
285
|
+
}, new Array()).map((asset) => `"/${asset.name}": ${JSON.stringify(asset)}`)} }`;
|
|
286
|
+
});
|
|
273
287
|
if (app.config.client === void 0) delete config.environments[CLIENT];
|
|
274
288
|
if (app.config.server === void 0) delete config.environments["ssr"];
|
|
275
289
|
},
|
package/package.json
CHANGED