intlayer 8.6.8 → 8.6.9
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/cli/script.cjs +1 -1
- package/dist/cjs/index.cjs +30 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/routing/index.cjs +9 -4
- package/dist/cjs/routing/index.cjs.map +1 -1
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/routing/index.mjs +9 -4
- package/dist/esm/routing/index.mjs.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -8
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -29
package/dist/cjs/cli/script.cjs
CHANGED
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
3
29
|
let _intlayer_types_allLocales = require("@intlayer/types/allLocales");
|
|
4
30
|
let _intlayer_types_locales = require("@intlayer/types/locales");
|
|
5
|
-
_intlayer_types_locales =
|
|
31
|
+
_intlayer_types_locales = __toESM(_intlayer_types_locales);
|
|
6
32
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
_intlayer_config_built =
|
|
33
|
+
_intlayer_config_built = __toESM(_intlayer_config_built);
|
|
8
34
|
let _intlayer_core_file = require("@intlayer/core/file");
|
|
9
35
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
10
36
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
@@ -66,6 +92,7 @@ Object.defineProperty(exports, 'Locales', {
|
|
|
66
92
|
return _intlayer_types_locales;
|
|
67
93
|
}
|
|
68
94
|
});
|
|
95
|
+
exports.__toESM = __toESM;
|
|
69
96
|
Object.defineProperty(exports, 'compact', {
|
|
70
97
|
enumerable: true,
|
|
71
98
|
get: function () {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["configuration"],"sources":["../../src/index.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noEmptyInterface: Intlayer module augmentation registries */\n\nimport type { CustomIntlayerConfig as IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary as DictionaryCore } from '@intlayer/types/dictionary';\nimport type { SchemaKeys } from '@intlayer/types/module_augmentation';\n\n/**\n * The dictionary type used to define the structure of a dictionary.\n * It is used to provide type safety and autocompletion when defining a dictionary.\n *\n * @example\n * ```ts\n * import { Dictionary } from 'intlayer';\n *\n * const dictionary: Dictionary = { ... };\n * ```\n */\ntype Dictionary<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = DictionaryCore<T, SchemaKey, true>;\n\n/**\n * The content of a dictionary.\n *\n * @deprecated Use `Dictionary<T>` instead.\n */\ntype DeclarationContent<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = Dictionary<T, SchemaKey>;\n\nexport { ALL_LOCALES, type Locale } from '@intlayer/types/allLocales';\nexport type { ContentNode } from '@intlayer/types/dictionary';\nexport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["configuration"],"sources":["../../src/index.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noEmptyInterface: Intlayer module augmentation registries */\n\nimport type { CustomIntlayerConfig as IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary as DictionaryCore } from '@intlayer/types/dictionary';\nimport type { SchemaKeys } from '@intlayer/types/module_augmentation';\n\n/**\n * The dictionary type used to define the structure of a dictionary.\n * It is used to provide type safety and autocompletion when defining a dictionary.\n *\n * @example\n * ```ts\n * import { Dictionary } from 'intlayer';\n *\n * const dictionary: Dictionary = { ... };\n * ```\n */\ntype Dictionary<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = DictionaryCore<T, SchemaKey, true>;\n\n/**\n * The content of a dictionary.\n *\n * @deprecated Use `Dictionary<T>` instead.\n */\ntype DeclarationContent<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = Dictionary<T, SchemaKey>;\n\nexport { ALL_LOCALES, type Locale } from '@intlayer/types/allLocales';\nexport type { ContentNode } from '@intlayer/types/dictionary';\nexport * as Locales from '@intlayer/types/locales';\nexport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type { DeclarationContent, Dictionary, IntlayerConfig };\n\nimport { default as configuration } from '@intlayer/config/built';\n\n/**\n * Returns the configuration of Intlayer.\n */\nconst getConfiguration = () => configuration;\n\n/**\n * The locales defined in the configuration.\n */\nconst locales = configuration.internationalization.locales;\n\n/**\n * The required locales defined in the configuration.\n */\nconst requiredLocales = configuration.internationalization.requiredLocales;\n\n/**\n * The default locale defined in the configuration.\n */\nconst defaultLocale = configuration.internationalization.defaultLocale;\n\n/**\n * The editor configuration defined in the configuration.\n */\nconst editor = configuration.editor;\n\nexport { file } from '@intlayer/core/file'; // Include specific export for browser because of node js function that can't be used in browser\nexport {\n compact,\n currency,\n date,\n Intl,\n number,\n percentage,\n relativeTime,\n units,\n} from '@intlayer/core/formatters';\nexport {\n getDictionary,\n getEnumeration,\n /**\n * @deprecated Use `getEnumeration` instead.\n */\n getEnumeration as getEnumerationContent,\n getIntlayer,\n getNesting,\n getTranslation,\n /**\n * @deprecated Use `getTranslation` instead.\n */\n getTranslation as getTranslationContent,\n} from '@intlayer/core/interpreter';\nexport type {\n GenerateSitemapOptions,\n SitemapUrlEntry,\n} from '@intlayer/core/localization';\nexport {\n generateSitemap,\n generateSitemapUrl,\n getBrowserLocale,\n getCanonicalPath,\n getHTMLTextDir,\n getLocale,\n getLocaleFromPath,\n getLocaleLang,\n getLocaleName,\n getLocalizedPath,\n getLocalizedUrl,\n getMultilingualUrls,\n getPathWithoutLocale,\n getPrefix,\n getRewriteRules,\n localeDetector,\n localeFlatMap,\n localeMap,\n localeRecord,\n localeResolver,\n validatePrefix,\n} from '@intlayer/core/localization';\nexport { getMarkdownMetadata } from '@intlayer/core/markdown';\nexport {\n cond,\n enu,\n gender,\n html,\n insert,\n md,\n nest,\n t,\n} from '@intlayer/core/transpiler';\nexport {\n getCookie,\n /**\n * @deprecated Use `getLocaleFromStorageClient` or `getLocaleFromStorageServer` instead.\n */\n getLocaleFromStorage,\n getLocaleFromStorageClient,\n getLocaleFromStorageServer,\n LocaleStorageClient,\n LocaleStorageServer,\n /**\n * @deprecated Use `setLocaleInStorageClient` or `setLocaleInStorageServer` instead.\n */\n setLocaleInStorage,\n setLocaleInStorageClient,\n setLocaleInStorageServer,\n} from '@intlayer/core/utils';\n// Reexport here for CJS compatibility\n// Fix ReferenceError: Cannot access 'xxx' before initialization\nexport {\n configuration,\n defaultLocale,\n editor,\n getConfiguration,\n locales,\n requiredLocales,\n};\n\n// --- Registries to be augmented by the generator ---\nexport interface __DictionaryRegistry {} // id -> interfaceof ictionary\nexport interface __DeclaredLocalesRegistry {} // 'fr': 1, 'en': 1, ...\nexport interface __RequiredLocalesRegistry {} // 'en': 1, ...\nexport interface __SchemaRegistry {} // id -> interface of schema\nexport interface __StrictModeRegistry {} // one of: { strict: true } | { inclusive: true } | { loose: true }\nexport interface __EditorRegistry {} // one of: { enabled: true } | { enabled: false }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,yBAAyBA;;;;AAK/B,MAAM,UAAUA,+BAAc,qBAAqB;;;;AAKnD,MAAM,kBAAkBA,+BAAc,qBAAqB;;;;AAK3D,MAAM,gBAAgBA,+BAAc,qBAAqB;;;;AAKzD,MAAM,SAASA,+BAAc"}
|
|
@@ -16,10 +16,15 @@ const cleanPath = (pattern) => pattern.startsWith("/") ? pattern : `/${pattern}`
|
|
|
16
16
|
*/
|
|
17
17
|
const normalizePattern = (pattern, framework) => {
|
|
18
18
|
let normalized = pattern;
|
|
19
|
-
if (framework === "nextjs")
|
|
20
|
-
|
|
21
|
-
else if (framework === "
|
|
22
|
-
|
|
19
|
+
if (framework === "nextjs") {
|
|
20
|
+
normalized = normalized.replace(/\[\[\.\.\.([^\]]+)\]\]/g, ":$1*").replace(/\[\.\.\.([^\]]+)\]/g, ":$1+").replace(/\[([^\]]+)\]/g, ":$1");
|
|
21
|
+
} else if (framework === "sveltekit") {
|
|
22
|
+
normalized = normalized.replace(/\[\.\.\.([^\]]+)\]/g, ":$1*").replace(/\[\[([^\]]+)\]\]/g, ":$1?").replace(/\[([^\]]+)\]/g, ":$1");
|
|
23
|
+
} else if (framework === "nuxt") {
|
|
24
|
+
normalized = normalized.replace(/\[\.\.\.([^\]]+)\]/g, ":$1*").replace(/\[([^\]]+)\]/g, ":$1");
|
|
25
|
+
} else {
|
|
26
|
+
normalized = normalized.replace(/\$([^/]+)/g, ":$1").replace(/\*([^/]+)/g, ":$1*").replace(/:([^/]+)\?/g, ":$1?").replace(/\*/g, ":path*");
|
|
27
|
+
}
|
|
23
28
|
return normalized;
|
|
24
29
|
};
|
|
25
30
|
/**
|
|
@@ -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,MAAM,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,UAAU;CAC/B,WAAW,OAAO,YAChB,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,QAAQ,GAAG,QAChC,CAAC,CACH;CACF,EAAE,EACJ;AAED,MAAM,aAAa,YACjB,QAAQ,WAAW,IAAI,GAAG,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;AAEjB,KAAI,cAAc,
|
|
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,MAAM,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,UAAU;CAC/B,WAAW,OAAO,YAChB,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,QAAQ,GAAG,QAChC,CAAC,CACH;CACF,EAAE,EACJ;AAED,MAAM,aAAa,YACjB,QAAQ,WAAW,IAAI,GAAG,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;AAEjB,KAAI,cAAc,UAAU;AAC1B,eAAa,WACV,QAAQ,2BAA2B,OAAO,CAC1C,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,iBAAiB,MAAM;YACzB,cAAc,aAAa;AACpC,eAAa,WACV,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,qBAAqB,OAAO,CACpC,QAAQ,iBAAiB,MAAM;YACzB,cAAc,QAAQ;AAC/B,eAAa,WACV,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,iBAAiB,MAAM;QAC7B;AAEL,eAAa,WACV,QAAQ,cAAc,MAAM,CAC5B,QAAQ,cAAc,OAAO,CAC7B,QAAQ,eAAe,OAAO,CAC9B,QAAQ,OAAO,SAAS;;AAG7B,QAAO;;;;;AAMT,MAAM,eAAe,YACnB,QACG,QAAQ,wCAAwC,IAAI,CACpD,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,GAAG,IAAI;;;;AAK3B,MAAM,mBACH,UAA6B,eAE5B,UACkB;CAClB,MAAM,aAAa,YAAoB,iBAAiB,SAAS,UAAU;CAC3E,MAAM,SAAS,YAAoB,YAAY,UAAU,QAAQ,CAAC;AAElE,QAAO;EACL,KAAK,WAAW,QAAe,YAAY,UAAU,MAAM,QAAQ,CAAC,CAAC;GACpE,WAAW,WAAW,QAAe,YACpC,UAAU,UAAU,QAAQ,CAAC,CAC9B;EACF;;;;;;;;;;AAWL,MAAa,gBAAgB,gBAAgB,UAAU,SAAS;;;;;;;;AAShE,MAAa,mBAAmB,gBAAgB,QAAQ,YAAY;;;;;;;;;AAUpE,MAAa,qBAAqB,gBAAgB,OAAO;;;;;;;;;AAUzD,MAAa,mBAAmB,gBAAgB,OAAO;;;;;;;;AASvD,MAAa,qBAAqB,gBAAgB,OAAO;;;;;;;;AASzD,MAAa,cAAc,gBAAgB,QAAQ,OAAO;;;;;;;;AAS1D,MAAa,wBAAwB,gBAAgB,OAAO;;;;;AAM5D,MAAa,cAAc,gBAAgB,OAAO"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ALL_LOCALES } from "@intlayer/types/allLocales";
|
|
2
|
-
import * as Locales from "@intlayer/types/locales";
|
|
3
1
|
import configuration from "@intlayer/config/built";
|
|
4
2
|
import { file } from "@intlayer/core/file";
|
|
5
3
|
import { Intl, compact, currency, date, number, percentage, relativeTime, units } from "@intlayer/core/formatters";
|
|
@@ -32,5 +30,8 @@ const defaultLocale = configuration.internationalization.defaultLocale;
|
|
|
32
30
|
const editor = configuration.editor;
|
|
33
31
|
|
|
34
32
|
//#endregion
|
|
35
|
-
export {
|
|
33
|
+
export { Intl, LocaleStorageClient, LocaleStorageServer, compact, cond, configuration, currency, date, defaultLocale, editor, enu, file, gender, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getConfiguration, getCookie, getDictionary, getEnumeration, getEnumerationContent, getHTMLTextDir, getIntlayer, getLocale, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMultilingualUrls, getNesting, getPathWithoutLocale, getPrefix, getRewriteRules, getTranslation, getTranslationContent, html, insert, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, locales, md, nest, number, percentage, relativeTime, requiredLocales, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, t, units, validatePrefix };
|
|
34
|
+
export { ALL_LOCALES } from "@intlayer/types/allLocales";
|
|
35
|
+
export * as Locales from "@intlayer/types/locales";
|
|
36
|
+
|
|
36
37
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noEmptyInterface: Intlayer module augmentation registries */\n\nimport type { CustomIntlayerConfig as IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary as DictionaryCore } from '@intlayer/types/dictionary';\nimport type { SchemaKeys } from '@intlayer/types/module_augmentation';\n\n/**\n * The dictionary type used to define the structure of a dictionary.\n * It is used to provide type safety and autocompletion when defining a dictionary.\n *\n * @example\n * ```ts\n * import { Dictionary } from 'intlayer';\n *\n * const dictionary: Dictionary = { ... };\n * ```\n */\ntype Dictionary<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = DictionaryCore<T, SchemaKey, true>;\n\n/**\n * The content of a dictionary.\n *\n * @deprecated Use `Dictionary<T>` instead.\n */\ntype DeclarationContent<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = Dictionary<T, SchemaKey>;\n\nexport { ALL_LOCALES, type Locale } from '@intlayer/types/allLocales';\nexport type { ContentNode } from '@intlayer/types/dictionary';\nexport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noEmptyInterface: Intlayer module augmentation registries */\n\nimport type { CustomIntlayerConfig as IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary as DictionaryCore } from '@intlayer/types/dictionary';\nimport type { SchemaKeys } from '@intlayer/types/module_augmentation';\n\n/**\n * The dictionary type used to define the structure of a dictionary.\n * It is used to provide type safety and autocompletion when defining a dictionary.\n *\n * @example\n * ```ts\n * import { Dictionary } from 'intlayer';\n *\n * const dictionary: Dictionary = { ... };\n * ```\n */\ntype Dictionary<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = DictionaryCore<T, SchemaKey, true>;\n\n/**\n * The content of a dictionary.\n *\n * @deprecated Use `Dictionary<T>` instead.\n */\ntype DeclarationContent<\n T = undefined,\n SchemaKey extends SchemaKeys | undefined = undefined,\n> = Dictionary<T, SchemaKey>;\n\nexport { ALL_LOCALES, type Locale } from '@intlayer/types/allLocales';\nexport type { ContentNode } from '@intlayer/types/dictionary';\nexport * as Locales from '@intlayer/types/locales';\nexport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\nexport type { DeclarationContent, Dictionary, IntlayerConfig };\n\nimport { default as configuration } from '@intlayer/config/built';\n\n/**\n * Returns the configuration of Intlayer.\n */\nconst getConfiguration = () => configuration;\n\n/**\n * The locales defined in the configuration.\n */\nconst locales = configuration.internationalization.locales;\n\n/**\n * The required locales defined in the configuration.\n */\nconst requiredLocales = configuration.internationalization.requiredLocales;\n\n/**\n * The default locale defined in the configuration.\n */\nconst defaultLocale = configuration.internationalization.defaultLocale;\n\n/**\n * The editor configuration defined in the configuration.\n */\nconst editor = configuration.editor;\n\nexport { file } from '@intlayer/core/file'; // Include specific export for browser because of node js function that can't be used in browser\nexport {\n compact,\n currency,\n date,\n Intl,\n number,\n percentage,\n relativeTime,\n units,\n} from '@intlayer/core/formatters';\nexport {\n getDictionary,\n getEnumeration,\n /**\n * @deprecated Use `getEnumeration` instead.\n */\n getEnumeration as getEnumerationContent,\n getIntlayer,\n getNesting,\n getTranslation,\n /**\n * @deprecated Use `getTranslation` instead.\n */\n getTranslation as getTranslationContent,\n} from '@intlayer/core/interpreter';\nexport type {\n GenerateSitemapOptions,\n SitemapUrlEntry,\n} from '@intlayer/core/localization';\nexport {\n generateSitemap,\n generateSitemapUrl,\n getBrowserLocale,\n getCanonicalPath,\n getHTMLTextDir,\n getLocale,\n getLocaleFromPath,\n getLocaleLang,\n getLocaleName,\n getLocalizedPath,\n getLocalizedUrl,\n getMultilingualUrls,\n getPathWithoutLocale,\n getPrefix,\n getRewriteRules,\n localeDetector,\n localeFlatMap,\n localeMap,\n localeRecord,\n localeResolver,\n validatePrefix,\n} from '@intlayer/core/localization';\nexport { getMarkdownMetadata } from '@intlayer/core/markdown';\nexport {\n cond,\n enu,\n gender,\n html,\n insert,\n md,\n nest,\n t,\n} from '@intlayer/core/transpiler';\nexport {\n getCookie,\n /**\n * @deprecated Use `getLocaleFromStorageClient` or `getLocaleFromStorageServer` instead.\n */\n getLocaleFromStorage,\n getLocaleFromStorageClient,\n getLocaleFromStorageServer,\n LocaleStorageClient,\n LocaleStorageServer,\n /**\n * @deprecated Use `setLocaleInStorageClient` or `setLocaleInStorageServer` instead.\n */\n setLocaleInStorage,\n setLocaleInStorageClient,\n setLocaleInStorageServer,\n} from '@intlayer/core/utils';\n// Reexport here for CJS compatibility\n// Fix ReferenceError: Cannot access 'xxx' before initialization\nexport {\n configuration,\n defaultLocale,\n editor,\n getConfiguration,\n locales,\n requiredLocales,\n};\n\n// --- Registries to be augmented by the generator ---\nexport interface __DictionaryRegistry {} // id -> interfaceof ictionary\nexport interface __DeclaredLocalesRegistry {} // 'fr': 1, 'en': 1, ...\nexport interface __RequiredLocalesRegistry {} // 'en': 1, ...\nexport interface __SchemaRegistry {} // id -> interface of schema\nexport interface __StrictModeRegistry {} // one of: { strict: true } | { inclusive: true } | { loose: true }\nexport interface __EditorRegistry {} // one of: { enabled: true } | { enabled: false }\n"],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,yBAAyB;;;;AAK/B,MAAM,UAAU,cAAc,qBAAqB;;;;AAKnD,MAAM,kBAAkB,cAAc,qBAAqB;;;;AAK3D,MAAM,gBAAgB,cAAc,qBAAqB;;;;AAKzD,MAAM,SAAS,cAAc"}
|
|
@@ -14,10 +14,15 @@ const cleanPath = (pattern) => pattern.startsWith("/") ? pattern : `/${pattern}`
|
|
|
14
14
|
*/
|
|
15
15
|
const normalizePattern = (pattern, framework) => {
|
|
16
16
|
let normalized = pattern;
|
|
17
|
-
if (framework === "nextjs")
|
|
18
|
-
|
|
19
|
-
else if (framework === "
|
|
20
|
-
|
|
17
|
+
if (framework === "nextjs") {
|
|
18
|
+
normalized = normalized.replace(/\[\[\.\.\.([^\]]+)\]\]/g, ":$1*").replace(/\[\.\.\.([^\]]+)\]/g, ":$1+").replace(/\[([^\]]+)\]/g, ":$1");
|
|
19
|
+
} else if (framework === "sveltekit") {
|
|
20
|
+
normalized = normalized.replace(/\[\.\.\.([^\]]+)\]/g, ":$1*").replace(/\[\[([^\]]+)\]\]/g, ":$1?").replace(/\[([^\]]+)\]/g, ":$1");
|
|
21
|
+
} else if (framework === "nuxt") {
|
|
22
|
+
normalized = normalized.replace(/\[\.\.\.([^\]]+)\]/g, ":$1*").replace(/\[([^\]]+)\]/g, ":$1");
|
|
23
|
+
} else {
|
|
24
|
+
normalized = normalized.replace(/\$([^/]+)/g, ":$1").replace(/\*([^/]+)/g, ":$1*").replace(/:([^/]+)\?/g, ":$1?").replace(/\*/g, ":path*");
|
|
25
|
+
}
|
|
21
26
|
return normalized;
|
|
22
27
|
};
|
|
23
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","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,MAAM,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,UAAU;CAC/B,WAAW,OAAO,YAChB,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,QAAQ,GAAG,QAChC,CAAC,CACH;CACF,EAAE,EACJ;AAED,MAAM,aAAa,YACjB,QAAQ,WAAW,IAAI,GAAG,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;AAEjB,KAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"index.mjs","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,MAAM,CAAC,KAAK,CAAC,WAAW,gBAAgB;CAC5D,WAAW,UAAU,UAAU;CAC/B,WAAW,OAAO,YAChB,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,QAAQ,aAAa,CACnD,QACA,UAAU,UAAU,QAAQ,GAAG,QAChC,CAAC,CACH;CACF,EAAE,EACJ;AAED,MAAM,aAAa,YACjB,QAAQ,WAAW,IAAI,GAAG,UAAU,IAAI;;;;;;;;;AAU1C,MAAM,oBAAoB,SAAiB,cAAuB;CAChE,IAAI,aAAa;AAEjB,KAAI,cAAc,UAAU;AAC1B,eAAa,WACV,QAAQ,2BAA2B,OAAO,CAC1C,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,iBAAiB,MAAM;YACzB,cAAc,aAAa;AACpC,eAAa,WACV,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,qBAAqB,OAAO,CACpC,QAAQ,iBAAiB,MAAM;YACzB,cAAc,QAAQ;AAC/B,eAAa,WACV,QAAQ,uBAAuB,OAAO,CACtC,QAAQ,iBAAiB,MAAM;QAC7B;AAEL,eAAa,WACV,QAAQ,cAAc,MAAM,CAC5B,QAAQ,cAAc,OAAO,CAC7B,QAAQ,eAAe,OAAO,CAC9B,QAAQ,OAAO,SAAS;;AAG7B,QAAO;;;;;AAMT,MAAM,eAAe,YACnB,QACG,QAAQ,wCAAwC,IAAI,CACpD,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,GAAG,IAAI;;;;AAK3B,MAAM,mBACH,UAA6B,eAE5B,UACkB;CAClB,MAAM,aAAa,YAAoB,iBAAiB,SAAS,UAAU;CAC3E,MAAM,SAAS,YAAoB,YAAY,UAAU,QAAQ,CAAC;AAElE,QAAO;EACL,KAAK,WAAW,QAAe,YAAY,UAAU,MAAM,QAAQ,CAAC,CAAC;GACpE,WAAW,WAAW,QAAe,YACpC,UAAU,UAAU,QAAQ,CAAC,CAC9B;EACF;;;;;;;;;;AAWL,MAAa,gBAAgB,gBAAgB,UAAU,SAAS;;;;;;;;AAShE,MAAa,mBAAmB,gBAAgB,QAAQ,YAAY;;;;;;;;;AAUpE,MAAa,qBAAqB,gBAAgB,OAAO;;;;;;;;;AAUzD,MAAa,mBAAmB,gBAAgB,OAAO;;;;;;;;AASvD,MAAa,qBAAqB,gBAAgB,OAAO;;;;;;;;AASzD,MAAa,cAAc,gBAAgB,QAAQ,OAAO;;;;;;;;AAS1D,MAAa,wBAAwB,gBAAgB,OAAO;;;;;AAM5D,MAAa,cAAc,gBAAgB,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBK,UAAA,kCAEe,UAAA,4BAChB,YAAA,CAAe,CAAA,EAAG,SAAA;;AAhBgD;;;;KAuBjE,kBAAA,kCAEe,UAAA,4BAChB,UAAA,CAAW,CAAA,EAAG,SAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBK,UAAA,kCAEe,UAAA,4BAChB,YAAA,CAAe,CAAA,EAAG,SAAA;;AAhBgD;;;;KAuBjE,kBAAA,kCAEe,UAAA,4BAChB,UAAA,CAAW,CAAA,EAAG,SAAA;;;;cAiBZ,gBAAA,QAAsC,yBAAA,CAAtB,cAAA;;;AA3BS;cAgCzB,OAAA,EAAoD,6BAAA,CAA7C,MAAA;;;;cAKP,eAAA,EAAoE,6BAAA,CAArD,MAAA;;;;cAKf,aAAA,EAAgE,6BAAA,CAAnD,MAAA;;;;cAKb,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,UA+FK,oBAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,gBAAA;AAAA,UACA,oBAAA;AAAA,UACA,gBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intlayer",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.9",
|
|
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": [
|
|
@@ -62,9 +62,6 @@
|
|
|
62
62
|
"cli": [
|
|
63
63
|
"./dist/types/cli/index.d.ts"
|
|
64
64
|
],
|
|
65
|
-
"cli/*": [
|
|
66
|
-
"./dist/types/cli/*"
|
|
67
|
-
],
|
|
68
65
|
"routing": [
|
|
69
66
|
"./dist/types/routing/index.d.ts"
|
|
70
67
|
],
|
|
@@ -98,10 +95,10 @@
|
|
|
98
95
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
99
96
|
},
|
|
100
97
|
"dependencies": {
|
|
101
|
-
"@intlayer/cli": "8.6.
|
|
102
|
-
"@intlayer/config": "8.6.
|
|
103
|
-
"@intlayer/core": "8.6.
|
|
104
|
-
"@intlayer/types": "8.6.
|
|
98
|
+
"@intlayer/cli": "8.6.9",
|
|
99
|
+
"@intlayer/config": "8.6.9",
|
|
100
|
+
"@intlayer/core": "8.6.9",
|
|
101
|
+
"@intlayer/types": "8.6.9"
|
|
105
102
|
},
|
|
106
103
|
"devDependencies": {
|
|
107
104
|
"@types/node": "25.5.2",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|