@scalar/nextjs-api-reference 0.10.2 → 0.10.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @scalar/nextjs-api-reference
2
2
 
3
+ ## 0.10.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8466](https://github.com/scalar/scalar/pull/8466): chore: new build pipeline
8
+
9
+ ## 0.10.3
10
+
11
+ ### Patch Changes
12
+
13
+ #### Updated Dependencies
14
+
15
+ - **@scalar/core@0.4.3**
16
+
3
17
  ## 0.10.2
4
18
 
5
19
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,75 +1,86 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const addIndent = (str, spaces = 2, initialIndent = false) => {
4
- const indent = " ".repeat(spaces);
5
- const lines = str.split("\n");
6
- return lines.map((line, index) => {
7
- if (index === 0 && !initialIndent) {
8
- return line;
9
- }
10
- return `${indent}${line}`;
11
- }).join("\n");
2
+ //#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
3
+ /**
4
+ * Helper function to add consistent indentation to multiline strings
5
+ * @param str The string to indent
6
+ * @param spaces Number of spaces for each level
7
+ * @param initialIndent Whether to indent the first line
8
+ */
9
+ var addIndent = (str, spaces = 2, initialIndent = false) => {
10
+ const indent = " ".repeat(spaces);
11
+ return str.split("\n").map((line, index) => {
12
+ if (index === 0 && !initialIndent) return line;
13
+ return `${indent}${line}`;
14
+ }).join("\n");
12
15
  };
13
- const getStyles = (configuration, customTheme2) => {
14
- const styles = [];
15
- if (configuration.customCss) {
16
- styles.push("/* Custom CSS */");
17
- styles.push(configuration.customCss);
18
- }
19
- if (!configuration.theme && customTheme2) {
20
- styles.push("/* Custom Theme */");
21
- styles.push(customTheme2);
22
- }
23
- if (styles.length === 0) {
24
- return "";
25
- }
26
- return `
16
+ /**
17
+ * Generate the style tag with custom theme if needed
18
+ */
19
+ var getStyles = (configuration, customTheme) => {
20
+ const styles = [];
21
+ if (configuration.customCss) {
22
+ styles.push("/* Custom CSS */");
23
+ styles.push(configuration.customCss);
24
+ }
25
+ if (!configuration.theme && customTheme) {
26
+ styles.push("/* Custom Theme */");
27
+ styles.push(customTheme);
28
+ }
29
+ if (styles.length === 0) return "";
30
+ return `
27
31
  <style type="text/css">
28
32
  ${addIndent(styles.join("\n\n"), 6)}
29
33
  </style>`;
30
34
  };
31
- const getHtmlDocument = (givenConfiguration, customTheme2 = "") => {
32
- const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
33
- const configuration = getConfiguration({
34
- ...rest,
35
- ...theme ? { theme } : {},
36
- customCss
37
- });
38
- const content = `<!doctype html>
35
+ /**
36
+ * The HTML document to render the Scalar API reference.
37
+ *
38
+ * We must check the passed in configuration and not the configuration for the theme as the configuration will have it
39
+ * defaulted to 'default'
40
+ */
41
+ var getHtmlDocument = (givenConfiguration, customTheme = "") => {
42
+ const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
43
+ const configuration = getConfiguration({
44
+ ...rest,
45
+ ...theme ? { theme } : {},
46
+ customCss
47
+ });
48
+ return `<!doctype html>
39
49
  <html>
40
50
  <head>
41
51
  <title>${pageTitle ?? "Scalar API Reference"}</title>
42
52
  <meta charset="utf-8" />
43
53
  <meta
44
54
  name="viewport"
45
- content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme2)}
55
+ content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme)}
46
56
  </head>
47
57
  <body>
48
58
  <div id="app"></div>${getScriptTags(configuration, cdn)}
49
59
  </body>
50
60
  </html>`;
51
- return content;
52
61
  };
53
- const serializeArrayWithFunctions = (arr) => {
54
- return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
62
+ /**
63
+ * Helper function to serialize arrays that may contain functions
64
+ */
65
+ var serializeArrayWithFunctions = (arr) => {
66
+ return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
55
67
  };
68
+ /**
69
+ * The script tags to load the @scalar/api-reference package from the CDN.
70
+ */
56
71
  function getScriptTags(configuration, cdn) {
57
- const restConfig = { ...configuration };
58
- const functionProps = [];
59
- for (const [key, value] of Object.entries(configuration)) {
60
- if (typeof value === "function") {
61
- functionProps.push(`"${key}": ${value.toString()}`);
62
- delete restConfig[key];
63
- } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
64
- functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
65
- delete restConfig[key];
66
- }
67
- }
68
- const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
69
- const functionPropsString = functionProps.length ? `,
70
- ${functionProps.join(",\n ")}
71
- }` : "}";
72
- return `
72
+ const restConfig = { ...configuration };
73
+ const functionProps = [];
74
+ for (const [key, value] of Object.entries(configuration)) if (typeof value === "function") {
75
+ functionProps.push(`"${key}": ${value.toString()}`);
76
+ delete restConfig[key];
77
+ } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
78
+ functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
79
+ delete restConfig[key];
80
+ }
81
+ const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
82
+ const functionPropsString = functionProps.length ? `,\n ${functionProps.join(",\n ")}\n }` : "}";
83
+ return `
73
84
  <!-- Load the Script -->
74
85
  <script src="${cdn ?? "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"><\/script>
75
86
 
@@ -78,19 +89,21 @@ function getScriptTags(configuration, cdn) {
78
89
  Scalar.createApiReference('#app', ${configString}${functionPropsString})
79
90
  <\/script>`;
80
91
  }
81
- const getConfiguration = (givenConfiguration) => {
82
- const configuration = {
83
- ...givenConfiguration
84
- };
85
- if (typeof configuration.content === "function") {
86
- configuration.content = configuration.content();
87
- }
88
- if (configuration.content && configuration.url) {
89
- delete configuration.content;
90
- }
91
- return configuration;
92
+ /**
93
+ * The configuration to pass to the @scalar/api-reference package.
94
+ */
95
+ var getConfiguration = (givenConfiguration) => {
96
+ const configuration = { ...givenConfiguration };
97
+ if (typeof configuration.content === "function") configuration.content = configuration.content();
98
+ if (configuration.content && configuration.url) delete configuration.content;
99
+ return configuration;
92
100
  };
93
- const customTheme = `
101
+ //#endregion
102
+ //#region src/custom-theme.ts
103
+ /**
104
+ * The custom theme for Next.js
105
+ */
106
+ var customTheme = `
94
107
  /* basic theme */
95
108
  .dark-mode {
96
109
  --scalar-color-1: rgba(255, 255, 255, 0.9);
@@ -212,20 +225,32 @@ const customTheme = `
212
225
  border: 1px solid var(--scalar-border-color);
213
226
  }
214
227
  `;
215
- const DEFAULT_CONFIGURATION = {
216
- _integration: "nextjs"
217
- };
218
- const ApiReference = (givenConfiguration) => {
219
- const configuration = {
220
- ...DEFAULT_CONFIGURATION,
221
- ...givenConfiguration
222
- };
223
- return () => {
224
- const referenceDocument = getHtmlDocument(configuration, customTheme);
225
- return new Response(referenceDocument, {
226
- status: 200,
227
- headers: { "Content-Type": "text/html" }
228
- });
229
- };
228
+ //#endregion
229
+ //#region src/ApiReference.ts
230
+ /**
231
+ * The default configuration for the API Reference.
232
+ */
233
+ var DEFAULT_CONFIGURATION = { _integration: "nextjs" };
234
+ /**
235
+ * Next.js adapter for an Api Reference
236
+ *
237
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
238
+ *
239
+ * @params config - the Api Reference config object
240
+ * @params options - reserved for future use to add customization to the response
241
+ */
242
+ var ApiReference = (givenConfiguration) => {
243
+ const configuration = {
244
+ ...DEFAULT_CONFIGURATION,
245
+ ...givenConfiguration
246
+ };
247
+ return () => {
248
+ const referenceDocument = getHtmlDocument(configuration, customTheme);
249
+ return new Response(referenceDocument, {
250
+ status: 200,
251
+ headers: { "Content-Type": "text/html" }
252
+ });
253
+ };
230
254
  };
255
+ //#endregion
231
256
  exports.ApiReference = ApiReference;
package/dist/index.js CHANGED
@@ -1,73 +1,85 @@
1
- const addIndent = (str, spaces = 2, initialIndent = false) => {
2
- const indent = " ".repeat(spaces);
3
- const lines = str.split("\n");
4
- return lines.map((line, index) => {
5
- if (index === 0 && !initialIndent) {
6
- return line;
7
- }
8
- return `${indent}${line}`;
9
- }).join("\n");
1
+ //#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
2
+ /**
3
+ * Helper function to add consistent indentation to multiline strings
4
+ * @param str The string to indent
5
+ * @param spaces Number of spaces for each level
6
+ * @param initialIndent Whether to indent the first line
7
+ */
8
+ var addIndent = (str, spaces = 2, initialIndent = false) => {
9
+ const indent = " ".repeat(spaces);
10
+ return str.split("\n").map((line, index) => {
11
+ if (index === 0 && !initialIndent) return line;
12
+ return `${indent}${line}`;
13
+ }).join("\n");
10
14
  };
11
- const getStyles = (configuration, customTheme2) => {
12
- const styles = [];
13
- if (configuration.customCss) {
14
- styles.push("/* Custom CSS */");
15
- styles.push(configuration.customCss);
16
- }
17
- if (!configuration.theme && customTheme2) {
18
- styles.push("/* Custom Theme */");
19
- styles.push(customTheme2);
20
- }
21
- if (styles.length === 0) {
22
- return "";
23
- }
24
- return `
15
+ /**
16
+ * Generate the style tag with custom theme if needed
17
+ */
18
+ var getStyles = (configuration, customTheme) => {
19
+ const styles = [];
20
+ if (configuration.customCss) {
21
+ styles.push("/* Custom CSS */");
22
+ styles.push(configuration.customCss);
23
+ }
24
+ if (!configuration.theme && customTheme) {
25
+ styles.push("/* Custom Theme */");
26
+ styles.push(customTheme);
27
+ }
28
+ if (styles.length === 0) return "";
29
+ return `
25
30
  <style type="text/css">
26
31
  ${addIndent(styles.join("\n\n"), 6)}
27
32
  </style>`;
28
33
  };
29
- const getHtmlDocument = (givenConfiguration, customTheme2 = "") => {
30
- const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
31
- const configuration = getConfiguration({
32
- ...rest,
33
- ...theme ? { theme } : {},
34
- customCss
35
- });
36
- const content = `<!doctype html>
34
+ /**
35
+ * The HTML document to render the Scalar API reference.
36
+ *
37
+ * We must check the passed in configuration and not the configuration for the theme as the configuration will have it
38
+ * defaulted to 'default'
39
+ */
40
+ var getHtmlDocument = (givenConfiguration, customTheme = "") => {
41
+ const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
42
+ const configuration = getConfiguration({
43
+ ...rest,
44
+ ...theme ? { theme } : {},
45
+ customCss
46
+ });
47
+ return `<!doctype html>
37
48
  <html>
38
49
  <head>
39
50
  <title>${pageTitle ?? "Scalar API Reference"}</title>
40
51
  <meta charset="utf-8" />
41
52
  <meta
42
53
  name="viewport"
43
- content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme2)}
54
+ content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme)}
44
55
  </head>
