revojs 0.0.77 → 0.0.79
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/html/index.d.ts +1 -1
- package/dist/http/index.d.ts +3 -0
- package/dist/index.js +23 -5
- package/dist/router/index.d.ts +4 -0
- package/dist/runtime/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare function useEvent<T extends keyof ElementEventMap>(scope: Scope,
|
|
|
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: Document | HTMLElement | undefined | null, event: T, input: EventListener<HTMLElementEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
90
90
|
export declare function onMounted(scope: Scope, event: EventListener<MountedEvent>): void;
|
|
91
|
-
export declare function startViewTransition(invoke: ViewTransitionUpdateCallback):
|
|
91
|
+
export declare function startViewTransition(invoke: ViewTransitionUpdateCallback): Promise<void>;
|
|
92
92
|
export declare function isClient(): boolean;
|
|
93
93
|
export declare function isServer(): boolean;
|
|
94
94
|
export declare function preventDefault(event: Event): void;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ export declare function sendRedirect(scope: Scope, path: string): Response;
|
|
|
29
29
|
export declare function sendBadRequest(scope: Scope, text: string): Response;
|
|
30
30
|
export declare function sendUnauthorized(scope: Scope): Response;
|
|
31
31
|
export declare function useUrl(scope: Scope, base?: string): URL;
|
|
32
|
+
export declare function useQuery(scope: Scope): {
|
|
33
|
+
[k: string]: string;
|
|
34
|
+
};
|
|
32
35
|
export declare function useCookies(scope: Scope): Record<string, string>;
|
|
33
36
|
export declare function useSetCookies(scope: Scope): Record<string, string>;
|
|
34
37
|
export declare function setCookie(scope: Scope, name: string, value: string, options?: CookieOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -146,6 +146,10 @@ function useUrl(scope, base) {
|
|
|
146
146
|
const { request } = useRuntime(scope);
|
|
147
147
|
return new URL(request?.url ?? window?.location.href, base);
|
|
148
148
|
}
|
|
149
|
+
function useQuery(scope) {
|
|
150
|
+
const { searchParams } = useUrl(scope);
|
|
151
|
+
return Object.fromEntries(searchParams);
|
|
152
|
+
}
|
|
149
153
|
function useCookies(scope) {
|
|
150
154
|
const { request } = useRuntime(scope);
|
|
151
155
|
return (isClient() ? document.cookie : request.headers.get("Cookie") ?? "").split("; ").reduce((result, cookie) => {
|
|
@@ -437,7 +441,9 @@ function useAsync(scope, invoke, options) {
|
|
|
437
441
|
const isLoading = createState(true);
|
|
438
442
|
const execute = async () => {
|
|
439
443
|
try {
|
|
440
|
-
|
|
444
|
+
const result = await invoke().finally(() => isLoading.value = false);
|
|
445
|
+
if (options?.viewTransition) await startViewTransition(() => state.value = result);
|
|
446
|
+
else state.value = result;
|
|
441
447
|
} catch (error) {
|
|
442
448
|
options?.catch?.(error);
|
|
443
449
|
}
|
|
@@ -592,12 +598,14 @@ function hydrate(scope, parentNode, slot, index, previous) {
|
|
|
592
598
|
if (previous$1 && hydration !== previous$1) if (Array.isArray(hydration)) if (Array.isArray(previous$1)) {
|
|
593
599
|
const range = toRange(previous$1);
|
|
594
600
|
range.deleteContents();
|
|
601
|
+
range.collapse(true);
|
|
595
602
|
range.insertNode(toFragment(hydration));
|
|
596
603
|
} else if (parentNode.contains(previous$1)) parentNode.replaceChild(toFragment(hydration), previous$1);
|
|
597
604
|
else parentNode.replaceChild(toFragment(hydration), parentNode.childNodes.item(index));
|
|
598
605
|
else if (Array.isArray(previous$1)) {
|
|
599
606
|
const range = toRange(previous$1);
|
|
600
607
|
range.deleteContents();
|
|
608
|
+
range.collapse(true);
|
|
601
609
|
range.insertNode(hydration);
|
|
602
610
|
} else if (parentNode.contains(previous$1)) parentNode.replaceChild(hydration, previous$1);
|
|
603
611
|
else parentNode.replaceChild(hydration, parentNode.childNodes.item(index));
|
|
@@ -625,7 +633,11 @@ function hydrate(scope, parentNode, slot, index, previous) {
|
|
|
625
633
|
return target.setAttribute(name, set);
|
|
626
634
|
}
|
|
627
635
|
});
|
|
628
|
-
|
|
636
|
+
let index$1 = 0;
|
|
637
|
+
for (const childSlot of slot.children) {
|
|
638
|
+
const nodes = toArray(hydrate(scope, hydration, childSlot, index$1));
|
|
639
|
+
index$1 += nodes.length || 1;
|
|
640
|
+
}
|
|
629
641
|
}
|
|
630
642
|
hydration ??= document.createComment("");
|
|
631
643
|
if (parentNode.childNodes.item(index) === null) parentNode.appendChild(toFragment(hydration));
|
|
@@ -785,7 +797,7 @@ function onMounted(scope, event) {
|
|
|
785
797
|
useEvent(scope, host, "mounted", event);
|
|
786
798
|
}
|
|
787
799
|
}
|
|
788
|
-
function startViewTransition(invoke) {
|
|
800
|
+
async function startViewTransition(invoke) {
|
|
789
801
|
if (isClient() && document.startViewTransition !== void 0) return document.startViewTransition(invoke).updateCallbackDone;
|
|
790
802
|
return invoke();
|
|
791
803
|
}
|
|
@@ -819,6 +831,11 @@ var AfterNavigateEvent = class extends Event {
|
|
|
819
831
|
super("afterNavigate");
|
|
820
832
|
}
|
|
821
833
|
};
|
|
834
|
+
var AfterNavigateTransitionEvent = class extends Event {
|
|
835
|
+
constructor() {
|
|
836
|
+
super("afterNavigateTransition");
|
|
837
|
+
}
|
|
838
|
+
};
|
|
822
839
|
function provideRouterContext(scope, options) {
|
|
823
840
|
const url = createState();
|
|
824
841
|
const route = createState();
|
|
@@ -853,7 +870,8 @@ function provideRouterContext(scope, options) {
|
|
|
853
870
|
route
|
|
854
871
|
});
|
|
855
872
|
fetch$1();
|
|
856
|
-
useEvent(scope, navigator, "navigate", () => startViewTransition(fetch$1));
|
|
873
|
+
useEvent(scope, navigator, "navigate", () => startViewTransition(fetch$1).finally(() => navigator.dispatchEvent(new AfterNavigateTransitionEvent())));
|
|
874
|
+
if (isClient()) requestAnimationFrame(() => navigator.dispatchEvent(new AfterNavigateTransitionEvent()));
|
|
857
875
|
return useRouter(scope);
|
|
858
876
|
}
|
|
859
877
|
function useRouter(scope, context) {
|
|
@@ -930,4 +948,4 @@ function useLocale(scope, context) {
|
|
|
930
948
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
931
949
|
|
|
932
950
|
//#endregion
|
|
933
|
-
export { $fetch, AfterNavigateEvent, 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, createMemo, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mergeObjects, mimeType, onMounted, preventDefault, provideLocaleContext, provideRouterContext, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, startViewTransition, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, untrack, useAsync, useCookies, useEvent, useFetch, useHost, useLocale, useRoute, useRouter, useRuntime, useSetCookies, useUrl };
|
|
951
|
+
export { $fetch, AfterNavigateEvent, AfterNavigateTransitionEvent, 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, createMemo, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mergeObjects, mimeType, onMounted, preventDefault, provideLocaleContext, provideRouterContext, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, startViewTransition, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, untrack, useAsync, useCookies, useEvent, useFetch, useHost, useLocale, useQuery, useRoute, useRouter, useRuntime, useSetCookies, useUrl };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export declare class NavigateEvent extends Event {
|
|
|
17
17
|
export declare class AfterNavigateEvent extends Event {
|
|
18
18
|
constructor();
|
|
19
19
|
}
|
|
20
|
+
export declare class AfterNavigateTransitionEvent extends Event {
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
20
23
|
export declare function provideRouterContext(scope: Scope, options: RouterOptions): {
|
|
21
24
|
url: State<URL | undefined>;
|
|
22
25
|
route: State<unknown>;
|
|
@@ -41,5 +44,6 @@ declare global {
|
|
|
41
44
|
interface ElementEventMap {
|
|
42
45
|
navigate: NavigateEvent;
|
|
43
46
|
afterNavigate: AfterNavigateEvent;
|
|
47
|
+
afterNavigateTransition: AfterNavigateTransitionEvent;
|
|
44
48
|
}
|
|
45
49
|
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type RouteContext = {
|
|
|
22
22
|
inputs: State<Record<string, string>>;
|
|
23
23
|
};
|
|
24
24
|
export type AsyncOptions = {
|
|
25
|
+
viewTransition?: boolean;
|
|
25
26
|
catch?: (error: unknown) => void | Promise<void>;
|
|
26
27
|
};
|
|
27
28
|
export declare function isRoute<T>(value?: T): value is Route & T;
|