@scalar/fastify-api-reference 1.17.3 → 1.17.6

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,17 @@
1
1
  # @scalar/fastify-api-reference
2
2
 
3
+ ## 1.17.6
4
+
5
+ ### Patch Changes
6
+
7
+ - ca7cced: fix: \_\_dirname undefined (again)
8
+
9
+ ## 1.17.5
10
+
11
+ ### Patch Changes
12
+
13
+ - d78e247: fix: ESM envs \_\_dirname is undefined
14
+
3
15
  ## 1.17.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;const e=require("node:fs"),n=require("node:path");const t={hide:!0},o=e=>`${e??""}/@scalar/fastify-api-reference/js/browser.js`.replace(/\/\//g,"/");function r(e){return`\n<!DOCTYPE html>\n<html>\n <head>\n <title>API Reference</title>\n <meta charset="utf-8" />\n <meta\n name="viewport"\n content="width=device-width, initial-scale=1" />\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n ${(e=>{var n,t,r,c;const{configuration:a}=e;return`\n <script\n id="api-reference"\n type="application/json"\n data-configuration="${JSON.stringify(a??{}).split('"').join("&quot;")}">${(null==(n=null==a?void 0:a.spec)?void 0:n.content)?"function"==typeof(null==(t=null==a?void 0:a.spec)?void 0:t.content)?JSON.stringify(null==(r=null==a?void 0:a.spec)?void 0:r.content()):JSON.stringify(null==(c=null==a?void 0:a.spec)?void 0:c.content):""}<\/script>\n <script src="${o(e.routePrefix)}"><\/script>\n `})(e)}\n </body>\n</html>\n`}module.exports=async(c,a)=>{var l,s;let{configuration:i}=a;const h=c.hasPlugin("@fastify/swagger");if(c.hasPlugin("fastify-html")||await c.register(import("fastify-html")),!(null==(l=null==i?void 0:i.spec)?void 0:l.content)&&!(null==(s=null==i?void 0:i.spec)?void 0:s.url)&&!h)return void c.log.warn("[@scalar/fastify-api-reference] You didn’t provide a spec.content or spec.url, and @fastify/swagger could not be found. Please provide one of these options.");const d=function(){const t=[n.resolve(`${__dirname}/js/standalone.js`),n.resolve(`${__dirname}/../../dist/js/standalone.js`)].find((n=>e.existsSync(n)));if(void 0===t)throw new Error(`JavaScript file not found: ${n.resolve(`${__dirname}/js/standalone.js`)}`);return e.readFileSync(t,"utf8")}();c.route({method:"GET",url:a.routePrefix??"/",schema:t,async handler(e,n){var t,o;return n.header("Content-Type","text/html; charset=utf-8"),(null==(t=null==i?void 0:i.spec)?void 0:t.content)||(null==(o=null==i?void 0:i.spec)?void 0:o.url)||!h||(i={...i,spec:{content:()=>c.swagger()}}),(null==i?void 0:i.customCss)||(null==i?void 0:i.theme)||(i={...i,customCss:"\n:root {\n --theme-font: 'Inter', var(--system-fonts);\n}\n\n.light-mode {\n color-scheme: light;\n --theme-color-1: #1c1e21;\n --theme-color-2: #757575;\n --theme-color-3: #8e8e8e;\n --theme-color-disabled: #b4b1b1;\n --theme-color-ghost: #a7a7a7;\n --theme-color-accent: #2f8555;\n --theme-background-1: #fff;\n --theme-background-2: #f5f5f5;\n --theme-background-3: #ededed;\n --theme-background-4: rgba(0, 0, 0, 0.06);\n --theme-background-accent: #2f85551f;\n\n --theme-border-color: rgba(0, 0, 0, 0.1);\n --theme-scrollbar-color: rgba(0, 0, 0, 0.18);\n --theme-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n --theme-lifted-brightness: 1;\n --theme-backdrop-brightness: 1;\n\n --theme-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.11);\n --theme-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 --theme-button-1: rgb(49 53 56);\n --theme-button-1-color: #fff;\n --theme-button-1-hover: rgb(28 31 33);\n\n --theme-color-green: #007300;\n --theme-color-red: #af272b;\n --theme-color-yellow: #b38200;\n --theme-color-blue: #3b8ba5;\n --theme-color-orange: #fb892c;\n --theme-color-purple: #5203d1;\n}\n\n.dark-mode {\n color-scheme: dark;\n --theme-color-1: rgba(255, 255, 255, 0.9);\n --theme-color-2: rgba(255, 255, 255, 0.62);\n --theme-color-3: rgba(255, 255, 255, 0.44);\n --theme-color-disabled: rgba(255, 255, 255, 0.34);\n --theme-color-ghost: rgba(255, 255, 255, 0.26);\n --theme-color-accent: #27c2a0;\n --theme-background-1: #1b1b1d;\n --theme-background-2: #242526;\n --theme-background-3: #3b3b3b;\n --theme-background-4: rgba(255, 255, 255, 0.06);\n --theme-background-accent: #27c2a01f;\n\n --theme-border-color: rgba(255, 255, 255, 0.1);\n --theme-scrollbar-color: rgba(255, 255, 255, 0.24);\n --theme-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n --theme-lifted-brightness: 1.45;\n --theme-backdrop-brightness: 0.5;\n\n --theme-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, 0.1);\n --theme-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 --theme-button-1: #f6f6f6;\n --theme-button-1-color: #000;\n --theme-button-1-hover: #e7e7e7;\n\n --theme-color-green: #26b226;\n --theme-color-red: #fb565b;\n --theme-color-yellow: #ffc426;\n --theme-color-blue: #6ecfef;\n --theme-color-orange: #ff8d4d;\n --theme-color-purple: #b191f9;\n}\n.scalar-card:nth-of-type(3) {\n display: none;\n}\n"}),n.html`!${r({...a,configuration:i})}`}}),c.route({method:"GET",url:o(a.routePrefix),schema:t,async handler(e,n){n.header("Content-Type","application/javascript; charset=utf-8"),n.send(d)}})};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;const e=require("node:fs"),n=require("node:path"),t=require("node:url");var o="undefined"!=typeof document?document.currentScript:null;const r={hide:!0},c=e=>`${e??""}/@scalar/fastify-api-reference/js/browser.js`.replace(/\/\//g,"/");function a(e){return`\n<!DOCTYPE html>\n<html>\n <head>\n <title>API Reference</title>\n <meta charset="utf-8" />\n <meta\n name="viewport"\n content="width=device-width, initial-scale=1" />\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n ${(e=>{var n,t,o,r;const{configuration:a}=e;return`\n <script\n id="api-reference"\n type="application/json"\n data-configuration="${JSON.stringify(a??{}).split('"').join("&quot;")}">${(null==(n=null==a?void 0:a.spec)?void 0:n.content)?"function"==typeof(null==(t=null==a?void 0:a.spec)?void 0:t.content)?JSON.stringify(null==(o=null==a?void 0:a.spec)?void 0:o.content()):JSON.stringify(null==(r=null==a?void 0:a.spec)?void 0:r.content):""}<\/script>\n <script src="${c(e.routePrefix)}"><\/script>\n `})(e)}\n </body>\n</html>\n`}module.exports=async(l,s)=>{var i,d;let{configuration:h}=s;const u=l.hasPlugin("@fastify/swagger");if(l.hasPlugin("fastify-html")||await l.register(import("fastify-html")),!(null==(i=null==h?void 0:h.spec)?void 0:i.content)&&!(null==(d=null==h?void 0:h.spec)?void 0:d.url)&&!u)return void l.log.warn("[@scalar/fastify-api-reference] You didn’t provide a spec.content or spec.url, and @fastify/swagger could not be found. Please provide one of these options.");const m=function(){const r=n.dirname(t.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:o&&o.src||new URL("index.cjs",document.baseURI).href)),c=[n.resolve(`${r}/js/standalone.js`),n.resolve(`${r}/../../dist/js/standalone.js`)].find((n=>e.existsSync(n)));if(void 0===c)throw new Error(`JavaScript file not found: ${n.resolve(`${r}/js/standalone.js`)}`);return e.readFileSync(c,"utf8")}();l.route({method:"GET",url:s.routePrefix??"/",schema:r,async handler(e,n){var t,o;return n.header("Content-Type","text/html; charset=utf-8"),(null==(t=null==h?void 0:h.spec)?void 0:t.content)||(null==(o=null==h?void 0:h.spec)?void 0:o.url)||!u||(h={...h,spec:{content:()=>l.swagger()}}),(null==h?void 0:h.customCss)||(null==h?void 0:h.theme)||(h={...h,customCss:"\n:root {\n --theme-font: 'Inter', var(--system-fonts);\n}\n\n.light-mode {\n color-scheme: light;\n --theme-color-1: #1c1e21;\n --theme-color-2: #757575;\n --theme-color-3: #8e8e8e;\n --theme-color-disabled: #b4b1b1;\n --theme-color-ghost: #a7a7a7;\n --theme-color-accent: #2f8555;\n --theme-background-1: #fff;\n --theme-background-2: #f5f5f5;\n --theme-background-3: #ededed;\n --theme-background-4: rgba(0, 0, 0, 0.06);\n --theme-background-accent: #2f85551f;\n\n --theme-border-color: rgba(0, 0, 0, 0.1);\n --theme-scrollbar-color: rgba(0, 0, 0, 0.18);\n --theme-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n --theme-lifted-brightness: 1;\n --theme-backdrop-brightness: 1;\n\n --theme-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.11);\n --theme-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 --theme-button-1: rgb(49 53 56);\n --theme-button-1-color: #fff;\n --theme-button-1-hover: rgb(28 31 33);\n\n --theme-color-green: #007300;\n --theme-color-red: #af272b;\n --theme-color-yellow: #b38200;\n --theme-color-blue: #3b8ba5;\n --theme-color-orange: #fb892c;\n --theme-color-purple: #5203d1;\n}\n\n.dark-mode {\n color-scheme: dark;\n --theme-color-1: rgba(255, 255, 255, 0.9);\n --theme-color-2: rgba(255, 255, 255, 0.62);\n --theme-color-3: rgba(255, 255, 255, 0.44);\n --theme-color-disabled: rgba(255, 255, 255, 0.34);\n --theme-color-ghost: rgba(255, 255, 255, 0.26);\n --theme-color-accent: #27c2a0;\n --theme-background-1: #1b1b1d;\n --theme-background-2: #242526;\n --theme-background-3: #3b3b3b;\n --theme-background-4: rgba(255, 255, 255, 0.06);\n --theme-background-accent: #27c2a01f;\n\n --theme-border-color: rgba(255, 255, 255, 0.1);\n --theme-scrollbar-color: rgba(255, 255, 255, 0.24);\n --theme-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n --theme-lifted-brightness: 1.45;\n --theme-backdrop-brightness: 0.5;\n\n --theme-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, 0.1);\n --theme-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 --theme-button-1: #f6f6f6;\n --theme-button-1-color: #000;\n --theme-button-1-hover: #e7e7e7;\n\n --theme-color-green: #26b226;\n --theme-color-red: #fb565b;\n --theme-color-yellow: #ffc426;\n --theme-color-blue: #6ecfef;\n --theme-color-orange: #ff8d4d;\n --theme-color-purple: #b191f9;\n}\n.scalar-card:nth-of-type(3) {\n display: none;\n}\n"}),n.html`!${a({...s,configuration:h})}`}}),l.route({method:"GET",url:c(s.routePrefix),schema:r,async handler(e,n){n.header("Content-Type","application/javascript; charset=utf-8"),n.send(m)}})};
package/dist/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
3
4
  function getJavaScriptFile() {
5
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
4
6
  const filePath = [
5
- path.resolve(`${__dirname}/js/standalone.js`),
6
- path.resolve(`${__dirname}/../../dist/js/standalone.js`)
7
+ path.resolve(`${dirname}/js/standalone.js`),
8
+ path.resolve(`${dirname}/../../dist/js/standalone.js`)
7
9
  ].find((file) => fs.existsSync(file));
8
10
  if (filePath === void 0) {
9
11
  throw new Error(
10
12
  `JavaScript file not found: ${path.resolve(
11
- `${__dirname}/js/standalone.js`
13
+ `${dirname}/js/standalone.js`
12
14
  )}`
13
15
  );
14
16
  }