@akinon/next 1.53.0 → 1.54.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 (63) hide show
  1. package/CHANGELOG.md +488 -0
  2. package/api/client.ts +50 -17
  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/bin/pz-generate-translations.js +41 -0
  7. package/bin/pz-prebuild.js +1 -0
  8. package/bin/pz-predev.js +1 -0
  9. package/components/file-input.tsx +8 -0
  10. package/components/index.ts +1 -0
  11. package/components/input.tsx +21 -7
  12. package/components/link.tsx +17 -13
  13. package/components/price.tsx +11 -4
  14. package/components/pz-root.tsx +15 -3
  15. package/components/selected-payment-option-view.tsx +26 -38
  16. package/data/client/account.ts +10 -9
  17. package/data/client/address.ts +32 -8
  18. package/data/client/api.ts +1 -1
  19. package/data/client/b2b.ts +35 -2
  20. package/data/client/basket.ts +6 -5
  21. package/data/client/checkout.ts +47 -4
  22. package/data/client/user.ts +3 -2
  23. package/data/server/category.ts +43 -19
  24. package/data/server/flatpage.ts +29 -7
  25. package/data/server/form.ts +29 -11
  26. package/data/server/landingpage.ts +26 -7
  27. package/data/server/list.ts +16 -6
  28. package/data/server/menu.ts +15 -2
  29. package/data/server/product.ts +46 -21
  30. package/data/server/seo.ts +17 -24
  31. package/data/server/special-page.ts +15 -5
  32. package/data/server/widget.ts +14 -7
  33. package/data/urls.ts +8 -1
  34. package/hocs/server/with-segment-defaults.tsx +4 -1
  35. package/hooks/index.ts +2 -1
  36. package/hooks/use-message-listener.ts +24 -0
  37. package/hooks/use-pagination.ts +2 -2
  38. package/hooks/use-payment-options.ts +2 -1
  39. package/lib/cache-handler.mjs +33 -0
  40. package/lib/cache.ts +8 -6
  41. package/middlewares/default.ts +87 -8
  42. package/middlewares/pretty-url.ts +11 -1
  43. package/middlewares/url-redirection.ts +4 -0
  44. package/package.json +4 -3
  45. package/plugins.d.ts +1 -0
  46. package/redux/middlewares/checkout.ts +70 -11
  47. package/redux/reducers/checkout.ts +24 -5
  48. package/redux/reducers/config.ts +2 -0
  49. package/routes/pretty-url.tsx +192 -0
  50. package/types/commerce/account.ts +1 -0
  51. package/types/commerce/address.ts +1 -1
  52. package/types/commerce/b2b.ts +12 -2
  53. package/types/commerce/checkout.ts +30 -0
  54. package/types/commerce/misc.ts +2 -0
  55. package/types/commerce/order.ts +5 -0
  56. package/types/index.ts +18 -2
  57. package/utils/app-fetch.ts +17 -8
  58. package/utils/generate-commerce-search-params.ts +3 -1
  59. package/utils/index.ts +27 -6
  60. package/utils/redirection-iframe.ts +85 -0
  61. package/utils/server-translation.ts +11 -1
  62. package/utils/server-variables.ts +2 -1
  63. package/with-pz-config.js +13 -2
@@ -8,7 +8,6 @@ import logger from './log';
8
8
 
9
9
  export const translations: Translations = {};
10
10
 
11
- // TODO: Read translations from cache
12
11
  export async function getTranslations(locale_: string) {
13
12
  try {
14
13
  const locale = settings.localization.locales.find(
@@ -55,3 +54,14 @@ export async function getTranslations(locale_: string) {
55
54
  export function t(path: string) {
56
55
  return getTranslateFn(path, translations);
57
56
  }
57
+
58
+ export async function t_(path: string, locale?: string) {
59
+ let translations_ = translations;
60
+
61
+ if (settings.useOptimizedTranslations && locale) {
62
+ const { getTranslations } = require('translations');
63
+ translations_ = await getTranslations(locale);
64
+ }
65
+
66
+ return getTranslateFn(path, translations_);
67
+ }
@@ -5,5 +5,6 @@ const { locales, defaultLocaleValue, defaultCurrencyCode } =
5
5
 
6
6
  export const ServerVariables = {
7
7
  locale: locales.find((l) => l.value === defaultLocaleValue)?.value ?? '',
8
- currency: defaultCurrencyCode
8
+ currency: defaultCurrencyCode,
9
+ globalHeaders: {}
9
10
  };
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
  },
@@ -56,7 +57,8 @@ const defaultConfig = {
56
57
  ...pzPlugins.reduce((acc, plugin) => {
57
58
  acc[`@akinon/${plugin}`] = false;
58
59
  return acc;
59
- }, {})
60
+ }, {}),
61
+ translations: false
60
62
  };
61
63
  return config;
62
64
  },
@@ -65,7 +67,12 @@ const defaultConfig = {
65
67
  }
66
68
  };
67
69
 
68
- const withPzConfig = (myNextConfig = {}) => {
70
+ const withPzConfig = (
71
+ myNextConfig = {},
72
+ options = {
73
+ useCacheHandler: false
74
+ }
75
+ ) => {
69
76
  let extendedConfig = deepMerge({}, defaultConfig, myNextConfig);
70
77
 
71
78
  const originalPzHeadersFunction = defaultConfig.headers;
@@ -91,6 +98,10 @@ const withPzConfig = (myNextConfig = {}) => {
91
98
  return [...pzRewrites, ...myRewrites];
92
99
  };
93
100
 
101
+ if (options.useCacheHandler && process.env.CACHE_HOST) {
102
+ extendedConfig.cacheHandler = require.resolve('./lib/cache-handler.mjs');
103
+ }
104
+
94
105
  return extendedConfig;
95
106
  };
96
107