@uniformdev/canvas-next 18.33.0 → 18.34.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.d.ts +1 -1
- package/dist/index.esm.js +16 -3
- package/dist/index.js +16 -3
- package/dist/index.mjs +16 -3
- package/dist/{models-6ff72d91.d.ts → models-092c0912.d.ts} +4 -0
- package/dist/project-map/index.d.ts +1 -1
- package/dist/project-map/index.js +8 -4
- package/dist/project-map/index.mjs +12 -6
- package/dist/slug/index.d.ts +1 -1
- package/dist/slug/index.js +8 -3
- package/dist/slug/index.mjs +12 -5
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsedUrlQuery } from 'querystring';
|
|
2
|
-
export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-
|
|
2
|
+
export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-092c0912.js';
|
|
3
3
|
import { NextApiHandler, NextApiRequest } from 'next';
|
|
4
4
|
import { RootComponentInstance } from '@uniformdev/canvas';
|
|
5
5
|
import '@uniformdev/canvas-react';
|
package/dist/index.esm.js
CHANGED
|
@@ -31,9 +31,22 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
|
|
|
31
31
|
if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
|
|
32
32
|
return res.status(401).json({ message: "Invalid token" });
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true";
|
|
35
|
+
res.setPreviewData(
|
|
36
|
+
{
|
|
37
|
+
isUniformContextualEditing,
|
|
38
|
+
compositionId: id,
|
|
39
|
+
compositionSlug: slug,
|
|
40
|
+
compositionPath: path,
|
|
41
|
+
locale
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
// By default the preview cookies stays as long as the tab is open. And in contextual editing mode, people tend to open Canvas editor (one tab) and another tab to see published changes.
|
|
45
|
+
// This causes the second tab to still have the preview cookie, which causes unexpected behavior.
|
|
46
|
+
// This is more obvious in contextual editing mode because we skip the composition fetching and the user sees a blank page where they expected the published composition.
|
|
47
|
+
maxAge: isUniformContextualEditing ? 0 : void 0
|
|
48
|
+
}
|
|
49
|
+
);
|
|
37
50
|
const cookies = res.getHeader("Set-Cookie");
|
|
38
51
|
res.setHeader(
|
|
39
52
|
"Set-Cookie",
|
package/dist/index.js
CHANGED
|
@@ -66,9 +66,22 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
|
|
|
66
66
|
if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
|
|
67
67
|
return res.status(401).json({ message: "Invalid token" });
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const isUniformContextualEditing = req.query[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true";
|
|
70
|
+
res.setPreviewData(
|
|
71
|
+
{
|
|
72
|
+
isUniformContextualEditing,
|
|
73
|
+
compositionId: id,
|
|
74
|
+
compositionSlug: slug,
|
|
75
|
+
compositionPath: path,
|
|
76
|
+
locale
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
// By default the preview cookies stays as long as the tab is open. And in contextual editing mode, people tend to open Canvas editor (one tab) and another tab to see published changes.
|
|
80
|
+
// This causes the second tab to still have the preview cookie, which causes unexpected behavior.
|
|
81
|
+
// This is more obvious in contextual editing mode because we skip the composition fetching and the user sees a blank page where they expected the published composition.
|
|
82
|
+
maxAge: isUniformContextualEditing ? 0 : void 0
|
|
83
|
+
}
|
|
84
|
+
);
|
|
72
85
|
const cookies = res.getHeader("Set-Cookie");
|
|
73
86
|
res.setHeader(
|
|
74
87
|
"Set-Cookie",
|
package/dist/index.mjs
CHANGED
|
@@ -31,9 +31,22 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
|
|
|
31
31
|
if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
|
|
32
32
|
return res.status(401).json({ message: "Invalid token" });
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true";
|
|
35
|
+
res.setPreviewData(
|
|
36
|
+
{
|
|
37
|
+
isUniformContextualEditing,
|
|
38
|
+
compositionId: id,
|
|
39
|
+
compositionSlug: slug,
|
|
40
|
+
compositionPath: path,
|
|
41
|
+
locale
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
// By default the preview cookies stays as long as the tab is open. And in contextual editing mode, people tend to open Canvas editor (one tab) and another tab to see published changes.
|
|
45
|
+
// This causes the second tab to still have the preview cookie, which causes unexpected behavior.
|
|
46
|
+
// This is more obvious in contextual editing mode because we skip the composition fetching and the user sees a blank page where they expected the published composition.
|
|
47
|
+
maxAge: isUniformContextualEditing ? 0 : void 0
|
|
48
|
+
}
|
|
49
|
+
);
|
|
37
50
|
const cookies = res.getHeader("Set-Cookie");
|
|
38
51
|
res.setHeader(
|
|
39
52
|
"Set-Cookie",
|
|
@@ -6,6 +6,10 @@ import { ParsedUrlQuery } from 'querystring';
|
|
|
6
6
|
type UniformCompositionNextPage<TProps = unknown> = NextPage<TProps & UniformCompositionProps>;
|
|
7
7
|
type UniformPreviewData = PreviewData & {
|
|
8
8
|
isUniformContextualEditing: boolean;
|
|
9
|
+
compositionId?: string;
|
|
10
|
+
compositionSlug?: string;
|
|
11
|
+
compositionPath?: string;
|
|
12
|
+
locale?: string;
|
|
9
13
|
};
|
|
10
14
|
type UniformGetStaticProps<P extends {
|
|
11
15
|
[key: string]: any;
|
|
@@ -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-
|
|
3
|
+
import { c as UniformGetServerSideProps, a as UniformPreviewData, b as UniformGetStaticProps } from '../models-092c0912.js';
|
|
4
4
|
import * as querystring from 'querystring';
|
|
5
5
|
import { ParsedUrlQuery } from 'querystring';
|
|
6
6
|
import * as _uniformdev_canvas from '@uniformdev/canvas';
|
|
@@ -33,7 +33,7 @@ module.exports = __toCommonJS(project_map_exports);
|
|
|
33
33
|
var import_canvas = require("@uniformdev/canvas");
|
|
34
34
|
var withUniformGetServerSideProps = (options) => {
|
|
35
35
|
return async function wrappedGetServerSideProps(context) {
|
|
36
|
-
var _a;
|
|
36
|
+
var _a, _b;
|
|
37
37
|
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
38
38
|
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
39
39
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
@@ -47,7 +47,9 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
47
47
|
if (options == null ? void 0 : options.modifyPath) {
|
|
48
48
|
nodePath = options.modifyPath(nodePath, context);
|
|
49
49
|
}
|
|
50
|
-
if (
|
|
50
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
51
|
+
composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
|
|
52
|
+
} else {
|
|
51
53
|
try {
|
|
52
54
|
const response = await canvasClient.getCompositionByNodePath({
|
|
53
55
|
...options == null ? void 0 : options.requestOptions,
|
|
@@ -118,7 +120,7 @@ var resolveSlugFromParams = ({
|
|
|
118
120
|
// src/project-map/withUniformGetStaticProps.ts
|
|
119
121
|
var withUniformGetStaticProps = (options) => {
|
|
120
122
|
return async function wrappedGetStaticProps(context) {
|
|
121
|
-
var _a, _b;
|
|
123
|
+
var _a, _b, _c;
|
|
122
124
|
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
123
125
|
let pathString = resolveSlugFromParams({
|
|
124
126
|
param: options == null ? void 0 : options.param,
|
|
@@ -135,7 +137,9 @@ var withUniformGetStaticProps = (options) => {
|
|
|
135
137
|
});
|
|
136
138
|
const { preview, previewData } = context;
|
|
137
139
|
let composition = void 0;
|
|
138
|
-
if (
|
|
140
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
141
|
+
composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_c = previewData.compositionId) != null ? _c : import_canvas3.EMPTY_COMPOSITION._id };
|
|
142
|
+
} else {
|
|
139
143
|
try {
|
|
140
144
|
const response = await canvasClient.getCompositionByNodePath({
|
|
141
145
|
...options == null ? void 0 : options.requestOptions,
|
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
CANVAS_DRAFT_STATE,
|
|
8
8
|
CANVAS_PUBLISHED_STATE,
|
|
9
|
-
CanvasClient
|
|
9
|
+
CanvasClient,
|
|
10
|
+
EMPTY_COMPOSITION
|
|
10
11
|
} from "@uniformdev/canvas";
|
|
11
12
|
var withUniformGetServerSideProps = (options) => {
|
|
12
13
|
return async function wrappedGetServerSideProps(context) {
|
|
13
|
-
var _a;
|
|
14
|
+
var _a, _b;
|
|
14
15
|
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
15
16
|
const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
|
|
16
17
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
@@ -24,7 +25,9 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
24
25
|
if (options == null ? void 0 : options.modifyPath) {
|
|
25
26
|
nodePath = options.modifyPath(nodePath, context);
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
29
|
+
composition = { ...EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION._id };
|
|
30
|
+
} else {
|
|
28
31
|
try {
|
|
29
32
|
const response = await canvasClient.getCompositionByNodePath({
|
|
30
33
|
...options == null ? void 0 : options.requestOptions,
|
|
@@ -85,11 +88,12 @@ var withUniformGetStaticPaths = (options) => {
|
|
|
85
88
|
import {
|
|
86
89
|
CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
|
|
87
90
|
CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
|
|
88
|
-
CanvasClient as CanvasClient2
|
|
91
|
+
CanvasClient as CanvasClient2,
|
|
92
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
89
93
|
} from "@uniformdev/canvas";
|
|
90
94
|
var withUniformGetStaticProps = (options) => {
|
|
91
95
|
return async function wrappedGetStaticProps(context) {
|
|
92
|
-
var _a, _b;
|
|
96
|
+
var _a, _b, _c;
|
|
93
97
|
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
94
98
|
let pathString = resolveSlugFromParams({
|
|
95
99
|
param: options == null ? void 0 : options.param,
|
|
@@ -106,7 +110,9 @@ var withUniformGetStaticProps = (options) => {
|
|
|
106
110
|
});
|
|
107
111
|
const { preview, previewData } = context;
|
|
108
112
|
let composition = void 0;
|
|
109
|
-
if (
|
|
113
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
114
|
+
composition = { ...EMPTY_COMPOSITION2, _id: (_c = previewData.compositionId) != null ? _c : EMPTY_COMPOSITION2._id };
|
|
115
|
+
} else {
|
|
110
116
|
try {
|
|
111
117
|
const response = await canvasClient.getCompositionByNodePath({
|
|
112
118
|
...options == null ? void 0 : options.requestOptions,
|
package/dist/slug/index.d.ts
CHANGED
|
@@ -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-
|
|
3
|
+
import { a as UniformPreviewData, c as UniformGetServerSideProps, b as UniformGetStaticProps } from '../models-092c0912.js';
|
|
4
4
|
import * as querystring from 'querystring';
|
|
5
5
|
import { ParsedUrlQuery } from 'querystring';
|
|
6
6
|
import * as _uniformdev_canvas from '@uniformdev/canvas';
|
package/dist/slug/index.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = __toCommonJS(slug_exports);
|
|
|
33
33
|
var import_canvas = require("@uniformdev/canvas");
|
|
34
34
|
var withUniformGetServerSideProps = (options) => {
|
|
35
35
|
return async function wrappedGetServerSideProps(context) {
|
|
36
|
+
var _a;
|
|
36
37
|
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
37
38
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
38
39
|
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
@@ -45,7 +46,9 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
45
46
|
if (options == null ? void 0 : options.modifySlug) {
|
|
46
47
|
slug = options.modifySlug(slug, context);
|
|
47
48
|
}
|
|
48
|
-
if (
|
|
49
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
50
|
+
composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_a = previewData.compositionId) != null ? _a : import_canvas.EMPTY_COMPOSITION._id };
|
|
51
|
+
} else {
|
|
49
52
|
try {
|
|
50
53
|
const response = await canvasClient.getCompositionBySlug({
|
|
51
54
|
...options == null ? void 0 : options.requestOptions,
|
|
@@ -112,7 +115,7 @@ var resolveSlugFromParams = ({
|
|
|
112
115
|
// src/slug/withUniformGetStaticProps.ts
|
|
113
116
|
var withUniformGetStaticProps = (options) => {
|
|
114
117
|
return async function wrappedGetStaticProps(context) {
|
|
115
|
-
var _a;
|
|
118
|
+
var _a, _b;
|
|
116
119
|
let slugString = resolveSlugFromParams({
|
|
117
120
|
param: options == null ? void 0 : options.param,
|
|
118
121
|
params: context == null ? void 0 : context.params
|
|
@@ -128,7 +131,9 @@ var withUniformGetStaticProps = (options) => {
|
|
|
128
131
|
});
|
|
129
132
|
const { preview, previewData } = context;
|
|
130
133
|
let composition = void 0;
|
|
131
|
-
if (
|
|
134
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
135
|
+
composition = { ...import_canvas3.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas3.EMPTY_COMPOSITION._id };
|
|
136
|
+
} else {
|
|
132
137
|
try {
|
|
133
138
|
const response = await canvasClient.getCompositionBySlug({
|
|
134
139
|
slug: slugString,
|
package/dist/slug/index.mjs
CHANGED
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
CANVAS_DRAFT_STATE,
|
|
8
8
|
CANVAS_PUBLISHED_STATE,
|
|
9
|
-
CanvasClient
|
|
9
|
+
CanvasClient,
|
|
10
|
+
EMPTY_COMPOSITION
|
|
10
11
|
} from "@uniformdev/canvas";
|
|
11
12
|
var withUniformGetServerSideProps = (options) => {
|
|
12
13
|
return async function wrappedGetServerSideProps(context) {
|
|
14
|
+
var _a;
|
|
13
15
|
const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
|
|
14
16
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
15
17
|
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
@@ -22,7 +24,9 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
22
24
|
if (options == null ? void 0 : options.modifySlug) {
|
|
23
25
|
slug = options.modifySlug(slug, context);
|
|
24
26
|
}
|
|
25
|
-
if (
|
|
27
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
28
|
+
composition = { ...EMPTY_COMPOSITION, _id: (_a = previewData.compositionId) != null ? _a : EMPTY_COMPOSITION._id };
|
|
29
|
+
} else {
|
|
26
30
|
try {
|
|
27
31
|
const response = await canvasClient.getCompositionBySlug({
|
|
28
32
|
...options == null ? void 0 : options.requestOptions,
|
|
@@ -81,11 +85,12 @@ var withUniformGetStaticPaths = (options) => {
|
|
|
81
85
|
import {
|
|
82
86
|
CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
|
|
83
87
|
CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
|
|
84
|
-
CanvasClient as CanvasClient3
|
|
88
|
+
CanvasClient as CanvasClient3,
|
|
89
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
85
90
|
} from "@uniformdev/canvas";
|
|
86
91
|
var withUniformGetStaticProps = (options) => {
|
|
87
92
|
return async function wrappedGetStaticProps(context) {
|
|
88
|
-
var _a;
|
|
93
|
+
var _a, _b;
|
|
89
94
|
let slugString = resolveSlugFromParams({
|
|
90
95
|
param: options == null ? void 0 : options.param,
|
|
91
96
|
params: context == null ? void 0 : context.params
|
|
@@ -101,7 +106,9 @@ var withUniformGetStaticProps = (options) => {
|
|
|
101
106
|
});
|
|
102
107
|
const { preview, previewData } = context;
|
|
103
108
|
let composition = void 0;
|
|
104
|
-
if (
|
|
109
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
110
|
+
composition = { ...EMPTY_COMPOSITION2, _id: (_b = previewData.compositionId) != null ? _b : EMPTY_COMPOSITION2._id };
|
|
111
|
+
} else {
|
|
105
112
|
try {
|
|
106
113
|
const response = await canvasClient.getCompositionBySlug({
|
|
107
114
|
slug: slugString,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.34.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.
|
|
57
|
-
"@uniformdev/canvas-react": "18.
|
|
58
|
-
"@uniformdev/project-map": "18.
|
|
56
|
+
"@uniformdev/canvas": "18.34.0",
|
|
57
|
+
"@uniformdev/canvas-react": "18.34.0",
|
|
58
|
+
"@uniformdev/project-map": "18.34.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": "
|
|
77
|
+
"gitHead": "563ab31aa4308102c988bea321028e73efe836d0"
|
|
78
78
|
}
|