@scalar/blocks 0.1.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.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/code-example/components/CodeExample.vue.d.ts +139 -0
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -0
- package/dist/code-example/components/CodeExample.vue.js +9 -0
- package/dist/code-example/components/CodeExample.vue.js.map +1 -0
- package/dist/code-example/components/CodeExample.vue.script.js +223 -0
- package/dist/code-example/components/CodeExample.vue.script.js.map +1 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts +16 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -0
- package/dist/code-example/components/ExamplePicker.vue.js +7 -0
- package/dist/code-example/components/ExamplePicker.vue.js.map +1 -0
- package/dist/code-example/components/ExamplePicker.vue.script.js +48 -0
- package/dist/code-example/components/ExamplePicker.vue.script.js.map +1 -0
- package/dist/code-example/components/HttpMethod.vue.d.ts +26 -0
- package/dist/code-example/components/HttpMethod.vue.d.ts.map +1 -0
- package/dist/code-example/components/HttpMethod.vue.js +7 -0
- package/dist/code-example/components/HttpMethod.vue.js.map +1 -0
- package/dist/code-example/components/HttpMethod.vue.script.js +27 -0
- package/dist/code-example/components/HttpMethod.vue.script.js.map +1 -0
- package/dist/code-example/helpers/filter-clients-by-query.d.ts +9 -0
- package/dist/code-example/helpers/filter-clients-by-query.d.ts.map +1 -0
- package/dist/code-example/helpers/filter-clients-by-query.js +21 -0
- package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -0
- package/dist/code-example/helpers/find-client.d.ts +41 -0
- package/dist/code-example/helpers/find-client.d.ts.map +1 -0
- package/dist/code-example/helpers/find-client.js +20 -0
- package/dist/code-example/helpers/find-client.js.map +1 -0
- package/dist/code-example/helpers/format-language.d.ts +8 -0
- package/dist/code-example/helpers/format-language.d.ts.map +1 -0
- package/dist/code-example/helpers/format-language.js +54 -0
- package/dist/code-example/helpers/format-language.js.map +1 -0
- package/dist/code-example/helpers/generate-client-options.d.ts +30 -0
- package/dist/code-example/helpers/generate-client-options.d.ts.map +1 -0
- package/dist/code-example/helpers/generate-client-options.js +35 -0
- package/dist/code-example/helpers/generate-client-options.js.map +1 -0
- package/dist/code-example/helpers/generate-code-snippet.d.ts +39 -0
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -0
- package/dist/code-example/helpers/generate-code-snippet.js +30 -0
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -0
- package/dist/code-example/helpers/get-clients.d.ts +12 -0
- package/dist/code-example/helpers/get-clients.d.ts.map +1 -0
- package/dist/code-example/helpers/get-clients.js +28 -0
- package/dist/code-example/helpers/get-clients.js.map +1 -0
- package/dist/code-example/helpers/get-custom-code-samples.d.ts +45 -0
- package/dist/code-example/helpers/get-custom-code-samples.d.ts.map +1 -0
- package/dist/code-example/helpers/get-custom-code-samples.js +42 -0
- package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -0
- package/dist/code-example/helpers/get-secrets.d.ts +4 -0
- package/dist/code-example/helpers/get-secrets.d.ts.map +1 -0
- package/dist/code-example/helpers/get-secrets.js +12 -0
- package/dist/code-example/helpers/get-secrets.js.map +1 -0
- package/dist/code-example/helpers/get-snippet.d.ts +8 -0
- package/dist/code-example/helpers/get-snippet.d.ts.map +1 -0
- package/dist/code-example/helpers/get-snippet.js +30 -0
- package/dist/code-example/helpers/get-snippet.js.map +1 -0
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +72 -0
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -0
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js +78 -0
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts +13 -0
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-body.js +100 -0
- package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +24 -0
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-parameters.js +189 -0
- package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.d.ts +15 -0
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +59 -0
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-server-url.d.ts +6 -0
- package/dist/code-example/helpers/operation-to-har/process-server-url.d.ts.map +1 -0
- package/dist/code-example/helpers/operation-to-har/process-server-url.js +12 -0
- package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -0
- package/dist/code-example/index.d.ts +17 -0
- package/dist/code-example/index.d.ts.map +1 -0
- package/dist/code-example/index.js +14 -0
- package/dist/code-example/mount.d.ts +51 -0
- package/dist/code-example/mount.d.ts.map +1 -0
- package/dist/code-example/mount.js +61 -0
- package/dist/code-example/mount.js.map +1 -0
- package/dist/code-example/test-utils.d.ts +4 -0
- package/dist/code-example/test-utils.d.ts.map +1 -0
- package/dist/code-example/types.d.ts +46 -0
- package/dist/code-example/types.d.ts.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/style.css +4995 -0
- package/dist/styles/tailwind.config.css +12 -0
- package/dist/vue-styles.css +2 -0
- package/package.json +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { 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.1/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))\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 const defaultStyle = {\n path: 'simple',\n query: '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 = (\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 return getExampleFromSchema(getResolvedRef(param.schema), options)\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 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 // 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 as unknown[]).map((v) => `${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 (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\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 as unknown[]).join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\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 as unknown[]).join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\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 as unknown[]).join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\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":";;;AAyBA,IAAM,KAAqB,OACxB,KAAU,EAAE,EAAE,KAAK,MAAU,EAAe,EAAM,CAAC,EAGhD,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAAA,IAC/C,EAAM,gBAEX,YAAY,KAAS,EAAM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AAI,IAAI,IAAS;;AAItD,WAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,IAAa;;AAI1D,OAAI,MAAM,QAAQ,EAAW,CAC3B,QAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAK,EAAyB,KAAK,IAAI,GAAG;AAInF,OAAI,OAAO,KAAe,YAAY,GAAqB;IACzD,IAAM,IAAS,OAAO,QAAQ,EAAsC,CACjE,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;AAEZ,WAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,IAAS;;AAItD,UAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,IAAa;EAG1D,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,EAAQ;AAC5D,UAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,EAAW,CAAC;;EAI3D,QACE,QAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,EAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
2
|
+
import type { Request as HarRequest } from 'har-format';
|
|
3
|
+
type ProcessedSecuritySchemesReturn = {
|
|
4
|
+
headers: HarRequest['headers'];
|
|
5
|
+
queryString: HarRequest['queryString'];
|
|
6
|
+
cookies: HarRequest['cookies'];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Process security schemes into whichever parameters they are applicable to
|
|
10
|
+
*
|
|
11
|
+
* TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied
|
|
12
|
+
*/
|
|
13
|
+
export declare const processSecuritySchemes: (securitySchemes: SecuritySchemeObjectSecret[]) => ProcessedSecuritySchemesReturn;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=process-security-schemes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { encode as e } from "js-base64";
|
|
2
|
+
//#region src/code-example/helpers/operation-to-har/process-security-schemes.ts
|
|
3
|
+
var t = (t) => {
|
|
4
|
+
let n = {
|
|
5
|
+
headers: [],
|
|
6
|
+
queryString: [],
|
|
7
|
+
cookies: []
|
|
8
|
+
};
|
|
9
|
+
for (let r of t) {
|
|
10
|
+
if (r.type === "apiKey") {
|
|
11
|
+
let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
12
|
+
if (!r.name) continue;
|
|
13
|
+
let t = {
|
|
14
|
+
name: r.name,
|
|
15
|
+
value: e
|
|
16
|
+
};
|
|
17
|
+
switch (r.in) {
|
|
18
|
+
case "header":
|
|
19
|
+
n.headers.push(t);
|
|
20
|
+
break;
|
|
21
|
+
case "query":
|
|
22
|
+
n.queryString.push(t);
|
|
23
|
+
break;
|
|
24
|
+
case "cookie":
|
|
25
|
+
n.cookies.push(t);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (r.type === "http") {
|
|
31
|
+
if (r.scheme === "basic") {
|
|
32
|
+
let t = `${r["x-scalar-secret-username"] || ""}:${r["x-scalar-secret-password"] || ""}`, i = t === ":" ? "username:password" : e(t);
|
|
33
|
+
n.headers.push({
|
|
34
|
+
name: "Authorization",
|
|
35
|
+
value: `Basic ${i}`
|
|
36
|
+
});
|
|
37
|
+
} else if (r.scheme === "bearer") {
|
|
38
|
+
let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
39
|
+
n.headers.push({
|
|
40
|
+
name: "Authorization",
|
|
41
|
+
value: `Bearer ${e}`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (r.type === "oauth2" && r.flows) {
|
|
47
|
+
let e = Object.values(r.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
48
|
+
n.headers.push({
|
|
49
|
+
name: "Authorization",
|
|
50
|
+
value: `Bearer ${e}`
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return n;
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { t as processSecuritySchemes };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=process-security-schemes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;AAeA,IAAa,KACX,MACmC;CACnC,IAAM,IAAyC;EAC7C,SAAS,EAAE;EACX,aAAa,EAAE;EACf,SAAS,EAAE;EACZ;AAED,MAAK,IAAM,KAAU,GAAiB;AAEpC,MAAI,EAAO,SAAS,UAAU;GAC5B,IAAM,IAAQ,EAAO,4BAA4B;AACjD,OAAI,CAAC,EAAO,KACV;GAGF,IAAM,IAAQ;IAAE,MAAM,EAAO;IAAM;IAAO;AAE1C,WAAQ,EAAO,IAAf;IACE,KAAK;AACH,OAAO,QAAQ,KAAK,EAAM;AAC1B;IACF,KAAK;AACH,OAAO,YAAY,KAAK,EAAM;AAC9B;IACF,KAAK;AACH,OAAO,QAAQ,KAAK,EAAM;AAC1B;;AAEJ;;AAIF,MAAI,EAAO,SAAS,QAAQ;AAC1B,OAAI,EAAO,WAAW,SAAS;IAQ7B,IAAM,IAAQ,GAPG,EAAO,+BAA+B,GAO7B,GANT,EAAO,+BAA+B,MAOjD,IAAO,MAAU,MAAM,sBAAsB,EAAO,EAAM;AAEhE,MAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;KACjB,CAAC;cACO,EAAO,WAAW,UAAU;IACrC,IAAM,IAAQ,EAAO,4BAA4B;AAEjD,MAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;KAClB,CAAC;;AAEJ;;AAIF,MAAI,EAAO,SAAS,YAAY,EAAO,OAAO;GAK5C,IAAM,IAJQ,OAAO,OAAO,EAAO,MAAM,CAGtB,MAAM,MAAM,EAAE,yBAAyB,GACrC,4BAA4B;AAEjD,KAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;IAClB,CAAC;;;AAIN,QAAO"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a server URL by replacing variables with their default values and merging with the path
|
|
4
|
+
*/
|
|
5
|
+
export declare const processServerUrl: (server: ServerObject | null, path: string) => string;
|
|
6
|
+
//# sourceMappingURL=process-server-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-server-url.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-server-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAEhG;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,GAAG,IAAI,EAAE,MAAM,MAAM,KAAG,MA4B5E,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { replaceVariables as e } from "@scalar/helpers/regex/replace-variables";
|
|
2
|
+
import { mergeUrls as t } from "@scalar/helpers/url/merge-urls";
|
|
3
|
+
//#region src/code-example/helpers/operation-to-har/process-server-url.ts
|
|
4
|
+
var n = (n, r) => {
|
|
5
|
+
if (!n?.url) return r;
|
|
6
|
+
let i = n.url;
|
|
7
|
+
return n.variables ? t(e(i, Object.entries(n.variables).reduce((e, [t, n]) => (n.default !== void 0 && (e[t] = n.default), e), {})), r) : t(i, r);
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as processServerUrl };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=process-server-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-server-url.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { replaceVariables } from '@scalar/helpers/regex/replace-variables'\nimport { mergeUrls } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Processes a server URL by replacing variables with their default values and merging with the path\n */\nexport const processServerUrl = (server: ServerObject | null, path: string): string => {\n if (!server?.url) {\n return path\n }\n const serverUrl = server.url\n\n // Replace server variables with their default values\n if (server.variables) {\n const variables = Object.entries(server.variables)\n\n // Extract default values from server variables\n const defaultValues = variables.reduce(\n (defaults, [variableName, variableConfig]) => {\n if (variableConfig.default !== undefined) {\n defaults[variableName] = variableConfig.default\n }\n return defaults\n },\n {} as Record<string, string | number>,\n )\n\n // Replace variables in the server URL with their default values\n const serverUrlWithVars = replaceVariables(serverUrl, defaultValues)\n\n return mergeUrls(serverUrlWithVars, path)\n }\n\n return mergeUrls(serverUrl, path)\n}\n"],"mappings":";;;AAOA,IAAa,KAAoB,GAA6B,MAAyB;AACrF,KAAI,CAAC,GAAQ,IACX,QAAO;CAET,IAAM,IAAY,EAAO;AAuBzB,QApBI,EAAO,YAiBF,EAFmB,EAAiB,GAdzB,OAAO,QAAQ,EAAO,UAAU,CAGlB,QAC7B,GAAU,CAAC,GAAc,QACpB,EAAe,YAAY,KAAA,MAC7B,EAAS,KAAgB,EAAe,UAEnC,IAET,EAAE,CACH,CAGmE,EAEhC,EAAK,GAGpC,EAAU,GAAW,EAAK"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { getResolvedRefDeep } from '@scalar/workspace-store/helpers/get-resolved-ref-deep';
|
|
2
|
+
export type { CodeExampleProps } from './components/CodeExample.vue';
|
|
3
|
+
export { default as CodeExample } from './components/CodeExample.vue';
|
|
4
|
+
export { default as ExamplePicker } from './components/ExamplePicker.vue';
|
|
5
|
+
export { default as HttpMethod } from './components/HttpMethod.vue';
|
|
6
|
+
export { filterClientsByQuery } from './helpers/filter-clients-by-query';
|
|
7
|
+
export { DEFAULT_CLIENT, type SelectedClientId, findClient, isClient, isSelectedClient } from './helpers/find-client';
|
|
8
|
+
export { generateClientOptions, getCustomClientIds } from './helpers/generate-client-options';
|
|
9
|
+
export { generateCodeSnippet } from './helpers/generate-code-snippet';
|
|
10
|
+
export { getClients } from './helpers/get-clients';
|
|
11
|
+
export { getCustomCodeSamples } from './helpers/get-custom-code-samples';
|
|
12
|
+
export { getSecrets } from './helpers/get-secrets';
|
|
13
|
+
export type { OperationToHarProps } from './helpers/operation-to-har/operation-to-har';
|
|
14
|
+
export { operationToHar } from './helpers/operation-to-har/operation-to-har';
|
|
15
|
+
export { type CreateCodeExampleOptions, createCodeExample } from './mount';
|
|
16
|
+
export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-example/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAA;AAE1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,EAAE,KAAK,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC1E,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { filterClientsByQuery as e } from "./helpers/filter-clients-by-query.js";
|
|
2
|
+
import { DEFAULT_CLIENT as t, findClient as n, isClient as r, isSelectedClient as i } from "./helpers/find-client.js";
|
|
3
|
+
import { generateClientOptions as a, getCustomClientIds as o } from "./helpers/generate-client-options.js";
|
|
4
|
+
import { operationToHar as s } from "./helpers/operation-to-har/operation-to-har.js";
|
|
5
|
+
import { generateCodeSnippet as c } from "./helpers/generate-code-snippet.js";
|
|
6
|
+
import { getCustomCodeSamples as l } from "./helpers/get-custom-code-samples.js";
|
|
7
|
+
import { getClients as u } from "./helpers/get-clients.js";
|
|
8
|
+
import { getSecrets as d } from "./helpers/get-secrets.js";
|
|
9
|
+
import f from "./components/ExamplePicker.vue.js";
|
|
10
|
+
import p from "./components/HttpMethod.vue.js";
|
|
11
|
+
import m from "./components/CodeExample.vue.js";
|
|
12
|
+
import { createCodeExample as h } from "./mount.js";
|
|
13
|
+
import { getResolvedRefDeep as g } from "@scalar/workspace-store/helpers/get-resolved-ref-deep";
|
|
14
|
+
export { m as CodeExample, t as DEFAULT_CLIENT, f as ExamplePicker, p as HttpMethod, h as createCodeExample, e as filterClientsByQuery, n as findClient, a as generateClientOptions, c as generateCodeSnippet, u as getClients, o as getCustomClientIds, l as getCustomCodeSamples, g as getResolvedRefDeep, d as getSecrets, r as isClient, i as isSelectedClient, s as operationToHar };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { AvailableClients } from '@scalar/snippetz';
|
|
3
|
+
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
4
|
+
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
5
|
+
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
6
|
+
export type CreateCodeExampleOptions = {
|
|
7
|
+
/** Workspace store that holds the OpenAPI document(s) to render from. */
|
|
8
|
+
store: WorkspaceStore;
|
|
9
|
+
/** Path of the operation to render, e.g. '/users/{id}'. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** HTTP method of the operation to render. */
|
|
12
|
+
method: HttpMethod;
|
|
13
|
+
/** Pre-selected client ID, e.g. 'shell/curl'. */
|
|
14
|
+
selectedClient?: AvailableClients[number];
|
|
15
|
+
/**
|
|
16
|
+
* Server object override used to build the example request.
|
|
17
|
+
*
|
|
18
|
+
* When omitted, the server is derived from the active document (operation,
|
|
19
|
+
* then path item, then document level), mirroring the API reference. Pass
|
|
20
|
+
* `null` to force "no server".
|
|
21
|
+
*/
|
|
22
|
+
selectedServer?: ServerObject | null;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-selected example key for parameters and the request body.
|
|
25
|
+
*
|
|
26
|
+
* The store is the source of truth once an example is picked, so
|
|
27
|
+
* `x-scalar-default-example` wins over this initial seed and the selection
|
|
28
|
+
* round-trips through the store like the client selection does.
|
|
29
|
+
*/
|
|
30
|
+
selectedExample?: string;
|
|
31
|
+
/** Security schemes applicable to the operation. */
|
|
32
|
+
securitySchemes?: SecuritySchemeObjectSecret[];
|
|
33
|
+
/**
|
|
34
|
+
* Force a color mode on the rendered block.
|
|
35
|
+
*
|
|
36
|
+
* When omitted, the block inherits the ambient theme of the host page.
|
|
37
|
+
* Pass `true` for dark mode or `false` for light mode.
|
|
38
|
+
*/
|
|
39
|
+
darkMode?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Mount the CodeExample block to a DOM element without Vue.
|
|
43
|
+
*
|
|
44
|
+
* The consumer creates and controls their own workspace store,
|
|
45
|
+
* then passes it in along with the path and method to render.
|
|
46
|
+
*/
|
|
47
|
+
export declare const createCodeExample: (el: HTMLElement | string, options: CreateCodeExampleOptions) => {
|
|
48
|
+
app: import("vue").App<Element>;
|
|
49
|
+
destroy: () => void;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +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;AAKpE,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;;;CAqI5F,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { generateClientOptions as e } from "./helpers/generate-client-options.js";
|
|
2
|
+
import t from "./components/CodeExample.vue.js";
|
|
3
|
+
import { createApp as n, h as r, reactive as i } from "vue";
|
|
4
|
+
import { createWorkspaceEventBus as a } from "@scalar/workspace-store/events";
|
|
5
|
+
import { getResolvedRef as o } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
|
+
import { ScalarTeleportRoot as s } from "@scalar/components/teleport";
|
|
7
|
+
import { getFirstServer as c } from "@scalar/workspace-store/helpers/get-first-server";
|
|
8
|
+
import { generateClientMutators as l } from "@scalar/workspace-store/mutators";
|
|
9
|
+
//#region src/code-example/mount.ts
|
|
10
|
+
var u = (e) => ["scalar-app", e === !0 ? "dark-mode" : e === !1 ? "light-mode" : ""].filter(Boolean).join(" "), d = (d, f) => {
|
|
11
|
+
let p = typeof d == "string" ? document.querySelector(d) : d;
|
|
12
|
+
if (!p) throw Error(`Element not found: ${d}`);
|
|
13
|
+
let m = a(), h = e(), g = l(f.store), _ = m.on("workspace:update:selected-client", (e) => g.workspace().workspace.updateSelectedClient(e)), v = m.on("workspace:update:selected-example", (e) => g.workspace().workspace.updateSelectedExample(e)), y = () => {
|
|
14
|
+
let e = f.store.workspace.activeDocument;
|
|
15
|
+
if (!e || !("paths" in e)) return;
|
|
16
|
+
let t = o(e.paths?.[f.path]), n = o(t?.[f.method]);
|
|
17
|
+
if (n) return {
|
|
18
|
+
operation: n,
|
|
19
|
+
server: c(n.servers ?? null, t?.servers ?? null, e.servers ?? null)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
if (!y()) throw Error(`Operation not found: ${f.method.toUpperCase()} ${f.path}`);
|
|
23
|
+
let b, x = () => {
|
|
24
|
+
let e = y();
|
|
25
|
+
return e && (b = e), e ?? b;
|
|
26
|
+
}, S = i({
|
|
27
|
+
get operation() {
|
|
28
|
+
return x().operation;
|
|
29
|
+
},
|
|
30
|
+
get method() {
|
|
31
|
+
return f.method;
|
|
32
|
+
},
|
|
33
|
+
get path() {
|
|
34
|
+
return f.path;
|
|
35
|
+
},
|
|
36
|
+
clientOptions: h,
|
|
37
|
+
eventBus: m,
|
|
38
|
+
get securitySchemes() {
|
|
39
|
+
return f.securitySchemes ?? [];
|
|
40
|
+
},
|
|
41
|
+
get selectedClient() {
|
|
42
|
+
return f.store.workspace["x-scalar-default-client"] ?? f.selectedClient;
|
|
43
|
+
},
|
|
44
|
+
get selectedExample() {
|
|
45
|
+
return f.store.workspace["x-scalar-default-example"] ?? f.selectedExample;
|
|
46
|
+
},
|
|
47
|
+
get selectedServer() {
|
|
48
|
+
return f.selectedServer === void 0 ? x().server : f.selectedServer;
|
|
49
|
+
}
|
|
50
|
+
}), C = () => r("span", { class: "font-code text-c-2 min-w-0 truncate" }, f.path), w = n(() => r("div", { class: u(f.darkMode) }, [r(s, null, { default: () => r(t, S, { header: C }) })]));
|
|
51
|
+
return w.mount(p), {
|
|
52
|
+
app: w,
|
|
53
|
+
destroy: () => {
|
|
54
|
+
_(), v(), w.unmount();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { d as createCodeExample };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +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 { 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.1/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.mount(element)\n\n return {\n app,\n destroy: () => {\n unsubscribeClient()\n unsubscribeExample()\n app.unmount()\n },\n }\n}\n"],"mappings":";;;;;;;;;AAyDA,IAAM,KAAmB,MACvB,CAAC,cAAc,MAAa,KAAO,cAAc,MAAa,KAAQ,eAAe,GAAG,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI,EAQvG,KAAqB,GAA0B,MAAsC;CAChG,IAAM,IAAU,OAAO,KAAO,WAAW,SAAS,cAAc,EAAG,GAAG;AACtE,KAAI,CAAC,EACH,OAAU,MAAM,sBAAsB,IAAK;CAG7C,IAAM,IAAW,GAAyB,EACpC,IAAgB,GAAuB,EAQvC,IAAW,EAAuB,EAAQ,MAAM,EAChD,IAAoB,EAAS,GAAG,qCAAqC,MACzE,EAAS,WAAW,CAAC,UAAU,qBAAqB,EAAQ,CAC7D,EAOK,IAAqB,EAAS,GAAG,sCAAsC,MAC3E,EAAS,WAAW,CAAC,UAAU,sBAAsB,EAAQ,CAC9D,E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AGb,GAFA,GAAmB,EACnB,GAAoB,EACpB,EAAI,SAAS;;EAEhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/code-example/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGvE,gDAAgD;AAChD,eAAO,MAAM,YAAY,EAQT,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ScalarComboboxOption, ScalarComboboxOptionGroup } from '@scalar/components/combobox';
|
|
2
|
+
import type { AvailableClients, ClientId, TargetId } from '@scalar/snippetz';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a client option in the request example block.
|
|
5
|
+
* Extends the base combobox option with language-specific information
|
|
6
|
+
* for generating code examples in different programming languages.
|
|
7
|
+
*/
|
|
8
|
+
export type ClientOption = ScalarComboboxOption & {
|
|
9
|
+
/** A more specific ID */
|
|
10
|
+
id: AvailableClients[number];
|
|
11
|
+
/** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
|
|
12
|
+
lang: TargetId | 'curl' | 'plaintext';
|
|
13
|
+
/** Title shows when the client is selected in the dropdown */
|
|
14
|
+
title: string;
|
|
15
|
+
/** Target key for the client, differs from the lang due to the curl thing */
|
|
16
|
+
targetKey: TargetId;
|
|
17
|
+
/** Title of the target */
|
|
18
|
+
targetTitle: string;
|
|
19
|
+
/** Client key for the client */
|
|
20
|
+
clientKey: ClientId<TargetId>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Augments the base combobox option group with ClientOptions
|
|
24
|
+
*/
|
|
25
|
+
export type ClientOptionGroup = ScalarComboboxOptionGroup<ClientOption> & {
|
|
26
|
+
/** Key of the group */
|
|
27
|
+
key: TargetId;
|
|
28
|
+
};
|
|
29
|
+
/** Better type safety when we have custom clients in the selector */
|
|
30
|
+
export type CustomClientOption = ScalarComboboxOption & {
|
|
31
|
+
/** A custom ID */
|
|
32
|
+
id: `custom/${string}`;
|
|
33
|
+
/** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
|
|
34
|
+
lang: TargetId | 'curl' | 'plaintext';
|
|
35
|
+
/** Title shows when the client is selected in the dropdown */
|
|
36
|
+
title: string;
|
|
37
|
+
/** Client key for the client */
|
|
38
|
+
clientKey: 'custom';
|
|
39
|
+
};
|
|
40
|
+
export type CustomOrDefaultClientOption = ClientOption | CustomClientOption;
|
|
41
|
+
/** Augments the base combobox option group with CustomClientOptions */
|
|
42
|
+
export type CustomClientOptionGroup = ScalarComboboxOptionGroup<CustomOrDefaultClientOption> & {
|
|
43
|
+
/** Key of the group */
|
|
44
|
+
key: 'custom' | TargetId;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/code-example/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG;IAChD,yBAAyB;IACzB,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC5B,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,SAAS,EAAE,QAAQ,CAAA;IACnB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,YAAY,CAAC,GAAG;IACxE,uBAAuB;IACvB,GAAG,EAAE,QAAQ,CAAA;CACd,CAAA;AAED,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,kBAAkB;IAClB,EAAE,EAAE,UAAU,MAAM,EAAE,CAAA;IACtB,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE3E,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC,2BAA2B,CAAC,GAAG;IAC7F,uBAAuB;IACvB,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAAA;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,gKAAgK;AAChK,eAAO,MAAM,WAAW,QAA+F,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** The version number taken from the package.json. Consumers can override at build time via define (e.g. OVERRIDE_PACKAGE_VERSION: JSON.stringify('1.2.3')). */\nexport const APP_VERSION = typeof OVERRIDE_PACKAGE_VERSION !== 'undefined' ? OVERRIDE_PACKAGE_VERSION : PACKAGE_VERSION\n"],"mappings":";AACA,IAAa,IAAc,OAAO,2BAA6B,MAAc,2BAAA"}
|