revojs 0.0.30 → 0.0.31
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 -14
- package/dist/locale/index.d.ts +8 -8
- package/dist/router/index.d.ts +2 -2
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { h } from "revojs/jsx-runtime";
|
|
|
3
3
|
|
|
4
4
|
//#region src/app/index.ts
|
|
5
5
|
const getRoutes = async () => {
|
|
6
|
-
return await import("#virtual/routes").then((module) => module.
|
|
6
|
+
return await import("#virtual/routes").then((module) => module.routes);
|
|
7
7
|
};
|
|
8
8
|
const getAssets = async () => {
|
|
9
|
-
return await import("#virtual/assets").then((module) => module.
|
|
9
|
+
return await import("#virtual/assets").then((module) => module.assets);
|
|
10
10
|
};
|
|
11
11
|
const createApp = (config) => {
|
|
12
12
|
return {
|
|
@@ -632,7 +632,7 @@ const createRuntime = async () => {
|
|
|
632
632
|
const scope = new Scope();
|
|
633
633
|
try {
|
|
634
634
|
scope.setContext(RUNTIME_CONTEXT, { event });
|
|
635
|
-
return sendHtml(event, await renderToString(scope, await import("#virtual/client").then((module) => module.
|
|
635
|
+
return sendHtml(event, await renderToString(scope, await import("#virtual/client").then((module) => module.client)));
|
|
636
636
|
} finally {
|
|
637
637
|
scope.stop();
|
|
638
638
|
}
|
|
@@ -680,13 +680,11 @@ var NavigateEvent = class extends Event {
|
|
|
680
680
|
}
|
|
681
681
|
};
|
|
682
682
|
const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
|
|
683
|
-
const createRouter =
|
|
684
|
-
const routes = await import("#virtual/routes").then((module) => module.index);
|
|
683
|
+
const createRouter = (options) => {
|
|
685
684
|
const navigator = new EventTarget();
|
|
686
685
|
const radix = new Radix();
|
|
687
686
|
const route = createState();
|
|
688
687
|
const inputs = createState();
|
|
689
|
-
const options = defu(input, { routes });
|
|
690
688
|
for (const path in options.routes) {
|
|
691
689
|
const [name] = toPath(path);
|
|
692
690
|
if (name) {
|
|
@@ -751,21 +749,19 @@ const Page = defineComponent({
|
|
|
751
749
|
//#endregion
|
|
752
750
|
//#region src/locale/index.ts
|
|
753
751
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
754
|
-
const createLocale =
|
|
755
|
-
const
|
|
756
|
-
const locale = createState();
|
|
752
|
+
const createLocale = (options) => {
|
|
753
|
+
const locale = createState(options.defaultLocale);
|
|
757
754
|
const messages = createState();
|
|
758
|
-
const options = defu(input, { locales });
|
|
759
755
|
const registerLocaleContext = async (scope) => {
|
|
760
756
|
const { inputs, navigator, navigate } = useRouter(scope);
|
|
761
757
|
const fetch$1 = async () => {
|
|
762
758
|
if (options.input) {
|
|
763
|
-
|
|
764
|
-
if (
|
|
759
|
+
const input = inputs.value?.[options.input];
|
|
760
|
+
if (input && input in options.locales) locale.value = input;
|
|
761
|
+
else navigate("/" + (locale.value ?? ""));
|
|
765
762
|
}
|
|
766
|
-
locale.value ??= options.defaultLocale;
|
|
767
763
|
if (locale.value) {
|
|
768
|
-
const target = locales[locale.value];
|
|
764
|
+
const target = options.locales[locale.value];
|
|
769
765
|
messages.value = typeof target === "function" ? await target() : target;
|
|
770
766
|
}
|
|
771
767
|
};
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -6,23 +6,23 @@ export type LocaleOptions<T extends Locales = Locales> = {
|
|
|
6
6
|
input?: string;
|
|
7
7
|
};
|
|
8
8
|
export type LocaleContext<T extends LocaleOptions = LocaleOptions> = {
|
|
9
|
-
locale: State<string>;
|
|
10
|
-
messages: State<Record<string, string
|
|
9
|
+
locale: State<string | undefined>;
|
|
10
|
+
messages: State<Record<string, string> | undefined>;
|
|
11
11
|
options: T;
|
|
12
12
|
};
|
|
13
13
|
export declare const LOCALE_CONTEXT: Descriptor<LocaleContext<LocaleOptions<Locales>>>;
|
|
14
|
-
export declare const createLocale: <T extends LocaleOptions>(
|
|
14
|
+
export declare const createLocale: <T extends LocaleOptions>(options: T) => {
|
|
15
15
|
LOCALE_CONTEXT: Descriptor<LocaleContext<T>>;
|
|
16
16
|
registerLocaleContext: (scope: Scope) => Promise<{
|
|
17
|
-
locale: State<string>;
|
|
18
|
-
messages: State<Record<string, string
|
|
17
|
+
locale: State<string | undefined>;
|
|
18
|
+
messages: State<Record<string, string> | undefined>;
|
|
19
19
|
prefix: (input?: string) => () => string;
|
|
20
20
|
$: (key: never) => () => string | number | symbol;
|
|
21
21
|
}>;
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
export declare const useLocale: <T extends LocaleContext>(scope: Scope, context?: Descriptor<T>) => {
|
|
24
|
-
locale: State<string>;
|
|
25
|
-
messages: State<Record<string, string
|
|
24
|
+
locale: State<string | undefined>;
|
|
25
|
+
messages: State<Record<string, string> | undefined>;
|
|
26
26
|
prefix: (input?: string) => () => string;
|
|
27
27
|
$: (key: keyof T["options"]["locales"][keyof T["options"]["locales"]]) => () => string | number | symbol;
|
|
28
28
|
};
|
package/dist/router/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class NavigateEvent extends Event {
|
|
|
16
16
|
constructor();
|
|
17
17
|
}
|
|
18
18
|
export declare const ROUTER_CONTEXT: Descriptor<RouterContext<RouterOptions<Routes>>>;
|
|
19
|
-
export declare const createRouter: <T extends RouterOptions>(
|
|
19
|
+
export declare const createRouter: <T extends RouterOptions>(options: T) => {
|
|
20
20
|
ROUTER_CONTEXT: Descriptor<RouterContext<T>>;
|
|
21
21
|
registerRouterContext: (scope: Scope) => Promise<{
|
|
22
22
|
route: State<unknown>;
|
|
@@ -25,7 +25,7 @@ export declare const createRouter: <T extends RouterOptions>(input?: Partial<T>)
|
|
|
25
25
|
navigate: (path: string) => void;
|
|
26
26
|
anchorNavigate: (event: Event) => void;
|
|
27
27
|
}>;
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
export declare const useRouter: <T extends RouterContext>(scope: Scope, context?: Descriptor<T>) => {
|
|
30
30
|
route: State<unknown>;
|
|
31
31
|
inputs: State<Record<string, string> | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revojs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "coverbase/revojs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,12 +16,15 @@
|
|
|
16
16
|
"./jsx-runtime": {
|
|
17
17
|
"types": "./dist/jsx/index.d.ts",
|
|
18
18
|
"import": "./dist/jsx/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./types": {
|
|
21
|
+
"types": "./src/types/index.d.ts"
|
|
19
22
|
}
|
|
20
23
|
},
|
|
21
24
|
"types": "./dist/index.d.ts",
|
|
22
25
|
"module": "./dist/index.js",
|
|
23
26
|
"main": "./dist/index.js",
|
|
24
|
-
"files": ["dist"],
|
|
27
|
+
"files": ["dist", "src/virtual"],
|
|
25
28
|
"scripts": {
|
|
26
29
|
"build": "rolldown -c rolldown.config.ts && tsc",
|
|
27
30
|
"watch": "rolldown -w -c rolldown.config.ts && tsc --watch"
|