@uniformdev/canvas-next-rsc 19.69.0 → 19.73.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/UniformComposition-38e22896.d.ts +61 -0
- package/dist/component.d.mts +76 -0
- package/dist/component.d.ts +76 -0
- package/dist/component.js +218 -0
- package/dist/component.mjs +182 -0
- package/dist/config.d.mts +6 -0
- package/dist/config.d.ts +6 -1
- package/dist/config.js +56 -29
- package/dist/config.mjs +41 -0
- package/dist/handler.d.mts +12 -0
- package/dist/handler.d.ts +12 -2
- package/dist/handler.js +703 -2
- package/dist/handler.mjs +682 -0
- package/dist/{client/manifestClient.d.ts → index.d.mts} +100 -18
- package/dist/index.d.ts +243 -23
- package/dist/index.esm.js +977 -0
- package/dist/index.js +1013 -29
- package/dist/index.mjs +977 -0
- package/package.json +23 -15
- package/dist/actions/updateContext.d.ts +0 -2
- package/dist/actions/updateContext.js +0 -17
- package/dist/client/canvasClient.d.ts +0 -5
- package/dist/client/canvasClient.js +0 -53
- package/dist/client/manifestClient.js +0 -33
- package/dist/client/projectMapClient.d.ts +0 -5
- package/dist/client/projectMapClient.js +0 -17
- package/dist/client/routeClient.d.ts +0 -5
- package/dist/client/routeClient.js +0 -68
- package/dist/components/DefaultNotImplementedComponent.d.ts +0 -2
- package/dist/components/DefaultNotImplementedComponent.js +0 -45
- package/dist/components/GoogleTagManagerAnalytics.d.ts +0 -3
- package/dist/components/GoogleTagManagerAnalytics.js +0 -44
- package/dist/components/UniformComponent.d.ts +0 -25
- package/dist/components/UniformComponent.js +0 -14
- package/dist/components/UniformComposition.d.ts +0 -40
- package/dist/components/UniformComposition.js +0 -35
- package/dist/components/UniformContext.d.ts +0 -8
- package/dist/components/UniformContext.js +0 -19
- package/dist/components/UniformRichText.d.ts +0 -38
- package/dist/components/UniformRichText.js +0 -15
- package/dist/components/UniformRichTextNode.d.ts +0 -10
- package/dist/components/UniformRichTextNode.js +0 -49
- package/dist/components/UniformScript.d.ts +0 -3
- package/dist/components/UniformScript.js +0 -49
- package/dist/components/UniformSlot.d.ts +0 -40
- package/dist/components/UniformSlot.js +0 -38
- package/dist/components/UniformText.d.ts +0 -6
- package/dist/components/UniformText.js +0 -5
- package/dist/components/__tests__/evaluateComposition.spec.d.ts +0 -1
- package/dist/components/__tests__/evaluateComposition.spec.js +0 -80
- package/dist/components/convertComponentToProps.d.ts +0 -14
- package/dist/components/convertComponentToProps.js +0 -22
- package/dist/components/evaluateComposition.d.ts +0 -22
- package/dist/components/evaluateComposition.js +0 -183
- package/dist/components/getEnrichmentTags.d.ts +0 -3
- package/dist/components/getEnrichmentTags.js +0 -13
- package/dist/components/getUniformContext.d.ts +0 -6
- package/dist/components/getUniformContext.js +0 -17
- package/dist/components/nodes/HeadingRichTextNode.d.ts +0 -2
- package/dist/components/nodes/HeadingRichTextNode.js +0 -6
- package/dist/components/nodes/LinebreakRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinebreakRichTextNode.js +0 -4
- package/dist/components/nodes/LinkRichTextNode.d.ts +0 -2
- package/dist/components/nodes/LinkRichTextNode.js +0 -6
- package/dist/components/nodes/ListItemRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListItemRichTextNode.js +0 -5
- package/dist/components/nodes/ListRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ListRichTextNode.js +0 -6
- package/dist/components/nodes/ParagraphRichTextNode.d.ts +0 -2
- package/dist/components/nodes/ParagraphRichTextNode.js +0 -6
- package/dist/components/nodes/TabRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TabRichTextNode.js +0 -4
- package/dist/components/nodes/TextRichTextNode.d.ts +0 -2
- package/dist/components/nodes/TextRichTextNode.js +0 -9
- package/dist/components/renderComponent.d.ts +0 -15
- package/dist/components/renderComponent.js +0 -52
- package/dist/components/resolvePath.d.ts +0 -5
- package/dist/components/resolvePath.js +0 -34
- package/dist/components/retrieveRoute.d.ts +0 -141
- package/dist/components/retrieveRoute.js +0 -146
- package/dist/components/types.d.ts +0 -11
- package/dist/components/types.js +0 -1
- package/dist/config/helpers.d.ts +0 -17
- package/dist/config/helpers.js +0 -34
- package/dist/config/models.d.ts +0 -51
- package/dist/config/models.js +0 -1
- package/dist/cookie/index.d.ts +0 -12
- package/dist/cookie/index.js +0 -21
- package/dist/handler/createPreviewGETRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewGETRouteHandler.js +0 -43
- package/dist/handler/createPreviewPOSTRouteHandler.d.ts +0 -1
- package/dist/handler/createPreviewPOSTRouteHandler.js +0 -88
- package/dist/handler/createUniformRouteHandler.d.ts +0 -4
- package/dist/handler/createUniformRouteHandler.js +0 -10
- package/dist/handler/helpers.d.ts +0 -19
- package/dist/handler/helpers.js +0 -148
- package/dist/handler/messages/handleCompositionChanged.d.ts +0 -2
- package/dist/handler/messages/handleCompositionChanged.js +0 -9
- package/dist/handler/messages/handleCompositionDeleted.d.ts +0 -2
- package/dist/handler/messages/handleCompositionDeleted.js +0 -9
- package/dist/handler/messages/handleCompositionPublished.d.ts +0 -2
- package/dist/handler/messages/handleCompositionPublished.js +0 -9
- package/dist/handler/messages/handleManifestPublished.d.ts +0 -2
- package/dist/handler/messages/handleManifestPublished.js +0 -10
- package/dist/handler/messages/handleProjectMapNodeDelete.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeDelete.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeInsert.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeInsert.js +0 -21
- package/dist/handler/messages/handleProjectMapNodeUpdate.d.ts +0 -2
- package/dist/handler/messages/handleProjectMapNodeUpdate.js +0 -22
- package/dist/handler/messages/handleRedirectDelete.d.ts +0 -2
- package/dist/handler/messages/handleRedirectDelete.js +0 -15
- package/dist/handler/messages/handleRedirectInsert.d.ts +0 -2
- package/dist/handler/messages/handleRedirectInsert.js +0 -15
- package/dist/handler/messages/handleRedirectUpdate.d.ts +0 -2
- package/dist/handler/messages/handleRedirectUpdate.js +0 -15
- package/dist/hooks/useForgetMe.d.ts +0 -4
- package/dist/hooks/useForgetMe.js +0 -10
- package/dist/hooks/useToggleConsent.d.ts +0 -7
- package/dist/hooks/useToggleConsent.js +0 -22
- package/dist/hooks/useUniformContext.d.ts +0 -1
- package/dist/hooks/useUniformContext.js +0 -3
- package/dist/models/index.d.ts +0 -30
- package/dist/models/index.js +0 -1
- package/dist/register/componentStore.d.ts +0 -1
- package/dist/register/componentStore.js +0 -2
- package/dist/register/componentStoreResolver.d.ts +0 -2
- package/dist/register/componentStoreResolver.js +0 -5
- package/dist/register/createComponentStore.d.ts +0 -12
- package/dist/register/createComponentStore.js +0 -13
- package/dist/register/createComponentStoreResolver.d.ts +0 -9
- package/dist/register/createComponentStoreResolver.js +0 -9
- package/dist/register/getTypeWithVariant.d.ts +0 -1
- package/dist/register/getTypeWithVariant.js +0 -1
- package/dist/register/registerUniformComponent.d.ts +0 -6
- package/dist/register/registerUniformComponent.js +0 -8
- package/dist/resolve/resolveChildren.d.ts +0 -10
- package/dist/resolve/resolveChildren.js +0 -20
- package/dist/score/index.d.ts +0 -3
- package/dist/score/index.js +0 -114
- package/dist/utils/__tests__/apply.spec.d.ts +0 -1
- package/dist/utils/__tests__/apply.spec.js +0 -358
- package/dist/utils/__tests__/diff.spec.d.ts +0 -1
- package/dist/utils/__tests__/diff.spec.js +0 -394
- package/dist/utils/apply.d.ts +0 -6
- package/dist/utils/apply.js +0 -124
- package/dist/utils/comp.d.ts +0 -16
- package/dist/utils/comp.js +0 -65
- package/dist/utils/diff.d.ts +0 -44
- package/dist/utils/diff.js +0 -144
- package/dist/utils/draft.d.ts +0 -12
- package/dist/utils/draft.js +0 -22
- package/dist/utils/tag.d.ts +0 -2
- package/dist/utils/tag.js +0 -7
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -10
package/dist/index.js
CHANGED
|
@@ -1,29 +1,1013 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
ContextUpdateTransfer: () => ContextUpdateTransfer,
|
|
34
|
+
UniformComposition: () => UniformComposition,
|
|
35
|
+
UniformContext: () => UniformContext,
|
|
36
|
+
UniformPlayground: () => UniformPlayground,
|
|
37
|
+
createServerUniformContext: () => createServerUniformContext,
|
|
38
|
+
createStaticParams: () => createStaticParams,
|
|
39
|
+
generateStaticParams: () => generateStaticParams,
|
|
40
|
+
getCanvasClient: () => getCanvasClient,
|
|
41
|
+
getDefaultCanvasClient: () => getDefaultCanvasClient,
|
|
42
|
+
getDefaultManifestClient: () => getDefaultManifestClient,
|
|
43
|
+
getDefaultProjectMapClient: () => getDefaultProjectMapClient,
|
|
44
|
+
getDefaultRouteClient: () => getDefaultRouteClient,
|
|
45
|
+
getManifest: () => getManifest,
|
|
46
|
+
getManifestClient: () => getManifestClient,
|
|
47
|
+
getProjectMapClient: () => getProjectMapClient,
|
|
48
|
+
getRouteClient: () => getRouteClient,
|
|
49
|
+
isDevelopmentEnvironment: () => isDevelopmentEnvironment,
|
|
50
|
+
isDraftModeEnabled: () => isDraftModeEnabled,
|
|
51
|
+
isIncontextEditingEnabled: () => isIncontextEditingEnabled,
|
|
52
|
+
isOnVercelPreviewEnvironment: () => isOnVercelPreviewEnvironment,
|
|
53
|
+
resolveComposition: () => resolveComposition
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(src_exports);
|
|
56
|
+
var import_server_only = require("server-only");
|
|
57
|
+
|
|
58
|
+
// src/clients/canvasClient.ts
|
|
59
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
60
|
+
|
|
61
|
+
// src/config/helpers.ts
|
|
62
|
+
var import_canvas_next_rsc_shared = require("@uniformdev/canvas-next-rsc-shared");
|
|
63
|
+
|
|
64
|
+
// src/utils/draft.ts
|
|
65
|
+
var import_canvas = require("@uniformdev/canvas");
|
|
66
|
+
var import_headers = require("next/headers");
|
|
67
|
+
var isDraftModeEnabled = ({
|
|
68
|
+
searchParams
|
|
69
|
+
}) => {
|
|
70
|
+
if (isDevelopmentEnvironment()) {
|
|
71
|
+
return isIncontextEditingEnabled({ searchParams });
|
|
72
|
+
}
|
|
73
|
+
let draftModeEnabled = false;
|
|
74
|
+
try {
|
|
75
|
+
draftModeEnabled = (0, import_headers.draftMode)().isEnabled;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
}
|
|
78
|
+
return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
|
|
79
|
+
};
|
|
80
|
+
var isIncontextEditingEnabled = ({
|
|
81
|
+
searchParams
|
|
82
|
+
}) => {
|
|
83
|
+
const containsKey = typeof (searchParams == null ? void 0 : searchParams[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
|
|
84
|
+
return containsKey;
|
|
85
|
+
};
|
|
86
|
+
var isOnVercelPreviewEnvironment = () => {
|
|
87
|
+
return process.env.VERCEL_ENV === "preview";
|
|
88
|
+
};
|
|
89
|
+
var isDevelopmentEnvironment = () => {
|
|
90
|
+
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/config/helpers.ts
|
|
94
|
+
var shouldCacheBeDisabled = (options) => {
|
|
95
|
+
if (isDraftModeEnabled(options)) {
|
|
96
|
+
return { disabled: true, reason: "DRAFT" };
|
|
97
|
+
}
|
|
98
|
+
if (isIncontextEditingEnabled(options)) {
|
|
99
|
+
return { disabled: true, reason: "INCONTEXT" };
|
|
100
|
+
}
|
|
101
|
+
if (isDevelopmentEnvironment()) {
|
|
102
|
+
return { disabled: true, reason: "DEV" };
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
disabled: false,
|
|
106
|
+
reason: void 0
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var getCanvasCacheStrategy = (options) => {
|
|
110
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
111
|
+
const config = (0, import_canvas_next_rsc_shared.getServerConfig)();
|
|
112
|
+
if (disabled) {
|
|
113
|
+
if (reason === "DEV" && config.canvasCache) {
|
|
114
|
+
console.warn("Canvas cache (disabled) has been overridden by canvasCache config.");
|
|
115
|
+
return config.canvasCache;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
type: "no-cache"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (config.canvasCache) {
|
|
122
|
+
return config.canvasCache;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
type: "force-cache"
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var getManifestCacheStrategy = (options) => {
|
|
129
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
130
|
+
const config = (0, import_canvas_next_rsc_shared.getServerConfig)();
|
|
131
|
+
if (disabled) {
|
|
132
|
+
if (reason === "DEV" && config.manifestCache) {
|
|
133
|
+
console.warn("Manifest cache (disabled) has been overridden by manifestCache config.");
|
|
134
|
+
return config.manifestCache;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
type: "no-cache"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (config.manifestCache) {
|
|
141
|
+
return config.manifestCache;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
type: "force-cache"
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
var getProjectMapCacheStrategy = (options) => {
|
|
148
|
+
const { disabled, reason } = shouldCacheBeDisabled(options);
|
|
149
|
+
const config = (0, import_canvas_next_rsc_shared.getServerConfig)();
|
|
150
|
+
if (disabled) {
|
|
151
|
+
if (reason === "DEV" && config.projectMapCache) {
|
|
152
|
+
console.warn("Project map cache (disabled) has been overridden by projectMapCache config.");
|
|
153
|
+
return config.projectMapCache;
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
type: "no-cache"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (config.projectMapCache) {
|
|
160
|
+
return config.projectMapCache;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
type: "force-cache"
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/env/index.ts
|
|
168
|
+
var env = {
|
|
169
|
+
getProjectId: () => {
|
|
170
|
+
return process.env.UNIFORM_PROJECT_ID;
|
|
171
|
+
},
|
|
172
|
+
getApiKey: () => {
|
|
173
|
+
return process.env.UNIFORM_API_KEY;
|
|
174
|
+
},
|
|
175
|
+
getApiHost: () => {
|
|
176
|
+
return process.env.UNIFORM_API_HOST || process.env.UNIFORM_CLI_BASE_URL;
|
|
177
|
+
},
|
|
178
|
+
getEdgeApiHost: () => {
|
|
179
|
+
return process.env.UNIFORM_EDGE_API_HOST || process.env.UNIFORM_CLI_BASE_EDGE_URL;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/utils/tag.ts
|
|
184
|
+
var buildPathTag = (path) => {
|
|
185
|
+
const actualPath = path.startsWith("/") ? path : `/${path}`;
|
|
186
|
+
return `path:${actualPath}`.toLowerCase();
|
|
187
|
+
};
|
|
188
|
+
var buildCompositionTag = (compositionId) => {
|
|
189
|
+
return `composition:${compositionId}`.toLowerCase();
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// src/clients/shared.ts
|
|
193
|
+
var determineFetchCacheOptions = (mode) => {
|
|
194
|
+
let cache = void 0;
|
|
195
|
+
let revalidate = void 0;
|
|
196
|
+
if (mode.type === "revalidate") {
|
|
197
|
+
cache = void 0;
|
|
198
|
+
revalidate = mode.interval;
|
|
199
|
+
} else {
|
|
200
|
+
cache = mode.type;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
cache,
|
|
204
|
+
revalidate
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/clients/canvasClient.ts
|
|
209
|
+
var getCanvasClient = (options) => {
|
|
210
|
+
return new import_canvas2.CanvasClient({
|
|
211
|
+
projectId: env.getProjectId(),
|
|
212
|
+
apiHost: env.getApiHost(),
|
|
213
|
+
apiKey: env.getApiKey(),
|
|
214
|
+
edgeApiHost: env.getEdgeApiHost(),
|
|
215
|
+
fetch: (req, init) => {
|
|
216
|
+
let requestedUrl;
|
|
217
|
+
if (typeof req === "string") {
|
|
218
|
+
requestedUrl = new URL(req);
|
|
219
|
+
} else if (req instanceof URL) {
|
|
220
|
+
requestedUrl = req;
|
|
221
|
+
} else {
|
|
222
|
+
requestedUrl = new URL(req.url);
|
|
223
|
+
}
|
|
224
|
+
const tags = [];
|
|
225
|
+
if (requestedUrl) {
|
|
226
|
+
const compositionIdKey = "compositionId";
|
|
227
|
+
const compositionIdsKey = "compositionIDs";
|
|
228
|
+
const compositionId = requestedUrl.searchParams.get(compositionIdKey);
|
|
229
|
+
const compositionIds = requestedUrl.searchParams.get(compositionIdsKey);
|
|
230
|
+
if (compositionId) {
|
|
231
|
+
tags.push(buildCompositionTag(compositionId));
|
|
232
|
+
}
|
|
233
|
+
if (compositionIds) {
|
|
234
|
+
const ids = compositionIds.split(",");
|
|
235
|
+
for (let i = 0; i < ids.length; i++) {
|
|
236
|
+
tags.push(buildCompositionTag(ids[i]));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const { cache, revalidate } = determineFetchCacheOptions(options.cache);
|
|
241
|
+
return fetch(req, {
|
|
242
|
+
...init,
|
|
243
|
+
cache,
|
|
244
|
+
headers: {
|
|
245
|
+
...init == null ? void 0 : init.headers,
|
|
246
|
+
"x-bypass-cache": "true"
|
|
247
|
+
},
|
|
248
|
+
next: {
|
|
249
|
+
revalidate
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
var getDefaultCanvasClient = ({
|
|
256
|
+
searchParams
|
|
257
|
+
}) => {
|
|
258
|
+
return getCanvasClient({
|
|
259
|
+
cache: getCanvasCacheStrategy({
|
|
260
|
+
searchParams
|
|
261
|
+
})
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/clients/manifestClient.ts
|
|
266
|
+
var import_api = require("@uniformdev/context/api");
|
|
267
|
+
var getManifestClient = (options) => {
|
|
268
|
+
const manifestClient = new import_api.ManifestClient({
|
|
269
|
+
apiHost: env.getApiHost(),
|
|
270
|
+
apiKey: env.getApiKey(),
|
|
271
|
+
projectId: env.getProjectId(),
|
|
272
|
+
fetch: (req, init) => {
|
|
273
|
+
const { cache, revalidate } = determineFetchCacheOptions(options.cache);
|
|
274
|
+
return fetch(req, {
|
|
275
|
+
...init,
|
|
276
|
+
headers: {
|
|
277
|
+
...init == null ? void 0 : init.headers,
|
|
278
|
+
"x-bypass-cache": "true"
|
|
279
|
+
},
|
|
280
|
+
cache,
|
|
281
|
+
next: {
|
|
282
|
+
revalidate,
|
|
283
|
+
tags: ["manifest"]
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
return manifestClient;
|
|
289
|
+
};
|
|
290
|
+
var getDefaultManifestClient = ({
|
|
291
|
+
searchParams
|
|
292
|
+
}) => {
|
|
293
|
+
return getManifestClient({
|
|
294
|
+
cache: getManifestCacheStrategy({
|
|
295
|
+
searchParams
|
|
296
|
+
})
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
var getManifest = ({ searchParams }) => {
|
|
300
|
+
const manifestClient = getDefaultManifestClient({
|
|
301
|
+
searchParams
|
|
302
|
+
});
|
|
303
|
+
return manifestClient.get();
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// src/clients/projectMapClient.ts
|
|
307
|
+
var import_project_map = require("@uniformdev/project-map");
|
|
308
|
+
var getProjectMapClient = (options) => {
|
|
309
|
+
const manifestClient = new import_project_map.ProjectMapClient({
|
|
310
|
+
apiHost: env.getApiHost(),
|
|
311
|
+
apiKey: env.getApiKey(),
|
|
312
|
+
projectId: env.getProjectId(),
|
|
313
|
+
fetch: (req, init) => {
|
|
314
|
+
const { cache, revalidate } = determineFetchCacheOptions(options.cache);
|
|
315
|
+
return fetch(req, {
|
|
316
|
+
...init,
|
|
317
|
+
headers: {
|
|
318
|
+
...init == null ? void 0 : init.headers,
|
|
319
|
+
"x-bypass-cache": "true"
|
|
320
|
+
},
|
|
321
|
+
cache,
|
|
322
|
+
next: {
|
|
323
|
+
revalidate
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return manifestClient;
|
|
329
|
+
};
|
|
330
|
+
var getDefaultProjectMapClient = ({
|
|
331
|
+
searchParams
|
|
332
|
+
}) => {
|
|
333
|
+
return getProjectMapClient({
|
|
334
|
+
cache: getProjectMapCacheStrategy({
|
|
335
|
+
searchParams
|
|
336
|
+
})
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/clients/routeClient.ts
|
|
341
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
342
|
+
var getRouteClient = (options) => {
|
|
343
|
+
const client = new import_canvas3.RouteClient({
|
|
344
|
+
projectId: env.getProjectId(),
|
|
345
|
+
apiKey: env.getApiKey(),
|
|
346
|
+
edgeApiHost: env.getEdgeApiHost(),
|
|
347
|
+
fetch: (req, init) => {
|
|
348
|
+
let requestedUrl;
|
|
349
|
+
if (typeof req === "string") {
|
|
350
|
+
requestedUrl = new URL(req);
|
|
351
|
+
} else if (req instanceof URL) {
|
|
352
|
+
requestedUrl = req;
|
|
353
|
+
} else {
|
|
354
|
+
requestedUrl = new URL(req.url);
|
|
355
|
+
}
|
|
356
|
+
const tags = [];
|
|
357
|
+
if (requestedUrl) {
|
|
358
|
+
const pathKey = "path";
|
|
359
|
+
const path = requestedUrl.searchParams.get(pathKey);
|
|
360
|
+
if (path) {
|
|
361
|
+
const pieces = path.split("/");
|
|
362
|
+
for (let i = 0; i < pieces.length; i++) {
|
|
363
|
+
const segmentPieces = pieces.slice(0, i + 1);
|
|
364
|
+
const segment = segmentPieces.join("/");
|
|
365
|
+
tags.push(buildPathTag(segment));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const { cache, revalidate } = determineFetchCacheOptions(options.cache);
|
|
370
|
+
return fetch(req, {
|
|
371
|
+
...init,
|
|
372
|
+
headers: {
|
|
373
|
+
...init == null ? void 0 : init.headers,
|
|
374
|
+
"x-bypass-cache": "true"
|
|
375
|
+
},
|
|
376
|
+
cache,
|
|
377
|
+
next: {
|
|
378
|
+
revalidate,
|
|
379
|
+
tags: tags.length ? tags : void 0
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
return client;
|
|
385
|
+
};
|
|
386
|
+
var getDefaultRouteClient = ({ searchParams }) => {
|
|
387
|
+
return getRouteClient({
|
|
388
|
+
cache: getCanvasCacheStrategy({
|
|
389
|
+
searchParams
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// src/components/ContextUpdateTransfer.tsx
|
|
395
|
+
var import_canvas_next_rsc_client = require("@uniformdev/canvas-next-rsc-client");
|
|
396
|
+
var import_react = __toESM(require("react"));
|
|
397
|
+
var ContextUpdateTransfer = async ({
|
|
398
|
+
update,
|
|
399
|
+
serverContext
|
|
400
|
+
}) => {
|
|
401
|
+
const result = typeof update === "function" ? await update() : update;
|
|
402
|
+
if (!result) {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
if (serverContext) {
|
|
406
|
+
await serverContext.__INTERNAL__.update(result);
|
|
407
|
+
}
|
|
408
|
+
return /* @__PURE__ */ import_react.default.createElement(import_canvas_next_rsc_client.ContextUpdateTransferClient, { ts: (/* @__PURE__ */ new Date()).valueOf(), update: result });
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/components/generateStaticParams.ts
|
|
412
|
+
var createStaticParams = async (options) => {
|
|
413
|
+
var _a, _b;
|
|
414
|
+
const { expand } = options != null ? options : {};
|
|
415
|
+
const client = getProjectMapClient({
|
|
416
|
+
cache: {
|
|
417
|
+
type: "no-cache"
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
const { nodes } = await client.getNodes({});
|
|
421
|
+
const resolvedPaths = [];
|
|
422
|
+
if (nodes) {
|
|
423
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
424
|
+
const node = nodes[i];
|
|
425
|
+
const isDynamic = node.path.includes(":");
|
|
426
|
+
if (!isDynamic) {
|
|
427
|
+
resolvedPaths.push(node.path);
|
|
428
|
+
} else if (expand) {
|
|
429
|
+
const expandedPaths = (_a = await expand(node)) != null ? _a : [];
|
|
430
|
+
resolvedPaths.push(...expandedPaths);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return (_b = resolvedPaths == null ? void 0 : resolvedPaths.map((path) => {
|
|
435
|
+
return {
|
|
436
|
+
path: path.split("/").filter(Boolean)
|
|
437
|
+
};
|
|
438
|
+
})) != null ? _b : [];
|
|
439
|
+
};
|
|
440
|
+
async function generateStaticParams() {
|
|
441
|
+
return createStaticParams();
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/components/UniformComposition.ts
|
|
445
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
446
|
+
var import_canvas_next_rsc_client4 = require("@uniformdev/canvas-next-rsc-client");
|
|
447
|
+
var import_canvas_next_rsc_shared6 = require("@uniformdev/canvas-next-rsc-shared");
|
|
448
|
+
var import_core = require("@uniformdev/canvas-react/core");
|
|
449
|
+
var import_headers3 = require("next/headers");
|
|
450
|
+
var import_navigation = require("next/navigation");
|
|
451
|
+
var import_react6 = require("react");
|
|
452
|
+
|
|
453
|
+
// src/context/createServerUniformContext.ts
|
|
454
|
+
var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
|
|
455
|
+
var import_context = require("@uniformdev/context");
|
|
456
|
+
var import_headers2 = require("next/headers");
|
|
457
|
+
var createServerUniformContext = async (options) => {
|
|
458
|
+
const manifest = await getManifest(options);
|
|
459
|
+
const context = createServerUniformContextFromManifest({
|
|
460
|
+
...options || {},
|
|
461
|
+
manifest
|
|
462
|
+
});
|
|
463
|
+
return context;
|
|
464
|
+
};
|
|
465
|
+
var createServerUniformContextFromManifest = async (options) => {
|
|
466
|
+
var _a;
|
|
467
|
+
const context = (0, import_canvas_next_rsc_shared2.createUniformContext)({
|
|
468
|
+
...options || {},
|
|
469
|
+
serverCookieValue: (_a = (0, import_headers2.cookies)().get(import_context.UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
470
|
+
});
|
|
471
|
+
return {
|
|
472
|
+
...context,
|
|
473
|
+
__INTERNAL__: {
|
|
474
|
+
update: (...props) => context.update(...props)
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/utils/route.ts
|
|
480
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
481
|
+
var import_canvas_next_rsc_shared3 = require("@uniformdev/canvas-next-rsc-shared");
|
|
482
|
+
var import_redirect = require("@uniformdev/redirect");
|
|
483
|
+
var retrieveRoute = async ({
|
|
484
|
+
params,
|
|
485
|
+
searchParams
|
|
486
|
+
}) => {
|
|
487
|
+
const { type, value } = (0, import_canvas_next_rsc_shared3.resolvePath)({
|
|
488
|
+
params
|
|
489
|
+
});
|
|
490
|
+
const states = determineState({
|
|
491
|
+
searchParams
|
|
492
|
+
});
|
|
493
|
+
let result;
|
|
494
|
+
for (let i = 0; i < states.length; i++) {
|
|
495
|
+
const state = states[i];
|
|
496
|
+
if (type === "path") {
|
|
497
|
+
try {
|
|
498
|
+
result = await retrieveRouteByPath({
|
|
499
|
+
path: value,
|
|
500
|
+
state,
|
|
501
|
+
searchParams
|
|
502
|
+
});
|
|
503
|
+
} catch (e) {
|
|
504
|
+
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
505
|
+
}
|
|
506
|
+
} else if (type === "slug") {
|
|
507
|
+
const canvasClient = getDefaultCanvasClient({
|
|
508
|
+
searchParams
|
|
509
|
+
});
|
|
510
|
+
try {
|
|
511
|
+
const composition = await canvasClient.getCompositionBySlug({
|
|
512
|
+
slug: value,
|
|
513
|
+
state
|
|
514
|
+
});
|
|
515
|
+
result = {
|
|
516
|
+
type: "composition",
|
|
517
|
+
compositionApiResponse: composition,
|
|
518
|
+
matchedRoute: "slug"
|
|
519
|
+
};
|
|
520
|
+
} catch (e) {
|
|
521
|
+
console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if ((result == null ? void 0 : result.type) !== "notFound") {
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (!result) {
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
...result,
|
|
533
|
+
path: value
|
|
534
|
+
};
|
|
535
|
+
};
|
|
536
|
+
var retrieveRouteByPath = async ({
|
|
537
|
+
path,
|
|
538
|
+
state,
|
|
539
|
+
searchParams
|
|
540
|
+
}) => {
|
|
541
|
+
var _a;
|
|
542
|
+
const client = getDefaultRouteClient({
|
|
543
|
+
searchParams
|
|
544
|
+
});
|
|
545
|
+
return await client.getRoute({
|
|
546
|
+
path,
|
|
547
|
+
state,
|
|
548
|
+
withComponentIDs: true,
|
|
549
|
+
withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = (0, import_canvas_next_rsc_shared3.getServerConfig)().experimental) == null ? void 0 : _a.vercelVisualEditing)
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
var resolveRedirectHref = (resolveResult, path) => {
|
|
553
|
+
let href;
|
|
554
|
+
if (resolveResult.redirect.targetProjectMapNodeId) {
|
|
555
|
+
const requestUrl = `${(0, import_canvas_next_rsc_shared3.getBaseUrl)()}${path}`;
|
|
556
|
+
const expandedUrl = (0, import_redirect.getTargetVariableExpandedUrl)(requestUrl, resolveResult.redirect);
|
|
557
|
+
const url = new URL(expandedUrl);
|
|
558
|
+
href = url.pathname;
|
|
559
|
+
} else {
|
|
560
|
+
href = resolveResult.redirect.targetUrl;
|
|
561
|
+
}
|
|
562
|
+
return href;
|
|
563
|
+
};
|
|
564
|
+
var determineState = ({ searchParams }) => {
|
|
565
|
+
const draftMode2 = isDraftModeEnabled({ searchParams });
|
|
566
|
+
const previewEnvironment = isOnVercelPreviewEnvironment();
|
|
567
|
+
const isDevelopment = isDevelopmentEnvironment();
|
|
568
|
+
const isCanvasEditing = isIncontextEditingEnabled({
|
|
569
|
+
searchParams
|
|
570
|
+
});
|
|
571
|
+
let states;
|
|
572
|
+
if (isCanvasEditing) {
|
|
573
|
+
states = [import_canvas4.CANVAS_EDITOR_STATE, import_canvas4.CANVAS_DRAFT_STATE];
|
|
574
|
+
} else {
|
|
575
|
+
states = draftMode2 || previewEnvironment || isDevelopment ? [import_canvas4.CANVAS_DRAFT_STATE] : [import_canvas4.CANVAS_PUBLISHED_STATE];
|
|
576
|
+
}
|
|
577
|
+
return states;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
// src/components/ContextUpdateTrigger.tsx
|
|
581
|
+
var import_canvas_next_rsc_client2 = require("@uniformdev/canvas-next-rsc-client");
|
|
582
|
+
var import_react2 = __toESM(require("react"));
|
|
583
|
+
var ContextUpdateTrigger = () => {
|
|
584
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_canvas_next_rsc_client2.ClientContextUpdate, null);
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
// src/components/PersonalizeClientWrapper.tsx
|
|
588
|
+
var import_canvas_next_rsc_client3 = require("@uniformdev/canvas-next-rsc-client");
|
|
589
|
+
var import_canvas_next_rsc_shared4 = require("@uniformdev/canvas-next-rsc-shared");
|
|
590
|
+
var import_react3 = __toESM(require("react"));
|
|
591
|
+
var PersonalizeClientWrapper = (props) => {
|
|
592
|
+
const { indexes } = (0, import_canvas_next_rsc_shared4.runPersonalization)({
|
|
593
|
+
...props,
|
|
594
|
+
contextInstance: void 0
|
|
595
|
+
});
|
|
596
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_canvas_next_rsc_client3.PersonalizeClient, { ...props, indexes });
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// src/components/PersonalizeServer.ts
|
|
600
|
+
var import_canvas5 = require("@uniformdev/canvas");
|
|
601
|
+
var import_canvas_next_rsc_shared5 = require("@uniformdev/canvas-next-rsc-shared");
|
|
602
|
+
var import_react4 = require("react");
|
|
603
|
+
var PersonalizeServer = (props) => {
|
|
604
|
+
var _a;
|
|
605
|
+
const { indexes } = (0, import_canvas_next_rsc_shared5.runPersonalization)(props);
|
|
606
|
+
const slot = (_a = props.slots) == null ? void 0 : _a[import_canvas5.CANVAS_PERSONALIZE_SLOT];
|
|
607
|
+
const components = indexes.map((index) => {
|
|
608
|
+
const component = slot.items[index];
|
|
609
|
+
return component;
|
|
610
|
+
});
|
|
611
|
+
return (0, import_react4.createElement)(import_react4.Fragment, void 0, components);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// src/components/TestServer.ts
|
|
615
|
+
var import_canvas6 = require("@uniformdev/canvas");
|
|
616
|
+
var import_react5 = require("react");
|
|
617
|
+
var TestServer = ({ test, component, contextInstance, slots }) => {
|
|
618
|
+
var _a, _b, _c;
|
|
619
|
+
const slot = ((_a = component.slots) == null ? void 0 : _a[import_canvas6.CANVAS_TEST_SLOT]) || [];
|
|
620
|
+
const { result } = contextInstance.test({
|
|
621
|
+
name: test,
|
|
622
|
+
variations: slot.map((v, i) => {
|
|
623
|
+
var _a2, _b2, _c2;
|
|
624
|
+
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas6.CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
|
|
625
|
+
const id = (_c2 = contextTag == null ? void 0 : contextTag.id) != null ? _c2 : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
|
|
626
|
+
return {
|
|
627
|
+
id,
|
|
628
|
+
testDistribution: contextTag == null ? void 0 : contextTag.testDistribution,
|
|
629
|
+
index: i
|
|
630
|
+
};
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
const components = result ? (_c = (_b = slots == null ? void 0 : slots[import_canvas6.CANVAS_TEST_SLOT]) == null ? void 0 : _b.items[result.index]) != null ? _c : null : null;
|
|
634
|
+
return (0, import_react5.createElement)(import_react5.Fragment, void 0, components);
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
// src/components/UniformComposition.ts
|
|
638
|
+
var UniformComposition = async ({
|
|
639
|
+
resolveComponent,
|
|
640
|
+
...props
|
|
641
|
+
}) => {
|
|
642
|
+
let searchParams;
|
|
643
|
+
let serverContext = void 0;
|
|
644
|
+
if (props.mode === "static") {
|
|
645
|
+
searchParams = void 0;
|
|
646
|
+
} else if (props.mode === "server") {
|
|
647
|
+
serverContext = props.serverContext || await createServerUniformContext({
|
|
648
|
+
searchParams: props.searchParams
|
|
649
|
+
});
|
|
650
|
+
searchParams = props.searchParams;
|
|
651
|
+
}
|
|
652
|
+
let route = void 0;
|
|
653
|
+
if (props.composition) {
|
|
654
|
+
const { value } = (0, import_canvas_next_rsc_shared6.resolvePath)(props);
|
|
655
|
+
route = {
|
|
656
|
+
type: "composition",
|
|
657
|
+
compositionApiResponse: props.composition,
|
|
658
|
+
matchedRoute: "composition",
|
|
659
|
+
path: value
|
|
660
|
+
};
|
|
661
|
+
} else {
|
|
662
|
+
route = await retrieveRoute({
|
|
663
|
+
params: props.params,
|
|
664
|
+
searchParams
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
if (!route || route.type === "notFound") {
|
|
668
|
+
(0, import_navigation.notFound)();
|
|
669
|
+
}
|
|
670
|
+
if (route.type === "redirect") {
|
|
671
|
+
const href = resolveRedirectHref(route, route.path);
|
|
672
|
+
(0, import_navigation.redirect)(href);
|
|
673
|
+
}
|
|
674
|
+
const state = route.compositionApiResponse.state;
|
|
675
|
+
if (state === import_canvas7.CANVAS_DRAFT_STATE || state === import_canvas7.CANVAS_EDITOR_STATE) {
|
|
676
|
+
(0, import_canvas7.walkNodeTree)(route.compositionApiResponse.composition, (node) => {
|
|
677
|
+
if (node.type === "component" && node.node.parameters) {
|
|
678
|
+
Object.keys(node.node.parameters).forEach((key) => {
|
|
679
|
+
const parameter = node.node.parameters[key];
|
|
680
|
+
if (parameter.type === "text") {
|
|
681
|
+
const contextualParameter = parameter;
|
|
682
|
+
contextualParameter._contextualEditing = {
|
|
683
|
+
isEditable: true
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
const compositionContext = {
|
|
691
|
+
composition: route.compositionApiResponse.composition,
|
|
692
|
+
matchedRoute: route.matchedRoute,
|
|
693
|
+
searchParams,
|
|
694
|
+
dynamicInputs: route.dynamicInputs,
|
|
695
|
+
type: "composition",
|
|
696
|
+
isContextualEditing: isIncontextEditingEnabled({ searchParams }),
|
|
697
|
+
isDraftMode: isDraftModeEnabled({ searchParams }),
|
|
698
|
+
state: route.compositionApiResponse.state,
|
|
699
|
+
path: route.path
|
|
700
|
+
};
|
|
701
|
+
const resolved = resolveComposition({
|
|
702
|
+
composition: route.compositionApiResponse.composition,
|
|
703
|
+
resolveComponent,
|
|
704
|
+
serverContext,
|
|
705
|
+
compositionContext,
|
|
706
|
+
mode: props.mode
|
|
707
|
+
});
|
|
708
|
+
let transfer = null;
|
|
709
|
+
if (props.mode === "server") {
|
|
710
|
+
const headersValue = (0, import_headers3.headers)();
|
|
711
|
+
const missingQuirkValue = "unknown";
|
|
712
|
+
transfer = (0, import_react6.createElement)(ContextUpdateTransfer, {
|
|
713
|
+
serverContext,
|
|
714
|
+
update: {
|
|
715
|
+
params: props.params,
|
|
716
|
+
searchParams,
|
|
717
|
+
cookies: (0, import_headers3.cookies)().getAll().reduce((acc, cookie) => {
|
|
718
|
+
acc[cookie.name] = cookie.value;
|
|
719
|
+
return acc;
|
|
720
|
+
}, {}),
|
|
721
|
+
quirks: {
|
|
722
|
+
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
723
|
+
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
|
724
|
+
"vc-city": headersValue.get("x-vercel-ip-city") || missingQuirkValue
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
} else if (props.mode === "static") {
|
|
729
|
+
transfer = (0, import_react6.createElement)(ContextUpdateTrigger);
|
|
730
|
+
}
|
|
731
|
+
return (0, import_react6.createElement)(import_react6.Fragment, void 0, transfer, resolved);
|
|
732
|
+
};
|
|
733
|
+
var isServerComponent = ({
|
|
734
|
+
component,
|
|
735
|
+
serverContext
|
|
736
|
+
}) => {
|
|
737
|
+
var _a, _b;
|
|
738
|
+
if (component.type === import_canvas7.CANVAS_PERSONALIZE_TYPE) {
|
|
739
|
+
return serverContext && ((_a = (0, import_canvas_next_rsc_shared6.getServerConfig)().evaluation) == null ? void 0 : _a.personalization) !== "client";
|
|
740
|
+
}
|
|
741
|
+
if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
|
|
742
|
+
return serverContext && ((_b = (0, import_canvas_next_rsc_shared6.getServerConfig)().evaluation) == null ? void 0 : _b.testing) !== "client";
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
var resolveSystemComponent = ({
|
|
746
|
+
component,
|
|
747
|
+
serverContext
|
|
748
|
+
}) => {
|
|
749
|
+
const server = isServerComponent({
|
|
750
|
+
component,
|
|
751
|
+
serverContext
|
|
752
|
+
});
|
|
753
|
+
if (component.type === import_canvas7.CANVAS_PERSONALIZE_TYPE) {
|
|
754
|
+
return server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
755
|
+
}
|
|
756
|
+
if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
|
|
757
|
+
return server ? TestServer : import_canvas_next_rsc_client4.TestClient;
|
|
758
|
+
}
|
|
759
|
+
return null;
|
|
760
|
+
};
|
|
761
|
+
var resolveSlots = ({
|
|
762
|
+
component,
|
|
763
|
+
root,
|
|
764
|
+
resolveComponent,
|
|
765
|
+
serverContext,
|
|
766
|
+
compositionContext,
|
|
767
|
+
mode
|
|
768
|
+
}) => {
|
|
769
|
+
const slots = {};
|
|
770
|
+
if (component.slots) {
|
|
771
|
+
Object.keys(component.slots).forEach((slotName, slotIndex) => {
|
|
772
|
+
const resolved = resolveComponents({
|
|
773
|
+
target: {
|
|
774
|
+
type: "slot",
|
|
775
|
+
components: component.slots[slotName],
|
|
776
|
+
root,
|
|
777
|
+
parent: component
|
|
778
|
+
},
|
|
779
|
+
slotName,
|
|
780
|
+
slotIndex,
|
|
781
|
+
resolveComponent,
|
|
782
|
+
serverContext,
|
|
783
|
+
compositionContext,
|
|
784
|
+
mode
|
|
785
|
+
});
|
|
786
|
+
if (resolved) {
|
|
787
|
+
slots[slotName] = {
|
|
788
|
+
name: slotName,
|
|
789
|
+
items: resolved
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
return slots;
|
|
795
|
+
};
|
|
796
|
+
var resolveComposition = (props) => {
|
|
797
|
+
const [resolved] = resolveComponents({
|
|
798
|
+
...props,
|
|
799
|
+
target: {
|
|
800
|
+
type: "root",
|
|
801
|
+
composition: props.composition
|
|
802
|
+
},
|
|
803
|
+
slotName: void 0,
|
|
804
|
+
slotIndex: void 0,
|
|
805
|
+
compositionContext: props.compositionContext
|
|
806
|
+
});
|
|
807
|
+
return resolved;
|
|
808
|
+
};
|
|
809
|
+
var resolveComponents = ({
|
|
810
|
+
serverContext,
|
|
811
|
+
target,
|
|
812
|
+
slotName,
|
|
813
|
+
slotIndex,
|
|
814
|
+
resolveComponent,
|
|
815
|
+
compositionContext,
|
|
816
|
+
mode
|
|
817
|
+
}) => {
|
|
818
|
+
const isRoot = !slotName && typeof slotIndex !== "number";
|
|
819
|
+
let root;
|
|
820
|
+
let parent = void 0;
|
|
821
|
+
let components;
|
|
822
|
+
if (target.type === "root") {
|
|
823
|
+
root = target.composition;
|
|
824
|
+
components = [target.composition];
|
|
825
|
+
} else {
|
|
826
|
+
root = target.root;
|
|
827
|
+
components = target.components;
|
|
828
|
+
parent = target.parent;
|
|
829
|
+
}
|
|
830
|
+
const resolved = components.map((component, componentIndex) => {
|
|
831
|
+
var _a, _b;
|
|
832
|
+
const isServer = isServerComponent({
|
|
833
|
+
component,
|
|
834
|
+
serverContext
|
|
835
|
+
});
|
|
836
|
+
const systemComponent = resolveSystemComponent({
|
|
837
|
+
component,
|
|
838
|
+
serverContext
|
|
839
|
+
});
|
|
840
|
+
const { component: regularComponent, includeContext } = resolveComponent({ component }) || {
|
|
841
|
+
component: null
|
|
842
|
+
};
|
|
843
|
+
if (!systemComponent && !regularComponent) {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
const slots = resolveSlots({
|
|
847
|
+
component,
|
|
848
|
+
root,
|
|
849
|
+
resolveComponent,
|
|
850
|
+
serverContext,
|
|
851
|
+
compositionContext,
|
|
852
|
+
mode
|
|
853
|
+
});
|
|
854
|
+
const resolvedComponent = systemComponent || regularComponent;
|
|
855
|
+
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
856
|
+
const enrichmentTags = (_b = parameters[import_canvas7.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
857
|
+
const componentProps = {
|
|
858
|
+
key: `${slotName}-${componentIndex}-component`,
|
|
859
|
+
...Object.keys(parameters).reduce((acc, cur) => {
|
|
860
|
+
acc[cur] = parameters[cur].value;
|
|
861
|
+
return acc;
|
|
862
|
+
}, {}),
|
|
863
|
+
component,
|
|
864
|
+
slots,
|
|
865
|
+
contextInstance: isServer || includeContext ? serverContext : void 0,
|
|
866
|
+
context: compositionContext
|
|
867
|
+
};
|
|
868
|
+
const element = (0, import_react6.createElement)(resolvedComponent, componentProps);
|
|
869
|
+
let tagElement = null;
|
|
870
|
+
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
871
|
+
tagElement = (0, import_react6.createElement)(ContextUpdateTransfer, {
|
|
872
|
+
key: `${slotName}-${componentIndex}-tags`,
|
|
873
|
+
update: {
|
|
874
|
+
enrichments: enrichmentTags
|
|
875
|
+
},
|
|
876
|
+
serverContext
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
let childNode;
|
|
880
|
+
if (compositionContext.isContextualEditing) {
|
|
881
|
+
const elements = [element];
|
|
882
|
+
if (tagElement) {
|
|
883
|
+
elements.push(tagElement);
|
|
884
|
+
}
|
|
885
|
+
childNode = (0, import_react6.createElement)(
|
|
886
|
+
import_core.PureContextualEditingComponentWrapper,
|
|
887
|
+
{
|
|
888
|
+
key: `${slotName}-${componentIndex}-wrapper`,
|
|
889
|
+
isPlaceholder: false,
|
|
890
|
+
parentComponent: parent,
|
|
891
|
+
component,
|
|
892
|
+
slotName,
|
|
893
|
+
indexInSlot: componentIndex,
|
|
894
|
+
slotChildrenCount: components.length,
|
|
895
|
+
isReadOnly: "false"
|
|
896
|
+
},
|
|
897
|
+
elements
|
|
898
|
+
);
|
|
899
|
+
} else if (mode === "static") {
|
|
900
|
+
const elements = [element];
|
|
901
|
+
if (tagElement) {
|
|
902
|
+
elements.push(tagElement);
|
|
903
|
+
}
|
|
904
|
+
childNode = (0, import_react6.createElement)(
|
|
905
|
+
import_canvas_next_rsc_client4.ClientContextualEditingComponentWrapper,
|
|
906
|
+
{
|
|
907
|
+
key: `${slotName}-${componentIndex}-wrapper`,
|
|
908
|
+
isPlaceholder: false,
|
|
909
|
+
parentComponent: parent,
|
|
910
|
+
component,
|
|
911
|
+
slotName,
|
|
912
|
+
indexInSlot: componentIndex,
|
|
913
|
+
slotChildrenCount: components.length,
|
|
914
|
+
isReadOnly: "false"
|
|
915
|
+
},
|
|
916
|
+
elements
|
|
917
|
+
);
|
|
918
|
+
} else {
|
|
919
|
+
const elements = [element];
|
|
920
|
+
if (tagElement) {
|
|
921
|
+
elements.push(tagElement);
|
|
922
|
+
}
|
|
923
|
+
childNode = elements;
|
|
924
|
+
}
|
|
925
|
+
return (0, import_react6.createElement)(
|
|
926
|
+
import_react6.Fragment,
|
|
927
|
+
{
|
|
928
|
+
key: !isRoot ? `${slotName}-${componentIndex}` : void 0
|
|
929
|
+
},
|
|
930
|
+
childNode
|
|
931
|
+
);
|
|
932
|
+
});
|
|
933
|
+
return resolved;
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
// src/components/UniformContext.tsx
|
|
937
|
+
var import_canvas_next_rsc_client5 = require("@uniformdev/canvas-next-rsc-client");
|
|
938
|
+
var import_react7 = require("react");
|
|
939
|
+
var import_react8 = __toESM(require("react"));
|
|
940
|
+
var UniformContext = async ({
|
|
941
|
+
clientContextComponent,
|
|
942
|
+
children
|
|
943
|
+
}) => {
|
|
944
|
+
const manifest = await getManifest({
|
|
945
|
+
searchParams: {}
|
|
946
|
+
});
|
|
947
|
+
const ContextComponent = clientContextComponent || import_canvas_next_rsc_client5.DefaultUniformClientContext;
|
|
948
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, children, /* @__PURE__ */ import_react8.default.createElement(ContextComponent, { manifest }), /* @__PURE__ */ import_react8.default.createElement(import_react7.Suspense, { fallback: /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null) }, /* @__PURE__ */ import_react8.default.createElement(import_canvas_next_rsc_client5.UniformScript, null)));
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
// src/components/UniformPlayground.tsx
|
|
952
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
953
|
+
var import_navigation2 = require("next/navigation");
|
|
954
|
+
var import_react9 = __toESM(require("react"));
|
|
955
|
+
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
956
|
+
if (!isDraftModeEnabled({ searchParams })) {
|
|
957
|
+
return /* @__PURE__ */ import_react9.default.createElement("div", null, /* @__PURE__ */ import_react9.default.createElement("h1", null, "Playground is only available in draft mode"));
|
|
958
|
+
}
|
|
959
|
+
const id = searchParams["id"];
|
|
960
|
+
if (!id) {
|
|
961
|
+
(0, import_navigation2.notFound)();
|
|
962
|
+
}
|
|
963
|
+
const canvasClient = getCanvasClient({
|
|
964
|
+
cache: {
|
|
965
|
+
type: "no-cache"
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
const possibleStates = [import_canvas8.CANVAS_EDITOR_STATE, import_canvas8.CANVAS_DRAFT_STATE];
|
|
969
|
+
let composition = void 0;
|
|
970
|
+
for (let i = 0; i < possibleStates.length; i++) {
|
|
971
|
+
const state = possibleStates[i];
|
|
972
|
+
try {
|
|
973
|
+
composition = await canvasClient.getCompositionById({
|
|
974
|
+
compositionId: id,
|
|
975
|
+
state,
|
|
976
|
+
withComponentIDs: true
|
|
977
|
+
});
|
|
978
|
+
} catch (e) {
|
|
979
|
+
console.warn(`Failed to get composition ${id} with state ${state}`, e);
|
|
980
|
+
}
|
|
981
|
+
if (composition) {
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (!composition) {
|
|
986
|
+
(0, import_navigation2.notFound)();
|
|
987
|
+
}
|
|
988
|
+
return /* @__PURE__ */ import_react9.default.createElement(UniformComposition, { mode: "server", params: {}, composition, ...rest });
|
|
989
|
+
};
|
|
990
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
991
|
+
0 && (module.exports = {
|
|
992
|
+
ContextUpdateTransfer,
|
|
993
|
+
UniformComposition,
|
|
994
|
+
UniformContext,
|
|
995
|
+
UniformPlayground,
|
|
996
|
+
createServerUniformContext,
|
|
997
|
+
createStaticParams,
|
|
998
|
+
generateStaticParams,
|
|
999
|
+
getCanvasClient,
|
|
1000
|
+
getDefaultCanvasClient,
|
|
1001
|
+
getDefaultManifestClient,
|
|
1002
|
+
getDefaultProjectMapClient,
|
|
1003
|
+
getDefaultRouteClient,
|
|
1004
|
+
getManifest,
|
|
1005
|
+
getManifestClient,
|
|
1006
|
+
getProjectMapClient,
|
|
1007
|
+
getRouteClient,
|
|
1008
|
+
isDevelopmentEnvironment,
|
|
1009
|
+
isDraftModeEnabled,
|
|
1010
|
+
isIncontextEditingEnabled,
|
|
1011
|
+
isOnVercelPreviewEnvironment,
|
|
1012
|
+
resolveComposition
|
|
1013
|
+
});
|