@scalar/blocks 0.5.3 → 0.6.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.
Files changed (249) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +13 -29
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts +19 -0
  4. package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts.map +1 -0
  5. package/dist/code-example/components/AsyncApiCodeExample.vue.js +9 -0
  6. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -0
  7. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +114 -0
  8. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -0
  9. package/dist/code-example/components/CodeExample.vue.js +4 -4
  10. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  11. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +258 -0
  12. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -0
  13. package/dist/code-example/components/ExamplePicker.vue.js +1 -1
  14. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  15. package/dist/code-example/components/{ExamplePicker.vue.script.js → ExamplePicker.vue_vue_type_script_setup_true_lang.js} +5 -5
  16. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  17. package/dist/code-example/components/HttpMethod.vue.js +1 -1
  18. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  19. package/dist/code-example/components/{HttpMethod.vue.script.js → HttpMethod.vue_vue_type_script_setup_true_lang.js} +1 -1
  20. package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js.map +1 -0
  21. package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
  22. package/dist/code-example/helpers/find-client.js.map +1 -1
  23. package/dist/code-example/helpers/format-language.js.map +1 -1
  24. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  25. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  26. package/dist/code-example/helpers/get-asyncapi-example-context.d.ts +12 -0
  27. package/dist/code-example/helpers/get-asyncapi-example-context.d.ts.map +1 -0
  28. package/dist/code-example/helpers/get-asyncapi-example-context.js +33 -0
  29. package/dist/code-example/helpers/get-asyncapi-example-context.js.map +1 -0
  30. package/dist/code-example/helpers/get-clients.js.map +1 -1
  31. package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
  32. package/dist/code-example/helpers/get-generated-payload-example.d.ts +4 -0
  33. package/dist/code-example/helpers/get-generated-payload-example.d.ts.map +1 -0
  34. package/dist/code-example/helpers/get-generated-payload-example.js +25 -0
  35. package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -0
  36. package/dist/code-example/helpers/get-message-example-content.d.ts +10 -0
  37. package/dist/code-example/helpers/get-message-example-content.d.ts.map +1 -0
  38. package/dist/code-example/helpers/get-message-example-content.js +29 -0
  39. package/dist/code-example/helpers/get-message-example-content.js.map +1 -0
  40. package/dist/code-example/helpers/get-secrets.js.map +1 -1
  41. package/dist/code-example/helpers/get-snippet.js.map +1 -1
  42. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +32 -32
  43. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  44. package/dist/code-example/helpers/operation-to-har/process-body.js +41 -47
  45. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  46. package/dist/code-example/helpers/operation-to-har/process-parameters.js +51 -55
  47. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  48. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +30 -38
  49. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  50. package/dist/code-example/helpers/operation-to-har/process-server-url.js +5 -1
  51. package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
  52. package/dist/code-example/index.d.ts +4 -0
  53. package/dist/code-example/index.d.ts.map +1 -1
  54. package/dist/code-example/index.js +17 -14
  55. package/dist/code-example/mount-asyncapi.d.ts +14 -0
  56. package/dist/code-example/mount-asyncapi.d.ts.map +1 -0
  57. package/dist/code-example/mount-asyncapi.js +27 -0
  58. package/dist/code-example/mount-asyncapi.js.map +1 -0
  59. package/dist/code-example/mount.d.ts +4 -2
  60. package/dist/code-example/mount.d.ts.map +1 -1
  61. package/dist/code-example/mount.js +39 -36
  62. package/dist/code-example/mount.js.map +1 -1
  63. package/dist/constants.js +1 -1
  64. package/dist/constants.js.map +1 -1
  65. package/dist/schema/LinkButton.vue.js.map +1 -1
  66. package/dist/schema/RenderString.vue.js +1 -1
  67. package/dist/schema/RenderString.vue.js.map +1 -1
  68. package/dist/schema/{RenderString.vue.script.js → RenderString.vue_vue_type_script_setup_true_lang.js} +1 -1
  69. package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js.map +1 -0
  70. package/dist/schema/Schema.vue.js +2 -2
  71. package/dist/schema/Schema.vue.js.map +1 -1
  72. package/dist/schema/{Schema.vue.script.js → Schema.vue_vue_type_script_setup_true_lang.js} +1 -1
  73. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -0
  74. package/dist/schema/SchemaCollapsedPreview.vue.js +1 -1
  75. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
  76. package/dist/schema/{SchemaCollapsedPreview.vue.script.js → SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js} +1 -1
  77. package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +1 -0
  78. package/dist/schema/SchemaComposition.vue.js +2 -2
  79. package/dist/schema/SchemaComposition.vue.js.map +1 -1
  80. package/dist/schema/{SchemaComposition.vue.script.js → SchemaComposition.vue_vue_type_script_setup_true_lang.js} +5 -5
  81. package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +1 -0
  82. package/dist/schema/SchemaEnumPropertyItem.vue.js +1 -1
  83. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
  84. package/dist/schema/{SchemaEnumPropertyItem.vue.script.js → SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js} +5 -5
  85. package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +1 -0
  86. package/dist/schema/SchemaEnums.vue.js +2 -2
  87. package/dist/schema/SchemaEnums.vue.js.map +1 -1
  88. package/dist/schema/{SchemaEnums.vue.script.js → SchemaEnums.vue_vue_type_script_setup_true_lang.js} +1 -1
  89. package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +1 -0
  90. package/dist/schema/SchemaGlyphPuck.vue.js +1 -1
  91. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
  92. package/dist/schema/{SchemaGlyphPuck.vue.script.js → SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js} +1 -1
  93. package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js.map +1 -0
  94. package/dist/schema/SchemaGutterToggle.vue.js +1 -1
  95. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
  96. package/dist/schema/{SchemaGutterToggle.vue.script.js → SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js} +1 -1
  97. package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js.map +1 -0
  98. package/dist/schema/SchemaHeading.vue.js +2 -2
  99. package/dist/schema/SchemaHeading.vue.js.map +1 -1
  100. package/dist/schema/{SchemaHeading.vue.script.js → SchemaHeading.vue_vue_type_script_setup_true_lang.js} +6 -6
  101. package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +1 -0
  102. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +1 -1
  103. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  104. package/dist/schema/{SchemaObjectExampleCodeBlock.vue.script.js → SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js} +1 -1
  105. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -0
  106. package/dist/schema/SchemaObjectProperties.vue.js +1 -1
  107. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
  108. package/dist/schema/{SchemaObjectProperties.vue.script.js → SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js} +3 -3
  109. package/dist/schema/{SchemaObjectProperties.vue.script.js.map → SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map} +1 -1
  110. package/dist/schema/SchemaProperty.vue.js +2 -2
  111. package/dist/schema/SchemaProperty.vue.js.map +1 -1
  112. package/dist/schema/{SchemaProperty.vue.script.js → SchemaProperty.vue_vue_type_script_setup_true_lang.js} +14 -18
  113. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -0
  114. package/dist/schema/SchemaPropertyDefault.vue.js +2 -2
  115. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
  116. package/dist/schema/{SchemaPropertyDefault.vue.script.js → SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js} +1 -1
  117. package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +1 -0
  118. package/dist/schema/SchemaPropertyDetail.vue.js +2 -2
  119. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
  120. package/dist/schema/{SchemaPropertyDetail.vue.script.js → SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js} +1 -1
  121. package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +1 -0
  122. package/dist/schema/SchemaPropertyExamples.vue.d.ts +2 -0
  123. package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -1
  124. package/dist/schema/SchemaPropertyExamples.vue.js +3 -3
  125. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  126. package/dist/schema/{SchemaPropertyExamples.vue.script.js → SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js} +10 -3
  127. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -0
  128. package/dist/schema/SchemaPropertyHeading.vue.js +2 -2
  129. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
  130. package/dist/schema/{SchemaPropertyHeading.vue.script.js → SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js} +1 -1
  131. package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -0
  132. package/dist/schema/SchemaPropertyPattern.vue.js +2 -2
  133. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
  134. package/dist/schema/{SchemaPropertyPattern.vue.script.js → SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js} +1 -1
  135. package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js.map +1 -0
  136. package/dist/schema/SchemaRailPanel.vue.js +1 -1
  137. package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
  138. package/dist/schema/{SchemaRailPanel.vue.script.js → SchemaRailPanel.vue_vue_type_script_setup_true_lang.js} +1 -1
  139. package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  140. package/dist/schema/components/CopyLinkButton.vue.js +1 -1
  141. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
  142. package/dist/schema/components/{CopyLinkButton.vue.script.js → CopyLinkButton.vue_vue_type_script_setup_true_lang.js} +1 -1
  143. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  144. package/dist/schema/components/WithBreadcrumb.vue.js +1 -1
  145. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
  146. package/dist/schema/components/{WithBreadcrumb.vue.script.js → WithBreadcrumb.vue_vue_type_script_setup_true_lang.js} +1 -1
  147. package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +1 -0
  148. package/dist/schema/discriminator-metadata.js.map +1 -1
  149. package/dist/schema/expansion/index.js +1 -2
  150. package/dist/schema/helpers/dynamic-scope.js.map +1 -1
  151. package/dist/schema/helpers/format-example.js.map +1 -1
  152. package/dist/schema/helpers/format-value.js.map +1 -1
  153. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
  154. package/dist/schema/helpers/get-discriminator-values.js.map +1 -1
  155. package/dist/schema/helpers/get-enum-values.js.map +1 -1
  156. package/dist/schema/helpers/get-property-description.js.map +1 -1
  157. package/dist/schema/helpers/get-ref-name.js.map +1 -1
  158. package/dist/schema/helpers/get-schema-type.js.map +1 -1
  159. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
  160. package/dist/schema/helpers/has-complex-array-items.js.map +1 -1
  161. package/dist/schema/helpers/is-empty-schema-object.js.map +1 -1
  162. package/dist/schema/helpers/is-model-linkable.js.map +1 -1
  163. package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -1
  164. package/dist/schema/helpers/is-type-object.js.map +1 -1
  165. package/dist/schema/helpers/merge-all-of-schemas.js +24 -25
  166. package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -1
  167. package/dist/schema/helpers/normalize-object-composition.js.map +1 -1
  168. package/dist/schema/helpers/optimize-value-for-display.js +5 -12
  169. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
  170. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
  171. package/dist/schema/helpers/schema-composition.js.map +1 -1
  172. package/dist/schema/helpers/schema-cycle.js.map +1 -1
  173. package/dist/schema/helpers/schema-expansion.js +4 -5
  174. package/dist/schema/helpers/schema-expansion.js.map +1 -1
  175. package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -1
  176. package/dist/schema/helpers/schema-name.js.map +1 -1
  177. package/dist/schema/helpers/should-display-description.js.map +1 -1
  178. package/dist/schema/helpers/should-display-heading.js.map +1 -1
  179. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
  180. package/dist/schema/helpers/sort-property-names.js.map +1 -1
  181. package/dist/schema/helpers/unwrap-for-read.js.map +1 -1
  182. package/dist/schema/index.d.ts +1 -0
  183. package/dist/schema/index.d.ts.map +1 -1
  184. package/dist/schema/index.js +6 -5
  185. package/dist/schema/localization/index.d.ts +1 -1
  186. package/dist/schema/localization/index.js.map +1 -1
  187. package/dist/schema/localization/locales/ar.js.map +1 -1
  188. package/dist/schema/localization/locales/de.js.map +1 -1
  189. package/dist/schema/localization/locales/en.js.map +1 -1
  190. package/dist/schema/localization/locales/es.js.map +1 -1
  191. package/dist/schema/localization/locales/fr.js.map +1 -1
  192. package/dist/schema/localization/locales/pt.js.map +1 -1
  193. package/dist/schema/localization/locales/ru.js.map +1 -1
  194. package/dist/schema/localization/locales/zh-cn.js.map +1 -1
  195. package/dist/schema/localization/locales/zh-tw.js.map +1 -1
  196. package/dist/schema/localization/translations.js.map +1 -1
  197. package/dist/schema/request-body-composition-index.js.map +1 -1
  198. package/dist/shared/Badge.vue.js +2 -2
  199. package/dist/shared/Badge.vue.js.map +1 -1
  200. package/dist/shared/{Badge.vue.script.js → Badge.vue_vue_type_script_setup_true_lang.js} +1 -1
  201. package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -0
  202. package/dist/shared/ExternalDocs.vue.js +1 -1
  203. package/dist/shared/ExternalDocs.vue.js.map +1 -1
  204. package/dist/shared/{ExternalDocs.vue.script.js → ExternalDocs.vue_vue_type_script_setup_true_lang.js} +1 -1
  205. package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +1 -0
  206. package/dist/shared/ScreenReader.vue.js +1 -1
  207. package/dist/shared/ScreenReader.vue.js.map +1 -1
  208. package/dist/shared/{ScreenReader.vue.script.js → ScreenReader.vue_vue_type_script_setup_true_lang.js} +1 -1
  209. package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js.map +1 -0
  210. package/dist/specification-extensions/ExtensionValue.vue.js +1 -1
  211. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
  212. package/dist/specification-extensions/{ExtensionValue.vue.script.js → ExtensionValue.vue_vue_type_script_setup_true_lang.js} +1 -1
  213. package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -0
  214. package/dist/specification-extensions/SpecificationExtensions.vue.js +1 -1
  215. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
  216. package/dist/specification-extensions/{SpecificationExtensions.vue.script.js → SpecificationExtensions.vue_vue_type_script_setup_true_lang.js} +1 -1
  217. package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -0
  218. package/dist/specification-extensions/index.js +1 -2
  219. package/dist/style.css +76 -31
  220. package/dist/vue-styles.css +1 -1
  221. package/package.json +23 -23
  222. package/dist/code-example/components/CodeExample.vue.script.js +0 -258
  223. package/dist/code-example/components/CodeExample.vue.script.js.map +0 -1
  224. package/dist/code-example/components/ExamplePicker.vue.script.js.map +0 -1
  225. package/dist/code-example/components/HttpMethod.vue.script.js.map +0 -1
  226. package/dist/schema/RenderString.vue.script.js.map +0 -1
  227. package/dist/schema/Schema.vue.script.js.map +0 -1
  228. package/dist/schema/SchemaCollapsedPreview.vue.script.js.map +0 -1
  229. package/dist/schema/SchemaComposition.vue.script.js.map +0 -1
  230. package/dist/schema/SchemaEnumPropertyItem.vue.script.js.map +0 -1
  231. package/dist/schema/SchemaEnums.vue.script.js.map +0 -1
  232. package/dist/schema/SchemaGlyphPuck.vue.script.js.map +0 -1
  233. package/dist/schema/SchemaGutterToggle.vue.script.js.map +0 -1
  234. package/dist/schema/SchemaHeading.vue.script.js.map +0 -1
  235. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js.map +0 -1
  236. package/dist/schema/SchemaProperty.vue.script.js.map +0 -1
  237. package/dist/schema/SchemaPropertyDefault.vue.script.js.map +0 -1
  238. package/dist/schema/SchemaPropertyDetail.vue.script.js.map +0 -1
  239. package/dist/schema/SchemaPropertyExamples.vue.script.js.map +0 -1
  240. package/dist/schema/SchemaPropertyHeading.vue.script.js.map +0 -1
  241. package/dist/schema/SchemaPropertyPattern.vue.script.js.map +0 -1
  242. package/dist/schema/SchemaRailPanel.vue.script.js.map +0 -1
  243. package/dist/schema/components/CopyLinkButton.vue.script.js.map +0 -1
  244. package/dist/schema/components/WithBreadcrumb.vue.script.js.map +0 -1
  245. package/dist/shared/Badge.vue.script.js.map +0 -1
  246. package/dist/shared/ExternalDocs.vue.script.js.map +0 -1
  247. package/dist/shared/ScreenReader.vue.script.js.map +0 -1
  248. package/dist/specification-extensions/ExtensionValue.vue.script.js.map +0 -1
  249. package/dist/specification-extensions/SpecificationExtensions.vue.script.js.map +0 -1
