@mintlify/msft-sdk 1.1.59 → 1.1.61

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.
@@ -1,12 +1,13 @@
1
1
  import "react/jsx-runtime";
2
- import $ from "@sindresorhus/slugify";
3
- const c = (r, e, t, i) => $(
4
- `${r ? `${r}-` : ""}${t ? `${t}-` : ""}${e || ""}-`,
2
+ import i from "@sindresorhus/slugify";
3
+ import "../../../contexts/EndpointLocationContext.js";
4
+ const s = (r, t, e, $) => i(
5
+ `${r ? `${r}-` : ""}${e ? `${e}-` : ""}${t || ""}-`,
5
6
  {
6
7
  decamelize: !0
7
8
  }
8
- ), s = (r, e) => r ? `${e ? `${e}` : ""}${r}.` : "";
9
+ ), m = (r, t) => r ? `${t ? `${t}` : ""}${r}.` : "";
9
10
  export {
10
- c as buildRecursiveParamFieldId,
11
- s as getRecursiveParentName
11
+ s as buildRecursiveParamFieldId,
12
+ m as getRecursiveParentName
12
13
  };
@@ -1,6 +1,7 @@
1
1
  import "react/jsx-runtime";
2
- import { useOpenApiEndpoint as n } from "../../hooks/useEndpoint.js";
3
- const p = () => (n(), null);
2
+ import "../../contexts/EndpointLocationContext.js";
3
+ import { useOpenApiEndpoint as t } from "../../hooks/useEndpoint.js";
4
+ const i = () => (t(), null);
4
5
  export {
5
- p as default
6
+ i as default
6
7
  };
@@ -1,31 +1,31 @@
1
- import { jsx as M } from "react/jsx-runtime";
2
- import { useState as j, useEffect as E } from "react";
3
- import { generateRequest as S } from "../../generators/generateRequest.js";
4
- import { generateSnippet as a } from "../../generators/generateSnippet.js";
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import { useState as B, useEffect as E } from "react";
3
+ import { generateRequest as j } from "../../generators/generateRequest.js";
4
+ import { generateSnippet as S } from "../../generators/generateSnippet.js";
5
5
  import { getFirstExampleValue as V } from "../../schemaGraph/processExamples.js";
