@scalar/blocks 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/code-example/components/AsyncApiCodeExample.vue.d.ts.map +1 -1
  3. package/dist/code-example/components/AsyncApiCodeExample.vue.js +1 -1
  4. package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
  5. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +2 -2
  6. package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  8. package/dist/code-example/components/CodeExample.vue.js +1 -1
  9. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  10. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +47 -49
  11. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -1
  13. package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
  14. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +21 -20
  15. package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
  16. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  17. package/dist/code-example/helpers/generate-code-snippet.js +6 -3
  18. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  19. package/dist/code-example/helpers/operation-to-har/process-body.js +5 -5
  20. package/dist/code-example/mount.js +4 -4
  21. package/dist/constants.js +1 -1
  22. package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts.map +1 -1
  23. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
  24. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +2 -5
  25. package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -1
  27. package/dist/schema/SchemaPropertyExamples.vue.js +1 -1
  28. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
  29. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +85 -81
  30. package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
  31. package/dist/schema/helpers/get-rendered-example.d.ts +19 -0
  32. package/dist/schema/helpers/get-rendered-example.d.ts.map +1 -0
  33. package/dist/schema/helpers/get-rendered-example.js +45 -0
  34. package/dist/schema/helpers/get-rendered-example.js.map +1 -0
  35. package/dist/schema/helpers/get-schema-type.d.ts.map +1 -1
  36. package/dist/schema/helpers/get-schema-type.js +1 -1
  37. package/dist/schema/helpers/get-schema-type.js.map +1 -1
  38. package/dist/schema/helpers/index.d.ts +1 -0
  39. package/dist/schema/helpers/index.d.ts.map +1 -1
  40. package/dist/schema/helpers/index.js +13 -12
  41. package/dist/style.css +75 -5
  42. package/dist/vue-styles.css +1 -1
  43. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @scalar/blocks
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11011](https://github.com/scalar/scalar/pull/11011): Make Vite configuration imports compatible with the native config loader.
8
+ - [#10980](https://github.com/scalar/scalar/pull/10980): feat: redesign code cards as a padded shell with the code on a lifted surface
9
+
10
+ This changes the default look of every `ScalarCard`, not only the cards in the API reference. `ScalarCard` drops its border and dividers for a 12px shell with 4px of padding, and each plain `ScalarCardSection` becomes an 8px surface lifted off it. If you use these components in your own app, check your cards after this bump:
11
+
12
+ - A card recolored to match its page (for example `bg-b-1` on a `bg-b-1` page) no longer has an edge. Pass `border` to bring it back, or give the card a fill that differs from the page.
13
+ - Two plain sections in a row are two surfaces with a 4px gap, where they were one box with a divider.
14
+ - Content placed straight in `ScalarCard` without a section sits inside the 4px padding. Pass `p-0` to remove it.
15
+
16
+ In the API reference, the request example, example responses, operations list and AsyncAPI cards all pick this up. The surface color is derived from `--scalar-background-2`, and its outline from `--scalar-shadow-1` and `--scalar-border-color`. A copy button on a surface sits one step above it, toward the text color. Set `--scalar-card-surface`, `--scalar-card-surface-raised` or `--scalar-card-surface-shadow` on `.scalar-card` to change them. Every class name is unchanged, and the new rules are single-class selectors, so existing theme and `customCss` rules keep winning.
17
+ - [#11037](https://github.com/scalar/scalar/pull/11037): Load object-valued `x-codeSamples.source` and `x-code-samples.source` file references as raw code text, with relative origins and lazy operation loading. Retain failed references and show an unavailable sample instead of silently replacing them with an empty string. Preserve literal `$ref` values in other extensions and example data.
18
+ - [#11041](https://github.com/scalar/scalar/pull/11041): fix: render the first request example on the server
19
+ - [#10961](https://github.com/scalar/scalar/pull/10961): Preserve named example summaries and names in header, parameter, and body example lists as muted labels above the value boxes while copying only their values. Keep schema example objects intact when their payload contains fields named `value` or `summary`.
20
+
21
+ Retain raw object examples in legacy schema example maps.
22
+ - [#11002](https://github.com/scalar/scalar/pull/11002): Use shared multi-type schema definitions when formatting array union labels.
23
+
3
24
  ## 0.7.1
4
25
 
5
26
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncApiCodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"names":[],"mappings":"AAqNA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,4BAA4B,CAAA;AASnC,KAAK,WAAW,GAAG;IACjB,kDAAkD;IAClD,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAA;CACtB,CAAC;AA8FF,KAAK,gBAAgB,GAAG;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAKF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA2RxD,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"AsyncApiCodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"names":[],"mappings":"AAqNA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,4BAA4B,CAAA;AASnC,KAAK,WAAW,GAAG;IACjB,kDAAkD;IAClD,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAA;CACtB,CAAC;AA8FF,KAAK,gBAAgB,GAAG;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAKF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA0RxD,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -2,7 +2,7 @@ import e from "./AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  //#region src/code-example/components/AsyncApiCodeExample.vue
5
- var n = /*#__PURE__*/ t(e, [["__scopeId", "data-v-41f67ce2"]]);
5
+ var n = /*#__PURE__*/ t(e, [["__scopeId", "data-v-aaf1efda"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncApiCodeExample.vue.js","names":["_sfc_main","AsyncApiCodeExample_vue_vue_type_script_setup_true_lang_default","_plugin_vue_export_helper_default","AsyncApiCodeExample_default"],"sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type {\n AsyncApiDocument,\n AsyncApiMessageObject,\n} from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { computed, ref, watch } from 'vue'\n\nimport { getAsyncApiExampleContext } from '../helpers/get-asyncapi-example-context'\nimport { getGeneratedPayloadExample } from '../helpers/get-generated-payload-example'\nimport { getMessageExampleContent } from '../helpers/get-message-example-content'\nimport ExamplePicker from './ExamplePicker.vue'\n\nconst { document, operationName } = defineProps<{\n /** A workspace-resolved AsyncAPI 3.x document. */\n document: AsyncApiDocument\n /** Key in document.operations. */\n operationName: string\n}>()\n\ntype PickerOptions = Record<string, { summary: string }>\ntype MessageExample = Exclude<\n NonNullable<AsyncApiMessageObject['examples']>[number],\n { $ref: string }\n> & { key: string }\nconst context = computed<ReturnType<typeof getAsyncApiExampleContext>>(() =>\n getAsyncApiExampleContext(document, operationName),\n)\nconst channelPathParts = computed(() =>\n (context.value?.channel?.address ?? operationName).split(/({[^}]+})/),\n)\n\nconst selectedMessage = defineModel<string>('selectedMessage', { default: '' })\nconst selectedExample = ref<string>('')\nconst messages = computed<PickerOptions>(() =>\n Object.fromEntries(\n (context.value?.messages ?? []).map(({ name, message }) => [\n name,\n { summary: message.title || message.name || name },\n ]),\n ),\n)\nconst message = computed<AsyncApiMessageObject | undefined>(\n () =>\n context.value?.messages.find(({ name }) => name === selectedMessage.value)\n ?.message,\n)\nconst examples = computed<MessageExample[]>(() =>\n (message.value?.examples ?? []).flatMap((node, index) => {\n const example = getResolvedAsyncApiRef(node)\n return example?.payload !== undefined\n ? [{ key: String(index), ...example }]\n : []\n }),\n)\nconst exampleOptions = computed<PickerOptions>(() =>\n Object.fromEntries(\n examples.value.map((example, index) => [\n example.key,\n { summary: example.name || example.summary || `Example ${index + 1}` },\n ]),\n ),\n)\nconst example = computed<MessageExample | undefined>(() =>\n examples.value.find(({ key }) => key === selectedExample.value),\n)\nconst messageLabel = computed<string>(\n () =>\n `Message: ${messages.value[selectedMessage.value]?.summary ?? 'Select a message'}`,\n)\nconst exampleLabel = computed<string>(\n () =>\n `Message example: ${exampleOptions.value[selectedExample.value]?.summary ?? 'Select an example'}`,\n)\n\n// Keep selections valid when operations, messages, or the active document change.\nwatch(\n messages,\n (options) => {\n if (!Object.hasOwn(options, selectedMessage.value))\n selectedMessage.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nwatch([selectedMessage, () => operationName], () => {\n selectedExample.value = Object.keys(exampleOptions.value)[0] ?? ''\n})\nwatch(\n exampleOptions,\n (options) => {\n if (!Object.hasOwn(options, selectedExample.value))\n selectedExample.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nconst content = computed(() =>\n getMessageExampleContent(\n example.value\n ? example.value.payload\n : message.value\n ? getGeneratedPayloadExample(message.value)\n : undefined,\n message.value?.contentType ?? document.defaultContentType,\n ),\n)\n</script>\n\n<template>\n <ScalarCard\n class=\"request-card dark-mode min-w-0\"\n label=\"Message example\">\n <ScalarCardHeader\n class=\"flex-nowrap items-start gap-3 pr-2.5 [&_.scalar-card-header-title]:flex-1 [&_.scalar-card-header-title]:whitespace-normal [&>div:last-child]:shrink-0\">\n <span class=\"sr-only\">Message example for</span>\n <span\n class=\"font-code mr-1.5 uppercase\"\n :class=\"\n context?.operation.action === 'send' ? 'text-blue' : 'text-green'\n \"\n >{{ context?.operation.action }}</span\n >\n <span class=\"text-c-2 font-code min-w-0 font-semibold break-words\">\n <template\n v-for=\"(part, index) in channelPathParts\"\n :key=\"index\">\n <span\n v-if=\"part.startsWith('{') && part.endsWith('}')\"\n class=\"text-c-1 whitespace-nowrap\"\n >{{ part }}</span\n >\n <ScalarWrappingText\n v-else\n :text=\"part\" />\n </template>\n </span>\n </ScalarCardHeader>\n <ScalarCardSection class=\"custom-scroll flex flex-1 p-0\">\n <div class=\"flex w-full flex-col\">\n <p\n v-if=\"content?.structural\"\n class=\"text-c-2 px-3 py-2 text-sm\">\n Structure only; not encoded\n </p>\n <ScalarCodeBlock\n v-if=\"content\"\n class=\"bg-b-2 h-full\"\n :content=\"content.content\"\n :lang=\"content.lang\"\n lineNumbers />\n <p\n v-else\n class=\"text-c-2 p-4\"\n role=\"status\">\n No message payload example available.\n </p>\n </div>\n </ScalarCardSection>\n <ScalarCardFooter\n v-if=\"Object.keys(messages).length || examples.length\"\n class=\"bg-b-3 relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5\">\n <div class=\"flex min-w-0 flex-1 flex-wrap items-center gap-2\">\n <ExamplePicker\n v-if=\"examples.length > 1\"\n v-model=\"selectedExample\"\n :aria-label=\"exampleLabel\"\n :examples=\"exampleOptions\" />\n <span\n v-else-if=\"examples.length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ exampleOptions[selectedExample]?.summary }}\n </span>\n <div class=\"ml-auto flex min-w-0 items-center\">\n <ExamplePicker\n v-if=\"Object.keys(messages).length > 1\"\n v-model=\"selectedMessage\"\n :aria-label=\"messageLabel\"\n :examples=\"messages\" />\n <span\n v-else-if=\"Object.keys(messages).length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ messages[selectedMessage]?.summary }}\n </span>\n </div>\n </div>\n </ScalarCardFooter>\n </ScalarCard>\n</template>\n\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"AsyncApiCodeExample.vue.js","names":["_sfc_main","AsyncApiCodeExample_vue_vue_type_script_setup_true_lang_default","_plugin_vue_export_helper_default","AsyncApiCodeExample_default"],"sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type {\n AsyncApiDocument,\n AsyncApiMessageObject,\n} from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { computed, ref, watch } from 'vue'\n\nimport { getAsyncApiExampleContext } from '../helpers/get-asyncapi-example-context'\nimport { getGeneratedPayloadExample } from '../helpers/get-generated-payload-example'\nimport { getMessageExampleContent } from '../helpers/get-message-example-content'\nimport ExamplePicker from './ExamplePicker.vue'\n\nconst { document, operationName } = defineProps<{\n /** A workspace-resolved AsyncAPI 3.x document. */\n document: AsyncApiDocument\n /** Key in document.operations. */\n operationName: string\n}>()\n\ntype PickerOptions = Record<string, { summary: string }>\ntype MessageExample = Exclude<\n NonNullable<AsyncApiMessageObject['examples']>[number],\n { $ref: string }\n> & { key: string }\nconst context = computed<ReturnType<typeof getAsyncApiExampleContext>>(() =>\n getAsyncApiExampleContext(document, operationName),\n)\nconst channelPathParts = computed(() =>\n (context.value?.channel?.address ?? operationName).split(/({[^}]+})/),\n)\n\nconst selectedMessage = defineModel<string>('selectedMessage', { default: '' })\nconst selectedExample = ref<string>('')\nconst messages = computed<PickerOptions>(() =>\n Object.fromEntries(\n (context.value?.messages ?? []).map(({ name, message }) => [\n name,\n { summary: message.title || message.name || name },\n ]),\n ),\n)\nconst message = computed<AsyncApiMessageObject | undefined>(\n () =>\n context.value?.messages.find(({ name }) => name === selectedMessage.value)\n ?.message,\n)\nconst examples = computed<MessageExample[]>(() =>\n (message.value?.examples ?? []).flatMap((node, index) => {\n const example = getResolvedAsyncApiRef(node)\n return example?.payload !== undefined\n ? [{ key: String(index), ...example }]\n : []\n }),\n)\nconst exampleOptions = computed<PickerOptions>(() =>\n Object.fromEntries(\n examples.value.map((example, index) => [\n example.key,\n { summary: example.name || example.summary || `Example ${index + 1}` },\n ]),\n ),\n)\nconst example = computed<MessageExample | undefined>(() =>\n examples.value.find(({ key }) => key === selectedExample.value),\n)\nconst messageLabel = computed<string>(\n () =>\n `Message: ${messages.value[selectedMessage.value]?.summary ?? 'Select a message'}`,\n)\nconst exampleLabel = computed<string>(\n () =>\n `Message example: ${exampleOptions.value[selectedExample.value]?.summary ?? 'Select an example'}`,\n)\n\n// Keep selections valid when operations, messages, or the active document change.\nwatch(\n messages,\n (options) => {\n if (!Object.hasOwn(options, selectedMessage.value))\n selectedMessage.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nwatch([selectedMessage, () => operationName], () => {\n selectedExample.value = Object.keys(exampleOptions.value)[0] ?? ''\n})\nwatch(\n exampleOptions,\n (options) => {\n if (!Object.hasOwn(options, selectedExample.value))\n selectedExample.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nconst content = computed(() =>\n getMessageExampleContent(\n example.value\n ? example.value.payload\n : message.value\n ? getGeneratedPayloadExample(message.value)\n : undefined,\n message.value?.contentType ?? document.defaultContentType,\n ),\n)\n</script>\n\n<template>\n <ScalarCard\n class=\"request-card dark-mode min-w-0\"\n label=\"Message example\">\n <ScalarCardHeader\n class=\"flex-nowrap items-start gap-3 pr-2.5 [&_.scalar-card-header-title]:flex-1 [&_.scalar-card-header-title]:whitespace-normal [&>div:last-child]:shrink-0\">\n <span class=\"sr-only\">Message example for</span>\n <span\n class=\"font-code mr-1.5 uppercase\"\n :class=\"\n context?.operation.action === 'send' ? 'text-blue' : 'text-green'\n \"\n >{{ context?.operation.action }}</span\n >\n <span class=\"text-c-2 font-code min-w-0 font-semibold break-words\">\n <template\n v-for=\"(part, index) in channelPathParts\"\n :key=\"index\">\n <span\n v-if=\"part.startsWith('{') && part.endsWith('}')\"\n class=\"text-c-1 whitespace-nowrap\"\n >{{ part }}</span\n >\n <ScalarWrappingText\n v-else\n :text=\"part\" />\n </template>\n </span>\n </ScalarCardHeader>\n <ScalarCardSection class=\"custom-scroll flex flex-1 p-0\">\n <div class=\"flex w-full flex-col\">\n <p\n v-if=\"content?.structural\"\n class=\"text-c-2 px-3 py-2 text-sm\">\n Structure only; not encoded\n </p>\n <ScalarCodeBlock\n v-if=\"content\"\n class=\"h-full bg-transparent\"\n :content=\"content.content\"\n :lang=\"content.lang\"\n lineNumbers />\n <p\n v-else\n class=\"text-c-2 p-4\"\n role=\"status\">\n No message payload example available.\n </p>\n </div>\n </ScalarCardSection>\n <ScalarCardFooter\n v-if=\"Object.keys(messages).length || examples.length\"\n class=\"relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5\">\n <div class=\"flex min-w-0 flex-1 flex-wrap items-center gap-2\">\n <ExamplePicker\n v-if=\"examples.length > 1\"\n v-model=\"selectedExample\"\n :aria-label=\"exampleLabel\"\n :examples=\"exampleOptions\" />\n <span\n v-else-if=\"examples.length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ exampleOptions[selectedExample]?.summary }}\n </span>\n <div class=\"ml-auto flex min-w-0 items-center\">\n <ExamplePicker\n v-if=\"Object.keys(messages).length > 1\"\n v-model=\"selectedMessage\"\n :aria-label=\"messageLabel\"\n :examples=\"messages\" />\n <span\n v-else-if=\"Object.keys(messages).length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ messages[selectedMessage]?.summary }}\n </span>\n </div>\n </div>\n </ScalarCardFooter>\n </ScalarCard>\n</template>\n\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n</style>\n"],"mappings":""}
@@ -69,7 +69,7 @@ var k = { class: "text-c-2 font-code min-w-0 font-semibold break-words" }, A = {
69
69
  u(v(T), { class: "custom-scroll flex flex-1 p-0" }, {
70
70
  default: x(() => [l("div", j, [J.value?.structural ? (m(), c("p", M, " Structure only; not encoded ")) : s("", !0), J.value ? (m(), o(v(E), {
71
71
  key: 1,
72
- class: "bg-b-2 h-full",
72
+ class: "h-full bg-transparent",
73
73
  content: J.value.content,
74
74
  lang: J.value.lang,
75
75
  lineNumbers: ""
@@ -78,7 +78,7 @@ var k = { class: "text-c-2 font-code min-w-0 font-semibold break-words" }, A = {
78
78
  }),
79
79
  Object.keys(V.value).length || U.value.length ? (m(), o(v(C), {
80
80
  key: 0,
81
- class: "bg-b-3 relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5"
81
+ class: "relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5"
82
82
  }, {
83
83
  default: x(() => [l("div", P, [U.value.length > 1 ? (m(), o(r, {
84
84
  key: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createElementVNode","_normalizeClass","_toDisplayString","_createElementBlock","_Fragment","_renderList","_createCommentVNode","ExamplePicker","ExamplePicker_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","AsyncApiCodeExample_vue_vue_type_script_setup_true_lang_default","\"selectedMessage\"","\"selectedMessageModifiers\"","context","computed","getAsyncApiExampleContext","__props","channelPathParts","selectedMessage","useModel","selectedExample","ref","messages","name","message","examples","example","getResolvedAsyncApiRef","node","index","exampleOptions","key","messageLabel","exampleLabel","watch","options","content","getMessageExampleContent","getGeneratedPayloadExample","openBlock","createBlock","unref","ScalarCard","withCtx","createVNode","ScalarCardHeader","_cache","createElementVNode","normalizeClass","toDisplayString","createElementBlock","Fragment","renderList","part","ScalarWrappingText","ScalarCardSection","createCommentVNode","ScalarCodeBlock","ScalarCardFooter","$event"],"sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type {\n AsyncApiDocument,\n AsyncApiMessageObject,\n} from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { computed, ref, watch } from 'vue'\n\nimport { getAsyncApiExampleContext } from '../helpers/get-asyncapi-example-context'\nimport { getGeneratedPayloadExample } from '../helpers/get-generated-payload-example'\nimport { getMessageExampleContent } from '../helpers/get-message-example-content'\nimport ExamplePicker from './ExamplePicker.vue'\n\nconst { document, operationName } = defineProps<{\n /** A workspace-resolved AsyncAPI 3.x document. */\n document: AsyncApiDocument\n /** Key in document.operations. */\n operationName: string\n}>()\n\ntype PickerOptions = Record<string, { summary: string }>\ntype MessageExample = Exclude<\n NonNullable<AsyncApiMessageObject['examples']>[number],\n { $ref: string }\n> & { key: string }\nconst context = computed<ReturnType<typeof getAsyncApiExampleContext>>(() =>\n getAsyncApiExampleContext(document, operationName),\n)\nconst channelPathParts = computed(() =>\n (context.value?.channel?.address ?? operationName).split(/({[^}]+})/),\n)\n\nconst selectedMessage = defineModel<string>('selectedMessage', { default: '' })\nconst selectedExample = ref<string>('')\nconst messages = computed<PickerOptions>(() =>\n Object.fromEntries(\n (context.value?.messages ?? []).map(({ name, message }) => [\n name,\n { summary: message.title || message.name || name },\n ]),\n ),\n)\nconst message = computed<AsyncApiMessageObject | undefined>(\n () =>\n context.value?.messages.find(({ name }) => name === selectedMessage.value)\n ?.message,\n)\nconst examples = computed<MessageExample[]>(() =>\n (message.value?.examples ?? []).flatMap((node, index) => {\n const example = getResolvedAsyncApiRef(node)\n return example?.payload !== undefined\n ? [{ key: String(index), ...example }]\n : []\n }),\n)\nconst exampleOptions = computed<PickerOptions>(() =>\n Object.fromEntries(\n examples.value.map((example, index) => [\n example.key,\n { summary: example.name || example.summary || `Example ${index + 1}` },\n ]),\n ),\n)\nconst example = computed<MessageExample | undefined>(() =>\n examples.value.find(({ key }) => key === selectedExample.value),\n)\nconst messageLabel = computed<string>(\n () =>\n `Message: ${messages.value[selectedMessage.value]?.summary ?? 'Select a message'}`,\n)\nconst exampleLabel = computed<string>(\n () =>\n `Message example: ${exampleOptions.value[selectedExample.value]?.summary ?? 'Select an example'}`,\n)\n\n// Keep selections valid when operations, messages, or the active document change.\nwatch(\n messages,\n (options) => {\n if (!Object.hasOwn(options, selectedMessage.value))\n selectedMessage.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nwatch([selectedMessage, () => operationName], () => {\n selectedExample.value = Object.keys(exampleOptions.value)[0] ?? ''\n})\nwatch(\n exampleOptions,\n (options) => {\n if (!Object.hasOwn(options, selectedExample.value))\n selectedExample.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nconst content = computed(() =>\n getMessageExampleContent(\n example.value\n ? example.value.payload\n : message.value\n ? getGeneratedPayloadExample(message.value)\n : undefined,\n message.value?.contentType ?? document.defaultContentType,\n ),\n)\n</script>\n\n<template>\n <ScalarCard\n class=\"request-card dark-mode min-w-0\"\n label=\"Message example\">\n <ScalarCardHeader\n class=\"flex-nowrap items-start gap-3 pr-2.5 [&_.scalar-card-header-title]:flex-1 [&_.scalar-card-header-title]:whitespace-normal [&>div:last-child]:shrink-0\">\n <span class=\"sr-only\">Message example for</span>\n <span\n class=\"font-code mr-1.5 uppercase\"\n :class=\"\n context?.operation.action === 'send' ? 'text-blue' : 'text-green'\n \"\n >{{ context?.operation.action }}</span\n >\n <span class=\"text-c-2 font-code min-w-0 font-semibold break-words\">\n <template\n v-for=\"(part, index) in channelPathParts\"\n :key=\"index\">\n <span\n v-if=\"part.startsWith('{') && part.endsWith('}')\"\n class=\"text-c-1 whitespace-nowrap\"\n >{{ part }}</span\n >\n <ScalarWrappingText\n v-else\n :text=\"part\" />\n </template>\n </span>\n </ScalarCardHeader>\n <ScalarCardSection class=\"custom-scroll flex flex-1 p-0\">\n <div class=\"flex w-full flex-col\">\n <p\n v-if=\"content?.structural\"\n class=\"text-c-2 px-3 py-2 text-sm\">\n Structure only; not encoded\n </p>\n <ScalarCodeBlock\n v-if=\"content\"\n class=\"bg-b-2 h-full\"\n :content=\"content.content\"\n :lang=\"content.lang\"\n lineNumbers />\n <p\n v-else\n class=\"text-c-2 p-4\"\n role=\"status\">\n No message payload example available.\n </p>\n </div>\n </ScalarCardSection>\n <ScalarCardFooter\n v-if=\"Object.keys(messages).length || examples.length\"\n class=\"bg-b-3 relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5\">\n <div class=\"flex min-w-0 flex-1 flex-wrap items-center gap-2\">\n <ExamplePicker\n v-if=\"examples.length > 1\"\n v-model=\"selectedExample\"\n :aria-label=\"exampleLabel\"\n :examples=\"exampleOptions\" />\n <span\n v-else-if=\"examples.length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ exampleOptions[selectedExample]?.summary }}\n </span>\n <div class=\"ml-auto flex min-w-0 items-center\">\n <ExamplePicker\n v-if=\"Object.keys(messages).length > 1\"\n v-model=\"selectedMessage\"\n :aria-label=\"messageLabel\"\n :examples=\"messages\" />\n <span\n v-else-if=\"Object.keys(messages).length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ messages[selectedMessage]?.summary }}\n </span>\n </div>\n </div>\n </ScalarCardFooter>\n </ScalarCard>\n</template>\n\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,IAAM2B,IAAUC,QACdC,EAA0BC,EAAA,UAAUA,EAAA,aAAa,CACnD,GACMC,IAAmBH,SACtBD,EAAQ,OAAO,SAAS,WAAWG,EAAA,cAAA,CAAe,MAAM,WAAW,CACtE,GAEME,IAAkBhC,EAAmB8B,GAAC,iBAAkC,GACxEI,IAAkBC,EAAY,EAAE,GAChCC,IAAWR,QACf,OAAO,aACJD,EAAQ,OAAO,YAAY,CAAC,EAAA,CAAG,KAAK,EAAE,SAAM,iBAAc,CACzDU,GACA,EAAE,SAASC,EAAQ,SAASA,EAAQ,QAAQD,EAAK,CACnD,CAA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AA;K,qCACFjD,EAAA,GAAAQ,EAKI,KALJU,GAGgB,yCAEhB,E;;;IAII,OAAO,KAAKiB,EAAA,KAAQ,CAAA,CAAE,UAAUG,EAAA,MAAS,UADjDtC,EAAA,GAAAC,EA2BmBC,EAAAqE,CAAA,GAAA;;KAzBjB,OAAM;;KACN,SAAApE,QAuBM,CAvBNE,EAuBM,OAvBNc,GAuBM,CArBImB,EAAA,MAAS,SAAM,KADvBtC,EAAA,GAAAC,EAI+BW,GAAA;;MAFpB,YAAAqB,EAAA;MAAA,uBAAA,AAAA0B,EAAA,QAAA,MAAA,EAAe,QAAAa;MACvB,cAAY1B,EAAA;MACZ,UAAUH,EAAA;;;;;K,MAEAL,EAAA,MAAS,WAAM,KAD5BtC,EAAA,GAAAQ,EAIO,QAJPY,GAIOb,EADFoC,EAAA,MAAeV,EAAA,MAAe,EAAG,OAAO,GAAA,CAAA,K,WAE7C5B,EAWM,OAXNgB,GAWM,CATI,OAAO,KAAKc,EAAA,KAAQ,CAAA,CAAE,SAAM,KADpCnC,EAAA,GAAAC,EAIyBW,GAAA;;MAFd,YAAAmB,EAAA;MAAA,uBAAA,AAAA4B,EAAA,QAAA,MAAA,EAAe,QAAAa;MACvB,cAAY3B,EAAA;MACZ,UAAUV,EAAA;;;;;K,MAEA,OAAO,KAAKA,EAAA,KAAQ,CAAA,CAAE,WAAM,KADzCnC,EAAA,GAAAQ,EAIO,QAJPc,GAIOf,EADF4B,EAAA,MAASJ,EAAA,MAAe,EAAG,OAAO,GAAA,CAAA,K"}
1
+ {"version":3,"file":"AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createElementVNode","_normalizeClass","_toDisplayString","_createElementBlock","_Fragment","_renderList","_createCommentVNode","ExamplePicker","ExamplePicker_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","AsyncApiCodeExample_vue_vue_type_script_setup_true_lang_default","\"selectedMessage\"","\"selectedMessageModifiers\"","context","computed","getAsyncApiExampleContext","__props","channelPathParts","selectedMessage","useModel","selectedExample","ref","messages","name","message","examples","example","getResolvedAsyncApiRef","node","index","exampleOptions","key","messageLabel","exampleLabel","watch","options","content","getMessageExampleContent","getGeneratedPayloadExample","openBlock","createBlock","unref","ScalarCard","withCtx","createVNode","ScalarCardHeader","_cache","createElementVNode","normalizeClass","toDisplayString","createElementBlock","Fragment","renderList","part","ScalarWrappingText","ScalarCardSection","createCommentVNode","ScalarCodeBlock","ScalarCardFooter","$event"],"sources":["../../../src/code-example/components/AsyncApiCodeExample.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarWrappingText } from '@scalar/components/wrapping-text'\nimport type {\n AsyncApiDocument,\n AsyncApiMessageObject,\n} from '@scalar/types/asyncapi/3.1'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\nimport { computed, ref, watch } from 'vue'\n\nimport { getAsyncApiExampleContext } from '../helpers/get-asyncapi-example-context'\nimport { getGeneratedPayloadExample } from '../helpers/get-generated-payload-example'\nimport { getMessageExampleContent } from '../helpers/get-message-example-content'\nimport ExamplePicker from './ExamplePicker.vue'\n\nconst { document, operationName } = defineProps<{\n /** A workspace-resolved AsyncAPI 3.x document. */\n document: AsyncApiDocument\n /** Key in document.operations. */\n operationName: string\n}>()\n\ntype PickerOptions = Record<string, { summary: string }>\ntype MessageExample = Exclude<\n NonNullable<AsyncApiMessageObject['examples']>[number],\n { $ref: string }\n> & { key: string }\nconst context = computed<ReturnType<typeof getAsyncApiExampleContext>>(() =>\n getAsyncApiExampleContext(document, operationName),\n)\nconst channelPathParts = computed(() =>\n (context.value?.channel?.address ?? operationName).split(/({[^}]+})/),\n)\n\nconst selectedMessage = defineModel<string>('selectedMessage', { default: '' })\nconst selectedExample = ref<string>('')\nconst messages = computed<PickerOptions>(() =>\n Object.fromEntries(\n (context.value?.messages ?? []).map(({ name, message }) => [\n name,\n { summary: message.title || message.name || name },\n ]),\n ),\n)\nconst message = computed<AsyncApiMessageObject | undefined>(\n () =>\n context.value?.messages.find(({ name }) => name === selectedMessage.value)\n ?.message,\n)\nconst examples = computed<MessageExample[]>(() =>\n (message.value?.examples ?? []).flatMap((node, index) => {\n const example = getResolvedAsyncApiRef(node)\n return example?.payload !== undefined\n ? [{ key: String(index), ...example }]\n : []\n }),\n)\nconst exampleOptions = computed<PickerOptions>(() =>\n Object.fromEntries(\n examples.value.map((example, index) => [\n example.key,\n { summary: example.name || example.summary || `Example ${index + 1}` },\n ]),\n ),\n)\nconst example = computed<MessageExample | undefined>(() =>\n examples.value.find(({ key }) => key === selectedExample.value),\n)\nconst messageLabel = computed<string>(\n () =>\n `Message: ${messages.value[selectedMessage.value]?.summary ?? 'Select a message'}`,\n)\nconst exampleLabel = computed<string>(\n () =>\n `Message example: ${exampleOptions.value[selectedExample.value]?.summary ?? 'Select an example'}`,\n)\n\n// Keep selections valid when operations, messages, or the active document change.\nwatch(\n messages,\n (options) => {\n if (!Object.hasOwn(options, selectedMessage.value))\n selectedMessage.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nwatch([selectedMessage, () => operationName], () => {\n selectedExample.value = Object.keys(exampleOptions.value)[0] ?? ''\n})\nwatch(\n exampleOptions,\n (options) => {\n if (!Object.hasOwn(options, selectedExample.value))\n selectedExample.value = Object.keys(options)[0] ?? ''\n },\n { immediate: true },\n)\nconst content = computed(() =>\n getMessageExampleContent(\n example.value\n ? example.value.payload\n : message.value\n ? getGeneratedPayloadExample(message.value)\n : undefined,\n message.value?.contentType ?? document.defaultContentType,\n ),\n)\n</script>\n\n<template>\n <ScalarCard\n class=\"request-card dark-mode min-w-0\"\n label=\"Message example\">\n <ScalarCardHeader\n class=\"flex-nowrap items-start gap-3 pr-2.5 [&_.scalar-card-header-title]:flex-1 [&_.scalar-card-header-title]:whitespace-normal [&>div:last-child]:shrink-0\">\n <span class=\"sr-only\">Message example for</span>\n <span\n class=\"font-code mr-1.5 uppercase\"\n :class=\"\n context?.operation.action === 'send' ? 'text-blue' : 'text-green'\n \"\n >{{ context?.operation.action }}</span\n >\n <span class=\"text-c-2 font-code min-w-0 font-semibold break-words\">\n <template\n v-for=\"(part, index) in channelPathParts\"\n :key=\"index\">\n <span\n v-if=\"part.startsWith('{') && part.endsWith('}')\"\n class=\"text-c-1 whitespace-nowrap\"\n >{{ part }}</span\n >\n <ScalarWrappingText\n v-else\n :text=\"part\" />\n </template>\n </span>\n </ScalarCardHeader>\n <ScalarCardSection class=\"custom-scroll flex flex-1 p-0\">\n <div class=\"flex w-full flex-col\">\n <p\n v-if=\"content?.structural\"\n class=\"text-c-2 px-3 py-2 text-sm\">\n Structure only; not encoded\n </p>\n <ScalarCodeBlock\n v-if=\"content\"\n class=\"h-full bg-transparent\"\n :content=\"content.content\"\n :lang=\"content.lang\"\n lineNumbers />\n <p\n v-else\n class=\"text-c-2 p-4\"\n role=\"status\">\n No message payload example available.\n </p>\n </div>\n </ScalarCardSection>\n <ScalarCardFooter\n v-if=\"Object.keys(messages).length || examples.length\"\n class=\"relative flex shrink-0 flex-wrap items-center justify-end gap-2 p-1.5\">\n <div class=\"flex min-w-0 flex-1 flex-wrap items-center gap-2\">\n <ExamplePicker\n v-if=\"examples.length > 1\"\n v-model=\"selectedExample\"\n :aria-label=\"exampleLabel\"\n :examples=\"exampleOptions\" />\n <span\n v-else-if=\"examples.length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ exampleOptions[selectedExample]?.summary }}\n </span>\n <div class=\"ml-auto flex min-w-0 items-center\">\n <ExamplePicker\n v-if=\"Object.keys(messages).length > 1\"\n v-model=\"selectedMessage\"\n :aria-label=\"messageLabel\"\n :examples=\"messages\" />\n <span\n v-else-if=\"Object.keys(messages).length === 1\"\n class=\"text-c-2 min-w-0 truncate px-1.5 py-0.75 text-base\">\n {{ messages[selectedMessage]?.summary }}\n </span>\n </div>\n </div>\n </ScalarCardFooter>\n </ScalarCard>\n</template>\n\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,IAAM2B,IAAUC,QACdC,EAA0BC,EAAA,UAAUA,EAAA,aAAa,CACnD,GACMC,IAAmBH,SACtBD,EAAQ,OAAO,SAAS,WAAWG,EAAA,cAAA,CAAe,MAAM,WAAW,CACtE,GAEME,IAAkBhC,EAAmB8B,GAAC,iBAAkC,GACxEI,IAAkBC,EAAY,EAAE,GAChCC,IAAWR,QACf,OAAO,aACJD,EAAQ,OAAO,YAAY,CAAC,EAAA,CAAG,KAAK,EAAE,SAAM,iBAAc,CACzDU,GACA,EAAE,SAASC,EAAQ,SAASA,EAAQ,QAAQD,EAAK,CACnD,CAAC,CACH,CACF,GACMC,IAAUV,QAEZD,EAAQ,OAAO,SAAS,MAAM,EAAE,cAAWU,MAASL,EAAgB,KAAK,CAAA,EACrE,OACR,GACMO,IAAWX,SACdU,EAAQ,OAAO,YAAY,CAAC,EAAA,CAAG,SAAS,GAAM,MAAU;GACvD,IAAME,IAAUC,EAAuBC,CAAI;GAC3C,OAAOF,GAAS,YAAY,KAAA,IAExB,CAAC,IADD,CAAC;IAAE,KAAK,OAAOG,CAAK;IAAG,GAAGH;GAAQ,CAAC;EAEzC,CAAC,CACH,GACMI,IAAiBhB,QACrB,OAAO,YACLW,EAAS,MAAM,KAAK,GAAS,MAAU,CACrCC,EAAQ,KACR,EAAE,SAASA,EAAQ,QAAQA,EAAQ,WAAW,WAAWG,IAAQ,IAAI,CACvE,CAAC,CACH,CACF,GACMH,IAAUZ,QACdW,EAAS,MAAM,MAAM,EAAE,aAAUM,MAAQX,EAAgB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,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;OAEG;IACH,eAAe,EAAE,0BAA0B,EAAE,CAAA;IAC7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,eAAe,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,MAAM,CAAA;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAuCN,MAAM,OAAO;IACvB,kGAAkG;qBACjF,MAAM,OAAO;YACpB,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAsyB7D,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"CodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/CodeExample.vue"],"names":[],"mappings":"AAiwBA,OAAO,EAAE,KAAK,iBAAiB,EAAE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AAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAuCN,MAAM,OAAO;IACvB,kGAAkG;qBACjF,MAAM,OAAO;YACpB,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAwyB7D,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -2,7 +2,7 @@ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./CodeExample.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/code-example/components/CodeExample.vue
5
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-9ef20696"]]);
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-3954f074"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","CodeExample_vue_vue_type_script_setup_true_lang_default","CodeExample_default"],"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 {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} 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 {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} 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 generatedTemplate = 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/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\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(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\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 group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"bg-b-2 h-full\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\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=\"displayCode ?? ''\" />\n </template>\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 <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\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 flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"CodeExample.vue.js","names":["_sfc_main","_plugin_vue_export_helper_default","CodeExample_vue_vue_type_script_setup_true_lang_default","CodeExample_default"],"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 {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} 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 {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} 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 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.\n// This runs during setup so the server renders the same example as the browser.\nlocalExampleKey.value = resolveExampleKey(selectedExample)\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 generatedTemplate = 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/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\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(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\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 group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"h-full bg-transparent\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block 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=\"displayCode ?? ''\" />\n </template>\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer\"\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 <!-- A single row of method, path and actions reads as a header, so it stays on the card -->\n <ScalarCardSection class=\"request-card-simple bg-transparent shadow-none\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\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/*\n * A long sample is drawn as virtual text with its own copy button rather than a code block, so\n * that button gets the same raised fill a code block gives its button on a card's surface.\n */\n.code-snippet > .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n.request-card-simple {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":""}
@@ -7,38 +7,38 @@ import { getCustomCodeSamples as te } from "../helpers/get-custom-code-samples.j
7
7
  import { getClients as ne } from "../helpers/get-clients.js";
8
8
  import { getSecrets as re } from "../helpers/get-secrets.js";
9
9
  import i from "./HttpMethod.vue.js";
10
- import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createSlots as ie, createTextVNode as d, createVNode as f, defineComponent as p, normalizeClass as ae, onBeforeMount as oe, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, unref as v, useId as se, watch as y, watchEffect as ce, withCtx as b } from "vue";
11
- import { ScalarCard as x, ScalarCardFooter as le, ScalarCardHeader as ue, ScalarCardSection as S } from "@scalar/components/card";
12
- import { ScalarCodeBlock as de, ScalarCodeBlockCopy as fe } from "@scalar/components/code-block";
13
- import { resolveCredentialPlaceholders as pe } from "@scalar/workspace-store/request-example";
10
+ import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createSlots as ie, createTextVNode as d, createVNode as f, defineComponent as p, normalizeClass as ae, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, unref as v, useId as oe, watch as y, watchEffect as se, withCtx as b } from "vue";
11
+ import { ScalarCard as x, ScalarCardFooter as ce, ScalarCardHeader as le, ScalarCardSection as S } from "@scalar/components/card";
12
+ import { ScalarCodeBlock as ue, ScalarCodeBlockCopy as de } from "@scalar/components/code-block";
13
+ import { resolveCredentialPlaceholders as fe } from "@scalar/workspace-store/request-example";
14
14
  import { ScalarButton as C } from "@scalar/components/button";
15
- import { ScalarIconCaretDown as me } from "@scalar/icons";
15
+ import { ScalarIconCaretDown as pe } from "@scalar/icons";
16
+ import { getResolvedRef as me } from "@scalar/workspace-store/helpers/get-resolved-ref";
16
17
  import { ScalarCombobox as he } from "@scalar/components/combobox";
17
18
  import { ScalarVirtualText as ge } from "@scalar/components/virtual-text";
18
19
  import { freezeElement as _e } from "@scalar/helpers/dom/freeze-element";
19
- import { getResolvedRef as ve } from "@scalar/workspace-store/helpers/get-resolved-ref";
20
- import { getOperationExamples as ye, resolveOperationExamples as w } from "@scalar/workspace-store/helpers/operation-examples";
21
- import { useExampleVisibility as T, useExternalExamples as E } from "@scalar/workspace-store/helpers/use-external-examples";
20
+ import { getOperationExamples as ve, resolveOperationExamples as ye } from "@scalar/workspace-store/helpers/operation-examples";
21
+ import { useExampleVisibility as w, useExternalExamples as T } from "@scalar/workspace-store/helpers/use-external-examples";
22
22
  //#region src/code-example/components/CodeExample.vue?vue&type=script&setup=true&lang.ts
23
- var D = ["innerHTML"], O = {
23
+ var E = ["innerHTML"], D = {
24
24
  key: 1,
25
25
  class: "text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal",
26
26
  "data-testid": "client-picker"
27
- }, k = {
27
+ }, O = {
28
28
  key: 0,
29
29
  class: "text-c-2 p-4",
30
30
  role: "status"
31
- }, A = {
31
+ }, k = {
32
32
  key: 1,
33
33
  class: "text-c-2 p-4",
34
34
  role: "status"
35
- }, j = ["id"], M = {
35
+ }, A = ["id"], j = {
36
36
  key: 0,
37
37
  class: "request-card-footer-addon"
38
- }, N = {
38
+ }, M = {
39
39
  key: 1,
40
40
  class: "request-card-footer-start"
41
- }, P = { class: "request-header" }, be = {
41
+ }, N = { class: "request-header" }, P = {
42
42
  key: 0,
43
43
  class: "request-card-actions relative max-w-full"
44
44
  }, F = /*@__PURE__*/ p({
@@ -68,30 +68,28 @@ var D = ["innerHTML"], O = {
68
68
  },
69
69
  emits: ["update:exampleKey"],
70
70
  setup(p, { emit: F }) {
71
- let xe = F, I = o(() => {
72
- let e = ve(p.operation.requestBody)?.content ?? {}, t = p.selectedContentType || Object.keys(e)[0];
71
+ let be = F, I = o(() => {
72
+ let e = me(p.operation.requestBody)?.content ?? {}, t = p.selectedContentType || Object.keys(e)[0];
73
73
  return t ? e[t]?.examples ?? {} : {};
74
74
  }), L = h(""), R = (e) => {
75
75
  let t = Object.keys(I.value);
76
76
  return e && t.includes(e) ? e : L.value && t.includes(L.value) ? L.value : t[0] ?? "";
77
77
  };
78
- oe(() => {
79
- L.value = R(p.selectedExample);
80
- }), y(() => p.selectedExample, (e) => {
78
+ L.value = R(p.selectedExample), y(() => p.selectedExample, (e) => {
81
79
  L.value = R(e);
82
80
  }), y(() => p.selectedContentType, () => {
83
81
  Object.keys(I.value).includes(L.value) || (L.value = R(p.selectedExample));
84
- }), ce(() => {
85
- xe("update:exampleKey", L.value);
82
+ }), se(() => {
83
+ be("update:exampleKey", L.value);
86
84
  });
87
- let Se = (e) => {
85
+ let xe = (e) => {
88
86
  L.value = e, p.eventBus.emit("workspace:update:selected-example", e);
89
87
  }, z = o(() => te(p.operation)), B = o(() => ne(z.value.samples, p.clientOptions, z.value.label)), V = o(() => B.value.reduce((e, t) => e + t.options.length, 0)), H = h(n(B.value, p.selectedClient));
90
88
  y([() => p.selectedClient, B], ([e]) => {
91
89
  let t = n(B.value, e);
92
90
  t && (H.value = t);
93
91
  });
94
- let Ce = o(() => [p.clientPickerLabel, H.value?.title].filter(Boolean).join(": ")), we = o(() => [p.codeSampleLabel, H.value?.title].filter(Boolean).join(": ")), U = h(null), Te = T(U), W = E(() => ye(p.operation, L.value, p.selectedContentType), () => Te.value), G = o(() => w(p.operation, L.value, p.selectedContentType, W.resolve)), K = o(() => Object.keys(I.value).length > 1), q = o(() => {
92
+ let Se = o(() => [p.clientPickerLabel, H.value?.title].filter(Boolean).join(": ")), Ce = o(() => [p.codeSampleLabel, H.value?.title].filter(Boolean).join(": ")), U = h(null), we = w(U), W = T(() => ve(p.operation, L.value, p.selectedContentType), () => we.value), G = o(() => ye(p.operation, L.value, p.selectedContentType, W.resolve)), K = o(() => Object.keys(I.value).length > 1), q = o(() => {
95
93
  if (!p.isWebhook) return null;
96
94
  try {
97
95
  return r({
@@ -121,11 +119,11 @@ var D = ["innerHTML"], O = {
121
119
  globalCookies: p.globalCookies,
122
120
  openapiVersion: p.openapiVersion,
123
121
  requestBodyCompositionSelection: p.requestBodyCompositionSelection
124
- })), Y = o(() => !p.isWebhook && H.value?.id.startsWith("custom/") && J.value !== null && p.securitySchemes.some((e) => "x-scalar-credential-placeholders" in e) ? pe(J.value, p.securitySchemes) : void 0), X = o(() => Y.value?.content ?? J.value), Z = o(() => Y.value?.displayContent ?? X.value), Q = o(() => p.isWebhook ? Ee.value : H.value?.lang), Ee = o(() => {
122
+ })), Y = o(() => !p.isWebhook && H.value?.id.startsWith("custom/") && J.value !== null && p.securitySchemes.some((e) => "x-scalar-credential-placeholders" in e) ? fe(J.value, p.securitySchemes) : void 0), X = o(() => Y.value?.content ?? J.value), Z = o(() => Y.value?.displayContent ?? X.value), Q = o(() => p.isWebhook ? Te.value : H.value?.lang), Te = o(() => {
125
123
  if (!q.value?.postData) return "json";
126
124
  let e = q.value.postData.mimeType;
127
125
  return e?.includes("json") ? "json" : e?.includes("xml") ? "xml" : e?.includes("yaml") || e?.includes("yml") ? "yaml" : e?.includes("text/plain") ? "text" : "json";
128
- }), De = o(() => Y.value ? [] : re(p.securitySchemes)), Oe = (e) => {
126
+ }), Ee = o(() => Y.value ? [] : re(p.securitySchemes)), De = (e) => {
129
127
  if (U.value) {
130
128
  let e = _e(U.value.$el);
131
129
  setTimeout(() => {
@@ -133,7 +131,7 @@ var D = ["innerHTML"], O = {
133
131
  }, 300);
134
132
  }
135
133
  H.value = e, e && p.eventBus.emit("workspace:update:selected-client", e.id);
136
- }, ke = o(() => (X.value?.length ?? 0) > 2e4), $ = se();
134
+ }, Oe = o(() => (X.value?.length ?? 0) > 2e4), $ = oe();
137
135
  return (n, r) => X.value === null || X.value || v(W).pending.value ? (m(), s(v(x), {
138
136
  key: 0,
139
137
  ref_key: "elem",
@@ -141,7 +139,7 @@ var D = ["innerHTML"], O = {
141
139
  class: "request-card dark-mode"
142
140
  }, {
143
141
  default: b(() => [
144
- f(v(ue), { class: "pr-2.5" }, ie({
142
+ f(v(le), { class: "pr-2.5" }, ie({
145
143
  default: b(() => [
146
144
  r[1] ||= u("span", { class: "sr-only" }, "Request Example for", -1),
147
145
  f(i, {
@@ -152,7 +150,7 @@ var D = ["innerHTML"], O = {
152
150
  p.generateLabel ? (m(), l("span", {
153
151
  key: 0,
154
152
  innerHTML: p.generateLabel()
155
- }, null, 8, D)) : c("", !0),
153
+ }, null, 8, E)) : c("", !0),
156
154
  g(n.$slots, "header", {}, void 0, !0)
157
155
  ]),
158
156
  _: 2
@@ -167,15 +165,15 @@ var D = ["innerHTML"], O = {
167
165
  options: B.value,
168
166
  placement: "bottom-end",
169
167
  teleport: "",
170
- "onUpdate:modelValue": r[0] ||= (e) => Oe(e)
168
+ "onUpdate:modelValue": r[0] ||= (e) => De(e)
171
169
  }, {
172
170
  default: b(() => [f(v(C), {
173
- "aria-label": Ce.value,
171
+ "aria-label": Se.value,
174
172
  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",
175
173
  "data-testid": "client-picker",
176
174
  variant: "ghost"
177
175
  }, {
178
- default: b(() => [d(_(H.value?.title) + " ", 1), f(v(me), {
176
+ default: b(() => [d(_(H.value?.title) + " ", 1), f(v(pe), {
179
177
  class: "ui-open:rotate-180 mt-px size-3 transition-transform duration-100",
180
178
  weight: "bold"
181
179
  })]),
@@ -187,22 +185,22 @@ var D = ["innerHTML"], O = {
187
185
  "inputLabel",
188
186
  "modelValue",
189
187
  "options"
190
- ])) : (m(), l("span", O, _(H.value?.title), 1))]),
188
+ ])) : (m(), l("span", D, _(H.value?.title), 1))]),
191
189
  key: "0"
192
190
  } : void 0]), 1024),
193
191
  f(v(S), { class: "request-editor-section custom-scroll p-0" }, {
194
- default: b(() => [v(W).pending.value ? (m(), l("div", k, [v(W).failed.value ? (m(), l(a, { key: 0 }, [r[3] ||= d(" Could not load this example. ", -1), f(v(C), {
192
+ default: b(() => [v(W).pending.value ? (m(), l("div", O, [v(W).failed.value ? (m(), l(a, { key: 0 }, [r[3] ||= d(" Could not load this example. ", -1), f(v(C), {
195
193
  size: "sm",
196
194
  variant: "ghost",
197
195
  onClick: v(W).retry
198
196
  }, {
199
197
  default: b(() => [...r[2] ||= [d(" Retry ", -1)]]),
200
198
  _: 1
201
- }, 8, ["onClick"])], 64)) : (m(), l(a, { key: 1 }, [d("Loading example…")], 64))])) : X.value === null ? (m(), l("div", A, _(p.codeSampleUnavailable), 1)) : (m(), l("div", {
199
+ }, 8, ["onClick"])], 64)) : (m(), l(a, { key: 1 }, [d("Loading example…")], 64))])) : X.value === null ? (m(), l("div", k, _(p.codeSampleUnavailable), 1)) : (m(), l("div", {
202
200
  key: 2,
203
201
  id: `${v($)}-example`,
204
202
  class: "code-snippet group/code-block relative"
205
- }, [ke.value ? (m(), l(a, { key: 1 }, [f(v(fe), {
203
+ }, [Oe.value ? (m(), l(a, { key: 1 }, [f(v(de), {
206
204
  "aria-controls": `${v($)}-virtual-code`,
207
205
  class: "scalar-code-copy absolute top-2.5 right-2.5 z-1",
208
206
  content: X.value,
@@ -214,18 +212,18 @@ var D = ["innerHTML"], O = {
214
212
  ]), f(v(ge), {
215
213
  id: `${v($)}-virtual-code`,
216
214
  "aria-label": "Request code sample",
217
- containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
215
+ containerClass: "custom-scroll scalar-code-block flex flex-1 max-h-screen",
218
216
  contentClass: "language-plaintext whitespace-pre font-code text-base p-2",
219
217
  lineHeight: 20,
220
218
  role: "region",
221
219
  text: Z.value ?? ""
222
- }, null, 8, ["id", "text"])], 64)) : (m(), s(v(de), {
220
+ }, null, 8, ["id", "text"])], 64)) : (m(), s(v(ue), {
223
221
  key: 0,
224
- class: "bg-b-2 h-full",
222
+ class: "h-full bg-transparent",
225
223
  content: Z.value ?? "",
226
224
  copyContent: Y.value ? X.value ?? "" : void 0,
227
- hideCredentials: De.value,
228
- label: we.value,
225
+ hideCredentials: Ee.value,
226
+ label: Ce.value,
229
227
  lang: Q.value,
230
228
  lineNumbers: ""
231
229
  }, null, 8, [
@@ -234,19 +232,19 @@ var D = ["innerHTML"], O = {
234
232
  "hideCredentials",
235
233
  "label",
236
234
  "lang"
237
- ]))], 8, j))]),
235
+ ]))], 8, A))]),
238
236
  _: 1
239
237
  }),
240
- K.value || n.$slots.footer || n.$slots["footer-start"] ? (m(), s(v(le), {
238
+ K.value || n.$slots.footer || n.$slots["footer-start"] ? (m(), s(v(ce), {
241
239
  key: 0,
242
- class: ae(["request-card-footer bg-b-3", { "request-card-footer--wraps": !K.value && n.$slots["footer-start"] }])
240
+ class: ae(["request-card-footer", { "request-card-footer--wraps": !K.value && n.$slots["footer-start"] }])
243
241
  }, {
244
- default: b(() => [K.value ? (m(), l("div", M, [Object.keys(I.value).length ? (m(), s(e, {
242
+ default: b(() => [K.value ? (m(), l("div", j, [Object.keys(I.value).length ? (m(), s(e, {
245
243
  key: 0,
246
244
  examples: I.value,
247
245
  modelValue: L.value,
248
- "onUpdate:modelValue": Se
249
- }, null, 8, ["examples", "modelValue"])) : c("", !0)])) : n.$slots["footer-start"] ? (m(), l("div", N, [g(n.$slots, "footer-start", {}, void 0, !0)])) : c("", !0), g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)]),
246
+ "onUpdate:modelValue": xe
247
+ }, null, 8, ["examples", "modelValue"])) : c("", !0)])) : n.$slots["footer-start"] ? (m(), l("div", M, [g(n.$slots, "footer-start", {}, void 0, !0)])) : c("", !0), g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)]),
250
248
  _: 3
251
249
  }, 8, ["class"])) : c("", !0)
252
250
  ]),
@@ -255,12 +253,12 @@ var D = ["innerHTML"], O = {
255
253
  key: 1,
256
254
  class: "request-card dark-mode"
257
255
  }, {
258
- default: b(() => [f(v(S), { class: "request-card-simple" }, {
259
- default: b(() => [u("div", P, [f(i, {
256
+ default: b(() => [f(v(S), { class: "request-card-simple bg-transparent shadow-none" }, {
257
+ default: b(() => [u("div", N, [f(i, {
260
258
  as: "span",
261
259
  class: "request-method",
262
260
  method: p.method
263
- }, null, 8, ["method"]), g(n.$slots, "header", {}, void 0, !0)]), n.$slots.footer ? (m(), l("div", be, [g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)])) : c("", !0)]),
261
+ }, null, 8, ["method"]), g(n.$slots, "header", {}, void 0, !0)]), n.$slots.footer ? (m(), l("div", P, [g(n.$slots, "footer", { exampleName: L.value }, void 0, !0)])) : c("", !0)]),
264
262
  _: 3
265
263
  })]),
266
264
  _: 3