revojs 0.0.81 → 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 +2 -13
- package/dist/index.js +9 -35
- package/dist/jsx/index.js +38 -0
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -67,14 +67,6 @@ export interface CustomElement<TEvents extends Events, TAttributes extends Attri
|
|
|
67
67
|
export interface CustomElementConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
68
68
|
new (): CustomElement<TEvents, TAttributes>;
|
|
69
69
|
}
|
|
70
|
-
export declare class ViewTransitionEvent extends Event {
|
|
71
|
-
readonly name: string;
|
|
72
|
-
constructor(name: string);
|
|
73
|
-
}
|
|
74
|
-
export declare class AfterViewTransitionEvent extends Event {
|
|
75
|
-
readonly name: string;
|
|
76
|
-
constructor(name: string);
|
|
77
|
-
}
|
|
78
70
|
export declare class MountedEvent extends Event {
|
|
79
71
|
constructor();
|
|
80
72
|
}
|
|
@@ -97,19 +89,16 @@ export declare function useEvent<T extends keyof WindowEventMap>(scope: Scope, t
|
|
|
97
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;
|
|
98
90
|
export declare function onMounted(scope: Scope, event: EventListener<MountedEvent>): void;
|
|
99
91
|
export declare function startViewTransition(name: string, invoke: ViewTransitionUpdateCallback): Promise<void>;
|
|
100
|
-
export declare function onViewTransition(
|
|
92
|
+
export declare function onViewTransition<T>(name: string, value: T): () => T | undefined;
|
|
101
93
|
export declare function isClient(): boolean;
|
|
102
94
|
export declare function isServer(): boolean;
|
|
103
95
|
export declare function preventDefault(event: Event): void;
|
|
104
96
|
export declare function stopPropagation(event: Event): void;
|
|
105
97
|
export declare function stopImmediatePropagation(event: Event): void;
|
|
98
|
+
export declare const activeViewTransition: State<string | undefined>;
|
|
106
99
|
export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
|
|
107
100
|
export declare const HOST_CONTEXT: import("..").Descriptor<HostContext>;
|
|
108
101
|
declare global {
|
|
109
|
-
interface ElementEventMap {
|
|
110
|
-
viewTransition: ViewTransitionEvent;
|
|
111
|
-
afterViewTransition: AfterViewTransitionEvent;
|
|
112
|
-
}
|
|
113
102
|
interface HTMLElementEventMap {
|
|
114
103
|
mounted: MountedEvent;
|
|
115
104
|
}
|
package/dist/index.js
CHANGED
|
@@ -520,20 +520,6 @@ const ROUTE_CONTEXT = defineContext("ROUTE_CONTEXT");
|
|
|
520
520
|
|
|
521
521
|
//#endregion
|
|
522
522
|
//#region src/html/index.ts
|
|
523
|
-
var ViewTransitionEvent = class extends Event {
|
|
524
|
-
name;
|
|
525
|
-
constructor(name) {
|
|
526
|
-
super("viewTransition");
|
|
527
|
-
this.name = name;
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
var AfterViewTransitionEvent = class extends Event {
|
|
531
|
-
name;
|
|
532
|
-
constructor(name) {
|
|
533
|
-
super("afterViewTransition");
|
|
534
|
-
this.name = name;
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
523
|
var MountedEvent = class extends Event {
|
|
538
524
|
constructor() {
|
|
539
525
|
super("mounted");
|
|
@@ -816,22 +802,15 @@ function onMounted(scope, event) {
|
|
|
816
802
|
}
|
|
817
803
|
async function startViewTransition(name, invoke) {
|
|
818
804
|
if (isClient() && document.startViewTransition !== void 0) {
|
|
819
|
-
|
|
820
|
-
return document.startViewTransition(invoke).finished.finally(() =>
|
|
805
|
+
activeViewTransition.value = name;
|
|
806
|
+
return document.startViewTransition(invoke).finished.finally(() => activeViewTransition.value = void 0);
|
|
821
807
|
}
|
|
822
808
|
return invoke();
|
|
823
809
|
}
|
|
824
|
-
function onViewTransition(
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
if (event.name === viewTransition) state.value = name;
|
|
829
|
-
});
|
|
830
|
-
useEvent(scope, document, "afterViewTransition", (event) => {
|
|
831
|
-
if (event.name === viewTransition) state.value = "none";
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
return () => `view-transition-name: ${state.value}`;
|
|
810
|
+
function onViewTransition(name, value) {
|
|
811
|
+
return () => {
|
|
812
|
+
if (activeViewTransition.value === name && isClient()) return value;
|
|
813
|
+
};
|
|
835
814
|
}
|
|
836
815
|
function isClient() {
|
|
837
816
|
return typeof window !== "undefined";
|
|
@@ -848,6 +827,7 @@ function stopPropagation(event) {
|
|
|
848
827
|
function stopImmediatePropagation(event) {
|
|
849
828
|
event.stopImmediatePropagation();
|
|
850
829
|
}
|
|
830
|
+
const activeViewTransition = createState();
|
|
851
831
|
const components = /* @__PURE__ */ new Map();
|
|
852
832
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
853
833
|
|
|
@@ -897,13 +877,7 @@ function provideRouterContext(scope, options) {
|
|
|
897
877
|
});
|
|
898
878
|
fetch$1();
|
|
899
879
|
useEvent(scope, navigator, "navigate", () => startViewTransition("navigate", fetch$1));
|
|
900
|
-
if (isClient())
|
|
901
|
-
useEvent(scope, window, "popstate", () => {
|
|
902
|
-
fetch$1();
|
|
903
|
-
document.dispatchEvent(new AfterViewTransitionEvent("navigate"));
|
|
904
|
-
});
|
|
905
|
-
requestAnimationFrame(() => document.dispatchEvent(new AfterViewTransitionEvent("navigate")));
|
|
906
|
-
}
|
|
880
|
+
if (isClient()) useEvent(scope, window, "popstate", fetch$1);
|
|
907
881
|
return useRouter(scope);
|
|
908
882
|
}
|
|
909
883
|
function useRouter(scope, context) {
|
|
@@ -980,4 +954,4 @@ function useLocale(scope, context) {
|
|
|
980
954
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
981
955
|
|
|
982
956
|
//#endregion
|
|
983
|
-
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
|