@scalar/nuxt 0.0.1 → 0.0.3

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,9 +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
- type ModuleOptions = Configuration;
7
- declare const _default: _nuxt_schema.NuxtModule<Configuration>;
8
-
9
- export { type ModuleOptions, _default as default };
1
+ export * from "/home/amritk/apps/scalar/scalar/packages/nuxt/src/module";
2
+ export { default } from "/home/amritk/apps/scalar/scalar/packages/nuxt/src/module";
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@scalar/nuxt",
3
3
  "configKey": "scalarConfig",
4
- "version": "0.0.1"
4
+ "version": "0.0.3"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,46 +1,12 @@
1
- import { defineNuxtModule, createResolver, addComponent, extendPages, addPlugin } from '@nuxt/kit';
1
+ import jiti from "file:///home/amritk/apps/scalar/scalar/node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/lib/index.js";
2
2
 
3
- const module = defineNuxtModule({
4
- meta: {
5
- name: "@scalar/nuxt",
6
- configKey: "scalarConfig"
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: "/scalar"
16
- },
17
- showSidebar: true
18
- },
19
- setup(_options, _nuxt) {
20
- const resolver = createResolver(import.meta.url);
21
- let isOpenApiEnabled = false;
22
- _nuxt.hook("nitro:config", (config) => {
23
- if (config.experimental?.openAPI)
24
- isOpenApiEnabled = true;
25
- });
26
- addComponent({
27
- name: "ScalarApiReference",
28
- export: "default",
29
- filePath: resolver.resolve("./runtime/components/ScalarApiReference.vue")
30
- });
31
- extendPages((pages) => {
32
- pages.push({
33
- name: "scalar",
34
- path: _options.pathRouting?.basePath + ":pathMatch(.*)*",
35
- meta: {
36
- configuration: _options,
37
- isOpenApiEnabled
38
- },
39
- file: resolver.resolve("./runtime/pages/ScalarPage.vue")
40
- });
41
- });
42
- addPlugin(resolver.resolve("./runtime/plugins/hydrateClient"));
3
+ /** @type {import("/home/amritk/apps/scalar/scalar/packages/nuxt/src/module")} */
4
+ const _module = jiti(null, {
5
+ "esmResolve": true,
6
+ "interopDefault": true,
7
+ "alias": {
8
+ "@scalar/nuxt": "/home/amritk/apps/scalar/scalar/packages/nuxt"
43
9
  }
44
- });
10
+ })("/home/amritk/apps/scalar/scalar/packages/nuxt/src/module.ts");
45
11
 
46
- export { module as default };
12
+ export default _module;
package/dist/types.d.mts CHANGED
@@ -1,16 +1,25 @@
1
1
 
