revojs 0.1.20 → 0.1.21
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-C4yy27ko.js → app-gPmc1xyv.js} +8 -6
- package/dist/{index-D-rKmbh3.d.ts → index-D6BvOWjN.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- 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
|
@@ -50,7 +50,7 @@ var Router = class extends Radix {
|
|
|
50
50
|
const { pathname } = useUrl(scope);
|
|
51
51
|
const context = {
|
|
52
52
|
route: this.rootNode,
|
|
53
|
-
segments:
|
|
53
|
+
segments: (request.method.toLowerCase() + pathname).split("/"),
|
|
54
54
|
parameters: {}
|
|
55
55
|
};
|
|
56
56
|
const invoke$1 = (node, index) => {
|
|
@@ -71,7 +71,7 @@ var Router = class extends Radix {
|
|
|
71
71
|
if (node.children[WILDCARD]) {
|
|
72
72
|
const wildcardNode = node.children[WILDCARD];
|
|
73
73
|
context.parameters[wildcardNode.parameter] = segment;
|
|
74
|
-
return wildcardNode.value ?? invoke$1(wildcardNode,
|
|
74
|
+
return wildcardNode.value ?? invoke$1(wildcardNode, context.segments.length);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
const route = invoke$1(this.rootNode, 0);
|
|
@@ -207,9 +207,8 @@ function mimeType(file) {
|
|
|
207
207
|
return mimeTypes[extension ?? ""] ?? "text/plain";
|
|
208
208
|
}
|
|
209
209
|
function toRoutePath(path) {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
return result.concat(properties).join("/");
|
|
210
|
+
const segments = path.toLowerCase().replaceAll(/\[\.\.\.(.*?)\]/g, (_, value) => WILDCARD + value).replaceAll(/\[(.*?)\]/g, (_, value) => PARAMETER + value).split(".");
|
|
211
|
+
return [(segments.shift() ?? "").split("/").filter((value) => value !== "index").join("/"), ...segments];
|
|
213
212
|
}
|
|
214
213
|
async function invoke(scope, pipeline, index = 0) {
|
|
215
214
|
return await pipeline.at(index)?.fetch(scope, async () => await invoke(scope, pipeline, index + 1));
|
|
@@ -218,7 +217,10 @@ async function createServer() {
|
|
|
218
217
|
const router = new Router();
|
|
219
218
|
const middlewares = new Array();
|
|
220
219
|
const routes = await import("#virtual/routes").then((module) => Object.entries(module.default));
|
|
221
|
-
for (const [path, route] of routes)
|
|
220
|
+
for (const [path, route] of routes) {
|
|
221
|
+
const [result, method] = toRoutePath(path);
|
|
222
|
+
router.use(method + "/" + result, route);
|
|
223
|
+
}
|
|
222
224
|
middlewares.push(router);
|
|
223
225
|
return {
|
|
224
226
|
router,
|
|
@@ -143,7 +143,7 @@ declare function sendRedirect(scope: Scope, path: string, config?: Mergeable<Res
|
|
|
143
143
|
declare function sendBadRequest(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
|
|
144
144
|
declare function sendUnauthorized(scope: Scope, config?: Mergeable<ResponseConfig>): Response;
|
|
145
145
|
declare function mimeType(file: string): MimeType;
|
|
146
|
-
declare function toRoutePath(path: string): string;
|
|
146
|
+
declare function toRoutePath(path: string): [string, ...Array<string>];
|
|
147
147
|
declare function invoke(scope: Scope, pipeline: Array<Middleware>, index?: number): Promise<Result>;
|
|
148
148
|
declare function createServer(): Promise<Server>;
|
|
149
149
|
declare const ROUTER_CONTEXT: Descriptor<RouterContext>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $fetch, App, BuildConfig, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, 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, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, getState, invoke, isFailure, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./index-
|
|
1
|
+
import { $fetch, App, BuildConfig, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, 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, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, getState, invoke, isFailure, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./index-D6BvOWjN.js";
|
|
2
2
|
export { $fetch, App, BuildConfig, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, 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, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, getState, invoke, isFailure, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, StopEvent, WILDCARD, createApp, createServer, defineContext, defineMiddleware, defineRoute, getState, invoke, isFailure, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./app-
|
|
1
|
+
import { CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, StopEvent, WILDCARD, createApp, createServer, defineContext, defineMiddleware, defineRoute, getState, invoke, isFailure, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./app-gPmc1xyv.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/index.ts
|
|
4
4
|
async function $fetch(scope, input, options) {
|
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 { CLIENT, SERVER, SERVER_CONTEXT, Scope, createApp, invoke } from "../app-
|
|
1
|
+
import { CLIENT, SERVER, SERVER_CONTEXT, Scope, createApp, invoke } from "../app-gPmc1xyv.js";
|
|
2
2
|
import { useKit } from "../kit-Bzr1NqHb.js";
|
|
3
3
|
import { basename, dirname, isAbsolute, join, posix, relative, win32 } from "path";
|
|
4
4
|
import { isRunnableDevEnvironment } from "vite";
|
|
@@ -307,7 +307,7 @@ function virtuals(virtuals$1) {
|
|
|
307
307
|
//#endregion
|
|
308
308
|
//#region package.json
|
|
309
309
|
var name = "revojs";
|
|
310
|
-
var version = "0.1.
|
|
310
|
+
var version = "0.1.21";
|
|
311
311
|
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/vite/index.ts
|