solid-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 (73) hide show
  1. package/dist/cjs/client/index.cjs +29 -0
  2. package/dist/cjs/client/index.cjs.map +1 -0
  3. package/dist/cjs/client/installIntlayer.cjs +53 -0
  4. package/dist/cjs/client/installIntlayer.cjs.map +1 -0
  5. package/dist/cjs/client/useDictionary.cjs +41 -0
  6. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  7. package/dist/cjs/client/useIntlayer.cjs +44 -0
  8. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  9. package/dist/cjs/client/useLocale.cjs +33 -0
  10. package/dist/cjs/client/useLocale.cjs.map +1 -0
  11. package/dist/cjs/getDictionary.cjs +42 -0
  12. package/dist/cjs/getDictionary.cjs.map +1 -0
  13. package/dist/cjs/getIntlayer.cjs +38 -0
  14. package/dist/cjs/getIntlayer.cjs.map +1 -0
  15. package/dist/cjs/index.cjs +10 -4
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/markdown/index.cjs +36 -0
  18. package/dist/cjs/markdown/index.cjs.map +1 -0
  19. package/dist/cjs/plugins.cjs +53 -0
  20. package/dist/cjs/plugins.cjs.map +1 -0
  21. package/dist/esm/client/index.mjs +5 -0
  22. package/dist/esm/client/index.mjs.map +1 -0
  23. package/dist/esm/client/installIntlayer.mjs +26 -0
  24. package/dist/esm/client/installIntlayer.mjs.map +1 -0
  25. package/dist/esm/client/useDictionary.mjs +17 -0
  26. package/dist/esm/client/useDictionary.mjs.map +1 -0
  27. package/dist/esm/client/useIntlayer.mjs +19 -0
  28. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  29. package/dist/esm/client/useLocale.mjs +9 -0
  30. package/dist/esm/client/useLocale.mjs.map +1 -0
  31. package/dist/esm/getDictionary.mjs +23 -0
  32. package/dist/esm/getDictionary.mjs.map +1 -0
  33. package/dist/esm/getIntlayer.mjs +19 -0
  34. package/dist/esm/getIntlayer.mjs.map +1 -0
  35. package/dist/esm/index.mjs +5 -2
  36. package/dist/esm/index.mjs.map +1 -1
  37. package/dist/esm/markdown/index.mjs +12 -0
  38. package/dist/esm/markdown/index.mjs.map +1 -0
  39. package/dist/esm/plugins.mjs +27 -0
  40. package/dist/esm/plugins.mjs.map +1 -0
  41. package/dist/types/client/index.d.ts +5 -0
  42. package/dist/types/client/index.d.ts.map +1 -0
  43. package/dist/types/client/installIntlayer.d.ts +11 -0
  44. package/dist/types/client/installIntlayer.d.ts.map +1 -0
  45. package/dist/types/client/useDictionary.d.ts +4 -0
  46. package/dist/types/client/useDictionary.d.ts.map +1 -0
  47. package/dist/types/client/useIntlayer.d.ts +8 -0
  48. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  49. package/dist/types/client/useLocale.d.ts +4 -0
  50. package/dist/types/client/useLocale.d.ts.map +1 -0
  51. package/dist/types/getDictionary.d.ts +5 -0
  52. package/dist/types/getDictionary.d.ts.map +1 -0
  53. package/dist/types/getIntlayer.d.ts +5 -0
  54. package/dist/types/getIntlayer.d.ts.map +1 -0
  55. package/dist/types/index.d.ts +10 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/markdown/index.d.ts +4 -0
  58. package/dist/types/markdown/index.d.ts.map +1 -0
  59. package/dist/types/plugins.d.ts +32 -0
  60. package/dist/types/plugins.d.ts.map +1 -0
  61. package/package.json +13 -10
  62. package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
  63. package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
  64. package/dist/cjs/intlayerPlugin.cjs +0 -76
  65. package/dist/cjs/intlayerPlugin.cjs.map +0 -1
  66. package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
  67. package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
  68. package/dist/esm/intlayerPlugin.mjs +0 -52
  69. package/dist/esm/intlayerPlugin.mjs.map +0 -1
  70. package/dist/types/intlayerMiddlewarePlugin.d.ts +0 -6
  71. package/dist/types/intlayerMiddlewarePlugin.d.ts.map +0 -1
  72. package/dist/types/intlayerPlugin.d.ts +0 -16
  73. package/dist/types/intlayerPlugin.d.ts.map +0 -1
