@scalar/api-client 3.25.1 → 3.26.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 (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/style.css +107 -41
  3. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  4. package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
  5. package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js +33 -3
  6. package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +2 -0
  8. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
  9. package/dist/v2/blocks/operation-block/components/Header.vue.js +1 -1
  10. package/dist/v2/blocks/operation-block/components/Header.vue.js.map +1 -1
  11. package/dist/v2/blocks/operation-block/components/Header.vue_vue_type_script_setup_true_lang.js +8 -6
  12. package/dist/v2/blocks/operation-block/components/Header.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/v2/blocks/request-block/RequestBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +2 -0
  15. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  16. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  17. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
  18. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue_vue_type_script_setup_true_lang.js +31 -3
  19. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  20. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
  22. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
  23. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue_vue_type_script_setup_true_lang.js +33 -21
  24. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.d.ts.map +1 -1
  26. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.js.map +1 -1
  27. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue_vue_type_script_setup_true_lang.js +4 -3
  28. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  29. package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.d.ts.map +1 -1
  30. package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.js.map +1 -1
  31. package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue_vue_type_script_setup_true_lang.js +4 -3
  32. package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  33. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
  34. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
  35. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue_vue_type_script_setup_true_lang.js +43 -25
  36. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue_vue_type_script_setup_true_lang.js.map +1 -1
  37. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth-device-authorization.js +1 -1
  38. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +1 -1
  39. package/dist/v2/constants.js +1 -1
  40. package/dist/v2/features/localization/locales/ar.d.ts +4 -0
  41. package/dist/v2/features/localization/locales/ar.d.ts.map +1 -1
  42. package/dist/v2/features/localization/locales/ar.js +4 -0
  43. package/dist/v2/features/localization/locales/ar.js.map +1 -1
  44. package/dist/v2/features/localization/locales/de.d.ts +4 -0
  45. package/dist/v2/features/localization/locales/de.d.ts.map +1 -1
  46. package/dist/v2/features/localization/locales/de.js +4 -0
  47. package/dist/v2/features/localization/locales/de.js.map +1 -1
  48. package/dist/v2/features/localization/locales/es.d.ts +4 -0
  49. package/dist/v2/features/localization/locales/es.d.ts.map +1 -1
  50. package/dist/v2/features/localization/locales/es.js +4 -0
  51. package/dist/v2/features/localization/locales/es.js.map +1 -1
  52. package/dist/v2/features/localization/locales/fr.d.ts +4 -0
  53. package/dist/v2/features/localization/locales/fr.d.ts.map +1 -1
  54. package/dist/v2/features/localization/locales/fr.js +4 -0
  55. package/dist/v2/features/localization/locales/fr.js.map +1 -1
  56. package/dist/v2/features/localization/locales/pt.d.ts +4 -0
  57. package/dist/v2/features/localization/locales/pt.d.ts.map +1 -1
  58. package/dist/v2/features/localization/locales/pt.js +4 -0
  59. package/dist/v2/features/localization/locales/pt.js.map +1 -1
  60. package/dist/v2/features/localization/locales/ru.d.ts +4 -0
  61. package/dist/v2/features/localization/locales/ru.d.ts.map +1 -1
  62. package/dist/v2/features/localization/locales/ru.js +4 -0
  63. package/dist/v2/features/localization/locales/ru.js.map +1 -1
  64. package/dist/v2/features/localization/locales/zh-cn.d.ts +4 -0
  65. package/dist/v2/features/localization/locales/zh-cn.d.ts.map +1 -1
  66. package/dist/v2/features/localization/locales/zh-cn.js +4 -0
  67. package/dist/v2/features/localization/locales/zh-cn.js.map +1 -1
  68. package/dist/v2/features/localization/locales/zh-tw.d.ts +4 -0
  69. package/dist/v2/features/localization/locales/zh-tw.d.ts.map +1 -1
  70. package/dist/v2/features/localization/locales/zh-tw.js +4 -0
  71. package/dist/v2/features/localization/locales/zh-tw.js.map +1 -1
  72. package/dist/v2/features/localization/translations.d.ts +4 -0
  73. package/dist/v2/features/localization/translations.d.ts.map +1 -1
  74. package/dist/v2/features/localization/translations.js +4 -0
  75. package/dist/v2/features/localization/translations.js.map +1 -1
  76. package/dist/vue-styles.css +16 -16
  77. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 3.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10986](https://github.com/scalar/scalar/pull/10986): Add an Open in browser action for GET requests using the configured URL and parameters.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#11041](https://github.com/scalar/scalar/pull/11041): fix: keep the auth form's rows inside their table in server-rendered markup
12
+ - [#11011](https://github.com/scalar/scalar/pull/11011): Make Vite configuration imports compatible with the native config loader.
13
+ - [#11041](https://github.com/scalar/scalar/pull/11041): fix: render the OAuth 2.0 redirect URL field the same way on the server and in the browser
14
+
3
15
  ## 3.25.1
4
16
 
5
17
  ### Patch Changes
package/dist/style.css CHANGED
@@ -713,6 +713,42 @@
713
713
  }
714
714
  }
715
715
 
716
+ .scalar-card {
717
+ --scalar-card-surface: var(--scalar-background-1);
718
+ --scalar-card-surface-raised: var(--scalar-background-2);
719
+ --scalar-card-surface-shadow: var(--scalar-shadow-1),
720
+ 0 0 0 var(--scalar-border-width) var(--scalar-border-color);
721
+ }
722
+
723
+ @supports (color: oklch(from white l c h)) {
724
+ .scalar-card {
725
+ --scalar-card-surface: oklch(from var(--scalar-background-2) calc(l + .055) c h);
726
+ --scalar-card-surface-raised: var(--scalar-card-surface);
727
+ }
728
+
729
+ @supports (color: color-mix(in lab, red, red)) {
730
+ .scalar-card {
731
+ --scalar-card-surface-raised: color-mix(in oklab,
732
+ var(--scalar-card-surface),
733
+ var(--scalar-color-1) 8%);
734
+ }
735
+ }
736
+ }
737
+
738
+ .scalar-card-content:where(:not(.scalar-card-header, .scalar-card-footer)) {
739
+ background: var(--scalar-card-surface);
740
+ border-radius: var(--scalar-radius-xl);
741
+ box-shadow: var(--scalar-card-surface-shadow);
742
+ }
743
+
744
+ :where(.scalar-card-content:not(.scalar-card-header, .scalar-card-footer)) + .scalar-card-content:where(:not(.scalar-card-header, .scalar-card-footer)) {
745
+ margin-top: 4px;
746
+ }
747
+
748
+ :where(.scalar-card-header, .scalar-card-footer) {
749
+ border-radius: var(--scalar-radius-xl);
750
+ }
751
+
716
752
  .scalar-app .hljs-regexp, .scalar-app .hljs-string, .scalar-app .hljs-built_in, .scalar-app .hljs-subst, .scalar-app .hljs-name, .scalar-app .hljs-doctag, .scalar-app .hljs-section, .scalar-app .hljs-title {
717
753
  color: var(--scalar-color-blue);
718
754
  }
@@ -730,10 +766,18 @@
730
766
  background-color: var(--scalar-background-2);
731
767
  }
732
768
 
769
+ .scalar-code-block.bg-transparent .scalar-code-copy-backdrop {
770
+ background: var(--scalar-card-surface, transparent);
771
+ }
772
+
733
773
  .scalar-code-block.bg-b-2 .scalar-code-copy {
734
774
  background-color: var(--scalar-background-3);
735
775
  }
736
776
 
777
+ .scalar-code-block.bg-transparent .scalar-code-copy {
778
+ background: var(--scalar-card-surface-raised, var(--scalar-background-2));
779
+ }
780
+
737
781
  .toggle-icon-ellipse[data-v-8f507267] {
738
782
  background: var(--scalar-background-1);
739
783
  border-radius: 50%;
@@ -1921,17 +1965,17 @@
1921
1965
  border-radius: var(--scalar-radius);
1922
1966
  }
1923
1967
 
