@uniformdev/canvas-next 19.14.0 → 19.14.1-alpha.11
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-ZOXJSPVQ.mjs → chunk-23O4NSDU.mjs} +6 -5
- package/dist/chunk-6IDBHA5X.mjs +109 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +49 -1
- package/dist/index.js +61 -2
- package/dist/index.mjs +49 -1
- package/dist/project-map/index.d.ts +2 -0
- package/dist/project-map/index.js +108 -2
- package/dist/project-map/index.mjs +2 -1
- package/dist/route/index.d.ts +4 -4
- package/dist/route/index.js +159 -16
- package/dist/route/index.mjs +54 -5
- package/dist/slug/index.d.ts +2 -0
- package/dist/slug/index.js +108 -2
- package/dist/slug/index.mjs +6 -5
- package/package.json +8 -7
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logCompositionResponse
|
|
3
|
+
} from "./chunk-6IDBHA5X.mjs";
|
|
1
4
|
import {
|
|
2
5
|
resolveSlugFromParams
|
|
3
6
|
} from "./chunk-TR7V6ABJ.mjs";
|
|
@@ -7,8 +10,7 @@ import {
|
|
|
7
10
|
CANVAS_DRAFT_STATE,
|
|
8
11
|
CANVAS_PUBLISHED_STATE,
|
|
9
12
|
CanvasClient,
|
|
10
|
-
EMPTY_COMPOSITION
|
|
11
|
-
logCompositionResponse
|
|
13
|
+
EMPTY_COMPOSITION
|
|
12
14
|
} from "@uniformdev/canvas";
|
|
13
15
|
var withUniformGetServerSideProps = (options) => {
|
|
14
16
|
const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
|
|
@@ -95,8 +97,7 @@ import {
|
|
|
95
97
|
CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
|
|
96
98
|
CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
|
|
97
99
|
CanvasClient as CanvasClient2,
|
|
98
|
-
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
99
|
-
logCompositionResponse as logCompositionResponse2
|
|
100
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
100
101
|
} from "@uniformdev/canvas";
|
|
101
102
|
var withUniformGetStaticProps = (options) => {
|
|
102
103
|
var _a;
|
|
@@ -132,7 +133,7 @@ var withUniformGetStaticProps = (options) => {
|
|
|
132
133
|
const duration = Date.now() - time;
|
|
133
134
|
composition = response.composition;
|
|
134
135
|
if (!(options == null ? void 0 : options.silent)) {
|
|
135
|
-
|
|
136
|
+
logCompositionResponse(response, duration);
|
|
136
137
|
}
|
|
137
138
|
} catch (e) {
|
|
138
139
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/logging/logCompositionResponse.ts
|
|
2
|
+
import { white as white2 } from "colorette";
|
|
3
|
+
|
|
4
|
+
// src/logging/logCompositionIssues.ts
|
|
5
|
+
import { gray, green, italic, red, white, yellow } from "colorette";
|
|
6
|
+
function logCompositionIssues(prefix, issues, colour = "red") {
|
|
7
|
+
const reversedIssues = [...issues].reverse();
|
|
8
|
+
const colours = { red, green, yellow, white };
|
|
9
|
+
console.error(
|
|
10
|
+
`${colours[colour](prefix)}
|
|
11
|
+
${reversedIssues.map(
|
|
12
|
+
(issue) => `${colours[colour](">")} ${italic(gray(indent(issue.type.toUpperCase(), 7)))} ${renderIssue(issue)}`
|
|
13
|
+
).join("\n")}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function renderIssue(issue) {
|
|
17
|
+
var _a;
|
|
18
|
+
let path;
|
|
19
|
+
let type;
|
|
20
|
+
let message = issue.message;
|
|
21
|
+
let detail;
|
|
22
|
+
if (issue.type !== "config") {
|
|
23
|
+
path = issue.componentPath;
|
|
24
|
+
type = issue.componentType;
|
|
25
|
+
message = issue.message;
|
|
26
|
+
}
|
|
27
|
+
if (issue.type === "binding") {
|
|
28
|
+
detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
|
|
29
|
+
} else if (issue.type === "data") {
|
|
30
|
+
detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
|
|
31
|
+
}
|
|
32
|
+
if (issue.type === "input") {
|
|
33
|
+
detail = issue.inputName;
|
|
34
|
+
}
|
|
35
|
+
let result = `${white(blockify(message))}`;
|
|
36
|
+
if (detail) {
|
|
37
|
+
result += `
|
|
38
|
+
${indent(" ", 10)}${gray(`${detail}`)}`;
|
|
39
|
+
}
|
|
40
|
+
if (path && type) {
|
|
41
|
+
result += `
|
|
42
|
+
${indent(" ", 10)}${gray(`Occurred on component ${type} at slot path ${path}`)}`;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function indent(str, len) {
|
|
47
|
+
const indent2 = len != null ? len : 10;
|
|
48
|
+
return str.padStart(indent2);
|
|
49
|
+
}
|
|
50
|
+
function blockify(str, len) {
|
|
51
|
+
const indentSize = len != null ? len : 10;
|
|
52
|
+
return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/logging/logCompositionResponse.ts
|
|
56
|
+
function logCompositionResponse(compositionApiResponse, duration) {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const resErrors = (_a = compositionApiResponse.errors) != null ? _a : [];
|
|
59
|
+
const resWarnings = (_b = compositionApiResponse.warnings) != null ? _b : [];
|
|
60
|
+
if (resErrors.length > 0) {
|
|
61
|
+
logCompositionIssues(
|
|
62
|
+
`Composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
|
|
63
|
+
resErrors,
|
|
64
|
+
"red"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (resWarnings.length > 0) {
|
|
68
|
+
logCompositionIssues(
|
|
69
|
+
`Composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
|
|
70
|
+
resWarnings,
|
|
71
|
+
"yellow"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (compositionApiResponse.diagnostics) {
|
|
75
|
+
console.log(`
|
|
76
|
+
Diagnostics`);
|
|
77
|
+
const { compositionFetch, data } = compositionApiResponse.diagnostics;
|
|
78
|
+
const table = {
|
|
79
|
+
[`${white2("Composition")}`]: {
|
|
80
|
+
"Duration (ms)": resolveDiagnosticsDuration(compositionFetch),
|
|
81
|
+
"Edge Cached": compositionFetch == null ? void 0 : compositionFetch.cacheHit
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (data) {
|
|
85
|
+
data.forEach((d) => {
|
|
86
|
+
table[d.dataName] = {
|
|
87
|
+
"Duration (ms)": resolveDiagnosticsDuration(d.performance),
|
|
88
|
+
"Edge Cached": d.performance.cacheHit,
|
|
89
|
+
"Retry Count": d.performance.retryCount
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
table["Total Response"] = {
|
|
94
|
+
"Duration (ms)": duration != null ? duration : "no data"
|
|
95
|
+
};
|
|
96
|
+
console.table(table);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function resolveDiagnosticsDuration(data) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
if (!data) {
|
|
102
|
+
return "no data";
|
|
103
|
+
}
|
|
104
|
+
return (_b = (_a = data.duration) != null ? _a : data.total) != null ? _b : "no data";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
logCompositionResponse
|
|
109
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { RichTextRendererComponent, RenderRichTextComponentResolver, UniformRichText as UniformRichText$1, UniformRichTextNode as UniformRichTextNode$1 } from '@uniformdev/canvas-react';
|
|
1
2
|
import { ParsedUrlQuery } from 'querystring';
|
|
2
3
|
export { U as UniformCompositionNextPage, c as UniformGetServerSideProps, b as UniformGetStaticProps, a as UniformPreviewData } from './models-092c0912.js';
|
|
3
4
|
import { NextApiHandler, NextApiRequest } from 'next';
|
|
4
5
|
import { RootComponentInstance } from '@uniformdev/canvas';
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
declare const NextLinkRichTextNode: RichTextRendererComponent;
|
|
8
|
+
declare function useResolveNextRichTextRenderer(resolveRichTextRenderer?: RenderRichTextComponentResolver): RenderRichTextComponentResolver;
|
|
9
|
+
declare const UniformRichText: typeof UniformRichText$1;
|
|
10
|
+
declare const UniformRichTextNode: typeof UniformRichTextNode$1;
|
|
6
11
|
|
|
7
12
|
declare const resolveSlugFromParams: ({ param, params, }: {
|
|
8
13
|
param: string | undefined;
|
|
@@ -42,4 +47,4 @@ declare const createPreviewHandlerPost: CreatePreviewHandlerPost;
|
|
|
42
47
|
type CreatePreviewHandler = (options?: CreatePreviewHandlerGetOptions & CreatePreviewHandlerPostOptions) => NextApiHandler;
|
|
43
48
|
declare const createPreviewHandler: CreatePreviewHandler;
|
|
44
49
|
|
|
45
|
-
export { CreatePreviewHandler, CreatePreviewHandlerGet, CreatePreviewHandlerGetOptions, CreatePreviewHandlerPost, CreatePreviewHandlerPostOptions, ResolveFullPath, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams };
|
|
50
|
+
export { CreatePreviewHandler, CreatePreviewHandlerGet, CreatePreviewHandlerGetOptions, CreatePreviewHandlerPost, CreatePreviewHandlerPostOptions, NextLinkRichTextNode, ResolveFullPath, UniformRichText, UniformRichTextNode, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost, resolveSlugFromParams, useResolveNextRichTextRenderer };
|
package/dist/index.esm.js
CHANGED
|
@@ -2,6 +2,50 @@ import {
|
|
|
2
2
|
resolveSlugFromParams
|
|
3
3
|
} from "./chunk-TR7V6ABJ.mjs";
|
|
4
4
|
|
|
5
|
+
// src/components/UniformRichText.tsx
|
|
6
|
+
import {
|
|
7
|
+
UniformRichText as ReactUniformRichText,
|
|
8
|
+
UniformRichTextNode as ReactUniformRichTextNode
|
|
9
|
+
} from "@uniformdev/canvas-react";
|
|
10
|
+
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
11
|
+
import NextLink from "next/link";
|
|
12
|
+
import React, { useCallback } from "react";
|
|
13
|
+
var NextLinkRichTextNode = ({ children, node }) => {
|
|
14
|
+
const { link } = node;
|
|
15
|
+
const href = linkParamValueToHref(link);
|
|
16
|
+
if (href) {
|
|
17
|
+
return /* @__PURE__ */ React.createElement(NextLink, { href }, children);
|
|
18
|
+
} else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function useResolveNextRichTextRenderer(resolveRichTextRenderer) {
|
|
23
|
+
return useCallback(
|
|
24
|
+
(node) => {
|
|
25
|
+
let result = void 0;
|
|
26
|
+
if (typeof resolveRichTextRenderer === "function") {
|
|
27
|
+
result = resolveRichTextRenderer(node);
|
|
28
|
+
}
|
|
29
|
+
if (typeof result === "undefined" && node.type === "link") {
|
|
30
|
+
return NextLinkRichTextNode;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
[resolveRichTextRenderer]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
var UniformRichText = ({ resolveRichTextRenderer, ...props }) => {
|
|
38
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(ReactUniformRichText, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
40
|
+
};
|
|
41
|
+
var UniformRichTextNode = ({
|
|
42
|
+
resolveRichTextRenderer,
|
|
43
|
+
...props
|
|
44
|
+
}) => {
|
|
45
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(ReactUniformRichTextNode, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
47
|
+
};
|
|
48
|
+
|
|
5
49
|
// src/preview/previewHandlerGet.ts
|
|
6
50
|
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
7
51
|
var getQueryParam = (req, paramName) => {
|
|
@@ -122,8 +166,12 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
|
|
|
122
166
|
return res.status(501).json({ message: `Method "${method}" not implemented` });
|
|
123
167
|
};
|
|
124
168
|
export {
|
|
169
|
+
NextLinkRichTextNode,
|
|
170
|
+
UniformRichText,
|
|
171
|
+
UniformRichTextNode,
|
|
125
172
|
createPreviewHandler,
|
|
126
173
|
createPreviewHandlerGet,
|
|
127
174
|
createPreviewHandlerPost,
|
|
128
|
-
resolveSlugFromParams
|
|
175
|
+
resolveSlugFromParams,
|
|
176
|
+
useResolveNextRichTextRenderer
|
|
129
177
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,71 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var src_exports = {};
|
|
22
32
|
__export(src_exports, {
|
|
33
|
+
NextLinkRichTextNode: () => NextLinkRichTextNode,
|
|
34
|
+
UniformRichText: () => UniformRichText,
|
|
35
|
+
UniformRichTextNode: () => UniformRichTextNode,
|
|
23
36
|
createPreviewHandler: () => createPreviewHandler,
|
|
24
37
|
createPreviewHandlerGet: () => createPreviewHandlerGet,
|
|
25
38
|
createPreviewHandlerPost: () => createPreviewHandlerPost,
|
|
26
|
-
resolveSlugFromParams: () => resolveSlugFromParams
|
|
39
|
+
resolveSlugFromParams: () => resolveSlugFromParams,
|
|
40
|
+
useResolveNextRichTextRenderer: () => useResolveNextRichTextRenderer
|
|
27
41
|
});
|
|
28
42
|
module.exports = __toCommonJS(src_exports);
|
|
29
43
|
|
|
44
|
+
// src/components/UniformRichText.tsx
|
|
45
|
+
var import_canvas_react = require("@uniformdev/canvas-react");
|
|
46
|
+
var import_richtext = require("@uniformdev/richtext");
|
|
47
|
+
var import_link = __toESM(require("next/link"));
|
|
48
|
+
var import_react = __toESM(require("react"));
|
|
49
|
+
var NextLinkRichTextNode = ({ children, node }) => {
|
|
50
|
+
const { link } = node;
|
|
51
|
+
const href = (0, import_richtext.linkParamValueToHref)(link);
|
|
52
|
+
if (href) {
|
|
53
|
+
return /* @__PURE__ */ import_react.default.createElement(import_link.default, { href }, children);
|
|
54
|
+
} else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function useResolveNextRichTextRenderer(resolveRichTextRenderer) {
|
|
59
|
+
return (0, import_react.useCallback)(
|
|
60
|
+
(node) => {
|
|
61
|
+
let result = void 0;
|
|
62
|
+
if (typeof resolveRichTextRenderer === "function") {
|
|
63
|
+
result = resolveRichTextRenderer(node);
|
|
64
|
+
}
|
|
65
|
+
if (typeof result === "undefined" && node.type === "link") {
|
|
66
|
+
return NextLinkRichTextNode;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
},
|
|
70
|
+
[resolveRichTextRenderer]
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
var UniformRichText = ({ resolveRichTextRenderer, ...props }) => {
|
|
74
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(import_canvas_react.UniformRichText, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
76
|
+
};
|
|
77
|
+
var UniformRichTextNode = ({
|
|
78
|
+
resolveRichTextRenderer,
|
|
79
|
+
...props
|
|
80
|
+
}) => {
|
|
81
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
82
|
+
return /* @__PURE__ */ import_react.default.createElement(import_canvas_react.UniformRichTextNode, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
83
|
+
};
|
|
84
|
+
|
|
30
85
|
// src/helpers/resolveSlugFromParams.ts
|
|
31
86
|
var resolveSlugFromParams = ({
|
|
32
87
|
param = "slug",
|
|
@@ -158,8 +213,12 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
|
|
|
158
213
|
};
|
|
159
214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
160
215
|
0 && (module.exports = {
|
|
216
|
+
NextLinkRichTextNode,
|
|
217
|
+
UniformRichText,
|
|
218
|
+
UniformRichTextNode,
|
|
161
219
|
createPreviewHandler,
|
|
162
220
|
createPreviewHandlerGet,
|
|
163
221
|
createPreviewHandlerPost,
|
|
164
|
-
resolveSlugFromParams
|
|
222
|
+
resolveSlugFromParams,
|
|
223
|
+
useResolveNextRichTextRenderer
|
|
165
224
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,50 @@ import {
|
|
|
2
2
|
resolveSlugFromParams
|
|
3
3
|
} from "./chunk-TR7V6ABJ.mjs";
|
|
4
4
|
|
|
5
|
+
// src/components/UniformRichText.tsx
|
|
6
|
+
import {
|
|
7
|
+
UniformRichText as ReactUniformRichText,
|
|
8
|
+
UniformRichTextNode as ReactUniformRichTextNode
|
|
9
|
+
} from "@uniformdev/canvas-react";
|
|
10
|
+
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
11
|
+
import NextLink from "next/link";
|
|
12
|
+
import React, { useCallback } from "react";
|
|
13
|
+
var NextLinkRichTextNode = ({ children, node }) => {
|
|
14
|
+
const { link } = node;
|
|
15
|
+
const href = linkParamValueToHref(link);
|
|
16
|
+
if (href) {
|
|
17
|
+
return /* @__PURE__ */ React.createElement(NextLink, { href }, children);
|
|
18
|
+
} else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function useResolveNextRichTextRenderer(resolveRichTextRenderer) {
|
|
23
|
+
return useCallback(
|
|
24
|
+
(node) => {
|
|
25
|
+
let result = void 0;
|
|
26
|
+
if (typeof resolveRichTextRenderer === "function") {
|
|
27
|
+
result = resolveRichTextRenderer(node);
|
|
28
|
+
}
|
|
29
|
+
if (typeof result === "undefined" && node.type === "link") {
|
|
30
|
+
return NextLinkRichTextNode;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
[resolveRichTextRenderer]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
var UniformRichText = ({ resolveRichTextRenderer, ...props }) => {
|
|
38
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(ReactUniformRichText, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
40
|
+
};
|
|
41
|
+
var UniformRichTextNode = ({
|
|
42
|
+
resolveRichTextRenderer,
|
|
43
|
+
...props
|
|
44
|
+
}) => {
|
|
45
|
+
const resolveNextRichTextRenderer = useResolveNextRichTextRenderer(resolveRichTextRenderer);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(ReactUniformRichTextNode, { ...props, resolveRichTextRenderer: resolveNextRichTextRenderer });
|
|
47
|
+
};
|
|
48
|
+
|
|
5
49
|
// src/preview/previewHandlerGet.ts
|
|
6
50
|
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
7
51
|
var getQueryParam = (req, paramName) => {
|
|
@@ -122,8 +166,12 @@ var createPreviewHandler = ({ secret, enhance, resolveFullPath } = {}) => async
|
|
|
122
166
|
return res.status(501).json({ message: `Method "${method}" not implemented` });
|
|
123
167
|
};
|
|
124
168
|
export {
|
|
169
|
+
NextLinkRichTextNode,
|
|
170
|
+
UniformRichText,
|
|
171
|
+
UniformRichTextNode,
|
|
125
172
|
createPreviewHandler,
|
|
126
173
|
createPreviewHandlerGet,
|
|
127
174
|
createPreviewHandlerPost,
|
|
128
|
-
resolveSlugFromParams
|
|
175
|
+
resolveSlugFromParams,
|
|
176
|
+
useResolveNextRichTextRenderer
|
|
129
177
|
};
|
|
@@ -32,6 +32,7 @@ declare const withUniformGetServerSideProps: <TProps extends {
|
|
|
32
32
|
withComponentIDs?: boolean | undefined;
|
|
33
33
|
withTotalCount?: boolean | undefined;
|
|
34
34
|
withUIStatus?: boolean | undefined;
|
|
35
|
+
withContentSourceMap?: boolean | undefined;
|
|
35
36
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
36
37
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
37
38
|
callback?: UniformGetServerSideProps<TProps> | undefined;
|
|
@@ -62,6 +63,7 @@ declare const withUniformGetStaticProps: <TProps extends {
|
|
|
62
63
|
withComponentIDs?: boolean | undefined;
|
|
63
64
|
withTotalCount?: boolean | undefined;
|
|
64
65
|
withUIStatus?: boolean | undefined;
|
|
66
|
+
withContentSourceMap?: boolean | undefined;
|
|
65
67
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "projectMapNodePath">> & _uniformdev_canvas.SpecificProjectMap & DataResolutionOption>, "state"> | undefined;
|
|
66
68
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
67
69
|
callback?: UniformGetStaticProps<TProps> | undefined;
|
|
@@ -31,6 +31,112 @@ module.exports = __toCommonJS(project_map_exports);
|
|
|
31
31
|
|
|
32
32
|
// src/project-map/withUniformGetServerSideProps.ts
|
|
33
33
|
var import_canvas = require("@uniformdev/canvas");
|
|
34
|
+
|
|
35
|
+
// src/logging/logCompositionIssues.ts
|
|
36
|
+
var import_colorette = require("colorette");
|
|
37
|
+
function logCompositionIssues(prefix, issues, colour = "red") {
|
|
38
|
+
const reversedIssues = [...issues].reverse();
|
|
39
|
+
const colours = { red: import_colorette.red, green: import_colorette.green, yellow: import_colorette.yellow, white: import_colorette.white };
|
|
40
|
+
console.error(
|
|
41
|
+
`${colours[colour](prefix)}
|
|
42
|
+
${reversedIssues.map(
|
|
43
|
+
(issue) => `${colours[colour](">")} ${(0, import_colorette.italic)((0, import_colorette.gray)(indent(issue.type.toUpperCase(), 7)))} ${renderIssue(issue)}`
|
|
44
|
+
).join("\n")}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function renderIssue(issue) {
|
|
48
|
+
var _a;
|
|
49
|
+
let path;
|
|
50
|
+
let type;
|
|
51
|
+
let message = issue.message;
|
|
52
|
+
let detail;
|
|
53
|
+
if (issue.type !== "config") {
|
|
54
|
+
path = issue.componentPath;
|
|
55
|
+
type = issue.componentType;
|
|
56
|
+
message = issue.message;
|
|
57
|
+
}
|
|
58
|
+
if (issue.type === "binding") {
|
|
59
|
+
detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
|
|
60
|
+
} else if (issue.type === "data") {
|
|
61
|
+
detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
|
|
62
|
+
}
|
|
63
|
+
if (issue.type === "input") {
|
|
64
|
+
detail = issue.inputName;
|
|
65
|
+
}
|
|
66
|
+
let result = `${(0, import_colorette.white)(blockify(message))}`;
|
|
67
|
+
if (detail) {
|
|
68
|
+
result += `
|
|
69
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`${detail}`)}`;
|
|
70
|
+
}
|
|
71
|
+
if (path && type) {
|
|
72
|
+
result += `
|
|
73
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`Occurred on component ${type} at slot path ${path}`)}`;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
function indent(str, len) {
|
|
78
|
+
const indent2 = len != null ? len : 10;
|
|
79
|
+
return str.padStart(indent2);
|
|
80
|
+
}
|
|
81
|
+
function blockify(str, len) {
|
|
82
|
+
const indentSize = len != null ? len : 10;
|
|
83
|
+
return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/logging/logCompositionResponse.ts
|
|
87
|
+
var import_colorette2 = require("colorette");
|
|
88
|
+
function logCompositionResponse(compositionApiResponse, duration) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const resErrors = (_a = compositionApiResponse.errors) != null ? _a : [];
|
|
91
|
+
const resWarnings = (_b = compositionApiResponse.warnings) != null ? _b : [];
|
|
92
|
+
if (resErrors.length > 0) {
|
|
93
|
+
logCompositionIssues(
|
|
94
|
+
`Composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
|
|
95
|
+
resErrors,
|
|
96
|
+
"red"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (resWarnings.length > 0) {
|
|
100
|
+
logCompositionIssues(
|
|
101
|
+
`Composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
|
|
102
|
+
resWarnings,
|
|
103
|
+
"yellow"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (compositionApiResponse.diagnostics) {
|
|
107
|
+
console.log(`
|
|
108
|
+
Diagnostics`);
|
|
109
|
+
const { compositionFetch, data } = compositionApiResponse.diagnostics;
|
|
110
|
+
const table = {
|
|
111
|
+
[`${(0, import_colorette2.white)("Composition")}`]: {
|
|
112
|
+
"Duration (ms)": resolveDiagnosticsDuration(compositionFetch),
|
|
113
|
+
"Edge Cached": compositionFetch == null ? void 0 : compositionFetch.cacheHit
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (data) {
|
|
117
|
+
data.forEach((d) => {
|
|
118
|
+
table[d.dataName] = {
|
|
119
|
+
"Duration (ms)": resolveDiagnosticsDuration(d.performance),
|
|
120
|
+
"Edge Cached": d.performance.cacheHit,
|
|
121
|
+
"Retry Count": d.performance.retryCount
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
table["Total Response"] = {
|
|
126
|
+
"Duration (ms)": duration != null ? duration : "no data"
|
|
127
|
+
};
|
|
128
|
+
console.table(table);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function resolveDiagnosticsDuration(data) {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if (!data) {
|
|
134
|
+
return "no data";
|
|
135
|
+
}
|
|
136
|
+
return (_b = (_a = data.duration) != null ? _a : data.total) != null ? _b : "no data";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/project-map/withUniformGetServerSideProps.ts
|
|
34
140
|
var withUniformGetServerSideProps = (options) => {
|
|
35
141
|
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
36
142
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
@@ -61,7 +167,7 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
61
167
|
const duration = Date.now() - time;
|
|
62
168
|
composition = response.composition;
|
|
63
169
|
if (!(options == null ? void 0 : options.silent)) {
|
|
64
|
-
|
|
170
|
+
logCompositionResponse(response, duration);
|
|
65
171
|
}
|
|
66
172
|
} catch (e) {
|
|
67
173
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -157,7 +263,7 @@ var withUniformGetStaticProps = (options) => {
|
|
|
157
263
|
const duration = Date.now() - time;
|
|
158
264
|
composition = response.composition;
|
|
159
265
|
if (!(options == null ? void 0 : options.silent)) {
|
|
160
|
-
|
|
266
|
+
logCompositionResponse(response, duration);
|
|
161
267
|
}
|
|
162
268
|
} catch (e) {
|
|
163
269
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
withUniformGetServerSideProps,
|
|
6
6
|
withUniformGetStaticPaths,
|
|
7
7
|
withUniformGetStaticProps
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-23O4NSDU.mjs";
|
|
9
|
+
import "../chunk-6IDBHA5X.mjs";
|
|
9
10
|
import "../chunk-TR7V6ABJ.mjs";
|
|
10
11
|
export {
|
|
11
12
|
getServerSideProps,
|
package/dist/route/index.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ declare const unstable_getServerSideProps: next.GetServerSideProps<{
|
|
|
136
136
|
} | undefined;
|
|
137
137
|
_overridability?: {
|
|
138
138
|
parameters?: {
|
|
139
|
-
[key: string]: "
|
|
139
|
+
[key: string]: "no" | "yes";
|
|
140
140
|
} | undefined;
|
|
141
141
|
variants?: boolean | undefined;
|
|
142
142
|
} | undefined;
|
|
@@ -172,7 +172,7 @@ declare const unstable_getServerSideProps: next.GetServerSideProps<{
|
|
|
172
172
|
} | undefined;
|
|
173
173
|
_overridability?: {
|
|
174
174
|
parameters?: {
|
|
175
|
-
[key: string]: "
|
|
175
|
+
[key: string]: "no" | "yes";
|
|
176
176
|
} | undefined;
|
|
177
177
|
variants?: boolean | undefined;
|
|
178
178
|
} | undefined;
|
|
@@ -255,7 +255,7 @@ declare const unstable_getStaticProps: next.GetStaticProps<{
|
|
|
255
255
|
} | undefined;
|
|
256
256
|
_overridability?: {
|
|
257
257
|
parameters?: {
|
|
258
|
-
[key: string]: "
|
|
258
|
+
[key: string]: "no" | "yes";
|
|
259
259
|
} | undefined;
|
|
260
260
|
variants?: boolean | undefined;
|
|
261
261
|
} | undefined;
|
|
@@ -291,7 +291,7 @@ declare const unstable_getStaticProps: next.GetStaticProps<{
|
|
|
291
291
|
} | undefined;
|
|
292
292
|
_overridability?: {
|
|
293
293
|
parameters?: {
|
|
294
|
-
[key: string]: "
|
|
294
|
+
[key: string]: "no" | "yes";
|
|
295
295
|
} | undefined;
|
|
296
296
|
variants?: boolean | undefined;
|
|
297
297
|
} | undefined;
|
package/dist/route/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/route/index.ts
|
|
@@ -41,6 +31,160 @@ module.exports = __toCommonJS(route_exports);
|
|
|
41
31
|
|
|
42
32
|
// src/project-map/withUniformGetServerSideProps.ts
|
|
43
33
|
var import_canvas = require("@uniformdev/canvas");
|
|
34
|
+
|
|
35
|
+
// src/logging/logCompositionIssues.ts
|
|
36
|
+
var import_colorette = require("colorette");
|
|
37
|
+
function logCompositionIssues(prefix, issues, colour = "red") {
|
|
38
|
+
const reversedIssues = [...issues].reverse();
|
|
39
|
+
const colours = { red: import_colorette.red, green: import_colorette.green, yellow: import_colorette.yellow, white: import_colorette.white };
|
|
40
|
+
console.error(
|
|
41
|
+
`${colours[colour](prefix)}
|
|
42
|
+
${reversedIssues.map(
|
|
43
|
+
(issue) => `${colours[colour](">")} ${(0, import_colorette.italic)((0, import_colorette.gray)(indent(issue.type.toUpperCase(), 7)))} ${renderIssue(issue)}`
|
|
44
|
+
).join("\n")}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function renderIssue(issue) {
|
|
48
|
+
var _a;
|
|
49
|
+
let path;
|
|
50
|
+
let type;
|
|
51
|
+
let message = issue.message;
|
|
52
|
+
let detail;
|
|
53
|
+
if (issue.type !== "config") {
|
|
54
|
+
path = issue.componentPath;
|
|
55
|
+
type = issue.componentType;
|
|
56
|
+
message = issue.message;
|
|
57
|
+
}
|
|
58
|
+
if (issue.type === "binding") {
|
|
59
|
+
detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
|
|
60
|
+
} else if (issue.type === "data") {
|
|
61
|
+
detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
|
|
62
|
+
}
|
|
63
|
+
if (issue.type === "input") {
|
|
64
|
+
detail = issue.inputName;
|
|
65
|
+
}
|
|
66
|
+
let result = `${(0, import_colorette.white)(blockify(message))}`;
|
|
67
|
+
if (detail) {
|
|
68
|
+
result += `
|
|
69
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`${detail}`)}`;
|
|
70
|
+
}
|
|
71
|
+
if (path && type) {
|
|
72
|
+
result += `
|
|
73
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`Occurred on component ${type} at slot path ${path}`)}`;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
function indent(str, len) {
|
|
78
|
+
const indent2 = len != null ? len : 10;
|
|
79
|
+
return str.padStart(indent2);
|
|
80
|
+
}
|
|
81
|
+
function blockify(str, len) {
|
|
82
|
+
const indentSize = len != null ? len : 10;
|
|
83
|
+
return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/logging/logCompositionResponse.ts
|
|
87
|
+
var import_colorette2 = require("colorette");
|
|
88
|
+
function logCompositionResponse(compositionApiResponse, duration) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const resErrors = (_a = compositionApiResponse.errors) != null ? _a : [];
|
|
91
|
+
const resWarnings = (_b = compositionApiResponse.warnings) != null ? _b : [];
|
|
92
|
+
if (resErrors.length > 0) {
|
|
93
|
+
logCompositionIssues(
|
|
94
|
+
`Composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
|
|
95
|
+
resErrors,
|
|
96
|
+
"red"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (resWarnings.length > 0) {
|
|
100
|
+
logCompositionIssues(
|
|
101
|
+
`Composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
|
|
102
|
+
resWarnings,
|
|
103
|
+
"yellow"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (compositionApiResponse.diagnostics) {
|
|
107
|
+
console.log(`
|
|
108
|
+
Diagnostics`);
|
|
109
|
+
const { compositionFetch, data } = compositionApiResponse.diagnostics;
|
|
110
|
+
const table = {
|
|
111
|
+
[`${(0, import_colorette2.white)("Composition")}`]: {
|
|
112
|
+
"Duration (ms)": resolveDiagnosticsDuration(compositionFetch),
|
|
113
|
+
"Edge Cached": compositionFetch == null ? void 0 : compositionFetch.cacheHit
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (data) {
|
|
117
|
+
data.forEach((d) => {
|
|
118
|
+
table[d.dataName] = {
|
|
119
|
+
"Duration (ms)": resolveDiagnosticsDuration(d.performance),
|
|
120
|
+
"Edge Cached": d.performance.cacheHit,
|
|
121
|
+
"Retry Count": d.performance.retryCount
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
table["Total Response"] = {
|
|
126
|
+
"Duration (ms)": duration != null ? duration : "no data"
|
|
127
|
+
};
|
|
128
|
+
console.table(table);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function resolveDiagnosticsDuration(data) {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if (!data) {
|
|
134
|
+
return "no data";
|
|
135
|
+
}
|
|
136
|
+
return (_b = (_a = data.duration) != null ? _a : data.total) != null ? _b : "no data";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/logging/logCompositionRouteResponse.ts
|
|
140
|
+
var import_colorette3 = require("colorette");
|
|
141
|
+
function logRouteCompositionResponse(matched, duration) {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const resErrors = (_a = matched.compositionApiResponse.errors) != null ? _a : [];
|
|
144
|
+
const resWarnings = (_b = matched.compositionApiResponse.warnings) != null ? _b : [];
|
|
145
|
+
const colour = resErrors.length > 0 ? import_colorette3.red : resWarnings.length > 0 ? import_colorette3.yellow : import_colorette3.green;
|
|
146
|
+
console.log(`${colour("Matched")} ${matched.type} ${matched.matchedRoute} (${duration}ms)`);
|
|
147
|
+
if (matched.dynamicInputs) {
|
|
148
|
+
const entries = Object.entries(matched.dynamicInputs);
|
|
149
|
+
if (entries.length > 0) {
|
|
150
|
+
console.log(
|
|
151
|
+
` ${(0, import_colorette3.gray)("Matched dynamic inputs:\n ")}`,
|
|
152
|
+
entries.map(([k, v]) => `${k}: ${v}`).join("\n ")
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
logCompositionResponse(matched.compositionApiResponse, duration);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/logging/logNotFoundRouteResponse.ts
|
|
160
|
+
var import_colorette4 = require("colorette");
|
|
161
|
+
function logNotFoundRouteResponse(_matched, duration) {
|
|
162
|
+
console.log(`${(0, import_colorette4.yellow)("Not found")} no project map or redirect path match (${duration}ms)`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/logging/logRedirectRouteResponse.ts
|
|
166
|
+
var import_colorette5 = require("colorette");
|
|
167
|
+
function logRedirectRouteResponse(matched, duration) {
|
|
168
|
+
console.log(
|
|
169
|
+
`${(0, import_colorette5.green)("Matched")} ${matched.type} ${matched.matchedRoute} (${duration}ms)
|
|
170
|
+
Target: ${matched.redirect.targetUrl}`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/logging/logRouteResponse.ts
|
|
175
|
+
function logRouteResponse(response, duration) {
|
|
176
|
+
if (response.type === "redirect") {
|
|
177
|
+
logRedirectRouteResponse(response, duration);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (response.type === "notFound") {
|
|
181
|
+
logNotFoundRouteResponse(response, duration);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
logRouteCompositionResponse(response, duration);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/project-map/withUniformGetServerSideProps.ts
|
|
44
188
|
var withUniformGetServerSideProps = (options) => {
|
|
45
189
|
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
46
190
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
@@ -71,7 +215,7 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
71
215
|
const duration = Date.now() - time;
|
|
72
216
|
composition = response.composition;
|
|
73
217
|
if (!(options == null ? void 0 : options.silent)) {
|
|
74
|
-
|
|
218
|
+
logCompositionResponse(response, duration);
|
|
75
219
|
}
|
|
76
220
|
} catch (e) {
|
|
77
221
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -167,7 +311,7 @@ var withUniformGetStaticProps = (options) => {
|
|
|
167
311
|
const duration = Date.now() - time;
|
|
168
312
|
composition = response.composition;
|
|
169
313
|
if (!(options == null ? void 0 : options.silent)) {
|
|
170
|
-
|
|
314
|
+
logCompositionResponse(response, duration);
|
|
171
315
|
}
|
|
172
316
|
} catch (e) {
|
|
173
317
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -195,8 +339,7 @@ var import_redirect = require("@uniformdev/redirect");
|
|
|
195
339
|
|
|
196
340
|
// src/route/createRouteFetcher.ts
|
|
197
341
|
var import_canvas4 = require("@uniformdev/canvas");
|
|
198
|
-
var
|
|
199
|
-
var { red } = import_ansi_colors.default;
|
|
342
|
+
var import_colorette6 = require("colorette");
|
|
200
343
|
function createRouteFetcher(options) {
|
|
201
344
|
const {
|
|
202
345
|
handleNotFound,
|
|
@@ -292,7 +435,7 @@ function createRouteFetcher(options) {
|
|
|
292
435
|
});
|
|
293
436
|
const duration = Date.now() - time;
|
|
294
437
|
if (!silent) {
|
|
295
|
-
|
|
438
|
+
logRouteResponse(response, duration);
|
|
296
439
|
}
|
|
297
440
|
if (response.type === "redirect") {
|
|
298
441
|
return invokeRedirectResult(response, duration);
|
|
@@ -306,7 +449,7 @@ function createRouteFetcher(options) {
|
|
|
306
449
|
}
|
|
307
450
|
return handleResult;
|
|
308
451
|
} catch (e) {
|
|
309
|
-
console.error(red("Failed to fetch route"), e);
|
|
452
|
+
console.error((0, import_colorette6.red)("Failed to fetch route"), e);
|
|
310
453
|
if (e instanceof import_canvas4.ApiClientError) {
|
|
311
454
|
if (e.statusCode === 404) {
|
|
312
455
|
return invokeNotFoundResult({ type: "notFound" }, 0);
|
package/dist/route/index.mjs
CHANGED
|
@@ -1,10 +1,61 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withUniformGetStaticPaths
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-23O4NSDU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
logCompositionResponse
|
|
6
|
+
} from "../chunk-6IDBHA5X.mjs";
|
|
4
7
|
import {
|
|
5
8
|
resolveSlugFromParams
|
|
6
9
|
} from "../chunk-TR7V6ABJ.mjs";
|
|
7
10
|
|
|
11
|
+
// src/logging/logCompositionRouteResponse.ts
|
|
12
|
+
import { gray, green, red, yellow } from "colorette";
|
|
13
|
+
function logRouteCompositionResponse(matched, duration) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const resErrors = (_a = matched.compositionApiResponse.errors) != null ? _a : [];
|
|
16
|
+
const resWarnings = (_b = matched.compositionApiResponse.warnings) != null ? _b : [];
|
|
17
|
+
const colour = resErrors.length > 0 ? red : resWarnings.length > 0 ? yellow : green;
|
|
18
|
+
console.log(`${colour("Matched")} ${matched.type} ${matched.matchedRoute} (${duration}ms)`);
|
|
19
|
+
if (matched.dynamicInputs) {
|
|
20
|
+
const entries = Object.entries(matched.dynamicInputs);
|
|
21
|
+
if (entries.length > 0) {
|
|
22
|
+
console.log(
|
|
23
|
+
` ${gray("Matched dynamic inputs:\n ")}`,
|
|
24
|
+
entries.map(([k, v]) => `${k}: ${v}`).join("\n ")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
logCompositionResponse(matched.compositionApiResponse, duration);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/logging/logNotFoundRouteResponse.ts
|
|
32
|
+
import { yellow as yellow2 } from "colorette";
|
|
33
|
+
function logNotFoundRouteResponse(_matched, duration) {
|
|
34
|
+
console.log(`${yellow2("Not found")} no project map or redirect path match (${duration}ms)`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/logging/logRedirectRouteResponse.ts
|
|
38
|
+
import { green as green2 } from "colorette";
|
|
39
|
+
function logRedirectRouteResponse(matched, duration) {
|
|
40
|
+
console.log(
|
|
41
|
+
`${green2("Matched")} ${matched.type} ${matched.matchedRoute} (${duration}ms)
|
|
42
|
+
Target: ${matched.redirect.targetUrl}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/logging/logRouteResponse.ts
|
|
47
|
+
function logRouteResponse(response, duration) {
|
|
48
|
+
if (response.type === "redirect") {
|
|
49
|
+
logRedirectRouteResponse(response, duration);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (response.type === "notFound") {
|
|
53
|
+
logNotFoundRouteResponse(response, duration);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
logRouteCompositionResponse(response, duration);
|
|
57
|
+
}
|
|
58
|
+
|
|
8
59
|
// src/route/withUniformGetServerSideProps.ts
|
|
9
60
|
import { RedirectClient } from "@uniformdev/redirect";
|
|
10
61
|
|
|
@@ -12,11 +63,9 @@ import { RedirectClient } from "@uniformdev/redirect";
|
|
|
12
63
|
import {
|
|
13
64
|
ApiClientError,
|
|
14
65
|
EMPTY_COMPOSITION,
|
|
15
|
-
logRouteResponse,
|
|
16
66
|
unstable_RouteClient
|
|
17
67
|
} from "@uniformdev/canvas";
|
|
18
|
-
import
|
|
19
|
-
var { red } = ansicolors;
|
|
68
|
+
import { red as red2 } from "colorette";
|
|
20
69
|
function createRouteFetcher(options) {
|
|
21
70
|
const {
|
|
22
71
|
handleNotFound,
|
|
@@ -126,7 +175,7 @@ function createRouteFetcher(options) {
|
|
|
126
175
|
}
|
|
127
176
|
return handleResult;
|
|
128
177
|
} catch (e) {
|
|
129
|
-
console.error(
|
|
178
|
+
console.error(red2("Failed to fetch route"), e);
|
|
130
179
|
if (e instanceof ApiClientError) {
|
|
131
180
|
if (e.statusCode === 404) {
|
|
132
181
|
return invokeNotFoundResult({ type: "notFound" }, 0);
|
package/dist/slug/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare const withUniformGetServerSideProps: <TProps extends {
|
|
|
28
28
|
withComponentIDs?: boolean | undefined;
|
|
29
29
|
withTotalCount?: boolean | undefined;
|
|
30
30
|
withUIStatus?: boolean | undefined;
|
|
31
|
+
withContentSourceMap?: boolean | undefined;
|
|
31
32
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
|
|
32
33
|
callback?: UniformGetServerSideProps<TProps> | undefined;
|
|
33
34
|
/** Disables logging of response information and timings */
|
|
@@ -73,6 +74,7 @@ declare const withUniformGetStaticProps: <TProps extends {
|
|
|
73
74
|
withComponentIDs?: boolean | undefined;
|
|
74
75
|
withTotalCount?: boolean | undefined;
|
|
75
76
|
withUIStatus?: boolean | undefined;
|
|
77
|
+
withContentSourceMap?: boolean | undefined;
|
|
76
78
|
} & Required<Pick<_uniformdev_canvas.CompositionGetParameters, "slug">> & DataResolutionOption>, "state"> | undefined;
|
|
77
79
|
/** Custom handler to specify return value and modify composition - e.g. enhance with CMS data */
|
|
78
80
|
callback?: UniformGetStaticProps<TProps> | undefined;
|
package/dist/slug/index.js
CHANGED
|
@@ -31,6 +31,112 @@ module.exports = __toCommonJS(slug_exports);
|
|
|
31
31
|
|
|
32
32
|
// src/slug/withUniformGetServerSideProps.ts
|
|
33
33
|
var import_canvas = require("@uniformdev/canvas");
|
|
34
|
+
|
|
35
|
+
// src/logging/logCompositionIssues.ts
|
|
36
|
+
var import_colorette = require("colorette");
|
|
37
|
+
function logCompositionIssues(prefix, issues, colour = "red") {
|
|
38
|
+
const reversedIssues = [...issues].reverse();
|
|
39
|
+
const colours = { red: import_colorette.red, green: import_colorette.green, yellow: import_colorette.yellow, white: import_colorette.white };
|
|
40
|
+
console.error(
|
|
41
|
+
`${colours[colour](prefix)}
|
|
42
|
+
${reversedIssues.map(
|
|
43
|
+
(issue) => `${colours[colour](">")} ${(0, import_colorette.italic)((0, import_colorette.gray)(indent(issue.type.toUpperCase(), 7)))} ${renderIssue(issue)}`
|
|
44
|
+
).join("\n")}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function renderIssue(issue) {
|
|
48
|
+
var _a;
|
|
49
|
+
let path;
|
|
50
|
+
let type;
|
|
51
|
+
let message = issue.message;
|
|
52
|
+
let detail;
|
|
53
|
+
if (issue.type !== "config") {
|
|
54
|
+
path = issue.componentPath;
|
|
55
|
+
type = issue.componentType;
|
|
56
|
+
message = issue.message;
|
|
57
|
+
}
|
|
58
|
+
if (issue.type === "binding") {
|
|
59
|
+
detail = `Binding expression: ${(_a = issue.expression) == null ? void 0 : _a.pointer}`;
|
|
60
|
+
} else if (issue.type === "data") {
|
|
61
|
+
detail = `Data resource name: ${issue.dataName}, data type: ${issue.dataType}`;
|
|
62
|
+
}
|
|
63
|
+
if (issue.type === "input") {
|
|
64
|
+
detail = issue.inputName;
|
|
65
|
+
}
|
|
66
|
+
let result = `${(0, import_colorette.white)(blockify(message))}`;
|
|
67
|
+
if (detail) {
|
|
68
|
+
result += `
|
|
69
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`${detail}`)}`;
|
|
70
|
+
}
|
|
71
|
+
if (path && type) {
|
|
72
|
+
result += `
|
|
73
|
+
${indent(" ", 10)}${(0, import_colorette.gray)(`Occurred on component ${type} at slot path ${path}`)}`;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
function indent(str, len) {
|
|
78
|
+
const indent2 = len != null ? len : 10;
|
|
79
|
+
return str.padStart(indent2);
|
|
80
|
+
}
|
|
81
|
+
function blockify(str, len) {
|
|
82
|
+
const indentSize = len != null ? len : 10;
|
|
83
|
+
return str.split("\n").map((line, index) => index === 0 ? line : `${indent(" ", indentSize)}${line}`).join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/logging/logCompositionResponse.ts
|
|
87
|
+
var import_colorette2 = require("colorette");
|
|
88
|
+
function logCompositionResponse(compositionApiResponse, duration) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const resErrors = (_a = compositionApiResponse.errors) != null ? _a : [];
|
|
91
|
+
const resWarnings = (_b = compositionApiResponse.warnings) != null ? _b : [];
|
|
92
|
+
if (resErrors.length > 0) {
|
|
93
|
+
logCompositionIssues(
|
|
94
|
+
`Composition data error${resErrors.length === 1 ? "" : "s"}; some content may be missing`,
|
|
95
|
+
resErrors,
|
|
96
|
+
"red"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (resWarnings.length > 0) {
|
|
100
|
+
logCompositionIssues(
|
|
101
|
+
`Composition data warning${resWarnings.length === 1 ? "" : "s"}; some content may be missing`,
|
|
102
|
+
resWarnings,
|
|
103
|
+
"yellow"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (compositionApiResponse.diagnostics) {
|
|
107
|
+
console.log(`
|
|
108
|
+
Diagnostics`);
|
|
109
|
+
const { compositionFetch, data } = compositionApiResponse.diagnostics;
|
|
110
|
+
const table = {
|
|
111
|
+
[`${(0, import_colorette2.white)("Composition")}`]: {
|
|
112
|
+
"Duration (ms)": resolveDiagnosticsDuration(compositionFetch),
|
|
113
|
+
"Edge Cached": compositionFetch == null ? void 0 : compositionFetch.cacheHit
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (data) {
|
|
117
|
+
data.forEach((d) => {
|
|
118
|
+
table[d.dataName] = {
|
|
119
|
+
"Duration (ms)": resolveDiagnosticsDuration(d.performance),
|
|
120
|
+
"Edge Cached": d.performance.cacheHit,
|
|
121
|
+
"Retry Count": d.performance.retryCount
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
table["Total Response"] = {
|
|
126
|
+
"Duration (ms)": duration != null ? duration : "no data"
|
|
127
|
+
};
|
|
128
|
+
console.table(table);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function resolveDiagnosticsDuration(data) {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if (!data) {
|
|
134
|
+
return "no data";
|
|
135
|
+
}
|
|
136
|
+
return (_b = (_a = data.duration) != null ? _a : data.total) != null ? _b : "no data";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/slug/withUniformGetServerSideProps.ts
|
|
34
140
|
var withUniformGetServerSideProps = (options) => {
|
|
35
141
|
const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
|
|
36
142
|
apiKey: process.env.UNIFORM_API_KEY,
|
|
@@ -59,7 +165,7 @@ var withUniformGetServerSideProps = (options) => {
|
|
|
59
165
|
const duration = Date.now() - time;
|
|
60
166
|
composition = response.composition;
|
|
61
167
|
if (!(options == null ? void 0 : options.silent)) {
|
|
62
|
-
|
|
168
|
+
logCompositionResponse(response, duration);
|
|
63
169
|
}
|
|
64
170
|
} catch (e) {
|
|
65
171
|
console.error("[canvas-next] Failed to fetch composition", e);
|
|
@@ -150,7 +256,7 @@ var withUniformGetStaticProps = (options) => {
|
|
|
150
256
|
const duration = Date.now() - time;
|
|
151
257
|
composition = response.composition;
|
|
152
258
|
if (!(options == null ? void 0 : options.silent)) {
|
|
153
|
-
|
|
259
|
+
logCompositionResponse(response, duration);
|
|
154
260
|
}
|
|
155
261
|
} catch (e) {
|
|
156
262
|
console.error("[canvas-next] Failed to fetch composition", e);
|
package/dist/slug/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logCompositionResponse
|
|
3
|
+
} from "../chunk-6IDBHA5X.mjs";
|
|
1
4
|
import {
|
|
2
5
|
resolveSlugFromParams
|
|
3
6
|
} from "../chunk-TR7V6ABJ.mjs";
|
|
@@ -7,8 +10,7 @@ import {
|
|
|
7
10
|
CANVAS_DRAFT_STATE,
|
|
8
11
|
CANVAS_PUBLISHED_STATE,
|
|
9
12
|
CanvasClient,
|
|
10
|
-
EMPTY_COMPOSITION
|
|
11
|
-
logCompositionResponse
|
|
13
|
+
EMPTY_COMPOSITION
|
|
12
14
|
} from "@uniformdev/canvas";
|
|
13
15
|
var withUniformGetServerSideProps = (options) => {
|
|
14
16
|
const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
|
|
@@ -92,8 +94,7 @@ import {
|
|
|
92
94
|
CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
|
|
93
95
|
CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
|
|
94
96
|
CanvasClient as CanvasClient3,
|
|
95
|
-
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
96
|
-
logCompositionResponse as logCompositionResponse2
|
|
97
|
+
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
97
98
|
} from "@uniformdev/canvas";
|
|
98
99
|
var withUniformGetStaticProps = (options) => {
|
|
99
100
|
var _a;
|
|
@@ -127,7 +128,7 @@ var withUniformGetStaticProps = (options) => {
|
|
|
127
128
|
const duration = Date.now() - time;
|
|
128
129
|
composition = response.composition;
|
|
129
130
|
if (!(options == null ? void 0 : options.silent)) {
|
|
130
|
-
|
|
131
|
+
logCompositionResponse(response, duration);
|
|
131
132
|
}
|
|
132
133
|
} catch (e) {
|
|
133
134
|
console.error("[canvas-next] Failed to fetch composition", e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next",
|
|
3
|
-
"version": "19.14.
|
|
3
|
+
"version": "19.14.1-alpha.11+89dabee14",
|
|
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,12 @@
|
|
|
63
63
|
"document": "api-extractor run --local"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@uniformdev/canvas": "19.14.
|
|
67
|
-
"@uniformdev/canvas-react": "19.14.
|
|
68
|
-
"@uniformdev/project-map": "19.14.
|
|
69
|
-
"@uniformdev/redirect": "19.14.
|
|
70
|
-
"
|
|
66
|
+
"@uniformdev/canvas": "19.14.1-alpha.11+89dabee14",
|
|
67
|
+
"@uniformdev/canvas-react": "19.14.1-alpha.11+89dabee14",
|
|
68
|
+
"@uniformdev/project-map": "19.14.1-alpha.11+89dabee14",
|
|
69
|
+
"@uniformdev/redirect": "19.14.1-alpha.11+89dabee14",
|
|
70
|
+
"@uniformdev/richtext": "19.14.1-alpha.11+89dabee14",
|
|
71
|
+
"colorette": "2.0.20"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
74
|
"next": ">= 12.0.0",
|
|
@@ -86,5 +87,5 @@
|
|
|
86
87
|
"publishConfig": {
|
|
87
88
|
"access": "public"
|
|
88
89
|
},
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "89dabee148728ef7f329e18b7194766a9e6b9631"
|
|
90
91
|
}
|