react-intlayer 3.5.10 → 4.0.0

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 (111) hide show
  1. package/dist/esm/client/IntlayerProvider.mjs +0 -1
  2. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  3. package/dist/esm/client/getBrowserLocale.mjs +0 -1
  4. package/dist/esm/client/getBrowserLocale.mjs.map +1 -1
  5. package/dist/esm/client/index.mjs +0 -1
  6. package/dist/esm/client/index.mjs.map +1 -1
  7. package/dist/esm/client/t.mjs +0 -1
  8. package/dist/esm/client/t.mjs.map +1 -1
  9. package/dist/esm/client/useContent.mjs +0 -1
  10. package/dist/esm/client/useContent.mjs.map +1 -1
  11. package/dist/esm/client/useDictionary.mjs +0 -1
  12. package/dist/esm/client/useDictionary.mjs.map +1 -1
  13. package/dist/esm/client/useIntlayer.mjs +0 -1
  14. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  15. package/dist/esm/client/useIntlayerAsync.mjs +0 -1
  16. package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
  17. package/dist/esm/client/useLocale.mjs +0 -1
  18. package/dist/esm/client/useLocale.mjs.map +1 -1
  19. package/dist/esm/client/useLocaleBase.mjs +0 -1
  20. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  21. package/dist/esm/client/useLocaleCookie.mjs +0 -1
  22. package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
  23. package/dist/esm/client/useTraduction.mjs +0 -1
  24. package/dist/esm/client/useTraduction.mjs.map +1 -1
  25. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +0 -1
  26. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  27. package/dist/esm/editor/ContentSelectorConnector.mjs +0 -1
  28. package/dist/esm/editor/ContentSelectorConnector.mjs.map +1 -1
  29. package/dist/esm/editor/ContentSelectorWrapper.mjs +0 -1
  30. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  31. package/dist/esm/editor/IntlayerEditorProvider.mjs +0 -1
  32. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  33. package/dist/esm/editor/renderContentEditor.mjs +0 -1
  34. package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
  35. package/dist/esm/getDictionary.mjs +0 -1
  36. package/dist/esm/getDictionary.mjs.map +1 -1
  37. package/dist/esm/getEnumeration.mjs +0 -1
  38. package/dist/esm/getEnumeration.mjs.map +1 -1
  39. package/dist/esm/getIntlayer.mjs +0 -1
  40. package/dist/esm/getIntlayer.mjs.map +1 -1
  41. package/dist/esm/getIntlayerAsync.mjs +0 -1
  42. package/dist/esm/getIntlayerAsync.mjs.map +1 -1
  43. package/dist/esm/getTranslation.mjs +0 -1
  44. package/dist/esm/getTranslation.mjs.map +1 -1
  45. package/dist/esm/index.mjs +0 -1
  46. package/dist/esm/index.mjs.map +1 -1
  47. package/dist/esm/processDictionary/index.mjs +0 -1
  48. package/dist/esm/processDictionary/index.mjs.map +1 -1
  49. package/dist/esm/server/IntlayerServerProvider.mjs +0 -1
  50. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  51. package/dist/esm/server/getLocaleTranslation.mjs +0 -1
  52. package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
  53. package/dist/esm/server/index.mjs +0 -1
  54. package/dist/esm/server/index.mjs.map +1 -1
  55. package/dist/esm/server/serverContext.mjs +0 -1
  56. package/dist/esm/server/serverContext.mjs.map +1 -1
  57. package/dist/esm/server/t.mjs +0 -1
  58. package/dist/esm/server/t.mjs.map +1 -1
  59. package/dist/esm/server/useDictionary.mjs +0 -1
  60. package/dist/esm/server/useDictionary.mjs.map +1 -1
  61. package/dist/esm/server/useIntlayer.mjs +0 -1
  62. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  63. package/dist/esm/server/useTraduction.mjs +0 -1
  64. package/dist/esm/server/useTraduction.mjs.map +1 -1
  65. package/dist/esm/utils/PoweredByMeta/index.mjs +0 -1
  66. package/dist/esm/utils/PoweredByMeta/index.mjs.map +1 -1
  67. package/package.json +14 -33
  68. package/dist/cjs/cli/react-intlayer.cjs +0 -73
  69. package/dist/cjs/cli/react-intlayer.cjs.map +0 -1
  70. package/dist/cjs/craco/craco.config.cjs +0 -32
  71. package/dist/cjs/craco/craco.config.cjs.map +0 -1
  72. package/dist/cjs/craco/intlayerCracoPlugin.cjs +0 -93
  73. package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +0 -1
  74. package/dist/cjs/utils/removeUndefinedValueObject.cjs +0 -38
  75. package/dist/cjs/utils/removeUndefinedValueObject.cjs.map +0 -1
  76. package/dist/cjs/vite/index.cjs +0 -25
  77. package/dist/cjs/vite/index.cjs.map +0 -1
  78. package/dist/cjs/vite/intlayerMiddlewarePlugin.cjs +0 -224
  79. package/dist/cjs/vite/intlayerMiddlewarePlugin.cjs.map +0 -1
  80. package/dist/cjs/vite/intlayerPlugin.cjs +0 -88
  81. package/dist/cjs/vite/intlayerPlugin.cjs.map +0 -1
  82. package/dist/esm/chunk-ZD7AOCMD.mjs +0 -9
  83. package/dist/esm/chunk-ZD7AOCMD.mjs.map +0 -1
  84. package/dist/esm/cli/react-intlayer.mjs +0 -50
  85. package/dist/esm/cli/react-intlayer.mjs.map +0 -1
  86. package/dist/esm/craco/craco.config.mjs +0 -17
  87. package/dist/esm/craco/craco.config.mjs.map +0 -1
  88. package/dist/esm/craco/intlayerCracoPlugin.mjs +0 -74
  89. package/dist/esm/craco/intlayerCracoPlugin.mjs.map +0 -1
  90. package/dist/esm/utils/removeUndefinedValueObject.mjs +0 -15
  91. package/dist/esm/utils/removeUndefinedValueObject.mjs.map +0 -1
  92. package/dist/esm/vite/index.mjs +0 -3
  93. package/dist/esm/vite/index.mjs.map +0 -1
  94. package/dist/esm/vite/intlayerMiddlewarePlugin.mjs +0 -201
  95. package/dist/esm/vite/intlayerMiddlewarePlugin.mjs.map +0 -1
  96. package/dist/esm/vite/intlayerPlugin.mjs +0 -55
  97. package/dist/esm/vite/intlayerPlugin.mjs.map +0 -1
  98. package/dist/types/cli/react-intlayer.d.ts +0 -9
  99. package/dist/types/cli/react-intlayer.d.ts.map +0 -1
  100. package/dist/types/craco/craco.config.d.ts +0 -2
  101. package/dist/types/craco/craco.config.d.ts.map +0 -1
  102. package/dist/types/craco/intlayerCracoPlugin.d.ts +0 -24
  103. package/dist/types/craco/intlayerCracoPlugin.d.ts.map +0 -1
  104. package/dist/types/utils/removeUndefinedValueObject.d.ts +0 -2
  105. package/dist/types/utils/removeUndefinedValueObject.d.ts.map +0 -1
  106. package/dist/types/vite/index.d.ts +0 -3
  107. package/dist/types/vite/index.d.ts.map +0 -1
  108. package/dist/types/vite/intlayerMiddlewarePlugin.d.ts +0 -6
  109. package/dist/types/vite/intlayerMiddlewarePlugin.d.ts.map +0 -1
  110. package/dist/types/vite/intlayerPlugin.d.ts +0 -16
  111. package/dist/types/vite/intlayerPlugin.d.ts.map +0 -1
