@uniformdev/canvas-next 18.25.1-alpha.16 → 18.27.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.
package/dist/index.esm.js CHANGED
@@ -91,6 +91,11 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
91
91
  return createPreviewHandlerGet({ secret, resolveFullPath })(req, res);
92
92
  } else if (method === "post") {
93
93
  return createPreviewHandlerPost({ secret, enhance })(req, res);
94
+ } else if (method === "options") {
95
+ res.setHeader("Access-Control-Allow-Origin", "*");
96
+ res.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept");
97
+ res.setHeader("Access-Control-Allow-Methods", "GET");
98
+ return res.status(204);
94
99
  }
95
100
  return res.status(501).json({ message: `Method "${method}" not implemented` });
96
101
  };
package/dist/index.js CHANGED
@@ -126,6 +126,11 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
126
126
  return createPreviewHandlerGet({ secret, resolveFullPath })(req, res);
127
127
  } else if (method === "post") {
128
128
  return createPreviewHandlerPost({ secret, enhance })(req, res);
129
+ } else if (method === "options") {
130
+ res.setHeader("Access-Control-Allow-Origin", "*");
131
+ res.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept");
132
+ res.setHeader("Access-Control-Allow-Methods", "GET");
133
+ return res.status(204);
129
134
  }
130
135
  return res.status(501).json({ message: `Method "${method}" not implemented` });
131
136
  };
package/dist/index.mjs CHANGED
@@ -91,6 +91,11 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
91
91
  return createPreviewHandlerGet({ secret, resolveFullPath })(req, res);
92
92
  } else if (method === "post") {
93
93
  return createPreviewHandlerPost({ secret, enhance })(req, res);
94
+ } else if (method === "options") {
95
+ res.setHeader("Access-Control-Allow-Origin", "*");
96
+ res.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept");
97
+ res.setHeader("Access-Control-Allow-Methods", "GET");
98
+ return res.status(204);
94
99
  }
95
100
  return res.status(501).json({ message: `Method "${method}" not implemented` });
96
101
  };
@@ -1,6 +1,6 @@
1
- import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-6ff72d91.js';
2
1
  import * as next from 'next';
3
2
  import { GetServerSidePropsContext, PreviewData, GetServerSideProps, GetStaticPropsContext, GetStaticProps } from 'next';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-6ff72d91.js';
4
4
  import * as querystring from 'querystring';
5
5
  import { ParsedUrlQuery } from 'querystring';
6
6
  import * as _uniformdev_canvas from '@uniformdev/canvas';
@@ -34,7 +34,7 @@ declare const withUniformGetServerSideProps: <TProps extends {
34
34
  } & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption> | undefined;
35
35
  /** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
36
36
  callback?: UniformGetServerSideProps<TProps, ParsedUrlQuery, PreviewData> | undefined;
37
- } | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, PreviewData>;
37
+ } | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
38
38
 
39
39
  declare const withUniformGetStaticPaths: (options?: {
40
40
  projectMapId?: string | undefined;
@@ -100,7 +100,7 @@ declare const withUniformGetStaticProps: <TProps extends {
100
100
 
101
101
  declare const getServerSideProps: next.GetServerSideProps<{
102
102
  [key: string]: any;
103
- }, querystring.ParsedUrlQuery, next.PreviewData>;
103
+ }, querystring.ParsedUrlQuery, UniformPreviewData>;
104
104
  /** Ready to go getStaticProps for dynamic route with 'path' param for [[...path]].jsx */
105
105
  declare const getStaticProps: next.GetStaticProps<{
106
106
  [key: string]: any;
@@ -40,25 +40,27 @@ var withUniformGetServerSideProps = (options) => {
40
40
  projectId: process.env.UNIFORM_PROJECT_ID,
41
41
  apiHost: process.env.UNIFORM_CLI_BASE_URL
42
42
  });
43
- const preview = context.preview || (options == null ? void 0 : options.preview);
43
+ const { preview, previewData } = context;
44
44
  let composition = void 0;
45
45
  let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
46
46
  if (options == null ? void 0 : options.modifyPath) {
47
47
  nodePath = options.modifyPath(nodePath, context);
48
48
  }
