revojs 0.1.22 → 0.1.24

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.
@@ -1,43 +1,69 @@
1
1
  //#region src/server/index.ts
2
2
  var Radix = class {
3
3
  rootNode;
4
- constructor() {
5
- this.rootNode = {
4
+ constructor(rootNode) {
5
+ this.rootNode = rootNode ?? {
6
6
  type: "PATH",
7
7
  children: {}
8
8
  };
9
9
  }
10
- use(path, value) {
10
+ use(segments, value) {
11
11
  let node = this.rootNode;
12
- for (const segment of path.split("/")) {
13
- if (segment.startsWith(WILDCARD)) {
12
+ for (const next of segments) {
13
+ const optionalWildcardMatch = (next.match(OPTIONAL_WILDCARD_MATCH) ?? []).at(1);
14
+ if (typeof optionalWildcardMatch === "string") {
15
+ let childNode$1 = node.children[WILDCARD];
16
+ childNode$1 ??= {
17
+ type: "OPTIONAL-WILDCARD",
18
+ parameter: optionalWildcardMatch,
19
+ children: {}
20
+ };
21
+ node.children[WILDCARD] ??= childNode$1;
22
+ node = childNode$1;
23
+ continue;
24
+ }
25
+ const wildcardMatch = (next.match(WILDCARD_MATCH) ?? []).at(1);
26
+ if (typeof wildcardMatch === "string") {
14
27
  let childNode$1 = node.children[WILDCARD];
15
28
  childNode$1 ??= {
16
29
  type: "WILDCARD",
17
- parameter: segment.substring(WILDCARD.length),
30
+ parameter: wildcardMatch,
18
31
  children: {}
19
32
  };
20
33
  node.children[WILDCARD] ??= childNode$1;
21
34
  node = childNode$1;
22
35
  continue;
23
36
  }
24
- if (segment.startsWith(PARAMETER)) {
37
+ const optionalParameterMatch = (next.match(OPTIONAL_PARAMETER_MATCH) ?? []).at(1);
38
+ if (typeof optionalParameterMatch === "string") {
39
+ let childNode$1 = node.children[PARAMETER];
40
+ childNode$1 ??= {
41
+ type: "OPTIONAL-PARAMETER",
42
+ parameter: optionalParameterMatch,
43
+ children: {}
44
+ };
45
+ node.children[PARAMETER] ??= childNode$1;
46
+ node = childNode$1;
47
+ continue;
48
+ }
49
+ const parameterMatch = (next.match(PARAMETER_MATCH) ?? []).at(1);
50
+ if (typeof parameterMatch === "string") {
25
51
  let childNode$1 = node.children[PARAMETER];
26
52
  childNode$1 ??= {
27
53
  type: "PARAMETER",
28
- parameter: segment.substring(PARAMETER.length),
54
+ parameter: parameterMatch,
29
55
  children: {}
30
56
  };
31
57
  node.children[PARAMETER] ??= childNode$1;
32
58
  node = childNode$1;
33
59
  continue;
34
60
  }
35
- let childNode = node.children[segment];
61
+ let childNode = node.children[next];
36
62
  childNode ??= {
37
63
  type: "PATH",
38
64
  children: {}
39
65
  };
40
- node.children[segment] ??= childNode;
66
+ node.children[next] ??= childNode;
41
67
  node = childNode;
42
68
  }
43
69
  node.value = value;
@@ -60,6 +86,14 @@ var Router = class extends Radix {
60
86
  const route$1 = invoke$1(node.children[segment], index + 1);
61
87
  if (route$1) return route$1;
62
88
  }
89
+ if (node.children[OPTIONAL_PARAMETER]) {
90
+ const optionalParameterNode = node.children[OPTIONAL_PARAMETER];
91
+ const route$1 = invoke$1(optionalParameterNode, index + 1);
92
+ if (route$1) {
93
+ context.parameters[optionalParameterNode.parameter] = segment;
94
+ return route$1;
95
+ }
96
+ }
63
97
  if (node.children[PARAMETER]) {
64
98
  const parameterNode = node.children[PARAMETER];
65
99
  const route$1 = invoke$1(parameterNode, index + 1);
@@ -68,6 +102,11 @@ var Router = class extends Radix {
68
102
  return route$1;
69
103
  }
70
104
  }
105
+ if (node.children[OPTIONAL_WILDCARD]) {
106
+ const optionalWildcardNode = node.children[OPTIONAL_WILDCARD];
107
+ context.parameters[optionalWildcardNode.parameter] = segment;
108
+ return optionalWildcardNode.value ?? invoke$1(optionalWildcardNode, context.segments.length);
109
+ }
71
110
  if (node.children[WILDCARD]) {
72
111
  const wildcardNode = node.children[WILDCARD];
73
112
  context.parameters[wildcardNode.parameter] = segment;
@@ -109,10 +148,7 @@ function useQuery(scope, schema) {
109
148
  }
110
149
  function withQuery(input, query) {
111
150
  const url = new URL(input);
112
- for (const name in query) {
113
- const value = query[name];
114
- if (value) url.searchParams.set(name, value);
115
- }
151
+ for (const name in query) url.searchParams.set(name, query[name]);
116
152
  return url.href;
117
153
  }
118
154
  function useCookies(scope, schema) {
@@ -203,12 +239,7 @@ function sendUnauthorized(scope, config) {
203
239
  return new Response(null, mergeObjects(response, config));
204
240
  }
205
241
  function mimeType(file) {
206
- const extension = /\.([a-zA-Z0-9]+?)$/.exec(file)?.at(1);
207
- return mimeTypes[extension ?? ""] ?? "text/plain";
208
- }
209
- function toRoutePath(path) {
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];
242
+ return mimeTypes[/\.([a-zA-Z0-9]+?)$/.exec(file)?.at(1) ?? ""] ?? "text/plain";
212
243
  }
213
244
  async function invoke(scope, pipeline, index = 0) {
214
245
  return await pipeline.at(index)?.fetch(scope, async () => await invoke(scope, pipeline, index + 1));
@@ -218,8 +249,13 @@ async function createServer() {
218
249
  const middlewares = new Array();
219
250
  const routes = await import("#virtual/routes").then((module) => Object.entries(module.default));
220
251
  for (const [path, route] of routes) {
221
- const [result, method] = toRoutePath(path);
222
- router.use(method + "/" + result, route);
252
+ const segments = path.toLowerCase().split("/");
253
+ for (const attribute of segments.pop()?.split(".") ?? []) {
254
+ if (attribute === "index" || attribute === "js" || attribute === "ts") continue;
255
+ if (attribute === "get" || attribute === "post" || attribute === "put" || attribute === "delete" || attribute === "patch" || attribute === "options" || attribute === "head" || attribute === "trace" || attribute === "connect") segments.unshift(attribute);
256
+ else segments.push(attribute);
257
+ }
258
+ router.use(segments, route);
223
259
  }
224
260
  middlewares.push(router);
225
261
  return {
@@ -230,15 +266,24 @@ async function createServer() {
230
266
  return await invoke(scope, middlewares);
231
267
  } catch (value) {
232
268
  if (value instanceof Response) return value;
269
+ throw value;
233
270
  }
234
271
  }
235
272
  };
236
273
  }
274
+ let STATES;
237
275
  const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
238
276
  const SERVER_CONTEXT = defineContext("SERVER_CONTEXT");
239
- const WILDCARD = "$";
240
- const PARAMETER = ":";
241
- let STATES;
277
+ const WILDCARD = "@";
278
+ const OPTIONAL_WILDCARD = "@@";
279
+ const PARAMETER = "@@@";
280
+ const OPTIONAL_PARAMETER = "@@@";
281
+ const WILDCARD_MATCH = /\[\.\.\.(.*?)\]/;
282
+ const OPTIONAL_WILDCARD_MATCH = /\[\[\.\.\.(.*?)\]\]/;
283
+ const PARAMETER_MATCH = /\[(.*?)\]/;
284
+ const OPTIONAL_PARAMETER_MATCH = /\[\[(.*?)\]\]/;
285
+ const isServer = import.meta.server ?? globalThis?.import?.meta?.server;
286
+ const isClient = import.meta.client ?? globalThis?.import?.meta?.client;
242
287
  const mimeTypes = {
243
288
  txt: "text/plain",
244
289
  css: "text/css",
@@ -284,18 +329,12 @@ const mimeTypes = {
284
329
  exe: "application/vnd.microsoft.portable-executable",
285
330
  apk: "application/vnd.android.package-archive"
286
331
  };
287
- const isServer = import.meta.server ?? globalThis?.import?.meta?.server;
288
- const isClient = import.meta.client ?? globalThis?.import?.meta?.client;
289
332
 
290
333
  //#endregion
291
334
  //#region src/shared/index.ts
292
- var Scope = class {
293
- parentScope;
294
- context;
335
+ var Hookable = class {
295
336
  hooks;
296
- constructor(parentScope) {
297
- this.parentScope = parentScope;
298
- this.context = {};
337
+ constructor() {
299
338
  this.hooks = {};
300
339
  }
301
340
  registerHook(name, invoke$1) {
@@ -313,6 +352,15 @@ var Scope = class {
313
352
  for (const invoke$1 of this.hooks[name] ?? []) results.push(await invoke$1(...inputs));
314
353
  return results;
315
354
  }
355
+ };
356
+ var Scope = class extends Hookable {
357
+ parentScope;
358
+ context;
359
+ constructor(parentScope) {
360
+ super();
361
+ this.parentScope = parentScope;
362
+ this.context = {};
363
+ }
316
364
  getContext(input) {
317
365
  let scope = this;
318
366
  while (scope) {
@@ -336,7 +384,7 @@ function isFailure(result) {
336
384
  }
337
385
  function parseSchema(scope, schema, value) {
338
386
  const result = schema["~standard"].validate(value);
339
- if (isFailure(result)) throw sendBadRequest(scope, result.issues.map((issue) => issue.message).join(", "));
387
+ if (isFailure(result)) throw sendJson(scope, result, { status: 400 });
340
388
  return result.value;
341
389
  }
342
390
  function mergeObjects(base, input) {
@@ -355,25 +403,42 @@ function mergeObjects(base, input) {
355
403
 
356
404
  //#endregion
357
405
  //#region src/app/index.ts
358
- function createApp(inputConfig) {
359
- let config = mergeObjects(inputConfig, {
360
- modules: [],
361
- sources: { routes: {
362
- match: "**/*.{get,head,post,put,delete,connect,options,trace,patch}.{js,ts}",
363
- entries: ["./routes"]
364
- } },
365
- development: { middlewares: [] },
366
- build: { externals: [] }
367
- });
368
- for (const module of config.modules) config = mergeObjects(config, module.config);
369
- return {
370
- config,
371
- virtuals: {},
372
- alias: {}
373
- };
374
- }
406
+ var App = class extends Hookable {
407
+ config;
408
+ constructor(inputConfig) {
409
+ super();
410
+ this.config = mergeObjects(inputConfig, {
411
+ modules: [],
412
+ client: "./index.html",
413
+ template: {
414
+ head: {
415
+ tagName: "head",
416
+ attributes: {},
417
+ children: []
418
+ },
419
+ body: {
420
+ tagName: "body",
421
+ attributes: {},
422
+ children: []
423
+ }
424
+ },
425
+ sources: { routes: {
426
+ match: "**/*.{get,head,post,put,delete,connect,options,trace,patch}.{js,ts}",
427
+ entries: ["./routes"]
428
+ } },
429
+ development: { middlewares: [] },
430
+ build: {
431
+ externals: [],
432
+ types: {},
433
+ virtuals: {},
434
+ alias: {}
435
+ }
436
+ });
437
+ for (const module of this.config.modules) this.config = mergeObjects(this.config, module.config);
438
+ }
439
+ };
375
440
  const SERVER = "ssr";
376
441
  const CLIENT = "client";
377
442
 
378
443
  //#endregion
379
- export { CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, WILDCARD, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
444
+ export { isServer as A, setState as B, WILDCARD_MATCH as C, getState as D, defineRoute as E, sendJson as F, useServer as G, useHeaders as H, sendRedirect as I, withQuery as J, useSetCookies as K, sendText as L, mimeTypes as M, sendBadRequest as N, invoke as O, sendHtml as P, sendUnauthorized as R, WILDCARD as S, defineMiddleware as T, useQuery as U, useCookies as V, useRouter as W, ROUTER_CONTEXT as _, Scope as a, SERVER_CONTEXT as b, isFailure as c, OPTIONAL_PARAMETER as d, OPTIONAL_PARAMETER_MATCH as f, PARAMETER_MATCH as g, PARAMETER as h, Hookable as i, mimeType as j, isClient as k, mergeObjects as l, OPTIONAL_WILDCARD_MATCH as m, CLIENT as n, defineContext as o, OPTIONAL_WILDCARD as p, useUrl as q, SERVER as r, defineHook as s, App as t, parseSchema as u, Radix as v, createServer as w, STATES as x, Router as y, setCookie as z };
@@ -7,7 +7,7 @@ type Context = Record<string, any>;
7
7
  type Output<T> = Success<T> | Failure;
8
8
  type InferInput<T extends Schema> = NonNullable<T["~standard"]["types"]>["input"];
9
9
  type InferOutput<T extends Schema> = NonNullable<T["~standard"]["types"]>["output"];
10
- type Mergeable<T> = { [P in keyof T]?: Mergeable<T[P]> };
10
+ type Mergeable<T> = { [Key in keyof T]?: Mergeable<T[Key]> };
11
11
  interface Issue {
12
12
  readonly message: string;
13
13
  }
@@ -26,13 +26,16 @@ interface Schema<T = unknown, TOutput = T> {
26
26
  };
27
27
  };
28
28
  }
29
- declare class Scope {
30
- parentScope?: Scope;
31
- readonly context: Context;
32
- readonly hooks: Record<string, Array<Invoke>>;
33
- constructor(parentScope?: Scope);
29
+ declare class Hookable {
30
+ private readonly hooks;
31
+ constructor();
34
32
  registerHook<T extends Invoke>(name: Descriptor<T>, invoke: T): () => void;
35
33
  dispatchHook<T extends Invoke>(name: Descriptor<T>, ...inputs: Parameters<T>): Promise<Awaited<ReturnType<T>>[]>;
34
+ }
35
+ declare class Scope extends Hookable {
36
+ private parentScope?;
37
+ private readonly context;
38
+ constructor(parentScope?: Scope);
36
39
  getContext<T>(input: Descriptor<T>): T;
37
40
  setContext<T>(input: Descriptor<T>, value: T): void;
38
41
  }
@@ -51,7 +54,7 @@ type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "bas
51
54
  type StatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 506 | 507 | 508 | 509 | 510 | 511 | 521 | 522 | 523 | 525 | 530 | 599;
52
55
  type MimeType = "text/plain" | "text/css" | "text/html" | "text/csv" | "text/javascript" | "application/json" | "application/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/x-icon" | "font/ttf" | "font/otf" | "font/woff" | "font/woff2" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/mp4" | "video/mp4" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "application/zip" | "application/vnd.rar" | "application/x-tar" | "application/gzip" | "application/x-7z-compressed" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.microsoft.portable-executable" | "application/vnd.android.package-archive";
53
56
  type Result = void | Response | Promise<void | Response>;
54
- type Node<T> = WildcardNode<T> | ParameterNode<T> | PathNode<T>;
57
+ type Node<T> = OptionalWildcardNode<T> | WildcardNode<T> | OptionalParameterNode<T> | ParameterNode<T> | PathNode<T>;
55
58
  type States = Record<string, unknown>;
56
59
  interface CookieOptions {
57
60
  domain?: string;
@@ -96,6 +99,18 @@ interface WildcardNode<T> {
96
99
  parameter: string;
97
100
  children: Record<string, Node<T>>;
98
101
  }
102
+ interface OptionalWildcardNode<T> {
103
+ type: "OPTIONAL-WILDCARD";
104
+ value?: T;
105
+ parameter: string;
106
+ children: Record<string, Node<T>>;
107
+ }
108
+ interface OptionalParameterNode<T> {
109
+ type: "OPTIONAL-PARAMETER";
110
+ value?: T;
111
+ parameter: string;
112
+ children: Record<string, Node<T>>;
113
+ }
99
114
  interface ParameterNode<T> {
100
115
  type: "PARAMETER";
101
116
  value?: T;
@@ -109,8 +124,8 @@ interface PathNode<T> {
109
124
  }
110
125
  declare class Radix<T> {
111
126
  readonly rootNode: Node<T>;
112
- constructor();
113
- use(path: string, value: T): Node<T>;
127
+ constructor(rootNode?: Node<T>);
128
+ use(segments: Array<string>, value: T): Node<T>;
114
129
  }
115
130
  declare class Router extends Radix<Route> implements Middleware {
116
131
  fetch(scope: Scope): Result;
@@ -138,31 +153,46 @@ declare function sendRedirect(scope: Scope, path: string, config?: Mergeable<Res
138
153
  declare function sendBadRequest(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
139
154
  declare function sendUnauthorized(scope: Scope, config?: Mergeable<ResponseConfig>): Response;
140
155
  declare function mimeType(file: string): MimeType;
141
- declare function toRoutePath(path: string): [string, ...Array<string>];
142
156
  declare function invoke(scope: Scope, pipeline: Array<Middleware>, index?: number): Promise<Result>;
143
157
  declare function createServer(): Promise<Server>;
158
+ declare let STATES: States;
144
159
  declare const ROUTER_CONTEXT: Descriptor<RouterContext>;
145
160
  declare const SERVER_CONTEXT: Descriptor<ServerContext<Context>>;
146
- declare const WILDCARD = "$";
147
- declare const PARAMETER = ":";
148
- declare let STATES: States;
149
- declare const mimeTypes: Record<string, MimeType>;
161
+ declare const WILDCARD = "@";
162
+ declare const OPTIONAL_WILDCARD = "@@";
163
+ declare const PARAMETER = "@@@";
164
+ declare const OPTIONAL_PARAMETER = "@@@";
165
+ declare const WILDCARD_MATCH: RegExp;
166
+ declare const OPTIONAL_WILDCARD_MATCH: RegExp;
167
+ declare const PARAMETER_MATCH: RegExp;
168
+ declare const OPTIONAL_PARAMETER_MATCH: RegExp;
150
169
  declare const isServer: boolean;
151
170
  declare const isClient: boolean;
171
+ declare const mimeTypes: Record<string, MimeType>;
152
172
  //#endregion
153
173
  //#region src/app/index.d.ts
154
174
  type Environment = typeof CLIENT | typeof SERVER;
155
175
  type Virtual = (environment: Environment) => undefined | string | Promise<string>;
176
+ type Content = () => string;
177
+ interface Template {
178
+ tagName: string;
179
+ attributes: Record<string, string>;
180
+ children: Array<string | Template>;
181
+ }
156
182
  interface DevelopmentConfig {
157
183
  middlewares: Array<Middleware>;
158
184
  }
159
185
  interface BuildConfig {
160
186
  externals: Array<string>;
187
+ types: Record<string, Content>;
188
+ virtuals: Record<string, Virtual>;
189
+ alias: Record<string, string>;
161
190
  }
162
191
  interface Config {
163
192
  modules: Array<Module>;
164
193
  client?: string;
165
194
  server?: string;
195
+ template: Record<"head" | "body", Template>;
166
196
  sources: Record<string, Source>;
167
197
  development: DevelopmentConfig;
168
198
  build: BuildConfig;
@@ -176,16 +206,14 @@ interface Source {
176
206
  entries: Array<string>;
177
207
  resolve?: (path: string) => string;
178
208
  }
179
- interface App {
209
+ declare class App extends Hookable {
180
210
  config: Config;
181
- virtuals: Record<string, Virtual>;
182
- alias: Record<string, string>;
211
+ constructor(inputConfig?: Mergeable<Config>);
183
212
  }
184
- declare function createApp(inputConfig?: Mergeable<Config>): App;
185
213
  declare const SERVER = "ssr";
186
214
  declare const CLIENT = "client";
187
215
  //#endregion
188
216
  //#region src/client/index.d.ts
189
217
  declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
190
218
  //#endregion
191
- export { $fetch, App, BuildConfig, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, HttpMethod, InferInput, InferOutput, Invoke, 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, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
219
+ export { isClient as $, ParameterNode as A, Scope as At, STATES as B, OPTIONAL_PARAMETER_MATCH as C, InferInput as Ct, OptionalWildcardNode as D, Mergeable as Dt, OptionalParameterNode as E, Issue as Et, Result as F, mergeObjects as Ft, WILDCARD as G, ServerContext as H, Route as I, parseSchema as It, createServer as J, WILDCARD_MATCH as K, Router as L, ROUTER_CONTEXT as M, defineContext as Mt, Radix as N, defineHook as Nt, PARAMETER as O, Output as Ot, ResponseConfig as P, isFailure as Pt, invoke as Q, RouterContext as R, OPTIONAL_PARAMETER as S, Hookable as St, OPTIONAL_WILDCARD_MATCH as T, Invoke as Tt, States as U, Server as V, StatusCode as W, defineRoute as X, defineMiddleware as Y, getState as Z, Encoding as _, useUrl as _t, Config as a, sendJson as at, MimeType as b, Descriptor as bt, Environment as c, sendUnauthorized as ct, Source as d, useCookies as dt, isServer as et, Template as f, useHeaders as ft, CookieSameSite as g, useSetCookies as gt, CookiePriority as h, useServer as ht, CLIENT as i, sendHtml as it, PathNode as j, Success as jt, PARAMETER_MATCH as k, Schema as kt, Module as l, setCookie as lt, CookieOptions as m, useRouter as mt, App as n, mimeTypes as nt, Content as o, sendRedirect as ot, Virtual as p, useQuery as pt, WildcardNode as q, BuildConfig as r, sendBadRequest as rt, DevelopmentConfig as s, sendText as st, $fetch as t, mimeType as tt, SERVER as u, setState as ut, HttpMethod as v, withQuery as vt, OPTIONAL_WILDCARD as w, InferOutput as wt, Node as x, Failure as xt, Middleware as y, Context as yt, SERVER_CONTEXT as z };
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, Invoke, 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, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./index-CUwjaRno.js";
2
- export { $fetch, App, BuildConfig, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, HttpMethod, InferInput, InferOutput, Invoke, 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, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
1
+ import { $ as isClient, A as ParameterNode, At as Scope, B as STATES, C as OPTIONAL_PARAMETER_MATCH, Ct as InferInput, D as OptionalWildcardNode, Dt as Mergeable, E as OptionalParameterNode, Et as Issue, F as Result, Ft as mergeObjects, G as WILDCARD, H as ServerContext, I as Route, It as parseSchema, J as createServer, K as WILDCARD_MATCH, L as Router, M as ROUTER_CONTEXT, Mt as defineContext, N as Radix, Nt as defineHook, O as PARAMETER, Ot as Output, P as ResponseConfig, Pt as isFailure, Q as invoke, R as RouterContext, S as OPTIONAL_PARAMETER, St as Hookable, T as OPTIONAL_WILDCARD_MATCH, Tt as Invoke, U as States, V as Server, W as StatusCode, X as defineRoute, Y as defineMiddleware, Z as getState, _ as Encoding, _t as useUrl, a as Config, at as sendJson, b as MimeType, bt as Descriptor, c as Environment, ct as sendUnauthorized, d as Source, dt as useCookies, et as isServer, f as Template, ft as useHeaders, g as CookieSameSite, gt as useSetCookies, h as CookiePriority, ht as useServer, i as CLIENT, it as sendHtml, j as PathNode, jt as Success, k as PARAMETER_MATCH, kt as Schema, l as Module, lt as setCookie, m as CookieOptions, mt as useRouter, n as App, nt as mimeTypes, o as Content, ot as sendRedirect, p as Virtual, pt as useQuery, q as WildcardNode, r as BuildConfig, rt as sendBadRequest, s as DevelopmentConfig, st as sendText, t as $fetch, tt as mimeType, u as SERVER, ut as setState, v as HttpMethod, vt as withQuery, w as OPTIONAL_WILDCARD, wt as InferOutput, x as Node, xt as Failure, y as Middleware, yt as Context, z as SERVER_CONTEXT } from "./index-NJXRiTAn.js";
2
+ export { $fetch, App, BuildConfig, CLIENT, 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 };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, WILDCARD, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery } from "./app-CZxSS8Ok.js";
1
+ import { A as isServer, B as setState, C as WILDCARD_MATCH, D as getState, E as defineRoute, F as sendJson, G as useServer, H as useHeaders, I as sendRedirect, J as withQuery, K as useSetCookies, L as sendText, M as mimeTypes, N as sendBadRequest, O as invoke, P as sendHtml, R as sendUnauthorized, S as WILDCARD, T as defineMiddleware, U as useQuery, V as useCookies, W as useRouter, _ as ROUTER_CONTEXT, a as Scope, b as SERVER_CONTEXT, c as isFailure, d as OPTIONAL_PARAMETER, f as OPTIONAL_PARAMETER_MATCH, g as PARAMETER_MATCH, h as PARAMETER, i as Hookable, j as mimeType, k as isClient, l as mergeObjects, m as OPTIONAL_WILDCARD_MATCH, n as CLIENT, o as defineContext, p as OPTIONAL_WILDCARD, q as useUrl, r as SERVER, s as defineHook, t as App, u as parseSchema, v as Radix, w as createServer, x as STATES, y as Router, z as setCookie } from "./app-B3x9-FYe.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, CLIENT, PARAMETER, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, WILDCARD, createApp, createServer, defineContext, defineHook, defineMiddleware, defineRoute, getState, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, setState, toRoutePath, useCookies, useHeaders, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
28
+ export { $fetch, App, CLIENT, 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 };
@@ -1,12 +1,12 @@
1
- import { App, Virtual } from "../index-CUwjaRno.js";
1
+ import { n as App, o as Content, p as Virtual } from "../index-NJXRiTAn.js";
2
2
 
3
3
  //#region src/kit/index.d.ts
4
- declare function useKit(app: App, source: string | URL): {
5
- source: string;
6
- toPath: (...paths: Array<string>) => string;
7
- addVirtual: (name: string, virtual: Virtual) => void;
8
- addAlias: (name: string, path: string) => void;
4
+ declare function useKit(source: string | URL): {
5
+ fromModule(...paths: Array<string>): string;
9
6
  };
7
+ declare function addAlias(app: App, name: string, path: string): void;
8
+ declare function addVirtual(app: App, name: string, virtual: Virtual): void;
9
+ declare function addTypes(app: App, name: string, types: Content): void;
10
10
  declare function addRoutes(app: App, path: string): void;
11
11
  //#endregion
12
- export { addRoutes, useKit };
12
+ export { addAlias, addRoutes, addTypes, addVirtual, useKit };
package/dist/kit/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { addRoutes, useKit } from "../kit-Bzr1NqHb.js";
1
+ import { a as useKit, i as addVirtual, n as addRoutes, r as addTypes, t as addAlias } from "../kit-BQv19une.js";
2
2
 
3
- export { addRoutes, useKit };
3
+ export { addAlias, addRoutes, addTypes, addVirtual, useKit };
@@ -0,0 +1,26 @@
1
+ import { dirname, join, posix, win32 } from "path";
2
+ import { fileURLToPath } from "url";
3
+
4
+ //#region src/kit/index.ts
5
+ function useKit(source) {
6
+ source = source.toString();
7
+ if (source.startsWith("file://")) source = dirname(fileURLToPath(source));
8
+ return { fromModule(...paths) {
9
+ return join(source, ...paths).split(win32.sep).join(posix.sep);
10
+ } };
11
+ }
12
+ function addAlias(app, name, path) {
13
+ app.config.build.alias["#alias/" + name] = path;
14
+ }
15
+ function addVirtual(app, name, virtual) {
16
+ app.config.build.virtuals["#virtual/" + name] = virtual;
17
+ }
18
+ function addTypes(app, name, types) {
19
+ app.config.build.types[name] = types;
20
+ }
21
+ function addRoutes(app, path) {
22
+ app.config.sources.routes?.entries.push(path);
23
+ }
24
+
25
+ //#endregion
26
+ export { useKit as a, addVirtual as i, addRoutes as n, addTypes as r, addAlias as t };
@@ -1,4 +1,4 @@
1
- import { Config, Mergeable } from "../index-CUwjaRno.js";
1
+ import { Dt as Mergeable, a as Config } from "../index-NJXRiTAn.js";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/vite/index.d.ts
@@ -1,13 +1,18 @@
1
- import { CLIENT, SERVER, SERVER_CONTEXT, Scope, createApp, invoke } from "../app-CZxSS8Ok.js";
2
- import { useKit } from "../kit-Bzr1NqHb.js";
3
- import { basename, dirname, isAbsolute, join, posix, relative, win32 } from "path";
1
+ import { O as invoke, a as Scope, b as SERVER_CONTEXT, n as CLIENT, r as SERVER, t as App } from "../app-B3x9-FYe.js";
2
+ import { a as useKit, i as addVirtual } from "../kit-BQv19une.js";
3
+ import { basename, isAbsolute, join, posix, resolve, win32 } from "path";
4
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
5
+ import { cwd } from "process";
6
+ import { globSync } from "tinyglobby";
4
7
  import { isRunnableDevEnvironment } from "vite";
5
8
  import { once } from "events";
6
9
  import { Readable, Stream } from "stream";
7
- import { existsSync, readFileSync } from "fs";
8
- import { globSync } from "tinyglobby";
9
- import { rm } from "fs/promises";
10
10
 
11
+ //#region package.json
12
+ var name = "revojs";
13
+ var version = "0.1.24";
14
+
15
+ //#endregion
11
16
  //#region src/vite/node/index.ts
12
17
  function splitSetCookieString(cookiesString) {
13
18
  if (Array.isArray(cookiesString)) return cookiesString.flatMap((c) => splitSetCookieString(c));
@@ -175,7 +180,7 @@ function client() {
175
180
  const path = key.substring(0, key.length - 7);
176
181
  if (bundle) for (const name$1 in bundle) {
177
182
  const file = bundle[name$1];
178
- if (file && file.type === "asset" && file.fileName === basename(path)) return file.source.toString();
183
+ if (file.type === "asset" && file.fileName === basename(path)) return file.source.toString();
179
184
  }
180
185
  return readFileSync(path, "utf-8");
181
186
  }
@@ -191,89 +196,6 @@ function client() {
191
196
  };
192
197
  }
193
198
 
194
- //#endregion
195
- //#region src/vite/plugins/css.ts
196
- function css() {
197
- let devServer;
198
- const styles = new Array();
199
- return {
200
- name: "css",
201
- apply: "serve",
202
- configureServer(server) {
203
- devServer = server;
204
- },
205
- transform(_, source) {
206
- if (source.match(/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/)) {
207
- if (!styles.includes(source) && !source.includes("?") && !source.includes(".node_modules") && !source.includes("@vite")) styles.push(relative(devServer.config.root, source));
208
- }
209
- },
210
- transformIndexHtml() {
211
- return [...styles.map((path) => ({
212
- tag: "link",
213
- injectTo: "head",
214
- attrs: {
215
- rel: "stylesheet",
216
- href: "/" + path,
217
- "data-preload": true
218
- }
219
- })), {
220
- tag: "script",
221
- injectTo: "head",
222
- attrs: { type: "module" },
223
- children: `
224
- const observer = new MutationObserver(() => {
225
- if (document.querySelector('style[data-vite-dev-id]')) {
226
- document.querySelectorAll('[data-preload]').forEach((node) => node.remove());
227
-
228
- observer.disconnect();
229
- }
230
- });
231
-
232
- observer.observe(document.head, { childList: true });
233
- `
234
- }];
235
- }
236
- };
237
- }
238
-
239
- //#endregion
240
- //#region src/vite/plugins/entry.ts
241
- function entry() {
242
- let entryName;
243
- let entryPath;
244
- return {
245
- name: "entry",
246
- enforce: "pre",
247
- sharedDuringBuild: true,
248
- resolveId: {
249
- filter: { id: /\.html$/ },
250
- handler(source, importer, options) {
251
- if (this.environment.name === CLIENT) {
252
- if (importer && entryPath) {
253
- const path = join(dirname(importer), source);
254
- if (existsSync(path)) return path;
255
- }
256
- if (options.isEntry) {
257
- entryName = basename(source);
258
- entryPath = source;
259
- return entryName;
260
- }
261
- }
262
- }
263
- },
264
- load: {
265
- filter: { id: /\.html$/ },
266
- handler(source) {
267
- if (entryName && entryPath && source === entryName) return readFileSync(entryPath, {
268
- encoding: "utf-8",
269
- flag: "r"
270
- });
271
- return null;
272
- }
273
- }
274
- };
275
- }
276
-
277
199
  //#endregion
278
200
  //#region src/vite/plugins/virtuals.ts
279
201
  function virtuals(virtuals$1) {
@@ -282,7 +204,7 @@ function virtuals(virtuals$1) {
282
204
  name: "virtuals",
283
205
  enforce: "pre",
284
206
  sharedDuringBuild: true,
285
- resolveId(key, importer) {
207
+ resolveId(key) {
286
208
  if (cache.has(key)) return key;
287
209
  if (key.startsWith("#")) {
288
210
  const path = "/" + key.slice(1);
@@ -304,44 +226,70 @@ function virtuals(virtuals$1) {
304
226
  };
305
227
  }
306
228
 
307
- //#endregion
308
- //#region package.json
309
- var name = "revojs";
310
- var version = "0.1.22";
311
-
312
229
  //#endregion
313
230
  //#region src/vite/index.ts
231
+ function toHtmlTagDescriptor(template, injectTo) {
232
+ let children;
233
+ for (const entry of template.children) {
234
+ if (typeof entry === "string") {
235
+ children ??= "";
236
+ if (typeof children === "string") children += entry;
237
+ }
238
+ if (typeof entry === "object") {
239
+ children ??= [];
240
+ if (Array.isArray(children)) children.push(toHtmlTagDescriptor(entry, injectTo));
241
+ }
242
+ }
243
+ return {
244
+ tag: template.tagName,
245
+ attrs: template.attributes,
246
+ children,
247
+ injectTo
248
+ };
249
+ }
314
250
  function revojs(config) {
315
- const app = createApp(config);
251
+ const app = new App(config);
316
252
  return [
317
253
  {
318
254
  name,
319
255
  version,
320
256
  sharedDuringBuild: true,
321
257
  async config() {
322
- const { toPath, addVirtual } = useKit(app, process.cwd());
258
+ const { fromModule } = useKit(cwd());
323
259
  for (const module of app.config.modules) await module.setup?.(app);
324
- if (app.config.client) addVirtual("client", () => `import client from "${app.config.client}?client"; export default client`);
325
- if (app.config.server) addVirtual("server", () => `import { createServer } from "revojs"; export default await createServer()`);
260
+ addVirtual(app, "client", () => {
261
+ if (app.config.client) return `import client from "${fromModule(app.config.client)}?client"; export default client`;
262
+ });
263
+ addVirtual(app, "server", () => {
264
+ if (app.config.server) return `import { createServer } from "revojs"; export default await createServer()`;
265
+ });
326
266
  for (const name$1 in app.config.sources) {
327
267
  const source = app.config.sources[name$1];
328
- if (source) addVirtual(name$1, () => {
268
+ addVirtual(app, name$1, () => {
329
269
  const entries = {};
330
270
  for (let path of source.entries) {
331
- path = isAbsolute(path) ? path : toPath(path);
271
+ path = isAbsolute(path) ? path : resolve(path);
332
272
  for (const asset of globSync(source.match, { cwd: path })) entries[asset] = join(path, asset).split(win32.sep).join(posix.sep);
333
273
  }
334
- const content = Object.values(entries).reduce((content$1, path, index) => content$1 + `import $${index} from "${source.resolve?.(path) ?? path}" \n`, "");
335
- const result = Object.keys(entries).map((name$2, index) => {
274
+ return `${Object.values(entries).reduce((content, path, index) => content + `import $${index} from "${source.resolve?.(path) ?? path}" \n`, "")} export default {${Object.keys(entries).map((name$2, index) => {
336
275
  if (entries[name$2]) return `"${name$2}": $${index}`;
337
- });
338
- return `${content} export default {${result}}`;
276
+ })}}`;
339
277
  });
340
278
  }
279
+ const metaTypesPath = join(resolve(".revojs"), "types");
280
+ rmSync(metaTypesPath, {
281
+ recursive: true,
282
+ force: true
283
+ });
284
+ mkdirSync(metaTypesPath, { recursive: true });
285
+ for (const type in app.config.build.types) {
286
+ const content = app.config.build.types[type];
287
+ writeFileSync(join(metaTypesPath, type), content());
288
+ }
341
289
  return {
342
290
  appType: "custom",
343
291
  optimizeDeps: { exclude: ["revojs"] },
344
- resolve: { alias: app.alias },
292
+ resolve: { alias: app.config.build.alias },
345
293
  build: {
346
294
  emptyOutDir: false,
347
295
  assetsInlineLimit: 4096 * 4,
@@ -350,13 +298,14 @@ function revojs(config) {
350
298
  builder: {
351
299
  sharedConfigBuild: true,
352
300
  async buildApp(builder) {
353
- await rm("./dist", {
301
+ rmSync("./dist", {
354
302
  recursive: true,
355
303
  force: true
356
304
  });
357
305
  for (const key in builder.environments) {
358
306
  const environment = builder.environments[key];
359
- if (environment) await builder.build(environment);
307
+ await builder.build(environment);
308
+ if (environment.name === CLIENT && typeof environment.config.build.rollupOptions.input === "string") rmSync(resolve(environment.config.build.outDir, basename(environment.config.build.rollupOptions.input)));
360
309
  }
361
310
  }
362
311
  },
@@ -365,7 +314,7 @@ function revojs(config) {
365
314
  consumer: "client",
366
315
  resolve: { noExternal: true },
367
316
  build: {
368
- rollupOptions: { input: { index: app.config.client } },
317
+ rollupOptions: { input: app.config.client },
369
318
  outDir: "./dist/public",
370
319
  copyPublicDir: true
371
320
  },
@@ -382,7 +331,7 @@ function revojs(config) {
382
331
  externalConditions: ["import"]
383
332
  },
384
333
  build: {
385
- rollupOptions: { input: { index: app.config.server } },
334
+ rollupOptions: { input: app.config.server },
386
335
  outDir: "./dist",
387
336
  copyPublicDir: false
388
337
  },
@@ -394,6 +343,17 @@ function revojs(config) {
394
343
  }
395
344
  };
396
345
  },
346
+ transformIndexHtml: {
347
+ order: "pre",
348
+ handler() {
349
+ const entries = new Array();
350
+ const head = toHtmlTagDescriptor(app.config.template.head, "head");
351
+ if (Array.isArray(head.children)) entries.push(...head.children);
352
+ const body = toHtmlTagDescriptor(app.config.template.body, "body");
353
+ if (Array.isArray(body.children)) entries.push(...body.children);
354
+ return entries;
355
+ }
356
+ },
397
357
  configResolved(config$1) {
398
358
  if (app.config.client === void 0) delete config$1.environments[CLIENT];
399
359
  if (app.config.server === void 0) delete config$1.environments[SERVER];
@@ -420,10 +380,8 @@ function revojs(config) {
420
380
  };
421
381
  }
422
382
  },
423
- virtuals(app.virtuals),
424
- client(),
425
- entry(),
426
- css()
383
+ virtuals(app.config.build.virtuals),
384
+ client()
427
385
  ];
428
386
  }
429
387
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",
@@ -1,26 +0,0 @@
1
- import { dirname, join, posix, win32 } from "path";
2
- import { fileURLToPath } from "url";
3
-
4
- //#region src/kit/index.ts
5
- function useKit(app, source) {
6
- source = source.toString();
7
- if (source.startsWith("file://")) source = dirname(fileURLToPath(source));
8
- return {
9
- source,
10
- toPath: (...paths) => {
11
- return join(source, ...paths).split(win32.sep).join(posix.sep);
12
- },
13
- addVirtual: (name, virtual) => {
14
- app.virtuals["#virtual/" + name] = virtual;
15
- },
16
- addAlias: (name, path) => {
17
- app.alias["#alias/" + name] = join(source, path).split(win32.sep).join(posix.sep);
18
- }
19
- };
20
- }
21
- function addRoutes(app, path) {
22
- app.config.sources.routes?.entries.push(path);
23
- }
24
-
25
- //#endregion
26
- export { addRoutes, useKit };