@@ -1,4 +1,3 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
1
  import react from "react";
3
2
  const cacheFallback = () => () => ({ value: void 0 });
4
3
  const createServerContext = (defaultValue) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/serverContext.ts"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer.Provider value={locale}>\n * {children}\n * </IntlayerServer.Provider>\n */\nimport react from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n return {\n Provider: ({ children, value }) => {\n getCache().value = value;\n return children;\n },\n Consumer: ({ children }) => {\n const store = getCache();\n return children(store ? store.value : defaultValue);\n },\n _storage: getCache,\n _defaultValue: defaultValue,\n };\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = {\n Provider: ({\n children,\n value,\n }: {\n children: React.ReactNode;\n value: T;\n }) => React.ReactNode;\n Consumer: ({\n children,\n }: {\n children: (context: T | undefined) => React.ReactNode;\n }) => React.ReactNode;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): void | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";AAWA,OAAO,WAAW;AAIlB,MAAM,gBAAgB,MAAM,OAAO,EAAE,OAAO,OAAU;AAE/C,MAAM,sBAAsB,CAAI,iBAAuC;AAC5E,gBAAc;AAGd,QAAM,QAAQ,MAAM,SAAuB;AAE3C,QAAM,WAAW,MAAM,OAAO;AAAA,IAC5B,OAAO;AAAA,EACT,EAAE;AAEF,SAAO;AAAA,IACL,UAAU,CAAC,EAAE,UAAU,MAAM,MAAM;AACjC,eAAS,EAAE,QAAQ;AACnB,aAAO;AAAA,IACT;AAAA,IACA,UAAU,CAAC,EAAE,SAAS,MAAM;AAC1B,YAAM,QAAQ,SAAS;AACvB,aAAO,SAAS,QAAQ,MAAM,QAAQ,YAAY;AAAA,IACpD;AAAA,IACA,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AASO,MAAM,mBAAmB,CAAI;AAAA,EAClC;AAAA,EACA;AACF,MAAwB;AAEtB,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,MAAM;AACf;AAuBA,MAAM,gBAAgB,MAAoB;AAExC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/serverContext.ts"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer.Provider value={locale}>\n * {children}\n * </IntlayerServer.Provider>\n */\nimport react from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n return {\n Provider: ({ children, value }) => {\n getCache().value = value;\n return children;\n },\n Consumer: ({ children }) => {\n const store = getCache();\n return children(store ? store.value : defaultValue);\n },\n _storage: getCache,\n _defaultValue: defaultValue,\n };\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = {\n Provider: ({\n children,\n value,\n }: {\n children: React.ReactNode;\n value: T;\n }) => React.ReactNode;\n Consumer: ({\n children,\n }: {\n children: (context: T | undefined) => React.ReactNode;\n }) => React.ReactNode;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): void | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":"AAWA,OAAO,WAAW;AAIlB,MAAM,gBAAgB,MAAM,OAAO,EAAE,OAAO,OAAU;AAE/C,MAAM,sBAAsB,CAAI,iBAAuC;AAC5E,gBAAc;AAGd,QAAM,QAAQ,MAAM,SAAuB;AAE3C,QAAM,WAAW,MAAM,OAAO;AAAA,IAC5B,OAAO;AAAA,EACT,EAAE;AAEF,SAAO;AAAA,IACL,UAAU,CAAC,EAAE,UAAU,MAAM,MAAM;AACjC,eAAS,EAAE,QAAQ;AACnB,aAAO;AAAA,IACT;AAAA,IACA,UAAU,CAAC,EAAE,SAAS,MAAM;AAC1B,YAAM,QAAQ,SAAS;AACvB,aAAO,SAAS,QAAQ,MAAM,QAAQ,YAAY;AAAA,IACpD;AAAA,IACA,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AASO,MAAM,mBAAmB,CAAI;AAAA,EAClC;AAAA,EACA;AACF,MAAwB;AAEtB,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,MAAM;AACf;AAuBA,MAAM,gBAAgB,MAAoB;AAExC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACF;","names":[]}
