@uniformdev/canvas-next 19.1.1-alpha.1 → 19.2.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.
@@ -0,0 +1,170 @@
1
+ import * as next from 'next';
2
+ import { GetServerSidePropsContext, PreviewData, GetServerSidePropsResult, GetServerSideProps } from 'next';
3
+ import { c as UniformGetServerSideProps, a as UniformPreviewData } from '../models-092c0912.js';
4
+ import * as querystring from 'querystring';
5
+ import { ParsedUrlQuery } from 'querystring';
6
+ import { RouteGetResponseEdgehancedComposition, unstable_RouteClient, RouteGetParameters, RootComponentInstance, RouteGetResponseRedirect, RouteGetResponseNotFound, CompositionIssue } from '@uniformdev/canvas';
7
+ import { ForegroundColorName } from 'chalk';
8
+ import '@uniformdev/canvas-react';
9
+
10
+ declare function defaultHandleComposition(matched: RouteGetResponseEdgehancedComposition): {
11
+ type: string;
12
+ parameters?: {
13
+ [key: string]: {
14
+ value: unknown;
15
+ type: string;
16
+ connectedData?: {
17
+ pointer: string;
18
+ syntax: "jptr";
19
+ } | undefined;
20
+ };
21
+ } | undefined;
22
+ variant?: string | undefined;
23
+ projectMapNodes?: {
24
+ id: string;
25
+ path: string;
26
+ projectMapId: string;
27
+ }[] | undefined;
28
+ slots?: {
29
+ [key: string]: {
30
+ type: string;
31
+ parameters?: {
32
+ [key: string]: {
33
+ value: unknown;
34
+ type: string;
35
+ connectedData?: {
36
+ pointer: string;
37
+ syntax: "jptr";
38
+ } | undefined;
39
+ };
40
+ } | undefined;
41
+ variant?: string | undefined;
42
+ slots?: {
43
+ [key: string]: any[];
44
+ } | undefined;
45
+ _id?: string | undefined;
46
+ _pattern?: string | undefined;
47
+ _dataResources?: {
48
+ [key: string]: {
49
+ type: string;
50
+ isPatternParameter?: boolean | undefined;
51
+ ignorePatternParameterDefault?: boolean | undefined;
52
+ variables?: {
53
+ [key: string]: string;
54
+ } | undefined;
55
+ };
56
+ } | undefined;
57
+ _patternDataResources?: {
58
+ [key: string]: {
59
+ type: string;
60
+ isPatternParameter?: boolean | undefined;
61
+ ignorePatternParameterDefault?: boolean | undefined;
62
+ variables?: {
63
+ [key: string]: string;
64
+ } | undefined;
65
+ };
66
+ } | undefined;
67
+ _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
68
+ _overrides?: {
69
+ [key: string]: {
70
+ parameters?: {
71
+ [key: string]: {
72
+ value: unknown;
73
+ type: string;
74
+ connectedData?: {
75
+ pointer: string;
76
+ syntax: "jptr";
77
+ } | undefined;
78
+ };
79
+ } | undefined;
80
+ variant?: string | undefined;
81
+ };
82
+ } | undefined;
83
+ _overridability?: {
84
+ parameters?: {
85
+ [key: string]: "yes" | "no";
86
+ } | undefined;
87
+ variants?: boolean | undefined;
88
+ } | undefined;
89
+ }[];
90
+ } | undefined;
91
+ _id: string;
92
+ _slug?: string | null | undefined;
93
+ _name: string;
94
+ _dataResources?: {
95
+ [key: string]: {
96
+ type: string;
97
+ isPatternParameter?: boolean | undefined;
98
+ ignorePatternParameterDefault?: boolean | undefined;
99
+ variables?: {
100
+ [key: string]: string;
101
+ } | undefined;
102
+ };
103
+ } | undefined;
104
+ _overrides?: {
105
+ [key: string]: {
106
+ parameters?: {
107
+ [key: string]: {
108
+ value: unknown;
109
+ type: string;
110
+ connectedData?: {
111
+ pointer: string;
112
+ syntax: "jptr";
113
+ } | undefined;
114
+ };
115
+ } | undefined;
116
+ variant?: string | undefined;
117
+ };
118
+ } | undefined;
119
+ _overridability?: {
120
+ parameters?: {
121
+ [key: string]: "yes" | "no";
122
+ } | undefined;
123
+ variants?: boolean | undefined;
124
+ } | undefined;
125
+ };
126
+
127
+ /**
128
+ * Creates an implementation of `getServerSideProps` using the Uniform Route API.
129
+ * Static and dynamic routing as well as redirection is automatically supported.
130
+ * Custom behavior can be added by passing in options to hook to specific processing events.
131
+ * @deprecated - this is experimental functionality that is subject to change without notice.
132
+ */
133
+ declare const unstable_withUniformGetServerSideProps: <TProps extends {
134
+ [key: string]: any;
135
+ } = {
136
+ [key: string]: any;
137
+ }>(options?: {
138
+ /** If you need to override the default client, you can pass it here */
139
+ client?: unstable_RouteClient | undefined;
140
+ /** A string that you want to strip from the resolved context.resolvedUrl. Useful when calling from a nested folder which is not part of your project map structure */
141
+ prefix?: string | undefined;
142
+ /** Useful when you need to modify the path passed to the API */
143
+ modifyPath?: ((path: string, context: GetServerSidePropsContext<ParsedUrlQuery, PreviewData>) => string) | undefined;
144
+ /** The project map ID to connect to. If not set, the default project map will be used. */
145
+ projectMapId?: string | undefined;
146
+ /** Way to override getRoute request params */
147
+ requestOptions?: Partial<RouteGetParameters> | undefined;
148
+ /**
149
+ * Custom handler to override resultant props.
150
+ * NOTE: not called for not found or redirect responses, only for valid-composition responses.
151
+ */
152
+ callback?: UniformGetServerSideProps<TProps> | undefined;
153
+ /** Override handling of a composition route response. Return null to signal not found. */
154
+ handleComposition?: ((composition: RouteGetResponseEdgehancedComposition, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>, defaultHandler: typeof defaultHandleComposition) => RootComponentInstance | null) | undefined;
155
+ /** Override default handling of a redirect route response */
156
+ handleRedirect?: ((redirect: RouteGetResponseRedirect, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>) => GetServerSidePropsResult<never>) | undefined;
157
+ /**
158
+ * Override default handling of a not found route response
159
+ * NOTE: not called when the API returns a 404 error (project map not found), only when the route result is not found
160
+ */
161
+ handleNotFound?: ((result: RouteGetResponseNotFound, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>) => GetServerSidePropsResult<never>) | undefined;
162
+ } | undefined) => GetServerSideProps<TProps, ParsedUrlQuery, UniformPreviewData>;
163
+
164
+ declare function unstable_logIssues(prefix: string, issues: CompositionIssue[], colour: ForegroundColorName): void;
165
+
166
+ declare const unstable_getServerSideProps: next.GetServerSideProps<{
167
+ [key: string]: any;
168
+ }, querystring.ParsedUrlQuery, UniformPreviewData>;
169
+
170
+ export { unstable_getServerSideProps, unstable_logIssues, unstable_withUniformGetServerSideProps };
@@ -0,0 +1,205 @@
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/route/index.ts
31
+ var route_exports = {};
32
+ __export(route_exports, {
33
+ unstable_getServerSideProps: () => unstable_getServerSideProps,
34
+ unstable_logIssues: () => unstable_logIssues,
35
+ unstable_withUniformGetServerSideProps: () => unstable_withUniformGetServerSideProps
36
+ });
37
+ module.exports = __toCommonJS(route_exports);
38
+
39
+ // src/route/withUniformGetServerSideProps.ts
40
+ var import_canvas = require("@uniformdev/canvas");
41
+ var import_chalk3 = __toESM(require("chalk"));
42
+
43
+ // src/route/defaultHandleComposition.ts
44
+ var import_chalk2 = __toESM(require("chalk"));
45
+
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) {
61
+ var _a;
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
+ );
113
+ }
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/withUniformGetServerSideProps.ts
137
+ var unstable_withUniformGetServerSideProps = (options) => {
138
+ var _a, _b, _c, _d;
139
+ const handleRedirect = (_a = options == null ? void 0 : options.handleRedirect) != null ? _a : () => {
140
+ throw new Error(`Redirects are not yet implemented by default. Please override handleRedirect option.`);
141
+ };
142
+ const handleNotFound = (_b = options == null ? void 0 : options.handleNotFound) != null ? _b : () => ({ notFound: true });
143
+ const handleComposition = (_c = options == null ? void 0 : options.handleComposition) != null ? _c : defaultHandleComposition;
144
+ const handleModifyPath = (_d = options == null ? void 0 : options.modifyPath) != null ? _d : (path) => decodeURI(path);
145
+ return async function wrappedGetServerSideProps(context) {
146
+ var _a2, _b2;
147
+ const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
148
+ const routeClient = (options == null ? void 0 : options.client) || new import_canvas.unstable_RouteClient({
149
+ apiKey: process.env.UNIFORM_API_KEY,
150
+ projectId: process.env.UNIFORM_PROJECT_ID,
151
+ edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
152
+ });
153
+ const { previewData } = context;
154
+ let composition = void 0;
155
+ let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
156
+ nodePath = handleModifyPath(nodePath, context);
157
+ if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
158
+ composition = { ...import_canvas.EMPTY_COMPOSITION, _id: (_b2 = previewData.compositionId) != null ? _b2 : import_canvas.EMPTY_COMPOSITION._id };
159
+ } else {
160
+ try {
161
+ console.log("[canvas-next] get route", nodePath);
162
+ const response = await routeClient.getRoute({
163
+ ...options == null ? void 0 : options.requestOptions,
164
+ projectMapId,
165
+ path: nodePath
166
+ });
167
+ if (response.type === "redirect") {
168
+ return handleRedirect(response, context);
169
+ }
170
+ if (response.type === "notFound") {
171
+ return handleNotFound(response, context);
172
+ }
173
+ const handleResult = handleComposition(response, context, defaultHandleComposition);
174
+ if (!handleResult) {
175
+ return { notFound: true };
176
+ }
177
+ composition = handleResult;
178
+ } catch (e) {
179
+ console.error(import_chalk3.default.red("[canvas-next] Failed to fetch composition"), e);
180
+ if (e instanceof import_canvas.ApiClientError) {
181
+ if (e.statusCode === 404) {
182
+ return { notFound: true };
183
+ }
184
+ throw new Error(`Failed to fetch composition. See server logs for details.`);
185
+ }
186
+ throw e;
187
+ }
188
+ }
189
+ const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
190
+ if (Object.hasOwn(ret, "props")) {
191
+ const casted = ret;
192
+ casted.props["data"] = composition;
193
+ }
194
+ return ret;
195
+ };
196
+ };
197
+
198
+ // src/route/index.ts
199
+ var unstable_getServerSideProps = unstable_withUniformGetServerSideProps();
200
+ // Annotate the CommonJS export names for ESM import in node:
201
+ 0 && (module.exports = {
202
+ unstable_getServerSideProps,
203
+ unstable_logIssues,
204
+ unstable_withUniformGetServerSideProps
205
+ });
@@ -0,0 +1,170 @@
1
+ // src/route/withUniformGetServerSideProps.ts
2
+ import {
3
+ ApiClientError,
4
+ EMPTY_COMPOSITION,
5
+ unstable_RouteClient
6
+ } from "@uniformdev/canvas";
7
+ import chalk3 from "chalk";
8
+
9
+ // src/route/defaultHandleComposition.ts
10
+ import chalk2 from "chalk";
11
+
12
+ // src/route/logIssues.ts
13
+ import chalk from "chalk";
14
+ function unstable_logIssues(prefix, issues, colour) {
15
+ colour = colour != null ? colour : "red";
16
+ const reversedIssues = [...issues].reverse();
17
+ console.error(
18
+ `${chalk[colour](prefix)}
19
+ ${reversedIssues.map(
20
+ (issue) => `${chalk[colour](">")} ${chalk.italic.gray(indent(issue.type.toUpperCase(), 7))} ${renderIssue(
21
+ issue
22
+ )}`
23
+ ).join("\n")}`
24
+ );
25
+ }
26
+ function renderIssue(issue) {
27
+ var _a;
28
+ let path;
29
+ let type;
30
+ let message = issue.message;
31
+ let detail;
32
+ if (issue.type !== "config") {
33
+ path = issue.componentPath;
34
+ type = issue.componentType;
35
+ message = issue.message;
36
+ }
37
+ if (issue.type === "binding") {
38
+ detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
39
+ } else if (issue.type === "data") {
40
+ detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
41
+ }
42
+ if (issue.type === "input") {
43
+ detail = issue.inputName;
44
+ }
45
+ let result = `${chalk.white(blockify(message))}`;
46
+ if (detail) {
47
+ result += `
48
+ ${indent(" ", 10)}${chalk.gray(`${detail}`)}`;
49
+ }
50
+ if (path && type) {
51
+ result += `
52
+ ${indent(" ", 10)}${chalk.gray(`Occurred on component ${type} at slot path ${path}`)}`;
53
+ }
54
+ return result;
55
+ }
56
+ function indent(str, len) {
57
+ const indent2 = len != null ? len : 10;
58
+ return str.padStart(indent2);
59
+ }
60
+ function blockify(str, len) {
61
+ const indentSize = len != null ? len : 10;
62
+ return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
63
+ }
64
+
65
+ // src/route/defaultHandleComposition.ts
66
+ function defaultHandleComposition(matched) {
67
+ var _a, _b;
68
+ const resErrors = (_a = matched.compositionApiResponse.errors) != null ? _a : [];
69
+ const resWarnings = (_b = matched.compositionApiResponse.warnings) != null ? _b : [];
70
+ const colour = resErrors.length > 0 ? "red" : resWarnings.length > 0 ? "yellow" : "green";
71
+ console.log(`[canvas-next] ${chalk2[colour]("matched")} ${matched.matchedRoute}`, matched.type);
72
+ if (matched.dynamicInputs) {
73
+ const entries = Object.entries(matched.dynamicInputs);
74
+ if (entries.length > 0) {
75
+ console.log(
76
+ ` ${chalk2.gray("Matched dynamic inputs:\n ")}`,
77
+ entries.map(([k, v]) => `${k}: ${v}`).join("\n ")
78
+ );
79
+ }
80
+ }
81
+ if (resErrors.length > 0) {
82
+ unstable_logIssues(
83
+ `[canvas-next] ${matched.matchedRoute} composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
84
+ resErrors,
85
+ "red"
86
+ );
87
+ }
88
+ if (resWarnings.length > 0) {
89
+ unstable_logIssues(
90
+ `[canvas-next] ${matched.matchedRoute} composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
91
+ resWarnings,
92
+ "yellow"
93
+ );
94
+ }
95
+ if (matched.compositionApiResponse.diagnostics) {
96
+ console.log(`[canvas-next] ${chalk2.green("Route diagnostics are enabled. Diagnostic data:")}`);
97
+ console.log(JSON.stringify(matched.compositionApiResponse.diagnostics, null, 2));
98
+ }
99
+ return matched.compositionApiResponse.composition;
100
+ }
101
+
102
+ // src/route/withUniformGetServerSideProps.ts
103
+ var unstable_withUniformGetServerSideProps = (options) => {
104
+ var _a, _b, _c, _d;
105
+ const handleRedirect = (_a = options == null ? void 0 : options.handleRedirect) != null ? _a : () => {
106
+ throw new Error(`Redirects are not yet implemented by default. Please override handleRedirect option.`);
107
+ };
108
+ const handleNotFound = (_b = options == null ? void 0 : options.handleNotFound) != null ? _b : () => ({ notFound: true });
109
+ const handleComposition = (_c = options == null ? void 0 : options.handleComposition) != null ? _c : defaultHandleComposition;
110
+ const handleModifyPath = (_d = options == null ? void 0 : options.modifyPath) != null ? _d : (path) => decodeURI(path);
111
+ return async function wrappedGetServerSideProps(context) {
112
+ var _a2, _b2;
113
+ const projectMapId = (_a2 = options == null ? void 0 : options.projectMapId) != null ? _a2 : process.env.UNIFORM_PROJECT_MAP_ID;
114
+ const routeClient = (options == null ? void 0 : options.client) || new unstable_RouteClient({
115
+ apiKey: process.env.UNIFORM_API_KEY,
116
+ projectId: process.env.UNIFORM_PROJECT_ID,
117
+ edgeApiHost: process.env.UNIFORM_CLI_BASE_EDGE_URL
118
+ });
119
+ const { previewData } = context;
120
+ let composition = void 0;
121
+ let nodePath = (options == null ? void 0 : options.prefix) ? context.resolvedUrl.replace(new RegExp(`^${options.prefix}`), "") : context.resolvedUrl;
122
+ nodePath = handleModifyPath(nodePath, context);
123
+ if (previewData == null ? void 0 : previewData.isUniformContextualEditing) {
124
+ composition = { ...EMPTY_COMPOSITION, _id: (_b2 = previewData.compositionId) != null ? _b2 : EMPTY_COMPOSITION._id };
125
+ } else {
126
+ try {
127
+ console.log("[canvas-next] get route", nodePath);
128
+ const response = await routeClient.getRoute({
129
+ ...options == null ? void 0 : options.requestOptions,
130
+ projectMapId,
131
+ path: nodePath
132
+ });
133
+ if (response.type === "redirect") {
134
+ return handleRedirect(response, context);
135
+ }
136
+ if (response.type === "notFound") {
137
+ return handleNotFound(response, context);
138
+ }
139
+ const handleResult = handleComposition(response, context, defaultHandleComposition);
140
+ if (!handleResult) {
141
+ return { notFound: true };
142
+ }
143
+ composition = handleResult;
144
+ } catch (e) {
145
+ console.error(chalk3.red("[canvas-next] Failed to fetch composition"), e);
146
+ if (e instanceof ApiClientError) {
147
+ if (e.statusCode === 404) {
148
+ return { notFound: true };
149
+ }
150
+ throw new Error(`Failed to fetch composition. See server logs for details.`);
151
+ }
152
+ throw e;
153
+ }
154
+ }
155
+ const ret = (options == null ? void 0 : options.callback) ? await options.callback(context, composition) : { props: {} };
156
+ if (Object.hasOwn(ret, "props")) {
157
+ const casted = ret;
158
+ casted.props["data"] = composition;
159
+ }
160
+ return ret;
161
+ };
162
+ };
163
+
164
+ // src/route/index.ts
165
+ var unstable_getServerSideProps = unstable_withUniformGetServerSideProps();
166
+ export {
167
+ unstable_getServerSideProps,
168
+ unstable_logIssues,
169
+ unstable_withUniformGetServerSideProps
170
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "19.1.1-alpha.1+3ec68fe9d",
3
+ "version": "19.2.0",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -26,6 +26,13 @@
26
26
  "default": "./dist/project-map/index.esm.js"
27
27
  },
