@scalar/blocks 0.1.8 → 0.1.10

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 (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  4. package/dist/code-example/components/CodeExample.vue.js +1 -1
  5. package/dist/code-example/components/CodeExample.vue.script.js +1 -1
  6. package/dist/code-example/components/CodeExample.vue.script.js.map +1 -1
  7. package/dist/code-example/components/ExamplePicker.vue.script.js +2 -2
  8. package/dist/code-example/components/ExamplePicker.vue.script.js.map +1 -1
  9. package/dist/code-example/components/HttpMethod.vue.script.js +1 -1
  10. package/dist/code-example/components/HttpMethod.vue.script.js.map +1 -1
  11. package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
  12. package/dist/code-example/helpers/find-client.js.map +1 -1
  13. package/dist/code-example/helpers/format-language.js.map +1 -1
  14. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  15. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  16. package/dist/code-example/helpers/get-clients.js.map +1 -1
  17. package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
  18. package/dist/code-example/helpers/get-secrets.js.map +1 -1
  19. package/dist/code-example/helpers/get-snippet.js.map +1 -1
  20. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  21. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  22. package/dist/code-example/helpers/operation-to-har/process-body.js +34 -32
  23. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  24. package/dist/code-example/helpers/operation-to-har/process-parameters.js +1 -1
  25. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  26. package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  27. package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
  28. package/dist/code-example/mount.js.map +1 -1
  29. package/dist/constants.js +1 -1
  30. package/dist/style.css +2239 -2807
  31. package/package.json +17 -26
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scalar/blocks
2
2
 
3
+ ## 0.1.10
4
+
5
+ ## 0.1.9
6
+
7
+ ### Patch Changes
8
+
9
+ - [#9752](https://github.com/scalar/scalar/pull/9752): fix: stop vendoring a second copy of the themes reset in the standalone stylesheet
10
+
11
+ The blocks `style.css` build pulled in `@scalar/components/style.css`, which re-imports `@scalar/themes/style.css` — so the published stylesheet shipped two unlayered copies of the universal reset. Loaded after the other Scalar packages, the late duplicate clobbered component font sizes, padding, and colors. Blocks now composes the lean `@scalar/components/vue-styles.css` instead, matching how `@scalar/api-reference` and `@scalar/components` build their stylesheets, and exposes `./vue-styles.css` alongside `./style.css` and `./tailwind.config.css`.
12
+
13
+ - [#9689](https://github.com/scalar/scalar/pull/9689): fix: multipart/form-data array-of-objects fields now serialize as a JSON array instead of a single object in generated request examples
14
+
3
15
  ## 0.1.8
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -8,7 +8,7 @@ Scalar is an open-source API platform for teams who want beautiful developer int
8
8
 
9
9
  - **[API References](https://scalar.com/products/api-references/getting-started)** — Interactive API documentation from OpenAPI and AsyncAPI specs.
10
10
  - **[Developer Docs](https://scalar.com/products/docs/getting-started)** — Write in Markdown/MDX, generate API references, sync with two-way Git.
11
- - **[SDK Generator](https://scalar.com/products/sdks/getting-started)** — Type-safe SDKs and CLIs in TypeScript, Python, Go, PHP, Java, and Ruby.
11
+ - **[SDK Generator](https://scalar.com/products/sdk-generator/getting-started)** — Type-safe SDKs and CLIs in TypeScript, Python, Go, PHP, Java, and Ruby.
12
12
  - **[API Client](https://scalar.com/products/api-client/getting-started)** — Open-source, offline-first Postman alternative built on OpenAPI.
13
13
 
14
14
  20M+ monthly npm installs · 15,500+ GitHub stars · MIT licensed · [scalar.com](https://scalar.com)
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/CodeExample.vue"],"names":[],"mappings":"AAukBA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAErF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAkBrE,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,UAAU,CAAA;AAKjB,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,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,cAAc,CAAA;IACtB;;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,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAkCR,MAAM,OAAO;YACb,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAsmB3D,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":"AAukBA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAErF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAkBrE,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,UAAU,CAAA;AAKjB,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,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,cAAc,CAAA;IACtB;;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,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;YAkCR,MAAM,OAAO;YACb,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;EAwmB3D,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 "./CodeExample.vue.script.js";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  //#region src/code-example/components/CodeExample.vue
5
- var n = /* @__PURE__ */ t(e, [["__scopeId", "data-v-e8761738"]]);
5
+ var n = /*#__PURE__*/ t(e, [["__scopeId", "data-v-e8761738"]]);
6
6
  //#endregion
7
7
  export { n as default };
8
8
 
@@ -24,7 +24,7 @@ var I = ["innerHTML"], L = {
24
24
  }, R = ["id"], z = {
25
25
  key: 0,
26
26
  class: "request-card-footer-addon"
27
- }, B = { class: "request-header" }, V = /* @__PURE__ */ _({
27
+ }, B = { class: "request-header" }, V = /*@__PURE__*/ _({
28
28
  __name: "CodeExample",
29
29
  props: {
30
30
  integration: {},
@@ -1 +1 @@
1
- {"version":3,"file":"CodeExample.vue.script.js","names":["$slots"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\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: HttpMethodType\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 requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport type { HttpMethod as HttpMethodType } from '@scalar/helpers/http/http-methods'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/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 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 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 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/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation,\n method,\n path,\n example: localExampleKey.value,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string>(() => {\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,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n requestBodyCompositionSelection,\n })\n})\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes))\n\n/** Grab the ref to freeze the ui as the clients change so there's no jump as the size of the dom changes */\nconst elem = ref<ComponentPublicInstance | null>(null)\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=\"generatedCode\"\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 :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\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 :id=\"`${id}-example`\"\n class=\"code-snippet\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"bg-b-2 h-full\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <ScalarVirtualText\n v-else\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 :text=\"generatedCode\" />\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"Object.keys(requestBodyExamples).length > 1 || $slots.footer\"\n class=\"request-card-footer bg-b-3\">\n <!-- Example picker -->\n <div\n v-if=\"Object.keys(requestBodyExamples).length > 1\"\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\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <ScalarCardSection class=\"request-card-simple\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n text-transform: uppercase;\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.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1;\n min-width: 0;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n.request-card-simple {\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyLA,IAAM,IAAO,GAiBP,IAAsB,QAAe;GACzC,IAAM,IAAU,EAAe,EAAA,UAAU,YAAY,EAAE,WAAW,EAAC,EAC7D,IAAc,EAAA,uBAAuB,OAAO,KAAK,EAAQ,CAAC;AAKhE,UAJK,IAEY,EAAQ,IAAc,YAAY,EAAC,GAF3B,EAAC;IAK3B,EASK,IAAkB,EAAI,GAAE,EAGxB,KAAqB,MAA0C;GACnE,IAAM,IAAO,OAAO,KAAK,EAAoB,MAAK;AAQlD,UAPI,KAAa,EAAK,SAAS,EAAU,GAChC,IAGL,EAAgB,SAAS,EAAK,SAAS,EAAgB,MAAM,GACxD,EAAgB,QAElB,EAAK,MAAM;;AAgCpB,EA5BA,SAAoB;AAClB,KAAgB,QAAQ,EAAkB,EAAA,gBAAe;IAC1D,EAGD,QACQ,EAAA,kBACL,MAAc;AACb,KAAgB,QAAQ,EAAkB,EAAS;IAEvD,EAGA,QACQ,EAAA,2BACA;AACJ,GACG,OAAO,KAAK,EAAoB,MAAM,CAAC,SAAS,EAAgB,MAAK,KAItE,EAAgB,QAAQ,EAAkB,EAAA,gBAAe;IAG/D,EAIA,QAAkB;AAChB,KAAK,qBAAqB,EAAgB,MAAK;IAChD;EAGD,IAAM,KAAiB,MAAgB;AAErC,GADA,EAAgB,QAAQ,GACxB,EAAA,SAAS,KAAK,qCAAqC,EAAG;KAIlD,IAAoB,QAAe,EAAqB,EAAA,UAAU,CAAA,EAGlE,IAAU,QACd,EACE,EAAkB,MAAM,SACxB,EAAA,eACA,EAAkB,MAAM,MACzB,CACH,EAGM,IAAc,QAClB,EAAQ,MAAM,QAAQ,GAAO,MAAU,IAAQ,EAAM,QAAQ,QAAQ,EAAE,CACzE,EAGM,IAAsB,EAC1B,EAAW,EAAQ,OAAO,EAAA,eAAe,CAC3C;AAQA,IAAM,OAAO,EAAA,gBAAgB,EAAQ,GAAG,CAAC,OAAe;GACtD,IAAM,IAAS,EAAW,EAAQ,OAAO,EAAS;AAClD,GAAI,MACF,EAAoB,QAAQ;IAE/B;EAGD,IAAM,IAAa,QAAe;AAChC,OAAI,CAAC,EAAA,UAAW,QAAO;AAEvB,OAAI;AACF,WAAO,EAAe;KACpB,WAAQ,EAAA;KACR,QAAK,EAAA;KACL,MAAG,EAAA;KACH,SAAS,EAAgB;KACzB,iCAA8B,EAAA;KAG9B,2BAA2B;KAC5B,CAAA;YACM,GAAO;AAEd,WADA,QAAQ,MAAM,gBAAgB,EAAK,EAC5B;;IAEV,EAGK,IAAgB,QAChB,EAAA,YACK,EAAW,OAAO,UAAU,QAAQ,KAGtC,EAAoB;GAGzB,2BAA2B;GAC3B,uBAAuB,EAAA,gBAAgB;GACvC,UAAU,EAAoB,OAAO;GACrC,mBAAmB,EAAkB,MAAM;GAC3C,WAAQ,EAAA;GACR,QAAK,EAAA;GACL,MAAG,EAAA;GACH,aAAa,EAAA;GACb,QAAQ,EAAA;GACR,iBAAc,EAAA;GACd,SAAS,EAAgB;GACzB,eAAY,EAAA;GACZ,iCAA8B,EAAA;GAC/B,CAAA,CACF,EAGK,KAAoB,QACpB,EAAA,YACK,GAAgB,QAGlB,EAAoB,OAAO,KACnC,EAGK,KAAkB,QAAuB;AAC7C,OAAI,CAAC,EAAW,OAAO,SAAU,QAAO;GAExC,IAAM,IAAc,EAAW,MAAM,SAAS;AAO9C,UANI,GAAa,SAAS,OAAO,GAAS,SACtC,GAAa,SAAS,MAAM,GAAS,QACrC,GAAa,SAAS,OAAO,IAAI,GAAa,SAAS,MAAM,GACxD,SACL,GAAa,SAAS,aAAa,GAAS,SAEzC;IACR,EAGK,KAAoB,QAAe,EAAW,EAAA,gBAAgB,CAAA,EAG9D,IAAO,EAAoC,KAAI,EAG/C,MAAgB,MAAyB;AAE7C,OAAI,EAAK,OAAO;IACd,IAAM,IAAW,EAAc,EAAK,MAAM,IAAG;AAC7C,qBAAiB;AACf,QAAS;OACR,IAAG;;AAQR,GALA,EAAoB,QAAQ,GAKxB,KACF,EAAA,SAAS,KAAK,oCAAoC,EAAO,GAAE;KASzD,KAAmB,SAChB,EAAc,MAAM,UAAU,KAAK,IAC5C,EAEM,KAAK,GAAM;mBAIP,EAAA,SAAA,GAAA,EADR,EA2Fa,EAAA,EAAA,EAAA;;YAzFP;GAAJ,KAAI;GACJ,OAAM;;oBA4Ca;IA1CnB,EA0CmB,EAAA,GAAA,EAAA,EA1CD,OAAM,UAAQ,EAAA,EAAA;sBACkB;eAAhD,EAAgD,QAAA,EAA1C,OAAM,WAAS,EAAC,uBAAmB,GAAA;MACzC,EAGqB,GAAA;OAFnB,IAAG;OACH,OAAM;OACL,QAAQ,EAAA;;MAEH,EAAA,iBAAA,GAAA,EADR,EAE6B,QAAA;;OAA3B,WAAQ,EAAA,eAAa;;MACvB,EAAsB,EAAA,QAAA,UAAA,EAAA,EAAA,KAAA,GAAA,GAAA;;;SAGb,EAAA,aAAa,EAAA,QAAA;WACnB;iBAoBgB,CAjBT,EAAA,QAAW,KAAA,GAAA,EADnB,EAkBiB,EAAA,EAAA,EAAA;;MAhBf,OAAM;MACL,UAAU,EAAA,EAAoB;MAC9B,YAAY,EAAA;MACZ,SAAS,EAAA;MACV,WAAU;MACV,UAAA;MACC,uBAAiB,AAAA,EAAA,QAAA,MAAE,GAAa,EAAM;;uBASxB,CARf,EAQe,EAAA,EAAA,EAAA;OAPb,OAAM;OACN,eAAY;OACZ,SAAQ;;wBACwB,CAAA,EAAA,EAA7B,EAAA,OAAqB,MAAK,GAAG,KAChC,EAAA,EAAA,EAEkB,EAAA,EAAA,EAAA;QADhB,OAAM;QACN,QAAO;;;;;;;;;iBAIb,EAKO,QALP,GAKO,EADF,EAAA,OAAqB,MAAK,EAAA,EAAA,EAAA,CAAA;;;IAMnC,EAkBoB,EAAA,EAAA,EAAA,EAlBD,OAAM,4CAA0C,EAAA;sBAiB3D,CAhBN,EAgBM,OAAA;MAfH,IAAE,GAAK,EAAA,GAAE,CAAA;MACV,OAAM;SAEG,GAAA,cAMT,EAK0B,EAAA,EAAA,EAAA;;MAHxB,gBAAe;MACf,cAAa;MACZ,YAAY;MACZ,MAAM,EAAA;+BAXA,GAAA,EADT,EAMgB,EAAA,EAAA,EAAA;;MAJd,OAAM;MACL,SAAS,EAAA;MACT,iBAAiB,GAAA;MACjB,MAAM,GAAA;MACP,aAAA;;;;;;;;IAYE,OAAO,KAAK,EAAA,MAAmB,CAAE,SAAM,KAAQA,EAAAA,OAAO,UAAA,GAAA,EAD9D,EAmBmB,EAAA,GAAA,EAAA;;KAjBjB,OAAM;;sBAWA,CARE,OAAO,KAAK,EAAA,MAAmB,CAAE,SAAM,KAAA,GAAA,EAD/C,EASM,OATN,GASM,CANY,OAAO,KAAK,EAAA,MAAmB,CAAE,UAAA,GAAA,EAC/C,EAGuC,GAAA;;MAFpC,UAAU,EAAA;MACV,YAAY,EAAA;MACZ,uBAAmB;0EAK1B,EAEkB,EAAA,QAAA,UAAA,EADf,aAAa,EAAA,OAAe,EAAA,KAAA,GAAA,GAAA,CAAA,CAAA;;;;;aAOtB,EAAA,YAAA,GAAA,EADb,EAea,EAAA,EAAA,EAAA;;GAbX,OAAM;;oBAYc,CAXpB,EAWoB,EAAA,EAAA,EAAA,EAXD,OAAM,uBAAqB,EAAA;qBAOtC,CANN,EAMM,OANN,GAMM,CALJ,EAGqB,GAAA;KAFnB,IAAG;KACH,OAAM;KACL,QAAQ,EAAA;6BACX,EAAsB,EAAA,QAAA,UAAA,EAAA,EAAA,KAAA,GAAA,GAAA,CAAA,CAAA,EAExB,EAEkB,EAAA,QAAA,UAAA,EADf,aAAa,EAAA,OAAe,EAAA,KAAA,GAAA,GAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"CodeExample.vue.script.js","names":["$slots"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\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: HttpMethodType\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 requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport type { HttpMethod as HttpMethodType } from '@scalar/helpers/http/http-methods'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/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 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 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 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/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation,\n method,\n path,\n example: localExampleKey.value,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string>(() => {\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,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n requestBodyCompositionSelection,\n })\n})\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes))\n\n/** Grab the ref to freeze the ui as the clients change so there's no jump as the size of the dom changes */\nconst elem = ref<ComponentPublicInstance | null>(null)\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=\"generatedCode\"\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 :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\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 :id=\"`${id}-example`\"\n class=\"code-snippet\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"bg-b-2 h-full\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <ScalarVirtualText\n v-else\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 :text=\"generatedCode\" />\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"Object.keys(requestBodyExamples).length > 1 || $slots.footer\"\n class=\"request-card-footer bg-b-3\">\n <!-- Example picker -->\n <div\n v-if=\"Object.keys(requestBodyExamples).length > 1\"\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\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <ScalarCardSection class=\"request-card-simple\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n text-transform: uppercase;\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.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1;\n min-width: 0;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n.request-card-simple {\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":"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"}
@@ -3,10 +3,10 @@ import { ScalarButton as f } from "@scalar/components/button";
3
3
  import { ScalarIconCaretDown as p } from "@scalar/icons";
4
4
  import { ScalarListbox as m } from "@scalar/components/listbox";
5
5
  //#region src/code-example/components/ExamplePicker.vue?vue&type=script&setup=true&lang.ts
6
- var h = { class: "min-w-0 flex-1 truncate" }, g = /* @__PURE__ */ i({
6
+ var h = { class: "min-w-0 flex-1 truncate" }, g = /*@__PURE__*/ i({
7
7
  inheritAttrs: !1,
8
8
  __name: "ExamplePicker",
9
- props: /* @__PURE__ */ a({ examples: { default: () => ({}) } }, {
9
+ props: /*@__PURE__*/ a({ examples: { default: () => ({}) } }, {
10
10
  modelValue: { required: !0 },
11
11
  modelModifiers: {}
12
12
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"ExamplePicker.vue.script.js","names":["$attrs"],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: example?.summary ?? key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAcA,IAAM,IAAqB,EAAmB,GAAA,aAE7C,EAIK,IAAiB,QACrB,OAAO,QAAQ,EAAA,SAAS,CAAC,KAAK,CAAC,GAAK,QAAc;GAChD,IAAI;GACJ,OAAO,GAAS,WAAW;GAC5B,EAAE,CACL,EAEM,IAAkB,EAA0C;GAChE,WACE,EAAe,MAAM,MAAM,EAAE,YAAS,MAAO,EAAmB,MAAM;GACxE,MAAM,MAAO,EAAmB,QAAQ,GAAG,MAAM;GAClD,CAAA;yBAIC,EAkBgB,EAAA,EAAA,EAAA;eAjBL,EAAA;4CAAe,QAAA;GACxB,OAAM;GACL,SAAS,EAAA;GACV,WAAU;GACV,UAAA;;oBAYe,CAXf,EAWe,EAAA,EAAA,EAXf,EAWe;IAVb,OAAM;IACN,eAAY;IACZ,SAAQ;MACAA,EAAAA,OAAM,EAAA;qBAGR,CAFN,EAEM,OAFN,GAEM,EADD,EAAA,OAAiB,SAAK,oBAAA,EAAA,EAAA,EAE3B,EAEkB,EAAA,EAAA,EAAA;KADhB,OAAM;KACN,QAAO"}
1
+ {"version":3,"file":"ExamplePicker.vue.script.js","names":["$attrs"],"sources":["../../../src/code-example/components/ExamplePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarListbox,\n type ScalarListboxOption,\n} from '@scalar/components/listbox'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { MediaTypeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nconst { examples = {} } = defineProps<{\n examples?: MediaTypeObject['examples'] | Record<string, string>\n}>()\n\nconst selectedExampleKey = defineModel<string>({\n required: true,\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst exampleOptions = computed<ScalarListboxOption[]>(() =>\n Object.entries(examples).map(([key, example]) => ({\n id: key,\n label: example?.summary ?? key,\n })),\n)\n\nconst selectedExample = computed<ScalarListboxOption | undefined>({\n get: () =>\n exampleOptions.value.find(({ id }) => id === selectedExampleKey.value),\n set: (v) => (selectedExampleKey.value = v?.id ?? ''),\n})\n</script>\n\n<template>\n <ScalarListbox\n v-model=\"selectedExample\"\n class=\"w-fit min-w-32\"\n :options=\"exampleOptions\"\n placement=\"bottom-start\"\n teleport>\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit min-w-0 gap-1.5 px-1.5 py-0.75 text-base font-normal\"\n data-testid=\"example-picker\"\n variant=\"ghost\"\n v-bind=\"$attrs\">\n <div class=\"min-w-0 flex-1 truncate\">\n {{ selectedExample?.label ?? 'Select an example' }}\n </div>\n <ScalarIconCaretDown\n class=\"ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarListbox>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAcA,IAAM,IAAqB,EAAmB,GAAA,YAE7C,GAIK,IAAiB,QACrB,OAAO,QAAQ,EAAA,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAK,QAAc;GAChD,IAAI;GACJ,OAAO,GAAS,WAAW;EAC7B,EAAE,CACJ,GAEM,IAAkB,EAA0C;GAChE,WACE,EAAe,MAAM,MAAM,EAAE,YAAS,MAAO,EAAmB,KAAK;GACvE,MAAM,MAAO,EAAmB,QAAQ,GAAG,MAAM;EACnD,CAAC;yBAIC,EAkBgB,EAAA,CAAA,GAAA;eAjBL,EAAA;4CAAe,QAAA;GACxB,OAAM;GACL,SAAS,EAAA;GACV,WAAU;GACV,UAAA;;oBAYe,CAXf,EAWe,EAAA,CAAA,GAXf,EAWe;IAVb,OAAM;IACN,eAAY;IACZ,SAAQ;MACAA,EAAAA,MAAM,GAAA;qBAGR,CAFN,EAEM,OAFN,GAEM,EADD,EAAA,OAAiB,SAAK,mBAAA,GAAA,CAAA,GAE3B,EAEkB,EAAA,CAAA,GAAA;KADhB,OAAM;KACN,QAAO"}
@@ -2,7 +2,7 @@ import { computed as e, createBlock as t, createTextVNode as n, defineComponent
2
2
  import { getHttpMethodInfo as u } from "@scalar/helpers/http/http-info";
3
3
  import { normalizeHttpMethod as d } from "@scalar/helpers/http/normalize-http-method";
4
4
  //#region src/code-example/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
5
- var f = /* @__PURE__ */ r({
5
+ var f = /*@__PURE__*/ r({
6
6
  __name: "HttpMethod",
7
7
  props: {
8
8
  as: {},
@@ -1 +1 @@
1
- {"version":3,"file":"HttpMethod.vue.script.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { normalizeHttpMethod } from '@scalar/helpers/http/normalize-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: HttpMethod | string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => normalizeHttpMethod(props.method))\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n class=\"uppercase\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAMA,IAAM,IAAQ,GAYR,IAAiB,QACrB,EAAkB,OAAO,EAAM,UAAU,GAAG,CAAC,CAC/C,EAGM,IAAa,QAAe,EAAoB,EAAM,OAAO,CAAA;yBAIjE,EAMY,EALL,EAAA,MAAE,OAAA,EAAA;GACP,OAAM;GACL,OAAK,EAAA,GAAK,EAAA,YAAQ,UAAc,EAAA,MAAe,UAAQ,CAAA;;oBAChD,CAAR,EAAQ,EAAA,QAAA,UAAA,EAAA,EAAA,MACR,EAAG,EAAA,QAAQ,EAAA,MAAe,QAAQ,EAAA,MAAU,EAAA,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"HttpMethod.vue.script.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { normalizeHttpMethod } from '@scalar/helpers/http/normalize-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: HttpMethod | string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => normalizeHttpMethod(props.method))\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n class=\"uppercase\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAMA,IAAM,IAAQ,GAYR,IAAiB,QACrB,EAAkB,OAAO,EAAM,UAAU,EAAE,CAAC,CAC9C,GAGM,IAAa,QAAe,EAAoB,EAAM,MAAM,CAAC;yBAIjE,EAMY,EALL,EAAA,MAAE,MAAA,GAAA;GACP,OAAM;GACL,OAAK,EAAA,GAAK,EAAA,YAAQ,UAAc,EAAA,MAAe,SAAQ,CAAA;;oBAChD,CAAR,EAAQ,EAAA,QAAA,SAAA,GAAA,EAAA,MACR,EAAG,EAAA,QAAQ,EAAA,MAAe,QAAQ,EAAA,KAAU,GAAA,CAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter-clients-by-query.js","names":[],"sources":["../../../src/code-example/helpers/filter-clients-by-query.ts"],"sourcesContent":["import type { ScalarComboboxFilterFunction } from '@scalar/components/combobox'\n\nimport type { CustomClientOptionGroup, CustomOrDefaultClientOption } from '../types'\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesOption = (option: CustomOrDefaultClientOption, query: string) => {\n const q = query.toLowerCase()\n return (\n option.label.toLowerCase().includes(q) ||\n option.clientKey.toLowerCase().includes(q) ||\n option.lang.toLowerCase().includes(q)\n )\n}\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesGroup = (group: CustomClientOptionGroup, query: string) => {\n const q = query.toLowerCase()\n return group.label.toLowerCase().includes(q) || group.key.toLowerCase().includes(q)\n}\n\n/**\n * Filters the clients based on a query\n *\n * When dealing with multiple groups, include all options from a group if the\n * group label itself matches — so searching \"JavaScript\" shows all JS clients.\n */\nexport const filterClientsByQuery = ((\n query: string,\n options: CustomOrDefaultClientOption[],\n groups: CustomClientOptionGroup[],\n): CustomOrDefaultClientOption[] => {\n if (query === '') {\n return options\n }\n\n const q = query.toLowerCase()\n\n // Only activate when more than one group is actually visible (has a label and options).\n const visibleGroupCount = groups ? groups.filter((g) => g.label && g.options.length > 0).length : 0\n\n if (groups && visibleGroupCount > 1) {\n const result: CustomOrDefaultClientOption[] = []\n for (const group of groups) {\n if (matchesGroup(group, q)) {\n result.push(...group.options)\n } else {\n result.push(...group.options.filter((o) => matchesOption(o, q)))\n }\n }\n return result\n }\n\n return options.filter((o) => matchesOption(o, q))\n}) satisfies ScalarComboboxFilterFunction<CustomOrDefaultClientOption, CustomClientOptionGroup>\n"],"mappings":";AAOA,IAAM,KAAiB,GAAqC,MAAkB;CAC5E,IAAM,IAAI,EAAM,aAAa;AAC7B,QACE,EAAO,MAAM,aAAa,CAAC,SAAS,EAAE,IACtC,EAAO,UAAU,aAAa,CAAC,SAAS,EAAE,IAC1C,EAAO,KAAK,aAAa,CAAC,SAAS,EAAE;GAOnC,KAAgB,GAAgC,MAAkB;CACtE,IAAM,IAAI,EAAM,aAAa;AAC7B,QAAO,EAAM,MAAM,aAAa,CAAC,SAAS,EAAE,IAAI,EAAM,IAAI,aAAa,CAAC,SAAS,EAAE;GASxE,MACX,GACA,GACA,MACkC;AAClC,KAAI,MAAU,GACZ,QAAO;CAGT,IAAM,IAAI,EAAM,aAAa,EAGvB,IAAoB,IAAS,EAAO,QAAQ,MAAM,EAAE,SAAS,EAAE,QAAQ,SAAS,EAAE,CAAC,SAAS;AAElG,KAAI,KAAU,IAAoB,GAAG;EACnC,IAAM,IAAwC,EAAE;AAChD,OAAK,IAAM,KAAS,EAClB,CAAI,EAAa,GAAO,EAAE,GACxB,EAAO,KAAK,GAAG,EAAM,QAAQ,GAE7B,EAAO,KAAK,GAAG,EAAM,QAAQ,QAAQ,MAAM,EAAc,GAAG,EAAE,CAAC,CAAC;AAGpE,SAAO;;AAGT,QAAO,EAAQ,QAAQ,MAAM,EAAc,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"filter-clients-by-query.js","names":[],"sources":["../../../src/code-example/helpers/filter-clients-by-query.ts"],"sourcesContent":["import type { ScalarComboboxFilterFunction } from '@scalar/components/combobox'\n\nimport type { CustomClientOptionGroup, CustomOrDefaultClientOption } from '../types'\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesOption = (option: CustomOrDefaultClientOption, query: string) => {\n const q = query.toLowerCase()\n return (\n option.label.toLowerCase().includes(q) ||\n option.clientKey.toLowerCase().includes(q) ||\n option.lang.toLowerCase().includes(q)\n )\n}\n\n/**\n * Checks if a client label, client key, or language matches a query\n */\nconst matchesGroup = (group: CustomClientOptionGroup, query: string) => {\n const q = query.toLowerCase()\n return group.label.toLowerCase().includes(q) || group.key.toLowerCase().includes(q)\n}\n\n/**\n * Filters the clients based on a query\n *\n * When dealing with multiple groups, include all options from a group if the\n * group label itself matches — so searching \"JavaScript\" shows all JS clients.\n */\nexport const filterClientsByQuery = ((\n query: string,\n options: CustomOrDefaultClientOption[],\n groups: CustomClientOptionGroup[],\n): CustomOrDefaultClientOption[] => {\n if (query === '') {\n return options\n }\n\n const q = query.toLowerCase()\n\n // Only activate when more than one group is actually visible (has a label and options).\n const visibleGroupCount = groups ? groups.filter((g) => g.label && g.options.length > 0).length : 0\n\n if (groups && visibleGroupCount > 1) {\n const result: CustomOrDefaultClientOption[] = []\n for (const group of groups) {\n if (matchesGroup(group, q)) {\n result.push(...group.options)\n } else {\n result.push(...group.options.filter((o) => matchesOption(o, q)))\n }\n }\n return result\n }\n\n return options.filter((o) => matchesOption(o, q))\n}) satisfies ScalarComboboxFilterFunction<CustomOrDefaultClientOption, CustomClientOptionGroup>\n"],"mappings":";AAOA,IAAM,KAAiB,GAAqC,MAAkB;CAC5E,IAAM,IAAI,EAAM,YAAY;CAC5B,OACE,EAAO,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,KACrC,EAAO,UAAU,YAAY,CAAC,CAAC,SAAS,CAAC,KACzC,EAAO,KAAK,YAAY,CAAC,CAAC,SAAS,CAAC;AAExC,GAKM,KAAgB,GAAgC,MAAkB;CACtE,IAAM,IAAI,EAAM,YAAY;CAC5B,OAAO,EAAM,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,KAAK,EAAM,IAAI,YAAY,CAAC,CAAC,SAAS,CAAC;AACpF,GAQa,MACX,GACA,GACA,MACkC;CAClC,IAAI,MAAU,IACZ,OAAO;CAGT,IAAM,IAAI,EAAM,YAAY,GAGtB,IAAoB,IAAS,EAAO,QAAQ,MAAM,EAAE,SAAS,EAAE,QAAQ,SAAS,CAAC,CAAC,CAAC,SAAS;CAElG,IAAI,KAAU,IAAoB,GAAG;EACnC,IAAM,IAAwC,CAAC;EAC/C,KAAK,IAAM,KAAS,GAClB,AAAI,EAAa,GAAO,CAAC,IACvB,EAAO,KAAK,GAAG,EAAM,OAAO,IAE5B,EAAO,KAAK,GAAG,EAAM,QAAQ,QAAQ,MAAM,EAAc,GAAG,CAAC,CAAC,CAAC;EAGnE,OAAO;CACT;CAEA,OAAO,EAAQ,QAAQ,MAAM,EAAc,GAAG,CAAC,CAAC;AAClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"find-client.js","names":[],"sources":["../../../src/code-example/helpers/find-client.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/snippetz'\n\nimport type { ClientOption, CustomClientOption, CustomClientOptionGroup } from '../types'\n\nexport const DEFAULT_CLIENT = 'shell/curl'\n\n/**\n * A selection the code sample picker understands: either a built-in client id\n * (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * The custom part is typed as `string & {}` rather than the `custom/${string}`\n * template literal: unioning that template literal with the (very large) built-in\n * client-id union trips TypeScript's \"union too complex\" limit inside Vue's\n * `defineProps` macro. `string & {}` keeps editor hints for the known client ids\n * without expanding the union.\n */\nexport type SelectedClientId = AvailableClients[number] | (string & {})\n\n/** Type guard to check if a string is a valid built-in client id */\nexport const isClient = (id: any): id is AvailableClients[number] => AVAILABLE_CLIENTS.includes(id)\n\n/** Type guard for any selection the picker can restore (built-in client or custom sample id) */\nexport const isSelectedClient = (id: any): id is SelectedClientId =>\n isClient(id) || (typeof id === 'string' && id.startsWith('custom/'))\n\n/**\n * Finds and returns the appropriate client option to select for an operation.\n *\n * Selection rules, given the globally selected client/sample id:\n *\n * 1. A custom sample is selected (`custom/<lang>`): show the matching sample on\n * this operation. If this operation has no sample for that exact language, we\n * keep showing a custom sample (its first one) so the selection stays \"global\".\n * 2. An explicit built-in client is selected: it wins, even when the operation\n * also has custom samples. This includes the default client (`shell/curl`):\n * a built-in id only reaches us through a real selection (config, persistence,\n * or the picker), never as an implicit default, so a deliberate cURL pick must\n * stick instead of snapping back to an SDK example.\n * 3. Otherwise (nothing selected yet): prefer a custom sample when the operation\n * has one, so custom examples are the default.\n * 4. Fall back to the default built-in client, then the first option.\n *\n * @param clientGroups - Array of client option groups, each containing a label and array of client options\n * @param clientId - Optional selection to restore (e.g. 'js/fetch' or 'custom/python')\n * @returns The selected client option, or undefined when there is nothing to select\n */\nexport const findClient = (\n clientGroups: CustomClientOptionGroup[],\n clientId?: SelectedClientId | undefined,\n): ClientOption | CustomClientOption | undefined => {\n const findById = (id: string) => {\n for (const group of clientGroups) {\n const option = group.options.find((option) => option.id === id)\n if (option) {\n return option\n }\n }\n return undefined\n }\n\n const firstCustom = clientGroups.find((group) => group.key === 'custom')?.options[0]\n\n // 1. A custom sample is selected: match the language, otherwise stay on a custom sample\n if (clientId?.startsWith('custom')) {\n return findById(clientId) ?? firstCustom ?? findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n }\n\n // 2. An explicit built-in client wins, even when custom samples exist. A built-in\n // id (including the default `shell/curl`) only reaches us through a real\n // selection, so it must stick rather than snap back to a custom sample.\n if (clientId) {\n const option = findById(clientId)\n if (option) {\n return option\n }\n }\n\n // 3. Nothing selected yet: prefer a custom sample when the operation has one\n if (firstCustom) {\n return firstCustom\n }\n\n // 4. Otherwise fall back to the default built-in client, then the first option\n return findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n}\n"],"mappings":";;AAIA,IAAa,IAAiB,cAejB,KAAY,MAA4C,EAAkB,SAAS,EAAG,EAGtF,KAAoB,MAC/B,EAAS,EAAG,IAAK,OAAO,KAAO,YAAY,EAAG,WAAW,UAAU,EAuBxD,KACX,GACA,MACkD;CAClD,IAAM,KAAY,MAAe;AAC/B,OAAK,IAAM,KAAS,GAAc;GAChC,IAAM,IAAS,EAAM,QAAQ,MAAM,MAAW,EAAO,OAAO,EAAG;AAC/D,OAAI,EACF,QAAO;;IAMP,IAAc,EAAa,MAAM,MAAU,EAAM,QAAQ,SAAS,EAAE,QAAQ;AAGlF,KAAI,GAAU,WAAW,SAAS,CAChC,QAAO,EAAS,EAAS,IAAI,KAAe,EAAA,aAAwB,IAAI,EAAa,IAAI,QAAQ;AAMnG,KAAI,GAAU;EACZ,IAAM,IAAS,EAAS,EAAS;AACjC,MAAI,EACF,QAAO;;AAUX,QALI,MAKG,EAAA,aAAwB,IAAI,EAAa,IAAI,QAAQ"}
1
+ {"version":3,"file":"find-client.js","names":[],"sources":["../../../src/code-example/helpers/find-client.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/snippetz'\n\nimport type { ClientOption, CustomClientOption, CustomClientOptionGroup } from '../types'\n\nexport const DEFAULT_CLIENT = 'shell/curl'\n\n/**\n * A selection the code sample picker understands: either a built-in client id\n * (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * The custom part is typed as `string & {}` rather than the `custom/${string}`\n * template literal: unioning that template literal with the (very large) built-in\n * client-id union trips TypeScript's \"union too complex\" limit inside Vue's\n * `defineProps` macro. `string & {}` keeps editor hints for the known client ids\n * without expanding the union.\n */\nexport type SelectedClientId = AvailableClients[number] | (string & {})\n\n/** Type guard to check if a string is a valid built-in client id */\nexport const isClient = (id: any): id is AvailableClients[number] => AVAILABLE_CLIENTS.includes(id)\n\n/** Type guard for any selection the picker can restore (built-in client or custom sample id) */\nexport const isSelectedClient = (id: any): id is SelectedClientId =>\n isClient(id) || (typeof id === 'string' && id.startsWith('custom/'))\n\n/**\n * Finds and returns the appropriate client option to select for an operation.\n *\n * Selection rules, given the globally selected client/sample id:\n *\n * 1. A custom sample is selected (`custom/<lang>`): show the matching sample on\n * this operation. If this operation has no sample for that exact language, we\n * keep showing a custom sample (its first one) so the selection stays \"global\".\n * 2. An explicit built-in client is selected: it wins, even when the operation\n * also has custom samples. This includes the default client (`shell/curl`):\n * a built-in id only reaches us through a real selection (config, persistence,\n * or the picker), never as an implicit default, so a deliberate cURL pick must\n * stick instead of snapping back to an SDK example.\n * 3. Otherwise (nothing selected yet): prefer a custom sample when the operation\n * has one, so custom examples are the default.\n * 4. Fall back to the default built-in client, then the first option.\n *\n * @param clientGroups - Array of client option groups, each containing a label and array of client options\n * @param clientId - Optional selection to restore (e.g. 'js/fetch' or 'custom/python')\n * @returns The selected client option, or undefined when there is nothing to select\n */\nexport const findClient = (\n clientGroups: CustomClientOptionGroup[],\n clientId?: SelectedClientId | undefined,\n): ClientOption | CustomClientOption | undefined => {\n const findById = (id: string) => {\n for (const group of clientGroups) {\n const option = group.options.find((option) => option.id === id)\n if (option) {\n return option\n }\n }\n return undefined\n }\n\n const firstCustom = clientGroups.find((group) => group.key === 'custom')?.options[0]\n\n // 1. A custom sample is selected: match the language, otherwise stay on a custom sample\n if (clientId?.startsWith('custom')) {\n return findById(clientId) ?? firstCustom ?? findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n }\n\n // 2. An explicit built-in client wins, even when custom samples exist. A built-in\n // id (including the default `shell/curl`) only reaches us through a real\n // selection, so it must stick rather than snap back to a custom sample.\n if (clientId) {\n const option = findById(clientId)\n if (option) {\n return option\n }\n }\n\n // 3. Nothing selected yet: prefer a custom sample when the operation has one\n if (firstCustom) {\n return firstCustom\n }\n\n // 4. Otherwise fall back to the default built-in client, then the first option\n return findById(DEFAULT_CLIENT) ?? clientGroups[0]?.options[0]\n}\n"],"mappings":";;AAIA,IAAa,IAAiB,cAejB,KAAY,MAA4C,EAAkB,SAAS,CAAE,GAGrF,KAAoB,MAC/B,EAAS,CAAE,KAAM,OAAO,KAAO,YAAY,EAAG,WAAW,SAAS,GAuBvD,KACX,GACA,MACkD;CAClD,IAAM,KAAY,MAAe;EAC/B,KAAK,IAAM,KAAS,GAAc;GAChC,IAAM,IAAS,EAAM,QAAQ,MAAM,MAAW,EAAO,OAAO,CAAE;GAC9D,IAAI,GACF,OAAO;EAEX;CAEF,GAEM,IAAc,EAAa,MAAM,MAAU,EAAM,QAAQ,QAAQ,CAAC,EAAE,QAAQ;CAGlF,IAAI,GAAU,WAAW,QAAQ,GAC/B,OAAO,EAAS,CAAQ,KAAK,KAAe,EAAA,YAAuB,KAAK,EAAa,EAAE,EAAE,QAAQ;CAMnG,IAAI,GAAU;EACZ,IAAM,IAAS,EAAS,CAAQ;EAChC,IAAI,GACF,OAAO;CAEX;CAQA,OALI,MAKG,EAAA,YAAuB,KAAK,EAAa,EAAE,EAAE,QAAQ;AAC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-language.js","names":[],"sources":["../../../src/code-example/helpers/format-language.ts"],"sourcesContent":["import { capitalize } from '@scalar/helpers/string/capitalize'\n\n/**\n * Display names for the most common languages found in custom code samples.\n *\n * Custom samples (`x-scalar-examples`, `x-readme`, `x-stainless-*`, …) carry a\n * free-form `lang` string that we otherwise show verbatim in the picker. This\n * map gives the common ones a properly cased label (e.g. `typescript` →\n * `TypeScript`). Anything not listed falls back to a simple capitalization.\n */\nconst LANGUAGE_LABELS: Record<string, string> = {\n c: 'C',\n clojure: 'Clojure',\n cpp: 'C++',\n 'c++': 'C++',\n csharp: 'C#',\n 'c#': 'C#',\n css: 'CSS',\n curl: 'cURL',\n dart: 'Dart',\n fsharp: 'F#',\n 'f#': 'F#',\n go: 'Go',\n golang: 'Go',\n graphql: 'GraphQL',\n html: 'HTML',\n http: 'HTTP',\n java: 'Java',\n javascript: 'JavaScript',\n js: 'JavaScript',\n json: 'JSON',\n kotlin: 'Kotlin',\n node: 'Node.js',\n nodejs: 'Node.js',\n objc: 'Objective-C',\n 'objective-c': 'Objective-C',\n ocaml: 'OCaml',\n php: 'PHP',\n powershell: 'PowerShell',\n py: 'Python',\n python: 'Python',\n r: 'R',\n ruby: 'Ruby',\n rust: 'Rust',\n scala: 'Scala',\n sh: 'Shell',\n shell: 'Shell',\n bash: 'Shell',\n sql: 'SQL',\n swift: 'Swift',\n ts: 'TypeScript',\n typescript: 'TypeScript',\n xml: 'XML',\n yaml: 'YAML',\n yml: 'YAML',\n}\n\n/**\n * Turn a free-form language identifier into a display label for the code sample picker.\n *\n * @param lang - The language identifier from a custom code sample (e.g. `typescript`)\n * @returns A properly cased label (e.g. `TypeScript`), or `undefined` when no language is given\n */\nexport const formatLanguage = (lang?: string): string | undefined => {\n if (!lang) {\n return undefined\n }\n\n return LANGUAGE_LABELS[lang.toLowerCase()] ?? capitalize(lang)\n}\n"],"mappings":";;AAUA,IAAM,IAA0C;CAC9C,GAAG;CACH,SAAS;CACT,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,IAAI;CACJ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;CACN,eAAe;CACf,OAAO;CACP,KAAK;CACL,YAAY;CACZ,IAAI;CACJ,QAAQ;CACR,GAAG;CACH,MAAM;CACN,MAAM;CACN,OAAO;CACP,IAAI;CACJ,OAAO;CACP,MAAM;CACN,KAAK;CACL,OAAO;CACP,IAAI;CACJ,YAAY;CACZ,KAAK;CACL,MAAM;CACN,KAAK;CACN,EAQY,KAAkB,MAAsC;AAC9D,OAIL,QAAO,EAAgB,EAAK,aAAa,KAAK,EAAW,EAAK"}
1
+ {"version":3,"file":"format-language.js","names":[],"sources":["../../../src/code-example/helpers/format-language.ts"],"sourcesContent":["import { capitalize } from '@scalar/helpers/string/capitalize'\n\n/**\n * Display names for the most common languages found in custom code samples.\n *\n * Custom samples (`x-scalar-examples`, `x-readme`, `x-stainless-*`, …) carry a\n * free-form `lang` string that we otherwise show verbatim in the picker. This\n * map gives the common ones a properly cased label (e.g. `typescript` →\n * `TypeScript`). Anything not listed falls back to a simple capitalization.\n */\nconst LANGUAGE_LABELS: Record<string, string> = {\n c: 'C',\n clojure: 'Clojure',\n cpp: 'C++',\n 'c++': 'C++',\n csharp: 'C#',\n 'c#': 'C#',\n css: 'CSS',\n curl: 'cURL',\n dart: 'Dart',\n fsharp: 'F#',\n 'f#': 'F#',\n go: 'Go',\n golang: 'Go',\n graphql: 'GraphQL',\n html: 'HTML',\n http: 'HTTP',\n java: 'Java',\n javascript: 'JavaScript',\n js: 'JavaScript',\n json: 'JSON',\n kotlin: 'Kotlin',\n node: 'Node.js',\n nodejs: 'Node.js',\n objc: 'Objective-C',\n 'objective-c': 'Objective-C',\n ocaml: 'OCaml',\n php: 'PHP',\n powershell: 'PowerShell',\n py: 'Python',\n python: 'Python',\n r: 'R',\n ruby: 'Ruby',\n rust: 'Rust',\n scala: 'Scala',\n sh: 'Shell',\n shell: 'Shell',\n bash: 'Shell',\n sql: 'SQL',\n swift: 'Swift',\n ts: 'TypeScript',\n typescript: 'TypeScript',\n xml: 'XML',\n yaml: 'YAML',\n yml: 'YAML',\n}\n\n/**\n * Turn a free-form language identifier into a display label for the code sample picker.\n *\n * @param lang - The language identifier from a custom code sample (e.g. `typescript`)\n * @returns A properly cased label (e.g. `TypeScript`), or `undefined` when no language is given\n */\nexport const formatLanguage = (lang?: string): string | undefined => {\n if (!lang) {\n return undefined\n }\n\n return LANGUAGE_LABELS[lang.toLowerCase()] ?? capitalize(lang)\n}\n"],"mappings":";;AAUA,IAAM,IAA0C;CAC9C,GAAG;CACH,SAAS;CACT,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,QAAQ;CACR,MAAM;CACN,IAAI;CACJ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;CACN,eAAe;CACf,OAAO;CACP,KAAK;CACL,YAAY;CACZ,IAAI;CACJ,QAAQ;CACR,GAAG;CACH,MAAM;CACN,MAAM;CACN,OAAO;CACP,IAAI;CACJ,OAAO;CACP,MAAM;CACN,KAAK;CACL,OAAO;CACP,IAAI;CACJ,YAAY;CACZ,KAAK;CACL,MAAM;CACN,KAAK;AACP,GAQa,KAAkB,MAAsC;CAC9D,OAIL,OAAO,EAAgB,EAAK,YAAY,MAAM,EAAW,CAAI;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-client-options.js","names":[],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n return seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id = `${group.key}/${plugin.client}` as AvailableClients[number]\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AAyBA,IAAa,KAAsB,MAAiD;CAClF,IAAM,oBAAc,IAAI,KAAqB;AAE7C,QAAO,EAAQ,KAAK,MAA+B;EACjD,IAAM,KAAQ,EAAO,QAAQ,aAAa,aAAa,EACjD,IAAO,EAAY,IAAI,EAAK,IAAI;AAGtC,SAFA,EAAY,IAAI,GAAM,IAAO,EAAE,EAExB,MAAS,IAAI,UAAU,MAAS,UAAU,EAAK,GAAG;GACzD;GASS,KAAyB,IAAmC,MAA2C;CAElH,IAAM,IAAoB,IAAI,IAAI,EAAe;AAoCjD,QAlCgB,GAAU,CACvB,SAAS,CACT,SAAS,MAAU;EAClB,IAAM,IAAU,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAM,IAAK,GAAG,EAAM,IAAI,GAAG,EAAO;AAOlC,UAJK,EAAkB,IAAI,EAAG,GAIvB;IACL;IACA,MAAM,EAAO,WAAW,SAAU,SAAmB,EAAM;IAC3D,OAAO,GAAG,EAAW,EAAM,MAAM,CAAC,GAAG,EAAO;IAC5C,OAAO,EAAO;IACd,WAAW,EAAM;IACjB,aAAa,EAAM;IACnB,WAAW,EAAO;IACnB,GAXQ,EAAE;IAYX;AAOF,SAJI,EAAQ,WAAW,IACd,EAAE,GAGJ;GACL,OAAO,EAAM;GACb,KAAK,EAAM;GACX;GACD;GACD"}
1
+ {"version":3,"file":"generate-client-options.js","names":[],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n return seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id = `${group.key}/${plugin.client}` as AvailableClients[number]\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AAyBA,IAAa,KAAsB,MAAiD;CAClF,IAAM,oBAAc,IAAI,IAAoB;CAE5C,OAAO,EAAQ,KAAK,MAA+B;EACjD,IAAM,KAAQ,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChD,IAAO,EAAY,IAAI,CAAI,KAAK;EAGtC,OAFA,EAAY,IAAI,GAAM,IAAO,CAAC,GAEvB,MAAS,IAAI,UAAU,MAAS,UAAU,EAAK,GAAG;CAC3D,CAAC;AACH,GAQa,KAAyB,IAAmC,MAA2C;CAElH,IAAM,IAAoB,IAAI,IAAI,CAAc;CAoChD,OAlCgB,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAM,IAAU,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAM,IAAK,GAAG,EAAM,IAAI,GAAG,EAAO;GAOlC,OAJK,EAAkB,IAAI,CAAE,IAItB;IACL;IACA,MAAM,EAAO,WAAW,SAAU,SAAmB,EAAM;IAC3D,OAAO,GAAG,EAAW,EAAM,KAAK,EAAE,GAAG,EAAO;IAC5C,OAAO,EAAO;IACd,WAAW,EAAM;IACjB,aAAa,EAAM;IACnB,WAAW,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJI,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAO,EAAM;GACb,KAAK,EAAM;GACX;EACF;CACF,CAEK;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-code-snippet.js","names":[],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: HttpMethod\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const index = ids.indexOf(clientId as CustomCodeSampleId)\n\n return customCodeSamples[index]?.source ?? 'Custom example not found'\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;AAyCA,IAAa,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,oCACA,mCACsC;AACtC,KAAI;AACF,MAAI,CAAC,EACH,QAAO;AAIT,MAAI,EAAS,WAAW,SAAS,CAI/B,QAAO,EAHK,EAAmB,EAAkB,CAC/B,QAAQ,EAA+B,GAExB,UAAU;EAG7C,IAAM,IAAa,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAEI,CAAC,GAAW,KAAa,EAAS,MAAM,IAAI,EAE5C,CAAC,GAAO,KAAW,EAAW,GAAW,GAAW,EAAW;AAMrE,SALI,KACF,QAAQ,MAAM,yBAAyB,EAAM,EACtC,EAAM,WAAW,mCAGnB;UACA,GAAO;AAEd,SADA,QAAQ,MAAM,yBAAyB,EAAM,EACtC"}
1
+ {"version":3,"file":"generate-code-snippet.js","names":[],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: HttpMethod\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const index = ids.indexOf(clientId as CustomCodeSampleId)\n\n return customCodeSamples[index]?.source ?? 'Custom example not found'\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;AAyCA,IAAa,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,oCACA,mCACsC;CACtC,IAAI;EACF,IAAI,CAAC,GACH,OAAO;EAIT,IAAI,EAAS,WAAW,QAAQ,GAI9B,OAAO,EAHK,EAAmB,CACjB,CAAA,CAAI,QAAQ,CAED,EAAM,EAAE,UAAU;EAG7C,IAAM,IAAa,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GAEK,CAAC,GAAW,KAAa,EAAS,MAAM,GAAG,GAE3C,CAAC,GAAO,KAAW,EAAW,GAAW,GAAW,CAAU;EAMpE,OALI,KACF,QAAQ,MAAM,yBAAyB,CAAK,GACrC,EAAM,WAAW,mCAGnB;CACT,SAAS,GAAO;EAEd,OADA,QAAQ,MAAM,yBAAyB,CAAK,GACrC;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-clients.js","names":[],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n // Handle custom code examples\n if (customCodeSamples.length) {\n // Language-keyed ids so the same sample can be selected across operations\n const ids = getCustomClientIds(customCodeSamples)\n\n const customClients = customCodeSamples.map((sample, index) => {\n const id = ids[index] ?? `custom/${index}`\n const label = sample.label || formatLanguage(sample.lang) || id\n const lang = (sample.lang as TargetId) || 'plaintext'\n\n return {\n id,\n lang,\n title: label,\n label,\n clientKey: 'custom',\n } satisfies CustomClientOption\n })\n\n return [\n {\n label,\n key: 'custom',\n options: customClients,\n },\n ...clientOptions,\n ]\n }\n\n return clientOptions\n}\n"],"mappings":";;;;AAgBA,IAAa,KACX,GACA,GACA,IAAgB,MACc;AAE9B,KAAI,EAAkB,QAAQ;EAE5B,IAAM,IAAM,EAAmB,EAAkB;AAgBjD,SAAO,CACL;GACE;GACA,KAAK;GACL,SAlBkB,EAAkB,KAAK,GAAQ,MAAU;IAC7D,IAAM,IAAK,EAAI,MAAU,UAAU,KAC7B,IAAQ,EAAO,SAAS,EAAe,EAAO,KAAK,IAAI;AAG7D,WAAO;KACL;KACA,MAJY,EAAO,QAAqB;KAKxC,OAAO;KACP;KACA,WAAW;KACZ;KACD;GAOC,EACD,GAAG,EACJ;;AAGH,QAAO"}
1
+ {"version":3,"file":"get-clients.js","names":[],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n // Handle custom code examples\n if (customCodeSamples.length) {\n // Language-keyed ids so the same sample can be selected across operations\n const ids = getCustomClientIds(customCodeSamples)\n\n const customClients = customCodeSamples.map((sample, index) => {\n const id = ids[index] ?? `custom/${index}`\n const label = sample.label || formatLanguage(sample.lang) || id\n const lang = (sample.lang as TargetId) || 'plaintext'\n\n return {\n id,\n lang,\n title: label,\n label,\n clientKey: 'custom',\n } satisfies CustomClientOption\n })\n\n return [\n {\n label,\n key: 'custom',\n options: customClients,\n },\n ...clientOptions,\n ]\n }\n\n return clientOptions\n}\n"],"mappings":";;;;AAgBA,IAAa,KACX,GACA,GACA,IAAgB,MACc;CAE9B,IAAI,EAAkB,QAAQ;EAE5B,IAAM,IAAM,EAAmB,CAAiB;EAgBhD,OAAO,CACL;GACE;GACA,KAAK;GACL,SAlBkB,EAAkB,KAAK,GAAQ,MAAU;IAC7D,IAAM,IAAK,EAAI,MAAU,UAAU,KAC7B,IAAQ,EAAO,SAAS,EAAe,EAAO,IAAI,KAAK;IAG7D,OAAO;KACL;KACA,MAJY,EAAO,QAAqB;KAKxC,OAAO;KACP;KACA,WAAW;IACb;GACF,CAMa;EACX,GACA,GAAG,CACL;CACF;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-custom-code-samples.js","names":[],"sources":["../../../src/code-example/helpers/get-custom-code-samples.ts"],"sourcesContent":["import type {\n XCodeSample,\n XLanguageExample,\n XReadmeCodeSample,\n} from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/** Turns a `{ language: source }` map (x-stainless-snippets) into code samples. */\nconst fromSnippetMap = (snippets: Record<string, string> | undefined, label?: string): XCodeSample[] =>\n Object.entries(snippets ?? {}).map(([lang, source]) => ({ lang, source, ...(label ? { label } : {}) }))\n\n/**\n * Turns `x-stainless-examples` / `x-scalar-examples` into code samples.\n *\n * Each example carries per-language request snippets and an optional title that\n * we surface as the picker label. The response is only used for documentation,\n * so it is ignored here.\n */\nconst fromLanguageExamples = (examples: XLanguageExample | XLanguageExample[] | undefined): XCodeSample[] => {\n if (!examples) {\n return []\n }\n\n return (Array.isArray(examples) ? examples : [examples]).flatMap((example) =>\n fromSnippetMap(example.request, example.title),\n )\n}\n\n/** Turns ReadMe's `x-readme.code-samples` into code samples. */\nconst fromReadmeSamples = (samples: XReadmeCodeSample[] | undefined): XCodeSample[] =>\n (samples ?? []).map((sample) => ({\n lang: sample.language,\n source: sample.code,\n ...(sample.name ? { label: sample.name } : {}),\n }))\n\n/** Picker group label for samples generated by an SDK provider (Scalar, Stainless, …). */\nconst SDK_GROUP_LABEL = 'SDK'\n\n/** Picker group label for generic or docs-platform samples (the standard `x-codeSamples` family, ReadMe, …). */\nexport const CODE_EXAMPLES_GROUP_LABEL = 'Code Examples'\n\ntype CustomCodeSampleGroupLabel = typeof SDK_GROUP_LABEL | typeof CODE_EXAMPLES_GROUP_LABEL\n\ntype CustomCodeSamples = {\n /**\n * Group label for the code sample picker.\n *\n * Samples that come from an SDK provider extension (`x-scalar-examples`,\n * `x-stainless-snippets`, `x-stainless-examples`) surface under \"SDK\". Generic\n * or docs-platform samples (`x-readme`, the `x-codeSamples` family) surface\n * under \"Code Examples\".\n */\n label: CustomCodeSampleGroupLabel\n /** The custom code samples, in picker order. */\n samples: XCodeSample[]\n}\n\n/**\n * Grabs any custom code samples from the operation.\n *\n * Several tools write code samples into OpenAPI under different extensions. When\n * more than one is present we use the highest-priority source only, rather than\n * showing duplicates from every tool. Priority, highest first:\n *\n * 1. `x-scalar-examples` (SDK)\n * 2. `x-stainless-snippets` (SDK, overrides `x-stainless-examples`)\n * 3. `x-stainless-examples` (SDK)\n * 4. `x-readme.code-samples` (Code Examples)\n * 5. `x-codeSamples` / `x-code-samples` / `x-custom-examples` (Code Examples)\n *\n * The winning source also determines the picker group label: SDK-provider\n * extensions surface under \"SDK\", everything else under \"Code Examples\".\n *\n * Note that Speakeasy does not have its own extension — it writes into the\n * standard `x-codeSamples`, so its snippets surface under \"Code Examples\".\n *\n * @param operation - The operation to get the custom code samples from\n * @returns The picker group label and the custom code samples which exist in the operation\n */\nexport const getCustomCodeSamples = (operation: OperationObject): CustomCodeSamples => {\n const scalarExamples = operation['x-scalar-examples'] ?? []\n if (scalarExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: scalarExamples }\n }\n\n const stainlessSnippets = fromSnippetMap(operation['x-stainless-snippets'])\n if (stainlessSnippets.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessSnippets }\n }\n\n const stainlessExamples = fromLanguageExamples(operation['x-stainless-examples'])\n if (stainlessExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessExamples }\n }\n\n const readmeSamples = fromReadmeSamples(operation['x-readme']?.['code-samples'])\n if (readmeSamples.length) {\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: readmeSamples }\n }\n\n const customCodeKeys = ['x-custom-examples', 'x-codeSamples', 'x-code-samples'] as const\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: customCodeKeys.flatMap((key) => operation[key] ?? []) }\n}\n"],"mappings":";AAQA,IAAM,KAAkB,GAA8C,MACpE,OAAO,QAAQ,KAAY,EAAE,CAAC,CAAC,KAAK,CAAC,GAAM,QAAa;CAAE;CAAM;CAAQ,GAAI,IAAQ,EAAE,UAAO,GAAG,EAAE;CAAG,EAAE,EASnG,KAAwB,MACvB,KAIG,MAAM,QAAQ,EAAS,GAAG,IAAW,CAAC,EAAS,EAAE,SAAS,MAChE,EAAe,EAAQ,SAAS,EAAQ,MAAM,CAC/C,GALQ,EAAE,EASP,KAAqB,OACxB,KAAW,EAAE,EAAE,KAAK,OAAY;CAC/B,MAAM,EAAO;CACb,QAAQ,EAAO;CACf,GAAI,EAAO,OAAO,EAAE,OAAO,EAAO,MAAM,GAAG,EAAE;CAC9C,EAAE,EAGC,IAAkB,OAGX,IAA4B,iBAwC5B,KAAwB,MAAkD;CACrF,IAAM,IAAiB,EAAU,wBAAwB,EAAE;AAC3D,KAAI,EAAe,OACjB,QAAO;EAAE,OAAO;EAAiB,SAAS;EAAgB;CAG5D,IAAM,IAAoB,EAAe,EAAU,wBAAwB;AAC3E,KAAI,EAAkB,OACpB,QAAO;EAAE,OAAO;EAAiB,SAAS;EAAmB;CAG/D,IAAM,IAAoB,EAAqB,EAAU,wBAAwB;AACjF,KAAI,EAAkB,OACpB,QAAO;EAAE,OAAO;EAAiB,SAAS;EAAmB;CAG/D,IAAM,IAAgB,EAAkB,EAAU,cAAc,gBAAgB;AAMhF,QALI,EAAc,SACT;EAAE,OAAO;EAA2B,SAAS;EAAe,GAI9D;EAAE,OAAO;EAA2B,SADpB;GAAC;GAAqB;GAAiB;GAAiB,CACZ,SAAS,MAAQ,EAAU,MAAQ,EAAE,CAAC;EAAE"}
1
+ {"version":3,"file":"get-custom-code-samples.js","names":[],"sources":["../../../src/code-example/helpers/get-custom-code-samples.ts"],"sourcesContent":["import type {\n XCodeSample,\n XLanguageExample,\n XReadmeCodeSample,\n} from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/** Turns a `{ language: source }` map (x-stainless-snippets) into code samples. */\nconst fromSnippetMap = (snippets: Record<string, string> | undefined, label?: string): XCodeSample[] =>\n Object.entries(snippets ?? {}).map(([lang, source]) => ({ lang, source, ...(label ? { label } : {}) }))\n\n/**\n * Turns `x-stainless-examples` / `x-scalar-examples` into code samples.\n *\n * Each example carries per-language request snippets and an optional title that\n * we surface as the picker label. The response is only used for documentation,\n * so it is ignored here.\n */\nconst fromLanguageExamples = (examples: XLanguageExample | XLanguageExample[] | undefined): XCodeSample[] => {\n if (!examples) {\n return []\n }\n\n return (Array.isArray(examples) ? examples : [examples]).flatMap((example) =>\n fromSnippetMap(example.request, example.title),\n )\n}\n\n/** Turns ReadMe's `x-readme.code-samples` into code samples. */\nconst fromReadmeSamples = (samples: XReadmeCodeSample[] | undefined): XCodeSample[] =>\n (samples ?? []).map((sample) => ({\n lang: sample.language,\n source: sample.code,\n ...(sample.name ? { label: sample.name } : {}),\n }))\n\n/** Picker group label for samples generated by an SDK provider (Scalar, Stainless, …). */\nconst SDK_GROUP_LABEL = 'SDK'\n\n/** Picker group label for generic or docs-platform samples (the standard `x-codeSamples` family, ReadMe, …). */\nexport const CODE_EXAMPLES_GROUP_LABEL = 'Code Examples'\n\ntype CustomCodeSampleGroupLabel = typeof SDK_GROUP_LABEL | typeof CODE_EXAMPLES_GROUP_LABEL\n\ntype CustomCodeSamples = {\n /**\n * Group label for the code sample picker.\n *\n * Samples that come from an SDK provider extension (`x-scalar-examples`,\n * `x-stainless-snippets`, `x-stainless-examples`) surface under \"SDK\". Generic\n * or docs-platform samples (`x-readme`, the `x-codeSamples` family) surface\n * under \"Code Examples\".\n */\n label: CustomCodeSampleGroupLabel\n /** The custom code samples, in picker order. */\n samples: XCodeSample[]\n}\n\n/**\n * Grabs any custom code samples from the operation.\n *\n * Several tools write code samples into OpenAPI under different extensions. When\n * more than one is present we use the highest-priority source only, rather than\n * showing duplicates from every tool. Priority, highest first:\n *\n * 1. `x-scalar-examples` (SDK)\n * 2. `x-stainless-snippets` (SDK, overrides `x-stainless-examples`)\n * 3. `x-stainless-examples` (SDK)\n * 4. `x-readme.code-samples` (Code Examples)\n * 5. `x-codeSamples` / `x-code-samples` / `x-custom-examples` (Code Examples)\n *\n * The winning source also determines the picker group label: SDK-provider\n * extensions surface under \"SDK\", everything else under \"Code Examples\".\n *\n * Note that Speakeasy does not have its own extension — it writes into the\n * standard `x-codeSamples`, so its snippets surface under \"Code Examples\".\n *\n * @param operation - The operation to get the custom code samples from\n * @returns The picker group label and the custom code samples which exist in the operation\n */\nexport const getCustomCodeSamples = (operation: OperationObject): CustomCodeSamples => {\n const scalarExamples = operation['x-scalar-examples'] ?? []\n if (scalarExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: scalarExamples }\n }\n\n const stainlessSnippets = fromSnippetMap(operation['x-stainless-snippets'])\n if (stainlessSnippets.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessSnippets }\n }\n\n const stainlessExamples = fromLanguageExamples(operation['x-stainless-examples'])\n if (stainlessExamples.length) {\n return { label: SDK_GROUP_LABEL, samples: stainlessExamples }\n }\n\n const readmeSamples = fromReadmeSamples(operation['x-readme']?.['code-samples'])\n if (readmeSamples.length) {\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: readmeSamples }\n }\n\n const customCodeKeys = ['x-custom-examples', 'x-codeSamples', 'x-code-samples'] as const\n return { label: CODE_EXAMPLES_GROUP_LABEL, samples: customCodeKeys.flatMap((key) => operation[key] ?? []) }\n}\n"],"mappings":";AAQA,IAAM,KAAkB,GAA8C,MACpE,OAAO,QAAQ,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAM,QAAa;CAAE;CAAM;CAAQ,GAAI,IAAQ,EAAE,SAAM,IAAI,CAAC;AAAG,EAAE,GASlG,KAAwB,MACvB,KAIG,MAAM,QAAQ,CAAQ,IAAI,IAAW,CAAC,CAAQ,EAAA,CAAG,SAAS,MAChE,EAAe,EAAQ,SAAS,EAAQ,KAAK,CAC/C,IALS,CAAC,GASN,KAAqB,OACxB,KAAW,CAAC,EAAA,CAAG,KAAK,OAAY;CAC/B,MAAM,EAAO;CACb,QAAQ,EAAO;CACf,GAAI,EAAO,OAAO,EAAE,OAAO,EAAO,KAAK,IAAI,CAAC;AAC9C,EAAE,GAGE,IAAkB,OAGX,IAA4B,iBAwC5B,KAAwB,MAAkD;CACrF,IAAM,IAAiB,EAAU,wBAAwB,CAAC;CAC1D,IAAI,EAAe,QACjB,OAAO;EAAE,OAAO;EAAiB,SAAS;CAAe;CAG3D,IAAM,IAAoB,EAAe,EAAU,uBAAuB;CAC1E,IAAI,EAAkB,QACpB,OAAO;EAAE,OAAO;EAAiB,SAAS;CAAkB;CAG9D,IAAM,IAAoB,EAAqB,EAAU,uBAAuB;CAChF,IAAI,EAAkB,QACpB,OAAO;EAAE,OAAO;EAAiB,SAAS;CAAkB;CAG9D,IAAM,IAAgB,EAAkB,EAAU,WAAW,GAAG,eAAe;CAM/E,OALI,EAAc,SACT;EAAE,OAAO;EAA2B,SAAS;CAAc,IAI7D;EAAE,OAAO;EAA2B,SAAS;GAD5B;GAAqB;GAAiB;EACV,CAAA,CAAe,SAAS,MAAQ,EAAU,MAAQ,CAAC,CAAC;CAAE;AAC5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-secrets.js","names":[],"sources":["../../../src/code-example/helpers/get-secrets.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { encode } from 'js-base64'\n\n/** Extract secrets from security schemes */\nexport const getSecrets = (securitySchemes: SecuritySchemeObjectSecret[]): string[] =>\n securitySchemes\n .flatMap((scheme) => {\n if (scheme.type === 'apiKey') {\n return scheme['x-scalar-secret-token']\n }\n if (scheme?.type === 'http') {\n return [\n scheme['x-scalar-secret-token'],\n scheme['x-scalar-secret-username'],\n scheme['x-scalar-secret-password'],\n encode(`${scheme['x-scalar-secret-username']}:${scheme['x-scalar-secret-password']}`),\n ]\n }\n if (scheme.type === 'oauth2') {\n const flows = Object.values(scheme.flows)\n return flows.map((flow) => flow['x-scalar-secret-token'])\n }\n\n return []\n })\n .filter(Boolean)\n"],"mappings":";;AAIA,IAAa,KAAc,MACzB,EACG,SAAS,MACJ,EAAO,SAAS,WACX,EAAO,2BAEZ,GAAQ,SAAS,SACZ;CACL,EAAO;CACP,EAAO;CACP,EAAO;CACP,EAAO,GAAG,EAAO,4BAA4B,GAAG,EAAO,8BAA8B;CACtF,GAEC,EAAO,SAAS,WACJ,OAAO,OAAO,EAAO,MAAM,CAC5B,KAAK,MAAS,EAAK,yBAAyB,GAGpD,EAAE,CACT,CACD,OAAO,QAAQ"}
1
+ {"version":3,"file":"get-secrets.js","names":[],"sources":["../../../src/code-example/helpers/get-secrets.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { encode } from 'js-base64'\n\n/** Extract secrets from security schemes */\nexport const getSecrets = (securitySchemes: SecuritySchemeObjectSecret[]): string[] =>\n securitySchemes\n .flatMap((scheme) => {\n if (scheme.type === 'apiKey') {\n return scheme['x-scalar-secret-token']\n }\n if (scheme?.type === 'http') {\n return [\n scheme['x-scalar-secret-token'],\n scheme['x-scalar-secret-username'],\n scheme['x-scalar-secret-password'],\n encode(`${scheme['x-scalar-secret-username']}:${scheme['x-scalar-secret-password']}`),\n ]\n }\n if (scheme.type === 'oauth2') {\n const flows = Object.values(scheme.flows)\n return flows.map((flow) => flow['x-scalar-secret-token'])\n }\n\n return []\n })\n .filter(Boolean)\n"],"mappings":";;AAIA,IAAa,KAAc,MACzB,EACG,SAAS,MACJ,EAAO,SAAS,WACX,EAAO,2BAEZ,GAAQ,SAAS,SACZ;CACL,EAAO;CACP,EAAO;CACP,EAAO;CACP,EAAO,GAAG,EAAO,4BAA4B,GAAG,EAAO,6BAA6B;AACtF,IAEE,EAAO,SAAS,WACJ,OAAO,OAAO,EAAO,KAC5B,CAAA,CAAM,KAAK,MAAS,EAAK,wBAAwB,IAGnD,CAAC,CACT,CAAC,CACD,OAAO,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-snippet.js","names":[],"sources":["../../../src/code-example/helpers/get-snippet.ts"],"sourcesContent":["import type { ErrorResponse } from '@scalar/helpers/errors/normalize-error'\nimport { type ClientId, type TargetId, snippetz } from '@scalar/snippetz'\nimport type { Request as HarRequest } from 'har-format'\n\n/** Key used to hack around the invalid urls */\nconst INVALID_URLS_PREFIX = 'ws://replace.me'\n\n/**\n * Returns a code example for given operation\n */\nexport const getSnippet = <T extends TargetId>(\n target: T | 'javascript',\n client: ClientId<T>,\n harRequest: HarRequest,\n): ErrorResponse<string> => {\n try {\n if (!harRequest.url) {\n return [new Error('Please enter a URL to see a code snippet'), null]\n }\n\n const separator = harRequest.url.startsWith('/') ? '' : '/'\n\n // Hack to get around invalid URLS until we update the snippets lib\n try {\n new URL(harRequest.url)\n } catch {\n harRequest.url = `${INVALID_URLS_PREFIX}${separator}${harRequest.url}`\n }\n\n // Ensure we have valid JSON\n if (harRequest.postData?.mimeType === 'application/json') {\n try {\n JSON.parse(harRequest.postData.text || '{}')\n } catch (error) {\n console.error('[getSnippet] Invalid JSON body', error)\n return [new Error('Invalid JSON body'), null]\n }\n }\n // TODO: Fix this, use js (instead of javascript) everywhere\n const snippetzTargetKey = target.replace('javascript', 'js') as TargetId\n\n if (snippetz().hasPlugin(snippetzTargetKey, client)) {\n const payload = snippetz().print(snippetzTargetKey, client as ClientId<TargetId>, harRequest)\n if (!payload) {\n return [new Error('Error generating snippet'), null]\n }\n\n return [null, payload.replace(`${INVALID_URLS_PREFIX}${separator}`, '')]\n }\n } catch (error) {\n console.error('[getSnippet] Error generating snippet', error)\n return [new Error('Error generating snippet'), null]\n }\n\n return [new Error('No snippet found'), null]\n}\n"],"mappings":";;AAKA,IAAM,IAAsB,mBAKf,KACX,GACA,GACA,MAC0B;AAC1B,KAAI;AACF,MAAI,CAAC,EAAW,IACd,QAAO,CAAC,gBAAI,MAAM,2CAA2C,EAAE,KAAK;EAGtE,IAAM,IAAY,EAAW,IAAI,WAAW,IAAI,GAAG,KAAK;AAGxD,MAAI;AACF,OAAI,IAAI,EAAW,IAAI;UACjB;AACN,KAAW,MAAM,GAAG,IAAsB,IAAY,EAAW;;AAInE,MAAI,EAAW,UAAU,aAAa,mBACpC,KAAI;AACF,QAAK,MAAM,EAAW,SAAS,QAAQ,KAAK;WACrC,GAAO;AAEd,UADA,QAAQ,MAAM,kCAAkC,EAAM,EAC/C,CAAC,gBAAI,MAAM,oBAAoB,EAAE,KAAK;;EAIjD,IAAM,IAAoB,EAAO,QAAQ,cAAc,KAAK;AAE5D,MAAI,GAAU,CAAC,UAAU,GAAmB,EAAO,EAAE;GACnD,IAAM,IAAU,GAAU,CAAC,MAAM,GAAmB,GAA8B,EAAW;AAK7F,UAJK,IAIE,CAAC,MAAM,EAAQ,QAAQ,GAAG,IAAsB,KAAa,GAAG,CAAC,GAH/D,CAAC,gBAAI,MAAM,2BAA2B,EAAE,KAAK;;UAKjD,GAAO;AAEd,SADA,QAAQ,MAAM,yCAAyC,EAAM,EACtD,CAAC,gBAAI,MAAM,2BAA2B,EAAE,KAAK;;AAGtD,QAAO,CAAC,gBAAI,MAAM,mBAAmB,EAAE,KAAK"}
1
+ {"version":3,"file":"get-snippet.js","names":[],"sources":["../../../src/code-example/helpers/get-snippet.ts"],"sourcesContent":["import type { ErrorResponse } from '@scalar/helpers/errors/normalize-error'\nimport { type ClientId, type TargetId, snippetz } from '@scalar/snippetz'\nimport type { Request as HarRequest } from 'har-format'\n\n/** Key used to hack around the invalid urls */\nconst INVALID_URLS_PREFIX = 'ws://replace.me'\n\n/**\n * Returns a code example for given operation\n */\nexport const getSnippet = <T extends TargetId>(\n target: T | 'javascript',\n client: ClientId<T>,\n harRequest: HarRequest,\n): ErrorResponse<string> => {\n try {\n if (!harRequest.url) {\n return [new Error('Please enter a URL to see a code snippet'), null]\n }\n\n const separator = harRequest.url.startsWith('/') ? '' : '/'\n\n // Hack to get around invalid URLS until we update the snippets lib\n try {\n new URL(harRequest.url)\n } catch {\n harRequest.url = `${INVALID_URLS_PREFIX}${separator}${harRequest.url}`\n }\n\n // Ensure we have valid JSON\n if (harRequest.postData?.mimeType === 'application/json') {\n try {\n JSON.parse(harRequest.postData.text || '{}')\n } catch (error) {\n console.error('[getSnippet] Invalid JSON body', error)\n return [new Error('Invalid JSON body'), null]\n }\n }\n // TODO: Fix this, use js (instead of javascript) everywhere\n const snippetzTargetKey = target.replace('javascript', 'js') as TargetId\n\n if (snippetz().hasPlugin(snippetzTargetKey, client)) {\n const payload = snippetz().print(snippetzTargetKey, client as ClientId<TargetId>, harRequest)\n if (!payload) {\n return [new Error('Error generating snippet'), null]\n }\n\n return [null, payload.replace(`${INVALID_URLS_PREFIX}${separator}`, '')]\n }\n } catch (error) {\n console.error('[getSnippet] Error generating snippet', error)\n return [new Error('Error generating snippet'), null]\n }\n\n return [new Error('No snippet found'), null]\n}\n"],"mappings":";;AAKA,IAAM,IAAsB,mBAKf,KACX,GACA,GACA,MAC0B;CAC1B,IAAI;EACF,IAAI,CAAC,EAAW,KACd,OAAO,CAAC,gBAAI,MAAM,0CAA0C,GAAG,IAAI;EAGrE,IAAM,IAAY,EAAW,IAAI,WAAW,GAAG,IAAI,KAAK;EAGxD,IAAI;GACF,IAAI,IAAI,EAAW,GAAG;EACxB,QAAQ;GACN,EAAW,MAAM,GAAG,IAAsB,IAAY,EAAW;EACnE;EAGA,IAAI,EAAW,UAAU,aAAa,oBACpC,IAAI;GACF,KAAK,MAAM,EAAW,SAAS,QAAQ,IAAI;EAC7C,SAAS,GAAO;GAEd,OADA,QAAQ,MAAM,kCAAkC,CAAK,GAC9C,CAAC,gBAAI,MAAM,mBAAmB,GAAG,IAAI;EAC9C;EAGF,IAAM,IAAoB,EAAO,QAAQ,cAAc,IAAI;EAE3D,IAAI,EAAS,CAAC,CAAC,UAAU,GAAmB,CAAM,GAAG;GACnD,IAAM,IAAU,EAAS,CAAC,CAAC,MAAM,GAAmB,GAA8B,CAAU;GAK5F,OAJK,IAIE,CAAC,MAAM,EAAQ,QAAQ,GAAG,IAAsB,KAAa,EAAE,CAAC,IAH9D,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;EAIvD;CACF,SAAS,GAAO;EAEd,OADA,QAAQ,MAAM,yCAAyC,CAAK,GACrD,CAAC,gBAAI,MAAM,0BAA0B,GAAG,IAAI;CACrD;CAEA,OAAO,CAAC,gBAAI,MAAM,kBAAkB,GAAG,IAAI;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: HttpMethod\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n // Handle parameters\n if (operation.parameters) {\n const { url, headers, queryString, cookies } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (existingContentTypeHeader && !existingContentTypeHeader.value) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAsFA,IAAa,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,oCACA,+BAA4B,SACS;CAWrC,IAAM,IAAsC,EAVrB,IACnB,EAAkB;EAChB;EACA;EACA,aAAa,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB,SAAS;GAAE,YAAY,GAAY;GAAE,YAAY;GAAa;EAC/D,CAAC,GACF,EAAE,CAC2F,EAE3F,IACJ,EAAU,iCAAiC,oBAAoB,KAAW,cAAc,EAAE,EAKtF,IAAyB;EAC7B;EACA,KALgB,EAAiB,GAAQ,EAAK;EAM9C,SAAS,OAAO,QAAQ,EAAoC,CAAC,KAAK,CAAC,GAAM,QAAY;GAAE;GAAM;GAAO,EAAE;EACtG,aAAa,EAAE;EACf,UAAU,KAAA;EACV,aAAa;EACb,SAAS,EAAE;EACX,aAAa;EACb,UAAU;EACX;AAGD,KAAI,EAAU,YAAY;EACxB,IAAM,EAAE,QAAK,YAAS,gBAAa,eAAY,EAAkB;GAC/D;GACA,YAAY,EAAU;GACtB;GACA,iBAAiB;GAClB,CAAC,EAGI,IACJ,GACI,QAAQ,MAAW,EAAmB;GAAE;GAAQ;GAAK;GAAuB,CAAC,CAAC,EAC9E,KAAK,OAAY;GAAE,MAAM,EAAO;GAAM,OAAO,EAAO;GAAO,EAAE,IAAI,EAAE;AAKzE,EAHA,EAAW,MAAM,GACjB,EAAW,UAAU,GACrB,EAAW,cAAc,GACzB,EAAW,UAAU,CAAC,GAAG,GAAuB,GAAG,EAAQ;;CAG7D,IAAM,IAAO,EAAe,EAAU,YAAY;AAGlD,KAAI,GAAM,SAAS;EACjB,IAAM,IAAW,EAAY;GAC3B,aAAa;GACb;GACA;GACA;GACD,CAAC;AAEF,MAAI,MACF,EAAW,WAAW,GACtB,EAAW,WAAW,EAAS,MAAM,UAAU,IAG3C,EAAS,WAAU;GACrB,IAAM,IAA4B,EAAW,QAAQ,MAClD,MAAW,EAAO,KAAK,aAAa,KAAK,eAC3C;AAED,GAAI,KAA6B,CAAC,EAA0B,QAC1D,EAA0B,QAAQ,EAAS,WAGnC,KACR,EAAW,QAAQ,KAAK;IACtB,MAAM;IACN,OAAO,EAAS;IACjB,CAAC;;;AAOV,KAAI,GAAiB;EACnB,IAAM,EAAE,YAAS,gBAAa,eAAY,EAAuB,EAAgB;AAGjF,EAFA,EAAW,QAAQ,KAAK,GAAG,EAAQ,EACnC,EAAW,YAAY,KAAK,GAAG,EAAY,EAC3C,EAAW,QAAQ,KAAK,GAAG,EAAQ;;CAIrC,IAAI,IAAc;AAClB,MAAK,IAAM,KAAK,EAAW,QAEzB,OAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;AAItE,QAFA,EAAW,cAAc,GAElB"}
1
+ {"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: HttpMethod\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n // Handle parameters\n if (operation.parameters) {\n const { url, headers, queryString, cookies } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (existingContentTypeHeader && !existingContentTypeHeader.value) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAsFA,IAAa,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,oCACA,+BAA4B,SACS;CAWrC,IAAM,IAAsC,EAVrB,IACnB,EAAkB;EAChB;EACA;EACA,aAAa,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB,SAAS;GAAE,YAAY,EAAW;GAAG,YAAY;EAAY;CAC/D,CAAC,IACD,CAAC,CAC2F,GAE1F,IACJ,EAAU,8BAA8B,GAAG,iBAAiB,GAAG,KAAW,cAAc,CAAC,GAKrF,IAAyB;EAC7B;EACA,KALgB,EAAiB,GAAQ,CAKpC;EACL,SAAS,OAAO,QAAQ,CAAmC,CAAC,CAAC,KAAK,CAAC,GAAM,QAAY;GAAE;GAAM;EAAM,EAAE;EACrG,aAAa,CAAC;EACd,UAAU,KAAA;EACV,aAAa;EACb,SAAS,CAAC;EACV,aAAa;EACb,UAAU;CACZ;CAGA,IAAI,EAAU,YAAY;EACxB,IAAM,EAAE,QAAK,YAAS,gBAAa,eAAY,EAAkB;GAC/D;GACA,YAAY,EAAU;GACtB;GACA,iBAAiB;EACnB,CAAC,GAGK,IACJ,GACI,QAAQ,MAAW,EAAmB;GAAE;GAAQ;GAAK;EAAsB,CAAC,CAAC,CAAC,EAC9E,KAAK,OAAY;GAAE,MAAM,EAAO;GAAM,OAAO,EAAO;EAAM,EAAE,KAAK,CAAC;EAKxE,AAHA,EAAW,MAAM,GACjB,EAAW,UAAU,GACrB,EAAW,cAAc,GACzB,EAAW,UAAU,CAAC,GAAG,GAAuB,GAAG,CAAO;CAC5D;CAEA,IAAM,IAAO,EAAe,EAAU,WAAW;CAGjD,IAAI,GAAM,SAAS;EACjB,IAAM,IAAW,EAAY;GAC3B,aAAa;GACb;GACA;GACA;EACF,CAAC;EAED,IAAI,MACF,EAAW,WAAW,GACtB,EAAW,WAAW,EAAS,MAAM,UAAU,IAG3C,EAAS,WAAU;GACrB,IAAM,IAA4B,EAAW,QAAQ,MAClD,MAAW,EAAO,KAAK,YAAY,MAAM,cAC5C;GAEA,AAAI,KAA6B,CAAC,EAA0B,QAC1D,EAA0B,QAAQ,EAAS,WAGnC,KACR,EAAW,QAAQ,KAAK;IACtB,MAAM;IACN,OAAO,EAAS;GAClB,CAAC;EAEL;CAEJ;CAGA,IAAI,GAAiB;EACnB,IAAM,EAAE,YAAS,gBAAa,eAAY,EAAuB,CAAe;EAGhF,AAFA,EAAW,QAAQ,KAAK,GAAG,CAAO,GAClC,EAAW,YAAY,KAAK,GAAG,CAAW,GAC1C,EAAW,QAAQ,KAAK,GAAG,CAAO;CACpC;CAGA,IAAI,IAAc;CAClB,KAAK,IAAM,KAAK,EAAW,SAEzB,MAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAc,GAElB;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,GAAG,iCAAiC,CAAC,GAAG;IACjH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAyJD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,yEAKzB,gBAAgB,KAAG,QAAQ,GAAG,SAyFhC,CAAA"}
1
+ {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,GAAG,iCAAiC,CAAC,GAAG;IACjH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAiKD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,yEAKzB,gBAAgB,KAAG,QAAQ,GAAG,SAyFhC,CAAA"}