@@ -0,0 +1,12 @@
1
+ const useMarkdown = () => {
2
+ const renderMarkdown = (content) => {
3
+ return content;
4
+ };
5
+ return {
6
+ renderMarkdown
7
+ };
8
+ };
9
+ export {
10
+ useMarkdown
11
+ };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export const useMarkdown = () => {\n const renderMarkdown = (content: string): string => {\n // Basic markdown rendering - in a real implementation, you'd use a markdown parser\n return content;\n };\n\n return {\n renderMarkdown,\n };\n};\n"],"mappings":"AAAO,MAAM,cAAc,MAAM;AAC/B,QAAM,iBAAiB,CAAC,YAA4B;AAElD,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,27 @@
1
+ const solidNodePlugins = {
2
+ id: "solid-node-plugin",
3
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
4
+ transform: (node, { children, ...rest }) => {
5
+ return children ?? node;
6
+ }
7
+ };
8
+ const intlayerNodePlugins = {
9
+ id: "intlayer-node-plugin",
10
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
11
+ transform: (node, { children, ...rest }) => {
12
+ return children ?? node;
13
+ }
14
+ };
15
+ const markdownPlugin = {
16
+ id: "markdown-plugin",
17
+ canHandle: (node) => typeof node === "string",
18
+ transform: (node, props) => {
19
+ return node;
20
+ }
21
+ };
22
+ export {
23
+ intlayerNodePlugins,
24
+ markdownPlugin,
25
+ solidNodePlugins
26
+ };
27
+ //# sourceMappingURL=plugins.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import type { Plugins } from '@intlayer/core';\n\n/**\n * Interface for Solid-specific plugin functionality\n * This interface can be augmented to add more Solid-specific transformations\n */\nexport interface IInterpreterPluginSolid<T> {\n /** Any Solid-specific properties can be added here */\n solidRendered?: T;\n}\n\n/**\n * Type that represents the deep transformation of content for Solid\n * This applies Solid-specific transformations recursively to all content\n */\nexport type DeepTransformContent<T> = T extends object\n ? {\n [K in keyof T]: DeepTransformContent<T[K]>;\n } & IInterpreterPluginSolid<T>\n : T;\n\n/**\n * Solid-specific node plugins for handling basic content types\n * These plugins handle strings, numbers, and bigints in Solid applications\n */\nexport const solidNodePlugins: Plugins = {\n id: 'solid-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // For Solid, we can return the raw content as Solid handles reactivity automatically\n // In more complex scenarios, you might want to wrap content in Solid components\n return children ?? node;\n },\n};\n\n/**\n * Basic Intlayer node plugins for content handling\n * These handle the core content transformation logic\n */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // Return the processed children or the node itself\n return children ?? node;\n },\n};\n\n/**\n * Markdown plugin for handling markdown content in Solid\n * This can be extended to integrate with Solid markdown processors\n */\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node, props) => {\n // Basic markdown handling - can be extended with proper markdown parser\n return node;\n },\n};\n"],"mappings":"AAyBO,MAAM,mBAA4B;AAAA,EACvC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAG1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAE1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAM,UAAU;AAE1B,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,5 @@
1
+ export * from './installIntlayer';
2
+ export * from './useDictionary';
3
+ export * from './useIntlayer';
4
+ export * from './useLocale';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { Accessor } from 'solid-js';
3
+ export interface IntlayerProvider {
4
+ locale: Accessor<LocalesValues>;
5
+ setLocale: (locale: LocalesValues) => void;
6
+ }
7
+ export declare const INTLAYER_SYMBOL: unique symbol;
8
+ export declare const IntlayerContext: import("solid-js").Context<IntlayerProvider>;
9
+ export declare const useIntlayerContext: () => IntlayerProvider;
10
+ export declare const createIntlayerProvider: (initialLocale: LocalesValues) => IntlayerProvider;
11
+ //# sourceMappingURL=installIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/installIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAA2C,MAAM,UAAU,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAChC,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,eAAe,eAAqB,CAAC;AAElD,eAAO,MAAM,eAAe,8CAAoC,CAAC;AAEjE,eAAO,MAAM,kBAAkB,QAAO,gBAQrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,eAAe,aAAa,KAC3B,gBAOF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { Dictionary } from '@intlayer/core';
3
+ export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => any;
4
+ //# sourceMappingURL=useDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK5C,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,KACrB,GAgBF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { DictionaryKeys } from '@intlayer/core';
3
+ /** guard utility — true only for objects generated by `renderIntlayerNode()` */
4
+ export declare const isUpdatableNode: (val: unknown) => val is {
5
+ __update: (n: unknown) => void;
6
+ };
7
+ export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => any;
8
+ //# sourceMappingURL=useIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,gFAAgF;AAChF,eAAO,MAAM,eAAe,GAC1B,KAAK,OAAO,KACX,GAAG,IAAI;IAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAGG,CAAC;AAE9C,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,GAgBF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { Accessor } from 'solid-js';
3
+ export declare const useLocale: () => [Accessor<LocalesValues>, (locale: LocalesValues) => void];
4
+ //# sourceMappingURL=useLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,eAAO,MAAM,SAAS,QAAO,CAC3B,QAAQ,CAAC,aAAa,CAAC,EACvB,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAKhC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Locales, LocalesValues } from '@intlayer/config/client';
2
+ import { Dictionary, Plugins } from '@intlayer/core';
3
+ import { DeepTransformContent } from './plugins';
4
+ export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
5
+ //# sourceMappingURL=getDictionary.d.ts.map
@@ -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,EAGrB,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,GAAG,OAAO,EAEjC,YAAY,CAAC,EACb,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAYjB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DictionaryKeys, Plugins } from '@intlayer/core';
2
+ import type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';
3
+ import { DeepTransformContent } from './plugins';
4
+ export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
5
+ //# 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,EAGrB,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,EAC3E,KAAK,CAAC,EACN,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAQ0B,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 { IInterpreterPluginSolid } from './plugins';
2
+ declare module '@intlayer/core' {
3
+ interface IInterpreterPlugin<T, S> extends IInterpreterPluginSolid<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,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;AAED,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const useMarkdown: () => {
2
+ renderMarkdown: (content: string) => string;
3
+ };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;8BACW,MAAM,KAAG,MAAM;CAQjD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Plugins } from '@intlayer/core';
2
+ /**
3
+ * Interface for Solid-specific plugin functionality
4
+ * This interface can be augmented to add more Solid-specific transformations
5
+ */
6
+ export interface IInterpreterPluginSolid<T> {
7
+ /** Any Solid-specific properties can be added here */
8
+ solidRendered?: T;
9
+ }
10
+ /**
11
+ * Type that represents the deep transformation of content for Solid
12
+ * This applies Solid-specific transformations recursively to all content
13
+ */
14
+ export type DeepTransformContent<T> = T extends object ? {
15
+ [K in keyof T]: DeepTransformContent<T[K]>;
16
+ } & IInterpreterPluginSolid<T> : T;
17
+ /**
18
+ * Solid-specific node plugins for handling basic content types
19
+ * These plugins handle strings, numbers, and bigints in Solid applications
20
+ */
21
+ export declare const solidNodePlugins: 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 Solid
29
+ * This can be extended to integrate with Solid 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.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,sDAAsD;IACtD,aAAa,CAAC,EAAE,CAAC,CAAC;CACnB;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,uBAAuB,CAAC,CAAC,CAAC,GAC9B,CAAC,CAAC;AAEN;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAW9B,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": "solid-intlayer",
3
- "version": "5.5.4",
3
+ "version": "5.5.6",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Solid 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/core": "5.5.4",
60
- "@intlayer/config": "5.5.4",
61
- "@intlayer/chokidar": "5.5.4"
59
+ "js-cookie": "^3.0.5",
60
+ "@intlayer/chokidar": "5.5.6",
61
+ "@intlayer/config": "5.5.6",
62
+ "@intlayer/core": "5.5.6",
63
+ "@intlayer/editor": "5.5.6"
62
64
  },
63
65
  "devDependencies": {
64
66
  "@types/node": "^22.13.10",
@@ -70,16 +72,17 @@
70
72
  "tsc-alias": "^1.8.11",
71
73
  "tsup": "^8.4.0",
72
74
  "typescript": "^5.8.2",
73
- "@utils/eslint-config": "1.0.4",
74
- "@utils/ts-config": "1.0.4",
75
75
  "@utils/ts-config-types": "1.0.4",
76
- "@utils/tsup-config": "1.0.4"
76
+ "@utils/ts-config": "1.0.4",
77
+ "@utils/tsup-config": "1.0.4",
78
+ "@utils/eslint-config": "1.0.4"
77
79
  },
78
80
  "peerDependencies": {
79
81
  "solid-js": "^1.9.5",
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/config": "5.5.6",
84
+ "@intlayer/core": "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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","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":[]}