@scalar/hono-api-reference 0.5.174 → 0.5.176
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/honoApiReference.d.ts +5 -13
- package/dist/honoApiReference.d.ts.map +1 -1
- package/dist/honoApiReference.js +20 -49
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +4 -3
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import type { ReferenceConfiguration } from '@scalar/types/legacy';
|
|
2
1
|
import type { Env, MiddlewareHandler } from 'hono';
|
|
3
|
-
|
|
4
|
-
pageTitle?: string;
|
|
5
|
-
cdn?: string;
|
|
6
|
-
};
|
|
2
|
+
import type { ApiReferenceConfiguration } from './types';
|
|
7
3
|
/**
|
|
8
|
-
* The custom theme
|
|
4
|
+
* The custom theme for Hono
|
|
9
5
|
*/
|
|
10
|
-
export declare const
|
|
6
|
+
export declare const customTheme = "\n.light-mode {\n color-scheme: light;\n --scalar-color-1: #2a2f45;\n --scalar-color-2: #757575;\n --scalar-color-3: #8e8e8e;\n --scalar-color-disabled: #b4b1b1;\n --scalar-color-ghost: #a7a7a7;\n --scalar-color-accent: #0099ff;\n --scalar-background-1: #fff;\n --scalar-background-2: #f6f6f6;\n --scalar-background-3: #e7e7e7;\n --scalar-background-4: rgba(0, 0, 0, 0.06);\n --scalar-background-accent: #8ab4f81f;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);\n --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n --scalar-lifted-brightness: 1;\n --scalar-backdrop-brightness: 1;\n\n --scalar-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.11);\n --scalar-shadow-2: rgba(0, 0, 0, 0.08) 0px 13px 20px 0px,\n rgba(0, 0, 0, 0.08) 0px 3px 8px 0px, #eeeeed 0px 0 0 1px;\n\n --scalar-button-1: rgb(49 53 56);\n --scalar-button-1-color: #fff;\n --scalar-button-1-hover: rgb(28 31 33);\n\n --scalar-color-green: #069061;\n --scalar-color-red: #ef0006;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0082d0;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\n}\n\n.dark-mode {\n color-scheme: dark;\n --scalar-color-1: rgba(255, 255, 245, .86);\n --scalar-color-2: rgba(255, 255, 245, .6);\n --scalar-color-3: rgba(255, 255, 245, .38);\n --scalar-color-disabled: rgba(255, 255, 245, .25);\n --scalar-color-ghost: rgba(255, 255, 245, .25);\n --scalar-color-accent: #e36002;\n --scalar-background-1: #1e1e20;\n --scalar-background-2: #2a2a2a;\n --scalar-background-3: #505053;\n --scalar-background-4: rgba(255, 255, 255, 0.06);\n --scalar-background-accent: #e360021f;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n --scalar-lifted-brightness: 1.45;\n --scalar-backdrop-brightness: 0.5;\n\n --scalar-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, 0.1);\n --scalar-shadow-2: rgba(15, 15, 15, 0.2) 0px 3px 6px,\n rgba(15, 15, 15, 0.4) 0px 9px 24px, 0 0 0 1px rgba(255, 255, 255, 0.1);\n\n --scalar-button-1: #f6f6f6;\n --scalar-button-1-color: #000;\n --scalar-button-1-hover: #e7e7e7;\n\n --scalar-color-green: #3dd68c;\n --scalar-color-red: #f66f81;\n --scalar-color-yellow: #f9b44e;\n --scalar-color-blue: #5c73e7;\n --scalar-color-orange: #ff8d4d;\n --scalar-color-purple: #b191f9;\n}\n/* Sidebar */\n.light-mode .t-doc__sidebar {\n --scalar-sidebar-background-1: var(--scalar-background-1);\n --scalar-sidebar-item-hover-color: currentColor;\n --scalar-sidebar-item-hover-background: var(--scalar-background-2);\n --scalar-sidebar-item-active-background: var(--scalar-background-accent);\n --scalar-sidebar-border-color: var(--scalar-border-color);\n --scalar-sidebar-color-1: var(--scalar-color-1);\n --scalar-sidebar-color-2: var(--scalar-color-2);\n --scalar-sidebar-color-active: var(--scalar-color-accent);\n --scalar-sidebar-search-background: var(--scalar-background-2);\n --scalar-sidebar-search-border-color: var(--scalar-sidebar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n.dark-mode .sidebar {\n --scalar-sidebar-background-1: #161618;\n --scalar-sidebar-item-hover-color: var(--scalar-color-accent);\n --scalar-sidebar-item-hover-background: transparent;\n --scalar-sidebar-item-active-background: transparent;\n --scalar-sidebar-border-color: transparent;\n --scalar-sidebar-color-1: var(--scalar-color-1);\n --scalar-sidebar-color-2: var(--scalar-color-2);\n --scalar-sidebar-color-active: var(--scalar-color-accent);\n --scalar-sidebar-search-background: #252529;\n --scalar-sidebar-search-border-color: transparent;\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n";
|
|
11
7
|
/**
|
|
12
|
-
* The
|
|
8
|
+
* The Hono middleware for the Scalar API Reference.
|
|
13
9
|
*/
|
|
14
|
-
export declare const
|
|
15
|
-
/**
|
|
16
|
-
* The middleware for the API Reference.
|
|
17
|
-
*/
|
|
18
|
-
export declare const apiReference: <E extends Env>(options: ApiReferenceOptions) => MiddlewareHandler<E>;
|
|
10
|
+
export declare const apiReference: <E extends Env>(givenConfiguration: ApiReferenceConfiguration) => MiddlewareHandler<E>;
|
|
19
11
|
//# sourceMappingURL=honoApiReference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honoApiReference.d.ts","sourceRoot":"","sources":["../src/honoApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"honoApiReference.d.ts","sourceRoot":"","sources":["../src/honoApiReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAGlD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AASxD;;GAEG;AACH,eAAO,MAAM,WAAW,mtHAoGvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,GAAG,sBAAsB,yBAAyB,KAAG,iBAAiB,CAAC,CAAC,CAW9G,CAAA"}
|
package/dist/honoApiReference.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHtmlDocument } from '@scalar/api-reference/lib/html-rendering';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
4
|
+
* The default configuration for the API Reference.
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
6
|
+
const DEFAULT_CONFIGURATION = {
|
|
7
|
+
_integration: 'hono',
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The custom theme for Hono
|
|
11
|
+
*/
|
|
12
|
+
const customTheme = `
|
|
7
13
|
.light-mode {
|
|
8
14
|
color-scheme: light;
|
|
9
15
|
--scalar-color-1: #2a2f45;
|
|
@@ -105,53 +111,18 @@ const customThemeCSS = `
|
|
|
105
111
|
}
|
|
106
112
|
`;
|
|
107
113
|
/**
|
|
108
|
-
* The
|
|
114
|
+
* The Hono middleware for the Scalar API Reference.
|
|
109
115
|
*/
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
const apiReference = (givenConfiguration) => {
|
|
117
|
+
// Merge the defaults
|
|
118
|
+
const configuration = {
|
|
119
|
+
...DEFAULT_CONFIGURATION,
|
|
120
|
+
...givenConfiguration,
|
|
121
|
+
};
|
|
122
|
+
// Respond with the HTML document
|
|
123
|
+
return async (c) => {
|
|
124
|
+
return c.html(/* html */ `${getHtmlDocument(configuration, customTheme)}`);
|
|
113
125
|
};
|
|
114
|
-
return html `
|
|
115
|
-
<script
|
|
116
|
-
id="api-reference"
|
|
117
|
-
type="application/json"
|
|
118
|
-
data-configuration="${JSON.stringify({
|
|
119
|
-
...defaultConfiguration,
|
|
120
|
-
...configuration,
|
|
121
|
-
})
|
|
122
|
-
.split('"')
|
|
123
|
-
.join('"')}">
|
|
124
|
-
${raw(configuration.spec?.content
|
|
125
|
-
? typeof configuration.spec?.content === 'function'
|
|
126
|
-
? JSON.stringify(configuration.spec?.content())
|
|
127
|
-
: JSON.stringify(configuration.spec?.content)
|
|
128
|
-
: '')}
|
|
129
|
-
</script>
|
|
130
|
-
<script src="${configuration.cdn || 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'}"></script>
|
|
131
|
-
`;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* The middleware for the API Reference.
|
|
135
|
-
*/
|
|
136
|
-
const apiReference = (options) => async (c) => {
|
|
137
|
-
return c.html(/* html */ `
|
|
138
|
-
<!DOCTYPE html>
|
|
139
|
-
<html>
|
|
140
|
-
<head>
|
|
141
|
-
<title>${options?.pageTitle ?? 'API Reference'}</title>
|
|
142
|
-
<meta charset="utf-8" />
|
|
143
|
-
<meta
|
|
144
|
-
name="viewport"
|
|
145
|
-
content="width=device-width, initial-scale=1" />
|
|
146
|
-
<style>
|
|
147
|
-
${options.theme ? null : customThemeCSS}
|
|
148
|
-
</style>
|
|
149
|
-
</head>
|
|
150
|
-
<body>
|
|
151
|
-
${javascript(options)}
|
|
152
|
-
</body>
|
|
153
|
-
</html>
|
|
154
|
-
`);
|
|
155
126
|
};
|
|
156
127
|
|
|
157
|
-
export { apiReference,
|
|
128
|
+
export { apiReference, customTheme };
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { apiReference,
|
|
1
|
+
export { apiReference, customTheme } from './honoApiReference.js';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HtmlRenderingConfiguration } from '@scalar/api-reference/lib/html-rendering';
|
|
2
|
+
/**
|
|
3
|
+
* The configuration for the Scalar API Reference for Express
|
|
4
|
+
*/
|
|
5
|
+
export type ApiReferenceConfiguration = HtmlRenderingConfiguration;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAA;AAE1F;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,CAAA"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "integrations/hono"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.5.
|
|
13
|
+
"version": "0.5.176",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=18"
|
|
16
16
|
},
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"module": "dist/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@scalar/types": "0.0.
|
|
32
|
+
"@scalar/types": "0.0.35",
|
|
33
|
+
"@scalar/api-reference": "1.25.123"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@hono/node-server": "^1.11.0",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"hono": "^4.6.5",
|
|
38
39
|
"vite": "^5.4.10",
|
|
39
40
|
"vitest": "^1.6.0",
|
|
40
|
-
"@scalar/build-tooling": "0.1.
|
|
41
|
+
"@scalar/build-tooling": "0.1.15"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"hono": "^4.0.0"
|