45
56
  <body>
46
57
  <div id="app"></div>${getScriptTags(configuration, cdn)}
47
58
  </body>
48
59
  </html>`;
49
- return content;
50
60
  };
51
- const serializeArrayWithFunctions = (arr) => {
52
- return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
61
+ /**
62
+ * Helper function to serialize arrays that may contain functions
63
+ */
64
+ var serializeArrayWithFunctions = (arr) => {
65
+ return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
53
66
  };
67
+ /**
68
+ * The script tags to load the @scalar/api-reference package from the CDN.
69
+ */
54
70
  function getScriptTags(configuration, cdn) {
55
- const restConfig = { ...configuration };
56
- const functionProps = [];
57
- for (const [key, value] of Object.entries(configuration)) {
58
- if (typeof value === "function") {
59
- functionProps.push(`"${key}": ${value.toString()}`);
60
- delete restConfig[key];
61
- } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
62
- functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
63
- delete restConfig[key];
64
- }
65
- }
66
- const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
67
- const functionPropsString = functionProps.length ? `,
68
- ${functionProps.join(",\n ")}
69
- }` : "}";
70
- return `
71
+ const restConfig = { ...configuration };
72
+ const functionProps = [];
73
+ for (const [key, value] of Object.entries(configuration)) if (typeof value === "function") {
74
+ functionProps.push(`"${key}": ${value.toString()}`);
75
+ delete restConfig[key];
76
+ } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
77
+ functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
78
+ delete restConfig[key];
79
+ }
80
+ const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
81
+ const functionPropsString = functionProps.length ? `,\n ${functionProps.join(",\n ")}\n }` : "}";
82
+ return `
71
83
  <!-- Load the Script -->
72
84
  <script src="${cdn ?? "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"><\/script>
73
85
 
@@ -76,19 +88,21 @@ function getScriptTags(configuration, cdn) {
76
88
  Scalar.createApiReference('#app', ${configString}${functionPropsString})
77
89
  <\/script>`;
