vitepress-openapi 0.2.13 → 0.2.15

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.
Files changed (43) hide show
  1. package/dist/{OAJSONEditor-Cxpub1dW.js → OAJSONEditor-BPdzinnW.js} +1 -1
  2. package/dist/{OAJSONEditor-B27HNYxA.cjs → OAJSONEditor-cdYfH8pW.cjs} +2 -2
  3. package/dist/{engine-javascript-Jp6ImdBF.js → engine-javascript-DSMQf2z2.js} +12 -12
  4. package/dist/{engine-javascript-C27eFBsG.cjs → engine-javascript-DsJlQOsE.cjs} +2 -2
  5. package/dist/standalone.css +1385 -0
  6. package/dist/types/src/client.d.ts +1 -12
  7. package/dist/types/src/components/Common/OADocRoot.vue.d.ts +15 -0
  8. package/dist/types/src/components/Feature/OASpec.vue.d.ts +17 -0
  9. package/dist/types/src/composables/useSidebar.d.ts +16 -3
  10. package/dist/types/src/lib/docRoot.d.ts +3 -0
  11. package/dist/types/src/lib/sidebar/cleanSidebarItems.d.ts +2 -3
  12. package/dist/types/src/lib/spec/lazyRendering.d.ts +5 -0
  13. package/dist/types/src/lib/utils/copyCode.d.ts +1 -0
  14. package/dist/types/src/vue.d.ts +35 -0
  15. package/dist/vitepress-openapi.client.cjs.js +1 -6
  16. package/dist/vitepress-openapi.client.es.js +10 -17169
  17. package/dist/vitepress-openapi.css +1 -1
  18. package/dist/vitepress-openapi.vue.cjs.js +1 -0
  19. package/dist/vitepress-openapi.vue.es.js +3 -0
  20. package/dist/vue-Cdo23EVh.cjs +6 -0
  21. package/dist/vue-DpVGGK22.js +17272 -0
  22. package/package.json +16 -4
  23. package/src/client.ts +6 -39
  24. package/src/components/Common/OADocRoot.vue +18 -0
  25. package/src/components/Feature/OAInfo.vue +11 -5
  26. package/src/components/Feature/OAIntroduction.vue +12 -6
  27. package/src/components/Feature/OAOperation.vue +22 -19
  28. package/src/components/Feature/OAServers.vue +11 -5
  29. package/src/components/Feature/OASpec.vue +37 -22
  30. package/src/components/Path/OAPaths.vue +12 -5
  31. package/src/components/Path/OAPathsGroup.vue +2 -1
  32. package/src/components/Path/OAPathsGroups.vue +2 -3
  33. package/src/composables/useSidebar.ts +18 -4
  34. package/src/lib/docRoot.ts +4 -0
  35. package/src/lib/sidebar/cleanSidebarItems.ts +4 -5
  36. package/src/lib/spec/lazyRendering.ts +12 -0
  37. package/src/lib/utils/copyCode.ts +46 -0
  38. package/src/standalone.css +38 -0
  39. package/src/vue.ts +81 -0
  40. package/dist/classPrivateFieldGet2-B5R_onup.js +0 -22
  41. package/dist/classPrivateFieldGet2-Bglvjmhn.cjs +0 -1
  42. package/dist/lib-DtBHFGXA.cjs +0 -1
  43. package/dist/lib-DuAv3NcE.js +0 -27
@@ -2,7 +2,6 @@ import type { Awaitable } from 'vitepress';
2
2
  import type { EnhanceAppContext, Theme } from 'vitepress/client';
3
3
  import type { Component } from 'vue';
4
4
  import type { OpenApiSpecInstance } from './lib/spec/createOpenApiSpec';
5
- import { DEFAULT_OPERATION_SLOTS } from './composables/useTheme';
6
5
  interface OAEnhanceAppContext extends EnhanceAppContext {
7
6
  openapi?: OpenApiSpecInstance | null;
8
7
  }