1924
- .request-card[data-v-41f67ce2], .request-card[data-v-9ef20696] {
1968
+ .request-card[data-v-aaf1efda], .request-card[data-v-3954f074] {
1925
1969
  color: var(--scalar-color-1);
1926
1970
  font-size: var(--scalar-font-size-3);
1927
1971
  }
1928
1972
 
1929
- .request-method[data-v-9ef20696] {
1973
+ .request-method[data-v-3954f074] {
1930
1974
  font-family: var(--scalar-font-code);
1931
1975
  margin-right: 6px;
1932
1976
  }
1933
1977
 
1934
- .request-card-footer[data-v-9ef20696] {
1978
+ .request-card-footer[data-v-3954f074] {
1935
1979
  flex-shrink: 0;
1936
1980
  justify-content: flex-end;
1937
1981
  padding: 6px;
@@ -1939,30 +1983,34 @@
1939
1983
  position: relative;
1940
1984
  }
1941
1985
 
1942
- .request-card-footer--wraps[data-v-9ef20696] {
1986
+ .request-card-footer--wraps[data-v-3954f074] {
1943
1987
  flex-wrap: wrap;
1944
1988
  row-gap: 4px;
1945
1989
  }
1946
1990
 
1947
- .request-card-footer-start[data-v-9ef20696] {
1991
+ .request-card-footer-start[data-v-3954f074] {
1948
1992
  flex: 1 0 auto;
1949
1993
  align-items: center;
1950
1994
  display: flex;
1951
1995
  }
1952
1996
 
1953
- .request-card-footer-addon[data-v-9ef20696] {
1997
+ .request-card-footer-addon[data-v-3954f074] {
1954
1998
  flex: 1;
1955
1999
  align-items: center;
1956
2000
  min-width: 0;
1957
2001
  display: flex;
1958
2002
  }
1959
2003
 
1960
- .request-editor-section[data-v-9ef20696] {
2004
+ .request-editor-section[data-v-3954f074] {
1961
2005
  flex: 1;
1962
2006
  display: flex;
1963
2007
  }
1964
2008
 
1965
- .request-card-simple[data-v-9ef20696] {
2009
+ .code-snippet > .scalar-code-copy[data-v-3954f074] {
2010
+ background: var(--scalar-card-surface-raised, var(--scalar-background-2));
2011
+ }
2012
+
2013
+ .request-card-simple[data-v-3954f074] {
1966
2014
  font-size: var(--scalar-small);
1967
2015
  flex-wrap: wrap;
1968
2016
  justify-content: space-between;
@@ -1972,30 +2020,30 @@
1972
2020
  display: flex;
1973
2021
  }
1974
2022
 
1975
- .request-header[data-v-9ef20696] {
2023
+ .request-header[data-v-3954f074] {
1976
2024
  overflow-wrap: anywhere;
1977
2025
  flex: 999 auto;
1978
2026
  min-width: 0;
1979
2027
  }
1980
2028
 
1981
- .request-card-actions[data-v-9ef20696] {
2029
+ .request-card-actions[data-v-3954f074] {
1982
2030
  flex: 1 0 auto;
1983
2031
  }
1984
2032
 
1985
- .code-snippet[data-v-9ef20696] {
2033
+ .code-snippet[data-v-3954f074] {
1986
2034
  flex-direction: column;
1987
2035
  width: 100%;
1988
2036
  display: flex;
1989
2037
  }
1990
2038
 
1991
- .property-example[data-v-a431d692] {
2039
+ .property-example[data-v-72248a2e] {
1992
2040
  font-size: var(--scalar-mini);
1993
2041
  flex-direction: column;
1994
2042
  display: flex;
1995
2043
  position: relative;
1996
2044
  }
1997
2045
 
1998
- .property-example[data-v-a431d692]:hover:before {
2046
+ .property-example[data-v-72248a2e]:hover:before {
1999
2047
  pointer-events: none;
2000
2048
  content: "";
2001
2049
  border-radius: var(--scalar-radius);
@@ -2006,7 +2054,7 @@
2006
2054
  left: 0;
2007
2055
  }
2008
2056
 
2009
- .property-example-value[data-v-a431d692] {
2057
+ .property-example-value[data-v-72248a2e] {
2010
2058
  font-family: var(--scalar-font-code);
2011
2059
  align-items: center;
2012
2060
  gap: 8px;
@@ -2015,28 +2063,28 @@
2015
2063
  display: flex;
2016
2064
  }
2017
2065
 
2018
- .property-example-value span[data-v-a431d692] {
2066
+ .property-example-value span[data-v-72248a2e] {
2019
2067
  text-overflow: ellipsis;
2020
2068
  white-space: pre;
2021
2069
  display: block;
2022
2070
  overflow: hidden;
2023
2071
  }
2024
2072
 
2025
- .property-example-value[data-v-a431d692] svg {
2073
+ .property-example-value[data-v-72248a2e] svg {
2026
2074
  color: var(--scalar-color-3);
2027
2075
  }
2028
2076
 
2029
- .property-example-value[data-v-a431d692]:hover svg {
2077
+ .property-example-value[data-v-72248a2e]:hover svg {
2030
2078
  color: var(--scalar-color-1);
2031
2079
  }
2032
2080
 
2033
- .property-example-value[data-v-a431d692] {
2081
+ .property-example-value[data-v-72248a2e] {
2034
2082
  background: var(--scalar-background-2);
2035
2083
  border: var(--scalar-border-width) solid var(--scalar-border-color);
2036
2084
  border-radius: var(--scalar-radius);
2037
2085
  }
2038
2086
 
2039
- .property-example-value-list[data-v-a431d692] {
2087
+ .property-example-value-list[data-v-72248a2e] {
2040
2088
  background-color: var(--scalar-background-1);
2041
2089
  box-shadow: var(--scalar-shadow-1);
2042
2090
  border-radius: var(--scalar-radius-lg);
@@ -2055,12 +2103,12 @@
2055
2103
  transform: translate(-50%);
2056
2104
  }
2057
2105
 
2058
- .property-example-value-list-start[data-v-a431d692] {
2106
+ .property-example-value-list-start[data-v-72248a2e] {
2059
2107
  left: 0;
2060
2108
  transform: none;
2061
2109
  }
2062
2110
 
2063
- .property-example:hover .property-example-value-list[data-v-a431d692] {
2111
+ .property-example:hover .property-example-value-list[data-v-72248a2e] {
2064
2112
  display: flex;
2065
2113
  }
2066
2114
 
@@ -2986,6 +3034,10 @@ code.property-detail-value[data-v-8b57daa7] {
2986
3034
  left: 0;
2987
3035
  }
2988
3036
 
3037
+ .scalar-app .left-0\.5 {
3038
+ left: 2px;
3039
+ }
3040
+
2989
3041
  .scalar-app .left-1\.75 {
2990
3042
  left: 7px;
2991
3043
  }
@@ -3807,10 +3859,6 @@ code.property-detail-value[data-v-8b57daa7] {
3807
3859
  width: 66.6667%;
3808
3860
  }
3809
3861
 
3810
- .scalar-app .w-3 {
3811
- width: 12px;
3812
- }
3813
-
3814
3862
  .scalar-app .w-4 {
3815
3863
  width: 16px;
3816
3864
  }
@@ -4050,6 +4098,11 @@ code.property-detail-value[data-v-8b57daa7] {
4050
4098
  translate: var(--tw-translate-x) var(--tw-translate-y);
4051
4099
  }
4052
4100
 
4101
+ .scalar-app .translate-x-1\.5 {
4102
+ --tw-translate-x: calc(4px * 1.5);
4103
+ translate: var(--tw-translate-x) var(--tw-translate-y);
4104
+ }
4105
+
4053
4106
  .scalar-app .translate-x-1\.25 {
4054
4107
  --tw-translate-x: calc(4px * 1.25);
4055
4108
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -4060,6 +4113,11 @@ code.property-detail-value[data-v-8b57daa7] {
4060
4113
  translate: var(--tw-translate-x) var(--tw-translate-y);
4061
4114
  }
4062
4115
 
4116
+ .scalar-app .translate-x-3 {
4117
+ --tw-translate-x: calc(4px * 3);
4118
+ translate: var(--tw-translate-x) var(--tw-translate-y);
4119
+ }
4120
+
4063
4121
  .scalar-app .translate-x-\[14px\] {
4064
4122
  --tw-translate-x: 14px;
4065
4123
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -4289,6 +4347,10 @@ code.property-detail-value[data-v-8b57daa7] {
4289
4347
  gap: 12px;
4290
4348
  }
4291
4349
 
4350
+ .scalar-app .gap-3\! {
4351
+ gap: 12px !important;
4352
+ }
4353
+
4292
4354
  .scalar-app .gap-4 {
4293
4355
  gap: 16px;
4294
4356
  }
@@ -4881,6 +4943,10 @@ code.property-detail-value[data-v-8b57daa7] {
4881
4943
  padding: 12px;
4882
4944
  }
4883
4945
 
4946
+ .scalar-app .p-3\! {
4947
+ padding: 12px !important;
4948
+ }
4949
+
4884
4950
  .scalar-app .p-4 {
4885
4951
  padding: 16px;
4886
4952
  }
@@ -7978,21 +8044,21 @@ to {
7978
8044
  background: var(--scalar-background-2);
7979
8045
  }
7980
8046
 
7981
- [data-v-6edfa5a3] .cm-editor {
8047
+ [data-v-b5b0a654] .cm-editor {
7982
8048
  height: 100%;
7983
8049
  outline: none;
7984
8050
  width: 100%;
7985
8051
  }
7986
- [data-v-6edfa5a3] .cm-line {
8052
+ [data-v-b5b0a654] .cm-line {
7987
8053
  padding: 0;
7988
8054
  }
7989
- [data-v-6edfa5a3] .cm-content {
8055
+ [data-v-b5b0a654] .cm-content {
7990
8056
  padding: 0;
7991
8057
  display: flex;
7992
8058
  align-items: center;
7993
8059
  font-size: var(--scalar-small);
7994
8060
  }
7995
- .scroll-timeline-x[data-v-6edfa5a3] {
8061
+ .scroll-timeline-x[data-v-b5b0a654] {
7996
8062
  -ms-overflow-style: none;
7997
8063
  /* Fade the URL at the viewport edges. Mask lives on the scrollport (this
7998
8064
  element) rather than on `.cm-scroller`, whose width follows the URL's
@@ -8005,31 +8071,31 @@ to {
8005
8071
  transparent 100%
8006
8072
  );
8007
8073
  }
8008
- .scroll-timeline-x-hidden[data-v-6edfa5a3] {
8074
+ .scroll-timeline-x-hidden[data-v-b5b0a654] {
8009
8075
  overflow-x: auto;
8010
8076
  }
8011
- .scroll-timeline-x-hidden[data-v-6edfa5a3] .cm-scroller {
8077
+ .scroll-timeline-x-hidden[data-v-b5b0a654] .cm-scroller {
8012
8078
  scrollbar-width: none;
8013
8079
  -ms-overflow-style: none;
8014
8080
  padding-right: 20px;
8015
8081
  overflow: auto;
8016
8082
  }
8017
- .scroll-timeline-x-hidden[data-v-6edfa5a3]::-webkit-scrollbar {
8083
+ .scroll-timeline-x-hidden[data-v-b5b0a654]::-webkit-scrollbar {
8018
8084
  width: 0;
8019
8085
  height: 0;
8020
8086
  display: none;
8021
8087
  }
8022
- .scroll-timeline-x-hidden[data-v-6edfa5a3] .cm-scroller::-webkit-scrollbar {
8088
+ .scroll-timeline-x-hidden[data-v-b5b0a654] .cm-scroller::-webkit-scrollbar {
8023
8089
  width: 0;
8024
8090
  height: 0;
8025
8091
  display: none;
8026
8092
  }
8027
- .scroll-timeline-x-address[data-v-6edfa5a3] {
8093
+ .scroll-timeline-x-address[data-v-b5b0a654] {
8028
8094
  line-height: 27px;
8029
8095
  scrollbar-width: none; /* Firefox */
8030
8096
  }
8031
8097
  /* make clickable are to left of send button */
8032
- .scroll-timeline-x-address[data-v-6edfa5a3]:after {
8098
+ .scroll-timeline-x-address[data-v-b5b0a654]:after {
8033
8099
  content: '';
8034
8100
  position: absolute;
8035
8101
  height: 100%;
@@ -8037,7 +8103,7 @@ to {
8037
8103
  right: 0;
8038
8104
  cursor: text;
8039
8105
  }
8040
- .address-bar-bg-states[data-v-6edfa5a3] {
8106
+ .address-bar-bg-states[data-v-b5b0a654] {
8041
8107
  --scalar-address-bar-bg: color-mix(
8042
8108
  in srgb,
8043
8109
  var(--scalar-background-1),
@@ -8045,22 +8111,22 @@ to {
8045
8111
  );
8046
8112
  background: var(--scalar-address-bar-bg);
8047
8113
  }
8048
- .address-bar-bg-states[data-v-6edfa5a3]:has(.cm-focused) {
8114
+ .address-bar-bg-states[data-v-b5b0a654]:has(.cm-focused) {
8049
8115
  --scalar-address-bar-bg: var(--scalar-background-1);
8050
8116
  border-color: var(--scalar-border-color);
8051
8117
  outline-width: 1px;
8052
8118
  outline-style: solid;
8053
8119
  }
8054
- .address-bar-bg-states:has(.cm-focused) .fade-left[data-v-6edfa5a3],
8055
- .address-bar-bg-states:has(.cm-focused) .fade-right[data-v-6edfa5a3] {
8120
+ .address-bar-bg-states:has(.cm-focused) .fade-left[data-v-b5b0a654],
8121
+ .address-bar-bg-states:has(.cm-focused) .fade-right[data-v-b5b0a654] {
8056
8122
  --scalar-address-bar-bg: var(--scalar-background-1);
8057
8123
  }
8058
8124
 
8059
- .app-exit-button[data-v-3a29d7a0] {
8125
+ .app-exit-button[data-v-6fb4c4d5] {
8060
8126
  color: white;
8061
8127
  background: rgba(0, 0, 0, 0.1);
8062
8128
  }
8063
- .app-exit-button[data-v-3a29d7a0]:hover {
8129
+ .app-exit-button[data-v-6fb4c4d5]:hover {
8064
8130
  background: rgba(255, 255, 255, 0.1);
8065
8131
  }
8066
8132
  /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@@ -1 +1 @@
1
- {"version":3,"file":"OperationBlock.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"OperationBlock.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"OperationBlock.vue.js","names":["_sfc_main"],"sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * OperationBlock\n *\n * Orchestrates the operation view by wiring together the Header, OperationBlock,\n * and ResponseBlock. Forwards user interactions to the workspace event bus and\n * passes through configuration such as auth, servers, plugins, and environment.\n * This component keeps the Operation page lean by centralizing event emission\n * and prop wiring between the blocks.\n *\n * Notable behavior:\n * - Uses operation['x-scalar-method'] and operation['x-scalar-path'] to provide\n * draft overrides for the UI when present.\n */\nexport default {\n name: 'OperationBlock',\n}\n\nexport type OperationBlockProps = {\n /** Keep execution and editing unavailable until the selected payload is ready. */\n externalExamplesPending?: boolean\n externalExamplesFailed?: boolean\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Application version */\n appVersion: string\n /** Openapi document */\n document: OpenApiDocument\n /** Openapi document slug */\n documentSlug: string\n /** Workspace cookies */\n workspaceCookies: XScalarCookie[]\n /** Document cookies */\n documentCookies: XScalarCookie[]\n /** Current request path */\n path: string\n /** Current request method */\n method: string\n /** Whether `path` identifies an OpenAPI webhook. */\n isWebhook?: boolean\n /** HTTP clients */\n httpClients: AvailableClients\n /** The history for the operation */\n history?: HistoryEntry[]\n /** Client layout */\n layout: ClientLayout\n /** Currently selected server */\n server: ServerObject | null\n /** Currently selected client */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** Meta information for the server */\n serverMeta: ServerMeta\n /** Hides the client button on the header */\n hideClientButton?: boolean\n /** Client integration */\n integration?: string | null\n /** Openapi document url for `modal` mode to open the client app */\n documentUrl?: string\n /** Client source */\n source?: 'gitbook' | 'api-reference'\n /** Operation object */\n operation: OperationObject\n /** Operation before downloaded examples are overlaid, for parameter edit targets. */\n sourceOperation?: OperationObject\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Meta information for the auth update */\n authMeta: AuthMeta\n /** Document defined security schemes */\n securitySchemes: MergedSecuritySchemes\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Environment list */\n environments?: string[]\n /** Currently selected environment */\n activeEnvironment?: string\n /** For environment variables in the inputs */\n environment: XScalarEnvironment\n /** The proxy URL for sending requests */\n proxyUrl: string\n /** Currently selected security */\n selectedSecurity: SelectedSecurity\n /** Currently selected security schemes */\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n /** Security requirements */\n securityRequirements: OpenApiDocument['security']\n /** Default headers */\n defaultHeaders: Record<string, string>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n}\n</script>\n<script setup lang=\"ts\">\nimport { generateClientOptions } from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ERRORS } from '@scalar/helpers/errors/normalize-error'\nimport { isElectron } from '@scalar/helpers/general/is-electron'\nimport { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport { isForbiddenHttpMethod } from '@scalar/helpers/http/is-forbidden-http-method'\nimport {\n executeHook,\n executeResponseHook,\n type ClientPlugin,\n} from '@scalar/oas-utils/helpers'\nimport {\n AVAILABLE_CLIENTS,\n type AvailableClients,\n} from '@scalar/types/snippetz'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { HistoryEntry } from '@scalar/workspace-store/entities/history/schema'\nimport type {\n AuthMeta,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n buildRequest,\n createVariablesStoreForRequest,\n getEnvironmentVariables,\n requestFactory,\n resolveExecutableRequestUrl,\n type MergedSecuritySchemes,\n type RequestPayload,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/operation'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n toValue,\n watch,\n} from 'vue'\n\nimport ViewLayout from '@/components/ViewLayout/ViewLayout.vue'\nimport ViewLayoutContent from '@/components/ViewLayout/ViewLayoutContent.vue'\nimport ViewLayoutSection from '@/components/ViewLayout/ViewLayoutSection.vue'\nimport { harToFetchRequest } from '@/v2/blocks/operation-block/helpers/har-to-fetch-request'\nimport { harToFetchResponse } from '@/v2/blocks/operation-block/helpers/har-to-fetch-response'\nimport {\n getCookieRequestUrl,\n getResponseCookieActions,\n} from '@/v2/blocks/operation-block/helpers/persist-response-cookies'\nimport { getEnvironmentPersistenceActions } from '@/v2/blocks/operation-block/helpers/persist-script-environment'\nimport {\n getOperationExampleKey,\n isStreamingResponse,\n responseCache,\n} from '@/v2/blocks/operation-block/helpers/response-cache'\nimport {\n sendRequest,\n type ResponseInstance,\n} from '@/v2/blocks/operation-block/helpers/send-request'\nimport { validatePathParameters } from '@/v2/blocks/operation-block/helpers/validate-path-parameters'\nimport { RequestBlock } from '@/v2/blocks/request-block'\nimport { ResponseBlock } from '@/v2/blocks/response-block'\nimport { type History } from '@/v2/blocks/scalar-address-bar-block'\nimport { useLocalization } from '@/v2/features/localization'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport Header from './components/Header.vue'\n\nconst {\n externalExamplesPending = false,\n externalExamplesFailed = false,\n authMeta,\n environment,\n eventBus,\n exampleKey,\n document,\n documentSlug,\n workspaceCookies = [],\n documentCookies = [],\n hideClientButton,\n httpClients = AVAILABLE_CLIENTS,\n history = [],\n layout,\n method,\n isWebhook = false,\n operation,\n sourceOperation,\n path,\n plugins = [],\n proxyUrl,\n requestBodyCompositionSelection,\n securitySchemes,\n selectedClient,\n server,\n servers,\n environments,\n options,\n activeEnvironment,\n serverMeta,\n selectedSecurity,\n selectedSecuritySchemes,\n securityRequirements,\n defaultHeaders,\n} = defineProps<OperationBlockProps>()\n\ndefineEmits<{ (e: 'retry:externalExamples'): void }>()\n\nconst { translate } = useLocalization()\n\n/** Hoist up client generation so it doesn't get re-generated on every operation */\nconst clientOptions = computed(() => generateClientOptions(httpClients))\n\nconst { toast } = useToasts()\nconst { copyToClipboard } = useClipboard()\n\n// Refs\nconst abortController = ref<AbortController | null>(null)\nconst response = ref<ResponseInstance | null>(null)\nconst requestError = ref<Error | null>(null)\nconst requestPayload = ref<RequestPayload | null>(null)\n\n/**\n * A webhook has no OpenAPI server, so its destination is the full URL the user\n * enters at runtime. The field holds that whole URL (not a server-relative path),\n * and the request is sent to it directly with no separate server base.\n */\nconst webhookUrl = ref('')\n\nwatch(\n [() => path, () => method, () => isWebhook],\n () => {\n webhookUrl.value = ''\n },\n { immediate: true },\n)\n\nconst requestPath = computed(() => (isWebhook ? webhookUrl.value : path))\nconst requestServer = computed<ServerObject | null>(() =>\n isWebhook ? null : server,\n)\n\n/** Cancel the request */\nconst cancelRequest = () => abortController.value?.abort(ERRORS.REQUEST_ABORTED)\n\n/**\n * Persist server-set cookies from a response into the document cookie jar.\n *\n * Scalar keeps its own cookie jar because browsers hide `Set-Cookie` from `fetch`.\n * Mirroring browser behavior, cookies are stored scoped to the request host and\n * path and removed when the server expires them, so a value like a Django CSRF\n * token stays available for later PUT/PATCH requests after a page reload.\n */\nconst persistResponseCookies = (sendResult: {\n response: ResponseInstance\n requestPayload: RequestPayload\n}) => {\n const actions = getResponseCookieActions({\n cookieHeaderKeys: sendResult.response.cookieHeaderKeys ?? [],\n documentCookies,\n requestUrl: getCookieRequestUrl(String(sendResult.requestPayload[0])),\n })\n\n for (const action of actions) {\n if (action.type === 'delete') {\n eventBus.emit('cookie:delete:cookie', {\n collectionType: 'document',\n cookieName: action.cookieName,\n index: action.index,\n })\n continue\n }\n\n eventBus.emit('cookie:upsert:cookie', {\n collectionType: 'document',\n payload: action.cookie,\n ...(action.index === undefined ? {} : { index: action.index }),\n })\n }\n}\n\n/**\n * Copy the executable URL — same pipeline as Send (`requestFactory` +\n * `resolveExecutableRequestUrl`), including security query params.\n */\nconst copyAddressBarUrl = async (): Promise<void> => {\n const { request } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies: [...workspaceCookies, ...documentCookies],\n method,\n operation,\n path: requestPath.value,\n proxyUrl,\n server: requestServer.value,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n openapiVersion: document.openapi,\n requestBodyCompositionSelection,\n })\n\n await copyToClipboard(\n resolveExecutableRequestUrl(request, getEnvironmentVariables(environment)),\n )\n}\n\n/** Execute the current operation example */\nconst handleExecute = async () => {\n if (externalExamplesPending) return\n requestError.value = null\n eventBus.flushDebouncedEmits?.()\n // Source edits must reach the overlaid operation prop before building the request.\n await nextTick()\n\n if (isWebhook && !requestPath.value.trim()) {\n toast(translate('apiClient.operationBlock.webhookUrlRequired'), 'error')\n return\n }\n\n const pathValidation = validatePathParameters(\n operation.parameters ?? [],\n exampleKey,\n )\n if (pathValidation.ok === false) {\n toast(translate('apiClient.operationBlock.pathParametersRequired'), 'error')\n return\n }\n\n const globalCookies = [...workspaceCookies, ...documentCookies]\n\n const { request: requestBuilder } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies,\n method,\n operation,\n path: requestPath.value,\n proxyUrl,\n server: requestServer.value,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n openapiVersion: document.openapi,\n requestBodyCompositionSelection,\n })\n\n // Stop any previous streaming response\n if (response.value && 'reader' in response.value) {\n response.value.reader.cancel()\n }\n\n const variablesStore = createVariablesStoreForRequest()\n\n // Seed the script variable store with the active environment so pm.environment.get()\n // and pm.variables.get() resolve to the same values as {{…}} placeholders. Without\n // seeding, the store starts empty and every scripted read returns undefined.\n const seededEnvironment = getEnvironmentVariables(environment)\n variablesStore.setEnvironment?.(\n Object.entries(seededEnvironment).map(([key, value]) => ({ key, value })),\n )\n\n // Snapshot the persistence target at request start, alongside the seed. Persistence runs after\n // the request completes (awaits below), and the environment props are reactive — if the active\n // environment is switched mid-flight, or a concurrent request splices these arrays, reading\n // them at persist time would apply the script's writes to the wrong environment or resolve\n // workspace/document indexes against a shifted list. Copy the arrays (not just the reference)\n // so the seeded values and these targets stay fixed to the same point in time.\n const persistenceTarget = activeEnvironment\n ? {\n environmentName: activeEnvironment,\n mergedVariables: [...environment.variables],\n documentVariables: [\n ...(document['x-scalar-environments']?.[activeEnvironment]\n ?.variables ?? []),\n ],\n environmentExistsOnDocument: Boolean(\n document['x-scalar-environments']?.[activeEnvironment],\n ),\n }\n : null\n\n // Execute the beforeRequest hook (plugins receive RequestFactory, not fetch Request)\n await executeHook(\n {\n requestBuilder,\n document,\n operation,\n variablesStore,\n server: requestServer.value,\n customFetch: toValue(options)?.customFetch,\n },\n 'beforeRequest',\n plugins,\n )\n\n // Persist environment variables set by scripts (pm.environment.set / unset) back to the active\n // environment so they survive to the next request, mirroring the Environment tab. Scope and\n // index are resolved from the seed-time environment so updates mutate in place. Defined here so\n // it can run on every exit path after the pre-request scripts — including a build failure or a\n // failed send — so a pre-request set, like a token stored before a flaky call, is not lost.\n const persistScriptEnvironment = () => {\n if (!persistenceTarget) {\n return\n }\n\n const environmentActions = getEnvironmentPersistenceActions({\n ...persistenceTarget,\n seededVariables: seededEnvironment,\n scriptVariables: variablesStore.getEnvironment(),\n })\n\n for (const action of environmentActions) {\n if (action.type === 'delete') {\n eventBus.emit('environment:delete:environment-variable', {\n environmentName: action.environmentName,\n index: action.index,\n collectionType: action.collectionType,\n })\n } else {\n eventBus.emit('environment:upsert:environment-variable', {\n environmentName: action.environmentName,\n variable: action.variable,\n index: action.index,\n collectionType: action.collectionType,\n })\n }\n }\n }\n\n // Resolve {{…}} placeholders from the script store so pre-request pm.environment.set() and\n // unset() take effect on this request. The store was seeded from the active environment, so\n // it already holds every value spreading seededEnvironment would add — minus the keys a script\n // unset, which must stay dropped (an object spread cannot remove them again).\n const envVariables = variablesStore.getVariables()\n\n // Build the fetch Request after hooks may have mutated the factory\n const built = buildRequest(requestBuilder, {\n envVariables,\n allowMissingRequestServerBase: layout === 'modal',\n })\n if (!built.ok) {\n // Save any pre-request script writes before bailing out on a build failure.\n persistScriptEnvironment()\n toast(built.message ?? built.error, 'error')\n return\n }\n\n // Check the final method because pre-request scripts can change it.\n const requestMethod = built.data.requestPayload[1].method ?? 'GET'\n if (isForbiddenHttpMethod(requestMethod)) {\n persistScriptEnvironment()\n toast(\n translate('apiClient.operationBlock.forbiddenMethod', {\n method: requestMethod.toUpperCase(),\n }),\n 'error',\n )\n return\n }\n\n // Store the abort controller for cancellation\n abortController.value = built.data.controller\n\n // Build the fetch Request once so the requestBuilt hook observes the exact bytes that are\n // sent. Rebuilding it later would generate a different multipart boundary, which breaks\n // plugins that hash the body (for example, request signing).\n const request = buildSafeBodyRequest(...built.data.requestPayload)\n\n // Execute the requestBuilt hook (plugins receive the exact fetch Request that will be sent)\n await executeHook(\n {\n request,\n requestBuilder,\n document,\n operation,\n variablesStore,\n },\n 'requestBuilt',\n plugins,\n )\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:sent', {\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n /** Execute the request */\n const [sendError, sendResult] = await sendRequest({\n isUsingProxy: built.data.isUsingProxy,\n requestPayload: built.data.requestPayload,\n request,\n plugins,\n customFetch: toValue(options)?.customFetch,\n onResponseReceived: async (response, responseDuration) => {\n const result = await executeResponseHook(\n {\n response,\n responseDuration,\n requestBuilder,\n request: buildSafeBodyRequest(...built.data.requestPayload),\n document,\n operation,\n variablesStore,\n },\n plugins,\n )\n return result.response\n },\n })\n\n // Save script environment writes (pre-request and, on success, post-response) back to the\n // active environment. Runs even when the send fails so a pre-request set is not lost.\n persistScriptEnvironment()\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:complete', {\n payload: sendResult\n ? {\n response: sendResult.originalResponse.clone(),\n requestPayload: sendResult.requestPayload,\n duration: sendResult.response.duration,\n timestamp: sendResult.timestamp,\n }\n : undefined,\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n if (sendError) {\n // Cancellation also happens when navigating away; keep the new operation intact.\n if (built.data.controller.signal.aborted) {\n if (abortController.value === built.data.controller) {\n abortController.value = null\n }\n return\n }\n requestError.value = sendError\n // clean up the response and request\n response.value = null\n requestPayload.value = null\n abortController.value = null\n\n toast(sendError.message, 'error')\n return\n }\n\n // Store the response\n response.value = sendResult.response\n requestPayload.value = sendResult.requestPayload\n\n // Persist server-set cookies into the document jar so values like a CSRF token\n // survive a page reload and get replayed on the next request, like a browser would.\n persistResponseCookies(sendResult)\n\n // Cache non-streaming responses so they can be restored when navigating back\n if (!isStreamingResponse(sendResult.response)) {\n responseCache.set(getOperationExampleKey(method, path, exampleKey), {\n response: sendResult.response,\n requestPayload: sendResult.requestPayload,\n })\n }\n}\n\nonMounted(() => {\n eventBus.on('operation:send:request:hotkey', handleExecute)\n eventBus.on('operation:cancel:request', cancelRequest)\n eventBus.on('copy-url:address-bar', copyAddressBarUrl)\n\n // Let plugins warm up per-operation resources (e.g. the scripts sandbox) so the first request\n // does not pay their cold-start cost.\n void executeHook({ document, operation }, 'onRequestMount', plugins)\n})\nonBeforeUnmount(() => {\n eventBus.off('operation:send:request:hotkey', handleExecute)\n eventBus.off('operation:cancel:request', cancelRequest)\n eventBus.off('copy-url:address-bar', copyAddressBarUrl)\n})\n\nconst operationHistory = computed<History[]>(() =>\n history\n .map((entry) => ({\n method: entry.request.method as string,\n path: entry.request.url,\n duration: entry.time,\n status: entry.response.status,\n }))\n .reverse(),\n)\n\nconst handleSelectHistoryItem = ({ index }: { index: number }) => {\n const transformedIndex = (history.length ?? 0) - index - 1\n const historyItem = history[transformedIndex]\n if (!historyItem) {\n return\n }\n\n const navigate = () =>\n eventBus.emit('ui:navigate', {\n page: 'example',\n method,\n path,\n exampleName: 'draft',\n callback: (status) => {\n // Do not replace the response if the navigation was not successful\n if (status !== 'success') {\n return\n }\n // Reconstruct the response\n const fetchResponse = harToFetchResponse({\n harResponse: historyItem.response,\n url: historyItem.request.url,\n method,\n path,\n duration: historyItem.time,\n })\n\n // Reconstruct the request\n const fetchRequest = harToFetchRequest({\n harRequest: historyItem.request,\n })\n\n // Update the response and request\n requestError.value = null\n response.value = fetchResponse\n requestPayload.value = fetchRequest\n },\n })\n\n eventBus.emit('operation:reload:history', {\n meta: {\n path,\n method,\n },\n index: transformedIndex,\n callback: navigate,\n })\n}\n\nconst handleNavigateSettings = () => {\n eventBus.emit('ui:navigate', {\n page: 'operation',\n path: 'overview',\n operationPath: path,\n method,\n })\n}\n\n/**\n * When the path, method, or example key changes, restore the response panel\n * for the new operation from the best available source:\n *\n * 1. `responseCache` — in-memory, populated on every successful send.\n * Has the live response object (including streams) so it wins.\n * 2. `history` — persisted in the workspace store. Used as a fallback when\n * the in-memory cache is empty (page reload, fresh app session, etc.)\n * so navigating to an operation that has been called before shows the\n * last response instead of an empty panel.\n * 3. Otherwise clear.\n *\n * Only the response is restored from history — the user's request inputs are\n * left alone, so we never silently overwrite an in-progress draft.\n */\nwatch(\n [() => path, () => method, () => exampleKey],\n ([newPath, newMethod, newExampleKey]) => {\n requestError.value = null\n const cached = responseCache.get(\n getOperationExampleKey(newMethod, newPath, newExampleKey),\n )\n\n if (cached) {\n response.value = cached.response\n requestPayload.value = cached.requestPayload\n } else {\n // History is keyed only by document/path/method but each entry carries\n // the example it came from, so we walk from the end and pick the most\n // recent entry that matches the active example. Otherwise a cache miss\n // on example B would restore example A's response. Only runs on a\n // cache miss — the common case (in-session navigation) skips it.\n const latest = (() => {\n for (let i = history.length - 1; i >= 0; i--) {\n const entry = history[i]\n if (entry?.meta.example === newExampleKey) {\n return entry\n }\n }\n return undefined\n })()\n\n if (latest) {\n response.value = harToFetchResponse({\n harResponse: latest.response,\n url: latest.request.url,\n method: newMethod,\n path: newPath,\n duration: latest.time,\n })\n requestPayload.value = null\n } else {\n response.value = null\n requestPayload.value = null\n }\n }\n\n // Cancel any in-flight request\n cancelRequest()\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n // We cancel the request if the component is unmounted\n cancelRequest()\n})\n</script>\n<template>\n <div class=\"bg-b-1 flex h-full min-w-0 flex-col\">\n <div\n class=\"lg:min-h-header flex w-full flex-wrap items-center justify-center p-2 lg:p-0\">\n <!-- Address Bar -->\n <Header\n :activeEnvironment\n :documentSlug\n :documentUrl\n :environment\n :environments\n :eventBus\n :exampleKey\n :executionDisabled=\"externalExamplesPending\"\n :hideClientButton\n :history=\"operationHistory\"\n :integration\n :isWebhook\n :layout\n :method\n :path=\"requestPath\"\n :server=\"requestServer\"\n :serverMeta\n :servers\n :source\n @execute=\"handleExecute\"\n @navigate:settings=\"handleNavigateSettings\"\n @select:history:item=\"handleSelectHistoryItem\"\n @update:webhookUrl=\"(value: string) => (webhookUrl = value)\" />\n </div>\n\n <ViewLayout class=\"border-t\">\n <ViewLayoutContent class=\"flex-1\">\n <!-- Request Section -->\n <ViewLayoutSection\n v-if=\"externalExamplesPending\"\n aria-label=\"Request\">\n <template #title>Request</template>\n <div\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamplesFailed\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"$emit('retry:externalExamples')\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n </ViewLayoutSection>\n <RequestBlock\n v-else\n :allowedSecuritySchemes=\"\n toValue(options)?.authentication?.allowedSecuritySchemes\n \"\n :authMeta\n :clientOptions\n :defaultHeaders\n :defaultRequestBodyView=\"\n document['x-scalar-default-request-body-view']\n \"\n :documentCookies\n :documentSlug\n :environment\n :eventBus\n :exampleKey\n :layout\n :method\n :openapiVersion=\"document.openapi\"\n :operation\n :options=\"toValue(options)\"\n :path=\"requestPath\"\n :plugins\n :proxyUrl\n :requestBodyCompositionSelection\n :securityRequirements\n :securitySchemes\n :selectedClient\n :selectedSecurity\n :selectedSecuritySchemes\n :server=\"requestServer\"\n :sourceOperation\n :workspaceCookies />\n\n <!-- Response Section -->\n <ResponseBlock\n :appVersion\n :eventBus\n :executionDisabled=\"externalExamplesPending\"\n :layout\n :plugins\n :requestError\n :requestPayload\n :response\n :totalPerformedRequests=\"operationHistory.length\" />\n </ViewLayoutContent>\n </ViewLayout>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"OperationBlock.vue.js","names":["_sfc_main"],"sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * OperationBlock\n *\n * Orchestrates the operation view by wiring together the Header, OperationBlock,\n * and ResponseBlock. Forwards user interactions to the workspace event bus and\n * passes through configuration such as auth, servers, plugins, and environment.\n * This component keeps the Operation page lean by centralizing event emission\n * and prop wiring between the blocks.\n *\n * Notable behavior:\n * - Uses operation['x-scalar-method'] and operation['x-scalar-path'] to provide\n * draft overrides for the UI when present.\n */\nexport default {\n name: 'OperationBlock',\n}\n\nexport type OperationBlockProps = {\n /** Keep execution and editing unavailable until the selected payload is ready. */\n externalExamplesPending?: boolean\n externalExamplesFailed?: boolean\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Application version */\n appVersion: string\n /** Openapi document */\n document: OpenApiDocument\n /** Openapi document slug */\n documentSlug: string\n /** Workspace cookies */\n workspaceCookies: XScalarCookie[]\n /** Document cookies */\n documentCookies: XScalarCookie[]\n /** Current request path */\n path: string\n /** Current request method */\n method: string\n /** Whether `path` identifies an OpenAPI webhook. */\n isWebhook?: boolean\n /** HTTP clients */\n httpClients: AvailableClients\n /** The history for the operation */\n history?: HistoryEntry[]\n /** Client layout */\n layout: ClientLayout\n /** Currently selected server */\n server: ServerObject | null\n /** Currently selected client */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** Meta information for the server */\n serverMeta: ServerMeta\n /** Hides the client button on the header */\n hideClientButton?: boolean\n /** Client integration */\n integration?: string | null\n /** Openapi document url for `modal` mode to open the client app */\n documentUrl?: string\n /** Client source */\n source?: 'gitbook' | 'api-reference'\n /** Operation object */\n operation: OperationObject\n /** Operation before downloaded examples are overlaid, for parameter edit targets. */\n sourceOperation?: OperationObject\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Meta information for the auth update */\n authMeta: AuthMeta\n /** Document defined security schemes */\n securitySchemes: MergedSecuritySchemes\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Environment list */\n environments?: string[]\n /** Currently selected environment */\n activeEnvironment?: string\n /** For environment variables in the inputs */\n environment: XScalarEnvironment\n /** The proxy URL for sending requests */\n proxyUrl: string\n /** Currently selected security */\n selectedSecurity: SelectedSecurity\n /** Currently selected security schemes */\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n /** Security requirements */\n securityRequirements: OpenApiDocument['security']\n /** Default headers */\n defaultHeaders: Record<string, string>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n}\n</script>\n<script setup lang=\"ts\">\nimport { generateClientOptions } from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ERRORS } from '@scalar/helpers/errors/normalize-error'\nimport { isElectron } from '@scalar/helpers/general/is-electron'\nimport { isAllowedOAuthUrl } from '@scalar/helpers/url/is-allowed-oauth-url'\nimport { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport { isForbiddenHttpMethod } from '@scalar/helpers/http/is-forbidden-http-method'\nimport {\n executeHook,\n executeResponseHook,\n type ClientPlugin,\n} from '@scalar/oas-utils/helpers'\nimport {\n AVAILABLE_CLIENTS,\n type AvailableClients,\n} from '@scalar/types/snippetz'\nimport { useClipboard } from '@scalar/use-hooks/useClipboard'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { HistoryEntry } from '@scalar/workspace-store/entities/history/schema'\nimport type {\n AuthMeta,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n buildRequest,\n createVariablesStoreForRequest,\n getEnvironmentVariables,\n requestFactory,\n resolveExecutableRequestUrl,\n type MergedSecuritySchemes,\n type RequestPayload,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/operation'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n toValue,\n watch,\n} from 'vue'\n\nimport ViewLayout from '@/components/ViewLayout/ViewLayout.vue'\nimport ViewLayoutContent from '@/components/ViewLayout/ViewLayoutContent.vue'\nimport ViewLayoutSection from '@/components/ViewLayout/ViewLayoutSection.vue'\nimport { harToFetchRequest } from '@/v2/blocks/operation-block/helpers/har-to-fetch-request'\nimport { harToFetchResponse } from '@/v2/blocks/operation-block/helpers/har-to-fetch-response'\nimport {\n getCookieRequestUrl,\n getResponseCookieActions,\n} from '@/v2/blocks/operation-block/helpers/persist-response-cookies'\nimport { getEnvironmentPersistenceActions } from '@/v2/blocks/operation-block/helpers/persist-script-environment'\nimport {\n getOperationExampleKey,\n isStreamingResponse,\n responseCache,\n} from '@/v2/blocks/operation-block/helpers/response-cache'\nimport {\n sendRequest,\n type ResponseInstance,\n} from '@/v2/blocks/operation-block/helpers/send-request'\nimport { validatePathParameters } from '@/v2/blocks/operation-block/helpers/validate-path-parameters'\nimport { RequestBlock } from '@/v2/blocks/request-block'\nimport { ResponseBlock } from '@/v2/blocks/response-block'\nimport { type History } from '@/v2/blocks/scalar-address-bar-block'\nimport { useLocalization } from '@/v2/features/localization'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport Header from './components/Header.vue'\n\nconst {\n externalExamplesPending = false,\n externalExamplesFailed = false,\n authMeta,\n environment,\n eventBus,\n exampleKey,\n document,\n documentSlug,\n workspaceCookies = [],\n documentCookies = [],\n hideClientButton,\n httpClients = AVAILABLE_CLIENTS,\n history = [],\n layout,\n method,\n isWebhook = false,\n operation,\n sourceOperation,\n path,\n plugins = [],\n proxyUrl,\n requestBodyCompositionSelection,\n securitySchemes,\n selectedClient,\n server,\n servers,\n environments,\n options,\n activeEnvironment,\n serverMeta,\n selectedSecurity,\n selectedSecuritySchemes,\n securityRequirements,\n defaultHeaders,\n} = defineProps<OperationBlockProps>()\n\ndefineEmits<{ (e: 'retry:externalExamples'): void }>()\n\nconst { translate } = useLocalization()\n\n/** Hoist up client generation so it doesn't get re-generated on every operation */\nconst clientOptions = computed(() => generateClientOptions(httpClients))\n\nconst { toast } = useToasts()\nconst { copyToClipboard } = useClipboard()\n\n// Refs\nconst abortController = ref<AbortController | null>(null)\nconst response = ref<ResponseInstance | null>(null)\nconst requestError = ref<Error | null>(null)\nconst requestPayload = ref<RequestPayload | null>(null)\n\n/**\n * A webhook has no OpenAPI server, so its destination is the full URL the user\n * enters at runtime. The field holds that whole URL (not a server-relative path),\n * and the request is sent to it directly with no separate server base.\n */\nconst webhookUrl = ref('')\n\nwatch(\n [() => path, () => method, () => isWebhook],\n () => {\n webhookUrl.value = ''\n },\n { immediate: true },\n)\n\nconst requestPath = computed(() => (isWebhook ? webhookUrl.value : path))\nconst requestServer = computed<ServerObject | null>(() =>\n isWebhook ? null : server,\n)\n\n/** Cancel the request */\nconst cancelRequest = () => abortController.value?.abort(ERRORS.REQUEST_ABORTED)\n\n/**\n * Persist server-set cookies from a response into the document cookie jar.\n *\n * Scalar keeps its own cookie jar because browsers hide `Set-Cookie` from `fetch`.\n * Mirroring browser behavior, cookies are stored scoped to the request host and\n * path and removed when the server expires them, so a value like a Django CSRF\n * token stays available for later PUT/PATCH requests after a page reload.\n */\nconst persistResponseCookies = (sendResult: {\n response: ResponseInstance\n requestPayload: RequestPayload\n}) => {\n const actions = getResponseCookieActions({\n cookieHeaderKeys: sendResult.response.cookieHeaderKeys ?? [],\n documentCookies,\n requestUrl: getCookieRequestUrl(String(sendResult.requestPayload[0])),\n })\n\n for (const action of actions) {\n if (action.type === 'delete') {\n eventBus.emit('cookie:delete:cookie', {\n collectionType: 'document',\n cookieName: action.cookieName,\n index: action.index,\n })\n continue\n }\n\n eventBus.emit('cookie:upsert:cookie', {\n collectionType: 'document',\n payload: action.cookie,\n ...(action.index === undefined ? {} : { index: action.index }),\n })\n }\n}\n\n/**\n * Resolve the executable URL using the same pipeline as Send (`requestFactory` +\n * `resolveExecutableRequestUrl`), including security query params.\n */\nconst getAddressBarUrl = (allowMissingRequestServerBase = true): string => {\n const { request } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies: [...workspaceCookies, ...documentCookies],\n method,\n operation,\n path: requestPath.value,\n proxyUrl,\n server: requestServer.value,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n openapiVersion: document.openapi,\n requestBodyCompositionSelection,\n })\n\n return resolveExecutableRequestUrl(\n request,\n getEnvironmentVariables(environment),\n { allowMissingRequestServerBase },\n )\n}\n\n/** Copy remains permissive so incomplete URLs can still be shared or edited. */\nconst copyAddressBarUrl = async (): Promise<void> => {\n await copyToClipboard(getAddressBarUrl())\n}\n\n/** Browser navigation uses the destination URL and the browser's own session. */\nconst openInBrowser = async (): Promise<void> => {\n if (method.toLowerCase() !== 'get' || externalExamplesPending) return\n\n eventBus.flushDebouncedEmits?.()\n // Apply pending parameter and address-bar edits before resolving the destination.\n await nextTick()\n\n if (!validatePathParameters(operation.parameters ?? [], exampleKey).ok) {\n toast(translate('apiClient.operationBlock.pathParametersRequired'), 'error')\n return\n }\n\n try {\n const url = new URL(getAddressBarUrl(layout === 'modal' && !isWebhook))\n // A request URL is untrusted input; navigation must never execute another scheme.\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n toast(translate('apiClient.addressBar.browserUrlRequired'), 'error')\n return\n }\n // Match Electron's external-navigation policy instead of silently dropping the action.\n if (isElectron() && !isAllowedOAuthUrl(url)) {\n toast(\n translate('apiClient.addressBar.desktopBrowserUrlRequired'),\n 'error',\n )\n return\n }\n window.open(url.href, '_blank', 'noopener,noreferrer')\n } catch {\n toast(translate('apiClient.addressBar.browserUrlRequired'), 'error')\n }\n}\n\n/** Execute the current operation example */\nconst handleExecute = async () => {\n if (externalExamplesPending) return\n requestError.value = null\n eventBus.flushDebouncedEmits?.()\n // Source edits must reach the overlaid operation prop before building the request.\n await nextTick()\n\n if (isWebhook && !requestPath.value.trim()) {\n toast(translate('apiClient.operationBlock.webhookUrlRequired'), 'error')\n return\n }\n\n const pathValidation = validatePathParameters(\n operation.parameters ?? [],\n exampleKey,\n )\n if (pathValidation.ok === false) {\n toast(translate('apiClient.operationBlock.pathParametersRequired'), 'error')\n return\n }\n\n const globalCookies = [...workspaceCookies, ...documentCookies]\n\n const { request: requestBuilder } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies,\n method,\n operation,\n path: requestPath.value,\n proxyUrl,\n server: requestServer.value,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n openapiVersion: document.openapi,\n requestBodyCompositionSelection,\n })\n\n // Stop any previous streaming response\n if (response.value && 'reader' in response.value) {\n response.value.reader.cancel()\n }\n\n const variablesStore = createVariablesStoreForRequest()\n\n // Seed the script variable store with the active environment so pm.environment.get()\n // and pm.variables.get() resolve to the same values as {{…}} placeholders. Without\n // seeding, the store starts empty and every scripted read returns undefined.\n const seededEnvironment = getEnvironmentVariables(environment)\n variablesStore.setEnvironment?.(\n Object.entries(seededEnvironment).map(([key, value]) => ({ key, value })),\n )\n\n // Snapshot the persistence target at request start, alongside the seed. Persistence runs after\n // the request completes (awaits below), and the environment props are reactive — if the active\n // environment is switched mid-flight, or a concurrent request splices these arrays, reading\n // them at persist time would apply the script's writes to the wrong environment or resolve\n // workspace/document indexes against a shifted list. Copy the arrays (not just the reference)\n // so the seeded values and these targets stay fixed to the same point in time.\n const persistenceTarget = activeEnvironment\n ? {\n environmentName: activeEnvironment,\n mergedVariables: [...environment.variables],\n documentVariables: [\n ...(document['x-scalar-environments']?.[activeEnvironment]\n ?.variables ?? []),\n ],\n environmentExistsOnDocument: Boolean(\n document['x-scalar-environments']?.[activeEnvironment],\n ),\n }\n : null\n\n // Execute the beforeRequest hook (plugins receive RequestFactory, not fetch Request)\n await executeHook(\n {\n requestBuilder,\n document,\n operation,\n variablesStore,\n server: requestServer.value,\n customFetch: toValue(options)?.customFetch,\n },\n 'beforeRequest',\n plugins,\n )\n\n // Persist environment variables set by scripts (pm.environment.set / unset) back to the active\n // environment so they survive to the next request, mirroring the Environment tab. Scope and\n // index are resolved from the seed-time environment so updates mutate in place. Defined here so\n // it can run on every exit path after the pre-request scripts — including a build failure or a\n // failed send — so a pre-request set, like a token stored before a flaky call, is not lost.\n const persistScriptEnvironment = () => {\n if (!persistenceTarget) {\n return\n }\n\n const environmentActions = getEnvironmentPersistenceActions({\n ...persistenceTarget,\n seededVariables: seededEnvironment,\n scriptVariables: variablesStore.getEnvironment(),\n })\n\n for (const action of environmentActions) {\n if (action.type === 'delete') {\n eventBus.emit('environment:delete:environment-variable', {\n environmentName: action.environmentName,\n index: action.index,\n collectionType: action.collectionType,\n })\n } else {\n eventBus.emit('environment:upsert:environment-variable', {\n environmentName: action.environmentName,\n variable: action.variable,\n index: action.index,\n collectionType: action.collectionType,\n })\n }\n }\n }\n\n // Resolve {{…}} placeholders from the script store so pre-request pm.environment.set() and\n // unset() take effect on this request. The store was seeded from the active environment, so\n // it already holds every value spreading seededEnvironment would add — minus the keys a script\n // unset, which must stay dropped (an object spread cannot remove them again).\n const envVariables = variablesStore.getVariables()\n\n // Build the fetch Request after hooks may have mutated the factory\n const built = buildRequest(requestBuilder, {\n envVariables,\n allowMissingRequestServerBase: layout === 'modal',\n })\n if (!built.ok) {\n // Save any pre-request script writes before bailing out on a build failure.\n persistScriptEnvironment()\n toast(built.message ?? built.error, 'error')\n return\n }\n\n // Check the final method because pre-request scripts can change it.\n const requestMethod = built.data.requestPayload[1].method ?? 'GET'\n if (isForbiddenHttpMethod(requestMethod)) {\n persistScriptEnvironment()\n toast(\n translate('apiClient.operationBlock.forbiddenMethod', {\n method: requestMethod.toUpperCase(),\n }),\n 'error',\n )\n return\n }\n\n // Store the abort controller for cancellation\n abortController.value = built.data.controller\n\n // Build the fetch Request once so the requestBuilt hook observes the exact bytes that are\n // sent. Rebuilding it later would generate a different multipart boundary, which breaks\n // plugins that hash the body (for example, request signing).\n const request = buildSafeBodyRequest(...built.data.requestPayload)\n\n // Execute the requestBuilt hook (plugins receive the exact fetch Request that will be sent)\n await executeHook(\n {\n request,\n requestBuilder,\n document,\n operation,\n variablesStore,\n },\n 'requestBuilt',\n plugins,\n )\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:sent', {\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n /** Execute the request */\n const [sendError, sendResult] = await sendRequest({\n isUsingProxy: built.data.isUsingProxy,\n requestPayload: built.data.requestPayload,\n request,\n plugins,\n customFetch: toValue(options)?.customFetch,\n onResponseReceived: async (response, responseDuration) => {\n const result = await executeResponseHook(\n {\n response,\n responseDuration,\n requestBuilder,\n request: buildSafeBodyRequest(...built.data.requestPayload),\n document,\n operation,\n variablesStore,\n },\n plugins,\n )\n return result.response\n },\n })\n\n // Save script environment writes (pre-request and, on success, post-response) back to the\n // active environment. Runs even when the send fails so a pre-request set is not lost.\n persistScriptEnvironment()\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:complete', {\n payload: sendResult\n ? {\n response: sendResult.originalResponse.clone(),\n requestPayload: sendResult.requestPayload,\n duration: sendResult.response.duration,\n timestamp: sendResult.timestamp,\n }\n : undefined,\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n if (sendError) {\n // Cancellation also happens when navigating away; keep the new operation intact.\n if (built.data.controller.signal.aborted) {\n if (abortController.value === built.data.controller) {\n abortController.value = null\n }\n return\n }\n requestError.value = sendError\n // clean up the response and request\n response.value = null\n requestPayload.value = null\n abortController.value = null\n\n toast(sendError.message, 'error')\n return\n }\n\n // Store the response\n response.value = sendResult.response\n requestPayload.value = sendResult.requestPayload\n\n // Persist server-set cookies into the document jar so values like a CSRF token\n // survive a page reload and get replayed on the next request, like a browser would.\n persistResponseCookies(sendResult)\n\n // Cache non-streaming responses so they can be restored when navigating back\n if (!isStreamingResponse(sendResult.response)) {\n responseCache.set(getOperationExampleKey(method, path, exampleKey), {\n response: sendResult.response,\n requestPayload: sendResult.requestPayload,\n })\n }\n}\n\nonMounted(() => {\n eventBus.on('operation:send:request:hotkey', handleExecute)\n eventBus.on('operation:cancel:request', cancelRequest)\n eventBus.on('copy-url:address-bar', copyAddressBarUrl)\n\n // Let plugins warm up per-operation resources (e.g. the scripts sandbox) so the first request\n // does not pay their cold-start cost.\n void executeHook({ document, operation }, 'onRequestMount', plugins)\n})\nonBeforeUnmount(() => {\n eventBus.off('operation:send:request:hotkey', handleExecute)\n eventBus.off('operation:cancel:request', cancelRequest)\n eventBus.off('copy-url:address-bar', copyAddressBarUrl)\n})\n\nconst operationHistory = computed<History[]>(() =>\n history\n .map((entry) => ({\n method: entry.request.method as string,\n path: entry.request.url,\n duration: entry.time,\n status: entry.response.status,\n }))\n .reverse(),\n)\n\nconst handleSelectHistoryItem = ({ index }: { index: number }) => {\n const transformedIndex = (history.length ?? 0) - index - 1\n const historyItem = history[transformedIndex]\n if (!historyItem) {\n return\n }\n\n const navigate = () =>\n eventBus.emit('ui:navigate', {\n page: 'example',\n method,\n path,\n exampleName: 'draft',\n callback: (status) => {\n // Do not replace the response if the navigation was not successful\n if (status !== 'success') {\n return\n }\n // Reconstruct the response\n const fetchResponse = harToFetchResponse({\n harResponse: historyItem.response,\n url: historyItem.request.url,\n method,\n path,\n duration: historyItem.time,\n })\n\n // Reconstruct the request\n const fetchRequest = harToFetchRequest({\n harRequest: historyItem.request,\n })\n\n // Update the response and request\n requestError.value = null\n response.value = fetchResponse\n requestPayload.value = fetchRequest\n },\n })\n\n eventBus.emit('operation:reload:history', {\n meta: {\n path,\n method,\n },\n index: transformedIndex,\n callback: navigate,\n })\n}\n\nconst handleNavigateSettings = () => {\n eventBus.emit('ui:navigate', {\n page: 'operation',\n path: 'overview',\n operationPath: path,\n method,\n })\n}\n\n/**\n * When the path, method, or example key changes, restore the response panel\n * for the new operation from the best available source:\n *\n * 1. `responseCache` — in-memory, populated on every successful send.\n * Has the live response object (including streams) so it wins.\n * 2. `history` — persisted in the workspace store. Used as a fallback when\n * the in-memory cache is empty (page reload, fresh app session, etc.)\n * so navigating to an operation that has been called before shows the\n * last response instead of an empty panel.\n * 3. Otherwise clear.\n *\n * Only the response is restored from history — the user's request inputs are\n * left alone, so we never silently overwrite an in-progress draft.\n */\nwatch(\n [() => path, () => method, () => exampleKey],\n ([newPath, newMethod, newExampleKey]) => {\n requestError.value = null\n const cached = responseCache.get(\n getOperationExampleKey(newMethod, newPath, newExampleKey),\n )\n\n if (cached) {\n response.value = cached.response\n requestPayload.value = cached.requestPayload\n } else {\n // History is keyed only by document/path/method but each entry carries\n // the example it came from, so we walk from the end and pick the most\n // recent entry that matches the active example. Otherwise a cache miss\n // on example B would restore example A's response. Only runs on a\n // cache miss — the common case (in-session navigation) skips it.\n const latest = (() => {\n for (let i = history.length - 1; i >= 0; i--) {\n const entry = history[i]\n if (entry?.meta.example === newExampleKey) {\n return entry\n }\n }\n return undefined\n })()\n\n if (latest) {\n response.value = harToFetchResponse({\n harResponse: latest.response,\n url: latest.request.url,\n method: newMethod,\n path: newPath,\n duration: latest.time,\n })\n requestPayload.value = null\n } else {\n response.value = null\n requestPayload.value = null\n }\n }\n\n // Cancel any in-flight request\n cancelRequest()\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n // We cancel the request if the component is unmounted\n cancelRequest()\n})\n</script>\n<template>\n <div class=\"bg-b-1 flex h-full min-w-0 flex-col\">\n <div\n class=\"lg:min-h-header flex w-full flex-wrap items-center justify-center p-2 lg:p-0\">\n <!-- Address Bar -->\n <Header\n :activeEnvironment\n :documentSlug\n :documentUrl\n :environment\n :environments\n :eventBus\n :exampleKey\n :executionDisabled=\"externalExamplesPending\"\n :hideClientButton\n :history=\"operationHistory\"\n :integration\n :isWebhook\n :layout\n :method\n :path=\"requestPath\"\n :server=\"requestServer\"\n :serverMeta\n :servers\n :source\n @execute=\"handleExecute\"\n @navigate:settings=\"handleNavigateSettings\"\n @open:browser=\"openInBrowser\"\n @select:history:item=\"handleSelectHistoryItem\"\n @update:webhookUrl=\"(value: string) => (webhookUrl = value)\" />\n </div>\n\n <ViewLayout class=\"border-t\">\n <ViewLayoutContent class=\"flex-1\">\n <!-- Request Section -->\n <ViewLayoutSection\n v-if=\"externalExamplesPending\"\n aria-label=\"Request\">\n <template #title>Request</template>\n <div\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamplesFailed\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"$emit('retry:externalExamples')\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n </ViewLayoutSection>\n <RequestBlock\n v-else\n :allowedSecuritySchemes=\"\n toValue(options)?.authentication?.allowedSecuritySchemes\n \"\n :authMeta\n :clientOptions\n :defaultHeaders\n :defaultRequestBodyView=\"\n document['x-scalar-default-request-body-view']\n \"\n :documentCookies\n :documentSlug\n :environment\n :eventBus\n :exampleKey\n :layout\n :method\n :openapiVersion=\"document.openapi\"\n :operation\n :options=\"toValue(options)\"\n :path=\"requestPath\"\n :plugins\n :proxyUrl\n :requestBodyCompositionSelection\n :securityRequirements\n :securitySchemes\n :selectedClient\n :selectedSecurity\n :selectedSecuritySchemes\n :server=\"requestServer\"\n :sourceOperation\n :workspaceCookies />\n\n <!-- Response Section -->\n <ResponseBlock\n :appVersion\n :eventBus\n :executionDisabled=\"externalExamplesPending\"\n :layout\n :plugins\n :requestError\n :requestPayload\n :response\n :totalPerformedRequests=\"operationHistory.length\" />\n </ViewLayoutContent>\n </ViewLayout>\n </div>\n</template>\n"],"mappings":""}
@@ -19,6 +19,7 @@ import { ERRORS } from "@scalar/helpers/errors/normalize-error";
19
19
  import { isElectron } from "@scalar/helpers/general/is-electron";
20
20
  import { buildSafeBodyRequest } from "@scalar/helpers/http/can-method-have-body";
21
21
  import { generateClientOptions } from "@scalar/blocks/code-example";
22
+ import { isAllowedOAuthUrl } from "@scalar/helpers/url/is-allowed-oauth-url";
22
23
  import { isForbiddenHttpMethod } from "@scalar/helpers/http/is-forbidden-http-method";
23
24
  import { executeHook, executeResponseHook } from "@scalar/oas-utils/helpers";
24
25
  import { AVAILABLE_CLIENTS } from "@scalar/types/snippetz";
@@ -141,10 +142,10 @@ var OperationBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
141
142
  }
142
143
  };
143
144
  /**
144
- * Copy the executable URL — same pipeline as Send (`requestFactory` +
145
+ * Resolve the executable URL using the same pipeline as Send (`requestFactory` +
145
146
  * `resolveExecutableRequestUrl`), including security query params.
146
147
  */
147
- const copyAddressBarUrl = async () => {
148
+ const getAddressBarUrl = (allowMissingRequestServerBase = true) => {
148
149
  const { request } = requestFactory({
149
150
  defaultHeaders: __props.defaultHeaders,
150
151
  environment: __props.environment,
@@ -160,7 +161,35 @@ var OperationBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
160
161
  openapiVersion: __props.document.openapi,
161
162
  requestBodyCompositionSelection: __props.requestBodyCompositionSelection
162
163
  });
163
- await copyToClipboard(resolveExecutableRequestUrl(request, getEnvironmentVariables(__props.environment)));
164
+ return resolveExecutableRequestUrl(request, getEnvironmentVariables(__props.environment), { allowMissingRequestServerBase });
165
+ };
166
+ /** Copy remains permissive so incomplete URLs can still be shared or edited. */
167
+ const copyAddressBarUrl = async () => {
168
+ await copyToClipboard(getAddressBarUrl());
169
+ };
170
+ /** Browser navigation uses the destination URL and the browser's own session. */
171
+ const openInBrowser = async () => {
172
+ if (__props.method.toLowerCase() !== "get" || __props.externalExamplesPending) return;
173
+ __props.eventBus.flushDebouncedEmits?.();
174
+ await nextTick();
175
+ if (!validatePathParameters(__props.operation.parameters ?? [], __props.exampleKey).ok) {
176
+ toast(translate("apiClient.operationBlock.pathParametersRequired"), "error");
177
+ return;
178
+ }
179
+ try {
180
+ const url = new URL(getAddressBarUrl(__props.layout === "modal" && !__props.isWebhook));
181
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
182
+ toast(translate("apiClient.addressBar.browserUrlRequired"), "error");
183
+ return;
184
+ }
185
+ if (isElectron() && !isAllowedOAuthUrl(url)) {
186
+ toast(translate("apiClient.addressBar.desktopBrowserUrlRequired"), "error");
187
+ return;
188
+ }
189
+ window.open(url.href, "_blank", "noopener,noreferrer");
190
+ } catch {
191
+ toast(translate("apiClient.addressBar.browserUrlRequired"), "error");
192
+ }
164
193
  };
165
194
  /** Execute the current operation example */
166
195
  const handleExecute = async () => {
@@ -450,6 +479,7 @@ var OperationBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
450
479
  source: __props.source,
451
480
  onExecute: handleExecute,
452
481
  "onNavigate:settings": handleNavigateSettings,
482
+ "onOpen:browser": openInBrowser,
453
483
  "onSelect:history:item": handleSelectHistoryItem,
454
484
  "onUpdate:webhookUrl": _cache[0] || (_cache[0] = (value) => webhookUrl.value = value)
455
485
  }, null, 8, [