revojs 0.0.80 → 0.0.82
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 +3 -1
- package/dist/index.js +15 -12
- package/dist/jsx/index.js +38 -0
- package/dist/router/index.d.ts +0 -4
- package/dist/runtime/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -88,12 +88,14 @@ 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): Promise<void>;
|
|
91
|
+
export declare function startViewTransition(name: string, invoke: ViewTransitionUpdateCallback): Promise<void>;
|
|
92
|
+
export declare function onViewTransition<T>(name: string, value: T): () => T | undefined;
|
|
92
93
|
export declare function isClient(): boolean;
|
|
93
94
|
export declare function isServer(): boolean;
|
|
94
95
|
export declare function preventDefault(event: Event): void;
|
|
95
96
|
export declare function stopPropagation(event: Event): void;
|
|
96
97
|
export declare function stopImmediatePropagation(event: Event): void;
|
|
98
|
+
export declare const activeViewTransition: State<string | undefined>;
|
|
97
99
|
export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
|
|
98
100
|
export declare const HOST_CONTEXT: import("..").Descriptor<HostContext>;
|
|
99
101
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -443,7 +443,7 @@ function useAsync(scope, invoke, options) {
|
|
|
443
443
|
isLoading.value = true;
|
|
444
444
|
try {
|
|
445
445
|
const result = await invoke();
|
|
446
|
-
if (options?.viewTransition) await startViewTransition(() => state.value = result);
|
|
446
|
+
if (options?.viewTransition) await startViewTransition(options.viewTransition, () => state.value = result);
|
|
447
447
|
else state.value = result;
|
|
448
448
|
} catch (error) {
|
|
449
449
|
options?.catch?.(error);
|
|
@@ -800,10 +800,18 @@ function onMounted(scope, event) {
|
|
|
800
800
|
useEvent(scope, host, "mounted", event);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
async function startViewTransition(invoke) {
|
|
804
|
-
if (isClient() && document.startViewTransition !== void 0)
|
|
803
|
+
async function startViewTransition(name, invoke) {
|
|
804
|
+
if (isClient() && document.startViewTransition !== void 0) {
|
|
805
|
+
activeViewTransition.value = name;
|
|
806
|
+
return document.startViewTransition(invoke).finished.finally(() => activeViewTransition.value = void 0);
|
|
807
|
+
}
|
|
805
808
|
return invoke();
|
|
806
809
|
}
|
|
810
|
+
function onViewTransition(name, value) {
|
|
811
|
+
return () => {
|
|
812
|
+
if (activeViewTransition.value === name && isClient()) return value;
|
|
813
|
+
};
|
|
814
|
+
}
|
|
807
815
|
function isClient() {
|
|
808
816
|
return typeof window !== "undefined";
|
|
809
817
|
}
|
|
@@ -819,6 +827,7 @@ function stopPropagation(event) {
|
|
|
819
827
|
function stopImmediatePropagation(event) {
|
|
820
828
|
event.stopImmediatePropagation();
|
|
821
829
|
}
|
|
830
|
+
const activeViewTransition = createState();
|
|
822
831
|
const components = /* @__PURE__ */ new Map();
|
|
823
832
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
824
833
|
|
|
@@ -834,11 +843,6 @@ var AfterNavigateEvent = class extends Event {
|
|
|
834
843
|
super("afterNavigate");
|
|
835
844
|
}
|
|
836
845
|
};
|
|
837
|
-
var AfterNavigateTransitionEvent = class extends Event {
|
|
838
|
-
constructor() {
|
|
839
|
-
super("afterNavigateTransition");
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
846
|
function provideRouterContext(scope, options) {
|
|
843
847
|
const url = createState();
|
|
844
848
|
const route = createState();
|
|
@@ -863,7 +867,6 @@ function provideRouterContext(scope, options) {
|
|
|
863
867
|
navigator.dispatchEvent(new AfterNavigateEvent());
|
|
864
868
|
}
|
|
865
869
|
};
|
|
866
|
-
if (isClient()) useEvent(scope, window, "popstate", fetch$1);
|
|
867
870
|
scope.setContext(ROUTE_CONTEXT, { inputs: createState() });
|
|
868
871
|
scope.setContext(ROUTER_CONTEXT, {
|
|
869
872
|
options,
|
|
@@ -873,8 +876,8 @@ function provideRouterContext(scope, options) {
|
|
|
873
876
|
route
|
|
874
877
|
});
|
|
875
878
|
fetch$1();
|
|
876
|
-
useEvent(scope, navigator, "navigate", () => startViewTransition(fetch$1)
|
|
877
|
-
if (isClient())
|
|
879
|
+
useEvent(scope, navigator, "navigate", () => startViewTransition("navigate", fetch$1));
|
|
880
|
+
if (isClient()) useEvent(scope, window, "popstate", fetch$1);
|
|
878
881
|
return useRouter(scope);
|
|
879
882
|
}
|
|
880
883
|
function useRouter(scope, context) {
|
|
@@ -951,4 +954,4 @@ function useLocale(scope, context) {
|
|
|
951
954
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
952
955
|
|
|
953
956
|
//#endregion
|
|
954
|
-
export { $fetch, AfterNavigateEvent,
|
|
957
|
+
export { $fetch, AfterNavigateEvent, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, activeViewTransition, components, createApp, createCompute, createElement, createMemo, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mergeObjects, mimeType, onMounted, onViewTransition, 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/jsx/index.js
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
//#region src/signals/index.ts
|
|
2
|
+
var Handler = class Handler {
|
|
3
|
+
get(target, key) {
|
|
4
|
+
const compute = activeCompute;
|
|
5
|
+
if (compute) {
|
|
6
|
+
const computes = targets.get(target) ?? /* @__PURE__ */ new Map();
|
|
7
|
+
const set = computes.get(key) ?? /* @__PURE__ */ new Set();
|
|
8
|
+
computes.set(key, set.add(compute));
|
|
9
|
+
targets.set(target, computes);
|
|
10
|
+
compute.parentScope?.onStop(() => {
|
|
11
|
+
set.delete(compute);
|
|
12
|
+
if (set.size === 0) {
|
|
13
|
+
computes.delete(key);
|
|
14
|
+
if (computes.size === 0) targets.delete(target);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const value = Reflect.get(target, key);
|
|
19
|
+
if (value) {
|
|
20
|
+
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
const tag = Object.prototype.toString.call(value);
|
|
23
|
+
if (tag === "[object Object]" || tag === "[object Array]" || tag === "[object Map]" || tag === "[object Set]" || tag === "[object WeakMap]" || tag === "[object WeakSet]") return new Proxy(value, new Handler());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
set(target, key, value) {
|
|
29
|
+
const result = Reflect.set(target, key, value);
|
|
30
|
+
for (const compute of targets.get(target)?.get(key) ?? []) compute.run();
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function createState(value) {
|
|
35
|
+
return new Proxy({ value }, new Handler());
|
|
36
|
+
}
|
|
2
37
|
function defineContext(key) {
|
|
3
38
|
return key;
|
|
4
39
|
}
|
|
40
|
+
let activeCompute;
|
|
41
|
+
const targets = /* @__PURE__ */ new WeakMap();
|
|
5
42
|
|
|
6
43
|
//#endregion
|
|
7
44
|
//#region src/runtime/index.ts
|
|
@@ -29,6 +66,7 @@ function createElement(input, attributes, ...children) {
|
|
|
29
66
|
children
|
|
30
67
|
});
|
|
31
68
|
}
|
|
69
|
+
const activeViewTransition = createState();
|
|
32
70
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
33
71
|
|
|
34
72
|
//#endregion
|
package/dist/router/index.d.ts
CHANGED
|
@@ -17,9 +17,6 @@ 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
|
-
}
|
|
23
20
|
export declare function provideRouterContext(scope: Scope, options: RouterOptions): {
|
|
24
21
|
url: State<URL | undefined>;
|
|
25
22
|
route: State<unknown>;
|
|
@@ -44,6 +41,5 @@ declare global {
|
|
|
44
41
|
interface ElementEventMap {
|
|
45
42
|
navigate: NavigateEvent;
|
|
46
43
|
afterNavigate: AfterNavigateEvent;
|
|
47
|
-
afterNavigateTransition: AfterNavigateTransitionEvent;
|
|
48
44
|
}
|
|
49
45
|
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type RouteContext = {
|
|
|
22
22
|
inputs: State<Record<string, string>>;
|
|
23
23
|
};
|
|
24
24
|
export type AsyncOptions = {
|
|
25
|
-
viewTransition?:
|
|
25
|
+
viewTransition?: string;
|
|
26
26
|
catch?: (error: unknown) => void | Promise<void>;
|
|
27
27
|
};
|
|
28
28
|
export declare function isRoute<T>(value?: T): value is Route & T;
|