78
90
  }
79
- const getConfiguration = (givenConfiguration) => {
80
- const configuration = {
81
- ...givenConfiguration
82
- };
83
- if (typeof configuration.content === "function") {
84
- configuration.content = configuration.content();
85
- }
86
- if (configuration.content && configuration.url) {
87
- delete configuration.content;
88
- }
89
- return configuration;
91
+ /**
92
+ * The configuration to pass to the @scalar/api-reference package.
93
+ */
94
+ var getConfiguration = (givenConfiguration) => {
95
+ const configuration = { ...givenConfiguration };
96
+ if (typeof configuration.content === "function") configuration.content = configuration.content();
97
+ if (configuration.content && configuration.url) delete configuration.content;
98
+ return configuration;
90
99
  };
91
- const customTheme = `
100
+ //#endregion
101
+ //#region src/custom-theme.ts
102
+ /**
103
+ * The custom theme for Next.js
104
+ */
105
+ var customTheme = `
92
106
  /* basic theme */
93
107
  .dark-mode {
94
108
  --scalar-color-1: rgba(255, 255, 255, 0.9);
@@ -210,22 +224,32 @@ const customTheme = `
210
224
  border: 1px solid var(--scalar-border-color);
211
225
  }
212
226
  `;
213
- const DEFAULT_CONFIGURATION = {
214
- _integration: "nextjs"
215
- };
216
- const ApiReference = (givenConfiguration) => {
217
- const configuration = {
218
- ...DEFAULT_CONFIGURATION,
219
- ...givenConfiguration
220
- };
221
- return () => {
222
- const referenceDocument = getHtmlDocument(configuration, customTheme);
223
- return new Response(referenceDocument, {
224
- status: 200,
225
- headers: { "Content-Type": "text/html" }
226
- });
227
- };
228
- };
229
- export {
230
- ApiReference
227
+ //#endregion
228
+ //#region src/ApiReference.ts
229
+ /**
230
+ * The default configuration for the API Reference.
231
+ */
232
+ var DEFAULT_CONFIGURATION = { _integration: "nextjs" };
233
+ /**
234
+ * Next.js adapter for an Api Reference
235
+ *
236
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
237
+ *
238
+ * @params config - the Api Reference config object
239
+ * @params options - reserved for future use to add customization to the response
240
+ */
241
+ var ApiReference = (givenConfiguration) => {
242
+ const configuration = {
243
+ ...DEFAULT_CONFIGURATION,
244
+ ...givenConfiguration
245
+ };
246
+ return () => {
247
+ const referenceDocument = getHtmlDocument(configuration, customTheme);
248
+ return new Response(referenceDocument, {
249
+ status: 200,
250
+ headers: { "Content-Type": "text/html" }
251
+ });
252
+ };
231
253
  };
254
+ //#endregion
255
+ export { ApiReference };
@@ -1,77 +1,89 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@scalar/nextjs-api-reference"] = {}));
3
- })(this, (function(exports2) {
4
- "use strict";
5
- const addIndent = (str, spaces = 2, initialIndent = false) => {
6
- const indent = " ".repeat(spaces);
7
- const lines = str.split("\n");
8
- return lines.map((line, index) => {
9
- if (index === 0 && !initialIndent) {
10
- return line;
11
- }
12
- return `${indent}${line}`;
13
- }).join("\n");
14
- };
15
- const getStyles = (configuration, customTheme2) => {
16
- const styles = [];
17
- if (configuration.customCss) {
18
- styles.push("/* Custom CSS */");
19
- styles.push(configuration.customCss);
20
- }
21
- if (!configuration.theme && customTheme2) {
22
- styles.push("/* Custom Theme */");
23
- styles.push(customTheme2);
24
- }
25
- if (styles.length === 0) {
26
- return "";
27
- }
28
- return `
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@scalar/nextjs-api-reference"] = {}));
3
+ })(this, function(exports) {
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
+ //#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
6
+ /**
7
+ * Helper function to add consistent indentation to multiline strings
8
+ * @param str The string to indent
9
+ * @param spaces Number of spaces for each level
10
+ * @param initialIndent Whether to indent the first line
11
+ */
12
+ var addIndent = (str, spaces = 2, initialIndent = false) => {
13
+ const indent = " ".repeat(spaces);
14
+ return str.split("\n").map((line, index) => {
15
+ if (index === 0 && !initialIndent) return line;
16
+ return `${indent}${line}`;
17
+ }).join("\n");
18
+ };
19
+ /**
20
+ * Generate the style tag with custom theme if needed
21
+ */
22
+ var getStyles = (configuration, customTheme) => {
23
+ const styles = [];
24
+ if (configuration.customCss) {
25
+ styles.push("/* Custom CSS */");
26
+ styles.push(configuration.customCss);
27
+ }
28
+ if (!configuration.theme && customTheme) {
29
+ styles.push("/* Custom Theme */");
30
+ styles.push(customTheme);
31
+ }
32
+ if (styles.length === 0) return "";
33
+ return `
29
34
  <style type="text/css">
30
35
  ${addIndent(styles.join("\n\n"), 6)}
31
36
  </style>`;
32
- };
33
- const getHtmlDocument = (givenConfiguration, customTheme2 = "") => {
34
- const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
35
- const configuration = getConfiguration({
36
- ...rest,
37
- ...theme ? { theme } : {},
38
- customCss
39
- });
40
- const content = `<!doctype html>
37
+ };
38
+ /**
39
+ * The HTML document to render the Scalar API reference.
40
+ *
41
+ * We must check the passed in configuration and not the configuration for the theme as the configuration will have it
42
+ * defaulted to 'default'
43
+ */
44
+ var getHtmlDocument = (givenConfiguration, customTheme = "") => {
45
+ const { cdn, pageTitle, customCss, theme, ...rest } = givenConfiguration;
46
+ const configuration = getConfiguration({
47
+ ...rest,
48
+ ...theme ? { theme } : {},
49
+ customCss
50
+ });
51
+ return `<!doctype html>
41
52
  <html>
42
53
  <head>
43
54
  <title>${pageTitle ?? "Scalar API Reference"}</title>
44
55
  <meta charset="utf-8" />
45
56
  <meta
46
57
  name="viewport"
47
- content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme2)}
58
+ content="width=device-width, initial-scale=1" />${getStyles(configuration, customTheme)}
48
59
  </head>
49
60
  <body>
50
61
  <div id="app"></div>${getScriptTags(configuration, cdn)}
51
62
  </body>
52
63
  </html>`;
53
- return content;
54
- };
55
- const serializeArrayWithFunctions = (arr) => {
56
- return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
57
- };
58
- function getScriptTags(configuration, cdn) {
59
- const restConfig = { ...configuration };
60
- const functionProps = [];
61
- for (const [key, value] of Object.entries(configuration)) {
62
- if (typeof value === "function") {
63
- functionProps.push(`"${key}": ${value.toString()}`);
64
- delete restConfig[key];
65
- } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
66
- functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
67
- delete restConfig[key];
68
- }
69
- }
70
- const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
71
- const functionPropsString = functionProps.length ? `,
72
- ${functionProps.join(",\n ")}
73
- }` : "}";
74
- return `
64
+ };
65
+ /**
66
+ * Helper function to serialize arrays that may contain functions
67
+ */
68
+ var serializeArrayWithFunctions = (arr) => {
69
+ return `[${arr.map((item) => typeof item === "function" ? item.toString() : JSON.stringify(item)).join(", ")}]`;
70
+ };
71
+ /**
72
+ * The script tags to load the @scalar/api-reference package from the CDN.
73
+ */
74
+ function getScriptTags(configuration, cdn) {
75
+ const restConfig = { ...configuration };
76
+ const functionProps = [];
77
+ for (const [key, value] of Object.entries(configuration)) if (typeof value === "function") {
78
+ functionProps.push(`"${key}": ${value.toString()}`);
79
+ delete restConfig[key];
80
+ } else if (Array.isArray(value) && value.some((item) => typeof item === "function")) {
81
+ functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
82
+ delete restConfig[key];
83
+ }
84
+ const configString = JSON.stringify(restConfig, null, 2).split("\n").map((line, index) => index === 0 ? line : " " + line).join("\n").replace(/\s*}$/, "");
85
+ const functionPropsString = functionProps.length ? `,\n ${functionProps.join(",\n ")}\n }` : "}";
86
+ return `
75
87
  <!-- Load the Script -->
76
88
  <script src="${cdn ?? "https://cdn.jsdelivr.net/npm/@scalar/api-reference"}"><\/script>
77
89
 
@@ -79,20 +91,22 @@
79
91
  <script type="text/javascript">
80
92
  Scalar.createApiReference('#app', ${configString}${functionPropsString})
81
93
  <\/script>`;
82
- }
83
- const getConfiguration = (givenConfiguration) => {
84
- const configuration = {
85
- ...givenConfiguration
86
- };
87
- if (typeof configuration.content === "function") {
88
- configuration.content = configuration.content();
89
- }
90
- if (configuration.content && configuration.url) {
91
- delete configuration.content;
92
- }
93
- return configuration;
94
- };
95
- const customTheme = `
94
+ }
95
+ /**
96
+ * The configuration to pass to the @scalar/api-reference package.
97
+ */
98
+ var getConfiguration = (givenConfiguration) => {
99
+ const configuration = { ...givenConfiguration };
100
+ if (typeof configuration.content === "function") configuration.content = configuration.content();
101
+ if (configuration.content && configuration.url) delete configuration.content;
102
+ return configuration;
103
+ };
104
+ //#endregion
105
+ //#region src/custom-theme.ts
106
+ /**
107
+ * The custom theme for Next.js
108
+ */
109
+ var customTheme = `
96
110
  /* basic theme */
97
111
  .dark-mode {
98
112
  --scalar-color-1: rgba(255, 255, 255, 0.9);
@@ -214,22 +228,33 @@
214
228
  border: 1px solid var(--scalar-border-color);
215
229
  }
216
230
  `;
217
- const DEFAULT_CONFIGURATION = {
218
- _integration: "nextjs"
219
- };
220
- const ApiReference = (givenConfiguration) => {
221
- const configuration = {
222
- ...DEFAULT_CONFIGURATION,
223
- ...givenConfiguration
224
- };
225
- return () => {
226
- const referenceDocument = getHtmlDocument(configuration, customTheme);
227
- return new Response(referenceDocument, {
228
- status: 200,
229
- headers: { "Content-Type": "text/html" }
230
- });
231
- };
232
- };
233
- exports2.ApiReference = ApiReference;
234
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
235
- }));
231
+ //#endregion
232
+ //#region src/ApiReference.ts
233
+ /**
234
+ * The default configuration for the API Reference.
235
+ */
236
+ var DEFAULT_CONFIGURATION = { _integration: "nextjs" };
237
+ /**
238
+ * Next.js adapter for an Api Reference
239
+ *
240
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
241
+ *
242
+ * @params config - the Api Reference config object
243
+ * @params options - reserved for future use to add customization to the response
244
+ */
245
+ var ApiReference = (givenConfiguration) => {
246
+ const configuration = {
247
+ ...DEFAULT_CONFIGURATION,
248
+ ...givenConfiguration
249
+ };
250
+ return () => {
251
+ const referenceDocument = getHtmlDocument(configuration, customTheme);
252
+ return new Response(referenceDocument, {
253
+ status: 200,
254
+ headers: { "Content-Type": "text/html" }
255
+ });
256
+ };
257
+ };
258
+ //#endregion
259
+ exports.ApiReference = ApiReference;
260
+ });
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "openapi",
19
19
  "swagger"