@@ -1,4 +1,3 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
1
  import { getTranslation } from '../getTranslation.mjs';
3
2
  import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
3
  import { getServerContext } from './serverContext.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the service side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const currentLocale = getServerContext<Locales>(IntlayerServerContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,gBAAgB,iBAA0B,qBAAqB;AACrE,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the service side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const currentLocale = getServerContext<Locales>(IntlayerServerContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,gBAAgB,iBAA0B,qBAAqB;AACrE,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
@@ -1,4 +1,3 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
1
  import { getDictionary } from '../getDictionary.mjs';
3
2
  import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
3
  import { getServerContext } from './serverContext.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { DeclarationContent } from '@intlayer/core';\nimport { getDictionary, type UseDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary: UseDictionary = <T extends DeclarationContent>(\n dictionary: T,\n locale?: Locales,\n isRenderEditor = false\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return getDictionary(dictionary, localeTarget, isRenderEditor);\n};\n"],"mappings":";AAEA,SAAS,qBAAyC;AAClD,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,gBAA+B,CAC1C,YACA,QACA,iBAAiB,UACd;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,cAAc,YAAY,cAAc,cAAc;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { DeclarationContent } from '@intlayer/core';\nimport { getDictionary, type UseDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary: UseDictionary = <T extends DeclarationContent>(\n dictionary: T,\n locale?: Locales,\n isRenderEditor = false\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return getDictionary(dictionary, localeTarget, isRenderEditor);\n};\n"],"mappings":"AAEA,SAAS,qBAAyC;AAClD,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,gBAA+B,CAC1C,YACA,QACA,iBAAiB,UACd;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,cAAc,YAAY,cAAc,cAAc;AAC/D;","names":[]}