@@ -12,14 +11,4 @@ interface VPTheme {
12
11
  extends?: Theme;
13
12
  }
14
13
  export declare const theme: VPTheme;
15
- export * from './components';
16
- export { useOpenapi } from './composables/useOpenapi';
17
- export { usePlayground } from './composables/usePlayground';
18
- export { DEFAULT_OPERATION_SLOTS };
19
- export { useShiki } from './composables/useShiki';
20
- export { useTheme } from './composables/useTheme';
21
- export { generateCodeSample } from './lib/codeSamples/generateCodeSample';
22
- export { OARequest } from './lib/codeSamples/request';
23
- export { createOpenApiSpec } from './lib/spec/createOpenApiSpec';
24
- export { minifyHtml } from './lib/utils/minifyHtml';
25
- export { locales } from './locales';
14
+ export * from './vue';
@@ -0,0 +1,15 @@
1
+ declare var __VLS_1: {}, __VLS_3: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ } & {
5
+ default?: (props: typeof __VLS_3) => any;
6
+ };
7
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
@@ -49,6 +49,14 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
49
49
  type: BooleanConstructor;
50
50
  default: undefined;
51
51
  };
52
+ /**
53
+ * Render only the first operation, and the rest when the browser is idle. Overrides `spec.lazyRendering`
54
+ * of the theme config for this instance, also during SSR (where page-level theme config may not apply).
55
+ */
56
+ lazyRendering: {
57
+ type: BooleanConstructor;
58
+ default: undefined;
59
+ };
52
60
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
53
61
  "update:spec": (...args: any[]) => void;
54
62
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -96,12 +104,21 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
96
104
  type: BooleanConstructor;
97
105
  default: undefined;
98
106
  };
