@scalar/express-api-reference 0.4.184 → 0.4.186

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,35 @@
1
1
  # @scalar/express-api-reference
2
2
 
3
+ ## 0.4.186
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4db5161]
8
+ - @scalar/api-reference@1.25.124
9
+ - @scalar/types@0.0.36
10
+
11
+ ## 0.4.185
12
+
13
+ ### Patch Changes
14
+
15
+ - 01882e5: fix: cloudbuild not running latest integrations
16
+ - 43031e7: feat: new lib/html-rendering in @scalar/api-reference
17
+ - Updated dependencies [50388ea]
18
+ - Updated dependencies [43031e7]
19
+ - Updated dependencies [946a5df]
20
+ - Updated dependencies [b22f554]
21
+ - Updated dependencies [c10bbf5]
22
+ - Updated dependencies [0ba190a]
23
+ - Updated dependencies [4f7b767]
24
+ - Updated dependencies [78f0cdf]
25
+ - Updated dependencies [bd70ab6]
26
+ - Updated dependencies [577602f]
27
+ - Updated dependencies [875ee2c]
28
+ - Updated dependencies [cf14cbb]
29
+ - Updated dependencies [e55bfd2]
30
+ - @scalar/api-reference@1.25.123
31
+ - @scalar/types@0.0.35
32
+
3
33
  ## 0.4.184
4
34
 
5
35
  ### Patch Changes
@@ -1,11 +1,11 @@
1
- import type { ApiReferenceOptions } from './types';
1
+ import type { ApiReferenceConfiguration } from './types';
2
2
  import type { Request, Response } from 'express';
3
3
  /**
4
- * The custom theme CSS for the Express theme.
4
+ * The custom theme CSS for the Express theme
5
5
  */
6
6
  export declare const customTheme = "\n/* basic theme */\n.light-mode {\n --scalar-color-1: #353535;\n --scalar-color-2: #555555;\n --scalar-color-3: #aeaeae;\n --scalar-color-accent: #259dff;\n\n --scalar-background-1: #fff;\n --scalar-background-2: #f7f7f7;\n --scalar-background-3: #dadada;\n --scalar-background-accent: #E0F5FF;\n\n --scalar-border-color: rgba(0, 0, 0, 0.1);\n}\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: #8ab4f8;\n\n --scalar-background-1: #1a1a1a;\n --scalar-background-2: #252525;\n --scalar-background-3: #323232;\n --scalar-background-accent: #8ab4f81f;\n\n --scalar-border-color: rgba(255, 255, 255, 0.1);\n}\n\n/* Document 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: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n.dark-mode .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: transparent;\n --scalar-sidebar-search-border-color: var(--scalar-border-color);\n --scalar-sidebar-search-color: var(--scalar-color-3);\n}\n\n/* advanced */\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: #669900;\n --scalar-color-red: #dc4a68;\n --scalar-color-yellow: #edbe20;\n --scalar-color-blue: #0277aa;\n --scalar-color-orange: #fb892c;\n --scalar-color-purple: #5203d1;\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: #00b648;\n --scalar-color-red: #dc1b19;\n --scalar-color-yellow: #ffc90d;\n --scalar-color-blue: #4eb3ec;\n --scalar-color-orange: #ff8d4d;\n --scalar-color-purple: #b191f9;\n\n --scalar-scrollbar-color: rgba(255, 255, 255, 0.24);\n --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n:root {\n --scalar-radius: 3px;\n --scalar-radius-lg: 3px;\n --scalar-radius-xl: 3px;\n}\n";
7
7
  /**
8
- * The route handler to render the API Reference.
8
+ * The route handler to render the Scalar API Reference.
9
9
  */
10
- export declare function apiReference(options: ApiReferenceOptions): (_: Request, res: Response) => void;
10
+ export declare function apiReference(givenConfiguration: ApiReferenceConfiguration): (_: Request, res: Response) => void;
11
11
  //# sourceMappingURL=apiReference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apiReference.d.ts","sourceRoot":"","sources":["../src/apiReference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,mnGA8FvB,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,OAC5C,OAAO,OAAO,QAAQ,UAGlC"}
1
+ {"version":3,"file":"apiReference.d.ts","sourceRoot":"","sources":["../src/apiReference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAShD;;GAEG;AACH,eAAO,MAAM,WAAW,mnGA8FvB,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,kBAAkB,EAAE,yBAAyB,OAQ7D,OAAO,OAAO,QAAQ,UAGlC"}
@@ -1,7 +1,13 @@
1
- import { getHtmlDocument } from './lib/static-rendering.js';
1
+ import { getHtmlDocument } from '@scalar/api-reference/lib/html-rendering';
2
2
 
3
3
  /**
4
- * The custom theme CSS for the Express theme.
4
+ * The default configuration for the API Reference.
5
+ */
6
+ const DEFAULT_CONFIGURATION = {
7
+ _integration: 'express',
8
+ };
9
+ /**
10
+ * The custom theme CSS for the Express theme
5
11
  */
6
12
  const customTheme = `
7
13
  /* basic theme */
@@ -99,11 +105,17 @@ const customTheme = `
99
105
  }
