svelte-intlayer 5.5.4 → 5.5.6

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.
Files changed (97) hide show
  1. package/dist/cjs/client/getBrowserLocale.cjs +39 -0
  2. package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
  3. package/dist/cjs/client/index.cjs +52 -0
  4. package/dist/cjs/client/index.cjs.map +1 -0
  5. package/dist/cjs/client/intlayerContext.cjs +38 -0
  6. package/dist/cjs/client/intlayerContext.cjs.map +1 -0
  7. package/dist/cjs/client/intlayerStore.cjs +42 -0
  8. package/dist/cjs/client/intlayerStore.cjs.map +1 -0
  9. package/dist/cjs/client/useDictionary.cjs +39 -0
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +57 -0
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
  13. package/dist/cjs/client/useIntlayer.cjs +39 -0
  14. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  15. package/dist/cjs/client/useIntlayerAsync.cjs +63 -0
  16. package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -0
  17. package/dist/cjs/client/useLocale.cjs +47 -0
  18. package/dist/cjs/client/useLocale.cjs.map +1 -0
  19. package/dist/cjs/getDictionary.cjs +43 -0
  20. package/dist/cjs/getDictionary.cjs.map +1 -0
  21. package/dist/cjs/getIntlayer.cjs +39 -0
  22. package/dist/cjs/getIntlayer.cjs.map +1 -0
  23. package/dist/cjs/index.cjs +10 -4
  24. package/dist/cjs/index.cjs.map +1 -1
  25. package/dist/cjs/markdown/index.cjs +39 -0
  26. package/dist/cjs/markdown/index.cjs.map +1 -0
  27. package/dist/cjs/plugins.cjs +53 -0
  28. package/dist/cjs/plugins.cjs.map +1 -0
  29. package/dist/esm/client/getBrowserLocale.mjs +15 -0
  30. package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
  31. package/dist/esm/client/index.mjs +20 -0
  32. package/dist/esm/client/index.mjs.map +1 -0
  33. package/dist/esm/client/intlayerContext.mjs +13 -0
  34. package/dist/esm/client/intlayerContext.mjs.map +1 -0
  35. package/dist/esm/client/intlayerStore.mjs +18 -0
  36. package/dist/esm/client/intlayerStore.mjs.map +1 -0
  37. package/dist/esm/client/useDictionary.mjs +15 -0
  38. package/dist/esm/client/useDictionary.mjs.map +1 -0
  39. package/dist/esm/client/useDictionaryDynamic.mjs +33 -0
  40. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
  41. package/dist/esm/client/useIntlayer.mjs +15 -0
  42. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  43. package/dist/esm/client/useIntlayerAsync.mjs +29 -0
  44. package/dist/esm/client/useIntlayerAsync.mjs.map +1 -0
  45. package/dist/esm/client/useLocale.mjs +23 -0
  46. package/dist/esm/client/useLocale.mjs.map +1 -0
  47. package/dist/esm/getDictionary.mjs +25 -0
  48. package/dist/esm/getDictionary.mjs.map +1 -0
  49. package/dist/esm/getIntlayer.mjs +21 -0
  50. package/dist/esm/getIntlayer.mjs.map +1 -0
  51. package/dist/esm/index.mjs +5 -2
  52. package/dist/esm/index.mjs.map +1 -1
  53. package/dist/esm/markdown/index.mjs +14 -0
  54. package/dist/esm/markdown/index.mjs.map +1 -0
  55. package/dist/esm/plugins.mjs +27 -0
  56. package/dist/esm/plugins.mjs.map +1 -0
  57. package/dist/types/client/getBrowserLocale.d.ts +7 -0
  58. package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
  59. package/dist/types/client/index.d.ts +10 -0
  60. package/dist/types/client/index.d.ts.map +1 -0
  61. package/dist/types/client/intlayerContext.d.ts +8 -0
  62. package/dist/types/client/intlayerContext.d.ts.map +1 -0
  63. package/dist/types/client/intlayerStore.d.ts +12 -0
  64. package/dist/types/client/intlayerStore.d.ts.map +1 -0
  65. package/dist/types/client/useDictionary.d.ts +12 -0
  66. package/dist/types/client/useDictionary.d.ts.map +1 -0
  67. package/dist/types/client/useDictionaryDynamic.d.ts +12 -0
  68. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  69. package/dist/types/client/useIntlayer.d.ts +13 -0
  70. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  71. package/dist/types/client/useIntlayerAsync.d.ts +13 -0
  72. package/dist/types/client/useIntlayerAsync.d.ts.map +1 -0
  73. package/dist/types/client/useLocale.d.ts +9 -0
  74. package/dist/types/client/useLocale.d.ts.map +1 -0
  75. package/dist/types/getDictionary.d.ts +12 -0
  76. package/dist/types/getDictionary.d.ts.map +1 -0
  77. package/dist/types/getIntlayer.d.ts +12 -0
  78. package/dist/types/getIntlayer.d.ts.map +1 -0
  79. package/dist/types/index.d.ts +10 -2
  80. package/dist/types/index.d.ts.map +1 -1
  81. package/dist/types/markdown/index.d.ts +28 -0
  82. package/dist/types/markdown/index.d.ts.map +1 -0
  83. package/dist/types/plugins.d.ts +32 -0
  84. package/dist/types/plugins.d.ts.map +1 -0
  85. package/package.json +12 -9
  86. package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
  87. package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
  88. package/dist/cjs/intlayerPlugin.cjs +0 -76
  89. package/dist/cjs/intlayerPlugin.cjs.map +0 -1
  90. package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
  91. package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
  92. package/dist/esm/intlayerPlugin.mjs +0 -52
  93. package/dist/esm/intlayerPlugin.mjs.map +0 -1
  94. package/dist/types/intlayerMiddlewarePlugin.d.ts +0 -6
  95. package/dist/types/intlayerMiddlewarePlugin.d.ts.map +0 -1
  96. package/dist/types/intlayerPlugin.d.ts +0 -16
  97. package/dist/types/intlayerPlugin.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/getDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,UAAU,EACV,OAAO,EAER,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EAIrB,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,GAAG,OAAO,EAEjC,YAAY,CAAC,EACb,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAajB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { DictionaryKeys, Plugins } from '@intlayer/core';
