@scalar/blocks 0.1.20 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/code-example/components/CodeExample.vue.d.ts +3 -2
  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.js.map +1 -1
  6. package/dist/code-example/components/CodeExample.vue.script.js +87 -82
  7. package/dist/code-example/components/CodeExample.vue.script.js.map +1 -1
  8. package/dist/code-example/components/HttpMethod.vue.d.ts +1 -2
  9. package/dist/code-example/components/HttpMethod.vue.d.ts.map +1 -1
  10. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  11. package/dist/code-example/components/HttpMethod.vue.script.js +15 -11
  12. package/dist/code-example/components/HttpMethod.vue.script.js.map +1 -1
  13. package/dist/code-example/helpers/generate-client-options.d.ts +1 -0
  14. package/dist/code-example/helpers/generate-client-options.d.ts.map +1 -1
  15. package/dist/code-example/helpers/generate-client-options.js +7 -3
  16. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  17. package/dist/code-example/helpers/generate-code-snippet.d.ts +3 -4
  18. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  19. package/dist/code-example/helpers/generate-code-snippet.js +24 -18
  20. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  21. package/dist/code-example/helpers/get-clients.d.ts.map +1 -1
  22. package/dist/code-example/helpers/get-clients.js +4 -2
  23. package/dist/code-example/helpers/get-clients.js.map +1 -1
  24. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +1 -2
  25. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  26. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +25 -12
  27. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  28. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  29. package/dist/code-example/helpers/operation-to-har/process-body.js +89 -68
  30. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  31. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +4 -0
  32. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  33. package/dist/code-example/helpers/operation-to-har/process-parameters.js +169 -83
  34. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  35. package/dist/code-example/mount.d.ts +3 -2
  36. package/dist/code-example/mount.d.ts.map +1 -1
  37. package/dist/code-example/mount.js +32 -28
  38. package/dist/code-example/mount.js.map +1 -1
  39. package/dist/constants.js +1 -1
  40. package/dist/style.css +1 -1
  41. package/dist/vue-styles.css +1 -1
  42. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { isObjectLike } from '@scalar/helpers/object/is-object'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n deSerializeParameter,\n getExample,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies only support 'form' style\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'form', explode }\n }\n\n // The 3.2 `querystring` location has no style/explode of its own, so it falls through to the\n // `form` default here and is then serialized like a regular query parameter (see the switch below).\n const defaultStyle =\n (\n {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n } as Record<string, string>\n )[param.in] ?? 'form'\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n defaultDisabled: boolean,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n // The 3.2 `querystring` location represents the whole query string. Handle it like a\n // regular query parameter so its value still lands in the query string instead of\n // being silently dropped.\n case 'query':\n case 'querystring': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Cookies only support 'form' style according to OpenAPI 3.1.1\n case 'cookie': {\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: harRequest.cookies,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;AA0BA,IAAM,KAAqB,OACxB,KAAU,CAAC,EAAA,CAAG,KAAK,MAAU,EAAe,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAU,MAAU,KAAA,CAAS,GAGtF,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAAA,IAC/C,EAAM,gBAEX,YAAY,KAAS,EAAM,UAAU,OAAO,EAAM,UAAW,YAAY,mBAAmB,EAAM,SAC5F,EAAM,OAAuC,kBAAkB,KAElE,IAIH,KAAoB,GAAe,MACnC,EAAgB,CAAK,IAChB,IAEF,mBAAmB,CAAK,GAO3B,KAA+B,MAAgE;CAEnG,IAAI,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAa,KAAS,EAAM,YAAY,KAAA,KAAY,EAAM;CACxC;CAIpC,IAAI,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAQ,SADR,aAAa,KAAS,EAAM,YAAY,KAAA,IAAY,EAAM,UAAU;CACpD;CAKlC,IAAM,IAEF;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AAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;IAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;GACrD;GAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;EAGzD,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,CAAO;GAC3D,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;EAC1D;EAGA,SACE,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;CAC5D;AACF"}