100
106
  `;
101
107
  /**
102
- * The route handler to render the API Reference.
108
+ * The route handler to render the Scalar API Reference.
103
109
  */
104
- function apiReference(options) {
110
+ function apiReference(givenConfiguration) {
111
+ // Merge the defaults
112
+ const configuration = {
113
+ ...DEFAULT_CONFIGURATION,
114
+ ...givenConfiguration,
115
+ };
116
+ // Respond with the HTML document
105
117
  return (_, res) => {
106
- res.type('text/html').send(getHtmlDocument(options, customTheme));
118
+ res.type('text/html').send(getHtmlDocument(configuration, customTheme));
107
119
  };
108
120
  }
109
121
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './apiReference.js';
2
+ export * from './types';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { ReferenceConfiguration } from '@scalar/types/legacy';
2
- export type ApiReferenceOptions = ReferenceConfiguration & {
3
- cdn?: string;
4
- };
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;
5
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
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/express"
12
12
  },
13
- "version": "0.4.184",
13
+ "version": "0.4.186",
14
14
  "engines": {
15
15
  "node": ">=18"
16
16
  },
@@ -30,16 +30,17 @@
30
30
  ],
31
31
  "module": "dist/index.js",
32
32
  "dependencies": {
33
- "@scalar/types": "0.0.34"
33
+ "@scalar/api-reference": "1.25.124",
34
+ "@scalar/types": "0.0.36"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/express": "^4.17.21",
37
38
  "@types/supertest": "^2.0.12",
38
39
  "express": "^4.21.2",
39
40
  "supertest": "^6.3.3",
41
+ "vite": "^5.4.10",
40
42
  "vitest": "^1.6.0",
41
- "@scalar/api-reference": "1.25.121",
42
- "@scalar/build-tooling": "0.1.14"
43
+ "@scalar/build-tooling": "0.1.15"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "scalar-build-rollup",
@@ -1,22 +0,0 @@
1
- import type { ApiReferenceOptions } from '../types';
2
- /**
3
- * The HTML document to render the Scalar API reference.
4
- */
5
- export declare function getHtmlDocument(options: ApiReferenceOptions, customTheme?: string): string;
6
- /**
7
- * The script tags to load the @scalar/api-reference package from the CDN.
8
- */
9
- export declare function getScriptTags(configuration: ApiReferenceOptions): string;
10
- /**
11
- * The configuration to pass to the @scalar/api-reference package.
12
- */
13
- export declare function getConfiguration(givenConfiguration: ApiReferenceOptions): string;
14
- /**
15
- * The content to pass to the @scalar/api-reference package as the <script> tag content.
16
- */
17
- export declare function getScriptTagContent(configuration: ApiReferenceOptions): string;
18
- /**
19
- * The CDN URL to load the @scalar/api-reference package from.
20
- */
21
- export declare function getCdnUrl(configuration: ApiReferenceOptions): string;
22
- //# sourceMappingURL=static-rendering.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-rendering.d.ts","sourceRoot":"","sources":["../../src/lib/static-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAOlD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,WAAW,CAAC,EAAE,MAAM,UAmBjF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,mBAAmB,UAQ/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,UAavE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,UAMrE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,mBAAmB,UAE3D"}
@@ -1,72 +0,0 @@
1
- const DEFAULT_CONFIGURATION = {
2
- _integration: 'express',
3
- };
4
- /**
5
- * The HTML document to render the Scalar API reference.
6
- */
7
- function getHtmlDocument(options, customTheme) {
8
- return `
9
- <!DOCTYPE html>
10
- <html>
11
- <head>
12
- <title>Scalar API Reference</title>
13
- <meta charset="utf-8" />
14
- <meta
15
- name="viewport"
16
- content="width=device-width, initial-scale=1" />
17
- <style>
18
- ${options.theme ? null : (customTheme)}
19
- </style>
20
- </head>
21
- <body>
22
- ${getScriptTags(options)}
23
- </body>
24
- </html>
25
- `;
26
- }
27
- /**
28
- * The script tags to load the @scalar/api-reference package from the CDN.
29
- */
30
- function getScriptTags(configuration) {
31
- return `
32
- <script
33
- id="api-reference"
34
- type="application/json"
35
- data-configuration="${getConfiguration(configuration)}">${getScriptTagContent(configuration)}</script>
36
- <script src="${getCdnUrl(configuration)}"></script>
37
- `;
38
- }
39
- /**
40
- * The configuration to pass to the @scalar/api-reference package.
41
- */
42
- function getConfiguration(givenConfiguration) {
43
- const configuration = {
44
- ...DEFAULT_CONFIGURATION,
45
- ...givenConfiguration,
46
- };
47
- if (!configuration.spec?.url) {
48
- delete configuration.spec;
49
- }
50
- else if (configuration.spec?.content) {
51
- delete configuration.spec?.content;
52
- }
53
- return JSON.stringify(configuration).split('"').join('&quot;');
54
- }
55
- /**
56
- * The content to pass to the @scalar/api-reference package as the <script> tag content.
57
- */
58
- function getScriptTagContent(configuration) {
59
- return configuration.spec?.content
60
- ? typeof configuration.spec?.content === 'function'
61
- ? JSON.stringify(configuration.spec?.content())
62
- : JSON.stringify(configuration.spec?.content)
63
- : '';
64
- }
65
- /**
66
- * The CDN URL to load the @scalar/api-reference package from.
67
- */
68
- function getCdnUrl(configuration) {
69
- return configuration.cdn || 'https://cdn.jsdelivr.net/npm/@scalar/api-reference';
70
- }
71
-
72
- export { getCdnUrl, getConfiguration, getHtmlDocument, getScriptTagContent, getScriptTags };