2
+ import type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';
3
+ import { DeepTransformContent } from './plugins';
4
+ /**
5
+ * Get dictionary content by key for Svelte applications
6
+ * @param key The dictionary key to retrieve
7
+ * @param locale The target locale (optional)
8
+ * @param additionalPlugins Additional transformation plugins
9
+ * @returns Transformed dictionary content optimized for Svelte
10
+ */
11
+ export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
12
+ //# sourceMappingURL=getIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAEd,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,gCAAgC,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EACL,oBAAoB,EAIrB,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,EAC3E,KAAK,CAAC,EACN,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAS0B,oBAAoB,CACzE,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
@@ -1,3 +1,11 @@
1
- export * from './intlayerPlugin';
2
- export * from './intlayerMiddlewarePlugin';
1
+ import { IInterpreterPluginSvelte } from './plugins';
2
+ declare module '@intlayer/core' {
3
+ interface IInterpreterPlugin<T, S> extends IInterpreterPluginSvelte<T> {
4
+ }
5
+ }
6
+ export * from './client';
7
+ export * from './getDictionary';
8
+ export * from './getIntlayer';
9
+ export * from './markdown';
10
+ export * from './plugins';
3
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;KAAG;CAC1E;AAED,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Markdown support for Svelte Intlayer
3
+ * This module provides markdown rendering capabilities for Svelte applications
4
+ */
5
+ export interface MarkdownProps {
6
+ children: string;
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * Basic markdown processor for Svelte
11
+ * This can be extended to use more sophisticated markdown libraries
12
+ * @param content Markdown content to process
13
+ * @returns Processed content (for now, returns as-is)
14
+ */
15
+ export declare const processMarkdown: (content: string) => string;
16
+ /**
17
+ * Markdown renderer component interface for Svelte
18
+ * This defines the expected interface for a markdown component
19
+ */
20
+ export interface MarkdownRenderer {
21
+ render: (content: string) => string;
22
+ configure?: (options: any) => void;
23
+ }
24
+ /**
25
+ * Default markdown renderer implementation
26
+ */
27
+ export declare const defaultMarkdownRenderer: MarkdownRenderer;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAIjD,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAMrC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Plugins } from '@intlayer/core';
2
+ /**
3
+ * Interface for Svelte-specific plugin functionality
4
+ * This interface can be augmented to add more Svelte-specific transformations
5
+ */
6
+ export interface IInterpreterPluginSvelte<T> {
7
+ /** Any Svelte-specific properties can be added here */
8
+ svelteRendered?: T;
9
+ }
10
+ /**
11
+ * Type that represents the deep transformation of content for Svelte
12
+ * This applies Svelte-specific transformations recursively to all content
13
+ */
14
+ export type DeepTransformContent<T> = T extends object ? {
15
+ [K in keyof T]: DeepTransformContent<T[K]>;
16
+ } & IInterpreterPluginSvelte<T> : T;
17
+ /**
18
+ * Svelte-specific node plugins for handling basic content types
19
+ * These plugins handle strings, numbers, and bigints in Svelte applications
20
+ */
21
+ export declare const svelteNodePlugins: Plugins;
22
+ /**
23
+ * Basic Intlayer node plugins for content handling
24
+ * These handle the core content transformation logic
25
+ */
26
+ export declare const intlayerNodePlugins: Plugins;
27
+ /**
28
+ * Markdown plugin for handling markdown content in Svelte
29
+ * This can be extended to integrate with Svelte markdown processors
30
+ */
31
+ export declare const markdownPlugin: Plugins;
32
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,uDAAuD;IACvD,cAAc,CAAC,EAAE,CAAC,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAClD;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,GAAG,wBAAwB,CAAC,CAAC,CAAC,GAC/B,CAAC,CAAC;AAEN;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAW/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAUjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,OAO5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "5.5.4",
3
+ "version": "5.5.6",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -56,9 +56,11 @@
56
56
  "./package.json"
