@uniformdev/canvas-next 19.99.1-alpha.0 → 19.103.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.
@@ -6,6 +6,7 @@ import { ParsedUrlQuery } from 'querystring';
6
6
  import { RouteGetResponseEdgehancedComposition, RouteGetResponseNotFound, RouteGetResponseRedirect, RouteClient, RouteGetParameters, RootComponentInstance } from '@uniformdev/canvas';
7
7
  import { ProjectMapNodeGetResponse, ProjectMapClient } from '@uniformdev/project-map';
8
8
  import { RedirectClient } from '@uniformdev/redirect';
9
+ import { GetStaticPropsContext as GetStaticPropsContext$1, GetServerSidePropsContext as GetServerSidePropsContext$1 } from 'next/types';
9
10
  import '@uniformdev/canvas-react';
10
11
 
11
12
  type HandleRouteCompositionFunction<TContext, TResult> = (composition: RouteGetResponseEdgehancedComposition, context: TContext, defaultHandler: (composition: RouteGetResponseEdgehancedComposition) => Promise<TResult | null> | TResult | null, duration: number) => Promise<TResult | null> | TResult | null;
@@ -98,6 +99,17 @@ declare const withUniformGetStaticProps: <TProps extends {
98
99
  param?: string | undefined;
99
100
  }) | undefined) => GetStaticProps<TProps, ParsedUrlQuery, UniformPreviewData>;
100
101
 