6
- import { CodeGroupSelect as G } from "../../../components/content-components/CodeGroupSelect/index.js";
7
- import { CodeSnippets as P } from "../../../components/content-components/code-snippets.js";
8
- import { langToPresetMap as k } from "../../../constants/snippetPresets.js";
6
+ import { CodeGroupSelect as w } from "../../../components/content-components/CodeGroupSelect/index.js";
7
+ import { CodeSnippets as G } from "../../../components/content-components/code-snippets.js";
8
+ import { langToPresetMap as P } from "../../../constants/snippetPresets.js";
9
9
  const J = ({
10
- baseUrl: r,
10
+ baseUrl: s,
11
11
  apiReferenceData: t,
12
12
  inputs: e,
13
13
  requestExampleLanguages: u,
14
- requiredOnly: s,
14
+ requiredOnly: r,
15
15
  maxHeight: o,
16
16
  selectedSecurityOptionIndex: f
17
17
  }) => {
18
- var h, T, c, n, x;
19
- const p = (h = t.dependencies) == null ? void 0 : h.requestBody;
18
+ var T, h, c, n, x;
19
+ const p = (T = t.dependencies) == null ? void 0 : T.requestBody;
20
20
  if (!p)
21
- return /* @__PURE__ */ M(
22
- B,
21
+ return /* @__PURE__ */ y(
22
+ a,
23
23
  {
24
24
  apiReferenceData: t,
25
- baseUrl: r,
25
+ baseUrl: s,
26
26
  inputs: e,
27
27
  requestExampleLanguages: u,
28
- requiredOnly: s,
28
+ requiredOnly: r,
29
29
  maxHeight: o,
30
30
  selectedSecurityOptionIndex: f
31
31
  }
@@ -33,84 +33,84 @@ const J = ({
33
33
  const i = V(p.content);
34
34
  if (!i) return null;
35
35
  const m = Object.entries(p.content).map(
36
- ([d, C]) => ({
37
- contentType: d,
38
- examples: C.examples
36
+ ([C, d]) => ({
37
+ contentType: C,
38
+ examples: d.examples
39
39
  })
40
40
  ), l = 0;
41
- return ((T = m[l]) == null ? void 0 : T.examples.length) > 1 ? /* @__PURE__ */ M(
42
- q,
41
+ return ((h = m[l]) == null ? void 0 : h.examples.length) > 1 ? /* @__PURE__ */ y(
42
+ k,
43
43
  {
44
44
  apiReferenceData: t,
45
45
  selectedBodyContentType: (c = m[l]) == null ? void 0 : c.contentType,
46
- baseUrl: r,
46
+ baseUrl: s,
47
47
  inputs: e,
48
48
  examples: (n = m[l]) == null ? void 0 : n.examples,
49
- requiredOnly: s,
49
+ requiredOnly: r,
50
50
  maxHeight: o,
51
51
  selectedSecurityOptionIndex: f
52
52
  }
53
- ) : /* @__PURE__ */ M(
54
- B,
53
+ ) : /* @__PURE__ */ y(
54
+ a,
55
55
  {
56
56
  apiReferenceData: t,
57
57
  selectedBodyContentType: (x = m[l]) == null ? void 0 : x.contentType,
58
- baseUrl: r,
58
+ baseUrl: s,
59
59
  inputs: e,
60
60
  exampleValue: i,
61
61
  requestExampleLanguages: u,
62
- requiredOnly: s,
62
+ requiredOnly: r,
63
63
  maxHeight: o,
64
64
  selectedSecurityOptionIndex: f
65
65
  }
66
66
  );
67
- }, B = ({
68
- baseUrl: r,
67
+ }, a = ({
68
+ baseUrl: s,
69
69
  apiReferenceData: t,
70
70
  inputs: e,
71
71
  selectedBodyContentType: u,
72
- exampleValue: s,
72
+ exampleValue: r,
73
73
  requestExampleLanguages: o,
74
74
  requiredOnly: f,
75
75
  maxHeight: p,
76
76
  selectedSecurityOptionIndex: i
77
77
  }) => {
78
- const m = S({
79
- baseUrl: r,
78
+ const m = j({
79
+ baseUrl: s,
80
80
  apiReferenceData: t,
81
81
  inputs: e,
82
82
  selectedBodyContentType: u,
83
- exampleData: s,
83
+ exampleData: r,
84
84
  requiredOnly: f,
85
85
  selectedSecurityOptionIndex: i
86
- }), l = o == null ? void 0 : o.reduce((T, c) => {
87
- const n = k[c];
88
- return n && T.push(n), T;
89
- }, []), h = a({
86
+ }), l = o == null ? void 0 : o.reduce((h, c) => {
87
+ const n = P[c];
88
+ return n && h.push(n), h;
89
+ }, []), T = S({
90
90
  apiReferenceData: t,
91
91
  pathInputs: e.path,
92
92
  request: m,
93
93
  snippetPresets: l
94
94
  });
95
- return /* @__PURE__ */ M(P, { snippets: h, dropdown: !0, maxHeight: p });
96
- }, q = ({
97
- baseUrl: r,
95
+ return /* @__PURE__ */ y(G, { snippets: T, dropdown: !0, maxHeight: p, showCopyButton: !1 });
96
+ }, k = ({
97
+ baseUrl: s,
98
98
  apiReferenceData: t,
99
99
  inputs: e,
100
100
  selectedBodyContentType: u,
101
- examples: s,
101
+ examples: r,
102
102
  requiredOnly: o,
103
103
  maxHeight: f,
104
104
  selectedSecurityOptionIndex: p
105
105
  }) => {
106
- const [i, m] = j({}), [l, h] = j(null);
106
+ const [i, m] = B({}), [l, T] = B(null);
107
107
  return E(() => {
108
- const T = e.path, c = {};
108
+ const h = e.path, c = {};
109
109
  try {
110
- for (const [n, { value: x }] of Object.entries(s)) {
110
+ for (const [n, { value: x }] of Object.entries(r)) {
111
111
  if (!x) continue;
112
- const d = S({
113
- baseUrl: r,
112
+ const C = j({
113
+ baseUrl: s,
114
114
  apiReferenceData: t,
115
115
  inputs: e,
116
116
  selectedBodyContentType: u,
@@ -118,23 +118,23 @@ const J = ({
118
118
  requiredOnly: o,
119
119
  selectedSecurityOptionIndex: p
120
120
  });
121
- a({
121
+ S({
122
122
  apiReferenceData: t,
123
- pathInputs: T,
124
- request: d,
123
+ pathInputs: h,
124
+ request: C,
125
125
  isMultipleRequest: !0
126
- }).forEach((y) => {
127
- c[y.filename] = {
128
- ...c[y.filename],
129
- [n]: y
126
+ }).forEach((M) => {
127
+ c[M.filename] = {
128
+ ...c[M.filename],
129
+ [n]: M
130
130
  };
131
131
  });
132
132
  }
133
133
  m(c);
134
134
  } catch (n) {
135
- console.error(n), h(n);
135
+ console.error(n), T(n);
136
136
  }
137
- }, [r, t, e, u, s, o, p]), l || Object.keys(i).length === 0 ? null : /* @__PURE__ */ M(G, { snippets: i, maxHeight: f });
137
+ }, [s, t, e, u, r, o, p]), l || Object.keys(i).length === 0 ? null : /* @__PURE__ */ y(w, { snippets: i, maxHeight: f });
138
138
  };
139
139
  export {
140
140
  J as GeneratedRequestExample
@@ -1,192 +1,39 @@
1
- import { generateUniqueString as C } from "../../utils/uuid.js";
1
+ import { HTTPSnippet as U } from "@readme/httpsnippet";
2
+ import { generateUniqueString as x } from "../../utils/uuid.js";
2
3
  import { snippetPresets as R } from "../../constants/snippetPresets.js";
3
- class q {
4
- constructor(r) {
5
- this.request = r;
6
- }
7
- convert(r, o) {
8
- const { method: t, url: e, headers: s = [], postData: i } = this.request, n = {};
9
- s.forEach((p) => {
10
- p.name && p.value && (n[p.name] = p.value);
11
- });
12
- const a = (i == null ? void 0 : i.text) || "";
13
- switch (r) {
14
- case "shell":
15
- return this.generateCurl(t, e, n, a);
16
- case "python":
17
- return this.generatePython(t, e, n, a, o);
18
- case "javascript":
19
- return this.generateJavaScript(t, e, n, a, o);
20
- case "php":
21
- return this.generatePHP(t, e, n, a);
22
- case "go":
23
- return this.generateGo(t, e, n, a);
24
- case "java":
25
- return this.generateJava(t, e, n, a);
26
- case "ruby":
27
- return this.generateRuby(t, e, n, a);
28
- default:
29
- return `# Code generation for ${r} not implemented yet`;
30
- }
31
- }
32
- generateCurl(r, o, t, e) {
33
- let s = `curl -X ${r.toUpperCase()} "${o}"`;
34
- return Object.entries(t).forEach(([i, n]) => {
35
- s += ` \\
36
- -H "${i}: ${n}"`;
37
- }), e && (s += ` \\
38
- -d '${e}'`), s;
39
- }
40
- generatePython(r, o, t, e, s) {
41
- if (s === "requests") {
42
- const i = JSON.stringify(t, null, 2).split(`
43
- `).join(`
44
- `), n = e ? `,
45
- data=${JSON.stringify(e)}` : "";
46
- return `import requests
47
-
48
- response = requests.${r.toLowerCase()}(
49
- "${o}",
50
- headers=${i}${n}
51
- )
52
-
53
- print(response.json())`;
54
- }
55
- return `# Python code generation not implemented for client: ${s}`;
56
- }
57
- generateJavaScript(r, o, t, e, s) {
58
- if (s === "fetch") {
59
- const i = JSON.stringify(t, null, 2).split(`
60
- `).map((a, p) => p === 0 ? a : " " + a).join(`
61
- `), n = e ? `,
62
- body: ${JSON.stringify(e)}` : "";
63
- return `fetch("${o}", {
64
- method: "${r.toUpperCase()}",
65
- headers: ${i}${n}
66
- })
67
- .then(response => response.json())
68
- .then(data => console.log(data))
69
- .catch(error => console.error('Error:', error));`;
70
- }
71
- return `// JavaScript code generation not implemented for client: ${s}`;
72
- }
73
- generatePHP(r, o, t, e) {
74
- const s = Object.entries(t).map(([n, a]) => ` "${n}: ${a}"`).join(`,
75
- `), i = e ? `,
76
- CURLOPT_POSTFIELDS => '${e}'` : "";
77
- return `<?php
78
- $ch = curl_init();
79
-
80
- curl_setopt_array($ch, [
81
- CURLOPT_URL => "${o}",
82
- CURLOPT_RETURNTRANSFER => true,
83
- CURLOPT_CUSTOMREQUEST => "${r.toUpperCase()}",
84
- CURLOPT_HTTPHEADER => [
85
- ${s}
86
- ]${i}
87
- ]);
88
-
89
- $response = curl_exec($ch);
90
- curl_close($ch);
91
-
92
- echo $response;
93
- ?>`;
94
- }
95
- generateGo(r, o, t, e) {
96
- const s = e ? `
97
- reqBody := strings.NewReader(${JSON.stringify(e)})
98
- req, _ := http.NewRequest("${r.toUpperCase()}", "${o}", reqBody)` : `
99
- req, _ := http.NewRequest("${r.toUpperCase()}", "${o}", nil)`, i = Object.entries(t).map(([n, a]) => ` req.Header.Add("${n}", "${a}")`).join(`
100
- `);
101
- return `package main
102
-
103
- import (
104
- "fmt"
105
- "net/http"
106
- "io/ioutil"
107
- "strings"
108
- )
109
-
110
- func main() {${s}
111
- ${i}
112
-
113
- client := &http.Client{}
114
- resp, _ := client.Do(req)
115
- defer resp.Body.Close()
116
-
117
- body, _ := ioutil.ReadAll(resp.Body)
118
- fmt.Println(string(body))
119
- }`;
120
- }
121
- generateJava(r, o, t, e) {
122
- const s = Object.entries(t).map(([n, a]) => ` .header("${n}", "${a}")`).join(`
123
- `), i = e ? `.POST(HttpRequest.BodyPublishers.ofString(${JSON.stringify(e)}))` : `.method("${r.toUpperCase()}", HttpRequest.BodyPublishers.noBody())`;
124
- return `import java.net.http.*;
125
- import java.net.URI;
126
-
127
- public class Main {
128
- public static void main(String[] args) throws Exception {
129
- HttpClient client = HttpClient.newHttpClient();
130
- HttpRequest request = HttpRequest.newBuilder()
131
- .uri(URI.create("${o}"))
132
- ${s}
133
- ${i}
134
- .build();
135
-
136
- HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
137
- System.out.println(response.body());
138
- }
139
- }`;
140
- }
141
- generateRuby(r, o, t, e) {
142
- const s = Object.entries(t).map(([n, a]) => `request["${n}"] = "${a}"`).join(`
143
- `), i = e ? `
144
- request.body = ${JSON.stringify(e)}` : "";
145
- return `require 'net/http'
146
- require 'uri'
147
-
148
- uri = URI.parse("${o}")
149
- http = Net::HTTP.new(uri.host, uri.port)
150
- request = Net::HTTP::${r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()}.new(uri.request_uri)
151
- ${s}${i}
152
-
153
- response = http.request(request)
154
- puts response.body`;
155
- }
156
- }
157
- const T = ({
158
- request: l,
159
- pathInputs: r,
160
- apiReferenceData: o,
161
- snippetPresets: t = R,
162
- isMultipleRequest: e = !1
4
+ const N = ({
5
+ request: r,
6
+ pathInputs: p,
7
+ apiReferenceData: s,
8
+ snippetPresets: i = R,
9
+ isMultipleRequest: c = !1
163
10
  }) => {
164
- const s = {}, i = /:{[^{}]+}/g, n = l.url.replace(i, (c) => {
165
- const u = ":62437";
166
- return s[u] = c, u;
167
- }), a = /{[^{}]+}/g, p = n.replace(a, (c) => {
168
- const u = c.slice(1, c.length - 1), d = r[u];
169
- if (c === "{endpoint}")
11
+ const a = {}, g = /:{[^{}]+}/g, m = r.url.replace(g, (t) => {
12
+ const e = ":62437";
13
+ return a[e] = t, e;
14
+ }), f = /{[^{}]+}/g, d = m.replace(f, (t) => {
15
+ const e = t.slice(1, t.length - 1), n = p[e];
16
+ if (t === "{endpoint}")
170
17
  return "https://{endpoint}";
171
- if (d && (typeof d != "string" || d.length > 0))
172
- return `${encodeURIComponent(d.toString())}`;
173
- const h = C();
174
- return s[h] = c, h;
175
- }), m = new q({
176
- ...l,
177
- url: p,
178
- postData: l.postData || { mimeType: "application/json" }
18
+ if (n && (typeof n != "string" || n.length > 0))
19
+ return `${encodeURIComponent(n.toString())}`;
20
+ const o = x();
21
+ return a[o] = t, o;
22
+ }), h = new U({
23
+ ...r,
24
+ url: d,
25
+ postData: r.postData || { mimeType: "application/json" }
179
26
  });
180
- return t.map((c) => {
181
- var g;
182
- const { filename: u, snippet: d, language: h } = c, { target: f, client: y } = d, $ = m.convert(f, y), S = P(s, ($ == null ? void 0 : $.toString()) || "");
27
+ return i.map((t) => {
28
+ var u;
29
+ const { filename: e, snippet: n, language: o } = t, { target: P, client: S } = n, l = h.convert(P, S), T = j(a, (l == null ? void 0 : l.toString()) || "");
183
30
  return {
184
- filename: e ? u : ((g = o.operation) == null ? void 0 : g.title) || u,
185
- code: S,
186
- language: h
31
+ filename: c ? e : ((u = s.operation) == null ? void 0 : u.title) || e,
32
+ code: T,
33
+ language: o
187
34
  };
188
35
  });
189
- }, P = (l, r) => Object.entries(l).reduce((o, [t, e]) => o.replace(t, e), r);
36
+ }, j = (r, p) => Object.entries(r).reduce((s, [i, c]) => s.replace(i, c), p);
190
37
  export {
191
- T as generateSnippet
38
+ N as generateSnippet
192
39
  };
@@ -1,6 +1,6 @@
1
- import { jsx as r, jsxs as N } from "react/jsx-runtime";
2
- import { ClipboardCheckmarkRegular as I, Copy20Regular as S } from "@fluentui/react-icons";
3
- import h from "prismjs";
1
+ import { jsxs as _, jsx as o } from "react/jsx-runtime";
2
+ import { ClipboardCheckmarkRegular as E, Copy20Regular as P } from "@fluentui/react-icons";
3
+ import g from "prismjs";
4
4
  import "prismjs/components/prism-bash.js";
5
5
  import "prismjs/components/prism-csharp.js";
6
6
  import "prismjs/components/prism-javascript.js";
@@ -9,167 +9,174 @@ import "prismjs/components/prism-markdown.js";
9
9
  import "prismjs/components/prism-powershell.js";
10
10
  import "prismjs/components/prism-python.js";
11
11
  import "prismjs/components/prism-typescript.js";
12
- import A, { useState as k, useEffect as R } from "react";
13
- import { cn as d } from "../../utils/cn.js";
14
- import { getNodeText as j } from "../../utils/get-node-text.js";
15
- import { getCodeBlockScrollbarClassname as E } from "../../utils/getScrollbarClassname.js";
16
- const w = ["image/png", "text/plain"];
12
+ import z, { useState as v, useEffect as F } from "react";
13
+ import { cn as p } from "../../utils/cn.js";
14
+ import { getNodeText as D } from "../../utils/get-node-text.js";
15
+ import { getCodeBlockScrollbarClassname as H } from "../../utils/getScrollbarClassname.js";
16
+ const T = ["image/png", "text/plain"];
17
17
  function y() {
18
- const [t, e] = k(!1), o = async (n) => {
18
+ const [t, e] = v(!1), r = async (n) => {
19
19
  try {
20
20
  await navigator.clipboard.writeText(n), e(!0), setTimeout(() => e(!1), 2e3);
21
- } catch (m) {
22
- console.error("Failed to copy to clipboard:", m);
21
+ } catch (i) {
22
+ console.error("Failed to copy to clipboard:", i);
23
23
  }
24
24
  };
25
- return { isCopied: t, copy: o, copyBlob: async (n, m) => {
25
+ return { isCopied: t, copy: r, copyBlob: async (n, i) => {
26
26
  try {
27
- if (w.includes(m)) {
28
- const i = await n.arrayBuffer(), a = new Blob([i], { type: m }), f = new ClipboardItem({
29
- [m]: a
27
+ if (T.includes(i)) {
28
+ const a = await n.arrayBuffer(), m = new Blob([a], { type: i }), u = new ClipboardItem({
29
+ [i]: m
30
30
  });
31
- await navigator.clipboard.write([f]), e(!0), setTimeout(() => e(!1), 2e3);
31
+ await navigator.clipboard.write([u]), e(!0), setTimeout(() => e(!1), 2e3);
32
32
  } else {
33
- const i = await n.text();
34
- await o(i);
33
+ const a = await n.text();
34
+ await r(a);
35
35
  }
36
- } catch (i) {
37
- console.error("Failed to copy blob to clipboard:", i);
36
+ } catch (a) {
37
+ console.error("Failed to copy blob to clipboard:", a);
38
38
  try {
39
- const a = await n.text();
40
- await o(a);
41
- } catch (a) {
42
- console.error("Failed to copy as text fallback:", a);
39
+ const m = await n.text();
40
+ await r(m);
41
+ } catch (m) {
42
+ console.error("Failed to copy as text fallback:", m);
43
43
  }
44
44
  }
45
45
  } };
46
46
  }
47
- function _({ onClick: t, isCopied: e, showTooltip: o = !0 }) {
48
- return /* @__PURE__ */ N("div", { className: "mint:relative", children: [
49
- o && e && /* @__PURE__ */ r("div", { className: "mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]", children: "Copied!" }),
50
- /* @__PURE__ */ r(
47
+ function C({ onClick: t, isCopied: e, showTooltip: r = !0 }) {
48
+ return /* @__PURE__ */ _("div", { className: "mint:relative", children: [
49
+ r && e && /* @__PURE__ */ o("div", { className: "mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]", children: "Copied!" }),
50
+ /* @__PURE__ */ o(
51
51
  "button",
52
52
  {
53
53
  onClick: t,
54
54
  className: "mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]",
55
55
  "aria-label": e ? "Copied" : "Copy code",
56
- children: e ? /* @__PURE__ */ r(I, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ r(S, { className: "mint:w-5 mint:h-5" })
56
+ children: e ? /* @__PURE__ */ o(E, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ o(P, { className: "mint:w-5 mint:h-5" })
57
57
  }
58
58
  )
59
59
  ] });
60
60
  }
61
- function V({
61
+ function tt({
62
62
  textToCopy: t,
63
63
  showTooltip: e = !0
64
64
  }) {
65
- const { isCopied: o, copy: c } = y();
66
- return /* @__PURE__ */ r(_, { onClick: () => {
65
+ const { isCopied: r, copy: c } = y();
66
+ return /* @__PURE__ */ o(C, { onClick: () => {
67
67
  c(t);
68
- }, isCopied: o, showTooltip: e });
68
+ }, isCopied: r, showTooltip: e });
69
69
  }
70
- function W({
70
+ function et({
71
71
  data: t,
72
72
  showTooltip: e = !0
73
73
  }) {
74
- const { isCopied: o, copy: c, copyBlob: n } = y();
75
- return /* @__PURE__ */ r(_, { onClick: () => {
76
- t.contentType && w.includes(t.contentType) ? n(t.blob, t.contentType) : t.type === "other" && t.content ? c(t.content) : console.error("Unsupported content type for clipboard");
77
- }, isCopied: o, showTooltip: e });
74
+ const { isCopied: r, copy: c, copyBlob: n } = y();
75
+ return /* @__PURE__ */ o(C, { onClick: () => {
76
+ t.contentType && T.includes(t.contentType) ? n(t.blob, t.contentType) : t.type === "other" && t.content ? c(t.content) : console.error("Unsupported content type for clipboard");
77
+ }, isCopied: r, showTooltip: e });
78
78
  }
79
- function X({
79
+ function ot({
80
80
  children: t,
81
81
  className: e,
82
- fileName: o,
82
+ fileName: r,
83
83
  language: c,
84
84
  blob: n,
85
- contentType: m,
86
- dataGroup: i = !1
85
+ contentType: i,
86
+ dataGroup: a = !1,
87
+ showCopyButton: m = !0
87
88
  }) {
88
- const [a, f] = k("");
89
- y();
90
- const s = c || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", u = j(t), T = !!o, g = A.useMemo(() => {
91
- var x, C;
89
+ const [u, k] = v(""), { isCopied: B, copy: N, copyBlob: I } = y(), s = c || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", d = D(t), S = !!r, h = z.useMemo(() => {
90
+ var x, w;
92
91
  if (typeof t != "object" || t == null)
93
92
  return !1;
94
- const p = Array.isArray(t) ? t : [t];
95
- for (const l of p)
93
+ const f = Array.isArray(t) ? t : [t];
94
+ for (const l of f)
96
95
  if (typeof l == "object" && l != null && "props" in l && ((x = l.props) != null && x.children)) {
97
- const B = Array.isArray(l.props.children) ? l.props.children : [l.props.children];
98
- for (const b of B)
99
- if (typeof b == "object" && b != null && "props" in b && ((C = b.props) != null && C.className))
96
+ const j = Array.isArray(l.props.children) ? l.props.children : [l.props.children];
97
+ for (const b of j)
98
+ if (typeof b == "object" && b != null && "props" in b && ((w = b.props) != null && w.className))
100
99
  return !0;
101
100
  }
102
101
  return !1;
103
102
  }, [t]);
104
- R(() => {
105
- if (!g)
103
+ F(() => {
104
+ if (!h)
106
105
  try {
107
- const p = h.languages[s] || h.languages.plaintext, x = h.highlight(u, p, s);
108
- f(x);
109
- } catch (p) {
110
- console.error("Failed to highlight code:", p), f(u);
106
+ const f = g.languages[s] || g.languages.plaintext, x = g.highlight(d, f, s);
107
+ k(x);
108
+ } catch (f) {
109
+ console.error("Failed to highlight code:", f), k(d);
111
110
  }
112
- }, [u, s, g]);
113
- const v = E("system", i);
114
- return /* @__PURE__ */ r(
111
+ }, [d, s, h]);
112
+ const A = () => {
113
+ n && i ? I(n, i) : N(d);
114
+ }, R = H("system", a);
115
+ return /* @__PURE__ */ _(
115
116
  "div",
116
117
  {
117
- className: T ? "mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden" : void 0,
118
- "data-group": i,
119
- children: /* @__PURE__ */ r(
120
- "div",
121
- {
122
- className: d(
123
- "not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414] code-block-wrapper",
124
- "mint:px-4 mint:py-2 mint:overflow-scroll mint:[scrollbar-gutter:stable] mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800",
125
- v,
126
- i && "mint:group"
127
- ),
128
- children: /* @__PURE__ */ r(
129
- "pre",
130
- {
131
- className: d(
132
- "mint:m-0 mint:whitespace-pre mint:text-sm"
133
- ),
134
- children: g ? /* @__PURE__ */ r(
135
- "code",
136
- {
137
- className: d(
138
- `language-${s}`,
139
- "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
140
- ),
141
- children: t
142
- }
143
- ) : a ? /* @__PURE__ */ r(
144
- "code",
145
- {
146
- className: d(
147
- `language-${s}`,
148
- "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
149
- ),
150
- dangerouslySetInnerHTML: { __html: a }
151
- }
152
- ) : /* @__PURE__ */ r(
153
- "code",
154
- {
155
- className: d(
156
- `language-${s}`,
157
- "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
158
- ),
159
- children: u
160
- }
161
- )
162
- }
163
- )
164
- }
165
- )
118
+ className: p(
119
+ "mint:relative",
120
+ S ? "mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden" : void 0
121
+ ),
122
+ "data-group": a,
123
+ children: [
124
+ m && /* @__PURE__ */ o("div", { className: "mint:absolute mint:top-2 mint:right-2 mint:z-10", children: /* @__PURE__ */ o(C, { onClick: A, isCopied: B, showTooltip: !0 }) }),
125
+ /* @__PURE__ */ o(
126
+ "div",
127
+ {
128
+ className: p(
129
+ "not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414] code-block-wrapper",
130
+ "mint:px-4 mint:py-2 mint:overflow-scroll mint:[scrollbar-gutter:stable] mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800",
131
+ R,
132
+ a && "mint:group"
133
+ ),
134
+ children: /* @__PURE__ */ o(
135
+ "pre",
136
+ {
137
+ className: p(
138
+ "mint:m-0 mint:whitespace-pre mint:text-sm"
139
+ ),
140
+ children: h ? /* @__PURE__ */ o(
141
+ "code",
142
+ {
143
+ className: p(
144
+ `language-${s}`,
145
+ "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
146
+ ),
147
+ children: t
148
+ }
149
+ ) : u ? /* @__PURE__ */ o(
150
+ "code",
151
+ {
152
+ className: p(
153
+ `language-${s}`,
154
+ "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
155
+ ),
156
+ dangerouslySetInnerHTML: { __html: u }
157
+ }
158
+ ) : /* @__PURE__ */ o(
159
+ "code",
160
+ {
161
+ className: p(
162
+ `language-${s}`,
163
+ "mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
164
+ ),
165
+ children: d
166
+ }
167
+ )
168
+ }
169
+ )
170
+ }
171
+ )
172
+ ]
166
173
  }
167
174
  );
168
175
  }
169
176
  export {
170
- X as CodeBlock,
171
- W as CopyDataToClipboardButton,
172
- _ as CopyIconButton,
173
- V as CopyToClipboardButton,
177
+ ot as CodeBlock,
178
+ et as CopyDataToClipboardButton,
179
+ C as CopyIconButton,
180
+ tt as CopyToClipboardButton,
174
181
  y as useCopyToClipboard
175
182
  };
@@ -1,21 +1,23 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
- import { CodeBlock as i } from "./code-block.js";
3
- import { CodeGroup as u } from "./code-group.js";
4
- import { CodeSnippet as d } from "./code-snippet.js";
5
- const h = ({
2
+ import { CodeBlock as u } from "./code-block.js";
3
+ import { CodeGroup as d } from "./code-group.js";
4
+ import { CodeSnippet as f } from "./code-snippet.js";
5
+ const p = ({
6
6
  snippets: o,
7
7
  dropdown: r,
8
8
  maxHeight: l,
9
- ...m
10
- }) => /* @__PURE__ */ a(u, { isSmallText: !0, ...m, dropdown: r, noMargins: !0, className: l, children: o.map(({ code: g, ...e }, n) => /* @__PURE__ */ a(
11
- i,
9
+ showCopyButton: m,
10
+ ...g
11
+ }) => /* @__PURE__ */ a(d, { isSmallText: !0, ...g, dropdown: r, noMargins: !0, className: l, children: o.map(({ code: n, ...e }, i) => /* @__PURE__ */ a(
12
+ u,
12
13
  {
13
14
  language: e.language,
14
15
  fileName: e.filename,
15
- children: /* @__PURE__ */ a(d, { language: e.language, children: g })
16
+ showCopyButton: m,
17
+ children: /* @__PURE__ */ a(f, { language: e.language, children: n })
16
18
  },
17
- `${e.filename}-${e.language}-${n}`
19
+ `${e.filename}-${e.language}-${i}`
18
20
  )) });
19
21
  export {
20
- h as CodeSnippets
22
+ p as CodeSnippets
21
23
  };
package/dist/index.d.ts CHANGED
@@ -240,7 +240,7 @@ export declare function cleanTitle(title: string): string;
240
240
 
241
241
  export declare function cn(...inputs: ClassValue[]): string;
242
242
 
243
- export declare function CodeBlock({ children, className, fileName, language, blob, contentType, dataGroup, }: CodeBlockProps): JSX_2.Element;
243
+ export declare function CodeBlock({ children, className, fileName, language, blob, contentType, dataGroup, showCopyButton, }: CodeBlockProps): JSX_2.Element;
244
244
 
245
245
  declare interface CodeBlockProps {
246
246
  children: default_2.ReactNode;
@@ -250,6 +250,7 @@ declare interface CodeBlockProps {
250
250
  blob?: Blob;
251
251
  contentType?: string;
252
252
  dataGroup?: boolean;
253
+ showCopyButton?: boolean;
253
254
  }
254
255
 
255
256
  export declare type CodeExample = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/msft-sdk",
3
- "version": "1.1.59",
3
+ "version": "1.1.61",
4
4
  "description": "Lightweight SDK for Microsoft documentation with MDX rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -56,6 +56,7 @@
56
56
  "@mintlify/validation": "^0.1.513",
57
57
  "@radix-ui/react-dropdown-menu": "^2.1.16",
58
58
  "@radix-ui/react-tabs": "^1.1.3",
59
+ "@readme/httpsnippet": "^11.0.0",
59
60
  "@sindresorhus/slugify": "^3.0.0",
60
61
  "@tailwindcss/typography": "^0.5.19",
61
62
  "@types/har-format": "^1.2.16",