57
57
  ],
58
58
  "dependencies": {
59
- "@intlayer/chokidar": "5.5.4",
60
- "@intlayer/config": "5.5.4",
61
- "@intlayer/core": "5.5.4"
59
+ "js-cookie": "^3.0.5",
60
+ "@intlayer/core": "5.5.6",
61
+ "@intlayer/chokidar": "5.5.6",
62
+ "@intlayer/config": "5.5.6",
63
+ "@intlayer/editor": "5.5.6"
62
64
  },
63
65
  "devDependencies": {
64
66
  "@types/node": "^22.13.10",
@@ -71,15 +73,16 @@
71
73
  "tsup": "^8.4.0",
72
74
  "typescript": "^5.8.2",
73
75
  "@utils/ts-config": "1.0.4",
74
- "@utils/tsup-config": "1.0.4",
75
76
  "@utils/ts-config-types": "1.0.4",
76
- "@utils/eslint-config": "1.0.4"
77
+ "@utils/eslint-config": "1.0.4",
78
+ "@utils/tsup-config": "1.0.4"
77
79
  },
78
80
  "peerDependencies": {
79
81
  "svelte": "^5.23.1",
80
- "@intlayer/chokidar": "5.5.4",
81
- "@intlayer/config": "5.5.4",
82
- "@intlayer/core": "5.5.4"
82
+ "@intlayer/chokidar": "5.5.6",
83
+ "@intlayer/core": "5.5.6",
84
+ "@intlayer/config": "5.5.6",
85
+ "@intlayer/editor": "5.5.6"
83
86
  },
