@scalar/hono-api-reference 0.9.1 → 0.9.2
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/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +7 -0
- package/dist/scalar.d.ts +1 -1
- package/dist/scalar.js +20 -32
- package/dist/scalar.js.map +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/scalar.d.ts
CHANGED
package/dist/scalar.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { getHtmlDocument } from
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The default configuration for the API Reference.
|
|
5
|
-
*/
|
|
1
|
+
import { getHtmlDocument } from "@scalar/core/libs/html-rendering";
|
|
6
2
|
const DEFAULT_CONFIGURATION = {
|
|
7
|
-
|
|
3
|
+
_integration: "hono"
|
|
8
4
|
};
|
|
9
|
-
/**
|
|
10
|
-
* The custom theme for Hono
|
|
11
|
-
*/
|
|
12
5
|
const customTheme = `
|
|
13
6
|
.light-mode {
|
|
14
7
|
color-scheme: light;
|
|
@@ -110,30 +103,25 @@ const customTheme = `
|
|
|
110
103
|
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
111
104
|
}
|
|
112
105
|
`;
|
|
113
|
-
/**
|
|
114
|
-
* The Hono middleware for the Scalar API Reference.
|
|
115
|
-
*/
|
|
116
106
|
const Scalar = (configOrResolver) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
...DEFAULT_CONFIGURATION,
|
|
128
|
-
...resolvedConfig,
|
|
129
|
-
};
|
|
130
|
-
// Respond with the HTML document
|
|
131
|
-
return c.html(getHtmlDocument(configuration, customTheme));
|
|
107
|
+
return async (c) => {
|
|
108
|
+
let resolvedConfig = {};
|
|
109
|
+
if (typeof configOrResolver === "function") {
|
|
110
|
+
resolvedConfig = await configOrResolver(c);
|
|
111
|
+
} else {
|
|
112
|
+
resolvedConfig = configOrResolver;
|
|
113
|
+
}
|
|
114
|
+
const configuration = {
|
|
115
|
+
...DEFAULT_CONFIGURATION,
|
|
116
|
+
...resolvedConfig
|
|
132
117
|
};
|
|
118
|
+
return c.html(getHtmlDocument(configuration, customTheme));
|
|
119
|
+
};
|
|
133
120
|
};
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated Use `Scalar` instead.
|
|
136
|
-
*/
|
|
137
121
|
const apiReference = Scalar;
|
|
138
|
-
|
|
139
|
-
|
|
122
|
+
export {
|
|
123
|
+
Scalar,
|
|
124
|
+
apiReference,
|
|
125
|
+
customTheme
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=scalar.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/scalar.ts"],
|
|
4
|
+
"sourcesContent": ["import { getHtmlDocument } from '@scalar/core/libs/html-rendering'\nimport type { Context, Env, MiddlewareHandler } from 'hono'\n\nimport type { ApiReferenceConfiguration } from './types'\n\n/**\n * The default configuration for the API Reference.\n */\nconst DEFAULT_CONFIGURATION: Partial<ApiReferenceConfiguration> = {\n _integration: 'hono',\n}\n\n/**\n * The custom theme for Hono\n */\nexport 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`\n\ntype Configuration<E extends Env> =\n | Partial<ApiReferenceConfiguration>\n | ((c: Context<E>) => Partial<ApiReferenceConfiguration> | Promise<Partial<ApiReferenceConfiguration>>)\n\n/**\n * The Hono middleware for the Scalar API Reference.\n */\nexport const Scalar = <E extends Env>(configOrResolver: Configuration<E>): MiddlewareHandler<E> => {\n return async (c) => {\n let resolvedConfig: Partial<ApiReferenceConfiguration> = {}\n\n if (typeof configOrResolver === 'function') {\n resolvedConfig = await configOrResolver(c)\n } else {\n resolvedConfig = configOrResolver\n }\n\n // Merge the defaults\n const configuration = {\n ...DEFAULT_CONFIGURATION,\n ...resolvedConfig,\n }\n\n // Respond with the HTML document\n return c.html(getHtmlDocument(configuration, customTheme))\n }\n}\n\n/**\n * @deprecated Use `Scalar` instead.\n */\nexport const apiReference = Scalar\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAQhC,MAAM,wBAA4D;AAAA,EAChE,cAAc;AAChB;AAKO,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6GpB,MAAM,SAAS,CAAgB,qBAA6D;AACjG,SAAO,OAAO,MAAM;AAClB,QAAI,iBAAqD,CAAC;AAE1D,QAAI,OAAO,qBAAqB,YAAY;AAC1C,uBAAiB,MAAM,iBAAiB,CAAC;AAAA,IAC3C,OAAO;AACL,uBAAiB;AAAA,IACnB;AAGA,UAAM,gBAAgB;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAGA,WAAO,EAAE,KAAK,gBAAgB,eAAe,WAAW,CAAC;AAAA,EAC3D;AACF;AAKO,MAAM,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
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.9.
|
|
13
|
+
"version": "0.9.2",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"hono": "^4.6.5",
|
|
38
38
|
"vite": "5.4.19",
|
|
39
39
|
"vitest": "^1.6.0",
|
|
40
|
-
"@scalar/openapi-to-markdown": "0.2.
|
|
41
|
-
"@scalar/build-tooling": "0.2.
|
|
40
|
+
"@scalar/openapi-to-markdown": "0.2.6",
|
|
41
|
+
"@scalar/build-tooling": "0.2.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"hono": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "scalar-build-
|
|
47
|
+
"build": "scalar-build-esbuild",
|
|
48
48
|
"dev": "nodemon --exec \"vite-node playground/index.ts\" --ext ts --quiet --watch ./",
|
|
49
49
|
"docker:build": "docker buildx build --platform=linux/amd64 -t scalar-hono-reference --build-arg=\"BASE_IMAGE=scalar-base\" .",
|
|
50
50
|
"docker:run": "docker run -t scalar-hono-reference",
|