@uniformdev/canvas-next 20.56.0 → 20.56.1-alpha.5

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.
@@ -1,3 +1,18 @@
1
+ // src/helpers/resolvePreviewReleaseId.ts
2
+ function resolvePreviewReleaseId({
3
+ explicitReleaseId,
4
+ isPreview,
5
+ previewReleaseId
6
+ }) {
7
+ if (typeof explicitReleaseId !== "undefined") {
8
+ return explicitReleaseId;
9
+ }
10
+ if (!isPreview) {
11
+ return void 0;
12
+ }
13
+ return previewReleaseId;
14
+ }
15
+
1
16
  // src/logging/logCompositionResponse.ts
2
17
  import { white as white2 } from "colorette";
3
18
 
@@ -104,5 +119,6 @@ function resolveDiagnosticsDuration(data) {
104
119
  }
105
120
 
106
121
  export {
122
+ resolvePreviewReleaseId,
107
123
  logCompositionResponse
108
124
  };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RichTextRendererComponent, RenderRichTextComponentResolver, UniformRichText as UniformRichText$1, UniformRichTextNode as UniformRichTextNode$1 } from '@uniformdev/canvas-react';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
- export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-CupnCqnn.mjs';
3
+ export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-r9gINwBs.mjs';
4
4
  import { NextApiHandler, NextApiRequest } from 'next';
5
5
  import { RootComponentInstance } from '@uniformdev/canvas';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RichTextRendererComponent, RenderRichTextComponentResolver, UniformRichText as UniformRichText$1, UniformRichTextNode as UniformRichTextNode$1 } from '@uniformdev/canvas-react';
2
2
  import { ParsedUrlQuery } from 'querystring';
3
- export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-CupnCqnn.js';
3
+ export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-r9gINwBs.js';
4
4
  import { NextApiHandler, NextApiRequest } from 'next';
5
5
  import { RootComponentInstance } from '@uniformdev/canvas';
6
6
 
package/dist/index.esm.js CHANGED
@@ -98,6 +98,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
98
98
  const slug = getQueryParam(req, compositionQueryParam.slug);
99
99
  const path = getQueryParam(req, compositionQueryParam.path);
100
100
  const locale = getQueryParam(req, compositionQueryParam.locale);
101
+ const releaseId = getQueryParam(req, "releaseId") || void 0;
101
102
  if (typeof pathToRedirectTo === "undefined") {
102
103
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
103
104
  }
@@ -125,6 +126,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
125
126
  compositionSlug: slug,
126
127
  compositionPath: path,
127
128
  locale,
129
+ releaseId,
128
130
  isPlayground,
129
131
  patternType: !isPlayground ? void 0 : getQueryParam(req, "patternType")
130
132
  },
@@ -143,6 +145,9 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
143
145
  );
144
146
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
145
147
  assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
