@scalar/api-reference 1.51.0 → 1.52.0
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 +13 -0
- package/dist/browser/standalone.js +205 -203
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/ApiReference.vue.js +1 -1
- package/dist/components/ApiReference.vue.js.map +1 -1
- package/dist/components/ApiReference.vue.script.js +1 -1
- package/dist/components/ApiReference.vue.script.js.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.js +1 -1
- package/dist/features/Operation/components/RequestBody.vue.js.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.script.js +31 -21
- package/dist/features/Operation/components/RequestBody.vue.script.js.map +1 -1
- package/dist/features/Operation/layouts/ModernLayout.vue.script.js.map +1 -1
- package/dist/features/Search/helpers/create-fuse-instance.d.ts.map +1 -1
- package/dist/features/Search/helpers/create-fuse-instance.js +4 -0
- package/dist/features/Search/helpers/create-fuse-instance.js.map +1 -1
- package/dist/features/Search/helpers/create-search-index.js +4 -3
- package/dist/features/Search/helpers/create-search-index.js.map +1 -1
- package/dist/features/Search/types.d.ts +2 -2
- package/dist/features/Search/types.d.ts.map +1 -1
- package/dist/helpers/map-config-plugins.d.ts +3 -2
- package/dist/helpers/map-config-plugins.d.ts.map +1 -1
- package/dist/helpers/map-config-plugins.js +13 -9
- package/dist/helpers/map-config-plugins.js.map +1 -1
- package/dist/helpers/openapi.d.ts +6 -14
- package/dist/helpers/openapi.d.ts.map +1 -1
- package/dist/helpers/openapi.js +24 -29
- package/dist/helpers/openapi.js.map +1 -1
- package/dist/standalone/lib/html-api.d.ts.map +1 -1
- package/dist/standalone/lib/html-api.js +12 -12
- package/dist/standalone/lib/html-api.js.map +1 -1
- package/dist/style.css +64 -25
- package/package.json +12 -17
- package/dist/ssr.d.ts +0 -22
- package/dist/ssr.d.ts.map +0 -1
- package/dist/ssr.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.js","names":[],"sources":["../../src/helpers/openapi.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.1/strict/media-type'\nimport type {\n OpenApiDocument,\n OperationObject,\n ParameterObject,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\n\n/** Object schema shape with properties, used when logging request body. */\ntype ObjectSchemaWithProperties = {\n properties: Record<string, SchemaReferenceType<SchemaObject>>\n required?: string[]\n}\n\nconst isSchemaObject = (value: unknown): value is SchemaObject => typeof value === 'object' && value !== null\n\nconst schemaTypeToString = (schema: SchemaObject): string => {\n if (!('type' in schema)) {\n return ''\n }\n\n if (typeof schema.type === 'string') {\n return schema.type\n }\n\n return Array.isArray(schema.type) ? schema.type.join('|') : ''\n}\n\n/**\n * Resolves a schema reference from workspace-store to a SchemaObject.\n * Returns undefined when a reference exists but has not been resolved yet.\n */\nfunction resolveSchemaRef(ref: SchemaReferenceType<SchemaObject>): SchemaObject | undefined {\n if (typeof ref === 'object' && ref !== null && '$ref' in ref) {\n return isSchemaObject(ref['$ref-value']) ? ref['$ref-value'] : undefined\n }\n\n return ref\n}\n\n/**\n * Formats a property object into a string.\n */\nfunction formatProperty(key: string, obj: ObjectSchemaWithProperties): string {\n let output = key\n const isRequired = obj.required?.includes(key)\n output += isRequired ? ' REQUIRED ' : ' optional '\n const propRef = obj.properties[key]\n if (!propRef) return output\n const property = resolveSchemaRef(propRef)\n\n if (property) {\n output += schemaTypeToString(property)\n\n if ('description' in property && typeof property.description === 'string') {\n output += ` ${property.description}`\n }\n }\n\n return output\n}\n\n/**\n * Recursively logs the properties of an object.\n */\nfunction recursiveLogger(obj: MediaTypeObject): string[] {\n const results: string[] = ['Body']\n const schema = getResolvedRef(obj?.schema)\n\n if (!schema || !isObjectSchema(schema) || !schema.properties) {\n return results\n }\n\n const properties = schema.properties\n const schemaWithProps: ObjectSchemaWithProperties = {\n properties,\n required: schema.required,\n }\n Object.keys(properties).forEach((key) => {\n if (!obj.schema) {\n return\n }\n\n results.push(formatProperty(key, schemaWithProps))\n\n const propRef = properties[key]\n if (!propRef) return\n const property = resolveSchemaRef(propRef)\n if (property && isObjectSchema(property) && property.properties) {\n const nestedProperties = property.properties\n Object.keys(nestedProperties).forEach((subKey) => {\n const ref = nestedProperties[subKey]\n if (!ref) return\n const nested = resolveSchemaRef(ref)\n const typeStr = nested ? schemaTypeToString(nested) : ''\n results.push(`${subKey} ${typeStr}`)\n })\n }\n })\n\n return results\n}\n\n/**\n * Extracts the request body from an operation.\n */\nexport function extractRequestBody(operation: OperationObject): string[] |
|
|
1
|
+
{"version":3,"file":"openapi.js","names":[],"sources":["../../src/helpers/openapi.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.1/strict/media-type'\nimport type {\n OpenApiDocument,\n OperationObject,\n ParameterObject,\n ReferenceType,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards'\n\n/** Object schema shape with properties, used when logging request body. */\ntype ObjectSchemaWithProperties = {\n properties: Record<string, SchemaReferenceType<SchemaObject>>\n required?: string[]\n}\n\nconst isSchemaObject = (value: unknown): value is SchemaObject => typeof value === 'object' && value !== null\n\nconst schemaTypeToString = (schema: SchemaObject): string => {\n if (!('type' in schema)) {\n return ''\n }\n\n if (typeof schema.type === 'string') {\n return schema.type\n }\n\n return Array.isArray(schema.type) ? schema.type.join('|') : ''\n}\n\n/**\n * Resolves a schema reference from workspace-store to a SchemaObject.\n * Returns undefined when a reference exists but has not been resolved yet.\n */\nfunction resolveSchemaRef(ref: SchemaReferenceType<SchemaObject>): SchemaObject | undefined {\n if (typeof ref === 'object' && ref !== null && '$ref' in ref) {\n return isSchemaObject(ref['$ref-value']) ? ref['$ref-value'] : undefined\n }\n\n return ref\n}\n\n/**\n * Formats a property object into a string.\n */\nfunction formatProperty(key: string, obj: ObjectSchemaWithProperties): string {\n let output = key\n const isRequired = obj.required?.includes(key)\n output += isRequired ? ' REQUIRED ' : ' optional '\n const propRef = obj.properties[key]\n if (!propRef) {\n return output\n }\n const property = resolveSchemaRef(propRef)\n\n if (property) {\n output += schemaTypeToString(property)\n\n if ('description' in property && typeof property.description === 'string') {\n output += ` ${property.description}`\n }\n }\n\n return output\n}\n\n/**\n * Recursively logs the properties of an object.\n */\nfunction recursiveLogger(obj: MediaTypeObject): string[] {\n const results: string[] = ['Body']\n const schema = getResolvedRef(obj?.schema)\n\n if (!schema || !isObjectSchema(schema) || !schema.properties) {\n return results\n }\n\n const properties = schema.properties\n const schemaWithProps: ObjectSchemaWithProperties = {\n properties,\n required: schema.required,\n }\n Object.keys(properties).forEach((key) => {\n if (!obj.schema) {\n return\n }\n\n results.push(formatProperty(key, schemaWithProps))\n\n const propRef = properties[key]\n if (!propRef) {\n return\n }\n const property = resolveSchemaRef(propRef)\n if (property && isObjectSchema(property) && property.properties) {\n const nestedProperties = property.properties\n Object.keys(nestedProperties).forEach((subKey) => {\n const ref = nestedProperties[subKey]\n if (!ref) {\n return\n }\n const nested = resolveSchemaRef(ref)\n const typeStr = nested ? schemaTypeToString(nested) : ''\n results.push(`${subKey} ${typeStr}`)\n })\n }\n })\n\n return results\n}\n\n/**\n * Extracts the request body from an operation.\n */\nexport function extractRequestBody(operation: OperationObject): string[] | null {\n const content = getResolvedRef(operation?.requestBody)?.content\n const contentValue = Object.values(content ?? {})\n if (contentValue.length === 0) {\n // No content found\n return null\n }\n\n return contentValue.flatMap((media) => recursiveLogger(media))\n}\n\n/**\n * Formats a parameter into a searchable string.\n */\nfunction formatParameter(param: ParameterObject): string {\n const output = [param.name]\n output.push(param.required ? 'REQUIRED' : 'optional')\n output.push(param.in)\n\n if ('schema' in param && param.schema) {\n const schema = getResolvedRef(param.schema)\n if (schema) {\n output.push(schemaTypeToString(schema))\n }\n }\n\n if (param.description) {\n output.push(param.description)\n }\n\n return output.join(' ')\n}\n\n/**\n * Extracts parameters from an operation into searchable strings.\n */\nexport function extractParameters(parameters: ReferenceType<ParameterObject>[]): string[] | null {\n return parameters.map((parameter) => formatParameter(getResolvedRef(parameter)))\n}\n\n/**\n * Deep merge for objects\n */\nexport function deepMerge(source: Record<any, any>, target: Record<any, any>) {\n for (const [key, val] of Object.entries(source)) {\n if (val !== null && typeof val === 'object') {\n target[key] ??= new val.__proto__.constructor()\n deepMerge(val, target[key])\n } else if (typeof val !== 'undefined') {\n target[key] = val\n }\n }\n\n return target\n}\n\n/**\n * Creates an empty specification object.\n * The returning object has the same structure as a valid OpenAPI specification, but everything is empty.\n */\nexport function createEmptySpecification(partialSpecification?: Partial<OpenApiDocument>) {\n const emptySpecification = {\n openapi: '3.1.0',\n info: {\n title: '',\n description: '',\n termsOfService: '',\n version: '',\n license: {\n name: '',\n url: '',\n },\n contact: {\n email: '',\n },\n },\n servers: [],\n tags: [],\n 'x-scalar-original-document-hash': '',\n }\n\n if (!partialSpecification) {\n return emptySpecification as OpenApiDocument\n }\n\n deepMerge(partialSpecification, emptySpecification)\n\n return emptySpecification as OpenApiDocument\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-api.d.ts","sourceRoot":"","sources":["../../../src/standalone/lib/html-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mCAAmC,EACnC,kBAAkB,EACnB,MAAM,6BAA6B,CAAA;AASpC;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,QAAQ,GAAG,mCAAmC,CA+GrG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,mCAAmC,QAiBnG;AAID,eAAO,MAAM,eAAe,GAAI,KAAK,QAAQ,EAAE,UAAU,OAAO,GAAG,IAAI,mBAatE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"html-api.d.ts","sourceRoot":"","sources":["../../../src/standalone/lib/html-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mCAAmC,EACnC,kBAAkB,EACnB,MAAM,6BAA6B,CAAA;AASpC;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,QAAQ,GAAG,mCAAmC,CA+GrG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,mCAAmC,QAiBnG;AAID,eAAO,MAAM,eAAe,GAAI,KAAK,QAAQ,EAAE,UAAU,OAAO,GAAG,IAAI,mBAatE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBA4HhC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ApiReference_default from "../../components/ApiReference.vue.js";
|
|
2
|
-
import { createApp, h, reactive } from "vue";
|
|
2
|
+
import { createApp, createSSRApp, h, reactive } from "vue";
|
|
3
3
|
import "@scalar/types/api-reference";
|
|
4
4
|
import { createHead } from "@unhead/vue/client";
|
|
5
5
|
//#region src/standalone/lib/html-api.ts
|
|
@@ -13,14 +13,16 @@ import { createHead } from "@unhead/vue/client";
|
|
|
13
13
|
var createApiReference = (elementOrSelectorOrConfig, optionalConfiguration) => {
|
|
14
14
|
const idPrefix = "scalar-refs";
|
|
15
15
|
const props = reactive({ configuration: optionalConfiguration ?? elementOrSelectorOrConfig ?? {} });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const createReferenceApp = (isSsr = false) => {
|
|
17
|
+
const referenceApp = isSsr ? createSSRApp(() => h(ApiReference_default, props)) : createApp(() => h(ApiReference_default, props));
|
|
18
|
+
referenceApp.use(createHead());
|
|
19
|
+
referenceApp.config.idPrefix = idPrefix;
|
|
20
|
+
return referenceApp;
|
|
21
|
+
};
|
|
22
|
+
const mountElement = optionalConfiguration ? typeof elementOrSelectorOrConfig === "string" ? document.querySelector(elementOrSelectorOrConfig) : elementOrSelectorOrConfig : null;
|
|
23
|
+
let app = createReferenceApp(!!optionalConfiguration && !!mountElement && mountElement.children.length > 0);
|
|
24
|
+
if (optionalConfiguration) if (mountElement) app.mount(mountElement);
|
|
25
|
+
else console.error("Could not find a mount point for API References:", elementOrSelectorOrConfig);
|
|
24
26
|
/**
|
|
25
27
|
* Reload the API Reference
|
|
26
28
|
* @deprecated
|
|
@@ -32,9 +34,7 @@ var createApiReference = (elementOrSelectorOrConfig, optionalConfiguration) => {
|
|
|
32
34
|
if (!currentElement) return;
|
|
33
35
|
if (currentElement && !document.body.contains(currentElement)) document.body.appendChild(currentElement);
|
|
34
36
|
app.unmount();
|
|
35
|
-
app =
|
|
36
|
-
app.use(createHead());
|
|
37
|
-
app.config.idPrefix = idPrefix;
|
|
37
|
+
app = createReferenceApp();
|
|
38
38
|
app.mount(currentElement);
|
|
39
39
|
}, false);
|
|
40
40
|
/** Destroy the current API Reference instance */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-api.js","names":[],"sources":["../../../src/standalone/lib/html-api.ts"],"sourcesContent":["import type {\n AnyApiReferenceConfiguration,\n ApiReferenceConfigurationWithSource,\n CreateApiReference,\n} from '@scalar/types/api-reference'\nimport { apiReferenceConfigurationWithSourceSchema } from '@scalar/types/api-reference'\nimport { createHead } from '@unhead/vue/client'\nimport { createApp, h, reactive } from 'vue'\n\nimport { default as ApiReference } from '@/components/ApiReference.vue'\n\nconst getSpecScriptTag = (doc: Document) => doc.getElementById('api-reference')\n\n/**\n * Reading the configuration from the data-attributes.\n */\nexport function getConfigurationFromDataAttributes(doc: Document): ApiReferenceConfigurationWithSource {\n const specElement = doc.querySelector('[data-spec]')\n const specUrlElement = doc.querySelector('[data-spec-url]')\n const configurationScriptElement = doc.querySelector('#api-reference[data-configuration]')\n\n const getConfiguration = () => {\n // <script data-configuration=\"{ … }\" />\n if (configurationScriptElement) {\n const configurationFromElement = configurationScriptElement.getAttribute('data-configuration')\n\n if (configurationFromElement) {\n return {\n _integration: 'html',\n ...JSON.parse(configurationFromElement.split('"').join('\"')),\n }\n }\n }\n\n return apiReferenceConfigurationWithSourceSchema.parse({ _integration: 'html' })\n }\n\n const getUrl = () => {\n // Let's first check if the user passed a spec URL in the configuration.\n if (getConfiguration().url) {\n return getConfiguration().url\n }\n\n if (getConfiguration().spec?.url) {\n return getConfiguration().spec?.url\n }\n\n // <script id=\"api-reference\" data-url=\"/scalar.json\" />\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const urlFromScriptTag = specScriptTag.getAttribute('data-url')?.trim()\n\n if (urlFromScriptTag) {\n return urlFromScriptTag\n }\n }\n\n // <div data-spec-url=\"/scalar.json\" />\n if (specUrlElement) {\n console.warn(\n '[@scalar/api-reference] The [data-spec-url] HTML API is deprecated. Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead.',\n )\n const urlFromSpecUrlElement = specUrlElement.getAttribute('data-spec-url')\n\n if (urlFromSpecUrlElement) {\n return urlFromSpecUrlElement\n }\n }\n\n return undefined\n }\n\n const getContent = (): string | undefined => {\n // <script id=\"api-reference\" type=\"application/json\">{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}</script>\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const specFromScriptTag = specScriptTag.innerHTML?.trim()\n\n if (specFromScriptTag) {\n return specFromScriptTag\n }\n }\n\n // <div data-spec='{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}' />\n if (specElement) {\n console.warn(\n '[@scalar/api-reference] The [data-spec] HTML API is deprecated. Use the new <script id=\"api-reference\" type=\"application/json\">{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}</script> API instead.',\n )\n const specFromSpecElement = specElement.getAttribute('data-spec')?.trim()\n\n if (specFromSpecElement) {\n return specFromSpecElement\n }\n }\n\n return undefined\n }\n\n const getProxyUrl = () => {\n // <script id=\"api-reference\" data-proxy-url=\"https://proxy.scalar.com\">…</script>\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const proxyUrl = specScriptTag.getAttribute('data-proxy-url')\n\n if (proxyUrl) {\n return proxyUrl.trim()\n }\n }\n\n return undefined\n }\n\n // Ensure Reference Props are reactive\n if (!specUrlElement && !specElement && !getSpecScriptTag(doc)) {\n // Stay quiet.\n } else {\n const urlOrContent = getContent() ? { content: getContent() } : { url: getUrl() }\n\n return apiReferenceConfigurationWithSourceSchema.parse({\n _integration: 'html',\n proxyUrl: getProxyUrl(),\n ...getConfiguration(),\n ...urlOrContent,\n })\n }\n\n return apiReferenceConfigurationWithSourceSchema.parse({ _integration: 'html' })\n}\n\n/**\n * Mount the Scalar API Reference on a given document.\n * Read the HTML data-attributes for configuration.\n */\nexport function findDataAttributes(doc: Document, configuration: ApiReferenceConfigurationWithSource) {\n /** @deprecated Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead. */\n const specElement = doc.querySelector('[data-spec]')\n /** @deprecated Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead. */\n const specUrlElement = doc.querySelector('[data-spec-url]')\n\n if (configuration?.darkMode) {\n doc.body?.classList.add('dark-mode')\n } else {\n doc.body?.classList.add('light-mode')\n }\n\n const container = createContainer(doc, specElement || specUrlElement)\n\n if (container) {\n createApiReference(container, configuration)\n }\n}\n\n// If it's a script tag, we can't mount the Vue.js app inside that tag.\n// We need to add a new container element before the script tag.\nexport const createContainer = (doc: Document, element?: Element | null) => {\n let _container: Element | null = null\n\n const specScriptTag = getSpecScriptTag(doc)\n\n if (specScriptTag) {\n _container = doc.createElement('div')\n specScriptTag?.parentNode?.insertBefore(_container, specScriptTag)\n } else if (element) {\n _container = element\n }\n\n return _container\n}\n\n/**\n * Create (and mount) a new Scalar API Reference\n *\n * @example createApiReference({ url: '/scalar.json' }).mount('#app')\n * @example createApiReference('#app', { url: '/scalar.json' })\n * @example createApiReference(document.getElementById('app'), { url: '/scalar.json' })\n */\nexport const createApiReference: CreateApiReference = (\n elementOrSelectorOrConfig,\n optionalConfiguration?: AnyApiReferenceConfiguration,\n) => {\n // Create an id prefix for useId so we don't have collisions with other Vue apps\n const idPrefix = 'scalar-refs'\n\n const props = reactive<{ configuration: AnyApiReferenceConfiguration }>({\n // Either the configuration will be the second argument or it MUST be the first (configuration only)\n configuration: optionalConfiguration ?? (elementOrSelectorOrConfig as AnyApiReferenceConfiguration) ?? {},\n })\n\n // Create a new Vue app instance\n let app = createApp(() => h(ApiReference, props))\n\n // Meta tags, etc.\n app.use(createHead())\n\n app.config.idPrefix = idPrefix\n\n // If we have an optional config, then we must mount the element immediately (not sure why type is not narrowing)\n if (optionalConfiguration) {\n // If the element is a string, we need to find the actual DOM element\n const element =\n typeof elementOrSelectorOrConfig === 'string'\n ? document.querySelector(elementOrSelectorOrConfig)\n : (elementOrSelectorOrConfig as Element)\n\n if (element) {\n app.mount(element)\n } else {\n console.error('Could not find a mount point for API References:', elementOrSelectorOrConfig)\n }\n }\n\n /**\n * Reload the API Reference\n * @deprecated\n */\n document.addEventListener(\n 'scalar:reload-references',\n () => {\n console.warn(\n 'scalar:reload-references event has been deprecated, please use the scalarInstance.app.mount method instead.',\n )\n if (!props.configuration) {\n return\n }\n\n // Snag the current element\n const currentElement =\n typeof elementOrSelectorOrConfig === 'string'\n ? document.querySelector(elementOrSelectorOrConfig)\n : (elementOrSelectorOrConfig as Element)\n\n if (!currentElement) {\n return\n }\n\n // Ensure we re-attach the element if it was unmounted\n if (currentElement && !document.body.contains(currentElement)) {\n document.body.appendChild(currentElement)\n }\n\n // Create a new Vue app instance\n app.unmount()\n app = createApp(() => h(ApiReference, props))\n app.use(createHead())\n app.config.idPrefix = idPrefix\n app.mount(currentElement)\n },\n false,\n )\n\n /** Destroy the current API Reference instance */\n const destroy = () => {\n props.configuration = {}\n app.unmount()\n }\n\n /**\n * Allow user to destroy the API Reference\n * @deprecated\n */\n document.addEventListener(\n 'scalar:destroy-references',\n () => {\n console.warn('scalar:destroy-references event has been deprecated, please use scalarInstance.destroy instead.')\n destroy()\n },\n false,\n )\n\n /**\n * Allow user to update configuration\n * @deprecated\n */\n document.addEventListener(\n 'scalar:update-references-config',\n (ev) => {\n console.warn(\n 'scalar:update-references-config event has been deprecated, please use scalarInstance.updateConfiguration instead.',\n )\n if ('detail' in ev) {\n Object.assign(props, ev.detail)\n }\n },\n false,\n )\n\n const instance = {\n app,\n getConfiguration: () => props.configuration ?? {},\n updateConfiguration: (newConfig: AnyApiReferenceConfiguration) => {\n props.configuration = newConfig\n },\n destroy,\n }\n\n return instance\n}\n"],"mappings":";;;;;;;;;;;;AAgLA,IAAa,sBACX,2BACA,0BACG;CAEH,MAAM,WAAW;CAEjB,MAAM,QAAQ,SAA0D,EAEtE,eAAe,yBAA0B,6BAA8D,EAAE,EAC1G,CAAC;CAGF,IAAI,MAAM,gBAAgB,EAAE,sBAAc,MAAM,CAAC;AAGjD,KAAI,IAAI,YAAY,CAAC;AAErB,KAAI,OAAO,WAAW;AAGtB,KAAI,uBAAuB;EAEzB,MAAM,UACJ,OAAO,8BAA8B,WACjC,SAAS,cAAc,0BAA0B,GAChD;AAEP,MAAI,QACF,KAAI,MAAM,QAAQ;MAElB,SAAQ,MAAM,oDAAoD,0BAA0B;;;;;;AAQhG,UAAS,iBACP,kCACM;AACJ,UAAQ,KACN,8GACD;AACD,MAAI,CAAC,MAAM,cACT;EAIF,MAAM,iBACJ,OAAO,8BAA8B,WACjC,SAAS,cAAc,0BAA0B,GAChD;AAEP,MAAI,CAAC,eACH;AAIF,MAAI,kBAAkB,CAAC,SAAS,KAAK,SAAS,eAAe,CAC3D,UAAS,KAAK,YAAY,eAAe;AAI3C,MAAI,SAAS;AACb,QAAM,gBAAgB,EAAE,sBAAc,MAAM,CAAC;AAC7C,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI,OAAO,WAAW;AACtB,MAAI,MAAM,eAAe;IAE3B,MACD;;CAGD,MAAM,gBAAgB;AACpB,QAAM,gBAAgB,EAAE;AACxB,MAAI,SAAS;;;;;;AAOf,UAAS,iBACP,mCACM;AACJ,UAAQ,KAAK,kGAAkG;AAC/G,WAAS;IAEX,MACD;;;;;AAMD,UAAS,iBACP,oCACC,OAAO;AACN,UAAQ,KACN,oHACD;AACD,MAAI,YAAY,GACd,QAAO,OAAO,OAAO,GAAG,OAAO;IAGnC,MACD;AAWD,QATiB;EACf;EACA,wBAAwB,MAAM,iBAAiB,EAAE;EACjD,sBAAsB,cAA4C;AAChE,SAAM,gBAAgB;;EAExB;EACD"}
|
|
1
|
+
{"version":3,"file":"html-api.js","names":[],"sources":["../../../src/standalone/lib/html-api.ts"],"sourcesContent":["import type {\n AnyApiReferenceConfiguration,\n ApiReferenceConfigurationWithSource,\n CreateApiReference,\n} from '@scalar/types/api-reference'\nimport { apiReferenceConfigurationWithSourceSchema } from '@scalar/types/api-reference'\nimport { createHead } from '@unhead/vue/client'\nimport { createApp, createSSRApp, h, reactive } from 'vue'\n\nimport { default as ApiReference } from '@/components/ApiReference.vue'\n\nconst getSpecScriptTag = (doc: Document) => doc.getElementById('api-reference')\n\n/**\n * Reading the configuration from the data-attributes.\n */\nexport function getConfigurationFromDataAttributes(doc: Document): ApiReferenceConfigurationWithSource {\n const specElement = doc.querySelector('[data-spec]')\n const specUrlElement = doc.querySelector('[data-spec-url]')\n const configurationScriptElement = doc.querySelector('#api-reference[data-configuration]')\n\n const getConfiguration = () => {\n // <script data-configuration=\"{ … }\" />\n if (configurationScriptElement) {\n const configurationFromElement = configurationScriptElement.getAttribute('data-configuration')\n\n if (configurationFromElement) {\n return {\n _integration: 'html',\n ...JSON.parse(configurationFromElement.split('"').join('\"')),\n }\n }\n }\n\n return apiReferenceConfigurationWithSourceSchema.parse({ _integration: 'html' })\n }\n\n const getUrl = () => {\n // Let's first check if the user passed a spec URL in the configuration.\n if (getConfiguration().url) {\n return getConfiguration().url\n }\n\n if (getConfiguration().spec?.url) {\n return getConfiguration().spec?.url\n }\n\n // <script id=\"api-reference\" data-url=\"/scalar.json\" />\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const urlFromScriptTag = specScriptTag.getAttribute('data-url')?.trim()\n\n if (urlFromScriptTag) {\n return urlFromScriptTag\n }\n }\n\n // <div data-spec-url=\"/scalar.json\" />\n if (specUrlElement) {\n console.warn(\n '[@scalar/api-reference] The [data-spec-url] HTML API is deprecated. Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead.',\n )\n const urlFromSpecUrlElement = specUrlElement.getAttribute('data-spec-url')\n\n if (urlFromSpecUrlElement) {\n return urlFromSpecUrlElement\n }\n }\n\n return undefined\n }\n\n const getContent = (): string | undefined => {\n // <script id=\"api-reference\" type=\"application/json\">{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}</script>\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const specFromScriptTag = specScriptTag.innerHTML?.trim()\n\n if (specFromScriptTag) {\n return specFromScriptTag\n }\n }\n\n // <div data-spec='{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}' />\n if (specElement) {\n console.warn(\n '[@scalar/api-reference] The [data-spec] HTML API is deprecated. Use the new <script id=\"api-reference\" type=\"application/json\">{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Example\"},\"paths\":{}}</script> API instead.',\n )\n const specFromSpecElement = specElement.getAttribute('data-spec')?.trim()\n\n if (specFromSpecElement) {\n return specFromSpecElement\n }\n }\n\n return undefined\n }\n\n const getProxyUrl = () => {\n // <script id=\"api-reference\" data-proxy-url=\"https://proxy.scalar.com\">…</script>\n const specScriptTag = getSpecScriptTag(doc)\n if (specScriptTag) {\n const proxyUrl = specScriptTag.getAttribute('data-proxy-url')\n\n if (proxyUrl) {\n return proxyUrl.trim()\n }\n }\n\n return undefined\n }\n\n // Ensure Reference Props are reactive\n if (!specUrlElement && !specElement && !getSpecScriptTag(doc)) {\n // Stay quiet.\n } else {\n const urlOrContent = getContent() ? { content: getContent() } : { url: getUrl() }\n\n return apiReferenceConfigurationWithSourceSchema.parse({\n _integration: 'html',\n proxyUrl: getProxyUrl(),\n ...getConfiguration(),\n ...urlOrContent,\n })\n }\n\n return apiReferenceConfigurationWithSourceSchema.parse({ _integration: 'html' })\n}\n\n/**\n * Mount the Scalar API Reference on a given document.\n * Read the HTML data-attributes for configuration.\n */\nexport function findDataAttributes(doc: Document, configuration: ApiReferenceConfigurationWithSource) {\n /** @deprecated Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead. */\n const specElement = doc.querySelector('[data-spec]')\n /** @deprecated Use the new <script id=\"api-reference\" data-url=\"/scalar.json\" /> API instead. */\n const specUrlElement = doc.querySelector('[data-spec-url]')\n\n if (configuration?.darkMode) {\n doc.body?.classList.add('dark-mode')\n } else {\n doc.body?.classList.add('light-mode')\n }\n\n const container = createContainer(doc, specElement || specUrlElement)\n\n if (container) {\n createApiReference(container, configuration)\n }\n}\n\n// If it's a script tag, we can't mount the Vue.js app inside that tag.\n// We need to add a new container element before the script tag.\nexport const createContainer = (doc: Document, element?: Element | null) => {\n let _container: Element | null = null\n\n const specScriptTag = getSpecScriptTag(doc)\n\n if (specScriptTag) {\n _container = doc.createElement('div')\n specScriptTag?.parentNode?.insertBefore(_container, specScriptTag)\n } else if (element) {\n _container = element\n }\n\n return _container\n}\n\n/**\n * Create (and mount) a new Scalar API Reference\n *\n * @example createApiReference({ url: '/scalar.json' }).mount('#app')\n * @example createApiReference('#app', { url: '/scalar.json' })\n * @example createApiReference(document.getElementById('app'), { url: '/scalar.json' })\n */\nexport const createApiReference: CreateApiReference = (\n elementOrSelectorOrConfig,\n optionalConfiguration?: AnyApiReferenceConfiguration,\n) => {\n // Create an id prefix for useId so we don't have collisions with other Vue apps\n const idPrefix = 'scalar-refs'\n\n const props = reactive<{ configuration: AnyApiReferenceConfiguration }>({\n // Either the configuration will be the second argument or it MUST be the first (configuration only)\n configuration: optionalConfiguration ?? (elementOrSelectorOrConfig as AnyApiReferenceConfiguration) ?? {},\n })\n\n const createReferenceApp = (isSsr = false) => {\n const referenceApp = isSsr ? createSSRApp(() => h(ApiReference, props)) : createApp(() => h(ApiReference, props))\n\n // Meta tags, etc.\n referenceApp.use(createHead())\n referenceApp.config.idPrefix = idPrefix\n\n return referenceApp\n }\n\n // If we have an optional config, then we must mount the element immediately (not sure why type is not narrowing)\n const mountElement = optionalConfiguration\n ? typeof elementOrSelectorOrConfig === 'string'\n ? document.querySelector(elementOrSelectorOrConfig)\n : (elementOrSelectorOrConfig as Element)\n : null\n\n // Detect server-rendered content and use createSSRApp for hydration\n const shouldHydrate = !!optionalConfiguration && !!mountElement && mountElement.children.length > 0\n let app = createReferenceApp(shouldHydrate)\n\n if (optionalConfiguration) {\n if (mountElement) {\n app.mount(mountElement)\n } else {\n console.error('Could not find a mount point for API References:', elementOrSelectorOrConfig)\n }\n }\n\n /**\n * Reload the API Reference\n * @deprecated\n */\n document.addEventListener(\n 'scalar:reload-references',\n () => {\n console.warn(\n 'scalar:reload-references event has been deprecated, please use the scalarInstance.app.mount method instead.',\n )\n if (!props.configuration) {\n return\n }\n\n // Snag the current element\n const currentElement =\n typeof elementOrSelectorOrConfig === 'string'\n ? document.querySelector(elementOrSelectorOrConfig)\n : (elementOrSelectorOrConfig as Element)\n\n if (!currentElement) {\n return\n }\n\n // Ensure we re-attach the element if it was unmounted\n if (currentElement && !document.body.contains(currentElement)) {\n document.body.appendChild(currentElement)\n }\n\n // Create a new Vue app instance\n app.unmount()\n app = createReferenceApp()\n app.mount(currentElement)\n },\n false,\n )\n\n /** Destroy the current API Reference instance */\n const destroy = () => {\n props.configuration = {}\n app.unmount()\n }\n\n /**\n * Allow user to destroy the API Reference\n * @deprecated\n */\n document.addEventListener(\n 'scalar:destroy-references',\n () => {\n console.warn('scalar:destroy-references event has been deprecated, please use scalarInstance.destroy instead.')\n destroy()\n },\n false,\n )\n\n /**\n * Allow user to update configuration\n * @deprecated\n */\n document.addEventListener(\n 'scalar:update-references-config',\n (ev) => {\n console.warn(\n 'scalar:update-references-config event has been deprecated, please use scalarInstance.updateConfiguration instead.',\n )\n if ('detail' in ev) {\n Object.assign(props, ev.detail)\n }\n },\n false,\n )\n\n const instance = {\n app,\n getConfiguration: () => props.configuration ?? {},\n updateConfiguration: (newConfig: AnyApiReferenceConfiguration) => {\n props.configuration = newConfig\n },\n destroy,\n }\n\n return instance\n}\n"],"mappings":";;;;;;;;;;;;AAgLA,IAAa,sBACX,2BACA,0BACG;CAEH,MAAM,WAAW;CAEjB,MAAM,QAAQ,SAA0D,EAEtE,eAAe,yBAA0B,6BAA8D,EAAE,EAC1G,CAAC;CAEF,MAAM,sBAAsB,QAAQ,UAAU;EAC5C,MAAM,eAAe,QAAQ,mBAAmB,EAAE,sBAAc,MAAM,CAAC,GAAG,gBAAgB,EAAE,sBAAc,MAAM,CAAC;AAGjH,eAAa,IAAI,YAAY,CAAC;AAC9B,eAAa,OAAO,WAAW;AAE/B,SAAO;;CAIT,MAAM,eAAe,wBACjB,OAAO,8BAA8B,WACnC,SAAS,cAAc,0BAA0B,GAChD,4BACH;CAIJ,IAAI,MAAM,mBADY,CAAC,CAAC,yBAAyB,CAAC,CAAC,gBAAgB,aAAa,SAAS,SAAS,EACvD;AAE3C,KAAI,sBACF,KAAI,aACF,KAAI,MAAM,aAAa;KAEvB,SAAQ,MAAM,oDAAoD,0BAA0B;;;;;AAQhG,UAAS,iBACP,kCACM;AACJ,UAAQ,KACN,8GACD;AACD,MAAI,CAAC,MAAM,cACT;EAIF,MAAM,iBACJ,OAAO,8BAA8B,WACjC,SAAS,cAAc,0BAA0B,GAChD;AAEP,MAAI,CAAC,eACH;AAIF,MAAI,kBAAkB,CAAC,SAAS,KAAK,SAAS,eAAe,CAC3D,UAAS,KAAK,YAAY,eAAe;AAI3C,MAAI,SAAS;AACb,QAAM,oBAAoB;AAC1B,MAAI,MAAM,eAAe;IAE3B,MACD;;CAGD,MAAM,gBAAgB;AACpB,QAAM,gBAAgB,EAAE;AACxB,MAAI,SAAS;;;;;;AAOf,UAAS,iBACP,mCACM;AACJ,UAAQ,KAAK,kGAAkG;AAC/G,WAAS;IAEX,MACD;;;;;AAMD,UAAS,iBACP,oCACC,OAAO;AACN,UAAQ,KACN,oHACD;AACD,MAAI,YAAY,GACd,QAAO,OAAO,OAAO,GAAG,OAAO;IAGnC,MACD;AAWD,QATiB;EACf;EACA,wBAAwB,MAAM,iBAAiB,EAAE;EACjD,sBAAsB,cAA4C;AAChE,SAAM,gBAAgB;;EAExB;EACD"}
|
package/dist/style.css
CHANGED
|
@@ -1680,10 +1680,10 @@ button.headers-card-title[data-v-ab19704d]:hover {
|
|
|
1680
1680
|
border-radius: var(--scalar-radius);
|
|
1681
1681
|
}
|
|
1682
1682
|
|
|
1683
|
-
.request-body[data-v-
|
|
1683
|
+
.request-body[data-v-f323f401] {
|
|
1684
1684
|
margin-top: 24px;
|
|
1685
1685
|
}
|
|
1686
|
-
.request-body-header[data-v-
|
|
1686
|
+
.request-body-header[data-v-f323f401] {
|
|
1687
1687
|
display: flex;
|
|
1688
1688
|
align-items: center;
|
|
1689
1689
|
justify-content: space-between;
|
|
@@ -1691,7 +1691,7 @@ button.headers-card-title[data-v-ab19704d]:hover {
|
|
|
1691
1691
|
border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);
|
|
1692
1692
|
flex-flow: wrap;
|
|
1693
1693
|
}
|
|
1694
|
-
.request-body-title[data-v-
|
|
1694
|
+
.request-body-title[data-v-f323f401] {
|
|
1695
1695
|
display: flex;
|
|
1696
1696
|
align-items: center;
|
|
1697
1697
|
gap: 8px;
|
|
@@ -1699,7 +1699,7 @@ button.headers-card-title[data-v-ab19704d]:hover {
|
|
|
1699
1699
|
font-weight: var(--scalar-semibold);
|
|
1700
1700
|
color: var(--scalar-color-1);
|
|
1701
1701
|
}
|
|
1702
|
-
.request-body-required[data-v-
|
|
1702
|
+
.request-body-required[data-v-f323f401] {
|
|
1703
1703
|
font-size: var(--scalar-micro);
|
|
1704
1704
|
color: var(--scalar-color-orange);
|
|
1705
1705
|
font-weight: normal;
|
|
@@ -1708,21 +1708,21 @@ button.headers-card-title[data-v-ab19704d]:hover {
|
|
|
1708
1708
|
padding: 2px 8px;
|
|
1709
1709
|
height: 20px;
|
|
1710
1710
|
}
|
|
1711
|
-
.request-body-description[data-v-
|
|
1711
|
+
.request-body-description[data-v-f323f401] {
|
|
1712
1712
|
margin-top: 6px;
|
|
1713
1713
|
font-size: var(--scalar-small);
|
|
1714
1714
|
width: 100%;
|
|
1715
1715
|
}
|
|
1716
1716
|
.request-body-header
|
|
1717
|
-
+ .request-body-schema[data-v-
|
|
1717
|
+
+ .request-body-schema[data-v-f323f401]:has(> .schema-card > .schema-card-description),
|
|
1718
1718
|
.request-body-header
|
|
1719
|
-
+ .request-body-schema[data-v-
|
|
1719
|
+
+ .request-body-schema[data-v-f323f401]:has(
|
|
1720
1720
|
> .schema-card > .schema-properties > * > .property--level-0
|
|
1721
1721
|
) {
|
|
1722
1722
|
/** Add a bit of space between the heading border and the schema description or properties */
|
|
1723
1723
|
padding-top: 8px;
|
|
1724
1724
|
}
|
|
1725
|
-
.request-body-description[data-v-
|
|
1725
|
+
.request-body-description[data-v-f323f401] .markdown * {
|
|
1726
1726
|
color: var(--scalar-color-2) !important;
|
|
1727
1727
|
}
|
|
1728
1728
|
|
|
@@ -3392,6 +3392,9 @@ body {
|
|
|
3392
3392
|
.scalar-app .-mx-2 {
|
|
3393
3393
|
margin-inline: -8px;
|
|
3394
3394
|
}
|
|
3395
|
+
.scalar-app .mx-1\.5 {
|
|
3396
|
+
margin-inline: 6px;
|
|
3397
|
+
}
|
|
3395
3398
|
.scalar-app .my-2 {
|
|
3396
3399
|
margin-block: 8px;
|
|
3397
3400
|
}
|
|
@@ -7869,12 +7872,18 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
7869
7872
|
.scalar-app .min-h-20 {
|
|
7870
7873
|
min-height: 80px;
|
|
7871
7874
|
}
|
|
7875
|
+
.scalar-app .min-h-\[4rem\] {
|
|
7876
|
+
min-height: 4rem;
|
|
7877
|
+
}
|
|
7872
7878
|
.scalar-app .min-h-\[64px\] {
|
|
7873
7879
|
min-height: 64px;
|
|
7874
7880
|
}
|
|
7875
7881
|
.scalar-app .min-h-\[65px\] {
|
|
7876
7882
|
min-height: 65px;
|
|
7877
7883
|
}
|
|
7884
|
+
.scalar-app .min-h-\[300px\] {
|
|
7885
|
+
min-height: 300px;
|
|
7886
|
+
}
|
|
7878
7887
|
.scalar-app .min-h-\[calc\(1rem\*4\)\] {
|
|
7879
7888
|
min-height: 4rem;
|
|
7880
7889
|
}
|
|
@@ -7899,6 +7908,9 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
7899
7908
|
.scalar-app .w-1\/2 {
|
|
7900
7909
|
width: 50%;
|
|
7901
7910
|
}
|
|
7911
|
+
.scalar-app .w-2 {
|
|
7912
|
+
width: 8px;
|
|
7913
|
+
}
|
|
7902
7914
|
.scalar-app .w-2\.5 {
|
|
7903
7915
|
width: 10px;
|
|
7904
7916
|
}
|
|
@@ -8484,7 +8496,7 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
8484
8496
|
.scalar-app .border-\(--scalar-color-alert\) {
|
|
8485
8497
|
border-color: var(--scalar-color-alert);
|
|
8486
8498
|
}
|
|
8487
|
-
.scalar-app .border-border {
|
|
8499
|
+
.scalar-app .border-\[var\(--scalar-border-color\)\], .scalar-app .border-border {
|
|
8488
8500
|
border-color: var(--scalar-border-color);
|
|
8489
8501
|
}
|
|
8490
8502
|
.scalar-app .border-c-1 {
|
|
@@ -8521,6 +8533,18 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
8521
8533
|
.scalar-app .bg-\(--scalar-background-alert\) {
|
|
8522
8534
|
background-color: var(--scalar-background-alert);
|
|
8523
8535
|
}
|
|
8536
|
+
.scalar-app .bg-\[var\(--scalar-background-1\)\] {
|
|
8537
|
+
background-color: var(--scalar-background-1);
|
|
8538
|
+
}
|
|
8539
|
+
.scalar-app .bg-\[var\(--scalar-background-2\)\] {
|
|
8540
|
+
background-color: var(--scalar-background-2);
|
|
8541
|
+
}
|
|
8542
|
+
.scalar-app .bg-\[var\(--scalar-background-3\)\] {
|
|
8543
|
+
background-color: var(--scalar-background-3);
|
|
8544
|
+
}
|
|
8545
|
+
.scalar-app .bg-\[var\(--scalar-color-green\)\] {
|
|
8546
|
+
background-color: var(--scalar-color-green);
|
|
8547
|
+
}
|
|
8524
8548
|
.scalar-app .bg-b-1 {
|
|
8525
8549
|
background-color: var(--scalar-background-1);
|
|
8526
8550
|
}
|
|
@@ -9179,6 +9203,10 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
9179
9203
|
--tw-shadow: 0 -8px 0 8px var(--tw-shadow-color, var(--scalar-background-1)), 0 0 8px 8px var(--tw-shadow-color, var(--scalar-background-1));
|
|
9180
9204
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
9181
9205
|
}
|
|
9206
|
+
.scalar-app .shadow-\[var\(--scalar-shadow-1\)\] {
|
|
9207
|
+
--tw-shadow: var(--scalar-shadow-1);
|
|
9208
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
9209
|
+
}
|
|
9182
9210
|
.scalar-app .shadow-border {
|
|
9183
9211
|
--tw-shadow: inset 0 0 0 var(--tw-shadow-color, var(--scalar-border-width)) var(--scalar-border-color);
|
|
9184
9212
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
@@ -9239,6 +9267,11 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
9239
9267
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
9240
9268
|
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
9241
9269
|
}
|
|
9270
|
+
.scalar-app .transition-all {
|
|
9271
|
+
transition-property: all;
|
|
9272
|
+
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
9273
|
+
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
9274
|
+
}
|
|
9242
9275
|
.scalar-app .transition-colors {
|
|
9243
9276
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
|
9244
9277
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
@@ -9601,6 +9634,9 @@ input[data-v-c1a50a6e]::placeholder {
|
|
|
9601
9634
|
.scalar-app .hover\:border-inherit:hover {
|
|
9602
9635
|
border-color: inherit;
|
|
9603
9636
|
}
|
|
9637
|
+
.scalar-app .hover\:bg-\[var\(--scalar-background-3\)\]:hover {
|
|
9638
|
+
background-color: var(--scalar-background-3);
|
|
9639
|
+
}
|
|
9604
9640
|
.scalar-app .hover\:bg-b-2:hover, .scalar-app .hover\:bg-b-2\/40:hover {
|
|
9605
9641
|
background-color: var(--scalar-background-2);
|
|
9606
9642
|
}
|
|
@@ -11908,6 +11944,9 @@ to {
|
|
|
11908
11944
|
gap: 1rem;
|
|
11909
11945
|
display: flex;
|
|
11910
11946
|
}
|
|
11947
|
+
.document-scripts-editors__container[data-v-8c8fa790] {
|
|
11948
|
+
min-height: 300px;
|
|
11949
|
+
}
|
|
11911
11950
|
.authenticationProvided[data-v-e3416cd5] {
|
|
11912
11951
|
color: var(--scalar-color-1);
|
|
11913
11952
|
font-weight: var(--scalar-semibold);
|
|
@@ -13469,7 +13508,7 @@ div + .userMessage[data-v-8e43ed7a] {
|
|
|
13469
13508
|
|
|
13470
13509
|
/* Configurable Layout Variables */
|
|
13471
13510
|
@layer scalar-config {
|
|
13472
|
-
.scalar-api-reference[data-v-
|
|
13511
|
+
.scalar-api-reference[data-v-f2a1208a] {
|
|
13473
13512
|
/* The header height */
|
|
13474
13513
|
--refs-header-height: calc(
|
|
13475
13514
|
var(--scalar-custom-header-height, 0px) + var(--scalar-header-height, 0px)
|
|
@@ -13491,20 +13530,20 @@ div + .userMessage[data-v-8e43ed7a] {
|
|
|
13491
13530
|
/* The maximum width of the content column */
|
|
13492
13531
|
--refs-content-max-width: var(--scalar-content-max-width, 1540px);
|
|
13493
13532
|
}
|
|
13494
|
-
.scalar-api-reference.references-classic[data-v-
|
|
13533
|
+
.scalar-api-reference.references-classic[data-v-f2a1208a] {
|
|
13495
13534
|
/* Classic layout is wider */
|
|
13496
13535
|
--refs-content-max-width: var(--scalar-content-max-width, 1420px);
|
|
13497
13536
|
min-height: 100dvh;
|
|
13498
13537
|
--refs-sidebar-width: 0;
|
|
13499
13538
|
}
|
|
13500
13539
|
}
|
|
13501
|
-
.t-doc__sidebar[data-v-
|
|
13540
|
+
.t-doc__sidebar[data-v-f2a1208a] {
|
|
13502
13541
|
z-index: 10;
|
|
13503
13542
|
}
|
|
13504
13543
|
|
|
13505
13544
|
/* ----------------------------------------------------- */
|
|
13506
13545
|
/* References Layout */
|
|
13507
|
-
.references-layout[data-v-
|
|
13546
|
+
.references-layout[data-v-f2a1208a] {
|
|
13508
13547
|
/* Try to fill the container */
|
|
13509
13548
|
min-height: 100dvh;
|
|
13510
13549
|
min-width: 100%;
|
|
@@ -13528,44 +13567,44 @@ div + .userMessage[data-v-8e43ed7a] {
|
|
|
13528
13567
|
|
|
13529
13568
|
background: var(--scalar-background-1);
|
|
13530
13569
|
}
|
|
13531
|
-
.references-editor[data-v-
|
|
13570
|
+
.references-editor[data-v-f2a1208a] {
|
|
13532
13571
|
grid-area: editor;
|
|
13533
13572
|
display: flex;
|
|
13534
13573
|
min-width: 0;
|
|
13535
13574
|
background: var(--scalar-background-1);
|
|
13536
13575
|
}
|
|
13537
|
-
.references-rendered[data-v-
|
|
13576
|
+
.references-rendered[data-v-f2a1208a] {
|
|
13538
13577
|
position: relative;
|
|
13539
13578
|
grid-area: rendered;
|
|
13540
13579
|
min-width: 0;
|
|
13541
13580
|
background: var(--scalar-background-1);
|
|
13542
13581
|
}
|
|
13543
|
-
.scalar-api-reference.references-classic[data-v-
|
|
13544
|
-
.references-classic .references-rendered[data-v-
|
|
13582
|
+
.scalar-api-reference.references-classic[data-v-f2a1208a],
|
|
13583
|
+
.references-classic .references-rendered[data-v-f2a1208a] {
|
|
13545
13584
|
height: initial !important;
|
|
13546
13585
|
max-height: initial !important;
|
|
13547
13586
|
}
|
|
13548
13587
|
@layer scalar-config {
|
|
13549
|
-
.references-sidebar[data-v-
|
|
13588
|
+
.references-sidebar[data-v-f2a1208a] {
|
|
13550
13589
|
/* Set a default width if references are enabled */
|
|
13551
13590
|
--refs-sidebar-width: var(--scalar-sidebar-width, 288px);
|
|
13552
13591
|
}
|
|
13553
13592
|
}
|
|
13554
13593
|
|
|
13555
13594
|
/* Footer */
|
|
13556
|
-
.references-footer[data-v-
|
|
13595
|
+
.references-footer[data-v-f2a1208a] {
|
|
13557
13596
|
grid-area: footer;
|
|
13558
13597
|
}
|
|
13559
13598
|
/* ----------------------------------------------------- */
|
|
13560
13599
|
/* Responsive / Mobile Layout */
|
|
13561
13600
|
@media (max-width: 1000px) {
|
|
13562
13601
|
/* Keep toolbar hidden on mobile without forcing desktop display mode. */
|
|
13563
|
-
.references-developer-tools[data-v-
|
|
13602
|
+
.references-developer-tools[data-v-f2a1208a] {
|
|
13564
13603
|
display: none;
|
|
13565
13604
|
}
|
|
13566
13605
|
|
|
13567
13606
|
/* Stack view on mobile */
|
|
13568
|
-
.references-layout[data-v-
|
|
13607
|
+
.references-layout[data-v-f2a1208a] {
|
|
13569
13608
|
/* Adjust the sidebar height to the viewport height minus the header height */
|
|
13570
13609
|
--refs-sidebar-height: calc(
|
|
13571
13610
|
var(--full-height, 100dvh) - var(--scalar-custom-header-height, 0px)
|
|
@@ -13580,13 +13619,13 @@ div + .userMessage[data-v-8e43ed7a] {
|
|
|
13580
13619
|
'rendered'
|
|
13581
13620
|
'footer';
|
|
13582
13621
|
}
|
|
13583
|
-
.references-editable[data-v-
|
|
13622
|
+
.references-editable[data-v-f2a1208a] {
|
|
13584
13623
|
grid-template-areas:
|
|
13585
13624
|
'header'
|
|
13586
13625
|
'navigation'
|
|
13587
13626
|
'editor';
|
|
13588
13627
|
}
|
|
13589
|
-
.references-rendered[data-v-
|
|
13628
|
+
.references-rendered[data-v-f2a1208a] {
|
|
13590
13629
|
position: static;
|
|
13591
13630
|
}
|
|
13592
13631
|
}
|
|
@@ -13597,12 +13636,12 @@ div + .userMessage[data-v-8e43ed7a] {
|
|
|
13597
13636
|
* when the new elements are available
|
|
13598
13637
|
*/
|
|
13599
13638
|
@media (max-width: 1000px) {
|
|
13600
|
-
.scalar-api-references-standalone-mobile[data-v-
|
|
13639
|
+
.scalar-api-references-standalone-mobile[data-v-f2a1208a]:not(.references-classic) {
|
|
13601
13640
|
--scalar-header-height: 50px;
|
|
13602
13641
|
}
|
|
13603
13642
|
}
|
|
13604
13643
|
|
|
13605
|
-
.darklight-reference[data-v-
|
|
13644
|
+
.darklight-reference[data-v-f2a1208a] {
|
|
13606
13645
|
width: 100%;
|
|
13607
13646
|
margin-top: auto;
|
|
13608
13647
|
}
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"vue",
|
|
21
21
|
"vue3"
|
|
22
22
|
],
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.52.0",
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=22"
|
|
26
26
|
},
|
|
@@ -64,11 +64,6 @@
|
|
|
64
64
|
"types": "./dist/helpers/index.d.ts",
|
|
65
65
|
"default": "./dist/helpers/index.js"
|
|
66
66
|
},
|
|
67
|
-
"./ssr": {
|
|
68
|
-
"import": "./dist/ssr.js",
|
|
69
|
-
"types": "./dist/ssr.d.ts",
|
|
70
|
-
"default": "./dist/ssr.js"
|
|
71
|
-
},
|
|
72
67
|
"./style.css": "./dist/style.css",
|
|
73
68
|
"./browser/standalone.js": "./dist/browser/standalone.js"
|
|
74
69
|
},
|
|
@@ -91,20 +86,20 @@
|
|
|
91
86
|
"nanoid": "^5.1.6",
|
|
92
87
|
"vue": "^3.5.30",
|
|
93
88
|
"yaml": "^2.8.0",
|
|
94
|
-
"@scalar/agent-chat": "0.10.
|
|
95
|
-
"@scalar/
|
|
96
|
-
"@scalar/code-highlight": "0.3.2",
|
|
89
|
+
"@scalar/agent-chat": "0.10.2",
|
|
90
|
+
"@scalar/components": "0.21.3",
|
|
97
91
|
"@scalar/helpers": "0.4.3",
|
|
98
|
-
"@scalar/
|
|
92
|
+
"@scalar/code-highlight": "0.3.2",
|
|
99
93
|
"@scalar/icons": "0.7.2",
|
|
100
|
-
"@scalar/
|
|
101
|
-
"@scalar/
|
|
102
|
-
"@scalar/
|
|
94
|
+
"@scalar/oas-utils": "0.11.0",
|
|
95
|
+
"@scalar/api-client": "2.42.0",
|
|
96
|
+
"@scalar/sidebar": "0.8.19",
|
|
97
|
+
"@scalar/snippetz": "0.8.0",
|
|
103
98
|
"@scalar/themes": "0.15.2",
|
|
104
99
|
"@scalar/use-hooks": "0.4.2",
|
|
105
|
-
"@scalar/workspace-store": "0.43.1",
|
|
106
100
|
"@scalar/use-toasts": "0.10.1",
|
|
107
|
-
"@scalar/types": "0.
|
|
101
|
+
"@scalar/types": "0.8.0",
|
|
102
|
+
"@scalar/workspace-store": "0.44.0"
|
|
108
103
|
},
|
|
109
104
|
"devDependencies": {
|
|
110
105
|
"@hono/node-server": "^1.19.10",
|
|
@@ -121,8 +116,8 @@
|
|
|
121
116
|
"vite-plugin-banner": "^0.8.1",
|
|
122
117
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
123
118
|
"vitest": "4.1.0",
|
|
124
|
-
"@scalar/
|
|
125
|
-
"@scalar/
|
|
119
|
+
"@scalar/core": "0.5.0",
|
|
120
|
+
"@scalar/galaxy": "0.6.2"
|
|
126
121
|
},
|
|
127
122
|
"scripts": {
|
|
128
123
|
"build": "pnpm build:default && pnpm build:standalone && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
package/dist/ssr.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSR entry point for @scalar/api-reference.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the same components as the main entry. The ApiReference component
|
|
5
|
-
* is SSR-compatible and works with createSSRApp and renderToString from
|
|
6
|
-
* @vue/server-renderer.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { createSSRApp } from 'vue'
|
|
11
|
-
* import { renderToString } from '@vue/server-renderer'
|
|
12
|
-
* import { ApiReference } from '@scalar/api-reference/ssr'
|
|
13
|
-
*
|
|
14
|
-
* const app = createSSRApp({
|
|
15
|
-
* render: () => h(ApiReference, { configuration: { url: '/openapi.json' } }),
|
|
16
|
-
* })
|
|
17
|
-
* const html = await renderToString(app)
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export type { ApiReferenceConfiguration, ReferenceProps } from './index.js';
|
|
21
|
-
export { ApiReference, GettingStarted, SearchButton, SearchModal, createApiReference, createEmptySpecification, } from './index.js';
|
|
22
|
-
//# sourceMappingURL=ssr.d.ts.map
|
package/dist/ssr.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../src/ssr.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,SAAS,CAAA"}
|
package/dist/ssr.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createEmptySpecification } from "./helpers/openapi.js";
|
|
2
|
-
import SearchModal_default from "./features/Search/components/SearchModal.vue.js";
|
|
3
|
-
import SearchButton_default from "./features/Search/components/SearchButton.vue.js";
|
|
4
|
-
import ApiReference_default from "./components/ApiReference.vue.js";
|
|
5
|
-
import GettingStarted_default from "./components/GettingStarted.vue.js";
|
|
6
|
-
import { createApiReference } from "./standalone/lib/html-api.js";
|
|
7
|
-
export { ApiReference_default as ApiReference, GettingStarted_default as GettingStarted, SearchButton_default as SearchButton, SearchModal_default as SearchModal, createApiReference, createEmptySpecification };
|