@scalar/blocks 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +45 -0
  3. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  4. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +1 -0
  5. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  6. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  7. package/dist/code-example/helpers/operation-to-har/process-body.js +51 -45
  8. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  9. package/dist/constants.js +1 -1
  10. package/dist/schema/LinkButton.vue.d.ts +14 -0
  11. package/dist/schema/LinkButton.vue.d.ts.map +1 -0
  12. package/dist/schema/LinkButton.vue.js +15 -0
  13. package/dist/schema/LinkButton.vue.js.map +1 -0
  14. package/dist/schema/RenderString.vue.d.ts +7 -0
  15. package/dist/schema/RenderString.vue.d.ts.map +1 -0
  16. package/dist/schema/RenderString.vue.js +7 -0
  17. package/dist/schema/RenderString.vue.js.map +1 -0
  18. package/dist/schema/RenderString.vue.script.js +14 -0
  19. package/dist/schema/RenderString.vue.script.js.map +1 -0
  20. package/dist/schema/Schema.vue.d.ts +50 -0
  21. package/dist/schema/Schema.vue.d.ts.map +1 -0
  22. package/dist/schema/Schema.vue.js +9 -0
  23. package/dist/schema/Schema.vue.js.map +1 -0
  24. package/dist/schema/Schema.vue.script.js +234 -0
  25. package/dist/schema/Schema.vue.script.js.map +1 -0
  26. package/dist/schema/SchemaCollapsedPreview.vue.d.ts +17 -0
  27. package/dist/schema/SchemaCollapsedPreview.vue.d.ts.map +1 -0
  28. package/dist/schema/SchemaCollapsedPreview.vue.js +7 -0
  29. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -0
  30. package/dist/schema/SchemaCollapsedPreview.vue.script.js +28 -0
  31. package/dist/schema/SchemaCollapsedPreview.vue.script.js.map +1 -0
  32. package/dist/schema/SchemaComposition.vue.d.ts +42 -0
  33. package/dist/schema/SchemaComposition.vue.d.ts.map +1 -0
  34. package/dist/schema/SchemaComposition.vue.js +9 -0
  35. package/dist/schema/SchemaComposition.vue.js.map +1 -0
  36. package/dist/schema/SchemaComposition.vue.script.js +231 -0
  37. package/dist/schema/SchemaComposition.vue.script.js.map +1 -0
  38. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts +8 -0
  39. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts.map +1 -0
  40. package/dist/schema/SchemaEnumPropertyItem.vue.js +7 -0
  41. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -0
  42. package/dist/schema/SchemaEnumPropertyItem.vue.script.js +24 -0
  43. package/dist/schema/SchemaEnumPropertyItem.vue.script.js.map +1 -0
  44. package/dist/schema/SchemaEnums.vue.d.ts +11 -0
  45. package/dist/schema/SchemaEnums.vue.d.ts.map +1 -0
  46. package/dist/schema/SchemaEnums.vue.js +9 -0
  47. package/dist/schema/SchemaEnums.vue.js.map +1 -0
  48. package/dist/schema/SchemaEnums.vue.script.js +78 -0
  49. package/dist/schema/SchemaEnums.vue.script.js.map +1 -0
  50. package/dist/schema/SchemaGlyphPuck.vue.d.ts +33 -0
  51. package/dist/schema/SchemaGlyphPuck.vue.d.ts.map +1 -0
  52. package/dist/schema/SchemaGlyphPuck.vue.js +7 -0
  53. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -0
  54. package/dist/schema/SchemaGlyphPuck.vue.script.js +30 -0
  55. package/dist/schema/SchemaGlyphPuck.vue.script.js.map +1 -0
  56. package/dist/schema/SchemaGutterToggle.vue.d.ts +32 -0
  57. package/dist/schema/SchemaGutterToggle.vue.d.ts.map +1 -0
  58. package/dist/schema/SchemaGutterToggle.vue.js +7 -0
  59. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -0
  60. package/dist/schema/SchemaGutterToggle.vue.script.js +43 -0
  61. package/dist/schema/SchemaGutterToggle.vue.script.js.map +1 -0
  62. package/dist/schema/SchemaHeading.vue.d.ts +9 -0
  63. package/dist/schema/SchemaHeading.vue.d.ts.map +1 -0
  64. package/dist/schema/SchemaHeading.vue.js +9 -0
  65. package/dist/schema/SchemaHeading.vue.js.map +1 -0
  66. package/dist/schema/SchemaHeading.vue.script.js +35 -0
  67. package/dist/schema/SchemaHeading.vue.script.js.map +1 -0
  68. package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts +8 -0
  69. package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts.map +1 -0
  70. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +7 -0
  71. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -0
  72. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js +48 -0
  73. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js.map +1 -0
  74. package/dist/schema/SchemaObjectProperties.vue.d.ts +22 -0
  75. package/dist/schema/SchemaObjectProperties.vue.d.ts.map +1 -0
  76. package/dist/schema/SchemaObjectProperties.vue.js +7 -0
  77. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -0
  78. package/dist/schema/SchemaObjectProperties.vue.script.js +207 -0
  79. package/dist/schema/SchemaObjectProperties.vue.script.js.map +1 -0
  80. package/dist/schema/SchemaProperty.vue.d.ts +88 -0
  81. package/dist/schema/SchemaProperty.vue.d.ts.map +1 -0
  82. package/dist/schema/SchemaProperty.vue.js +9 -0
  83. package/dist/schema/SchemaProperty.vue.js.map +1 -0
  84. package/dist/schema/SchemaProperty.vue.script.js +456 -0
  85. package/dist/schema/SchemaProperty.vue.script.js.map +1 -0
  86. package/dist/schema/SchemaPropertyDefault.vue.d.ts +7 -0
  87. package/dist/schema/SchemaPropertyDefault.vue.d.ts.map +1 -0
  88. package/dist/schema/SchemaPropertyDefault.vue.js +9 -0
  89. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -0
  90. package/dist/schema/SchemaPropertyDefault.vue.script.js +64 -0
  91. package/dist/schema/SchemaPropertyDefault.vue.script.js.map +1 -0
  92. package/dist/schema/SchemaPropertyDetail.vue.d.ts +22 -0
  93. package/dist/schema/SchemaPropertyDetail.vue.d.ts.map +1 -0
  94. package/dist/schema/SchemaPropertyDetail.vue.js +9 -0
  95. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -0
  96. package/dist/schema/SchemaPropertyDetail.vue.script.js +25 -0
  97. package/dist/schema/SchemaPropertyDetail.vue.script.js.map +1 -0
  98. package/dist/schema/SchemaPropertyExamples.vue.d.ts +8 -0
  99. package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -0
  100. package/dist/schema/SchemaPropertyExamples.vue.js +9 -0
  101. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -0
  102. package/dist/schema/SchemaPropertyExamples.vue.script.js +125 -0
  103. package/dist/schema/SchemaPropertyExamples.vue.script.js.map +1 -0
  104. package/dist/schema/SchemaPropertyHeading.vue.d.ts +59 -0
  105. package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -0
  106. package/dist/schema/SchemaPropertyHeading.vue.js +9 -0
  107. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -0
  108. package/dist/schema/SchemaPropertyHeading.vue.script.js +270 -0
  109. package/dist/schema/SchemaPropertyHeading.vue.script.js.map +1 -0
  110. package/dist/schema/SchemaPropertyPattern.vue.d.ts +7 -0
  111. package/dist/schema/SchemaPropertyPattern.vue.d.ts.map +1 -0
  112. package/dist/schema/SchemaPropertyPattern.vue.js +9 -0
  113. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -0
  114. package/dist/schema/SchemaPropertyPattern.vue.script.js +45 -0
  115. package/dist/schema/SchemaPropertyPattern.vue.script.js.map +1 -0
  116. package/dist/schema/SchemaRailPanel.vue.d.ts +35 -0
  117. package/dist/schema/SchemaRailPanel.vue.d.ts.map +1 -0
  118. package/dist/schema/SchemaRailPanel.vue.js +7 -0
  119. package/dist/schema/SchemaRailPanel.vue.js.map +1 -0
  120. package/dist/schema/SchemaRailPanel.vue.script.js +49 -0
  121. package/dist/schema/SchemaRailPanel.vue.script.js.map +1 -0
  122. package/dist/schema/components/CopyLinkButton.vue.d.ts +27 -0
  123. package/dist/schema/components/CopyLinkButton.vue.d.ts.map +1 -0
  124. package/dist/schema/components/CopyLinkButton.vue.js +7 -0
  125. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -0
  126. package/dist/schema/components/CopyLinkButton.vue.script.js +26 -0
  127. package/dist/schema/components/CopyLinkButton.vue.script.js.map +1 -0
  128. package/dist/schema/components/WithBreadcrumb.vue.d.ts +19 -0
  129. package/dist/schema/components/WithBreadcrumb.vue.d.ts.map +1 -0
  130. package/dist/schema/components/WithBreadcrumb.vue.js +7 -0
  131. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -0
  132. package/dist/schema/components/WithBreadcrumb.vue.script.js +18 -0
  133. package/dist/schema/components/WithBreadcrumb.vue.script.js.map +1 -0
  134. package/dist/schema/expansion/index.d.ts +2 -0
  135. package/dist/schema/expansion/index.d.ts.map +1 -0
  136. package/dist/schema/expansion/index.js +2 -0
  137. package/dist/schema/helpers/dynamic-scope.d.ts +27 -0
  138. package/dist/schema/helpers/dynamic-scope.d.ts.map +1 -0
  139. package/dist/schema/helpers/dynamic-scope.js +8 -0
  140. package/dist/schema/helpers/dynamic-scope.js.map +1 -0
  141. package/dist/schema/helpers/format-example.d.ts +5 -0
  142. package/dist/schema/helpers/format-example.d.ts.map +1 -0
  143. package/dist/schema/helpers/format-example.js +12 -0
  144. package/dist/schema/helpers/format-example.js.map +1 -0
  145. package/dist/schema/helpers/format-value.d.ts +5 -0
  146. package/dist/schema/helpers/format-value.d.ts.map +1 -0
  147. package/dist/schema/helpers/format-value.js +8 -0
  148. package/dist/schema/helpers/format-value.js.map +1 -0
  149. package/dist/schema/helpers/get-compositions-to-render.d.ts +33 -0
  150. package/dist/schema/helpers/get-compositions-to-render.d.ts.map +1 -0
  151. package/dist/schema/helpers/get-compositions-to-render.js +39 -0
  152. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -0
  153. package/dist/schema/helpers/get-discriminator-values.d.ts +4 -0
  154. package/dist/schema/helpers/get-discriminator-values.d.ts.map +1 -0
  155. package/dist/schema/helpers/get-discriminator-values.js +6 -0
  156. package/dist/schema/helpers/get-discriminator-values.js.map +1 -0
  157. package/dist/schema/helpers/get-enum-values.d.ts +9 -0
  158. package/dist/schema/helpers/get-enum-values.d.ts.map +1 -0
  159. package/dist/schema/helpers/get-enum-values.js +16 -0
  160. package/dist/schema/helpers/get-enum-values.js.map +1 -0
  161. package/dist/schema/helpers/get-property-description.d.ts +9 -0
  162. package/dist/schema/helpers/get-property-description.d.ts.map +1 -0
  163. package/dist/schema/helpers/get-property-description.js +27 -0
  164. package/dist/schema/helpers/get-property-description.js.map +1 -0
  165. package/dist/schema/helpers/get-ref-name.d.ts +24 -0
  166. package/dist/schema/helpers/get-ref-name.d.ts.map +1 -0
  167. package/dist/schema/helpers/get-ref-name.js +15 -0
  168. package/dist/schema/helpers/get-ref-name.js.map +1 -0
  169. package/dist/schema/helpers/get-schema-type.d.ts +13 -0
  170. package/dist/schema/helpers/get-schema-type.d.ts.map +1 -0
  171. package/dist/schema/helpers/get-schema-type.js +24 -0
  172. package/dist/schema/helpers/get-schema-type.js.map +1 -0
  173. package/dist/schema/helpers/get-type-signature-tokens.d.ts +48 -0
  174. package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -0
  175. package/dist/schema/helpers/get-type-signature-tokens.js +62 -0
  176. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -0
  177. package/dist/schema/helpers/has-complex-array-items.d.ts +10 -0
  178. package/dist/schema/helpers/has-complex-array-items.d.ts.map +1 -0
  179. package/dist/schema/helpers/has-complex-array-items.js +22 -0
  180. package/dist/schema/helpers/has-complex-array-items.js.map +1 -0
  181. package/dist/schema/helpers/index.d.ts +12 -0
  182. package/dist/schema/helpers/index.d.ts.map +1 -0
  183. package/dist/schema/helpers/index.js +12 -0
  184. package/dist/schema/helpers/is-empty-schema-object.d.ts +8 -0
  185. package/dist/schema/helpers/is-empty-schema-object.d.ts.map +1 -0
  186. package/dist/schema/helpers/is-empty-schema-object.js +11 -0
  187. package/dist/schema/helpers/is-empty-schema-object.js.map +1 -0
  188. package/dist/schema/helpers/is-model-linkable.d.ts +15 -0
  189. package/dist/schema/helpers/is-model-linkable.d.ts.map +1 -0
  190. package/dist/schema/helpers/is-model-linkable.js +13 -0
  191. package/dist/schema/helpers/is-model-linkable.js.map +1 -0
  192. package/dist/schema/helpers/is-on-schema-target-path.d.ts +3 -0
  193. package/dist/schema/helpers/is-on-schema-target-path.d.ts.map +1 -0
  194. package/dist/schema/helpers/is-on-schema-target-path.js +6 -0
  195. package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -0
  196. package/dist/schema/helpers/is-type-object.d.ts +5 -0
  197. package/dist/schema/helpers/is-type-object.d.ts.map +1 -0
  198. package/dist/schema/helpers/is-type-object.js +15 -0
  199. package/dist/schema/helpers/is-type-object.js.map +1 -0
  200. package/dist/schema/helpers/merge-all-of-schemas.d.ts +12 -0
  201. package/dist/schema/helpers/merge-all-of-schemas.d.ts.map +1 -0
  202. package/dist/schema/helpers/merge-all-of-schemas.js +151 -0
  203. package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -0
  204. package/dist/schema/helpers/normalize-object-composition.d.ts +9 -0
  205. package/dist/schema/helpers/normalize-object-composition.d.ts.map +1 -0
  206. package/dist/schema/helpers/normalize-object-composition.js +29 -0
  207. package/dist/schema/helpers/normalize-object-composition.js.map +1 -0
  208. package/dist/schema/helpers/optimize-value-for-display.d.ts +13 -0
  209. package/dist/schema/helpers/optimize-value-for-display.d.ts.map +1 -0
  210. package/dist/schema/helpers/optimize-value-for-display.js +64 -0
  211. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -0
  212. package/dist/schema/helpers/partition-all-of-compositions.d.ts +32 -0
  213. package/dist/schema/helpers/partition-all-of-compositions.d.ts.map +1 -0
  214. package/dist/schema/helpers/partition-all-of-compositions.js +67 -0
  215. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -0
  216. package/dist/schema/helpers/schema-composition.d.ts +4 -0
  217. package/dist/schema/helpers/schema-composition.d.ts.map +1 -0
  218. package/dist/schema/helpers/schema-composition.js +11 -0
  219. package/dist/schema/helpers/schema-composition.js.map +1 -0
  220. package/dist/schema/helpers/schema-cycle.d.ts +31 -0
  221. package/dist/schema/helpers/schema-cycle.d.ts.map +1 -0
  222. package/dist/schema/helpers/schema-cycle.js +8 -0
  223. package/dist/schema/helpers/schema-cycle.js.map +1 -0
  224. package/dist/schema/helpers/schema-expansion.d.ts +89 -0
  225. package/dist/schema/helpers/schema-expansion.d.ts.map +1 -0
  226. package/dist/schema/helpers/schema-expansion.js +93 -0
  227. package/dist/schema/helpers/schema-expansion.js.map +1 -0
  228. package/dist/schema/helpers/schema-keyboard-nav.d.ts +23 -0
  229. package/dist/schema/helpers/schema-keyboard-nav.d.ts.map +1 -0
  230. package/dist/schema/helpers/schema-keyboard-nav.js +36 -0
  231. package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -0
  232. package/dist/schema/helpers/schema-name.d.ts +27 -0
  233. package/dist/schema/helpers/schema-name.d.ts.map +1 -0
  234. package/dist/schema/helpers/schema-name.js +40 -0
  235. package/dist/schema/helpers/schema-name.js.map +1 -0
  236. package/dist/schema/helpers/should-display-description.d.ts +10 -0
  237. package/dist/schema/helpers/should-display-description.d.ts.map +1 -0
  238. package/dist/schema/helpers/should-display-description.js +6 -0
  239. package/dist/schema/helpers/should-display-description.js.map +1 -0
  240. package/dist/schema/helpers/should-display-heading.d.ts +11 -0
  241. package/dist/schema/helpers/should-display-heading.d.ts.map +1 -0
  242. package/dist/schema/helpers/should-display-heading.js +6 -0
  243. package/dist/schema/helpers/should-display-heading.js.map +1 -0
  244. package/dist/schema/helpers/should-render-array-item-composition.d.ts +10 -0
  245. package/dist/schema/helpers/should-render-array-item-composition.d.ts.map +1 -0
  246. package/dist/schema/helpers/should-render-array-item-composition.js +12 -0
  247. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -0
  248. package/dist/schema/helpers/sort-property-names.d.ts +23 -0
  249. package/dist/schema/helpers/sort-property-names.d.ts.map +1 -0
  250. package/dist/schema/helpers/sort-property-names.js +55 -0
  251. package/dist/schema/helpers/sort-property-names.js.map +1 -0
  252. package/dist/schema/helpers/unwrap-for-read.d.ts +48 -0
  253. package/dist/schema/helpers/unwrap-for-read.d.ts.map +1 -0
  254. package/dist/schema/helpers/unwrap-for-read.js +8 -0
  255. package/dist/schema/helpers/unwrap-for-read.js.map +1 -0
  256. package/dist/schema/index.d.ts +12 -0
  257. package/dist/schema/index.d.ts.map +1 -0
  258. package/dist/schema/index.js +11 -0
  259. package/dist/schema/localization/index.d.ts +59 -0
  260. package/dist/schema/localization/index.d.ts.map +1 -0
  261. package/dist/schema/localization/index.js +18 -0
  262. package/dist/schema/localization/index.js.map +1 -0
  263. package/dist/schema/localization/locales/ar.d.ts +58 -0
  264. package/dist/schema/localization/locales/ar.d.ts.map +1 -0
  265. package/dist/schema/localization/locales/ar.js +60 -0
  266. package/dist/schema/localization/locales/ar.js.map +1 -0
  267. package/dist/schema/localization/locales/de.d.ts +58 -0
  268. package/dist/schema/localization/locales/de.d.ts.map +1 -0
  269. package/dist/schema/localization/locales/de.js +60 -0
  270. package/dist/schema/localization/locales/de.js.map +1 -0
  271. package/dist/schema/localization/locales/en.d.ts +58 -0
  272. package/dist/schema/localization/locales/en.d.ts.map +1 -0
  273. package/dist/schema/localization/locales/en.js +60 -0
  274. package/dist/schema/localization/locales/en.js.map +1 -0
  275. package/dist/schema/localization/locales/es.d.ts +58 -0
  276. package/dist/schema/localization/locales/es.d.ts.map +1 -0
  277. package/dist/schema/localization/locales/es.js +60 -0
  278. package/dist/schema/localization/locales/es.js.map +1 -0
  279. package/dist/schema/localization/locales/fr.d.ts +58 -0
  280. package/dist/schema/localization/locales/fr.d.ts.map +1 -0
  281. package/dist/schema/localization/locales/fr.js +60 -0
  282. package/dist/schema/localization/locales/fr.js.map +1 -0
  283. package/dist/schema/localization/locales/pt.d.ts +58 -0
  284. package/dist/schema/localization/locales/pt.d.ts.map +1 -0
  285. package/dist/schema/localization/locales/pt.js +60 -0
  286. package/dist/schema/localization/locales/pt.js.map +1 -0
  287. package/dist/schema/localization/locales/ru.d.ts +58 -0
  288. package/dist/schema/localization/locales/ru.d.ts.map +1 -0
  289. package/dist/schema/localization/locales/ru.js +60 -0
  290. package/dist/schema/localization/locales/ru.js.map +1 -0
  291. package/dist/schema/localization/locales/zh-cn.d.ts +58 -0
  292. package/dist/schema/localization/locales/zh-cn.d.ts.map +1 -0
  293. package/dist/schema/localization/locales/zh-cn.js +60 -0
  294. package/dist/schema/localization/locales/zh-cn.js.map +1 -0
  295. package/dist/schema/localization/translations.d.ts +460 -0
  296. package/dist/schema/localization/translations.d.ts.map +1 -0
  297. package/dist/schema/localization/translations.js +23 -0
  298. package/dist/schema/localization/translations.js.map +1 -0
  299. package/dist/schema/request-body-composition-index.d.ts +8 -0
  300. package/dist/schema/request-body-composition-index.d.ts.map +1 -0
  301. package/dist/schema/request-body-composition-index.js +6 -0
  302. package/dist/schema/request-body-composition-index.js.map +1 -0
  303. package/dist/schema/schema-tree.bench.d.ts +2 -0
  304. package/dist/schema/schema-tree.bench.d.ts.map +1 -0
  305. package/dist/schema/types.d.ts +51 -0
  306. package/dist/schema/types.d.ts.map +1 -0
  307. package/dist/shared/Badge.vue.d.ts +17 -0
  308. package/dist/shared/Badge.vue.d.ts.map +1 -0
  309. package/dist/shared/Badge.vue.js +9 -0
  310. package/dist/shared/Badge.vue.js.map +1 -0
  311. package/dist/shared/Badge.vue.script.js +16 -0
  312. package/dist/shared/Badge.vue.script.js.map +1 -0
  313. package/dist/shared/ScreenReader.vue.d.ts +21 -0
  314. package/dist/shared/ScreenReader.vue.d.ts.map +1 -0
  315. package/dist/shared/ScreenReader.vue.js +7 -0
  316. package/dist/shared/ScreenReader.vue.js.map +1 -0
  317. package/dist/shared/ScreenReader.vue.script.js +19 -0
  318. package/dist/shared/ScreenReader.vue.script.js.map +1 -0
  319. package/dist/shared/index.d.ts +3 -0
  320. package/dist/shared/index.d.ts.map +1 -0
  321. package/dist/shared/index.js +3 -0
  322. package/dist/specification-extensions/ExtensionValue.vue.d.ts +13 -0
  323. package/dist/specification-extensions/ExtensionValue.vue.d.ts.map +1 -0
  324. package/dist/specification-extensions/ExtensionValue.vue.js +7 -0
  325. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -0
  326. package/dist/specification-extensions/ExtensionValue.vue.script.js +84 -0
  327. package/dist/specification-extensions/ExtensionValue.vue.script.js.map +1 -0
  328. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts +9 -0
  329. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts.map +1 -0
  330. package/dist/specification-extensions/SpecificationExtensions.vue.js +7 -0
  331. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -0
  332. package/dist/specification-extensions/SpecificationExtensions.vue.script.js +21 -0
  333. package/dist/specification-extensions/SpecificationExtensions.vue.script.js.map +1 -0
  334. package/dist/specification-extensions/index.d.ts +2 -0
  335. package/dist/specification-extensions/index.d.ts.map +1 -0
  336. package/dist/specification-extensions/index.js +2 -0
  337. package/dist/style.css +576 -15
  338. package/dist/styles/schema-tree.css +91 -0
  339. package/dist/styles/tailwind.config.css +22 -0
  340. package/dist/vue-styles.css +1 -1
  341. package/package.json +45 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-all-of-schemas.js","names":[],"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 === undefined\n ? incoming.enum?.slice()\n : incoming.enum === undefined\n ? existing.enum.slice()\n : existing.enum.filter((value) => incoming.enum?.some((candidate) => isObjectEqual(value, candidate)))\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 (!_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,IA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GAAG,EAAS,WAAW;EAAE;EAElF,OADA,EAA0B,EAAO,YAAY,EAAS,YAAY,CAAQ,GACnE;CACT;CAEA,OAAO;EAAE,GAAG;EAAU,GAAG;CAAS;AACpC"}
@@ -0,0 +1,9 @@
1
+ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
+ /** Display schemas may carry the nullable annotation produced by composition optimization. */
3
+ type DisplaySchema = SchemaObject & {
4
+ nullable?: boolean;
5
+ };
6
+ /** Preserve a named property's object boundary when all of its composition members form one object. */
7
+ export declare const normalizeObjectComposition: (value: DisplaySchema | undefined, name: string | undefined) => DisplaySchema | undefined;
8
+ export {};
9
+ //# sourceMappingURL=normalize-object-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-object-composition.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/normalize-object-composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAKhG,8FAA8F;AAC9F,KAAK,aAAa,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE1D,uGAAuG;AACvG,eAAO,MAAM,0BAA0B,GACrC,OAAO,aAAa,GAAG,SAAS,EAChC,MAAM,MAAM,GAAG,SAAS,KACvB,aAAa,GAAG,SAmClB,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { isTypeObject as e } from "./is-type-object.js";
2
+ import { partitionAllOfCompositions as t } from "./partition-all-of-compositions.js";
3
+ //#region src/schema/helpers/normalize-object-composition.ts
4
+ var n = (n, r) => {
5
+ if (!r || !n?.allOf || n.oneOf || n.anyOf || n.not) return n;
6
+ let { segments: i } = t(n), a = i[0];
7
+ if (i.length !== 1 || a?.kind !== "object" || !e(a.schema)) return n;
8
+ let o = { ...a.schema };
9
+ "$ref" in o && delete o.$ref;
10
+ let s = {
11
+ title: n.title,
12
+ description: n.description,
13
+ deprecated: n.deprecated,
14
+ readOnly: n.readOnly,
15
+ writeOnly: n.writeOnly,
16
+ example: n.example,
17
+ examples: n.examples,
18
+ nullable: n.nullable
19
+ };
20
+ return {
21
+ ...o,
22
+ ...s,
23
+ ..."$ref" in n && typeof n.$ref == "string" ? { $ref: n.$ref } : {}
24
+ };
25
+ };
26
+ //#endregion
27
+ export { n as normalizeObjectComposition };
28
+
29
+ //# sourceMappingURL=normalize-object-composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-object-composition.js","names":[],"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,IAAa,KACX,GACA,MAC8B;CAE9B,IAAI,CAAC,KAAQ,CAAC,GAAO,SAAS,EAAM,SAAS,EAAM,SAAS,EAAM,KAChE,OAAO;CAGT,IAAM,EAAE,gBAAa,EAA2B,CAAK,GAC/C,IAAU,EAAS;CACzB,IAAI,EAAS,WAAW,KAAK,GAAS,SAAS,YAAY,CAAC,EAAa,EAAQ,MAAM,GACrF,OAAO;CAKT,IAAM,IAAe,EAAE,GAAG,EAAQ,OAAO;CACzC,AAAI,UAAU,KACZ,OAAO,EAAa;CAItB,IAAM,IAAc;EAClB,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,YAAY,EAAM;EAClB,UAAU,EAAM;EAChB,WAAW,EAAM;EACjB,SAAS,EAAM;EACf,UAAU,EAAM;EAChB,UAAU,EAAM;CAClB;CACA,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAI,UAAU,KAAS,OAAO,EAAM,QAAS,WAAW,EAAE,MAAM,EAAM,KAAK,IAAI,CAAC;CAClF;AACF"}
@@ -0,0 +1,13 @@
1
+ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
+ /** Display normalization tracks null branches without changing the stored OpenAPI schema. */
3
+ type DisplaySchema = SchemaObject & {
4
+ nullable?: boolean;
5
+ };
6
+ /**
7
+ * Normalize compositions for display without changing the source schema. Null branches
8
+ * become nullable state, single branches are flattened, and shared properties and
9
+ * required fields are merged into variants so the renderer keeps their full context.
10
+ */
11
+ export declare function optimizeValueForDisplay(value: DisplaySchema | undefined): DisplaySchema | undefined;
12
+ export {};
13
+ //# sourceMappingURL=optimize-value-for-display.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimize-value-for-display.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/optimize-value-for-display.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAIhG,6FAA6F;AAC7F,KAAK,aAAa,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAmD1D;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAmHnG"}
@@ -0,0 +1,64 @@
1
+ import { compositions as e } from "./schema-composition.js";
2
+ import { resolve as t } from "@scalar/workspace-store/resolve";
3
+ //#region src/schema/helpers/optimize-value-for-display.ts
4
+ function n(...e) {
5
+ let t = {}, n = {}, r = /* @__PURE__ */ new Set(), i = !1, a = !1;
6
+ for (let o of e) if (o) for (let [e, s] of Object.entries(o)) {
7
+ if (e === "properties" && s && typeof s == "object") {
8
+ Object.assign(n, s), i = !0;
9
+ continue;
10
+ }
11
+ if (e === "required" && Array.isArray(s)) {
12
+ for (let e of s) r.add(e);
13
+ a = !0;
14
+ continue;
15
+ }
16
+ t[e] = s;
17
+ }
18
+ return i && (t.properties = n), a && (t.required = [...r]), t;
19
+ }
20
+ function r(r) {
21
+ if (!r || typeof r != "object") return r;
22
+ let i = e.find((e) => e in r && e !== "not");
23
+ if (!i) return { ...r };
24
+ let a = r[i];
25
+ if (!Array.isArray(a)) return { ...r };
26
+ let { [i]: o, nullable: s, ...c } = r, l = Object.keys(c).length > 0, { filteredSchemas: u, hasNullSchema: d } = a.reduce((e, n) => {
27
+ let r = t.schema(n);
28
+ return "type" in r && r.type === "null" ? e.hasNullSchema = !0 : e.filteredSchemas.push(r), e;
29
+ }, {
30
+ filteredSchemas: [],
31
+ hasNullSchema: !1
32
+ }), f = d || s === !0;
33
+ if (u.length === 1) {
34
+ let e = n(u[0], c);
35
+ return f && (e.nullable = !0), e;
36
+ }
37
+ if ((i === "oneOf" || i === "anyOf") && (l || u.some((e) => e.allOf))) {
38
+ let { discriminator: e, ...a } = c, o = u.map((e) => {
39
+ let r = t.schema(e);
40
+ if (r.allOf?.length === 1) {
41
+ let { allOf: e, ...i } = r, o = t.schema(e[0]);
42
+ if ("properties" in i || "required" in i || "$ref" in i) {
43
+ let { $ref: e, title: t, name: r, ...s } = o;
44
+ return n(a, i, s);
45
+ }
46
+ return n(a, i, o);
47
+ }
48
+ return n(a, r);
49
+ }), s = { [i]: o };
50
+ return typeof r.description == "string" && (s.description = r.description), f && (s.nullable = !0), s;
51
+ }
52
+ if (u.length !== a.length) {
53
+ let e = {
54
+ ...r,
55
+ [i]: u
56
+ };
57
+ return f && (e.nullable = !0), e;
58
+ }
59
+ return { ...r };
60
+ }
61
+ //#endregion
62
+ export { r as optimizeValueForDisplay };
63
+
64
+ //# sourceMappingURL=optimize-value-for-display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimize-value-for-display.js","names":[],"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 { 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<string, 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 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 // 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 const { discriminator: _discriminator, ...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 (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":";;;AAgBA,SAAS,EAAsB,GAAG,GAA2E;CAC3G,IAAM,IAAkC,CAAC,GACnC,IAAsC,CAAC,GACvC,oBAAW,IAAI,IAAY,GAC7B,IAAgB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AOA,KAHG,MAAgB,WAAW,MAAgB,aAC3C,KAAqB,EAAgB,MAAM,MAAW,EAAO,KAAK,IAEtC;EAI7B,IAAM,EAAE,eAAe,GAAgB,GAAG,MAA0B,GAE9D,IAAgB,EAAgB,KAAK,MAAY;GACrD,IAAM,IAAS,EAAQ,OAAO,CAAO;GAYrC,IAAI,EAAO,OAAO,WAAW,GAAG;IAC9B,IAAM,EAAE,UAAO,GAAG,MAAe,GAC3B,IAAc,EAAQ,OAAO,EAAM,EAAE;IAE3C,IAD8B,gBAAgB,KAAc,cAAc,KAAc,UAAU,GACvE;KACzB,IAAM,EAAE,MAAM,GAAM,OAAO,GAAQ,MAAM,GAAO,GAAG,MAA+B;KAClF,OAAO,EAAsB,GAAuB,GAAY,CAA0B;IAC5F;IACA,OAAO,EAAsB,GAAuB,GAAY,CAAW;GAC7E;GACA,OAAO,EAAsB,GAAuB,CAAM;EAC5D,CAAC,GAGK,IAAS,GAAG,IAAc,EAAc;EAO9C,OANI,OAAO,EAAM,eAAgB,aAC/B,EAAO,cAAc,EAAM,cAEzB,MACF,EAAO,WAAW,KAEb;CACT;CAGA,IAAI,EAAgB,WAAW,EAAQ,QAAQ;EAC7C,IAAM,IAAwB;GAAE,GAAG;IAAQ,IAAc;EAAgB;EAIzE,OAHI,MACF,EAAO,WAAW,KAEb;CACT;CAEA,OAAO,EAAE,GAAG,EAAM;AACpB"}
@@ -0,0 +1,32 @@
1
+ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
2
+ import type { CompositionKeyword } from './schema-composition';
3
+ type ChoiceKeyword = Extract<CompositionKeyword, 'oneOf' | 'anyOf'>;
4
+ /** An ordered piece of an `allOf`: either a merged object or a choice picker. */
5
+ type AllOfSegment = {
6
+ kind: 'object';
7
+ schema: SchemaObject;
8
+ } | {
9
+ kind: 'choice';
10
+ composition: ChoiceKeyword;
11
+ /** A minimal schema carrying only this group's composition, for SchemaComposition */
12
+ value: SchemaObject;
13
+ /** Ordinal among choice members, matching the request-example composition key */
14
+ choiceIndex: number;
15
+ };
16
+ /**
17
+ * Splits an `allOf` schema into an ordered list of segments so the renderer can
18
+ * show each `oneOf`/`anyOf` group as its own picker **in the position it was
19
+ * declared**, with the surrounding plain fields around it.
20
+ *
21
+ * `mergeAllOfSchemas` alone keeps only the FIRST `oneOf`/`anyOf` (dropping the
22
+ * 2nd+ groups of an object with several independent mutually-exclusive
23
+ * selections) and, being a merge, also loses the ordering between fields and
24
+ * choices. Walking the members in order fixes both: runs of consecutive object
25
+ * members are merged into one object segment, and each choice member becomes its
26
+ * own picker segment in place.
27
+ */
28
+ export declare const partitionAllOfCompositions: (schema: SchemaObject | undefined) => {
29
+ segments: AllOfSegment[];
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=partition-all-of-compositions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition-all-of-compositions.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGhG,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;AAmFL;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,YAAY,GAAG,SAAS,KAAG;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CAmFvG,CAAA"}
@@ -0,0 +1,67 @@
1
+ import { mergeAllOfSchemas as e } from "./merge-all-of-schemas.js";
2
+ import { resolve as t } from "@scalar/workspace-store/resolve";
3
+ //#region src/schema/helpers/partition-all-of-compositions.ts
4
+ var n = ["oneOf", "anyOf"], r = (e, i, a) => {
5
+ let { allOf: o, oneOf: s, anyOf: c, not: l, if: u, then: d, else: f, ...p } = e;
6
+ Object.keys(p).length > 0 && i.push({
7
+ kind: "object",
8
+ schema: p
9
+ });
10
+ for (let e of n) {
11
+ let t = e === "oneOf" ? s : c, n = Array.isArray(t) && t.some((e) => {
12
+ let t = e && typeof e == "object" && "$ref" in e ? e.$ref : void 0;
13
+ return typeof t == "string" && a.has(t);
14
+ });
15
+ Array.isArray(t) && t.length > 0 && i.push({
16
+ kind: "choice",
17
+ composition: e,
18
+ value: { [e]: t },
19
+ inheritedSelection: n
20
+ });
21
+ }
22
+ if (Array.isArray(o)) {
23
+ for (let e of o) if (e && typeof e == "object") {
24
+ let n = t.schema(e), o = n.$ref;
25
+ if (typeof o == "string") {
26
+ if (a.has(o)) continue;
27
+ r(n, i, new Set(a).add(o));
28
+ } else r(n, i, a);
29
+ }
30
+ }
31
+ }, i = (n) => {
32
+ if (!n) return { segments: [] };
33
+ let { allOf: i, oneOf: a, anyOf: o, not: s, if: c, then: l, else: u, ...d } = n;
34
+ if (!Array.isArray(i)) return { segments: [{
35
+ kind: "object",
36
+ schema: n
37
+ }] };
38
+ let f = [];
39
+ Object.keys(d).length > 0 && f.push({
40
+ kind: "object",
41
+ schema: d
42
+ });
43
+ let p = "$ref" in n ? n.$ref : void 0, m = new Set(typeof p == "string" ? [p] : []);
44
+ for (let e of i) if (e && typeof e == "object") {
45
+ let n = t.schema(e), i = n.$ref;
46
+ r(n, f, typeof i == "string" ? new Set(m).add(i) : m);
47
+ }
48
+ let h = [], g = [], _ = 0, v = () => {
49
+ if (g.length === 0) return;
50
+ let t = g.length === 1 ? g[0] : e({ allOf: g });
51
+ h.push({
52
+ kind: "object",
53
+ schema: t
54
+ }), g = [];
55
+ };
56
+ for (let e of f) e.kind === "object" ? g.push(e.schema) : e.inheritedSelection ? _++ : (v(), h.push({
57
+ kind: "choice",
58
+ composition: e.composition,
59
+ value: e.value,
60
+ choiceIndex: _++
61
+ }));
62
+ return v(), { segments: h };
63
+ };
64
+ //#endregion
65
+ export { i as partitionAllOfCompositions };
66
+
67
+ //# sourceMappingURL=partition-all-of-compositions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition-all-of-compositions.js","names":[],"sources":["../../../src/schema/helpers/partition-all-of-compositions.ts"],"sourcesContent":["import { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } 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: '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 = (schema: SchemaObject, out: Member[], seenRefs: Set<string>): void => {\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 (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(resolved, out, new Set(seenRefs).add(ref))\n } else {\n collectMembers(resolved, 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 (rawMember && typeof rawMember === 'object') {\n const resolved: SchemaObject & { $ref?: string } = resolve.schema(rawMember)\n const ref = resolved.$ref\n collectMembers(resolved, 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.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":";;;AAoBA,IAAM,IAAmC,CAAC,SAAS,OAAO,GAepD,KAAkB,GAAsB,GAAe,MAAgC;CAC3F,IAAM,EACJ,UACA,UACA,UACA,KAAK,GACL,IAAI,GACJ,MAAM,GACN,MAAM,GACN,GAAG,MASD;CAEJ,AAAI,OAAO,KAAK,CAAI,CAAC,CAAC,SAAS,KAC7B,EAAI,KAAK;EAAE,MAAM;EAAU,QAAQ;CAAK,CAAC;CAG3C,KAAK,IAAM,KAAW,GAAiB;EACrC,IAAM,IAAQ,MAAY,UAAU,IAAQ,GAItC,IACJ,MAAM,QAAQ,CAAK,KACnB,EAAM,MAAM,MAAW;GACrB,IAAM,IAAM,KAAU,OAAO,KAAW,YAAY,UAAU,IAAS,EAAO,OAAO,KAAA;GACrF,OAAO,OAAO,KAAQ,YAAY,EAAS,IAAI,CAAG;EACpD,CAAC;EACH,AAAI,MAAM,QAAQ,CAAK,KAAK,EAAM,SAAS,KACzC,EAAI,KAAK;GACP,MAAM;GACN,aAAa;GACb,OAAO,GAAG,IAAU,EAAM;GAC1B,oBAAoB;EACtB,CAAC;CAEL;CAEA,IAAI,MAAM,QAAQ,CAAK;OAChB,IAAM,KAAa,GACtB,IAAI,KAAa,OAAO,KAAc,UAAU;GAC9C,IAAM,IAA6C,EAAQ,OAAO,CAAS,GAIrE,IAAM,EAAS;GACrB,IAAI,OAAO,KAAQ,UAAU;IAC3B,IAAI,EAAS,IAAI,CAAG,GAClB;IAEF,EAAe,GAAU,GAAK,IAAI,IAAI,CAAQ,CAAC,CAAC,IAAI,CAAG,CAAC;GAC1D,OACE,EAAe,GAAU,GAAK,CAAQ;EAE1C;;AAGN,GAca,KAA8B,MAAmE;CAC5G,IAAI,CAAC,GACH,OAAO,EAAE,UAAU,CAAC,EAAE;CAKxB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ompositionKeyword = 'oneOf' | 'anyOf' | 'allOf' | 'not';
3
+ export declare const compositions: CompositionKeyword[];
4
+ //# sourceMappingURL=schema-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-composition.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/schema-composition.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAA;AAEpE,eAAO,MAAM,YAAY,EAAE,kBAAkB,EAAuC,CAAA"}
@@ -0,0 +1,11 @@
1
+ //#region src/schema/helpers/schema-composition.ts
2
+ var e = [
3
+ "oneOf",
4
+ "anyOf",
5
+ "allOf",
6
+ "not"
7
+ ];
8
+ //#endregion
9
+ export { e as compositions };
10
+
11
+ //# sourceMappingURL=schema-composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-composition.js","names":[],"sources":["../../../src/schema/helpers/schema-composition.ts"],"sourcesContent":["/** Composition */\nexport type CompositionKeyword = 'oneOf' | 'anyOf' | 'allOf' | 'not'\n\nexport const compositions: CompositionKeyword[] = ['oneOf', 'anyOf', 'allOf', 'not']\n"],"mappings":";AAGA,IAAa,IAAqC;CAAC;CAAS;CAAS;CAAS;AAAK"}
@@ -0,0 +1,31 @@
1
+ import type { InjectionKey } from 'vue';
2
+ /**
3
+ * The set of schema "cycle keys" for every ancestor on the current render path.
4
+ *
5
+ * Each `Schema` component injects this set, adds its own key, and re-provides
6
+ * it to its descendants. When a node's key is already present in the ancestor
7
+ * set we've hit a cycle (a self-referential schema) and must stop force
8
+ * expanding to avoid rendering forever.
9
+ *
10
+ * See {@link getCycleKey} for how a node's key is derived.
11
+ */
12
+ export declare const SCHEMA_ANCESTORS_SYMBOL: InjectionKey<ReadonlySet<unknown>>;
13
+ /**
14
+ * Derive a stable identity for a schema node from its *raw* (unresolved) value.
15
+ *
16
+ * Cycle detection needs a key that is identical every time the same schema is
17
+ * reached along a path, and that survives the shallow copies/merges performed
18
+ * while rendering (which break object identity of the resolved schema).
19
+ *
20
+ * - For `$ref` nodes we use the ref string. Two branches that reference the
21
+ * same component share the string, so a schema that (transitively) references
22
+ * itself is detected as a cycle, while sibling references are not.
23
+ * - For inline schemas there is no ref, so we fall back to the raw object
24
+ * reference. A self-referential inline schema reuses the same object, so
25
+ * object identity catches the cycle.
26
+ *
27
+ * Returns `undefined` for primitives/booleans (e.g. `additionalProperties: true`)
28
+ * which can never form a cycle.
29
+ */
30
+ export declare const getCycleKey: (raw: unknown) => unknown;
31
+ //# sourceMappingURL=schema-cycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-cycle.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/schema-cycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AAEvC;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAA8B,CAAA;AAErG;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,KAAG,OAS1C,CAAA"}
@@ -0,0 +1,8 @@
1
+ //#region src/schema/helpers/schema-cycle.ts
2
+ var e = Symbol("schema-ancestors"), t = (e) => {
3
+ if (e && typeof e == "object") return "$ref" in e && typeof e.$ref == "string" ? e.$ref : e;
4
+ };
5
+ //#endregion
6
+ export { e as SCHEMA_ANCESTORS_SYMBOL, t as getCycleKey };
7
+
8
+ //# sourceMappingURL=schema-cycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-cycle.js","names":[],"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,IAAa,IAA8D,OAAO,kBAAkB,GAmBvF,KAAe,MAA0B;CACpD,IAAI,KAAO,OAAO,KAAQ,UAIxB,OAHI,UAAU,KAAO,OAAO,EAAI,QAAS,WAC/B,EAAyB,OAE5B;AAIX"}
@@ -0,0 +1,89 @@
1
+ import { type InjectionKey, type Ref } from 'vue';
2
+ /**
3
+ * What a node does when nobody has expressed an opinion about it: its own
4
+ * `defaultOpen`, or whatever expand-all / collapse-all last set.
5
+ */
6
+ type ExpansionBaseline = 'default' | 'expanded' | 'collapsed';
7
+ /** What the store cannot work out about a node on its own. */
8
+ type ExpansionContext = {
9
+ /**
10
+ * Whether this node sits on a `$ref` cycle. Bulk expansion and the baseline
11
+ * skip cyclic nodes; without that, `expandAll()` on a self-referential schema
12
+ * never terminates, because the cycle guard only suppresses auto-expansion.
13
+ */
14
+ cyclic?: boolean;
15
+ /** What the node would do with no store at all (its `defaultOpen`). */
16
+ defaultOpen?: boolean;
17
+ /**
18
+ * The public anchor path this node covers, when it differs from its key. A
19
+ * key carrying a structural marker (`~headers`) must still open for a deep
20
+ * link written against the anchor path (`…headers.X-Rate`).
21
+ */
22
+ anchorPath?: string;
23
+ };
24
+ /** Shared expansion controls for a host and its schema trees. */
25
+ export type SchemaExpansionStore = {
26
+ /** Resolve whether a node is open. See the resolution order below. */
27
+ isExpanded: (key: string, ctx?: ExpansionContext) => boolean;
28
+ /** Record an explicit user decision about one node. */
29
+ setExpanded: (key: string, value: boolean) => void;
30
+ /** Flip one node, resolving its current state first. */
31
+ toggle: (key: string, ctx?: ExpansionContext) => void;
32
+ /** Expand everything, or everything beneath `root`. */
33
+ expandAll: (root?: string) => void;
34
+ /** Collapse everything, or everything beneath `root`. */
35
+ collapseAll: (root?: string) => void;
36
+ /** Make a deep link's expansion permanent by opening every ancestor of `path`. */
37
+ commitPath: (path: string) => void;
38
+ /** The standing baseline, exposed so a print hook can flip it and put it back. */
39
+ baseline: Ref<ExpansionBaseline>;
40
+ /**
41
+ * The budget for closed panels kept in the DOM as `hidden="until-found"`. It
42
+ * lives on the store, so it is shared by every schema tree under one reference.
43
+ * Kept panels stay searchable with find-in-page but grow the DOM, so a closing
44
+ * row asks `acquire()` first and simply unmounts past the cap. Deliberately
45
+ * not reactive: it only matters at the moment a panel closes.
46
+ */
47
+ untilFound: {
48
+ acquire: () => boolean;
49
+ release: () => void;
50
+ };
51
+ /**
52
+ * Run a bulk transition with slot retention paused. A collapse-all or the
53
+ * afterprint restore closes many rows in one flush; letting each one
54
+ * `acquire()` would drain the budget in a single gesture and pin hundreds of
55
+ * hidden subtrees. Releases still run, so reopened rows hand slots back.
56
+ */
57
+ pauseRetentionFor: (mutate: () => void) => void;
58
+ };
59
+ /**
60
+ * Build the node key for a breadcrumb: the dot-joined anchor path, so store keys
61
+ * and public anchors are the same string. Callers append `~`-marked structural
62
+ * segments (`~headers`, `~anonymous-…`) for nodes the anchor cannot name.
63
+ */
64
+ export declare const toNodeKey: (breadcrumb: readonly string[] | undefined) => string;
65
+ /**
66
+ * A per-reference store of which schema properties are open. Sparse by
67
+ * construction: only what somebody touched, typically under twenty keys, where
68
+ * a dense map over a large document would be tens of thousands. The maps are
69
+ * `shallowReactive` because a Map inside a `shallowRef` does not track `.set()`
70
+ * (clicks would do nothing) and replacing the Map wholesale would invalidate
71
+ * every mounted row on every toggle.
72
+ */
73
+ export declare const createSchemaExpansionStore: (scrollTargetId?: Ref<string>) => SchemaExpansionStore;
74
+ /**
75
+ * Marks that an enclosing Schema already owns the tree root. Nesting depth
76
+ * cannot identify the outermost tree, because a nested Schema may mount at depth
77
+ * 0 (an `allOf` member, or a caller that omits `depth`), and the root-only
78
+ * features (sticky ancestor strip, keyboard navigation) must not install twice.
79
+ */
80
+ export declare const SCHEMA_TREE_ROOT_SYMBOL: InjectionKey<boolean>;
81
+ /**
82
+ * Create the expansion store for one `<ApiReference>` and wire up deep links.
83
+ * The scroll target is read only after mount: it comes from a URL fragment the
84
+ * server never sees, so committing it during SSR would make every ancestor
85
+ * panel on a deep-linked path a hydration mismatch.
86
+ */
87
+ export declare const useSchemaExpansion: (scrollTargetId?: Ref<string>) => SchemaExpansionStore;
88
+ export {};
89
+ //# sourceMappingURL=schema-expansion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-expansion.d.ts","sourceRoot":"","sources":["../../../src/schema/helpers/schema-expansion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GAAG,EAOT,MAAM,KAAK,CAAA;AAIZ;;;GAGG;AACH,KAAK,iBAAiB,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAA;AAE7D,8DAA8D;AAC9D,KAAK,gBAAgB,GAAG;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,C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C,MAAM,CAAkB,KAAG,oBA2CjF,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { isOnSchemaTargetPath as e } from "./is-on-schema-target-path.js";
2
+ import { nextTick as t, onBeforeUnmount as n, onMounted as r, shallowReactive as i, shallowRef as a, watch as o } from "vue";
3
+ //#region src/schema/helpers/schema-expansion.ts
4
+ var s = (e, t) => t === "" || e === t || e.startsWith(`${t}.`), c = (e) => e?.join(".") ?? "", l = 300, u = (n = a("")) => {
5
+ let r = i(/* @__PURE__ */ new Map()), o = i(/* @__PURE__ */ new Map()), c = a("default"), u = (e) => {
6
+ if (o.size === 0) return;
7
+ let t = e;
8
+ for (;;) {
9
+ let e = o.get(t);
10
+ if (e !== void 0) return e;
11
+ let n = t.lastIndexOf(".");
12
+ if (n === -1) return o.get("");
13
+ t = t.slice(0, n);
14
+ }
15
+ }, d = (e) => {
16
+ for (let t of [...r.keys()]) s(t, e) && r.delete(t);
17
+ }, f = !1, p = (e) => {
18
+ f = !0, e(), t(() => {
19
+ f = !1;
20
+ });
21
+ }, m = (e, t) => {
22
+ if (d(e), e === "") {
23
+ o.clear(), c.value = t ? "expanded" : "collapsed";
24
+ return;
25
+ }
26
+ for (let t of [...o.keys()]) s(t, e) && o.delete(t);
27
+ o.set(e, t);
28
+ }, h = (t, i = {}) => {
29
+ let a = r.get(t);
30
+ if (a !== void 0) return a;
31
+ if (!i.cyclic) {
32
+ let e = u(t);
33
+ if (e !== void 0) return e;
34
+ if (c.value === "expanded") return !0;
35
+ if (c.value === "collapsed") return !1;
36
+ }
37
+ return e(i.anchorPath ?? t, n.value) ? !0 : i.defaultOpen ?? !1;
38
+ }, g = (e, t) => {
39
+ r.set(e, t);
40
+ };
41
+ return {
42
+ isExpanded: h,
43
+ setExpanded: g,
44
+ toggle: (e, t) => g(e, !h(e, t)),
45
+ expandAll: (e = "") => m(e, !0),
46
+ collapseAll: (e = "") => p(() => m(e, !1)),
47
+ commitPath: (e) => {
48
+ if (!e) return;
49
+ let t = e.split(".");
50
+ for (let e = 1; e <= t.length; e++) {
51
+ let n = t.slice(0, e).join(".");
52
+ r.set(n, !0);
53
+ let i = n.lastIndexOf(".");
54
+ i !== -1 && r.set(`${n.slice(0, i)}.~${n.slice(i + 1)}`, !0);
55
+ }
56
+ },
57
+ baseline: c,
58
+ pauseRetentionFor: p,
59
+ untilFound: (() => {
60
+ let e = 0;
61
+ return {
62
+ acquire: () => f || e >= l ? !1 : (e += 1, !0),
63
+ release: () => {
64
+ e = Math.max(0, e - 1);
65
+ }
66
+ };
67
+ })()
68
+ };
69
+ }, d = Symbol("schema-tree-root"), f = (e = a("")) => {
70
+ let t = u(e);
71
+ return r(() => {
72
+ o(e, (e) => {
73
+ e && t.commitPath(e);
74
+ }, { immediate: !0 });
75
+ let r = null, i = () => {
76
+ r = t.baseline.value, t.baseline.value = "expanded";
77
+ }, a = () => {
78
+ if (r !== null) {
79
+ let e = r;
80
+ t.pauseRetentionFor(() => {
81
+ t.baseline.value = e;
82
+ }), r = null;
83
+ }
84
+ };
85
+ window.addEventListener("beforeprint", i), window.addEventListener("afterprint", a), n(() => {
86
+ window.removeEventListener("beforeprint", i), window.removeEventListener("afterprint", a);
87
+ });
88
+ }), t;
89
+ };
90
+ //#endregion
91
+ export { d as SCHEMA_TREE_ROOT_SYMBOL, u as createSchemaExpansionStore, c as toNodeKey, f as useSchemaExpansion };
92
+
93
+ //# sourceMappingURL=schema-expansion.js.map