148
+ if (releaseId) {
149
+ redirectionUrl.searchParams.set("releaseId", releaseId);
150
+ }
146
151
  if (!isUniformContextualEditing) {
147
152
  contextualEditingQueryParams.forEach((param) => {
148
153
  redirectionUrl.searchParams.delete(param);
package/dist/index.js CHANGED
@@ -140,6 +140,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
140
140
  const slug = getQueryParam(req, compositionQueryParam.slug);
141
141
  const path = getQueryParam(req, compositionQueryParam.path);
142
142
  const locale = getQueryParam(req, compositionQueryParam.locale);
143
+ const releaseId = getQueryParam(req, "releaseId") || void 0;
143
144
  if (typeof pathToRedirectTo === "undefined") {
144
145
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
145
146
  }
@@ -167,6 +168,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
167
168
  compositionSlug: slug,
168
169
  compositionPath: path,
169
170
  locale,
171
+ releaseId,
170
172
  isPlayground,
171
173
  patternType: !isPlayground ? void 0 : getQueryParam(req, "patternType")
172
174
  },
@@ -185,6 +187,9 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
185
187
  );
186
188
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
187
189
  assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
190
+ if (releaseId) {
191
+ redirectionUrl.searchParams.set("releaseId", releaseId);
192
+ }
188
193
  if (!isUniformContextualEditing) {
189
194
  contextualEditingQueryParams.forEach((param) => {
190
195
  redirectionUrl.searchParams.delete(param);
package/dist/index.mjs CHANGED
@@ -98,6 +98,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
98
98
  const slug = getQueryParam(req, compositionQueryParam.slug);
99
99
  const path = getQueryParam(req, compositionQueryParam.path);
100
100
  const locale = getQueryParam(req, compositionQueryParam.locale);
101
+ const releaseId = getQueryParam(req, "releaseId") || void 0;
101
102
  if (typeof pathToRedirectTo === "undefined") {
102
103
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
103
104
  }
@@ -125,6 +126,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
125
126
  compositionSlug: slug,
126
127
  compositionPath: path,
127
128
  locale,
129
+ releaseId,
128
130
  isPlayground,
129
131
  patternType: !isPlayground ? void 0 : getQueryParam(req, "patternType")
130
132
  },
@@ -143,6 +145,9 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
143
145
  );
144
146
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
145
147
  assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
148
+ if (releaseId) {
149
+ redirectionUrl.searchParams.set("releaseId", releaseId);
150
+ }
146
151
  if (!isUniformContextualEditing) {
147
152
  contextualEditingQueryParams.forEach((param) => {
148
153
  redirectionUrl.searchParams.delete(param);
@@ -10,6 +10,7 @@ type UniformPreviewData = PreviewData & {
10
10
  compositionSlug?: string;
11
11
  compositionPath?: string;
12
12
  locale?: string;
13
+ releaseId?: string;
13
14
  isPlayground?: boolean;
14
15
  /**
15
16
  * The type of pattern being previewed in Canvas editor. This value is only set when `isPlayground` is `true`.
@@ -10,6 +10,7 @@ type UniformPreviewData = PreviewData & {
10
10
  compositionSlug?: string;
11
11
  compositionPath?: string;
12
12
  locale?: string;
13
+ releaseId?: string;
13
14
  isPlayground?: boolean;
14
15
  /**
15
16
  * The type of pattern being previewed in Canvas editor. This value is only set when `isPlayground` is `true`.
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, PreviewData, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-CupnCqnn.mjs';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-r9gINwBs.mjs';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import { CanvasClient, CompositionGetByNodePathParameters, DataResolutionOption } from '@uniformdev/canvas';
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, PreviewData, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
- import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-CupnCqnn.js';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-r9gINwBs.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import { CanvasClient, CompositionGetByNodePathParameters, DataResolutionOption } from '@uniformdev/canvas';
@@ -32,6 +32,21 @@ module.exports = __toCommonJS(project_map_exports);
32
32
  // src/project-map/withUniformGetServerSideProps.ts
33
33
  var import_canvas = require("@uniformdev/canvas");
34
34
 
35
+ // src/helpers/resolvePreviewReleaseId.ts
36
+ function resolvePreviewReleaseId({
37
+ explicitReleaseId,
38
+ isPreview,
39
+ previewReleaseId
40
+ }) {
41
+ if (typeof explicitReleaseId !== "undefined") {
42
+ return explicitReleaseId;
43
+ }
44
+ if (!isPreview) {
45
+ return void 0;
46
+ }
47
+ return previewReleaseId;
48
+ }
49
+
35
50
  // src/logging/logCompositionIssues.ts
36
51
  var import_colorette = require("colorette");
37
52
  function logCompositionIssues(prefix, issues, colour = "red") {
@@ -144,16 +159,21 @@ var withUniformGetServerSideProps = (options) => {
144
159
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
145
160
  });
146
161
  return async function wrappedGetServerSideProps(context) {
147
- var _a, _b;
162
+ var _a, _b, _c;
148
163
  const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
149
164
  const { preview, previewData } = context;
165
+ const releaseId = resolvePreviewReleaseId({
166
+ explicitReleaseId: (_b = options == null ? void 0 : options.requestOptions) == null ? void 0 : _b.releaseId,
167
+ isPreview: preview || (options == null ? void 0 : options.preview),
168
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
169
+ });
150
170
  let composition = void 0;
151
171
  let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
152
172
  if (options == null ? void 0 : options.modifyPath) {
153
173
  nodePath = options.modifyPath(nodePath, context);
154
174
  }
155
175
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
156
- composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
176
+ composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_c = previewData.compositionId) != null ? _c : import_canvas.EMPTY_COMPOSITION._id };
157
177
  } else {
158
178
  try {
159
179
  const time = Date.now();
@@ -161,7 +181,8 @@ var withUniformGetServerSideProps = (options) => {
161
181
  ...options == null ? void 0 : options.requestOptions,
162
182
  projectMapId,
163
183
  projectMapNodePath: nodePath,
164
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
184
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE,
185
+ releaseId
165
186
  });
166
187
  const duration = Date.now() - time;
167
188
  composition = response.composition;
@@ -237,7 +258,7 @@ var withUniformGetStaticProps = (options) => {
237
258
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
238
259
  });
239
260
  return async function wrappedGetStaticProps(context) {
240
- var _a2, _b;
261
+ var _a2, _b, _c;
241
262
  const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
242
263
  let pathString = resolveSlugFromParams({
243
264
  param: options == null ? void 0 : options.param,
@@ -247,9 +268,14 @@ var withUniformGetStaticProps = (options) => {
247
268
  pathString = options.modifyPath(pathString, context);
248
269
  }
249
270
  const { preview, previewData } = context;
271
+ const releaseId = resolvePreviewReleaseId({
272
+ explicitReleaseId: (_b = options == null ? void 0 : options.requestOptions) == null ? void 0 : _b.releaseId,
273
+ isPreview: preview || (options == null ? void 0 : options.preview),
274
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
275
+ });
250
276
  let composition = void 0;
251
277
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
252
- composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas3.EMPTY_COMPOSITION._id };
278
+ composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_c = previewData.compositionId) != null ? _c : import_canvas3.EMPTY_COMPOSITION._id };
253
279
  } else {
254
280
  try {
255
281
  const time = Date.now();
@@ -257,7 +283,8 @@ var withUniformGetStaticProps = (options) => {
257
283
  ...options == null ? void 0 : options.requestOptions,
258
284
  projectMapId,
259
285
  projectMapNodePath: pathString,
260
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
286
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE,
287
+ releaseId
261
288
  });
262
289
  const duration = Date.now() - time;
263
290
  composition = response.composition;
@@ -1,6 +1,7 @@
1
1
  import {
2
- logCompositionResponse
3
- } from "../chunk-JQWYBVLI.mjs";
2
+ logCompositionResponse,
3
+ resolvePreviewReleaseId
4
+ } from "../chunk-4YXXKXP3.mjs";
4
5
  import {
5
6
  resolveSlugFromParams
6
7
  } from "../chunk-TR7V6ABJ.mjs";
@@ -20,16 +21,21 @@ var withUniformGetServerSideProps = (options) => {
20
21
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
21
22
  });
22
23
  return async function wrappedGetServerSideProps(context) {
23
- var _a, _b;
24
+ var _a, _b, _c;
24
25
  const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
25
26
  const { preview, previewData } = context;
27
+ const releaseId = resolvePreviewReleaseId({
28
+ explicitReleaseId: (_b = options == null ? void 0 : options.requestOptions) == null ? void 0 : _b.releaseId,
29
+ isPreview: preview || (options == null ? void 0 : options.preview),
30
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
31
+ });
26
32
  let composition = void 0;
27
33
  let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
28
34
  if (options == null ? void 0 : options.modifyPath) {
29
35
  nodePath = options.modifyPath(nodePath, context);
30
36
  }
31
37
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
32
- composition = { ...EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION._id };
38
+ composition = { ...EMPTY_COMPOSITION, _id: (_c = previewData.compositionId) != null ? _c : EMPTY_COMPOSITION._id };
33
39
  } else {
34
40
  try {
35
41
  const time = Date.now();
@@ -37,7 +43,8 @@ var withUniformGetServerSideProps = (options) => {
37
43
  ...options == null ? void 0 : options.requestOptions,
38
44
  projectMapId,
39
45
  projectMapNodePath: nodePath,
40
- state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
46
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE,
47
+ releaseId
41
48
  });
42
49
  const duration = Date.now() - time;
43
50
  composition = response.composition;
@@ -108,7 +115,7 @@ var withUniformGetStaticProps = (options) => {
108
115
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
109
116
  });
110
117
  return async function wrappedGetStaticProps(context) {
111
- var _a2, _b;
118
+ var _a2, _b, _c;
112
119
  const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
113
120
  let pathString = resolveSlugFromParams({
114
121
  param: options == null ? void 0 : options.param,
@@ -118,9 +125,14 @@ var withUniformGetStaticProps = (options) => {
118
125
  pathString = options.modifyPath(pathString, context);
119
126
  }
120
127
  const { preview, previewData } = context;
128
+ const releaseId = resolvePreviewReleaseId({
129
+ explicitReleaseId: (_b = options == null ? void 0 : options.requestOptions) == null ? void 0 : _b.releaseId,
130
+ isPreview: preview || (options == null ? void 0 : options.preview),
131
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
132
+ });
121
133
  let composition = void 0;
122
134
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
123
- composition = { ...EMPTY_COMPOSITION2, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION2._id };
135
+ composition = { ...EMPTY_COMPOSITION2, _id: (_c = previewData.compositionId) != null ? _c : EMPTY_COMPOSITION2._id };
124
136
  } else {
125
137
  try {
126
138
  const time = Date.now();
@@ -128,7 +140,8 @@ var withUniformGetStaticProps = (options) => {
128
140
  ...options == null ? void 0 : options.requestOptions,
129
141
  projectMapId,
130
142
  projectMapNodePath: pathString,
131
- state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3
143
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3,
144
+ releaseId
132
145
  });
133
146
  const duration = Date.now() - time;
134
147
  composition = response.composition;
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, GetServerSidePropsResult, GetServerSideProps, GetStaticPropsContext, GetStaticPropsResult, GetStaticProps } from 'next';
3
- import { a as UniformPreviewData } from '../models-CupnCqnn.mjs';
3
+ import { a as UniformPreviewData } from '../models-r9gINwBs.mjs';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_context__ from '@uniformdev/context/*';
@@ -1,6 +1,6 @@
1
1
  import * as next from 'next';
2
2
  import { GetServerSidePropsContext, GetServerSidePropsResult, GetServerSideProps, GetStaticPropsContext, GetStaticPropsResult, GetStaticProps } from 'next';
3
- import { a as UniformPreviewData } from '../models-CupnCqnn.js';
3
+ import { a as UniformPreviewData } from '../models-r9gINwBs.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_context__ from '@uniformdev/context/*';
@@ -38,6 +38,21 @@ var import_redirect = require("@uniformdev/redirect");
38
38
  var import_canvas = require("@uniformdev/canvas");
39
39
  var import_colorette6 = require("colorette");
40
40
 
41
+ // src/helpers/resolvePreviewReleaseId.ts
42
+ function resolvePreviewReleaseId({
43
+ explicitReleaseId,
44
+ isPreview,
45
+ previewReleaseId
46
+ }) {
47
+ if (typeof explicitReleaseId !== "undefined") {
48
+ return explicitReleaseId;
49
+ }
50
+ if (!isPreview) {
51
+ return void 0;
52
+ }
53
+ return previewReleaseId;
54
+ }
55
+
41
56
  // src/logging/logCompositionIssues.ts
42
57
  var import_colorette = require("colorette");
43
58
  function logCompositionIssues(prefix, issues, colour = "red") {
@@ -218,7 +233,9 @@ function createRouteFetcher(options) {
218
233
  contextualEditingCompositionId,
219
234
  contextualEditingPath,
220
235
  resolvedUrl,
221
- defaultFetchState: defaultPreviewState
236
+ defaultFetchState: defaultPreviewState,
237
+ isPreview,
238
+ previewReleaseId
222
239
  } = parseContext(context);
223
240
  let nodePath = prefix ? resolvedUrl.replace(new RegExp(`^${prefix}`), "") : resolvedUrl;
224
241
  nodePath = handleModifyPath(nodePath, context);
@@ -286,6 +303,11 @@ function createRouteFetcher(options) {
286
303
  console.log("Fetch route", nodePath);
287
304
  }
288
305
  const resolvedOptions = typeof requestOptions === "function" ? requestOptions(context) : requestOptions;
306
+ const releaseId = resolvePreviewReleaseId({
307
+ explicitReleaseId: resolvedOptions == null ? void 0 : resolvedOptions.releaseId,
308
+ isPreview,
309
+ previewReleaseId
310
+ });
289
311
  const time = Date.now();
290
312
  const response = await routeClient.getRoute({
291
313
  ...resolvedOptions,
@@ -295,7 +317,8 @@ function createRouteFetcher(options) {
295
317
  defaultPreviewState
296
318
  ),
297
319
  projectMapId,
298
- path: nodePath
320
+ path: nodePath,
321
+ releaseId
299
322
  });
300
323
  const duration = Date.now() - time;
301
324
  if (!silent) {
@@ -361,14 +384,16 @@ var withUniformGetServerSideProps = (options) => {
361
384
  defaultHandleNotFound,
362
385
  defaultHandleRedirect,
363
386
  parseContext(context) {
364
- var _a, _b, _c, _d;
387
+ var _a, _b, _c, _d, _e;
365
388
  return {
366
389
  contextualEditingCompositionId: ((_a = context.previewData) == null ? void 0 : _a.isUniformContextualEditing) ? (_b = context.previewData) == null ? void 0 : _b.compositionId : void 0,
367
390
  contextualEditingPath: ((_c = context.previewData) == null ? void 0 : _c.isUniformContextualEditing) ? (_d = context.previewData) == null ? void 0 : _d.compositionPath : void 0,
368
391
  resolvedUrl: context.resolvedUrl,
369
392
  // auto engage draft content when in next preview mode
370
393
  // (can override with explicit setting of request options)'
371
- defaultFetchState: context.preview ? import_canvas2.CANVAS_DRAFT_STATE : void 0
394
+ defaultFetchState: context.preview ? import_canvas2.CANVAS_DRAFT_STATE : void 0,
395
+ isPreview: context.preview,
396
+ previewReleaseId: (_e = context.previewData) == null ? void 0 : _e.releaseId
372
397
  };
373
398
  }
374
399
  });
@@ -471,7 +496,7 @@ var withUniformGetStaticProps = (options) => {
471
496
  defaultHandleNotFound,
472
497
  defaultHandleRedirect,
473
498
  parseContext(context) {
474
- var _a, _b, _c, _d, _e;
499
+ var _a, _b, _c, _d, _e, _f;
475
500
  return {
476
501
  contextualEditingCompositionId: ((_a = context.previewData) == null ? void 0 : _a.isUniformContextualEditing) ? (_b = context.previewData) == null ? void 0 : _b.compositionId : void 0,
477
502
  contextualEditingPath: ((_c = context.previewData) == null ? void 0 : _c.isUniformContextualEditing) ? (_d = context.previewData) == null ? void 0 : _d.compositionPath : void 0,
@@ -481,7 +506,9 @@ var withUniformGetStaticProps = (options) => {
481
506
  }),
482
507
  // auto engage draft content when in next preview mode
483
508
  // (can override with explicit setting of request options)
484
- defaultFetchState: context.preview ? import_canvas4.CANVAS_DRAFT_STATE : void 0
509
+ defaultFetchState: context.preview ? import_canvas4.CANVAS_DRAFT_STATE : void 0,
510
+ isPreview: context.preview,
511
+ previewReleaseId: (_f = context.previewData) == null ? void 0 : _f.releaseId
485
512
  };
486
513
  }
487
514
  });
@@ -1,6 +1,7 @@
1
1
  import {
2
- logCompositionResponse
3
- } from "../chunk-JQWYBVLI.mjs";
2
+ logCompositionResponse,
3
+ resolvePreviewReleaseId
4
+ } from "../chunk-4YXXKXP3.mjs";
4
5
  import {
5
6
  resolveSlugFromParams
6
7
  } from "../chunk-TR7V6ABJ.mjs";
@@ -96,7 +97,9 @@ function createRouteFetcher(options) {
96
97
  contextualEditingCompositionId,
97
98
  contextualEditingPath,
98
99
  resolvedUrl,
99
- defaultFetchState: defaultPreviewState
100
+ defaultFetchState: defaultPreviewState,
101
+ isPreview,
102
+ previewReleaseId
100
103
  } = parseContext(context);
101
104
  let nodePath = prefix ? resolvedUrl.replace(new RegExp(`^${prefix}`), "") : resolvedUrl;
102
105
  nodePath = handleModifyPath(nodePath, context);
@@ -164,6 +167,11 @@ function createRouteFetcher(options) {
164
167
  console.log("Fetch route", nodePath);
165
168
  }
166
169
  const resolvedOptions = typeof requestOptions === "function" ? requestOptions(context) : requestOptions;
170
+ const releaseId = resolvePreviewReleaseId({
171
+ explicitReleaseId: resolvedOptions == null ? void 0 : resolvedOptions.releaseId,
172
+ isPreview,
173
+ previewReleaseId
174
+ });
167
175
  const time = Date.now();
168
176
  const response = await routeClient.getRoute({
169
177
  ...resolvedOptions,
@@ -173,7 +181,8 @@ function createRouteFetcher(options) {
173
181
  defaultPreviewState
174
182
  ),
175
183
  projectMapId,
176
- path: nodePath
184
+ path: nodePath,
185
+ releaseId
177
186
  });
178
187
  const duration = Date.now() - time;
179
188
  if (!silent) {
@@ -239,14 +248,16 @@ var withUniformGetServerSideProps = (options) => {
239
248
  defaultHandleNotFound,
240
249
  defaultHandleRedirect,
241
250
  parseContext(context) {
242
- var _a, _b, _c, _d;
251
+ var _a, _b, _c, _d, _e;
243
252
  return {
244
253
  contextualEditingCompositionId: ((_a = context.previewData) == null ? void 0 : _a.isUniformContextualEditing) ? (_b = context.previewData) == null ? void 0 : _b.compositionId : void 0,
245
254
  contextualEditingPath: ((_c = context.previewData) == null ? void 0 : _c.isUniformContextualEditing) ? (_d = context.previewData) == null ? void 0 : _d.compositionPath : void 0,
246
255
  resolvedUrl: context.resolvedUrl,
247
256
  // auto engage draft content when in next preview mode
248
257
  // (can override with explicit setting of request options)'
249
- defaultFetchState: context.preview ? CANVAS_DRAFT_STATE : void 0
258
+ defaultFetchState: context.preview ? CANVAS_DRAFT_STATE : void 0,
259
+ isPreview: context.preview,
260
+ previewReleaseId: (_e = context.previewData) == null ? void 0 : _e.releaseId
250
261
  };
251
262
  }
252
263
  });
@@ -339,7 +350,7 @@ var withUniformGetStaticProps = (options) => {
339
350
  defaultHandleNotFound,
340
351
  defaultHandleRedirect,
341
352
  parseContext(context) {
342
- var _a, _b, _c, _d, _e;
353
+ var _a, _b, _c, _d, _e, _f;
343
354
  return {
344
355
  contextualEditingCompositionId: ((_a = context.previewData) == null ? void 0 : _a.isUniformContextualEditing) ? (_b = context.previewData) == null ? void 0 : _b.compositionId : void 0,
345
356
  contextualEditingPath: ((_c = context.previewData) == null ? void 0 : _c.isUniformContextualEditing) ? (_d = context.previewData) == null ? void 0 : _d.compositionPath : void 0,
@@ -349,7 +360,9 @@ var withUniformGetStaticProps = (options) => {
349
360
  }),
350
361
  // auto engage draft content when in next preview mode
351
362
  // (can override with explicit setting of request options)
352
- defaultFetchState: context.preview ? CANVAS_DRAFT_STATE3 : void 0
363
+ defaultFetchState: context.preview ? CANVAS_DRAFT_STATE3 : void 0,
364
+ isPreview: context.preview,
365
+ previewReleaseId: (_f = context.previewData) == null ? void 0 : _f.releaseId
353
366
  };
354
367
  }
355
368
  });
@@ -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-CupnCqnn.mjs';
3
+ import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models-r9gINwBs.mjs';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import { CanvasClient, CompositionGetBySlugParameters, DataResolutionOption, CompositionGetParameters, CompositionGetResponse } from '@uniformdev/canvas';
@@ -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-CupnCqnn.js';
3
+ import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models-r9gINwBs.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import { CanvasClient, CompositionGetBySlugParameters, DataResolutionOption, CompositionGetParameters, CompositionGetResponse } from '@uniformdev/canvas';
@@ -32,6 +32,21 @@ module.exports = __toCommonJS(slug_exports);
32
32
  // src/slug/withUniformGetServerSideProps.ts
33
33
  var import_canvas = require("@uniformdev/canvas");
34
34
 
35
+ // src/helpers/resolvePreviewReleaseId.ts
36
+ function resolvePreviewReleaseId({
37
+ explicitReleaseId,
38
+ isPreview,
39
+ previewReleaseId
40
+ }) {
41
+ if (typeof explicitReleaseId !== "undefined") {
42
+ return explicitReleaseId;
43
+ }
44
+ if (!isPreview) {
45
+ return void 0;
46
+ }
47
+ return previewReleaseId;
48
+ }
49
+
35
50
  // src/logging/logCompositionIssues.ts
36
51
  var import_colorette = require("colorette");
37
52
  function logCompositionIssues(prefix, issues, colour = "red") {
@@ -144,15 +159,20 @@ var withUniformGetServerSideProps = (options) => {
144
159
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
145
160
  });
146
161
  return async function wrappedGetServerSideProps(context) {
147
- var _a;
162
+ var _a, _b;
148
163
  const { preview, previewData } = context;
164
+ const releaseId = resolvePreviewReleaseId({
165
+ explicitReleaseId: (_a = options == null ? void 0 : options.requestOptions) == null ? void 0 : _a.releaseId,
166
+ isPreview: preview || (options == null ? void 0 : options.preview),
167
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
168
+ });
149
169
  let composition = void 0;
150
170
  let slug = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
151
171
  if (options == null ? void 0 : options.modifySlug) {
152
172
  slug = options.modifySlug(slug, context);
153
173
  }
154
174
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
155
- composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_a = previewData.compositionId) != null ? _a : import_canvas.EMPTY_COMPOSITION._id };
175
+ composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
156
176
  } else {
157
177
  try {
158
178
  const time = Date.now();
@@ -160,7 +180,8 @@ var withUniformGetServerSideProps = (options) => {
160
180
  ...options == null ? void 0 : options.requestOptions,
161
181
  slug,
162
182
  state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE,
163
- diagnostics: true
183
+ diagnostics: true,
184
+ releaseId
164
185
  });
165
186
  const duration = Date.now() - time;
166
187
  composition = response.composition;
@@ -233,7 +254,7 @@ var withUniformGetStaticProps = (options) => {
233
254
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
234
255
  });
235
256
  return async function wrappedGetStaticProps(context) {
236
- var _a2;
257
+ var _a2, _b;
237
258
  let slugString = resolveSlugFromParams({
238
259
  param: options == null ? void 0 : options.param,
239
260
  params: context == null ? void 0 : context.params
@@ -242,16 +263,22 @@ var withUniformGetStaticProps = (options) => {
242
263
  slugString = options.modifySlug(slugString, context);
243
264
  }
244
265
  const { preview, previewData } = context;
266
+ const releaseId = resolvePreviewReleaseId({
267
+ explicitReleaseId: (_a2 = options == null ? void 0 : options.requestOptions) == null ? void 0 : _a2.releaseId,
268
+ isPreview: preview || (options == null ? void 0 : options.preview),
269
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
270
+ });
245
271
  let composition = void 0;
246
272
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
247
- composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_a2 = previewData.compositionId) != null ? _a2 : import_canvas3.EMPTY_COMPOSITION._id };
273
+ composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas3.EMPTY_COMPOSITION._id };
248
274
  } else {
249
275
  try {
250
276
  const time = Date.now();
251
277
  const response = await canvasClient.getCompositionBySlug({
252
278
  slug: slugString,
253
279
  state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE,
254
- ...options == null ? void 0 : options.requestOptions
280
+ ...options == null ? void 0 : options.requestOptions,
281
+ releaseId
255
282
  });
256
283
  const duration = Date.now() - time;
257
284
  composition = response.composition;
@@ -1,6 +1,7 @@
1
1
  import {
2
- logCompositionResponse
3
- } from "../chunk-JQWYBVLI.mjs";
2
+ logCompositionResponse,
3
+ resolvePreviewReleaseId
4
+ } from "../chunk-4YXXKXP3.mjs";
4
5
  import {
5
6
  resolveSlugFromParams
6
7
  } from "../chunk-TR7V6ABJ.mjs";
@@ -20,15 +21,20 @@ var withUniformGetServerSideProps = (options) => {
20
21
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
21
22
  });
22
23
  return async function wrappedGetServerSideProps(context) {
23
- var _a;
24
+ var _a, _b;
24
25
  const { preview, previewData } = context;
26
+ const releaseId = resolvePreviewReleaseId({
27
+ explicitReleaseId: (_a = options == null ? void 0 : options.requestOptions) == null ? void 0 : _a.releaseId,
28
+ isPreview: preview || (options == null ? void 0 : options.preview),
29
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
30
+ });
25
31
  let composition = void 0;
26
32
  let slug = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
27
33
  if (options == null ? void 0 : options.modifySlug) {
28
34
  slug = options.modifySlug(slug, context);
29
35
  }
30
36
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
31
- composition = { ...EMPTY_COMPOSITION, _id: (_a = previewData.compositionId) != null ? _a : EMPTY_COMPOSITION._id };
37
+ composition = { ...EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION._id };
32
38
  } else {
33
39
  try {
34
40
  const time = Date.now();
@@ -36,7 +42,8 @@ var withUniformGetServerSideProps = (options) => {
36
42
  ...options == null ? void 0 : options.requestOptions,
37
43
  slug,
38
44
  state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE,
39
- diagnostics: true
45
+ diagnostics: true,
46
+ releaseId
40
47
  });
41
48
  const duration = Date.now() - time;
42
49
  composition = response.composition;
@@ -106,7 +113,7 @@ var withUniformGetStaticProps = (options) => {
106
113
  edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
107
114
  });
108
115
  return async function wrappedGetStaticProps(context) {
109
- var _a2;
116
+ var _a2, _b;
110
117
  let slugString = resolveSlugFromParams({
111
118
  param: options == null ? void 0 : options.param,
112
119
  params: context == null ? void 0 : context.params
@@ -115,16 +122,22 @@ var withUniformGetStaticProps = (options) => {
115
122
  slugString = options.modifySlug(slugString, context);
116
123
  }
117
124
  const { preview, previewData } = context;
125
+ const releaseId = resolvePreviewReleaseId({
126
+ explicitReleaseId: (_a2 = options == null ? void 0 : options.requestOptions) == null ? void 0 : _a2.releaseId,
127
+ isPreview: preview || (options == null ? void 0 : options.preview),
128
+ previewReleaseId: previewData == null ? void 0 : previewData.releaseId
129
+ });
118
130
  let composition = void 0;
119
131
  if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
120
- composition = { ...EMPTY_COMPOSITION2, _id: (_a2 = previewData.compositionId) != null ? _a2 : EMPTY_COMPOSITION2._id };
132
+ composition = { ...EMPTY_COMPOSITION2, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION2._id };
121
133
  } else {
122
134
  try {
123
135
  const time = Date.now();
124
136
  const response = await canvasClient.getCompositionBySlug({
125
137
  slug: slugString,
126
138
  state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3,
127
- ...options == null ? void 0 : options.requestOptions
139
+ ...options == null ? void 0 : options.requestOptions,
140
+ releaseId
128
141
  });
129
142
  const duration = Date.now() - time;
130
143
  composition = response.composition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "20.56.0",
3
+ "version": "20.56.1-alpha.5+1bce2eca70",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -67,12 +67,12 @@
67
67
  "document:prebuild": "api-extractor run --local"
68
68
  },
69
69
  "dependencies": {
70
- "@uniformdev/canvas": "20.56.0",
71
- "@uniformdev/canvas-react": "20.56.0",
72
- "@uniformdev/context": "20.56.0",
73
- "@uniformdev/project-map": "20.56.0",
74
- "@uniformdev/redirect": "20.56.0",
75
- "@uniformdev/richtext": "20.56.0",
70
+ "@uniformdev/canvas": "20.56.1-alpha.5+1bce2eca70",
71
+ "@uniformdev/canvas-react": "20.56.1-alpha.5+1bce2eca70",
72
+ "@uniformdev/context": "20.56.1-alpha.5+1bce2eca70",
73
+ "@uniformdev/project-map": "20.56.1-alpha.5+1bce2eca70",
74
+ "@uniformdev/redirect": "20.56.1-alpha.5+1bce2eca70",
75
+ "@uniformdev/richtext": "20.56.1-alpha.5+1bce2eca70",
76
76
  "colorette": "2.0.20"
77
77
  },
78
78
  "peerDependencies": {
@@ -92,5 +92,5 @@
92
92
  "publishConfig": {
93
93
  "access": "public"
94
94
  },
95
- "gitHead": "45d5acb6435efe756dae0c7f211ad86e2596d9fb"
95
+ "gitHead": "1bce2eca70191de304d93909e5cf08740b01fb5a"
96
96
  }