revojs 0.0.81 → 0.0.83
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 +6 -13
- package/dist/index.js +14 -35
- package/dist/jsx/index.js +38 -0
- package/package.json +1 -1
package/dist/app/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type Mergeable<T> = {
|
|
|
5
5
|
export type Environment = typeof CLIENT | typeof SERVER;
|
|
6
6
|
export type Virtual = (environment: Environment) => void | string;
|
|
7
7
|
export type ClientEntry = "index.html" | (string & {});
|
|
8
|
-
export type ServerEntry = "@revojs/bun/runtime" | "revojs/cloudflare/runtime" | (string & {});
|
|
8
|
+
export type ServerEntry = "@revojs/bun/runtime" | "@revojs/cloudflare/runtime" | (string & {});
|
|
9
9
|
export type Module = {
|
|
10
10
|
setup: (app: App) => void | Promise<void>;
|
|
11
11
|
};
|
package/dist/html/index.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export type Template = {
|
|
|
16
16
|
attributes: Record<string, unknown>;
|
|
17
17
|
children: Array<Slot>;
|
|
18
18
|
};
|
|
19
|
+
export type ActiveViewTransition = {
|
|
20
|
+
name: string;
|
|
21
|
+
update: Promise<void>;
|
|
22
|
+
};
|
|
19
23
|
export type EventInput<T extends Events> = {
|
|
20
24
|
[K in keyof T]?: EventListener<Infer<T[K]["type"]> extends Event ? Infer<T[K]["type"]> : CustomEvent<Infer<T[K]["type"]>>>;
|
|
21
25
|
};
|
|
@@ -67,14 +71,6 @@ export interface CustomElement<TEvents extends Events, TAttributes extends Attri
|
|
|
67
71
|
export interface CustomElementConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
68
72
|
new (): CustomElement<TEvents, TAttributes>;
|
|
69
73
|
}
|
|
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
74
|
export declare class MountedEvent extends Event {
|
|
79
75
|
constructor();
|
|
80
76
|
}
|
|
@@ -97,19 +93,16 @@ export declare function useEvent<T extends keyof WindowEventMap>(scope: Scope, t
|
|
|
97
93
|
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
94
|
export declare function onMounted(scope: Scope, event: EventListener<MountedEvent>): void;
|
|
99
95
|
export declare function startViewTransition(name: string, invoke: ViewTransitionUpdateCallback): Promise<void>;
|
|
100
|
-
export declare function onViewTransition(
|
|
96
|
+
export declare function onViewTransition<T>(name: string, value: T | ((name: string) => T)): () => T | undefined;
|
|
101
97
|
export declare function isClient(): boolean;
|
|
102
98
|
export declare function isServer(): boolean;
|
|
103
99
|
export declare function preventDefault(event: Event): void;
|
|
104
100
|
export declare function stopPropagation(event: Event): void;
|
|
105
101
|
export declare function stopImmediatePropagation(event: Event): void;
|
|
102
|
+
export declare const activeViewTransition: State<ActiveViewTransition | undefined>;
|
|
106
103
|
export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
|
|
107
104
|
export declare const HOST_CONTEXT: import("..").Descriptor<HostContext>;
|
|
108
105
|
declare global {
|
|
109
|
-
interface ElementEventMap {
|
|
110
|
-
viewTransition: ViewTransitionEvent;
|
|
111
|
-
afterViewTransition: AfterViewTransitionEvent;
|
|
112
|
-
}
|
|
113
106
|
interface HTMLElementEventMap {
|
|
114
107
|
mounted: MountedEvent;
|
|
115
108
|
}
|
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,20 @@ function onMounted(scope, event) {
|
|
|
816
802
|
}
|
|
817
803
|
async function startViewTransition(name, invoke) {
|
|
818
804
|
if (isClient() && document.startViewTransition !== void 0) {
|
|
819
|
-
|
|
820
|
-
|
|
805
|
+
await activeViewTransition.value?.update;
|
|
806
|
+
const update = document.startViewTransition(invoke).finished.finally(() => activeViewTransition.value = void 0);
|
|
807
|
+
activeViewTransition.value = {
|
|
808
|
+
name,
|
|
809
|
+
update
|
|
810
|
+
};
|
|
811
|
+
return update;
|
|
821
812
|
}
|
|
822
813
|
return invoke();
|
|
823
814
|
}
|
|
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}`;
|
|
815
|
+
function onViewTransition(name, value) {
|
|
816
|
+
return () => {
|
|
817
|
+
if (activeViewTransition.value?.name === name && isClient()) return value instanceof Function ? value(name) : value;
|
|
818
|
+
};
|
|
835
819
|
}
|
|
836
820
|
function isClient() {
|
|
837
821
|
return typeof window !== "undefined";
|
|
@@ -848,6 +832,7 @@ function stopPropagation(event) {
|
|
|
848
832
|
function stopImmediatePropagation(event) {
|
|
849
833
|
event.stopImmediatePropagation();
|
|
850
834
|
}
|
|
835
|
+
const activeViewTransition = createState();
|
|
851
836
|
const components = /* @__PURE__ */ new Map();
|
|
852
837
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
853
838
|
|
|
@@ -897,13 +882,7 @@ function provideRouterContext(scope, options) {
|
|
|
897
882
|
});
|
|
898
883
|
fetch$1();
|
|
899
884
|
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
|
-
}
|
|
885
|
+
if (isClient()) useEvent(scope, window, "popstate", fetch$1);
|
|
907
886
|
return useRouter(scope);
|
|
908
887
|
}
|
|
909
888
|
function useRouter(scope, context) {
|
|
@@ -980,4 +959,4 @@ function useLocale(scope, context) {
|
|
|
980
959
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
981
960
|
|
|
982
961
|
//#endregion
|
|
983
|
-
export { $fetch, AfterNavigateEvent,
|
|
962
|
+
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
|