revojs 0.0.74 → 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.
- package/dist/index.js +22 -16
- package/dist/locale/index.d.ts +2 -0
- package/dist/router/index.d.ts +6 -2
- package/package.json +1 -1
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)
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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,13 +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);
|
|
862
|
-
|
|
865
|
+
navigator.dispatchEvent(new NavigateEvent());
|
|
863
866
|
}
|
|
864
|
-
throw sendRedirect(scope, path);
|
|
867
|
+
if (isServer()) throw sendRedirect(scope, path);
|
|
865
868
|
};
|
|
866
869
|
const anchorNavigate = (event) => {
|
|
867
870
|
event.preventDefault();
|
|
@@ -871,6 +874,8 @@ function useRouter(scope, context) {
|
|
|
871
874
|
url,
|
|
872
875
|
route,
|
|
873
876
|
navigator,
|
|
877
|
+
options,
|
|
878
|
+
radix,
|
|
874
879
|
navigate,
|
|
875
880
|
anchorNavigate
|
|
876
881
|
};
|
|
@@ -907,17 +912,18 @@ function provideLocaleContext(scope, options) {
|
|
|
907
912
|
return useLocale(scope);
|
|
908
913
|
}
|
|
909
914
|
function useLocale(scope, context) {
|
|
910
|
-
const { locale, messages } = scope.getContext(context ?? LOCALE_CONTEXT);
|
|
915
|
+
const { locale, messages, options } = scope.getContext(context ?? LOCALE_CONTEXT);
|
|
911
916
|
const $ = (key) => {
|
|
912
917
|
return () => messages.value?.[key] ?? key;
|
|
913
918
|
};
|
|
914
|
-
const date = (date$1, options) => {
|
|
915
|
-
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);
|
|
916
921
|
if (date$1) return format.format(date$1);
|
|
917
922
|
};
|
|
918
923
|
return {
|
|
919
924
|
locale,
|
|
920
925
|
messages,
|
|
926
|
+
options,
|
|
921
927
|
$,
|
|
922
928
|
date
|
|
923
929
|
};
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/router/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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>;
|