@uniformdev/canvas-next 18.6.0 → 18.7.1-alpha.11

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.
package/dist/index.d.ts CHANGED
@@ -11,9 +11,14 @@ declare const resolveSlugFromParams: ({ param, params, prefix, }: {
11
11
  }) => string;
12
12
 
13
13
  type ResolveFullPath = (options: {
14
+ /** The ID of the composition */
14
15
  id?: string;
16
+ /** The slug of the composition */
15
17
  slug?: string;
18
+ /** The path of the project map node attached to the composition, if there is one */
16
19
  path?: string;
20
+ /** The preview locale selected in Visual Canvas, available only if Localization is set up */
21
+ locale?: string;
17
22
  }) => string | undefined;
18
23
  type CreatePreviewHandlerGetOptions = {
19
24
  secret?: () => string;
package/dist/index.esm.js CHANGED
@@ -4,12 +4,20 @@ import {
4
4
 
5
5
  // src/preview/previewHandlerGet.ts
6
6
  import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
7
+ var getQueryParam = (req, paramName) => {
8
+ const value = req.query[paramName];
9
+ if (typeof value === "undefined") {
10
+ return void 0;
11
+ }
12
+ return Array.isArray(value) ? value[0] : value;
13
+ };
7
14
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault } = {}) => async (req, res) => {
8
15
  const queryParamsToPreserve = [IN_CONTEXT_EDITOR_QUERY_STRING_PARAM];
9
- const id = Array.isArray(req.query.id) ? req.query.id[0] : req.query.id;
10
- const slug = Array.isArray(req.query.slug) ? req.query.slug[0] : req.query.slug;
11
- const path = Array.isArray(req.query.path) ? req.query.path[0] : req.query.path;
12
- const pathToRedirectTo = resolveFullPath({ id, slug, path });
16
+ const id = getQueryParam(req, "id");
17
+ const slug = getQueryParam(req, "slug");
18
+ const path = getQueryParam(req, "path");
19
+ const locale = getQueryParam(req, "locale");
20
+ const pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
13
21
  if (!pathToRedirectTo) {
14
22
  return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
15
23
  }
@@ -26,6 +34,11 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
26
34
  res.setPreviewData({
27
35
  isUniformContextualEditing: req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true"
28
36
  });
37
+ const cookies = res.getHeader("Set-Cookie");
38
+ res.setHeader(
39
+ "Set-Cookie",
40
+ cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
41
+ );
29
42
  const newQuery = new URLSearchParams();
30
43
  queryParamsToPreserve.forEach((param) => {
31
44
  const paramValue = req.query[param];
package/dist/index.js CHANGED
@@ -40,12 +40,20 @@ var resolveSlugFromParams = ({
40
40
 
41
41
  // src/preview/previewHandlerGet.ts
42
42
  var import_canvas = require("@uniformdev/canvas");
43
+ var getQueryParam = (req, paramName) => {
44
+ const value = req.query[paramName];
45
+ if (typeof value === "undefined") {
46
+ return void 0;
47
+ }
48
+ return Array.isArray(value) ? value[0] : value;
49
+ };
43
50
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault } = {}) => async (req, res) => {
44
51
  const queryParamsToPreserve = [import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM];
45
- const id = Array.isArray(req.query.id) ? req.query.id[0] : req.query.id;
46
- const slug = Array.isArray(req.query.slug) ? req.query.slug[0] : req.query.slug;
47
- const path = Array.isArray(req.query.path) ? req.query.path[0] : req.query.path;
48
- const pathToRedirectTo = resolveFullPath({ id, slug, path });
52
+ const id = getQueryParam(req, "id");
53
+ const slug = getQueryParam(req, "slug");
54
+ const path = getQueryParam(req, "path");
55
+ const locale = getQueryParam(req, "locale");
56
+ const pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
49
57
  if (!pathToRedirectTo) {
50
58
  return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
51
59
  }
@@ -62,6 +70,11 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
62
70
  res.setPreviewData({
63
71
  isUniformContextualEditing: req.query[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true"
64
72
  });
73
+ const cookies = res.getHeader("Set-Cookie");
74
+ res.setHeader(
75
+ "Set-Cookie",
76
+ cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
77
+ );
65
78
  const newQuery = new URLSearchParams();
66
79
  queryParamsToPreserve.forEach((param) => {
67
80
  const paramValue = req.query[param];
package/dist/index.mjs CHANGED
@@ -4,12 +4,20 @@ import {
4
4
 
5
5
  // src/preview/previewHandlerGet.ts
6
6
  import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
7
+ var getQueryParam = (req, paramName) => {
8
+ const value = req.query[paramName];
9
+ if (typeof value === "undefined") {
10
+ return void 0;
11
+ }
12
+ return Array.isArray(value) ? value[0] : value;
13
+ };
7
14
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault } = {}) => async (req, res) => {
8
15
  const queryParamsToPreserve = [IN_CONTEXT_EDITOR_QUERY_STRING_PARAM];
9
- const id = Array.isArray(req.query.id) ? req.query.id[0] : req.query.id;
10
- const slug = Array.isArray(req.query.slug) ? req.query.slug[0] : req.query.slug;
11
- const path = Array.isArray(req.query.path) ? req.query.path[0] : req.query.path;
12
- const pathToRedirectTo = resolveFullPath({ id, slug, path });
16
+ const id = getQueryParam(req, "id");
17
+ const slug = getQueryParam(req, "slug");
18
+ const path = getQueryParam(req, "path");
19
+ const locale = getQueryParam(req, "locale");
20
+ const pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
13
21
  if (!pathToRedirectTo) {
14
22
  return res.status(400).json({ message: "Could not resolve the full path of the preview page" });
15
23
  }
@@ -26,6 +34,11 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
26
34
  res.setPreviewData({
27
35
  isUniformContextualEditing: req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true"
28
36
  });
37
+ const cookies = res.getHeader("Set-Cookie");
38
+ res.setHeader(
39
+ "Set-Cookie",
40
+ cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
41
+ );
29
42
  const newQuery = new URLSearchParams();
30
43
  queryParamsToPreserve.forEach((param) => {
31
44
  const paramValue = req.query[param];
@@ -169,7 +169,7 @@ var withUniformGetStaticProps = (callback, options) => {
169
169
  }
170
170
  }
171
171
  const ret = callback ? await callback(context, composition) : { props: {} };
172
- if (Object.hasOwn(ret, "props")) {
172
+ if (composition && Object.hasOwn(ret, "props")) {
173
173
  const casted = ret;
174
174
  casted.props["data"] = composition;
175
175
  }
@@ -133,7 +133,7 @@ var withUniformGetStaticProps = (callback, options) => {
133
133
  }
134
134
  }
135
135
  const ret = callback ? await callback(context, composition) : { props: {} };
136
- if (Object.hasOwn(ret, "props")) {
136
+ if (composition && Object.hasOwn(ret, "props")) {
137
137
  const casted = ret;
138
138
  casted.props["data"] = composition;
139
139
  }
@@ -114,7 +114,7 @@ var withUniformGetStaticPaths = (options) => {
114
114
  });
115
115
  return {
116
116
  paths,
117
- fallback: false
117
+ fallback: true
118
118
  };
119
119
  };
120
120
  };
@@ -78,7 +78,7 @@ var withUniformGetStaticPaths = (options) => {
78
78
  });
79
79
  return {
80
80
  paths,
81
- fallback: false
81
+ fallback: true
82
82
  };
83
83
  };
84
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "18.6.0",
3
+ "version": "18.7.1-alpha.11+7cf93b7e6",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -52,9 +52,9 @@
52
52
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
53
53
  },
54
54
  "dependencies": {
55
- "@uniformdev/canvas": "18.6.0",
56
- "@uniformdev/canvas-react": "18.6.0",
57
- "@uniformdev/project-map": "18.6.0"
55
+ "@uniformdev/canvas": "18.7.1-alpha.11+7cf93b7e6",
56
+ "@uniformdev/canvas-react": "18.7.1-alpha.11+7cf93b7e6",
57
+ "@uniformdev/project-map": "18.7.1-alpha.11+7cf93b7e6"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "next": ">= 12.0.0",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/react": "18.0.27",
66
- "next": "13.1.4",
66
+ "next": "13.1.6",
67
67
  "react": "18.2.0",
68
68
  "react-dom": "18.2.0"
69
69
  },
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "2e2b4d179180900386f8b3ceb30d4a854a7e22fd"
76
+ "gitHead": "7cf93b7e693ac5a98f87d00f0028c43be13733da"
77
77
  }