102
+ /**
103
+ * Prepends correct locale to the path before sending it to Uniform Route API.
104
+ *
105
+ * Recommended default callback for `options.modifyPath` in `withUniformGetStaticProps` and `withUniformGetServerSideProps`.
106
+ * Should be used together with Next.js Internationalization Routing.
107
+ *
108
+ * @see https://nextjs.org/docs/pages/building-your-application/routing/internationalization
109
+ * @see https://docs.uniform.app/docs/guides/composition/localization#enable-localization-on-your-frontend-application
110
+ */
111
+ declare const prependLocale: (path: string, { locale, defaultLocale, locales }: GetStaticPropsContext$1 | GetServerSidePropsContext$1) => string;
112
+
101
113
  /**
102
114
  * Default implementation of getServerSideProps with routes
103
115
  * To configure custom behavior, use:
@@ -192,6 +204,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
192
204
  } | undefined;
193
205
  variants?: boolean | undefined;
194
206
  } | undefined;
207
+ _locales?: string[] | undefined;
195
208
  }[];
196
209
  } | undefined;
197
210
  _id: string;
@@ -339,6 +352,7 @@ declare const getStaticProps: next.GetStaticProps<{
339
352
  } | undefined;
340
353
  variants?: boolean | undefined;
341
354
  } | undefined;
355
+ _locales?: string[] | undefined;
342
356
  }[];
343
357
  } | undefined;
344
358
  _id: string;
@@ -404,4 +418,4 @@ declare const getStaticPaths: () => Promise<{
404
418
  fallback: boolean;
405
419
  }>;
406
420
 
407
- export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
421
+ export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, prependLocale, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
@@ -6,6 +6,7 @@ import { ParsedUrlQuery } from 'querystring';
6
6
  import { RouteGetResponseEdgehancedComposition, RouteGetResponseNotFound, RouteGetResponseRedirect, RouteClient, RouteGetParameters, RootComponentInstance } from '@uniformdev/canvas';
7
7
  import { ProjectMapNodeGetResponse, ProjectMapClient } from '@uniformdev/project-map';
8
8
  import { RedirectClient } from '@uniformdev/redirect';
9
+ import { GetStaticPropsContext as GetStaticPropsContext$1, GetServerSidePropsContext as GetServerSidePropsContext$1 } from 'next/types';
9
10
  import '@uniformdev/canvas-react';
10
11
 
11
12
  type HandleRouteCompositionFunction<TContext, TResult> = (composition: RouteGetResponseEdgehancedComposition, context: TContext, defaultHandler: (composition: RouteGetResponseEdgehancedComposition) => Promise<TResult | null> | TResult | null, duration: number) => Promise<TResult | null> | TResult | null;
@@ -98,6 +99,17 @@ declare const withUniformGetStaticProps: <TProps extends {
98
99
  param?: string | undefined;
99
100
  }) | undefined) => GetStaticProps<TProps, ParsedUrlQuery, UniformPreviewData>;
100
101
 
102
+ /**
103
+ * Prepends correct locale to the path before sending it to Uniform Route API.
104
+ *
105
+ * Recommended default callback for `options.modifyPath` in `withUniformGetStaticProps` and `withUniformGetServerSideProps`.
106
+ * Should be used together with Next.js Internationalization Routing.
107
+ *
108
+ * @see https://nextjs.org/docs/pages/building-your-application/routing/internationalization
109
+ * @see https://docs.uniform.app/docs/guides/composition/localization#enable-localization-on-your-frontend-application
110
+ */
111
+ declare const prependLocale: (path: string, { locale, defaultLocale, locales }: GetStaticPropsContext$1 | GetServerSidePropsContext$1) => string;
112
+
101
113
  /**
102
114
  * Default implementation of getServerSideProps with routes
103
115
  * To configure custom behavior, use:
@@ -192,6 +204,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
192
204
  } | undefined;
193
205
  variants?: boolean | undefined;
194
206
  } | undefined;
207
+ _locales?: string[] | undefined;
195
208
  }[];
196
209
  } | undefined;
197
210
  _id: string;
@@ -339,6 +352,7 @@ declare const getStaticProps: next.GetStaticProps<{
339
352
  } | undefined;
340
353
  variants?: boolean | undefined;
341
354
  } | undefined;
355
+ _locales?: string[] | undefined;
342
356
  }[];
343
357
  } | undefined;
344
358
  _id: string;
@@ -404,4 +418,4 @@ declare const getStaticPaths: () => Promise<{
404
418
  fallback: boolean;
405
419
  }>;
406
420
 
407
- export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
421
+ export { type HandleRouteCompositionFunction, type HandleRouteNotFoundFunction, type HandleRouteRedirectFunction, type RouteHandlerOptions, getServerSideProps, getStaticPaths, getStaticProps, prependLocale, withUniformGetServerSideProps, withUniformGetStaticPaths, withUniformGetStaticProps };
@@ -23,6 +23,7 @@ __export(route_exports, {
23
23
  getServerSideProps: () => getServerSideProps,
24
24
  getStaticPaths: () => getStaticPaths,
25
25
  getStaticProps: () => getStaticProps,
26
+ prependLocale: () => prependLocale,
26
27
  withUniformGetServerSideProps: () => withUniformGetServerSideProps,
27
28
  withUniformGetStaticPaths: () => withUniformGetStaticPaths,
28
29
  withUniformGetStaticProps: () => withUniformGetStaticProps
@@ -474,6 +475,14 @@ var withUniformGetStaticProps = (options) => {
474
475
  return routeFetcher;
475
476
  };
476
477
 
478
+ // src/route/localePathModifier.ts
479
+ var prependLocale = (path, { locale, defaultLocale, locales }) => {
480
+ if (!(locales == null ? void 0 : locales.length))
481
+ return path;
482
+ const slug = path === "/" ? "" : path;
483
+ return decodeURI(`/${locale || defaultLocale}${slug}`);
484
+ };
485
+
477
486
  // src/route/index.ts
478
487
  var getServerSideProps = withUniformGetServerSideProps();
479
488
  var getStaticProps = withUniformGetStaticProps();
@@ -483,6 +492,7 @@ var getStaticPaths = withUniformGetStaticPaths();
483
492
  getServerSideProps,
484
493
  getStaticPaths,
485
494
  getStaticProps,
495
+ prependLocale,
486
496
  withUniformGetServerSideProps,
487
497
  withUniformGetStaticPaths,
488
498
  withUniformGetStaticProps
@@ -342,6 +342,14 @@ var withUniformGetStaticProps = (options) => {
342
342
  return routeFetcher;
343
343
  };
344
344
 
345
+ // src/route/localePathModifier.ts
346
+ var prependLocale = (path, { locale, defaultLocale, locales }) => {
347
+ if (!(locales == null ? void 0 : locales.length))
348
+ return path;
349
+ const slug = path === "/" ? "" : path;
350
+ return decodeURI(`/${locale || defaultLocale}${slug}`);
351
+ };
352
+
345
353
  // src/route/index.ts
346
354
  var getServerSideProps = withUniformGetServerSideProps();
347
355
  var getStaticProps = withUniformGetStaticProps();
@@ -350,6 +358,7 @@ export {
350
358
  getServerSideProps,
351
359
  getStaticPaths,
352
360
  getStaticProps,
361
+ prependLocale,
353
362
  withUniformGetServerSideProps,
354
363
  withUniformGetStaticPaths,
355
364
  withUniformGetStaticProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "19.99.1-alpha.0+ccafd6a7e",
3
+ "version": "19.103.0",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -67,11 +67,11 @@
67
67
  "document": "api-extractor run --local"
68
68
  },
69
69
  "dependencies": {
70
- "@uniformdev/canvas": "19.99.1-alpha.0+ccafd6a7e",
71
- "@uniformdev/canvas-react": "19.99.1-alpha.0+ccafd6a7e",
72
- "@uniformdev/project-map": "19.99.1-alpha.0+ccafd6a7e",
73
- "@uniformdev/redirect": "19.99.1-alpha.0+ccafd6a7e",
74
- "@uniformdev/richtext": "19.99.1-alpha.0+ccafd6a7e",
70
+ "@uniformdev/canvas": "19.103.0",
71
+ "@uniformdev/canvas-react": "19.103.0",
72
+ "@uniformdev/project-map": "19.103.0",
73
+ "@uniformdev/redirect": "19.103.0",
74
+ "@uniformdev/richtext": "19.103.0",
75
75
  "colorette": "2.0.20"
76
76
  },
77
77
  "peerDependencies": {
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "ccafd6a7ec5eadfdd2c203dd22c8d2c2eab718e3"
94
+ "gitHead": "ebdcac3a77d293bff272925f62f8c1c10be855bc"
95
95
  }