@scalar/blocks 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  3. package/dist/code-example/components/CodeExample.vue.js +1 -1
  4. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +60 -66
  5. package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  7. package/dist/code-example/helpers/operation-to-har/process-parameters.js +126 -156
  8. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  9. package/dist/code-example/mount.d.ts +1 -1
  10. package/dist/code-example/mount.d.ts.map +1 -1
  11. package/dist/code-example/mount.js +49 -39
  12. package/dist/code-example/mount.js.map +1 -1
  13. package/dist/constants.js +1 -1
  14. package/dist/schema/Schema.vue.d.ts.map +1 -1
  15. package/dist/schema/Schema.vue.js +1 -1
  16. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +40 -39
  17. package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -1
  18. package/dist/schema/SchemaProperty.vue.d.ts +1 -1
  19. package/dist/schema/SchemaProperty.vue.d.ts.map +1 -1
  20. package/dist/schema/SchemaProperty.vue.js +1 -1
  21. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +7 -2
  22. package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -1
  23. package/dist/schema/SchemaPropertyHeading.vue.d.ts +1 -1
  24. package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
  25. package/dist/schema/components/CopyLinkButton.vue.d.ts +5 -0
  26. package/dist/schema/components/CopyLinkButton.vue.d.ts.map +1 -1
  27. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +2 -1
  28. package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  29. package/dist/schema/helpers/dynamic-scope.d.ts +3 -1
  30. package/dist/schema/helpers/dynamic-scope.d.ts.map +1 -1
  31. package/dist/schema/helpers/dynamic-scope.js +19 -4
  32. package/dist/schema/helpers/dynamic-scope.js.map +1 -1
  33. package/dist/schema/helpers/get-compositions-to-render.d.ts.map +1 -1
  34. package/dist/schema/helpers/get-compositions-to-render.js +24 -24
  35. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
  36. package/dist/schema/helpers/index.d.ts +1 -0
  37. package/dist/schema/helpers/index.d.ts.map +1 -1
  38. package/dist/schema/helpers/index.js +14 -13
  39. package/dist/schema/helpers/partition-all-of-compositions.d.ts.map +1 -1
  40. package/dist/schema/helpers/partition-all-of-compositions.js +24 -14
  41. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
  42. package/dist/schema/helpers/should-render-array-item-composition.d.ts +2 -0
  43. package/dist/schema/helpers/should-render-array-item-composition.d.ts.map +1 -1
  44. package/dist/schema/helpers/should-render-array-item-composition.js +2 -6
  45. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
  46. package/dist/schema/localization/index.d.ts +1 -1
  47. package/dist/shared/ExternalExampleStatus.vue.d.ts +12 -0
  48. package/dist/shared/ExternalExampleStatus.vue.d.ts.map +1 -0
  49. package/dist/shared/ExternalExampleStatus.vue.js +6 -0
  50. package/dist/shared/ExternalExampleStatus.vue.js.map +1 -0
  51. package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js +26 -0
  52. package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js.map +1 -0
  53. package/dist/shared/external-example-localization/index.d.ts +4 -0
  54. package/dist/shared/external-example-localization/index.d.ts.map +1 -0
  55. package/dist/shared/external-example-localization/index.js +17 -0
  56. package/dist/shared/external-example-localization/index.js.map +1 -0
  57. package/dist/shared/external-example-localization/locales/ar.d.ts +8 -0
  58. package/dist/shared/external-example-localization/locales/ar.d.ts.map +1 -0
  59. package/dist/shared/external-example-localization/locales/ar.js +9 -0
  60. package/dist/shared/external-example-localization/locales/ar.js.map +1 -0
  61. package/dist/shared/external-example-localization/locales/de.d.ts +8 -0
  62. package/dist/shared/external-example-localization/locales/de.d.ts.map +1 -0
  63. package/dist/shared/external-example-localization/locales/de.js +9 -0
  64. package/dist/shared/external-example-localization/locales/de.js.map +1 -0
  65. package/dist/shared/external-example-localization/locales/en.d.ts +8 -0
  66. package/dist/shared/external-example-localization/locales/en.d.ts.map +1 -0
  67. package/dist/shared/external-example-localization/locales/en.js +9 -0
  68. package/dist/shared/external-example-localization/locales/en.js.map +1 -0
  69. package/dist/shared/external-example-localization/locales/es.d.ts +8 -0
  70. package/dist/shared/external-example-localization/locales/es.d.ts.map +1 -0
  71. package/dist/shared/external-example-localization/locales/es.js +9 -0
  72. package/dist/shared/external-example-localization/locales/es.js.map +1 -0
  73. package/dist/shared/external-example-localization/locales/fr.d.ts +8 -0
  74. package/dist/shared/external-example-localization/locales/fr.d.ts.map +1 -0
  75. package/dist/shared/external-example-localization/locales/fr.js +9 -0
  76. package/dist/shared/external-example-localization/locales/fr.js.map +1 -0
  77. package/dist/shared/external-example-localization/locales/pt.d.ts +8 -0
  78. package/dist/shared/external-example-localization/locales/pt.d.ts.map +1 -0
  79. package/dist/shared/external-example-localization/locales/pt.js +9 -0
  80. package/dist/shared/external-example-localization/locales/pt.js.map +1 -0
  81. package/dist/shared/external-example-localization/locales/ru.d.ts +8 -0
  82. package/dist/shared/external-example-localization/locales/ru.d.ts.map +1 -0
  83. package/dist/shared/external-example-localization/locales/ru.js +9 -0
  84. package/dist/shared/external-example-localization/locales/ru.js.map +1 -0
  85. package/dist/shared/external-example-localization/locales/zh-cn.d.ts +8 -0
  86. package/dist/shared/external-example-localization/locales/zh-cn.d.ts.map +1 -0
  87. package/dist/shared/external-example-localization/locales/zh-cn.js +9 -0
  88. package/dist/shared/external-example-localization/locales/zh-cn.js.map +1 -0
  89. package/dist/shared/external-example-localization/locales/zh-tw.d.ts +8 -0
  90. package/dist/shared/external-example-localization/locales/zh-tw.d.ts.map +1 -0
  91. package/dist/shared/external-example-localization/locales/zh-tw.js +9 -0
  92. package/dist/shared/external-example-localization/locales/zh-tw.js.map +1 -0
  93. package/dist/shared/external-example-localization/translations.d.ts +67 -0
  94. package/dist/shared/external-example-localization/translations.d.ts.map +1 -0
  95. package/dist/shared/external-example-localization/translations.js +24 -0
  96. package/dist/shared/external-example-localization/translations.js.map +1 -0
  97. package/dist/shared/index.d.ts +3 -0
  98. package/dist/shared/index.d.ts.map +1 -1
  99. package/dist/shared/index.js +4 -2
  100. package/dist/style.css +3 -3
  101. package/dist/vue-styles.css +1 -1
  102. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"get-compositions-to-render.js","names":["normalizeDiscriminatorMappingRef","value","inferDiscriminatorMappingComposition","mapping","document","unwrapForRead","documentProp","refs","variantRefs","mappingValue","ref","refName","getRefName","refValue","resolve","unescapeJsonPointerSegment","isDefined","getCompositionsToRender","compositions","composition","inferredDiscriminatorComposition","shouldRenderArrayItemComposition","isArraySchema"],"sources":["../../../src/schema/helpers/get-compositions-to-render.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { unescapeJsonPointerSegment } from '@scalar/helpers/json/unescape-json-pointer-segment'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { OpenApiDocument, 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 { getRefName } from './get-ref-name'\nimport { type CompositionKeyword, compositions } from './schema-composition'\nimport { shouldRenderArrayItemComposition } from './should-render-array-item-composition'\nimport { unwrapForRead } from './unwrap-for-read'\n\ntype CompositionToRender = {\n composition: CompositionKeyword\n value: SchemaObject\n}\n\ntype DocumentSchemaLookup = Pick<OpenApiDocument, 'components'>\n\nconst normalizeDiscriminatorMappingRef = (value: string) =>\n value.startsWith('#/') || value.includes('/') ? value : `#/components/schemas/${value}`\n\n/**\n * Builds a synthetic `oneOf` composition from a `discriminator.mapping` when the\n * schema declares a mapping but no explicit `oneOf`/`anyOf`. This is the shape\n * NSwag emits for polymorphic types, where the base type is a plain object with\n * a discriminator mapping pointing at the concrete variants.\n *\n * Returns `null` when there is nothing to infer (an explicit composition is\n * already present, no document to resolve refs against, or no resolvable refs).\n */\nexport const inferDiscriminatorMappingComposition = (\n value: SchemaObject,\n documentProp?: DocumentSchemaLookup,\n /** Inheritance can supply ordered variants, including schemas that share a mapped value. */\n variantRefs?: readonly string[],\n): SchemaObject | null => {\n if (value.oneOf || value.anyOf) {\n return null\n }\n\n // A schema without a mapping can never infer anything, so it is checked before the document is\n // touched at all: the document read below is by far the more expensive of the two.\n const mapping = value.discriminator?.mapping\n\n if (!mapping) {\n return null\n }\n\n // Reading `components.schemas` per row through the reactive and detect-changes layers is the\n // dominant cost of this helper, so the document is unwrapped once here. See `unwrapForRead`.\n const document = unwrapForRead(documentProp)\n\n if (!document?.components?.schemas) {\n return null\n }\n\n const refs = (variantRefs ?? Object.values(mapping))\n .filter((mappingValue): mappingValue is string => typeof mappingValue === 'string')\n .map((mappingValue) => {\n const ref = normalizeDiscriminatorMappingRef(mappingValue)\n const refName = getRefName(ref)\n const refValue = refName\n ? resolve.schema(document.components?.schemas?.[unescapeJsonPointerSegment(refName)])\n : undefined\n\n if (!refValue) {\n return undefined\n }\n\n return {\n $ref: ref,\n '$ref-value': refValue,\n }\n })\n .filter(isDefined)\n\n if (refs.length === 0) {\n return null\n }\n\n return {\n ...resolve.schema(value),\n oneOf: refs,\n }\n}\n\n/**\n * Computes which compositions should be rendered and with which values\n *\n * @param value - The schema object to check for compositions\n * @returns Array of compositions to render with their values\n */\nexport const getCompositionsToRender = (\n value: SchemaObject | undefined,\n document?: DocumentSchemaLookup,\n /**\n * The `oneOf` inferred from a bare `discriminator.mapping`, when the caller has\n * already computed it. `SchemaProperty` needs the same value to decide whether\n * to suppress the duplicate base object block, so it passes it here to avoid\n * inferring twice. Omit it and it is inferred from `value`.\n */\n inferredDiscriminatorComposition: SchemaObject | null = value\n ? inferDiscriminatorMappingComposition(value, document)\n : null,\n): CompositionToRender[] => {\n if (!value) {\n return []\n }\n\n return compositions\n .map((composition) => {\n if (composition === 'oneOf' && inferredDiscriminatorComposition) {\n return {\n composition,\n value: inferredDiscriminatorComposition,\n }\n }\n\n // Check for array item-level composition first (more specific case)\n if (shouldRenderArrayItemComposition(value, composition) && isArraySchema(value) && value.items) {\n return {\n composition,\n value: resolve.schema(value.items),\n }\n }\n\n // Check for property-level composition\n if (value[composition]) {\n // Skip if array items have this composition (even if complex/not rendered)\n const hasArrayItemComposition =\n isArraySchema(value) && value.items && typeof value.items === 'object' && composition in value.items\n\n if (!hasArrayItemComposition) {\n return {\n composition,\n value: resolve.schema(value),\n }\n }\n }\n\n return null\n })\n .filter(isDefined)\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAMA,KAAoC,MACxCC,EAAM,WAAW,IAAI,KAAKA,EAAM,SAAS,GAAG,IAAIA,IAAQ,wBAAwBA,KAWrEC,KACX,GACA,GAEA,MACwB;CACxB,IAAID,EAAM,SAASA,EAAM,OACvB,OAAO;CAKT,IAAME,IAAUF,EAAM,eAAe;CAErC,IAAI,CAACE,GACH,OAAO;CAKT,IAAMC,IAAWC,EAAcC,CAAY;CAE3C,IAAI,CAACF,GAAU,YAAY,SACzB,OAAO;CAGT,IAAMG,KAAQC,KAAe,OAAO,OAAOL,CAAO,EAAA,CAC/C,QAAQ,MAAyC,OAAOM,KAAiB,QAAQ,CAAC,CAClF,KAAK,MAAiB;EACrB,IAAMC,IAAMV,EAAiCS,CAAY,GACnDE,IAAUC,EAAWF,CAAG,GACxBG,IAAWF,IACbG,EAAQ,OAAOV,EAAS,YAAY,UAAUW,EAA2BJ,CAAO,EAAE,IAClF,KAAA;EAEJ,IAAKE,GAIL,OAAO;GACL,MAAMH;GACN,cAAcG;EAChB;CACF,CAAC,CAAC,CACD,OAAOG,CAAS;CAMnB,OAJIT,EAAK,WAAW,IACX,OAGF;EACL,GAAGO,EAAQ,OAAOb,CAAK;EACvB,OAAOM;CACT;AACF,GAQaU,KACX,GACA,GAOA,IAAwDhB,IACpDC,EAAqCD,GAAOG,CAAQ,IACpD,SAECH,IAIEiB,EACJ,KAAK,MACAC,MAAgB,WAAWC,IACtB;CACL;CACA,OAAOA;AACT,IAIEC,EAAiCpB,GAAOkB,CAAW,KAAKG,EAAcrB,CAAK,KAAKA,EAAM,QACjF;CACL;CACA,OAAOa,EAAQ,OAAOb,EAAM,KAAK;AACnC,IAIEA,EAAMkB,MAKJ,EAFFG,EAAcrB,CAAK,KAAKA,EAAM,SAAS,OAAOA,EAAM,SAAU,YAAYkB,KAAelB,EAAM,SAGxF;CACL;CACA,OAAOa,EAAQ,OAAOb,CAAK;AAC7B,IAIG,IACR,CAAC,CACD,OAAOe,CAAS,IApCV,CAAC"}
