revojs 0.0.48 → 0.0.49
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 +1 -1
- package/dist/html/index.d.ts +0 -1
- package/dist/http/index.d.ts +4 -4
- package/dist/index.js +9 -15
- package/dist/runtime/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/app/index.d.ts
CHANGED
|
@@ -24,6 +24,6 @@ export type App = {
|
|
|
24
24
|
config: Config;
|
|
25
25
|
virtuals: Record<string, (environment: Environment) => string>;
|
|
26
26
|
};
|
|
27
|
-
export declare const createApp:
|
|
27
|
+
export declare const createApp: (config?: NestedPartial<Config>) => App;
|
|
28
28
|
export declare const SERVER = "ssr";
|
|
29
29
|
export declare const CLIENT = "client";
|
package/dist/html/index.d.ts
CHANGED
|
@@ -87,7 +87,6 @@ export declare const registerComponent: <TEvents extends Events, TAttributes ext
|
|
|
87
87
|
export declare function useEvent<T extends keyof ElementEventMap>(scope: Scope, target: EventTarget | undefined | null, event: T, input: EventListener<ElementEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
88
88
|
export declare function useEvent<T extends keyof WindowEventMap>(scope: Scope, target: Window | undefined | null, event: T, input: EventListener<WindowEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
89
89
|
export declare function useEvent<T extends keyof HTMLElementEventMap>(scope: Scope, target: HTMLElement | undefined | null, event: T, input: EventListener<HTMLElementEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
90
|
-
export declare const getCustomElement: (node: Node | null) => CustomElement<Events, Attributes> | undefined;
|
|
91
90
|
export declare const isClient: () => boolean;
|
|
92
91
|
export declare const isServer: () => boolean;
|
|
93
92
|
export declare const preventDefault: (event: Event) => void;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const sendJson: <T>(scope: Scope, value: T) => Response;
|
|
|
26
26
|
export declare const sendRedirect: (scope: Scope, path: string) => Response;
|
|
27
27
|
export declare const sendBadRequest: (scope: Scope, text: string) => Response;
|
|
28
28
|
export declare const sendUnauthorized: (scope: Scope) => Response;
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const
|
|
29
|
+
export declare const useRequestUrl: (scope: Scope, base?: string) => URL;
|
|
30
|
+
export declare const useCookies: (scope: Scope) => Record<string, string>;
|
|
31
|
+
export declare const useSetCookies: (scope: Scope) => Record<string, string>;
|
|
32
32
|
export declare const setCookie: (scope: Scope, name: string, value: string, options?: CookieOptions) => void;
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const mimeType: (file: string) => MimeType;
|
package/dist/index.js
CHANGED
|
@@ -462,12 +462,6 @@ function useEvent(scope, target, event, input, options) {
|
|
|
462
462
|
});
|
|
463
463
|
scope.onStop(() => controller.abort());
|
|
464
464
|
}
|
|
465
|
-
const getCustomElement = (node) => {
|
|
466
|
-
if (node) {
|
|
467
|
-
if ("component" in node) return node;
|
|
468
|
-
return getCustomElement(node.parentNode);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
465
|
const isClient = () => typeof window !== "undefined";
|
|
472
466
|
const isServer = () => typeof window === "undefined";
|
|
473
467
|
const preventDefault = (event) => event.preventDefault();
|
|
@@ -573,7 +567,7 @@ const createRuntime = async () => {
|
|
|
573
567
|
const assets = await import("#virtual/assets").then((module) => module.assets);
|
|
574
568
|
for (const path in assets) radix.insert("GET/" + path, defineRoute({ fetch: async (scope) => {
|
|
575
569
|
const { response } = useRuntime(scope);
|
|
576
|
-
response.headers.set("Content-Type",
|
|
570
|
+
response.headers.set("Content-Type", mimeType(path));
|
|
577
571
|
return new Response(await assets[path]?.(), response);
|
|
578
572
|
} }));
|
|
579
573
|
const invoke = (scope, next, index) => {
|
|
@@ -584,8 +578,8 @@ const createRuntime = async () => {
|
|
|
584
578
|
middlewares,
|
|
585
579
|
fetch: async (scope) => {
|
|
586
580
|
const { request } = useRuntime(scope);
|
|
587
|
-
const
|
|
588
|
-
const { value: route, inputs } = radix.match(request.method +
|
|
581
|
+
const { pathname } = useRequestUrl(scope);
|
|
582
|
+
const { value: route, inputs } = radix.match(request.method + pathname);
|
|
589
583
|
try {
|
|
590
584
|
scope.setContext(ROUTE_CONTEXT, { inputs: createState(inputs) });
|
|
591
585
|
if (route) {
|
|
@@ -636,11 +630,11 @@ const sendUnauthorized = (scope) => {
|
|
|
636
630
|
response.status = 401;
|
|
637
631
|
return new Response(null, response);
|
|
638
632
|
};
|
|
639
|
-
const
|
|
633
|
+
const useRequestUrl = (scope, base) => {
|
|
640
634
|
const { request } = useRuntime(scope);
|
|
641
635
|
return new URL(request.url, base);
|
|
642
636
|
};
|
|
643
|
-
const
|
|
637
|
+
const useCookies = (scope) => {
|
|
644
638
|
const { request } = useRuntime(scope);
|
|
645
639
|
return (request.headers.get("Cookie")?.split("; ") ?? []).reduce((result, cookie) => {
|
|
646
640
|
const [name, value] = cookie.split("=");
|
|
@@ -648,7 +642,7 @@ const getCookies = (scope) => {
|
|
|
648
642
|
return result;
|
|
649
643
|
}, {});
|
|
650
644
|
};
|
|
651
|
-
const
|
|
645
|
+
const useSetCookies = (scope) => {
|
|
652
646
|
const { request } = useRuntime(scope);
|
|
653
647
|
return request.headers.getSetCookie().reduce((result, cookie) => {
|
|
654
648
|
const [name, value] = cookie.split("=");
|
|
@@ -669,7 +663,7 @@ const setCookie = (scope, name, value, options) => {
|
|
|
669
663
|
if (options?.secure) cookie += `; Secure`;
|
|
670
664
|
response.headers.append("Set-Cookie", cookie);
|
|
671
665
|
};
|
|
672
|
-
const
|
|
666
|
+
const mimeType = (file) => {
|
|
673
667
|
const extension = /\.([a-zA-Z0-9]+?)$/.exec(file)?.at(1);
|
|
674
668
|
return mimeTypes[extension ?? ""] ?? "text/plain";
|
|
675
669
|
};
|
|
@@ -787,7 +781,7 @@ const useRouter = (scope, context) => {
|
|
|
787
781
|
const Page = defineComponent({
|
|
788
782
|
name: "x-page",
|
|
789
783
|
setup: ({ scope }) => {
|
|
790
|
-
const { route } = scope
|
|
784
|
+
const { route } = useRouter(scope);
|
|
791
785
|
return () => route.value;
|
|
792
786
|
}
|
|
793
787
|
});
|
|
@@ -934,4 +928,4 @@ const markdownToSlot = (input, options) => {
|
|
|
934
928
|
};
|
|
935
929
|
|
|
936
930
|
//#endregion
|
|
937
|
-
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue,
|
|
931
|
+
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue, hydrate, isClient, isServer, isTemplate, markdownToSlot, mimeType, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useCookies, useEvent, useHost, useLocale, useRequestUrl, useRoute, useRouter, useRuntime, useSetCookies };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type RuntimeContext<T = Record<string, unknown>> = {
|
|
|
17
17
|
export type RouteContext = {
|
|
18
18
|
inputs: State<Record<string, string>>;
|
|
19
19
|
};
|
|
20
|
-
export declare const useRuntime: (scope: Scope) => RuntimeContext<
|
|
20
|
+
export declare const useRuntime: <T = Record<string, unknown>>(scope: Scope) => RuntimeContext<T>;
|
|
21
21
|
export declare const useRoute: (scope: Scope) => RouteContext;
|
|
22
22
|
export declare const defineRoute: (route: Route) => Route;
|
|
23
23
|
export declare const fileName: (path: string) => string | undefined;
|