@uniformdev/canvas-next 19.14.1-alpha.11 → 19.14.1

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.
@@ -1,6 +1,3 @@
1
- import {
2
- logCompositionResponse
3
- } from "./chunk-6IDBHA5X.mjs";
4
1
  import {
5
2
  resolveSlugFromParams
6
3
  } from "./chunk-TR7V6ABJ.mjs";
@@ -10,7 +7,8 @@ import {
10
7
  CANVAS_DRAFT_STATE,
11
8
  CANVAS_PUBLISHED_STATE,
12
9
  CanvasClient,
13
- EMPTY_COMPOSITION
10
+ EMPTY_COMPOSITION,
11
+ logCompositionResponse
14
12
  } from "@uniformdev/canvas";
15
13
  var withUniformGetServerSideProps = (options) => {
16
14
  const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
@@ -97,7 +95,8 @@ import {
97
95
  CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
98
96
  CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
99
97
  CanvasClient as CanvasClient2,
100
- EMPTY_COMPOSITION as EMPTY_COMPOSITION2
98
+ EMPTY_COMPOSITION as EMPTY_COMPOSITION2,
99
+ logCompositionResponse as logCompositionResponse2
101
100
  } from "@uniformdev/canvas";
102
101
  var withUniformGetStaticProps = (options) => {
103
102
  var _a;
@@ -133,7 +132,7 @@ var withUniformGetStaticProps = (options) => {
133
132
  const duration = Date.now() - time;
134
133
  composition = response.composition;
135
134
  if (!(options == null ? void 0 : options.silent)) {
136
- logCompositionResponse(response, duration);
135
+ logCompositionResponse2(response, duration);
137
136
  }
138
137
  } catch (e) {
139
138
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -31,112 +31,6 @@ 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
140
34
  var withUniformGetServerSideProps = (options) => {
141
35
  const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
142
36
  apiKey: process.env.UNIFORM_API_KEY,
@@ -167,7 +61,7 @@ var withUniformGetServerSideProps = (options) => {
167
61
  const duration = Date.now() - time;
168
62
  composition = response.composition;
169
63
  if (!(options == null ? void 0 : options.silent)) {
170
- logCompositionResponse(response, duration);
64
+ (0, import_canvas.logCompositionResponse)(response, duration);
171
65
  }
172
66
  } catch (e) {
173
67
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -263,7 +157,7 @@ var withUniformGetStaticProps = (options) => {
263
157
  const duration = Date.now() - time;
264
158
  composition = response.composition;
265
159
  if (!(options == null ? void 0 : options.silent)) {
266
- logCompositionResponse(response, duration);
160
+ (0, import_canvas3.logCompositionResponse)(response, duration);
267
161
  }
268
162
  } catch (e) {
269
163
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -5,8 +5,7 @@ import {
5
5
  withUniformGetServerSideProps,
6
6
  withUniformGetStaticPaths,
7
7
  withUniformGetStaticProps
8
- } from "../chunk-23O4NSDU.mjs";
9
- import "../chunk-6IDBHA5X.mjs";
8
+ } from "../chunk-ZOXJSPVQ.mjs";
10
9
  import "../chunk-TR7V6ABJ.mjs";
11
10
  export {
12
11
  getServerSideProps,
@@ -136,7 +136,7 @@ declare const unstable_getServerSideProps: next.GetServerSideProps<{
136
136
  } | undefined;
137
137
  _overridability?: {
138
138
  parameters?: {
139
- [key: string]: "no" | "yes";
139
+ [key: string]: "yes" | "no";
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]: "no" | "yes";
175
+ [key: string]: "yes" | "no";
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]: "no" | "yes";
258
+ [key: string]: "yes" | "no";
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]: "no" | "yes";
294
+ [key: string]: "yes" | "no";
295
295
  } | undefined;
296
296
  variants?: boolean | undefined;
297
297
  } | undefined;
@@ -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,6 +17,14 @@ 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/route/index.ts
@@ -31,160 +41,6 @@ module.exports = __toCommonJS(route_exports);
31
41
 
32
42
  // src/project-map/withUniformGetServerSideProps.ts
33
43
  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
188
44
  var withUniformGetServerSideProps = (options) => {
189
45
  const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
190
46
  apiKey: process.env.UNIFORM_API_KEY,
@@ -215,7 +71,7 @@ var withUniformGetServerSideProps = (options) => {
215
71
  const duration = Date.now() - time;
216
72
  composition = response.composition;
217
73
  if (!(options == null ? void 0 : options.silent)) {
218
- logCompositionResponse(response, duration);
74
+ (0, import_canvas.logCompositionResponse)(response, duration);
219
75
  }
220
76
  } catch (e) {
221
77
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -311,7 +167,7 @@ var withUniformGetStaticProps = (options) => {
311
167
  const duration = Date.now() - time;
312
168
  composition = response.composition;
313
169
  if (!(options == null ? void 0 : options.silent)) {
314
- logCompositionResponse(response, duration);
170
+ (0, import_canvas3.logCompositionResponse)(response, duration);
315
171
  }
316
172
  } catch (e) {
317
173
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -339,7 +195,8 @@ var import_redirect = require("@uniformdev/redirect");
339
195
 
340
196
  // src/route/createRouteFetcher.ts
341
197
  var import_canvas4 = require("@uniformdev/canvas");
342
- var import_colorette6 = require("colorette");
198
+ var import_ansi_colors = __toESM(require("ansi-colors"));
199
+ var { red } = import_ansi_colors.default;
343
200
  function createRouteFetcher(options) {
344
201
  const {
345
202
  handleNotFound,
@@ -435,7 +292,7 @@ function createRouteFetcher(options) {
435
292
  });
436
293
  const duration = Date.now() - time;
437
294
  if (!silent) {
438
- logRouteResponse(response, duration);
295
+ (0, import_canvas4.logRouteResponse)(response, duration);
439
296
  }
440
297
  if (response.type === "redirect") {
441
298
  return invokeRedirectResult(response, duration);
@@ -449,7 +306,7 @@ function createRouteFetcher(options) {
449
306
  }
450
307
  return handleResult;
451
308
  } catch (e) {
452
- console.error((0, import_colorette6.red)("Failed to fetch route"), e);
309
+ console.error(red("Failed to fetch route"), e);
453
310
  if (e instanceof import_canvas4.ApiClientError) {
454
311
  if (e.statusCode === 404) {
455
312
  return invokeNotFoundResult({ type: "notFound" }, 0);
@@ -1,61 +1,10 @@
1
1
  import {
2
2
  withUniformGetStaticPaths
3
- } from "../chunk-23O4NSDU.mjs";
4
- import {
5
- logCompositionResponse
6
- } from "../chunk-6IDBHA5X.mjs";
3
+ } from "../chunk-ZOXJSPVQ.mjs";
7
4
  import {
8
5
  resolveSlugFromParams
9
6
  } from "../chunk-TR7V6ABJ.mjs";
10
7
 
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
-
59
8
  // src/route/withUniformGetServerSideProps.ts
60
9
  import { RedirectClient } from "@uniformdev/redirect";
61
10
 
@@ -63,9 +12,11 @@ import { RedirectClient } from "@uniformdev/redirect";
63
12
  import {
64
13
  ApiClientError,
65
14
  EMPTY_COMPOSITION,
15
+ logRouteResponse,
66
16
  unstable_RouteClient
67
17
  } from "@uniformdev/canvas";
68
- import { red as red2 } from "colorette";
18
+ import ansicolors from "ansi-colors";
19
+ var { red } = ansicolors;
69
20
  function createRouteFetcher(options) {
70
21
  const {
71
22
  handleNotFound,
@@ -175,7 +126,7 @@ function createRouteFetcher(options) {
175
126
  }
176
127
  return handleResult;
177
128
  } catch (e) {
178
- console.error(red2("Failed to fetch route"), e);
129
+ console.error(red("Failed to fetch route"), e);
179
130
  if (e instanceof ApiClientError) {
180
131
  if (e.statusCode === 404) {
181
132
  return invokeNotFoundResult({ type: "notFound" }, 0);
@@ -31,112 +31,6 @@ 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
140
34
  var withUniformGetServerSideProps = (options) => {
141
35
  const canvasClient = (options == null ? void 0 : options.client) || new import_canvas.CanvasClient({
142
36
  apiKey: process.env.UNIFORM_API_KEY,
@@ -165,7 +59,7 @@ var withUniformGetServerSideProps = (options) => {
165
59
  const duration = Date.now() - time;
166
60
  composition = response.composition;
167
61
  if (!(options == null ? void 0 : options.silent)) {
168
- logCompositionResponse(response, duration);
62
+ (0, import_canvas.logCompositionResponse)(response, duration);
169
63
  }
170
64
  } catch (e) {
171
65
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -256,7 +150,7 @@ var withUniformGetStaticProps = (options) => {
256
150
  const duration = Date.now() - time;
257
151
  composition = response.composition;
258
152
  if (!(options == null ? void 0 : options.silent)) {
259
- logCompositionResponse(response, duration);
153
+ (0, import_canvas3.logCompositionResponse)(response, duration);
260
154
  }
261
155
  } catch (e) {
262
156
  console.error("[canvas-next] Failed to fetch composition", e);
@@ -1,6 +1,3 @@
1
- import {
2
- logCompositionResponse
3
- } from "../chunk-6IDBHA5X.mjs";
4
1
  import {
5
2
  resolveSlugFromParams
6
3
  } from "../chunk-TR7V6ABJ.mjs";
@@ -10,7 +7,8 @@ import {
10
7
  CANVAS_DRAFT_STATE,
11
8
  CANVAS_PUBLISHED_STATE,
12
9
  CanvasClient,
13
- EMPTY_COMPOSITION
10
+ EMPTY_COMPOSITION,
11
+ logCompositionResponse
14
12
  } from "@uniformdev/canvas";
15
13
  var withUniformGetServerSideProps = (options) => {
16
14
  const canvasClient = (options == null ? void 0 : options.client) || new CanvasClient({
@@ -94,7 +92,8 @@ import {
94
92
  CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3,
95
93
  CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3,
96
94
  CanvasClient as CanvasClient3,
97
- EMPTY_COMPOSITION as EMPTY_COMPOSITION2
95
+ EMPTY_COMPOSITION as EMPTY_COMPOSITION2,
96
+ logCompositionResponse as logCompositionResponse2
98
97
  } from "@uniformdev/canvas";
99
98
  var withUniformGetStaticProps = (options) => {
100
99
  var _a;
@@ -128,7 +127,7 @@ var withUniformGetStaticProps = (options) => {
128
127
  const duration = Date.now() - time;
129
128
  composition = response.composition;
130
129
  if (!(options == null ? void 0 : options.silent)) {
131
- logCompositionResponse(response, duration);
130
+ logCompositionResponse2(response, duration);
132
131
  }
133
132
  } catch (e) {
134
133
  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.1-alpha.11+89dabee14",
3
+ "version": "19.14.1",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -63,12 +63,12 @@
63
63
  "document": "api-extractor run --local"
64
64
  },
65
65
  "dependencies": {
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"
66
+ "@uniformdev/canvas": "19.14.1",
67
+ "@uniformdev/canvas-react": "19.14.1",
68
+ "@uniformdev/project-map": "19.14.1",
69
+ "@uniformdev/redirect": "19.14.1",
70
+ "@uniformdev/richtext": "19.14.1",
71
+ "ansi-colors": "^4.1.3"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "next": ">= 12.0.0",
@@ -87,5 +87,5 @@
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  },
90
- "gitHead": "89dabee148728ef7f329e18b7194766a9e6b9631"
90
+ "gitHead": "edd5e3bb74b148c5b947109a794a3bab42384cb7"
91
91
  }
@@ -1,109 +0,0 @@
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
- };