revojs 0.0.82 → 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.
@@ -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
  };
@@ -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
  };
@@ -89,13 +93,13 @@ export declare function useEvent<T extends keyof WindowEventMap>(scope: Scope, t
89
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;
90
94
  export declare function onMounted(scope: Scope, event: EventListener<MountedEvent>): void;
91
95
  export declare function startViewTransition(name: string, invoke: ViewTransitionUpdateCallback): Promise<void>;
92
- export declare function onViewTransition<T>(name: string, value: T): () => T | undefined;
96
+ export declare function onViewTransition<T>(name: string, value: T | ((name: string) => T)): () => T | undefined;
93
97
  export declare function isClient(): boolean;
94
98
  export declare function isServer(): boolean;
95
99
  export declare function preventDefault(event: Event): void;
96
100
  export declare function stopPropagation(event: Event): void;
97
101
  export declare function stopImmediatePropagation(event: Event): void;
98
- export declare const activeViewTransition: State<string | undefined>;
102
+ export declare const activeViewTransition: State<ActiveViewTransition | undefined>;
99
103
  export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
100
104
  export declare const HOST_CONTEXT: import("..").Descriptor<HostContext>;
101
105
  declare global {
package/dist/index.js CHANGED
@@ -802,14 +802,19 @@ function onMounted(scope, event) {
802
802
  }
803
803
  async function startViewTransition(name, invoke) {
804
804
  if (isClient() && document.startViewTransition !== void 0) {
805
- activeViewTransition.value = name;
806
- return document.startViewTransition(invoke).finished.finally(() => activeViewTransition.value = void 0);
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;
807
812
  }
808
813
  return invoke();
809
814
  }
810
815
  function onViewTransition(name, value) {
811
816
  return () => {
812
- if (activeViewTransition.value === name && isClient()) return value;
817
+ if (activeViewTransition.value?.name === name && isClient()) return value instanceof Function ? value(name) : value;
813
818
  };
814
819
  }
815
820
  function isClient() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",