@@ -0,0 +1,258 @@
1
+ import e from "./ExamplePicker.vue.js";
2
+ import { filterClientsByQuery as t } from "../helpers/filter-clients-by-query.js";
3
+ import { findClient as n } from "../helpers/find-client.js";
4
+ import { operationToHar as r } from "../helpers/operation-to-har/operation-to-har.js";
5
+ import { generateCodeSnippet as i } from "../helpers/generate-code-snippet.js";
6
+ import { getCustomCodeSamples as a } from "../helpers/get-custom-code-samples.js";
7
+ import { getClients as ee } from "../helpers/get-clients.js";
8
+ import { getSecrets as te } from "../helpers/get-secrets.js";
9
+ import o from "./HttpMethod.vue.js";
10
+ import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createSlots as ne, createTextVNode as p, createVNode as m, defineComponent as h, normalizeClass as re, onBeforeMount as ie, openBlock as g, ref as _, renderSlot as v, toDisplayString as y, unref as b, useId as ae, watch as x, watchEffect as oe, withCtx as S } from "vue";
11
+ import { ScalarCard as C, ScalarCardFooter as se, ScalarCardHeader as ce, ScalarCardSection as w } from "@scalar/components/card";
12
+ import { ScalarCodeBlock as le } from "@scalar/components/code-block";
13
+ import { ScalarButton as T } from "@scalar/components/button";
14
+ import { ScalarIconCaretDown as ue } from "@scalar/icons";
15
+ import { ScalarCombobox as de } from "@scalar/components/combobox";
16
+ import { ScalarVirtualText as fe } from "@scalar/components/virtual-text";
17
+ import { freezeElement as pe } from "@scalar/helpers/dom/freeze-element";
18
+ import { getResolvedRef as E } from "@scalar/workspace-store/helpers/get-resolved-ref";
19
+ import { getOperationExamples as D, resolveOperationExamples as O } from "@scalar/workspace-store/helpers/operation-examples";
20
+ import { useExampleVisibility as k, useExternalExamples as A } from "@scalar/workspace-store/helpers/use-external-examples";
21
+ //#region src/code-example/components/CodeExample.vue?vue&type=script&setup=true&lang.ts
22
+ var j = ["innerHTML"], M = {
23
+ key: 1,
24
+ class: "text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal",
25
+ "data-testid": "client-picker"
26
+ }, N = {
27
+ key: 0,
28
+ class: "text-c-2 p-4",
29
+ role: "status"
30
+ }, P = {
31
+ key: 1,
32
+ class: "text-c-2 p-4",
33
+ role: "status"
34
+ }, F = ["id"], I = {
35
+ key: 0,
36
+ class: "request-card-footer-addon"
37
+ }, L = {
38
+ key: 1,
39
+ class: "request-card-footer-start"
40
+ }, R = { class: "request-header" }, z = /*@__PURE__*/ h({
41
+ __name: "CodeExample",
42
+ props: {
43
+ codeSampleUnavailable: { default: "No code sample available for this example." },
44
+ clientPickerLabel: { default: "Change code sample language" },
45
+ clientSearchLabel: { default: "Search clients" },
46
+ codeSampleLabel: { default: "Code sample" },
47
+ integration: {},
48
+ clientOptions: {},
49
+ selectedClient: {},
50
+ selectedServer: { default: null },
51
+ selectedContentType: {},
52
+ selectedExample: {},
53
+ eventBus: {},
54
+ securitySchemes: { default: () => [] },
55
+ method: {},
56
+ path: {},
57
+ operation: {},
58
+ fallback: { type: Boolean },
59
+ generateLabel: { type: Function },
60
+ isWebhook: { type: Boolean },
61
+ globalCookies: {},
62
+ openapiVersion: {},
63
+ requestBodyCompositionSelection: {}
64
+ },
65
+ emits: ["update:exampleKey"],
66
+ setup(h, { emit: z }) {
67
+ let B = z, V = c(() => {
68
+ let e = E(h.operation.requestBody)?.content ?? {}, t = h.selectedContentType || Object.keys(e)[0];
69
+ return t ? e[t]?.examples ?? {} : {};
70
+ }), H = _(""), U = (e) => {
71
+ let t = Object.keys(V.value);
72
+ return e && t.includes(e) ? e : H.value && t.includes(H.value) ? H.value : t[0] ?? "";
73
+ };
74
+ ie(() => {
75
+ H.value = U(h.selectedExample);
76
+ }), x(() => h.selectedExample, (e) => {
77
+ H.value = U(e);
78
+ }), x(() => h.selectedContentType, () => {
79
+ Object.keys(V.value).includes(H.value) || (H.value = U(h.selectedExample));
80
+ }), oe(() => {
81
+ B("update:exampleKey", H.value);
82
+ });
83
+ let me = (e) => {
84
+ H.value = e, h.eventBus.emit("workspace:update:selected-example", e);
85
+ }, W = c(() => a(h.operation)), G = c(() => ee(W.value.samples, h.clientOptions, W.value.label)), K = c(() => G.value.reduce((e, t) => e + t.options.length, 0)), q = _(n(G.value, h.selectedClient));
86
+ x([() => h.selectedClient, G], ([e]) => {
87
+ let t = n(G.value, e);
88
+ t && (q.value = t);
89
+ });
90
+ let he = c(() => [h.clientPickerLabel, q.value?.title].filter(Boolean).join(": ")), ge = c(() => [h.codeSampleLabel, q.value?.title].filter(Boolean).join(": ")), J = _(null), _e = k(J), Y = A(() => D(h.operation, H.value, h.selectedContentType), () => _e.value), X = c(() => O(h.operation, H.value, h.selectedContentType, Y.resolve)), Z = c(() => Object.keys(V.value).length > 1), Q = c(() => {
91
+ if (!h.isWebhook) return null;
92
+ try {
93
+ return r({
94
+ operation: X.value,
95
+ method: h.method,
96
+ path: h.path,
97
+ example: H.value,
98
+ openapiVersion: h.openapiVersion,
99
+ requestBodyCompositionSelection: h.requestBodyCompositionSelection,
100
+ defaultDisabledParameters: !0
101
+ });
102
+ } catch (e) {
103
+ return console.error("[webhookHar]", e), null;
104
+ }
105
+ }), $ = c(() => h.isWebhook ? Q.value?.postData?.text ?? "" : i({
106
+ defaultDisabledParameters: !0,
107
+ includeDefaultHeaders: h.integration === "client",
108
+ clientId: q.value?.id,
109
+ customCodeSamples: W.value.samples,
110
+ operation: X.value,
111
+ method: h.method,
112
+ path: h.path,
113
+ contentType: h.selectedContentType,
114
+ server: h.selectedServer,
115
+ securitySchemes: h.securitySchemes,
116
+ example: H.value,
117
+ globalCookies: h.globalCookies,
118
+ openapiVersion: h.openapiVersion,
119
+ requestBodyCompositionSelection: h.requestBodyCompositionSelection
120
+ })), ve = c(() => h.isWebhook ? ye.value : q.value?.lang), ye = c(() => {
121
+ if (!Q.value?.postData) return "json";
122
+ let e = Q.value.postData.mimeType;
123
+ return e?.includes("json") ? "json" : e?.includes("xml") ? "xml" : e?.includes("yaml") || e?.includes("yml") ? "yaml" : e?.includes("text/plain") ? "text" : "json";
124
+ }), be = c(() => te(h.securitySchemes)), xe = (e) => {
125
+ if (J.value) {
126
+ let e = pe(J.value.$el);
127
+ setTimeout(() => {
128
+ e();
129
+ }, 300);
130
+ }
131
+ q.value = e, e && h.eventBus.emit("workspace:update:selected-client", e.id);
132
+ }, Se = c(() => ($.value?.length ?? 0) > 2e4), Ce = ae();
133
+ return (n, r) => $.value === null || $.value || b(Y).pending.value ? (g(), l(b(C), {
134
+ key: 0,
135
+ ref_key: "elem",
136
+ ref: J,
137
+ class: "request-card dark-mode"
138
+ }, {
139
+ default: S(() => [
140
+ m(b(ce), { class: "pr-2.5" }, ne({
141
+ default: S(() => [
142
+ r[1] ||= f("span", { class: "sr-only" }, "Request Example for", -1),
143
+ m(o, {
144
+ as: "span",
145
+ class: "request-method",
146
+ method: h.method
147
+ }, null, 8, ["method"]),
148
+ h.generateLabel ? (g(), d("span", {
149
+ key: 0,
150
+ innerHTML: h.generateLabel()
151
+ }, null, 8, j)) : u("", !0),
152
+ v(n.$slots, "header", {}, void 0, !0)
153
+ ]),
154
+ _: 2
155
+ }, [!h.isWebhook && K.value ? {
156
+ name: "actions",
157
+ fn: S(() => [K.value > 1 ? (g(), l(b(de), {
158
+ key: 0,
159
+ class: "max-h-80",
160
+ filterFn: b(t),
161
+ inputLabel: h.clientSearchLabel,
162
+ modelValue: q.value,
163
+ options: G.value,
164
+ placement: "bottom-end",
165
+ teleport: "",
166
+ "onUpdate:modelValue": r[0] ||= (e) => xe(e)
167
+ }, {
168
+ default: S(() => [m(b(T), {
169
+ "aria-label": he.value,
170
+ class: "text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal",
171
+ "data-testid": "client-picker",
172
+ variant: "ghost"
173
+ }, {
174
+ default: S(() => [p(y(q.value?.title) + " ", 1), m(b(ue), {
175
+ class: "ui-open:rotate-180 mt-px size-3 transition-transform duration-100",
176
+ weight: "bold"
177
+ })]),
178
+ _: 1
179
+ }, 8, ["aria-label"])]),
180
+ _: 1
181
+ }, 8, [
182
+ "filterFn",
183
+ "inputLabel",
184
+ "modelValue",
185
+ "options"
186
+ ])) : (g(), d("span", M, y(q.value?.title), 1))]),
187
+ key: "0"
188
+ } : void 0]), 1024),
189
+ m(b(w), { class: "request-editor-section custom-scroll p-0" }, {
190
+ default: S(() => [b(Y).pending.value ? (g(), d("div", N, [b(Y).failed.value ? (g(), d(s, { key: 0 }, [r[3] ||= p(" Could not load this example. ", -1), m(b(T), {
191
+ size: "sm",
192
+ variant: "ghost",
193
+ onClick: b(Y).retry
194
+ }, {
195
+ default: S(() => [...r[2] ||= [p(" Retry ", -1)]]),
196
+ _: 1
197
+ }, 8, ["onClick"])], 64)) : (g(), d(s, { key: 1 }, [p("Loading example…")], 64))])) : $.value === null ? (g(), d("div", P, y(h.codeSampleUnavailable), 1)) : (g(), d("div", {
198
+ key: 2,
199
+ id: `${b(Ce)}-example`,
200
+ class: "code-snippet"
201
+ }, [Se.value ? (g(), l(b(fe), {
202
+ key: 1,
203
+ "aria-label": "Request code sample",
204
+ containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
205
+ contentClass: "language-plaintext whitespace-pre font-code text-base p-2",
206
+ lineHeight: 20,
207
+ role: "region",
208
+ text: $.value
209
+ }, null, 8, ["text"])) : (g(), l(b(le), {
210
+ key: 0,
211
+ class: "bg-b-2 h-full",
212
+ content: $.value,
213
+ hideCredentials: be.value,
214
+ label: ge.value,
215
+ lang: ve.value,
216
+ lineNumbers: ""
217
+ }, null, 8, [
218
+ "content",
219
+ "hideCredentials",
220
+ "label",
221
+ "lang"
222
+ ]))], 8, F))]),
223
+ _: 1
224
+ }),
225
+ Z.value || n.$slots.footer || n.$slots["footer-start"] ? (g(), l(b(se), {
226
+ key: 0,
227
+ class: re(["request-card-footer bg-b-3", { "request-card-footer--wraps": !Z.value && n.$slots["footer-start"] }])
228
+ }, {
229
+ default: S(() => [Z.value ? (g(), d("div", I, [Object.keys(V.value).length ? (g(), l(e, {
230
+ key: 0,
231
+ examples: V.value,
232
+ modelValue: H.value,
233
+ "onUpdate:modelValue": me
234
+ }, null, 8, ["examples", "modelValue"])) : u("", !0)])) : n.$slots["footer-start"] ? (g(), d("div", L, [v(n.$slots, "footer-start", {}, void 0, !0)])) : u("", !0), v(n.$slots, "footer", { exampleName: H.value }, void 0, !0)]),
235
+ _: 3
236
+ }, 8, ["class"])) : u("", !0)
237
+ ]),
238
+ _: 3
239
+ }, 512)) : h.fallback ? (g(), l(b(C), {
240
+ key: 1,
241
+ class: "request-card dark-mode"
242
+ }, {
243
+ default: S(() => [m(b(w), { class: "request-card-simple" }, {
244
+ default: S(() => [f("div", R, [m(o, {
245
+ as: "span",
246
+ class: "request-method",
247
+ method: h.method
248
+ }, null, 8, ["method"]), v(n.$slots, "header", {}, void 0, !0)]), v(n.$slots, "footer", { exampleName: H.value }, void 0, !0)]),
249
+ _: 3
250
+ })]),
251
+ _: 3
252
+ })) : u("", !0);
253
+ }
254
+ });
255
+ //#endregion
256
+ export { z as default };
257
+
258
+ //# sourceMappingURL=CodeExample.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeExample.vue_vue_type_script_setup_true_lang.js","names":["$slots","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createSlots","_createElementVNode","HttpMethod","_createElementBlock","_createCommentVNode","_renderSlot","_createTextVNode","_toDisplayString","_Fragment","_normalizeClass","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","onBeforeMount","watch","watchEffect","selectExample","key","customCodeSamples","getCustomCodeSamples","clients","getClients","clientCount","total","group","localSelectedClient","findClient","newClient","client","clientPickerAriaLabel","codeSampleAriaLabel","elem","visible","useExampleVisibility","externalExamples","useExternalExamples","getOperationExamples","resolvedOperation","resolveOperationExamples","showExamplePicker","webhookHar","operationToHar","error","generatedCode","generateCodeSnippet","codeBlockLanguage","webhookLanguage","secretCredentials","getSecrets","selectClient","unfreeze","freezeElement","option","shouldVirtualize","id","useId","unref","openBlock","createBlock","ScalarCard","withCtx","createVNode","ScalarCardHeader","createSlots","_cache","createElementVNode","createElementBlock","createCommentVNode","renderSlot","_ctx","ScalarCombobox","filterClientsByQuery","$event","ScalarButton","createTextVNode","toDisplayString","ScalarIconCaretDown","ScalarCardSection","Fragment","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter","normalizeClass"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /**\n * Localized purpose of the client picker. It opens the button's accessible name and the\n * selected client's title is appended, so the name still contains the visible label.\n */\n clientPickerLabel?: string\n /** Localized accessible name for the search field inside the client picker. */\n clientSearchLabel?: string\n /**\n * Localized accessible name for the focusable code sample. The selected client's title is\n * appended so the announcement also says which language the sample is in.\n */\n codeSampleLabel?: string\n /**\n * Integration type: determines if the code sample is displayed in a client environment\n * or in an API reference environment.\n */\n integration?: 'client' | 'reference'\n /**\n * List of all http clients formatted into option groups for the client selector\n */\n clientOptions: ClientOptionGroup[]\n /**\n * Pre-selected client, this will determine which client is initially selected in the dropdown.\n * Either a built-in client id (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * Typed as a plain string: unioning the (large) client-id union with the `custom/...`\n * ids overflows TypeScript's union-complexity limit inside this component's `defineProps`.\n *\n * @defaults to a custom sample if one is available, otherwise shell/curl\n */\n selectedClient?: string\n /**\n * Which server from the spec to use for the code example\n */\n selectedServer?: ServerObject | null\n /**\n * The selected content type from the requestBody.content, this will determine which examples are available\n * as well as the content type of the code example\n *\n * @defaults to the first content type if not provided\n */\n selectedContentType?: string\n /**\n * Example name to use for resolving example values for parameters AND requestBody.\n *\n * This is the document-wide selection: it is honored only when this operation defines an example\n * with the same key, so picking an example on one operation syncs the rest without blanking out\n * operations that do not share that key.\n *\n * @example \"limited\"\n * ```ts\n * parameters: {\n * name: 'foobar',\n * in: 'query',\n * examples: {\n * limited: {\n * dataValue: 10,\n * }\n * }\n * },\n * body: {\n * content: {\n * 'application/json': {\n * examples: {\n * limited: {\n * dataValue: { foo: 'bar' },\n * }\n * }\n * }\n * }\n * }\n *\n * ```\n */\n selectedExample?: string\n /**\n * Event bus\n */\n eventBus: WorkspaceEventBus\n /**\n * The security schemes which are applicable to this operation\n */\n securitySchemes: SecuritySchemeObjectSecret[]\n /**\n * HTTP method of the operation\n */\n method: string\n /**\n * Path of the operation\n */\n path: string\n /**\n * De-referenced OpenAPI Operation object\n */\n operation: OperationObject\n /**\n * If true and there's no example, we will display a small card with the method and path only\n */\n fallback?: boolean\n /**\n * A method to generate the label of the block, should return an html string\n */\n generateLabel?: () => string\n /**\n * If true, render this as a webhook request example\n */\n isWebhook?: boolean\n /**\n * Workspace + document cookies\n */\n globalCookies?: XScalarCookie[]\n /**\n * When the request body schema uses oneOf/anyOf, use these selected variants\n * for the example snippet (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getOperationExamples,\n resolveOperationExamples,\n} from '@scalar/workspace-store/helpers/operation-examples'\nimport {\n useExampleVisibility,\n useExternalExamples,\n} from '@scalar/workspace-store/helpers/use-external-examples'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n onBeforeMount,\n ref,\n useId,\n watch,\n watchEffect,\n type ComponentPublicInstance,\n} from 'vue'\n\nimport { filterClientsByQuery } from '../helpers/filter-clients-by-query'\nimport { findClient } from '../helpers/find-client'\nimport { generateCodeSnippet } from '../helpers/generate-code-snippet'\nimport { getClients } from '../helpers/get-clients'\nimport { getCustomCodeSamples } from '../helpers/get-custom-code-samples'\nimport { getSecrets } from '../helpers/get-secrets'\nimport { operationToHar } from '../helpers/operation-to-har/operation-to-har'\nimport type {\n ClientOption,\n ClientOptionGroup,\n CustomClientOption,\n} from '../types'\nimport ExamplePicker from './ExamplePicker.vue'\nimport HttpMethod from './HttpMethod.vue'\n\nconst {\n integration,\n codeSampleUnavailable = 'No code sample available for this example.',\n clientPickerLabel = 'Change code sample language',\n clientSearchLabel = 'Search clients',\n codeSampleLabel = 'Code sample',\n clientOptions,\n selectedClient,\n selectedServer = null,\n selectedContentType,\n selectedExample,\n securitySchemes = [],\n method,\n eventBus,\n path,\n operation,\n isWebhook,\n generateLabel,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n} = defineProps<CodeExampleProps>()\n\nconst emit = defineEmits<{\n /**\n * Emitted whenever the example key actually shown for this operation changes.\n *\n * This is the resolved local key (not the raw document-wide selection), so layouts that render\n * the test-request button outside this component can open the client with the same example the\n * snippet displays.\n */\n (e: 'update:exampleKey', value: string): void\n}>()\n\ndefineSlots<{\n 'header': () => unknown\n /** Rendered at the start of the footer, only while the example picker does not need that space */\n 'footer-start'?: () => unknown\n 'footer': ({ exampleName }: { exampleName: string }) => unknown\n}>()\n\n/** Grab the examples for the given content type */\nconst requestBodyExamples = computed(() => {\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const contentType = selectedContentType || Object.keys(content)[0]\n if (!contentType) return {}\n\n const examples = content[contentType]?.examples ?? {}\n\n return examples\n})\n\n/**\n * The example key actually shown for this operation.\n *\n * `selectedExample` is the document-wide selection that syncs across operations. We honor it only\n * when this operation actually defines that key, otherwise we keep the local example: a selection\n * on one operation should never blank out an operation that does not share the same example.\n */\nconst localExampleKey = ref('')\n\n/** Resolve the key to display, preferring the document-wide selection when this operation has it */\nconst resolveExampleKey = (preferred: string | undefined): string => {\n const keys = Object.keys(requestBodyExamples.value)\n if (preferred && keys.includes(preferred)) {\n return preferred\n }\n // Keep the current local example when it is still valid, otherwise fall back to the first one\n if (localExampleKey.value && keys.includes(localExampleKey.value)) {\n return localExampleKey.value\n }\n return keys[0] ?? ''\n}\n\n// Set the initial example from the document-wide selection, falling back to the first example\nonBeforeMount(() => {\n localExampleKey.value = resolveExampleKey(selectedExample)\n})\n\n// Follow the document-wide selection when it changes and this operation has that example\nwatch(\n () => selectedExample,\n (preferred) => {\n localExampleKey.value = resolveExampleKey(preferred)\n },\n)\n\n/** Reset the selected example key if the content type changes and the new content type doesn't have the previously selected example */\nwatch(\n () => selectedContentType,\n () => {\n if (\n !Object.keys(requestBodyExamples.value).includes(localExampleKey.value)\n ) {\n // Re-resolve so the new content type still follows the document-wide selection when it has\n // that key, instead of always snapping back to the first example\n localExampleKey.value = resolveExampleKey(selectedExample)\n }\n },\n)\n\n// Keep the parent informed of the resolved key so a test-request button rendered outside this\n// component (e.g. the classic layout header) opens the client with the example the snippet shows\nwatchEffect(() => {\n emit('update:exampleKey', localExampleKey.value)\n})\n\n/** Select an example locally and sync the choice across the document */\nconst selectExample = (key: string) => {\n localExampleKey.value = key\n eventBus.emit('workspace:update:selected-example', key)\n}\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/** Total number of available clients across all option groups */\nconst clientCount = computed(() =>\n clients.value.reduce((total, group) => total + group.options.length, 0),\n)\n\n/** The locally selected client which would include code samples from this operation only */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/**\n * Accessible name for the client picker.\n *\n * On its own the button reads as its current value (\"C Libcurl\"), which never\n * says what activating it does. The visible title stays part of the name so it\n * still matches what is on screen.\n */\nconst clientPickerAriaLabel = computed(() =>\n [clientPickerLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\n/**\n * Accessible name for the focusable code sample, e.g. \"Code sample: Shell cURL\".\n *\n * Screen readers announce only the name and role when focus lands on the scroller, so the\n * name tells the user both what the region is and which client it is generated for.\n */\nconst codeSampleAriaLabel = computed(() =>\n [codeSampleLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\nconst elem = ref<ComponentPublicInstance | null>(null)\nconst visible = useExampleVisibility(elem)\nconst externalExamples = useExternalExamples(\n () =>\n getOperationExamples(operation, localExampleKey.value, selectedContentType),\n () => visible.value,\n)\nconst resolvedOperation = computed(() =>\n resolveOperationExamples(\n operation,\n localExampleKey.value,\n selectedContentType,\n externalExamples.resolve,\n ),\n)\n\n/** Keep the picker available because it also selects the example opened by Test Request. */\nconst showExamplePicker = computed(\n () => Object.keys(requestBodyExamples.value).length > 1,\n)\n\n/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation: resolvedOperation.value,\n method,\n path,\n example: localExampleKey.value,\n openapiVersion,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string | null>(() => {\n if (isWebhook) {\n return webhookHar.value?.postData?.text ?? ''\n }\n\n return generateCodeSnippet({\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n includeDefaultHeaders: integration === 'client',\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation: resolvedOperation.value,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n })\n})\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes))\n\n/** Set custom example, or update the selected HTTP client globally */\nconst selectClient = (option: ClientOption) => {\n // We need to freeze the ui to prevent scrolling as the clients change\n if (elem.value) {\n const unfreeze = freezeElement(elem.value.$el)\n setTimeout(() => {\n unfreeze()\n }, 300)\n }\n // Update to the local example\n localSelectedClient.value = option\n\n // Sync the selection globally so other operations follow along. Custom samples\n // sync too (keyed by language), so picking e.g. the Python SDK example here\n // shows the Python example on every operation that ships one.\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n// Virtualize the code block if it's too large\n// This prevents the entire app from freezing up if there's a massive example\n// We set a lower threshold here as code examples can get quite large\nconst VIRTUALIZATION_THRESHOLD = 20_000\n\nconst shouldVirtualize = computed(\n () => (generatedCode.value?.length ?? 0) > VIRTUALIZATION_THRESHOLD,\n)\n\nconst id = useId()\n</script>\n<template>\n <ScalarCard\n v-if=\"\n generatedCode === null || generatedCode || externalExamples.pending.value\n \"\n ref=\"elem\"\n class=\"request-card dark-mode\">\n <!-- Header -->\n <ScalarCardHeader class=\"pr-2.5\">\n <span class=\"sr-only\">Request Example for</span>\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <span\n v-if=\"generateLabel\"\n v-html=\"generateLabel()\" />\n <slot name=\"header\" />\n <!-- Client picker -->\n <template\n v-if=\"!isWebhook && clientCount\"\n #actions>\n <!-- Multiple clients: render a dropdown to switch between them -->\n <ScalarCombobox\n v-if=\"clientCount > 1\"\n class=\"max-h-80\"\n :filterFn=\"filterClientsByQuery\"\n :inputLabel=\"clientSearchLabel\"\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\n :aria-label=\"clientPickerAriaLabel\"\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-px size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarCombobox>\n <!-- Single client: just show its label, no need for a dropdown -->\n <span\n v-else\n class=\"text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\">\n {{ localSelectedClient?.title }}\n </span>\n </template>\n </ScalarCardHeader>\n\n <!-- Code snippet -->\n <ScalarCardSection class=\"request-editor-section custom-scroll p-0\">\n <div\n v-if=\"externalExamples.pending.value\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamples.failed.value\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"externalExamples.retry\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n <div\n v-else-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ codeSampleUnavailable }}\n </div>\n <div\n v-else\n :id=\"`${id}-example`\"\n class=\"code-snippet\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"bg-b-2 h-full\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <ScalarVirtualText\n v-else\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"20\"\n role=\"region\"\n :text=\"generatedCode\" />\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer bg-b-3\"\n :class=\"{\n 'request-card-footer--wraps':\n !showExamplePicker && $slots['footer-start'],\n }\">\n <!-- Example picker -->\n <div\n v-if=\"showExamplePicker\"\n class=\"request-card-footer-addon\">\n <template v-if=\"Object.keys(requestBodyExamples).length\">\n <ExamplePicker\n :examples=\"requestBodyExamples\"\n :modelValue=\"localExampleKey\"\n @update:modelValue=\"selectExample\" />\n </template>\n </div>\n <!-- Otherwise the start of the footer is free for the caller -->\n <div\n v-else-if=\"$slots['footer-start']\"\n class=\"request-card-footer-start\">\n <slot name=\"footer-start\" />\n </div>\n\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <ScalarCardSection class=\"request-card-simple\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n margin-right: 6px;\n}\n.request-card-footer {\n display: flex;\n justify-content: flex-end;\n padding: 6px;\n flex-shrink: 0;\n position: relative;\n}\n/*\n * Footer-start content keeps its full width; when the footer is too narrow for everything,\n * the end controls wrap onto a second line instead of squeezing or covering it.\n */\n.request-card-footer--wraps {\n flex-wrap: wrap;\n row-gap: 4px;\n}\n.request-card-footer-start {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n}\n.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1;\n min-width: 0;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n.request-card-simple {\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import e from "./ExamplePicker.vue.script.js";
1
+ import e from "./ExamplePicker.vue_vue_type_script_setup_true_lang.js";
2
2
  //#region src/code-example/components/ExamplePicker.vue