49
- try {
50
- const response = await canvasClient.getCompositionByNodePath({
51
- ...options == null ? void 0 : options.requestOptions,
52
- projectMapId,
53
- projectMapNodePath: nodePath,
54
- state: preview ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
55
- });
56
- composition = response.composition;
57
- } catch (e) {
58
- console.error("[canvas-next] Failed to fetch composition", e);
59
- return {
60
- notFound: true
61
- };
49
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
50
+ try {
51
+ const response = await canvasClient.getCompositionByNodePath({
52
+ ...options == null ? void 0 : options.requestOptions,
53
+ projectMapId,
54
+ projectMapNodePath: nodePath,
55
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
56
+ });
57
+ composition = response.composition;
58
+ } catch (e) {
59
+ console.error("[canvas-next] Failed to fetch composition", e);
60
+ return {
61
+ notFound: true
62
+ };
63
+ }
62
64
  }
63
65
  const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
64
66
  if (Object.hasOwn(ret, "props")) {
@@ -131,17 +133,17 @@ var withUniformGetStaticProps = (options) => {
131
133
  });
132
134
  const { preview, previewData } = context;
133
135
  let composition = void 0;
134
- try {
135
- const response = await canvasClient.getCompositionByNodePath({
136
- ...options == null ? void 0 : options.requestOptions,
137
- projectMapId,
138
- projectMapNodePath: pathString,
139
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
140
- });
141
- composition = response.composition;
142
- } catch (e) {
143
- console.error("[canvas-next] Failed to fetch composition", e);
144
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
136
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
137
+ try {
138
+ const response = await canvasClient.getCompositionByNodePath({
139
+ ...options == null ? void 0 : options.requestOptions,
140
+ projectMapId,
141
+ projectMapNodePath: pathString,
142
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE
143
+ });
144
+ composition = response.composition;
145
+ } catch (e) {
146
+ console.error("[canvas-next] Failed to fetch composition", e);
145
147
  return {
146
148
  notFound: true
147
149
  };
@@ -17,25 +17,27 @@ var withUniformGetServerSideProps = (options) => {
17
17
  projectId: process.env.UNIFORM_PROJECT_ID,
18
18
  apiHost: process.env.UNIFORM_CLI_BASE_URL
19
19
  });
20
- const preview = context.preview || (options == null ? void 0 : options.preview);
20
+ const { preview, previewData } = context;
21
21
  let composition = void 0;
22
22
  let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
23
23
  if (options == null ? void 0 : options.modifyPath) {
24
24
  nodePath = options.modifyPath(nodePath, context);
25
25
  }
26
- try {
27
- const response = await canvasClient.getCompositionByNodePath({
28
- ...options == null ? void 0 : options.requestOptions,
29
- projectMapId,
30
- projectMapNodePath: nodePath,
31
- state: preview ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
32
- });
33
- composition = response.composition;
34
- } catch (e) {
35
- console.error("[canvas-next] Failed to fetch composition", e);
36
- return {
37
- notFound: true
38
- };
26
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
27
+ try {
28
+ const response = await canvasClient.getCompositionByNodePath({
29
+ ...options == null ? void 0 : options.requestOptions,
30
+ projectMapId,
31
+ projectMapNodePath: nodePath,
32
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
33
+ });
34
+ composition = response.composition;
35
+ } catch (e) {
36
+ console.error("[canvas-next] Failed to fetch composition", e);
37
+ return {
38
+ notFound: true
39
+ };
40
+ }
39
41
  }
40
42
  const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
41
43
  if (Object.hasOwn(ret, "props")) {
@@ -102,17 +104,17 @@ var withUniformGetStaticProps = (options) => {
102
104
  });
103
105
  const { preview, previewData } = context;
104
106
  let composition = void 0;
105
- try {
106
- const response = await canvasClient.getCompositionByNodePath({
107
- ...options == null ? void 0 : options.requestOptions,
108
- projectMapId,
109
- projectMapNodePath: pathString,
110
- state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3
111
- });
112
- composition = response.composition;
113
- } catch (e) {
114
- console.error("[canvas-next] Failed to fetch composition", e);
115
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
107
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
108
+ try {
109
+ const response = await canvasClient.getCompositionByNodePath({
110
+ ...options == null ? void 0 : options.requestOptions,
111
+ projectMapId,
112
+ projectMapNodePath: pathString,
113
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3
114
+ });
115
+ composition = response.composition;
116
+ } catch (e) {
117
+ console.error("[canvas-next] Failed to fetch composition", e);
116
118
  return {
117
119
  notFound: true
118
120
  };
@@ -44,16 +44,16 @@ var withUniformGetServerSideProps = (options) => {
44
44
  if (options == null ? void 0 : options.modifySlug) {
45
45
  slug = options.modifySlug(slug, context);
46
46
  }
47
- try {
48
- const response = await canvasClient.getCompositionBySlug({
49
- ...options == null ? void 0 : options.requestOptions,
50
- slug,
51
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
52
- });
53
- composition = response.composition;
54
- } catch (e) {
55
- console.error("[canvas-next] Failed to fetch composition", e);
56
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
47
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
48
+ try {
49
+ const response = await canvasClient.getCompositionBySlug({
50
+ ...options == null ? void 0 : options.requestOptions,
51
+ slug,
52
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
53
+ });
54
+ composition = response.composition;
55
+ } catch (e) {
56
+ console.error("[canvas-next] Failed to fetch composition", e);
57
57
  return {
58
58
  notFound: true
59
59
  };
@@ -125,16 +125,16 @@ var withUniformGetStaticProps = (options) => {
125
125
  });
126
126
  const { preview, previewData } = context;
127
127
  let composition = void 0;
128
- try {
129
- const response = await canvasClient.getCompositionBySlug({
130
- slug: slugString,
131
- state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE,
132
- ...options == null ? void 0 : options.requestOptions
133
- });
134
- composition = response.composition;
135
- } catch (e) {
136
- console.error("[canvas-next] Failed to fetch composition", e);
137
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
128
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
129
+ try {
130
+ const response = await canvasClient.getCompositionBySlug({
131
+ slug: slugString,
132
+ state: preview || (options == null ? void 0 : options.preview) ? import_canvas3.CANVAS_DRAFT_STATE : import_canvas3.CANVAS_PUBLISHED_STATE,
133
+ ...options == null ? void 0 : options.requestOptions
134
+ });
135
+ composition = response.composition;
136
+ } catch (e) {
137
+ console.error("[canvas-next] Failed to fetch composition", e);
138
138
  return {
139
139
  notFound: true
140
140
  };
@@ -21,16 +21,16 @@ var withUniformGetServerSideProps = (options) => {
21
21
  if (options == null ? void 0 : options.modifySlug) {
22
22
  slug = options.modifySlug(slug, context);
23
23
  }
24
- try {
25
- const response = await canvasClient.getCompositionBySlug({
26
- ...options == null ? void 0 : options.requestOptions,
27
- slug,
28
- state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
29
- });
30
- composition = response.composition;
31
- } catch (e) {
32
- console.error("[canvas-next] Failed to fetch composition", e);
33
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
24
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
25
+ try {
26
+ const response = await canvasClient.getCompositionBySlug({
27
+ ...options == null ? void 0 : options.requestOptions,
28
+ slug,
29
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE
30
+ });
31
+ composition = response.composition;
32
+ } catch (e) {
33
+ console.error("[canvas-next] Failed to fetch composition", e);
34
34
  return {
35
35
  notFound: true
36
36
  };
@@ -98,16 +98,16 @@ var withUniformGetStaticProps = (options) => {
98
98
  });
99
99
  const { preview, previewData } = context;
100
100
  let composition = void 0;
101
- try {
102
- const response = await canvasClient.getCompositionBySlug({
103
- slug: slugString,
104
- state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3,
105
- ...options == null ? void 0 : options.requestOptions
106
- });
107
- composition = response.composition;
108
- } catch (e) {
109
- console.error("[canvas-next] Failed to fetch composition", e);
110
- if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
101
+ if (!(previewData == null ? void 0 : previewData.isUniformContextualEditing)) {
102
+ try {
103
+ const response = await canvasClient.getCompositionBySlug({
104
+ slug: slugString,
105
+ state: preview || (options == null ? void 0 : options.preview) ? CANVAS_DRAFT_STATE3 : CANVAS_PUBLISHED_STATE3,
106
+ ...options == null ? void 0 : options.requestOptions
107
+ });
108
+ composition = response.composition;
109
+ } catch (e) {
110
+ console.error("[canvas-next] Failed to fetch composition", e);
111
111
  return {
112
112
  notFound: true
113
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "18.25.1-alpha.16+650a7b092",
3
+ "version": "18.27.0",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -53,9 +53,9 @@
53
53
  "document": "api-extractor run --local"
54
54
  },
55
55
  "dependencies": {
56
- "@uniformdev/canvas": "18.25.1-alpha.16+650a7b092",
57
- "@uniformdev/canvas-react": "18.25.1-alpha.16+650a7b092",
58
- "@uniformdev/project-map": "18.25.1-alpha.16+650a7b092"
56
+ "@uniformdev/canvas": "18.27.0",
57
+ "@uniformdev/canvas-react": "18.27.0",
58
+ "@uniformdev/project-map": "18.27.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "next": ">= 12.0.0",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "650a7b092914e3eb21d60d103de9e8af96e4575f"
77
+ "gitHead": "2f40af577d2f8ce537e857f8fbc08b4030e73cd1"
78
78
  }