revojs 0.0.55 → 0.0.57
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/html/index.d.ts +1 -1
- package/dist/index.js +14 -11
- package/dist/locale/index.d.ts +0 -2
- package/dist/router/index.d.ts +4 -4
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare const toCustomElement: <TEvents extends Events, TAttributes exten
|
|
|
86
86
|
export declare const registerComponent: <TEvents extends Events, TAttributes extends Attributes>(component: ComponentConstructor<TEvents, TAttributes>) => ComponentConstructor<TEvents, TAttributes>;
|
|
87
87
|
export declare function useEvent<T extends keyof ElementEventMap>(scope: Scope, target: EventTarget | undefined | null, event: T, input: EventListener<ElementEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
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
|
-
export declare function useEvent<T extends keyof HTMLElementEventMap>(scope: Scope, target: HTMLElement | undefined | null, event: T, input: EventListener<HTMLElementEventMap[T]>, options?: AddEventListenerOptions): void;
|
|
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 const isClient: () => boolean;
|
|
91
91
|
export declare const isServer: () => boolean;
|
|
92
92
|
export declare const preventDefault: (event: Event) => void;
|
package/dist/index.js
CHANGED
|
@@ -163,8 +163,11 @@ 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);
|
|
167
|
-
if (typeof value === "object")
|
|
166
|
+
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
167
|
+
if (typeof value === "object") {
|
|
168
|
+
const tag = Object.prototype.toString.call(value);
|
|
169
|
+
if (tag === "[object Object]" || tag === "[object Array]" || tag === "[object Map]" || tag === "[object Set]" || tag === "[object WeakMap]" || tag === "[object WeakSet]") return new Proxy(value, new Handler());
|
|
170
|
+
}
|
|
168
171
|
}
|
|
169
172
|
return value;
|
|
170
173
|
}
|
|
@@ -749,15 +752,15 @@ const createRouter = (options) => {
|
|
|
749
752
|
}
|
|
750
753
|
const registerRouterContext = async (scope) => {
|
|
751
754
|
const fetch$1 = async () => {
|
|
755
|
+
const { inputs } = useRoute(scope);
|
|
752
756
|
const { request } = useRuntime(scope);
|
|
753
757
|
url.value = new URL(request?.url ?? window?.location.href);
|
|
754
758
|
const match = radix.match(url.value.pathname);
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
if (Page$1) route.value = /* @__PURE__ */ h(Page$1, null);
|
|
759
|
+
inputs.value = match.inputs;
|
|
760
|
+
route.value = await match.value?.();
|
|
758
761
|
};
|
|
759
762
|
if (isClient()) useEvent(scope, window, "popstate", () => navigator.dispatchEvent(new NavigateEvent()));
|
|
760
|
-
|
|
763
|
+
scope.setContext(ROUTE_CONTEXT, { inputs: createState() });
|
|
761
764
|
scope.setContext(ROUTER_CONTEXT, {
|
|
762
765
|
options,
|
|
763
766
|
navigator,
|
|
@@ -765,6 +768,7 @@ const createRouter = (options) => {
|
|
|
765
768
|
radix,
|
|
766
769
|
route
|
|
767
770
|
});
|
|
771
|
+
await fetch$1().then(() => useEvent(scope, navigator, "navigate", fetch$1));
|
|
768
772
|
return useRouter(scope);
|
|
769
773
|
};
|
|
770
774
|
return {
|
|
@@ -796,7 +800,10 @@ const Page = defineComponent({
|
|
|
796
800
|
name: "x-page",
|
|
797
801
|
setup: ({ scope }) => {
|
|
798
802
|
const { route } = useRouter(scope);
|
|
799
|
-
return () =>
|
|
803
|
+
return () => {
|
|
804
|
+
const Page$1 = route.value;
|
|
805
|
+
if (Page$1) return /* @__PURE__ */ h(Page$1, null);
|
|
806
|
+
};
|
|
800
807
|
}
|
|
801
808
|
});
|
|
802
809
|
|
|
@@ -837,13 +844,9 @@ const useLocale = (scope, context) => {
|
|
|
837
844
|
const $ = (key) => {
|
|
838
845
|
return () => messages.value?.[key] ?? key;
|
|
839
846
|
};
|
|
840
|
-
const prefix = (input) => {
|
|
841
|
-
return () => `/${locale.value}` + (input ?? "");
|
|
842
|
-
};
|
|
843
847
|
return {
|
|
844
848
|
locale,
|
|
845
849
|
messages,
|
|
846
|
-
prefix,
|
|
847
850
|
$
|
|
848
851
|
};
|
|
849
852
|
};
|
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;
|