@scalar/nextjs-api-reference 0.10.6 → 0.10.7
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 +2 -0
- package/dist/index.cjs +42 -13
- package/dist/index.js +42 -13
- package/dist/index.umd.cjs +42 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region ../../packages/
|
|
2
|
+
//#region ../../packages/client-side-rendering/dist/html-rendering.js
|
|
3
|
+
var DEFAULT_CDN = "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
|
|
4
|
+
/**
|
|
5
|
+
* Escape HTML special characters in user-provided strings.
|
|
6
|
+
*/
|
|
7
|
+
var escapeHtml = (str) => {
|
|
8
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
9
|
+
};
|
|
3
10
|
/**
|
|
4
11
|
* Helper function to add consistent indentation to multiline strings
|
|
5
12
|
* @param str The string to indent
|
|
@@ -33,22 +40,26 @@ var getStyles = (configuration, customTheme) => {
|
|
|
33
40
|
</style>`;
|
|
34
41
|
};
|
|
35
42
|
/**
|
|
36
|
-
*
|
|
43
|
+
* Render the Scalar API Reference as a complete HTML document using the CDN.
|
|
37
44
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
45
|
+
* Generates static HTML that loads the @scalar/api-reference standalone bundle
|
|
46
|
+
* from a CDN and renders client-side. No server-side dependencies required.
|
|
47
|
+
*
|
|
48
|
+
* For server-side rendering with hydration, use the server module instead.
|
|
40
49
|
*/
|
|
41
|
-
|
|
42
|
-
const {
|
|
50
|
+
function renderApiReference(options, customTheme = "") {
|
|
51
|
+
const { config: givenConfig, pageTitle, cdn } = options;
|
|
52
|
+
const title = escapeHtml(pageTitle ?? "Scalar API Reference");
|
|
53
|
+
const { customCss, theme, ...rest } = (Array.isArray(givenConfig) ? givenConfig[0] : givenConfig) ?? {};
|
|
43
54
|
const configuration = getConfiguration({
|
|
44
55
|
...rest,
|
|
45
56
|
...theme ? { theme } : {},
|
|
46
|
-
customCss
|
|
57
|
+
...customCss !== void 0 ? { customCss } : {}
|
|
47
58
|
});
|
|
48
59
|
return `<!doctype html>
|
|
49
60
|
<html>
|
|
50
61
|
<head>
|
|
51
|
-
<title>${
|
|
62
|
+
<title>${title}</title>
|
|
52
63
|
<meta charset="utf-8" />
|
|
53
64
|
<meta
|
|
54
65
|
name="viewport"
|
|
@@ -58,7 +69,7 @@ var getHtmlDocument = (givenConfiguration, customTheme = "") => {
|
|
|
58
69
|
<div id="app"></div>${getScriptTags(configuration, cdn)}
|
|
59
70
|
</body>
|
|
60
71
|
</html>`;
|
|
61
|
-
}
|
|
72
|
+
}
|
|
62
73
|
/**
|
|
63
74
|
* Helper function to serialize arrays that may contain functions
|
|
64
75
|
*/
|
|
@@ -78,15 +89,18 @@ function getScriptTags(configuration, cdn) {
|
|
|
78
89
|
functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
|
|
79
90
|
delete restConfig[key];
|
|
80
91
|
}
|
|
81
|
-
const
|
|
82
|
-
const
|
|
92
|
+
const jsonString = JSON.stringify(restConfig, null, 2);
|
|
93
|
+
const indentedJsonString = jsonString.split("\n").map((line, index) => index === 0 ? line : ` ${line}`).join("\n");
|
|
94
|
+
let configString = indentedJsonString;
|
|
95
|
+
if (functionProps.length > 0) if (jsonString === "{}") configString = `{\n ${functionProps.join(",\n ")}\n }`;
|
|
96
|
+
else configString = `${indentedJsonString.split("\n").slice(0, -1).join("\n")},\n ${functionProps.join(",\n ")}\n }`;
|
|
83
97
|
return `
|
|
84
98
|
<!-- Load the Script -->
|
|
85
|
-
<script src="${cdn ??
|
|
99
|
+
<script src="${cdn ?? DEFAULT_CDN}"><\/script>
|
|
86
100
|
|
|
87
101
|
<!-- Initialize the Scalar API Reference -->
|
|
88
102
|
<script type="text/javascript">
|
|
89
|
-
Scalar.createApiReference('#app', ${configString}
|
|
103
|
+
Scalar.createApiReference('#app', ${configString})
|
|
90
104
|
<\/script>`;
|
|
91
105
|
}
|
|
92
106
|
/**
|
|
@@ -99,6 +113,21 @@ var getConfiguration = (givenConfiguration) => {
|
|
|
99
113
|
return configuration;
|
|
100
114
|
};
|
|
101
115
|
//#endregion
|
|
116
|
+
//#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
|
|
117
|
+
/**
|
|
118
|
+
* The HTML document to render the Scalar API reference.
|
|
119
|
+
*
|
|
120
|
+
* @deprecated Use `renderApiReference` from `@scalar/client-side-rendering` instead.
|
|
121
|
+
*/
|
|
122
|
+
var getHtmlDocument = (givenConfiguration, customTheme = "") => {
|
|
123
|
+
const { cdn, pageTitle, ...config } = givenConfiguration;
|
|
124
|
+
return renderApiReference({
|
|
125
|
+
config,
|
|
126
|
+
pageTitle,
|
|
127
|
+
cdn
|
|
128
|
+
}, customTheme);
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
102
131
|
//#region src/custom-theme.ts
|
|
103
132
|
/**
|
|
104
133
|
* The custom theme for Next.js
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
//#region ../../packages/
|
|
1
|
+
//#region ../../packages/client-side-rendering/dist/html-rendering.js
|
|
2
|
+
var DEFAULT_CDN = "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
|
|
3
|
+
/**
|
|
4
|
+
* Escape HTML special characters in user-provided strings.
|
|
5
|
+
*/
|
|
6
|
+
var escapeHtml = (str) => {
|
|
7
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* Helper function to add consistent indentation to multiline strings
|
|
4
11
|
* @param str The string to indent
|
|
@@ -32,22 +39,26 @@ var getStyles = (configuration, customTheme) => {
|
|
|
32
39
|
</style>`;
|
|
33
40
|
};
|
|
34
41
|
/**
|
|
35
|
-
*
|
|
42
|
+
* Render the Scalar API Reference as a complete HTML document using the CDN.
|
|
36
43
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
44
|
+
* Generates static HTML that loads the @scalar/api-reference standalone bundle
|
|
45
|
+
* from a CDN and renders client-side. No server-side dependencies required.
|
|
46
|
+
*
|
|
47
|
+
* For server-side rendering with hydration, use the server module instead.
|
|
39
48
|
*/
|
|
40
|
-
|
|
41
|
-
const {
|
|
49
|
+
function renderApiReference(options, customTheme = "") {
|
|
50
|
+
const { config: givenConfig, pageTitle, cdn } = options;
|
|
51
|
+
const title = escapeHtml(pageTitle ?? "Scalar API Reference");
|
|
52
|
+
const { customCss, theme, ...rest } = (Array.isArray(givenConfig) ? givenConfig[0] : givenConfig) ?? {};
|
|
42
53
|
const configuration = getConfiguration({
|
|
43
54
|
...rest,
|
|
44
55
|
...theme ? { theme } : {},
|
|
45
|
-
customCss
|
|
56
|
+
...customCss !== void 0 ? { customCss } : {}
|
|
46
57
|
});
|
|
47
58
|
return `<!doctype html>
|
|
48
59
|
<html>
|
|
49
60
|
<head>
|
|
50
|
-
<title>${
|
|
61
|
+
<title>${title}</title>
|
|
51
62
|
<meta charset="utf-8" />
|
|
52
63
|
<meta
|
|
53
64
|
name="viewport"
|
|
@@ -57,7 +68,7 @@ var getHtmlDocument = (givenConfiguration, customTheme = "") => {
|
|
|
57
68
|
<div id="app"></div>${getScriptTags(configuration, cdn)}
|
|
58
69
|
</body>
|
|
59
70
|
</html>`;
|
|
60
|
-
}
|
|
71
|
+
}
|
|
61
72
|
/**
|
|
62
73
|
* Helper function to serialize arrays that may contain functions
|
|
63
74
|
*/
|
|
@@ -77,15 +88,18 @@ function getScriptTags(configuration, cdn) {
|
|
|
77
88
|
functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
|
|
78
89
|
delete restConfig[key];
|
|
79
90
|
}
|
|
80
|
-
const
|
|
81
|
-
const
|
|
91
|
+
const jsonString = JSON.stringify(restConfig, null, 2);
|
|
92
|
+
const indentedJsonString = jsonString.split("\n").map((line, index) => index === 0 ? line : ` ${line}`).join("\n");
|
|
93
|
+
let configString = indentedJsonString;
|
|
94
|
+
if (functionProps.length > 0) if (jsonString === "{}") configString = `{\n ${functionProps.join(",\n ")}\n }`;
|
|
95
|
+
else configString = `${indentedJsonString.split("\n").slice(0, -1).join("\n")},\n ${functionProps.join(",\n ")}\n }`;
|
|
82
96
|
return `
|
|
83
97
|
<!-- Load the Script -->
|
|
84
|
-
<script src="${cdn ??
|
|
98
|
+
<script src="${cdn ?? DEFAULT_CDN}"><\/script>
|
|
85
99
|
|
|
86
100
|
<!-- Initialize the Scalar API Reference -->
|
|
87
101
|
<script type="text/javascript">
|
|
88
|
-
Scalar.createApiReference('#app', ${configString}
|
|
102
|
+
Scalar.createApiReference('#app', ${configString})
|
|
89
103
|
<\/script>`;
|
|
90
104
|
}
|
|
91
105
|
/**
|
|
@@ -98,6 +112,21 @@ var getConfiguration = (givenConfiguration) => {
|
|
|
98
112
|
return configuration;
|
|
99
113
|
};
|
|
100
114
|
//#endregion
|
|
115
|
+
//#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
|
|
116
|
+
/**
|
|
117
|
+
* The HTML document to render the Scalar API reference.
|
|
118
|
+
*
|
|
119
|
+
* @deprecated Use `renderApiReference` from `@scalar/client-side-rendering` instead.
|
|
120
|
+
*/
|
|
121
|
+
var getHtmlDocument = (givenConfiguration, customTheme = "") => {
|
|
122
|
+
const { cdn, pageTitle, ...config } = givenConfiguration;
|
|
123
|
+
return renderApiReference({
|
|
124
|
+
config,
|
|
125
|
+
pageTitle,
|
|
126
|
+
cdn
|
|
127
|
+
}, customTheme);
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
101
130
|
//#region src/custom-theme.ts
|
|
102
131
|
/**
|
|
103
132
|
* The custom theme for Next.js
|
package/dist/index.umd.cjs
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
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
3
|
})(this, function(exports) {
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
|
-
//#region ../../packages/
|
|
5
|
+
//#region ../../packages/client-side-rendering/dist/html-rendering.js
|
|
6
|
+
var DEFAULT_CDN = "https://cdn.jsdelivr.net/npm/@scalar/api-reference";
|
|
7
|
+
/**
|
|
8
|
+
* Escape HTML special characters in user-provided strings.
|
|
9
|
+
*/
|
|
10
|
+
var escapeHtml = (str) => {
|
|
11
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
12
|
+
};
|
|
6
13
|
/**
|
|
7
14
|
* Helper function to add consistent indentation to multiline strings
|
|
8
15
|
* @param str The string to indent
|
|
@@ -36,22 +43,26 @@
|
|
|
36
43
|
</style>`;
|
|
37
44
|
};
|
|
38
45
|
/**
|
|
39
|
-
*
|
|
46
|
+
* Render the Scalar API Reference as a complete HTML document using the CDN.
|
|
40
47
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
48
|
+
* Generates static HTML that loads the @scalar/api-reference standalone bundle
|
|
49
|
+
* from a CDN and renders client-side. No server-side dependencies required.
|
|
50
|
+
*
|
|
51
|
+
* For server-side rendering with hydration, use the server module instead.
|
|
43
52
|
*/
|
|
44
|
-
|
|
45
|
-
const {
|
|
53
|
+
function renderApiReference(options, customTheme = "") {
|
|
54
|
+
const { config: givenConfig, pageTitle, cdn } = options;
|
|
55
|
+
const title = escapeHtml(pageTitle ?? "Scalar API Reference");
|
|
56
|
+
const { customCss, theme, ...rest } = (Array.isArray(givenConfig) ? givenConfig[0] : givenConfig) ?? {};
|
|
46
57
|
const configuration = getConfiguration({
|
|
47
58
|
...rest,
|
|
48
59
|
...theme ? { theme } : {},
|
|
49
|
-
customCss
|
|
60
|
+
...customCss !== void 0 ? { customCss } : {}
|
|
50
61
|
});
|
|
51
62
|
return `<!doctype html>
|
|
52
63
|
<html>
|
|
53
64
|
<head>
|
|
54
|
-
<title>${
|
|
65
|
+
<title>${title}</title>
|
|
55
66
|
<meta charset="utf-8" />
|
|
56
67
|
<meta
|
|
57
68
|
name="viewport"
|
|
@@ -61,7 +72,7 @@
|
|
|
61
72
|
<div id="app"></div>${getScriptTags(configuration, cdn)}
|
|
62
73
|
</body>
|
|
63
74
|
</html>`;
|
|
64
|
-
}
|
|
75
|
+
}
|
|
65
76
|
/**
|
|
66
77
|
* Helper function to serialize arrays that may contain functions
|
|
67
78
|
*/
|
|
@@ -81,15 +92,18 @@
|
|
|
81
92
|
functionProps.push(`"${key}": ${serializeArrayWithFunctions(value)}`);
|
|
82
93
|
delete restConfig[key];
|
|
83
94
|
}
|
|
84
|
-
const
|
|
85
|
-
const
|
|
95
|
+
const jsonString = JSON.stringify(restConfig, null, 2);
|
|
96
|
+
const indentedJsonString = jsonString.split("\n").map((line, index) => index === 0 ? line : ` ${line}`).join("\n");
|
|
97
|
+
let configString = indentedJsonString;
|
|
98
|
+
if (functionProps.length > 0) if (jsonString === "{}") configString = `{\n ${functionProps.join(",\n ")}\n }`;
|
|
99
|
+
else configString = `${indentedJsonString.split("\n").slice(0, -1).join("\n")},\n ${functionProps.join(",\n ")}\n }`;
|
|
86
100
|
return `
|
|
87
101
|
<!-- Load the Script -->
|
|
88
|
-
<script src="${cdn ??
|
|
102
|
+
<script src="${cdn ?? DEFAULT_CDN}"><\/script>
|
|
89
103
|
|
|
90
104
|
<!-- Initialize the Scalar API Reference -->
|
|
91
105
|
<script type="text/javascript">
|
|
92
|
-
Scalar.createApiReference('#app', ${configString}
|
|
106
|
+
Scalar.createApiReference('#app', ${configString})
|
|
93
107
|
<\/script>`;
|
|
94
108
|
}
|
|
95
109
|
/**
|
|
@@ -102,6 +116,21 @@
|
|
|
102
116
|
return configuration;
|
|
103
117
|
};
|
|
104
118
|
//#endregion
|
|
119
|
+
//#region ../../packages/core/dist/libs/html-rendering/html-rendering.js
|
|
120
|
+
/**
|
|
121
|
+
* The HTML document to render the Scalar API reference.
|
|
122
|
+
*
|
|
123
|
+
* @deprecated Use `renderApiReference` from `@scalar/client-side-rendering` instead.
|
|
124
|
+
*/
|
|
125
|
+
var getHtmlDocument = (givenConfiguration, customTheme = "") => {
|
|
126
|
+
const { cdn, pageTitle, ...config } = givenConfiguration;
|
|
127
|
+
return renderApiReference({
|
|
128
|
+
config,
|
|
129
|
+
pageTitle,
|
|
130
|
+
cdn
|
|
131
|
+
}, customTheme);
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
105
134
|
//#region src/custom-theme.ts
|
|
106
135
|
/**
|
|
107
136
|
* The custom theme for Next.js
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"openapi",
|
|
19
19
|
"swagger"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.10.
|
|
21
|
+
"version": "0.10.7",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=22"
|
|
24
24
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"documentation": "https://scalar.com/products/api-references/integrations/nextjs"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@scalar/core": "0.
|
|
53
|
+
"@scalar/core": "0.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^24.1.0",
|