react-intlayer 9.0.0-canary.2 → 9.0.0-canary.21
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/cjs/IntlayerNode.cjs +0 -1
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/UI/ContentSelector.cjs +0 -1
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/analytics/AnalyticsProvider.cjs +16 -0
- package/dist/cjs/analytics/AnalyticsProvider.cjs.map +1 -0
- package/dist/cjs/analytics/exposureSink.cjs +27 -0
- package/dist/cjs/analytics/exposureSink.cjs.map +1 -0
- package/dist/cjs/analytics/index.cjs +10 -0
- package/dist/cjs/analytics/useAnalytics.cjs +54 -0
- package/dist/cjs/analytics/useAnalytics.cjs.map +1 -0
- package/dist/cjs/analytics/useConversion.cjs +32 -0
- package/dist/cjs/analytics/useConversion.cjs.map +1 -0
- package/dist/cjs/analytics/useExperiment.cjs +65 -0
- package/dist/cjs/analytics/useExperiment.cjs.map +1 -0
- package/dist/cjs/client/IntlayerProvider.cjs +6 -2
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/useCompact.cjs +0 -1
- package/dist/cjs/client/format/useCompact.cjs.map +1 -1
- package/dist/cjs/client/format/useCurrency.cjs +0 -1
- package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/client/format/useDate.cjs +0 -1
- package/dist/cjs/client/format/useDate.cjs.map +1 -1
- package/dist/cjs/client/format/useIntl.cjs +0 -1
- package/dist/cjs/client/format/useIntl.cjs.map +1 -1
- package/dist/cjs/client/format/useList.cjs +0 -1
- package/dist/cjs/client/format/useList.cjs.map +1 -1
- package/dist/cjs/client/format/useNumber.cjs +0 -1
- package/dist/cjs/client/format/useNumber.cjs.map +1 -1
- package/dist/cjs/client/format/usePercentage.cjs +0 -1
- package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/client/format/useRelativeTime.cjs +0 -1
- package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/client/format/useUnit.cjs +0 -1
- package/dist/cjs/client/format/useUnit.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +2 -0
- package/dist/cjs/client/t.cjs +0 -1
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -2
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +0 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +2 -3
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useI18n.cjs +0 -1
- package/dist/cjs/client/useI18n.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -3
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +0 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +0 -1
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +0 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/usePathname.cjs +40 -0
- package/dist/cjs/client/usePathname.cjs.map +1 -0
- package/dist/cjs/client/useRewriteURL.cjs +0 -1
- package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs +0 -1
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelector.cjs +1 -2
- package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
- package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -2
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -2
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -2
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/html/HTMLProvider.cjs +0 -1
- package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs +0 -1
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
- package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +0 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +0 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
- package/dist/cjs/markdown/processor.cjs +0 -1
- package/dist/cjs/markdown/processor.cjs.map +1 -1
- package/dist/cjs/markdown/runtime.cjs +0 -1
- package/dist/cjs/markdown/runtime.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +41 -24
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/reactElement/renderReactElement.cjs +0 -1
- package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs +0 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/format/useCompact.cjs +0 -1
- package/dist/cjs/server/format/useCompact.cjs.map +1 -1
- package/dist/cjs/server/format/useCurrency.cjs +0 -1
- package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/server/format/useDate.cjs +0 -1
- package/dist/cjs/server/format/useDate.cjs.map +1 -1
- package/dist/cjs/server/format/useIntl.cjs +0 -1
- package/dist/cjs/server/format/useIntl.cjs.map +1 -1
- package/dist/cjs/server/format/useList.cjs +0 -1
- package/dist/cjs/server/format/useList.cjs.map +1 -1
- package/dist/cjs/server/format/useNumber.cjs +0 -1
- package/dist/cjs/server/format/useNumber.cjs.map +1 -1
- package/dist/cjs/server/format/usePercentage.cjs +0 -1
- package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/server/format/useRelativeTime.cjs +0 -1
- package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/server/format/useUnit.cjs +0 -1
- package/dist/cjs/server/format/useUnit.cjs.map +1 -1
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +0 -1
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +1 -1
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryAsync.cjs +0 -1
- package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryDynamic.cjs +2 -3
- package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/server/useI18n.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +2 -2
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/server/useLocale.cjs +0 -1
- package/dist/cjs/server/useLocale.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/analytics/AnalyticsProvider.mjs +15 -0
- package/dist/esm/analytics/AnalyticsProvider.mjs.map +1 -0
- package/dist/esm/analytics/exposureSink.mjs +24 -0
- package/dist/esm/analytics/exposureSink.mjs.map +1 -0
- package/dist/esm/analytics/index.mjs +6 -0
- package/dist/esm/analytics/useAnalytics.mjs +53 -0
- package/dist/esm/analytics/useAnalytics.mjs.map +1 -0
- package/dist/esm/analytics/useConversion.mjs +31 -0
- package/dist/esm/analytics/useConversion.mjs.map +1 -0
- package/dist/esm/analytics/useExperiment.mjs +64 -0
- package/dist/esm/analytics/useExperiment.mjs.map +1 -0
- package/dist/esm/client/IntlayerProvider.mjs +6 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/useCompact.mjs.map +1 -1
- package/dist/esm/client/format/useCurrency.mjs.map +1 -1
- package/dist/esm/client/format/useDate.mjs.map +1 -1
- package/dist/esm/client/format/useIntl.mjs.map +1 -1
- package/dist/esm/client/format/useList.mjs.map +1 -1
- package/dist/esm/client/format/useNumber.mjs.map +1 -1
- package/dist/esm/client/format/usePercentage.mjs.map +1 -1
- package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/client/format/useUnit.mjs.map +1 -1
- package/dist/esm/client/index.mjs +2 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useI18n.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -2
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/client/usePathname.mjs +39 -0
- package/dist/esm/client/usePathname.mjs.map +1 -0
- package/dist/esm/client/useRewriteURL.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelector.mjs +1 -1
- package/dist/esm/editor/ContentSelector.mjs.map +1 -1
- package/dist/esm/editor/EditorProvider.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/html/HTMLProvider.mjs.map +1 -1
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
- package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
- package/dist/esm/index.mjs +5 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
- package/dist/esm/markdown/processor.mjs.map +1 -1
- package/dist/esm/markdown/runtime.mjs.map +1 -1
- package/dist/esm/plugins.mjs +41 -24
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/format/useCompact.mjs.map +1 -1
- package/dist/esm/server/format/useCurrency.mjs.map +1 -1
- package/dist/esm/server/format/useDate.mjs.map +1 -1
- package/dist/esm/server/format/useIntl.mjs.map +1 -1
- package/dist/esm/server/format/useList.mjs.map +1 -1
- package/dist/esm/server/format/useNumber.mjs.map +1 -1
- package/dist/esm/server/format/usePercentage.mjs.map +1 -1
- package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/server/format/useUnit.mjs.map +1 -1
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +1 -1
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/server/useDictionaryDynamic.mjs +2 -2
- package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/server/useI18n.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +2 -2
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/server/useLocale.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +1 -6
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +0 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/analytics/AnalyticsProvider.d.ts +10 -0
- package/dist/types/analytics/AnalyticsProvider.d.ts.map +1 -0
- package/dist/types/analytics/exposureSink.d.ts +32 -0
- package/dist/types/analytics/exposureSink.d.ts.map +1 -0
- package/dist/types/analytics/index.d.ts +5 -0
- package/dist/types/analytics/useAnalytics.d.ts +15 -0
- package/dist/types/analytics/useAnalytics.d.ts.map +1 -0
- package/dist/types/analytics/useConversion.d.ts +31 -0
- package/dist/types/analytics/useConversion.d.ts.map +1 -0
- package/dist/types/analytics/useExperiment.d.ts +41 -0
- package/dist/types/analytics/useExperiment.d.ts.map +1 -0
- package/dist/types/client/IntlayerProvider.d.ts +1 -3
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/format/useCompact.d.ts +1 -3
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +1 -3
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useDate.d.ts +0 -1
- package/dist/types/client/format/useDate.d.ts.map +1 -1
- package/dist/types/client/format/useIntl.d.ts +0 -1
- package/dist/types/client/format/useIntl.d.ts.map +1 -1
- package/dist/types/client/format/useList.d.ts +4 -6
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +1 -3
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +1 -3
- package/dist/types/client/format/usePercentage.d.ts.map +1 -1
- package/dist/types/client/format/useRelativeTime.d.ts +1 -3
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/client/format/useUnit.d.ts +1 -3
- package/dist/types/client/format/useUnit.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +2 -1
- package/dist/types/client/t.d.ts +0 -1
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -5
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +0 -1
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +0 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts +0 -1
- package/dist/types/client/useI18n.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +2 -6
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +1 -5
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +2 -4
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +5 -10
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/usePathname.d.ts +23 -0
- package/dist/types/client/usePathname.d.ts.map +1 -0
- package/dist/types/client/useRewriteURL.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +0 -1
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts +0 -1
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts +0 -1
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +1 -2
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLComponentTypes.d.ts +8 -9
- package/dist/types/html/HTMLComponentTypes.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts +0 -1
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts +2 -7
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/html/HTMLRendererPlugin.d.ts +0 -1
- package/dist/types/html/HTMLRendererPlugin.d.ts.map +1 -1
- package/dist/types/html/types.d.ts +0 -1
- package/dist/types/html/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +18 -35
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +7 -4
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +2 -17
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts +0 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/processor.d.ts +0 -1
- package/dist/types/markdown/processor.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts +0 -1
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -2
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +0 -1
- package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +1 -3
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/format/useCompact.d.ts +0 -1
- package/dist/types/server/format/useCompact.d.ts.map +1 -1
- package/dist/types/server/format/useCurrency.d.ts +0 -1
- package/dist/types/server/format/useCurrency.d.ts.map +1 -1
- package/dist/types/server/format/useDate.d.ts +0 -1
- package/dist/types/server/format/useDate.d.ts.map +1 -1
- package/dist/types/server/format/useIntl.d.ts +0 -1
- package/dist/types/server/format/useIntl.d.ts.map +1 -1
- package/dist/types/server/format/useList.d.ts +0 -1
- package/dist/types/server/format/useList.d.ts.map +1 -1
- package/dist/types/server/format/useNumber.d.ts +0 -1
- package/dist/types/server/format/useNumber.d.ts.map +1 -1
- package/dist/types/server/format/usePercentage.d.ts +0 -1
- package/dist/types/server/format/usePercentage.d.ts.map +1 -1
- package/dist/types/server/format/useRelativeTime.d.ts +0 -1
- package/dist/types/server/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/server/format/useUnit.d.ts +0 -1
- package/dist/types/server/format/useUnit.d.ts.map +1 -1
- package/dist/types/server/serverContext.d.ts +1 -5
- package/dist/types/server/serverContext.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +0 -1
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +2 -5
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +2 -5
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +0 -1
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/server/useI18n.d.ts +0 -1
- package/dist/types/server/useI18n.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +3 -6
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/dist/types/server/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/server/useLocale.d.ts +0 -1
- package/dist/types/server/useLocale.d.ts.map +1 -1
- package/package.json +22 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,mBAAmB;CAC9B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,mBAAmB;CAC9B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ?? currentLocale ?? internationalization?.defaultLocale\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,WAAW,WAAwC;CAC9D,MAAM,gBAAgB,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ?? currentLocale ?? internationalization?.defaultLocale\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,WAAW,WAAwC;CAC9D,MAAM,gBAAgB,iBAAgC,qBAAqB;CAE3E,OAAO,SACL,UAAU,iBAAiB,sBAAsB,aACnD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,kBAAkB;CAC7B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,kBAAkB;CAC7B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,sBAAsB;CACjC,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,sBAAsB;CACjC,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,wBAAwB;CACnC,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,wBAAwB;CACnC,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,aAAa,KAAK,IAAI,KAAK,sBAAM,IAAI,KAAK,GAAG;EAC3C,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/server/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/server/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,qBAAqB;CAEpE,QAAQ,GAAG,SACT,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.mjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"serverContext.mjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,OAAU;AAEtD,MAAa,uBAA2B,iBAAuC;CAC7E,cAAc;CAKd,MAAM,YAFQ,MAAM,SAAuB,cAErB,QAAQ,EAC5B,OAAO,OACT,EAAE;CAEF,MAAM,YAAkD,EACtD,UACA,YACI;EACJ,SAAS,CAAC,CAAC,QAAQ;EACnB,OAAO;CACT;CAEA,MAAM,gBAAgB;CACtB,cAAc,WAAW;CACzB,cAAc,YAAY,UAAU;EAClC,MAAM,QAAQ,SAAS;EACvB,OAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,YAAY;CAC1D;CACA,cAAc,WAAW;CACzB,cAAc,gBAAgB;CAE9B,OAAO;AACT;;;;;;;;AASA,MAAa,oBAAwB,EACnC,UACA,oBACsB;CAEtB,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,MAAM;AACf;;;;;AAeA,MAAM,sBAAyC;CAE7C,IAAI,OAAO,WAAW,aACpB,MAAM,IAAI,MAAM,qDAAqD;AAEzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"t.mjs","names":[],"sources":["../../../src/server/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string, L extends LocalesValues = DeclaredLocales>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: L\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? (currentLocale as LocalesValues);\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,gBAAgB,iBAAgC,
|
|
1
|
+
{"version":3,"file":"t.mjs","names":[],"sources":["../../../src/server/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string, L extends LocalesValues = DeclaredLocales>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: L\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? (currentLocale as LocalesValues);\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,gBAAgB,iBAAgC,qBAAqB;CAG3E,OAAO,eAAwB,kBAFV,UAAW,aAE6B;AAC/D"}
|
|
@@ -12,7 +12,7 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
|
12
12
|
*/
|
|
13
13
|
const useDictionary = (dictionary, localeOrSelector, fallbackLocale) => {
|
|
14
14
|
const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
|
|
15
|
-
if (process.env
|
|
15
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return getDictionary(dictionary, {
|
|
16
16
|
...localeOrSelector,
|
|
17
17
|
locale: localeOrSelector.locale ?? contextLocale
|
|
18
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary (or qualified\n * dictionary group) and return the content\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getDictionary<T, A>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAa,iBAMX,YACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAO,cAAc,YAAY;EAC/B,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAO,cAAoB,YAFL,oBAAoB,aAES;AACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACA,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACA,iBAAgC,qBAAqB,KACrD,kBACA,qBAAqB;CAIvB,OAAO,cAAoB,MAFD,kBAA0B,aAAa,GAAG,GAE7B,YAAiB;AAC1D"}
|
|
@@ -18,12 +18,12 @@ import { isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveQualifiedD
|
|
|
18
18
|
* context locale is used.
|
|
19
19
|
*/
|
|
20
20
|
const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector, fallbackLocale) => {
|
|
21
|
-
const { locale: selectorLocale, selector } = process.env
|
|
21
|
+
const { locale: selectorLocale, selector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(localeOrSelector) : {
|
|
22
22
|
locale: localeOrSelector,
|
|
23
23
|
selector: void 0
|
|
24
24
|
};
|
|
25
25
|
const localeTarget = selectorLocale ?? getServerContext(IntlayerServerContext) ?? fallbackLocale ?? internationalization.defaultLocale;
|
|
26
|
-
if (process.env
|
|
26
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && isQualifiedDynamicLoaderMap(dictionaryPromise)) return resolveQualifiedDynamicContent({
|
|
27
27
|
loaderMap: dictionaryPromise,
|
|
28
28
|
key: String(key),
|
|
29
29
|
locale: localeTarget,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":["loadDynamicChunk"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContent,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n// `useLoadDynamic` wraps `react.use`, which may be called in loops /\n// conditionally — aliased to a non-hook name so a collection can load several\n// chunks at once.\nimport { useLoadDynamic as loadDynamicChunk } from './useLoadDynamic';\n\n/**\n * Server-side hook that lazily loads a dictionary and returns its content.\n *\n * The dictionary entry is either a plain dynamic loader map\n * (`locale → loader`) or a qualified one (`locale → qualifierId → loader`,\n * tagged with the qualifier dimension). For qualified maps, only the chunk(s)\n * the selector targets are loaded; the resolution mirrors static mode.\n *\n * If the locale is not provided (directly or through the selector), the server\n * context locale is used.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const { locale: selectorLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector<LocalesValues>(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n\n const localeTarget =\n selectorLocale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n internationalization.defaultLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n return resolveQualifiedDynamicContent({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n loadChunk: (cacheKey, promise) => loadDynamicChunk(cacheKey, promise),\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n });\n }\n\n const plainLoaders = dictionaryPromise as StrictModeLocaleMap<\n () => Promise<T>\n >;\n\n const dictionary = loadDynamicChunk<T>(\n `${String(key)}.${localeTarget}`,\n plainLoaders[localeTarget as keyof typeof plainLoaders]?.() as Promise<T>\n );\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAa,wBAIX,mBAGA,KACA,kBACA,mBACG;CACH,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,QAAQ,IAAI,iCAAiC,UACzC,wBAAuC,gBAAgB,IACvD;EACE,QAAQ;EACR,UAAU;CACZ;CAEN,MAAM,eACJ,kBACA,iBAAgC,qBAAqB,KACrD,kBACA,qBAAqB;CAEvB,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAE7C,OAAO,+BAA+B;EACpC,WAAW;EACX,KAAK,OAAO,GAAG;EACf,QAAQ;EACR;EACA,YAAY,UAAU,YAAYA,eAAiB,UAAU,OAAO;EACpE,YAAY,eAAe,cAAc,YAAY,YAAY;CACnE,CAAC;CAGH,MAAM,eAAe;CASrB,OAAO,cALYA,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBAClB,aAAa,aAA0C,GAAG,CAG9B,GAAG,YAAY;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.mjs","names":[],"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,WACX,WACA,WACG;CAKH,MAAM,oBAAoB,YAAY,WAHpC,UAAU,iBAAgC,
|
|
1
|
+
{"version":3,"file":"useI18n.mjs","names":[],"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,WACX,WACA,WACG;CAKH,MAAM,oBAAoB,YAAY,WAHpC,UAAU,iBAAgC,qBAAqB,CAGJ;CAI7D,MAAM,KACJ,SACsE;EACtE,IAAI,CAAC,MACH,OAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,GAAG;EAC5C,IAAI,UAAe;EAEnB,KAAK,MAAM,OAAO,WAAW;GAC3B,UAAU,UAAU;GACpB,IAAI,YAAY,QAEd,OAAO;EAEX;EAEA,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
@@ -7,13 +7,13 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
|
7
7
|
* On the server side, Hook that picking one dictionary by its key and return the content
|
|
8
8
|
*
|
|
9
9
|
* The second argument is either a locale or a selector object
|
|
10
|
-
* (`{ item }`, `{ variant }`,
|
|
10
|
+
* (`{ item }`, `{ variant }`, optionally with `locale`).
|
|
11
11
|
*
|
|
12
12
|
* If the locale is not provided, it will use the locale from the server context
|
|
13
13
|
*/
|
|
14
14
|
const useIntlayer = (key, localeOrSelector, fallbackLocale) => {
|
|
15
15
|
const contextLocale = getServerContext(IntlayerServerContext) ?? fallbackLocale;
|
|
16
|
-
if (process.env
|
|
16
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof localeOrSelector === "object" && localeOrSelector !== null) return getIntlayer(key, {
|
|
17
17
|
...localeOrSelector,
|
|
18
18
|
locale: localeOrSelector.locale ?? contextLocale
|
|
19
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`,
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`).\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n fallbackLocale?: DeclaredLocales\n) => {\n const contextLocale =\n getServerContext<LocalesValues>(IntlayerServerContext) ?? fallbackLocale;\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null\n ) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? contextLocale,\n } as A);\n }\n\n const localeTarget = (localeOrSelector ?? contextLocale) as A;\n\n return getIntlayer<T, A>(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,kBACA,mBACG;CACH,MAAM,gBACJ,iBAAgC,qBAAqB,KAAK;CAE5D,IACE,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB,MAErB,OAAO,YAAY,KAAK;EACtB,GAAG;EACH,QAAQ,iBAAiB,UAAU;CACrC,CAAM;CAKR,OAAO,YAAkB,KAFH,oBAAoB,aAEA;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/server/useLoadDynamic.ts"],"sourcesContent":["import react from 'react';\n\nexport const useLoadDynamic = <T>(_key: string, promise: Promise<T>): T => {\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cachedPromise = react.cache(async () => await promise)();\n\n /** @ts-ignore remove error Property 'use' does not exist on type 'typeof React'. */\n const dictionary = react.use(cachedPromise);\n\n return dictionary;\n};\n"],"mappings":";;;AAEA,MAAa,kBAAqB,MAAc,YAA2B;;CAEzE,MAAM,gBAAgB,MAAM,MAAM,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/server/useLoadDynamic.ts"],"sourcesContent":["import react from 'react';\n\nexport const useLoadDynamic = <T>(_key: string, promise: Promise<T>): T => {\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cachedPromise = react.cache(async () => await promise)();\n\n /** @ts-ignore remove error Property 'use' does not exist on type 'typeof React'. */\n const dictionary = react.use(cachedPromise);\n\n return dictionary;\n};\n"],"mappings":";;;AAEA,MAAa,kBAAqB,MAAc,YAA2B;;CAEzE,MAAM,gBAAgB,MAAM,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;CAK7D,OAFmB,MAAM,IAAI,aAEb;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,
|
|
1
|
+
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/server/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useLocale = (): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const locale = (getServerContext(IntlayerServerContext) ??\n defaultLocale) as DeclaredLocales;\n\n return { locale, defaultLocale, availableLocales };\n};\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,kBAAmC;CAC9C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,CAAC;CAK3B,OAAO;EAAE,QAHO,iBAAiB,qBAAqB,KACpD;EAEe;EAAe;CAAiB;AACnD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NodeProps } from "@intlayer/core/interpreter";
|
|
2
2
|
import { ResolvedEditor } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { PropsWithChildren, ReactNode } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/IntlayerNode.d.ts
|
|
6
5
|
type IntlayerNode<T = NodeProps['children'], AdditionalProps = Record<string, never>> = ResolvedEditor<T, ReactNode> & {
|
|
7
6
|
value: T;
|
|
@@ -13,11 +12,7 @@ type RenderIntlayerNodeProps<T> = PropsWithChildren<{
|
|
|
13
12
|
[key: string]: any;
|
|
14
13
|
};
|
|
15
14
|
}>;
|
|
16
|
-
declare const renderIntlayerNode: <T>({
|
|
17
|
-
children,
|
|
18
|
-
value,
|
|
19
|
-
additionalProps
|
|
20
|
-
}: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
15
|
+
declare const renderIntlayerNode: <T>({ children, value, additionalProps }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
21
16
|
//#endregion
|
|
22
17
|
export { IntlayerNode, renderIntlayerNode };
|
|
23
18
|
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;KASY,aACV,IAAI,uBACJ,kBAAkB,yBAChB,eAAe,GAAG;EACpB,OAAO;IACL,kBACF;KAEG,wBAAwB,KAAK;EAChC,OAAO;EACP,UAAU;EACV;KAAqB;;;cAGV,qBACX,KAAC,UAAA,OAAA,mBAKA,wBAAwB,OAAK,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;KAcK;EACH;EACA;EACA;EACA;EACA;EACA;IACE,KAAK,eAAe;cAEX,iBAAiB,GAAG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from "react";
|
|
2
|
+
//#region src/analytics/AnalyticsProvider.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
|
|
5
|
+
* {@link IntlayerProvider} alongside `EditorProvider`.
|
|
6
|
+
*/
|
|
7
|
+
declare const AnalyticsProvider: FC<PropsWithChildren>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { AnalyticsProvider };
|
|
10
|
+
//# sourceMappingURL=AnalyticsProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyticsProvider.d.ts","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"mappings":";;;;;;cAOa,mBAAmB,GAAG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { KeyPath } from "@intlayer/types/keyPath";
|
|
2
|
+
//#region src/analytics/exposureSink.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Node metadata reported for a content exposure. Kept dependency-free (types
|
|
5
|
+
* only) so the interpreter hot path in `plugins.tsx` never statically imports
|
|
6
|
+
* `@intlayer/analytics` — the package stays optional and tree-shakeable.
|
|
7
|
+
*/
|
|
8
|
+
type ExposureInput = {
|
|
9
|
+
dictionaryKey: string;
|
|
10
|
+
keyPath: KeyPath[];
|
|
11
|
+
locale?: string;
|
|
12
|
+
nodeType?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Consumer of exposure reports, installed by `useAnalytics` after init. */
|
|
15
|
+
type ExposureSink = (input: ExposureInput) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Installs (or clears) the exposure sink. `useAnalytics` sets this once the
|
|
18
|
+
* analytics client has loaded, and clears it on unmount.
|
|
19
|
+
*
|
|
20
|
+
* @param next - The sink to install, or `null` to clear.
|
|
21
|
+
*/
|
|
22
|
+
declare const setExposureSink: (next: ExposureSink | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Forwards a content exposure to the installed sink. A cheap null-check when
|
|
25
|
+
* analytics is not running, so it is safe to call from every node resolution.
|
|
26
|
+
*
|
|
27
|
+
* @param input - The node metadata to report.
|
|
28
|
+
*/
|
|
29
|
+
declare const reportExposure: (input: ExposureInput) => void;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ExposureInput, ExposureSink, reportExposure, setExposureSink };
|
|
32
|
+
//# sourceMappingURL=exposureSink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":";;;;;;;KAOY;EACV;EACA,SAAS;EACT;EACA;;;KAIU,gBAAgB,OAAO;;;;;;;cAUtB,kBAAe,MAAU;;;;;;;cAUzB,iBAAc,OAAW"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AnalyticsProvider } from "./AnalyticsProvider.js";
|
|
2
|
+
import { useAnalytics } from "./useAnalytics.js";
|
|
3
|
+
import { ConversionParams, useConversion } from "./useConversion.js";
|
|
4
|
+
import { ExperimentState, useExperiment } from "./useExperiment.js";
|
|
5
|
+
export { AnalyticsProvider, ConversionParams, ExperimentState, useAnalytics, useConversion, useExperiment };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/analytics/useAnalytics.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Initializes the Intlayer analytics client singleton when analytics is enabled
|
|
4
|
+
* and keeps it aware of the current locale.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
|
|
7
|
+
* ships as its own async chunk, off the critical rendering path. Apps that
|
|
8
|
+
* don't opt in (`analytics.enabled !== true`) pay nothing — the whole body is
|
|
9
|
+
* guarded by `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build
|
|
10
|
+
* time.
|
|
11
|
+
*/
|
|
12
|
+
declare const useAnalytics: () => void;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useAnalytics };
|
|
15
|
+
//# sourceMappingURL=useAnalytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"mappings":";;;;;;;;;;;cAkBa"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/analytics/useConversion.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Parameters describing a conversion to record.
|
|
4
|
+
*/
|
|
5
|
+
type ConversionParams = {
|
|
6
|
+
/** The experiment this conversion is attributed to. */
|
|
7
|
+
experimentKey: string;
|
|
8
|
+
/** The variant the session was assigned. */
|
|
9
|
+
variant: string;
|
|
10
|
+
/** The goal reached (e.g. `"signup"`, `"cta_click"`). */
|
|
11
|
+
goal: string;
|
|
12
|
+
/** Optional numeric value (e.g. revenue). */
|
|
13
|
+
value?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Returns a stable `trackConversion` callback for content A/B testing. Safe to
|
|
17
|
+
* call from any component: it resolves to a no-op when analytics is disabled
|
|
18
|
+
* or the client has not been initialized yet.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const trackConversion = useConversion();
|
|
23
|
+
* <button onClick={() => trackConversion({
|
|
24
|
+
* experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',
|
|
25
|
+
* })}>Get started</button>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare const useConversion: () => (params: ConversionParams) => void;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ConversionParams, useConversion };
|
|
31
|
+
//# sourceMappingURL=useConversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.tsx"],"mappings":";;;;KAQY;;EAEV;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;cAgBW,sBAAa,QACI"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/analytics/useExperiment.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The state of an A/B experiment for the current session.
|
|
4
|
+
*/
|
|
5
|
+
type ExperimentState = {
|
|
6
|
+
/**
|
|
7
|
+
* The variant assigned to this session. Until assignment resolves (and on
|
|
8
|
+
* the server, or when analytics is disabled), this is the first variant —
|
|
9
|
+
* treat the first variant as the control.
|
|
10
|
+
*/
|
|
11
|
+
variant: string;
|
|
12
|
+
/**
|
|
13
|
+
* `true` once the variant has been deterministically assigned and its
|
|
14
|
+
* exposure recorded. Useful to defer rendering when a flash of the control
|
|
15
|
+
* variant is not acceptable.
|
|
16
|
+
*/
|
|
17
|
+
isAssigned: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Assigns this session to a variant of an A/B experiment and records the
|
|
21
|
+
* exposure, scoped to `experimentKey`, so the backend can compute per-variant
|
|
22
|
+
* conversion rates against `useConversion` events.
|
|
23
|
+
*
|
|
24
|
+
* Assignment is deterministic per session (no server round-trip, stable across
|
|
25
|
+
* re-mounts). The exposure is recorded once per mount.
|
|
26
|
+
*
|
|
27
|
+
* @param experimentKey - Unique key identifying the experiment.
|
|
28
|
+
* @param variants - The candidate variant names; the first one is the control.
|
|
29
|
+
* @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
|
|
30
|
+
* @returns The {@link ExperimentState} for this session.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const { variant } = useExperiment('homepage-hero', ['a', 'b']);
|
|
35
|
+
* const content = useIntlayer(variant === 'b' ? 'hero-b' : 'hero');
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ExperimentState, useExperiment };
|
|
41
|
+
//# sourceMappingURL=useExperiment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.tsx"],"mappings":";;;;KAQY;;;;;;EAMV;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;cAsBW,gBAAa,uBACH,oBACH,uBAEjB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$react from "react";
|
|
3
2
|
import { FC, PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
3
|
//#region src/client/IntlayerProvider.d.ts
|
|
6
4
|
type IntlayerValue = {
|
|
7
5
|
locale: LocalesValues;
|
|
@@ -12,7 +10,7 @@ type IntlayerValue = {
|
|
|
12
10
|
/**
|
|
13
11
|
* Context that stores the current locale on the client side.
|
|
14
12
|
*/
|
|
15
|
-
declare const IntlayerClientContext:
|
|
13
|
+
declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
|
|
16
14
|
/**
|
|
17
15
|
* Hook that provides the current Intlayer client context.
|
|
18
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAkBK;EACH,QAAQ;EACR,YAAY,WAAW;EACvB;EACA;;;;;cAMW,uCAAqB,QAAA;;;;;;cAWrB;;;;KAKD,wBAAwB;;;;EAIlC,SAAS;;;;EAIT,gBAAgB;;;;EAIhB,aAAa,QAAQ;;;;EAIrB;;;;EAIA;;;;;;;;;;cAWW,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;cA8E5B,kBAAkB,GAAG"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/client/format/useCompact.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a compact number formatter
|
|
@@ -12,7 +10,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
12
10
|
* ```
|
|
13
11
|
*/
|
|
14
12
|
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
15
|
-
locale?:
|
|
13
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
16
14
|
}) => string;
|
|
17
15
|
//#endregion
|
|
18
16
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"mappings":";;;;;;;;;;;cAgBa,mBAAU,wBAAA,UAAA,KAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/client/format/useCurrency.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a currency formatter
|
|
@@ -26,7 +24,7 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
26
24
|
* ```
|
|
27
25
|
*/
|
|
28
26
|
declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
29
|
-
locale?:
|
|
27
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
30
28
|
}) => string;
|
|
31
29
|
//#endregion
|
|
32
30
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;cA8Ba,oBAAW,wBAAA,UAAA,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../../src/client/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../../src/client/format/useDate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgCa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCa,UAAO,SAAa,kBAAa"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
2
|
-
|
|
3
1
|
//#region src/client/format/useList.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* React client hook that provides a list formatter
|
|
@@ -23,11 +21,11 @@ import * as _$_intlayer_types0 from "@intlayer/types";
|
|
|
23
21
|
* ```
|
|
24
22
|
*/
|
|
25
23
|
declare const useList: () => (values: (string | number)[], options?: {
|
|
26
|
-
localeMatcher?:
|
|
27
|
-
type?:
|
|
28
|
-
style?:
|
|
24
|
+
localeMatcher?: 'lookup' | 'best fit';
|
|
25
|
+
type?: 'conjunction' | 'disjunction' | 'unit';
|
|
26
|
+
style?: 'long' | 'short' | 'narrow';
|
|
29
27
|
} & {
|
|
30
|
-
locale?:
|
|
28
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
31
29
|
}) => string;
|
|
32
30
|
//#endregion
|
|
33
31
|
export { useList };
|