@scalar/nuxt 0.2.27 → 0.2.29

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/module.d.ts CHANGED
@@ -1,22 +1,2 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { ReferenceConfiguration } from '@scalar/api-reference';
3
-
4
- type Configuration = Omit<ReferenceConfiguration, 'layout' | 'isEditable' | 'onSpecUpdate'> & {
5
- /**
6
- * Whether to show scalar in Nuxt DevTools
7
- *
8
- * @default true
9
- */
10
- devtools: boolean;
11
- };
12
-
13
- type ModuleOptions = {
14
- /**
15
- * For multiple references, pass an array of config objects into
16
- * configurations. These configurations will extend over the base config
17
- */
18
- configurations: Omit<Configuration, 'devtools'>[];
19
- } & Configuration;
20
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
21
-
22
- export { type ModuleOptions, _default as default };
1
+ export * from "/home/runner/work/scalar/scalar/packages/nuxt/src/module";
2
+ export { default } from "/home/runner/work/scalar/scalar/packages/nuxt/src/module";
package/dist/module.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "@scalar/nuxt",
3
3
  "configKey": "scalar",
4
- "version": "0.2.27"
4
+ "version": "0.2.29",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.8.1",
7
+ "unbuild": "unknown"
8
+ }
5
9
  }
package/dist/module.mjs CHANGED
@@ -1,87 +1,12 @@
1
- import { defineNuxtModule, createResolver, addComponent, extendPages, addPlugin } from '@nuxt/kit';
1
+ import jiti from "file:///home/runner/work/scalar/scalar/node_modules/.pnpm/jiti@1.21.6/node_modules/jiti/lib/index.js";
2
2
 
3
- const module = defineNuxtModule({
4
- meta: {
5
- name: "@scalar/nuxt",
6
- configKey: "scalar"
7
- },
8
- // Default configuration options of the Nuxt module
9
- defaults: {
10
- darkMode: true,
11
- metaData: {
12
- title: "API Documentation by Scalar"
13
- },
14
- pathRouting: {
15
- basePath: "/docs"
16
- },
17
- showSidebar: true,
18
- devtools: true,
19
- configurations: []
20
- },
21
- setup(_options, _nuxt) {
22
- const resolver = createResolver(import.meta.url);
23
- let isOpenApiEnabled = false;
24
- _nuxt.options.build.transpile.push("yaml");
25
- _nuxt.options.vite.optimizeDeps ||= {};
26
- _nuxt.options.vite.optimizeDeps.include ||= [];
27
- _nuxt.options.vite.optimizeDeps.include.push(
28
- "debug",
29
- "extend",
30
- "stringify-object",
31
- "rehype-highlight"
32
- );
33
- _nuxt.hook("nitro:config", (config) => {
34
- if (config.experimental?.openAPI)
35
- isOpenApiEnabled = true;
36
- });
37
- addComponent({
38
- name: "ScalarApiReference",
39
- export: "default",
40
- filePath: resolver.resolve("./runtime/components/ScalarApiReference.vue")
41
- });
42
- extendPages((pages) => {
43
- if (_options.configurations.length) {
44
- const { configurations, ...baseConfig } = _options;
45
- configurations.forEach((_config, index) => {
46
- const configuration = { ...baseConfig, ..._config };
47
- pages.push({
48
- name: "scalar-" + index,
49
- path: configuration.pathRouting?.basePath + ":pathMatch(.*)*",
50
- meta: {
51
- configuration,
52
- isOpenApiEnabled
53
- },
54
- file: resolver.resolve("./runtime/pages/ScalarPage.vue")
55
- });
56
- });
57
- } else {
58
- pages.push({
59
- name: "scalar",
60
- path: _options.pathRouting?.basePath + ":pathMatch(.*)*",
61
- meta: {
62
- configuration: _options,
63
- isOpenApiEnabled
64
- },
65
- file: resolver.resolve("./runtime/pages/ScalarPage.vue")
66
- });
67
- }
68
- });
69
- if (_nuxt.options.dev && _options.devtools) {
70
- _nuxt.hook("devtools:customTabs", (tabs) => {
71
- tabs.push({
72
- name: "scalar",
73
- title: "Scalar",
74
- icon: "https://gist.githubusercontent.com/cameronrohani/0fa020f6dcf957266bff49e7b6b7c05e/raw/17fce1ef37bbb036dca36b778c8b422056ad6fdf/scalar-logo-nuxt-color.svg",
75
- category: "server",
76
- view: {
77
- type: "iframe",
78
- src: _options.pathRouting?.basePath ?? "/docs"
79
- }
80
- });
81
- });
82
- }
83
- addPlugin(resolver.resolve("./runtime/plugins/hydrateClient"));
3
+ /** @type {import("/home/runner/work/scalar/scalar/packages/nuxt/src/module")} */
4
+ const _module = jiti(null, {
5
+ "esmResolve": true,
6
+ "interopDefault": true,
7
+ "alias": {
8
+ "@scalar/nuxt": "/home/runner/work/scalar/scalar/packages/nuxt"
84
9
  }
85
- });
10
+ })("/home/runner/work/scalar/scalar/packages/nuxt/src/module.ts");
86
11
 
87
- export { module as default };
12
+ export default _module;
package/dist/types.d.mts CHANGED
@@ -1,16 +1,19 @@
1
+ import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.js'
1
2
 
2
- import type { ModuleOptions } from './module.js'
3
-
3
+ declare module '#app' {
4
+ interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
+ }
4
6
 
5
7
  declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['scalar']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['scalar']?: ModuleOptions }