20
20
  ],
21
- "version": "0.10.2",
21
+ "version": "0.10.4",
22
22
  "engines": {
23
23
  "node": ">=22"
24
24
  },
@@ -50,20 +50,19 @@
50
50
  "documentation": "https://scalar.com/products/api-references/integrations/nextjs"
51
51
  },
52
52
  "dependencies": {
53
- "@scalar/core": "0.4.2"
53
+ "@scalar/core": "0.4.4"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^24.1.0",
57
57
  "@types/react": "^19.2.7",
58
58
  "@types/react-dom": "^19.2.3",
59
- "@vitejs/plugin-react": "5.0.4",
59
+ "@vitejs/plugin-react": "6.0.1",
60
60
  "next": "^15.5.10",
61
61
  "react": "^19.2.3",
62
62
  "react-dom": "^19.2.3",
63
- "vite": "^7.3.1",
63
+ "vite": "8.0.0",
64
64
  "vite-plugin-dts": "^4.3.0",
65
- "vitest": "4.0.16",
66
- "@scalar/build-tooling": "0.5.0"
65
+ "vitest": "4.1.0"
67
66
  },
68
67
  "peerDependencies": {
69
68
  "next": "^15.0.0 || ^16.0.0",
@@ -72,10 +71,6 @@
72
71
  "scripts": {
73
72
  "build": "pnpm types:check && pnpm build-only",
74
73
  "build-only": "vite build",
75
- "format": "scalar-format",
76
- "format:check": "scalar-format-check",
77
- "lint:check": "scalar-lint-check",
78
- "lint:fix": "scalar-lint-fix",
79
74
  "test": "vitest",
80
75
  "types:check": "tsc --noEmit --skipLibCheck"
81
76
  }