107
+ /**
108
+ * Render only the first operation, and the rest when the browser is idle. Overrides `spec.lazyRendering`
109
+ * of the theme config for this instance, also during SSR (where page-level theme config may not apply).
110
+ */
111
+ lazyRendering: {
112
+ type: BooleanConstructor;
113
+ default: undefined;
114
+ };
99
115
  }>> & Readonly<{
100
116
  "onUpdate:spec"?: ((...args: any[]) => any) | undefined;
101
117
  }>, {
102
118
  tags: unknown[];
103
119
  spec: string | Record<string, any>;
104
120
  groupByTags: boolean;
121
+ lazyRendering: boolean;
105
122
  specUrl: string;
106
123
  hideDefaultFooter: boolean;
107
124
  hideBranding: boolean;
@@ -1,5 +1,4 @@
1
1
  import type { OpenAPIV3 } from '@scalar/openapi-types';
2
- import type { DefaultTheme } from 'vitepress';
3
2
  import type { OpenAPIDocument } from '../types';
4
3
  type MethodAliases = Record<string, string>;
5
4
  export interface SidebarItemTemplateParams {
@@ -40,7 +39,21 @@ export interface SidebarGroupsConfig {
40
39
  sidebarItemTemplate?: SidebarItemTemplateFn;
41
40
  sidebarGroupTemplate?: SidebarGroupTemplateFn;
42
41
  }
43
- export interface OASidebarItem extends DefaultTheme.SidebarItem {
42
+ /**
43
+ * Same shape as VitePress' `SidebarItem`, so it can be used as `themeConfig.sidebar`,
44
+ * without depending on VitePress types (e.g. in a plain Vue app).
45
+ */
46
+ export interface SidebarItem {
47
+ text?: string;
48
+ link?: string;
49
+ items?: SidebarItem[];
50
+ collapsed?: boolean;
51
+ base?: string;
52
+ docFooterText?: string;
53
+ rel?: string;
54
+ target?: string;
55
+ }
56
+ export interface OASidebarItem extends SidebarItem {
44
57
  path?: string;
45
58
  isOperation?: boolean;
46
59
  flattenedItems?: OASidebarItem[];
@@ -59,6 +72,6 @@ export declare function useSidebar({ spec, linkPrefix, tagLinkPrefix, defaultTag
59
72
  linkPrefix?: string;
60
73
  sidebarItemTemplate?: SidebarItemTemplateFn;
61
74
  sidebarGroupTemplate?: SidebarGroupTemplateFn;
62
- }) => DefaultTheme.SidebarItem[];
75
+ }) => SidebarItem[];
63
76
  };
64
77
  export {};
@@ -0,0 +1,3 @@
1
+ import type { InjectionKey } from 'vue';
2
+ /** Provided by the VOpenapi plugin: wrap the entry components in a `.vp-doc` element. */
3
+ export declare const DOC_ROOT_KEY: InjectionKey<boolean>;
@@ -1,3 +1,2 @@
1
- import type { DefaultTheme } from 'vitepress';
2
- import type { OASidebarItem } from '../../composables/useSidebar';
3
- export declare function cleanSidebarItems(result: (OASidebarItem[] | OASidebarItem)): DefaultTheme.SidebarItem[] | DefaultTheme.SidebarItem;
1
+ import type { OASidebarItem, SidebarItem } from '../../composables/useSidebar';
2
+ export declare function cleanSidebarItems(result: (OASidebarItem[] | OASidebarItem)): SidebarItem[] | SidebarItem;
@@ -0,0 +1,5 @@
1
+ import type { InjectionKey } from 'vue';
2
+ /** Provided by OASpec when it receives `lazy-rendering`, so it applies per instance, also during SSR. */
3
+ export declare const LAZY_RENDERING_KEY: InjectionKey<boolean | undefined>;
4
+ /** `lazy-rendering` of the closest OASpec, or `spec.lazyRendering` of the theme config. */
5
+ export declare function useLazyRendering(): boolean;
@@ -0,0 +1 @@
1
+ export declare function setupCopyCode(): void;
@@ -0,0 +1,35 @@
1
+ import type { Plugin } from 'vue';
2
+ import type { PartialUseThemeConfig } from './composables/useTheme';
3
+ import type { OpenAPIDocument } from './types';
4
+ import { DEFAULT_OPERATION_SLOTS } from './composables/useTheme';
5
+ export interface VOpenapiOptions {
6
+ /** OpenAPI document (object, or a JSON/YAML string) used by components without their own `spec`. */
7
+ spec?: OpenAPIDocument | string;
8
+ /** Theme configuration, the same as `useTheme(config)`. */
9
+ config?: PartialUseThemeConfig;
10
+ /** Handle the copy buttons of code blocks. VitePress already does it, so its theme disables this. Default: true. */
11
+ copyCode?: boolean;
12
+ /**
13
+ * Wrap the entry components (OAOperation, OASpec, OAIntroduction, OAInfo, OAServers) in a `.vp-doc`
14
+ * element, which `standalone.css` styles. VitePress pages are already inside `.vp-doc`, so its theme
15
+ * disables this. Default: true.
16
+ */
17
+ vpDoc?: boolean;
18
+ }
19
+ /**
20
+ * Vue plugin to use the components in any Vue 3 app, without VitePress.
21
+ * It installs i18n and registers the components globally.
22
+ */
23
+ export declare const VOpenapi: Plugin<[VOpenapiOptions?]>;
24
+ export * from './components';
25
+ export { useOpenapi } from './composables/useOpenapi';
26
+ export { usePlayground } from './composables/usePlayground';
27
+ export { DEFAULT_OPERATION_SLOTS };
28
+ export { useShiki } from './composables/useShiki';
29
+ export { type SidebarItem, useSidebar } from './composables/useSidebar';
30
+ export { type PartialUseThemeConfig, useTheme } from './composables/useTheme';
31
+ export { generateCodeSample } from './lib/codeSamples/generateCodeSample';
32
+ export { OARequest } from './lib/codeSamples/request';
33
+ export { createOpenApiSpec } from './lib/spec/createOpenApiSpec';
34
+ export { minifyHtml } from './lib/utils/minifyHtml';
35
+ export { locales } from './locales';