intlayer 9.2.0 → 9.3.1

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 CHANGED
@@ -47,27 +47,27 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
47
47
 
48
48
  ## Keys benefits of Intlayer:
49
49
 
50
- | Feature | Description |
51
- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) |
70
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
50
+ | Feature | Description |
51
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
72
72
  ---
73
73
 
@@ -162,7 +162,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
162
162
  <li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
163
163
  <li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
164
164
  <ul>
165
- <li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
165
+ <li><a href="https://intlayer.org/doc/concept/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
166
166
  <li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
167
167
  <li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
168
168
  <li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
@@ -183,7 +183,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
183
183
  <ul>
184
184
  <li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
185
185
  <li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
186
- <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
186
+ <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-page-router" rel=''>Next.js Page Router</a></li>
187
187
  <li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
188
188
  </ul>
189
189
  </li>
@@ -212,7 +212,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
212
212
  <li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
213
213
  <li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
214
214
  <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
215
- <li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
215
+ <li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
216
216
  <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
217
217
  <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
218
218
  <li>
@@ -1,5 +1,4 @@
1
1
 
2
-
3
2
  var _intlayer_cli = require("@intlayer/cli");
4
3
  Object.keys(_intlayer_cli).forEach(function (k) {
5
4
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -1 +1 @@
1
- {"version":3,"file":"script.cjs","names":[],"sources":["../../../src/cli/script.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { setAPI } from '@intlayer/cli';\n\nsetAPI();\n"],"mappings":";;;;0BAGO"}
1
+ {"version":3,"file":"script.cjs","names":["setAPI"],"sources":["../../../src/cli/script.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { setAPI } from '@intlayer/cli';\n\nsetAPI();\n"],"mappings":";;;;IAGAA,sBAAO"}
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
20
20
  }
21
21
  return to;
22
22
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
24
24
  value: mod,
25
25
  enumerable: true
26
26
  }) : target, mod));
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/routing/index.ts
4
3
  const buildRules = (rules, processor) => ({ rules: Object.entries(rules).map(([canonical, localized]) => ({
5
4
  canonical: processor(canonical),
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/routing/index.ts"],"sourcesContent":["import type {\n RewriteObject,\n RewriteRule,\n RewriteRules,\n} from '@intlayer/types/config';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\n\nconst buildRules = (\n rules: Record<string, StrictModeLocaleMap<string>>,\n processor: (pattern: string) => string\n): RewriteRules => ({\n rules: Object.entries(rules).map(([canonical, localized]) => ({\n canonical: processor(canonical),\n localized: Object.fromEntries(\n Object.entries(localized).map(([locale, pattern]) => [\n locale,\n pattern ? processor(pattern) : pattern,\n ])\n ) as StrictModeLocaleMap<string>,\n })) as RewriteRule[],\n});\n\nconst cleanPath = (pattern: string) =>\n pattern.startsWith('/') ? pattern : `/${pattern}`;\n\n/**\n * Standardizes pattern to :param syntax.\n * Supports:\n * - Next.js/SvelteKit/Nuxt: [slug], [...slug], [[slug]]\n * - TanStack Router: $slug\n * - Solid Router: *slug\n * - React/Vue Router: :slug, *\n */\nconst normalizePattern = (pattern: string, framework?: string) => {\n let normalized = pattern;\n\n if (framework === 'nextjs') {\n normalized = normalized\n .replace(/\\[\\[\\.\\.\\.([^\\]]+)\\]\\]/g, ':$1*') // [[...slug]] -> :slug* (0+)\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1+') // [...slug] -> :slug+ (1+)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else if (framework === 'sveltekit') {\n normalized = normalized\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1*') // [...path] -> :path* (0+)\n .replace(/\\[\\[([^\\]]+)\\]\\]/g, ':$1?') // [[optional]] -> :optional? (0-1)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else if (framework === 'nuxt') {\n normalized = normalized\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1*') // [...slug] -> :slug* (0+)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else {\n // Default / Generic (React Router, Vue Router, Solid Router, TanStack Router)\n normalized = normalized\n .replace(/\\$([^/]+)/g, ':$1') // TanStack $slug -> :slug\n .replace(/\\*([^/]+)/g, ':$1*') // Solid *slug -> :slug*\n .replace(/:([^/]+)\\?/g, ':$1?') // Vue Router/React Router :slug? -> :slug?\n .replace(/\\*/g, ':path*'); // React Router * -> :path*\n }\n\n return normalized;\n};\n\n/**\n * Removes locale markers from the pattern.\n */\nconst stripLocale = (pattern: string) =>\n pattern\n .replace(/\\/?(:locale|\\[locale\\]|\\$locale)\\/?/g, '/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '') || '/';\n\n/**\n * Factory to create formatters that populate 'url' and a specific proxy key.\n */\nconst createFormatter =\n (proxyKey: 'nextjs' | 'vite', framework?: string) =>\n <T extends string = string>(\n rules: Record<T, Partial<StrictModeLocaleMap<string>>>\n ): RewriteObject => {\n const normalize = (pattern: string) => normalizePattern(pattern, framework);\n const strip = (pattern: string) => stripLocale(normalize(pattern));\n\n return {\n url: buildRules(rules as any, (pattern) => cleanPath(strip(pattern))),\n [proxyKey]: buildRules(rules as any, (pattern) =>\n cleanPath(normalize(pattern))\n ),\n } as RewriteObject;\n };\n\n/**\n * Formatter for Next.js style rewrites.\n * Patterns use Next.js dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (1+)\n * - Optional catch-all: `[[...slug]]` (0+)\n * - Locale: `[locale]`\n */\nexport const nextjsRewrite = createFormatter('nextjs', 'nextjs');\n\n/**\n * Formatter for SvelteKit style rewrites.\n * Patterns use SvelteKit dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (0+)\n * - Locale: `[locale]`\n */\nexport const svelteKitRewrite = createFormatter('vite', 'sveltekit');\n\n/**\n * Formatter for React Router style rewrites.\n * Patterns use React Router dynamic routing syntax:\n * - Slug: `:slug`\n * - Optional slug: `:slug?`\n * - Catch-all: `*`\n * - Locale: `:locale`\n */\nexport const reactRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Vue style rewrites.\n * Patterns use Vue Router 4 dynamic routing syntax:\n * - Slug: `:slug`\n * - Optional slug: `:slug?`\n * - Catch-all: `:slug*` or `:slug+`\n * - Locale: `:locale`\n */\nexport const vueRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Solid Router style rewrites.\n * Patterns use Solid Router dynamic routing syntax:\n * - Slug: `:slug`\n * - Catch-all: `*slug`\n * - Locale: `:locale`\n */\nexport const solidRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Nuxt style rewrites.\n * Patterns use Nuxt 3 dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (0+)\n * - Locale: `[locale]`\n */\nexport const nuxtRewrite = createFormatter('vite', 'nuxt');\n\n/**\n * Formatter for TanStack Router style rewrites.\n * Patterns use TanStack Router dynamic routing syntax:\n * - Slug: `$slug`\n * - Catch-all: `*`\n * - Locale: `$locale`\n */\nexport const tanstackRouterRewrite = createFormatter('vite');\n\n/**\n * Generic formatter for Vite-based projects.\n * Supports most dynamic routing syntaxes and normalizes them for the Vite proxy.\n */\nexport const viteRewrite = createFormatter('vite');\n"],"mappings":";;;AAOA,MAAM,cACJ,OACA,eACkB,EAClB,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,SAAS;CAC9B,WAAW,OAAO,YAChB,OAAO,QAAQ,SAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,OAAO,IAAI,OACjC,CAAC,CACH;AACF,EAAE,EACJ;AAEA,MAAM,aAAa,YACjB,QAAQ,WAAW,GAAG,IAAI,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;CAEjB,IAAI,cAAc,UAAU;EAC1B,aAAa,WACV,QAAQ,2BAA2B,MAAM,CAAC,CAC1C,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,iBAAiB,KAAK;CACnC,OAAO,IAAI,cAAc,aAAa;EACpC,aAAa,WACV,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,qBAAqB,MAAM,CAAC,CACpC,QAAQ,iBAAiB,KAAK;CACnC,OAAO,IAAI,cAAc,QAAQ;EAC/B,aAAa,WACV,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,iBAAiB,KAAK;CACnC,OAAO;EAEL,aAAa,WACV,QAAQ,cAAc,KAAK,CAAC,CAC5B,QAAQ,cAAc,MAAM,CAAC,CAC7B,QAAQ,eAAe,MAAM,CAAC,CAC9B,QAAQ,OAAO,QAAQ;CAC5B;CAEA,OAAO;AACT;;;;AAKA,MAAM,eAAe,YACnB,QACG,QAAQ,wCAAwC,GAAG,CAAC,CACpD,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,OAAO,EAAE,KAAK;;;;AAK3B,MAAM,mBACH,UAA6B,eAE5B,UACkB;CAClB,MAAM,aAAa,YAAoB,iBAAiB,SAAS,SAAS;CAC1E,MAAM,SAAS,YAAoB,YAAY,UAAU,OAAO,CAAC;CAEjE,OAAO;EACL,KAAK,WAAW,QAAe,YAAY,UAAU,MAAM,OAAO,CAAC,CAAC;GACnE,WAAW,WAAW,QAAe,YACpC,UAAU,UAAU,OAAO,CAAC,CAC9B;CACF;AACF;;;;;;;;;AAUF,MAAa,gBAAgB,gBAAgB,UAAU,QAAQ;;;;;;;;AAS/D,MAAa,mBAAmB,gBAAgB,QAAQ,WAAW;;;;;;;;;AAUnE,MAAa,qBAAqB,gBAAgB,MAAM;;;;;;;;;AAUxD,MAAa,mBAAmB,gBAAgB,MAAM;;;;;;;;AAStD,MAAa,qBAAqB,gBAAgB,MAAM;;;;;;;;AASxD,MAAa,cAAc,gBAAgB,QAAQ,MAAM;;;;;;;;AASzD,MAAa,wBAAwB,gBAAgB,MAAM;;;;;AAM3D,MAAa,cAAc,gBAAgB,MAAM"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/routing/index.ts"],"sourcesContent":["import type {\n RewriteObject,\n RewriteRule,\n RewriteRules,\n} from '@intlayer/types/config';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\n\nconst buildRules = (\n rules: Record<string, StrictModeLocaleMap<string>>,\n processor: (pattern: string) => string\n): RewriteRules => ({\n rules: Object.entries(rules).map(([canonical, localized]) => ({\n canonical: processor(canonical),\n localized: Object.fromEntries(\n Object.entries(localized).map(([locale, pattern]) => [\n locale,\n pattern ? processor(pattern) : pattern,\n ])\n ) as StrictModeLocaleMap<string>,\n })) as RewriteRule[],\n});\n\nconst cleanPath = (pattern: string) =>\n pattern.startsWith('/') ? pattern : `/${pattern}`;\n\n/**\n * Standardizes pattern to :param syntax.\n * Supports:\n * - Next.js/SvelteKit/Nuxt: [slug], [...slug], [[slug]]\n * - TanStack Router: $slug\n * - Solid Router: *slug\n * - React/Vue Router: :slug, *\n */\nconst normalizePattern = (pattern: string, framework?: string) => {\n let normalized = pattern;\n\n if (framework === 'nextjs') {\n normalized = normalized\n .replace(/\\[\\[\\.\\.\\.([^\\]]+)\\]\\]/g, ':$1*') // [[...slug]] -> :slug* (0+)\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1+') // [...slug] -> :slug+ (1+)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else if (framework === 'sveltekit') {\n normalized = normalized\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1*') // [...path] -> :path* (0+)\n .replace(/\\[\\[([^\\]]+)\\]\\]/g, ':$1?') // [[optional]] -> :optional? (0-1)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else if (framework === 'nuxt') {\n normalized = normalized\n .replace(/\\[\\.\\.\\.([^\\]]+)\\]/g, ':$1*') // [...slug] -> :slug* (0+)\n .replace(/\\[([^\\]]+)\\]/g, ':$1'); // [slug] -> :slug (1)\n } else {\n // Default / Generic (React Router, Vue Router, Solid Router, TanStack Router)\n normalized = normalized\n .replace(/\\$([^/]+)/g, ':$1') // TanStack $slug -> :slug\n .replace(/\\*([^/]+)/g, ':$1*') // Solid *slug -> :slug*\n .replace(/:([^/]+)\\?/g, ':$1?') // Vue Router/React Router :slug? -> :slug?\n .replace(/\\*/g, ':path*'); // React Router * -> :path*\n }\n\n return normalized;\n};\n\n/**\n * Removes locale markers from the pattern.\n */\nconst stripLocale = (pattern: string) =>\n pattern\n .replace(/\\/?(:locale|\\[locale\\]|\\$locale)\\/?/g, '/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '') || '/';\n\n/**\n * Factory to create formatters that populate 'url' and a specific proxy key.\n */\nconst createFormatter =\n (proxyKey: 'nextjs' | 'vite', framework?: string) =>\n <T extends string = string>(\n rules: Record<T, Partial<StrictModeLocaleMap<string>>>\n ): RewriteObject => {\n const normalize = (pattern: string) => normalizePattern(pattern, framework);\n const strip = (pattern: string) => stripLocale(normalize(pattern));\n\n return {\n url: buildRules(rules as any, (pattern) => cleanPath(strip(pattern))),\n [proxyKey]: buildRules(rules as any, (pattern) =>\n cleanPath(normalize(pattern))\n ),\n } as RewriteObject;\n };\n\n/**\n * Formatter for Next.js style rewrites.\n * Patterns use Next.js dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (1+)\n * - Optional catch-all: `[[...slug]]` (0+)\n * - Locale: `[locale]`\n */\nexport const nextjsRewrite = createFormatter('nextjs', 'nextjs');\n\n/**\n * Formatter for SvelteKit style rewrites.\n * Patterns use SvelteKit dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (0+)\n * - Locale: `[locale]`\n */\nexport const svelteKitRewrite = createFormatter('vite', 'sveltekit');\n\n/**\n * Formatter for React Router style rewrites.\n * Patterns use React Router dynamic routing syntax:\n * - Slug: `:slug`\n * - Optional slug: `:slug?`\n * - Catch-all: `*`\n * - Locale: `:locale`\n */\nexport const reactRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Vue style rewrites.\n * Patterns use Vue Router 4 dynamic routing syntax:\n * - Slug: `:slug`\n * - Optional slug: `:slug?`\n * - Catch-all: `:slug*` or `:slug+`\n * - Locale: `:locale`\n */\nexport const vueRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Solid Router style rewrites.\n * Patterns use Solid Router dynamic routing syntax:\n * - Slug: `:slug`\n * - Catch-all: `*slug`\n * - Locale: `:locale`\n */\nexport const solidRouterRewrite = createFormatter('vite');\n\n/**\n * Formatter for Nuxt style rewrites.\n * Patterns use Nuxt 3 dynamic routing syntax:\n * - Slug: `[slug]`\n * - Catch-all: `[...slug]` (0+)\n * - Locale: `[locale]`\n */\nexport const nuxtRewrite = createFormatter('vite', 'nuxt');\n\n/**\n * Formatter for TanStack Router style rewrites.\n * Patterns use TanStack Router dynamic routing syntax:\n * - Slug: `$slug`\n * - Catch-all: `*`\n * - Locale: `$locale`\n */\nexport const tanstackRouterRewrite = createFormatter('vite');\n\n/**\n * Generic formatter for Vite-based projects.\n * Supports most dynamic routing syntaxes and normalizes them for the Vite proxy.\n */\nexport const viteRewrite = createFormatter('vite');\n"],"mappings":";;AAOA,MAAM,cACJ,OACA,eACkB,EAClB,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,SAAS;CAC9B,WAAW,OAAO,YAChB,OAAO,QAAQ,SAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,OAAO,IAAI,OACjC,CAAC,CACH;AACF,EAAE,EACJ;AAEA,MAAM,aAAa,YACjB,QAAQ,WAAW,GAAG,IAAI,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;CAEjB,IAAI,cAAc,UAAU;EAC1B,aAAa,WACV,QAAQ,2BAA2B,MAAM,CAAC,CAC1C,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,iBAAiB,KAAK;CACnC,OAAO,IAAI,cAAc,aAAa;EACpC,aAAa,WACV,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,qBAAqB,MAAM,CAAC,CACpC,QAAQ,iBAAiB,KAAK;CACnC,OAAO,IAAI,cAAc,QAAQ;EAC/B,aAAa,WACV,QAAQ,uBAAuB,MAAM,CAAC,CACtC,QAAQ,iBAAiB,KAAK;CACnC,OAAO;EAEL,aAAa,WACV,QAAQ,cAAc,KAAK,CAAC,CAC5B,QAAQ,cAAc,MAAM,CAAC,CAC7B,QAAQ,eAAe,MAAM,CAAC,CAC9B,QAAQ,OAAO,QAAQ;CAC5B;CAEA,OAAO;AACT;;;;AAKA,MAAM,eAAe,YACnB,QACG,QAAQ,wCAAwC,GAAG,CAAC,CACpD,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,OAAO,EAAE,KAAK;;;;AAK3B,MAAM,mBACH,UAA6B,eAE5B,UACkB;CAClB,MAAM,aAAa,YAAoB,iBAAiB,SAAS,SAAS;CAC1E,MAAM,SAAS,YAAoB,YAAY,UAAU,OAAO,CAAC;CAEjE,OAAO;EACL,KAAK,WAAW,QAAe,YAAY,UAAU,MAAM,OAAO,CAAC,CAAC;GACnE,WAAW,WAAW,QAAe,YACpC,UAAU,UAAU,OAAO,CAAC,CAC9B;CACF;AACF;;;;;;;;;AAUF,MAAa,gBAAgB,gBAAgB,UAAU,QAAQ;;;;;;;;AAS/D,MAAa,mBAAmB,gBAAgB,QAAQ,WAAW;;;;;;;;;AAUnE,MAAa,qBAAqB,gBAAgB,MAAM;;;;;;;;;AAUxD,MAAa,mBAAmB,gBAAgB,MAAM;;;;;;;;AAStD,MAAa,qBAAqB,gBAAgB,MAAM;;;;;;;;AASxD,MAAa,cAAc,gBAAgB,QAAQ,MAAM;;;;;;;;AASzD,MAAa,wBAAwB,gBAAgB,MAAM;;;;;AAM3D,MAAa,cAAc,gBAAgB,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intlayer",
3
- "version": "9.2.0",
3
+ "version": "9.3.1",
4
4
  "private": false,
5
5
  "description": "Manage internationalization i18n in a simple way, through TypeScript, declaration file, declare your multilingual content every where in your code.",
6
6
  "keywords": [
@@ -95,13 +95,13 @@
95
95
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
96
96
  },
97
97
  "dependencies": {
98
- "@intlayer/cli": "9.2.0",
99
- "@intlayer/config": "9.2.0",
100
- "@intlayer/core": "9.2.0",
101
- "@intlayer/types": "9.2.0"
98
+ "@intlayer/cli": "9.3.1",
99
+ "@intlayer/config": "9.3.1",
100
+ "@intlayer/core": "9.3.1",
101
+ "@intlayer/types": "9.3.1"
102
102
  },
103
103
  "devDependencies": {
104
- "@types/node": "26.1.2",
104
+ "@types/node": "26.2.0",
105
105
  "@utils/ts-config": "1.0.4",
106
106
  "@utils/ts-config-types": "1.0.4",
107
107
  "@utils/tsdown-config": "1.0.4",