3
3
  var t = e;
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ExamplePicker.vue.js","names":[],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: example?.summary ?? key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"ExamplePicker.vue.js","names":["_sfc_main","ExamplePicker_vue_vue_type_script_setup_true_lang_default","ExamplePicker_default"],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: example?.summary ?? key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import { computed as e, createBlock as t, createElementVNode as n, createVNode as r, defineComponent as i, mergeModels as a, mergeProps as o, openBlock as s, toDisplayString as c, unref as l, useModel as u, withCtx as d } from "vue";
2
2
  import { ScalarButton as f } from "@scalar/components/button";
3
- import { ScalarIconCaretDown as p } from "@scalar/icons";
4
- import { ScalarListbox as m } from "@scalar/components/listbox";
3
+ import { ScalarListbox as p } from "@scalar/components/listbox";
4
+ import { ScalarIconCaretDown as m } from "@scalar/icons";
5
5
  //#region src/code-example/components/ExamplePicker.vue?vue&type=script&setup=true&lang.ts
6
6
  var h = { class: "min-w-0 flex-1 truncate" }, g = /*@__PURE__*/ i({
7
7
  inheritAttrs: !1,
@@ -19,7 +19,7 @@ var h = { class: "min-w-0 flex-1 truncate" }, g = /*@__PURE__*/ i({
19
19
  get: () => g.value.find(({ id: e }) => e === a.value),
20
20
  set: (e) => a.value = e?.id ?? ""
21
21
  });
22
- return (e, i) => (s(), t(l(m), {
22
+ return (e, i) => (s(), t(l(p), {
23
23
  modelValue: _.value,
24
24
  "onUpdate:modelValue": i[0] ||= (e) => _.value = e,
25
25
  class: "w-fit min-w-32",
@@ -32,7 +32,7 @@ var h = { class: "min-w-0 flex-1 truncate" }, g = /*@__PURE__*/ i({
32
32
  "data-testid": "example-picker",
33
33
  variant: "ghost"
34
34
  }, e.$attrs), {
35
- default: d(() => [n("div", h, c(_.value?.label ?? "Select an example"), 1), r(l(p), {
35
+ default: d(() => [n("div", h, c(_.value?.label ?? "Select an example"), 1), r(l(m), {
36
36
  class: "ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100",
37
37
  weight: "bold"
38
38
  })]),
@@ -45,4 +45,4 @@ var h = { class: "min-w-0 flex-1 truncate" }, g = /*@__PURE__*/ i({
45
45
  //#endregion
46
46
  export { g as default };
47
47
 
48
- //# sourceMappingURL=ExamplePicker.vue.script.js.map
48
+ //# sourceMappingURL=ExamplePicker.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExamplePicker.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_mergeProps","_createElementVNode","_toDisplayString","_hoisted_1","ExamplePicker_vue_vue_type_script_setup_true_lang_default","\"modelValue\"","\"modelModifiers\"","selectedExampleKey","useModel","__props","exampleOptions","computed","key","example","selectedExample","id","v","openBlock","createBlock","unref","ScalarListbox","_cache","$event","withCtx","createVNode","ScalarButton","mergeProps","_ctx","createElementVNode","toDisplayString","ScalarIconCaretDown"],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: example?.summary ?? key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAcA,IAAMc,IAAqBb,EAAmBe,GAAA,YAE7C,GAIKC,IAAiBC,QACrB,OAAO,QAAQF,EAAA,QAAQ,CAAC,CAAC,KAAK,CAACG,GAAKC,QAAc;GAChD,IAAID;GACJ,OAAOC,GAAS,WAAWD;EAC7B,EAAE,CACJ,GAEME,IAAkBH,EAA0C;GAChE,WACED,EAAe,MAAM,MAAM,EAAE,YAASK,MAAOR,EAAmB,KAAK;GACvE,MAAM,MAAO,EAAmB,QAAQS,GAAG,MAAM;EACnD,CAAC;E,kBAICrB,EAAA,GAAAC,EAkBgBC,EAAAuB,CAAA,GAAA;GAjBL,YAAAN,EAAA;GAAA,uBAAA,AAAAO,EAAA,QAAA,MAAA,EAAe,QAAAC;GACxB,OAAM;GACL,SAASZ,EAAA;GACV,WAAU;GACV,UAAA;;GACA,SAAAZ,QAWe,CAXfC,EAWeF,EAAA4B,CAAA,GAXfzB,EAWe;IAVb,OAAM;IACN,eAAY;IACZ,SAAQ;GACAP,GAAAA,EAAAA,MAAM,GAAA;IACd,SAAAK,QAEM,CAFNG,EAEM,OAFNE,GAEMD,EADDY,EAAA,OAAiB,SAAK,mBAAA,GAAA,CAAA,GAE3Bf,EAEkBF,EAAAiC,CAAA,GAAA;KADhB,OAAM;KACN,QAAO"}
@@ -1,4 +1,4 @@
1
- import e from "./HttpMethod.vue.script.js";
1
+ import e from "./HttpMethod.vue_vue_type_script_setup_true_lang.js";
2
2
  //#region src/code-example/components/HttpMethod.vue
3
3
  var t = e;
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"HttpMethod.vue.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"HttpMethod.vue.js","names":["_sfc_main","HttpMethod_vue_vue_type_script_setup_true_lang_default","HttpMethod_default"],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":""}
@@ -28,4 +28,4 @@ var m = /*@__PURE__*/ r({
28
28
  //#endregion
29
29
  export { m as default };
30
30
 
31
- //# sourceMappingURL=HttpMethod.vue.script.js.map
31
+ //# sourceMappingURL=HttpMethod.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpMethod.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_unref","_normalizeStyle","_withCtx","_renderSlot","_createTextVNode","_toDisplayString","HttpMethod_vue_vue_type_script_setup_true_lang_default","props","__props","httpMethodInfo","computed","getHttpMethodInfo","normalized","method","isHttpMethod","openBlock","createBlock","resolveDynamicComponent","normalizeClass","unref","normalizeStyle","withCtx","renderSlot","_ctx","createTextVNode","toDisplayString"],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAKA,IAAMW,IAAQC,GAYRC,IAAiBC,QACrBC,EAAkB,OAAOJ,EAAM,UAAU,EAAE,CAAC,CAC9C,GAGMK,IAAaF,QAAe;GAChC,IAAI,OAAOH,EAAM,UAAW,YAAY,CAACA,EAAM,OAAO,KAAK,GACzD,OAAO;GAET,IAAMM,IAASN,EAAM,OAAO,KAAK;GACjC,OAAOO,EAAaD,EAAO,YAAY,CAAC,IAAIA,EAAO,YAAY,IAAIA;EACrE,CAAC;E,kBAICjB,EAAA,GAAAC,EAMYC,EALLU,EAAA,MAAE,MAAA,GAAA;GACN,OAAKT,EAAA,EAAA,WAAeC,EAAAc,CAAA,CAAY,CAACF,EAAA,KAAU,EAAA,CAAA;GAC3C,OAAKX,EAAA,GAAKO,EAAA,YAAQ,UAAcC,EAAA,MAAe,SAAQ,CAAA;;GACxD,SAAAP,QAAQ,CAARC,EAAQoB,EAAA,QAAA,SAAA,GAAAnB,EAAA,MACRC,EAAGG,EAAA,QAAQC,EAAA,MAAe,QAAQG,EAAA,KAAU,GAAA,CAAA,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter-clients-by-query.js","names":[],"sources":["../../../src/code-example/helpers/filter-clients-by-query.ts"],"sourcesContent":["import type { ScalarComboboxFilterFunction } from '@scalar/components/combobox'\n\nimport type { CustomClientOptionGroup, CustomOrDefaultClientOption } from '../types'\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesOption = (option: CustomOrDefaultClientOption, query: string) => {\n const q = query.toLowerCase()\n return (\n option.label.toLowerCase().includes(q) ||\n option.clientKey.toLowerCase().includes(q) ||\n option.lang.toLowerCase().includes(q)\n )\n}\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesGroup = (group: CustomClientOptionGroup, query: string) => {\n const q = query.toLowerCase()\n return group.label.toLowerCase().includes(q) || group.key.toLowerCase().includes(q)\n}\n\n/**\n * Filters the clients based on a query\n *\n * When dealing with multiple groups, include all options from a group if the\n * group label itself matches — so searching \"JavaScript\" shows all JS clients.\n */\nexport const filterClientsByQuery = ((\n query: string,\n options: CustomOrDefaultClientOption[],\n groups: CustomClientOptionGroup[],\n): CustomOrDefaultClientOption[] => {\n if (query === '') {\n return options\n }\n\n const q = query.toLowerCase()\n\n // Only activate when more than one group is actually visible (has a label and options).\n const visibleGroupCount = groups ? groups.filter((g) => g.label && g.options.length > 0).length : 0\n\n if (groups && visibleGroupCount > 1) {\n const result: CustomOrDefaultClientOption[] = []\n for (const group of groups) {\n if (matchesGroup(group, q)) {\n result.push(...group.options)\n } else {\n result.push(...group.options.filter((o) => matchesOption(o, q)))\n }\n }\n return result\n }\n\n return options.filter((o) => matchesOption(o, q))\n}) satisfies ScalarComboboxFilterFunction<CustomOrDefaultClientOption, CustomClientOptionGroup>\n"],"mappings":";AAOA,IAAM,KAAiB,GAAqC,MAAkB;CAC5E,IAAM,IAAI,EAAM,YAAY;CAC5B,OACE,EAAO,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,KACrC,EAAO,UAAU,YAAY,CAAC,CAAC,SAAS,CAAC,KACzC,EAAO,KAAK,YAAY,CAAC,CAAC,SAAS,CAAC;AAExC,GAKM,KAAgB,GAAgC,MAAkB;CACtE,IAAM,IAAI,EAAM,YAAY;CAC5B,OAAO,EAAM,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,KAAK,EAAM,IAAI,YAAY,CAAC,CAAC,SAAS,CAAC;AACpF,GAQa,MACX,GACA,GACA,MACkC;CAClC,IAAI,MAAU,IACZ,OAAO;CAGT,IAAM,IAAI,EAAM,YAAY,GAGtB,IAAoB,IAAS,EAAO,QAAQ,MAAM,EAAE,SAAS,EAAE,QAAQ,SAAS,CAAC,CAAC,CAAC,SAAS;CAElG,IAAI,KAAU,IAAoB,GAAG;EACnC,IAAM,IAAwC,CAAC;EAC/C,KAAK,IAAM,KAAS,GAClB,AAAI,EAAa,GAAO,CAAC,IACvB,EAAO,KAAK,GAAG,EAAM,OAAO,IAE5B,EAAO,KAAK,GAAG,EAAM,QAAQ,QAAQ,MAAM,EAAc,GAAG,CAAC,CAAC,CAAC;EAGnE,OAAO;CACT;CAEA,OAAO,EAAQ,QAAQ,MAAM,EAAc,GAAG,CAAC,CAAC;AAClD"}
1
+ {"version":3,"file":"filter-clients-by-query.js","names":["matchesOption","q","query","option","matchesGroup","group","filterClientsByQuery","options","visibleGroupCount","groups","g","result","o"],"sources":["../../../src/code-example/helpers/filter-clients-by-query.ts"],"sourcesContent":["import type { ScalarComboboxFilterFunction } from '@scalar/components/combobox'\n\nimport type { CustomClientOptionGroup, CustomOrDefaultClientOption } from '../types'\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesOption = (option: CustomOrDefaultClientOption, query: string) => {\n const q = query.toLowerCase()\n return (\n option.label.toLowerCase().includes(q) ||\n option.clientKey.toLowerCase().includes(q) ||\n option.lang.toLowerCase().includes(q)\n )\n}\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesGroup = (group: CustomClientOptionGroup, query: string) => {\n const q = query.toLowerCase()\n return group.label.toLowerCase().includes(q) || group.key.toLowerCase().includes(q)\n}\n\n/**\n * Filters the clients based on a query\n *\n * When dealing with multiple groups, include all options from a group if the\n * group label itself matches — so searching \"JavaScript\" shows all JS clients.\n */\nexport const filterClientsByQuery = ((\n query: string,\n options: CustomOrDefaultClientOption[],\n groups: CustomClientOptionGroup[],\n): CustomOrDefaultClientOption[] => {\n if (query === '') {\n return options\n }\n\n const q = query.toLowerCase()\n\n // Only activate when more than one group is actually visible (has a label and options).\n const visibleGroupCount = groups ? groups.filter((g) => g.label && g.options.length > 0).length : 0\n\n if (groups && visibleGroupCount > 1) {\n const result: CustomOrDefaultClientOption[] = []\n for (const group of groups) {\n if (matchesGroup(group, q)) {\n result.push(...group.options)\n } else {\n result.push(...group.options.filter((o) => matchesOption(o, q)))\n }\n }\n return result\n }\n\n return options.filter((o) => matchesOption(o, q))\n}) satisfies ScalarComboboxFilterFunction<CustomOrDefaultClientOption, CustomClientOptionGroup>\n"],"mappings":";AAOA,IAAMA,KAAiB,GAAqC,MAAkB;CAC5E,IAAMC,IAAIC,EAAM,YAAY;CAC5B,OACEC,EAAO,MAAM,YAAY,CAAC,CAAC,SAASF,CAAC,KACrCE,EAAO,UAAU,YAAY,CAAC,CAAC,SAASF,CAAC,KACzCE,EAAO,KAAK,YAAY,CAAC,CAAC,SAASF,CAAC;AAExC,GAKMG,KAAgB,GAAgC,MAAkB;CACtE,IAAMH,IAAIC,EAAM,YAAY;CAC5B,OAAOG,EAAM,MAAM,YAAY,CAAC,CAAC,SAASJ,CAAC,KAAKI,EAAM,IAAI,YAAY,CAAC,CAAC,SAASJ,CAAC;AACpF,GAQaK,MACX,GACA,GACA,MACkC;CAClC,IAAIJ,MAAU,IACZ,OAAOK;CAGT,IAAMN,IAAIC,EAAM,YAAY,GAGtBM,IAAoBC,IAASA,EAAO,QAAQ,MAAMC,EAAE,SAASA,EAAE,QAAQ,SAAS,CAAC,CAAC,CAAC,SAAS;CAElG,IAAID,KAAUD,IAAoB,GAAG;EACnC,IAAMG,IAAwC,CAAC;EAC/C,KAAK,IAAMN,KAASI,GAClB,AAAIL,EAAaC,GAAOJ,CAAC,IACvBU,EAAO,KAAK,GAAGN,EAAM,OAAO,IAE5BM,EAAO,KAAK,GAAGN,EAAM,QAAQ,QAAQ,MAAML,EAAcY,GAAGX,CAAC,CAAC,CAAC;EAGnE,OAAOU;CACT;CAEA,OAAOJ,EAAQ,QAAQ,MAAMP,EAAcY,GAAGX,CAAC,CAAC;AAClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"find-client.js","names":[],"sources":["../../../src/code-example/helpers/find-client.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/snippetz'\n\nimport type { ClientOption, CustomClientOption, CustomClientOptionGroup } from '../types'\n\nexport const DEFAULT_CLIENT = 'shell/curl'\n\n/**\n * A selection the code sample picker understands: either a built-in client id\n * (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * The custom part is typed as `string & {}` rather than the `custom/${string}`\n * template literal: unioning that template literal with the (very large) built-in\n * client-id union trips TypeScript's \"union too complex\" limit inside Vue's\n * `defineProps` macro. `string & {}` keeps editor hints for the known client ids\n * without expanding the union.\n */\nexport type SelectedClientId = AvailableClients[number] | (string & {})\n\n/** Type guard to check if a string is a valid built-in client id */\nexport const isClient = (id: any): id is AvailableClients[number] => AVAILABLE_CLIENTS.includes(id)\n\n/** Type guard for any selection the picker can restore (built-in client or custom sample id) */\nexport const isSelectedClient = (id: any): id is SelectedClientId =>\n isClient(id) || (typeof id === 'string' && id.startsWith('custom/'))\n\n/**\n * Finds and returns the appropriate client option to select for an operation.\n *\n * Selection rules, given the globally selected client/sample id:\n *\n * 1. A custom sample is selected (`custom/<lang>`): show the matching sample on\n * this operation. If this operation has no sample for that exact language, we\n * keep showing a custom sample (its first one) so the selection stays \"global\".\n * 2. An explicit built-in client is selected: it wins, even when the operation\n * also has custom samples. This includes the default client (`shell/curl`):\n * a built-in id only reaches us through a real selection (config, persistence,\n * or the picker), never as an implicit default, so a deliberate cURL pick must\n * stick instead of snapping back to an SDK example.\n * 3. Otherwise (nothing selected yet): prefer a custom sample when the operation\n * has one, so custom examples are the default.\n * 4. Fall back to the default built-in client, then the first option.\n *\n * @param clientGroups - Array of client option groups, each containing a label and array of client options\n * @param clientId - Optional selection to restore (e.g. 'js/fetch' or 'custom/python')\n * @returns The selected client option, or undefined when there is nothing to select\n */\nexport const findClient = (\n clientGroups: CustomClientOptionGroup[],\n clientId?: SelectedClientId | undefined,\n): ClientOption | CustomClientOption | undefined => {\n const findById = (id: string) => {\n for (const group of clientGroups) {\n const option = group.options.find((option) => option.id === id)\n if (option) {\n return option\n }\n }\n return undefined\n }\n\n const firstCustom = clientGroups.find((group) => group.key === 'custom')?.options[0]\n\n // 1. A custom sample is selected: match the language, otherwise stay on a custom sample\n if (clientId?.startsWith('custom')) {\n return findById(clientId) ?? firstCustom ?? findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n }\n\n // 2. An explicit built-in client wins, even when custom samples exist. A built-in\n // id (including the default `shell/curl`) only reaches us through a real\n // selection, so it must stick rather than snap back to a custom sample.\n if (clientId) {\n const option = findById(clientId)\n if (option) {\n return option\n }\n }\n\n // 3. Nothing selected yet: prefer a custom sample when the operation has one\n if (firstCustom) {\n return firstCustom\n }\n\n // 4. Otherwise fall back to the default built-in client, then the first option\n return findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n}\n"],"mappings":";;AAIA,IAAa,IAAiB,cAejB,KAAY,MAA4C,EAAkB,SAAS,CAAE,GAGrF,KAAoB,MAC/B,EAAS,CAAE,KAAM,OAAO,KAAO,YAAY,EAAG,WAAW,SAAS,GAuBvD,KACX,GACA,MACkD;CAClD,IAAM,KAAY,MAAe;EAC/B,KAAK,IAAM,KAAS,GAAc;GAChC,IAAM,IAAS,EAAM,QAAQ,MAAM,MAAW,EAAO,OAAO,CAAE;GAC9D,IAAI,GACF,OAAO;EAEX;CAEF,GAEM,IAAc,EAAa,MAAM,MAAU,EAAM,QAAQ,QAAQ,CAAC,EAAE,QAAQ;CAGlF,IAAI,GAAU,WAAW,QAAQ,GAC/B,OAAO,EAAS,CAAQ,KAAK,KAAe,EAAA,YAAuB,KAAK,EAAa,EAAE,EAAE,QAAQ;CAMnG,IAAI,GAAU;EACZ,IAAM,IAAS,EAAS,CAAQ;EAChC,IAAI,GACF,OAAO;CAEX;CAQA,OALI,MAKG,EAAA,YAAuB,KAAK,EAAa,EAAE,EAAE,QAAQ;AAC9D"}
1
+ {"version":3,"file":"find-client.js","names":["DEFAULT_CLIENT","isClient","AVAILABLE_CLIENTS","id","isSelectedClient","findClient","findById","group","clientGroups","option","firstCustom","clientId"],"sources":["../../../src/code-example/helpers/find-client.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/snippetz'\n\nimport type { ClientOption, CustomClientOption, CustomClientOptionGroup } from '../types'\n\nexport const DEFAULT_CLIENT = 'shell/curl'\n\n/**\n * A selection the code sample picker understands: either a built-in client id\n * (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * The custom part is typed as `string & {}` rather than the `custom/${string}`\n * template literal: unioning that template literal with the (very large) built-in\n * client-id union trips TypeScript's \"union too complex\" limit inside Vue's\n * `defineProps` macro. `string & {}` keeps editor hints for the known client ids\n * without expanding the union.\n */\nexport type SelectedClientId = AvailableClients[number] | (string & {})\n\n/** Type guard to check if a string is a valid built-in client id */\nexport const isClient = (id: any): id is AvailableClients[number] => AVAILABLE_CLIENTS.includes(id)\n\n/** Type guard for any selection the picker can restore (built-in client or custom sample id) */\nexport const isSelectedClient = (id: any): id is SelectedClientId =>\n isClient(id) || (typeof id === 'string' && id.startsWith('custom/'))\n\n/**\n * Finds and returns the appropriate client option to select for an operation.\n *\n * Selection rules, given the globally selected client/sample id:\n *\n * 1. A custom sample is selected (`custom/<lang>`): show the matching sample on\n * this operation. If this operation has no sample for that exact language, we\n * keep showing a custom sample (its first one) so the selection stays \"global\".\n * 2. An explicit built-in client is selected: it wins, even when the operation\n * also has custom samples. This includes the default client (`shell/curl`):\n * a built-in id only reaches us through a real selection (config, persistence,\n * or the picker), never as an implicit default, so a deliberate cURL pick must\n * stick instead of snapping back to an SDK example.\n * 3. Otherwise (nothing selected yet): prefer a custom sample when the operation\n * has one, so custom examples are the default.\n * 4. Fall back to the default built-in client, then the first option.\n *\n * @param clientGroups - Array of client option groups, each containing a label and array of client options\n * @param clientId - Optional selection to restore (e.g. 'js/fetch' or 'custom/python')\n * @returns The selected client option, or undefined when there is nothing to select\n */\nexport const findClient = (\n clientGroups: CustomClientOptionGroup[],\n clientId?: SelectedClientId | undefined,\n): ClientOption | CustomClientOption | undefined => {\n const findById = (id: string) => {\n for (const group of clientGroups) {\n const option = group.options.find((option) => option.id === id)\n if (option) {\n return option\n }\n }\n return undefined\n }\n\n const firstCustom = clientGroups.find((group) => group.key === 'custom')?.options[0]\n\n // 1. A custom sample is selected: match the language, otherwise stay on a custom sample\n if (clientId?.startsWith('custom')) {\n return findById(clientId) ?? firstCustom ?? findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n }\n\n // 2. An explicit built-in client wins, even when custom samples exist. A built-in\n // id (including the default `shell/curl`) only reaches us through a real\n // selection, so it must stick rather than snap back to a custom sample.\n if (clientId) {\n const option = findById(clientId)\n if (option) {\n return option\n }\n }\n\n // 3. Nothing selected yet: prefer a custom sample when the operation has one\n if (firstCustom) {\n return firstCustom\n }\n\n // 4. Otherwise fall back to the default built-in client, then the first option\n return findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n}\n"],"mappings":";;AAIA,IAAaA,IAAiB,cAejBC,KAAY,MAA4CC,EAAkB,SAASC,CAAE,GAGrFC,KAAoB,MAC/BH,EAASE,CAAE,KAAM,OAAOA,KAAO,YAAYA,EAAG,WAAW,SAAS,GAuBvDE,KACX,GACA,MACkD;CAClD,IAAMC,KAAY,MAAe;EAC/B,KAAK,IAAMC,KAASC,GAAc;GAChC,IAAMC,IAASF,EAAM,QAAQ,MAAM,MAAWE,EAAO,OAAON,CAAE;GAC9D,IAAIM,GACF,OAAOA;EAEX;CAEF,GAEMC,IAAcF,EAAa,MAAM,MAAUD,EAAM,QAAQ,QAAQ,CAAC,EAAE,QAAQ;CAGlF,IAAII,GAAU,WAAW,QAAQ,GAC/B,OAAOL,EAASK,CAAQ,KAAKD,KAAeJ,EAAA,YAAuB,KAAKE,EAAa,EAAE,EAAE,QAAQ;CAMnG,IAAIG,GAAU;EACZ,IAAMF,IAASH,EAASK,CAAQ;EAChC,IAAIF,GACF,OAAOA;CAEX;CAQA,OALIC,MAKGJ,EAAA,YAAuB,KAAKE,EAAa,EAAE,EAAE,QAAQ;AAC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-language.js","names":[],"sources":["../../../src/code-example/helpers/format-language.ts"],"sourcesContent":["import { capitalize } from '@scalar/helpers/string/capitalize'\n\n/**\n * Display names for the most common languages found in custom code samples.\n *\n * Custom samples (`x-scalar-examples`, `x-readme`, `x-stainless-*`, …) carry a\n * free-form `lang` string that we otherwise show verbatim in the picker. This\n * map gives the common ones a properly cased label (e.g. `typescript` →\n * `TypeScript`). Anything not listed falls back to a simple capitalization.\n */\nconst LANGUAGE_LABELS: Record<string, string> = {\n c: 'C',\n clojure: 'Clojure',\n cpp: 'C++',\n 'c++': 'C++',\n csharp: 'C#',\n 'c#': 'C#',\n css: 'CSS',\n curl: 'cURL',\n dart: 'Dart',\n fsharp: 'F#',\n 'f#': 'F#',\n go: 'Go',\n golang: 'Go',\n graphql: 'GraphQL',\n html: 'HTML',\n http: 'HTTP',\n java: 'Java',\n javascript: 'JavaScript',\n js: 'JavaScript',\n json: 'JSON',\n jl: 'Julia',\n julia: 'Julia',\n kotlin: 'Kotlin',\n node: 'Node.js',\n nodejs: 'Node.js',\n objc: 'Objective-C',\n 'objective-c': 'Objective-C',\n ocaml: 'OCaml',\n php: 'PHP',\n powershell: 'PowerShell',\n py: 'Python',\n python: 'Python',\n r: 'R',\n ruby: 'Ruby',\n rust: 'Rust',\n scala: 'Scala',\n sh: 'Shell',\n shell: 'Shell',\n bash: 'Shell',\n sql: 'SQL',\n swift: 'Swift',\n ts: 'TypeScript',\n typescript: 'TypeScript',\n xml: 'XML',\n yaml: 'YAML',\n yml: 'YAML',\n}\n\n/**\n * Turn a free-form language identifier into a display label for the code sample picker.\n *\n * @param lang - The language identifier from a custom code sample (e.g. `typescript`)\n * @returns A properly cased label (e.g. `TypeScript`), or `undefined` when no language is given\n */\nexport const formatLanguage = (lang?: string): string | undefined => {\n if (!lang) {\n return undefined\n }\n\n return LANGUAGE_LABELS[lang.toLowerCase()] ?? capitalize(lang)\n}\n"],"mappings":";;AAUA,IAAM,IAA0C;CAC9C,GAAG;CACH,SAAS;CACT,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,IAAI;CACJ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;CACN,eAAe;CACf,OAAO;CACP,KAAK;CACL,YAAY;CACZ,IAAI;CACJ,QAAQ;CACR,GAAG;CACH,MAAM;CACN,MAAM;CACN,OAAO;CACP,IAAI;CACJ,OAAO;CACP,MAAM;CACN,KAAK;CACL,OAAO;CACP,IAAI;CACJ,YAAY;CACZ,KAAK;CACL,MAAM;CACN,KAAK;AACP,GAQa,KAAkB,MAAsC;CAC9D,OAIL,OAAO,EAAgB,EAAK,YAAY,MAAM,EAAW,CAAI;AAC/D"}
1
+ {"version":3,"file":"format-language.js","names":["LANGUAGE_LABELS","formatLanguage","lang","capitalize"],"sources":["../../../src/code-example/helpers/format-language.ts"],"sourcesContent":["import { capitalize } from '@scalar/helpers/string/capitalize'\n\n/**\n * Display names for the most common languages found in custom code samples.\n *\n * Custom samples (`x-scalar-examples`, `x-readme`, `x-stainless-*`, …) carry a\n * free-form `lang` string that we otherwise show verbatim in the picker. This\n * map gives the common ones a properly cased label (e.g. `typescript` →\n * `TypeScript`). Anything not listed falls back to a simple capitalization.\n */\nconst LANGUAGE_LABELS: Record<string, string> = {\n c: 'C',\n clojure: 'Clojure',\n cpp: 'C++',\n 'c++': 'C++',\n csharp: 'C#',\n 'c#': 'C#',\n css: 'CSS',\n curl: 'cURL',\n dart: 'Dart',\n fsharp: 'F#',\n 'f#': 'F#',\n go: 'Go',\n golang: 'Go',\n graphql: 'GraphQL',\n html: 'HTML',\n http: 'HTTP',\n java: 'Java',\n javascript: 'JavaScript',\n js: 'JavaScript',\n json: 'JSON',\n jl: 'Julia',\n julia: 'Julia',\n kotlin: 'Kotlin',\n node: 'Node.js',\n nodejs: 'Node.js',\n objc: 'Objective-C',\n 'objective-c': 'Objective-C',\n ocaml: 'OCaml',\n php: 'PHP',\n powershell: 'PowerShell',\n py: 'Python',\n python: 'Python',\n r: 'R',\n ruby: 'Ruby',\n rust: 'Rust',\n scala: 'Scala',\n sh: 'Shell',\n shell: 'Shell',\n bash: 'Shell',\n sql: 'SQL',\n swift: 'Swift',\n ts: 'TypeScript',\n typescript: 'TypeScript',\n xml: 'XML',\n yaml: 'YAML',\n yml: 'YAML',\n}\n\n/**\n * Turn a free-form language identifier into a display label for the code sample picker.\n *\n * @param lang - The language identifier from a custom code sample (e.g. `typescript`)\n * @returns A properly cased label (e.g. `TypeScript`), or `undefined` when no language is given\n */\nexport const formatLanguage = (lang?: string): string | undefined => {\n if (!lang) {\n return undefined\n }\n\n return LANGUAGE_LABELS[lang.toLowerCase()] ?? capitalize(lang)\n}\n"],"mappings":";;AAUA,IAAMA,IAA0C;CAC9C,GAAG;CACH,SAAS;CACT,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,IAAI;CACJ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;CACN,eAAe;CACf,OAAO;CACP,KAAK;CACL,YAAY;CACZ,IAAI;CACJ,QAAQ;CACR,GAAG;CACH,MAAM;CACN,MAAM;CACN,OAAO;CACP,IAAI;CACJ,OAAO;CACP,MAAM;CACN,KAAK;CACL,OAAO;CACP,IAAI;CACJ,YAAY;CACZ,KAAK;CACL,MAAM;CACN,KAAK;AACP,GAQaC,KAAkB,MAAsC;CACnE,IAAKC,GAIL,OAAOF,EAAgBE,EAAK,YAAY,MAAMC,EAAWD,CAAI;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-client-options.js","names":[],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n * Linked request examples with the same language and label share an id.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n const linkedGroups = new Map<string, CustomCodeSampleId>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const group = JSON.stringify([lang, sample.label ?? ''])\n const existing = sample.example !== undefined ? linkedGroups.get(group) : undefined\n if (existing) {\n return existing\n }\n\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n const id: CustomCodeSampleId = seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n // Named request examples share one language option; legacy samples remain separate.\n if (sample.example !== undefined) {\n linkedGroups.set(group, id)\n }\n return id\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id: AvailableClients[number] = `${group.key}/${plugin.client}`\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AA0BA,IAAa,KAAsB,MAAiD;CAClF,IAAM,oBAAc,IAAI,IAAoB,GACtC,oBAAe,IAAI,IAAgC;CAEzD,OAAO,EAAQ,KAAK,MAA+B;EACjD,IAAM,KAAQ,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChD,IAAQ,KAAK,UAAU,CAAC,GAAM,EAAO,SAAS,EAAE,CAAC,GACjD,IAAW,EAAO,YAAY,KAAA,IAAsC,KAAA,IAA1B,EAAa,IAAI,CAAK;EACtE,IAAI,GACF,OAAO;EAGT,IAAM,IAAO,EAAY,IAAI,CAAI,KAAK;EACtC,EAAY,IAAI,GAAM,IAAO,CAAC;EAE9B,IAAM,IAAyB,MAAS,IAAI,UAAU,MAAS,UAAU,EAAK,GAAG;EAKjF,OAHI,EAAO,YAAY,KAAA,KACrB,EAAa,IAAI,GAAO,CAAE,GAErB;CACT,CAAC;AACH,GAQa,KAAyB,IAAmC,MAA2C;CAElH,IAAM,IAAoB,IAAI,IAAI,CAAc;CAoChD,OAlCgB,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAM,IAAU,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAM,IAA+B,GAAG,EAAM,IAAI,GAAG,EAAO;GAO5D,OAJK,EAAkB,IAAI,CAAE,IAItB;IACL;IACA,MAAM,EAAO,WAAW,SAAU,SAAmB,EAAM;IAC3D,OAAO,GAAG,EAAW,EAAM,KAAK,EAAE,GAAG,EAAO;IAC5C,OAAO,EAAO;IACd,WAAW,EAAM;IACjB,aAAa,EAAM;IACnB,WAAW,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJI,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAO,EAAM;GACb,KAAK,EAAM;GACX;EACF;CACF,CAEK;AACT"}
1
+ {"version":3,"file":"generate-client-options.js","names":["getCustomClientIds","countByLang","linkedGroups","samples","lang","sample","group","existing","seen","id","generateClientOptions","AVAILABLE_CLIENTS","allowedClientsSet","allowedClients","snippetz","options","plugin","capitalize"],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n * Linked request examples with the same language and label share an id.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n const linkedGroups = new Map<string, CustomCodeSampleId>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const group = JSON.stringify([lang, sample.label ?? ''])\n const existing = sample.example !== undefined ? linkedGroups.get(group) : undefined\n if (existing) {\n return existing\n }\n\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n const id: CustomCodeSampleId = seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n // Named request examples share one language option; legacy samples remain separate.\n if (sample.example !== undefined) {\n linkedGroups.set(group, id)\n }\n return id\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id: AvailableClients[number] = `${group.key}/${plugin.client}`\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AA0BA,IAAaA,KAAsB,MAAiD;CAClF,IAAMC,oBAAc,IAAI,IAAoB,GACtCC,oBAAe,IAAI,IAAgC;CAEzD,OAAOC,EAAQ,KAAK,MAA+B;EACjD,IAAMC,KAAQC,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChDC,IAAQ,KAAK,UAAU,CAACF,GAAMC,EAAO,SAAS,EAAE,CAAC,GACjDE,IAAWF,EAAO,YAAY,KAAA,IAAsC,KAAA,IAA1BH,EAAa,IAAII,CAAK;EACtE,IAAIC,GACF,OAAOA;EAGT,IAAMC,IAAOP,EAAY,IAAIG,CAAI,KAAK;EACtC,EAAY,IAAIA,GAAMI,IAAO,CAAC;EAE9B,IAAMC,IAAyBD,MAAS,IAAI,UAAUJ,MAAS,UAAUA,EAAK,GAAGI;EAKjF,OAHIH,EAAO,YAAY,KAAA,KACrBH,EAAa,IAAII,GAAOG,CAAE,GAErBA;CACT,CAAC;AACH,GAQaC,KAAyB,IAAmCC,MAA2C;CAElH,IAAMC,IAAoB,IAAI,IAAIC,CAAc;CAoChD,OAlCgBC,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAMC,IAAUT,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAMG,IAA+B,GAAGH,EAAM,IAAI,GAAGU,EAAO;GAO5D,OAJKJ,EAAkB,IAAIH,CAAE,IAItB;IACL;IACA,MAAMO,EAAO,WAAW,SAAU,SAAmBV,EAAM;IAC3D,OAAO,GAAGW,EAAWX,EAAM,KAAK,EAAE,GAAGU,EAAO;IAC5C,OAAOA,EAAO;IACd,WAAWV,EAAM;IACjB,aAAaA,EAAM;IACnB,WAAWU,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJID,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAOT,EAAM;GACb,KAAKA,EAAM;GACX;EACF;CACF,CAEK;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-code-snippet.js","names":[],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\nimport { CookieSerializationError } from './operation-to-har/process-parameters'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: string\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string | null => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const samples = customCodeSamples.filter((_, index) => ids[index] === clientId)\n if (!samples.some((sample) => sample.example !== undefined)) {\n return samples[0]?.source ?? 'Custom example not found'\n }\n\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const mediaType = contentType ?? Object.keys(content)[0]\n const exampleKey = example ?? Object.keys(content[mediaType ?? '']?.examples ?? {})[0]\n const sample =\n samples.find((sample) => sample.example === exampleKey && sample.contentType === mediaType) ??\n samples.find((sample) => sample.example === exampleKey && sample.contentType === undefined)\n return sample?.source ?? null\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return error instanceof CookieSerializationError ? error.message : 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;;;AA4CA,IAAa,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,mBACA,oCACA,mCAC6C;CAC7C,IAAI;EACF,IAAI,CAAC,GACH,OAAO;EAIT,IAAI,EAAS,WAAW,QAAQ,GAAG;GACjC,IAAM,IAAM,EAAmB,CAAiB,GAC1C,IAAU,EAAkB,QAAQ,GAAG,MAAU,EAAI,OAAW,CAAQ;GAC9E,IAAI,CAAC,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAA,CAAS,GACxD,OAAO,EAAQ,EAAE,EAAE,UAAU;GAG/B,IAAM,IAAU,EAAe,EAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7D,IAAY,KAAe,OAAO,KAAK,CAAO,CAAC,CAAC,IAChD,IAAa,KAAW,OAAO,KAAK,EAAQ,KAAa,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;GAIpF,QAFE,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAc,EAAO,gBAAgB,CAAS,KAC1F,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAc,EAAO,gBAAgB,KAAA,CAAS,EAAA,EAC7E,UAAU;EAC3B;EAEA,IAAM,IAAa,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GAEK,CAAC,GAAW,KAAa,EAAS,MAAM,GAAG,GAE3C,CAAC,GAAO,KAAW,EAAW,GAAW,GAAW,CAAU;EAMpE,OALI,KACF,QAAQ,MAAM,yBAAyB,CAAK,GACrC,EAAM,WAAW,mCAGnB;CACT,SAAS,GAAO;EAEd,OADA,QAAQ,MAAM,yBAAyB,CAAK,GACrC,aAAiB,IAA2B,EAAM,UAAU;CACrE;AACF"}
1
+ {"version":3,"file":"generate-code-snippet.js","names":["generateCodeSnippet","clientId","ids","getCustomClientIds","customCodeSamples","samples","index","sample","content","getResolvedRef","operation","mediaType","contentType","exampleKey","example","harRequest","operationToHar","targetKey","clientKey","error","payload","getSnippet","CookieSerializationError"],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\nimport { CookieSerializationError } from './operation-to-har/process-parameters'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: string\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string | null => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const samples = customCodeSamples.filter((_, index) => ids[index] === clientId)\n if (!samples.some((sample) => sample.example !== undefined)) {\n return samples[0]?.source ?? 'Custom example not found'\n }\n\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const mediaType = contentType ?? Object.keys(content)[0]\n const exampleKey = example ?? Object.keys(content[mediaType ?? '']?.examples ?? {})[0]\n const sample =\n samples.find((sample) => sample.example === exampleKey && sample.contentType === mediaType) ??\n samples.find((sample) => sample.example === exampleKey && sample.contentType === undefined)\n return sample?.source ?? null\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return error instanceof CookieSerializationError ? error.message : 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;;;AA4CA,IAAaA,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,mBACA,oCACA,mCAC6C;CAC7C,IAAI;EACF,IAAI,CAACC,GACH,OAAO;EAIT,IAAIA,EAAS,WAAW,QAAQ,GAAG;GACjC,IAAMC,IAAMC,EAAmBC,CAAiB,GAC1CC,IAAUD,EAAkB,QAAQ,GAAG,MAAUF,EAAII,OAAWL,CAAQ;GAC9E,IAAI,CAACI,EAAQ,MAAM,MAAWE,EAAO,YAAY,KAAA,CAAS,GACxD,OAAOF,EAAQ,EAAE,EAAE,UAAU;GAG/B,IAAMG,IAAUC,EAAeC,EAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7DC,IAAYC,KAAe,OAAO,KAAKJ,CAAO,CAAC,CAAC,IAChDK,IAAaC,KAAW,OAAO,KAAKN,EAAQG,KAAa,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;GAIpF,QAFEN,EAAQ,MAAM,MAAWE,EAAO,YAAYM,KAAcN,EAAO,gBAAgBI,CAAS,KAC1FN,EAAQ,MAAM,MAAWE,EAAO,YAAYM,KAAcN,EAAO,gBAAgB,KAAA,CAAS,EAAA,EAC7E,UAAU;EAC3B;EAEA,IAAMQ,IAAaC,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GAEK,CAACC,GAAWC,KAAajB,EAAS,MAAM,GAAG,GAE3C,CAACkB,GAAOC,KAAWC,EAAWJ,GAAWC,GAAWH,CAAU;EAMpE,OALII,KACF,QAAQ,MAAM,yBAAyBA,CAAK,GACrCA,EAAM,WAAW,mCAGnBC;CACT,SAASD,GAAO;EAEd,OADA,QAAQ,MAAM,yBAAyBA,CAAK,GACrCA,aAAiBG,IAA2BH,EAAM,UAAU;CACrE;AACF"}
@@ -0,0 +1,12 @@
1
+ import type { AsyncApiChannelObject, AsyncApiDocument, AsyncApiOperationObject } from '@scalar/types/asyncapi/3.1';
2
+ import { type ChannelMessageEntry } from '@scalar/workspace-store/channel-example';
3
+ type AsyncApiExampleContext = {
4
+ operation: AsyncApiOperationObject;
5
+ channelName: string | undefined;
6
+ channel: AsyncApiChannelObject | undefined;
7
+ messages: ChannelMessageEntry[];
8
+ };
9
+ /** Resolve operation-level samples and only the messages that operation permits. */
10
+ export declare const getAsyncApiExampleContext: (document: AsyncApiDocument, operationName: string) => AsyncApiExampleContext | undefined;
11
+ export {};
12
+ //# sourceMappingURL=get-asyncapi-example-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-asyncapi-example-context.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-asyncapi-example-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAEhB,uBAAuB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,yCAAyC,CAAA;AAKhD,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,uBAAuB,CAAA;IAClC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,OAAO,EAAE,qBAAqB,GAAG,SAAS,CAAA;IAC1C,QAAQ,EAAE,mBAAmB,EAAE,CAAA;CAChC,CAAA;AAED,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,GACpC,UAAU,gBAAgB,EAC1B,eAAe,MAAM,KACpB,sBAAsB,GAAG,SA0B3B,CAAA"}