1
+ {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { isObjectLike } from '@scalar/helpers/object/is-object'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (param: ParameterObject, example: string | undefined, defaultDisabled: boolean): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example)\n const exampleValue = selected.example\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, { defaultDisabled })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n newQueryString.push({ name: param.name, value: encodeQueryValue(text, param) })\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const paramValue = getParameterValue(param, example, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;;AAmCA,IAAM,KAAqB,OACxB,KAAU,CAAC,EAAA,CAAG,KAAK,MAAU,EAAe,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAU,MAAU,KAAA,CAAS,GAGtF,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAA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AAO,QAAQ,CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;KAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;IACrD;IAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;GACzD;GAGA,IAAI,MAAM,QAAQ,CAAU,GAC1B,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,EAAW,KAAK,GAAG,GAAG;GAInE,IAAI,EAAa,CAAU,GAAG;IAC5B,IAAM,IAAS,OAAO,QAAQ,CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;IAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;GACrD;GAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;EAGzD,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,CAAO;GAC3D,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;EAC1D;EAGA,SACE,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;CAC5D;AACF"}
@@ -1,15 +1,16 @@
1
- import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
1
  import type { AvailableClients } from '@scalar/snippetz';
3
2
  import type { WorkspaceStore } from '@scalar/workspace-store/client';
4
3
  import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
5
4
  import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
6
5
  export type CreateCodeExampleOptions = {
6
+ /** Localized status text shown when the selected example has no linked code sample. */
7
+ codeSampleUnavailable?: string;
7
8
  /** Workspace store that holds the OpenAPI document(s) to render from. */
8
9
  store: WorkspaceStore;
9
10
  /** Path of the operation to render, e.g. '/users/{id}'. */
10
11
  path: string;
11
12
  /** HTTP method of the operation to render. */
12
- method: HttpMethod;
13
+ method: string;
13
14
  /** Pre-selected client ID, e.g. 'shell/curl'. */
14
15
  selectedClient?: AvailableClients[number];
15
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/code-example/mount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAMpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAMjH,MAAM,MAAM,wBAAwB,GAAG;IACrC,yEAAyE;IACzE,KAAK,EAAE,cAAc,CAAA;IACrB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,MAAM,EAAE,UAAU,CAAA;IAClB,iDAAiD;IACjD,cAAc,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACzC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oDAAoD;IACpD,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAWD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,WAAW,GAAG,MAAM,EAAE,SAAS,wBAAwB;;;CAsI5F,CAAA"}
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/code-example/mount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAOpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAMjH,MAAM,MAAM,wBAAwB,GAAG;IACrC,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,yEAAyE;IACzE,KAAK,EAAE,cAAc,CAAA;IACrB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,cAAc,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACzC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oDAAoD;IACpD,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAWD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,WAAW,GAAG,MAAM,EAAE,SAAS,wBAAwB;;;CAyI5F,CAAA"}
@@ -5,58 +5,62 @@ import { createWorkspaceEventBus as a } from "@scalar/workspace-store/events";
5
5
  import { getResolvedRef as o } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
6
  import { EXTERNAL_EXAMPLES as s } from "@scalar/workspace-store/helpers/use-external-examples";
7
7
  import { ScalarTeleportRoot as c } from "@scalar/components/teleport";
8
- import { getFirstServer as l } from "@scalar/workspace-store/helpers/get-first-server";
9
- import { generateClientMutators as u } from "@scalar/workspace-store/mutators";
8
+ import { getPathItemOperation as l } from "@scalar/workspace-store/helpers/for-each-path-item-operation";
9
+ import { getFirstServer as u } from "@scalar/workspace-store/helpers/get-first-server";
10
+ import { generateClientMutators as d } from "@scalar/workspace-store/mutators";
10
11
  //#region src/code-example/mount.ts
11
- var d = (e) => ["scalar-app", e === !0 ? "dark-mode" : e === !1 ? "light-mode" : ""].filter(Boolean).join(" "), f = (f, p) => {
12
- let m = typeof f == "string" ? document.querySelector(f) : f;
13
- if (!m) throw Error(`Element not found: ${f}`);
14
- let h = a(), g = e(), _ = u(p.store), v = h.on("workspace:update:selected-client", (e) => _.workspace().workspace.updateSelectedClient(e)), y = h.on("workspace:update:selected-example", (e) => _.workspace().workspace.updateSelectedExample(e)), b = () => {
15
- let e = p.store.workspace.activeDocument;
12
+ var f = (e) => ["scalar-app", e === !0 ? "dark-mode" : e === !1 ? "light-mode" : ""].filter(Boolean).join(" "), p = (p, m) => {
13
+ let h = typeof p == "string" ? document.querySelector(p) : p;
14
+ if (!h) throw Error(`Element not found: ${p}`);
15
+ let g = a(), _ = e(), v = d(m.store), y = g.on("workspace:update:selected-client", (e) => v.workspace().workspace.updateSelectedClient(e)), b = g.on("workspace:update:selected-example", (e) => v.workspace().workspace.updateSelectedExample(e)), x = () => {
16
+ let e = m.store.workspace.activeDocument;
16
17
  if (!e || !("paths" in e)) return;
17
- let t = o(e.paths?.[p.path]), n = o(t?.[p.method]);
18
+ let t = o(e.paths?.[m.path]), n = o(l(t, m.method));
18
19
  if (n) return {
19
20
  operation: n,
20
- server: l(n.servers ?? null, t?.servers ?? null, e.servers ?? null)
21
+ server: u(n.servers ?? null, t?.servers ?? null, e.servers ?? null)
21
22
  };
22
23
  };
23
- if (!b()) throw Error(`Operation not found: ${p.method.toUpperCase()} ${p.path}`);
24
- let x, S = () => {
25
- let e = b();
26
- return e && (x = e), e ?? x;
27
- }, C = i({
24
+ if (!x()) throw Error(`Operation not found: ${m.method.toUpperCase()} ${m.path}`);
25
+ let S, C = () => {
26
+ let e = x();
27
+ return e && (S = e), e ?? S;
28
+ }, w = i({
29
+ get codeSampleUnavailable() {
30
+ return m.codeSampleUnavailable;
31
+ },
28
32
  get operation() {
29
- return S().operation;
33
+ return C().operation;
30
34
  },
31
35
  get method() {
32
- return p.method;
36
+ return m.method;
33
37
  },
34
38
  get path() {
35
- return p.path;
39
+ return m.path;
36
40
  },
37
- clientOptions: g,
38
- eventBus: h,
41
+ clientOptions: _,
42
+ eventBus: g,
39
43
  get securitySchemes() {
40
- return p.securitySchemes ?? [];
44
+ return m.securitySchemes ?? [];
41
45
  },
42
46
  get selectedClient() {
43
- return p.store.workspace["x-scalar-default-client"] ?? p.selectedClient;
47
+ return m.store.workspace["x-scalar-default-client"] ?? m.selectedClient;
44
48
  },
45
49
  get selectedExample() {
46
- return p.store.workspace["x-scalar-default-example"] ?? p.selectedExample;
50
+ return m.store.workspace["x-scalar-default-example"] ?? m.selectedExample;
47
51
  },
48
52
  get selectedServer() {
49
- return p.selectedServer === void 0 ? S().server : p.selectedServer;
53
+ return m.selectedServer === void 0 ? C().server : m.selectedServer;
50
54
  }
51
- }), w = () => r("span", { class: "font-code text-c-2 min-w-0 truncate" }, p.path), T = n(() => r("div", { class: d(p.darkMode) }, [r(c, null, { default: () => r(t, C, { header: w }) })]));
52
- return T.provide(s, () => p.store.externalExamples()), T.mount(m), {
53
- app: T,
55
+ }), T = () => r("span", { class: "font-code text-c-2 min-w-0 truncate" }, m.path), E = n(() => r("div", { class: f(m.darkMode) }, [r(c, null, { default: () => r(t, w, { header: T }) })]));
56
+ return E.provide(s, () => m.store.externalExamples()), E.mount(h), {
57
+ app: E,
54
58
  destroy: () => {
55
- v(), y(), T.unmount();
59
+ y(), b(), E.unmount();
56
60
  }
57
61
  };
58
62
  };
59
63
  //#endregion
60
- export { f as createCodeExample };
64
+ export { p as createCodeExample };
61
65
 
62
66
  //# sourceMappingURL=mount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","names":[],"sources":["../../src/code-example/mount.ts"],"sourcesContent":["import { ScalarTeleportRoot } from '@scalar/components/teleport'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { AvailableClients } from '@scalar/snippetz'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getFirstServer } from '@scalar/workspace-store/helpers/get-first-server'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { EXTERNAL_EXAMPLES } from '@scalar/workspace-store/helpers/use-external-examples'\nimport { generateClientMutators } from '@scalar/workspace-store/mutators'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { createApp, h, reactive } from 'vue'\n\nimport CodeExample, { type CodeExampleProps } from './components/CodeExample.vue'\nimport { generateClientOptions } from './helpers/generate-client-options'\n\nexport type CreateCodeExampleOptions = {\n /** Workspace store that holds the OpenAPI document(s) to render from. */\n store: WorkspaceStore\n /** Path of the operation to render, e.g. '/users/{id}'. */\n path: string\n /** HTTP method of the operation to render. */\n method: HttpMethod\n /** Pre-selected client ID, e.g. 'shell/curl'. */\n selectedClient?: AvailableClients[number]\n /**\n * Server object override used to build the example request.\n *\n * When omitted, the server is derived from the active document (operation,\n * then path item, then document level), mirroring the API reference. Pass\n * `null` to force \"no server\".\n */\n selectedServer?: ServerObject | null\n /**\n * Pre-selected example key for parameters and the request body.\n *\n * The store is the source of truth once an example is picked, so\n * `x-scalar-default-example` wins over this initial seed and the selection\n * round-trips through the store like the client selection does.\n */\n selectedExample?: string\n /** Security schemes applicable to the operation. */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /**\n * Force a color mode on the rendered block.\n *\n * When omitted, the block inherits the ambient theme of the host page.\n * Pass `true` for dark mode or `false` for light mode.\n */\n darkMode?: boolean\n}\n\n/**\n * Builds the wrapper classes for the mounted block.\n *\n * The `.scalar-app` class scopes the Tailwind utilities, and the optional\n * color-mode class lets consumers pin the block to dark or light.\n */\nconst getWrapperClass = (darkMode: boolean | undefined): string =>\n ['scalar-app', darkMode === true ? 'dark-mode' : darkMode === false ? 'light-mode' : ''].filter(Boolean).join(' ')\n\n/**\n * Mount the CodeExample block to a DOM element without Vue.\n *\n * The consumer creates and controls their own workspace store,\n * then passes it in along with the path and method to render.\n */\nexport const createCodeExample = (el: HTMLElement | string, options: CreateCodeExampleOptions) => {\n const element = typeof el === 'string' ? document.querySelector(el) : el\n if (!element) {\n throw new Error(`Element not found: ${el}`)\n }\n\n const eventBus = createWorkspaceEventBus()\n const clientOptions = generateClientOptions()\n\n // Persist client changes back to the store. The block emits\n // `workspace:update:selected-client` on its private bus when the user picks a\n // client; without this subscription the choice would never reach the store\n // and `x-scalar-default-client` (the source of truth read below) would stay\n // stale, so the selection would not survive a re-render or be shared with\n // other blocks reading from the same store.\n const mutators = generateClientMutators(options.store)\n const unsubscribeClient = eventBus.on('workspace:update:selected-client', (payload) =>\n mutators.workspace().workspace.updateSelectedClient(payload),\n )\n\n // Persist example changes back to the store as well, mirroring the client\n // round-trip above. The block emits `workspace:update:selected-example` when\n // the user picks an example; without this the choice would never reach\n // `x-scalar-default-example` (read below) and would neither survive a\n // re-render nor sync to other blocks reading from the same store.\n const unsubscribeExample = eventBus.on('workspace:update:selected-example', (payload) =>\n mutators.workspace().workspace.updateSelectedExample(payload),\n )\n\n type OperationContext = { operation: OperationObject; server: ServerObject | null }\n\n /**\n * Resolve the operation and its effective server from the active document.\n *\n * The server is resolved from the same document the operation came from\n * (operation, then path item, then document level), so a snippet never pairs\n * an operation with a server URL from a different spec.\n */\n const resolveContext = (): OperationContext | undefined => {\n // The active document may be an AsyncAPI document, which has no `paths`.\n const activeDocument = options.store.workspace.activeDocument\n if (!activeDocument || !('paths' in activeDocument)) {\n return undefined\n }\n const pathItem = getResolvedRef(activeDocument.paths?.[options.path])\n const operation = getResolvedRef(pathItem?.[options.method])\n if (!operation) {\n return undefined\n }\n const server = getFirstServer(operation.servers ?? null, pathItem?.servers ?? null, activeDocument.servers ?? null)\n return { operation, server }\n }\n\n // Fail loudly if the path and method do not point at an operation in the store,\n // mirroring the \"element not found\" guard above.\n if (!resolveContext()) {\n throw new Error(`Operation not found: ${options.method.toUpperCase()} ${options.path}`)\n }\n\n // Remember the last context that resolved so a transient miss (e.g. the active\n // document is swapped to one without this path or method after mount) keeps\n // rendering the previous operation, paired with the server it actually came\n // from, instead of feeding `undefined` to the block.\n let lastContext: OperationContext | undefined\n\n /** Current operation + server, falling back to the last good resolution on a transient miss. */\n const currentContext = (): OperationContext => {\n const context = resolveContext()\n if (context) {\n lastContext = context\n }\n return (context ?? lastContext) as OperationContext\n }\n\n // Props are getters so the block tracks the reactive store (active document,\n // `x-scalar-default-client`, `x-scalar-default-example`) live. Change the\n // client, example, or server through the store to drive re-renders.\n const props = reactive<CodeExampleProps>({\n get operation(): OperationObject {\n return currentContext().operation\n },\n get method() {\n return options.method\n },\n get path() {\n return options.path\n },\n clientOptions,\n eventBus,\n get securitySchemes() {\n return options.securitySchemes ?? []\n },\n get selectedClient() {\n // The store is the source of truth once the user picks a client, so it\n // wins over the initial `options.selectedClient` seed and the selection\n // round-trips through the subscription above.\n return options.store.workspace['x-scalar-default-client'] ?? options.selectedClient\n },\n get selectedExample() {\n // Same as the client: the store wins over the initial seed so the example\n // selection survives re-renders and syncs across blocks.\n return options.store.workspace['x-scalar-default-example'] ?? options.selectedExample\n },\n get selectedServer() {\n // An explicit option wins (including an explicit `null` for \"no server\");\n // otherwise derive it from the same document the operation resolved from.\n return options.selectedServer !== undefined ? options.selectedServer : currentContext().server\n },\n })\n\n // Render the operation path in the header by default. The reference renders\n // this via the `#header` slot too, so the standalone block matches its look.\n const renderHeader = () => h('span', { class: 'font-code text-c-2 min-w-0 truncate' }, options.path)\n\n // Wrap the block in its own teleport root so floating UI (the client picker\n // popover) renders inside the themed `.scalar-app` wrapper instead of escaping\n // to `body`, where it would miss the color-mode variables and lose its styling.\n const app = createApp(() =>\n h('div', { class: getWrapperClass(options.darkMode) }, [\n h(ScalarTeleportRoot, null, { default: () => h(CodeExample, props, { header: renderHeader }) }),\n ]),\n )\n\n app.provide(EXTERNAL_EXAMPLES, () => options.store.externalExamples())\n app.mount(element)\n\n return {\n app,\n destroy: () => {\n unsubscribeClient()\n unsubscribeExample()\n app.unmount()\n },\n }\n}\n"],"mappings":";;;;;;;;;;AA0DA,IAAM,KAAmB,MACvB,CAAC,cAAc,MAAa,KAAO,cAAc,MAAa,KAAQ,eAAe,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAQtG,KAAqB,GAA0B,MAAsC;CAChG,IAAM,IAAU,OAAO,KAAO,WAAW,SAAS,cAAc,CAAE,IAAI;CACtE,IAAI,CAAC,GACH,MAAU,MAAM,sBAAsB,GAAI;CAG5C,IAAM,IAAW,EAAwB,GACnC,IAAgB,EAAsB,GAQtC,IAAW,EAAuB,EAAQ,KAAK,GAC/C,IAAoB,EAAS,GAAG,qCAAqC,MACzE,EAAS,UAAU,CAAC,CAAC,UAAU,qBAAqB,CAAO,CAC7D,GAOM,IAAqB,EAAS,GAAG,sCAAsC,MAC3E,EAAS,UAAU,CAAC,CAAC,UAAU,sBAAsB,CAAO,CAC9D,GAWM,UAAqD;EAEzD,IAAM,IAAiB,EAAQ,MAAM,UAAU;EAC/C,IAAI,CAAC,KAAkB,EAAE,WAAW,IAClC;EAEF,IAAM,IAAW,EAAe,EAAe,QAAQ,EAAQ,KAAK,GAC9D,IAAY,EAAe,IAAW,EAAQ,OAAO;EACtD,OAIL,OAAO;GAAE;GAAW,QADL,EAAe,EAAU,WAAW,MAAM,GAAU,WAAW,MAAM,EAAe,WAAW,IAC1F;EAAO;CAC7B;CAIA,IAAI,CAAC,EAAe,GAClB,MAAU,MAAM,wBAAwB,EAAQ,OAAO,YAAY,EAAE,GAAG,EAAQ,MAAM;CAOxF,IAAI,GAGE,UAAyC;EAC7C,IAAM,IAAU,EAAe;EAI/B,OAHI,MACF,IAAc,IAER,KAAW;CACrB,GAKM,IAAQ,EAA2B;EACvC,IAAI,YAA6B;GAC/B,OAAO,EAAe,CAAC,CAAC;EAC1B;EACA,IAAI,SAAS;GACX,OAAO,EAAQ;EACjB;EACA,IAAI,OAAO;GACT,OAAO,EAAQ;EACjB;EACA;EACA;EACA,IAAI,kBAAkB;GACpB,OAAO,EAAQ,mBAAmB,CAAC;EACrC;EACA,IAAI,iBAAiB;GAInB,OAAO,EAAQ,MAAM,UAAU,8BAA8B,EAAQ;EACvE;EACA,IAAI,kBAAkB;GAGpB,OAAO,EAAQ,MAAM,UAAU,+BAA+B,EAAQ;EACxE;EACA,IAAI,iBAAiB;GAGnB,OAAO,EAAQ,mBAAmB,KAAA,IAAqC,EAAe,CAAC,CAAC,SAA1C,EAAQ;EACxD;CACF,CAAC,GAIK,UAAqB,EAAE,QAAQ,EAAE,OAAO,sCAAsC,GAAG,EAAQ,IAAI,GAK7F,IAAM,QACV,EAAE,OAAO,EAAE,OAAO,EAAgB,EAAQ,QAAQ,EAAE,GAAG,CACrD,EAAE,GAAoB,MAAM,EAAE,eAAe,EAAE,GAAa,GAAO,EAAE,QAAQ,EAAa,CAAC,EAAE,CAAC,CAChG,CAAC,CACH;CAKA,OAHA,EAAI,QAAQ,SAAyB,EAAQ,MAAM,iBAAiB,CAAC,GACrE,EAAI,MAAM,CAAO,GAEV;EACL;EACA,eAAe;GAGb,AAFA,EAAkB,GAClB,EAAmB,GACnB,EAAI,QAAQ;EACd;CACF;AACF"}
1
+ {"version":3,"file":"mount.js","names":[],"sources":["../../src/code-example/mount.ts"],"sourcesContent":["import { ScalarTeleportRoot } from '@scalar/components/teleport'\nimport type { AvailableClients } from '@scalar/snippetz'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getPathItemOperation } from '@scalar/workspace-store/helpers/for-each-path-item-operation'\nimport { getFirstServer } from '@scalar/workspace-store/helpers/get-first-server'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { EXTERNAL_EXAMPLES } from '@scalar/workspace-store/helpers/use-external-examples'\nimport { generateClientMutators } from '@scalar/workspace-store/mutators'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { createApp, h, reactive } from 'vue'\n\nimport CodeExample, { type CodeExampleProps } from './components/CodeExample.vue'\nimport { generateClientOptions } from './helpers/generate-client-options'\n\nexport type CreateCodeExampleOptions = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /** Workspace store that holds the OpenAPI document(s) to render from. */\n store: WorkspaceStore\n /** Path of the operation to render, e.g. '/users/{id}'. */\n path: string\n /** HTTP method of the operation to render. */\n method: string\n /** Pre-selected client ID, e.g. 'shell/curl'. */\n selectedClient?: AvailableClients[number]\n /**\n * Server object override used to build the example request.\n *\n * When omitted, the server is derived from the active document (operation,\n * then path item, then document level), mirroring the API reference. Pass\n * `null` to force \"no server\".\n */\n selectedServer?: ServerObject | null\n /**\n * Pre-selected example key for parameters and the request body.\n *\n * The store is the source of truth once an example is picked, so\n * `x-scalar-default-example` wins over this initial seed and the selection\n * round-trips through the store like the client selection does.\n */\n selectedExample?: string\n /** Security schemes applicable to the operation. */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /**\n * Force a color mode on the rendered block.\n *\n * When omitted, the block inherits the ambient theme of the host page.\n * Pass `true` for dark mode or `false` for light mode.\n */\n darkMode?: boolean\n}\n\n/**\n * Builds the wrapper classes for the mounted block.\n *\n * The `.scalar-app` class scopes the Tailwind utilities, and the optional\n * color-mode class lets consumers pin the block to dark or light.\n */\nconst getWrapperClass = (darkMode: boolean | undefined): string =>\n ['scalar-app', darkMode === true ? 'dark-mode' : darkMode === false ? 'light-mode' : ''].filter(Boolean).join(' ')\n\n/**\n * Mount the CodeExample block to a DOM element without Vue.\n *\n * The consumer creates and controls their own workspace store,\n * then passes it in along with the path and method to render.\n */\nexport const createCodeExample = (el: HTMLElement | string, options: CreateCodeExampleOptions) => {\n const element = typeof el === 'string' ? document.querySelector(el) : el\n if (!element) {\n throw new Error(`Element not found: ${el}`)\n }\n\n const eventBus = createWorkspaceEventBus()\n const clientOptions = generateClientOptions()\n\n // Persist client changes back to the store. The block emits\n // `workspace:update:selected-client` on its private bus when the user picks a\n // client; without this subscription the choice would never reach the store\n // and `x-scalar-default-client` (the source of truth read below) would stay\n // stale, so the selection would not survive a re-render or be shared with\n // other blocks reading from the same store.\n const mutators = generateClientMutators(options.store)\n const unsubscribeClient = eventBus.on('workspace:update:selected-client', (payload) =>\n mutators.workspace().workspace.updateSelectedClient(payload),\n )\n\n // Persist example changes back to the store as well, mirroring the client\n // round-trip above. The block emits `workspace:update:selected-example` when\n // the user picks an example; without this the choice would never reach\n // `x-scalar-default-example` (read below) and would neither survive a\n // re-render nor sync to other blocks reading from the same store.\n const unsubscribeExample = eventBus.on('workspace:update:selected-example', (payload) =>\n mutators.workspace().workspace.updateSelectedExample(payload),\n )\n\n type OperationContext = { operation: OperationObject; server: ServerObject | null }\n\n /**\n * Resolve the operation and its effective server from the active document.\n *\n * The server is resolved from the same document the operation came from\n * (operation, then path item, then document level), so a snippet never pairs\n * an operation with a server URL from a different spec.\n */\n const resolveContext = (): OperationContext | undefined => {\n // The active document may be an AsyncAPI document, which has no `paths`.\n const activeDocument = options.store.workspace.activeDocument\n if (!activeDocument || !('paths' in activeDocument)) {\n return undefined\n }\n const pathItem = getResolvedRef(activeDocument.paths?.[options.path])\n const operation = getResolvedRef(getPathItemOperation(pathItem, options.method))\n if (!operation) {\n return undefined\n }\n const server = getFirstServer(operation.servers ?? null, pathItem?.servers ?? null, activeDocument.servers ?? null)\n return { operation, server }\n }\n\n // Fail loudly if the path and method do not point at an operation in the store,\n // mirroring the \"element not found\" guard above.\n if (!resolveContext()) {\n throw new Error(`Operation not found: ${options.method.toUpperCase()} ${options.path}`)\n }\n\n // Remember the last context that resolved so a transient miss (e.g. the active\n // document is swapped to one without this path or method after mount) keeps\n // rendering the previous operation, paired with the server it actually came\n // from, instead of feeding `undefined` to the block.\n let lastContext: OperationContext | undefined\n\n /** Current operation + server, falling back to the last good resolution on a transient miss. */\n const currentContext = (): OperationContext => {\n const context = resolveContext()\n if (context) {\n lastContext = context\n }\n return (context ?? lastContext) as OperationContext\n }\n\n // Props are getters so the block tracks the reactive store (active document,\n // `x-scalar-default-client`, `x-scalar-default-example`) live. Change the\n // client, example, or server through the store to drive re-renders.\n const props = reactive<CodeExampleProps>({\n get codeSampleUnavailable() {\n return options.codeSampleUnavailable\n },\n get operation(): OperationObject {\n return currentContext().operation\n },\n get method() {\n return options.method\n },\n get path() {\n return options.path\n },\n clientOptions,\n eventBus,\n get securitySchemes() {\n return options.securitySchemes ?? []\n },\n get selectedClient() {\n // The store is the source of truth once the user picks a client, so it\n // wins over the initial `options.selectedClient` seed and the selection\n // round-trips through the subscription above.\n return options.store.workspace['x-scalar-default-client'] ?? options.selectedClient\n },\n get selectedExample() {\n // Same as the client: the store wins over the initial seed so the example\n // selection survives re-renders and syncs across blocks.\n return options.store.workspace['x-scalar-default-example'] ?? options.selectedExample\n },\n get selectedServer() {\n // An explicit option wins (including an explicit `null` for \"no server\");\n // otherwise derive it from the same document the operation resolved from.\n return options.selectedServer !== undefined ? options.selectedServer : currentContext().server\n },\n })\n\n // Render the operation path in the header by default. The reference renders\n // this via the `#header` slot too, so the standalone block matches its look.\n const renderHeader = () => h('span', { class: 'font-code text-c-2 min-w-0 truncate' }, options.path)\n\n // Wrap the block in its own teleport root so floating UI (the client picker\n // popover) renders inside the themed `.scalar-app` wrapper instead of escaping\n // to `body`, where it would miss the color-mode variables and lose its styling.\n const app = createApp(() =>\n h('div', { class: getWrapperClass(options.darkMode) }, [\n h(ScalarTeleportRoot, null, { default: () => h(CodeExample, props, { header: renderHeader }) }),\n ]),\n )\n\n app.provide(EXTERNAL_EXAMPLES, () => options.store.externalExamples())\n app.mount(element)\n\n return {\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C;EAC1B;EACA,IAAI,SAAS;GACX,OAAO,EAAQ;EACjB;EACA,IAAI,OAAO;GACT,OAAO,EAAQ;EACjB;EACA;EACA;EACA,IAAI,kBAAkB;GACpB,OAAO,EAAQ,mBAAmB,CAAC;EACrC;EACA,IAAI,iBAAiB;GAInB,OAAO,EAAQ,MAAM,UAAU,8BAA8B,EAAQ;EACvE;EACA,IAAI,kBAAkB;GAGpB,OAAO,EAAQ,MAAM,UAAU,+BAA+B,EAAQ;EACxE;EACA,IAAI,iBAAiB;GAGnB,OAAO,EAAQ,mBAAmB,KAAA,IAAqC,EAAe,CAAC,CAAC,SAA1C,EAAQ;EACxD;CACF,CAAC,GAIK,UAAqB,EAAE,QAAQ,EAAE,OAAO,sCAAsC,GAAG,EAAQ,IAAI,GAK7F,IAAM,QACV,EAAE,OAAO,EAAE,OAAO,EAAgB,EAAQ,QAAQ,EAAE,GAAG,CACrD,EAAE,GAAoB,MAAM,EAAE,eAAe,EAAE,GAAa,GAAO,EAAE,QAAQ,EAAa,CAAC,EAAE,CAAC,CAChG,CAAC,CACH;CAKA,OAHA,EAAI,QAAQ,SAAyB,EAAQ,MAAM,iBAAiB,CAAC,GACrE,EAAI,MAAM,CAAO,GAEV;EACL;EACA,eAAe;GAGb,AAFA,EAAkB,GAClB,EAAmB,GACnB,EAAI,QAAQ;EACd;CACF;AACF"}
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.ts
2
- var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.1.20";
2
+ var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.3.0";
3
3
  //#endregion
4
4
  export { e as APP_VERSION };
5
5
 
package/dist/style.css CHANGED
@@ -4463,5 +4463,5 @@
4463
4463
  opacity: .5;
4464
4464
  }
4465
4465
  }
4466
- .request-card[data-v-8b0cd212]{color:var(--scalar-color-1);font-size:var(--scalar-font-size-3)}.request-method[data-v-8b0cd212]{font-family:var(--scalar-font-code);text-transform:uppercase;margin-right:6px}.request-card-footer[data-v-8b0cd212]{flex-shrink:0;justify-content:flex-end;padding:6px;display:flex;position:relative}.request-card-footer-addon[data-v-8b0cd212]{flex:1;align-items:center;min-width:0;display:flex}.request-editor-section[data-v-8b0cd212]{flex:1;display:flex}.request-card-simple[data-v-8b0cd212]{font-size:var(--scalar-small);justify-content:space-between;align-items:center;padding:8px 8px 8px 12px;display:flex}.code-snippet[data-v-8b0cd212]{flex-direction:column;width:100%;display:flex}
4466
+ .request-card[data-v-0f51a301]{color:var(--scalar-color-1);font-size:var(--scalar-font-size-3)}.request-method[data-v-0f51a301]{font-family:var(--scalar-font-code);margin-right:6px}.request-card-footer[data-v-0f51a301]{flex-shrink:0;justify-content:flex-end;padding:6px;display:flex;position:relative}.request-card-footer-addon[data-v-0f51a301]{flex:1;align-items:center;min-width:0;display:flex}.request-editor-section[data-v-0f51a301]{flex:1;display:flex}.request-card-simple[data-v-0f51a301]{font-size:var(--scalar-small);justify-content:space-between;align-items:center;padding:8px 8px 8px 12px;display:flex}.code-snippet[data-v-0f51a301]{flex-direction:column;width:100%;display:flex}
4467
4467
  /*$vite$:1*/
@@ -1,2 +1,2 @@
1
- .request-card[data-v-8b0cd212]{color:var(--scalar-color-1);font-size:var(--scalar-font-size-3)}.request-method[data-v-8b0cd212]{font-family:var(--scalar-font-code);text-transform:uppercase;margin-right:6px}.request-card-footer[data-v-8b0cd212]{flex-shrink:0;justify-content:flex-end;padding:6px;display:flex;position:relative}.request-card-footer-addon[data-v-8b0cd212]{flex:1;align-items:center;min-width:0;display:flex}.request-editor-section[data-v-8b0cd212]{flex:1;display:flex}.request-card-simple[data-v-8b0cd212]{font-size:var(--scalar-small);justify-content:space-between;align-items:center;padding:8px 8px 8px 12px;display:flex}.code-snippet[data-v-8b0cd212]{flex-direction:column;width:100%;display:flex}
1
+ .request-card[data-v-0f51a301]{color:var(--scalar-color-1);font-size:var(--scalar-font-size-3)}.request-method[data-v-0f51a301]{font-family:var(--scalar-font-code);margin-right:6px}.request-card-footer[data-v-0f51a301]{flex-shrink:0;justify-content:flex-end;padding:6px;display:flex;position:relative}.request-card-footer-addon[data-v-0f51a301]{flex:1;align-items:center;min-width:0;display:flex}.request-editor-section[data-v-0f51a301]{flex:1;display:flex}.request-card-simple[data-v-0f51a301]{font-size:var(--scalar-small);justify-content:space-between;align-items:center;padding:8px 8px 8px 12px;display:flex}.code-snippet[data-v-0f51a301]{flex-direction:column;width:100%;display:flex}
2
2
  /*$vite$:1*/
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "blocks",
18
18
  "docs"
19
19
  ],
20
- "version": "0.1.20",
20
+ "version": "0.3.0",
21
21
  "engines": {
22
22
  "node": ">=22"
23
23
  },
@@ -37,13 +37,13 @@
37
37
  "CHANGELOG.md"
38
38
  ],
39
39
  "dependencies": {
40
- "@scalar/components": "0.30.0",
41
- "@scalar/helpers": "0.12.0",
40
+ "@scalar/components": "0.30.2",
41
+ "@scalar/helpers": "0.14.0",
42
42
  "@scalar/icons": "0.7.6",
43
- "@scalar/snippetz": "0.9.32",
43
+ "@scalar/snippetz": "0.10.1",
44
44
  "@scalar/themes": "0.18.0",
45
- "@scalar/types": "0.20.1",
46
- "@scalar/workspace-store": "0.64.0",
45
+ "@scalar/types": "0.22.0",
46
+ "@scalar/workspace-store": "0.66.0",
47
47
  "@types/har-format": "^1.2.16",
48
48
  "js-base64": "^3.9.2",
49
49
  "vue": "^3.5.40"