8
+ interface NuxtHooks extends ModuleHooks {}
9
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
10
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
8
11
  }
9
12
 
10
13
  declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['scalar']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['scalar']?: ModuleOptions }
14
+ interface NuxtHooks extends ModuleHooks {}
15
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
16
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
13
17
  }
14
18
 
15
-
16
- export type { ModuleOptions, default } from './module.js'
19
+ export * from "./module.js"
package/dist/types.d.ts CHANGED
@@ -1,16 +1,19 @@
1
+ import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
1
2
 
2
- import type { ModuleOptions } from './module'
3
-
3
+ declare module '#app' {
4
+ interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
+ }
4
6
 
5
7
  declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['scalar']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['scalar']?: ModuleOptions }
8
+ interface NuxtHooks extends ModuleHooks {}
9
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
10
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
8
11
  }
9
12
 
10
13
  declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['scalar']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['scalar']?: ModuleOptions }
14
+ interface NuxtHooks extends ModuleHooks {}
15
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
16
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
13
17
  }
14
18
 
15
-
16
- export type { ModuleOptions, default } from './module'
19
+ export * from "./module"
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "testing",
21
21
  "vue"
22
22
  ],
23
- "version": "0.2.27",
23
+ "version": "0.2.29",
24
24
  "engines": {
25
25
  "node": ">=18"
26
26
  },
@@ -38,20 +38,20 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@nuxt/kit": "^3.11.2",
42
- "@scalar/api-client": "2.0.5",
43
- "@scalar/api-reference": "1.24.28"
41
+ "@nuxt/kit": "^3.12.3",
42
+ "@scalar/api-client": "2.0.7",
43
+ "@scalar/api-reference": "1.24.30"
44
44
  },
45
45
  "devDependencies": {
46
- "@nuxt/devtools": "^1.1.5",
47
- "@nuxt/eslint-config": "^0.3.4",
48
- "@nuxt/module-builder": "^0.5.5",
49
- "@nuxt/schema": "^3.11.2",
50
- "@nuxt/test-utils": "^3.12.0",
46
+ "@nuxt/devtools": "^1.3.9",
47
+ "@nuxt/eslint-config": "^0.3.13",
48
+ "@nuxt/module-builder": "^0.8.1",
49
+ "@nuxt/schema": "^3.12.3",
50
+ "@nuxt/test-utils": "^3.13.1",
51
51
  "@types/node": "^20.8.4",
52
52
  "changelogen": "^0.5.5",
53
53
  "eslint": "^8.56.0",
54
- "nuxt": "^3.11.2",
54
+ "nuxt": "^3.12.3",
55
55
  "vitest": "^1.6.0"
56
56
  },
