@scalar/sveltekit 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Scalar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Scalar for SvelteKit
2
+
3
+ [![Version](https://img.shields.io/npm/v/%40scalar/sveltekit)](https://www.npmjs.com/package/@scalar/sveltekit)
4
+ [![Downloads](https://img.shields.io/npm/dm/%40scalar/sveltekit)](https://www.npmjs.com/package/@scalar/sveltekit)
5
+ [![License](https://img.shields.io/npm/l/%40scalar%2Fsveltekit)](https://www.npmjs.com/package/@scalar/sveltekit)
6
+ [![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)](https://discord.gg/scalar)
7
+
8
+ A SvelteKit integration for the Scalar API Reference
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @scalar/sveltekit
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ // routes/+server.ts
20
+ import { ScalarApiReference } from '@scalar/sveltekit'
21
+ import type { RequestHandler } from './$types'
22
+
23
+ const render = ScalarApiReference({
24
+ url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
25
+ })
26
+
27
+ export const GET: RequestHandler = () => {
28
+ return render()
29
+ }
30
+ ```
31
+
32
+ ## Community
33
+
34
+ We are API nerds. You too? Let’s chat on Discord: <https://discord.gg/scalar>
35
+
36
+ ## License
37
+
38
+ The source code in this repository is licensed under [MIT](https://github.com/scalar/scalar/blob/main/LICENSE).
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The custom theme for SvelteKit
3
+ */
4
+ export declare const customTheme = "\n/* basic theme */\n.dark-mode {\n --scalar-color-1: rgba(255, 255, 255, 0.9);\n --scalar-color-2: rgba(255, 255, 255, 0.62);\n --scalar-color-3: rgba(255, 255, 255, 0.44);\n --scalar-color-accent: #3070ec;\n\n --scalar-background-1: #000000;\n --scalar-background-2: #1a1a1a;\n --scalar-background-3: #2a2828;\n --scalar-background-accent: transparent;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n\n.light-mode .dark-mode,\n.light-mode {\n --scalar-color-1: #2a2f45;\n --scalar-color-2: #757575;\n --scalar-color-3: #8e8e8e;\n --scalar-color-accent: #3070ec;\n\n --scalar-background-1: #fff;\n --scalar-background-2: #fafafa;\n --scalar-background-3: #e7e7e7;\n --scalar-background-accent: transparent;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\n.light-mode .scalar-card {\n --scalar-background-1: #fff;\n --scalar-background-2: #fff !important;\n --scalar-background-3: #fff !important;\n}\n.dark-mode .scalar-card {\n --scalar-background-1: #000000;\n --scalar-background-2: #000000 !important;\n --scalar-background-3: #000000 !important;\n}\n.light-mode .examples .scalar-card .scalar-card-header {\n --scalar-background-2: #fafafa;\n}\n.dark-mode .examples .scalar-card .scalar-card-header {\n --scalar-background-2: #1a1a1a;\n --scalar-border-color: #1a1a1a;\n}\n/* Document header */\n.light-mode .t-doc__header,\n.dark-mode .t-doc__header {\n --header-background-1: rgba(255,255,255,.8);\n --header-border-color: var(--scalar-border-color);\n --header-color-1: var(--scalar-color-1);\n --header-color-2: var(--scalar-color-2);\n --header-background-toggle: var(--scalar-color-3);\n --header-call-to-action-color: var(--scalar-color-accent);\n backdrop-filter: saturate(180%) blur(5px);\n}\n\n.dark-mode .t-doc__header {\n --header-background-1: rgba(0,0,0,.5);\n}\n/* Document Sidebar */\n.light-mode .t-doc__sidebar,\n.dark-mode .t-doc__sidebar {\n --scalar-sidebar-background-1: var(--scalar-background-1);\n --scalar-sidebar-item-hover-color: var(--scalar-sidebar-color-1);\n --scalar-sidebar-item-hover-background: transparent;\n --scalar-sidebar-item-active-background: var(--scalar-background-accent);\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: var(--scalar-background-2);\n --scalar-sidebar-search-border-color: var(--scalar-background-2);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n --scalar-sidebar-indent-border: var(--scalar-border-color);\n --scalar-sidebar-indent-border-active: #6aacf8;\n}\n.api-client-drawer .t-doc__sidebar {\n --scalar-sidebar-border-color: var(--scalar-border-color);\n}\n/* advanced */\n.light-mode .dark-mode,\n.light-mode {\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: #417942;\n --scalar-color-red: #ae3763;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #2b66cf;\n --scalar-color-orange: #cf7a2b;\n --scalar-color-purple: #6e27b5;\n\n --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);\n --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n}\n.dark-mode {\n --scalar-button-1: #f6f6f6;\n --scalar-button-1-color: #000;\n --scalar-button-1-hover: #e7e7e7;\n\n --scalar-color-green: #7abe7b;\n --scalar-color-red: #e5698f;\n --scalar-color-yellow: #f8ea68;\n --scalar-color-blue: #68a6f8;\n --scalar-color-orange: #f89c68;\n --scalar-color-purple: #b57de9;\n\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n.sidebar .sidebar-indent-nested .sidebar-heading {\n padding-right: 0;\n}\n.sidebar-search-key {\n background: var(--scalar-background-1) !important;\n border: 1px solid var(--scalar-border-color);\n}\n";
5
+ //# sourceMappingURL=custom-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-theme.d.ts","sourceRoot":"","sources":["../src/custom-theme.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,62HAyHvB,CAAA"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The custom theme for SvelteKit
3
+ */
4
+ export const customTheme = `
5
+ /* basic theme */
6
+ .dark-mode {
7
+ --scalar-color-1: rgba(255, 255, 255, 0.9);
8
+ --scalar-color-2: rgba(255, 255, 255, 0.62);
9
+ --scalar-color-3: rgba(255, 255, 255, 0.44);
10
+ --scalar-color-accent: #3070ec;
11
+
12
+ --scalar-background-1: #000000;
13
+ --scalar-background-2: #1a1a1a;
14
+ --scalar-background-3: #2a2828;
15
+ --scalar-background-accent: transparent;
16
+
17
+ --scalar-border-color: rgba(255, 255, 255, 0.1);
18
+ }
19
+
20
+ .light-mode .dark-mode,
21
+ .light-mode {
22
+ --scalar-color-1: #2a2f45;
23
+ --scalar-color-2: #757575;
24
+ --scalar-color-3: #8e8e8e;
25
+ --scalar-color-accent: #3070ec;
26
+
27
+ --scalar-background-1: #fff;
28
+ --scalar-background-2: #fafafa;
29
+ --scalar-background-3: #e7e7e7;
30
+ --scalar-background-accent: transparent;
31
+
32
+ --scalar-border-color: rgba(0, 0, 0, 0.1);
33
+ }
34
+ .light-mode .scalar-card {
35
+ --scalar-background-1: #fff;
36
+ --scalar-background-2: #fff !important;
37
+ --scalar-background-3: #fff !important;
38
+ }
39
+ .dark-mode .scalar-card {
40
+ --scalar-background-1: #000000;
41
+ --scalar-background-2: #000000 !important;
42
+ --scalar-background-3: #000000 !important;
43
+ }
44
+ .light-mode .examples .scalar-card .scalar-card-header {
45
+ --scalar-background-2: #fafafa;
46
+ }
47
+ .dark-mode .examples .scalar-card .scalar-card-header {
48
+ --scalar-background-2: #1a1a1a;
49
+ --scalar-border-color: #1a1a1a;
50
+ }
51
+ /* Document header */
52
+ .light-mode .t-doc__header,
53
+ .dark-mode .t-doc__header {
54
+ --header-background-1: rgba(255,255,255,.8);
55
+ --header-border-color: var(--scalar-border-color);
56
+ --header-color-1: var(--scalar-color-1);
57
+ --header-color-2: var(--scalar-color-2);
58
+ --header-background-toggle: var(--scalar-color-3);
59
+ --header-call-to-action-color: var(--scalar-color-accent);
60
+ backdrop-filter: saturate(180%) blur(5px);
61
+ }
62
+
63
+ .dark-mode .t-doc__header {
64
+ --header-background-1: rgba(0,0,0,.5);
65
+ }
66
+ /* Document Sidebar */
67
+ .light-mode .t-doc__sidebar,
68
+ .dark-mode .t-doc__sidebar {
69
+ --scalar-sidebar-background-1: var(--scalar-background-1);
70
+ --scalar-sidebar-item-hover-color: var(--scalar-sidebar-color-1);
71
+ --scalar-sidebar-item-hover-background: transparent;
72
+ --scalar-sidebar-item-active-background: var(--scalar-background-accent);
73
+ --scalar-sidebar-border-color: transparent;
74
+ --scalar-sidebar-color-1: var(--scalar-color-1);
75
+ --scalar-sidebar-color-2: var(--scalar-color-2);
76
+ --scalar-sidebar-color-active: var(--scalar-color-accent);
77
+ --scalar-sidebar-search-background: var(--scalar-background-2);
78
+ --scalar-sidebar-search-border-color: var(--scalar-background-2);
79
+ --scalar-sidebar-search-color: var(--scalar-color-3);
80
+ --scalar-sidebar-indent-border: var(--scalar-border-color);
81
+ --scalar-sidebar-indent-border-active: #6aacf8;
82
+ }
83
+ .api-client-drawer .t-doc__sidebar {
84
+ --scalar-sidebar-border-color: var(--scalar-border-color);
85
+ }
86
+ /* advanced */
87
+ .light-mode .dark-mode,
88
+ .light-mode {
89
+ --scalar-button-1: rgb(49 53 56);
90
+ --scalar-button-1-color: #fff;
91
+ --scalar-button-1-hover: rgb(28 31 33);
92
+
93
+ --scalar-color-green: #417942;
94
+ --scalar-color-red: #ae3763;
95
+ --scalar-color-yellow: #edbe20;
96
+ --scalar-color-blue: #2b66cf;
97
+ --scalar-color-orange: #cf7a2b;
98
+ --scalar-color-purple: #6e27b5;
99
+
100
+ --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
101
+ --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
102
+ }
103
+ .dark-mode {
104
+ --scalar-button-1: #f6f6f6;
105
+ --scalar-button-1-color: #000;
106
+ --scalar-button-1-hover: #e7e7e7;
107
+
108
+ --scalar-color-green: #7abe7b;
109
+ --scalar-color-red: #e5698f;
110
+ --scalar-color-yellow: #f8ea68;
111
+ --scalar-color-blue: #68a6f8;
112
+ --scalar-color-orange: #f89c68;
113
+ --scalar-color-purple: #b57de9;
114
+
115
+ --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
116
+ --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
117
+ }
118
+ .sidebar .sidebar-indent-nested .sidebar-heading {
119
+ padding-right: 0;
120
+ }
121
+ .sidebar-search-key {
122
+ background: var(--scalar-background-1) !important;
123
+ border: 1px solid var(--scalar-border-color);
124
+ }
125
+ `;
@@ -0,0 +1,2 @@
1
+ export { ScalarApiReference } from './scalar-api-reference.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { ScalarApiReference } from './scalar-api-reference.js';
@@ -0,0 +1,8 @@
1
+ import type { ApiReferenceConfiguration } from './types.js';
2
+ /**
3
+ * SvelteKit adapter for an API Reference
4
+ *
5
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
6
+ */
7
+ export declare const ScalarApiReference: (givenConfiguration: Partial<ApiReferenceConfiguration>) => () => Promise<Response>;
8
+ //# sourceMappingURL=scalar-api-reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar-api-reference.d.ts","sourceRoot":"","sources":["../src/scalar-api-reference.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAU3D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,uBAAwB,OAAO,CAAC,yBAAyB,CAAC,4BAexF,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { getHtmlDocument } from '@scalar/core/libs/html-rendering';
2
+ import { customTheme } from './custom-theme.js';
3
+ /**
4
+ * The default configuration for the API Reference.
5
+ */
6
+ const DEFAULT_CONFIGURATION = {
7
+ // TODO: Must be available in the CDN version
8
+ // _integration: 'svelte',
9
+ };
10
+ /**
11
+ * SvelteKit adapter for an API Reference
12
+ *
13
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
14
+ */
15
+ export const ScalarApiReference = (givenConfiguration) => {
16
+ // Merge the defaults
17
+ const configuration = {
18
+ ...DEFAULT_CONFIGURATION,
19
+ ...givenConfiguration,
20
+ };
21
+ return async () => {
22
+ return new Response(getHtmlDocument(configuration, customTheme), {
23
+ status: 200,
24
+ headers: {
25
+ 'Content-Type': 'text/html',
26
+ },
27
+ });
28
+ };
29
+ };
@@ -0,0 +1,6 @@
1
+ import type { HtmlRenderingConfiguration } from '@scalar/core/libs/html-rendering';
2
+ /**
3
+ * The configuration for the Scalar API Reference for SvelteKit
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,kCAAkC,CAAA;AAElF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@scalar/sveltekit",
3
+ "version": "0.1.0",
4
+ "description": "A SvelteKit server handler to render API references from an OpenAPI file",
5
+ "license": "MIT",
6
+ "author": "Scalar (https://github.com/scalar)",
7
+ "homepage": "https://github.com/scalar/scalar",
8
+ "bugs": "https://github.com/scalar/scalar/issues/new/choose",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/scalar/scalar.git",
12
+ "directory": "integrations/sveltekit"
13
+ },
14
+ "keywords": [
15
+ "api",
16
+ "documentation",
17
+ "svelte",
18
+ "sveltekit",
19
+ "openapi",
20
+ "swagger"
21
+ ],
22
+ "files": [
23
+ "dist",
24
+ "!dist/**/*.test.*",
25
+ "!dist/**/*.spec.*",
26
+ "src",
27
+ "!src/**/*.test.*",
28
+ "!src/**/*.spec.*"
29
+ ],
30
+ "sideEffects": [
31
+ "**/*.css"
32
+ ],
33
+ "svelte": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "type": "module",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "svelte": "./dist/index.js"
40
+ }
41
+ },
42
+ "dependencies": {
43
+ "@scalar/types": "0.1.12",
44
+ "@scalar/core": "0.2.12"
45
+ },
46
+ "peerDependencies": {
47
+ "svelte": "^5.0.0",
48
+ "@sveltejs/kit": "^2.16.0"
49
+ },
50
+ "devDependencies": {
51
+ "@sveltejs/kit": "^2.16.0",
52
+ "@sveltejs/package": "^2.0.0",
53
+ "publint": "^0.3.2",
54
+ "svelte": "^5.0.0",
55
+ "svelte-check": "^4.0.0"
56
+ },
57
+ "scripts": {
58
+ "build": "svelte-package --input src",
59
+ "check": "svelte-check --tsconfig ./tsconfig.json",
60
+ "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch"
61
+ }
62
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The custom theme for SvelteKit
3
+ */
4
+ export const customTheme = `
5
+ /* basic theme */
6
+ .dark-mode {
7
+ --scalar-color-1: rgba(255, 255, 255, 0.9);
8
+ --scalar-color-2: rgba(255, 255, 255, 0.62);
9
+ --scalar-color-3: rgba(255, 255, 255, 0.44);
10
+ --scalar-color-accent: #3070ec;
11
+
12
+ --scalar-background-1: #000000;
13
+ --scalar-background-2: #1a1a1a;
14
+ --scalar-background-3: #2a2828;
15
+ --scalar-background-accent: transparent;
16
+
17
+ --scalar-border-color: rgba(255, 255, 255, 0.1);
18
+ }
19
+
20
+ .light-mode .dark-mode,
21
+ .light-mode {
22
+ --scalar-color-1: #2a2f45;
23
+ --scalar-color-2: #757575;
24
+ --scalar-color-3: #8e8e8e;
25
+ --scalar-color-accent: #3070ec;
26
+
27
+ --scalar-background-1: #fff;
28
+ --scalar-background-2: #fafafa;
29
+ --scalar-background-3: #e7e7e7;
30
+ --scalar-background-accent: transparent;
31
+
32
+ --scalar-border-color: rgba(0, 0, 0, 0.1);
33
+ }
34
+ .light-mode .scalar-card {
35
+ --scalar-background-1: #fff;
36
+ --scalar-background-2: #fff !important;
37
+ --scalar-background-3: #fff !important;
38
+ }
39
+ .dark-mode .scalar-card {
40
+ --scalar-background-1: #000000;
41
+ --scalar-background-2: #000000 !important;
42
+ --scalar-background-3: #000000 !important;
43
+ }
44
+ .light-mode .examples .scalar-card .scalar-card-header {
45
+ --scalar-background-2: #fafafa;
46
+ }
47
+ .dark-mode .examples .scalar-card .scalar-card-header {
48
+ --scalar-background-2: #1a1a1a;
49
+ --scalar-border-color: #1a1a1a;
50
+ }
51
+ /* Document header */
52
+ .light-mode .t-doc__header,
53
+ .dark-mode .t-doc__header {
54
+ --header-background-1: rgba(255,255,255,.8);
55
+ --header-border-color: var(--scalar-border-color);
56
+ --header-color-1: var(--scalar-color-1);
57
+ --header-color-2: var(--scalar-color-2);
58
+ --header-background-toggle: var(--scalar-color-3);
59
+ --header-call-to-action-color: var(--scalar-color-accent);
60
+ backdrop-filter: saturate(180%) blur(5px);
61
+ }
62
+
63
+ .dark-mode .t-doc__header {
64
+ --header-background-1: rgba(0,0,0,.5);
65
+ }
66
+ /* Document Sidebar */
67
+ .light-mode .t-doc__sidebar,
68
+ .dark-mode .t-doc__sidebar {
69
+ --scalar-sidebar-background-1: var(--scalar-background-1);
70
+ --scalar-sidebar-item-hover-color: var(--scalar-sidebar-color-1);
71
+ --scalar-sidebar-item-hover-background: transparent;
72
+ --scalar-sidebar-item-active-background: var(--scalar-background-accent);
73
+ --scalar-sidebar-border-color: transparent;
74
+ --scalar-sidebar-color-1: var(--scalar-color-1);
75
+ --scalar-sidebar-color-2: var(--scalar-color-2);
76
+ --scalar-sidebar-color-active: var(--scalar-color-accent);
77
+ --scalar-sidebar-search-background: var(--scalar-background-2);
78
+ --scalar-sidebar-search-border-color: var(--scalar-background-2);
79
+ --scalar-sidebar-search-color: var(--scalar-color-3);
80
+ --scalar-sidebar-indent-border: var(--scalar-border-color);
81
+ --scalar-sidebar-indent-border-active: #6aacf8;
82
+ }
83
+ .api-client-drawer .t-doc__sidebar {
84
+ --scalar-sidebar-border-color: var(--scalar-border-color);
85
+ }
86
+ /* advanced */
87
+ .light-mode .dark-mode,
88
+ .light-mode {
89
+ --scalar-button-1: rgb(49 53 56);
90
+ --scalar-button-1-color: #fff;
91
+ --scalar-button-1-hover: rgb(28 31 33);
92
+
93
+ --scalar-color-green: #417942;
94
+ --scalar-color-red: #ae3763;
95
+ --scalar-color-yellow: #edbe20;
96
+ --scalar-color-blue: #2b66cf;
97
+ --scalar-color-orange: #cf7a2b;
98
+ --scalar-color-purple: #6e27b5;
99
+
100
+ --scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
101
+ --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
102
+ }
103
+ .dark-mode {
104
+ --scalar-button-1: #f6f6f6;
105
+ --scalar-button-1-color: #000;
106
+ --scalar-button-1-hover: #e7e7e7;
107
+
108
+ --scalar-color-green: #7abe7b;
109
+ --scalar-color-red: #e5698f;
110
+ --scalar-color-yellow: #f8ea68;
111
+ --scalar-color-blue: #68a6f8;
112
+ --scalar-color-orange: #f89c68;
113
+ --scalar-color-purple: #b57de9;
114
+
115
+ --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
116
+ --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
117
+ }
118
+ .sidebar .sidebar-indent-nested .sidebar-heading {
119
+ padding-right: 0;
120
+ }
121
+ .sidebar-search-key {
122
+ background: var(--scalar-background-1) !important;
123
+ border: 1px solid var(--scalar-border-color);
124
+ }
125
+ `
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { ScalarApiReference } from './scalar-api-reference.js'
@@ -0,0 +1,34 @@
1
+ import { getHtmlDocument } from '@scalar/core/libs/html-rendering'
2
+
3
+ import { customTheme } from './custom-theme.js'
4
+ import type { ApiReferenceConfiguration } from './types.js'
5
+
6
+ /**
7
+ * The default configuration for the API Reference.
8
+ */
9
+ const DEFAULT_CONFIGURATION: Partial<ApiReferenceConfiguration> = {
10
+ // TODO: Must be available in the CDN version
11
+ // _integration: 'svelte',
12
+ }
13
+
14
+ /**
15
+ * SvelteKit adapter for an API Reference
16
+ *
17
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
18
+ */
19
+ export const ScalarApiReference = (givenConfiguration: Partial<ApiReferenceConfiguration>) => {
20
+ // Merge the defaults
21
+ const configuration = {
22
+ ...DEFAULT_CONFIGURATION,
23
+ ...givenConfiguration,
24
+ } satisfies Partial<ApiReferenceConfiguration>
25
+
26
+ return async () => {
27
+ return new Response(getHtmlDocument(configuration, customTheme), {
28
+ status: 200,
29
+ headers: {
30
+ 'Content-Type': 'text/html',
31
+ },
32
+ })
33
+ }
34
+ }
package/src/types.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { HtmlRenderingConfiguration } from '@scalar/core/libs/html-rendering'
2
+
3
+ /**
4
+ * The configuration for the Scalar API Reference for SvelteKit
5
+ */
6
+ export type ApiReferenceConfiguration = HtmlRenderingConfiguration