84
87
  "engines": {
85
88
  "node": ">=14.18"
@@ -1,224 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var intlayerMiddlewarePlugin_exports = {};
20
- __export(intlayerMiddlewarePlugin_exports, {
21
- intLayerMiddlewarePlugin: () => intLayerMiddlewarePlugin
22
- });
23
- module.exports = __toCommonJS(intlayerMiddlewarePlugin_exports);
24
- var import_url = require("url");
25
- var import_config = require("@intlayer/config");
26
- var import_core = require("@intlayer/core");
27
- const intlayerConfig = (0, import_config.getConfiguration)();
28
- const { internationalization, middleware } = intlayerConfig;
29
- const { locales: supportedLocales, defaultLocale } = internationalization;
30
- const {
31
- cookieName,
32
- headerName,
33
- prefixDefault,
34
- noPrefix,
35
- serverSetCookie,
36
- basePath = ""
37
- } = middleware;
38
- const intLayerMiddlewarePlugin = () => {
39
- return {
40
- name: "vite-intlayer-middleware-plugin",
41
- configureServer: (server) => {
42
- server.middlewares.use((req, res, next) => {
43
- if (req.url?.startsWith("/node_modules") || req.url?.startsWith("/@") || req.url?.split("?")[0].match(/\.[a-z]+$/i)) {
44
- return next();
45
- }
46
- const parsedUrl = (0, import_url.parse)(req.url ?? "/", true);
47
- const originalPath = parsedUrl.pathname ?? "/";
48
- const cookies = parseCookies(req.headers.cookie ?? "");
49
- const cookieLocale = getValidLocaleFromCookie(cookies[cookieName]);
50
- const pathLocale = getPathLocale(originalPath);
51
- if (noPrefix) {
52
- handleNoPrefix({
53
- req,
54
- res,
55
- next,
56
- originalPath,
57
- cookieLocale
58
- });
59
- return;
60
- }
61
- handlePrefix({
62
- req,
63
- res,
64
- next,
65
- originalPath,
66
- pathLocale,
67
- cookieLocale
68
- });
69
- });
70
- }
71
- };
72
- };
73
- const parseCookies = (cookieHeader) => {
74
- return cookieHeader.split(";").reduce(
75
- (acc, cookie) => {
76
- const [key, val] = cookie.trim().split("=");
77
- acc[key] = val;
78
- return acc;
79
- },
80
- {}
81
- );
82
- };
83
- const getValidLocaleFromCookie = (locale) => {
84
- if (locale && supportedLocales.includes(locale)) {
85
- return locale;
86
- }
87
- return void 0;
88
- };
89
- const getPathLocale = (pathname) => {
90
- const segments = pathname.split("/").filter(Boolean);
91
- const firstSegment = segments[0];
92
- if (firstSegment && supportedLocales.includes(firstSegment)) {
93
- return firstSegment;
94
- }
95
- return void 0;
96
- };
97
- const redirectUrl = (res, newUrl) => {
98
- res.writeHead(301, { Location: newUrl });
99
- return res.end();
100
- };
101
- const rewriteUrl = (req, res, newUrl, locale) => {
102
- req.url = newUrl;
103
- if (locale && headerName) {
104
- res.setHeader(headerName, locale);
105
- }
106
- };
107
- const constructPath = (locale, currentPath) => {
108
- const cleanBasePath = basePath.startsWith("/") ? basePath : `/${basePath}`;
109
- const normalizedBasePath = cleanBasePath === "/" ? "" : cleanBasePath;
110
- let newPath = `${normalizedBasePath}/${locale}${currentPath}`;
111
- if (!prefixDefault && locale === defaultLocale) {
112
- newPath = `${normalizedBasePath}${currentPath}`;
113
- }
114
- return newPath;
115
- };
116
- const handleNoPrefix = ({
117
- req,
118
- res,
119
- next,
120
- originalPath,
121
- cookieLocale
122
- }) => {
123
- let locale = cookieLocale ?? defaultLocale;
124
- if (!cookieLocale) {
125
- const detectedLocale = (0, import_core.localeDetector)(
126
- req.headers,
127
- supportedLocales,
128
- defaultLocale
129
- );
130
- locale = detectedLocale;
131
- }
132
- rewriteUrl(req, res, originalPath, locale);
133
- return next();
134
- };
135
- const handlePrefix = ({
136
- req,
137
- res,
138
- next,
139
- originalPath,
140
- pathLocale,
141
- cookieLocale
142
- }) => {
143
- if (!pathLocale) {
144
- handleMissingPathLocale({
145
- req,
146
- res,
147
- next,
148
- originalPath,
149
- cookieLocale
150
- });
151
- return;
152
- }
153
- handleExistingPathLocale({
154
- req,
155
- res,
156
- next,
157
- originalPath,
158
- pathLocale,
159
- cookieLocale
160
- });
161
- };
162
- const handleMissingPathLocale = ({
163
- req,
164
- res,
165
- next,
166
- originalPath,
167
- cookieLocale
168
- }) => {
169
- let locale = cookieLocale ?? (0, import_core.localeDetector)(
170
- req.headers,
171
- supportedLocales,
172
- defaultLocale
173
- );
174
- if (!supportedLocales.includes(locale)) {
175
- locale = defaultLocale;
176
- }
177
- const newPath = constructPath(locale, originalPath);
178
- if (prefixDefault || locale !== defaultLocale) {
179
- return redirectUrl(res, newPath);
180
- }
181
- rewriteUrl(req, res, newPath, locale);
182
- return next();
183
- };
184
- const handleExistingPathLocale = ({
185
- req,
186
- res,
187
- next,
188
- originalPath,
189
- pathLocale,
190
- cookieLocale
191
- }) => {
192
- if (cookieLocale && cookieLocale !== pathLocale && serverSetCookie !== "always") {
193
- const newPath = originalPath.replace(`/${pathLocale}`, `/${cookieLocale}`);
194
- const finalPath = constructPath(cookieLocale, newPath.replace(/^\/+/, "/"));
195
- return redirectUrl(res, finalPath);
196
- }
197
- handleDefaultLocaleRedirect({
198
- req,
199
- res,
200
- next,
201
- originalPath,
202
- pathLocale
203
- });
204
- };
205
- const handleDefaultLocaleRedirect = ({
206
- req,
207
- res,
208
- next,
209
- originalPath,
210
- pathLocale
211
- }) => {
212
- if (!prefixDefault && pathLocale === defaultLocale) {
213
- const newPath = originalPath.replace(`/${defaultLocale}`, "") ?? "/";
214
- rewriteUrl(req, res, newPath, pathLocale);
215
- return next();
216
- }
217
- rewriteUrl(req, res, originalPath, pathLocale);
218
- return next();
219
- };
220
- // Annotate the CommonJS export names for ESM import in node:
221
- 0 && (module.exports = {
222
- intLayerMiddlewarePlugin
223
- });
224
- //# sourceMappingURL=intlayerMiddlewarePlugin.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/intlayerMiddlewarePlugin.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http';\nimport { parse } from 'url';\nimport { getConfiguration, type Locales } from '@intlayer/config';\nimport { localeDetector } from '@intlayer/core';\n/* @ts-ignore - Vite types error */\nimport type { Connect, Plugin } from 'vite';\n\n// Grab all the config you need.\n// Make sure your config includes the following fields if you want to replicate Next.js logic:\n// - internationalization.locales\n// - internationalization.defaultLocale\n// - middleware.cookieName\n// - middleware.headerName\n// - middleware.prefixDefault\n// - middleware.noPrefix\n// - middleware.serverSetCookie\n// - middleware.basePath\n// - etc.\nconst intlayerConfig = getConfiguration();\nconst { internationalization, middleware } = intlayerConfig;\nconst { locales: supportedLocales, defaultLocale } = internationalization;\n\nconst {\n cookieName,\n headerName,\n prefixDefault,\n noPrefix,\n serverSetCookie,\n basePath = '',\n} = middleware;\n\n/**\n * A Vite plugin that integrates a logic similar to the Next.js intlayer middleware.\n */\nexport const intLayerMiddlewarePlugin = (): Plugin => {\n return {\n name: 'vite-intlayer-middleware-plugin',\n configureServer: (server) => {\n server.middlewares.use((req, res, next) => {\n // 1. Bypass assets and special Vite endpoints\n if (\n req.url?.startsWith('/node_modules') ||\n req.url?.startsWith('/@') ||\n req.url?.split('?')[0].match(/\\.[a-z]+$/i) // checks for file extensions\n ) {\n return next();\n }\n\n // 2. Parse original URL for path and query\n const parsedUrl = parse(req.url ?? '/', true);\n const originalPath = parsedUrl.pathname ?? '/';\n\n // 3. Attempt to read the cookie locale\n const cookies = parseCookies(req.headers.cookie ?? '');\n const cookieLocale = getValidLocaleFromCookie(cookies[cookieName]);\n\n // 4. Check if there's a locale prefix in the path\n const pathLocale = getPathLocale(originalPath);\n\n // 5. If noPrefix is true, we skip prefix logic altogether\n if (noPrefix) {\n handleNoPrefix({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n });\n return;\n }\n\n // 6. Otherwise, handle prefix logic\n handlePrefix({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n });\n });\n },\n };\n};\n\n/* --------------------------------------------------------------------\n * Helper & Utility Functions\n * --------------------------------------------------------------------\n */\n\n/**\n * Parses cookies from the Cookie header string into an object.\n */\nconst parseCookies = (cookieHeader: string) => {\n return cookieHeader.split(';').reduce(\n (acc, cookie) => {\n const [key, val] = cookie.trim().split('=');\n acc[key] = val;\n return acc;\n },\n {} as Record<string, string>\n );\n};\n\n/**\n * Checks if the cookie locale is valid and is included in the supported locales.\n */\nconst getValidLocaleFromCookie = (\n locale: string | undefined\n): Locales | undefined => {\n if (locale && supportedLocales.includes(locale as Locales)) {\n return locale as Locales;\n }\n return undefined;\n};\n\n/**\n * Extracts the locale from the URL pathname if present as the first segment.\n */\nconst getPathLocale = (pathname: string): Locales | undefined => {\n // e.g. if pathname is /en/some/page or /en\n // we check if \"en\" is in your supportedLocales\n const segments = pathname.split('/').filter(Boolean);\n const firstSegment = segments[0];\n if (firstSegment && supportedLocales.includes(firstSegment as Locales)) {\n return firstSegment as Locales;\n }\n return undefined;\n};\n\n/**\n * Writes a 301 redirect response with the given new URL.\n */\nconst redirectUrl = (res: ServerResponse<IncomingMessage>, newUrl: string) => {\n res.writeHead(301, { Location: newUrl });\n return res.end();\n};\n\n/**\n * \"Rewrite\" the request internally by adjusting req.url;\n * we also set the locale in the response header if needed.\n */\nconst rewriteUrl = (\n req: Connect.IncomingMessage,\n res: ServerResponse<IncomingMessage>,\n newUrl: string,\n locale?: Locales\n) => {\n req.url = newUrl;\n // If you want to mimic Next.js's behavior of setting a header for the locale:\n if (locale && headerName) {\n res.setHeader(headerName, locale);\n }\n};\n\n/**\n * Constructs a new path string, optionally including a locale prefix and basePath.\n * - basePath: (e.g., '/myapp')\n * - locale: (e.g., 'en')\n * - currentPath:(e.g., '/products/shoes')\n */\nconst constructPath = (locale: Locales, currentPath: string) => {\n // Ensure basePath always starts with '/', and remove trailing slash if needed\n const cleanBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`;\n // If basePath is '/', no trailing slash is needed\n const normalizedBasePath = cleanBasePath === '/' ? '' : cleanBasePath;\n\n // Combine basePath + locale + the rest of the path\n // Example: basePath = '/myapp', locale = 'en', currentPath = '/products' => '/myapp/en/products'\n let newPath = `${normalizedBasePath}/${locale}${currentPath}`;\n\n // Special case: if prefixDefault is false and locale is defaultLocale, remove the locale prefix\n if (!prefixDefault && locale === defaultLocale) {\n newPath = `${normalizedBasePath}${currentPath}`;\n }\n\n return newPath;\n};\n\n/* --------------------------------------------------------------------\n * Handlers that mirror Next.js style logic\n * --------------------------------------------------------------------\n */\n\n/**\n * If `noPrefix` is true, we never prefix the locale in the URL.\n * We simply rewrite the request to the same path, but with the best-chosen locale\n * in a header or cookie if desired.\n */\nconst handleNoPrefix = ({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n cookieLocale?: Locales;\n}) => {\n // Determine the best locale\n let locale = cookieLocale ?? defaultLocale;\n\n // Use fallback to localeDetector if no cookie\n if (!cookieLocale) {\n const detectedLocale = localeDetector(\n req.headers as Record<string, string>,\n supportedLocales,\n defaultLocale\n );\n locale = detectedLocale as Locales;\n }\n\n // Just rewrite the URL in-place (no prefix). We do NOT redirect because we do not want to alter the URL.\n rewriteUrl(req, res, originalPath, locale);\n return next();\n};\n\n/**\n * The main prefix logic:\n * - If there's no pathLocale in the URL, we might want to detect & redirect or rewrite\n * - If there is a pathLocale, handle cookie mismatch or default locale special cases\n */\nconst handlePrefix = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale?: Locales;\n cookieLocale?: Locales;\n}) => {\n // 1. If pathLocale is missing, handle\n if (!pathLocale) {\n handleMissingPathLocale({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n });\n return;\n }\n\n // 2. If pathLocale exists, handle possible mismatch with cookie\n handleExistingPathLocale({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n });\n};\n\n/**\n * Handles requests where the locale is missing from the URL pathname.\n * We detect a locale from cookie / headers / default, then either redirect or rewrite.\n */\nconst handleMissingPathLocale = ({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n cookieLocale?: Locales;\n}) => {\n // 1. Choose the best locale\n let locale = (cookieLocale ??\n localeDetector(\n req.headers as Record<string, string>,\n supportedLocales,\n defaultLocale\n )) as Locales;\n\n // 2. If still invalid, fallback\n if (!supportedLocales.includes(locale)) {\n locale = defaultLocale;\n }\n\n // 3. Construct new path\n const newPath = constructPath(locale, originalPath);\n\n // If we always prefix default or if this is not the default locale, do a 301 redirect\n // so that the user sees the locale in the URL.\n if (prefixDefault || locale !== defaultLocale) {\n return redirectUrl(res, newPath);\n }\n\n // If we do NOT prefix the default locale, just rewrite in place\n rewriteUrl(req, res, newPath, locale);\n return next();\n};\n\n/**\n * Handles requests where the locale prefix is present in the pathname.\n * We verify if the cookie locale differs from the path locale; if so, handle.\n */\nconst handleExistingPathLocale = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale: Locales;\n cookieLocale?: Locales;\n}) => {\n // 1. If the cookie locale is set and differs from the path locale,\n // and we're not forcing the cookie to always override\n if (\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n // We want to swap out the pathLocale with the cookieLocale\n const newPath = originalPath.replace(`/${pathLocale}`, `/${cookieLocale}`);\n const finalPath = constructPath(cookieLocale, newPath.replace(/^\\/+/, '/'));\n return redirectUrl(res, finalPath);\n }\n\n // 2. Otherwise, handle default-locale prefix if needed\n handleDefaultLocaleRedirect({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n });\n};\n\n/**\n * If the path locale is the default locale but we don't want to prefix the default, remove it.\n */\nconst handleDefaultLocaleRedirect = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale: Locales;\n}) => {\n // If we don't prefix default AND the path locale is the default locale -> remove it\n if (!prefixDefault && pathLocale === defaultLocale) {\n // Remove the default locale part from the path\n const newPath = originalPath.replace(`/${defaultLocale}`, '') ?? '/';\n rewriteUrl(req, res, newPath, pathLocale);\n return next();\n }\n\n // If we do prefix default or pathLocale != default, keep as is, but rewrite headers\n rewriteUrl(req, res, originalPath, pathLocale);\n return next();\n};\n"],"mappings":";;;;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AAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMM;AAEJ,MAAI,CAAC,iBAAiB,eAAe,eAAe;AAElD,UAAM,UAAU,aAAa,QAAQ,IAAI,aAAa,IAAI,EAAE,KAAK;AACjE,eAAW,KAAK,KAAK,SAAS,UAAU;AACxC,WAAO,KAAK;AAAA,EACd;AAGA,aAAW,KAAK,KAAK,cAAc,UAAU;AAC7C,SAAO,KAAK;AACd;","names":[]}
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var intlayerPlugin_exports = {};
20
- __export(intlayerPlugin_exports, {
21
- intlayerPlugin: () => intlayerPlugin
22
- });
23
- module.exports = __toCommonJS(intlayerPlugin_exports);
24
- var import_path = require("path");
25
- var import_chokidar = require("@intlayer/chokidar");
26
- var import_config = require("@intlayer/config");
27
- const intlayerPlugin = (_pluginOptions = {}) => ({
28
- name: "vite-intlayer-plugin",
29
- config: (config) => {
30
- const intlayerConfig = (0, import_config.getConfiguration)();
31
- const {
32
- mainDir,
33
- configDir,
34
- baseDir,
35
- watch: isWatchMode
36
- } = intlayerConfig.content;
37
- const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
38
- const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
39
- const configurationPath = (0, import_path.join)(configDir, "configuration.json");
40
- const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
41
- config.resolve = {
42
- ...config.resolve,
43
- alias: {
44
- ...config.resolve?.alias,
45
- "@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath),
46
- "@intlayer/config/built": (0, import_path.resolve)(relativeConfigurationPath)
47
- }
48
- };
49
- if (isWatchMode) {
50
- config.optimizeDeps = {
51
- ...config.optimizeDeps,
52
- exclude: [
53
- ...config.optimizeDeps?.exclude ?? [],
54
- "@intlayer/dictionaries-entry",
55
- "@intlayer/config/built"
56
- ]
57
- };
58
- }
59
- return config;
60
- },
61
- configureServer: async () => {
62
- const intlayerConfig = (0, import_config.getConfiguration)();
63
- if (intlayerConfig.content.watch) {
64
- (0, import_chokidar.watch)({ configuration: intlayerConfig });
65
- }
66
- },
67
- buildStart: async () => {
68
- const intlayerConfig = (0, import_config.getConfiguration)();
69
- await (0, import_chokidar.prepareIntlayer)(intlayerConfig);
70
- }
71
- });
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- intlayerPlugin
75
- });
76
- //# sourceMappingURL=intlayerPlugin.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { type PluginOption } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayerPlugin() ],\n * });\n * ```\n * */\nexport const intlayerPlugin = (\n _pluginOptions: PluginOptions = {}\n): PluginOption => ({\n name: 'vite-intlayer-plugin',\n\n config: (config) => {\n const intlayerConfig = getConfiguration();\n const {\n mainDir,\n configDir,\n baseDir,\n watch: isWatchMode,\n } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\n },\n };\n\n if (isWatchMode) {\n // Ajout de l'option optimizeDeps.exclude\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude ?? []),\n '@intlayer/dictionaries-entry',\n '@intlayer/config/built',\n ],\n };\n }\n\n return config;\n },\n\n configureServer: async () => {\n // Runs when the dev server starts\n const intlayerConfig = getConfiguration();\n\n if (intlayerConfig.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n\n buildStart: async () => {\n // Code to run when Vite build starts\n const intlayerConfig = getConfiguration();\n await prepareIntlayer(intlayerConfig);\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,sBAAuC;AACvC,oBAAiC;AAoB1B,MAAM,iBAAiB,CAC5B,iBAAgC,CAAC,OACf;AAAA,EAClB,MAAM;AAAA,EAEN,QAAQ,CAAC,WAAW;AAClB,UAAM,qBAAiB,gCAAiB;AACxC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT,IAAI,eAAe;AAEnB,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,UAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,UAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAGrE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,QAChE,8BAA0B,qBAAQ,yBAAyB;AAAA,MAC7D;AAAA,IACF;AAEA,QAAI,aAAa;AAEf,aAAO,eAAe;AAAA,QACpB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,UACrC;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,YAAY;AAE3B,UAAM,qBAAiB,gCAAiB;AAExC,QAAI,eAAe,QAAQ,OAAO;AAEhC,iCAAM,EAAE,eAAe,eAAe,CAAC;AAAA,IACzC;AAAA,EACF;AAAA,EAEA,YAAY,YAAY;AAEtB,UAAM,qBAAiB,gCAAiB;AACxC,cAAM,iCAAgB,cAAc;AAAA,EACtC;AACF;","names":[]}