57
57
  "scripts": {
package/dist/module.d.mts DELETED
@@ -1,22 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { ReferenceConfiguration } from '@scalar/api-reference';
3
-
4
- type Configuration = Omit<ReferenceConfiguration, 'layout' | 'isEditable' | 'onSpecUpdate'> & {
5
- /**
6
- * Whether to show scalar in Nuxt DevTools
7
- *
8
- * @default true
9
- */
10
- devtools: boolean;
11
- };
12
-
13
- type ModuleOptions = {
14
- /**
15
- * For multiple references, pass an array of config objects into
16
- * configurations. These configurations will extend over the base config
17
- */
18
- configurations: Omit<Configuration, 'devtools'>[];
19
- } & Configuration;
20
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
21
-
22
- export { type ModuleOptions, _default as default };
@@ -1,53 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useHead, useRequestURL, useSeoMeta } from '#imports'
3
- import { ModernLayout, parse } from '@scalar/api-reference'
4
- import { reactive, ref, toRaw } from 'vue'
5
- import type { Configuration } from '~/src/types'
6
-
7
- import './nuxt-theme.css'
8
-
9
- const props = defineProps<{
10
- configuration: Configuration
11
- }>()
12
-
13
- const isDark = ref(props.configuration.darkMode)
14
-
15
- // Grab spec if we can
16
- const content: unknown = props.configuration.spec?.content
17
- ? toRaw(props.configuration.spec.content)
18
- : props.configuration.spec?.url
19
- ? await $fetch(props.configuration.spec?.url)
20
- : await $fetch('/_nitro/openapi.json')
21
-
22
- // Check for empty spec
23
- if (!content)
24
- throw new Error('You must provide a spec for Scalar API References')
25
-
26
- const parsedSpec = reactive(await parse(content))
27
- const rawSpec = JSON.stringify(content)
28
-
29
- // Load up the metadata
30
- if (props.configuration?.metaData) useSeoMeta(props.configuration.metaData)
31
-
32
- useHead({
33
- bodyAttrs: {
34
- class: () => (isDark.value ? 'dark-mode' : 'light-mode'),
35
- },
36
- })
37
-
38
- // Add baseServerURL
39
- const { origin } = useRequestURL()
40
- const config = {
41
- baseServerURL: origin,
42
- ...props.configuration,
43
- }
44
- </script>
45
-
46
- <template>
47
- <ModernLayout
48
- :configuration="config"
49
- :isDark="isDark"
50
- :parsedSpec="parsedSpec"
51
- :rawSpec="rawSpec"
52
- @toggleDarkMode="isDark = !isDark" />
53
- </template>
@@ -1 +0,0 @@
1
- @import "@scalar/api-client/style.css";@import "@scalar/api-reference/style.css";.light-mode{--scalar-background-1:#fff;--scalar-background-2:#f8fafc;--scalar-background-3:#e7e7e7;--scalar-background-accent:#8ab4f81f;--scalar-color-1:#000;--scalar-color-2:#6b7280;--scalar-color-3:#9ca3af;--scalar-color-accent:#00c16a;--scalar-border-color:#e5e7eb;--scalar-color-green:#069061;--scalar-color-red:#ef4444;--scalar-color-yellow:#f59e0b;--scalar-color-blue:#1d4ed8;--scalar-color-orange:#fb892c;--scalar-color-purple:#6d28d9;--scalar-button-1:#000;--scalar-button-1-hover:rgba(0,0,0,.9);--scalar-button-1-color:#fff}.dark-mode{--scalar-background-1:#020420;--scalar-background-2:#121a31;--scalar-background-3:#1e293b;--scalar-background-accent:#8ab4f81f;--scalar-color-1:#fff;--scalar-color-2:#cbd5e1;--scalar-color-3:#94a3b8;--scalar-color-accent:#00dc82;--scalar-border-color:#1e293b;--scalar-color-green:#069061;--scalar-color-red:#f87171;--scalar-color-yellow:#fde68a;--scalar-color-blue:#60a5fa;--scalar-color-orange:#fb892c;--scalar-color-purple:#ddd6fe;--scalar-button-1:hsla(0,0%,100%,.9);--scalar-button-1-hover:hsla(0,0%,100%,.8);--scalar-button-1-color:#000}.dark-mode .t-doc__sidebar,.light-mode .t-doc__sidebar{--scalar-sidebar-background-1:var(--scalar-background-1);--scalar-sidebar-color-1:var(--scalar-color-1);--scalar-sidebar-color-2:var(--scalar-color-3);--scalar-sidebar-border-color:var(--scalar-border-color);--scalar-sidebar-item-hover-background:transparent;--scalar-sidebar-item-hover-color:var(--scalar-color-1);--scalar-sidebar-item-active-background:transparent;--scalar-sidebar-color-active:var(--scalar-color-accent);--scalar-sidebar-search-background:transparent;--scalar-sidebar-search-color:var(--scalar-color-3);--scalar-sidebar-search-border-color:var(--scalar-border-color);--scalar-sidebar-indent-border:var(--scalar-border-color);--scalar-sidebar-indent-border-hover:var(--scalar-color-1);--scalar-sidebar-indent-border-active:var(--scalar-color-accent)}.scalar-card .request-card-footer{--scalar-background-3:var(--scalar-background-2);--scalar-button-1:#0f172a;--scalar-button-1-hover:rgba(30,41,59,.5);--scalar-button-1-color:#fff}.scalar-card .show-api-client-button{border:1px solid #334155!important}
@@ -1,21 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useRoute } from '#imports'
3
- import type { Meta } from '~/src/types'
4
-
5
- const route = useRoute()
6
- const meta = route.meta as Meta
7
-
8
- // Ensure we have a spec
9
- if (
10
- !meta.isOpenApiEnabled &&
11
- !meta.configuration?.spec?.url &&
12
- !meta.configuration?.spec?.content
13
- )
14
- throw new Error(
15
- 'You must either provide a spec to scalar, or enable experimental openApi in the Nitro config.',
16
- )
17
- </script>
18
-
19
- <template>
20
- <ScalarApiReference :configuration="meta.configuration" />
21
- </template>
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,13 +0,0 @@
1
- import { defineNuxtPlugin } from "#app";
2
- import { useHead } from "#imports";
3
- export default defineNuxtPlugin((_nuxtApp) => {
4
- _nuxtApp.hook("app:rendered", ({ ssrContext }) => {
5
- useHead({
6
- script: [
7
- {
8
- children: `window.__SCALAR__ = ${JSON.stringify(ssrContext?.payload?.data ?? {})}`
9
- }
10
- ]
11
- });
12
- });
13
- });