@uniformdev/canvas-next 19.9.2-alpha.3 → 19.10.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/{chunk-TR7V6ABJ.mjs → chunk-2MI7UYW7.mjs} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/project-map/index.d.ts +41 -11
- package/dist/project-map/index.js +16 -27
- package/dist/project-map/index.mjs +142 -8
- package/dist/route/index.d.ts +157 -285
- package/dist/route/index.js +139 -333
- package/dist/route/index.mjs +142 -190
- package/dist/slug/index.d.ts +4 -8
- package/dist/slug/index.js +15 -26
- package/dist/slug/index.mjs +17 -30
- package/package.json +7 -7
- package/dist/chunk-ZOXJSPVQ.mjs +0 -165
- package/dist/withUniformGetStaticPaths-6a31a8f8.d.ts +0 -38
package/dist/route/index.js
CHANGED
|
@@ -30,379 +30,185 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/route/index.ts
|
|
31
31
|
var route_exports = {};
|
|
32
32
|
__export(route_exports, {
|
|
33
|
-
getStaticPaths: () => getStaticPaths2,
|
|
34
33
|
unstable_getServerSideProps: () => unstable_getServerSideProps,
|
|
35
|
-
|
|
36
|
-
unstable_withUniformGetServerSideProps: () => unstable_withUniformGetServerSideProps
|
|
37
|
-
unstable_withUniformGetStaticProps: () => unstable_withUniformGetStaticProps,
|
|
38
|
-
withUniformGetStaticPaths: () => withUniformGetStaticPaths
|
|
34
|
+
unstable_logIssues: () => unstable_logIssues,
|
|
35
|
+
unstable_withUniformGetServerSideProps: () => unstable_withUniformGetServerSideProps
|
|
39
36
|
});
|
|
40
37
|
module.exports = __toCommonJS(route_exports);
|
|
41
38
|
|
|
42
|
-
// src/
|
|
39
|
+
// src/route/withUniformGetServerSideProps.ts
|
|
43
40
|
var import_canvas = require("@uniformdev/canvas");
|
|
44
|
-
var
|
|
45
|
-
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
46
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
47
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
48
|
-
apiHost: process.env.UNIFORM_CLI_BASE_URL,
|
|
49
|
-
edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
|
|
50
|
-
});
|
|
51
|
-
return async function wrappedGetServerSideProps(context) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
54
|
-
const { preview, previewData } = context;
|
|
55
|
-
let composition = void 0;
|
|
56
|
-
let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
|
|
57
|
-
if (options == null ? void 0 : options.modifyPath) {
|
|
58
|
-
nodePath = options.modifyPath(nodePath, context);
|
|
59
|
-
}
|
|
60
|
-
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
61
|
-
composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b = previewData.compositionId) != null ? _b : import_canvas.EMPTY_COMPOSITION._id };
|
|
62
|
-
} else {
|
|
63
|
-
try {
|
|
64
|
-
const time = Date.now();
|
|
65
|
-
const response = await canvasClient.getCompositionByNodePath({
|
|
66
|
-
...options == null ? void 0 : options.requestOptions,
|
|
67
|
-
projectMapId,
|
|
68
|
-
projectMapNodePath: nodePath,
|
|
69
|
-
state: preview || (options == null ? void 0 : options.preview) ? import_canvas.CANVAS_DRAFT_STATE : import_canvas.CANVAS_PUBLISHED_STATE
|
|
70
|
-
});
|
|
71
|
-
const duration = Date.now() - time;
|
|
72
|
-
composition = response.composition;
|
|
73
|
-
if (!(options == null ? void 0 : options.silent)) {
|
|
74
|
-
(0, import_canvas.logCompositionResponse)(response, duration);
|
|
75
|
-
}
|
|
76
|
-
} catch (e) {
|
|
77
|
-
console.error("[canvas-next] Failed to fetch composition", e);
|
|
78
|
-
return {
|
|
79
|
-
notFound: true
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
|
|
84
|
-
if (Object.hasOwn(ret, "props")) {
|
|
85
|
-
const casted = ret;
|
|
86
|
-
casted.props["data"] = composition;
|
|
87
|
-
}
|
|
88
|
-
return ret;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
41
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
91
42
|
|
|
92
|
-
// src/
|
|
93
|
-
var
|
|
94
|
-
var import_project_map = require("@uniformdev/project-map");
|
|
95
|
-
var withUniformGetStaticPaths = (options) => {
|
|
96
|
-
return async function wrappedGetStaticPaths() {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
const projectMapId = (_a = options == null ? void 0 : options.projectMapId) != null ? _a : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
99
|
-
const projectMapClient = (_b = options == null ? void 0 : options.client) != null ? _b : new import_project_map.ProjectMapClient({
|
|
100
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
101
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
102
|
-
apiHost: process.env.UNIFORM_CLI_BASE_URL
|
|
103
|
-
});
|
|
104
|
-
const response = await projectMapClient.getNodes({
|
|
105
|
-
...options == null ? void 0 : options.requestOptions,
|
|
106
|
-
path: options == null ? void 0 : options.rootPath,
|
|
107
|
-
projectMapId,
|
|
108
|
-
state: (options == null ? void 0 : options.preview) ? import_canvas2.CANVAS_DRAFT_STATE : import_canvas2.CANVAS_PUBLISHED_STATE
|
|
109
|
-
});
|
|
110
|
-
const nodes = (options == null ? void 0 : options.callback) ? await options.callback(response.nodes) : response.nodes;
|
|
111
|
-
const paths = nodes == null ? void 0 : nodes.filter((node) => Boolean(node.compositionId)).map((node) => {
|
|
112
|
-
var _a2;
|
|
113
|
-
return `${(_a2 = options == null ? void 0 : options.prefix) != null ? _a2 : ""}${node.path}`;
|
|
114
|
-
});
|
|
115
|
-
return {
|
|
116
|
-
paths,
|
|
117
|
-
fallback: true
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
};
|
|
43
|
+
// src/route/defaultHandleComposition.ts
|
|
44
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
121
45
|
|
|
122
|
-
// src/
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
46
|
+
// src/route/logIssues.ts
|
|
47
|
+
var import_chalk = __toESM(require("chalk"));
|
|
48
|
+
function unstable_logIssues(prefix, issues, colour) {
|
|
49
|
+
colour = colour != null ? colour : "red";
|
|
50
|
+
const reversedIssues = [...issues].reverse();
|
|
51
|
+
console.error(
|
|
52
|
+
`${import_chalk.default[colour](prefix)}
|
|
53
|
+
${reversedIssues.map(
|
|
54
|
+
(issue) => `${import_chalk.default[colour](">")} ${import_chalk.default.italic.gray(indent(issue.type.toUpperCase(), 7))} ${renderIssue(
|
|
55
|
+
issue
|
|
56
|
+
)}`
|
|
57
|
+
).join("\n")}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function renderIssue(issue) {
|
|
137
61
|
var _a;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
62
|
+
let path;
|
|
63
|
+
let type;
|
|
64
|
+
let message = issue.message;
|
|
65
|
+
let detail;
|
|
66
|
+
if (issue.type !== "config") {
|
|
67
|
+
path = issue.componentPath;
|
|
68
|
+
type = issue.componentType;
|
|
69
|
+
message = issue.message;
|
|
70
|
+
}
|
|
71
|
+
if (issue.type === "binding") {
|
|
72
|
+
detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
|
|
73
|
+
} else if (issue.type === "data") {
|
|
74
|
+
detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
|
|
75
|
+
}
|
|
76
|
+
if (issue.type === "input") {
|
|
77
|
+
detail = issue.inputName;
|
|
78
|
+
}
|
|
79
|
+
let result = `${import_chalk.default.white(blockify(message))}`;
|
|
80
|
+
if (detail) {
|
|
81
|
+
result += `
|
|
82
|
+
${indent(" ", 10)}${import_chalk.default.gray(`${detail}`)}`;
|
|
83
|
+
}
|
|
84
|
+
if (path && type) {
|
|
85
|
+
result += `
|
|
86
|
+
${indent(" ", 10)}${import_chalk.default.gray(`Occurred on component ${type} at slot path ${path}`)}`;
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
function indent(str, len) {
|
|
91
|
+
const indent2 = len != null ? len : 10;
|
|
92
|
+
return str.padStart(indent2);
|
|
93
|
+
}
|
|
94
|
+
function blockify(str, len) {
|
|
95
|
+
const indentSize = len != null ? len : 10;
|
|
96
|
+
return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/route/defaultHandleComposition.ts
|
|
100
|
+
function defaultHandleComposition(matched) {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
const resErrors = (_a = matched.compositionApiResponse.errors) != null ? _a : [];
|
|
103
|
+
const resWarnings = (_b = matched.compositionApiResponse.warnings) != null ? _b : [];
|
|
104
|
+
const colour = resErrors.length > 0 ? "red" : resWarnings.length > 0 ? "yellow" : "green";
|
|
105
|
+
console.log(`[canvas-next] ${import_chalk2.default[colour]("matched")} ${matched.matchedRoute}`, matched.type);
|
|
106
|
+
if (matched.dynamicInputs) {
|
|
107
|
+
const entries = Object.entries(matched.dynamicInputs);
|
|
108
|
+
if (entries.length > 0) {
|
|
109
|
+
console.log(
|
|
110
|
+
` ${import_chalk2.default.gray("Matched dynamic inputs:\n ")}`,
|
|
111
|
+
entries.map(([k, v]) => `${k}: ${v}`).join("\n ")
|
|
112
|
+
);
|
|
178
113
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
114
|
+
}
|
|
115
|
+
if (resErrors.length > 0) {
|
|
116
|
+
unstable_logIssues(
|
|
117
|
+
`[canvas-next] ${matched.matchedRoute} composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
|
|
118
|
+
resErrors,
|
|
119
|
+
"red"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
if (resWarnings.length > 0) {
|
|
123
|
+
unstable_logIssues(
|
|
124
|
+
`[canvas-next] ${matched.matchedRoute} composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
|
|
125
|
+
resWarnings,
|
|
126
|
+
"yellow"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (matched.compositionApiResponse.diagnostics) {
|
|
130
|
+
console.log(`[canvas-next] ${import_chalk2.default.green("Route diagnostics are enabled. Diagnostic data:")}`);
|
|
131
|
+
console.log(JSON.stringify(matched.compositionApiResponse.diagnostics, null, 2));
|
|
132
|
+
}
|
|
133
|
+
return matched.compositionApiResponse.composition;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/route/defaultHandleRedirect.ts
|
|
137
|
+
var import_redirect = require("@uniformdev/redirect");
|
|
138
|
+
function defaultHandleRedirect(matched, requestUrl) {
|
|
139
|
+
return {
|
|
140
|
+
redirect: {
|
|
141
|
+
destination: import_redirect.RedirectClient.getTargetVariableExpandedUrl(requestUrl, matched.redirect),
|
|
142
|
+
statusCode: matched.redirect.targetStatusCode
|
|
183
143
|
}
|
|
184
|
-
return ret;
|
|
185
144
|
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// src/project-map/index.ts
|
|
189
|
-
var getServerSideProps = withUniformGetServerSideProps();
|
|
190
|
-
var getStaticProps = withUniformGetStaticProps({ param: "path" });
|
|
191
|
-
var getStaticPaths = withUniformGetStaticPaths();
|
|
145
|
+
}
|
|
192
146
|
|
|
193
147
|
// src/route/withUniformGetServerSideProps.ts
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
prefix,
|
|
212
|
-
requestOptions,
|
|
213
|
-
silent,
|
|
214
|
-
parseContext
|
|
215
|
-
} = options;
|
|
216
|
-
const routeClient = client || new import_canvas4.unstable_RouteClient({
|
|
217
|
-
apiKey: process.env.UNIFORM_API_KEY,
|
|
218
|
-
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
219
|
-
edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
|
|
220
|
-
});
|
|
221
|
-
const handleModifyPath = modifyPath != null ? modifyPath : (path) => decodeURI(path);
|
|
222
|
-
return async function fetcher(context) {
|
|
223
|
-
const { contextualEditingCompositionId, resolvedUrl } = parseContext(context);
|
|
224
|
-
let nodePath = prefix ? resolvedUrl.replace(new RegExp(`^${prefix}`), "") : resolvedUrl;
|
|
148
|
+
var unstable_withUniformGetServerSideProps = (options) => {
|
|
149
|
+
var _a, _b, _c, _d;
|
|
150
|
+
const handleNotFound = (_a = options == null ? void 0 : options.handleNotFound) != null ? _a : () => ({ notFound: true });
|
|
151
|
+
const handleComposition = (_b = options == null ? void 0 : options.handleComposition) != null ? _b : defaultHandleComposition;
|
|
152
|
+
const handleRedirect = (_c = options == null ? void 0 : options.handleRedirect) != null ? _c : defaultHandleRedirect;
|
|
153
|
+
const handleModifyPath = (_d = options == null ? void 0 : options.modifyPath) != null ? _d : (path) => decodeURI(path);
|
|
154
|
+
return async function wrappedGetServerSideProps(context) {
|
|
155
|
+
var _a2, _b2;
|
|
156
|
+
const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
|
|
157
|
+
const routeClient = (options == null ? void 0 : options.client) || new import_canvas.unstable_RouteClient({
|
|
158
|
+
apiKey: process.env.UNIFORM_API_KEY,
|
|
159
|
+
projectId: process.env.UNIFORM_PROJECT_ID,
|
|
160
|
+
edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
|
|
161
|
+
});
|
|
162
|
+
const { previewData } = context;
|
|
163
|
+
let composition = void 0;
|
|
164
|
+
let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
|
|
225
165
|
nodePath = handleModifyPath(nodePath, context);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
redirect,
|
|
229
|
-
context,
|
|
230
|
-
(response) => defaultHandleRedirect(
|
|
231
|
-
nodePath,
|
|
232
|
-
response,
|
|
233
|
-
context,
|
|
234
|
-
() => {
|
|
235
|
-
throw new Error();
|
|
236
|
-
},
|
|
237
|
-
duration
|
|
238
|
-
),
|
|
239
|
-
duration
|
|
240
|
-
);
|
|
241
|
-
const invokeNotFoundResult = (response, duration) => (handleNotFound != null ? handleNotFound : defaultHandleNotFound)(
|
|
242
|
-
response,
|
|
243
|
-
context,
|
|
244
|
-
(response2) => defaultHandleNotFound(
|
|
245
|
-
response2,
|
|
246
|
-
context,
|
|
247
|
-
() => {
|
|
248
|
-
throw new Error();
|
|
249
|
-
},
|
|
250
|
-
duration
|
|
251
|
-
),
|
|
252
|
-
duration
|
|
253
|
-
);
|
|
254
|
-
const invokeCompositionResult = (response, duration) => (handleComposition != null ? handleComposition : defaultHandleComposition)(
|
|
255
|
-
response,
|
|
256
|
-
context,
|
|
257
|
-
(response2) => defaultHandleComposition(
|
|
258
|
-
response2,
|
|
259
|
-
context,
|
|
260
|
-
() => {
|
|
261
|
-
throw new Error();
|
|
262
|
-
},
|
|
263
|
-
duration
|
|
264
|
-
),
|
|
265
|
-
duration
|
|
266
|
-
);
|
|
267
|
-
if (contextualEditingCompositionId) {
|
|
268
|
-
const previewEmptyComposition = await invokeCompositionResult(
|
|
269
|
-
{
|
|
270
|
-
type: "composition",
|
|
271
|
-
matchedRoute: "contextual-editing",
|
|
272
|
-
compositionApiResponse: {
|
|
273
|
-
composition: {
|
|
274
|
-
...import_canvas4.EMPTY_COMPOSITION,
|
|
275
|
-
_id: contextualEditingCompositionId != null ? contextualEditingCompositionId : import_canvas4.EMPTY_COMPOSITION._id
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
0
|
|
280
|
-
);
|
|
281
|
-
return previewEmptyComposition;
|
|
166
|
+
if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
|
|
167
|
+
composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b2 = previewData.compositionId) != null ? _b2 : import_canvas.EMPTY_COMPOSITION._id };
|
|
282
168
|
} else {
|
|
283
169
|
try {
|
|
284
|
-
console.log("
|
|
285
|
-
const time = Date.now();
|
|
170
|
+
console.log("[canvas-next] get route", nodePath);
|
|
286
171
|
const response = await routeClient.getRoute({
|
|
287
|
-
...requestOptions,
|
|
172
|
+
...options == null ? void 0 : options.requestOptions,
|
|
288
173
|
projectMapId,
|
|
289
174
|
path: nodePath
|
|
290
175
|
});
|
|
291
|
-
const duration = Date.now() - time;
|
|
292
|
-
if (!silent) {
|
|
293
|
-
(0, import_canvas4.logRouteResponse)(response, duration);
|
|
294
|
-
}
|
|
295
176
|
if (response.type === "redirect") {
|
|
296
|
-
return
|
|
177
|
+
return handleRedirect(response, nodePath, context, defaultHandleRedirect);
|
|
297
178
|
}
|
|
298
179
|
if (response.type === "notFound") {
|
|
299
|
-
return
|
|
180
|
+
return handleNotFound(response, context);
|
|
300
181
|
}
|
|
301
|
-
const handleResult =
|
|
182
|
+
const handleResult = handleComposition(response, context, defaultHandleComposition);
|
|
302
183
|
if (!handleResult) {
|
|
303
|
-
return
|
|
184
|
+
return { notFound: true };
|
|
304
185
|
}
|
|
305
|
-
|
|
186
|
+
composition = handleResult;
|
|
306
187
|
} catch (e) {
|
|
307
|
-
console.error(red("Failed to fetch
|
|
308
|
-
if (e instanceof
|
|
188
|
+
console.error(import_chalk3.default.red("[canvas-next] Failed to fetch composition"), e);
|
|
189
|
+
if (e instanceof import_canvas.ApiClientError) {
|
|
309
190
|
if (e.statusCode === 404) {
|
|
310
|
-
return
|
|
191
|
+
return { notFound: true };
|
|
311
192
|
}
|
|
312
|
-
throw new Error(`Failed to fetch
|
|
193
|
+
throw new Error(`Failed to fetch composition. See server logs for details.`);
|
|
313
194
|
}
|
|
314
195
|
throw e;
|
|
315
196
|
}
|
|
316
197
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var unstable_withUniformGetServerSideProps = (options) => {
|
|
322
|
-
const defaultHandleRedirect = (requestUrl, matched) => {
|
|
323
|
-
return {
|
|
324
|
-
redirect: {
|
|
325
|
-
destination: import_redirect.RedirectClient.getTargetVariableExpandedUrl(requestUrl, matched.redirect),
|
|
326
|
-
statusCode: matched.redirect.targetStatusCode
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
const defaultHandleNotFound = () => ({
|
|
331
|
-
notFound: true
|
|
332
|
-
});
|
|
333
|
-
const defaultHandleComposition = async (matched) => {
|
|
334
|
-
return {
|
|
335
|
-
props: {
|
|
336
|
-
data: matched.compositionApiResponse.composition
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
};
|
|
340
|
-
const routeFetcher = createRouteFetcher({
|
|
341
|
-
...options,
|
|
342
|
-
defaultHandleComposition,
|
|
343
|
-
defaultHandleNotFound,
|
|
344
|
-
defaultHandleRedirect,
|
|
345
|
-
parseContext(context) {
|
|
346
|
-
var _a;
|
|
347
|
-
return {
|
|
348
|
-
contextualEditingCompositionId: (_a = context.previewData) == null ? void 0 : _a.compositionId,
|
|
349
|
-
resolvedUrl: context.resolvedUrl
|
|
350
|
-
};
|
|
198
|
+
const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
|
|
199
|
+
if (Object.hasOwn(ret, "props")) {
|
|
200
|
+
const casted = ret;
|
|
201
|
+
casted.props["data"] = composition;
|
|
351
202
|
}
|
|
352
|
-
|
|
353
|
-
return routeFetcher;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
// src/route/withUniformGetStaticProps.ts
|
|
357
|
-
var import_redirect2 = require("@uniformdev/redirect");
|
|
358
|
-
var unstable_withUniformGetStaticProps = (options) => {
|
|
359
|
-
const defaultHandleRedirect = (requestUrl, matched) => {
|
|
360
|
-
return {
|
|
361
|
-
redirect: {
|
|
362
|
-
destination: import_redirect2.RedirectClient.getTargetVariableExpandedUrl(requestUrl, matched.redirect),
|
|
363
|
-
statusCode: matched.redirect.targetStatusCode
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
};
|
|
367
|
-
const defaultHandleNotFound = () => ({
|
|
368
|
-
notFound: true
|
|
369
|
-
});
|
|
370
|
-
const defaultHandleComposition = async (matched) => {
|
|
371
|
-
return {
|
|
372
|
-
props: {
|
|
373
|
-
data: matched.compositionApiResponse.composition
|
|
374
|
-
}
|
|
375
|
-
};
|
|
203
|
+
return ret;
|
|
376
204
|
};
|
|
377
|
-
const routeFetcher = createRouteFetcher({
|
|
378
|
-
...options,
|
|
379
|
-
defaultHandleComposition,
|
|
380
|
-
defaultHandleNotFound,
|
|
381
|
-
defaultHandleRedirect,
|
|
382
|
-
parseContext(context) {
|
|
383
|
-
var _a, _b;
|
|
384
|
-
return {
|
|
385
|
-
contextualEditingCompositionId: (_a = context.previewData) == null ? void 0 : _a.compositionId,
|
|
386
|
-
resolvedUrl: resolveSlugFromParams({
|
|
387
|
-
params: context.params,
|
|
388
|
-
param: (_b = options == null ? void 0 : options.param) != null ? _b : "route"
|
|
389
|
-
})
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
return routeFetcher;
|
|
394
205
|
};
|
|
395
206
|
|
|
396
207
|
// src/route/index.ts
|
|
397
208
|
var unstable_getServerSideProps = unstable_withUniformGetServerSideProps();
|
|
398
|
-
var unstable_getStaticProps = unstable_withUniformGetStaticProps();
|
|
399
|
-
var getStaticPaths2 = withUniformGetStaticPaths();
|
|
400
209
|
// Annotate the CommonJS export names for ESM import in node:
|
|
401
210
|
0 && (module.exports = {
|
|
402
|
-
getStaticPaths,
|
|
403
211
|
unstable_getServerSideProps,
|
|
404
|
-
|
|
405
|
-
unstable_withUniformGetServerSideProps
|
|
406
|
-
unstable_withUniformGetStaticProps,
|
|
407
|
-
withUniformGetStaticPaths
|
|
212
|
+
unstable_logIssues,
|
|
213
|
+
unstable_withUniformGetServerSideProps
|
|
408
214
|
});
|