revojs 0.0.74 → 0.0.76

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