@uniformdev/canvas-next 19.79.1-alpha.11 → 19.79.1-alpha.18

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.
@@ -20,17 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/route/index.ts
21
21
  var route_exports = {};
22
22
  __export(route_exports, {
23
- getServerSideProps: () => getServerSideProps2,
24
- getStaticPaths: () => getStaticPaths2,
25
- getStaticProps: () => getStaticProps2,
26
- withUniformGetServerSideProps: () => withUniformGetServerSideProps2,
23
+ getServerSideProps: () => getServerSideProps,
24
+ getStaticPaths: () => getStaticPaths,
25
+ getStaticProps: () => getStaticProps,
26
+ prependLocale: () => prependLocale,
27
+ withUniformGetServerSideProps: () => withUniformGetServerSideProps,
27
28
  withUniformGetStaticPaths: () => withUniformGetStaticPaths,
28
- withUniformGetStaticProps: () => withUniformGetStaticProps2
29
+ withUniformGetStaticProps: () => withUniformGetStaticProps
29
30
  });
30
31
  module.exports = __toCommonJS(route_exports);
31
32
 
32
- // src/project-map/withUniformGetServerSideProps.ts
33
+ // src/route/withUniformGetServerSideProps.ts
34
+ var import_canvas2 = require("@uniformdev/canvas");
35
+ var import_redirect = require("@uniformdev/redirect");
36
+
37
+ // src/route/createRouteFetcher.ts
33
38
  var import_canvas = require("@uniformdev/canvas");
39
+ var import_colorette6 = require("colorette");
34
40
 
35
41
  // src/logging/logCompositionIssues.ts
36
42
  var import_colorette = require("colorette");
@@ -183,163 +189,7 @@ function logRouteResponse(response, duration) {
183
189
  logRouteCompositionResponse(response, duration);
184
190
  }
185
191
 
