revojs 0.1.53 → 0.1.55
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-B4nGVcLE.d.mts → index-DOmfkUsW.d.mts} +12 -45
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/kit/index.d.mts +1 -1
- package/dist/{package-D8FgpUMW.mjs → package-BcN3Ewsh.mjs} +1 -1
- package/dist/{server-BKOK-LN2.mjs → server-BplNURRd.mjs} +115 -122
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/index.mjs +2 -2
- package/package.json +1 -1
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-BcN3Ewsh.mjs";
|
|
3
3
|
import { resolvePaths } from "../kit/index.mjs";
|
|
4
4
|
import { defineCommand, runMain } from "citty";
|
|
5
5
|
import { copyFileSync, mkdirSync } from "fs";
|
|
@@ -1,45 +1,18 @@
|
|
|
1
1
|
import { UserConfig } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/router/index.d.ts
|
|
4
|
-
type
|
|
5
|
-
interface
|
|
6
|
-
type:
|
|
7
|
-
|
|
8
|
-
children: Record<string, Node<T>>;
|
|
9
|
-
}
|
|
10
|
-
interface WildcardNode<T> {
|
|
11
|
-
type: "WILDCARD";
|
|
12
|
-
value?: T;
|
|
13
|
-
parameter: string;
|
|
14
|
-
children: Record<string, Node<T>>;
|
|
15
|
-
}
|
|
16
|
-
interface OptionalWildcardNode<T> {
|
|
17
|
-
type: "OPTIONAL-WILDCARD";
|
|
18
|
-
value?: T;
|
|
19
|
-
parameter: string;
|
|
20
|
-
children: Record<string, Node<T>>;
|
|
21
|
-
}
|
|
22
|
-
interface ParameterNode<T> {
|
|
23
|
-
type: "PARAMETER";
|
|
24
|
-
value?: T;
|
|
25
|
-
parameter: string;
|
|
26
|
-
children: Record<string, Node<T>>;
|
|
27
|
-
}
|
|
28
|
-
interface OptionalParameterNode<T> {
|
|
29
|
-
type: "OPTIONAL-PARAMETER";
|
|
4
|
+
type NodeType = "PATH" | "PARAMETER" | "OPTIONAL-PARAMETER" | "WILDCARD" | "OPTIONAL-WILDCARD" | "GROUP";
|
|
5
|
+
interface Node<T> {
|
|
6
|
+
type: NodeType;
|
|
7
|
+
name: string;
|
|
30
8
|
value?: T;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
children:
|
|
38
|
-
}
|
|
39
|
-
interface HookNode<T> {
|
|
40
|
-
type: "HOOK";
|
|
41
|
-
value?: Array<T>;
|
|
42
|
-
children: Record<string, Node<T>>;
|
|
9
|
+
hooks: Array<T>;
|
|
10
|
+
parameter?: Node<T>;
|
|
11
|
+
optionalParameter?: Node<T>;
|
|
12
|
+
wildcard?: Node<T>;
|
|
13
|
+
optionalWildcard?: Node<T>;
|
|
14
|
+
groups: Map<string, Node<T>>;
|
|
15
|
+
children: Map<string, Node<T>>;
|
|
43
16
|
}
|
|
44
17
|
interface RouterContext<T> {
|
|
45
18
|
route?: T;
|
|
@@ -54,12 +27,6 @@ declare class Router<T> {
|
|
|
54
27
|
use(segments: Array<string>, value: T): Node<T>;
|
|
55
28
|
match(segments: Array<string>): RouterContext<T>;
|
|
56
29
|
}
|
|
57
|
-
declare const WILDCARD = "@";
|
|
58
|
-
declare const OPTIONAL_WILDCARD = "@@";
|
|
59
|
-
declare const PARAMETER = "@@@";
|
|
60
|
-
declare const OPTIONAL_PARAMETER = "@@@@";
|
|
61
|
-
declare const GROUP = "@@@@@";
|
|
62
|
-
declare const HOOK = "@@@@@@";
|
|
63
30
|
declare const WILDCARD_MATCH: RegExp;
|
|
64
31
|
declare const OPTIONAL_WILDCARD_MATCH: RegExp;
|
|
65
32
|
declare const PARAMETER_MATCH: RegExp;
|
|
@@ -259,4 +226,4 @@ declare function createStaticMiddleware(resolve: (path: string | URL) => Awaitab
|
|
|
259
226
|
fetch(scope: Scope, next: (() => Result) | undefined): Promise<void | Response>;
|
|
260
227
|
};
|
|
261
228
|
//#endregion
|
|
262
|
-
export { sendUnauthorized as $,
|
|
229
|
+
export { sendUnauthorized as $, StatusCode as A, Scope as At, isClient as B, PARAMETER_MATCH as Bt, Result as C, Awaitable as Ct, STATES as D, Invoke as Dt, SERVER_ROUTER_CONTEXT as E, Hookable as Et, defineRoute as F, HOOK_MATCH as Ft, sendBadRequest as G, mimeType as H, RouterContext as Ht, encodings as I, Node as It, sendNoContent as J, sendCreated as K, getState as L, NodeType as Lt, cookieSameSites as M, defineHook as Mt, createServer as N, mergeObjects as Nt, Server as O, Mergeable as Ot, defineMiddleware as P, GROUP_MATCH as Pt, sendResponse as Q, httpMethods as R, OPTIONAL_PARAMETER_MATCH as Rt, ResponseConfig as S, parseSchema as St, SERVER_CONTEXT as T, Descriptor as Tt, mimeTypes as U, WILDCARD_MATCH as Ut, isServer as V, Router as Vt, parseCookiePair as W, sendOk as X, sendNotFound as Y, sendRedirect as Z, CookieSameSite as _, Output as _t, CLIENT as a, useHeaders as at, Middleware as b, isFailure as bt, Content as c, useRouter as ct, Module as d, useUrl as dt, setCookie as et, SERVER as f, withQuery as ft, CookiePriority as g, Issue as gt, CookieOptions as h, InferOutput as ht, Asset as i, useCookies as it, cookiePriorities as j, defineContext as jt, ServerContext as k, Primitive as kt, DevelopmentConfig as l, useServer as lt, Template as m, InferInput as mt, fetch as n, statusCodes as nt, CLOSE_HOOK as o, useParameters as ot, Source as p, Failure as pt, sendForbidden as q, App as r, useBody as rt, Config as s, useQuery as st, createStaticMiddleware as t, setState as tt, Environment as u, useSetCookies as ut, Encoding as v, Schema as vt, Route as w, Context as wt, MimeType as x, isSuccess as xt, HttpMethod as y, Success as yt, invoke as z, OPTIONAL_WILDCARD_MATCH as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as sendUnauthorized,
|
|
2
|
-
export { App, Asset, Awaitable, CLIENT, CLOSE_HOOK, Config, Content, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure,
|
|
1
|
+
import { $ as sendUnauthorized, A as StatusCode, At as Scope, B as isClient, Bt as PARAMETER_MATCH, C as Result, Ct as Awaitable, D as STATES, Dt as Invoke, E as SERVER_ROUTER_CONTEXT, Et as Hookable, F as defineRoute, Ft as HOOK_MATCH, G as sendBadRequest, H as mimeType, Ht as RouterContext, I as encodings, It as Node, J as sendNoContent, K as sendCreated, L as getState, Lt as NodeType, M as cookieSameSites, Mt as defineHook, N as createServer, Nt as mergeObjects, O as Server, Ot as Mergeable, P as defineMiddleware, Pt as GROUP_MATCH, Q as sendResponse, R as httpMethods, Rt as OPTIONAL_PARAMETER_MATCH, S as ResponseConfig, St as parseSchema, T as SERVER_CONTEXT, Tt as Descriptor, U as mimeTypes, Ut as WILDCARD_MATCH, V as isServer, Vt as Router, W as parseCookiePair, X as sendOk, Y as sendNotFound, Z as sendRedirect, _ as CookieSameSite, _t as Output, a as CLIENT, at as useHeaders, b as Middleware, bt as isFailure, c as Content, ct as useRouter, d as Module, dt as useUrl, et as setCookie, f as SERVER, ft as withQuery, g as CookiePriority, gt as Issue, h as CookieOptions, ht as InferOutput, i as Asset, it as useCookies, j as cookiePriorities, jt as defineContext, k as ServerContext, kt as Primitive, l as DevelopmentConfig, lt as useServer, m as Template, mt as InferInput, n as fetch, nt as statusCodes, o as CLOSE_HOOK, ot as useParameters, p as Source, pt as Failure, q as sendForbidden, r as App, rt as useBody, s as Config, st as useQuery, t as createStaticMiddleware, tt as setState, u as Environment, ut as useSetCookies, v as Encoding, vt as Schema, w as Route, wt as Context, x as MimeType, xt as isSuccess, y as HttpMethod, yt as Success, z as invoke, zt as OPTIONAL_WILDCARD_MATCH } from "./index-DOmfkUsW.mjs";
|
|
2
|
+
export { App, Asset, Awaitable, CLIENT, CLOSE_HOOK, Config, Content, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, GROUP_MATCH, HOOK_MATCH, Hookable, HttpMethod, InferInput, InferOutput, Invoke, Issue, Mergeable, Middleware, MimeType, Module, Node, NodeType, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD_MATCH, Output, PARAMETER_MATCH, Primitive, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, SERVER_ROUTER_CONTEXT, STATES, Schema, Scope, Server, ServerContext, Source, StatusCode, Success, Template, WILDCARD_MATCH, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, fetch, getState, httpMethods, invoke, isClient, isFailure, isServer, isSuccess, 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,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SERVER, A as useBody, B as isFailure, C as sendOk, D as setCookie, E as sendUnauthorized, F as useRouter, G as OPTIONAL_PARAMETER_MATCH, H as parseSchema, I as useServer, J as Router, K as OPTIONAL_WILDCARD_MATCH, L as useSetCookies, M as useHeaders, N as useParameters, O as setState, P as useQuery, Q as CLOSE_HOOK, R as useUrl, S as sendNotFound, T as sendResponse, U as GROUP_MATCH, V as isSuccess, W as HOOK_MATCH, X as App, Y as WILDCARD_MATCH, Z as CLIENT, _ as parseCookiePair, a as cookieSameSites, b as sendForbidden, c as defineRoute, d as httpMethods, et as Hookable, f as invoke, g as mimeTypes, h as mimeType, i as cookiePriorities, it as mergeObjects, j as useCookies, k as statusCodes, l as encodings, m as isServer, n as SERVER_ROUTER_CONTEXT, nt as defineContext, o as createServer, p as isClient, q as PARAMETER_MATCH, r as STATES, rt as defineHook, s as defineMiddleware, t as SERVER_CONTEXT, tt as Scope, u as getState, v as sendBadRequest, w as sendRedirect, x as sendNoContent, y as sendCreated, z as withQuery } from "./server-BplNURRd.mjs";
|
|
2
2
|
import assets from "#assets";
|
|
3
3
|
//#region src/client/index.ts
|
|
4
4
|
async function fetch(scope, input, options) {
|
|
@@ -52,4 +52,4 @@ function createStaticMiddleware(resolve) {
|
|
|
52
52
|
} });
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
|
-
export { App, CLIENT, CLOSE_HOOK,
|
|
55
|
+
export { App, CLIENT, CLOSE_HOOK, GROUP_MATCH, HOOK_MATCH, Hookable, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD_MATCH, PARAMETER_MATCH, Router, SERVER, SERVER_CONTEXT, SERVER_ROUTER_CONTEXT, STATES, Scope, WILDCARD_MATCH, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, fetch, getState, httpMethods, invoke, isClient, isFailure, isServer, isSuccess, 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
|
@@ -109,94 +109,97 @@ var Router = class {
|
|
|
109
109
|
constructor(rootNode) {
|
|
110
110
|
this.rootNode = rootNode ?? {
|
|
111
111
|
type: "PATH",
|
|
112
|
-
|
|
112
|
+
name: "",
|
|
113
|
+
children: /* @__PURE__ */ new Map(),
|
|
114
|
+
groups: /* @__PURE__ */ new Map(),
|
|
115
|
+
hooks: []
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
use(segments, value) {
|
|
116
119
|
let node = this.rootNode;
|
|
117
|
-
for (const
|
|
118
|
-
const
|
|
119
|
-
if (typeof
|
|
120
|
-
|
|
121
|
-
childNode ??= {
|
|
120
|
+
for (const segment of segments) {
|
|
121
|
+
const optionalWildcard = OPTIONAL_WILDCARD_MATCH.exec(segment)?.[1];
|
|
122
|
+
if (typeof optionalWildcard === "string") {
|
|
123
|
+
node.optionalWildcard ??= {
|
|
122
124
|
type: "OPTIONAL-WILDCARD",
|
|
123
|
-
|
|
124
|
-
children:
|
|
125
|
+
name: optionalWildcard,
|
|
126
|
+
children: /* @__PURE__ */ new Map(),
|
|
127
|
+
groups: /* @__PURE__ */ new Map(),
|
|
128
|
+
hooks: []
|
|
125
129
|
};
|
|
126
|
-
node
|
|
127
|
-
node = childNode;
|
|
130
|
+
node = node.optionalWildcard;
|
|
128
131
|
continue;
|
|
129
132
|
}
|
|
130
|
-
const
|
|
131
|
-
if (typeof
|
|
132
|
-
|
|
133
|
-
childNode ??= {
|
|
133
|
+
const wildcard = WILDCARD_MATCH.exec(segment)?.[1];
|
|
134
|
+
if (typeof wildcard === "string") {
|
|
135
|
+
node.wildcard ??= {
|
|
134
136
|
type: "WILDCARD",
|
|
135
|
-
|
|
136
|
-
children:
|
|
137
|
+
name: wildcard,
|
|
138
|
+
children: /* @__PURE__ */ new Map(),
|
|
139
|
+
groups: /* @__PURE__ */ new Map(),
|
|
140
|
+
hooks: []
|
|
137
141
|
};
|
|
138
|
-
node
|
|
139
|
-
node = childNode;
|
|
142
|
+
node = node.wildcard;
|
|
140
143
|
continue;
|
|
141
144
|
}
|
|
142
|
-
const
|
|
143
|
-
if (typeof
|
|
144
|
-
|
|
145
|
-
childNode ??= {
|
|
145
|
+
const optionalParameter = OPTIONAL_PARAMETER_MATCH.exec(segment)?.[1];
|
|
146
|
+
if (typeof optionalParameter === "string") {
|
|
147
|
+
node.optionalParameter ??= {
|
|
146
148
|
type: "OPTIONAL-PARAMETER",
|
|
147
|
-
|
|
148
|
-
children:
|
|
149
|
+
name: optionalParameter,
|
|
150
|
+
children: /* @__PURE__ */ new Map(),
|
|
151
|
+
groups: /* @__PURE__ */ new Map(),
|
|
152
|
+
hooks: []
|
|
149
153
|
};
|
|
150
|
-
node
|
|
151
|
-
node = childNode;
|
|
154
|
+
node = node.optionalParameter;
|
|
152
155
|
continue;
|
|
153
156
|
}
|
|
154
|
-
const
|
|
155
|
-
if (typeof
|
|
156
|
-
|
|
157
|
-
childNode ??= {
|
|
157
|
+
const parameter = PARAMETER_MATCH.exec(segment)?.[1];
|
|
158
|
+
if (typeof parameter === "string") {
|
|
159
|
+
node.parameter ??= {
|
|
158
160
|
type: "PARAMETER",
|
|
159
|
-
|
|
160
|
-
children:
|
|
161
|
+
name: parameter,
|
|
162
|
+
children: /* @__PURE__ */ new Map(),
|
|
163
|
+
groups: /* @__PURE__ */ new Map(),
|
|
164
|
+
hooks: []
|
|
161
165
|
};
|
|
162
|
-
node
|
|
163
|
-
node = childNode;
|
|
166
|
+
node = node.parameter;
|
|
164
167
|
continue;
|
|
165
168
|
}
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
169
|
+
const group = GROUP_MATCH.exec(segment)?.[1];
|
|
170
|
+
if (typeof group === "string") {
|
|
171
|
+
let child = node.groups.get(group);
|
|
172
|
+
if (!child) {
|
|
173
|
+
child = {
|
|
174
|
+
type: "GROUP",
|
|
175
|
+
name: group,
|
|
176
|
+
children: /* @__PURE__ */ new Map(),
|
|
177
|
+
groups: /* @__PURE__ */ new Map(),
|
|
178
|
+
hooks: []
|
|
179
|
+
};
|
|
180
|
+
node.groups.set(group, child);
|
|
181
|
+
}
|
|
182
|
+
node = child;
|
|
176
183
|
continue;
|
|
177
184
|
}
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
if (typeof HOOK_MATCH.exec(segment)?.[1] === "string") {
|
|
186
|
+
node.hooks.push(value);
|
|
187
|
+
return node;
|
|
188
|
+
}
|
|
189
|
+
let child = node.children.get(segment);
|
|
190
|
+
if (!child) {
|
|
191
|
+
child = {
|
|
192
|
+
type: "PATH",
|
|
193
|
+
name: segment,
|
|
194
|
+
children: /* @__PURE__ */ new Map(),
|
|
195
|
+
groups: /* @__PURE__ */ new Map(),
|
|
196
|
+
hooks: []
|
|
183
197
|
};
|
|
184
|
-
node.children
|
|
185
|
-
node = childNode;
|
|
186
|
-
continue;
|
|
198
|
+
node.children.set(segment, child);
|
|
187
199
|
}
|
|
188
|
-
|
|
189
|
-
childNode ??= {
|
|
190
|
-
type: "PATH",
|
|
191
|
-
children: {}
|
|
192
|
-
};
|
|
193
|
-
node.children[next] ??= childNode;
|
|
194
|
-
node = childNode;
|
|
200
|
+
node = child;
|
|
195
201
|
}
|
|
196
|
-
|
|
197
|
-
node.value ??= [];
|
|
198
|
-
node.value.push(value);
|
|
199
|
-
} else if (node.type === "PATH" || node.type === "PARAMETER" || node.type === "OPTIONAL-PARAMETER" || node.type === "WILDCARD" || node.type === "OPTIONAL-WILDCARD") node.value = value;
|
|
202
|
+
node.value = value;
|
|
200
203
|
return node;
|
|
201
204
|
}
|
|
202
205
|
match(segments) {
|
|
@@ -206,67 +209,57 @@ var Router = class {
|
|
|
206
209
|
groups: [],
|
|
207
210
|
hooks: []
|
|
208
211
|
};
|
|
209
|
-
|
|
210
|
-
const hookNode = node.children[HOOK];
|
|
211
|
-
if (hookNode?.value) context.hooks.push(...hookNode.value);
|
|
212
|
-
if (index === context.segments.length) return node;
|
|
213
|
-
const segment = context.segments[index];
|
|
214
|
-
if (node.children[segment]) {
|
|
215
|
-
const route = invoke(node.children[segment], index + 1);
|
|
216
|
-
if (route) return route;
|
|
217
|
-
}
|
|
218
|
-
if (node.children["@@@@@"]) {
|
|
219
|
-
const groupNode = node.children[GROUP];
|
|
220
|
-
const route = invoke(groupNode, index);
|
|
221
|
-
if (route) {
|
|
222
|
-
context.groups.push(groupNode.label);
|
|
223
|
-
return route;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (node.children["@@@@"]) {
|
|
227
|
-
const optionalParameterNode = node.children[OPTIONAL_PARAMETER];
|
|
228
|
-
const route = invoke(optionalParameterNode, index + 1);
|
|
229
|
-
if (route) {
|
|
230
|
-
context.parameters[optionalParameterNode.parameter] = segment;
|
|
231
|
-
return route;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (node.children["@@@"]) {
|
|
235
|
-
const parameterNode = node.children["@@@"];
|
|
236
|
-
const route = invoke(parameterNode, index + 1);
|
|
237
|
-
if (route) {
|
|
238
|
-
context.parameters[parameterNode.parameter] = segment;
|
|
239
|
-
return route;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (node.children["@@"]) {
|
|
243
|
-
const optionalWildcardNode = node.children["@@"];
|
|
244
|
-
const wildcardPath = context.segments.slice(index).join("/");
|
|
245
|
-
context.parameters[optionalWildcardNode.parameter] = wildcardPath;
|
|
246
|
-
return optionalWildcardNode ?? invoke(optionalWildcardNode, context.segments.length);
|
|
247
|
-
}
|
|
248
|
-
if (node.children["@"]) {
|
|
249
|
-
const wildcardNode = node.children["@"];
|
|
250
|
-
const wildcardPath = context.segments.slice(index).join("/");
|
|
251
|
-
context.parameters[wildcardNode.parameter] = wildcardPath;
|
|
252
|
-
return wildcardNode ?? invoke(wildcardNode, context.segments.length);
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
const match = invoke(this.rootNode, 0);
|
|
256
|
-
if (match?.type === "PATH" || match?.type === "PARAMETER" || match?.type === "OPTIONAL-PARAMETER" || match?.type === "WILDCARD" || match?.type === "OPTIONAL-WILDCARD") context.route = match.value;
|
|
212
|
+
visit(this.rootNode, 0, context);
|
|
257
213
|
return context;
|
|
258
214
|
}
|
|
259
215
|
};
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
216
|
+
function visit(node, index, context) {
|
|
217
|
+
const hookCount = context.hooks.length;
|
|
218
|
+
const groupCount = context.groups.length;
|
|
219
|
+
if (node.hooks.length > 0) context.hooks.push(...node.hooks);
|
|
220
|
+
if (node.type === "GROUP") context.groups.push(node.name);
|
|
221
|
+
if (match(node, index, context)) return true;
|
|
222
|
+
context.hooks.length = hookCount;
|
|
223
|
+
context.groups.length = groupCount;
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
function match(node, index, context) {
|
|
227
|
+
if (index === context.segments.length) {
|
|
228
|
+
if (node.value !== void 0) {
|
|
229
|
+
context.route = node.value;
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
for (const group of node.groups.values()) if (visit(group, index, context)) return true;
|
|
233
|
+
if (node.optionalParameter && visit(node.optionalParameter, index, context)) return true;
|
|
234
|
+
if (node.optionalWildcard && assign(node.optionalWildcard, "", index, context)) return true;
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
for (const group of node.groups.values()) if (visit(group, index, context)) return true;
|
|
238
|
+
const segment = context.segments[index] ?? "";
|
|
239
|
+
const child = node.children.get(segment);
|
|
240
|
+
if (child && visit(child, index + 1, context)) return true;
|
|
241
|
+
if (node.parameter && assign(node.parameter, segment, index + 1, context)) return true;
|
|
242
|
+
if (node.optionalParameter && assign(node.optionalParameter, segment, index + 1, context)) return true;
|
|
243
|
+
if (node.wildcard) {
|
|
244
|
+
const rest = context.segments.slice(index).join("/");
|
|
245
|
+
if (assign(node.wildcard, rest, context.segments.length, context)) return true;
|
|
246
|
+
}
|
|
247
|
+
if (node.optionalWildcard) {
|
|
248
|
+
const rest = context.segments.slice(index).join("/");
|
|
249
|
+
if (assign(node.optionalWildcard, rest, context.segments.length, context)) return true;
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
function assign(node, value, index, context) {
|
|
254
|
+
context.parameters[node.name] = value;
|
|
255
|
+
if (visit(node, index, context)) return true;
|
|
256
|
+
delete context.parameters[node.name];
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
const WILDCARD_MATCH = /^\[\.\.\.(.*)\]$/;
|
|
260
|
+
const OPTIONAL_WILDCARD_MATCH = /^\[\[\.\.\.(.*)\]\]$/;
|
|
261
|
+
const PARAMETER_MATCH = /^\[(.*)\]$/;
|
|
262
|
+
const OPTIONAL_PARAMETER_MATCH = /^\[\[(.*)\]\]$/;
|
|
270
263
|
const GROUP_MATCH = /^\((.*)\)$/;
|
|
271
264
|
const HOOK_MATCH = /^\+(.+)$/;
|
|
272
265
|
//#endregion
|
|
@@ -659,4 +652,4 @@ const mimeTypes = {
|
|
|
659
652
|
"apk": "application/vnd.android.package-archive"
|
|
660
653
|
};
|
|
661
654
|
//#endregion
|
|
662
|
-
export {
|
|
655
|
+
export { SERVER as $, useBody as A, isFailure as B, sendOk as C, setCookie as D, sendUnauthorized as E, useRouter as F, OPTIONAL_PARAMETER_MATCH as G, parseSchema as H, useServer as I, Router as J, OPTIONAL_WILDCARD_MATCH as K, useSetCookies as L, useHeaders as M, useParameters as N, setState as O, useQuery as P, CLOSE_HOOK as Q, useUrl as R, sendNotFound as S, sendResponse as T, GROUP_MATCH as U, isSuccess as V, HOOK_MATCH as W, App as X, WILDCARD_MATCH as Y, CLIENT as Z, parseCookiePair as _, cookieSameSites as a, sendForbidden as b, defineRoute as c, httpMethods as d, Hookable as et, invoke as f, mimeTypes as g, mimeType as h, cookiePriorities as i, mergeObjects as it, useCookies as j, statusCodes as k, encodings as l, isServer as m, SERVER_ROUTER_CONTEXT as n, defineContext as nt, createServer as o, isClient as p, PARAMETER_MATCH as q, STATES as r, defineHook as rt, defineMiddleware as s, SERVER_CONTEXT as t, Scope as tt, getState as u, sendBadRequest as v, sendRedirect as w, sendNoContent as x, sendCreated as y, withQuery as z };
|
package/dist/vite/index.d.mts
CHANGED
package/dist/vite/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as version, t as name } from "../package-
|
|
1
|
+
import { Q as CLOSE_HOOK, X as App, Z as CLIENT, f as invoke, h as mimeType, it as mergeObjects, t as SERVER_CONTEXT, tt as Scope } from "../server-BplNURRd.mjs";
|
|
2
|
+
import { n as version, t as name } from "../package-BcN3Ewsh.mjs";
|
|
3
3
|
import { addTemplate, addTypes, addVirtual, resolvePaths, useKit } from "../kit/index.mjs";
|
|
4
4
|
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve, win32 } from "path";
|