@uniformdev/canvas-next-rsc 19.37.1 → 19.38.2
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,4 +1,5 @@
|
|
|
1
1
|
import { CanvasClient } from '@uniformdev/canvas';
|
|
2
|
+
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
2
3
|
import { buildCompositionTag } from '../utils/tag';
|
|
3
4
|
export const getCanvasClient = (options) => {
|
|
4
5
|
return new CanvasClient({
|
|
@@ -36,7 +37,7 @@ export const getCanvasClient = (options) => {
|
|
|
36
37
|
}
|
|
37
38
|
let revalidate = options === null || options === void 0 ? void 0 : options.revalidate;
|
|
38
39
|
let noCache = false;
|
|
39
|
-
if (revalidate === -1) {
|
|
40
|
+
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
40
41
|
noCache = true;
|
|
41
42
|
revalidate = undefined;
|
|
42
43
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ManifestClient } from '@uniformdev/context/api';
|
|
2
2
|
import { getManifestRevalidateInterval } from '../config/helpers';
|
|
3
|
+
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
3
4
|
export const getManifestClient = (options) => {
|
|
4
5
|
const manifestClient = new ManifestClient({
|
|
5
6
|
apiHost: process.env.UNIFORM_API_HOST || process.env.UNIFORM_CLI_BASE_URL,
|
|
@@ -8,7 +9,7 @@ export const getManifestClient = (options) => {
|
|
|
8
9
|
fetch: (req, init) => {
|
|
9
10
|
let revalidate = options === null || options === void 0 ? void 0 : options.revalidate;
|
|
10
11
|
let noCache = false;
|
|
11
|
-
if (revalidate === -1) {
|
|
12
|
+
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
12
13
|
noCache = true;
|
|
13
14
|
revalidate = undefined;
|
|
14
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RouteClient } from '@uniformdev/canvas';
|
|
2
|
+
import { isDevelopmentEnvironment } from '../utils/draft';
|
|
2
3
|
import { buildPathTag } from '../utils/tag';
|
|
3
4
|
export const getRouteClient = (options) => {
|
|
4
5
|
const client = new RouteClient({
|
|
@@ -38,7 +39,7 @@ export const getRouteClient = (options) => {
|
|
|
38
39
|
if (options === null || options === void 0 ? void 0 : options.revalidate) {
|
|
39
40
|
revalidate = options.revalidate;
|
|
40
41
|
}
|
|
41
|
-
if (revalidate === -1) {
|
|
42
|
+
if (revalidate === -1 || isDevelopmentEnvironment()) {
|
|
42
43
|
noCache = true;
|
|
43
44
|
revalidate = undefined;
|
|
44
45
|
}
|
|
@@ -3,7 +3,7 @@ import { CANVAS_DRAFT_STATE, CANVAS_PUBLISHED_STATE } from '@uniformdev/canvas';
|
|
|
3
3
|
import { notFound, redirect } from 'next/navigation';
|
|
4
4
|
import { Suspense } from 'react';
|
|
5
5
|
import { getManifestFromApi } from '../client/manifestClient';
|
|
6
|
-
import { isDraftModeEnabled, isOnVercelPreviewEnvironment } from '../utils/draft';
|
|
6
|
+
import { isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, } from '../utils/draft';
|
|
7
7
|
import { evaluateComposition } from './evaluateComposition';
|
|
8
8
|
import { resolvePath } from './resolvePath';
|
|
9
9
|
import { resolveRedirectHref, retrieveRoute } from './retrieveRoute';
|
|
@@ -26,6 +26,10 @@ const UniformCompositionInner = async ({ params, searchParams, children }) => {
|
|
|
26
26
|
});
|
|
27
27
|
const draftMode = isDraftModeEnabled({ searchParams });
|
|
28
28
|
const previewEnvironment = isOnVercelPreviewEnvironment();
|
|
29
|
+
const isDevelopment = isDevelopmentEnvironment();
|
|
30
|
+
const isCanvasEditing = isIncontextEditingEnabled({
|
|
31
|
+
searchParams,
|
|
32
|
+
});
|
|
29
33
|
// resolve the path from provided params
|
|
30
34
|
const path = resolvePath({
|
|
31
35
|
params,
|
|
@@ -33,7 +37,7 @@ const UniformCompositionInner = async ({ params, searchParams, children }) => {
|
|
|
33
37
|
// resolve the route from the path
|
|
34
38
|
const resolveResult = await retrieveRoute({
|
|
35
39
|
path,
|
|
36
|
-
state: draftMode || previewEnvironment ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE,
|
|
40
|
+
state: draftMode || previewEnvironment || isDevelopment ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE,
|
|
37
41
|
searchParams,
|
|
38
42
|
});
|
|
39
43
|
// if the route is a redirect, redirect
|
|
@@ -56,5 +60,5 @@ const UniformCompositionInner = async ({ params, searchParams, children }) => {
|
|
|
56
60
|
path,
|
|
57
61
|
searchParams,
|
|
58
62
|
};
|
|
59
|
-
return (_jsxs(UniformProvider, { cookieValue: cookieValue, seenComponents: seenComponents, children: [_jsx(UniformScript, { enabled:
|
|
63
|
+
return (_jsxs(UniformProvider, { cookieValue: cookieValue, seenComponents: seenComponents, children: [_jsx(UniformScript, { enabled: isCanvasEditing }), _jsx(UniformComponent, { data: evaluatedComposition, context: context }), Boolean(children) && children] }));
|
|
60
64
|
};
|
package/dist/utils/draft.d.ts
CHANGED
package/dist/utils/draft.js
CHANGED
|
@@ -3,16 +3,15 @@ import { draftMode } from 'next/headers';
|
|
|
3
3
|
export const isDraftModeEnabled = ({ searchParams, }) => {
|
|
4
4
|
// workaround for this https://github.com/vercel/next.js/issues/49927, as draftMode() is not working in dev mode
|
|
5
5
|
// so we just need to check if the query string contains the IN_CONTEXT_EDITOR_QUERY_STRING_PARAM blindly
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
return containsKey;
|
|
6
|
+
if (isDevelopmentEnvironment()) {
|
|
7
|
+
return isIncontextEditingEnabled({ searchParams });
|
|
9
8
|
}
|
|
10
9
|
return draftMode().isEnabled;
|
|
11
10
|
};
|
|
12
11
|
export const isIncontextEditingEnabled = ({ searchParams, }) => {
|
|
13
12
|
// workaround for this https://github.com/vercel/next.js/issues/49927, as draftMode() is not working in dev mode
|
|
14
13
|
// so we just need to check if the query string contains the IN_CONTEXT_EDITOR_QUERY_STRING_PARAM blindly
|
|
15
|
-
if (
|
|
14
|
+
if (isDevelopmentEnvironment()) {
|
|
16
15
|
const containsKey = typeof (searchParams === null || searchParams === void 0 ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== 'undefined';
|
|
17
16
|
return containsKey;
|
|
18
17
|
}
|
|
@@ -21,3 +20,6 @@ export const isIncontextEditingEnabled = ({ searchParams, }) => {
|
|
|
21
20
|
export const isOnVercelPreviewEnvironment = () => {
|
|
22
21
|
return process.env.VERCEL_ENV === 'preview';
|
|
23
22
|
};
|
|
23
|
+
export const isDevelopmentEnvironment = () => {
|
|
24
|
+
return process.env.NODE_ENV === 'development';
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.38.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "pnpm build --watch",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"@types/node": "^18.0.0",
|
|
51
51
|
"@types/react": "^18.2.3",
|
|
52
52
|
"eslint": "^8.11.0",
|
|
53
|
-
"next": "13.4.
|
|
53
|
+
"next": "13.4.12",
|
|
54
54
|
"react": "18.2.0",
|
|
55
55
|
"react-dom": "18.2.0",
|
|
56
56
|
"typescript": "^5.0.4"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@uniformdev/canvas": "19.
|
|
60
|
-
"@uniformdev/canvas-react": "19.
|
|
61
|
-
"@uniformdev/context": "19.
|
|
62
|
-
"@uniformdev/project-map": "19.
|
|
63
|
-
"@uniformdev/redirect": "19.
|
|
64
|
-
"@uniformdev/richtext": "19.
|
|
65
|
-
"@uniformdev/webhooks": "19.
|
|
59
|
+
"@uniformdev/canvas": "19.38.2",
|
|
60
|
+
"@uniformdev/canvas-react": "19.38.2",
|
|
61
|
+
"@uniformdev/context": "19.38.2",
|
|
62
|
+
"@uniformdev/project-map": "19.38.2",
|
|
63
|
+
"@uniformdev/redirect": "19.38.2",
|
|
64
|
+
"@uniformdev/richtext": "19.38.2",
|
|
65
|
+
"@uniformdev/webhooks": "19.38.2",
|
|
66
66
|
"@vercel/edge-config": "^0.2.0",
|
|
67
67
|
"dequal": "^2.0.3",
|
|
68
68
|
"js-cookie": "^3.0.5",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "b97fd17fd44e0f5bd3806e942b516cb2bd218096"
|
|
80
80
|
}
|