revojs 0.1.31 → 0.1.33
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-CctiAxL9.js → app-Cw42JCxa.js} +15 -10
- package/dist/{index-py7c6iKv.d.ts → index-FHYfF5lq.d.ts} +6 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kit/index.d.ts +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
|
@@ -146,8 +146,8 @@ function useQuery(scope, schema) {
|
|
|
146
146
|
const entries = Object.fromEntries(searchParams);
|
|
147
147
|
return schema ? parseSchema(scope, schema, entries) : entries;
|
|
148
148
|
}
|
|
149
|
-
function withQuery(input, query) {
|
|
150
|
-
const url = new URL(input);
|
|
149
|
+
function withQuery(scope, input, query) {
|
|
150
|
+
const url = new URL(input, useUrl(scope));
|
|
151
151
|
for (const name in query) url.searchParams.set(name, query[name]);
|
|
152
152
|
return url.href;
|
|
153
153
|
}
|
|
@@ -212,10 +212,10 @@ function sendText(scope, text, config) {
|
|
|
212
212
|
response.headers.set("Content-Type", "text/plain");
|
|
213
213
|
return new Response(text, mergeObjects(response, config));
|
|
214
214
|
}
|
|
215
|
-
function sendHtml(scope,
|
|
215
|
+
function sendHtml(scope, html, config) {
|
|
216
216
|
const { response } = useServer(scope);
|
|
217
217
|
response.headers.set("Content-Type", "text/html");
|
|
218
|
-
return new Response(
|
|
218
|
+
return new Response(html, mergeObjects(response, config));
|
|
219
219
|
}
|
|
220
220
|
function sendJson(scope, value, config) {
|
|
221
221
|
const { response } = useServer(scope);
|
|
@@ -228,15 +228,20 @@ function sendRedirect(scope, path, config) {
|
|
|
228
228
|
response.headers.set("Location", path);
|
|
229
229
|
return new Response(null, mergeObjects(response, config));
|
|
230
230
|
}
|
|
231
|
-
function sendBadRequest(scope,
|
|
231
|
+
function sendBadRequest(scope, body, config) {
|
|
232
232
|
const { response } = useServer(scope);
|
|
233
233
|
response.status = 400;
|
|
234
|
-
return new Response(
|
|
234
|
+
return new Response(body, mergeObjects(response, config));
|
|
235
235
|
}
|
|
236
|
-
function sendUnauthorized(scope, config) {
|
|
236
|
+
function sendUnauthorized(scope, body, config) {
|
|
237
237
|
const { response } = useServer(scope);
|
|
238
238
|
response.status = 401;
|
|
239
|
-
return new Response(
|
|
239
|
+
return new Response(body, mergeObjects(response, config));
|
|
240
|
+
}
|
|
241
|
+
function sendNotFound(scope, body, config) {
|
|
242
|
+
const { response } = useServer(scope);
|
|
243
|
+
response.status = 404;
|
|
244
|
+
return new Response(body, mergeObjects(response, config));
|
|
240
245
|
}
|
|
241
246
|
function mimeType(file) {
|
|
242
247
|
return mimeTypes[/\.([a-zA-Z0-9]+?)$/.exec(file)?.at(1) ?? ""] ?? "text/plain";
|
|
@@ -263,7 +268,7 @@ async function createServer() {
|
|
|
263
268
|
middlewares,
|
|
264
269
|
async fetch(scope) {
|
|
265
270
|
try {
|
|
266
|
-
return await invoke(scope, middlewares);
|
|
271
|
+
return await invoke(scope, middlewares) ?? sendNotFound(scope);
|
|
267
272
|
} catch (value) {
|
|
268
273
|
if (value instanceof Response) return value;
|
|
269
274
|
throw value;
|
|
@@ -444,4 +449,4 @@ const CLIENT = "client";
|
|
|
444
449
|
const CLOSE_HOOK = defineHook("CLOSE_HOOK");
|
|
445
450
|
|
|
446
451
|
//#endregion
|
|
447
|
-
export { isClient as A,
|
|
452
|
+
export { isClient as A, sendUnauthorized as B, WILDCARD as C, defineRoute as D, defineMiddleware as E, sendHtml as F, useQuery as G, setState as H, sendJson as I, useSetCookies as J, useRouter as K, sendNotFound as L, mimeType as M, mimeTypes as N, getState as O, sendBadRequest as P, sendRedirect as R, STATES as S, createServer as T, useCookies as U, setCookie as V, useHeaders as W, withQuery as X, useUrl as Y, PARAMETER_MATCH as _, Hookable as a, Router as b, defineHook as c, parseSchema as d, OPTIONAL_PARAMETER as f, PARAMETER as g, OPTIONAL_WILDCARD_MATCH as h, SERVER as i, isServer as j, invoke as k, isFailure as l, OPTIONAL_WILDCARD as m, CLIENT as n, Scope as o, OPTIONAL_PARAMETER_MATCH as p, useServer as q, CLOSE_HOOK as r, defineContext as s, App as t, mergeObjects as u, ROUTER_CONTEXT as v, WILDCARD_MATCH as w, SERVER_CONTEXT as x, Radix as y, sendText as z };
|
|
@@ -138,7 +138,7 @@ declare function useUrl(scope: Scope, base?: string): URL;
|
|
|
138
138
|
declare function useHeaders(scope: Scope): Headers;
|
|
139
139
|
declare function useQuery(scope: Scope): Record<string, string>;
|
|
140
140
|
declare function useQuery<T extends Schema>(scope: Scope, schema: T): InferOutput<T>;
|
|
141
|
-
declare function withQuery(input: string, query: Record<string, string>): string;
|
|
141
|
+
declare function withQuery(scope: Scope, input: string, query: Record<string, string>): string;
|
|
142
142
|
declare function useCookies(scope: Scope): Record<string, string>;
|
|
143
143
|
declare function useCookies<T extends Schema>(scope: Scope, schema: T): InferOutput<T>;
|
|
144
144
|
declare function useSetCookies(scope: Scope): Record<string, string>;
|
|
@@ -147,11 +147,12 @@ declare function setCookie(scope: Scope, name: string, value: string, options?:
|
|
|
147
147
|
declare function getState<T>(scope: Scope, name: string): T;
|
|
148
148
|
declare function setState<T>(scope: Scope, name: string, value: T): void;
|
|
149
149
|
declare function sendText(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
|
|
150
|
-
declare function sendHtml(scope: Scope,
|
|
150
|
+
declare function sendHtml(scope: Scope, html: string, config?: Mergeable<ResponseConfig>): Response;
|
|
151
151
|
declare function sendJson<T>(scope: Scope, value: T, config?: Mergeable<ResponseConfig>): Response;
|
|
152
152
|
declare function sendRedirect(scope: Scope, path: string, config?: Mergeable<ResponseConfig>): Response;
|
|
153
|
-
declare function sendBadRequest(scope: Scope,
|
|
154
|
-
declare function sendUnauthorized(scope: Scope, config?: Mergeable<ResponseConfig>): Response;
|
|
153
|
+
declare function sendBadRequest(scope: Scope, body?: BodyInit, config?: Mergeable<ResponseConfig>): Response;
|
|
154
|
+
declare function sendUnauthorized(scope: Scope, body?: BodyInit, config?: Mergeable<ResponseConfig>): Response;
|
|
155
|
+
declare function sendNotFound(scope: Scope, body?: BodyInit, config?: Mergeable<ResponseConfig>): Response;
|
|
155
156
|
declare function mimeType(file: string): MimeType;
|
|
156
157
|
declare function invoke(scope: Scope, pipeline: Array<Middleware>, index?: number): Promise<Result>;
|
|
157
158
|
declare function createServer(): Promise<Server>;
|
|
@@ -219,4 +220,4 @@ declare const CLOSE_HOOK: Descriptor<() => void>;
|
|
|
219
220
|
//#region src/client/index.d.ts
|
|
220
221
|
declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
|
|
221
222
|
//#endregion
|
|
222
|
-
export { invoke as $, PARAMETER_MATCH as A,
|
|
223
|
+
export { invoke as $, PARAMETER_MATCH as A, Output as At, SERVER_CONTEXT as B, OPTIONAL_PARAMETER as C, Failure as Ct, OptionalParameterNode as D, Invoke as Dt, OPTIONAL_WILDCARD_MATCH as E, InferOutput as Et, ResponseConfig as F, defineHook as Ft, StatusCode as G, Server as H, Result as I, isFailure as It, WildcardNode as J, WILDCARD as K, Route as L, mergeObjects as Lt, PathNode as M, Scope as Mt, ROUTER_CONTEXT as N, Success as Nt, OptionalWildcardNode as O, Issue as Ot, Radix as P, defineContext as Pt, getState as Q, Router as R, parseSchema as Rt, Node as S, Descriptor as St, OPTIONAL_WILDCARD as T, InferInput as Tt, ServerContext as U, STATES as V, States as W, defineMiddleware as X, createServer as Y, defineRoute as Z, CookieSameSite as _, useServer as _t, CLOSE_HOOK as a, sendHtml as at, Middleware as b, withQuery as bt, DevelopmentConfig as c, sendRedirect as ct, SERVER as d, setCookie as dt, isClient as et, Source as f, setState as ft, CookiePriority as g, useRouter as gt, CookieOptions as h, useQuery as ht, CLIENT as i, sendBadRequest as it, ParameterNode as j, Schema as jt, PARAMETER as k, Mergeable as kt, Environment as l, sendText as lt, Virtual as m, useHeaders as mt, App as n, mimeType as nt, Config as o, sendJson as ot, Template as p, useCookies as pt, WILDCARD_MATCH as q, BuildConfig as r, mimeTypes as rt, Content as s, sendNotFound as st, $fetch as t, isServer as tt, Module as u, sendUnauthorized as ut, Encoding as v, useSetCookies as vt, OPTIONAL_PARAMETER_MATCH as w, Hookable as wt, MimeType as x, Context as xt, HttpMethod as y, useUrl as yt, RouterContext as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as invoke, A as PARAMETER_MATCH, At as
|
|
2
|
-
export { $fetch, App, BuildConfig, 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, 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, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
|
1
|
+
import { $ as invoke, A as PARAMETER_MATCH, At as Output, B as SERVER_CONTEXT, C as OPTIONAL_PARAMETER, Ct as Failure, D as OptionalParameterNode, Dt as Invoke, E as OPTIONAL_WILDCARD_MATCH, Et as InferOutput, F as ResponseConfig, Ft as defineHook, G as StatusCode, H as Server, I as Result, It as isFailure, J as WildcardNode, K as WILDCARD, L as Route, Lt as mergeObjects, M as PathNode, Mt as Scope, N as ROUTER_CONTEXT, Nt as Success, O as OptionalWildcardNode, Ot as Issue, P as Radix, Pt as defineContext, Q as getState, R as Router, Rt as parseSchema, S as Node, St as Descriptor, T as OPTIONAL_WILDCARD, Tt as InferInput, U as ServerContext, V as STATES, W as States, X as defineMiddleware, Y as createServer, Z as defineRoute, _ as CookieSameSite, _t as useServer, a as CLOSE_HOOK, at as sendHtml, b as Middleware, bt as withQuery, c as DevelopmentConfig, ct as sendRedirect, d as SERVER, dt as setCookie, et as isClient, f as Source, ft as setState, g as CookiePriority, gt as useRouter, h as CookieOptions, ht as useQuery, i as CLIENT, it as sendBadRequest, j as ParameterNode, jt as Schema, k as PARAMETER, kt as Mergeable, l as Environment, lt as sendText, m as Virtual, mt as useHeaders, n as App, nt as mimeType, o as Config, ot as sendJson, p as Template, pt as useCookies, q as WILDCARD_MATCH, r as BuildConfig, rt as mimeTypes, s as Content, st as sendNotFound, t as $fetch, tt as isServer, u as Module, ut as sendUnauthorized, v as Encoding, vt as useSetCookies, w as OPTIONAL_PARAMETER_MATCH, wt as Hookable, x as MimeType, xt as Context, y as HttpMethod, yt as useUrl, z as RouterContext } from "./index-FHYfF5lq.js";
|
|
2
|
+
export { $fetch, App, BuildConfig, 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, 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, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendNotFound, sendRedirect, sendText, sendUnauthorized, setCookie, setState, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as isClient, B as
|
|
1
|
+
import { A as isClient, B as sendUnauthorized, C as WILDCARD, D as defineRoute, E as defineMiddleware, F as sendHtml, G as useQuery, H as setState, I as sendJson, J as useSetCookies, K as useRouter, L as sendNotFound, M as mimeType, N as mimeTypes, O as getState, P as sendBadRequest, R as sendRedirect, S as STATES, T as createServer, U as useCookies, V as setCookie, W as useHeaders, X as withQuery, Y as useUrl, _ as PARAMETER_MATCH, a as Hookable, b as Router, c as defineHook, d as parseSchema, f as OPTIONAL_PARAMETER, g as PARAMETER, h as OPTIONAL_WILDCARD_MATCH, i as SERVER, j as isServer, k as invoke, l as isFailure, m as OPTIONAL_WILDCARD, n as CLIENT, o as Scope, p as OPTIONAL_PARAMETER_MATCH, q as useServer, r as CLOSE_HOOK, s as defineContext, t as App, u as mergeObjects, v as ROUTER_CONTEXT, w as WILDCARD_MATCH, x as SERVER_CONTEXT, y as Radix, z as sendText } from "./app-Cw42JCxa.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/index.ts
|
|
4
4
|
async function $fetch(scope, input, options) {
|
|
@@ -25,4 +25,4 @@ async function $fetch(scope, input, options) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
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, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
|
28
|
+
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, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendNotFound, sendRedirect, sendText, sendUnauthorized, setCookie, setState, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/kit/index.d.ts
CHANGED
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SERVER, k as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, x as SERVER_CONTEXT } from "../app-
|
|
1
|
+
import { i as SERVER, k as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, x as SERVER_CONTEXT } from "../app-Cw42JCxa.js";
|
|
2
2
|
import { a as addVirtual, i as addTypes, o as useKit } from "../kit-Vr6NzLTO.js";
|
|
3
3
|
import { basename, isAbsolute, join, posix, resolve, win32 } from "path";
|
|
4
4
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
@@ -10,7 +10,7 @@ import { Readable, Stream } from "stream";
|
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
12
|
var name = "revojs";
|
|
13
|
-
var version = "0.1.
|
|
13
|
+
var version = "0.1.33";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/vite/node/index.ts
|