revojs 0.0.73 → 0.0.75

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.
@@ -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): Promise<void>;
91
+ export declare function startViewTransition(invoke: ViewTransitionUpdateCallback): void | 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/index.js CHANGED
@@ -589,16 +589,19 @@ function hydrate(scope, parentNode, slot, index, previous) {
589
589
  let input = slot;
590
590
  while (typeof input === "function") input = input();
591
591
  hydration = hydrate(scope$1, parentNode, input, index, previous$1);
592
- if (previous$1 && hydration !== previous$1) if (Array.isArray(hydration)) if (Array.isArray(previous$1)) {
593
- const range = toRange(previous$1);
594
- range.deleteContents();
595
- for (const childNode of toArray(hydration)) range.insertNode(childNode);
596
- } else parentNode.replaceChild(toFragment(hydration), previous$1);
597
- else if (Array.isArray(previous$1)) {
598
- const range = toRange(previous$1);
599
- range.deleteContents();
600
- range.insertNode(hydration);
601
- } else parentNode.replaceChild(hydration, previous$1);
592
+ if (previous$1 && hydration !== previous$1) {
593
+ if (Array.isArray(hydration)) {
594
+ if (Array.isArray(previous$1)) {
595
+ const range = toRange(previous$1);
596
+ range.deleteContents();
597
+ for (const childNode of toArray(hydration)) range.insertNode(childNode);
598
+ } else if (parentNode.contains(previous$1)) parentNode.replaceChild(toFragment(hydration), previous$1);
599
+ } else if (Array.isArray(previous$1)) {
600
+ const range = toRange(previous$1);
601
+ range.deleteContents();
602
+ range.insertNode(hydration);
603
+ } else if (parentNode.contains(previous$1)) parentNode.replaceChild(hydration, previous$1);
604
+ }
602
605
  previous$1 = hydration;
603
606
  });
604
607
  }
@@ -855,12 +858,13 @@ function provideRouterContext(scope, options) {
855
858
  return useRouter(scope);
856
859
  }
857
860
  function useRouter(scope, context) {
858
- const { url, route, navigator } = scope.getContext(context ?? ROUTER_CONTEXT);
861
+ const { url, route, navigator, options, radix } = scope.getContext(context ?? ROUTER_CONTEXT);
859
862
  const navigate = (path) => {
860
863
  if (isClient()) {
861
864
  if (window.location.pathname != path) window.history.pushState(window.history.state, "", path);
865
+ navigator.dispatchEvent(new NavigateEvent());
862
866
  }
863
- navigator.dispatchEvent(new NavigateEvent());
867
+ if (isServer()) throw sendRedirect(scope, path);
864
868
  };
865
869
  const anchorNavigate = (event) => {
866
870
  event.preventDefault();
@@ -870,6 +874,8 @@ function useRouter(scope, context) {
870
874
  url,
871
875
  route,
872
876
  navigator,
877
+ options,
878
+ radix,
873
879
  navigate,
874
880
  anchorNavigate
875
881
  };
@@ -906,17 +912,18 @@ function provideLocaleContext(scope, options) {
906
912
  return useLocale(scope);
907
913
  }
908
914
  function useLocale(scope, context) {
909
- const { locale, messages } = scope.getContext(context ?? LOCALE_CONTEXT);
915
+ const { locale, messages, options } = scope.getContext(context ?? LOCALE_CONTEXT);
910
916
  const $ = (key) => {
911
917
  return () => messages.value?.[key] ?? key;
912
918
  };
913
- const date = (date$1, options) => {
914
- const format = new Intl.DateTimeFormat(locale.value, options);
919
+ const date = (date$1, options$1) => {
920
+ const format = new Intl.DateTimeFormat(locale.value, options$1);
915
921
  if (date$1) return format.format(date$1);
916
922
  };
917
923
  return {
918
924
  locale,
919
925
  messages,
926
+ options,
920
927
  $,
921
928
  date
922
929
  };
@@ -12,12 +12,14 @@ export type LocaleContext = {
12
12
  export declare function provideLocaleContext(scope: Scope, options: LocaleOptions): {
13
13
  locale: State<string | undefined>;
14
14
  messages: State<Record<string, string> | undefined>;
15
+ options: LocaleOptions;
15
16
  $: (key: string) => () => string | number | symbol;
16
17
  date: (date?: Date, options?: Intl.DateTimeFormatOptions) => string | undefined;
17
18
  };
18
19
  export declare function useLocale<T extends LocaleContext>(scope: Scope, context?: Descriptor<T>): {
19
20
  locale: State<string | undefined>;
20
21
  messages: State<Record<string, string> | undefined>;
22
+ options: LocaleOptions;
21
23
  $: (key: keyof T["options"]["locales"][keyof T["options"]["locales"]]) => () => string | number | symbol;
22
24
  date: (date?: Date, options?: Intl.DateTimeFormatOptions) => string | undefined;
23
25
  };
@@ -21,6 +21,8 @@ export declare function provideRouterContext(scope: Scope, options: RouterOption
21
21
  url: State<URL | undefined>;
22
22
  route: State<unknown>;
23
23
  navigator: EventTarget;
24
+ options: RouterOptions;
25
+ radix: Radix<unknown>;
24
26
  navigate: (path: string) => void;
25
27
  anchorNavigate: (event: Event) => void;
26
28
  };
@@ -28,6 +30,8 @@ export declare function useRouter<T extends RouterContext>(scope: Scope, context
28
30
  url: State<URL | undefined>;
29
31
  route: State<unknown>;
30
32
  navigator: EventTarget;
33
+ options: RouterOptions;
34
+ radix: Radix<unknown>;
31
35
  navigate: (path: string) => void;
32
36
  anchorNavigate: (event: Event) => void;
33
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",