revojs 0.0.55 → 0.0.56
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 +10 -10
- package/dist/locale/index.d.ts +0 -2
- package/dist/router/index.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -163,7 +163,7 @@ var Handler = class Handler {
|
|
|
163
163
|
}
|
|
164
164
|
const value = Reflect.get(target, key);
|
|
165
165
|
if (value) {
|
|
166
|
-
if (typeof value === "function") return value.bind(target);
|
|
166
|
+
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
167
167
|
if (typeof value === "object") return new Proxy(value, new Handler());
|
|
168
168
|
}
|
|
169
169
|
return value;
|
|
@@ -749,15 +749,15 @@ const createRouter = (options) => {
|
|
|
749
749
|
}
|
|
750
750
|
const registerRouterContext = async (scope) => {
|
|
751
751
|
const fetch$1 = async () => {
|
|
752
|
+
const { inputs } = useRoute(scope);
|
|
752
753
|
const { request } = useRuntime(scope);
|
|
753
754
|
url.value = new URL(request?.url ?? window?.location.href);
|
|
754
755
|
const match = radix.match(url.value.pathname);
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
if (Page$1) route.value = /* @__PURE__ */ h(Page$1, null);
|
|
756
|
+
inputs.value = match.inputs;
|
|
757
|
+
route.value = await match.value?.();
|
|
758
758
|
};
|
|
759
759
|
if (isClient()) useEvent(scope, window, "popstate", () => navigator.dispatchEvent(new NavigateEvent()));
|
|
760
|
-
|
|
760
|
+
scope.setContext(ROUTE_CONTEXT, { inputs: createState() });
|
|
761
761
|
scope.setContext(ROUTER_CONTEXT, {
|
|
762
762
|
options,
|
|
763
763
|
navigator,
|
|
@@ -765,6 +765,7 @@ const createRouter = (options) => {
|
|
|
765
765
|
radix,
|
|
766
766
|
route
|
|
767
767
|
});
|
|
768
|
+
await fetch$1().then(() => useEvent(scope, navigator, "navigate", fetch$1));
|
|
768
769
|
return useRouter(scope);
|
|
769
770
|
};
|
|
770
771
|
return {
|
|
@@ -796,7 +797,10 @@ const Page = defineComponent({
|
|
|
796
797
|
name: "x-page",
|
|
797
798
|
setup: ({ scope }) => {
|
|
798
799
|
const { route } = useRouter(scope);
|
|
799
|
-
return () =>
|
|
800
|
+
return () => {
|
|
801
|
+
const Page$1 = route.value;
|
|
802
|
+
if (Page$1) return /* @__PURE__ */ h(Page$1, null);
|
|
803
|
+
};
|
|
800
804
|
}
|
|
801
805
|
});
|
|
802
806
|
|
|
@@ -837,13 +841,9 @@ const useLocale = (scope, context) => {
|
|
|
837
841
|
const $ = (key) => {
|
|
838
842
|
return () => messages.value?.[key] ?? key;
|
|
839
843
|
};
|
|
840
|
-
const prefix = (input) => {
|
|
841
|
-
return () => `/${locale.value}` + (input ?? "");
|
|
842
|
-
};
|
|
843
844
|
return {
|
|
844
845
|
locale,
|
|
845
846
|
messages,
|
|
846
|
-
prefix,
|
|
847
847
|
$
|
|
848
848
|
};
|
|
849
849
|
};
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -16,13 +16,11 @@ export declare const createLocale: <T extends LocaleOptions>(options: T) => {
|
|
|
16
16
|
registerLocaleContext: (scope: Scope) => Promise<{
|
|
17
17
|
locale: State<string | undefined>;
|
|
18
18
|
messages: State<Record<string, string> | undefined>;
|
|
19
|
-
prefix: (input?: string) => () => string;
|
|
20
19
|
$: (key: never) => () => string | number | symbol;
|
|
21
20
|
}>;
|
|
22
21
|
};
|
|
23
22
|
export declare const useLocale: <T extends LocaleContext>(scope: Scope, context?: Descriptor<T>) => {
|
|
24
23
|
locale: State<string | undefined>;
|
|
25
24
|
messages: State<Record<string, string> | undefined>;
|
|
26
|
-
prefix: (input?: string) => () => string;
|
|
27
25
|
$: (key: keyof T["options"]["locales"][keyof T["options"]["locales"]]) => () => string | number | symbol;
|
|
28
26
|
};
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Attributes, type ComponentConstructor, type Events
|
|
1
|
+
import { type Attributes, type ComponentConstructor, type Events } from "../html";
|
|
2
2
|
import { Radix } from "../radix";
|
|
3
3
|
import { type Descriptor, Scope, type State } from "../signals";
|
|
4
4
|
export type Routes = Record<string, () => Promise<ComponentConstructor<Events, Attributes>>>;
|
|
@@ -10,7 +10,7 @@ export type RouterContext<T extends RouterOptions = RouterOptions> = {
|
|
|
10
10
|
navigator: EventTarget;
|
|
11
11
|
url: State<URL | undefined>;
|
|
12
12
|
radix: Radix<() => Promise<ComponentConstructor<Events, Attributes>>>;
|
|
13
|
-
route: State<
|
|
13
|
+
route: State<ComponentConstructor<Events, Attributes> | undefined>;
|
|
14
14
|
};
|
|
15
15
|
export declare class NavigateEvent extends Event {
|
|
16
16
|
constructor();
|
|
@@ -20,7 +20,7 @@ export declare const createRouter: <T extends RouterOptions>(options: T) => {
|
|
|
20
20
|
ROUTER_CONTEXT: Descriptor<RouterContext<T>>;
|
|
21
21
|
registerRouterContext: (scope: Scope) => Promise<{
|
|
22
22
|
url: State<URL | undefined>;
|
|
23
|
-
route: State<
|
|
23
|
+
route: State<ComponentConstructor<Events, Attributes> | undefined>;
|
|
24
24
|
navigator: EventTarget;
|
|
25
25
|
navigate: (path: string) => void;
|
|
26
26
|
anchorNavigate: (event: Event) => void;
|
|
@@ -28,7 +28,7 @@ export declare const createRouter: <T extends RouterOptions>(options: T) => {
|
|
|
28
28
|
};
|
|
29
29
|
export declare const useRouter: <T extends RouterContext>(scope: Scope, context?: Descriptor<T>) => {
|
|
30
30
|
url: State<URL | undefined>;
|
|
31
|
-
route: State<
|
|
31
|
+
route: State<ComponentConstructor<Events, Attributes> | undefined>;
|
|
32
32
|
navigator: EventTarget;
|
|
33
33
|
navigate: (path: string) => void;
|
|
34
34
|
anchorNavigate: (event: Event) => void;
|