@@ -1,4 +1,3 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
1
  import {
3
2
  getIntlayer
4
3
  } from '../getIntlayer.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n getIntlayer,\n type UseIntlayerEditable,\n} from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer: UseIntlayerEditable = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales,\n isRenderEditor = true\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget, isRenderEditor);\n};\n"],"mappings":";AACA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAAmC,CAC9C,KACA,QACA,iBAAiB,SACd;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,YAAY,KAAK,cAAc,cAAc;AACtD;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n getIntlayer,\n type UseIntlayerEditable,\n} from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer: UseIntlayerEditable = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales,\n isRenderEditor = true\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget, isRenderEditor);\n};\n"],"mappings":"AACA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAAmC,CAC9C,KACA,QACA,iBAAiB,SACd;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,YAAY,KAAK,cAAc,cAAc;AACtD;","names":[]}
@@ -1,4 +1,3 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
1
  import { getTranslation } from '../getTranslation.mjs';
3
2
  import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
3
  import { getServerContext } from './serverContext.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,SAAS,iBAA0B,qBAAqB;AAE9D,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":"AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,SAAS,iBAA0B,qBAAqB;AAE9D,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- import "../../chunk-ZD7AOCMD.mjs";
3
2
  import { useEffect } from "react";
4
3
  const PoweredByMeta = () => {
5
4
  if (process.env.NODE_ENV !== "production") return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/PoweredByMeta/index.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";;AAEA,SAAkB,iBAAiB;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,YAAU,MAAM;AACd,UAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAQ,OAAO;AACf,YAAQ,UAAU;AAClB,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/PoweredByMeta/index.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";AAEA,SAAkB,iBAAiB;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,YAAU,MAAM;AACd,UAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAQ,OAAO;AACf,YAAQ,UAAU;AAClB,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "3.5.10",
3
+ "version": "4.0.0",
4
4
  "private": false,
5
5
  "description": "Internationalization layer for React applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
6
6
  "keywords": [
@@ -45,21 +45,6 @@
45
45
  "require": "./dist/cjs/server/index.cjs",
46
46
  "import": "./dist/esm/server/index.mjs"
47
47
  },
48
- "./craco-plugin": {
49
- "types": "./dist/types/craco/intlayerCracoPlugin.d.ts",
50
- "require": "./dist/cjs/craco/intlayerCracoPlugin.cjs",
51
- "import": "./dist/esm/craco/intlayerCracoPlugin.mjs"
52
- },
53
- "./craco-config": {
54
- "types": "./dist/types/craco/craco.config.d.ts",
55
- "require": "./dist/cjs/craco/craco.config.cjs",
56
- "import": "./dist/esm/craco/craco.config.mjs"
57
- },
58
- "./vite": {
59
- "types": "./dist/types/vite/index.d.ts",
60
- "require": "./dist/cjs/vite/index.cjs",
61
- "import": "./dist/esm/vite/index.mjs"
62
- },
63
48
  "./editor": {
64
49
  "types": "./dist/types/editor/index.d.ts",
65
50
  "require": "./dist/cjs/editor/index.cjs",
@@ -85,22 +70,19 @@
85
70
  "./package.json"
86
71
  ],
87
72
  "dependencies": {
88
- "@craco/craco": "^7.1.0",
89
73
  "cross-spawn": "^7.0.6",
90
74
  "js-cookie": "^3.0.5",
91
- "node-loader": "^2.1.0",
92
75
  "vite": "^6.0.7",
93
76
  "webpack": "^5.97.1",
94
- "@intlayer/api": "3.5.10",
95
- "@intlayer/chokidar": "3.5.10",
96
- "@intlayer/config": "3.5.10",
97
- "@intlayer/core": "3.5.10",
98
- "@intlayer/dictionaries-entry": "3.5.10",
99
- "@intlayer/webpack": "3.5.10"
77
+ "@intlayer/chokidar": "4.0.0",
78
+ "@intlayer/core": "4.0.0",
79
+ "@intlayer/config": "4.0.0",
80
+ "@intlayer/api": "4.0.0",
81
+ "@intlayer/dictionaries-entry": "4.0.0",
82
+ "@intlayer/webpack": "4.0.0"
100
83
  },
101
84
  "devDependencies": {
102
85
  "@craco/types": "^7.1.0",
103
- "@types/cross-spawn": "^6.0.6",
104
86
  "@types/js-cookie": "^3.0.6",
105
87
  "@types/node": "^22.10.6",
106
88
  "@types/react": "^18.3.1",
@@ -115,7 +97,7 @@
115
97
  "tsc-alias": "^1.8.10",
116
98
  "tsup": "^8.3.5",
117
99
  "typescript": "^5.7.3",
118
- "@intlayer/backend": "3.5.10",
100
+ "@intlayer/backend": "4.0.0",
119
101
  "@utils/eslint-config": "1.0.4",
120
102
  "@utils/ts-config": "1.0.4",
121
103
  "@utils/ts-config-types": "1.0.4",
@@ -126,13 +108,12 @@
126
108
  "react-dom": ">=16.0.0",
127
109
  "vite": ">=4.0.0",
128
110
  "webpack": ">=5.0.0",
129
- "@intlayer/backend": "3.5.10",
130
- "@intlayer/chokidar": "3.5.10",
131
- "@intlayer/config": "3.5.10",
132
- "@intlayer/core": "3.5.10",
133
- "@intlayer/dictionaries-entry": "3.5.10",
134
- "intlayer": "3.5.10",
135
- "@intlayer/webpack": "3.5.10"
111
+ "@intlayer/chokidar": "4.0.0",
112
+ "@intlayer/dictionaries-entry": "4.0.0",
113
+ "intlayer": "4.0.0",
114
+ "@intlayer/webpack": "4.0.0",
115
+ "@intlayer/core": "4.0.0",
116
+ "@intlayer/config": "4.0.0"
136
117
  },
137
118
  "engines": {
138
119
  "node": ">=14.18"
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
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 (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
- var import_config = require("@intlayer/config");
26
- var import_cross_spawn = __toESM(require("cross-spawn"));
27
- const args = process.argv.slice(2);
28
- const scriptIndex = args.findIndex(
29
- (x) => x === "build" || x === "start" || x === "test"
30
- );
31
- const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
32
- switch (script) {
33
- case "build":
34
- case "start":
35
- case "test": {
36
- const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
37
- const scriptPath = import_config.ESMxCJSRequire.resolve(
38
- `@craco/craco/dist/scripts/${script}`
39
- );
40
- const scriptArgs = args.slice(scriptIndex + 1);
41
- const processArgs = nodeArgs.concat(scriptPath).concat([
42
- ...scriptArgs,
43
- "--config",
44
- "./node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs"
45
- ]);
46
- const child = import_cross_spawn.default.sync("node", processArgs, {
47
- stdio: "inherit"
48
- });
49
- if (child.signal) {
50
- if (child.signal === "SIGKILL") {
51
- (0, import_config.appLogger)(`
52
- The build failed because the process exited too early.
53
- This probably means the system ran out of memory or someone called
54
- \`kill -9\` on the process.
55
- `);
56
- } else if (child.signal === "SIGTERM") {
57
- (0, import_config.appLogger)(`
58
- The build failed because the process exited too early.
59
- Someone might have called \`kill\` or \`killall\`, or the system could
60
- be shutting down.
61
- `);
62
- }
63
- process.exit(1);
64
- }
65
- process.exit(child.status ?? void 0);
66
- break;
67
- }
68
- default:
69
- (0, import_config.appLogger)(`Unknown script "${script}".`);
70
- (0, import_config.appLogger)("Perhaps you need to update craco?");
71
- break;
72
- }
73
- //# sourceMappingURL=react-intlayer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cli/react-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire, appLogger } from '@intlayer/config';\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n appLogger(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n appLogger(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n appLogger(`Unknown script \"${script}\".`);\n appLogger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,oBAA0C;AAC1C,yBAAkB;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,6BAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,mBAAAA,QAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,iCAAU,mBAAmB,MAAM,IAAI;AACvC,iCAAU,mCAAmC;AAC7C;AACJ;","names":["spawn"]}
@@ -1,32 +0,0 @@
1
- "use strict";
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 (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var intlayerPlugin = __toESM(require('./intlayerCracoPlugin.cjs'));
25
- module.exports = {
26
- plugins: [
27
- {
28
- plugin: intlayerPlugin
29
- }
30
- ]
31
- };
32
- //# sourceMappingURL=craco.config.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/craco/craco.config.ts"],"sourcesContent":["import type { CracoConfig, CracoPlugin } from '@craco/types';\nimport * as intlayerPlugin from './intlayerCracoPlugin';\n\n// Usage Example\nmodule.exports = {\n plugins: [\n {\n plugin: intlayerPlugin as CracoPlugin,\n },\n ],\n} satisfies CracoConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,qBAAgC;AAGhC,OAAO,UAAU;AAAA,EACf,SAAS;AAAA,IACP;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AACF;","names":[]}
@@ -1,93 +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 intlayerCracoPlugin_exports = {};
20
- __export(intlayerCracoPlugin_exports, {
21
- overrideCracoConfig: () => overrideCracoConfig,
22
- overrideWebpackConfig: () => overrideWebpackConfig,
23
- plugin: () => plugin
24
- });
25
- module.exports = __toCommonJS(intlayerCracoPlugin_exports);
26
- var import_path = require("path");
27
- var import_config = require("@intlayer/config");
28
- var import_webpack = require("@intlayer/webpack");
29
- var import_webpack2 = require("webpack");
30
- var import_removeUndefinedValueObject = require('../utils/removeUndefinedValueObject.cjs');
31
- const intlayerConfig = (0, import_config.getConfiguration)();
32
- const env = (0, import_config.formatEnvVariable)("react_app");
33
- const overrideWebpackConfig = ({
34
- webpackConfig
35
- }) => {
36
- webpackConfig.externals = {
37
- ...typeof webpackConfig.externals === "object" ? webpackConfig.externals : {},
38
- esbuild: "esbuild",
39
- module: "module",
40
- fs: "fs",
41
- vm: "vm"
42
- };
43
- (webpackConfig.module?.rules ?? []).push({
44
- test: /\.node$/,
45
- use: "node-loader"
46
- });
47
- return webpackConfig;
48
- };
49
- const overrideCracoConfig = ({
50
- cracoConfig
51
- }) => {
52
- const { mainDir, baseDir } = intlayerConfig.content;
53
- const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
54
- const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
55
- return {
56
- ...cracoConfig,
57
- webpack: {
58
- ...cracoConfig.webpack,
59
- plugins: {
60
- ...cracoConfig.webpack?.plugins,
61
- add: [
62
- new import_webpack2.EnvironmentPlugin((0, import_removeUndefinedValueObject.removeUndefinedValueObject)(env)),
63
- new import_webpack.IntLayerPlugin()
64
- ]
65
- },
66
- configure: {
67
- ...cracoConfig.webpack?.configure ?? {},
68
- resolve: {
69
- ...cracoConfig.webpack?.configure?.resolve ?? {},
70
- fallback: {
71
- ...cracoConfig.webpack?.configure?.resolve?.fallback ?? {},
72
- process: import_config.ESMxCJSRequire.resolve("process/browser")
73
- }
74
- }
75
- },
76
- alias: {
77
- ...cracoConfig.webpack?.alias,
78
- "@intlayer/dictionaries-entry": (0, import_path.resolve)("./", relativeDictionariesPath)
79
- }
80
- }
81
- };
82
- };
83
- const plugin = {
84
- overrideCracoConfig,
85
- overrideWebpackConfig
86
- };
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- overrideCracoConfig,
90
- overrideWebpackConfig,
91
- plugin
92
- });
93
- //# sourceMappingURL=intlayerCracoPlugin.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport {\n getConfiguration,\n formatEnvVariable,\n ESMxCJSRequire,\n} from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport {\n type Configuration as WebpackConfig,\n EnvironmentPlugin,\n} from 'webpack';\nimport { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n configure: {\n ...(cracoConfig.webpack?.configure ?? {}),\n resolve: {\n ...(cracoConfig.webpack?.configure?.resolve ?? {}),\n fallback: {\n ...(cracoConfig.webpack?.configure?.resolve?.fallback ?? {}),\n process: ESMxCJSRequire.resolve('process/browser'),\n },\n },\n },\n\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAOxC,oBAIO;AACP,qBAAwD;AACxD,IAAAA,kBAGO;AACP,wCAA2C;AAG3C,MAAM,qBAAiB,gCAAiB;AAGxC,MAAM,UAA8B,iCAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,sCAAkB,8DAA2B,GAAG,CAAC;AAAA,UACrD,IAAI,eAAAC,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW;AAAA,QACT,GAAI,YAAY,SAAS,aAAa,CAAC;AAAA,QACvC,SAAS;AAAA,UACP,GAAI,YAAY,SAAS,WAAW,WAAW,CAAC;AAAA,UAChD,UAAU;AAAA,YACR,GAAI,YAAY,SAAS,WAAW,SAAS,YAAY,CAAC;AAAA,YAC1D,SAAS,6BAAe,QAAQ,iBAAiB;AAAA,UACnD;AAAA,QACF;AAAA,MACF;AAAA,MAEA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":["import_webpack","IntLayerWebpackPlugin"]}
@@ -1,38 +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 removeUndefinedValueObject_exports = {};
20
- __export(removeUndefinedValueObject_exports, {
21
- removeUndefinedValueObject: () => removeUndefinedValueObject
22
- });
23
- module.exports = __toCommonJS(removeUndefinedValueObject_exports);
24
- const removeUndefinedValueObject = (obj) => {
25
- const newObj = {};
26
- for (const key in obj) {
27
- if (obj[key] !== void 0) {
28
- newObj[key] = obj[key];
29
- }
30
- }
31
- Object.freeze(newObj);
32
- return newObj;
33
- };
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- removeUndefinedValueObject
37
- });
38
- //# sourceMappingURL=removeUndefinedValueObject.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
@@ -1,25 +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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var vite_exports = {};
17
- module.exports = __toCommonJS(vite_exports);
18
- __reExport(vite_exports, require('./intlayerPlugin.cjs'), module.exports);
19
- __reExport(vite_exports, require('./intlayerMiddlewarePlugin.cjs'), module.exports);
20
- // Annotate the CommonJS export names for ESM import in node:
21
- 0 && (module.exports = {
22
- ...require('./intlayerPlugin.cjs'),
23
- ...require('./intlayerMiddlewarePlugin.cjs')
24
- });
25
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/vite/index.ts"],"sourcesContent":["export * from './intlayerPlugin';\nexport * from './intlayerMiddlewarePlugin';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,6BAAd;AACA,yBAAc,uCADd;","names":[]}