@scalar/blocks 0.11.2 → 0.11.3
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 +20 -0
- package/dist/code-example/components/AsyncApiCodeExample.vue.js +111 -6
- package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
- package/dist/code-example/components/AsyncApiCodeExample3.vue.js +8 -0
- package/dist/code-example/components/AsyncApiCodeExample3.vue.js.map +1 -0
- package/dist/code-example/components/CodeExample.vue.d.ts +10 -0
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/CodeExample.vue.js +297 -6
- package/dist/code-example/components/CodeExample.vue.js.map +1 -1
- package/dist/code-example/components/CodeExample3.vue.js +8 -0
- package/dist/code-example/components/CodeExample3.vue.js.map +1 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts +2 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue.js +50 -4
- package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
- package/dist/code-example/components/ExamplePicker2.vue.js +6 -0
- package/dist/code-example/components/ExamplePicker2.vue.js.map +1 -0
- package/dist/code-example/components/HttpMethod.vue.js +32 -4
- package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
- package/dist/code-example/components/HttpMethod2.vue.js +6 -0
- package/dist/code-example/components/HttpMethod2.vue.js.map +1 -0
- package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
- package/dist/code-example/helpers/find-client.js.map +1 -1
- package/dist/code-example/helpers/format-language.js.map +1 -1
- package/dist/code-example/helpers/generate-client-options.js.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.d.ts +8 -2
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.js +57 -27
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
- package/dist/code-example/helpers/get-asyncapi-example-context.js.map +1 -1
- package/dist/code-example/helpers/get-clients.js.map +1 -1
- package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
- package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -1
- package/dist/code-example/helpers/get-message-example-content.js.map +1 -1
- package/dist/code-example/helpers/get-secrets.js.map +1 -1
- package/dist/code-example/helpers/get-snippet.d.ts +2 -2
- package/dist/code-example/helpers/get-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/get-snippet.js +7 -9
- package/dist/code-example/helpers/get-snippet.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts +2 -2
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-body.js +102 -81
- package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.js +49 -47
- package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +6 -6
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
- package/dist/code-example/index.d.ts +1 -1
- package/dist/code-example/index.d.ts.map +1 -1
- package/dist/code-example/index.js +14 -14
- package/dist/code-example/mount-asyncapi.js +1 -1
- package/dist/code-example/mount-asyncapi.js.map +1 -1
- package/dist/code-example/mount.js +1 -1
- package/dist/code-example/mount.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/schema/LinkButton.vue.js.map +1 -1
- package/dist/schema/RenderString.vue.js +11 -4
- package/dist/schema/RenderString.vue.js.map +1 -1
- package/dist/schema/RenderString2.vue.js +6 -0
- package/dist/schema/RenderString2.vue.js.map +1 -0
- package/dist/schema/Schema.vue.js +235 -6
- package/dist/schema/Schema.vue.js.map +1 -1
- package/dist/schema/Schema3.vue.js +8 -0
- package/dist/schema/Schema3.vue.js.map +1 -0
- package/dist/schema/SchemaCollapsedPreview.vue.js +25 -4
- package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
- package/dist/schema/SchemaCollapsedPreview2.vue.js +6 -0
- package/dist/schema/SchemaCollapsedPreview2.vue.js.map +1 -0
- package/dist/schema/SchemaComposition.vue.js +232 -6
- package/dist/schema/SchemaComposition.vue.js.map +1 -1
- package/dist/schema/SchemaComposition3.vue.js +8 -0
- package/dist/schema/SchemaComposition3.vue.js.map +1 -0
- package/dist/schema/SchemaEnumPropertyItem.vue.d.ts +1 -0
- package/dist/schema/SchemaEnumPropertyItem.vue.d.ts.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem.vue.js +23 -4
- package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem2.vue.js +6 -0
- package/dist/schema/SchemaEnumPropertyItem2.vue.js.map +1 -0
- package/dist/schema/SchemaEnums.vue.d.ts.map +1 -1
- package/dist/schema/SchemaEnums.vue.js +74 -6
- package/dist/schema/SchemaEnums.vue.js.map +1 -1
- package/dist/schema/SchemaEnums3.vue.js +8 -0
- package/dist/schema/SchemaEnums3.vue.js.map +1 -0
- package/dist/schema/SchemaGlyphPuck.vue.js +27 -4
- package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
- package/dist/schema/SchemaGlyphPuck2.vue.js +6 -0
- package/dist/schema/SchemaGlyphPuck2.vue.js.map +1 -0
- package/dist/schema/SchemaGutterToggle.vue.js +40 -4
- package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
- package/dist/schema/SchemaGutterToggle2.vue.js +6 -0
- package/dist/schema/SchemaGutterToggle2.vue.js.map +1 -0
- package/dist/schema/SchemaHeading.vue.js +32 -6
- package/dist/schema/SchemaHeading.vue.js.map +1 -1
- package/dist/schema/SchemaHeading3.vue.js +8 -0
- package/dist/schema/SchemaHeading3.vue.js.map +1 -0
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +42 -4
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js +6 -0
- package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js.map +1 -0
- package/dist/schema/SchemaObjectProperties.vue.js +213 -4
- package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
- package/dist/schema/SchemaObjectProperties2.vue.js +6 -0
- package/dist/schema/SchemaObjectProperties2.vue.js.map +1 -0
- package/dist/schema/SchemaProperty.vue.js +472 -6
- package/dist/schema/SchemaProperty.vue.js.map +1 -1
- package/dist/schema/SchemaProperty3.vue.js +8 -0
- package/dist/schema/SchemaProperty3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyDefault.vue.js +61 -6
- package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDefault3.vue.js +8 -0
- package/dist/schema/SchemaPropertyDefault3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyDetail.vue.js +22 -6
- package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDetail3.vue.js +8 -0
- package/dist/schema/SchemaPropertyDetail3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyExamples.vue.js +133 -6
- package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples3.vue.js +8 -0
- package/dist/schema/SchemaPropertyExamples3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyHeading.vue.js +312 -6
- package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyHeading3.vue.js +8 -0
- package/dist/schema/SchemaPropertyHeading3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyPattern.vue.js +42 -6
- package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyPattern3.vue.js +8 -0
- package/dist/schema/SchemaPropertyPattern3.vue.js.map +1 -0
- package/dist/schema/SchemaRailPanel.vue.js +53 -4
- package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
- package/dist/schema/SchemaRailPanel2.vue.js +6 -0
- package/dist/schema/SchemaRailPanel2.vue.js.map +1 -0
- package/dist/schema/components/CopyLinkButton.vue.js +24 -4
- package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
- package/dist/schema/components/CopyLinkButton2.vue.js +6 -0
- package/dist/schema/components/CopyLinkButton2.vue.js.map +1 -0
- package/dist/schema/components/WithBreadcrumb.vue.js +15 -4
- package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
- package/dist/schema/components/WithBreadcrumb2.vue.js +6 -0
- package/dist/schema/components/WithBreadcrumb2.vue.js.map +1 -0
- package/dist/schema/helpers/dynamic-scope.js.map +1 -1
- package/dist/schema/helpers/format-example.js.map +1 -1
- package/dist/schema/helpers/format-structured-value.d.ts +3 -0
- package/dist/schema/helpers/format-structured-value.d.ts.map +1 -0
- package/dist/schema/helpers/format-structured-value.js +6 -0
- package/dist/schema/helpers/format-structured-value.js.map +1 -0
- package/dist/schema/helpers/format-value.js.map +1 -1
- package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
- package/dist/schema/helpers/get-discriminator-values.js.map +1 -1
- package/dist/schema/helpers/get-enum-values.js.map +1 -1
- package/dist/schema/helpers/get-property-description.js.map +1 -1
- package/dist/schema/helpers/get-ref-name.js.map +1 -1
- package/dist/schema/helpers/get-rendered-example.js.map +1 -1
- package/dist/schema/helpers/get-schema-type.js.map +1 -1
- package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
- package/dist/schema/helpers/get-type-signature-tokens.js +37 -36
- package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
- package/dist/schema/helpers/has-complex-array-items.js.map +1 -1
- package/dist/schema/helpers/is-empty-schema-object.js.map +1 -1
- package/dist/schema/helpers/is-model-linkable.js.map +1 -1
- package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -1
- package/dist/schema/helpers/is-type-object.js.map +1 -1
- package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -1
- package/dist/schema/helpers/normalize-object-composition.js.map +1 -1
- package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
- package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
- package/dist/schema/helpers/schema-cycle.js.map +1 -1
- package/dist/schema/helpers/schema-expansion.js.map +1 -1
- package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -1
- package/dist/schema/helpers/schema-name.js.map +1 -1
- package/dist/schema/helpers/should-display-description.js.map +1 -1
- package/dist/schema/helpers/should-display-heading.js.map +1 -1
- package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
- package/dist/schema/helpers/sort-property-names.js.map +1 -1
- package/dist/schema/helpers/unwrap-for-read.js.map +1 -1
- package/dist/schema/index.js +8 -8
- package/dist/schema/localization/index.js.map +1 -1
- package/dist/schema/localization/translations.js.map +1 -1
- package/dist/shared/Badge.vue.js +13 -6
- package/dist/shared/Badge.vue.js.map +1 -1
- package/dist/shared/Badge3.vue.js +8 -0
- package/dist/shared/Badge3.vue.js.map +1 -0
- package/dist/shared/ExternalDocs.vue.js +43 -4
- package/dist/shared/ExternalDocs.vue.js.map +1 -1
- package/dist/shared/ExternalDocs2.vue.js +6 -0
- package/dist/shared/ExternalDocs2.vue.js.map +1 -0
- package/dist/shared/ExternalExampleStatus.vue.js +24 -4
- package/dist/shared/ExternalExampleStatus.vue.js.map +1 -1
- package/dist/shared/ExternalExampleStatus2.vue.js +6 -0
- package/dist/shared/ExternalExampleStatus2.vue.js.map +1 -0
- package/dist/shared/ScreenReader.vue.js +16 -4
- package/dist/shared/ScreenReader.vue.js.map +1 -1
- package/dist/shared/ScreenReader2.vue.js +6 -0
- package/dist/shared/ScreenReader2.vue.js.map +1 -0
- package/dist/shared/external-example-localization/index.js.map +1 -1
- package/dist/shared/external-example-localization/translations.js.map +1 -1
- package/dist/shared/index.js +4 -4
- package/dist/specification-extensions/ExtensionValue.vue.js +89 -4
- package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
- package/dist/specification-extensions/ExtensionValue2.vue.js +6 -0
- package/dist/specification-extensions/ExtensionValue2.vue.js.map +1 -0
- package/dist/specification-extensions/SpecificationExtensions.vue.js +76 -4
- package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
- package/dist/specification-extensions/SpecificationExtensions2.vue.js +6 -0
- package/dist/specification-extensions/SpecificationExtensions2.vue.js.map +1 -0
- package/dist/specification-extensions/index.js +1 -1
- package/dist/style.css +13 -9
- package/dist/vue-styles.css +1 -1
- package/package.json +18 -18
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +0 -113
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +0 -269
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +0 -48
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +0 -34
- package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +0 -13
- package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +0 -237
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +0 -27
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +0 -234
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +0 -23
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +0 -77
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +0 -29
- package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +0 -42
- package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +0 -34
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +0 -44
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +0 -215
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +0 -474
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +0 -63
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +0 -24
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +0 -135
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +0 -314
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +0 -44
- package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +0 -55
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +0 -26
- package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +0 -17
- package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +0 -15
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +0 -45
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js +0 -26
- package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +0 -18
- package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +0 -91
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +0 -78
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-all-of-schemas.js","names":["LAST_WINS_KEYS","ENUM_ANNOTATIONS","mergeEnums","values","existing","incoming","isObjectEqual","value","candidate","merged","key","source","override","annotation","sourceValues","mergeAllOfSchemas","schemas","rootSchema","result","_","baseSchema","_schema","schema","resolve","mergeSchemaIntoResult","seenRefs","declaresOwnDiscriminator","schemaKeys","objectKeys","mergedEnums","propertyName","getResolvedRef","mergePropertiesIntoResult","items","isArraySchema","mergedItems","propertyKeys","properties","rawProperty","newSchemaRef","nextNewSeenRefs","schemaRef","nextSeenRefs","existingItems","mergeItems","mergeItemsIntoResult","allOfSchemas","incomingRef","mergeItemsInner"],"sources":["../../../src/schema/helpers/merge-all-of-schemas.ts"],"sourcesContent":["import { isObjectEqual } from '@scalar/helpers/object/is-object-equal'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\n/**\n * Schema keywords whose value should reflect the *last* occurrence when merging\n * `allOf` members. Most keywords keep the first occurrence, but for human-facing\n * annotations a later subschema is expected to override an earlier one — matching\n * OpenAPI/JSON Schema tooling like Swagger UI.\n */\nconst LAST_WINS_KEYS = new Set<string>(['description', 'title'])\n\nconst ENUM_ANNOTATIONS = ['x-enum-varnames', 'x-enumNames', 'x-enum-descriptions', 'x-enumDescriptions'] as const\n\n/** Keep positional annotations attached to their values when intersecting enum constraints. */\nconst mergeEnums = (\n existing: SchemaObject,\n incoming: SchemaObject,\n override: boolean = false,\n): Partial<SchemaObject> => {\n const values =\n existing.enum?.filter(\n (value) => incoming.enum === undefined || incoming.enum.some((candidate) => isObjectEqual(value, candidate)),\n ) ?? incoming.enum?.slice()\n\n if (values === undefined) {\n return {}\n }\n\n const merged: Partial<SchemaObject> = { enum: values }\n for (const key of ENUM_ANNOTATIONS) {\n const source = incoming[key] !== undefined && (override || existing[key] === undefined) ? incoming : existing\n const annotation = source[key]\n const sourceValues = source.enum\n if (Array.isArray(annotation)) {\n merged[key] =\n sourceValues === undefined\n ? annotation\n : values.map(\n (value) => annotation[sourceValues.findIndex((candidate) => isObjectEqual(value, candidate))] ?? '',\n )\n } else if (annotation !== undefined && (key === 'x-enum-descriptions' || key === 'x-enumDescriptions')) {\n merged[key] = annotation\n }\n }\n return merged\n}\n\n/**\n * Merges multiple OpenAPI schema objects into a single schema object.\n * Handles nested allOf compositions and merges properties recursively.\n *\n * @param schemas - Array of OpenAPI schema objects to merge\n * @param rootSchema - Optional root schema to merge with the result\n * @param seenRefs - `$ref` strings already being merged higher in the call stack\n * @returns Merged schema object\n */\nexport const mergeAllOfSchemas = (\n schemas: SchemaObject | undefined,\n rootSchema?: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle max depth, empty or invalid input\n if (!schemas?.allOf?.length || !Array.isArray(schemas.allOf)) {\n return rootSchema || ({} as SchemaObject)\n }\n\n // Initialize result object once\n const result = {} as SchemaObject\n\n // Extract base schema properties (everything except allOf)\n const { allOf: _, ...baseSchema } = schemas\n\n // Process allOf schemas first\n for (const _schema of schemas.allOf) {\n if (typeof _schema !== 'boolean' && (!_schema || typeof _schema !== 'object')) {\n continue\n }\n\n // Resolve ref if present\n const schema = resolve.schema(_schema)\n\n // Handle nested allOf recursively\n if (schema.allOf) {\n const nestedMerged = mergeAllOfSchemas(schema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, false, seenRefs)\n continue\n }\n\n mergeSchemaIntoResult(result, schema, false, seenRefs)\n }\n\n // Apply base schema properties with precedence over allOf properties\n if (Object.keys(baseSchema).length > 0) {\n mergeSchemaIntoResult(result, baseSchema, true, seenRefs)\n }\n\n // Process root schema last if provided\n if (rootSchema && typeof rootSchema === 'object') {\n if (rootSchema.allOf) {\n const nestedMerged = mergeAllOfSchemas(rootSchema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, true, seenRefs)\n } else {\n mergeSchemaIntoResult(result, rootSchema, true, seenRefs)\n }\n }\n\n // Drop a `discriminator` inherited from an `allOf` member: a merged subtype is\n // one concrete branch, not a choice-point, and keeping the base's mapping makes\n // it look like the base again, recursing the selector inference (issue #9674).\n // A discriminator the schema declares itself is kept.\n const declaresOwnDiscriminator =\n 'discriminator' in baseSchema ||\n Boolean(rootSchema && typeof rootSchema === 'object' && 'discriminator' in rootSchema)\n\n if ('discriminator' in result && !declaresOwnDiscriminator) {\n delete (result as Record<string, unknown>).discriminator\n }\n\n return result\n}\n\n/**\n * Efficiently merges a source schema into a target result object.\n * Handles all schema merging logic in a single optimized function.\n *\n * @param result - The target schema object to merge into\n * @param schema - The source schema object to merge from\n * @param override - Whether to override existing properties (default: false)\n */\nconst mergeSchemaIntoResult = (\n result: SchemaObject,\n schema: SchemaObject,\n override: boolean = false,\n seenRefs: Set<string> = new Set(),\n): void => {\n // Early return if schema is empty\n const schemaKeys = objectKeys(schema)\n if (schemaKeys.length === 0) {\n return\n }\n\n const mergedEnums = mergeEnums(result, schema, override)\n\n // Loop through all schema properties and handle them appropriately\n for (const key of schemaKeys) {\n const propertyName: string = key\n const value = getResolvedRef(schema[key]) as any\n\n if (value === undefined) {\n continue\n }\n\n // Required\n if (propertyName === 'required') {\n // Merge required fields with deduplication\n if (Array.isArray(value) && value.length > 0) {\n // @ts-expect-error\n if (result.required?.length) {\n // @ts-expect-error\n result.required = [...new Set([...result.required, ...value])]\n } else {\n // @ts-expect-error\n result.required = value.slice()\n }\n }\n }\n // Properties\n else if (propertyName === 'properties') {\n // Merge properties recursively\n if (value && typeof value === 'object') {\n // @ts-expect-error\n if (!result.properties) {\n // @ts-expect-error\n result.properties = {}\n }\n\n // @ts-expect-error\n mergePropertiesIntoResult(result.properties, value, seenRefs)\n }\n }\n // Items\n else if (propertyName === 'items') {\n // Handle items (for both arrays and objects with items)\n const items = resolve.schema(value)\n if (items) {\n if (isArraySchema(schema)) {\n // @ts-expect-error\n if (!result.items) {\n // @ts-expect-error\n result.items = {}\n }\n\n // Handle allOf within array items\n if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n // @ts-expect-error\n Object.assign(result.items, mergedItems)\n } else {\n // @ts-expect-error\n mergeItemsIntoResult(getResolvedRef(result.items), items, seenRefs)\n }\n }\n // For non-array types with items.allOf, merge into properties\n else if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n if ('properties' in mergedItems) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n\n 'properties' in result && mergePropertiesIntoResult(result.properties, mergedItems.properties, seenRefs)\n }\n }\n // For non-array types without allOf, still set items if not already set\n else if (!('items' in result)) {\n // @ts-expect-error\n result.items = items\n }\n }\n }\n // Enum values and their annotations are applied together after the other keywords.\n else if (key === 'enum') {\n continue\n }\n // OneOf/AnyOf\n else if (key === 'oneOf' || key === 'anyOf') {\n // Preserve the composition itself so its variants keep rendering as a\n // selector. Flattening the option properties into the parent would drop\n // the variant structure entirely and silently lose branches that have no\n // top-level `properties` (for example branches that are themselves an\n // `allOf`). The sibling `allOf` members stay on `result` as base\n // properties, which the Schema component renders above the selector.\n if (Array.isArray(value) && value.length > 0 && (override || result[key] === undefined)) {\n result[key] = value\n }\n }\n // Skip allOf as it's handled at a higher level\n else if (key === 'allOf') {\n continue\n }\n // For all other properties, preserve the first occurrence or override if specified.\n // Annotation keywords (see LAST_WINS_KEYS) always take the latest value so a later\n // allOf member can override an earlier one.\n else {\n if (override || LAST_WINS_KEYS.has(propertyName) || result[key] === undefined) {\n result[key] = value\n }\n }\n }\n Object.assign(result, mergedEnums)\n}\n\n/**\n * Efficiently merges properties into a result object without creating new objects.\n */\nconst mergePropertiesIntoResult = (\n result: Extract<SchemaObject, { type: 'object' }>['properties'],\n properties: Extract<SchemaObject, { type: 'object' }>['properties'],\n seenRefs: Set<string> = new Set(),\n): void => {\n const propertyKeys = Object.keys(properties ?? {})\n if (!properties || !result || propertyKeys.length === 0) {\n return\n }\n\n for (const key of propertyKeys) {\n const schema = resolve.schema(properties[key])\n if (!schema) {\n delete result[key]\n continue\n }\n\n if (typeof schema !== 'object') {\n result[key] = schema\n continue\n }\n\n if (!result[key]) {\n // Break self-referential cycles reached through `allOf`. When a brand-new\n // property's `$ref` is already being merged higher in the call stack,\n // keep the raw reference instead of recursing into its `allOf` forever.\n // This mirrors the guard in the \"merge existing property\" branch below and\n // covers schemas that point back at themselves through an `allOf` member\n // (e.g. a node whose `self` property $refs the node, which is an allOf).\n const rawProperty = properties[key]\n const newSchemaRef = (rawProperty as { $ref?: string })?.$ref\n if (rawProperty && typeof newSchemaRef === 'string' && seenRefs.has(newSchemaRef)) {\n result[key] = rawProperty\n continue\n }\n const nextNewSeenRefs = typeof newSchemaRef === 'string' ? new Set(seenRefs).add(newSchemaRef) : seenRefs\n\n // Handle new property with allOf\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas(schema, undefined, nextNewSeenRefs)\n } else if (isArraySchema(schema) && resolve.schema(schema.items)?.allOf) {\n result[key] = {\n ...schema,\n items: mergeAllOfSchemas(resolve.schema(schema.items), undefined, seenRefs),\n }\n } else if (properties[key]) {\n result[key] = properties[key]\n }\n continue\n }\n\n // Merge existing property\n const existing = resolve.schema(result[key])\n\n // Break self-referential cycles: when this property's `$ref` is already\n // being merged higher in the call stack, keep the partially merged existing\n // schema instead of recursing into it again. This mirrors the guard in\n // `mergeItems` and covers schemas that point back at themselves through a\n // plain object property (e.g. a tree node whose `parent` $refs the node).\n const schemaRef = schema.$ref\n if (typeof schemaRef === 'string' && seenRefs.has(schemaRef)) {\n result[key] = existing\n continue\n }\n const nextSeenRefs = typeof schemaRef === 'string' ? new Set(seenRefs).add(schemaRef) : seenRefs\n\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas({ allOf: [existing, schema] } as SchemaObject, undefined, nextSeenRefs)\n } else if (isArraySchema(schema) && isArraySchema(existing) && schema.items) {\n const existingItems = resolve.schema(existing.items)\n result[key] = {\n ...existing,\n type: 'array',\n items: existingItems\n ? mergeItems(existingItems, resolve.schema(schema.items), nextSeenRefs)\n : resolve.schema(schema.items),\n }\n } else {\n // Create merged object with properties handled separately\n if ('properties' in existing && 'properties' in schema) {\n const merged = { ...existing, ...schema }\n merged.properties = { ...existing.properties }\n mergePropertiesIntoResult(merged.properties, schema.properties, nextSeenRefs)\n result[key] = merged\n }\n // Simple merge without property recursion\n else {\n result[key] = {\n ...schema,\n ...existing,\n ...mergeEnums(existing, schema),\n }\n }\n }\n }\n}\n\n/**\n * Efficiently merges array items into a result object.\n */\nconst mergeItemsIntoResult = (result: SchemaObject, items: SchemaObject, seenRefs: Set<string> = new Set()): void => {\n // Handle allOf in items\n if (items.allOf || result.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (result.allOf) {\n for (const schema of result.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(result)\n }\n\n if (items.allOf) {\n for (const schema of items.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(items)\n }\n\n const merged = mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n Object.assign(result, merged)\n return\n }\n\n // Regular merge\n Object.assign(result, items)\n\n // Merge properties if both have them\n if ('properties' in result && 'properties' in items) {\n mergePropertiesIntoResult(result.properties, items.properties, seenRefs)\n }\n}\n\n/**\n * Helper function for merging items that returns a new object.\n */\nconst mergeItems = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n const incomingRef = (incoming as { $ref?: string }).$ref\n\n if (typeof incomingRef === 'string') {\n if (seenRefs.has(incomingRef)) {\n return existing\n }\n return mergeItemsInner(existing, incoming, new Set(seenRefs).add(incomingRef))\n }\n\n return mergeItemsInner(existing, incoming, seenRefs)\n}\n\nconst mergeItemsInner = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle allOf in either schema\n if (existing.allOf || incoming.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (existing.allOf) {\n for (const schema of existing.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(existing)\n }\n\n if (incoming.allOf) {\n for (const schema of incoming.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(incoming)\n }\n\n return mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n }\n\n // Construct the merged object after narrowing both schemas so their property types survive.\n if ('properties' in existing && 'properties' in incoming) {\n const merged = { ...existing, ...incoming, properties: { ...existing.properties } }\n mergePropertiesIntoResult(merged.properties, incoming.properties, seenRefs)\n return merged\n }\n\n return { ...existing, ...incoming }\n}\n"],"mappings":";;;;;;AAaA,IAAMA,oBAAiB,IAAI,IAAY,CAAC,eAAe,OAAO,CAAC,GAEzDC,IAAmB;CAAC;CAAmB;CAAe;CAAuB;AAAoB,GAGjGC,KACJ,GACA,GACA,IAAoB,OACM;CAC1B,IAAMC,IACJC,EAAS,MAAM,QACZ,MAAUC,EAAS,SAAS,KAAA,KAAaA,EAAS,KAAK,MAAM,MAAcC,EAAcC,GAAOC,CAAS,CAAC,CAC7G,KAAKH,EAAS,MAAM,MAAM;CAE5B,IAAIF,MAAW,KAAA,GACb,OAAO,CAAC;CAGV,IAAMM,IAAgC,EAAE,MAAMN,EAAO;CACrD,KAAK,IAAMO,KAAOT,GAAkB;EAClC,IAAMU,IAASN,EAASK,OAAS,KAAA,MAAcE,KAAYR,EAAS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AAgBC,GAAU;EACxD,IAAMI,IAAS;GAAE,GAAGL;GAAU,GAAGC;GAAU,YAAY,EAAE,GAAGD,EAAS,WAAW;EAAE;EAElF,OADA4B,EAA0BvB,EAAO,YAAYJ,EAAS,YAAYoB,CAAQ,GACnEhB;CACT;CAEA,OAAO;EAAE,GAAGL;EAAU,GAAGC;CAAS;AACpC"}
|
|
1
|
+
{"version":3,"file":"merge-all-of-schemas.js","names":["getResolvedRef","resolve","isArraySchema","isObjectEqual","objectKeys","LAST_WINS_KEYS","ENUM_ANNOTATIONS","mergeEnums","existing","incoming","override","values","value","candidate","merged","key","source","annotation","sourceValues","mergeAllOfSchemas","schemas","rootSchema","seenRefs","result","_","baseSchema","_schema","schema","mergeSchemaIntoResult","declaresOwnDiscriminator","schemaKeys","mergedEnums","propertyName","mergePropertiesIntoResult","items","mergedItems","mergeItemsIntoResult","properties","propertyKeys","rawProperty","newSchemaRef","nextNewSeenRefs","schemaRef","nextSeenRefs","existingItems","mergeItems","allOfSchemas","incomingRef","mergeItemsInner"],"sources":["../../../src/schema/helpers/merge-all-of-schemas.ts"],"sourcesContent":["import { isObjectEqual } from '@scalar/helpers/object/is-object-equal'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\n/**\n * Schema keywords whose value should reflect the *last* occurrence when merging\n * `allOf` members. Most keywords keep the first occurrence, but for human-facing\n * annotations a later subschema is expected to override an earlier one — matching\n * OpenAPI/JSON Schema tooling like Swagger UI.\n */\nconst LAST_WINS_KEYS = new Set<string>(['description', 'title'])\n\nconst ENUM_ANNOTATIONS = ['x-enum-varnames', 'x-enumNames', 'x-enum-descriptions', 'x-enumDescriptions'] as const\n\n/** Keep positional annotations attached to their values when intersecting enum constraints. */\nconst mergeEnums = (\n existing: SchemaObject,\n incoming: SchemaObject,\n override: boolean = false,\n): Partial<SchemaObject> => {\n const values =\n existing.enum?.filter(\n (value) => incoming.enum === undefined || incoming.enum.some((candidate) => isObjectEqual(value, candidate)),\n ) ?? incoming.enum?.slice()\n\n if (values === undefined) {\n return {}\n }\n\n const merged: Partial<SchemaObject> = { enum: values }\n for (const key of ENUM_ANNOTATIONS) {\n const source = incoming[key] !== undefined && (override || existing[key] === undefined) ? incoming : existing\n const annotation = source[key]\n const sourceValues = source.enum\n if (Array.isArray(annotation)) {\n merged[key] =\n sourceValues === undefined\n ? annotation\n : values.map(\n (value) => annotation[sourceValues.findIndex((candidate) => isObjectEqual(value, candidate))] ?? '',\n )\n } else if (annotation !== undefined && (key === 'x-enum-descriptions' || key === 'x-enumDescriptions')) {\n merged[key] = annotation\n }\n }\n return merged\n}\n\n/**\n * Merges multiple OpenAPI schema objects into a single schema object.\n * Handles nested allOf compositions and merges properties recursively.\n *\n * @param schemas - Array of OpenAPI schema objects to merge\n * @param rootSchema - Optional root schema to merge with the result\n * @param seenRefs - `$ref` strings already being merged higher in the call stack\n * @returns Merged schema object\n */\nexport const mergeAllOfSchemas = (\n schemas: SchemaObject | undefined,\n rootSchema?: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle max depth, empty or invalid input\n if (!schemas?.allOf?.length || !Array.isArray(schemas.allOf)) {\n return rootSchema || ({} as SchemaObject)\n }\n\n // Initialize result object once\n const result = {} as SchemaObject\n\n // Extract base schema properties (everything except allOf)\n const { allOf: _, ...baseSchema } = schemas\n\n // Process allOf schemas first\n for (const _schema of schemas.allOf) {\n if (typeof _schema !== 'boolean' && (!_schema || typeof _schema !== 'object')) {\n continue\n }\n\n // Resolve ref if present\n const schema = resolve.schema(_schema)\n\n // Handle nested allOf recursively\n if (schema.allOf) {\n const nestedMerged = mergeAllOfSchemas(schema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, false, seenRefs)\n continue\n }\n\n mergeSchemaIntoResult(result, schema, false, seenRefs)\n }\n\n // Apply base schema properties with precedence over allOf properties\n if (Object.keys(baseSchema).length > 0) {\n mergeSchemaIntoResult(result, baseSchema, true, seenRefs)\n }\n\n // Process root schema last if provided\n if (rootSchema && typeof rootSchema === 'object') {\n if (rootSchema.allOf) {\n const nestedMerged = mergeAllOfSchemas(rootSchema, undefined, seenRefs)\n mergeSchemaIntoResult(result, nestedMerged, true, seenRefs)\n } else {\n mergeSchemaIntoResult(result, rootSchema, true, seenRefs)\n }\n }\n\n // Drop a `discriminator` inherited from an `allOf` member: a merged subtype is\n // one concrete branch, not a choice-point, and keeping the base's mapping makes\n // it look like the base again, recursing the selector inference (issue #9674).\n // A discriminator the schema declares itself is kept.\n const declaresOwnDiscriminator =\n 'discriminator' in baseSchema ||\n Boolean(rootSchema && typeof rootSchema === 'object' && 'discriminator' in rootSchema)\n\n if ('discriminator' in result && !declaresOwnDiscriminator) {\n delete (result as Record<string, unknown>).discriminator\n }\n\n return result\n}\n\n/**\n * Efficiently merges a source schema into a target result object.\n * Handles all schema merging logic in a single optimized function.\n *\n * @param result - The target schema object to merge into\n * @param schema - The source schema object to merge from\n * @param override - Whether to override existing properties (default: false)\n */\nconst mergeSchemaIntoResult = (\n result: SchemaObject,\n schema: SchemaObject,\n override: boolean = false,\n seenRefs: Set<string> = new Set(),\n): void => {\n // Early return if schema is empty\n const schemaKeys = objectKeys(schema)\n if (schemaKeys.length === 0) {\n return\n }\n\n const mergedEnums = mergeEnums(result, schema, override)\n\n // Loop through all schema properties and handle them appropriately\n for (const key of schemaKeys) {\n const propertyName: string = key\n const value = getResolvedRef(schema[key]) as any\n\n if (value === undefined) {\n continue\n }\n\n // Required\n if (propertyName === 'required') {\n // Merge required fields with deduplication\n if (Array.isArray(value) && value.length > 0) {\n // @ts-expect-error\n if (result.required?.length) {\n // @ts-expect-error\n result.required = [...new Set([...result.required, ...value])]\n } else {\n // @ts-expect-error\n result.required = value.slice()\n }\n }\n }\n // Properties\n else if (propertyName === 'properties') {\n // Merge properties recursively\n if (value && typeof value === 'object') {\n // @ts-expect-error\n if (!result.properties) {\n // @ts-expect-error\n result.properties = {}\n }\n\n // @ts-expect-error\n mergePropertiesIntoResult(result.properties, value, seenRefs)\n }\n }\n // Items\n else if (propertyName === 'items') {\n // Handle items (for both arrays and objects with items)\n const items = resolve.schema(value)\n if (items) {\n if (isArraySchema(schema)) {\n // @ts-expect-error\n if (!result.items) {\n // @ts-expect-error\n result.items = {}\n }\n\n // Handle allOf within array items\n if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n // @ts-expect-error\n Object.assign(result.items, mergedItems)\n } else {\n // @ts-expect-error\n mergeItemsIntoResult(getResolvedRef(result.items), items, seenRefs)\n }\n }\n // For non-array types with items.allOf, merge into properties\n else if (items.allOf) {\n const mergedItems = mergeAllOfSchemas(items, undefined, seenRefs)\n if ('properties' in mergedItems) {\n if (!('properties' in result)) {\n // @ts-expect-error\n result.properties = {}\n }\n\n 'properties' in result && mergePropertiesIntoResult(result.properties, mergedItems.properties, seenRefs)\n }\n }\n // For non-array types without allOf, still set items if not already set\n else if (!('items' in result)) {\n // @ts-expect-error\n result.items = items\n }\n }\n }\n // Enum values and their annotations are applied together after the other keywords.\n else if (key === 'enum') {\n continue\n }\n // OneOf/AnyOf\n else if (key === 'oneOf' || key === 'anyOf') {\n // Preserve the composition itself so its variants keep rendering as a\n // selector. Flattening the option properties into the parent would drop\n // the variant structure entirely and silently lose branches that have no\n // top-level `properties` (for example branches that are themselves an\n // `allOf`). The sibling `allOf` members stay on `result` as base\n // properties, which the Schema component renders above the selector.\n if (Array.isArray(value) && value.length > 0 && (override || result[key] === undefined)) {\n result[key] = value\n }\n }\n // Skip allOf as it's handled at a higher level\n else if (key === 'allOf') {\n continue\n }\n // For all other properties, preserve the first occurrence or override if specified.\n // Annotation keywords (see LAST_WINS_KEYS) always take the latest value so a later\n // allOf member can override an earlier one.\n else {\n if (override || LAST_WINS_KEYS.has(propertyName) || result[key] === undefined) {\n result[key] = value\n }\n }\n }\n Object.assign(result, mergedEnums)\n}\n\n/**\n * Efficiently merges properties into a result object without creating new objects.\n */\nconst mergePropertiesIntoResult = (\n result: Extract<SchemaObject, { type: 'object' }>['properties'],\n properties: Extract<SchemaObject, { type: 'object' }>['properties'],\n seenRefs: Set<string> = new Set(),\n): void => {\n const propertyKeys = Object.keys(properties ?? {})\n if (!properties || !result || propertyKeys.length === 0) {\n return\n }\n\n for (const key of propertyKeys) {\n const schema = resolve.schema(properties[key])\n if (!schema) {\n delete result[key]\n continue\n }\n\n if (typeof schema !== 'object') {\n result[key] = schema\n continue\n }\n\n if (!result[key]) {\n // Break self-referential cycles reached through `allOf`. When a brand-new\n // property's `$ref` is already being merged higher in the call stack,\n // keep the raw reference instead of recursing into its `allOf` forever.\n // This mirrors the guard in the \"merge existing property\" branch below and\n // covers schemas that point back at themselves through an `allOf` member\n // (e.g. a node whose `self` property $refs the node, which is an allOf).\n const rawProperty = properties[key]\n const newSchemaRef = (rawProperty as { $ref?: string })?.$ref\n if (rawProperty && typeof newSchemaRef === 'string' && seenRefs.has(newSchemaRef)) {\n result[key] = rawProperty\n continue\n }\n const nextNewSeenRefs = typeof newSchemaRef === 'string' ? new Set(seenRefs).add(newSchemaRef) : seenRefs\n\n // Handle new property with allOf\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas(schema, undefined, nextNewSeenRefs)\n } else if (isArraySchema(schema) && resolve.schema(schema.items)?.allOf) {\n result[key] = {\n ...schema,\n items: mergeAllOfSchemas(resolve.schema(schema.items), undefined, seenRefs),\n }\n } else if (properties[key]) {\n result[key] = properties[key]\n }\n continue\n }\n\n // Merge existing property\n const existing = resolve.schema(result[key])\n\n // Break self-referential cycles: when this property's `$ref` is already\n // being merged higher in the call stack, keep the partially merged existing\n // schema instead of recursing into it again. This mirrors the guard in\n // `mergeItems` and covers schemas that point back at themselves through a\n // plain object property (e.g. a tree node whose `parent` $refs the node).\n const schemaRef = schema.$ref\n if (typeof schemaRef === 'string' && seenRefs.has(schemaRef)) {\n result[key] = existing\n continue\n }\n const nextSeenRefs = typeof schemaRef === 'string' ? new Set(seenRefs).add(schemaRef) : seenRefs\n\n if (schema.allOf) {\n result[key] = mergeAllOfSchemas({ allOf: [existing, schema] } as SchemaObject, undefined, nextSeenRefs)\n } else if (isArraySchema(schema) && isArraySchema(existing) && schema.items) {\n const existingItems = resolve.schema(existing.items)\n result[key] = {\n ...existing,\n type: 'array',\n items: existingItems\n ? mergeItems(existingItems, resolve.schema(schema.items), nextSeenRefs)\n : resolve.schema(schema.items),\n }\n } else {\n // Create merged object with properties handled separately\n if ('properties' in existing && 'properties' in schema) {\n const merged = { ...existing, ...schema }\n merged.properties = { ...existing.properties }\n mergePropertiesIntoResult(merged.properties, schema.properties, nextSeenRefs)\n result[key] = merged\n }\n // Simple merge without property recursion\n else {\n result[key] = {\n ...schema,\n ...existing,\n ...mergeEnums(existing, schema),\n }\n }\n }\n }\n}\n\n/**\n * Efficiently merges array items into a result object.\n */\nconst mergeItemsIntoResult = (result: SchemaObject, items: SchemaObject, seenRefs: Set<string> = new Set()): void => {\n // Handle allOf in items\n if (items.allOf || result.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (result.allOf) {\n for (const schema of result.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(result)\n }\n\n if (items.allOf) {\n for (const schema of items.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(items)\n }\n\n const merged = mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n Object.assign(result, merged)\n return\n }\n\n // Regular merge\n Object.assign(result, items)\n\n // Merge properties if both have them\n if ('properties' in result && 'properties' in items) {\n mergePropertiesIntoResult(result.properties, items.properties, seenRefs)\n }\n}\n\n/**\n * Helper function for merging items that returns a new object.\n */\nconst mergeItems = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n const incomingRef = (incoming as { $ref?: string }).$ref\n\n if (typeof incomingRef === 'string') {\n if (seenRefs.has(incomingRef)) {\n return existing\n }\n return mergeItemsInner(existing, incoming, new Set(seenRefs).add(incomingRef))\n }\n\n return mergeItemsInner(existing, incoming, seenRefs)\n}\n\nconst mergeItemsInner = (\n existing: SchemaObject,\n incoming: SchemaObject,\n seenRefs: Set<string> = new Set(),\n): SchemaObject => {\n // Handle allOf in either schema\n if (existing.allOf || incoming.allOf) {\n // Build array without spreads for better performance\n const allOfSchemas: SchemaObject[] = []\n\n if (existing.allOf) {\n for (const schema of existing.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(existing)\n }\n\n if (incoming.allOf) {\n for (const schema of incoming.allOf) {\n allOfSchemas.push(resolve.schema(schema))\n }\n } else {\n allOfSchemas.push(incoming)\n }\n\n return mergeAllOfSchemas({ allOf: allOfSchemas } as SchemaObject, undefined, seenRefs)\n }\n\n // Construct the merged object after narrowing both schemas so their property types survive.\n if ('properties' in existing && 'properties' in incoming) {\n const merged = { ...existing, ...incoming, properties: { ...existing.properties } }\n mergePropertiesIntoResult(merged.properties, incoming.properties, seenRefs)\n return merged\n }\n\n return { ...existing, ...incoming }\n}\n"],"mappings":";;;;;;AAaA,IAAMK,oBAAiB,IAAI,IAAY,CAAC,eAAe,OAAO,CAAC,GAEzDC,IAAmB;CAAC;CAAmB;CAAe;CAAuB;AAAoB,GAGjGC,KACJC,GACAC,GACAC,IAAoB,OACM;CAC1B,IAAMC,IACJH,EAAS,MAAM,QACZI,MAAUH,EAAS,SAAS,KAAA,KAAaA,EAAS,KAAK,MAAMI,MAAcV,EAAcS,GAAOC,CAAS,CAAC,CAC7G,KAAKJ,EAAS,MAAM,MAAM;CAE5B,IAAIE,MAAW,KAAA,GACb,OAAO,CAAC;CAGV,IAAMG,IAAgC,EAAE,MAAMH,EA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AkB,EAAE,OAAO2B,EAAa,GAAmB,KAAA,GAAWxB,CAAQ;CACvF;CAGA,IAAI,gBAAgBd,KAAY,gBAAgBC,GAAU;EACxD,IAAMK,IAAS;GAAE,GAAGN;GAAU,GAAGC;GAAU,YAAY,EAAE,GAAGD,EAAS,WAAW;EAAE;EAElF,OADAyB,EAA0BnB,EAAO,YAAYL,EAAS,YAAYa,CAAQ,GACnER;CACT;CAEA,OAAO;EAAE,GAAGN;EAAU,GAAGC;CAAS;AACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-object-composition.js","names":["
|
|
1
|
+
{"version":3,"file":"normalize-object-composition.js","names":["isTypeObject","partitionAllOfCompositions","normalizeObjectComposition","value","name","segments","segment","objectSchema","annotations"],"sources":["../../../src/schema/helpers/normalize-object-composition.ts"],"sourcesContent":["import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { isTypeObject } from './is-type-object'\nimport { partitionAllOfCompositions } from './partition-all-of-compositions'\n\n/** Display schemas may carry the nullable annotation produced by composition optimization. */\ntype DisplaySchema = SchemaObject & { nullable?: boolean }\n\n/** Preserve a named property's object boundary when all of its composition members form one object. */\nexport const normalizeObjectComposition = (\n value: DisplaySchema | undefined,\n name: string | undefined,\n): DisplaySchema | undefined => {\n // Choice groups and unnamed composition containers keep their existing rendering.\n if (!name || !value?.allOf || value.oneOf || value.anyOf || value.not) {\n return value\n }\n\n const { segments } = partitionAllOfCompositions(value)\n const segment = segments[0]\n if (segments.length !== 1 || segment?.kind !== 'object' || !isTypeObject(segment.schema)) {\n return value\n }\n\n // A member reference identifies only part of this object, not the combined property.\n // Keep the property's own reference, if it has one.\n const objectSchema = { ...segment.schema }\n if ('$ref' in objectSchema) {\n delete objectSchema.$ref\n }\n // Member annotations describe only one part of the combined property. Keep the\n // property's annotations authoritative without changing merged validation rules.\n const annotations = {\n title: value.title,\n description: value.description,\n deprecated: value.deprecated,\n readOnly: value.readOnly,\n writeOnly: value.writeOnly,\n example: value.example,\n examples: value.examples,\n nullable: value.nullable,\n }\n return {\n ...objectSchema,\n ...annotations,\n ...('$ref' in value && typeof value.$ref === 'string' ? { $ref: value.$ref } : {}),\n }\n}\n"],"mappings":";;;AASA,IAAaE,KACXC,GACAC,MAC8B;CAE9B,IAAI,CAACA,KAAQ,CAACD,GAAO,SAASA,EAAM,SAASA,EAAM,SAASA,EAAM,KAChE,OAAOA;CAGT,IAAM,EAAEE,gBAAaJ,EAA2BE,CAAK,GAC/CG,IAAUD,EAAS;CACzB,IAAIA,EAAS,WAAW,KAAKC,GAAS,SAAS,YAAY,CAACN,EAAaM,EAAQ,MAAM,GACrF,OAAOH;CAKT,IAAMI,IAAe,EAAE,GAAGD,EAAQ,OAAO;CACrC,UAAUC,KACZ,OAAOA,EAAa;CAItB,IAAMC,IAAc;EAClB,OAAOL,EAAM;EACb,aAAaA,EAAM;EACnB,YAAYA,EAAM;EAClB,UAAUA,EAAM;EAChB,WAAWA,EAAM;EACjB,SAASA,EAAM;EACf,UAAUA,EAAM;EAChB,UAAUA,EAAM;CAClB;CACA,OAAO;EACL,GAAGI;EACH,GAAGC;EACH,GAAI,UAAUL,KAAS,OAAOA,EAAM,QAAS,WAAW,EAAE,MAAMA,EAAM,KAAK,IAAI,CAAC;CAClF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize-value-for-display.js","names":["mergeSchemaProperties","objects","merged","properties","required","hasProperties","hasRequired","object","key","val","name","optimizeValueForDisplay","value","schemaDiscriminator","composition","compositions","keyword","schemas","_","originalNullable","rootProperties","hasRootProperties","schema","resolve","_schema","acc","shouldBeNullable","hasNullSchema","filteredSchemas","mergedSchema","_discriminator","badges","variantRootProperties","mergedSchemas","otherProps","allOfMember","allOf","_ref","_title","_name","allOfMemberWithoutIdentity","result"],"sources":["../../../src/schema/helpers/optimize-value-for-display.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type DiscriminatorSchema, schemaDiscriminator } from '../discriminator-metadata'\nimport { compositions } from './schema-composition'\n\n/** Display normalization tracks null branches without changing the stored OpenAPI schema. */\ntype DisplaySchema = SchemaObject & { nullable?: boolean }\n\n/**\n * Shallow-merges schema-like objects, but unions `properties` and `required`\n * instead of letting a later object's `properties`/`required` completely\n * overwrite an earlier one's. Without this, a variant schema (e.g. a `oneOf`\n * branch) that declares its own `properties`/`required` would wipe out the\n * shared base fields factored out at the root (or via a sibling `allOf`)\n * instead of being combined with them (#9657).\n */\nfunction mergeSchemaProperties(...objects: (Record<string, unknown> | undefined)[]): Record<string, unknown> {\n const merged: Record<PropertyKey, unknown> = {}\n const properties: Record<string, unknown> = {}\n const required = new Set<string>()\n let hasProperties = false\n let hasRequired = false\n\n for (const object of objects) {\n if (!object) {\n continue\n }\n\n // Renderer-only symbols must survive flattening nullable and single-branch compositions.\n for (const key of Object.getOwnPropertySymbols(object)) {\n merged[key] = (object as Record<PropertyKey, unknown>)[key]\n }\n\n for (const [key, val] of Object.entries(object)) {\n if (key === 'properties' && val && typeof val === 'object') {\n Object.assign(properties, val)\n hasProperties = true\n continue\n }\n\n if (key === 'required' && Array.isArray(val)) {\n for (const name of val) {\n required.add(name)\n }\n hasRequired = true\n continue\n }\n\n merged[key] = val\n }\n }\n\n if (hasProperties) {\n merged.properties = properties\n }\n if (hasRequired) {\n merged.required = [...required]\n }\n\n return merged\n}\n\n/**\n * Normalize compositions for display without changing the source schema. Null branches\n * become nullable state, single branches are flattened, and shared properties and\n * required fields are merged into variants so the renderer keeps their full context.\n */\nexport function optimizeValueForDisplay(value: DisplaySchema | undefined): DisplaySchema | undefined {\n if (!value || typeof value !== 'object') {\n return value\n }\n\n // Inferred AsyncAPI variants already carry complete concrete schemas. Flattening\n // them would lose reference identities and merge the base identity into descendants.\n if ((value as DiscriminatorSchema)[schemaDiscriminator]?.inheritedVariants) {\n return value\n }\n\n // Find the composition keyword early to avoid unnecessary work\n const composition = compositions.find((keyword) => keyword in value && keyword !== 'not')\n\n // If there's no relevant composition keyword, return a shallow copy\n if (!composition) {\n return { ...value }\n }\n\n const schemas = value[composition]\n if (!Array.isArray(schemas)) {\n return { ...value }\n }\n\n // Extract root properties efficiently (excluding composition and nullable)\n const { [composition]: _, nullable: originalNullable, ...rootProperties } = value\n const hasRootProperties = Object.keys(rootProperties).length > 0\n\n // Check for null schemas and filter them out in one pass\n const { filteredSchemas, hasNullSchema } = schemas.reduce<{\n filteredSchemas: SchemaObject[]\n hasNullSchema: boolean\n }>(\n (acc, _schema) => {\n const schema = resolve.schema(_schema)\n\n if ('type' in schema && schema.type === 'null') {\n acc.hasNullSchema = true\n } else {\n acc.filteredSchemas.push(schema)\n }\n return acc\n },\n { filteredSchemas: [], hasNullSchema: false },\n )\n\n // Determine if nullable should be set\n const shouldBeNullable = hasNullSchema || originalNullable === true\n\n // If only one schema remains after filtering, merge with root properties.\n // `properties`/`required` are unioned so sibling properties declared next to\n // the composition (e.g. `properties` alongside a single-`$ref` `allOf`) are\n // kept instead of being overwritten by the member schema's own `properties`.\n // Root-level annotations (title, description, …) win over the member's: they\n // describe the combined schema, not the base it extends.\n if (filteredSchemas.length === 1) {\n const mergedSchema = mergeSchemaProperties(filteredSchemas[0], rootProperties) as DisplaySchema\n if (shouldBeNullable) {\n mergedSchema.nullable = true\n }\n return mergedSchema\n }\n\n // Check if root properties should be merged into schemas\n const shouldMergeRootProperties =\n (composition === 'oneOf' || composition === 'anyOf') &&\n (hasRootProperties || filteredSchemas.some((schema) => schema.allOf))\n\n if (shouldMergeRootProperties) {\n // The discriminator belongs to the union, not to its variants. Copied into a variant, it\n // makes the variant look like a bare `discriminator.mapping` base, which then infers a\n // second selector inside the variant.\n // The property's badges also belong to the union, while variants can define their own.\n const { discriminator: _discriminator, 'x-badges': badges, ...variantRootProperties } = rootProperties\n\n const mergedSchemas = filteredSchemas.map((_schema) => {\n const schema = resolve.schema(_schema)\n\n // Flatten single-item allOf and merge with root properties. If the\n // variant has its own properties/required/$ref, the allOf member's own\n // identity (`$ref`, `title`, `name`) is dropped before merging so it\n // cannot overwrite the variant's, which would otherwise mislabel the\n // flattened schema as the base it extends instead of the variant itself\n // (#9964). `getModelNameFromSchema` labels a variant by title → name →\n // $ref, so any of those leaking from the base is enough to mislabel it.\n // A variant that is a bare wrapper around the allOf member has no\n // identity of its own to protect, so the base's identity is kept as a\n // fallback label.\n if (schema.allOf?.length === 1) {\n const { allOf, ...otherProps } = schema\n const allOfMember = resolve.schema(allOf[0])!\n const variantHasOwnIdentity = 'properties' in otherProps || 'required' in otherProps || '$ref' in otherProps\n if (variantHasOwnIdentity) {\n const { $ref: _ref, title: _title, name: _name, ...allOfMemberWithoutIdentity } = allOfMember\n return mergeSchemaProperties(variantRootProperties, otherProps, allOfMemberWithoutIdentity)\n }\n return mergeSchemaProperties(variantRootProperties, otherProps, allOfMember)\n }\n return mergeSchemaProperties(variantRootProperties, schema)\n })\n\n // @ts-expect-error - We avoid using coerceValue here as it may be dangerous, so we type cast\n const result = { [composition]: mergedSchemas } as DisplaySchema\n if (badges !== undefined) {\n result['x-badges'] = badges\n }\n if (typeof value.description === 'string') {\n result.description = value.description\n }\n if (shouldBeNullable) {\n result.nullable = true\n }\n return result\n }\n\n // Return with filtered schemas if any nulls were removed\n if (filteredSchemas.length !== schemas.length) {\n const result: DisplaySchema = { ...value, [composition]: filteredSchemas }\n if (shouldBeNullable) {\n result.nullable = true\n }\n return result\n }\n\n return { ...value }\n}\n"],"mappings":";;;;AAiBA,SAASA,EAAsB,GAAGC,GAA2E;CAC3G,IAAMC,IAAuC,CAAC,GACxCC,IAAsC,CAAC,GACvCC,oBAAW,IAAI,IAAY,GAC7BC,IAAgB,IAChBC,IAAc;CAElB,KAAK,IAAMC,KAAUN,GACnB,IAAKM,GAKL;OAAK,IAAMC,KAAO,OAAO,sBAAsBD,CAAM,GACnD,EAAOC,KAAQD,EAAwCC;EAGzD,K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a,WAAW,KAEnBG;CACT;CAOA,KAHGf,MAAgB,WAAWA,MAAgB,aAC3CO,KAAqBO,EAAgB,MAAM,MAAWN,EAAO,KAAK,IAEtC;EAK7B,IAAM,EAAE,eAAeQ,GAAgB,YAAYC,GAAQ,GAAGC,MAA0BZ,GAElFa,IAAgBL,EAAgB,KAAK,MAAY;GACrD,IAAMN,IAASC,EAAQ,OAAOC,CAAO;GAYrC,IAAIF,EAAO,OAAO,WAAW,GAAG;IAC9B,IAAM,EAAE,UAAO,GAAGY,MAAeZ,GAC3Ba,IAAcZ,EAAQ,OAAOa,EAAM,EAAE;IAE3C,IAD8B,gBAAgBF,KAAc,cAAcA,KAAc,UAAUA,GACvE;KACzB,IAAM,EAAE,MAAMG,GAAM,OAAOC,GAAQ,MAAMC,GAAO,GAAGC,MAA+BL;KAClF,OAAOnC,EAAsBgC,GAAuBE,GAAYM,CAA0B;IAC5F;IACA,OAAOxC,EAAsBgC,GAAuBE,GAAYC,CAAW;GAC7E;GACA,OAAOnC,EAAsBgC,GAAuBV,CAAM;EAC5D,CAAC,GAGKmB,IAAS,GAAG3B,IAAcmB,EAAc;EAU9C,OATIF,MAAW,KAAA,MACb,EAAO,cAAcA,IAEnB,OAAOnB,EAAM,eAAgB,aAC/B,EAAO,cAAcA,EAAM,cAEzBc,MACF,EAAO,WAAW,KAEbe;CACT;CAGA,IAAIb,EAAgB,WAAWX,EAAQ,QAAQ;EAC7C,IAAMwB,IAAwB;GAAE,GAAG7B;IAAQE,IAAcc;EAAgB;EAIzE,OAHIF,MACF,EAAO,WAAW,KAEbe;CACT;CAEA,OAAO,EAAE,GAAG7B,EAAM;AACpB"}
|
|
1
|
+
{"version":3,"file":"optimize-value-for-display.js","names":["schemaDiscriminator","compositions","resolve","mergeSchemaProperties","objects","merged","properties","required","hasProperties","hasRequired","object","key","val","name","optimizeValueForDisplay","value","composition","keyword","schemas","_","originalNullable","rootProperties","hasRootProperties","filteredSchemas","hasNullSchema","acc","_schema","schema","shouldBeNullable","mergedSchema","_discriminator","badges","variantRootProperties","mergedSchemas","allOf","otherProps","allOfMember","_ref","_title","_name","allOfMemberWithoutIdentity","result"],"sources":["../../../src/schema/helpers/optimize-value-for-display.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type DiscriminatorSchema, schemaDiscriminator } from '../discriminator-metadata'\nimport { compositions } from './schema-composition'\n\n/** Display normalization tracks null branches without changing the stored OpenAPI schema. */\ntype DisplaySchema = SchemaObject & { nullable?: boolean }\n\n/**\n * Shallow-merges schema-like objects, but unions `properties` and `required`\n * instead of letting a later object's `properties`/`required` completely\n * overwrite an earlier one's. Without this, a variant schema (e.g. a `oneOf`\n * branch) that declares its own `properties`/`required` would wipe out the\n * shared base fields factored out at the root (or via a sibling `allOf`)\n * instead of being combined with them (#9657).\n */\nfunction mergeSchemaProperties(...objects: (Record<string, unknown> | undefined)[]): Record<string, unknown> {\n const merged: Record<PropertyKey, unknown> = {}\n const properties: Record<string, unknown> = {}\n const required = new Set<string>()\n let hasProperties = false\n let hasRequired = false\n\n for (const object of objects) {\n if (!object) {\n continue\n }\n\n // Renderer-only symbols must survive flattening nullable and single-branch compositions.\n for (const key of Object.getOwnPropertySymbols(object)) {\n merged[key] = (object as Record<PropertyKey, unknown>)[key]\n }\n\n for (const [key, val] of Object.entries(object)) {\n if (key === 'properties' && val && typeof val === 'object') {\n Object.assign(properties, val)\n hasProperties = true\n continue\n }\n\n if (key === 'required' && Array.isArray(val)) {\n for (const name of val) {\n required.add(name)\n }\n hasRequired = true\n continue\n }\n\n merged[key] = val\n }\n }\n\n if (hasProperties) {\n merged.properties = properties\n }\n if (hasRequired) {\n merged.required = [...required]\n }\n\n return merged\n}\n\n/**\n * Normalize compositions for display without changing the source schema. Null branches\n * become nullable state, single branches are flattened, and shared properties and\n * required fields are merged into variants so the renderer keeps their full context.\n */\nexport function optimizeValueForDisplay(value: DisplaySchema | undefined): DisplaySchema | undefined {\n if (!value || typeof value !== 'object') {\n return value\n }\n\n // Inferred AsyncAPI variants already carry complete concrete schemas. Flattening\n // them would lose reference identities and merge the base identity into descendants.\n if ((value as DiscriminatorSchema)[schemaDiscriminator]?.inheritedVariants) {\n return value\n }\n\n // Find the composition keyword early to avoid unnecessary work\n const composition = compositions.find((keyword) => keyword in value && keyword !== 'not')\n\n // If there's no relevant composition keyword, return a shallow copy\n if (!composition) {\n return { ...value }\n }\n\n const schemas = value[composition]\n if (!Array.isArray(schemas)) {\n return { ...value }\n }\n\n // Extract root properties efficiently (excluding composition and nullable)\n const { [composition]: _, nullable: originalNullable, ...rootProperties } = value\n const hasRootProperties = Object.keys(rootProperties).length > 0\n\n // Check for null schemas and filter them out in one pass\n const { filteredSchemas, hasNullSchema } = schemas.reduce<{\n filteredSchemas: SchemaObject[]\n hasNullSchema: boolean\n }>(\n (acc, _schema) => {\n const schema = resolve.schema(_schema)\n\n if ('type' in schema && schema.type === 'null') {\n acc.hasNullSchema = true\n } else {\n acc.filteredSchemas.push(schema)\n }\n return acc\n },\n { filteredSchemas: [], hasNullSchema: false },\n )\n\n // Determine if nullable should be set\n const shouldBeNullable = hasNullSchema || originalNullable === true\n\n // If only one schema remains after filtering, merge with root properties.\n // `properties`/`required` are unioned so sibling properties declared next to\n // the composition (e.g. `properties` alongside a single-`$ref` `allOf`) are\n // kept instead of being overwritten by the member schema's own `properties`.\n // Root-level annotations (title, description, …) win over the member's: they\n // describe the combined schema, not the base it extends.\n if (filteredSchemas.length === 1) {\n const mergedSchema = mergeSchemaProperties(filteredSchemas[0], rootProperties) as DisplaySchema\n if (shouldBeNullable) {\n mergedSchema.nullable = true\n }\n return mergedSchema\n }\n\n // Check if root properties should be merged into schemas\n const shouldMergeRootProperties =\n (composition === 'oneOf' || composition === 'anyOf') &&\n (hasRootProperties || filteredSchemas.some((schema) => schema.allOf))\n\n if (shouldMergeRootProperties) {\n // The discriminator belongs to the union, not to its variants. Copied into a variant, it\n // makes the variant look like a bare `discriminator.mapping` base, which then infers a\n // second selector inside the variant.\n // The property's badges also belong to the union, while variants can define their own.\n const { discriminator: _discriminator, 'x-badges': badges, ...variantRootProperties } = rootProperties\n\n const mergedSchemas = filteredSchemas.map((_schema) => {\n const schema = resolve.schema(_schema)\n\n // Flatten single-item allOf and merge with root properties. If the\n // variant has its own properties/required/$ref, the allOf member's own\n // identity (`$ref`, `title`, `name`) is dropped before merging so it\n // cannot overwrite the variant's, which would otherwise mislabel the\n // flattened schema as the base it extends instead of the variant itself\n // (#9964). `getModelNameFromSchema` labels a variant by title → name →\n // $ref, so any of those leaking from the base is enough to mislabel it.\n // A variant that is a bare wrapper around the allOf member has no\n // identity of its own to protect, so the base's identity is kept as a\n // fallback label.\n if (schema.allOf?.length === 1) {\n const { allOf, ...otherProps } = schema\n const allOfMember = resolve.schema(allOf[0])!\n const variantHasOwnIdentity = 'properties' in otherProps || 'required' in otherProps || '$ref' in otherProps\n if (variantHasOwnIdentity) {\n const { $ref: _ref, title: _title, name: _name, ...allOfMemberWithoutIdentity } = allOfMember\n return mergeSchemaProperties(variantRootProperties, otherProps, allOfMemberWithoutIdentity)\n }\n return mergeSchemaProperties(variantRootProperties, otherProps, allOfMember)\n }\n return mergeSchemaProperties(variantRootProperties, schema)\n })\n\n // @ts-expect-error - We avoid using coerceValue here as it may be dangerous, so we type cast\n const result = { [composition]: mergedSchemas } as DisplaySchema\n if (badges !== undefined) {\n result['x-badges'] = badges\n }\n if (typeof value.description === 'string') {\n result.description = value.description\n }\n if (shouldBeNullable) {\n result.nullable = true\n }\n return result\n }\n\n // Return with filtered schemas if any nulls were removed\n if (filteredSchemas.length !== schemas.length) {\n const result: DisplaySchema = { ...value, [composition]: filteredSchemas }\n if (shouldBeNullable) {\n result.nullable = true\n }\n return result\n }\n\n return { ...value }\n}\n"],"mappings":";;;;AAiBA,SAASG,EAAsB,GAAGC,GAA2E;CAC3G,IAAMC,IAAuC,CAAC,GACxCC,IAAsC,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AM;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partition-all-of-compositions.js","names":["CHOICE_KEYWORDS","collectMembers","target","getResolvedRef","input","resolve","_not","_if","_then","_else","rest","out","keyword","value","oneOf","anyOf","selectsAncestor","ref","branch","seenRefs","allOf","rawMember","partitionAllOfCompositions","schema","_oneOf","_anyOf","members","firstMemberIndex","ownDescription","schemaRef","startsWithChoice","index","resolved","segments","objectRun","choiceIndex","flushObjectRun","merged","mergeAllOfSchemas","includesParent","segment","_description","fields","member"],"sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject, SchemaReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { mergeAllOfSchemas } from './merge-all-of-schemas'\nimport type { CompositionKeyword } from './schema-composition'\n\ntype ChoiceKeyword = Extract<CompositionKeyword, 'oneOf' | 'anyOf'>\n\n/** An ordered piece of an `allOf`: either a merged object or a choice picker. */\ntype AllOfSegment =\n | { kind: 'object'; schema: SchemaObject }\n | {\n kind: 'choice'\n composition: ChoiceKeyword\n /** A minimal schema carrying only this group's composition, for SchemaComposition */\n value: SchemaObject\n /** Ordinal among choice members, matching the request-example composition key */\n choiceIndex: number\n }\n\nconst CHOICE_KEYWORDS: ChoiceKeyword[] = ['oneOf', 'anyOf']\n\ntype Member =\n | { kind: 'object'; schema: SchemaObject }\n | { kind: 'boolean'; schema: SchemaObject }\n | { kind: 'choice'; composition: ChoiceKeyword; value: SchemaObject; inheritedSelection: boolean }\n\n/**\n * Flattens a member's own (non-composition) properties and every `oneOf`/`anyOf`\n * group it declares — recursing into nested `allOf` — into a flat, ordered list,\n * preserving source order so choice groups stay where they were authored.\n *\n * Pure-constraint keywords (`not`, `if/then/else`) are dropped: they carry no\n * visual variant and Scalar would otherwise render `not` as a bogus picker. The\n * rule still lives in the schema (validation) and in field descriptions.\n */\nconst collectMembers = (\n input: SchemaReferenceType<SchemaObject> | boolean,\n out: Member[],\n seenRefs: Set<string>,\n): void => {\n const target = getResolvedRef(input)\n if (typeof target === 'boolean') {\n // Keep the explanation separate: merging it with an object's description would hide it.\n out.push({ kind: 'boolean', schema: resolve.schema(target) })\n return\n }\n const schema = resolve.schema(input)\n const {\n allOf,\n oneOf,\n anyOf,\n not: _not,\n if: _if,\n then: _then,\n else: _else,\n ...rest\n }: SchemaObject & {\n allOf?: unknown[]\n oneOf?: unknown[]\n anyOf?: unknown[]\n not?: unknown\n if?: unknown\n then?: unknown\n else?: unknown\n } = schema\n\n if (Object.keys(rest).length > 0) {\n out.push({ kind: 'object', schema: rest })\n }\n\n for (const keyword of CHOICE_KEYWORDS) {\n const value = keyword === 'oneOf' ? oneOf : anyOf\n // A variant inherits its base fields through allOf, but the base's choice\n // containing that variant has already been selected. Rendering it again\n // would re-enter the variant and expose fields from the other branches.\n const selectsAncestor =\n Array.isArray(value) &&\n value.some((branch) => {\n const ref = branch && typeof branch === 'object' && '$ref' in branch ? branch.$ref : undefined\n return typeof ref === 'string' && seenRefs.has(ref)\n })\n if (Array.isArray(value) && value.length > 0) {\n out.push({\n kind: 'choice',\n composition: keyword,\n value: { [keyword]: value } as unknown as SchemaObject,\n inheritedSelection: selectsAncestor,\n })\n }\n }\n\n if (Array.isArray(allOf)) {\n for (const rawMember of allOf) {\n if (typeof rawMember === 'boolean' || (rawMember && typeof rawMember === 'object')) {\n const resolved: SchemaObject & { $ref?: string } = resolve.schema(rawMember)\n // Break `$ref` cycles reached through `allOf` (e.g. a member that\n // references an ancestor). Without this guard a recursive `allOf`\n // schema would recurse forever. `mergeAllOfSchemas` guards the same way.\n const ref = resolved.$ref\n if (typeof ref === 'string') {\n if (seenRefs.has(ref)) {\n continue\n }\n collectMembers(rawMember, out, new Set(seenRefs).add(ref))\n } else {\n collectMembers(rawMember, out, seenRefs)\n }\n }\n }\n }\n}\n\n/**\n * Splits an `allOf` schema into an ordered list of segments so the renderer can\n * show each `oneOf`/`anyOf` group as its own picker **in the position it was\n * declared**, with the surrounding plain fields around it.\n *\n * `mergeAllOfSchemas` alone keeps only the FIRST `oneOf`/`anyOf` (dropping the\n * 2nd+ groups of an object with several independent mutually-exclusive\n * selections) and, being a merge, also loses the ordering between fields and\n * choices. Walking the members in order fixes both: runs of consecutive object\n * members are merged into one object segment, and each choice member becomes its\n * own picker segment in place.\n */\nexport const partitionAllOfCompositions = (schema: SchemaObject | undefined): { segments: AllOfSegment[] } => {\n if (!schema) {\n return { segments: [] }\n }\n\n // The schema's own (non-composition) keys, minus its top-level `oneOf`/`anyOf`\n // — those are rendered as their own composition by the caller, not here.\n const {\n allOf,\n oneOf: _oneOf,\n anyOf: _anyOf,\n not: _not,\n if: _if,\n then: _then,\n else: _else,\n ...rest\n }: SchemaObject & {\n allOf?: unknown[]\n oneOf?: unknown[]\n anyOf?: unknown[]\n not?: unknown\n if?: unknown\n then?: unknown\n else?: unknown\n } = schema\n\n if (!Array.isArray(allOf)) {\n return { segments: [{ kind: 'object', schema: schema }] }\n }\n\n const members: Member[] = []\n if (Object.keys(rest).length > 0) {\n members.push({ kind: 'object', schema: rest })\n }\n const firstMemberIndex = members.length\n const ownDescription = typeof rest.description === 'string' ? rest.description : undefined\n const schemaRef = '$ref' in schema ? schema.$ref : undefined\n const seenRefs = new Set<string>(typeof schemaRef === 'string' ? [schemaRef] : [])\n let startsWithChoice = false\n for (const [index, rawMember] of allOf.entries()) {\n if (typeof rawMember === 'boolean' || (rawMember && typeof rawMember === 'object')) {\n const resolved: SchemaObject & { $ref?: string } = resolve.schema(rawMember)\n const ref = resolved.$ref\n collectMembers(rawMember, members, typeof ref === 'string' ? new Set(seenRefs).add(ref) : seenRefs)\n if (index === 0) {\n startsWithChoice = Boolean(\n resolved.oneOf?.length || resolved.anyOf?.length || members[firstMemberIndex]?.kind === 'choice',\n )\n }\n }\n }\n\n // Coalesce consecutive object members into a single merged object segment,\n // keeping choice members as their own segments between them.\n const segments: AllOfSegment[] = []\n let objectRun: SchemaObject[] = []\n let choiceIndex = 0\n\n const flushObjectRun = (): void => {\n if (objectRun.length === 0) {\n return\n }\n const merged = objectRun.length === 1 ? objectRun[0]! : mergeAllOfSchemas({ allOf: objectRun } as SchemaObject)\n const includesParent = objectRun[0] === rest\n let segment = merged\n if (ownDescription !== undefined) {\n // The parent's description covers the whole composition, including fields in later segments.\n // A leading choice keeps its existing display, including descriptions after the picker.\n if (includesParent && merged.description !== ownDescription) {\n segment = { ...merged, description: ownDescription }\n } else if (!includesParent && !startsWithChoice && merged.description !== undefined) {\n const { description: _description, ...fields } = merged\n segment = fields\n }\n }\n segments.push({ kind: 'object', schema: segment })\n objectRun = []\n }\n\n for (const member of members) {\n if (member.kind === 'object') {\n objectRun.push(member.schema)\n } else if (member.kind === 'boolean') {\n flushObjectRun()\n segments.push({ kind: 'object', schema: member.schema })\n } else if (member.inheritedSelection) {\n // Hidden inherited choices still occupy an ordinal in the request example.\n choiceIndex++\n } else {\n flushObjectRun()\n // `choiceIndex` is the ordinal used to build the composition-selection key\n // that syncs each picker with the request example. It MUST stay aligned\n // with the ordinal computed while walking `allOf` in\n // `get-example-from-schema.ts` (`@scalar/workspace-store`), or a picker and\n // its generated example fall out of sync.\n segments.push({\n kind: 'choice',\n composition: member.composition,\n value: member.value,\n choiceIndex: choiceIndex++,\n })\n }\n }\n flushObjectRun()\n\n return { segments }\n}\n"],"mappings":";;;;AAqBA,IAAMA,IAAmC,CAAC,SAAS,OAAO,GAgBpDC,KACJ,GACA,GACA,MACS;CACT,IAAMC,IAASC,EAAeC,CAAK;CACnC,IAAI,OAAOF,KAAW,WAAW;EAE/B,EAAI,KAAK;GAAE,MAAM;GAAW,QAAQG,EAAQ,OAAOH,CAAM;EAAE,CAAC;EAC5D;CACF;CAEA,IAAM,EACJ,UACA,UACA,UACA,KAAKI,GACL,IAAIC,GACJ,MAAMC,GACN,MAAMC,GACN,GAAGC,MATUL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AaI,GAAc,GAAGC,MAAWL;IACjD,IAAUK;GACZ;EACF;EAEA,AADAT,EAAS,KAAK;GAAE,MAAM;GAAU,QAAQO;EAAQ,CAAC,GACjD,IAAY,CAAC;CACf;CAEA,KAAK,IAAMG,KAAUjB,GACnB,AAAIiB,EAAO,SAAS,WAClBT,EAAU,KAAKS,EAAO,MAAM,IACnBA,EAAO,SAAS,aACzBP,EAAe,GACfH,EAAS,KAAK;EAAE,MAAM;EAAU,QAAQU,EAAO;CAAO,CAAC,KAC9CA,EAAO,qBAEhB,OAEAP,EAAe,GAMfH,EAAS,KAAK;EACZ,MAAM;EACN,aAAaU,EAAO;EACpB,OAAOA,EAAO;EACd,aAAa;CACf,CAAC;CAKL,OAFAP,EAAe,GAER,EAAE,YAAS;AACpB"}
|
|
1
|
+
{"version":3,"file":"partition-all-of-compositions.js","names":["mergeAllOfSchemas","getResolvedRef","resolve","CHOICE_KEYWORDS","collectMembers","input","out","seenRefs","target","allOf","oneOf","anyOf","_not","_if","_then","_else","rest","keyword","value","selectsAncestor","branch","ref","rawMember","partitionAllOfCompositions","schema","_oneOf","_anyOf","members","firstMemberIndex","ownDescription","schemaRef","startsWithChoice","index","resolved","segments","objectRun","choiceIndex","flushObjectRun","merged","includesParent","segment","_description","fields","member"],"sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject, SchemaReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { mergeAllOfSchemas } from './merge-all-of-schemas'\nimport type { CompositionKeyword } from './schema-composition'\n\ntype ChoiceKeyword = Extract<CompositionKeyword, 'oneOf' | 'anyOf'>\n\n/** An ordered piece of an `allOf`: either a merged object or a choice picker. */\ntype AllOfSegment =\n | { kind: 'object'; schema: SchemaObject }\n | {\n kind: 'choice'\n composition: ChoiceKeyword\n /** A minimal schema carrying only this group's composition, for SchemaComposition */\n value: SchemaObject\n /** Ordinal among choice members, matching the request-example composition key */\n choiceIndex: number\n }\n\nconst CHOICE_KEYWORDS: ChoiceKeyword[] = ['oneOf', 'anyOf']\n\ntype Member =\n | { kind: 'object'; schema: SchemaObject }\n | { kind: 'boolean'; schema: SchemaObject }\n | { kind: 'choice'; composition: ChoiceKeyword; value: SchemaObject; inheritedSelection: boolean }\n\n/**\n * Flattens a member's own (non-composition) properties and every `oneOf`/`anyOf`\n * group it declares — recursing into nested `allOf` — into a flat, ordered list,\n * preserving source order so choice groups stay where they were authored.\n *\n * Pure-constraint keywords (`not`, `if/then/else`) are dropped: they carry no\n * visual variant and Scalar would otherwise render `not` as a bogus picker. The\n * rule still lives in the schema (validation) and in field descriptions.\n */\nconst collectMembers = (\n input: SchemaReferenceType<SchemaObject> | boolean,\n out: Member[],\n seenRefs: Set<string>,\n): void => {\n const target = getResolvedRef(input)\n if (typeof target === 'boolean') {\n // Keep the explanation separate: merging it with an object's description would hide it.\n out.push({ kind: 'boolean', schema: resolve.schema(target) })\n return\n }\n const schema = resolve.schema(input)\n const {\n allOf,\n oneOf,\n anyOf,\n not: _not,\n if: _if,\n then: _then,\n else: _else,\n ...rest\n }: SchemaObject & {\n allOf?: unknown[]\n oneOf?: unknown[]\n anyOf?: unknown[]\n not?: unknown\n if?: unknown\n then?: unknown\n else?: unknown\n } = schema\n\n if (Object.keys(rest).length > 0) {\n out.push({ kind: 'object', schema: rest })\n }\n\n for (const keyword of CHOICE_KEYWORDS) {\n const value = keyword === 'oneOf' ? oneOf : anyOf\n // A variant inherits its base fields through allOf, but the base's choice\n // containing that variant has already been selected. Rendering it again\n // would re-enter the variant and expose fields from the other branches.\n const selectsAncestor =\n Array.isArray(value) &&\n value.some((branch) => {\n const ref = branch && typeof branch === 'object' && '$ref' in branch ? branch.$ref : undefined\n return typeof ref === 'string' && seenRefs.has(ref)\n })\n if (Array.isArray(value) && value.length > 0) {\n out.push({\n kind: 'choice',\n composition: keyword,\n value: { [keyword]: value } as unknown as SchemaObject,\n inheritedSelection: selectsAncestor,\n })\n }\n }\n\n if (Array.isArray(allOf)) {\n for (const rawMember of allOf) {\n if (typeof rawMember === 'boolean' || (rawMember && typeof rawMember === 'object')) {\n const resolved: SchemaObject & { $ref?: string } = resolve.schema(rawMember)\n // Break `$ref` cycles reached through `allOf` (e.g. a member that\n // references an ancestor). Without this guard a recursive `allOf`\n // schema would recurse forever. `mergeAllOfSchemas` guards the same way.\n const ref = resolved.$ref\n if (typeof ref === 'string') {\n if (seenRefs.has(ref)) {\n continue\n }\n collectMembers(rawMember, out, new Set(seenRefs).add(ref))\n } else {\n collectMembers(rawMember, out, seenRefs)\n }\n }\n }\n }\n}\n\n/**\n * Splits an `allOf` schema into an ordered list of segments so the renderer can\n * show each `oneOf`/`anyOf` group as its own picker **in the position it was\n * declared**, with the surrounding plain fields around it.\n *\n * `mergeAllOfSchemas` alone keeps only the FIRST `oneOf`/`anyOf` (dropping the\n * 2nd+ groups of an object with several independent mutually-exclusive\n * selections) and, being a merge, also loses the ordering between fields and\n * choices. Walking the members in order fixes both: runs of consecutive object\n * members are merged into one object segment, and each choice member becomes its\n * own picker segment in place.\n */\nexport const partitionAllOfCompositions = (schema: SchemaObject | undefined): { segments: AllOfSegment[] } => {\n if (!schema) {\n return { segments: [] }\n }\n\n // The schema's own (non-composition) keys, minus its top-level `oneOf`/`anyOf`\n // — those are rendered as their own composition by the caller, not here.\n const {\n allOf,\n oneOf: _oneOf,\n anyOf: _anyOf,\n not: _not,\n if: _if,\n then: _then,\n else: _else,\n ...rest\n }: SchemaObject & {\n allOf?: unknown[]\n oneOf?: unknown[]\n anyOf?: unknown[]\n not?: unknown\n if?: unknown\n then?: unknown\n else?: unknown\n } = schema\n\n if (!Array.isArray(allOf)) {\n return { segments: [{ kind: 'object', schema: schema }] }\n }\n\n const members: Member[] = []\n if (Object.keys(rest).length > 0) {\n members.push({ kind: 'object', schema: rest })\n }\n const firstMemberIndex = members.length\n const ownDescription = typeof rest.description === 'string' ? rest.description : undefined\n const schemaRef = '$ref' in schema ? schema.$ref : undefined\n const seenRefs = new Set<string>(typeof schemaRef === 'string' ? [schemaRef] : [])\n let startsWithChoice = false\n for (const [index, rawMember] of allOf.entries()) {\n if (typeof rawMember === 'boolean' || (rawMember && typeof rawMember === 'object')) {\n const resolved: SchemaObject & { $ref?: string } = resolve.schema(rawMember)\n const ref = resolved.$ref\n collectMembers(rawMember, members, typeof ref === 'string' ? new Set(seenRefs).add(ref) : seenRefs)\n if (index === 0) {\n startsWithChoice = Boolean(\n resolved.oneOf?.length || resolved.anyOf?.length || members[firstMemberIndex]?.kind === 'choice',\n )\n }\n }\n }\n\n // Coalesce consecutive object members into a single merged object segment,\n // keeping choice members as their own segments between them.\n const segments: AllOfSegment[] = []\n let objectRun: SchemaObject[] = []\n let choiceIndex = 0\n\n const flushObjectRun = (): void => {\n if (objectRun.length === 0) {\n return\n }\n const merged = objectRun.length === 1 ? objectRun[0]! : mergeAllOfSchemas({ allOf: objectRun } as SchemaObject)\n const includesParent = objectRun[0] === rest\n let segment = merged\n if (ownDescription !== undefined) {\n // The parent's description covers the whole composition, including fields in later segments.\n // A leading choice keeps its existing display, including descriptions after the picker.\n if (includesParent && merged.description !== ownDescription) {\n segment = { ...merged, description: ownDescription }\n } else if (!includesParent && !startsWithChoice && merged.description !== undefined) {\n const { description: _description, ...fields } = merged\n segment = fields\n }\n }\n segments.push({ kind: 'object', schema: segment })\n objectRun = []\n }\n\n for (const member of members) {\n if (member.kind === 'object') {\n objectRun.push(member.schema)\n } else if (member.kind === 'boolean') {\n flushObjectRun()\n segments.push({ kind: 'object', schema: member.schema })\n } else if (member.inheritedSelection) {\n // Hidden inherited choices still occupy an ordinal in the request example.\n choiceIndex++\n } else {\n flushObjectRun()\n // `choiceIndex` is the ordinal used to build the composition-selection key\n // that syncs each picker with the request example. It MUST stay aligned\n // with the ordinal computed while walking `allOf` in\n // `get-example-from-schema.ts` (`@scalar/workspace-store`), or a picker and\n // its generated example fall out of sync.\n segments.push({\n kind: 'choice',\n composition: member.composition,\n value: member.value,\n choiceIndex: choiceIndex++,\n })\n }\n }\n flushObjectRun()\n\n return { segments }\n}\n"],"mappings":";;;;AAqBA,IAAMG,IAAmC,CAAC,SAAS,OAAO,GAgBpDC,KACJC,GACAC,GACAC,MACS;CACT,IAAMC,IAASP,EAAeI,CAAK;CACnC,IAAI,OAAOG,KAAW,WAAW;EAE/BF,EAAI,KAAK;GAAE,MAAM;GAAW,QAAQJ,EAAQ,OAAOM,CAAM;EAAE,CAAC;EAC5D;CACF;CAEA,IAAM,EACJC,UACAC,UACAC,UACA,KAAKC,GACL,IAAIC,GACJ,MAAMC,GACN,MAAMC,GACN,GAAGC,MATUd,EAAQ,OAAOG,CAkB1B;CAEA,OAAO,KAAKW,CAAI,CAAC,CAAC,SAAS,KAC7BV,EAAI,KAAK;EAAE,MAAM;EAAU,QAAQU;CAAK,CAAC;CAG3C,KAAK,IAAMC,KAAWd,GAAiB;EACrC,IAAMe,IAAQD,MAAY,UAAUP,IAAQC,GAItCQ,IACJ,MAAM,QAAQD,CAAK,KACnBA,EAAM,MAAME,MAAW;GACrB,IAAMC,IAAMD,KAAU,OAAOA,KAAW,YAAY,UAAUA,IAASA,EAAO,OAAO,KAAA;GACrF,OAAO,OAAOC,KAAQ,YAAYd,EAAS,IAAIc,CAAG;EACpD,CAAC;EACC,MAAM,QAAQH,CAAK,KAAKA,EAAM,SAAS,KACzCZ,EAAI,KAAK;GACP,MAAM;GACN,aAAaW;GACb,OAAO,GAAGA,IAAUC,EAAM;GAC1B,oBAAoBC;EACtB,CAAC;CAEL;CAEA,IAAI,MAAM,QAAQV,CAAK,GAChB;OAAA,IAAMa,KAAab,GACtB,IAAI,OAAOa,KAAc,aAAcA,KAAa,OAAOA,KAAc,UAAW;GAKlF,IAAMD,IAJ6CnB,EAAQ,OAAOoB,CAItD,CAAA,CAAS;GACrB,IAAI,OAAOD,KAAQ,UAAU;IAC3B,IAAId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2B,CAAC,GAC9BC,IAA4B,CAAC,GAC7BC,IAAc,GAEZC,UAA6B;EACjC,IAAIF,EAAU,WAAW,GACvB;EAEF,IAAMG,IAASH,EAAU,WAAW,IAAIA,EAAU,KAAMnC,EAAkB,EAAE,OAAOmC,EAAU,CAAiB,GACxGI,IAAiBJ,EAAU,OAAOnB,GACpCwB,IAAUF;EACd,IAAIT,MAAmB,KAAA,GAAW;GAGhC,IAAIU,KAAkBD,EAAO,gBAAgBT,GAC3CW,IAAU;IAAE,GAAGF;IAAQ,aAAaT;GAAe;QAC9C,IAAI,CAACU,KAAkB,CAACR,KAAoBO,EAAO,gBAAgB,KAAA,GAAW;IACnF,IAAM,EAAE,aAAaG,GAAc,GAAGC,MAAWJ;IACjDE,IAAUE;GACZ;EACF;EACAR,EAAS,KAAK;GAAE,MAAM;GAAU,QAAQM;EAAQ,CAAC,GACjDL,IAAY,CAAC;CACf;CAEA,KAAK,IAAMQ,KAAUhB,GACfgB,EAAO,SAAS,WAClBR,EAAU,KAAKQ,EAAO,MAAM,IACnBA,EAAO,SAAS,aACzBN,EAAe,GACfH,EAAS,KAAK;EAAE,MAAM;EAAU,QAAQS,EAAO;CAAO,CAAC,KAC9CA,EAAO,qBAEhBP,OAEAC,EAAe,GAMfH,EAAS,KAAK;EACZ,MAAM;EACN,aAAaS,EAAO;EACpB,OAAOA,EAAO;EACd,aAAaP;CACf,CAAC;CAKL,OAFAC,EAAe,GAER,EAAEH,YAAS;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-cycle.js","names":["SCHEMA_ANCESTORS_SYMBOL","getCycleKey","raw"],"sources":["../../../src/schema/helpers/schema-cycle.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\n\n/**\n * The set of schema \"cycle keys\" for every ancestor on the current render path.\n *\n * Each `Schema` component injects this set, adds its own key, and re-provides\n * it to its descendants. When a node's key is already present in the ancestor\n * set we've hit a cycle (a self-referential schema) and must stop force\n * expanding to avoid rendering forever.\n *\n * See {@link getCycleKey} for how a node's key is derived.\n */\nexport const SCHEMA_ANCESTORS_SYMBOL: InjectionKey<ReadonlySet<unknown>> = Symbol('schema-ancestors')\n\n/**\n * Derive a stable identity for a schema node from its *raw* (unresolved) value.\n *\n * Cycle detection needs a key that is identical every time the same schema is\n * reached along a path, and that survives the shallow copies/merges performed\n * while rendering (which break object identity of the resolved schema).\n *\n * - For `$ref` nodes we use the ref string. Two branches that reference the\n * same component share the string, so a schema that (transitively) references\n * itself is detected as a cycle, while sibling references are not.\n * - For inline schemas there is no ref, so we fall back to the raw object\n * reference. A self-referential inline schema reuses the same object, so\n * object identity catches the cycle.\n *\n * Returns `undefined` for primitives/booleans (e.g. `additionalProperties: true`)\n * which can never form a cycle.\n */\nexport const getCycleKey = (raw: unknown): unknown => {\n if (raw && typeof raw === 'object') {\n if ('$ref' in raw && typeof raw.$ref === 'string') {\n return (raw as { $ref: string }).$ref\n }\n return raw\n }\n\n return undefined\n}\n"],"mappings":";AAYA,IAAaA,IAA8D,OAAO,kBAAkB,GAmBvFC,
|
|
1
|
+
{"version":3,"file":"schema-cycle.js","names":["SCHEMA_ANCESTORS_SYMBOL","getCycleKey","raw"],"sources":["../../../src/schema/helpers/schema-cycle.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\n\n/**\n * The set of schema \"cycle keys\" for every ancestor on the current render path.\n *\n * Each `Schema` component injects this set, adds its own key, and re-provides\n * it to its descendants. When a node's key is already present in the ancestor\n * set we've hit a cycle (a self-referential schema) and must stop force\n * expanding to avoid rendering forever.\n *\n * See {@link getCycleKey} for how a node's key is derived.\n */\nexport const SCHEMA_ANCESTORS_SYMBOL: InjectionKey<ReadonlySet<unknown>> = Symbol('schema-ancestors')\n\n/**\n * Derive a stable identity for a schema node from its *raw* (unresolved) value.\n *\n * Cycle detection needs a key that is identical every time the same schema is\n * reached along a path, and that survives the shallow copies/merges performed\n * while rendering (which break object identity of the resolved schema).\n *\n * - For `$ref` nodes we use the ref string. Two branches that reference the\n * same component share the string, so a schema that (transitively) references\n * itself is detected as a cycle, while sibling references are not.\n * - For inline schemas there is no ref, so we fall back to the raw object\n * reference. A self-referential inline schema reuses the same object, so\n * object identity catches the cycle.\n *\n * Returns `undefined` for primitives/booleans (e.g. `additionalProperties: true`)\n * which can never form a cycle.\n */\nexport const getCycleKey = (raw: unknown): unknown => {\n if (raw && typeof raw === 'object') {\n if ('$ref' in raw && typeof raw.$ref === 'string') {\n return (raw as { $ref: string }).$ref\n }\n return raw\n }\n\n return undefined\n}\n"],"mappings":";AAYA,IAAaA,IAA8D,OAAO,kBAAkB,GAmBvFC,KAAeC,MAA0B;CACpD,IAAIA,KAAO,OAAOA,KAAQ,UAIxB,OAHI,UAAUA,KAAO,OAAOA,EAAI,QAAS,WAC/BA,EAAyB,OAE5BA;AAIX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-expansion.js","names":["isUnder","root","key","toNodeKey","breadcrumb","UNTIL_FOUND_CAP","createSchemaExpansionStore","shallowRef","overrides","shallowReactive","bulkRoots","baseline","nearestBulkRoot","candidate","value","cut","clearOverridesUnder","retentionPaused","pauseRetentionFor","mutate","nextTick","setBulk","existing","isExpanded","override","ctx","bulk","isOnSchemaTargetPath","scrollTargetId","setExpanded","path","segments","index","prefix","used","SCHEMA_TREE_ROOT_SYMBOL","useSchemaExpansion","store","onMounted","target","baselineBeforePrint","handleBeforePrint","handleAfterPrint","previous","onBeforeUnmount"],"sources":["../../../src/schema/helpers/schema-expansion.ts"],"sourcesContent":["import {\n type InjectionKey,\n type Ref,\n nextTick,\n onBeforeUnmount,\n onMounted,\n shallowReactive,\n shallowRef,\n watch,\n} from 'vue'\n\nimport { isOnSchemaTargetPath } from './is-on-schema-target-path'\n\n/**\n * What a node does when nobody has expressed an opinion about it: its own\n * `defaultOpen`, or whatever expand-all / collapse-all last set.\n */\ntype ExpansionBaseline = 'default' | 'expanded' | 'collapsed'\n\n/** What the store cannot work out about a node on its own. */\ntype ExpansionContext = {\n /**\n * Whether this node sits on a `$ref` cycle. Bulk expansion and the baseline\n * skip cyclic nodes; without that, `expandAll()` on a self-referential schema\n * never terminates, because the cycle guard only suppresses auto-expansion.\n */\n cyclic?: boolean\n /** What the node would do with no store at all (its `defaultOpen`). */\n defaultOpen?: boolean\n /**\n * The public anchor path this node covers, when it differs from its key. A\n * key carrying a structural marker (`~headers`) must still open for a deep\n * link written against the anchor path (`…headers.X-Rate`).\n */\n anchorPath?: string\n}\n\n/** Shared expansion controls for a host and its schema trees. */\nexport type SchemaExpansionStore = {\n /** Resolve whether a node is open. See the resolution order below. */\n isExpanded: (key: string, ctx?: ExpansionContext) => boolean\n /** Record an explicit user decision about one node. */\n setExpanded: (key: string, value: boolean) => void\n /** Flip one node, resolving its current state first. */\n toggle: (key: string, ctx?: ExpansionContext) => void\n /** Expand everything, or everything beneath `root`. */\n expandAll: (root?: string) => void\n /** Collapse everything, or everything beneath `root`. */\n collapseAll: (root?: string) => void\n /** Make a deep link's expansion permanent by opening every ancestor of `path`. */\n commitPath: (path: string) => void\n /** The standing baseline, exposed so a print hook can flip it and put it back. */\n baseline: Ref<ExpansionBaseline>\n /**\n * The budget for closed panels kept in the DOM as `hidden=\"until-found\"`. It\n * lives on the store, so it is shared by every schema tree under one reference.\n * Kept panels stay searchable with find-in-page but grow the DOM, so a closing\n * row asks `acquire()` first and simply unmounts past the cap. Deliberately\n * not reactive: it only matters at the moment a panel closes.\n */\n untilFound: {\n acquire: () => boolean\n release: () => void\n }\n /**\n * Run a bulk transition with slot retention paused. A collapse-all or the\n * afterprint restore closes many rows in one flush; letting each one\n * `acquire()` would drain the budget in a single gesture and pin hundreds of\n * hidden subtrees. Releases still run, so reopened rows hand slots back.\n */\n pauseRetentionFor: (mutate: () => void) => void\n}\n\n/**\n * Whether `key` is `root` or sits beneath it. A literal `.` is the separator\n * even though property names may contain one (`a.b` + `c` collides with `a` +\n * `b.c`); the key is deliberately the same string as the public anchor used by\n * the sidebar, `scrollTargetId` and shared URLs, so it cannot be re-encoded alone.\n */\nconst isUnder = (key: string, root: string): boolean => root === '' || key === root || key.startsWith(`${root}.`)\n\n/**\n * Build the node key for a breadcrumb: the dot-joined anchor path, so store keys\n * and public anchors are the same string. Callers append `~`-marked structural\n * segments (`~headers`, `~anonymous-…`) for nodes the anchor cannot name.\n */\nexport const toNodeKey = (breadcrumb: readonly string[] | undefined): string => breadcrumb?.join('.') ?? ''\n\n/**\n * How many closed panels one store keeps mounted as `hidden=\"until-found\"` —\n * one `<ApiReference>`, not one tree, since every tree under it shares a store.\n */\nconst UNTIL_FOUND_CAP = 300\n\n/**\n * A per-reference store of which schema properties are open. Sparse by\n * construction: only what somebody touched, typically under twenty keys, where\n * a dense map over a large document would be tens of thousands. The maps are\n * `shallowReactive` because a Map inside a `shallowRef` does not track `.set()`\n * (clicks would do nothing) and replacing the Map wholesale would invalidate\n * every mounted row on every toggle.\n */\nexport const createSchemaExpansionStore = (scrollTargetId: Ref<string> = shallowRef('')): SchemaExpansionStore => {\n /** Only what the user explicitly opened or closed. */\n const overrides = shallowReactive(new Map<string, boolean>())\n /** Per-subtree expand-all / collapse-all roots. */\n const bulkRoots = shallowReactive(new Map<string, boolean>())\n const baseline = shallowRef<ExpansionBaseline>('default')\n\n /** The nearest bulk root at or above `key`, if any. */\n const nearestBulkRoot = (key: string): boolean | undefined => {\n if (bulkRoots.size === 0) {\n return undefined\n }\n\n let candidate = key\n\n while (true) {\n const value = bulkRoots.get(candidate)\n\n if (value !== undefined) {\n return value\n }\n\n const cut = candidate.lastIndexOf('.')\n\n if (cut === -1) {\n return bulkRoots.get('')\n }\n\n candidate = candidate.slice(0, cut)\n }\n }\n\n /**\n * Newest intent wins: a bulk write drops the overrides beneath its root, so\n * \"an explicit override always wins\" never becomes \"Expand all silently skips\n * every node the user has ever touched\". O(overrides), which stays small.\n */\n const clearOverridesUnder = (root: string): void => {\n for (const key of [...overrides.keys()]) {\n if (isUnder(key, root)) {\n overrides.delete(key)\n }\n }\n }\n\n /** While true, closing rows must not take until-found slots. */\n let retentionPaused = false\n\n const pauseRetentionFor = (mutate: () => void): void => {\n retentionPaused = true\n mutate()\n\n // The closes land in the same pre-render flush as the write, so the pause can lift after it.\n void nextTick(() => {\n retentionPaused = false\n })\n }\n\n const setBulk = (root: string, value: boolean): void => {\n clearOverridesUnder(root)\n\n if (root === '') {\n // A document-wide bulk action supersedes every narrower one.\n bulkRoots.clear()\n baseline.value = value ? 'expanded' : 'collapsed'\n return\n }\n\n for (const existing of [...bulkRoots.keys()]) {\n if (isUnder(existing, root)) {\n bulkRoots.delete(existing)\n }\n }\n\n bulkRoots.set(root, value)\n }\n\n const isExpanded = (key: string, ctx: ExpansionContext = {}): boolean => {\n // 1. An explicit decision by the user, O(1).\n const override = overrides.get(key)\n\n if (override !== undefined) {\n return override\n }\n\n // 2 and 3 are skipped for cyclic nodes, so bulk expansion terminates.\n if (!ctx.cyclic) {\n // 2. The nearest enclosing bulk action.\n const bulk = nearestBulkRoot(key)\n\n if (bulk !== undefined) {\n return bulk\n }\n\n // 3. The standing baseline.\n if (baseline.value === 'expanded') {\n return true\n }\n\n if (baseline.value === 'collapsed') {\n return false\n }\n }\n\n // 4. A live deep link, read here rather than at mount so a second deep link\n // into an already-rendered operation still works.\n if (isOnSchemaTargetPath(ctx.anchorPath ?? key, scrollTargetId.value)) {\n return true\n }\n\n // 5. Whatever the node would have done on its own.\n return ctx.defaultOpen ?? false\n }\n\n const setExpanded = (key: string, value: boolean): void => {\n overrides.set(key, value)\n }\n\n return {\n isExpanded,\n setExpanded,\n toggle: (key, ctx) => setExpanded(key, !isExpanded(key, ctx)),\n expandAll: (root = '') => setBulk(root, true),\n collapseAll: (root = '') => pauseRetentionFor(() => setBulk(root, false)),\n commitPath: (path: string): void => {\n if (!path) {\n return\n }\n\n // Open every ancestor and the target itself as overrides, so the expansion\n // outlives `clearScrollTarget` and stays user-collapsible.\n const segments = path.split('.')\n\n for (let index = 1; index <= segments.length; index++) {\n const prefix = segments.slice(0, index).join('.')\n overrides.set(prefix, true)\n\n /*\n * Also commit the marked form (`~headers`) of this segment: it is not a\n * literal prefix of the anchor, so it would re-collapse, and unmount the\n * landed-on row, once the scroll target cleared. Derived rather than\n * registered, because operations mount lazily and would register too\n * late. An override for a key nothing uses is inert.\n */\n const cut = prefix.lastIndexOf('.')\n\n if (cut !== -1) {\n overrides.set(`${prefix.slice(0, cut)}.~${prefix.slice(cut + 1)}`, true)\n }\n }\n },\n baseline,\n pauseRetentionFor,\n untilFound: (() => {\n let used = 0\n\n return {\n acquire: (): boolean => {\n if (retentionPaused || used >= UNTIL_FOUND_CAP) {\n return false\n }\n\n used += 1\n return true\n },\n release: (): void => {\n used = Math.max(0, used - 1)\n },\n }\n })(),\n }\n}\n\n/**\n * Marks that an enclosing Schema already owns the tree root. Nesting depth\n * cannot identify the outermost tree, because a nested Schema may mount at depth\n * 0 (an `allOf` member, or a caller that omits `depth`), and the root-only\n * features (sticky ancestor strip, keyboard navigation) must not install twice.\n */\nexport const SCHEMA_TREE_ROOT_SYMBOL: InjectionKey<boolean> = Symbol('schema-tree-root')\n\n/**\n * Create the expansion store for one `<ApiReference>` and wire up deep links.\n * The scroll target is read only after mount: it comes from a URL fragment the\n * server never sees, so committing it during SSR would make every ancestor\n * panel on a deep-linked path a hydration mismatch.\n */\nexport const useSchemaExpansion = (scrollTargetId: Ref<string> = shallowRef('')): SchemaExpansionStore => {\n const store = createSchemaExpansionStore(scrollTargetId)\n\n onMounted(() => {\n watch(\n scrollTargetId,\n (target) => {\n if (target) {\n store.commitPath(target)\n }\n },\n { immediate: true },\n )\n\n /** Print with everything expanded, then put the reader's state back. */\n let baselineBeforePrint: ExpansionBaseline | null = null\n\n const handleBeforePrint = (): void => {\n baselineBeforePrint = store.baseline.value\n store.baseline.value = 'expanded'\n }\n\n const handleAfterPrint = (): void => {\n if (baselineBeforePrint !== null) {\n // Restoring the baseline closes every row the print flip opened; none may claim a slot.\n const previous = baselineBeforePrint\n store.pauseRetentionFor(() => {\n store.baseline.value = previous\n })\n baselineBeforePrint = null\n }\n }\n\n window.addEventListener('beforeprint', handleBeforePrint)\n window.addEventListener('afterprint', handleAfterPrint)\n\n onBeforeUnmount(() => {\n window.removeEventListener('beforeprint', handleBeforePrint)\n window.removeEventListener('afterprint', handleAfterPrint)\n })\n })\n\n return store\n}\n"],"mappings":";;;AA+EA,IAAMA,KAAW,GAAa,MAA0BC,MAAS,MAAMC,MAAQD,KAAQC,EAAI,WAAW,GAAGD,EAAK,EAAE,GAOnGE,KAAa,MAAsDC,GAAY,KAAK,GAAG,KAAK,IAMnGC,IAAkB,KAUXC,KAA8B,IAA8BC,EAAW,EAAE,MAA4B;CAEhH,IAAMC,IAAYC,kBAAgB,IAAI,IAAqB,CAAC,GAEtDC,IAAYD,kBAAgB,IAAI,IAAqB,CAAC,GACtDE,IAAWJ,EAA8B,SAAS,GAGlDK,KAAmB,MAAqC;EAC5D,IAAIF,EAAU,SAAS,GACrB;EAGF,IAAIG,IAAYX;EAEhB,SAAa;GACX,IAAMY,IAAQJ,EAAU,IAAIG,CAAS;GAErC,IAAIC,MAAU,KAAA,GACZ,OAAOA;GAGT,IAAMC,IAAMF,EAAU,YAAY,GAAG;GAErC,IAAIE,MAAQ,IACV,OAAOL,EAAU,IAAI,EAAE;GAGzB,IAAYG,EAAU,MAAM,GAAGE,CAAG;EACpC;CACF,GAOMC,KAAuB,MAAuB;EAClD,KAAK,IAAMd,KAAO,CAAC,GAAGM,EAAU,KAAK,CAAC,GACpC,AAAIR,EAAQE,GAAKD,CAAI,KACnBO,EAAU,OAAON,CAAG;CAG1B,GAGIe,IAAkB,IAEhBC,KAAqB,MAA6B;EAKtD,AAJA,IAAkB,IAClBC,EAAO,GAGPC,QAAoB;GAClB,IAAkB;EACpB,CAAC;CACH,GAEMC,KAAW,GAAc,MAAyB;EAGtD,IAFAL,EAAoBf,CAAI,GAEpBA,MAAS,IAGX,AADAS,EAAU,MAAM,GAChB,EAAS,QAAQI,IAAQ,aA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,IAAM,CAAC,KAAK,EAAI;GAE3E;EACF;EACA;EACA;EACA,mBAAmB;GACjB,IAAImB,IAAO;GAEX,OAAO;IACL,eACMjB,KAAmBiB,KAAQ7B,IACtB,MAGT,KAAQ,GACD;IAET,eAAqB;KACnB,IAAO,KAAK,IAAI,GAAG6B,IAAO,CAAC;IAC7B;GACF;EACF,EAAA,CAAG;CACL;AACF,GAQaC,IAAiD,OAAO,kBAAkB,GAQ1EC,KAAsB,IAA8B7B,EAAW,EAAE,MAA4B;CACxG,IAAM8B,IAAQ/B,EAA2BsB,CAAc;CAyCvD,OAvCAU,QAAgB;EACd,EACEV,IACC,MAAW;GACV,AAAIW,KACFF,EAAM,WAAWE,CAAM;EAE3B,GACA,EAAE,WAAW,GAAK,CACpB;EAGA,IAAIC,IAAgD,MAE9CC,UAAgC;GAEpC,AADA,IAAsBJ,EAAM,SAAS,OACrC,EAAM,SAAS,QAAQ;EACzB,GAEMK,UAA+B;GACnC,IAAIF,MAAwB,MAAM;IAEhC,IAAMG,IAAWH;IAIjB,AAHAH,EAAM,wBAAwB;KAC5B,EAAM,SAAS,QAAQM;IACzB,CAAC,GACD,IAAsB;GACxB;EACF;EAKA,AAHA,OAAO,iBAAiB,eAAeF,CAAiB,GACxD,OAAO,iBAAiB,cAAcC,CAAgB,GAEtDE,QAAsB;GAEpB,AADA,OAAO,oBAAoB,eAAeH,CAAiB,GAC3D,OAAO,oBAAoB,cAAcC,CAAgB;EAC3D,CAAC;CACH,CAAC,GAEML;AACT"}
|
|
1
|
+
{"version":3,"file":"schema-expansion.js","names":["isOnSchemaTargetPath","nextTick","onBeforeUnmount","onMounted","shallowReactive","shallowRef","watch","isUnder","key","root","toNodeKey","breadcrumb","UNTIL_FOUND_CAP","createSchemaExpansionStore","scrollTargetId","overrides","bulkRoots","baseline","nearestBulkRoot","candidate","value","cut","clearOverridesUnder","retentionPaused","pauseRetentionFor","mutate","setBulk","existing","isExpanded","ctx","override","bulk","setExpanded","path","segments","index","prefix","used","SCHEMA_TREE_ROOT_SYMBOL","useSchemaExpansion","store","target","baselineBeforePrint","handleBeforePrint","handleAfterPrint","previous"],"sources":["../../../src/schema/helpers/schema-expansion.ts"],"sourcesContent":["import {\n type InjectionKey,\n type Ref,\n nextTick,\n onBeforeUnmount,\n onMounted,\n shallowReactive,\n shallowRef,\n watch,\n} from 'vue'\n\nimport { isOnSchemaTargetPath } from './is-on-schema-target-path'\n\n/**\n * What a node does when nobody has expressed an opinion about it: its own\n * `defaultOpen`, or whatever expand-all / collapse-all last set.\n */\ntype ExpansionBaseline = 'default' | 'expanded' | 'collapsed'\n\n/** What the store cannot work out about a node on its own. */\ntype ExpansionContext = {\n /**\n * Whether this node sits on a `$ref` cycle. Bulk expansion and the baseline\n * skip cyclic nodes; without that, `expandAll()` on a self-referential schema\n * never terminates, because the cycle guard only suppresses auto-expansion.\n */\n cyclic?: boolean\n /** What the node would do with no store at all (its `defaultOpen`). */\n defaultOpen?: boolean\n /**\n * The public anchor path this node covers, when it differs from its key. A\n * key carrying a structural marker (`~headers`) must still open for a deep\n * link written against the anchor path (`…headers.X-Rate`).\n */\n anchorPath?: string\n}\n\n/** Shared expansion controls for a host and its schema trees. */\nexport type SchemaExpansionStore = {\n /** Resolve whether a node is open. See the resolution order below. */\n isExpanded: (key: string, ctx?: ExpansionContext) => boolean\n /** Record an explicit user decision about one node. */\n setExpanded: (key: string, value: boolean) => void\n /** Flip one node, resolving its current state first. */\n toggle: (key: string, ctx?: ExpansionContext) => void\n /** Expand everything, or everything beneath `root`. */\n expandAll: (root?: string) => void\n /** Collapse everything, or everything beneath `root`. */\n collapseAll: (root?: string) => void\n /** Make a deep link's expansion permanent by opening every ancestor of `path`. */\n commitPath: (path: string) => void\n /** The standing baseline, exposed so a print hook can flip it and put it back. */\n baseline: Ref<ExpansionBaseline>\n /**\n * The budget for closed panels kept in the DOM as `hidden=\"until-found\"`. It\n * lives on the store, so it is shared by every schema tree under one reference.\n * Kept panels stay searchable with find-in-page but grow the DOM, so a closing\n * row asks `acquire()` first and simply unmounts past the cap. Deliberately\n * not reactive: it only matters at the moment a panel closes.\n */\n untilFound: {\n acquire: () => boolean\n release: () => void\n }\n /**\n * Run a bulk transition with slot retention paused. A collapse-all or the\n * afterprint restore closes many rows in one flush; letting each one\n * `acquire()` would drain the budget in a single gesture and pin hundreds of\n * hidden subtrees. Releases still run, so reopened rows hand slots back.\n */\n pauseRetentionFor: (mutate: () => void) => void\n}\n\n/**\n * Whether `key` is `root` or sits beneath it. A literal `.` is the separator\n * even though property names may contain one (`a.b` + `c` collides with `a` +\n * `b.c`); the key is deliberately the same string as the public anchor used by\n * the sidebar, `scrollTargetId` and shared URLs, so it cannot be re-encoded alone.\n */\nconst isUnder = (key: string, root: string): boolean => root === '' || key === root || key.startsWith(`${root}.`)\n\n/**\n * Build the node key for a breadcrumb: the dot-joined anchor path, so store keys\n * and public anchors are the same string. Callers append `~`-marked structural\n * segments (`~headers`, `~anonymous-…`) for nodes the anchor cannot name.\n */\nexport const toNodeKey = (breadcrumb: readonly string[] | undefined): string => breadcrumb?.join('.') ?? ''\n\n/**\n * How many closed panels one store keeps mounted as `hidden=\"until-found\"` —\n * one `<ApiReference>`, not one tree, since every tree under it shares a store.\n */\nconst UNTIL_FOUND_CAP = 300\n\n/**\n * A per-reference store of which schema properties are open. Sparse by\n * construction: only what somebody touched, typically under twenty keys, where\n * a dense map over a large document would be tens of thousands. The maps are\n * `shallowReactive` because a Map inside a `shallowRef` does not track `.set()`\n * (clicks would do nothing) and replacing the Map wholesale would invalidate\n * every mounted row on every toggle.\n */\nexport const createSchemaExpansionStore = (scrollTargetId: Ref<string> = shallowRef('')): SchemaExpansionStore => {\n /** Only what the user explicitly opened or closed. */\n const overrides = shallowReactive(new Map<string, boolean>())\n /** Per-subtree expand-all / collapse-all roots. */\n const bulkRoots = shallowReactive(new Map<string, boolean>())\n const baseline = shallowRef<ExpansionBaseline>('default')\n\n /** The nearest bulk root at or above `key`, if any. */\n const nearestBulkRoot = (key: string): boolean | undefined => {\n if (bulkRoots.size === 0) {\n return undefined\n }\n\n let candidate = key\n\n while (true) {\n const value = bulkRoots.get(candidate)\n\n if (value !== undefined) {\n return value\n }\n\n const cut = candidate.lastIndexOf('.')\n\n if (cut === -1) {\n return bulkRoots.get('')\n }\n\n candidate = candidate.slice(0, cut)\n }\n }\n\n /**\n * Newest intent wins: a bulk write drops the overrides beneath its root, so\n * \"an explicit override always wins\" never becomes \"Expand all silently skips\n * every node the user has ever touched\". O(overrides), which stays small.\n */\n const clearOverridesUnder = (root: string): void => {\n for (const key of [...overrides.keys()]) {\n if (isUnder(key, root)) {\n overrides.delete(key)\n }\n }\n }\n\n /** While true, closing rows must not take until-found slots. */\n let retentionPaused = false\n\n const pauseRetentionFor = (mutate: () => void): void => {\n retentionPaused = true\n mutate()\n\n // The closes land in the same pre-render flush as the write, so the pause can lift after it.\n void nextTick(() => {\n retentionPaused = false\n })\n }\n\n const setBulk = (root: string, value: boolean): void => {\n clearOverridesUnder(root)\n\n if (root === '') {\n // A document-wide bulk action supersedes every narrower one.\n bulkRoots.clear()\n baseline.value = value ? 'expanded' : 'collapsed'\n return\n }\n\n for (const existing of [...bulkRoots.keys()]) {\n if (isUnder(existing, root)) {\n bulkRoots.delete(existing)\n }\n }\n\n bulkRoots.set(root, value)\n }\n\n const isExpanded = (key: string, ctx: ExpansionContext = {}): boolean => {\n // 1. An explicit decision by the user, O(1).\n const override = overrides.get(key)\n\n if (override !== undefined) {\n return override\n }\n\n // 2 and 3 are skipped for cyclic nodes, so bulk expansion terminates.\n if (!ctx.cyclic) {\n // 2. The nearest enclosing bulk action.\n const bulk = nearestBulkRoot(key)\n\n if (bulk !== undefined) {\n return bulk\n }\n\n // 3. The standing baseline.\n if (baseline.value === 'expanded') {\n return true\n }\n\n if (baseline.value === 'collapsed') {\n return false\n }\n }\n\n // 4. A live deep link, read here rather than at mount so a second deep link\n // into an already-rendered operation still works.\n if (isOnSchemaTargetPath(ctx.anchorPath ?? key, scrollTargetId.value)) {\n return true\n }\n\n // 5. Whatever the node would have done on its own.\n return ctx.defaultOpen ?? false\n }\n\n const setExpanded = (key: string, value: boolean): void => {\n overrides.set(key, value)\n }\n\n return {\n isExpanded,\n setExpanded,\n toggle: (key, ctx) => setExpanded(key, !isExpanded(key, ctx)),\n expandAll: (root = '') => setBulk(root, true),\n collapseAll: (root = '') => pauseRetentionFor(() => setBulk(root, false)),\n commitPath: (path: string): void => {\n if (!path) {\n return\n }\n\n // Open every ancestor and the target itself as overrides, so the expansion\n // outlives `clearScrollTarget` and stays user-collapsible.\n const segments = path.split('.')\n\n for (let index = 1; index <= segments.length; index++) {\n const prefix = segments.slice(0, index).join('.')\n overrides.set(prefix, true)\n\n /*\n * Also commit the marked form (`~headers`) of this segment: it is not a\n * literal prefix of the anchor, so it would re-collapse, and unmount the\n * landed-on row, once the scroll target cleared. Derived rather than\n * registered, because operations mount lazily and would register too\n * late. An override for a key nothing uses is inert.\n */\n const cut = prefix.lastIndexOf('.')\n\n if (cut !== -1) {\n overrides.set(`${prefix.slice(0, cut)}.~${prefix.slice(cut + 1)}`, true)\n }\n }\n },\n baseline,\n pauseRetentionFor,\n untilFound: (() => {\n let used = 0\n\n return {\n acquire: (): boolean => {\n if (retentionPaused || used >= UNTIL_FOUND_CAP) {\n return false\n }\n\n used += 1\n return true\n },\n release: (): void => {\n used = Math.max(0, used - 1)\n },\n }\n })(),\n }\n}\n\n/**\n * Marks that an enclosing Schema already owns the tree root. Nesting depth\n * cannot identify the outermost tree, because a nested Schema may mount at depth\n * 0 (an `allOf` member, or a caller that omits `depth`), and the root-only\n * features (sticky ancestor strip, keyboard navigation) must not install twice.\n */\nexport const SCHEMA_TREE_ROOT_SYMBOL: InjectionKey<boolean> = Symbol('schema-tree-root')\n\n/**\n * Create the expansion store for one `<ApiReference>` and wire up deep links.\n * The scroll target is read only after mount: it comes from a URL fragment the\n * server never sees, so committing it during SSR would make every ancestor\n * panel on a deep-linked path a hydration mismatch.\n */\nexport const useSchemaExpansion = (scrollTargetId: Ref<string> = shallowRef('')): SchemaExpansionStore => {\n const store = createSchemaExpansionStore(scrollTargetId)\n\n onMounted(() => {\n watch(\n scrollTargetId,\n (target) => {\n if (target) {\n store.commitPath(target)\n }\n },\n { immediate: true },\n )\n\n /** Print with everything expanded, then put the reader's state back. */\n let baselineBeforePrint: ExpansionBaseline | null = null\n\n const handleBeforePrint = (): void => {\n baselineBeforePrint = store.baseline.value\n store.baseline.value = 'expanded'\n }\n\n const handleAfterPrint = (): void => {\n if (baselineBeforePrint !== null) {\n // Restoring the baseline closes every row the print flip opened; none may claim a slot.\n const previous = baselineBeforePrint\n store.pauseRetentionFor(() => {\n store.baseline.value = previous\n })\n baselineBeforePrint = null\n }\n }\n\n window.addEventListener('beforeprint', handleBeforePrint)\n window.addEventListener('afterprint', handleAfterPrint)\n\n onBeforeUnmount(() => {\n window.removeEventListener('beforeprint', handleBeforePrint)\n window.removeEventListener('afterprint', handleAfterPrint)\n })\n })\n\n return store\n}\n"],"mappings":";;;AA+EA,IAAMO,KAAWC,GAAaC,MAA0BA,MAAS,MAAMD,MAAQC,KAAQD,EAAI,WAAW,GAAGC,EAAK,EAAE,GAOnGC,KAAaC,MAAsDA,GAAY,KAAK,GAAG,KAAK,IAMnGC,IAAkB,KAUXC,KAA8BC,IAA8BT,EAAW,EAAE,MAA4B;CAEhH,IAAMU,IAAYX,kBAAgB,IAAI,IAAqB,CAAC,GAEtDY,IAAYZ,kBAAgB,IAAI,IAAqB,CAAC,GACtDa,IAAWZ,EAA8B,SAAS,GAGlDa,KAAmBV,MAAqC;EAC5D,IAAIQ,EAAU,SAAS,GACrB;EAGF,IAAIG,IAAYX;EAEhB,SAAa;GACX,IAAMY,IAAQJ,EAAU,IAAIG,CAAS;GAErC,IAAIC,MAAU,KAAA,GACZ,OAAOA;GAGT,IAAMC,IAAMF,EAAU,YAAY,GAAG;GAErC,IAAIE,MAAQ,IACV,OAAOL,EAAU,IAAI,EAAE;GAGzBG,IAAYA,EA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AoB,eAAeyC,CAAiB,GAC3D,OAAO,oBAAoB,cAAcC,CAAgB;EAC3D,CAAC;CACH,CAAC,GAEMJ;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-keyboard-nav.js","names":["visibleToggles","root","toggle","parentToggle","firstChildToggle","handleTreeKeydown","
|
|
1
|
+
{"version":3,"file":"schema-keyboard-nav.js","names":["visibleToggles","root","toggle","parentToggle","firstChildToggle","handleTreeKeydown","event","target","toggles","index","isExpanded"],"sources":["../../../src/schema/helpers/schema-keyboard-nav.ts"],"sourcesContent":["/**\n * Arrow-key navigation over the schema tree's disclosure toggles, behind\n * `schemaKeyboardNav`. One delegated keydown per tree root, only for a\n * `[data-schema-toggle]` target with no modifier held. The bindings follow the\n * APG tree pattern, but nothing announces them, so Tab order must stand alone.\n */\n\n/**\n * All toggles under the root that are visible right now. `offsetParent` alone\n * is not enough: a panel kept as `hidden=\"until-found\"` retains its descendants'\n * layout boxes, so their toggles pass that test while `focus()` does nothing.\n */\nconst visibleToggles = (root: HTMLElement): HTMLElement[] =>\n [...root.querySelectorAll<HTMLElement>('[data-schema-toggle]')].filter(\n (toggle) => toggle.offsetParent !== null && !toggle.closest('[hidden]'),\n )\n\n/** The toggle of the row that owns the panel this toggle's row sits inside. */\nconst parentToggle = (toggle: HTMLElement): HTMLElement | null =>\n toggle\n .closest('.property-children')\n ?.closest('.property--tree')\n ?.querySelector<HTMLElement>(':scope > [data-schema-toggle]') ?? null\n\n/** The first toggle inside this row's own panel, when one is open. */\nconst firstChildToggle = (toggle: HTMLElement): HTMLElement | null =>\n toggle.closest('.property--tree')?.querySelector<HTMLElement>(':scope > .property-children [data-schema-toggle]') ??\n null\n\n/**\n * Move focus between tree toggles in response to one keydown.\n *\n * Bind this as a keydown listener on any element that owns tree rows — the\n * schema tree itself, or the response headers group that sits beside one. The\n * listener is delegated, so the element it is bound to defines the set of rows\n * it navigates: `event.currentTarget` is the root, and only the toggles under\n * that root are reachable.\n *\n * It acts only when the event target is a `[data-schema-toggle]` element and no\n * modifier key is held, so typing and browser shortcuts pass through untouched.\n * When it does handle a key it calls `preventDefault`, which doubles as the\n * handoff between nested roots: an inner root marks the event, and any outer\n * delegate the event bubbles to leaves focus where the inner one put it.\n */\nexport const handleTreeKeydown = (event: KeyboardEvent): void => {\n const target = event.target\n\n if (\n // A nested tree root already moved focus for this key; the event keeps\n // bubbling to any outer delegate, which must not move it a second time.\n event.defaultPrevented ||\n !(target instanceof HTMLElement) ||\n !target.hasAttribute('data-schema-toggle') ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n ) {\n return\n }\n\n /*\n * The root is whatever element the listener was bound to, so any surface that\n * owns tree rows can delegate here — the schema tree itself, and the response\n * headers group, which sits beside a tree rather than inside one.\n */\n const root = event.currentTarget instanceof HTMLElement ? event.currentTarget : null\n\n if (!root) {\n return\n }\n\n const toggles = visibleToggles(root)\n const index = toggles.indexOf(target)\n\n if (index === -1) {\n return\n }\n\n const isExpanded = target.getAttribute('aria-expanded') === 'true'\n\n switch (event.key) {\n case 'ArrowDown':\n toggles[index + 1]?.focus()\n break\n case 'ArrowUp':\n toggles[index - 1]?.focus()\n break\n case 'ArrowRight':\n if (!isExpanded) {\n target.click()\n } else {\n // Expanded with only leaf children — the majority case — is a no-op.\n firstChildToggle(target)?.focus()\n }\n break\n case 'ArrowLeft':\n if (isExpanded) {\n target.click()\n } else {\n parentToggle(target)?.focus()\n }\n break\n case 'Home':\n toggles[0]?.focus()\n break\n case 'End':\n toggles[toggles.length - 1]?.focus()\n break\n default:\n return\n }\n\n event.preventDefault()\n}\n"],"mappings":";AAYA,IAAMA,KAAkBC,MACtB,CAAC,GAAGA,EAAK,iBAA8B,sBAAsB,CAAC,CAAC,CAAC,QAC7DC,MAAWA,EAAO,iBAAiB,QAAQ,CAACA,EAAO,QAAQ,UAAU,CACxE,GAGIC,KAAgBD,MACpBA,EACG,QAAQ,oBAAoB,CAAC,EAC5B,QAAQ,iBAAiB,CAAC,EAC1B,cAA2B,+BAA+B,KAAK,MAG/DE,KAAoBF,MACxBA,EAAO,QAAQ,iBAAiB,CAAC,EAAE,cAA2B,kDAAkD,KAChH,MAiBWG,KAAqBC,MAA+B;CAC/D,IAAMC,IAASD,EAAM;CAErB,IAGEA,EAAM,oBACN,EAAEC,aAAkB,gBACpB,CAACA,EAAO,aAAa,oBAAoB,KACzCD,EAAM,UACNA,EAAM,WACNA,EAAM,WACNA,EAAM,UAEN;CAQF,IAAML,IAAOK,EAAM,yBAAyB,cAAcA,EAAM,gBAAgB;CAEhF,IAAI,CAACL,GACH;CAGF,IAAMO,IAAUR,EAAeC,CAAI,GAC7BQ,IAAQD,EAAQ,QAAQD,CAAM;CAEpC,IAAIE,MAAU,IACZ;CAGF,IAAMC,IAAaH,EAAO,aAAa,eAAe,MAAM;CAE5D,QAAQD,EAAM,KAAd;EACE,KAAK;GACHE,EAAQC,IAAQ,EAAE,EAAE,MAAM;GAC1B;EACF,KAAK;GACHD,EAAQC,IAAQ,EAAE,EAAE,MAAM;GAC1B;EACF,KAAK;GACEC,IAIHN,EAAiBG,CAAM,CAAC,EAAE,MAAM,IAHhCA,EAAO,MAAM;GAKf;EACF,KAAK;GACCG,IACFH,EAAO,MAAM,IAEbJ,EAAaI,CAAM,CAAC,EAAE,MAAM;GAE9B;EACF,KAAK;GACHC,EAAQ,EAAE,EAAE,MAAM;GAClB;EACF,KAAK;GACHA,EAAQA,EAAQ,SAAS,EAAE,EAAE,MAAM;GACnC;EACF,SACE;CACJ;CAEAF,EAAM,eAAe;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-name.js","names":["
|
|
1
|
+
{"version":3,"file":"schema-name.js","names":["getRefName","getSchemaRefName","resolve","isArraySchema","getModelNameFromSchema","schemaOrRef","schema","schemaKey","label","getModelNameWithArray","direct","itemName"],"sources":["../../../src/schema/helpers/schema-name.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject, SchemaReferenceType } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport { getRefName, getSchemaRefName } from './get-ref-name'\n\ntype SchemaModelName = {\n /**\n * The key in `components.schemas` (extracted from `$ref`), used for sidebar\n * navigation. Only set when the `$ref` actually targets\n * `#/components/schemas/`; `null` for refs into other component buckets or\n * external files, so those never render a dead link.\n */\n schemaKey: string | null\n /** The human-readable name to display (schema.title, schema.name, or ref key). */\n label: string\n}\n\n/**\n * Extract schema name from various schema formats\n *\n * Handles $ref, title, name, type, and schema dictionary lookup\n */\nexport const getModelNameFromSchema = (\n schemaOrRef: SchemaObject | SchemaReferenceType<SchemaObject>,\n): SchemaModelName | null => {\n if (!schemaOrRef || typeof schemaOrRef !== 'object') {\n return null\n }\n\n const schema = resolve.schema(schemaOrRef)\n\n // Only refs into `#/components/schemas/` are navigable in the models section.\n const schemaKey = '$ref' in schemaOrRef ? getSchemaRefName(schemaOrRef.$ref) : null\n\n if (schema.title) {\n return { schemaKey, label: schema.title }\n }\n\n if (schema.name) {\n return { schemaKey, label: schema.name }\n }\n\n if ('$ref' in schemaOrRef) {\n // Fall back to the last ref segment as a display label, even for\n // non-schema refs. The name still shows, it just is not a link.\n const label = getRefName(schemaOrRef.$ref)\n if (label) {\n return { schemaKey, label }\n }\n }\n\n return null\n}\n\n/**\n * Model name for a schema, resolving array branches too: an inline\n * `{ type: 'array', items: { $ref: Model } }` becomes `Model[]` instead of the\n * structural `array object[]`. Returns `null` when no model name applies (for\n * example an array of primitives), so callers can fall back to `getSchemaType`.\n */\nexport const getModelNameWithArray = (\n schemaOrRef: SchemaObject | SchemaReferenceType<SchemaObject>,\n): SchemaModelName | null => {\n const direct = getModelNameFromSchema(schemaOrRef)\n if (direct) {\n return direct\n }\n\n const schema = resolve.schema(schemaOrRef)\n if (isArraySchema(schema) && schema.items && typeof schema.items === 'object') {\n const itemName = getModelNameFromSchema(schema.items)\n if (itemName) {\n return { schemaKey: itemName.schemaKey, label: `${itemName.label}[]` }\n }\n }\n\n return null\n}\n"],"mappings":";;;;AAuBA,IAAaI,KACXC,MAC2B;CAC3B,IAAI,CAACA,KAAe,OAAOA,KAAgB,UACzC,OAAO;CAGT,IAAMC,IAASJ,EAAQ,OAAOG,CAAW,GAGnCE,IAAY,UAAUF,IAAcJ,EAAiBI,EAAY,IAAI,IAAI;CAE/E,IAAIC,EAAO,OACT,OAAO;EAAEC;EAAW,OAAOD,EAAO;CAAM;CAG1C,IAAIA,EAAO,MACT,OAAO;EAAEC;EAAW,OAAOD,EAAO;CAAK;CAGzC,IAAI,UAAUD,GAAa;EAGzB,IAAMG,IAAQR,EAAWK,EAAY,IAAI;EACzC,IAAIG,GACF,OAAO;GAAED;GAAWC;EAAM;CAE9B;CAEA,OAAO;AACT,GAQaC,KACXJ,MAC2B;CAC3B,IAAMK,IAASN,EAAuBC,CAAW;CACjD,IAAIK,GACF,OAAOA;CAGT,IAAMJ,IAASJ,EAAQ,OAAOG,CAAW;CACzC,IAAIF,EAAcG,CAAM,KAAKA,EAAO,SAAS,OAAOA,EAAO,SAAU,UAAU;EAC7E,IAAMK,IAAWP,EAAuBE,EAAO,KAAK;EACpD,IAAIK,GACF,OAAO;GAAE,WAAWA,EAAS;GAAW,OAAO,GAAGA,EAAS,MAAM;EAAI;CAEzE;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-display-description.js","names":["shouldDisplayDescription","schema","propDescription"],"sources":["../../../src/schema/helpers/should-display-description.ts"],"sourcesContent":["import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/**\n * Determine if description should be displayed\n *\n * @param schema - The schema object to check\n * @param propDescription - Optional description from props\n * @returns Description string to display, or null if should not be displayed\n */\nexport const shouldDisplayDescription = (schema: SchemaObject | undefined, propDescription?: string): string | null => {\n if (!schema) {\n return null\n }\n\n // Don't show description for schemas with compositions to avoid duplicate descriptions\n if (schema.allOf) {\n return null\n }\n\n // When both an external description (e.g. a response or parameter description) and the\n // schema's own description are present, show both so neither is lost. This matters for\n // responses with multiple content types where each media type schema carries its own\n // description (see expandAllResponses). Identical descriptions are shown only once.\n if (propDescription && schema.description) {\n return propDescription === schema.description ? propDescription : `${propDescription}\\n\\n${schema.description}`\n }\n\n return propDescription || schema.description || null\n}\n"],"mappings":";AASA,IAAaA,
|
|
1
|
+
{"version":3,"file":"should-display-description.js","names":["shouldDisplayDescription","schema","propDescription"],"sources":["../../../src/schema/helpers/should-display-description.ts"],"sourcesContent":["import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/**\n * Determine if description should be displayed\n *\n * @param schema - The schema object to check\n * @param propDescription - Optional description from props\n * @returns Description string to display, or null if should not be displayed\n */\nexport const shouldDisplayDescription = (schema: SchemaObject | undefined, propDescription?: string): string | null => {\n if (!schema) {\n return null\n }\n\n // Don't show description for schemas with compositions to avoid duplicate descriptions\n if (schema.allOf) {\n return null\n }\n\n // When both an external description (e.g. a response or parameter description) and the\n // schema's own description are present, show both so neither is lost. This matters for\n // responses with multiple content types where each media type schema carries its own\n // description (see expandAllResponses). Identical descriptions are shown only once.\n if (propDescription && schema.description) {\n return propDescription === schema.description ? propDescription : `${propDescription}\\n\\n${schema.description}`\n }\n\n return propDescription || schema.description || null\n}\n"],"mappings":";AASA,IAAaA,KAA4BC,GAAkCC,MACrE,CAACD,KAKDA,EAAO,QACF,OAOLC,KAAmBD,EAAO,cACrBC,MAAoBD,EAAO,cAAcC,IAAkB,GAAGA,EAAgB,MAAMD,EAAO,gBAG7FC,KAAmBD,EAAO,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-display-heading.js","names":["shouldDisplayHeading","
|
|
1
|
+
{"version":3,"file":"should-display-heading.js","names":["shouldDisplayHeading","schema","name","required"],"sources":["../../../src/schema/helpers/should-display-heading.ts"],"sourcesContent":["import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/**\n * Determine if property heading should be displayed\n *\n * @param schema - The schema object to check\n * @param name - Optional property name\n * @param required - Whether the property is required\n * @returns true if heading should be displayed, false otherwise\n */\nexport const shouldDisplayHeading = (schema: SchemaObject | undefined, name?: string, required = false): boolean => {\n // Early return for simple cases\n if (name || required) {\n return true\n }\n\n // If schema is undefined, return false\n if (!schema) {\n return false\n }\n\n // Check schema properties that warrant a heading\n return (\n schema.deprecated === true ||\n schema.const !== undefined ||\n schema.enum?.length === 1 ||\n ('type' in schema && schema.type !== undefined) ||\n ('nullable' in schema && schema.nullable === true) ||\n schema.writeOnly === true ||\n schema.readOnly === true\n )\n}\n"],"mappings":";AAUA,IAAaA,KAAwBC,GAAkCC,GAAeC,IAAW,OAE3FD,KAAQC,IACH,KAIJF,IAMHA,EAAO,eAAe,MACtBA,EAAO,UAAU,KAAA,KACjBA,EAAO,MAAM,WAAW,KACvB,UAAUA,KAAUA,EAAO,SAAS,KAAA,KACpC,cAAcA,KAAUA,EAAO,aAAa,MAC7CA,EAAO,cAAc,MACrBA,EAAO,aAAa,KAXb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-render-array-item-composition.js","names":["
|
|
1
|
+
{"version":3,"file":"should-render-array-item-composition.js","names":["hasComplexArrayItems","isArraySchema","hasArrayItemComposition","schema","composition","shouldRenderArrayItemComposition"],"sources":["../../../src/schema/helpers/should-render-array-item-composition.ts"],"sourcesContent":["import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport { hasComplexArrayItems } from './has-complex-array-items'\n\n/** Whether the array declares the composition on its item schema. */\nexport const hasArrayItemComposition = (schema: SchemaObject | undefined, composition: string): boolean =>\n Boolean(\n schema && isArraySchema(schema) && schema.items && typeof schema.items === 'object' && composition in schema.items,\n )\n\n/**\n * Check if array item composition should be rendered\n *\n * @param schema - The schema object to check\n * @param composition - The composition keyword to check for\n * @returns true if array item composition should be rendered, false otherwise\n */\nexport const shouldRenderArrayItemComposition = (schema: SchemaObject | undefined, composition: string): boolean =>\n hasArrayItemComposition(schema, composition) && !hasComplexArrayItems(schema)\n"],"mappings":";;;AAMA,IAAaE,KAA2BC,GAAkCC,MACxE,GACED,KAAUF,EAAcE,CAAM,KAAKA,EAAO,SAAS,OAAOA,EAAO,SAAU,YAAYC,KAAeD,EAAO,QAUpGE,KAAoCF,GAAkCC,MACjFF,EAAwBC,GAAQC,CAAW,KAAK,CAACJ,EAAqBG,CAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-property-names.js","names":["reduceNamesToObject","names","prop","properties","name","acc","collator","sortCache","EMPTY_NAMES","sortPropertyNames","isTypeObject","schema","required","discriminatorName","discriminator","cacheKey","hideReadOnly","hideWriteOnly","orderSchemaPropertiesBy","orderRequiredPropertiesFirst","bucket","cached","requiredPropertiesSet","shouldFilter","records","propertySchema","resolved","resolve","a","b","record"],"sources":["../../../src/schema/helpers/sort-property-names.ts"],"sourcesContent":["import type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { DiscriminatorObject, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { isTypeObject } from './is-type-object'\n\n/** Extract the type of properties */\ntype Properties = NonNullable<Extract<SchemaObject, { type: 'object' }>['properties']>\n\ntype Options = Partial<\n Pick<ApiReferenceConfiguration, 'orderSchemaPropertiesBy' | 'orderRequiredPropertiesFirst'> & {\n hideReadOnly: boolean\n hideWriteOnly: boolean\n }\n>\n\n/** Take a list of property names and reduce it back into an object */\nexport const reduceNamesToObject = (names: string[], properties: Properties): Properties =>\n names.reduce<Properties>((acc, name) => {\n const prop = properties?.[name]\n if (prop) {\n acc[name] = prop\n }\n return acc\n }, {})\n\n/**\n * One collator for every sort, rather than a fresh locale lookup per comparison.\n * `String.localeCompare` builds its collator on each call, which dominates the\n * comparator on schemas with many properties; `Intl.Collator` is the same\n * ordering with the setup hoisted out of the loop.\n */\nconst collator = new Intl.Collator(undefined)\n\n/**\n * Everything the comparator needs to know about one property, read once.\n *\n * The comparator used to fetch `schema.properties[name]` and probe it for\n * `x-order` on every comparison. In the app the document is a stack of proxies\n * (reactive, change detection, overrides, `$ref` magic), so each of those reads\n * costs microseconds and a sort makes `n log n` of them: a 60-property object\n * took milliseconds per sort. With the inputs hoisted the comparator only reads\n * plain fields. It makes the same decisions in the same order on the same\n * values, and `Array.prototype.sort` is stable, so the result is identical.\n */\ntype PropertyRecord = {\n name: string\n /** The `x-order` extension value, `undefined` when the property does not carry one */\n order: unknown\n required: boolean\n discriminator: boolean\n}\n\n/**\n * Sorted names, memoised per `properties` object.\n *\n * A row sorts its children while it is collapsed (for the preview) and again\n * when it opens (for the panel), and every row that `$ref`s the same schema\n * sorts the same `properties` object over again. That object's identity\n * survives each copy on the render path (the display-time spreads keep the\n * reference, and every proxy layer caches its child proxies per target), so it\n * is a stable key, and a `WeakMap` lets the entries die with the document.\n *\n * An entry is valid only while `schema.required` is the same array: the\n * composition path builds a fresh `properties` AND a fresh `required` when it\n * merges variants, so a merged schema never hits a stale entry. Every option\n * that affects the order is part of the inner key. Nothing else the sort reads\n * changes while a document is rendered: api-reference never rewrites a schema\n * subtree in place, it swaps whole documents.\n */\ntype SortCacheEntry = {\n required: unknown\n names: readonly string[]\n}\nconst sortCache = new WeakMap<object, Map<string, SortCacheEntry>>()\n\n/** The one array every \"nothing to sort\" answer returns, frozen like the sorted ones. */\nconst EMPTY_NAMES: readonly string[] = Object.freeze([])\n\n/**\n * Sort property names in an object schema.\n *\n * The returned array is shared with later calls for the same schema and options,\n * so it is frozen: an in-place `sort` / `reverse` / `splice` by one caller would\n * otherwise silently reorder every other consumer of the same schema. Callers\n * that need a mutable list copy it first (`slice`).\n */\nexport const sortPropertyNames = (\n schema: SchemaObject,\n discriminator?: DiscriminatorObject,\n {\n hideReadOnly = false,\n hideWriteOnly = false,\n orderSchemaPropertiesBy = 'alpha',\n orderRequiredPropertiesFirst = true,\n }: Options = {},\n): readonly string[] => {\n if (!isTypeObject(schema) || !schema.properties) {\n return EMPTY_NAMES\n }\n\n const properties = schema.properties\n const required = schema.required\n const discriminatorName = discriminator?.propertyName\n\n // A `!` marks a present discriminator so an absent one can never collide with\n // a property literally named like the placeholder.\n const cacheKey = [\n discriminatorName === undefined ? '' : `!${discriminatorName}`,\n hideReadOnly,\n hideWriteOnly,\n orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst,\n ].join('|')\n\n const bucket = sortCache.get(properties)\n const cached = bucket?.get(cacheKey)\n if (cached && cached.required === required) {\n return cached.names\n }\n\n const requiredPropertiesSet = new Set(required || [])\n\n /*\n * Filter BEFORE sorting, and only when something is actually hidden.\n *\n * The filter resolves every property through `resolve.schema` to read\n * `readOnly`/`writeOnly`; with neither flag set that is a full resolve pass\n * per schema whose result is always \"keep\". Skipping it there, and shrinking\n * the array the comparator runs over when it does apply, leaves the ordering\n * identical — the filter is order-preserving and independent of the compare.\n * It shares the single read of each property with the record below.\n */\n const shouldFilter = hideReadOnly || hideWriteOnly\n const records: PropertyRecord[] = []\n\n for (const name of Object.keys(properties)) {\n const propertySchema = properties[name]\n\n if (shouldFilter) {\n const resolved = resolve.schema(propertySchema)\n\n if (hideReadOnly && resolved?.readOnly === true) {\n continue\n }\n if (hideWriteOnly && resolved?.writeOnly === true) {\n continue\n }\n }\n\n records.push({\n name,\n order:\n propertySchema && typeof propertySchema === 'object' && 'x-order' in propertySchema\n ? propertySchema['x-order']\n : undefined,\n required: requiredPropertiesSet.has(name),\n discriminator: name === discriminatorName,\n })\n }\n\n records.sort((a, b) => {\n // Discriminator comes first always\n if (a.discriminator && !b.discriminator) {\n return -1\n }\n if (!a.discriminator && b.discriminator) {\n return 1\n }\n\n // Sort by x-order specification extension when present\n if (a.order !== undefined && b.order !== undefined) {\n return Number(a.order) - Number(b.order)\n }\n if (a.order !== undefined && b.order === undefined) {\n return -1\n }\n if (a.order === undefined && b.order !== undefined) {\n return 1\n }\n\n // Order required properties first\n if (orderRequiredPropertiesFirst) {\n // If one is required and the other isn't, required comes first\n if (a.required && !b.required) {\n return -1\n }\n if (!a.required && b.required) {\n return 1\n }\n }\n\n // If both have the same required status, sort alphabetically\n if (orderSchemaPropertiesBy === 'alpha') {\n return collator.compare(a.name, b.name)\n }\n\n return 0\n })\n\n // Frozen before it is shared, so a caller that sorts or splices it in place\n // fails loudly here instead of corrupting every other reader of this schema.\n const names = Object.freeze(records.map((record) => record.name))\n\n // A malformed document can carry a non-object `properties`; that cannot key\n // a WeakMap, so it simply goes uncached.\n if (typeof properties === 'object' && properties !== null) {\n if (bucket) {\n bucket.set(cacheKey, { required, names })\n } else {\n sortCache.set(properties, new Map([[cacheKey, { required, names }]]))\n }\n }\n\n return names\n}\n"],"mappings":";;;AAiBA,IAAaA,KAAuB,GAAiB,MACnDC,EAAM,QAAoB,GAAK,MAAS;CACtC,IAAMC,IAAOC,IAAaC;CAI1B,OAHIF,MACF,EAAIE,KAAQF,IAEPG;AACT,GAAG,CAAC,CAAC,GAQDC,IAAW,IAAI,KAAK,SAAS,KAAA,CAAS,GA0CtCC,oBAAY,IAAI,QAA6C,GAG7DC,IAAiC,OAAO,OAAO,CAAC,CAAC,GAU1CC,KACX,GACA,GACA,EACE,kBAAe,IACf,mBAAgB,IAChB,6BAA0B,SAC1B,kCAA+B,OACpB,CAAC,MACQ;CACtB,IAAI,CAACC,EAAaC,CAAM,KAAK,CAACA,EAAO,YACnC,OAAOH;CAGT,IAAML,IAAaQ,EAAO,YACpBC,IAAWD,EAAO,UAClBE,IAAoBC,GAAe,cAInCC,IAAW;EACfF,MAAsB,KAAA,IAAY,KAAK,IAAIA;EAC3CG;EACAC;EACAC;EACAC;CACF,CAAC,CAAC,KAAK,GAAG,GAEJC,IAASb,EAAU,IAAIJ,CAAU,GACjCkB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C;CAYhE,OARI,OAAO3B,KAAe,YAAYA,MAChCiB,IACFA,EAAO,IAAIL,GAAU;EAAE;EAAU;CAAM,CAAC,IAExCR,EAAU,IAAIJ,mBAAY,IAAI,IAAI,CAAC,CAACY,GAAU;EAAE;EAAU;CAAM,CAAC,CAAC,CAAC,CAAC,IAIjEd;AACT"}
|
|
1
|
+
{"version":3,"file":"sort-property-names.js","names":["isTypeObject","resolve","reduceNamesToObject","names","properties","acc","name","prop","collator","sortCache","EMPTY_NAMES","sortPropertyNames","schema","discriminator","hideReadOnly","hideWriteOnly","orderSchemaPropertiesBy","orderRequiredPropertiesFirst","required","discriminatorName","cacheKey","bucket","cached","requiredPropertiesSet","shouldFilter","records","propertySchema","resolved","a","b","record"],"sources":["../../../src/schema/helpers/sort-property-names.ts"],"sourcesContent":["import type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { DiscriminatorObject, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { isTypeObject } from './is-type-object'\n\n/** Extract the type of properties */\ntype Properties = NonNullable<Extract<SchemaObject, { type: 'object' }>['properties']>\n\ntype Options = Partial<\n Pick<ApiReferenceConfiguration, 'orderSchemaPropertiesBy' | 'orderRequiredPropertiesFirst'> & {\n hideReadOnly: boolean\n hideWriteOnly: boolean\n }\n>\n\n/** Take a list of property names and reduce it back into an object */\nexport const reduceNamesToObject = (names: string[], properties: Properties): Properties =>\n names.reduce<Properties>((acc, name) => {\n const prop = properties?.[name]\n if (prop) {\n acc[name] = prop\n }\n return acc\n }, {})\n\n/**\n * One collator for every sort, rather than a fresh locale lookup per comparison.\n * `String.localeCompare` builds its collator on each call, which dominates the\n * comparator on schemas with many properties; `Intl.Collator` is the same\n * ordering with the setup hoisted out of the loop.\n */\nconst collator = new Intl.Collator(undefined)\n\n/**\n * Everything the comparator needs to know about one property, read once.\n *\n * The comparator used to fetch `schema.properties[name]` and probe it for\n * `x-order` on every comparison. In the app the document is a stack of proxies\n * (reactive, change detection, overrides, `$ref` magic), so each of those reads\n * costs microseconds and a sort makes `n log n` of them: a 60-property object\n * took milliseconds per sort. With the inputs hoisted the comparator only reads\n * plain fields. It makes the same decisions in the same order on the same\n * values, and `Array.prototype.sort` is stable, so the result is identical.\n */\ntype PropertyRecord = {\n name: string\n /** The `x-order` extension value, `undefined` when the property does not carry one */\n order: unknown\n required: boolean\n discriminator: boolean\n}\n\n/**\n * Sorted names, memoised per `properties` object.\n *\n * A row sorts its children while it is collapsed (for the preview) and again\n * when it opens (for the panel), and every row that `$ref`s the same schema\n * sorts the same `properties` object over again. That object's identity\n * survives each copy on the render path (the display-time spreads keep the\n * reference, and every proxy layer caches its child proxies per target), so it\n * is a stable key, and a `WeakMap` lets the entries die with the document.\n *\n * An entry is valid only while `schema.required` is the same array: the\n * composition path builds a fresh `properties` AND a fresh `required` when it\n * merges variants, so a merged schema never hits a stale entry. Every option\n * that affects the order is part of the inner key. Nothing else the sort reads\n * changes while a document is rendered: api-reference never rewrites a schema\n * subtree in place, it swaps whole documents.\n */\ntype SortCacheEntry = {\n required: unknown\n names: readonly string[]\n}\nconst sortCache = new WeakMap<object, Map<string, SortCacheEntry>>()\n\n/** The one array every \"nothing to sort\" answer returns, frozen like the sorted ones. */\nconst EMPTY_NAMES: readonly string[] = Object.freeze([])\n\n/**\n * Sort property names in an object schema.\n *\n * The returned array is shared with later calls for the same schema and options,\n * so it is frozen: an in-place `sort` / `reverse` / `splice` by one caller would\n * otherwise silently reorder every other consumer of the same schema. Callers\n * that need a mutable list copy it first (`slice`).\n */\nexport const sortPropertyNames = (\n schema: SchemaObject,\n discriminator?: DiscriminatorObject,\n {\n hideReadOnly = false,\n hideWriteOnly = false,\n orderSchemaPropertiesBy = 'alpha',\n orderRequiredPropertiesFirst = true,\n }: Options = {},\n): readonly string[] => {\n if (!isTypeObject(schema) || !schema.properties) {\n return EMPTY_NAMES\n }\n\n const properties = schema.properties\n const required = schema.required\n const discriminatorName = discriminator?.propertyName\n\n // A `!` marks a present discriminator so an absent one can never collide with\n // a property literally named like the placeholder.\n const cacheKey = [\n discriminatorName === undefined ? '' : `!${discriminatorName}`,\n hideReadOnly,\n hideWriteOnly,\n orderSchemaPropertiesBy,\n orderRequiredPropertiesFirst,\n ].join('|')\n\n const bucket = sortCache.get(properties)\n const cached = bucket?.get(cacheKey)\n if (cached && cached.required === required) {\n return cached.names\n }\n\n const requiredPropertiesSet = new Set(required || [])\n\n /*\n * Filter BEFORE sorting, and only when something is actually hidden.\n *\n * The filter resolves every property through `resolve.schema` to read\n * `readOnly`/`writeOnly`; with neither flag set that is a full resolve pass\n * per schema whose result is always \"keep\". Skipping it there, and shrinking\n * the array the comparator runs over when it does apply, leaves the ordering\n * identical — the filter is order-preserving and independent of the compare.\n * It shares the single read of each property with the record below.\n */\n const shouldFilter = hideReadOnly || hideWriteOnly\n const records: PropertyRecord[] = []\n\n for (const name of Object.keys(properties)) {\n const propertySchema = properties[name]\n\n if (shouldFilter) {\n const resolved = resolve.schema(propertySchema)\n\n if (hideReadOnly && resolved?.readOnly === true) {\n continue\n }\n if (hideWriteOnly && resolved?.writeOnly === true) {\n continue\n }\n }\n\n records.push({\n name,\n order:\n propertySchema && typeof propertySchema === 'object' && 'x-order' in propertySchema\n ? propertySchema['x-order']\n : undefined,\n required: requiredPropertiesSet.has(name),\n discriminator: name === discriminatorName,\n })\n }\n\n records.sort((a, b) => {\n // Discriminator comes first always\n if (a.discriminator && !b.discriminator) {\n return -1\n }\n if (!a.discriminator && b.discriminator) {\n return 1\n }\n\n // Sort by x-order specification extension when present\n if (a.order !== undefined && b.order !== undefined) {\n return Number(a.order) - Number(b.order)\n }\n if (a.order !== undefined && b.order === undefined) {\n return -1\n }\n if (a.order === undefined && b.order !== undefined) {\n return 1\n }\n\n // Order required properties first\n if (orderRequiredPropertiesFirst) {\n // If one is required and the other isn't, required comes first\n if (a.required && !b.required) {\n return -1\n }\n if (!a.required && b.required) {\n return 1\n }\n }\n\n // If both have the same required status, sort alphabetically\n if (orderSchemaPropertiesBy === 'alpha') {\n return collator.compare(a.name, b.name)\n }\n\n return 0\n })\n\n // Frozen before it is shared, so a caller that sorts or splices it in place\n // fails loudly here instead of corrupting every other reader of this schema.\n const names = Object.freeze(records.map((record) => record.name))\n\n // A malformed document can carry a non-object `properties`; that cannot key\n // a WeakMap, so it simply goes uncached.\n if (typeof properties === 'object' && properties !== null) {\n if (bucket) {\n bucket.set(cacheKey, { required, names })\n } else {\n sortCache.set(properties, new Map([[cacheKey, { required, names }]]))\n }\n }\n\n return names\n}\n"],"mappings":";;;AAiBA,IAAaE,KAAuBC,GAAiBC,MACnDD,EAAM,QAAoBE,GAAKC,MAAS;CACtC,IAAMC,IAAOH,IAAaE;CAI1B,OAHIC,MACFF,EAAIC,KAAQC,IAEPF;AACT,GAAG,CAAC,CAAC,GAQDG,IAAW,IAAI,KAAK,SAAS,KAAA,CAAS,GA0CtCC,oBAAY,IAAI,QAA6C,GAG7DC,IAAiC,OAAO,OAAO,CAAC,CAAC,GAU1CC,KACXC,GACAC,GACA,EACEC,kBAAe,IACfC,mBAAgB,IAChBC,6BAA0B,SAC1BC,kCAA+B,OACpB,CAAC,MACQ;CACtB,IAAI,CAACjB,EAAaY,CAAM,KAAK,CAACA,EAAO,YACnC,OAAOF;CAGT,IAAMN,IAAaQ,EAAO,YACpBM,IAAWN,EAAO,UAClBO,IAAoBN,GAAe,cAInCO,IAAW;EACfD,MAAsB,KAAA,IAAY,KAAK,IAAIA;EAC3CL;EACAC;EACAC;EACAC;CACF,CAAC,CAAC,KAAK,GAAG,GAEJI,IAASZ,EAAU,IAAIL,CAAU,GACjCkB,IAASD,GAAQ,IAAID,CAAQ;CACnC,IAAIE,KAAUA,EAAO,aAAaJ,GAChC,OAAOI,EAAO;CAGhB,IAAMC,IAAwB,IAAI,IAAIL,KAAY,CAAC,CAAC,GAY9CM,IAAeV,KAAgBC,GAC/BU,IAA4B,CAAC;CAEnC,KAAK,IA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CAAC,CAAC,CAAC,IAIjEA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrap-for-read.js","names":["
|
|
1
|
+
{"version":3,"file":"unwrap-for-read.js","names":["toRaw","unpackDetectChangesProxy","unwrapForRead","value"],"sources":["../../../src/schema/helpers/unwrap-for-read.ts"],"sourcesContent":["import { unpackDetectChangesProxy } from '@scalar/workspace-store/helpers/detect-changes-proxy'\nimport { toRaw } from 'vue'\n\n/**\n * Peel the two write-oriented layers off a workspace value so the schema tree reads it\n * through the magic and overrides proxies only.\n *\n * In the app a document sits under four proxies: Vue's `reactive` wraps a detect-changes\n * proxy (see `createWorkspaceStore`), which wraps `createOverridesProxy(createMagicProxy(raw))`.\n * Rendering a schema is read-only, but every property access still pays for all four: the\n * reactive layer tracks a dependency and lazily wraps the child, and the detect-changes `get`\n * allocates a fresh `{ ...args, path: [...args.path, prop] }` for every object-valued read.\n * Together they make a nested read roughly sixteen times more expensive than the same read\n * through the magic layer alone.\n *\n * Only the outer two layers are removed. The magic layer must stay, because every resolver in\n * this directory reads the virtual `$ref-value` property it synthesises, and the overrides\n * layer must stay so `x-scalar-*` overrides keep resolving. That rules out the store's own\n * `getRaw` / `unpackProxyObject` helpers (they strip the magic layer, and `unpackProxyObject`\n * writes unpacked children back onto the raw document) as well as `markRaw` (it would write\n * `__v_skip` through the detect-changes set hooks).\n *\n * What this gives up is Vue dependency tracking on reads *inside* a schema subtree. That is\n * safe here because the API reference never mutates a schema node in place: documents are\n * added or replaced whole and switched by name, so a `Schema` root always receives a new\n * object and re-renders from the prop identity, and the in-place writes that do exist\n * (`x-scalar-active-document`, `x-scalar-is-dirty`) are document-level keys no schema\n * component reads.\n *\n * That invariant is the precondition, so here is what would break it. Anything that fills an\n * existing schema node in place, rather than handing the tree a new object, becomes invisible\n * to every component below a `Schema` root and the stale subtree stays on screen:\n *\n * - `store.resolve(path)` in `@scalar/workspace-store` (see `client.ts`) bundles lazily and\n * populates the node already at `path`. The API reference does not call it today. Wiring up\n * lazy `$ref` bundling means this unwrap has to go, or the resolved subtree has to arrive as\n * a new object the `Schema` prop can be swapped to.\n * - `merge-all-of-schemas.ts` reaches one in-place write of its own: when a merged `items` was\n * itself taken from the document (`result.items = items`), a later pass `Object.assign`s onto\n * that document node. It is idempotent and runs while the same render is still computing, so\n * nothing re-reads it afterwards, but it is the shape to watch for.\n *\n * There is deliberately no runtime guard. Catching these writes would mean proxying the whole\n * subtree again — the exact per-read cost this removes — and the writes above happen on nodes\n * reached through `resolve.schema`, not through the value returned here, so a shallow proxy on\n * the root would catch none of them.\n *\n * Idempotent: a plain object (unit tests, stories, static documents) is returned unchanged.\n */\nexport const unwrapForRead = <T>(value: T): T => unpackDetectChangesProxy(toRaw(value))\n"],"mappings":";;;AAiDA,IAAaE,KAAoBC,MAAgBF,EAAyBD,EAAMG,CAAK,CAAC"}
|
package/dist/schema/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import { schemaTranslations as r } from "./localization/translations.js";
|
|
|
5
5
|
import { protobufFieldNumber as i, protobufPresence as a } from "./protobuf-metadata.js";
|
|
6
6
|
import { schemaRecursiveTarget as o } from "./recursive-metadata.js";
|
|
7
7
|
import { REQUEST_BODY_COMPOSITION_INDEX_SYMBOL as s } from "./request-body-composition-index.js";
|
|
8
|
-
import c from "./
|
|
9
|
-
import l from "./
|
|
10
|
-
import u from "./
|
|
11
|
-
import d from "./
|
|
12
|
-
import f from "./
|
|
13
|
-
import p from "./
|
|
14
|
-
import m from "./
|
|
15
|
-
import h from "./
|
|
8
|
+
import c from "./Schema3.vue.js";
|
|
9
|
+
import l from "./SchemaGlyphPuck2.vue.js";
|
|
10
|
+
import u from "./SchemaGutterToggle2.vue.js";
|
|
11
|
+
import d from "./SchemaHeading3.vue.js";
|
|
12
|
+
import f from "./SchemaObjectExampleCodeBlock2.vue.js";
|
|
13
|
+
import p from "./SchemaProperty3.vue.js";
|
|
14
|
+
import m from "./SchemaPropertyExamples3.vue.js";
|
|
15
|
+
import h from "./SchemaRailPanel2.vue.js";
|
|
16
16
|
export { n as LinkButton, s as REQUEST_BODY_COMPOSITION_INDEX_SYMBOL, c as Schema, l as SchemaGlyphPuck, u as SchemaGutterToggle, d as SchemaHeading, f as SchemaObjectExampleCodeBlock, p as SchemaProperty, m as SchemaPropertyExamples, h as SchemaRailPanel, t as inferDiscriminatorMappingComposition, i as protobufFieldNumber, a as protobufPresence, e as schemaDiscriminator, o as schemaRecursiveTarget, r as schemaTranslations };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["schemaTranslations","createLocalization","useLocalization"],"sources":["../../../src/schema/localization/index.ts"],"sourcesContent":["import { createLocalization } from '@scalar/localization'\nimport type { ApiReferenceTranslationKey } from '@scalar/types/api-reference'\n\nimport { schemaTranslations } from './translations'\n\n/** Schema translations inherit the host locale and custom overrides through the shared context. */\nexport const { useLocalization } = createLocalization<\n typeof schemaTranslations.en,\n Extract<\n ApiReferenceTranslationKey,\n `schema.${string}` | 'common.copyDefault' | 'common.copyExample' | 'actions.copyLinkTo'\n >\n>({\n localeTranslations: schemaTranslations,\n defaultLocale: 'en',\n rtlLocales: new Set(['ar', 'fa', 'he', 'ur']),\n logPrefix: '[@scalar/blocks/schema]',\n})\n"],"mappings":";;;AAMA,IAAa,EAAEE,uBAAoBD,EAMjC;CACA,oBAAoBD;CACpB,eAAe;CACf,4BAAY,IAAI,IAAI;EAAC;EAAM;EAAM;EAAM;CAAI,CAAC;CAC5C,WAAW;AACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","names":["
|
|
1
|
+
{"version":3,"file":"translations.js","names":["ar","de","en","es","fr","pt","ru","zhCn","zhTw","schemaTranslations"],"sources":["../../../src/schema/localization/translations.ts"],"sourcesContent":["import { ar } from './locales/ar'\nimport { de } from './locales/de'\nimport { en } from './locales/en'\nimport { es } from './locales/es'\nimport { fr } from './locales/fr'\nimport { pt } from './locales/pt'\nimport { ru } from './locales/ru'\nimport { zhCn } from './locales/zh-cn'\nimport { zhTw } from './locales/zh-tw'\n\n/** Built-in schema translations, also composed into API Reference's public dictionary. */\nexport const schemaTranslations = { en, de, es, fr, pt, ru, ar, 'zh-CN': zhCn, 'zh-TW': zhTw }\n"],"mappings":";;;;;;;;;;AAWA,IAAaS,IAAqB;CAAEP;CAAID;CAAIE;CAAIC;CAAIC;CAAIC;CAAIN;CAAI,SAASO;CAAM,SAASC;AAAK"}
|