revojs 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/index.d.ts +4 -1
- package/dist/index.js +23 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,9 @@ declare function createApp(inputConfig?: Mergeable<Config>): App;
|
|
|
78
78
|
declare const SERVER = "ssr";
|
|
79
79
|
declare const CLIENT = "client";
|
|
80
80
|
//#endregion
|
|
81
|
+
//#region src/client/index.d.ts
|
|
82
|
+
declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
|
|
83
|
+
//#endregion
|
|
81
84
|
//#region src/server/index.d.ts
|
|
82
85
|
type CookiePriority = "Low" | "Medium" | "High";
|
|
83
86
|
type CookieSameSite = "Lax" | "Strict" | "None";
|
|
@@ -174,4 +177,4 @@ declare const WILDCARD = "$";
|
|
|
174
177
|
declare const PARAMETER = ":";
|
|
175
178
|
declare const mimeTypes: Record<string, MimeType>;
|
|
176
179
|
//#endregion
|
|
177
|
-
export { App, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, Encoding, Environment, Failure, HttpMethod, InferInput, InferOutput, Issue, Mergeable, Middleware, MimeType, Module, Node, Output, PARAMETER, ParameterNode, PathNode, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, Schema, Scope, Server, ServerContext, Source, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, toRoutePath, useCookies, useQuery, useServer, useSetCookies, useUrl };
|
|
180
|
+
export { $fetch, App, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, Encoding, Environment, Failure, HttpMethod, InferInput, InferOutput, Issue, Mergeable, Middleware, MimeType, Module, Node, Output, PARAMETER, ParameterNode, PathNode, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, Schema, Scope, Server, ServerContext, Source, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, toRoutePath, useCookies, useQuery, useServer, useSetCookies, useUrl };
|
package/dist/index.js
CHANGED
|
@@ -347,4 +347,26 @@ const SERVER = "ssr";
|
|
|
347
347
|
const CLIENT = "client";
|
|
348
348
|
|
|
349
349
|
//#endregion
|
|
350
|
-
|
|
350
|
+
//#region src/client/index.ts
|
|
351
|
+
async function $fetch(scope, input, options) {
|
|
352
|
+
const { request, variables } = useServer(scope);
|
|
353
|
+
let response;
|
|
354
|
+
if (request) {
|
|
355
|
+
const next = new Scope();
|
|
356
|
+
next.setContext(SERVER_CONTEXT, {
|
|
357
|
+
request: new Request(new URL(input.toString(), request.url), options),
|
|
358
|
+
response: { headers: new Headers() },
|
|
359
|
+
variables
|
|
360
|
+
});
|
|
361
|
+
response = await (await import("#virtual/server")).default.fetch(next);
|
|
362
|
+
}
|
|
363
|
+
response ??= await fetch(input, options);
|
|
364
|
+
if (response.ok === false) throw response;
|
|
365
|
+
switch (response.headers.get("Content-Type")?.split(";").shift() ?? "") {
|
|
366
|
+
case "application/json": return response.json();
|
|
367
|
+
default: return response;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
//#endregion
|
|
372
|
+
export { $fetch, CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, Scope, StopEvent, WILDCARD, createApp, createServer, defineContext, defineMiddleware, defineRoute, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, toRoutePath, useCookies, useQuery, useServer, useSetCookies, useUrl };
|
package/dist/vite/index.js
CHANGED