@scalar/nextjs-api-reference 0.4.11 → 0.4.14

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,30 @@
1
1
  # @scalar/nextjs-api-reference
2
2
 
3
+ ## 0.4.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [716811f]
8
+ - Updated dependencies [5812c2f]
9
+ - Updated dependencies [ee5fdee]
10
+ - @scalar/api-reference@1.24.16
11
+
12
+ ## 0.4.13
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [d7a011a]
17
+ - Updated dependencies [40d7c3d]
18
+ - @scalar/api-reference@1.24.15
19
+
20
+ ## 0.4.12
21
+
22
+ ### Patch Changes
23
+
24
+ - 008ac8c: feat: add URL support
25
+ - Updated dependencies [fb9baa5]
26
+ - @scalar/api-reference@1.24.14
27
+
3
28
  ## 0.4.11
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -46,7 +46,9 @@ const config = {
46
46
  }
47
47
  ```
48
48
 
49
- The Next.js handler takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/tree/main/packages/api-reference#configuration) in the core package README.
49
+ We wrote a [detailed integration guide for Next.js](/documentation/nextjs.md).
50
+
51
+ The Next.js handler takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/tree/main/documentation/configuration.md) in the core package README.
50
52
 
51
53
  ## Themes
52
54
 
package/dist/index.cjs CHANGED
@@ -122,14 +122,20 @@ const nextjsThemeCss = `
122
122
  border: 1px solid var(--scalar-border-color);
123
123
  }
124
124
  `;
125
- const ApiReference = (refConfig) => {
126
- const { spec, ...config } = refConfig;
127
- if (!(spec == null ? void 0 : spec.content) && !(spec == null ? void 0 : spec.url)) {
125
+ const ApiReference = (config) => {
126
+ var _a, _b, _c, _d, _e, _f;
127
+ if (!((_a = config.spec) == null ? void 0 : _a.content) && !((_b = config.spec) == null ? void 0 : _b.url)) {
128
128
  throw new Error(
129
129
  "[@scalar/nextjs-api-reference] You didn’t provide a spec.content or spec.url. Please provide one of these options."
130
130
  );
131
131
  }
132
- const contentString = (spec == null ? void 0 : spec.content) ? typeof spec.content === "function" ? JSON.stringify(spec.content()) : JSON.stringify(spec.content) : "";
132
+ if (typeof ((_c = config.spec) == null ? void 0 : _c.content) === "function") {
133
+ config.spec.content = config.spec.content();
134
+ }
135
+ const documentString = ((_d = config == null ? void 0 : config.spec) == null ? void 0 : _d.content) ? typeof ((_e = config == null ? void 0 : config.spec) == null ? void 0 : _e.content) === "string" ? config.spec.content : JSON.stringify(config.spec.content) : "";
136
+ if ((_f = config == null ? void 0 : config.spec) == null ? void 0 : _f.content) {
137
+ delete config.spec.content;
138
+ }
133
139
  if (!(config == null ? void 0 : config.customCss) && !(config == null ? void 0 : config.theme)) {
134
140
  config.customCss = nextjsThemeCss;
135
141
  }
@@ -149,7 +155,7 @@ const ApiReference = (refConfig) => {
149
155
  id="api-reference"
150
156
  type="application/json"
151
157
  data-configuration="${configString}">
152
- ${contentString}
158
+ ${documentString}
153
159
  <\/script>
154
160
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
155
161
  </body>
package/dist/index.d.ts CHANGED
@@ -3,11 +3,11 @@ import { ReferenceConfiguration } from '@scalar/api-reference';
3
3
  /**
4
4
  * Next.js adapter for an Api Reference
5
5
  *
6
- * {@link https://github.com/scalar/scalar?tab=readme-ov-file#configuration Configuration}
6
+ * {@link https://github.com/scalar/scalar/tree/main/documentation/configuration.md Configuration}
7
7
  *
8
8
  * @params config - the Api Reference config object
9
9
  * @params options - reserved for future use to add customization to the response
10
10
  */
11
- export declare const ApiReference: (refConfig: ReferenceConfiguration) => () => Promise<Response>;
11
+ export declare const ApiReference: (config: ReferenceConfiguration) => () => Promise<Response>;
12
12
 
13
13
  export { }
package/dist/index.js CHANGED
@@ -120,14 +120,20 @@ const nextjsThemeCss = `
120
120
  border: 1px solid var(--scalar-border-color);
121
121
  }
