@akinon/next 1.46.0 → 1.47.0-rc.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 (53) hide show
  1. package/CHANGELOG.md +365 -0
  2. package/api/client.ts +39 -9
  3. package/assets/styles/index.css +49 -0
  4. package/assets/styles/index.css.map +1 -0
  5. package/assets/styles/index.scss +50 -26
  6. package/components/file-input.tsx +8 -0
  7. package/components/index.ts +1 -0
  8. package/components/input.tsx +21 -7
  9. package/components/link.tsx +17 -13
  10. package/components/pagination.tsx +1 -2
  11. package/components/price.tsx +11 -4
  12. package/components/selected-payment-option-view.tsx +26 -38
  13. package/data/client/account.ts +10 -9
  14. package/data/client/address.ts +32 -8
  15. package/data/client/api.ts +2 -2
  16. package/data/client/b2b.ts +35 -2
  17. package/data/client/basket.ts +6 -5
  18. package/data/client/checkout.ts +47 -4
  19. package/data/client/wishlist.ts +70 -2
  20. package/data/server/category.ts +2 -2
  21. package/data/server/list.ts +2 -2
  22. package/data/server/product.ts +15 -13
  23. package/data/server/special-page.ts +2 -2
  24. package/data/urls.ts +17 -3
  25. package/hooks/index.ts +2 -1
  26. package/hooks/use-message-listener.ts +24 -0
  27. package/hooks/use-payment-options.ts +2 -1
  28. package/lib/cache-handler.mjs +33 -0
  29. package/lib/cache.ts +18 -6
  30. package/middlewares/default.ts +50 -2
  31. package/middlewares/locale.ts +32 -30
  32. package/middlewares/pretty-url.ts +4 -0
  33. package/middlewares/url-redirection.ts +4 -0
  34. package/package.json +5 -4
  35. package/plugins.d.ts +1 -0
  36. package/redux/middlewares/checkout.ts +70 -11
  37. package/redux/reducers/checkout.ts +24 -5
  38. package/redux/reducers/config.ts +2 -0
  39. package/routes/pretty-url.tsx +194 -0
  40. package/types/commerce/account.ts +1 -0
  41. package/types/commerce/address.ts +1 -1
  42. package/types/commerce/b2b.ts +12 -2
  43. package/types/commerce/checkout.ts +30 -0
  44. package/types/commerce/misc.ts +2 -0
  45. package/types/commerce/order.ts +12 -0
  46. package/types/index.ts +30 -2
  47. package/utils/app-fetch.ts +1 -1
  48. package/utils/generate-commerce-search-params.ts +6 -2
  49. package/utils/index.ts +27 -6
  50. package/utils/menu-generator.ts +2 -2
  51. package/utils/redirection-iframe.ts +85 -0
  52. package/utils/server-translation.ts +5 -1
  53. package/with-pz-config.js +11 -1
@@ -5,10 +5,10 @@ import { getTranslateFn } from '../utils';
5
5
  import { Translations } from '../types';
6
6
  import settings from 'settings';
7
7
  import logger from './log';
8
+ import { unstable_cache } from 'next/cache';
8
9
 
9
10
  export const translations: Translations = {};
10
11
 
11
- // TODO: Read translations from cache
12
12
  export async function getTranslations(locale_: string) {
13
13
  try {
14
14
  const locale = settings.localization.locales.find(
@@ -52,6 +52,10 @@ export async function getTranslations(locale_: string) {
52
52
  return translations;
53
53
  }
54
54
 
55
+ export const getCachedTranslations = unstable_cache(async (locale: string) =>
56
+ getTranslations(locale)
57
+ );
58
+
55
59
  export function t(path: string) {
56
60
  return getTranslateFn(path, translations);
57
61
  }
package/with-pz-config.js CHANGED
@@ -8,6 +8,7 @@ const defaultConfig = {
8
8
  transpilePackages: ['@akinon/next', ...pzPlugins.map((p) => `@akinon/${p}`)],
9
9
  skipTrailingSlashRedirect: true,
10
10
  poweredByHeader: false,
11
+ cacheMaxMemorySize: 0,
11
12
  env: {
12
13
  NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN
13
14
  },
@@ -65,7 +66,12 @@ const defaultConfig = {
65
66
  }
66
67
  };
67
68
 
68
- const withPzConfig = (myNextConfig = {}) => {
69
+ const withPzConfig = (
70
+ myNextConfig = {},
71
+ options = {
72
+ useCacheHandler: false
73
+ }
74
+ ) => {
69
75
  let extendedConfig = deepMerge({}, defaultConfig, myNextConfig);
70
76
 
71
77
  const originalPzHeadersFunction = defaultConfig.headers;
@@ -91,6 +97,10 @@ const withPzConfig = (myNextConfig = {}) => {
91
97
  return [...pzRewrites, ...myRewrites];
92
98
  };
93
99
 
100
+ if (options.useCacheHandler && process.env.CACHE_HOST) {
101
+ extendedConfig.cacheHandler = require.resolve('./lib/cache-handler.mjs');
102
+ }
103
+
94
104
  return extendedConfig;
95
105
  };
96
106