186
- // src/project-map/withUniformGetServerSideProps.ts
187
- var withUniformGetServerSideProps = (options) => {
188
- const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
189
- apiKey: process.env.UNIFORM_API_KEY,
190
- projectId: process.env.UNIFORM_PROJECT_ID,
191
- apiHost: process.env.UNIFORM_CLI_BASE_URL,
192
- edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
193
- });
194
- return async function wrappedGetServerSideProps(context) {
195
- var _a, _b;
196
- const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
197
- const { preview, previewData } = context;
198
- let composition = void 0;
199
- let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
200
- if (options == null ? void 0 : options.modifyPath) {
201
- nodePath = options.modifyPath(nodePath, context);
202
- }
203
- if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
204
- composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
205
- } else {
206
- try {
207
- const time = Date.now();
208
- const response = await canvasClient.getCompositionByNodePath({
209
- ...options == null ? void 0 : options.requestOptions,
210
- projectMapId,
211
- projectMapNodePath: nodePath,
212
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
213
- });
214
- const duration = Date.now() - time;
215
- composition = response.composition;
216
- if (!(options == null ? void 0 : options.silent)) {
217
- logCompositionResponse(response, duration);
218
- }
219
- } catch (e) {
220
- console.error("[canvas-next] Failed to fetch composition", e);
221
- return {
222
- notFound: true
223
- };
224
- }
225
- }
226
- const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
227
- if (Object.hasOwn(ret, "props")) {
228
- const casted = ret;
229
- casted.props["data"] = composition;
230
- }
231
- return ret;
232
- };
233
- };
234
-
235
- // src/project-map/withUniformGetStaticPaths.ts
236
- var import_canvas2 = require("@uniformdev/canvas");
237
- var import_project_map = require("@uniformdev/project-map");
238
- var withUniformGetStaticPaths = (options) => {
239
- return async function wrappedGetStaticPaths() {
240
- var _a, _b;
241
- const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
242
- const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new import_project_map.ProjectMapClient({
243
- apiKey: process.env.UNIFORM_API_KEY,
244
- projectId: process.env.UNIFORM_PROJECT_ID,
245
- apiHost: process.env.UNIFORM_CLI_BASE_URL
246
- });
247
- const response = await projectMapClient.getNodes({
248
- ...options == null ? void 0 : options.requestOptions,
249
- path: options == null ? void 0 : options.rootPath,
250
- projectMapId,
251
- state: (options == null ? void 0 : options.preview) ? import_canvas2.CANVAS_DRAFT_STATE : import_canvas2.CANVAS_PUBLISHED_STATE
252
- });
253
- const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
254
- const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
255
- var _a2;
256
- return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
257
- });
258
- return {
259
- paths,
260
- fallback: true
261
- };
262
- };
263
- };
264
-
265
- // src/project-map/withUniformGetStaticProps.ts
266
- var import_canvas3 = require("@uniformdev/canvas");
267
-
268
- // src/helpers/resolveSlugFromParams.ts
269
- var resolveSlugFromParams = ({
270
- param = "slug",
271
- params
272
- }) => {
273
- const slug = (params == null ? void 0 : params[param]) || "";
274
- const slugString = Array.isArray(slug) ? slug.join("/") : slug;
275
- return `/${slugString}`;
276
- };
277
-
278
- // src/project-map/withUniformGetStaticProps.ts
279
- var withUniformGetStaticProps = (options) => {
280
- var _a;
281
- const canvasClient = (_a = options == null ? void 0 : options.client) != null ? _a : new import_canvas3.CanvasClient({
282
- apiKey: process.env.UNIFORM_API_KEY,
283
- projectId: process.env.UNIFORM_PROJECT_ID,
284
- apiHost: process.env.UNIFORM_CLI_BASE_URL,
285
- edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
286
- });
287
- return async function wrappedGetStaticProps(context) {
288
- var _a2, _b;
289
- const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
290
- let pathString = resolveSlugFromParams({
291
- param: options == null ? void 0 : options.param,
292
- params: context == null ? void 0 : context.params
293
- });
294
- if (options == null ? void 0 : options.modifyPath) {
295
- pathString = options.modifyPath(pathString, context);
296
- }
297
- const { preview, previewData } = context;
298
- let composition = void 0;
299
- if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
300
- composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas3.EMPTY_COMPOSITION._id };
301
- } else {
302
- try {
303
- const time = Date.now();
304
- const response = await canvasClient.getCompositionByNodePath({
305
- ...options == null ? void 0 : options.requestOptions,
306
- projectMapId,
307
- projectMapNodePath: pathString,
308
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
309
- });
310
- const duration = Date.now() - time;
311
- composition = response.composition;
312
- if (!(options == null ? void 0 : options.silent)) {
313
- logCompositionResponse(response, duration);
314
- }
315
- } catch (e) {
316
- console.error("[canvas-next] Failed to fetch composition", e);
317
- return {
318
- notFound: true
319
- };
320
- }
321
- }
322
- const ret = options.callback ? await options.callback(context, composition) : { props: {} };
323
- if (composition && Object.hasOwn(ret, "props")) {
324
- const casted = ret;
325
- casted.props["data"] = composition;
326
- }
327
- return ret;
328
- };
329
- };
330
-
331
- // src/project-map/index.ts
332
- var getServerSideProps = withUniformGetServerSideProps();
333
- var getStaticProps = withUniformGetStaticProps({ param: "path" });
334
- var getStaticPaths = withUniformGetStaticPaths();
335
-
336
- // src/route/withUniformGetServerSideProps.ts
337
- var import_canvas5 = require("@uniformdev/canvas");
338
- var import_redirect = require("@uniformdev/redirect");
339
-
340
192
  // src/route/createRouteFetcher.ts
