@primate/core 0.8.2 → 0.8.4
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/lib/private/frontend.js +7 -2
- package/lib/private/i18n/API.d.ts +18 -5
- package/lib/private/i18n/config.client.d.ts +2 -3
- package/lib/private/i18n/config.client.js +35 -55
- package/lib/private/i18n/config.server.d.ts +2 -3
- package/lib/private/i18n/config.server.js +32 -43
- package/package.json +2 -2
package/lib/private/frontend.js
CHANGED
|
@@ -210,9 +210,14 @@ export default function frontend_module(init) {
|
|
|
210
210
|
for (const view of views) {
|
|
211
211
|
const { path } = view.debase(views_base, "/");
|
|
212
212
|
contents += `export { default as ${await normalize(path)} }
|
|
213
|
-
|
|
213
|
+
from "view:${path}";\n`;
|
|
214
214
|
}
|
|
215
|
-
return {
|
|
215
|
+
return {
|
|
216
|
+
contents,
|
|
217
|
+
resolveDir: app.root.path,
|
|
218
|
+
watchDirs: [views_base.path],
|
|
219
|
+
watchFiles: views.map(view => view.path),
|
|
220
|
+
};
|
|
216
221
|
});
|
|
217
222
|
const filter = new RegExp(`(${extensions.map(e => e.replace(".", "\\.")).join("|")})$`);
|
|
218
223
|
build.onLoad({ filter }, async (args) => {
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
+
import type Catalog from "#i18n/Catalog";
|
|
1
2
|
import type Catalogs from "#i18n/Catalogs";
|
|
3
|
+
import type { DotPaths, EntriesOf, ParamsFromEntries, PathValue } from "#i18n/types";
|
|
2
4
|
type RestoreRequest = {
|
|
3
5
|
cookies?: Record<string, string | undefined>;
|
|
4
6
|
};
|
|
7
|
+
export type Schema<C extends Catalogs> = C[keyof C] extends Catalog ? C[keyof C] : never;
|
|
8
|
+
export type Key<C extends Catalogs> = DotPaths<Schema<C>> & string;
|
|
9
|
+
type Resolved<C extends Catalogs, K extends string> = [
|
|
10
|
+
K
|
|
11
|
+
] extends [Key<C>] ? PathValue<Schema<C>, K> : never;
|
|
12
|
+
type Message<C extends Catalogs, K extends Key<C>> = Extract<Resolved<C, K>, string>;
|
|
13
|
+
type Params<C extends Catalogs, K extends Key<C>> = ParamsFromEntries<EntriesOf<Message<C, K>>>;
|
|
14
|
+
export type Args<C extends Catalogs, K extends string> = K extends Key<C> ? ([EntriesOf<Message<C, K>>] extends [never] ? [key: K] : [key: K, params: Params<C, K>]) : [`[i18n] Missing locale key "${K & string}".`];
|
|
15
|
+
export type Result<C extends Catalogs, K extends string> = K extends Key<C> ? (Resolved<C, K> extends string ? string : Resolved<C, K>) : string;
|
|
16
|
+
export type TFn<C extends Catalogs> = <K extends string>(...args: Args<C, K>) => Result<C, K>;
|
|
5
17
|
export default interface API<C extends Catalogs> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
defaultLocale: keyof C & string;
|
|
19
|
+
locales: readonly (keyof C & string)[];
|
|
20
|
+
catalogs: C;
|
|
21
|
+
currency: string;
|
|
22
|
+
locale: {
|
|
11
23
|
get(): keyof C & string;
|
|
12
24
|
set(locale: keyof C & string): void;
|
|
13
25
|
};
|
|
14
26
|
restore(request?: RestoreRequest): void;
|
|
27
|
+
with(locale: keyof C & string): TFn<C>;
|
|
15
28
|
}
|
|
16
29
|
export {};
|
|
17
30
|
//# sourceMappingURL=API.d.ts.map
|