@scalar/blocks 0.11.3 → 0.11.4
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 +8 -0
- package/dist/constants.js +1 -1
- package/dist/schema/Schema.vue.d.ts.map +1 -1
- package/dist/schema/Schema.vue.js +4 -4
- package/dist/schema/Schema.vue.js.map +1 -1
- package/dist/schema/Schema3.vue.js +1 -1
- package/dist/schema/SchemaProperty.vue.d.ts +7 -2
- package/dist/schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/schema/SchemaProperty.vue.js +257 -235
- package/dist/schema/SchemaProperty.vue.js.map +1 -1
- package/dist/schema/SchemaProperty3.vue.js +1 -1
- package/dist/schema/SchemaPropertyHeading.vue.d.ts +4 -1
- package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
- package/dist/schema/SchemaPropertyHeading.vue.js +113 -112
- package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyHeading3.vue.js +1 -1
- package/dist/schema/helpers/get-compositions-to-render.d.ts.map +1 -1
- package/dist/schema/helpers/get-compositions-to-render.js +34 -31
- package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
- package/dist/schema/helpers/get-ref-name.d.ts +14 -5
- package/dist/schema/helpers/get-ref-name.d.ts.map +1 -1
- package/dist/schema/helpers/get-ref-name.js +8 -11
- package/dist/schema/helpers/get-ref-name.js.map +1 -1
- package/dist/schema/helpers/index.d.ts +1 -1
- package/dist/schema/helpers/index.d.ts.map +1 -1
- package/dist/schema/helpers/index.js +3 -3
- package/dist/schema/helpers/schema-name.d.ts +7 -3
- package/dist/schema/helpers/schema-name.d.ts.map +1 -1
- package/dist/schema/helpers/schema-name.js +36 -26
- package/dist/schema/helpers/schema-name.js.map +1 -1
- package/dist/shared/ExternalDocs.vue.d.ts +2 -0
- package/dist/shared/ExternalDocs.vue.d.ts.map +1 -1
- package/dist/shared/ExternalDocs.vue.js +24 -17
- package/dist/shared/ExternalDocs.vue.js.map +1 -1
- package/dist/style.css +11 -11
- package/dist/vue-styles.css +1 -1
- package/package.json +10 -10
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { compositions as
|
|
3
|
-
import { hasArrayItemComposition as
|
|
4
|
-
import { unwrapForRead as
|
|
5
|
-
import { resolve as
|
|
6
|
-
import { isArraySchema as
|
|
7
|
-
import { isDefined as
|
|
8
|
-
import { unescapeJsonPointerSegment as
|
|
1
|
+
import { getRawRefName as e, getRefName as t } from "./get-ref-name.js";
|
|
2
|
+
import { compositions as n } from "./schema-composition.js";
|
|
3
|
+
import { hasArrayItemComposition as r, shouldRenderArrayItemComposition as i } from "./should-render-array-item-composition.js";
|
|
4
|
+
import { unwrapForRead as a } from "./unwrap-for-read.js";
|
|
5
|
+
import { resolve as o } from "@scalar/workspace-store/resolve";
|
|
6
|
+
import { isArraySchema as s } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
|
|
7
|
+
import { isDefined as c } from "@scalar/helpers/array/is-defined";
|
|
8
|
+
import { unescapeJsonPointerSegment as l } from "@scalar/helpers/json/unescape-json-pointer-segment";
|
|
9
9
|
// src/schema/helpers/get-compositions-to-render.ts
|
|
10
|
-
var
|
|
11
|
-
if (
|
|
12
|
-
let
|
|
13
|
-
if (!
|
|
14
|
-
let
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
if (i) return
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
var u = (e) => e.startsWith("#/") || e.includes("/") ? e : `#/components/schemas/${e}`, d = (n, r, i) => {
|
|
11
|
+
if (n.oneOf || n.anyOf) return null;
|
|
12
|
+
let s = n.discriminator?.mapping;
|
|
13
|
+
if (!s) return null;
|
|
14
|
+
let d = a(r);
|
|
15
|
+
if (!d?.components?.schemas) return null;
|
|
16
|
+
let f = (i ?? Object.values(s)).filter((e) => typeof e == "string").map((n) => {
|
|
17
|
+
let r = u(n), i = e(r);
|
|
18
|
+
if (!i) return;
|
|
19
|
+
let a = l(i), s = o.schema(d.components?.schemas?.[a]);
|
|
20
|
+
if (s) return {
|
|
21
|
+
$ref: r,
|
|
22
|
+
"$ref-value": s,
|
|
23
|
+
...!s.title && !s.name && a !== t(r) ? { name: a } : {}
|
|
21
24
|
};
|
|
22
|
-
}).filter(
|
|
23
|
-
return
|
|
24
|
-
...
|
|
25
|
-
oneOf:
|
|
25
|
+
}).filter(c);
|
|
26
|
+
return f.length === 0 ? null : {
|
|
27
|
+
...o.schema(n),
|
|
28
|
+
oneOf: f
|
|
26
29
|
};
|
|
27
|
-
},
|
|
30
|
+
}, f = (e, t, a = e ? d(e, t) : null) => e ? n.map((t) => t === "oneOf" && a ? {
|
|
28
31
|
composition: t,
|
|
29
|
-
value:
|
|
30
|
-
} :
|
|
32
|
+
value: a
|
|
33
|
+
} : i(e, t) && s(e) && e.items ? {
|
|
31
34
|
composition: t,
|
|
32
|
-
value:
|
|
33
|
-
} : e[t] && !
|
|
35
|
+
value: o.schema(e.items)
|
|
36
|
+
} : e[t] && !r(e, t) ? {
|
|
34
37
|
composition: t,
|
|
35
|
-
value:
|
|
36
|
-
} : null).filter(
|
|
37
|
-
export {
|
|
38
|
+
value: o.schema(e)
|
|
39
|
+
} : null).filter(c) : [];
|
|
40
|
+
export { f as getCompositionsToRender, d as inferDiscriminatorMappingComposition };
|
|
38
41
|
|
|
39
42
|
//# sourceMappingURL=get-compositions-to-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-compositions-to-render.js","names":["getRefName","compositions","hasArrayItemComposition","shouldRenderArrayItemComposition","unwrapForRead","resolve","isArraySchema","isDefined","unescapeJsonPointerSegment","normalizeDiscriminatorMappingRef","value","inferDiscriminatorMappingComposition","documentProp","variantRefs","mapping","document","refs","mappingValue","ref","refName","refValue","getCompositionsToRender","inferredDiscriminatorComposition","composition"],"sources":["../../../src/schema/helpers/get-compositions-to-render.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { unescapeJsonPointerSegment } from '@scalar/helpers/json/unescape-json-pointer-segment'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { OpenApiDocument, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport { getRefName } from './get-ref-name'\nimport { type CompositionKeyword, compositions } from './schema-composition'\nimport { hasArrayItemComposition, shouldRenderArrayItemComposition } from './should-render-array-item-composition'\nimport { unwrapForRead } from './unwrap-for-read'\n\ntype CompositionToRender = {\n composition: CompositionKeyword\n value: SchemaObject\n}\n\ntype DocumentSchemaLookup = Pick<OpenApiDocument, 'components'>\n\nconst normalizeDiscriminatorMappingRef = (value: string) =>\n value.startsWith('#/') || value.includes('/') ? value : `#/components/schemas/${value}`\n\n/**\n * Builds a synthetic `oneOf` composition from a `discriminator.mapping` when the\n * schema declares a mapping but no explicit `oneOf`/`anyOf`. This is the shape\n * NSwag emits for polymorphic types, where the base type is a plain object with\n * a discriminator mapping pointing at the concrete variants.\n *\n * Returns `null` when there is nothing to infer (an explicit composition is\n * already present, no document to resolve refs against, or no resolvable refs).\n */\nexport const inferDiscriminatorMappingComposition = (\n value: SchemaObject,\n documentProp?: DocumentSchemaLookup,\n /** Inheritance can supply ordered variants, including schemas that share a mapped value. */\n variantRefs?: readonly string[],\n): SchemaObject | null => {\n if (value.oneOf || value.anyOf) {\n return null\n }\n\n // A schema without a mapping can never infer anything, so it is checked before the document is\n // touched at all: the document read below is by far the more expensive of the two.\n const mapping = value.discriminator?.mapping\n\n if (!mapping) {\n return null\n }\n\n // Reading `components.schemas` per row through the reactive and detect-changes layers is the\n // dominant cost of this helper, so the document is unwrapped once here. See `unwrapForRead`.\n const document = unwrapForRead(documentProp)\n\n if (!document?.components?.schemas) {\n return null\n }\n\n const refs = (variantRefs ?? Object.values(mapping))\n .filter((mappingValue): mappingValue is string => typeof mappingValue === 'string')\n .map((mappingValue) => {\n const ref = normalizeDiscriminatorMappingRef(mappingValue)\n const refName =
|
|
1
|
+
{"version":3,"file":"get-compositions-to-render.js","names":["getRawRefName","getRefName","compositions","hasArrayItemComposition","shouldRenderArrayItemComposition","unwrapForRead","resolve","isArraySchema","isDefined","unescapeJsonPointerSegment","normalizeDiscriminatorMappingRef","value","inferDiscriminatorMappingComposition","documentProp","variantRefs","mapping","document","refs","mappingValue","ref","refName","schemaKey","refValue","getCompositionsToRender","inferredDiscriminatorComposition","composition"],"sources":["../../../src/schema/helpers/get-compositions-to-render.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { unescapeJsonPointerSegment } from '@scalar/helpers/json/unescape-json-pointer-segment'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { OpenApiDocument, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport { getRawRefName, getRefName } from './get-ref-name'\nimport { type CompositionKeyword, compositions } from './schema-composition'\nimport { hasArrayItemComposition, shouldRenderArrayItemComposition } from './should-render-array-item-composition'\nimport { unwrapForRead } from './unwrap-for-read'\n\ntype CompositionToRender = {\n composition: CompositionKeyword\n value: SchemaObject\n}\n\ntype DocumentSchemaLookup = Pick<OpenApiDocument, 'components'>\n\nconst normalizeDiscriminatorMappingRef = (value: string) =>\n value.startsWith('#/') || value.includes('/') ? value : `#/components/schemas/${value}`\n\n/**\n * Builds a synthetic `oneOf` composition from a `discriminator.mapping` when the\n * schema declares a mapping but no explicit `oneOf`/`anyOf`. This is the shape\n * NSwag emits for polymorphic types, where the base type is a plain object with\n * a discriminator mapping pointing at the concrete variants.\n *\n * Returns `null` when there is nothing to infer (an explicit composition is\n * already present, no document to resolve refs against, or no resolvable refs).\n */\nexport const inferDiscriminatorMappingComposition = (\n value: SchemaObject,\n documentProp?: DocumentSchemaLookup,\n /** Inheritance can supply ordered variants, including schemas that share a mapped value. */\n variantRefs?: readonly string[],\n): SchemaObject | null => {\n if (value.oneOf || value.anyOf) {\n return null\n }\n\n // A schema without a mapping can never infer anything, so it is checked before the document is\n // touched at all: the document read below is by far the more expensive of the two.\n const mapping = value.discriminator?.mapping\n\n if (!mapping) {\n return null\n }\n\n // Reading `components.schemas` per row through the reactive and detect-changes layers is the\n // dominant cost of this helper, so the document is unwrapped once here. See `unwrapForRead`.\n const document = unwrapForRead(documentProp)\n\n if (!document?.components?.schemas) {\n return null\n }\n\n const refs = (variantRefs ?? Object.values(mapping))\n .filter((mappingValue): mappingValue is string => typeof mappingValue === 'string')\n .map((mappingValue) => {\n const ref = normalizeDiscriminatorMappingRef(mappingValue)\n const refName = getRawRefName(ref)\n if (!refName) {\n return undefined\n }\n\n const schemaKey = unescapeJsonPointerSegment(refName)\n const refValue = resolve.schema(document.components?.schemas?.[schemaKey])\n\n if (!refValue) {\n return undefined\n }\n\n return {\n $ref: ref,\n '$ref-value': refValue,\n // Keep the selected component's name when decoding a literal percent sequence would change it.\n ...(!refValue.title && !refValue.name && schemaKey !== getRefName(ref) ? { name: schemaKey } : {}),\n }\n })\n .filter(isDefined)\n\n if (refs.length === 0) {\n return null\n }\n\n return {\n ...resolve.schema(value),\n oneOf: refs,\n }\n}\n\n/**\n * Computes which compositions should be rendered and with which values\n *\n * @param value - The schema object to check for compositions\n * @returns Array of compositions to render with their values\n */\nexport const getCompositionsToRender = (\n value: SchemaObject | undefined,\n document?: DocumentSchemaLookup,\n /**\n * The `oneOf` inferred from a bare `discriminator.mapping`, when the caller has\n * already computed it. `SchemaProperty` needs the same value to decide whether\n * to suppress the duplicate base object block, so it passes it here to avoid\n * inferring twice. Omit it and it is inferred from `value`.\n */\n inferredDiscriminatorComposition: SchemaObject | null = value\n ? inferDiscriminatorMappingComposition(value, document)\n : null,\n): CompositionToRender[] => {\n if (!value) {\n return []\n }\n\n return compositions\n .map((composition) => {\n if (composition === 'oneOf' && inferredDiscriminatorComposition) {\n return {\n composition,\n value: inferredDiscriminatorComposition,\n }\n }\n\n // Check for array item-level composition first (more specific case)\n if (shouldRenderArrayItemComposition(value, composition) && isArraySchema(value) && value.items) {\n return {\n composition,\n value: resolve.schema(value.items),\n }\n }\n\n // Check for property-level composition\n if (value[composition] && !hasArrayItemComposition(value, composition)) {\n return {\n composition,\n value: resolve.schema(value),\n }\n }\n\n return null\n })\n .filter(isDefined)\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAMU,KAAoCC,MACxCA,EAAM,WAAW,IAAI,KAAKA,EAAM,SAAS,GAAG,IAAIA,IAAQ,wBAAwBA,KAWrEC,KACXD,GACAE,GAEAC,MACwB;CACxB,IAAIH,EAAM,SAASA,EAAM,OACvB,OAAO;CAKT,IAAMI,IAAUJ,EAAM,eAAe;CAErC,IAAI,CAACI,GACH,OAAO;CAKT,IAAMC,IAAWX,EAAcQ,CAAY;CAE3C,IAAI,CAACG,GAAU,YAAY,SACzB,OAAO;CAGT,IAAMC,KAAQH,KAAe,OAAO,OAAOC,CAAO,EAAA,CAC/C,QAAQG,MAAyC,OAAOA,KAAiB,QAAQ,CAAC,CAClF,KAAKA,MAAiB;EACrB,IAAMC,IAAMT,EAAiCQ,CAAY,GACnDE,IAAUpB,EAAcmB,CAAG;EACjC,IAAI,CAACC,GACH;EAGF,IAAMC,IAAYZ,EAA2BW,CAAO,GAC9CE,IAAWhB,EAAQ,OAAOU,EAAS,YAAY,UAAUK,EAAU;EAEzE,IAAKC,GAIL,OAAO;GACL,MAAMH;GACN,cAAcG;GAEd,GAAI,CAACA,EAAS,SAAS,CAACA,EAAS,QAAQD,MAAcpB,EAAWkB,CAAG,IAAI,EAAE,MAAME,EAAU,IAAI,CAAC;EAClG;CACF,CAAC,CAAC,CACD,OAAOb,CAAS;CAMnB,OAJIS,EAAK,WAAW,IACX,OAGF;EACL,GAAGX,EAAQ,OAAOK,CAAK;EACvB,OAAOM;CACT;AACF,GAQaM,KACXZ,GACAK,GAOAQ,IAAwDb,IACpDC,EAAqCD,GAAOK,CAAQ,IACpD,SAECL,IAIET,EACJ,KAAKuB,MACAA,MAAgB,WAAWD,IACtB;CACLC;CACA,OAAOD;AACT,IAIEpB,EAAiCO,GAAOc,CAAW,KAAKlB,EAAcI,CAAK,KAAKA,EAAM,QACjF;CACLc;CACA,OAAOnB,EAAQ,OAAOK,EAAM,KAAK;AACnC,IAIEA,EAAMc,MAAgB,CAACtB,EAAwBQ,GAAOc,CAAW,IAC5D;CACLA;CACA,OAAOnB,EAAQ,OAAOK,CAAK;AAC7B,IAGK,IACR,CAAC,CACD,OAAOH,CAAS,IA9BV,CAAC"}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
+
export declare const COMPONENT_SCHEMAS_REF_PREFIX = "#/components/schemas/";
|
|
2
|
+
/** Decode a reference fragment and read its JSON Pointer segments. */
|
|
3
|
+
export declare const getRefPointer: (ref: string) => string[] | undefined;
|
|
4
|
+
/** Read the final reference segment as written in the original reference. */
|
|
5
|
+
export declare const getRawRefName: (ref: string) => string | null;
|
|
6
|
+
/** Read the display name from a reference with an already parsed pointer. */
|
|
7
|
+
export declare const getRefNameFromPointer: (ref: string, pointer: string[] | undefined) => string | null;
|
|
1
8
|
/**
|
|
2
9
|
* Gets the final reference segment for display, including external references.
|
|
3
|
-
* Use getSchemaRefName when the name must link to a local model.
|
|
4
10
|
*
|
|
5
|
-
* @example
|
|
11
|
+
* @example
|
|
12
|
+
* getRefName('#/components/schemas/Result%601') // 'Result`1'
|
|
6
13
|
*/
|
|
7
|
-
export declare const getRefName: (ref: string) => string | null
|
|
14
|
+
export declare const getRefName: (ref: string) => string | null;
|
|
15
|
+
/** Read the model key from a direct components.schemas pointer. */
|
|
16
|
+
export declare const getSchemaNameFromPointer: (pointer: string[] | undefined) => string | null;
|
|
8
17
|
/**
|
|
9
|
-
* Gets the models-section key for a
|
|
10
|
-
*
|
|
18
|
+
* Gets the models-section key for a direct `#/components/schemas/` reference.
|
|
19
|
+
* The key is percent-decoded and JSON Pointer escapes `~0` and `~1` are unescaped.
|
|
11
20
|
*
|
|
12
21
|
* The models index used for navigation is built exclusively from
|
|
13
22
|
* `components.schemas`, so a ref into any other bucket (`parameters`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-ref-name.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/get-ref-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-ref-name.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/get-ref-name.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAEnE,sEAAsE;AACtE,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,MAAM,EAAE,GAAG,SAGtD,CAAA;AAED,6EAA6E;AAC7E,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAA8C,CAAA;AAEnG,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,KAAG,MAAM,GAAG,IAK3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAAsD,CAAA;AAExG,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,EAAE,GAAG,SAAS,KAAG,MAAM,GAAG,IAKjF,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAC4C,CAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decodeUriFragment as e } from "@scalar/helpers/json/decode-uri-fragment";
|
|
2
|
+
import { parseDecodedJsonPointer as t } from "@scalar/helpers/json/parse-decoded-json-pointer";
|
|
3
|
+
import { REGEX as n } from "@scalar/helpers/regex/regex-helpers";
|
|
2
4
|
// src/schema/helpers/get-ref-name.ts
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!e) return null;
|
|
9
|
-
let t = e.match(n);
|
|
10
|
-
return t?.[1] ? decodeURIComponent(t[1]) : null;
|
|
11
|
-
};
|
|
12
|
-
export { t as getRefName, r as getSchemaRefName };
|
|
5
|
+
var r = "#/components/schemas/", i = (n) => {
|
|
6
|
+
let r = n.indexOf("#");
|
|
7
|
+
return r === -1 ? void 0 : t(e(n.slice(r + 1)));
|
|
8
|
+
}, a = (e) => e.match(n.REF_NAME)?.[1] ?? null, o = (e, t) => t?.length ? t.at(-1) || null : a(e), s = (e) => o(e, i(e)), c = (e) => e?.length === 3 && e[0] === "components" && e[1] === "schemas" && e[2] || null, l = (e) => e.startsWith("#/components/schemas/") ? c(i(e)) : null;
|
|
9
|
+
export { r as COMPONENT_SCHEMAS_REF_PREFIX, a as getRawRefName, s as getRefName, o as getRefNameFromPointer, i as getRefPointer, c as getSchemaNameFromPointer, l as getSchemaRefName };
|
|
13
10
|
|
|
14
11
|
//# sourceMappingURL=get-ref-name.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-ref-name.js","names":["REGEX","
|
|
1
|
+
{"version":3,"file":"get-ref-name.js","names":["decodeUriFragment","parseDecodedJsonPointer","REGEX","COMPONENT_SCHEMAS_REF_PREFIX","getRefPointer","ref","fragmentStart","getRawRefName","getRefNameFromPointer","pointer","getRefName","getSchemaNameFromPointer","getSchemaRefName"],"sources":["../../../src/schema/helpers/get-ref-name.ts"],"sourcesContent":["import { decodeUriFragment } from '@scalar/helpers/json/decode-uri-fragment'\nimport { parseDecodedJsonPointer } from '@scalar/helpers/json/parse-decoded-json-pointer'\nimport { REGEX } from '@scalar/helpers/regex/regex-helpers'\n\nexport const COMPONENT_SCHEMAS_REF_PREFIX = '#/components/schemas/'\n\n/** Decode a reference fragment and read its JSON Pointer segments. */\nexport const getRefPointer = (ref: string): string[] | undefined => {\n const fragmentStart = ref.indexOf('#')\n return fragmentStart === -1 ? undefined : parseDecodedJsonPointer(decodeUriFragment(ref.slice(fragmentStart + 1)))\n}\n\n/** Read the final reference segment as written in the original reference. */\nexport const getRawRefName = (ref: string): string | null => ref.match(REGEX.REF_NAME)?.[1] ?? null\n\n/** Read the display name from a reference with an already parsed pointer. */\nexport const getRefNameFromPointer = (ref: string, pointer: string[] | undefined): string | null => {\n if (pointer?.length) {\n return pointer.at(-1) || null\n }\n return getRawRefName(ref)\n}\n\n/**\n * Gets the final reference segment for display, including external references.\n *\n * @example\n * getRefName('#/components/schemas/Result%601') // 'Result`1'\n */\nexport const getRefName = (ref: string): string | null => getRefNameFromPointer(ref, getRefPointer(ref))\n\n/** Read the model key from a direct components.schemas pointer. */\nexport const getSchemaNameFromPointer = (pointer: string[] | undefined): string | null => {\n if (pointer?.length === 3 && pointer[0] === 'components' && pointer[1] === 'schemas') {\n return pointer[2] || null\n }\n return null\n}\n\n/**\n * Gets the models-section key for a direct `#/components/schemas/` reference.\n * The key is percent-decoded and JSON Pointer escapes `~0` and `~1` are unescaped.\n *\n * The models index used for navigation is built exclusively from\n * `components.schemas`, so a ref into any other bucket (`parameters`,\n * `responses`, ...) or an external file (`./other.yaml#/Foo`) has no navigable\n * target. Returning `null` for those keeps the name visible as plain text while\n * avoiding a dead link.\n *\n * @example\n * getSchemaRefName('#/components/schemas/Planet') // 'Planet'\n * getSchemaRefName('#/components/parameters/Planet') // null\n * getSchemaRefName('./planets.yaml#/Planet') // null\n */\nexport const getSchemaRefName = (ref: string): string | null =>\n ref.startsWith(COMPONENT_SCHEMAS_REF_PREFIX) ? getSchemaNameFromPointer(getRefPointer(ref)) : null\n"],"mappings":";;;;AAIA,IAAaG,IAA+B,yBAG/BC,KAAiBC,MAAsC;CAClE,IAAMC,IAAgBD,EAAI,QAAQ,GAAG;CACrC,OAAOC,MAAkB,KAAK,KAAA,IAAYL,EAAwBD,EAAkBK,EAAI,MAAMC,IAAgB,CAAC,CAAC,CAAC;AACnH,GAGaC,KAAiBF,MAA+BA,EAAI,MAAMH,EAAM,QAAQ,CAAC,GAAG,MAAM,MAGlFM,KAAyBH,GAAaI,MAC7CA,GAAS,SACJA,EAAQ,GAAG,EAAE,KAAK,OAEpBF,EAAcF,CAAG,GASbK,KAAcL,MAA+BG,EAAsBH,GAAKD,EAAcC,CAAG,CAAC,GAG1FM,KAA4BF,MACnCA,GAAS,WAAW,KAAKA,EAAQ,OAAO,gBAAgBA,EAAQ,OAAO,aAClEA,EAAQ,MAAM,MAoBZG,KAAoBP,MAC/BA,EAAI,WAAA,uBAAuC,IAAIM,EAAyBP,EAAcC,CAAG,CAAC,IAAI"}
|
|
@@ -9,6 +9,6 @@ export { isModelLinkable } from './is-model-linkable';
|
|
|
9
9
|
export { isTypeObject } from './is-type-object';
|
|
10
10
|
export { optimizeValueForDisplay } from './optimize-value-for-display';
|
|
11
11
|
export { handleTreeKeydown } from './schema-keyboard-nav';
|
|
12
|
-
export { getModelNameFromSchema, getModelNameWithArray } from './schema-name';
|
|
12
|
+
export { type SchemaModelName, getModelNameFromRef, getModelNameFromSchema, getModelNameWithArray } from './schema-name';
|
|
13
13
|
export { reduceNamesToObject, sortPropertyNames } from './sort-property-names';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,KAAK,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACxH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -9,6 +9,6 @@ import { isModelLinkable as c } from "./is-model-linkable.js";
|
|
|
9
9
|
import { isTypeObject as l } from "./is-type-object.js";
|
|
10
10
|
import { optimizeValueForDisplay as u } from "./optimize-value-for-display.js";
|
|
11
11
|
import { handleTreeKeydown as d } from "./schema-keyboard-nav.js";
|
|
12
|
-
import {
|
|
13
|
-
import { reduceNamesToObject as
|
|
14
|
-
export { f as
|
|
12
|
+
import { getModelNameFromRef as f, getModelNameFromSchema as p, getModelNameWithArray as m } from "./schema-name.js";
|
|
13
|
+
import { reduceNamesToObject as h, sortPropertyNames as g } from "./sort-property-names.js";
|
|
14
|
+
export { f as getModelNameFromRef, p as getModelNameFromSchema, m as getModelNameWithArray, n as getRefName, r as getRenderedExample, a as getSchemaType, o as getTypeSignatureTokens, d as handleTreeKeydown, s as hasComplexArrayItems, t as inferDiscriminatorMappingComposition, c as isModelLinkable, l as isTypeObject, i as normalizeRenderedExamples, u as optimizeValueForDisplay, h as reduceNamesToObject, e as resolveDisplaySchema, g as sortPropertyNames };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SchemaObject, SchemaReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
|
-
|
|
1
|
+
import type { OpenApiDocument, SchemaObject, SchemaReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
|
+
/** Display label and optional navigation key for a named schema. */
|
|
3
|
+
export type SchemaModelName = {
|
|
3
4
|
/**
|
|
4
5
|
* The key in `components.schemas` (extracted from `$ref`), used for sidebar
|
|
5
6
|
* navigation. Only set when the `$ref` actually targets
|
|
@@ -10,6 +11,10 @@ type SchemaModelName = {
|
|
|
10
11
|
/** The human-readable name to display (schema.title, schema.name, or ref key). */
|
|
11
12
|
label: string;
|
|
12
13
|
};
|
|
14
|
+
/** Display the authored reference name and link it to a model when the target is local. */
|
|
15
|
+
export declare const getModelNameFromRef: (reference: Extract<SchemaReferenceType<SchemaObject>, {
|
|
16
|
+
$ref: string;
|
|
17
|
+
}>, document?: Pick<OpenApiDocument, "components">) => SchemaModelName | null;
|
|
13
18
|
/**
|
|
14
19
|
* Extract schema name from various schema formats
|
|
15
20
|
*
|
|
@@ -23,5 +28,4 @@ export declare const getModelNameFromSchema: (schemaOrRef: SchemaObject | Schema
|
|
|
23
28
|
* example an array of primitives), so callers can fall back to `getSchemaType`.
|
|
24
29
|
*/
|
|
25
30
|
export declare const getModelNameWithArray: (schemaOrRef: SchemaObject | SchemaReferenceType<SchemaObject>) => SchemaModelName | null;
|
|
26
|
-
export {};
|
|
27
31
|
//# sourceMappingURL=schema-name.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-name.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/schema-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-name.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/schema-name.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACpB,MAAM,8DAA8D,CAAA;AAWrE,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;OAKG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,GAC9B,WAAW,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACvE,WAAW,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,KAC7C,eAAe,GAAG,IA2BpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,aAAa,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,KAC5D,eAAe,GAAG,IAapB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,KAC5D,eAAe,GAAG,IAepB,CAAA"}
|
|
@@ -1,32 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getRefNameFromPointer as e, getRefPointer as t, getSchemaNameFromPointer as n, getSchemaRefName as r } from "./get-ref-name.js";
|
|
2
|
+
import { unpackProxyShallow as i } from "@scalar/workspace-store/helpers/unpack-proxy";
|
|
3
|
+
import { resolve as a } from "@scalar/workspace-store/resolve";
|
|
4
|
+
import { isArraySchema as o } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
|
|
4
5
|
// src/schema/helpers/schema-name.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
label:
|
|
6
|
+
var s = (r, a) => {
|
|
7
|
+
let o = r.$ref, s = t(o), c = e(o, s);
|
|
8
|
+
if (!c) return null;
|
|
9
|
+
let l = n(s), u = o.startsWith("#/components/schemas/") ? l : null;
|
|
10
|
+
if (!l || !a) return {
|
|
11
|
+
label: c,
|
|
12
|
+
schemaKey: u
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
label:
|
|
14
|
+
let d = a.components?.schemas?.[l];
|
|
15
|
+
if (d === void 0) return {
|
|
16
|
+
label: c,
|
|
17
|
+
schemaKey: null
|
|
15
18
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
19
|
+
let f = r["$ref-value"];
|
|
20
|
+
return f === void 0 ? {
|
|
21
|
+
label: c,
|
|
22
|
+
schemaKey: u
|
|
23
|
+
} : {
|
|
24
|
+
label: c,
|
|
25
|
+
schemaKey: i(f) === i(d) ? l : null
|
|
26
|
+
};
|
|
27
|
+
}, c = (e) => {
|
|
28
|
+
if (!e || typeof e != "object") return null;
|
|
29
|
+
let t = a.schema(e), n = t.title || t.name;
|
|
30
|
+
return n ? {
|
|
31
|
+
schemaKey: "$ref" in e ? r(e.$ref) : null,
|
|
32
|
+
label: n
|
|
33
|
+
} : "$ref" in e ? s(e) : null;
|
|
34
|
+
}, l = (e) => {
|
|
35
|
+
let t = c(e);
|
|
26
36
|
if (t) return t;
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
let e =
|
|
37
|
+
let n = a.schema(e);
|
|
38
|
+
if (o(n) && n.items && typeof n.items == "object") {
|
|
39
|
+
let e = c(n.items);
|
|
30
40
|
if (e) return {
|
|
31
41
|
schemaKey: e.schemaKey,
|
|
32
42
|
label: `${e.label}[]`
|
|
@@ -34,6 +44,6 @@ var i = (r) => {
|
|
|
34
44
|
}
|
|
35
45
|
return null;
|
|
36
46
|
};
|
|
37
|
-
export {
|
|
47
|
+
export { s as getModelNameFromRef, c as getModelNameFromSchema, l as getModelNameWithArray };
|
|
38
48
|
|
|
39
49
|
//# sourceMappingURL=schema-name.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-name.js","names":["
|
|
1
|
+
{"version":3,"file":"schema-name.js","names":["getRefNameFromPointer","getRefPointer","getSchemaNameFromPointer","getSchemaRefName","unpackProxyShallow","resolve","isArraySchema","getModelNameFromRef","reference","document","ref","pointer","label","schemaKey","fragmentKey","component","target","getModelNameFromSchema","schemaOrRef","schema","getModelNameWithArray","direct","itemName"],"sources":["../../../src/schema/helpers/schema-name.ts"],"sourcesContent":["import { unpackProxyShallow } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n OpenApiDocument,\n SchemaObject,\n SchemaReferenceType,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport {\n COMPONENT_SCHEMAS_REF_PREFIX,\n getRefNameFromPointer,\n getRefPointer,\n getSchemaNameFromPointer,\n getSchemaRefName,\n} from './get-ref-name'\n\n/** Display label and optional navigation key for a named schema. */\nexport type SchemaModelName = {\n /**\n * The key in `components.schemas` (extracted from `$ref`), used for sidebar\n * navigation. Only set when the `$ref` actually targets\n * `#/components/schemas/`; `null` for refs into other component buckets or\n * external files, so those never render a dead link.\n */\n schemaKey: string | null\n /** The human-readable name to display (schema.title, schema.name, or ref key). */\n label: string\n}\n\n/** Display the authored reference name and link it to a model when the target is local. */\nexport const getModelNameFromRef = (\n reference: Extract<SchemaReferenceType<SchemaObject>, { $ref: string }>,\n document?: Pick<OpenApiDocument, 'components'>,\n): SchemaModelName | null => {\n const ref = reference.$ref\n const pointer = getRefPointer(ref)\n const label = getRefNameFromPointer(ref, pointer)\n if (!label) {\n return null\n }\n\n const schemaKey = getSchemaNameFromPointer(pointer)\n const fragmentKey = ref.startsWith(COMPONENT_SCHEMAS_REF_PREFIX) ? schemaKey : null\n if (!schemaKey || !document) {\n return { label, schemaKey: fragmentKey }\n }\n\n const component = document.components?.schemas?.[schemaKey]\n if (component === undefined) {\n return { label, schemaKey: null }\n }\n\n const target = reference['$ref-value']\n if (target !== undefined) {\n // Distinct aliases can resolve to the same schema. Link only to the referenced component.\n return { label, schemaKey: unpackProxyShallow(target) === unpackProxyShallow(component) ? schemaKey : null }\n }\n\n // A direct fragment keeps its model link while the target is loaded on demand.\n return { label, schemaKey: fragmentKey }\n}\n\n/**\n * Extract schema name from various schema formats\n *\n * Handles $ref, title, name, type, and schema dictionary lookup\n */\nexport const getModelNameFromSchema = (\n schemaOrRef: SchemaObject | SchemaReferenceType<SchemaObject>,\n): SchemaModelName | null => {\n if (!schemaOrRef || typeof schemaOrRef !== 'object') {\n return null\n }\n\n const schema = resolve.schema(schemaOrRef)\n const label = schema.title || schema.name\n if (label) {\n const schemaKey = '$ref' in schemaOrRef ? getSchemaRefName(schemaOrRef.$ref) : null\n return { schemaKey, label }\n }\n\n return '$ref' in schemaOrRef ? getModelNameFromRef(schemaOrRef) : null\n}\n\n/**\n * Model name for a schema, resolving array branches too: an inline\n * `{ type: 'array', items: { $ref: Model } }` becomes `Model[]` instead of the\n * structural `array object[]`. Returns `null` when no model name applies (for\n * example an array of primitives), so callers can fall back to `getSchemaType`.\n */\nexport const getModelNameWithArray = (\n schemaOrRef: SchemaObject | SchemaReferenceType<SchemaObject>,\n): SchemaModelName | null => {\n const direct = getModelNameFromSchema(schemaOrRef)\n if (direct) {\n return direct\n }\n\n const schema = resolve.schema(schemaOrRef)\n if (isArraySchema(schema) && schema.items && typeof schema.items === 'object') {\n const itemName = getModelNameFromSchema(schema.items)\n if (itemName) {\n return { schemaKey: itemName.schemaKey, label: `${itemName.label}[]` }\n }\n }\n\n return null\n}\n"],"mappings":";;;;;AA+BA,IAAaO,KACXC,GACAC,MAC2B;CAC3B,IAAMC,IAAMF,EAAU,MAChBG,IAAUV,EAAcS,CAAG,GAC3BE,IAAQZ,EAAsBU,GAAKC,CAAO;CAChD,IAAI,CAACC,GACH,OAAO;CAGT,IAAMC,IAAYX,EAAyBS,CAAO,GAC5CG,IAAcJ,EAAI,WAAA,uBAAuC,IAAIG,IAAY;CAC/E,IAAI,CAACA,KAAa,CAACJ,GACjB,OAAO;EAAEG;EAAO,WAAWE;CAAY;CAGzC,IAAMC,IAAYN,EAAS,YAAY,UAAUI;CACjD,IAAIE,MAAc,KAAA,GAChB,OAAO;EAAEH;EAAO,WAAW;CAAK;CAGlC,IAAMI,IAASR,EAAU;CAOzB,OANIQ,MAAW,KAAA,IAMR;EAAEJ;EAAO,WAAWE;CAAY,IAJ9B;EAAEF;EAAO,WAAWR,EAAmBY,CAAM,MAAMZ,EAAmBW,CAAS,IAAIF,IAAY;CAAK;AAK/G,GAOaI,KACXC,MAC2B;CAC3B,IAAI,CAACA,KAAe,OAAOA,KAAgB,UACzC,OAAO;CAGT,IAAMC,IAASd,EAAQ,OAAOa,CAAW,GACnCN,IAAQO,EAAO,SAASA,EAAO;CAMrC,OALIP,IAEK;EAAE,WADS,UAAUM,IAAcf,EAAiBe,EAAY,IAAI,IAAI;EAC3DN;CAAM,IAGrB,UAAUM,IAAcX,EAAoBW,CAAW,IAAI;AACpE,GAQaE,KACXF,MAC2B;CAC3B,IAAMG,IAASJ,EAAuBC,CAAW;CACjD,IAAIG,GACF,OAAOA;CAGT,IAAMF,IAASd,EAAQ,OAAOa,CAAW;CACzC,IAAIZ,EAAca,CAAM,KAAKA,EAAO,SAAS,OAAOA,EAAO,SAAU,UAAU;EAC7E,IAAMG,IAAWL,EAAuBE,EAAO,KAAK;EACpD,IAAIG,GACF,OAAO;GAAE,WAAWA,EAAS;GAAW,OAAO,GAAGA,EAAS,MAAM;EAAI;CAEzE;CAEA,OAAO;AACT"}
|
|
@@ -2,6 +2,8 @@ import { type NodeInput } from '@scalar/workspace-store/helpers/get-resolved-ref
|
|
|
2
2
|
import type { ExternalDocumentationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
value?: NodeInput<ExternalDocumentationObject>;
|
|
5
|
+
/** Use the spacing of the surrounding schema row. */
|
|
6
|
+
inline?: boolean;
|
|
5
7
|
};
|
|
6
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
9
|
declare const _default: typeof __VLS_export;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalDocs.vue.d.ts","sourceRoot":"","sources":["../../src/shared/ExternalDocs.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExternalDocs.vue.d.ts","sourceRoot":"","sources":["../../src/shared/ExternalDocs.vue"],"names":[],"mappings":"AAiEA,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,kDAAkD,CAAA;AACzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8DAA8D,CAAA;AAG/G,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC,2BAA2B,CAAC,CAAA;IAC9C,qDAAqD;IACrD,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAgHF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createVNode as i, defineComponent as a,
|
|
2
|
-
import { ScalarIconBook as
|
|
3
|
-
import { getResolvedRef as
|
|
4
|
-
import { getDocumentationUrl as
|
|
1
|
+
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createVNode as i, defineComponent as a, normalizeClass as o, openBlock as s, resolveDynamicComponent as c, toDisplayString as l, unref as u, withCtx as d } from "vue";
|
|
2
|
+
import { ScalarIconBook as f } from "@scalar/icons";
|
|
3
|
+
import { getResolvedRef as p } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
+
import { getDocumentationUrl as m } from "@scalar/workspace-store/helpers/documentation-url";
|
|
5
5
|
// src/shared/ExternalDocs.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "group narrow:border-r-0 narrow:first:ml-0 flex items-center border-r first:ml-auto last:border-r-0"
|
|
9
|
-
}, h = {
|
|
6
|
+
var h = {
|
|
10
7
|
key: 0,
|
|
11
8
|
class: "ml-1 empty:hidden"
|
|
12
9
|
}, g = {
|
|
@@ -14,30 +11,40 @@ var m = {
|
|
|
14
11
|
class: "ml-1 empty:hidden"
|
|
15
12
|
}, _ = /*@__PURE__*/ a({
|
|
16
13
|
__name: "ExternalDocs",
|
|
17
|
-
props: {
|
|
14
|
+
props: {
|
|
15
|
+
value: {},
|
|
16
|
+
inline: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !1
|
|
19
|
+
}
|
|
20
|
+
},
|
|
18
21
|
setup(a) {
|
|
19
22
|
let _ = e(() => {
|
|
20
|
-
let e =
|
|
23
|
+
let e = p(a.value);
|
|
21
24
|
return e && typeof e.url == "string" && e.url ? e : void 0;
|
|
22
|
-
}), v = e(() =>
|
|
23
|
-
return (e,
|
|
25
|
+
}), v = e(() => m(_.value?.url, _.value));
|
|
26
|
+
return (e, p) => _.value ? (s(), r("div", {
|
|
27
|
+
key: 0,
|
|
28
|
+
class: o(["group flex items-center", a.inline ? "max-w-full" : "narrow:border-r-0 border-r last:border-r-0"])
|
|
29
|
+
}, [(s(), t(c(v.value ? "a" : "span"), {
|
|
24
30
|
"aria-label": _.value.description || _.value.url,
|
|
25
|
-
class: "text-c-1 hover:bg-b-2
|
|
31
|
+
class: o(["text-c-1 hover:bg-b-2 flex min-h-7 min-w-7 items-center rounded-lg px-2 py-1 no-underline", a.inline ? "wrap-anywhere" : "narrow:border mr-2 group-last:mr-0"]),
|
|
26
32
|
href: v.value,
|
|
27
33
|
rel: v.value ? "noopener noreferrer" : void 0,
|
|
28
34
|
target: v.value ? "_blank" : void 0
|
|
29
35
|
}, {
|
|
30
|
-
default:
|
|
31
|
-
class: "size-3 text-current",
|
|
36
|
+
default: d(() => [i(u(f), {
|
|
37
|
+
class: "size-3 shrink-0 text-current",
|
|
32
38
|
weight: "bold"
|
|
33
|
-
}), _.value.description ? (
|
|
39
|
+
}), _.value.description ? (s(), r("span", h, l(_.value.description), 1)) : (s(), r("span", g, l(_.value.url), 1))]),
|
|
34
40
|
_: 1
|
|
35
41
|
}, 8, [
|
|
36
42
|
"aria-label",
|
|
43
|
+
"class",
|
|
37
44
|
"href",
|
|
38
45
|
"rel",
|
|
39
46
|
"target"
|
|
40
|
-
]))])) : n("", !0);
|
|
47
|
+
]))], 2)) : n("", !0);
|
|
41
48
|
}
|
|
42
49
|
});
|
|
43
50
|
export { _ as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalDocs.vue.js","names":["_openBlock","_createElementBlock","_createBlock","_resolveDynamicComponent","_withCtx","_createVNode","_unref","_toDisplayString","computed","createBlock","createCommentVNode","createElementBlock","createVNode","defineComponent","openBlock","resolveDynamicComponent","toDisplayString","unref","withCtx","ScalarIconBook","getResolvedRef","getDocumentationUrl","_hoisted_1","_hoisted_2","
|
|
1
|
+
{"version":3,"file":"ExternalDocs.vue.js","names":["_openBlock","_createElementBlock","_normalizeClass","_createBlock","_resolveDynamicComponent","_withCtx","_createVNode","_unref","_toDisplayString","computed","createBlock","createCommentVNode","createElementBlock","createVNode","defineComponent","normalizeClass","openBlock","resolveDynamicComponent","toDisplayString","unref","withCtx","ScalarIconBook","getResolvedRef","getDocumentationUrl","_hoisted_1","_hoisted_2","ExternalDocs_vue_vue_type_script_setup_true_lang_default","__props","documentation","resolved","url","_ctx","_cache"],"sources":["../../src/shared/ExternalDocs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconBook } from '@scalar/icons'\nimport { getDocumentationUrl } from '@scalar/workspace-store/helpers/documentation-url'\nimport {\n getResolvedRef,\n type NodeInput,\n} from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { ExternalDocumentationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { value, inline = false } = defineProps<{\n value?: NodeInput<ExternalDocumentationObject>\n /** Use the spacing of the surrounding schema row. */\n inline?: boolean\n}>()\n\nconst documentation = computed<ExternalDocumentationObject | undefined>(() => {\n const resolved = getResolvedRef(value)\n return resolved && typeof resolved.url === 'string' && resolved.url\n ? resolved\n : undefined\n})\n/** Unsafe URL protocols fall back to a plain-text label. */\nconst url = computed<string | undefined>(() =>\n getDocumentationUrl(documentation.value?.url, documentation.value),\n)\n</script>\n\n<template>\n <template v-if=\"documentation\">\n <div\n class=\"group flex items-center\"\n :class=\"\n inline ? 'max-w-full' : 'narrow:border-r-0 border-r last:border-r-0'\n \">\n <component\n :is=\"url ? 'a' : 'span'\"\n :aria-label=\"documentation.description || documentation.url\"\n class=\"text-c-1 hover:bg-b-2 flex min-h-7 min-w-7 items-center rounded-lg px-2 py-1 no-underline\"\n :class=\"inline ? 'wrap-anywhere' : 'narrow:border mr-2 group-last:mr-0'\"\n :href=\"url\"\n :rel=\"url ? 'noopener noreferrer' : undefined\"\n :target=\"url ? '_blank' : undefined\">\n <ScalarIconBook\n class=\"size-3 shrink-0 text-current\"\n weight=\"bold\" />\n <span\n v-if=\"documentation.description\"\n class=\"ml-1 empty:hidden\">\n {{ documentation.description }}\n </span>\n <span\n v-else\n class=\"ml-1 empty:hidden\">\n {{ documentation.url }}\n </span>\n </component>\n </div>\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAgBA,IAAM4B,IAAgBnB,QAAwD;GAC5E,IAAMoB,IAAWP,EAAeK,EAAA,KAAK;GACrC,OAAOE,KAAY,OAAOA,EAAS,OAAQ,YAAYA,EAAS,MAC5DA,IACA,KAAA;EACN,CAAC,GAEKC,IAAMrB,QACVc,EAAoBK,EAAc,OAAO,KAAKA,EAAc,KAAK,CACnE;E,iBAIkBA,EAAA,SACd5B,EAAA,GAAAC,EA2BM,OAAA;;GA1BJ,OAAKC,EAAA,CAAC,2BACWyB,EAAA,SAAM,eAAA,4C;E,KAGvB3B,EAAA,GAAAG,EAqBYC,EApBL0B,EAAA,QAAG,MAAA,MAAA,GAAA;GACP,cAAYF,EAAA,MAAc,eAAeA,EAAA,MAAc;GACxD,OAAK1B,EAAA,CAAC,6FACEyB,EAAA,SAAM,kBAAA,oCAAA,CAAA;GACb,MAAMG,EAAA;GACN,KAAKA,EAAA,QAAG,wBAA2B,KAAA;GACnC,QAAQA,EAAA,QAAG,WAAc,KAAA;;GAC1B,SAAAzB,QAEkB,CAFlBC,EAEkBC,EAAAc,CAAA,GAAA;IADhB,OAAM;IACN,QAAO;G,IAEDO,EAAA,MAAc,eADtB5B,EAAA,GAAAC,EAIO,QAJPuB,GAIOhB,EADFoB,EAAA,MAAc,WAAW,GAAA,CAAA,MAE9B5B,EAAA,GAAAC,EAIO,QAJPwB,GAIOjB,EADFoB,EAAA,MAAc,GAAG,GAAA,CAAA,E"}
|