2
- import type { ModuleOptions } from './module.js'
2
+ import type { ModuleOptions, ModuleHooks, RuntimeModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.js'
3
3
 
4
+ declare module '#app' {
5
+ interface RuntimeNuxtHooks extends RuntimeModuleHooks, ModuleRuntimeHooks {}
6
+ }
4
7
 
5
8
  declare module '@nuxt/schema' {
6
9
  interface NuxtConfig { ['scalarConfig']?: Partial<ModuleOptions> }
7
10
  interface NuxtOptions { ['scalarConfig']?: ModuleOptions }
11
+ interface NuxtHooks extends ModuleHooks {}
12
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
13
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
8
14
  }
9
15
 
10
16
  declare module 'nuxt/schema' {
11
17
  interface NuxtConfig { ['scalarConfig']?: Partial<ModuleOptions> }
12
18
  interface NuxtOptions { ['scalarConfig']?: ModuleOptions }
19
+ interface NuxtHooks extends ModuleHooks {}
20
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
21
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
13
22
  }
14
23
 
15
24
 
16
- export type { ModuleOptions, default } from './module.js'
25
+ export type { default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,16 +1,25 @@
1
1
 
2
- import type { ModuleOptions } from './module'
2
+ import type { ModuleOptions, ModuleHooks, RuntimeModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
3
3
 
4
+ declare module '#app' {
5
+ interface RuntimeNuxtHooks extends RuntimeModuleHooks, ModuleRuntimeHooks {}
6
+ }
4
7
 
5
8
  declare module '@nuxt/schema' {
6
9
  interface NuxtConfig { ['scalarConfig']?: Partial<ModuleOptions> }
7
10
  interface NuxtOptions { ['scalarConfig']?: ModuleOptions }
11
+ interface NuxtHooks extends ModuleHooks {}
12
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
13
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
8
14
  }
9
15
 
10
16
  declare module 'nuxt/schema' {
11
17
  interface NuxtConfig { ['scalarConfig']?: Partial<ModuleOptions> }
12
18
  interface NuxtOptions { ['scalarConfig']?: ModuleOptions }
19
+ interface NuxtHooks extends ModuleHooks {}
20
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
21
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
13
22
  }
14
23
 
15
24
 
16
- export type { ModuleOptions, default } from './module'
25
+ export type { default } from './module'
package/package.json CHANGED
@@ -15,10 +15,24 @@
15
15
  "testing",
16
16
  "vue"
17
17
  ],
18
- "version": "0.0.1",
18
+ "version": "0.0.3",
19
19
  "engines": {
20
20
  "node": ">=18"
21
21
  },
22
+ "type": "module",
23
+ "scripts": {
24
+ "build": "nuxt-module-build build",
25
+ "dev": "nuxi dev playground",
26
+ "dev:build": "nuxi build playground",
27
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
28
+ "lint:check": "eslint .",
29
+ "lint:fix": "eslint . --fix",
30
+ "prepack": "nuxt-module-build build",
31
+ "prepare": "pnpm dev:prepare",
32
+ "toist": "vitest run",
33
+ "test:watch": "vitest watch",
34
+ "types:check": "nuxi typecheck"
35
+ },
22
36
  "main": "./dist/module.cjs",
23
37
  "types": "./dist/types.d.ts",
24
38
  "exports": {
@@ -33,7 +47,10 @@
33
47
  ],
34
48
  "dependencies": {
35
49
  "@nuxt/kit": "^3.11.2",
36
- "@scalar/api-reference": "1.20.30"
50
+ "@scalar/api-reference": "workspace:*"
51
+ },
52
+ "peerDepenencies": {
53
+ "debug": "4.3.4"
37
54
  },
38
55
  "devDependencies": {
39
56
  "@nuxt/devtools": "^1.1.5",
@@ -46,17 +63,5 @@
46
63
  "eslint": "^8.56.0",
47
64
  "nuxt": "^3.11.2",
48
65
  "vitest": "^1.2.2"
49
- },
50
- "scripts": {
51
- "build": "nuxt-module-build build",
52
- "dev": "nuxi dev playground",
53
- "dev:build": "nuxi build playground",
54
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
55
- "lint:check": "eslint .",
56
- "lint:fix": "eslint . --fix",
57
- "postinstall": "pnpm dev:prepare",
58
- "toist": "vitest run",
59
- "test:watch": "vitest watch",
60
- "types:check": "nuxi typecheck"
61
66
  }
62
- }
67
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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/dist/module.d.mts DELETED
@@ -1,9 +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
- type ModuleOptions = Configuration;
7
- declare const _default: _nuxt_schema.NuxtModule<Configuration>;
8
-
9
- export { type ModuleOptions, _default as default };
@@ -1,53 +0,0 @@
1
- <script lang="ts" setup>
2
- import { ModernLayout, parse } from '@scalar/api-reference'
3
- import '@scalar/api-reference/index.css'
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
- .light-mode{--theme-background-1:#fff;--theme-background-2:#f8fafc;--theme-background-3:#e7e7e7;--theme-background-accent:#8ab4f81f;--theme-color-1:#000;--theme-color-2:#6b7280;--theme-color-3:#9ca3af;--theme-color-accent:#00c16a;--theme-border-color:#e5e7eb;--theme-color-green:#069061;--theme-color-red:#ef4444;--theme-color-yellow:#f59e0b;--theme-color-blue:#1d4ed8;--theme-color-orange:#fb892c;--theme-color-purple:#6d28d9;--theme-button-1:#000;--theme-button-1-hover:rgba(0,0,0,.9);--theme-button-1-color:#fff}.dark-mode{--theme-background-1:#020420;--theme-background-2:#121a31;--theme-background-3:#1e293b;--theme-background-accent:#8ab4f81f;--theme-color-1:#fff;--theme-color-2:#cbd5e1;--theme-color-3:#94a3b8;--theme-color-accent:#00dc82;--theme-border-color:#1e293b;--theme-color-green:#069061;--theme-color-red:#f87171;--theme-color-yellow:#fde68a;--theme-color-blue:#60a5fa;--theme-color-orange:#fb892c;--theme-color-purple:#ddd6fe;--theme-button-1:hsla(0,0%,100%,.9);--theme-button-1-hover:hsla(0,0%,100%,.8);--theme-button-1-color:#000}.dark-mode .t-doc__sidebar,.light-mode .t-doc__sidebar{--sidebar-background-1:var(--theme-background-1);--sidebar-color-1:var(--theme-color-1);--sidebar-color-2:var(--theme-color-3);--sidebar-border-color:var(--theme-border-color);--sidebar-item-hover-background:transparent;--sidebar-item-hover-color:var(--theme-color-1);--sidebar-item-active-background:transparent;--sidebar-color-active:var(--theme-color-accent);--sidebar-search-background:transparent;--sidebar-search-color:var(--theme-color-3);--sidebar-search-border-color:var(--theme-border-color);--sidebar-indent-border:var(--theme-border-color);--sidebar-indent-border-hover:var(--theme-color-1);--sidebar-indent-border-active:var(--theme-color-accent)}.scalar-card .request-card-footer{--theme-background-3:var(--theme-background-2);--theme-button-1:#0f172a;--theme-button-1-hover:rgba(30,41,59,.5);--theme-button-1-color:#fff}.scalar-card .show-api-client-button{border:1px solid #334155!important}
@@ -1,20 +0,0 @@
1
- <script lang="ts" setup>
2
- import type { Meta } from '~/src/types'
3
-
4
- const route = useRoute()
5
- const meta = route.meta as Meta
6
-
7
- // Ensure we have a spec
8
- if (
9
- !meta.isOpenApiEnabled &&
10
- !meta.configuration?.spec?.url &&
11
- !meta.configuration?.spec?.content
12
- )
13
- throw new Error(
14
- 'You must either provide a spec to scalarConfig, or enable experimental openApi in the Nitro config.',
15
- )
16
- </script>
17
-
18
- <template>
19
- <ScalarApiReference :configuration="meta.configuration" />
20
- </template>
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,12 +0,0 @@
1
- import { defineNuxtPlugin } from "#app";
2
- export default defineNuxtPlugin((_nuxtApp) => {
3
- _nuxtApp.hook("app:rendered", ({ ssrContext }) => {
4
- useHead({
5
- script: [
6
- {
7
- children: `window.__SCALAR__ = ${JSON.stringify(ssrContext?.payload?.data ?? {})}`
8
- }
9
- ]
10
- });
11
- });
12
- });