28
28
  "require": "./dist/project-map/index.js"
29
+ },
30
+ "./route": {
31
+ "import": {
32
+ "node": "./dist/route/index.mjs",
33
+ "default": "./dist/route/index.esm.js"
34
+ },
35
+ "require": "./dist/route/index.js"
29
36
  }
30
37
  },
31
38
  "types": "./dist/index.d.ts",
@@ -39,6 +46,9 @@
39
46
  ],
40
47
  "project-map": [
41
48
  "./dist/project-map/index.d.ts"
49
+ ],
50
+ "route": [
51
+ "./dist/route/index.d.ts"
42
52
  ]
43
53
  }
44
54
  },
@@ -53,9 +63,10 @@
53
63
  "document": "api-extractor run --local"
54
64
  },
55
65
  "dependencies": {
56
- "@uniformdev/canvas": "19.1.1-alpha.1+3ec68fe9d",
57
- "@uniformdev/canvas-react": "19.1.1-alpha.1+3ec68fe9d",
58
- "@uniformdev/project-map": "19.1.1-alpha.1+3ec68fe9d"
66
+ "@uniformdev/canvas": "19.2.0",
67
+ "@uniformdev/canvas-react": "19.2.0",
68
+ "@uniformdev/project-map": "19.2.0",
69
+ "chalk": "^5.2.0"
59
70
  },
60
71
  "peerDependencies": {
61
72
  "next": ">= 12.0.0",
@@ -63,7 +74,7 @@
63
74
  "react-dom": ">=16"
64
75
  },
65
76
  "devDependencies": {
66
- "@types/react": "18.0.37",
77
+ "@types/react": "18.0.38",
67
78
  "next": "13.3.0",
68
79
  "react": "18.2.0",
69
80
  "react-dom": "18.2.0"
@@ -74,5 +85,5 @@
74
85
  "publishConfig": {
75
86
  "access": "public"
76
87
  },
77
- "gitHead": "3ec68fe9d54c7128e57cc8a5c8116fe968f65865"
88
+ "gitHead": "9eb2423cd12a5db527f9f3a9d46b47ac2a0e7eb3"
78
89
  }