@uniformdev/canvas-next 19.8.0 → 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/route/index.d.ts +9 -2
- package/dist/route/index.js +15 -6
- package/dist/route/index.mjs +15 -6
- package/package.json +7 -6
package/dist/route/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GetServerSidePropsContext, PreviewData, GetServerSidePropsResult, GetSe
|
|
|
3
3
|
import { c as UniformGetServerSideProps, a as UniformPreviewData } from '../models-092c0912.js';
|
|
4
4
|
import * as querystring from 'querystring';
|
|
5
5
|
import { ParsedUrlQuery } from 'querystring';
|
|
6
|
-
import { RouteGetResponseEdgehancedComposition, unstable_RouteClient, RouteGetParameters, RootComponentInstance,
|
|
6
|
+
import { RouteGetResponseEdgehancedComposition, RouteGetResponseRedirect, unstable_RouteClient, RouteGetParameters, RootComponentInstance, RouteGetResponseNotFound, CompositionIssue } from '@uniformdev/canvas';
|
|
7
7
|
import { ForegroundColorName } from 'chalk';
|
|
8
8
|
import '@uniformdev/canvas-react';
|
|
9
9
|
|
|
@@ -124,6 +124,13 @@ declare function defaultHandleComposition(matched: RouteGetResponseEdgehancedCom
|
|
|
124
124
|
} | undefined;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
declare function defaultHandleRedirect(matched: RouteGetResponseRedirect, requestUrl: string): {
|
|
128
|
+
redirect: {
|
|
129
|
+
destination: string;
|
|
130
|
+
statusCode: number;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
127
134
|
/**
|
|
128
135
|
* Creates an implementation of `getServerSideProps` using the Uniform Route API.
|
|
129
136
|
* Static and dynamic routing as well as redirection is automatically supported.
|
|
@@ -153,7 +160,7 @@ declare const unstable_withUniformGetServerSideProps: <TProps extends {
|
|
|
153
160
|
/** Override handling of a composition route response. Return null to signal not found. */
|
|
154
161
|
handleComposition?: ((composition: RouteGetResponseEdgehancedComposition, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>, defaultHandler: typeof defaultHandleComposition) => RootComponentInstance | null) | undefined;
|
|
155
162
|
/** Override default handling of a redirect route response */
|
|
156
|
-
handleRedirect?: ((redirect: RouteGetResponseRedirect, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData
|
|
163
|
+
handleRedirect?: ((redirect: RouteGetResponseRedirect, requestUrl: string, context: GetServerSidePropsContext<ParsedUrlQuery, UniformPreviewData>, defaultHandler: typeof defaultHandleRedirect) => GetServerSidePropsResult<never>) | undefined;
|
|
157
164
|
/**
|
|
158
165
|
* Override default handling of a not found route response
|
|
159
166
|
* NOTE: not called when the API returns a 404 error (project map not found), only when the route result is not found
|
package/dist/route/index.js
CHANGED
|
@@ -133,14 +133,23 @@ function defaultHandleComposition(matched) {
|
|
|
133
133
|
return matched.compositionApiResponse.composition;
|
|
134
134
|
}
|
|
135
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
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
136
147
|
// src/route/withUniformGetServerSideProps.ts
|
|
137
148
|
var unstable_withUniformGetServerSideProps = (options) => {
|
|
138
149
|
var _a, _b, _c, _d;
|
|
139
|
-
const
|
|
140
|
-
|
|
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;
|
|
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;
|
|
144
153
|
const handleModifyPath = (_d = options == null ? void 0 : options.modifyPath) != null ? _d : (path) => decodeURI(path);
|
|
145
154
|
return async function wrappedGetServerSideProps(context) {
|
|
146
155
|
var _a2, _b2;
|
|
@@ -165,7 +174,7 @@ var unstable_withUniformGetServerSideProps = (options) => {
|
|
|
165
174
|
path: nodePath
|
|
166
175
|
});
|
|
167
176
|
if (response.type === "redirect") {
|
|
168
|
-
return handleRedirect(response, context);
|
|
177
|
+
return handleRedirect(response, nodePath, context, defaultHandleRedirect);
|
|
169
178
|
}
|
|
170
179
|
if (response.type === "notFound") {
|
|
171
180
|
return handleNotFound(response, context);
|
package/dist/route/index.mjs
CHANGED
|
@@ -99,14 +99,23 @@ function defaultHandleComposition(matched) {
|
|
|
99
99
|
return matched.compositionApiResponse.composition;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// src/route/defaultHandleRedirect.ts
|
|
103
|
+
import { RedirectClient } from "@uniformdev/redirect";
|
|
104
|
+
function defaultHandleRedirect(matched, requestUrl) {
|
|
105
|
+
return {
|
|
106
|
+
redirect: {
|
|
107
|
+
destination: RedirectClient.getTargetVariableExpandedUrl(requestUrl, matched.redirect),
|
|
108
|
+
statusCode: matched.redirect.targetStatusCode
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
// src/route/withUniformGetServerSideProps.ts
|
|
103
114
|
var unstable_withUniformGetServerSideProps = (options) => {
|
|
104
115
|
var _a, _b, _c, _d;
|
|
105
|
-
const
|
|
106
|
-
|
|
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;
|
|
116
|
+
const handleNotFound = (_a = options == null ? void 0 : options.handleNotFound) != null ? _a : () => ({ notFound: true });
|
|
117
|
+
const handleComposition = (_b = options == null ? void 0 : options.handleComposition) != null ? _b : defaultHandleComposition;
|
|
118
|
+
const handleRedirect = (_c = options == null ? void 0 : options.handleRedirect) != null ? _c : defaultHandleRedirect;
|
|
110
119
|
const handleModifyPath = (_d = options == null ? void 0 : options.modifyPath) != null ? _d : (path) => decodeURI(path);
|
|
111
120
|
return async function wrappedGetServerSideProps(context) {
|
|
112
121
|
var _a2, _b2;
|
|
@@ -131,7 +140,7 @@ var unstable_withUniformGetServerSideProps = (options) => {
|
|
|
131
140
|
path: nodePath
|
|
132
141
|
});
|
|
133
142
|
if (response.type === "redirect") {
|
|
134
|
-
return handleRedirect(response, context);
|
|
143
|
+
return handleRedirect(response, nodePath, context, defaultHandleRedirect);
|
|
135
144
|
}
|
|
136
145
|
if (response.type === "notFound") {
|
|
137
146
|
return handleNotFound(response, context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.10.0",
|
|
4
4
|
"description": "Next.js SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -63,9 +63,10 @@
|
|
|
63
63
|
"document": "api-extractor run --local"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@uniformdev/canvas": "19.
|
|
67
|
-
"@uniformdev/canvas-react": "19.
|
|
68
|
-
"@uniformdev/project-map": "19.
|
|
66
|
+
"@uniformdev/canvas": "19.10.0",
|
|
67
|
+
"@uniformdev/canvas-react": "19.10.0",
|
|
68
|
+
"@uniformdev/project-map": "19.10.0",
|
|
69
|
+
"@uniformdev/redirect": "19.10.0",
|
|
69
70
|
"chalk": "^5.2.0"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"react-dom": ">=16"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
|
-
"@types/react": "18.2.
|
|
78
|
+
"@types/react": "18.2.6",
|
|
78
79
|
"next": "13.3.4",
|
|
79
80
|
"react": "18.2.0",
|
|
80
81
|
"react-dom": "18.2.0"
|
|
@@ -85,5 +86,5 @@
|
|
|
85
86
|
"publishConfig": {
|
|
86
87
|
"access": "public"
|
|
87
88
|
},
|
|
88
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "149f942da715ed802545850283f9b99291829a04"
|
|
89
90
|
}
|