revojs 0.0.43 → 0.0.45
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/index.d.ts +0 -2
- package/dist/http/index.d.ts +1 -1
- package/dist/index.js +47 -11
- package/package.json +1 -1
- package/src/types/index.d.ts +2 -2
package/dist/app/index.d.ts
CHANGED
|
@@ -24,8 +24,6 @@ export type App<T> = {
|
|
|
24
24
|
config: Config<T>;
|
|
25
25
|
virtuals: Record<string, (environment: Environment) => string>;
|
|
26
26
|
};
|
|
27
|
-
export declare const getRoutes: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
28
|
-
export declare const getAssets: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
29
27
|
export declare const createApp: <T>(config?: NestedPartial<Config<T>>) => App<T>;
|
|
30
28
|
export declare const SERVER = "ssr";
|
|
31
29
|
export declare const CLIENT = "client";
|
package/dist/http/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type CookieOptions = {
|
|
|
11
11
|
export type HttpMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE";
|
|
12
12
|
export type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
|
13
13
|
export 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;
|
|
14
|
-
export type MimeType = "text/css" | "text/
|
|
14
|
+
export 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";
|
|
15
15
|
export type Context<T> = {
|
|
16
16
|
inputs: Record<string, string>;
|
|
17
17
|
variables: T;
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,6 @@ import { defu } from "defu";
|
|
|
2
2
|
import { h } from "revojs/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/app/index.ts
|
|
5
|
-
const getRoutes = async () => {
|
|
6
|
-
return await import("#virtual/routes").then((module) => module.routes);
|
|
7
|
-
};
|
|
8
|
-
const getAssets = async () => {
|
|
9
|
-
return await import("#virtual/assets").then((module) => module.assets);
|
|
10
|
-
};
|
|
11
5
|
const createApp = (config) => {
|
|
12
6
|
return {
|
|
13
7
|
config: defu(config, {
|
|
@@ -552,9 +546,49 @@ const getMimeType = (file) => {
|
|
|
552
546
|
return mimeTypes[extension ?? ""] ?? "text/plain";
|
|
553
547
|
};
|
|
554
548
|
const mimeTypes = {
|
|
549
|
+
txt: "text/plain",
|
|
555
550
|
css: "text/css",
|
|
551
|
+
html: "text/html",
|
|
552
|
+
htm: "text/html",
|
|
556
553
|
js: "text/javascript",
|
|
557
|
-
|
|
554
|
+
json: "application/json",
|
|
555
|
+
xml: "application/xml",
|
|
556
|
+
csv: "text/csv",
|
|
557
|
+
jpg: "image/jpeg",
|
|
558
|
+
jpeg: "image/jpeg",
|
|
559
|
+
png: "image/png",
|
|
560
|
+
gif: "image/gif",
|
|
561
|
+
webp: "image/webp",
|
|
562
|
+
svg: "image/svg+xml",
|
|
563
|
+
bmp: "image/bmp",
|
|
564
|
+
ico: "image/x-icon",
|
|
565
|
+
ttf: "font/ttf",
|
|
566
|
+
otf: "font/otf",
|
|
567
|
+
woff: "font/woff",
|
|
568
|
+
woff2: "font/woff2",
|
|
569
|
+
mp3: "audio/mpeg",
|
|
570
|
+
wav: "audio/wav",
|
|
571
|
+
ogg: "audio/ogg",
|
|
572
|
+
m4a: "audio/mp4",
|
|
573
|
+
mp4: "video/mp4",
|
|
574
|
+
webm: "video/webm",
|
|
575
|
+
ogv: "video/ogg",
|
|
576
|
+
mov: "video/quicktime",
|
|
577
|
+
avi: "video/x-msvideo",
|
|
578
|
+
zip: "application/zip",
|
|
579
|
+
rar: "application/vnd.rar",
|
|
580
|
+
tar: "application/x-tar",
|
|
581
|
+
gz: "application/gzip",
|
|
582
|
+
"7z": "application/x-7z-compressed",
|
|
583
|
+
pdf: "application/pdf",
|
|
584
|
+
doc: "application/msword",
|
|
585
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
586
|
+
xls: "application/vnd.ms-excel",
|
|
587
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
588
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
589
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
590
|
+
exe: "application/vnd.microsoft.portable-executable",
|
|
591
|
+
apk: "application/vnd.android.package-archive"
|
|
558
592
|
};
|
|
559
593
|
|
|
560
594
|
//#endregion
|
|
@@ -633,7 +667,7 @@ const getVariables = (event) => {
|
|
|
633
667
|
const createRuntime = async () => {
|
|
634
668
|
const radix = new Radix();
|
|
635
669
|
const middlewares = new Array();
|
|
636
|
-
const routes = await
|
|
670
|
+
const routes = await import("#virtual/routes").then((module) => module.routes);
|
|
637
671
|
for (const path in routes) {
|
|
638
672
|
const [name, method] = toPath(path);
|
|
639
673
|
radix.insert((method ?? "GET").toUpperCase() + name, defineRoute({ fetch: async (event) => {
|
|
@@ -650,7 +684,7 @@ const createRuntime = async () => {
|
|
|
650
684
|
}
|
|
651
685
|
} }));
|
|
652
686
|
}
|
|
653
|
-
const assets = await
|
|
687
|
+
const assets = await import("#virtual/assets").then((module) => module.assets);
|
|
654
688
|
for (const path in assets) radix.insert("GET/" + path, defineRoute({ fetch: async (event) => {
|
|
655
689
|
event.response.headers.set("Content-Type", getMimeType(path));
|
|
656
690
|
return new Response(await assets[path]?.(), event.response);
|
|
@@ -734,7 +768,9 @@ const createRouter = (options) => {
|
|
|
734
768
|
const useRouter = (scope, context) => {
|
|
735
769
|
const { url, route, inputs, navigator } = scope.getContext(context ?? ROUTER_CONTEXT);
|
|
736
770
|
const navigate = (path) => {
|
|
737
|
-
if (isClient())
|
|
771
|
+
if (isClient()) {
|
|
772
|
+
if (window.location.pathname != path) window.history.pushState(window.history.state, "", path);
|
|
773
|
+
}
|
|
738
774
|
navigator.dispatchEvent(new NavigateEvent());
|
|
739
775
|
};
|
|
740
776
|
const anchorNavigate = (event) => {
|
|
@@ -900,4 +936,4 @@ const markdownToSlot = (input, options) => {
|
|
|
900
936
|
};
|
|
901
937
|
|
|
902
938
|
//#endregion
|
|
903
|
-
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createEvent, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue,
|
|
939
|
+
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createEvent, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue, getCookies, getCustomElement, getMimeType, getRequestUrl, getSetCookies, getVariables, hydrate, isClient, isServer, isTemplate, markdownToSlot, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useEvent, useHost, useLocale, useRouter, useRuntime };
|
package/package.json
CHANGED
package/src/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ declare module "#virtual/locales" {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
declare module "#virtual/assets" {
|
|
6
|
-
export const assets: Record<string, () => Promise<
|
|
6
|
+
export const assets: Record<string, () => Promise<string>>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare module "#virtual/client" {
|
|
@@ -13,7 +13,7 @@ declare module "#virtual/client" {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
declare module "#virtual/routes" {
|
|
16
|
-
export const routes: Record<string, () => Promise<T
|
|
16
|
+
export const routes: Record<string, () => Promise<Route<T> | ComponentConstructor<Events, Attributes>>>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
declare module "#virtual/runtime" {
|