1
+ {"version":3,"file":"get-compositions-to-render.js","names":["normalizeDiscriminatorMappingRef","value","inferDiscriminatorMappingComposition","mapping","document","unwrapForRead","documentProp","refs","variantRefs","mappingValue","ref","refName","getRefName","refValue","resolve","unescapeJsonPointerSegment","isDefined","getCompositionsToRender","compositions","composition","inferredDiscriminatorComposition","shouldRenderArrayItemComposition","isArraySchema","hasArrayItemComposition"],"sources":["../../../src/schema/helpers/get-compositions-to-render.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { unescapeJsonPointerSegment } from '@scalar/helpers/json/unescape-json-pointer-segment'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { OpenApiDocument, 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 { getRefName } from './get-ref-name'\nimport { type CompositionKeyword, compositions } from './schema-composition'\nimport { hasArrayItemComposition, shouldRenderArrayItemComposition } from './should-render-array-item-composition'\nimport { unwrapForRead } from './unwrap-for-read'\n\ntype CompositionToRender = {\n composition: CompositionKeyword\n value: SchemaObject\n}\n\ntype DocumentSchemaLookup = Pick<OpenApiDocument, 'components'>\n\nconst normalizeDiscriminatorMappingRef = (value: string) =>\n value.startsWith('#/') || value.includes('/') ? value : `#/components/schemas/${value}`\n\n/**\n * Builds a synthetic `oneOf` composition from a `discriminator.mapping` when the\n * schema declares a mapping but no explicit `oneOf`/`anyOf`. This is the shape\n * NSwag emits for polymorphic types, where the base type is a plain object with\n * a discriminator mapping pointing at the concrete variants.\n *\n * Returns `null` when there is nothing to infer (an explicit composition is\n * already present, no document to resolve refs against, or no resolvable refs).\n */\nexport const inferDiscriminatorMappingComposition = (\n value: SchemaObject,\n documentProp?: DocumentSchemaLookup,\n /** Inheritance can supply ordered variants, including schemas that share a mapped value. */\n variantRefs?: readonly string[],\n): SchemaObject | null => {\n if (value.oneOf || value.anyOf) {\n return null\n }\n\n // A schema without a mapping can never infer anything, so it is checked before the document is\n // touched at all: the document read below is by far the more expensive of the two.\n const mapping = value.discriminator?.mapping\n\n if (!mapping) {\n return null\n }\n\n // Reading `components.schemas` per row through the reactive and detect-changes layers is the\n // dominant cost of this helper, so the document is unwrapped once here. See `unwrapForRead`.\n const document = unwrapForRead(documentProp)\n\n if (!document?.components?.schemas) {\n return null\n }\n\n const refs = (variantRefs ?? Object.values(mapping))\n .filter((mappingValue): mappingValue is string => typeof mappingValue === 'string')\n .map((mappingValue) => {\n const ref = normalizeDiscriminatorMappingRef(mappingValue)\n const refName = getRefName(ref)\n const refValue = refName\n ? resolve.schema(document.components?.schemas?.[unescapeJsonPointerSegment(refName)])\n : undefined\n\n if (!refValue) {\n return undefined\n }\n\n return {\n $ref: ref,\n '$ref-value': refValue,\n }\n })\n .filter(isDefined)\n\n if (refs.length === 0) {\n return null\n }\n\n return {\n ...resolve.schema(value),\n oneOf: refs,\n }\n}\n\n/**\n * Computes which compositions should be rendered and with which values\n *\n * @param value - The schema object to check for compositions\n * @returns Array of compositions to render with their values\n */\nexport const getCompositionsToRender = (\n value: SchemaObject | undefined,\n document?: DocumentSchemaLookup,\n /**\n * The `oneOf` inferred from a bare `discriminator.mapping`, when the caller has\n * already computed it. `SchemaProperty` needs the same value to decide whether\n * to suppress the duplicate base object block, so it passes it here to avoid\n * inferring twice. Omit it and it is inferred from `value`.\n */\n inferredDiscriminatorComposition: SchemaObject | null = value\n ? inferDiscriminatorMappingComposition(value, document)\n : null,\n): CompositionToRender[] => {\n if (!value) {\n return []\n }\n\n return compositions\n .map((composition) => {\n if (composition === 'oneOf' && inferredDiscriminatorComposition) {\n return {\n composition,\n value: inferredDiscriminatorComposition,\n }\n }\n\n // Check for array item-level composition first (more specific case)\n if (shouldRenderArrayItemComposition(value, composition) && isArraySchema(value) && value.items) {\n return {\n composition,\n value: resolve.schema(value.items),\n }\n }\n\n // Check for property-level composition\n if (value[composition] && !hasArrayItemComposition(value, composition)) {\n return {\n composition,\n value: resolve.schema(value),\n }\n }\n\n return null\n })\n .filter(isDefined)\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAMA,KAAoC,MACxCC,EAAM,WAAW,IAAI,KAAKA,EAAM,SAAS,GAAG,IAAIA,IAAQ,wBAAwBA,KAWrEC,KACX,GACA,GAEA,MACwB;CACxB,IAAID,EAAM,SAASA,EAAM,OACvB,OAAO;CAKT,IAAME,IAAUF,EAAM,eAAe;CAErC,IAAI,CAACE,GACH,OAAO;CAKT,IAAMC,IAAWC,EAAcC,CAAY;CAE3C,IAAI,CAACF,GAAU,YAAY,SACzB,OAAO;CAGT,IAAMG,KAAQC,KAAe,OAAO,OAAOL,CAAO,EAAA,CAC/C,QAAQ,MAAyC,OAAOM,KAAiB,QAAQ,CAAC,CAClF,KAAK,MAAiB;EACrB,IAAMC,IAAMV,EAAiCS,CAAY,GACnDE,IAAUC,EAAWF,CAAG,GACxBG,IAAWF,IACbG,EAAQ,OAAOV,EAAS,YAAY,UAAUW,EAA2BJ,CAAO,EAAE,IAClF,KAAA;EAEJ,IAAKE,GAIL,OAAO;GACL,MAAMH;GACN,cAAcG;EAChB;CACF,CAAC,CAAC,CACD,OAAOG,CAAS;CAMnB,OAJIT,EAAK,WAAW,IACX,OAGF;EACL,GAAGO,EAAQ,OAAOb,CAAK;EACvB,OAAOM;CACT;AACF,GAQaU,KACX,GACA,GAOA,IAAwDhB,IACpDC,EAAqCD,GAAOG,CAAQ,IACpD,SAECH,IAIEiB,EACJ,KAAK,MACAC,MAAgB,WAAWC,IACtB;CACL;CACA,OAAOA;AACT,IAIEC,EAAiCpB,GAAOkB,CAAW,KAAKG,EAAcrB,CAAK,KAAKA,EAAM,QACjF;CACL;CACA,OAAOa,EAAQ,OAAOb,EAAM,KAAK;AACnC,IAIEA,EAAMkB,MAAgB,CAACI,EAAwBtB,GAAOkB,CAAW,IAC5D;CACL;CACA,OAAOL,EAAQ,OAAOb,CAAK;AAC7B,IAGK,IACR,CAAC,CACD,OAAOe,CAAS,IA9BV,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { resolveDisplaySchema } from './dynamic-scope';
1
2
  export { inferDiscriminatorMappingComposition } from './get-compositions-to-render';
2
3
  export { getRefName } from './get-ref-name';
3
4
  export { type RenderedExample, getRenderedExample, normalizeRenderedExamples } from './get-rendered-example';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
@@ -1,13 +1,14 @@
1
- import { inferDiscriminatorMappingComposition as e } from "./get-compositions-to-render.js";
2
- import { getRefName as t } from "./get-ref-name.js";
3
- import { getRenderedExample as n, normalizeRenderedExamples as r } from "./get-rendered-example.js";
4
- import { getSchemaType as i } from "./get-schema-type.js";
5
- import { getTypeSignatureTokens as a } from "./get-type-signature-tokens.js";
6
- import { hasComplexArrayItems as o } from "./has-complex-array-items.js";
7
- import { isModelLinkable as s } from "./is-model-linkable.js";
8
- import { isTypeObject as c } from "./is-type-object.js";
9
- import { optimizeValueForDisplay as l } from "./optimize-value-for-display.js";
10
- import { handleTreeKeydown as u } from "./schema-keyboard-nav.js";
11
- import { getModelNameFromSchema as d, getModelNameWithArray as f } from "./schema-name.js";
12
- import { reduceNamesToObject as p, sortPropertyNames as m } from "./sort-property-names.js";
13
- export { d as getModelNameFromSchema, f as getModelNameWithArray, t as getRefName, n as getRenderedExample, i as getSchemaType, a as getTypeSignatureTokens, u as handleTreeKeydown, o as hasComplexArrayItems, e as inferDiscriminatorMappingComposition, s as isModelLinkable, c as isTypeObject, r as normalizeRenderedExamples, l as optimizeValueForDisplay, p as reduceNamesToObject, m as sortPropertyNames };
1
+ import { resolveDisplaySchema as e } from "./dynamic-scope.js";
2
+ import { inferDiscriminatorMappingComposition as t } from "./get-compositions-to-render.js";
3
+ import { getRefName as n } from "./get-ref-name.js";
4
+ import { getRenderedExample as r, normalizeRenderedExamples as i } from "./get-rendered-example.js";
5
+ import { getSchemaType as a } from "./get-schema-type.js";
6
+ import { getTypeSignatureTokens as o } from "./get-type-signature-tokens.js";
7
+ import { hasComplexArrayItems as s } from "./has-complex-array-items.js";
8
+ import { isModelLinkable as c } from "./is-model-linkable.js";
9
+ import { isTypeObject as l } from "./is-type-object.js";
10
+ import { optimizeValueForDisplay as u } from "./optimize-value-for-display.js";
11
+ import { handleTreeKeydown as d } from "./schema-keyboard-nav.js";
12
+ import { getModelNameFromSchema as f, getModelNameWithArray as p } from "./schema-name.js";
13
+ import { reduceNamesToObject as m, sortPropertyNames as h } from "./sort-property-names.js";
14
+ export { f as getModelNameFromSchema, p as getModelNameWithArray, n as getRefName, r as getRenderedExample, a as getSchemaType, o as getTypeSignatureTokens, d as handleTreeKeydown, s as hasComplexArrayItems, t as inferDiscriminatorMappingComposition, c as isModelLinkable, l as isTypeObject, i as normalizeRenderedExamples, u as optimizeValueForDisplay, m as reduceNamesToObject, e as resolveDisplaySchema, h as sortPropertyNames };
@@ -1 +1 @@
1
- {"version":3,"file":"partition-all-of-compositions.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,8DAA8D,CAAA;AAGrH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,KAAK,aAAa,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAA;AAEnE,iFAAiF;AACjF,KAAK,YAAY,GACb;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GACxC;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,WAAW,EAAE,aAAa,CAAA;IAC1B,qFAAqF;IACrF,KAAK,EAAE,YAAY,CAAA;IACnB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AA+FL;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,YAAY,GAAG,SAAS,KAAG;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CAsFvG,CAAA"}
1
+ {"version":3,"file":"partition-all-of-compositions.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,8DAA8D,CAAA;AAGrH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,KAAK,aAAa,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAA;AAEnE,iFAAiF;AACjF,KAAK,YAAY,GACb;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GACxC;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,WAAW,EAAE,aAAa,CAAA;IAC1B,qFAAqF;IACrF,KAAK,EAAE,YAAY,CAAA;IACnB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AA+FL;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,YAAY,GAAG,SAAS,KAAG;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CA0GvG,CAAA"}
@@ -49,29 +49,39 @@ var r = ["oneOf", "anyOf"], i = (e, a, o) => {
49
49
  kind: "object",
50
50
  schema: d
51
51
  });
52
- let p = "$ref" in t ? t.$ref : void 0, m = new Set(typeof p == "string" ? [p] : []);
53
- for (let e of r) if (typeof e == "boolean" || e && typeof e == "object") {
54
- let t = n.schema(e).$ref;
55
- i(e, f, typeof t == "string" ? new Set(m).add(t) : m);
52
+ let p = f.length, m = typeof d.description == "string" ? d.description : void 0, h = "$ref" in t ? t.$ref : void 0, g = new Set(typeof h == "string" ? [h] : []), _ = !1;
53
+ for (let [e, t] of r.entries()) if (typeof t == "boolean" || t && typeof t == "object") {
54
+ let r = n.schema(t), a = r.$ref;
55
+ i(t, f, typeof a == "string" ? new Set(g).add(a) : g), e === 0 && (_ = !!(r.oneOf?.length || r.anyOf?.length || f[p]?.kind === "choice"));
56
56
  }
57
- let h = [], g = [], _ = 0, v = () => {
58
- if (g.length === 0) return;
59
- let t = g.length === 1 ? g[0] : e({ allOf: g });
60
- h.push({
57
+ let v = [], y = [], b = 0, x = () => {
58
+ if (y.length === 0) return;
59
+ let t = y.length === 1 ? y[0] : e({ allOf: y }), n = y[0] === d, r = t;
60
+ if (m !== void 0) {
61
+ if (n && t.description !== m) r = {
62
+ ...t,
63
+ description: m
64
+ };
65
+ else if (!n && !_ && t.description !== void 0) {
66
+ let { description: e, ...n } = t;
67
+ r = n;
68
+ }
69
+ }
70
+ v.push({
61
71
  kind: "object",
62
- schema: t
63
- }), g = [];
72
+ schema: r
73
+ }), y = [];
64
74
  };
65
- for (let e of f) e.kind === "object" ? g.push(e.schema) : e.kind === "boolean" ? (v(), h.push({
75
+ for (let e of f) e.kind === "object" ? y.push(e.schema) : e.kind === "boolean" ? (x(), v.push({
66
76
  kind: "object",
67
77
  schema: e.schema
68
- })) : e.inheritedSelection ? _++ : (v(), h.push({
78
+ })) : e.inheritedSelection ? b++ : (x(), v.push({
69
79
  kind: "choice",
70
80
  composition: e.composition,
71
81
  value: e.value,
72
- choiceIndex: _++
82
+ choiceIndex: b++
73
83
  }));
74
- return v(), { segments: h };
84
+ return x(), { segments: v };
75
85
  };
76
86
  export { a as partitionAllOfCompositions };
77
87
 
@@ -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","schemaRef","segments","objectRun","choiceIndex","flushObjectRun","merged","mergeAllOfSchemas","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 schemaRef = '$ref' in schema ? schema.$ref : undefined\n const seenRefs = new Set<string>(typeof schemaRef === 'string' ? [schemaRef] : [])\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 const ref = resolved.$ref\n collectMembers(rawMember, members, typeof ref === 'string' ? new Set(seenRefs).add(ref) : seenRefs)\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 = () => {\n if (objectRun.length === 0) {\n return\n }\n const merged = objectRun.length === 1 ? objectRun[0]! : mergeAllOfSchemas({ allOf: objectRun } as SchemaObject)\n segments.push({ kind: 'object', schema: merged })\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,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S;AACpB"}
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,EAAQ,OAAOD,CAkB1B;CAEJ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,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,4 +1,6 @@
1
1
  import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
+ /** Whether the array declares the composition on its item schema. */
3
+ export declare const hasArrayItemComposition: (schema: SchemaObject | undefined, composition: string) => boolean;
2
4
  /**
3
5
  * Check if array item composition should be rendered
4
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"should-render-array-item-composition.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/should-render-array-item-composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAKhG;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,OAcxG,CAAA"}
1
+ {"version":3,"file":"should-render-array-item-composition.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/should-render-array-item-composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAKhG,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,OAG7F,CAAA;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,OAC1B,CAAA"}
@@ -1,11 +1,7 @@
1
1
  import { hasComplexArrayItems as e } from "./has-complex-array-items.js";
2
2
  import { isArraySchema as t } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
3
3
  // src/schema/helpers/should-render-array-item-composition.ts
4
- var n = (n, r) => {
5
- if (!n || !t(n)) return !1;
6
- let i = n.items;
7
- return !i || typeof i != "object" || !(r in i) ? !1 : !e(n);
8
- };
9
- export { n as shouldRenderArrayItemComposition };
4
+ var n = (e, n) => !!(e && t(e) && e.items && typeof e.items == "object" && n in e.items), r = (t, r) => n(t, r) && !e(t);
5
+ export { n as hasArrayItemComposition, r as shouldRenderArrayItemComposition };
10
6
 
11
7
  //# sourceMappingURL=should-render-array-item-composition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-render-array-item-composition.js","names":["shouldRenderArrayItemComposition","schema","isArraySchema","items","composition","hasComplexArrayItems"],"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/**\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 // Early return if schema is invalid or not an array\n if (!schema || !isArraySchema(schema)) {\n return false\n }\n\n // Check if items exist and have the composition keyword\n const items = schema.items\n if (!items || typeof items !== 'object' || !(composition in items)) {\n return false\n }\n\n // Only render if items are not complex (complex items are handled differently)\n return !hasComplexArrayItems(schema)\n}\n"],"mappings":";;;AAYA,IAAaA,KAAoC,GAAkC,MAAiC;CAElH,IAAI,CAACC,KAAU,CAACC,EAAcD,CAAM,GAClC,OAAO;CAIT,IAAME,IAAQF,EAAO;CAMrB,OALI,CAACE,KAAS,OAAOA,KAAU,YAAY,EAAEC,KAAeD,KACnD,KAIF,CAACE,EAAqBJ,CAAM;AACrC"}
1
+ {"version":3,"file":"should-render-array-item-composition.js","names":["hasArrayItemComposition","schema","isArraySchema","composition","shouldRenderArrayItemComposition","hasComplexArrayItems"],"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,IAAaA,KAA2B,GAAkC,MACxE,GACEC,KAAUC,EAAcD,CAAM,KAAKA,EAAO,SAAS,OAAOA,EAAO,SAAU,YAAYE,KAAeF,EAAO,QAUpGG,KAAoC,GAAkC,MACjFJ,EAAwBC,GAAQE,CAAW,KAAK,CAACE,EAAqBJ,CAAM"}
@@ -66,5 +66,5 @@ export declare const useLocalization: () => import("@scalar/localization").Local
66
66
  actions: {
67
67
  copyLinkTo: string;
68
68
  };
69
- }, ("schema.keys" | "schema.values" | "schema.allOf" | "schema.schema" | "schema.default" | "schema.enum" | "schema.const" | "schema.deprecated" | "schema.discriminator" | "schema.readOnly" | "schema.writeOnly" | "schema.example" | "schema.examples" | "schema.oneOf" | "schema.anyOf" | "schema.not" | "schema.type" | "schema.format" | "schema.multipleOf" | "schema.maxLength" | "schema.minLength" | "schema.pattern" | "schema.required" | "schema.additionalProperties" | "schema.propertyNames" | "schema.nullable" | "schema.recursive" | "schema.max" | "schema.min" | "schema.unique" | "schema.variants" | "schema.discriminatorValue" | "schema.noAllowedValues" | "schema.emptyObject" | "schema.showAdditionalProperties" | "schema.showOneMoreProperty" | "schema.showMoreProperties" | "schema.forName" | "schema.showSchemaDetails" | "schema.unknownType" | "schema.propertyCount" | "schema.headerCount" | "schema.extensionCount" | "schema.recursiveReference" | "schema.greaterThan" | "schema.lessThan" | "schema.copyPattern" | "schema.hideValues" | "schema.showAllValues" | "schema.typeInteger" | "schema.formatInt32" | "schema.formatInt64" | "schema.formatDate" | "schema.formatDateTime" | "schema.formatPassword" | "schema.formatBase64" | "schema.formatBinary") | "actions.copyLinkTo" | "common.copyDefault" | "common.copyExample">;
69
+ }, ("schema.keys" | "schema.values" | "schema.allOf" | "schema.schema" | "schema.default" | "schema.enum" | "schema.const" | "schema.deprecated" | "schema.discriminator" | "schema.readOnly" | "schema.writeOnly" | "schema.example" | "schema.examples" | "schema.oneOf" | "schema.anyOf" | "schema.not" | "schema.type" | "schema.format" | "schema.multipleOf" | "schema.maxLength" | "schema.minLength" | "schema.pattern" | "schema.required" | "schema.additionalProperties" | "schema.propertyNames" | "schema.variants" | "schema.discriminatorValue" | "schema.noAllowedValues" | "schema.emptyObject" | "schema.showAdditionalProperties" | "schema.showOneMoreProperty" | "schema.showMoreProperties" | "schema.forName" | "schema.showSchemaDetails" | "schema.unknownType" | "schema.propertyCount" | "schema.headerCount" | "schema.extensionCount" | "schema.recursiveReference" | "schema.recursive" | "schema.greaterThan" | "schema.lessThan" | "schema.max" | "schema.min" | "schema.nullable" | "schema.copyPattern" | "schema.hideValues" | "schema.showAllValues" | "schema.unique" | "schema.typeInteger" | "schema.formatInt32" | "schema.formatInt64" | "schema.formatDate" | "schema.formatDateTime" | "schema.formatPassword" | "schema.formatBase64" | "schema.formatBinary") | "common.copyDefault" | "common.copyExample" | "actions.copyLinkTo">;
70
70
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ type __VLS_Props = {
2
+ /** Show the error message and Retry button after the download fails. */
3
+ failed: boolean;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ retry: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onRetry?: (() => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
12
+ //# sourceMappingURL=ExternalExampleStatus.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExternalExampleStatus.vue.d.ts","sourceRoot":"","sources":["../../src/shared/ExternalExampleStatus.vue"],"names":[],"mappings":"AAoCA,KAAK,WAAW,GAAG;IACjB,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC;AA2EF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,6 @@
1
+ import e from "./ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js";
2
+ // src/shared/ExternalExampleStatus.vue
3
+ var t = e;
4
+ export { t as default };
5
+
6
+ //# sourceMappingURL=ExternalExampleStatus.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExternalExampleStatus.vue.js","names":["ExternalExampleStatus_vue_vue_type_script_setup_true_lang_default","ExternalExampleStatus_default"],"sources":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { useExternalExampleLocalization as e } from "./external-example-localization/index.js";
2
+ import { Fragment as t, createElementBlock as n, createTextVNode as r, createVNode as i, defineComponent as a, openBlock as o, toDisplayString as s, unref as c, withCtx as l } from "vue";
3
+ import { ScalarButton as u } from "@scalar/components/button";
4
+ // src/shared/ExternalExampleStatus.vue?vue&type=script&setup=true&lang.ts
5
+ var d = {
6
+ class: "text-c-2 p-4",
7
+ role: "status"
8
+ }, f = /*@__PURE__*/ a({
9
+ __name: "ExternalExampleStatus",
10
+ props: { failed: { type: Boolean } },
11
+ emits: ["retry"],
12
+ setup(a, { emit: f }) {
13
+ let p = f, { translate: m } = e();
14
+ return (e, f) => (o(), n("div", d, [a.failed ? (o(), n(t, { key: 0 }, [r(s(c(m)("externalExample.loadFailed")) + " ", 1), i(c(u), {
15
+ size: "sm",
16
+ variant: "ghost",
17
+ onClick: f[0] ||= (e) => p("retry")
18
+ }, {
19
+ default: l(() => [r(s(c(m)("externalExample.retry")), 1)]),
20
+ _: 1
21
+ })], 64)) : (o(), n(t, { key: 1 }, [r(s(c(m)("externalExample.loading")), 1)], 64))]));
22
+ }
23
+ });
24
+ export { f as default };
25
+
26
+ //# sourceMappingURL=ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString","_unref","_createVNode","_withCtx","_hoisted_1","ExternalExampleStatus_vue_vue_type_script_setup_true_lang_default","__emit","emit","useExternalExampleLocalization","openBlock","createElementBlock","__props","Fragment","createTextVNode","toDisplayString","unref","translate","createVNode","ScalarButton","_cache","withCtx"],"sources":["../../src/shared/ExternalExampleStatus.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\n\nimport { useExternalExampleLocalization } from './external-example-localization'\n\nconst { failed } = defineProps<{\n /** Show the error message and Retry button after the download fails. */\n failed: boolean\n}>()\nconst emit = defineEmits<{ retry: [] }>()\n\nconst { translate } = useExternalExampleLocalization()\n</script>\n<template>\n <div\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"failed\">\n {{ translate('externalExample.loadFailed') }}\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('retry')\">\n {{ translate('externalExample.retry') }}\n </ScalarButton>\n </template>\n <template v-else>{{ translate('externalExample.loading') }}</template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;EASA,IAAMW,IAAOD,GAEP,EAAE,iBAAcE,EAA+B;E,kBAGnDZ,EAAA,GAAAC,EAaM,OAbNO,GAaM,CAVYO,EAAA,UAAhBf,EAAA,GAAAC,EAQWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAPNC,EAAAC,EAAAC,EAAAe,CAAA,CAAS,CAAA,4BAAA,CAAA,IAAiC,KAC7C,CAAA,GAAAd,EAKeD,EAAAiB,CAAA,GAAA;GAJb,MAAK;GACL,SAAQ;GACP,SAAK,AAAAC,EAAA,QAAA,MAAEZ,EAAI,OAAA;;GACZ,SAAAJ,QAAwC,CAArCJ,EAAAC,EAAAC,EAAAe,CAAA,CAAS,CAAA,uBAAA,CAAA,GAAA,CAAA,C;;E,aAGhBpB,EAAA,GAAAC,EAAsEC,GAAA,EAAA,KAAA,EAAA,GAAA,CAAlDC,EAAAC,EAAAC,EAAAe,CAAA,CAAS,CAAA,yBAAA,CAAA,GAAA,CAAA,C"}
@@ -0,0 +1,4 @@
1
+ import type { ApiReferenceTranslations } from '@scalar/types/api-reference';
2
+ /** Inherits the host locale and overrides, with an English fallback for standalone blocks. */
3
+ export declare const useExternalExampleLocalization: () => import("@scalar/localization").LocalizationContext<Pick<ApiReferenceTranslations, "externalExample">, "externalExample.loading" | "externalExample.loadFailed" | "externalExample.retry">;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/external-example-localization/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAIvG,8FAA8F;AAC9F,eAAO,MAAyB,8BAA8B,iMAQ5D,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { externalExampleTranslations as e } from "./translations.js";
2
+ import { createLocalization as t } from "@scalar/localization";
3
+ // src/shared/external-example-localization/index.ts
4
+ var { useLocalization: n } = t({
5
+ localeTranslations: e,
6
+ defaultLocale: "en",
7
+ rtlLocales: /* @__PURE__ */ new Set([
8
+ "ar",
9
+ "fa",
10
+ "he",
11
+ "ur"
12
+ ]),
13
+ logPrefix: "[@scalar/blocks/external-example]"
14
+ });
15
+ export { n as useExternalExampleLocalization };
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useExternalExampleLocalization","createLocalization","externalExampleTranslations"],"sources":["../../../src/shared/external-example-localization/index.ts"],"sourcesContent":["import { createLocalization } from '@scalar/localization'\nimport type { ApiReferenceTranslationKey, ApiReferenceTranslations } from '@scalar/types/api-reference'\n\nimport { externalExampleTranslations } from './translations'\n\n/** Inherits the host locale and overrides, with an English fallback for standalone blocks. */\nexport const { useLocalization: useExternalExampleLocalization } = createLocalization<\n Pick<ApiReferenceTranslations, 'externalExample'>,\n Extract<ApiReferenceTranslationKey, `externalExample.${string}`>\n>({\n localeTranslations: externalExampleTranslations,\n defaultLocale: 'en',\n rtlLocales: new Set(['ar', 'fa', 'he', 'ur']),\n logPrefix: '[@scalar/blocks/external-example]',\n})\n"],"mappings":";;;AAMA,IAAa,EAAE,iBAAiBA,MAAmCC,EAGjE;CACA,oBAAoBC;CACpB,eAAe;CACf,4BAAY,IAAI,IAAI;EAAC;EAAM;EAAM;EAAM;CAAI,CAAC;CAC5C,WAAW;AACb,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const ar: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=ar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ar.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/ar.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/ar.ts
2
+ var e = { externalExample: {
3
+ loading: "جارٍ تحميل المثال…",
4
+ loadFailed: "تعذّر تحميل هذا المثال.",
5
+ retry: "إعادة المحاولة"
6
+ } };
7
+ export { e as ar };
8
+
9
+ //# sourceMappingURL=ar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ar.js","names":["ar"],"sources":["../../../../src/shared/external-example-localization/locales/ar.ts"],"sourcesContent":["export const ar = {\n externalExample: {\n loading: 'جارٍ تحميل المثال…',\n loadFailed: 'تعذّر تحميل هذا المثال.',\n retry: 'إعادة المحاولة',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const de: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=de.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/de.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/de.ts
2
+ var e = { externalExample: {
3
+ loading: "Beispiel wird geladen…",
4
+ loadFailed: "Das Beispiel konnte nicht geladen werden.",
5
+ retry: "Erneut versuchen"
6
+ } };
7
+ export { e as de };
8
+
9
+ //# sourceMappingURL=de.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de.js","names":["de"],"sources":["../../../../src/shared/external-example-localization/locales/de.ts"],"sourcesContent":["export const de = {\n externalExample: {\n loading: 'Beispiel wird geladen…',\n loadFailed: 'Das Beispiel konnte nicht geladen werden.',\n retry: 'Erneut versuchen',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const en: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=en.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/en.ts
2
+ var e = { externalExample: {
3
+ loading: "Loading example…",
4
+ loadFailed: "Could not load this example.",
5
+ retry: "Retry"
6
+ } };
7
+ export { e as en };
8
+
9
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","names":["en"],"sources":["../../../../src/shared/external-example-localization/locales/en.ts"],"sourcesContent":["export const en = {\n externalExample: {\n loading: 'Loading example…',\n loadFailed: 'Could not load this example.',\n retry: 'Retry',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const es: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=es.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/es.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/es.ts
2
+ var e = { externalExample: {
3
+ loading: "Cargando ejemplo…",
4
+ loadFailed: "No se pudo cargar este ejemplo.",
5
+ retry: "Reintentar"
6
+ } };
7
+ export { e as es };
8
+
9
+ //# sourceMappingURL=es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"es.js","names":["es"],"sources":["../../../../src/shared/external-example-localization/locales/es.ts"],"sourcesContent":["export const es = {\n externalExample: {\n loading: 'Cargando ejemplo…',\n loadFailed: 'No se pudo cargar este ejemplo.',\n retry: 'Reintentar',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const fr: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=fr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/fr.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/fr.ts
2
+ var e = { externalExample: {
3
+ loading: "Chargement de l’exemple…",
4
+ loadFailed: "Impossible de charger cet exemple.",
5
+ retry: "Réessayer"
6
+ } };
7
+ export { e as fr };
8
+
9
+ //# sourceMappingURL=fr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fr.js","names":["fr"],"sources":["../../../../src/shared/external-example-localization/locales/fr.ts"],"sourcesContent":["export const fr = {\n externalExample: {\n loading: 'Chargement de l’exemple…',\n loadFailed: 'Impossible de charger cet exemple.',\n retry: 'Réessayer',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const pt: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=pt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pt.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/pt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/pt.ts
2
+ var e = { externalExample: {
3
+ loading: "Carregando exemplo…",
4
+ loadFailed: "Não foi possível carregar este exemplo.",
5
+ retry: "Tentar novamente"
6
+ } };
7
+ export { e as pt };
8
+
9
+ //# sourceMappingURL=pt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pt.js","names":["pt"],"sources":["../../../../src/shared/external-example-localization/locales/pt.ts"],"sourcesContent":["export const pt = {\n externalExample: {\n loading: 'Carregando exemplo…',\n loadFailed: 'Não foi possível carregar este exemplo.',\n retry: 'Tentar novamente',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const ru: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=ru.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ru.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/ru.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;CAMd,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/ru.ts
2
+ var e = { externalExample: {
3
+ loading: "Загрузка примера…",
4
+ loadFailed: "Не удалось загрузить этот пример.",
5
+ retry: "Повторить попытку"
6
+ } };
7
+ export { e as ru };
8
+
9
+ //# sourceMappingURL=ru.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ru.js","names":["ru"],"sources":["../../../../src/shared/external-example-localization/locales/ru.ts"],"sourcesContent":["export const ru = {\n externalExample: {\n loading: 'Загрузка примера…',\n loadFailed: 'Не удалось загрузить этот пример.',\n retry: 'Повторить попытку',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAK,EAChB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}
@@ -0,0 +1,8 @@
1
+ export declare const zhCn: {
2
+ externalExample: {
3
+ loading: string;
4
+ loadFailed: string;
5
+ retry: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=zh-cn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zh-cn.d.ts","sourceRoot":"","sources":["../../../../src/shared/external-example-localization/locales/zh-cn.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;;;CAMhB,CAAA"}
@@ -0,0 +1,9 @@
1
+ // src/shared/external-example-localization/locales/zh-cn.ts
2
+ var e = { externalExample: {
3
+ loading: "正在加载示例…",
4
+ loadFailed: "无法加载此示例。",
5
+ retry: "重试"
6
+ } };
7
+ export { e as zhCn };
8
+
9
+ //# sourceMappingURL=zh-cn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zh-cn.js","names":["zhCn"],"sources":["../../../../src/shared/external-example-localization/locales/zh-cn.ts"],"sourcesContent":["export const zhCn = {\n externalExample: {\n loading: '正在加载示例…',\n loadFailed: '无法加载此示例。',\n retry: '重试',\n },\n}\n"],"mappings":";AAAA,IAAaA,IAAO,EAClB,iBAAiB;CACf,SAAS;CACT,YAAY;CACZ,OAAO;AACT,EACF"}