122
122
  `;
123
- const ApiReference = (refConfig) => {
124
- const { spec, ...config } = refConfig;
125
- if (!(spec == null ? void 0 : spec.content) && !(spec == null ? void 0 : spec.url)) {
123
+ const ApiReference = (config) => {
124
+ var _a, _b, _c, _d, _e, _f;
125
+ if (!((_a = config.spec) == null ? void 0 : _a.content) && !((_b = config.spec) == null ? void 0 : _b.url)) {
126
126
  throw new Error(
127
127
  "[@scalar/nextjs-api-reference] You didn’t provide a spec.content or spec.url. Please provide one of these options."
128
128
  );
129
129
  }
130
- const contentString = (spec == null ? void 0 : spec.content) ? typeof spec.content === "function" ? JSON.stringify(spec.content()) : JSON.stringify(spec.content) : "";
130
+ if (typeof ((_c = config.spec) == null ? void 0 : _c.content) === "function") {
131
+ config.spec.content = config.spec.content();
132
+ }
133
+ const documentString = ((_d = config == null ? void 0 : config.spec) == null ? void 0 : _d.content) ? typeof ((_e = config == null ? void 0 : config.spec) == null ? void 0 : _e.content) === "string" ? config.spec.content : JSON.stringify(config.spec.content) : "";
134
+ if ((_f = config == null ? void 0 : config.spec) == null ? void 0 : _f.content) {
135
+ delete config.spec.content;
136
+ }
131
137
  if (!(config == null ? void 0 : config.customCss) && !(config == null ? void 0 : config.theme)) {
132
138
  config.customCss = nextjsThemeCss;
133
139
  }
@@ -147,7 +153,7 @@ const ApiReference = (refConfig) => {
147
153
  id="api-reference"
148
154
  type="application/json"
149
155
  data-configuration="${configString}">
150
- ${contentString}
156
+ ${documentString}
151
157
  <\/script>
152
158
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
153
159
  </body>
@@ -124,14 +124,20 @@
124
124
  border: 1px solid var(--scalar-border-color);
125
125
  }
126
126
  `;
127
- const ApiReference = (refConfig) => {
128
- const { spec, ...config } = refConfig;
129
- if (!(spec == null ? void 0 : spec.content) && !(spec == null ? void 0 : spec.url)) {
127
+ const ApiReference = (config) => {
128
+ var _a, _b, _c, _d, _e, _f;
129
+ if (!((_a = config.spec) == null ? void 0 : _a.content) && !((_b = config.spec) == null ? void 0 : _b.url)) {
130
130
  throw new Error(
131
131
  "[@scalar/nextjs-api-reference] You didn’t provide a spec.content or spec.url. Please provide one of these options."
132
132
  );
133
133
  }
134
- const contentString = (spec == null ? void 0 : spec.content) ? typeof spec.content === "function" ? JSON.stringify(spec.content()) : JSON.stringify(spec.content) : "";
134
+ if (typeof ((_c = config.spec) == null ? void 0 : _c.content) === "function") {
135
+ config.spec.content = config.spec.content();
136
+ }
137
+ const documentString = ((_d = config == null ? void 0 : config.spec) == null ? void 0 : _d.content) ? typeof ((_e = config == null ? void 0 : config.spec) == null ? void 0 : _e.content) === "string" ? config.spec.content : JSON.stringify(config.spec.content) : "";
138
+ if ((_f = config == null ? void 0 : config.spec) == null ? void 0 : _f.content) {
139
+ delete config.spec.content;
140
+ }
135
141
  if (!(config == null ? void 0 : config.customCss) && !(config == null ? void 0 : config.theme)) {
136
142
  config.customCss = nextjsThemeCss;
137
143
  }
@@ -151,7 +157,7 @@
151
157
  id="api-reference"
152
158
  type="application/json"
153
159
  data-configuration="${configString}">
154
- ${contentString}
160
+ ${documentString}
155
161
  <\/script>
156
162
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
157
163
  </body>
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "openapi",
19
19
  "swagger"
20
20
  ],
21
- "version": "0.4.11",
21
+ "version": "0.4.14",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "next": "^14.1.1",
39
39
  "react": "^18.3.1",
40
- "@scalar/api-reference": "1.24.13"
40
+ "@scalar/api-reference": "1.24.16"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.8.4",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^18.3.1",
50
50
  "vite": "^5.2.10",
51
51
  "vite-plugin-dts": "^3.6.3",
52
- "@scalar/api-reference": "1.24.13"
52
+ "@scalar/api-reference": "1.24.16"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "pnpm types:check && pnpm build-only",