341
- var import_canvas4 = require("@uniformdev/canvas");
342
- var import_colorette6 = require("colorette");
343
193
  function createRouteFetcher(options) {
344
194
  const {
345
195
  handleNotFound,
@@ -356,7 +206,7 @@ function createRouteFetcher(options) {
356
206
  silent,
357
207
  parseContext
358
208
  } = options;
359
- const routeClient = client || new import_canvas4.RouteClient({
209
+ const routeClient = client || new import_canvas.RouteClient({
360
210
  apiKey: process.env.UNIFORM_API_KEY,
361
211
  projectId: process.env.UNIFORM_PROJECT_ID,
362
212
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
@@ -419,8 +269,8 @@ function createRouteFetcher(options) {
419
269
  matchedRoute: "contextual-editing",
420
270
  compositionApiResponse: {
421
271
  composition: {
422
- ...import_canvas4.EMPTY_COMPOSITION,
423
- _id: contextualEditingCompositionId != null ? contextualEditingCompositionId : import_canvas4.EMPTY_COMPOSITION._id
272
+ ...import_canvas.EMPTY_COMPOSITION,
273
+ _id: contextualEditingCompositionId != null ? contextualEditingCompositionId : import_canvas.EMPTY_COMPOSITION._id
424
274
  }
425
275
  }
426
276
  },
@@ -436,7 +286,7 @@ function createRouteFetcher(options) {
436
286
  const time = Date.now();
437
287
  const response = await routeClient.getRoute({
438
288
  ...resolvedOptions,
439
- state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : import_canvas4.CANVAS_PUBLISHED_STATE,
289
+ state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : import_canvas.CANVAS_PUBLISHED_STATE,
440
290
  projectMapId,
441
291
  path: nodePath
442
292
  });
@@ -457,7 +307,7 @@ function createRouteFetcher(options) {
457
307
  return handleResult;
458
308
  } catch (e) {
459
309
  console.error((0, import_colorette6.red)("Failed to fetch route"), e);
460
- if (e instanceof import_canvas4.ApiClientError) {
310
+ if (e instanceof import_canvas.ApiClientError) {
461
311
  if (e.statusCode === 404) {
462
312
  return invokeNotFoundResult({ type: "notFound" }, 0);
463
313
  }
@@ -470,7 +320,7 @@ function createRouteFetcher(options) {
470
320
  }
471
321
 
472
322
  // src/route/withUniformGetServerSideProps.ts
473
- var withUniformGetServerSideProps2 = (options) => {
323
+ var withUniformGetServerSideProps = (options) => {
474
324
  const defaultHandleRedirect = (requestUrl, matched, context) => {
475
325
  if (matched.redirect.targetStatusCode > 400) {
476
326
  return {
@@ -481,7 +331,8 @@ var withUniformGetServerSideProps2 = (options) => {
481
331
  return {
482
332
  redirect: {
483
333
  destination: (0, import_redirect.getTargetVariableExpandedUrl)(absoluteUrl, matched.redirect),
484
- statusCode: matched.redirect.targetStatusCode
334
+ statusCode: matched.redirect.targetStatusCode,
335
+ basePath: matched.redirect.targetPreserveIncomingDomain === false || matched.redirect.targetPreserveIncomingProtocol === false ? false : void 0
485
336
  }
486
337
  };
487
338
  };
@@ -507,21 +358,87 @@ var withUniformGetServerSideProps2 = (options) => {
507
358
  resolvedUrl: context.resolvedUrl,
508
359
  // auto engage draft content when in next preview mode
509
360
  // (can override with explicit setting of request options)'
510
- defaultFetchState: context.preview ? import_canvas5.CANVAS_DRAFT_STATE : void 0
361
+ defaultFetchState: context.preview ? import_canvas2.CANVAS_DRAFT_STATE : void 0
511
362
  };
512
363
  }
513
364
  });
514
365
  return routeFetcher;
515
366
  };
516
367
 
517
- // src/route/withUniformGetStaticProps.ts
518
- var import_canvas6 = require("@uniformdev/canvas");
368
+ // src/route/withUniformGetStaticPaths.ts
369
+ var import_canvas3 = require("@uniformdev/canvas");
370
+ var import_project_map = require("@uniformdev/project-map");
519
371
  var import_redirect2 = require("@uniformdev/redirect");
520
- var withUniformGetStaticProps2 = (options) => {
372
+ var findChildRedirects = async (allRedirects, parentPath) => {
373
+ const children = [];
374
+ let redirect = await allRedirects.next();
375
+ while (!redirect.done) {
376
+ const index = parentPath ? redirect.value.redirect.sourceUrl.indexOf(parentPath) : 0;
377
+ if (index > -1) {
378
+ children.push(redirect.value);
379
+ }
380
+ redirect = await allRedirects.next();
381
+ }
382
+ return children;
383
+ };
384
+ var withUniformGetStaticPaths = (options) => {
385
+ return async function wrappedGetStaticPaths() {
386
+ var _a, _b, _c;
387
+ const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
388
+ const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new import_project_map.ProjectMapClient({
389
+ apiKey: process.env.UNIFORM_API_KEY,
390
+ projectId: process.env.UNIFORM_PROJECT_ID,
391
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
392
+ });
393
+ const finalRedirectClient = (_c = options == null ? void 0 : options.redirectClient) != null ? _c : new import_redirect2.RedirectClient({
394
+ apiKey: process.env.UNIFORM_API_KEY,
395
+ projectId: process.env.UNIFORM_PROJECT_ID,
396
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
397
+ });
398
+ const [response, redirectResponse] = await Promise.all([
399
+ projectMapClient.getNodes({
400
+ ...options == null ? void 0 : options.requestOptions,
401
+ path: options == null ? void 0 : options.rootPath,
402
+ projectMapId,
403
+ state: (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
404
+ }),
405
+ finalRedirectClient.getAllRedirects()
406
+ ]);
407
+ const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
408
+ const redirectSources = (await findChildRedirects(redirectResponse, options == null ? void 0 : options.rootPath)).map(
409
+ (r) => r.redirect.sourceUrl
410
+ );
411
+ const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
412
+ var _a2;
413
+ return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
414
+ });
415
+ return {
416
+ paths: [...paths != null ? paths : [], ...redirectSources],
417
+ fallback: true
418
+ };
419
+ };
420
+ };
421
+
422
+ // src/route/withUniformGetStaticProps.ts
423
+ var import_canvas4 = require("@uniformdev/canvas");
424
+ var import_redirect3 = require("@uniformdev/redirect");
425
+
426
+ // src/helpers/resolveSlugFromParams.ts
427
+ var resolveSlugFromParams = ({
428
+ param = "slug",
429
+ params
430
+ }) => {
431
+ const slug = (params == null ? void 0 : params[param]) || "";
432
+ const slugString = Array.isArray(slug) ? slug.join("/") : slug;
433
+ return `/${slugString}`;
434
+ };
435
+
436
+ // src/route/withUniformGetStaticProps.ts
437
+ var withUniformGetStaticProps = (options) => {
521
438
  const defaultHandleRedirect = (requestUrl, matched) => {
522
439
  return {
523
440
  redirect: {
524
- destination: (0, import_redirect2.getTargetVariableExpandedUrl)(requestUrl, matched.redirect),
441
+ destination: (0, import_redirect3.getTargetVariableExpandedUrl)(requestUrl, matched.redirect),
525
442
  statusCode: matched.redirect.targetStatusCode
526
443
  }
527
444
  };
@@ -551,22 +468,31 @@ var withUniformGetStaticProps2 = (options) => {
551
468
  }),
552
469
  // auto engage draft content when in next preview mode
553
470
  // (can override with explicit setting of request options)
554
- defaultFetchState: context.preview ? import_canvas6.CANVAS_DRAFT_STATE : void 0
471
+ defaultFetchState: context.preview ? import_canvas4.CANVAS_DRAFT_STATE : void 0
555
472
  };
556
473
  }
557
474
  });
558
475
  return routeFetcher;
559
476
  };
560
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
+
561
486
  // src/route/index.ts
562
- var getServerSideProps2 = withUniformGetServerSideProps2();
563
- var getStaticProps2 = withUniformGetStaticProps2();
564
- var getStaticPaths2 = withUniformGetStaticPaths();
487
+ var getServerSideProps = withUniformGetServerSideProps();
488
+ var getStaticProps = withUniformGetStaticProps();
489
+ var getStaticPaths = withUniformGetStaticPaths();
565
490
  // Annotate the CommonJS export names for ESM import in node:
566
491
  0 && (module.exports = {
567
492
  getServerSideProps,
568
493
  getStaticPaths,
569
494
  getStaticProps,
495
+ prependLocale,
570
496
  withUniformGetServerSideProps,
571
497
  withUniformGetStaticPaths,
572
498
  withUniformGetStaticProps
@@ -1,6 +1,3 @@
1
- import {
2
- withUniformGetStaticPaths
3
- } from "../chunk-ZLQ2WCJC.mjs";
4
1
  import {
5
2
  logCompositionResponse
6
3
  } from "../chunk-JQWYBVLI.mjs";
@@ -8,6 +5,19 @@ import {
8
5
  resolveSlugFromParams
9
6
  } from "../chunk-TR7V6ABJ.mjs";
10
7
 
8
+ // src/route/withUniformGetServerSideProps.ts
9
+ import { CANVAS_DRAFT_STATE } from "@uniformdev/canvas";
10
+ import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
11
+
12
+ // src/route/createRouteFetcher.ts
13
+ import {
14
+ ApiClientError,
15
+ CANVAS_PUBLISHED_STATE,
16
+ EMPTY_COMPOSITION,
17
+ RouteClient
18
+ } from "@uniformdev/canvas";
19
+ import { red as red2 } from "colorette";
20
+
11
21
  // src/logging/logCompositionRouteResponse.ts
12
22
  import { gray, green, red, yellow } from "colorette";
13
23
  function logRouteCompositionResponse(matched, duration) {
@@ -56,18 +66,7 @@ function logRouteResponse(response, duration) {
56
66
  logRouteCompositionResponse(response, duration);
57
67
  }
58
68
 
59
- // src/route/withUniformGetServerSideProps.ts
60
- import { CANVAS_DRAFT_STATE } from "@uniformdev/canvas";
61
- import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
62
-
63
69
  // src/route/createRouteFetcher.ts
64
- import {
65
- ApiClientError,
66
- CANVAS_PUBLISHED_STATE,
67
- EMPTY_COMPOSITION,
68
- RouteClient
69
- } from "@uniformdev/canvas";
70
- import { red as red2 } from "colorette";
71
70
  function createRouteFetcher(options) {
72
71
  const {
73
72
  handleNotFound,
@@ -209,7 +208,8 @@ var withUniformGetServerSideProps = (options) => {
209
208
  return {
210
209
  redirect: {
211
210
  destination: getTargetVariableExpandedUrl(absoluteUrl, matched.redirect),
212
- statusCode: matched.redirect.targetStatusCode
211
+ statusCode: matched.redirect.targetStatusCode,
212
+ basePath: matched.redirect.targetPreserveIncomingDomain === false || matched.redirect.targetPreserveIncomingProtocol === false ? false : void 0
213
213
  }
214
214
  };
215
215
  };
@@ -242,8 +242,64 @@ var withUniformGetServerSideProps = (options) => {
242
242
  return routeFetcher;
243
243
  };
244
244
 
245
+ // src/route/withUniformGetStaticPaths.ts
246
+ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2, CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2 } from "@uniformdev/canvas";
247
+ import {
248
+ ProjectMapClient
249
+ } from "@uniformdev/project-map";
250
+ import { RedirectClient } from "@uniformdev/redirect";
251
+ var findChildRedirects = async (allRedirects, parentPath) => {
252
+ const children = [];
253
+ let redirect = await allRedirects.next();
254
+ while (!redirect.done) {
255
+ const index = parentPath ? redirect.value.redirect.sourceUrl.indexOf(parentPath) : 0;
256
+ if (index > -1) {
257
+ children.push(redirect.value);
258
+ }
259
+ redirect = await allRedirects.next();
260
+ }
261
+ return children;
262
+ };
263
+ var withUniformGetStaticPaths = (options) => {
264
+ return async function wrappedGetStaticPaths() {
265
+ var _a, _b, _c;
266
+ const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
267
+ const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new ProjectMapClient({
268
+ apiKey: process.env.UNIFORM_API_KEY,
269
+ projectId: process.env.UNIFORM_PROJECT_ID,
270
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
271
+ });
272
+ const finalRedirectClient = (_c = options == null ? void 0 : options.redirectClient) != null ? _c : new RedirectClient({
273
+ apiKey: process.env.UNIFORM_API_KEY,
274
+ projectId: process.env.UNIFORM_PROJECT_ID,
275
+ apiHost: process.env.UNIFORM_CLI_BASE_URL
276
+ });
277
+ const [response, redirectResponse] = await Promise.all([
278
+ projectMapClient.getNodes({
279
+ ...options == null ? void 0 : options.requestOptions,
280
+ path: options == null ? void 0 : options.rootPath,
281
+ projectMapId,
282
+ state: (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE2 : CANVAS_PUBLISHED_STATE2
283
+ }),
284
+ finalRedirectClient.getAllRedirects()
285
+ ]);
286
+ const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
287
+ const redirectSources = (await findChildRedirects(redirectResponse, options == null ? void 0 : options.rootPath)).map(
288
+ (r) => r.redirect.sourceUrl
289
+ );
290
+ const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
291
+ var _a2;
292
+ return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
293
+ });
294
+ return {
295
+ paths: [...paths != null ? paths : [], ...redirectSources],
296
+ fallback: true
297
+ };
298
+ };
299
+ };
300
+
245
301
  // src/route/withUniformGetStaticProps.ts
246
- import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2 } from "@uniformdev/canvas";
302
+ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3 } from "@uniformdev/canvas";
247
303
  import { getTargetVariableExpandedUrl as getTargetVariableExpandedUrl2 } from "@uniformdev/redirect";
248
304
  var withUniformGetStaticProps = (options) => {
249
305
  const defaultHandleRedirect = (requestUrl, matched) => {
@@ -279,13 +335,21 @@ var withUniformGetStaticProps = (options) => {
279
335
  }),
280
336
  // auto engage draft content when in next preview mode
281
337
  // (can override with explicit setting of request options)
282
- defaultFetchState: context.preview ? CANVAS_DRAFT_STATE2 : void 0
338
+ defaultFetchState: context.preview ? CANVAS_DRAFT_STATE3 : void 0
283
339
  };
284
340
  }
285
341
  });
286
342
  return routeFetcher;
287
343
  };
288
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
+
289
353
  // src/route/index.ts
290
354
  var getServerSideProps = withUniformGetServerSideProps();
291
355
  var getStaticProps = withUniformGetStaticProps();
@@ -294,6 +358,7 @@ export {
294
358
  getServerSideProps,
295
359
  getStaticPaths,
296
360
  getStaticProps,
361
+ prependLocale,
297
362
  withUniformGetServerSideProps,
298
363
  withUniformGetStaticPaths,
299
364
  withUniformGetStaticProps
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models-f9fd03c4.js';
3
+ import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models--s4UGr5M.mjs';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_canvas from '@uniformdev/canvas';
@@ -30,6 +30,8 @@ declare const withUniformGetServerSideProps: <TProps extends {
30
30
  withTotalCount?: boolean | undefined;
31
31
  withUIStatus?: boolean | undefined;
32
32
  withContentSourceMap?: boolean | undefined;
33
+ locale?: string | undefined;
34
+ releaseId?: string | undefined;
33
35
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
34
36
  callback?: UniformGetServerSideProps<TProps> | undefined;
35
37
  /** Disables logging of response information and timings */
@@ -77,6 +79,8 @@ declare const withUniformGetStaticProps: <TProps extends {
77
79
  withTotalCount?: boolean | undefined;
78
80
  withUIStatus?: boolean | undefined;
79
81
  withContentSourceMap?: boolean | undefined;
82
+ locale?: string | undefined;
83
+ releaseId?: string | undefined;
80
84
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
81
85
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
82
86
  callback?: UniformGetStaticProps<TProps> | undefined;
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models-f9fd03c4.js';
3
+ import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models--s4UGr5M.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_canvas from '@uniformdev/canvas';
@@ -30,6 +30,8 @@ declare const withUniformGetServerSideProps: <TProps extends {
30
30
  withTotalCount?: boolean | undefined;
31
31
  withUIStatus?: boolean | undefined;
32
32
  withContentSourceMap?: boolean | undefined;
33
+ locale?: string | undefined;
34
+ releaseId?: string | undefined;
33
35
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
34
36
  callback?: UniformGetServerSideProps<TProps> | undefined;
35
37
  /** Disables logging of response information and timings */
@@ -77,6 +79,8 @@ declare const withUniformGetStaticProps: <TProps extends {
77
79
  withTotalCount?: boolean | undefined;
78
80
  withUIStatus?: boolean | undefined;
79
81
  withContentSourceMap?: boolean | undefined;
82
+ locale?: string | undefined;
83
+ releaseId?: string | undefined;
80
84
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
81
85
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
82
86
  callback?: UniformGetStaticProps<TProps> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "19.79.1-alpha.11+4547ef846",
3
+ "version": "19.79.1-alpha.18+12234b9350",
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.79.1-alpha.11+4547ef846",
71
- "@uniformdev/canvas-react": "19.79.1-alpha.11+4547ef846",
72
- "@uniformdev/project-map": "19.79.1-alpha.11+4547ef846",
73
- "@uniformdev/redirect": "19.79.1-alpha.11+4547ef846",
74
- "@uniformdev/richtext": "19.79.1-alpha.11+4547ef846",
70
+ "@uniformdev/canvas": "19.79.1-alpha.18+12234b9350",
71
+ "@uniformdev/canvas-react": "19.79.1-alpha.18+12234b9350",
72
+ "@uniformdev/project-map": "19.79.1-alpha.18+12234b9350",
73
+ "@uniformdev/redirect": "19.79.1-alpha.18+12234b9350",
74
+ "@uniformdev/richtext": "19.79.1-alpha.18+12234b9350",
75
75
  "colorette": "2.0.20"
76
76
  },
77
77
  "peerDependencies": {
@@ -80,7 +80,7 @@
80
80
  "react-dom": ">=16"
81
81
  },
82
82
  "devDependencies": {
83
- "@types/react": "18.2.21",
83
+ "@types/react": "18.2.40",
84
84
  "next": "13.4.12",
85
85
  "react": "18.2.0",
86
86
  "react-dom": "18.2.0"
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "4547ef8469f21f7f2341bcd87203372c4646bc08"
94
+ "gitHead": "12234b9350cfa4209bc7e242701d2dc535ece19e"
95
95
  }