@uniformdev/canvas-next-rsc 19.196.1-alpha.2 → 19.196.1
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/config.js +16 -43
- package/dist/config.mjs +16 -43
- package/dist/handler.js +2 -2
- package/dist/handler.mjs +2 -2
- package/dist/index.d.mts +20 -21
- package/dist/index.d.ts +20 -21
- package/dist/index.esm.js +42 -56
- package/dist/index.js +42 -56
- package/dist/index.mjs +42 -56
- package/package.json +20 -21
package/dist/config.js
CHANGED
|
@@ -28,58 +28,31 @@ var import_path = require("path");
|
|
|
28
28
|
var getConfigPath = () => {
|
|
29
29
|
const possibleExtensions = [".js", ".cjs", ".mjs", ".ts"];
|
|
30
30
|
let configFilePath;
|
|
31
|
-
let configFileName;
|
|
32
31
|
for (const extension of possibleExtensions) {
|
|
33
|
-
const
|
|
34
|
-
const filePath = (0, import_path.join)(process.cwd(), fileName);
|
|
32
|
+
const filePath = (0, import_path.join)(process.cwd(), `uniform.server.config${extension}`);
|
|
35
33
|
if ((0, import_fs.existsSync)(filePath)) {
|
|
36
34
|
configFilePath = filePath;
|
|
37
|
-
configFileName = fileName;
|
|
38
35
|
break;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
filePath: configFilePath,
|
|
46
|
-
fileName: configFileName
|
|
47
|
-
};
|
|
38
|
+
return configFilePath;
|
|
48
39
|
};
|
|
49
|
-
var withUniformConfig = (nextConfig) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
...nextConfig,
|
|
61
|
-
experimental: {
|
|
62
|
-
...nextConfig.experimental || {},
|
|
63
|
-
turbo: {
|
|
64
|
-
...((_c = nextConfig.experimental) == null ? void 0 : _c.turbo) || {},
|
|
65
|
-
resolveAlias: turboResolveAliases
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
webpack: (config, context) => {
|
|
69
|
-
if (nextConfig.webpack) {
|
|
70
|
-
nextConfig.webpack(config, context);
|
|
71
|
-
}
|
|
72
|
-
if (context.isServer) {
|
|
73
|
-
const { filePath: uniformConfigPath } = getConfigPath() || {};
|
|
74
|
-
if (uniformConfigPath) {
|
|
75
|
-
console.log("Using Uniform config from", uniformConfigPath);
|
|
76
|
-
config.resolve.alias["uniform.server.config"] = (0, import_path.resolve)(config.context, uniformConfigPath);
|
|
77
|
-
}
|
|
40
|
+
var withUniformConfig = (nextConfig) => ({
|
|
41
|
+
...nextConfig,
|
|
42
|
+
webpack: (config, context) => {
|
|
43
|
+
if (nextConfig.webpack) {
|
|
44
|
+
nextConfig.webpack(config, context);
|
|
45
|
+
}
|
|
46
|
+
if (context.isServer) {
|
|
47
|
+
const uniformConfigPath = getConfigPath();
|
|
48
|
+
if (uniformConfigPath) {
|
|
49
|
+
console.log("Using Uniform config from", uniformConfigPath);
|
|
50
|
+
config.resolve.alias["uniform.server.config"] = (0, import_path.resolve)(config.context, uniformConfigPath);
|
|
78
51
|
}
|
|
79
|
-
return config;
|
|
80
52
|
}
|
|
81
|
-
|
|
82
|
-
}
|
|
53
|
+
return config;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
83
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
57
|
0 && (module.exports = {
|
|
85
58
|
withUniformConfig
|
package/dist/config.mjs
CHANGED
|
@@ -4,58 +4,31 @@ import { join, resolve } from "path";
|
|
|
4
4
|
var getConfigPath = () => {
|
|
5
5
|
const possibleExtensions = [".js", ".cjs", ".mjs", ".ts"];
|
|
6
6
|
let configFilePath;
|
|
7
|
-
let configFileName;
|
|
8
7
|
for (const extension of possibleExtensions) {
|
|
9
|
-
const
|
|
10
|
-
const filePath = join(process.cwd(), fileName);
|
|
8
|
+
const filePath = join(process.cwd(), `uniform.server.config${extension}`);
|
|
11
9
|
if (existsSync(filePath)) {
|
|
12
10
|
configFilePath = filePath;
|
|
13
|
-
configFileName = fileName;
|
|
14
11
|
break;
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
filePath: configFilePath,
|
|
22
|
-
fileName: configFileName
|
|
23
|
-
};
|
|
14
|
+
return configFilePath;
|
|
24
15
|
};
|
|
25
|
-
var withUniformConfig = (nextConfig) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
...nextConfig,
|
|
37
|
-
experimental: {
|
|
38
|
-
...nextConfig.experimental || {},
|
|
39
|
-
turbo: {
|
|
40
|
-
...((_c = nextConfig.experimental) == null ? void 0 : _c.turbo) || {},
|
|
41
|
-
resolveAlias: turboResolveAliases
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
webpack: (config, context) => {
|
|
45
|
-
if (nextConfig.webpack) {
|
|
46
|
-
nextConfig.webpack(config, context);
|
|
47
|
-
}
|
|
48
|
-
if (context.isServer) {
|
|
49
|
-
const { filePath: uniformConfigPath } = getConfigPath() || {};
|
|
50
|
-
if (uniformConfigPath) {
|
|
51
|
-
console.log("Using Uniform config from", uniformConfigPath);
|
|
52
|
-
config.resolve.alias["uniform.server.config"] = resolve(config.context, uniformConfigPath);
|
|
53
|
-
}
|
|
16
|
+
var withUniformConfig = (nextConfig) => ({
|
|
17
|
+
...nextConfig,
|
|
18
|
+
webpack: (config, context) => {
|
|
19
|
+
if (nextConfig.webpack) {
|
|
20
|
+
nextConfig.webpack(config, context);
|
|
21
|
+
}
|
|
22
|
+
if (context.isServer) {
|
|
23
|
+
const uniformConfigPath = getConfigPath();
|
|
24
|
+
if (uniformConfigPath) {
|
|
25
|
+
console.log("Using Uniform config from", uniformConfigPath);
|
|
26
|
+
config.resolve.alias["uniform.server.config"] = resolve(config.context, uniformConfigPath);
|
|
54
27
|
}
|
|
55
|
-
return config;
|
|
56
28
|
}
|
|
57
|
-
|
|
58
|
-
}
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
59
32
|
export {
|
|
60
33
|
withUniformConfig
|
|
61
34
|
};
|
package/dist/handler.js
CHANGED
|
@@ -100,14 +100,14 @@ var createPreviewGETRouteHandler = (options) => {
|
|
|
100
100
|
return new Response("Could not resolve the full path of the preview page", { status: 400 });
|
|
101
101
|
}
|
|
102
102
|
if (disable) {
|
|
103
|
-
(
|
|
103
|
+
(0, import_headers.draftMode)().disable();
|
|
104
104
|
(0, import_navigation.redirect)(pathToRedirectTo);
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
if (secret !== process.env.UNIFORM_PREVIEW_SECRET) {
|
|
108
108
|
return new Response("Invalid preview secret", { status: 401 });
|
|
109
109
|
}
|
|
110
|
-
(
|
|
110
|
+
(0, import_headers.draftMode)().enable();
|
|
111
111
|
const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
|
|
112
112
|
assignRequestQueryToSearchParams(redirectionUrl.searchParams, searchParams);
|
|
113
113
|
if (isPlayground) {
|
package/dist/handler.mjs
CHANGED
|
@@ -67,14 +67,14 @@ var createPreviewGETRouteHandler = (options) => {
|
|
|
67
67
|
return new Response("Could not resolve the full path of the preview page", { status: 400 });
|
|
68
68
|
}
|
|
69
69
|
if (disable) {
|
|
70
|
-
|
|
70
|
+
draftMode().disable();
|
|
71
71
|
redirect(pathToRedirectTo);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (secret !== process.env.UNIFORM_PREVIEW_SECRET) {
|
|
75
75
|
return new Response("Invalid preview secret", { status: 401 });
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
draftMode().enable();
|
|
78
78
|
const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
|
|
79
79
|
assignRequestQueryToSearchParams(redirectionUrl.searchParams, searchParams);
|
|
80
80
|
if (isPlayground) {
|
package/dist/index.d.mts
CHANGED
|
@@ -14,18 +14,18 @@ type GetCanvasClientOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
declare const getCanvasClient: (options: GetCanvasClientOptions) => CanvasClient;
|
|
16
16
|
declare const getDefaultCanvasClient: ({ searchParams, }: {
|
|
17
|
-
searchParams:
|
|
18
|
-
}) =>
|
|
17
|
+
searchParams: PageParameters["searchParams"];
|
|
18
|
+
}) => CanvasClient;
|
|
19
19
|
|
|
20
20
|
type GetManifestClientOptions = {
|
|
21
21
|
cache: NonNullable<UniformServerConfig['manifestCache']>;
|
|
22
22
|
};
|
|
23
23
|
declare const getManifestClient: (options: GetManifestClientOptions) => ManifestClient;
|
|
24
24
|
declare const getDefaultManifestClient: ({ searchParams, }: {
|
|
25
|
-
searchParams?:
|
|
26
|
-
}) =>
|
|
27
|
-
declare const getManifest: ({ searchParams
|
|
28
|
-
searchParams:
|
|
25
|
+
searchParams?: PageParameters["searchParams"];
|
|
26
|
+
}) => ManifestClient;
|
|
27
|
+
declare const getManifest: ({ searchParams }: {
|
|
28
|
+
searchParams: PageParameters["searchParams"];
|
|
29
29
|
}) => Promise<{
|
|
30
30
|
project: {
|
|
31
31
|
id?: string;
|
|
@@ -187,16 +187,16 @@ type GetProjectMapClientOptions = {
|
|
|
187
187
|
};
|
|
188
188
|
declare const getProjectMapClient: (options: GetProjectMapClientOptions) => ProjectMapClient;
|
|
189
189
|
declare const getDefaultProjectMapClient: ({ searchParams, }: {
|
|
190
|
-
searchParams:
|
|
191
|
-
}) =>
|
|
190
|
+
searchParams: PageParameters["searchParams"];
|
|
191
|
+
}) => ProjectMapClient;
|
|
192
192
|
|
|
193
193
|
type GetRouteClientOptions = {
|
|
194
194
|
cache: NonNullable<UniformServerConfig['canvasCache']>;
|
|
195
195
|
};
|
|
196
196
|
declare const getRouteClient: (options: GetRouteClientOptions) => RouteClient;
|
|
197
|
-
declare const getDefaultRouteClient: ({ searchParams
|
|
198
|
-
searchParams:
|
|
199
|
-
}) =>
|
|
197
|
+
declare const getDefaultRouteClient: ({ searchParams }: {
|
|
198
|
+
searchParams: PageParameters["searchParams"];
|
|
199
|
+
}) => RouteClient;
|
|
200
200
|
|
|
201
201
|
type ContextUpdateTransferProps = {
|
|
202
202
|
update: Partial<AppDirectoryContextState> | (() => Promise<Partial<ContextState> | undefined>);
|
|
@@ -223,10 +223,10 @@ type UniformContextProps = {
|
|
|
223
223
|
declare const UniformContext: React__default.FC<PropsWithChildren<UniformContextProps>>;
|
|
224
224
|
|
|
225
225
|
type UniformPlaygroundProps = PlaygroundParameters & Omit<UniformCompositionProps, 'params' | 'searchParams' | 'route' | 'mode'>;
|
|
226
|
-
declare const UniformPlayground: ({ searchParams
|
|
226
|
+
declare const UniformPlayground: ({ searchParams, ...rest }: UniformPlaygroundProps) => Promise<React__default.JSX.Element>;
|
|
227
227
|
|
|
228
228
|
type CreateServerUniformContextProps = Omit<ContextOptions, 'transitionStore' | 'manifest'> & {
|
|
229
|
-
searchParams:
|
|
229
|
+
searchParams: PageParameters['searchParams'];
|
|
230
230
|
};
|
|
231
231
|
declare const createServerUniformContext: (options: CreateServerUniformContextProps) => Promise<AppDirectoryServerContext>;
|
|
232
232
|
|
|
@@ -234,10 +234,12 @@ declare const isDraftModeEnabled: ({ searchParams, }: {
|
|
|
234
234
|
searchParams: {
|
|
235
235
|
[key: string]: string | undefined;
|
|
236
236
|
} | undefined;
|
|
237
|
-
}) =>
|
|
238
|
-
declare const isIncontextEditingEnabled: ({ searchParams
|
|
239
|
-
searchParams:
|
|
240
|
-
|
|
237
|
+
}) => boolean;
|
|
238
|
+
declare const isIncontextEditingEnabled: ({ searchParams, }: {
|
|
239
|
+
searchParams: {
|
|
240
|
+
[key: string]: string | undefined;
|
|
241
|
+
} | undefined;
|
|
242
|
+
}) => boolean;
|
|
241
243
|
declare const isOnVercelPreviewEnvironment: () => boolean;
|
|
242
244
|
declare const isDevelopmentEnvironment: () => boolean;
|
|
243
245
|
|
|
@@ -249,10 +251,7 @@ type RetrieveCommonOptions = {
|
|
|
249
251
|
*/
|
|
250
252
|
skipPrefetch?: boolean;
|
|
251
253
|
};
|
|
252
|
-
type RetrieveRouteOptions =
|
|
253
|
-
params: Awaited<PageParameters['params']>;
|
|
254
|
-
searchParams: Awaited<PageParameters['searchParams']>;
|
|
255
|
-
} & RetrieveCommonOptions;
|
|
254
|
+
type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
|
|
256
255
|
type RetrieveSlugOptions = Pick<CompositionGetBySlugParameters, 'slug' | 'locale' | 'releaseId' | 'versionId'> & {
|
|
257
256
|
/**
|
|
258
257
|
* The searchParams object from Next.js router. Used for signal evaluation.
|
package/dist/index.d.ts
CHANGED
|
@@ -14,18 +14,18 @@ type GetCanvasClientOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
declare const getCanvasClient: (options: GetCanvasClientOptions) => CanvasClient;
|
|
16
16
|
declare const getDefaultCanvasClient: ({ searchParams, }: {
|
|
17
|
-
searchParams:
|
|
18
|
-
}) =>
|
|
17
|
+
searchParams: PageParameters["searchParams"];
|
|
18
|
+
}) => CanvasClient;
|
|
19
19
|
|
|
20
20
|
type GetManifestClientOptions = {
|
|
21
21
|
cache: NonNullable<UniformServerConfig['manifestCache']>;
|
|
22
22
|
};
|
|
23
23
|
declare const getManifestClient: (options: GetManifestClientOptions) => ManifestClient;
|
|
24
24
|
declare const getDefaultManifestClient: ({ searchParams, }: {
|
|
25
|
-
searchParams?:
|
|
26
|
-
}) =>
|
|
27
|
-
declare const getManifest: ({ searchParams
|
|
28
|
-
searchParams:
|
|
25
|
+
searchParams?: PageParameters["searchParams"];
|
|
26
|
+
}) => ManifestClient;
|
|
27
|
+
declare const getManifest: ({ searchParams }: {
|
|
28
|
+
searchParams: PageParameters["searchParams"];
|
|
29
29
|
}) => Promise<{
|
|
30
30
|
project: {
|
|
31
31
|
id?: string;
|
|
@@ -187,16 +187,16 @@ type GetProjectMapClientOptions = {
|
|
|
187
187
|
};
|
|
188
188
|
declare const getProjectMapClient: (options: GetProjectMapClientOptions) => ProjectMapClient;
|
|
189
189
|
declare const getDefaultProjectMapClient: ({ searchParams, }: {
|
|
190
|
-
searchParams:
|
|
191
|
-
}) =>
|
|
190
|
+
searchParams: PageParameters["searchParams"];
|
|
191
|
+
}) => ProjectMapClient;
|
|
192
192
|
|
|
193
193
|
type GetRouteClientOptions = {
|
|
194
194
|
cache: NonNullable<UniformServerConfig['canvasCache']>;
|
|
195
195
|
};
|
|
196
196
|
declare const getRouteClient: (options: GetRouteClientOptions) => RouteClient;
|
|
197
|
-
declare const getDefaultRouteClient: ({ searchParams
|
|
198
|
-
searchParams:
|
|
199
|
-
}) =>
|
|
197
|
+
declare const getDefaultRouteClient: ({ searchParams }: {
|
|
198
|
+
searchParams: PageParameters["searchParams"];
|
|
199
|
+
}) => RouteClient;
|
|
200
200
|
|
|
201
201
|
type ContextUpdateTransferProps = {
|
|
202
202
|
update: Partial<AppDirectoryContextState> | (() => Promise<Partial<ContextState> | undefined>);
|
|
@@ -223,10 +223,10 @@ type UniformContextProps = {
|
|
|
223
223
|
declare const UniformContext: React__default.FC<PropsWithChildren<UniformContextProps>>;
|
|
224
224
|
|
|
225
225
|
type UniformPlaygroundProps = PlaygroundParameters & Omit<UniformCompositionProps, 'params' | 'searchParams' | 'route' | 'mode'>;
|
|
226
|
-
declare const UniformPlayground: ({ searchParams
|
|
226
|
+
declare const UniformPlayground: ({ searchParams, ...rest }: UniformPlaygroundProps) => Promise<React__default.JSX.Element>;
|
|
227
227
|
|
|
228
228
|
type CreateServerUniformContextProps = Omit<ContextOptions, 'transitionStore' | 'manifest'> & {
|
|
229
|
-
searchParams:
|
|
229
|
+
searchParams: PageParameters['searchParams'];
|
|
230
230
|
};
|
|
231
231
|
declare const createServerUniformContext: (options: CreateServerUniformContextProps) => Promise<AppDirectoryServerContext>;
|
|
232
232
|
|
|
@@ -234,10 +234,12 @@ declare const isDraftModeEnabled: ({ searchParams, }: {
|
|
|
234
234
|
searchParams: {
|
|
235
235
|
[key: string]: string | undefined;
|
|
236
236
|
} | undefined;
|
|
237
|
-
}) =>
|
|
238
|
-
declare const isIncontextEditingEnabled: ({ searchParams
|
|
239
|
-
searchParams:
|
|
240
|
-
|
|
237
|
+
}) => boolean;
|
|
238
|
+
declare const isIncontextEditingEnabled: ({ searchParams, }: {
|
|
239
|
+
searchParams: {
|
|
240
|
+
[key: string]: string | undefined;
|
|
241
|
+
} | undefined;
|
|
242
|
+
}) => boolean;
|
|
241
243
|
declare const isOnVercelPreviewEnvironment: () => boolean;
|
|
242
244
|
declare const isDevelopmentEnvironment: () => boolean;
|
|
243
245
|
|
|
@@ -249,10 +251,7 @@ type RetrieveCommonOptions = {
|
|
|
249
251
|
*/
|
|
250
252
|
skipPrefetch?: boolean;
|
|
251
253
|
};
|
|
252
|
-
type RetrieveRouteOptions =
|
|
253
|
-
params: Awaited<PageParameters['params']>;
|
|
254
|
-
searchParams: Awaited<PageParameters['searchParams']>;
|
|
255
|
-
} & RetrieveCommonOptions;
|
|
254
|
+
type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
|
|
256
255
|
type RetrieveSlugOptions = Pick<CompositionGetBySlugParameters, 'slug' | 'locale' | 'releaseId' | 'versionId'> & {
|
|
257
256
|
/**
|
|
258
257
|
* The searchParams object from Next.js router. Used for signal evaluation.
|
package/dist/index.esm.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
14
14
|
} from "@uniformdev/canvas";
|
|
15
15
|
import { draftMode } from "next/headers";
|
|
16
|
-
var isDraftModeEnabled =
|
|
16
|
+
var isDraftModeEnabled = ({
|
|
17
17
|
searchParams
|
|
18
18
|
}) => {
|
|
19
19
|
if (isDevelopmentEnvironment()) {
|
|
@@ -21,15 +21,14 @@ var isDraftModeEnabled = async ({
|
|
|
21
21
|
}
|
|
22
22
|
let draftModeEnabled = false;
|
|
23
23
|
try {
|
|
24
|
-
draftModeEnabled =
|
|
24
|
+
draftModeEnabled = draftMode().isEnabled;
|
|
25
25
|
} catch (e) {
|
|
26
26
|
}
|
|
27
27
|
return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
|
|
28
28
|
};
|
|
29
|
-
var isIncontextEditingEnabled =
|
|
30
|
-
searchParams
|
|
29
|
+
var isIncontextEditingEnabled = ({
|
|
30
|
+
searchParams
|
|
31
31
|
}) => {
|
|
32
|
-
const searchParams = await (providedSearchParams || Promise.resolve(void 0));
|
|
33
32
|
const containsKey = typeof (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
|
|
34
33
|
return containsKey;
|
|
35
34
|
};
|
|
@@ -64,11 +63,11 @@ var isDevelopmentEnvironment = () => {
|
|
|
64
63
|
var getServerConfig = () => {
|
|
65
64
|
return serverConfig;
|
|
66
65
|
};
|
|
67
|
-
var shouldCacheBeDisabled =
|
|
68
|
-
if (
|
|
66
|
+
var shouldCacheBeDisabled = (options) => {
|
|
67
|
+
if (isDraftModeEnabled(options)) {
|
|
69
68
|
return { disabled: true, reason: "DRAFT" };
|
|
70
69
|
}
|
|
71
|
-
if (
|
|
70
|
+
if (isIncontextEditingEnabled(options)) {
|
|
72
71
|
return { disabled: true, reason: "INCONTEXT" };
|
|
73
72
|
}
|
|
74
73
|
if (isDevelopmentEnvironment()) {
|
|
@@ -79,8 +78,8 @@ var shouldCacheBeDisabled = async (options) => {
|
|
|
79
78
|
reason: void 0
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
|
-
var getCanvasCacheStrategy =
|
|
83
|
-
const { disabled, reason } =
|
|
81
|
+
var getCanvasCacheStrategy = (options) => {
|
|
82
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
84
83
|
const config = getServerConfig();
|
|
85
84
|
if (disabled) {
|
|
86
85
|
if (reason === "DEV" && config.canvasCache) {
|
|
@@ -99,8 +98,8 @@ var getCanvasCacheStrategy = async (options) => {
|
|
|
99
98
|
type: "force-cache"
|
|
100
99
|
};
|
|
101
100
|
};
|
|
102
|
-
var getManifestCacheStrategy =
|
|
103
|
-
const { disabled, reason } =
|
|
101
|
+
var getManifestCacheStrategy = (options) => {
|
|
102
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
104
103
|
const config = getServerConfig();
|
|
105
104
|
if (disabled) {
|
|
106
105
|
if (reason === "DEV" && config.manifestCache) {
|
|
@@ -118,8 +117,8 @@ var getManifestCacheStrategy = async (options) => {
|
|
|
118
117
|
type: "force-cache"
|
|
119
118
|
};
|
|
120
119
|
};
|
|
121
|
-
var getProjectMapCacheStrategy =
|
|
122
|
-
const { disabled, reason } =
|
|
120
|
+
var getProjectMapCacheStrategy = (options) => {
|
|
121
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
123
122
|
const config = getServerConfig();
|
|
124
123
|
if (disabled) {
|
|
125
124
|
if (reason === "DEV" && config.projectMapCache) {
|
|
@@ -228,11 +227,11 @@ var getCanvasClient = (options) => {
|
|
|
228
227
|
}
|
|
229
228
|
});
|
|
230
229
|
};
|
|
231
|
-
var getDefaultCanvasClient =
|
|
230
|
+
var getDefaultCanvasClient = ({
|
|
232
231
|
searchParams
|
|
233
232
|
}) => {
|
|
234
233
|
return getCanvasClient({
|
|
235
|
-
cache:
|
|
234
|
+
cache: getCanvasCacheStrategy({
|
|
236
235
|
searchParams
|
|
237
236
|
})
|
|
238
237
|
});
|
|
@@ -263,19 +262,17 @@ var getManifestClient = (options) => {
|
|
|
263
262
|
});
|
|
264
263
|
return manifestClient;
|
|
265
264
|
};
|
|
266
|
-
var getDefaultManifestClient =
|
|
265
|
+
var getDefaultManifestClient = ({
|
|
267
266
|
searchParams
|
|
268
267
|
}) => {
|
|
269
268
|
return getManifestClient({
|
|
270
|
-
cache:
|
|
269
|
+
cache: getManifestCacheStrategy({
|
|
271
270
|
searchParams
|
|
272
271
|
})
|
|
273
272
|
});
|
|
274
273
|
};
|
|
275
|
-
var getManifest =
|
|
276
|
-
|
|
277
|
-
}) => {
|
|
278
|
-
const manifestClient = await getDefaultManifestClient({
|
|
274
|
+
var getManifest = ({ searchParams }) => {
|
|
275
|
+
const manifestClient = getDefaultManifestClient({
|
|
279
276
|
searchParams
|
|
280
277
|
});
|
|
281
278
|
return manifestClient.get();
|
|
@@ -305,11 +302,11 @@ var getProjectMapClient = (options) => {
|
|
|
305
302
|
});
|
|
306
303
|
return manifestClient;
|
|
307
304
|
};
|
|
308
|
-
var getDefaultProjectMapClient =
|
|
305
|
+
var getDefaultProjectMapClient = ({
|
|
309
306
|
searchParams
|
|
310
307
|
}) => {
|
|
311
308
|
return getProjectMapClient({
|
|
312
|
-
cache:
|
|
309
|
+
cache: getProjectMapCacheStrategy({
|
|
313
310
|
searchParams
|
|
314
311
|
})
|
|
315
312
|
});
|
|
@@ -362,11 +359,9 @@ var getRouteClient = (options) => {
|
|
|
362
359
|
});
|
|
363
360
|
return client;
|
|
364
361
|
};
|
|
365
|
-
var getDefaultRouteClient =
|
|
366
|
-
searchParams
|
|
367
|
-
}) => {
|
|
362
|
+
var getDefaultRouteClient = ({ searchParams }) => {
|
|
368
363
|
return getRouteClient({
|
|
369
|
-
cache:
|
|
364
|
+
cache: getCanvasCacheStrategy({
|
|
370
365
|
searchParams
|
|
371
366
|
})
|
|
372
367
|
});
|
|
@@ -460,7 +455,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
460
455
|
var _a;
|
|
461
456
|
const context = createUniformContext({
|
|
462
457
|
...options || {},
|
|
463
|
-
serverCookieValue: (_a =
|
|
458
|
+
serverCookieValue: (_a = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
464
459
|
});
|
|
465
460
|
return context;
|
|
466
461
|
};
|
|
@@ -489,12 +484,12 @@ var retrieveCompositionBySlug = async ({
|
|
|
489
484
|
});
|
|
490
485
|
}
|
|
491
486
|
let result;
|
|
492
|
-
const states =
|
|
487
|
+
const states = determineState({
|
|
493
488
|
searchParams
|
|
494
489
|
});
|
|
495
490
|
for (let i = 0; i < states.length; i++) {
|
|
496
491
|
const state = states[i];
|
|
497
|
-
const canvasClient =
|
|
492
|
+
const canvasClient = getDefaultCanvasClient({
|
|
498
493
|
searchParams
|
|
499
494
|
});
|
|
500
495
|
try {
|
|
@@ -532,7 +527,7 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
532
527
|
const { value } = resolvePath({
|
|
533
528
|
params
|
|
534
529
|
});
|
|
535
|
-
const states =
|
|
530
|
+
const states = determineState({
|
|
536
531
|
searchParams
|
|
537
532
|
});
|
|
538
533
|
let result;
|
|
@@ -559,12 +554,11 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
559
554
|
var retrieveRouteByPath = async ({
|
|
560
555
|
path,
|
|
561
556
|
state,
|
|
562
|
-
searchParams
|
|
557
|
+
searchParams,
|
|
563
558
|
fetchOptions
|
|
564
559
|
}) => {
|
|
565
560
|
var _a;
|
|
566
|
-
const
|
|
567
|
-
const client = await getDefaultRouteClient({
|
|
561
|
+
const client = getDefaultRouteClient({
|
|
568
562
|
searchParams
|
|
569
563
|
});
|
|
570
564
|
let queryPath = path;
|
|
@@ -595,13 +589,11 @@ var resolveRedirectHref = (resolveResult, path) => {
|
|
|
595
589
|
const url = new URL(expandedUrl);
|
|
596
590
|
return url.pathname;
|
|
597
591
|
};
|
|
598
|
-
var determineState =
|
|
599
|
-
searchParams
|
|
600
|
-
}) => {
|
|
601
|
-
const draftMode2 = await isDraftModeEnabled({ searchParams });
|
|
592
|
+
var determineState = ({ searchParams }) => {
|
|
593
|
+
const draftMode2 = isDraftModeEnabled({ searchParams });
|
|
602
594
|
const previewEnvironment = isOnVercelPreviewEnvironment();
|
|
603
595
|
const isDevelopment = isDevelopmentEnvironment();
|
|
604
|
-
const isCanvasEditing =
|
|
596
|
+
const isCanvasEditing = isIncontextEditingEnabled({
|
|
605
597
|
searchParams
|
|
606
598
|
});
|
|
607
599
|
let states;
|
|
@@ -733,14 +725,12 @@ var UniformComposition = async ({
|
|
|
733
725
|
if (props.mode === "static") {
|
|
734
726
|
searchParams = void 0;
|
|
735
727
|
} else if (props.mode === "server") {
|
|
736
|
-
searchParams = await props.searchParams;
|
|
737
728
|
serverContext = props.serverContext || await createServerUniformContext({
|
|
738
|
-
searchParams
|
|
729
|
+
searchParams: props.searchParams
|
|
739
730
|
});
|
|
731
|
+
searchParams = props.searchParams;
|
|
740
732
|
}
|
|
741
|
-
const { value: path } = resolvePath2(
|
|
742
|
-
params: await props.params
|
|
743
|
-
});
|
|
733
|
+
const { value: path } = resolvePath2(props);
|
|
744
734
|
if (!route || route.type === "notFound") {
|
|
745
735
|
notFound();
|
|
746
736
|
}
|
|
@@ -770,8 +760,8 @@ var UniformComposition = async ({
|
|
|
770
760
|
searchParams,
|
|
771
761
|
dynamicInputs: route.dynamicInputs,
|
|
772
762
|
type: "composition",
|
|
773
|
-
isContextualEditing:
|
|
774
|
-
isDraftMode:
|
|
763
|
+
isContextualEditing: isIncontextEditingEnabled({ searchParams }),
|
|
764
|
+
isDraftMode: isDraftModeEnabled({ searchParams }),
|
|
775
765
|
state: route.compositionApiResponse.state,
|
|
776
766
|
path,
|
|
777
767
|
previewMode: determinePreviewMode({ searchParams })
|
|
@@ -785,14 +775,14 @@ var UniformComposition = async ({
|
|
|
785
775
|
});
|
|
786
776
|
let transfer = null;
|
|
787
777
|
if (props.mode === "server") {
|
|
788
|
-
const headersValue =
|
|
778
|
+
const headersValue = headers();
|
|
789
779
|
const missingQuirkValue = "unknown";
|
|
790
780
|
transfer = createElement3(ContextUpdateTransfer, {
|
|
791
781
|
serverContext,
|
|
792
782
|
update: {
|
|
793
|
-
params:
|
|
783
|
+
params: props.params,
|
|
794
784
|
searchParams,
|
|
795
|
-
cookies:
|
|
785
|
+
cookies: cookies2().getAll().reduce(
|
|
796
786
|
(acc, cookie) => {
|
|
797
787
|
acc[cookie.name] = cookie.value;
|
|
798
788
|
return acc;
|
|
@@ -1086,12 +1076,8 @@ var UniformContext = async ({
|
|
|
1086
1076
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
1087
1077
|
import { notFound as notFound2 } from "next/navigation";
|
|
1088
1078
|
import React8 from "react";
|
|
1089
|
-
var UniformPlayground = async ({
|
|
1090
|
-
searchParams
|
|
1091
|
-
...rest
|
|
1092
|
-
}) => {
|
|
1093
|
-
const searchParams = await (providedSearchParams != null ? providedSearchParams : {});
|
|
1094
|
-
if (!await isDraftModeEnabled({ searchParams })) {
|
|
1079
|
+
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1080
|
+
if (!isDraftModeEnabled({ searchParams })) {
|
|
1095
1081
|
return /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1096
1082
|
}
|
|
1097
1083
|
const id = searchParams["id"];
|
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var import_uniform_server = __toESM(require("uniform.server.config"));
|
|
|
66
66
|
// src/utils/draft.ts
|
|
67
67
|
var import_canvas = require("@uniformdev/canvas");
|
|
68
68
|
var import_headers = require("next/headers");
|
|
69
|
-
var isDraftModeEnabled =
|
|
69
|
+
var isDraftModeEnabled = ({
|
|
70
70
|
searchParams
|
|
71
71
|
}) => {
|
|
72
72
|
if (isDevelopmentEnvironment()) {
|
|
@@ -74,15 +74,14 @@ var isDraftModeEnabled = async ({
|
|
|
74
74
|
}
|
|
75
75
|
let draftModeEnabled = false;
|
|
76
76
|
try {
|
|
77
|
-
draftModeEnabled = (
|
|
77
|
+
draftModeEnabled = (0, import_headers.draftMode)().isEnabled;
|
|
78
78
|
} catch (e) {
|
|
79
79
|
}
|
|
80
80
|
return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
|
|
81
81
|
};
|
|
82
|
-
var isIncontextEditingEnabled =
|
|
83
|
-
searchParams
|
|
82
|
+
var isIncontextEditingEnabled = ({
|
|
83
|
+
searchParams
|
|
84
84
|
}) => {
|
|
85
|
-
const searchParams = await (providedSearchParams || Promise.resolve(void 0));
|
|
86
85
|
const containsKey = typeof (searchParams == null ? void 0 : searchParams[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
|
|
87
86
|
return containsKey;
|
|
88
87
|
};
|
|
@@ -117,11 +116,11 @@ var isDevelopmentEnvironment = () => {
|
|
|
117
116
|
var getServerConfig = () => {
|
|
118
117
|
return import_uniform_server.default;
|
|
119
118
|
};
|
|
120
|
-
var shouldCacheBeDisabled =
|
|
121
|
-
if (
|
|
119
|
+
var shouldCacheBeDisabled = (options) => {
|
|
120
|
+
if (isDraftModeEnabled(options)) {
|
|
122
121
|
return { disabled: true, reason: "DRAFT" };
|
|
123
122
|
}
|
|
124
|
-
if (
|
|
123
|
+
if (isIncontextEditingEnabled(options)) {
|
|
125
124
|
return { disabled: true, reason: "INCONTEXT" };
|
|
126
125
|
}
|
|
127
126
|
if (isDevelopmentEnvironment()) {
|
|
@@ -132,8 +131,8 @@ var shouldCacheBeDisabled = async (options) => {
|
|
|
132
131
|
reason: void 0
|
|
133
132
|
};
|
|
134
133
|
};
|
|
135
|
-
var getCanvasCacheStrategy =
|
|
136
|
-
const { disabled, reason } =
|
|
134
|
+
var getCanvasCacheStrategy = (options) => {
|
|
135
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
137
136
|
const config = getServerConfig();
|
|
138
137
|
if (disabled) {
|
|
139
138
|
if (reason === "DEV" && config.canvasCache) {
|
|
@@ -152,8 +151,8 @@ var getCanvasCacheStrategy = async (options) => {
|
|
|
152
151
|
type: "force-cache"
|
|
153
152
|
};
|
|
154
153
|
};
|
|
155
|
-
var getManifestCacheStrategy =
|
|
156
|
-
const { disabled, reason } =
|
|
154
|
+
var getManifestCacheStrategy = (options) => {
|
|
155
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
157
156
|
const config = getServerConfig();
|
|
158
157
|
if (disabled) {
|
|
159
158
|
if (reason === "DEV" && config.manifestCache) {
|
|
@@ -171,8 +170,8 @@ var getManifestCacheStrategy = async (options) => {
|
|
|
171
170
|
type: "force-cache"
|
|
172
171
|
};
|
|
173
172
|
};
|
|
174
|
-
var getProjectMapCacheStrategy =
|
|
175
|
-
const { disabled, reason } =
|
|
173
|
+
var getProjectMapCacheStrategy = (options) => {
|
|
174
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
176
175
|
const config = getServerConfig();
|
|
177
176
|
if (disabled) {
|
|
178
177
|
if (reason === "DEV" && config.projectMapCache) {
|
|
@@ -281,11 +280,11 @@ var getCanvasClient = (options) => {
|
|
|
281
280
|
}
|
|
282
281
|
});
|
|
283
282
|
};
|
|
284
|
-
var getDefaultCanvasClient =
|
|
283
|
+
var getDefaultCanvasClient = ({
|
|
285
284
|
searchParams
|
|
286
285
|
}) => {
|
|
287
286
|
return getCanvasClient({
|
|
288
|
-
cache:
|
|
287
|
+
cache: getCanvasCacheStrategy({
|
|
289
288
|
searchParams
|
|
290
289
|
})
|
|
291
290
|
});
|
|
@@ -316,19 +315,17 @@ var getManifestClient = (options) => {
|
|
|
316
315
|
});
|
|
317
316
|
return manifestClient;
|
|
318
317
|
};
|
|
319
|
-
var getDefaultManifestClient =
|
|
318
|
+
var getDefaultManifestClient = ({
|
|
320
319
|
searchParams
|
|
321
320
|
}) => {
|
|
322
321
|
return getManifestClient({
|
|
323
|
-
cache:
|
|
322
|
+
cache: getManifestCacheStrategy({
|
|
324
323
|
searchParams
|
|
325
324
|
})
|
|
326
325
|
});
|
|
327
326
|
};
|
|
328
|
-
var getManifest =
|
|
329
|
-
|
|
330
|
-
}) => {
|
|
331
|
-
const manifestClient = await getDefaultManifestClient({
|
|
327
|
+
var getManifest = ({ searchParams }) => {
|
|
328
|
+
const manifestClient = getDefaultManifestClient({
|
|
332
329
|
searchParams
|
|
333
330
|
});
|
|
334
331
|
return manifestClient.get();
|
|
@@ -358,11 +355,11 @@ var getProjectMapClient = (options) => {
|
|
|
358
355
|
});
|
|
359
356
|
return manifestClient;
|
|
360
357
|
};
|
|
361
|
-
var getDefaultProjectMapClient =
|
|
358
|
+
var getDefaultProjectMapClient = ({
|
|
362
359
|
searchParams
|
|
363
360
|
}) => {
|
|
364
361
|
return getProjectMapClient({
|
|
365
|
-
cache:
|
|
362
|
+
cache: getProjectMapCacheStrategy({
|
|
366
363
|
searchParams
|
|
367
364
|
})
|
|
368
365
|
});
|
|
@@ -415,11 +412,9 @@ var getRouteClient = (options) => {
|
|
|
415
412
|
});
|
|
416
413
|
return client;
|
|
417
414
|
};
|
|
418
|
-
var getDefaultRouteClient =
|
|
419
|
-
searchParams
|
|
420
|
-
}) => {
|
|
415
|
+
var getDefaultRouteClient = ({ searchParams }) => {
|
|
421
416
|
return getRouteClient({
|
|
422
|
-
cache:
|
|
417
|
+
cache: getCanvasCacheStrategy({
|
|
423
418
|
searchParams
|
|
424
419
|
})
|
|
425
420
|
});
|
|
@@ -500,7 +495,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
500
495
|
var _a;
|
|
501
496
|
const context = (0, import_canvas_next_rsc_shared.createUniformContext)({
|
|
502
497
|
...options || {},
|
|
503
|
-
serverCookieValue: (_a = (
|
|
498
|
+
serverCookieValue: (_a = (0, import_headers2.cookies)().get(import_context.UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
504
499
|
});
|
|
505
500
|
return context;
|
|
506
501
|
};
|
|
@@ -524,12 +519,12 @@ var retrieveCompositionBySlug = async ({
|
|
|
524
519
|
});
|
|
525
520
|
}
|
|
526
521
|
let result;
|
|
527
|
-
const states =
|
|
522
|
+
const states = determineState({
|
|
528
523
|
searchParams
|
|
529
524
|
});
|
|
530
525
|
for (let i = 0; i < states.length; i++) {
|
|
531
526
|
const state = states[i];
|
|
532
|
-
const canvasClient =
|
|
527
|
+
const canvasClient = getDefaultCanvasClient({
|
|
533
528
|
searchParams
|
|
534
529
|
});
|
|
535
530
|
try {
|
|
@@ -567,7 +562,7 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
567
562
|
const { value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
|
|
568
563
|
params
|
|
569
564
|
});
|
|
570
|
-
const states =
|
|
565
|
+
const states = determineState({
|
|
571
566
|
searchParams
|
|
572
567
|
});
|
|
573
568
|
let result;
|
|
@@ -594,12 +589,11 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
594
589
|
var retrieveRouteByPath = async ({
|
|
595
590
|
path,
|
|
596
591
|
state,
|
|
597
|
-
searchParams
|
|
592
|
+
searchParams,
|
|
598
593
|
fetchOptions
|
|
599
594
|
}) => {
|
|
600
595
|
var _a;
|
|
601
|
-
const
|
|
602
|
-
const client = await getDefaultRouteClient({
|
|
596
|
+
const client = getDefaultRouteClient({
|
|
603
597
|
searchParams
|
|
604
598
|
});
|
|
605
599
|
let queryPath = path;
|
|
@@ -630,13 +624,11 @@ var resolveRedirectHref = (resolveResult, path) => {
|
|
|
630
624
|
const url = new URL(expandedUrl);
|
|
631
625
|
return url.pathname;
|
|
632
626
|
};
|
|
633
|
-
var determineState =
|
|
634
|
-
searchParams
|
|
635
|
-
}) => {
|
|
636
|
-
const draftMode2 = await isDraftModeEnabled({ searchParams });
|
|
627
|
+
var determineState = ({ searchParams }) => {
|
|
628
|
+
const draftMode2 = isDraftModeEnabled({ searchParams });
|
|
637
629
|
const previewEnvironment = isOnVercelPreviewEnvironment();
|
|
638
630
|
const isDevelopment = isDevelopmentEnvironment();
|
|
639
|
-
const isCanvasEditing =
|
|
631
|
+
const isCanvasEditing = isIncontextEditingEnabled({
|
|
640
632
|
searchParams
|
|
641
633
|
});
|
|
642
634
|
let states;
|
|
@@ -763,14 +755,12 @@ var UniformComposition = async ({
|
|
|
763
755
|
if (props.mode === "static") {
|
|
764
756
|
searchParams = void 0;
|
|
765
757
|
} else if (props.mode === "server") {
|
|
766
|
-
searchParams = await props.searchParams;
|
|
767
758
|
serverContext = props.serverContext || await createServerUniformContext({
|
|
768
|
-
searchParams
|
|
759
|
+
searchParams: props.searchParams
|
|
769
760
|
});
|
|
761
|
+
searchParams = props.searchParams;
|
|
770
762
|
}
|
|
771
|
-
const { value: path } = (0, import_canvas_next_rsc_shared6.resolvePath)(
|
|
772
|
-
params: await props.params
|
|
773
|
-
});
|
|
763
|
+
const { value: path } = (0, import_canvas_next_rsc_shared6.resolvePath)(props);
|
|
774
764
|
if (!route || route.type === "notFound") {
|
|
775
765
|
(0, import_navigation.notFound)();
|
|
776
766
|
}
|
|
@@ -800,8 +790,8 @@ var UniformComposition = async ({
|
|
|
800
790
|
searchParams,
|
|
801
791
|
dynamicInputs: route.dynamicInputs,
|
|
802
792
|
type: "composition",
|
|
803
|
-
isContextualEditing:
|
|
804
|
-
isDraftMode:
|
|
793
|
+
isContextualEditing: isIncontextEditingEnabled({ searchParams }),
|
|
794
|
+
isDraftMode: isDraftModeEnabled({ searchParams }),
|
|
805
795
|
state: route.compositionApiResponse.state,
|
|
806
796
|
path,
|
|
807
797
|
previewMode: determinePreviewMode({ searchParams })
|
|
@@ -815,14 +805,14 @@ var UniformComposition = async ({
|
|
|
815
805
|
});
|
|
816
806
|
let transfer = null;
|
|
817
807
|
if (props.mode === "server") {
|
|
818
|
-
const headersValue =
|
|
808
|
+
const headersValue = (0, import_headers3.headers)();
|
|
819
809
|
const missingQuirkValue = "unknown";
|
|
820
810
|
transfer = (0, import_react9.createElement)(ContextUpdateTransfer, {
|
|
821
811
|
serverContext,
|
|
822
812
|
update: {
|
|
823
|
-
params:
|
|
813
|
+
params: props.params,
|
|
824
814
|
searchParams,
|
|
825
|
-
cookies: (
|
|
815
|
+
cookies: (0, import_headers3.cookies)().getAll().reduce(
|
|
826
816
|
(acc, cookie) => {
|
|
827
817
|
acc[cookie.name] = cookie.value;
|
|
828
818
|
return acc;
|
|
@@ -1113,12 +1103,8 @@ var UniformContext = async ({
|
|
|
1113
1103
|
var import_canvas9 = require("@uniformdev/canvas");
|
|
1114
1104
|
var import_navigation2 = require("next/navigation");
|
|
1115
1105
|
var import_react12 = __toESM(require("react"));
|
|
1116
|
-
var UniformPlayground = async ({
|
|
1117
|
-
searchParams
|
|
1118
|
-
...rest
|
|
1119
|
-
}) => {
|
|
1120
|
-
const searchParams = await (providedSearchParams != null ? providedSearchParams : {});
|
|
1121
|
-
if (!await isDraftModeEnabled({ searchParams })) {
|
|
1106
|
+
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1107
|
+
if (!isDraftModeEnabled({ searchParams })) {
|
|
1122
1108
|
return /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1123
1109
|
}
|
|
1124
1110
|
const id = searchParams["id"];
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
14
14
|
} from "@uniformdev/canvas";
|
|
15
15
|
import { draftMode } from "next/headers";
|
|
16
|
-
var isDraftModeEnabled =
|
|
16
|
+
var isDraftModeEnabled = ({
|
|
17
17
|
searchParams
|
|
18
18
|
}) => {
|
|
19
19
|
if (isDevelopmentEnvironment()) {
|
|
@@ -21,15 +21,14 @@ var isDraftModeEnabled = async ({
|
|
|
21
21
|
}
|
|
22
22
|
let draftModeEnabled = false;
|
|
23
23
|
try {
|
|
24
|
-
draftModeEnabled =
|
|
24
|
+
draftModeEnabled = draftMode().isEnabled;
|
|
25
25
|
} catch (e) {
|
|
26
26
|
}
|
|
27
27
|
return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
|
|
28
28
|
};
|
|
29
|
-
var isIncontextEditingEnabled =
|
|
30
|
-
searchParams
|
|
29
|
+
var isIncontextEditingEnabled = ({
|
|
30
|
+
searchParams
|
|
31
31
|
}) => {
|
|
32
|
-
const searchParams = await (providedSearchParams || Promise.resolve(void 0));
|
|
33
32
|
const containsKey = typeof (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
|
|
34
33
|
return containsKey;
|
|
35
34
|
};
|
|
@@ -64,11 +63,11 @@ var isDevelopmentEnvironment = () => {
|
|
|
64
63
|
var getServerConfig = () => {
|
|
65
64
|
return serverConfig;
|
|
66
65
|
};
|
|
67
|
-
var shouldCacheBeDisabled =
|
|
68
|
-
if (
|
|
66
|
+
var shouldCacheBeDisabled = (options) => {
|
|
67
|
+
if (isDraftModeEnabled(options)) {
|
|
69
68
|
return { disabled: true, reason: "DRAFT" };
|
|
70
69
|
}
|
|
71
|
-
if (
|
|
70
|
+
if (isIncontextEditingEnabled(options)) {
|
|
72
71
|
return { disabled: true, reason: "INCONTEXT" };
|
|
73
72
|
}
|
|
74
73
|
if (isDevelopmentEnvironment()) {
|
|
@@ -79,8 +78,8 @@ var shouldCacheBeDisabled = async (options) => {
|
|
|
79
78
|
reason: void 0
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
|
-
var getCanvasCacheStrategy =
|
|
83
|
-
const { disabled, reason } =
|
|
81
|
+
var getCanvasCacheStrategy = (options) => {
|
|
82
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
84
83
|
const config = getServerConfig();
|
|
85
84
|
if (disabled) {
|
|
86
85
|
if (reason === "DEV" && config.canvasCache) {
|
|
@@ -99,8 +98,8 @@ var getCanvasCacheStrategy = async (options) => {
|
|
|
99
98
|
type: "force-cache"
|
|
100
99
|
};
|
|
101
100
|
};
|
|
102
|
-
var getManifestCacheStrategy =
|
|
103
|
-
const { disabled, reason } =
|
|
101
|
+
var getManifestCacheStrategy = (options) => {
|
|
102
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
104
103
|
const config = getServerConfig();
|
|
105
104
|
if (disabled) {
|
|
106
105
|
if (reason === "DEV" && config.manifestCache) {
|
|
@@ -118,8 +117,8 @@ var getManifestCacheStrategy = async (options) => {
|
|
|
118
117
|
type: "force-cache"
|
|
119
118
|
};
|
|
120
119
|
};
|
|
121
|
-
var getProjectMapCacheStrategy =
|
|
122
|
-
const { disabled, reason } =
|
|
120
|
+
var getProjectMapCacheStrategy = (options) => {
|
|
121
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
123
122
|
const config = getServerConfig();
|
|
124
123
|
if (disabled) {
|
|
125
124
|
if (reason === "DEV" && config.projectMapCache) {
|
|
@@ -228,11 +227,11 @@ var getCanvasClient = (options) => {
|
|
|
228
227
|
}
|
|
229
228
|
});
|
|
230
229
|
};
|
|
231
|
-
var getDefaultCanvasClient =
|
|
230
|
+
var getDefaultCanvasClient = ({
|
|
232
231
|
searchParams
|
|
233
232
|
}) => {
|
|
234
233
|
return getCanvasClient({
|
|
235
|
-
cache:
|
|
234
|
+
cache: getCanvasCacheStrategy({
|
|
236
235
|
searchParams
|
|
237
236
|
})
|
|
238
237
|
});
|
|
@@ -263,19 +262,17 @@ var getManifestClient = (options) => {
|
|
|
263
262
|
});
|
|
264
263
|
return manifestClient;
|
|
265
264
|
};
|
|
266
|
-
var getDefaultManifestClient =
|
|
265
|
+
var getDefaultManifestClient = ({
|
|
267
266
|
searchParams
|
|
268
267
|
}) => {
|
|
269
268
|
return getManifestClient({
|
|
270
|
-
cache:
|
|
269
|
+
cache: getManifestCacheStrategy({
|
|
271
270
|
searchParams
|
|
272
271
|
})
|
|
273
272
|
});
|
|
274
273
|
};
|
|
275
|
-
var getManifest =
|
|
276
|
-
|
|
277
|
-
}) => {
|
|
278
|
-
const manifestClient = await getDefaultManifestClient({
|
|
274
|
+
var getManifest = ({ searchParams }) => {
|
|
275
|
+
const manifestClient = getDefaultManifestClient({
|
|
279
276
|
searchParams
|
|
280
277
|
});
|
|
281
278
|
return manifestClient.get();
|
|
@@ -305,11 +302,11 @@ var getProjectMapClient = (options) => {
|
|
|
305
302
|
});
|
|
306
303
|
return manifestClient;
|
|
307
304
|
};
|
|
308
|
-
var getDefaultProjectMapClient =
|
|
305
|
+
var getDefaultProjectMapClient = ({
|
|
309
306
|
searchParams
|
|
310
307
|
}) => {
|
|
311
308
|
return getProjectMapClient({
|
|
312
|
-
cache:
|
|
309
|
+
cache: getProjectMapCacheStrategy({
|
|
313
310
|
searchParams
|
|
314
311
|
})
|
|
315
312
|
});
|
|
@@ -362,11 +359,9 @@ var getRouteClient = (options) => {
|
|
|
362
359
|
});
|
|
363
360
|
return client;
|
|
364
361
|
};
|
|
365
|
-
var getDefaultRouteClient =
|
|
366
|
-
searchParams
|
|
367
|
-
}) => {
|
|
362
|
+
var getDefaultRouteClient = ({ searchParams }) => {
|
|
368
363
|
return getRouteClient({
|
|
369
|
-
cache:
|
|
364
|
+
cache: getCanvasCacheStrategy({
|
|
370
365
|
searchParams
|
|
371
366
|
})
|
|
372
367
|
});
|
|
@@ -460,7 +455,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
460
455
|
var _a;
|
|
461
456
|
const context = createUniformContext({
|
|
462
457
|
...options || {},
|
|
463
|
-
serverCookieValue: (_a =
|
|
458
|
+
serverCookieValue: (_a = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
464
459
|
});
|
|
465
460
|
return context;
|
|
466
461
|
};
|
|
@@ -489,12 +484,12 @@ var retrieveCompositionBySlug = async ({
|
|
|
489
484
|
});
|
|
490
485
|
}
|
|
491
486
|
let result;
|
|
492
|
-
const states =
|
|
487
|
+
const states = determineState({
|
|
493
488
|
searchParams
|
|
494
489
|
});
|
|
495
490
|
for (let i = 0; i < states.length; i++) {
|
|
496
491
|
const state = states[i];
|
|
497
|
-
const canvasClient =
|
|
492
|
+
const canvasClient = getDefaultCanvasClient({
|
|
498
493
|
searchParams
|
|
499
494
|
});
|
|
500
495
|
try {
|
|
@@ -532,7 +527,7 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
532
527
|
const { value } = resolvePath({
|
|
533
528
|
params
|
|
534
529
|
});
|
|
535
|
-
const states =
|
|
530
|
+
const states = determineState({
|
|
536
531
|
searchParams
|
|
537
532
|
});
|
|
538
533
|
let result;
|
|
@@ -559,12 +554,11 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
559
554
|
var retrieveRouteByPath = async ({
|
|
560
555
|
path,
|
|
561
556
|
state,
|
|
562
|
-
searchParams
|
|
557
|
+
searchParams,
|
|
563
558
|
fetchOptions
|
|
564
559
|
}) => {
|
|
565
560
|
var _a;
|
|
566
|
-
const
|
|
567
|
-
const client = await getDefaultRouteClient({
|
|
561
|
+
const client = getDefaultRouteClient({
|
|
568
562
|
searchParams
|
|
569
563
|
});
|
|
570
564
|
let queryPath = path;
|
|
@@ -595,13 +589,11 @@ var resolveRedirectHref = (resolveResult, path) => {
|
|
|
595
589
|
const url = new URL(expandedUrl);
|
|
596
590
|
return url.pathname;
|
|
597
591
|
};
|
|
598
|
-
var determineState =
|
|
599
|
-
searchParams
|
|
600
|
-
}) => {
|
|
601
|
-
const draftMode2 = await isDraftModeEnabled({ searchParams });
|
|
592
|
+
var determineState = ({ searchParams }) => {
|
|
593
|
+
const draftMode2 = isDraftModeEnabled({ searchParams });
|
|
602
594
|
const previewEnvironment = isOnVercelPreviewEnvironment();
|
|
603
595
|
const isDevelopment = isDevelopmentEnvironment();
|
|
604
|
-
const isCanvasEditing =
|
|
596
|
+
const isCanvasEditing = isIncontextEditingEnabled({
|
|
605
597
|
searchParams
|
|
606
598
|
});
|
|
607
599
|
let states;
|
|
@@ -733,14 +725,12 @@ var UniformComposition = async ({
|
|
|
733
725
|
if (props.mode === "static") {
|
|
734
726
|
searchParams = void 0;
|
|
735
727
|
} else if (props.mode === "server") {
|
|
736
|
-
searchParams = await props.searchParams;
|
|
737
728
|
serverContext = props.serverContext || await createServerUniformContext({
|
|
738
|
-
searchParams
|
|
729
|
+
searchParams: props.searchParams
|
|
739
730
|
});
|
|
731
|
+
searchParams = props.searchParams;
|
|
740
732
|
}
|
|
741
|
-
const { value: path } = resolvePath2(
|
|
742
|
-
params: await props.params
|
|
743
|
-
});
|
|
733
|
+
const { value: path } = resolvePath2(props);
|
|
744
734
|
if (!route || route.type === "notFound") {
|
|
745
735
|
notFound();
|
|
746
736
|
}
|
|
@@ -770,8 +760,8 @@ var UniformComposition = async ({
|
|
|
770
760
|
searchParams,
|
|
771
761
|
dynamicInputs: route.dynamicInputs,
|
|
772
762
|
type: "composition",
|
|
773
|
-
isContextualEditing:
|
|
774
|
-
isDraftMode:
|
|
763
|
+
isContextualEditing: isIncontextEditingEnabled({ searchParams }),
|
|
764
|
+
isDraftMode: isDraftModeEnabled({ searchParams }),
|
|
775
765
|
state: route.compositionApiResponse.state,
|
|
776
766
|
path,
|
|
777
767
|
previewMode: determinePreviewMode({ searchParams })
|
|
@@ -785,14 +775,14 @@ var UniformComposition = async ({
|
|
|
785
775
|
});
|
|
786
776
|
let transfer = null;
|
|
787
777
|
if (props.mode === "server") {
|
|
788
|
-
const headersValue =
|
|
778
|
+
const headersValue = headers();
|
|
789
779
|
const missingQuirkValue = "unknown";
|
|
790
780
|
transfer = createElement3(ContextUpdateTransfer, {
|
|
791
781
|
serverContext,
|
|
792
782
|
update: {
|
|
793
|
-
params:
|
|
783
|
+
params: props.params,
|
|
794
784
|
searchParams,
|
|
795
|
-
cookies:
|
|
785
|
+
cookies: cookies2().getAll().reduce(
|
|
796
786
|
(acc, cookie) => {
|
|
797
787
|
acc[cookie.name] = cookie.value;
|
|
798
788
|
return acc;
|
|
@@ -1086,12 +1076,8 @@ var UniformContext = async ({
|
|
|
1086
1076
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
1087
1077
|
import { notFound as notFound2 } from "next/navigation";
|
|
1088
1078
|
import React8 from "react";
|
|
1089
|
-
var UniformPlayground = async ({
|
|
1090
|
-
searchParams
|
|
1091
|
-
...rest
|
|
1092
|
-
}) => {
|
|
1093
|
-
const searchParams = await (providedSearchParams != null ? providedSearchParams : {});
|
|
1094
|
-
if (!await isDraftModeEnabled({ searchParams })) {
|
|
1079
|
+
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1080
|
+
if (!isDraftModeEnabled({ searchParams })) {
|
|
1095
1081
|
return /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1096
1082
|
}
|
|
1097
1083
|
const id = searchParams["id"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc",
|
|
3
|
-
"version": "19.196.1
|
|
3
|
+
"version": "19.196.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -53,39 +53,38 @@
|
|
|
53
53
|
"/dist"
|
|
54
54
|
],
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@types/node": "20.
|
|
57
|
-
"@types/react": "18.3.
|
|
56
|
+
"@types/node": "20.10.6",
|
|
57
|
+
"@types/react": "18.3.3",
|
|
58
58
|
"eslint": "9.9.0",
|
|
59
|
-
"next": "
|
|
60
|
-
"react": "
|
|
61
|
-
"react-dom": "
|
|
62
|
-
"typescript": "5.6.3"
|
|
59
|
+
"next": "^14.0.0",
|
|
60
|
+
"react": "18.3.1",
|
|
61
|
+
"react-dom": "18.3.1"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@uniformdev/canvas": "19.196.1
|
|
66
|
-
"@uniformdev/canvas-next-rsc-client": "^19.196.1
|
|
67
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.196.1
|
|
68
|
-
"@uniformdev/canvas-react": "19.196.1
|
|
69
|
-
"@uniformdev/context": "19.196.1
|
|
70
|
-
"@uniformdev/project-map": "19.196.1
|
|
71
|
-
"@uniformdev/redirect": "19.196.1
|
|
72
|
-
"@uniformdev/richtext": "19.196.1
|
|
73
|
-
"@uniformdev/webhooks": "19.196.1
|
|
64
|
+
"@uniformdev/canvas": "19.196.1",
|
|
65
|
+
"@uniformdev/canvas-next-rsc-client": "^19.196.1",
|
|
66
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.196.1",
|
|
67
|
+
"@uniformdev/canvas-react": "19.196.1",
|
|
68
|
+
"@uniformdev/context": "19.196.1",
|
|
69
|
+
"@uniformdev/project-map": "19.196.1",
|
|
70
|
+
"@uniformdev/redirect": "19.196.1",
|
|
71
|
+
"@uniformdev/richtext": "19.196.1",
|
|
72
|
+
"@uniformdev/webhooks": "19.196.1",
|
|
74
73
|
"@vercel/edge-config": "^0.4.0",
|
|
75
74
|
"encoding": "^0.1.13",
|
|
76
75
|
"server-only": "^0.0.1",
|
|
77
76
|
"svix": "^1.5.0"
|
|
78
77
|
},
|
|
79
78
|
"engines": {
|
|
80
|
-
"node": ">=
|
|
79
|
+
"node": ">=16.14.0"
|
|
81
80
|
},
|
|
82
81
|
"peerDependencies": {
|
|
83
|
-
"next": ">=
|
|
84
|
-
"react": "
|
|
85
|
-
"react-dom": "
|
|
82
|
+
"next": ">=13.4.7",
|
|
83
|
+
"react": ">=18.2",
|
|
84
|
+
"react-dom": ">=18.2"
|
|
86
85
|
},
|
|
87
86
|
"publishConfig": {
|
|
88
87
|
"access": "public"
|
|
89
88
|
},
|
|
90
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "2956ed44925708e9c670de8f8fa8227208f03584"
|
|
91
90
|
}
|