astro-intlayer 9.5.4 → 9.5.5
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/README.md +2 -1
- package/dist/cjs/client/format/index.cjs +57 -0
- package/dist/cjs/client/index.cjs +81 -0
- package/dist/cjs/format/index.cjs +20 -0
- package/dist/cjs/format/useCompact.cjs +18 -0
- package/dist/cjs/format/useCompact.cjs.map +1 -0
- package/dist/cjs/format/useCurrency.cjs +18 -0
- package/dist/cjs/format/useCurrency.cjs.map +1 -0
- package/dist/cjs/format/useDate.cjs +27 -0
- package/dist/cjs/format/useDate.cjs.map +1 -0
- package/dist/cjs/format/useIntl.cjs +24 -0
- package/dist/cjs/format/useIntl.cjs.map +1 -0
- package/dist/cjs/format/useList.cjs +18 -0
- package/dist/cjs/format/useList.cjs.map +1 -0
- package/dist/cjs/format/useNumber.cjs +21 -0
- package/dist/cjs/format/useNumber.cjs.map +1 -0
- package/dist/cjs/format/usePercentage.cjs +18 -0
- package/dist/cjs/format/usePercentage.cjs.map +1 -0
- package/dist/cjs/format/useRelativeTime.cjs +18 -0
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -0
- package/dist/cjs/format/useUnit.cjs +18 -0
- package/dist/cjs/format/useUnit.cjs.map +1 -0
- package/dist/cjs/html/index.cjs +33 -0
- package/dist/cjs/index.cjs +33 -35
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/integration.cjs +67 -0
- package/dist/cjs/integration.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +45 -0
- package/dist/cjs/middleware.cjs +43 -0
- package/dist/cjs/middleware.cjs.map +1 -0
- package/dist/cjs/requestStorage.cjs +24 -0
- package/dist/cjs/requestStorage.cjs.map +1 -0
- package/dist/cjs/useDictionary.cjs +38 -0
- package/dist/cjs/useDictionary.cjs.map +1 -0
- package/dist/cjs/useIntlayer.cjs +38 -0
- package/dist/cjs/useIntlayer.cjs.map +1 -0
- package/dist/cjs/useLocale.cjs +41 -0
- package/dist/cjs/useLocale.cjs.map +1 -0
- package/dist/cjs/withInertOnChange.cjs +17 -0
- package/dist/cjs/withInertOnChange.cjs.map +1 -0
- package/dist/esm/client/format/index.mjs +3 -0
- package/dist/esm/client/index.mjs +3 -0
- package/dist/esm/format/index.mjs +11 -0
- package/dist/esm/format/useCompact.mjs +17 -0
- package/dist/esm/format/useCompact.mjs.map +1 -0
- package/dist/esm/format/useCurrency.mjs +17 -0
- package/dist/esm/format/useCurrency.mjs.map +1 -0
- package/dist/esm/format/useDate.mjs +26 -0
- package/dist/esm/format/useDate.mjs.map +1 -0
- package/dist/esm/format/useIntl.mjs +23 -0
- package/dist/esm/format/useIntl.mjs.map +1 -0
- package/dist/esm/format/useList.mjs +17 -0
- package/dist/esm/format/useList.mjs.map +1 -0
- package/dist/esm/format/useNumber.mjs +20 -0
- package/dist/esm/format/useNumber.mjs.map +1 -0
- package/dist/esm/format/usePercentage.mjs +17 -0
- package/dist/esm/format/usePercentage.mjs.map +1 -0
- package/dist/esm/format/useRelativeTime.mjs +17 -0
- package/dist/esm/format/useRelativeTime.mjs.map +1 -0
- package/dist/esm/format/useUnit.mjs +17 -0
- package/dist/esm/format/useUnit.mjs.map +1 -0
- package/dist/esm/html/index.mjs +3 -0
- package/dist/esm/index.mjs +30 -36
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/integration.mjs +65 -0
- package/dist/esm/integration.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +3 -0
- package/dist/esm/middleware.mjs +42 -0
- package/dist/esm/middleware.mjs.map +1 -0
- package/dist/esm/requestStorage.mjs +21 -0
- package/dist/esm/requestStorage.mjs.map +1 -0
- package/dist/esm/useDictionary.mjs +37 -0
- package/dist/esm/useDictionary.mjs.map +1 -0
- package/dist/esm/useIntlayer.mjs +37 -0
- package/dist/esm/useIntlayer.mjs.map +1 -0
- package/dist/esm/useLocale.mjs +40 -0
- package/dist/esm/useLocale.mjs.map +1 -0
- package/dist/esm/withInertOnChange.mjs +16 -0
- package/dist/esm/withInertOnChange.mjs.map +1 -0
- package/dist/types/client/format/index.d.ts +2 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/format/index.d.ts +10 -0
- package/dist/types/format/useCompact.d.ts +5 -0
- package/dist/types/format/useCompact.d.ts.map +1 -0
- package/dist/types/format/useCurrency.d.ts +5 -0
- package/dist/types/format/useCurrency.d.ts.map +1 -0
- package/dist/types/format/useDate.d.ts +8 -0
- package/dist/types/format/useDate.d.ts.map +1 -0
- package/dist/types/format/useIntl.d.ts +15 -0
- package/dist/types/format/useIntl.d.ts.map +1 -0
- package/dist/types/format/useList.d.ts +5 -0
- package/dist/types/format/useList.d.ts.map +1 -0
- package/dist/types/format/useNumber.d.ts +8 -0
- package/dist/types/format/useNumber.d.ts.map +1 -0
- package/dist/types/format/usePercentage.d.ts +5 -0
- package/dist/types/format/usePercentage.d.ts.map +1 -0
- package/dist/types/format/useRelativeTime.d.ts +5 -0
- package/dist/types/format/useRelativeTime.d.ts.map +1 -0
- package/dist/types/format/useUnit.d.ts +5 -0
- package/dist/types/format/useUnit.d.ts.map +1 -0
- package/dist/types/html/index.d.ts +2 -0
- package/dist/types/index.d.ts +13 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integration.d.ts +37 -0
- package/dist/types/integration.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +2 -0
- package/dist/types/middleware.d.ts +46 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/requestStorage.d.ts +22 -0
- package/dist/types/requestStorage.d.ts.map +1 -0
- package/dist/types/useDictionary.d.ts +29 -0
- package/dist/types/useDictionary.d.ts.map +1 -0
- package/dist/types/useIntlayer.d.ts +28 -0
- package/dist/types/useIntlayer.d.ts.map +1 -0
- package/dist/types/useLocale.d.ts +29 -0
- package/dist/types/useLocale.d.ts.map +1 -0
- package/dist/types/withInertOnChange.d.ts +12 -0
- package/dist/types/withInertOnChange.d.ts.map +1 -0
- package/package.json +88 -6
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { IntlayerLocals } from "./middleware.js";
|
|
2
|
+
import { getIntlayerLocals } from "./requestStorage.js";
|
|
3
|
+
import { useDictionary } from "./useDictionary.js";
|
|
4
|
+
import { useIntlayer } from "./useIntlayer.js";
|
|
5
|
+
import { UseLocaleProps, UseLocaleResult, useLocale } from "./useLocale.js";
|
|
1
6
|
import { AstroIntegration } from "astro";
|
|
2
7
|
//#region src/index.d.ts
|
|
3
8
|
/**
|
|
@@ -7,12 +12,14 @@ import { AstroIntegration } from "astro";
|
|
|
7
12
|
* 1. Preparing Intlayer resources (dictionaries) at config setup.
|
|
8
13
|
* 2. Injecting Vite plugins for aliases, locale-based routing (middleware), and build optimizations (prune).
|
|
9
14
|
* 3. Configuring Vite aliases for dictionary access.
|
|
10
|
-
* 4.
|
|
15
|
+
* 4. Registering the `astro-intlayer/middleware`, which resolves the request
|
|
16
|
+
* locale into `Astro.locals.intlayer` for the `useLocale` / `useIntlayer` /
|
|
17
|
+
* `useDictionary` hooks of this package.
|
|
18
|
+
* 5. Emitting the prerendered pages at their rewritten (localized) URLs.
|
|
11
19
|
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* content edit twice.
|
|
20
|
+
* The implementation is loaded lazily: this entry is also the one pages import
|
|
21
|
+
* their hooks from, and it must not drag the Node-only tooling into their
|
|
22
|
+
* server bundle.
|
|
16
23
|
*
|
|
17
24
|
* @returns An Astro integration object.
|
|
18
25
|
*
|
|
@@ -29,5 +36,5 @@ import { AstroIntegration } from "astro";
|
|
|
29
36
|
*/
|
|
30
37
|
export declare const intlayer: () => AstroIntegration;
|
|
31
38
|
//#endregion
|
|
32
|
-
export { intlayer as default };
|
|
39
|
+
export { type IntlayerLocals, type UseLocaleProps, type UseLocaleResult, intlayer as default, getIntlayerLocals, useDictionary, useIntlayer, useLocale };
|
|
33
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqDa,gBAAe"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AstroIntegration } from "astro";
|
|
2
|
+
//#region src/integration.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Node-only half of the integration, loaded lazily by the `astro-intlayer`
|
|
5
|
+
* entry when a hook runs.
|
|
6
|
+
*
|
|
7
|
+
* Pages import their hooks from that same entry, and Astro bundles the whole
|
|
8
|
+
* package into the server build (`ssr.noExternal`), so the config loader,
|
|
9
|
+
* `@intlayer/engine` and `vite-intlayer` must stay behind a dynamic import:
|
|
10
|
+
* a static one would put them in the module graph of every page.
|
|
11
|
+
*/
|
|
12
|
+
type ConfigSetupOptions = Parameters<NonNullable<AstroIntegration['hooks']['astro:config:setup']>>[0];
|
|
13
|
+
type BuildDoneOptions = Parameters<NonNullable<AstroIntegration['hooks']['astro:build:done']>>[0];
|
|
14
|
+
/**
|
|
15
|
+
* `astro:config:setup`:
|
|
16
|
+
* 1. Prepares the Intlayer resources (dictionaries).
|
|
17
|
+
* 2. Injects the Vite plugins for aliases, locale-based routing and build
|
|
18
|
+
* optimizations (prune).
|
|
19
|
+
* 3. Configures the Vite aliases for dictionary access.
|
|
20
|
+
* 4. Registers the `astro-intlayer/middleware`, which resolves the request
|
|
21
|
+
* locale into `Astro.locals.intlayer` for the hooks.
|
|
22
|
+
*
|
|
23
|
+
* The dev-time content watcher is not started here: the bundled
|
|
24
|
+
* `vite-intlayer` plugin already starts one from `configureServer`, and
|
|
25
|
+
* `watch()` subscribes anew on every call, so doing both would rebuild each
|
|
26
|
+
* content edit twice.
|
|
27
|
+
*/
|
|
28
|
+
export declare const configSetup: ({ updateConfig, addMiddleware }: ConfigSetupOptions) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* `astro:build:done`: Astro renders each page from its canonical file-system
|
|
31
|
+
* route, so a static build has no file for the localized paths declared in
|
|
32
|
+
* `routing.rewrite`. Mirror them here, otherwise the URLs produced by
|
|
33
|
+
* `getLocalizedUrl` (links, hreflang, sitemap) 404 once deployed.
|
|
34
|
+
*/
|
|
35
|
+
export declare const buildDone: ({ dir, logger }: BuildDoneOptions) => Promise<void>;
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.ts","names":[],"sources":["../../src/integration.ts"],"mappings":";;;;;;;;;;;KAqCK,qBAAqB,WACxB,YAAY;KAGT,mBAAmB,WACtB,YAAY;;;;;;;;;;;;;;;qBAiBD,gBAAW,cAAA,iBAGrB,uBAAqB;;;;;;;qBAkDX,cAAS,KAAA,UAGnB,qBAAmB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { IntlayerMarkdownPluginOptions, IntlayerMarkdownProvider, MarkdownCompilerOptions, MarkdownProviderOptions, ParsedMarkdown, RenderMarkdownFunction, RenderMarkdownProps, compileMarkdown, installIntlayerMarkdown, installIntlayerMarkdownDynamic, parseMarkdown, renderMarkdown, useMarkdown, useMarkdownRenderer } from "vanilla-intlayer/markdown";
|
|
2
|
+
export { type IntlayerMarkdownPluginOptions, type IntlayerMarkdownProvider, type MarkdownCompilerOptions, type MarkdownProviderOptions, type ParsedMarkdown, type RenderMarkdownFunction, type RenderMarkdownProps, compileMarkdown, installIntlayerMarkdown, installIntlayerMarkdownDynamic, parseMarkdown, renderMarkdown, useMarkdown, useMarkdownRenderer };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { MiddlewareHandler } from "astro";
|
|
3
|
+
//#region src/middleware.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Intlayer state stored in `Astro.locals.intlayer` by the {@link onRequest} middleware.
|
|
6
|
+
*/
|
|
7
|
+
export type IntlayerLocals = {
|
|
8
|
+
/** Locale resolved for the current request. */
|
|
9
|
+
locale: DeclaredLocales;
|
|
10
|
+
/** Locale configured as fallback in `intlayer.config.ts`. */
|
|
11
|
+
defaultLocale: DeclaredLocales;
|
|
12
|
+
/** Every locale declared in `intlayer.config.ts`. */
|
|
13
|
+
availableLocales: DeclaredLocales[];
|
|
14
|
+
};
|
|
15
|
+
declare global {
|
|
16
|
+
namespace App {
|
|
17
|
+
interface Locals {
|
|
18
|
+
intlayer: IntlayerLocals;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Astro middleware resolving the request locale into `Astro.locals.intlayer`.
|
|
24
|
+
*
|
|
25
|
+
* Priority: the URL (path prefix or `?locale=` search param, in every routing
|
|
26
|
+
* mode but `no-prefix`), then the locale persisted by the client (cookie or
|
|
27
|
+
* custom header), then `Accept-Language` negotiation.
|
|
28
|
+
*
|
|
29
|
+
* The `intlayer()` integration registers it automatically, before the user
|
|
30
|
+
* middleware, so `Astro.locals.intlayer` is available in every page, endpoint
|
|
31
|
+
* and middleware. The rest of the request renders inside an
|
|
32
|
+
* `AsyncLocalStorage` scope bound to those locals, which is how the hooks of
|
|
33
|
+
* `astro-intlayer/server` read the locale with no argument.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // src/middleware.ts — only needed when composing it by hand
|
|
38
|
+
* import { onRequest as intlayer } from 'astro-intlayer/middleware';
|
|
39
|
+
* import { sequence } from 'astro:middleware';
|
|
40
|
+
*
|
|
41
|
+
* export const onRequest = sequence(intlayer, myMiddleware);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const onRequest: MiddlewareHandler;
|
|
45
|
+
//#endregion
|
|
46
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":";;;;;;YASY;;EAEV,QAAQ;;EAER,eAAe;;EAEf,kBAAkB;;QAGZ;YACI;cACE;MACR,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;qBA2BH,WAAW"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IntlayerLocals } from "./middleware.js";
|
|
2
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
//#region src/requestStorage.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* `Astro.locals` of the request being rendered, made available to every
|
|
7
|
+
* function running inside the middleware scope — page and component
|
|
8
|
+
* frontmatter, endpoints, nested middleware — without passing `Astro` around.
|
|
9
|
+
*/
|
|
10
|
+
export declare const requestStorage: AsyncLocalStorage<{
|
|
11
|
+
intlayer?: IntlayerLocals;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the Intlayer locals of the request being rendered, if any.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getIntlayerLocals: () => IntlayerLocals | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the locale of the request being rendered, if any.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getRequestLocale: () => DeclaredLocales | undefined;
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=requestStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":";;;;;;;;;qBASa,gBAAc;EACd,WAAA;;;;;qBAMA,yBAAwB;;;;qBAMxB,wBAAuB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DeepTransformContent, WithOnChange } from "vanilla-intlayer";
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
|
|
4
|
+
//#region src/useDictionary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
7
|
+
* its content for the locale of the request being rendered, read from
|
|
8
|
+
* `Astro.locals.intlayer`.
|
|
9
|
+
*
|
|
10
|
+
* The second argument is either a locale or a selector object
|
|
11
|
+
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
12
|
+
* over the request locale.
|
|
13
|
+
*
|
|
14
|
+
* Same signature and content shape as the client-side hook this entry resolves
|
|
15
|
+
* to in the browser (`vanilla-intlayer`).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```astro
|
|
19
|
+
* ---
|
|
20
|
+
* import { useDictionary } from 'astro-intlayer';
|
|
21
|
+
* import homeContent from '../content/home.content';
|
|
22
|
+
*
|
|
23
|
+
* const { title } = useDictionary(homeContent);
|
|
24
|
+
* ---
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => WithOnChange<DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBA0Ca,sBACL,UAAU,aAAa,gCACvB,UACF,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,MAClB,aACD,qBACE,kCAAkC,GAAG,IACrC,sBAAsB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DeepTransformContent, WithOnChange } from "vanilla-intlayer";
|
|
2
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
//#region src/useIntlayer.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Picks one dictionary by its key and returns its content for the locale of
|
|
6
|
+
* the request being rendered, read from `Astro.locals.intlayer`.
|
|
7
|
+
*
|
|
8
|
+
* The second argument is either a locale or a selector object
|
|
9
|
+
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
10
|
+
* over the request locale.
|
|
11
|
+
*
|
|
12
|
+
* Same signature and content shape as the client-side hook this entry resolves
|
|
13
|
+
* to in the browser (`vanilla-intlayer`), so a call moves between the
|
|
14
|
+
* frontmatter and a `<script>` unchanged.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```astro
|
|
18
|
+
* ---
|
|
19
|
+
* import { useIntlayer } from 'astro-intlayer';
|
|
20
|
+
*
|
|
21
|
+
* const { title, description } = useIntlayer('home');
|
|
22
|
+
* ---
|
|
23
|
+
* <h1>{title}</h1>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => WithOnChange<DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../src/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;qBAuCa,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,MAClB,aACD,qBAAqB,yBAAyB,GAAG,IAAI,sBAAsB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UseLocaleProps, UseLocaleProps as UseLocaleProps$1, UseLocaleResult as UseLocaleResult$1 } from "vanilla-intlayer";
|
|
2
|
+
//#region src/useLocale.d.ts
|
|
3
|
+
export type UseLocaleResult = UseLocaleResult$1;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the locale of the request being rendered, read from
|
|
6
|
+
* `Astro.locals.intlayer`, with the configured default and available locales.
|
|
7
|
+
*
|
|
8
|
+
* Falls back to the default locale outside of a request, i.e. when the
|
|
9
|
+
* `astro-intlayer/middleware` did not run.
|
|
10
|
+
*
|
|
11
|
+
* Same shape as the client-side hook this entry resolves to in the browser
|
|
12
|
+
* (`vanilla-intlayer`). A request has no locale to switch, so `setLocale` and
|
|
13
|
+
* `subscribe` are inert here: switch the locale from a `<script>`, where the
|
|
14
|
+
* same import gives the client implementation.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```astro
|
|
18
|
+
* ---
|
|
19
|
+
* import { useLocale } from 'astro-intlayer';
|
|
20
|
+
*
|
|
21
|
+
* const { locale, availableLocales } = useLocale();
|
|
22
|
+
* ---
|
|
23
|
+
* <html lang={locale}>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const useLocale: (_props?: UseLocaleProps$1) => UseLocaleResult;
|
|
27
|
+
//#endregion
|
|
28
|
+
export type { UseLocaleProps };
|
|
29
|
+
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../src/useLocale.ts"],"mappings":";;YAUY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;qBA0BjB,YAAS,SAAY,qBAAsB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WithOnChange } from "vanilla-intlayer";
|
|
2
|
+
//#region src/withInertOnChange.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gives server-rendered content the `.onChange()` of its client counterpart.
|
|
5
|
+
*
|
|
6
|
+
* The locale cannot change during a server render, so the subscription never
|
|
7
|
+
* fires; it only keeps the content shape identical on both sides of the
|
|
8
|
+
* `astro-intlayer` entry.
|
|
9
|
+
*/
|
|
10
|
+
export declare const withInertOnChange: <T>(content: T) => WithOnChange<T>;
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=withInertOnChange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withInertOnChange.d.ts","names":[],"sources":["../../src/withInertOnChange.ts"],"mappings":";;;;;;;;;qBASa,oBAAqB,GAAC,SAAW,MAAI,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Astro applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,9 +41,71 @@
|
|
|
41
41
|
"exports": {
|
|
42
42
|
".": {
|
|
43
43
|
"types": "./dist/types/index.d.ts",
|
|
44
|
+
"node": {
|
|
45
|
+
"require": "./dist/cjs/index.cjs",
|
|
46
|
+
"import": "./dist/esm/index.mjs"
|
|
47
|
+
},
|
|
48
|
+
"bun": {
|
|
49
|
+
"require": "./dist/cjs/index.cjs",
|
|
50
|
+
"import": "./dist/esm/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"deno": {
|
|
53
|
+
"require": "./dist/cjs/index.cjs",
|
|
54
|
+
"import": "./dist/esm/index.mjs"
|
|
55
|
+
},
|
|
56
|
+
"workerd": {
|
|
57
|
+
"require": "./dist/cjs/index.cjs",
|
|
58
|
+
"import": "./dist/esm/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"worker": {
|
|
61
|
+
"require": "./dist/cjs/index.cjs",
|
|
62
|
+
"import": "./dist/esm/index.mjs"
|
|
63
|
+
},
|
|
64
|
+
"edge-light": {
|
|
65
|
+
"require": "./dist/cjs/index.cjs",
|
|
66
|
+
"import": "./dist/esm/index.mjs"
|
|
67
|
+
},
|
|
68
|
+
"browser": {
|
|
69
|
+
"require": "./dist/cjs/client/index.cjs",
|
|
70
|
+
"import": "./dist/esm/client/index.mjs"
|
|
71
|
+
},
|
|
44
72
|
"require": "./dist/cjs/index.cjs",
|
|
45
73
|
"import": "./dist/esm/index.mjs"
|
|
46
74
|
},
|
|
75
|
+
"./client": {
|
|
76
|
+
"types": "./dist/types/client/index.d.ts",
|
|
77
|
+
"require": "./dist/cjs/client/index.cjs",
|
|
78
|
+
"import": "./dist/esm/client/index.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./integration": {
|
|
81
|
+
"types": "./dist/types/integration.d.ts",
|
|
82
|
+
"require": "./dist/cjs/integration.cjs",
|
|
83
|
+
"import": "./dist/esm/integration.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./middleware": {
|
|
86
|
+
"types": "./dist/types/middleware.d.ts",
|
|
87
|
+
"require": "./dist/cjs/middleware.cjs",
|
|
88
|
+
"import": "./dist/esm/middleware.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./format": {
|
|
91
|
+
"types": "./dist/types/format/index.d.ts",
|
|
92
|
+
"browser": {
|
|
93
|
+
"require": "./dist/cjs/client/format/index.cjs",
|
|
94
|
+
"import": "./dist/esm/client/format/index.mjs"
|
|
95
|
+
},
|
|
96
|
+
"require": "./dist/cjs/format/index.cjs",
|
|
97
|
+
"import": "./dist/esm/format/index.mjs"
|
|
98
|
+
},
|
|
99
|
+
"./html": {
|
|
100
|
+
"types": "./dist/types/html/index.d.ts",
|
|
101
|
+
"require": "./dist/cjs/html/index.cjs",
|
|
102
|
+
"import": "./dist/esm/html/index.mjs"
|
|
103
|
+
},
|
|
104
|
+
"./markdown": {
|
|
105
|
+
"types": "./dist/types/markdown/index.d.ts",
|
|
106
|
+
"require": "./dist/cjs/markdown/index.cjs",
|
|
107
|
+
"import": "./dist/esm/markdown/index.mjs"
|
|
108
|
+
},
|
|
47
109
|
"./package.json": "./package.json"
|
|
48
110
|
},
|
|
49
111
|
"main": "dist/cjs/index.cjs",
|
|
@@ -51,8 +113,26 @@
|
|
|
51
113
|
"types": "dist/types/index.d.ts",
|
|
52
114
|
"typesVersions": {
|
|
53
115
|
"*": {
|
|
116
|
+
"client": [
|
|
117
|
+
"./dist/types/client/index.d.ts"
|
|
118
|
+
],
|
|
119
|
+
"format": [
|
|
120
|
+
"./dist/types/format/index.d.ts"
|
|
121
|
+
],
|
|
122
|
+
"html": [
|
|
123
|
+
"./dist/types/html/index.d.ts"
|
|
124
|
+
],
|
|
125
|
+
"markdown": [
|
|
126
|
+
"./dist/types/markdown/index.d.ts"
|
|
127
|
+
],
|
|
128
|
+
"middleware": [
|
|
129
|
+
"./dist/types/middleware.d.ts"
|
|
130
|
+
],
|
|
54
131
|
"package.json": [
|
|
55
132
|
"./package.json"
|
|
133
|
+
],
|
|
134
|
+
"integration": [
|
|
135
|
+
"./dist/types/integration.d.ts"
|
|
56
136
|
]
|
|
57
137
|
}
|
|
58
138
|
},
|
|
@@ -79,13 +159,15 @@
|
|
|
79
159
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
80
160
|
},
|
|
81
161
|
"dependencies": {
|
|
82
|
-
"@intlayer/config": "9.5.
|
|
83
|
-
"@intlayer/core": "9.5.
|
|
84
|
-
"@intlayer/engine": "9.5.
|
|
85
|
-
"@intlayer/types": "9.5.
|
|
86
|
-
"
|
|
162
|
+
"@intlayer/config": "9.5.5",
|
|
163
|
+
"@intlayer/core": "9.5.5",
|
|
164
|
+
"@intlayer/engine": "9.5.5",
|
|
165
|
+
"@intlayer/types": "9.5.5",
|
|
166
|
+
"vanilla-intlayer": "9.5.5",
|
|
167
|
+
"vite-intlayer": "9.5.5"
|
|
87
168
|
},
|
|
88
169
|
"devDependencies": {
|
|
170
|
+
"@intlayer/dictionaries-entry": "9.5.5",
|
|
89
171
|
"@types/node": "^22",
|
|
90
172
|
"@utils/ts-config": "1.0.4",
|
|
91
173
|
"@utils/ts-config-types": "1.0.4",
|