@uniformdev/canvas-next 19.20.1-alpha.32 → 19.22.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 +2 -2
- package/dist/route/index.js +19 -4
- package/dist/route/index.mjs +20 -4
- package/package.json +7 -7
package/dist/route/index.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ type RouteHandlerOptions<TContext, TResult, TSuccessResult> = {
|
|
|
20
20
|
modifyPath?: (path: string, context: TContext) => string;
|
|
21
21
|
/** The project map ID to connect to. If not set, the default project map for the configured project will be used. */
|
|
22
22
|
projectMapId?: string;
|
|
23
|
-
/** Way to override getRoute request params */
|
|
24
|
-
requestOptions?: Partial<RouteGetParameters
|
|
23
|
+
/** Way to override getRoute request params. Can also be a function to compute options based on context values. */
|
|
24
|
+
requestOptions?: Partial<RouteGetParameters> | ((context: TContext) => Partial<RouteGetParameters>);
|
|
25
25
|
/** Disables logging of response information and timings */
|
|
26
26
|
silent?: boolean;
|
|
27
27
|
/** Override handling of a composition route response. Return null to signal not found. */
|
package/dist/route/index.js
CHANGED
|
@@ -335,6 +335,7 @@ var getStaticProps = withUniformGetStaticProps({ param: "path" });
|
|
|
335
335
|
var getStaticPaths = withUniformGetStaticPaths();
|
|
336
336
|
|
|
337
337
|
// src/route/withUniformGetServerSideProps.ts
|
|
338
|
+
var import_canvas5 = require("@uniformdev/canvas");
|
|
338
339
|
var import_redirect = require("@uniformdev/redirect");
|
|
339
340
|
|
|
340
341
|
// src/route/createRouteFetcher.ts
|
|
@@ -363,7 +364,12 @@ function createRouteFetcher(options) {
|
|
|
363
364
|
});
|
|
364
365
|
const handleModifyPath = modifyPath != null ? modifyPath : (path) => decodeURI(path);
|
|
365
366
|
return async function fetcher(context) {
|
|
366
|
-
|
|
367
|
+
var _a, _b;
|
|
368
|
+
const {
|
|
369
|
+
contextualEditingCompositionId,
|
|
370
|
+
resolvedUrl,
|
|
371
|
+
defaultFetchState: defaultPreviewState
|
|
372
|
+
} = parseContext(context);
|
|
367
373
|
let nodePath = prefix ? resolvedUrl.replace(new RegExp(`^${prefix}`), "") : resolvedUrl;
|
|
368
374
|
nodePath = handleModifyPath(nodePath, context);
|
|
369
375
|
const invokeRedirectResult = (redirect, duration) => (handleRedirect != null ? handleRedirect : defaultHandleRedirect)(
|
|
@@ -427,9 +433,11 @@ function createRouteFetcher(options) {
|
|
|
427
433
|
if (!silent) {
|
|
428
434
|
console.log("Fetch route", nodePath);
|
|
429
435
|
}
|
|
436
|
+
const resolvedOptions = typeof requestOptions === "function" ? requestOptions(context) : requestOptions;
|
|
430
437
|
const time = Date.now();
|
|
431
438
|
const response = await routeClient.getRoute({
|
|
432
|
-
...
|
|
439
|
+
...resolvedOptions,
|
|
440
|
+
state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : import_canvas4.CANVAS_PUBLISHED_STATE,
|
|
433
441
|
projectMapId,
|
|
434
442
|
path: nodePath
|
|
435
443
|
});
|
|
@@ -496,7 +504,10 @@ var withUniformGetServerSideProps2 = (options) => {
|
|
|
496
504
|
var _a;
|
|
497
505
|
return {
|
|
498
506
|
contextualEditingCompositionId: (_a = context.previewData) == null ? void 0 : _a.compositionId,
|
|
499
|
-
resolvedUrl: context.resolvedUrl
|
|
507
|
+
resolvedUrl: context.resolvedUrl,
|
|
508
|
+
// auto engage draft content when in next preview mode
|
|
509
|
+
// (can override with explicit setting of request options)'
|
|
510
|
+
defaultFetchState: context.preview ? import_canvas5.CANVAS_DRAFT_STATE : void 0
|
|
500
511
|
};
|
|
501
512
|
}
|
|
502
513
|
});
|
|
@@ -504,6 +515,7 @@ var withUniformGetServerSideProps2 = (options) => {
|
|
|
504
515
|
};
|
|
505
516
|
|
|
506
517
|
// src/route/withUniformGetStaticProps.ts
|
|
518
|
+
var import_canvas6 = require("@uniformdev/canvas");
|
|
507
519
|
var import_redirect2 = require("@uniformdev/redirect");
|
|
508
520
|
var withUniformGetStaticProps2 = (options) => {
|
|
509
521
|
const defaultHandleRedirect = (requestUrl, matched) => {
|
|
@@ -536,7 +548,10 @@ var withUniformGetStaticProps2 = (options) => {
|
|
|
536
548
|
resolvedUrl: resolveSlugFromParams({
|
|
537
549
|
params: context.params,
|
|
538
550
|
param: (_b = options == null ? void 0 : options.param) != null ? _b : "route"
|
|
539
|
-
})
|
|
551
|
+
}),
|
|
552
|
+
// auto engage draft content when in next preview mode
|
|
553
|
+
// (can override with explicit setting of request options)
|
|
554
|
+
defaultFetchState: context.preview ? import_canvas6.CANVAS_DRAFT_STATE : void 0
|
|
540
555
|
};
|
|
541
556
|
}
|
|
542
557
|
});
|
package/dist/route/index.mjs
CHANGED
|
@@ -57,11 +57,13 @@ function logRouteResponse(response, duration) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// src/route/withUniformGetServerSideProps.ts
|
|
60
|
+
import { CANVAS_DRAFT_STATE } from "@uniformdev/canvas";
|
|
60
61
|
import { RedirectClient } from "@uniformdev/redirect";
|
|
61
62
|
|
|
62
63
|
// src/route/createRouteFetcher.ts
|
|
63
64
|
import {
|
|
64
65
|
ApiClientError,
|
|
66
|
+
CANVAS_PUBLISHED_STATE,
|
|
65
67
|
EMPTY_COMPOSITION,
|
|
66
68
|
RouteClient
|
|
67
69
|
} from "@uniformdev/canvas";
|
|
@@ -89,7 +91,12 @@ function createRouteFetcher(options) {
|
|
|
89
91
|
});
|
|
90
92
|
const handleModifyPath = modifyPath != null ? modifyPath : (path) => decodeURI(path);
|
|
91
93
|
return async function fetcher(context) {
|
|
92
|
-
|
|
94
|
+
var _a, _b;
|
|
95
|
+
const {
|
|
96
|
+
contextualEditingCompositionId,
|
|
97
|
+
resolvedUrl,
|
|
98
|
+
defaultFetchState: defaultPreviewState
|
|
99
|
+
} = parseContext(context);
|
|
93
100
|
let nodePath = prefix ? resolvedUrl.replace(new RegExp(`^${prefix}`), "") : resolvedUrl;
|
|
94
101
|
nodePath = handleModifyPath(nodePath, context);
|
|
95
102
|
const invokeRedirectResult = (redirect, duration) => (handleRedirect != null ? handleRedirect : defaultHandleRedirect)(
|
|
@@ -153,9 +160,11 @@ function createRouteFetcher(options) {
|
|
|
153
160
|
if (!silent) {
|
|
154
161
|
console.log("Fetch route", nodePath);
|
|
155
162
|
}
|
|
163
|
+
const resolvedOptions = typeof requestOptions === "function" ? requestOptions(context) : requestOptions;
|
|
156
164
|
const time = Date.now();
|
|
157
165
|
const response = await routeClient.getRoute({
|
|
158
|
-
...
|
|
166
|
+
...resolvedOptions,
|
|
167
|
+
state: (_b = (_a = resolvedOptions == null ? void 0 : resolvedOptions.state) != null ? _a : defaultPreviewState) != null ? _b : CANVAS_PUBLISHED_STATE,
|
|
159
168
|
projectMapId,
|
|
160
169
|
path: nodePath
|
|
161
170
|
});
|
|
@@ -222,7 +231,10 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
222
231
|
var _a;
|
|
223
232
|
return {
|
|
224
233
|
contextualEditingCompositionId: (_a = context.previewData) == null ? void 0 : _a.compositionId,
|
|
225
|
-
resolvedUrl: context.resolvedUrl
|
|
234
|
+
resolvedUrl: context.resolvedUrl,
|
|
235
|
+
// auto engage draft content when in next preview mode
|
|
236
|
+
// (can override with explicit setting of request options)'
|
|
237
|
+
defaultFetchState: context.preview ? CANVAS_DRAFT_STATE : void 0
|
|
226
238
|
};
|
|
227
239
|
}
|
|
228
240
|
});
|
|
@@ -230,6 +242,7 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
230
242
|
};
|
|
231
243
|
|
|
232
244
|
// src/route/withUniformGetStaticProps.ts
|
|
245
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2 } from "@uniformdev/canvas";
|
|
233
246
|
import { RedirectClient as RedirectClient2 } from "@uniformdev/redirect";
|
|
234
247
|
var withUniformGetStaticProps = (options) => {
|
|
235
248
|
const defaultHandleRedirect = (requestUrl, matched) => {
|
|
@@ -262,7 +275,10 @@ var withUniformGetStaticProps = (options) => {
|
|
|
262
275
|
resolvedUrl: resolveSlugFromParams({
|
|
263
276
|
params: context.params,
|
|
264
277
|
param: (_b = options == null ? void 0 : options.param) != null ? _b : "route"
|
|
265
|
-
})
|
|
278
|
+
}),
|
|
279
|
+
// auto engage draft content when in next preview mode
|
|
280
|
+
// (can override with explicit setting of request options)
|
|
281
|
+
defaultFetchState: context.preview ? CANVAS_DRAFT_STATE2 : void 0
|
|
266
282
|
};
|
|
267
283
|
}
|
|
268
284
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.22.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,11 +63,11 @@
|
|
|
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.
|
|
69
|
-
"@uniformdev/redirect": "19.
|
|
70
|
-
"@uniformdev/richtext": "19.
|
|
66
|
+
"@uniformdev/canvas": "19.22.0",
|
|
67
|
+
"@uniformdev/canvas-react": "19.22.0",
|
|
68
|
+
"@uniformdev/project-map": "19.22.0",
|
|
69
|
+
"@uniformdev/redirect": "19.22.0",
|
|
70
|
+
"@uniformdev/richtext": "19.22.0",
|
|
71
71
|
"colorette": "2.0.20"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "f3b826c15f64a8abc5bd7ca08c0539bd85684cf9"
|
|
91
91
|
}
|