@scalar/snippetz 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,145 +1,201 @@
1
- function u(s) {
2
- return s.reduce((t, e) => (t[e.name] = e.value, t), {});
1
+ function u(n) {
2
+ return n.reduce((t, e) => (t[e.name] = e.value, t), {});
3
3
  }
4
- function p(s) {
5
- return /\s|-/.test(s);
4
+ function p(n) {
5
+ return /\s|-/.test(n);
6
6
  }
7
- function h(s, t = 0) {
8
- let e = [], n = " ".repeat(t), o = " ".repeat(t + 2);
9
- for (const [c, a] of Object.entries(s)) {
10
- let d = p(c) ? `'${c}'` : c;
11
- if (Array.isArray(a)) {
12
- const i = a.map((r) => typeof r == "string" ? `'${r}'` : r && typeof r == "object" ? h(r, t + 2) : r).join(`, ${o}`);
13
- e.push(`${o}${d}: [${i}]`);
14
- } else if (a && typeof a == "object")
7
+ function c(n, t = 0) {
8
+ let e = [], a = " ".repeat(t), s = " ".repeat(t + 2);
9
+ for (const [h, i] of Object.entries(n)) {
10
+ let d = p(h) ? `'${h}'` : h;
11
+ if (Array.isArray(i)) {
12
+ const r = i.map((o) => typeof o == "string" ? `'${o}'` : o && typeof o == "object" ? c(o, t + 2) : o).join(`, ${s}`);
13
+ e.push(`${s}${d}: [${r}]`);
14
+ } else if (i && typeof i == "object")
15
15
  e.push(
16
- `${o}${d}: ${h(
17
- a,
16
+ `${s}${d}: ${c(
17
+ i,
18
18
  t + 2
19
19
  )}`
20
20
  );
21
- else if (typeof a == "string") {
22
- let i = `${a}`;
23
- if (a.startsWith("JSON.stringify")) {
24
- const r = a.split(`
21
+ else if (typeof i == "string") {
22
+ let r = `${i}`;
23
+ if (i.startsWith("JSON.stringify")) {
24
+ const o = i.split(`
25
25
  `);
26
- r.length > 1 && (i = r.map((f, l) => l === 0 ? f : `${o}${f}`).join(`
26
+ o.length > 1 && (r = o.map((f, l) => l === 0 ? f : `${s}${f}`).join(`
27
27
  `));
28
28
  } else
29
- i = `'${a}'`;
30
- e.push(`${o}${d}: ${i}`);
29
+ r = `'${i}'`;
30
+ e.push(`${s}${d}: ${r}`);
31
31
  } else
32
- e.push(`${o}${d}: ${a}`);
32
+ e.push(`${s}${d}: ${i}`);
33
33
  }
34
34
  return `{
35
35
  ${e.join(`,
36
36
  `)}
37
- ${n}}`;
37
+ ${a}}`;
38
38
  }
39
- function $(s) {
40
- var d, i;
39
+ function m(n) {
40
+ var d, r;
41
41
  const t = {
42
42
  method: "GET",
43
- ...s
43
+ ...n
44
44
  };
45
45
  t.method = t.method.toUpperCase();
46
46
  const e = {
47
47
  method: t.method === "GET" ? void 0 : t.method
48
- }, n = new URLSearchParams(
48
+ }, a = new URLSearchParams(
49
49
  t.queryString ? u(t.queryString) : void 0
50
- ), o = n.size ? `?${n.toString()}` : "";
51
- (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
52
- e.headers[r.name] = r.value;
53
- })), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
54
- e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
55
- })), Object.keys(e).forEach((r) => {
56
- e[r] === void 0 && delete e[r];
57
- }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(JSON.parse(e.body))})`));
58
- const c = Object.keys(e).length ? `, ${h(e)}` : "";
50
+ ), s = a.size ? `?${a.toString()}` : "";
51
+ (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
52
+ e.headers[o.name] = o.value;
53
+ })), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
54
+ e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
55
+ })), Object.keys(e).forEach((o) => {
56
+ e[o] === void 0 && delete e[o];
57
+ }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(JSON.parse(e.body))})`));
58
+ const h = Object.keys(e).length ? `, ${c(e)}` : "";
59
59
  return {
60
60
  target: "node",
61
61
  client: "undici",
62
62
  code: `import { request } from 'undici'
63
63
 
64
- const { statusCode, body } = await request('${t.url}${o}'${c})`
64
+ const { statusCode, body } = await request('${t.url}${s}'${h})`
65
65
  };
66
66
  }
67
- function g(s) {
68
- var d, i;
67
+ function $(n) {
68
+ var d, r;
69
69
  const t = {
70
70
  method: "GET",
71
- ...s
71
+ ...n
72
72
  };
73
73
  t.method = t.method.toUpperCase();
74
74
  const e = {
75
75
  method: t.method === "GET" ? void 0 : t.method
76
- }, n = new URLSearchParams(
76
+ }, a = new URLSearchParams(
77
77
  t.queryString ? u(t.queryString) : void 0
78
- ), o = n.size ? `?${n.toString()}` : "";
79
- (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
80
- e.headers[r.name] = r.value;
81
- })), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
82
- e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
83
- })), Object.keys(e).forEach((r) => {
84
- e[r] === void 0 && delete e[r];
85
- }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(
78
+ ), s = a.size ? `?${a.toString()}` : "";
79
+ (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
80
+ e.headers[o.name] = o.value;
81
+ })), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
82
+ e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
83
+ })), Object.keys(e).forEach((o) => {
84
+ e[o] === void 0 && delete e[o];
85
+ }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(
86
86
  JSON.parse(e.body)
87
87
  )})`));
88
- const c = Object.keys(e).length ? `, ${h(e)}` : "";
88
+ const h = Object.keys(e).length ? `, ${c(e)}` : "";
89
89
  return {
90
90
  target: "node",
91
91
  client: "fetch",
92
- code: `fetch('${t.url}${o}'${c})`
92
+ code: `fetch('${t.url}${s}'${h})`
93
+ };
94
+ }
95
+ function g(n) {
96
+ var d, r;
97
+ const t = {
98
+ method: "GET",
99
+ ...n
100
+ };
101
+ t.method = t.method.toUpperCase();
102
+ const e = {
103
+ method: t.method === "GET" ? void 0 : t.method
104
+ }, a = new URLSearchParams(
105
+ t.queryString ? u(t.queryString) : void 0
106
+ ), s = a.size ? `?${a.toString()}` : "";
107
+ (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
108
+ e.headers[o.name] = o.value;
109
+ })), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
110
+ e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
111
+ })), Object.keys(e).forEach((o) => {
112
+ e[o] === void 0 && delete e[o];
113
+ }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(
114
+ JSON.parse(e.body)
115
+ )})`));
116
+ const h = Object.keys(e).length ? `, ${c(e)}` : "";
117
+ return {
118
+ target: "js",
119
+ client: "fetch",
120
+ code: `fetch('${t.url}${s}'${h})`
93
121
  };
94
122
  }
95
- function m(s) {
96
- var d, i;
123
+ function y(n) {
124
+ var i, d;
97
125
  const t = {
98
126
  method: "GET",
99
- ...s
127
+ ...n
100
128
  };
101
129
  t.method = t.method.toUpperCase();
102
130
  const e = {
103
131
  method: t.method === "GET" ? void 0 : t.method
104
- }, n = new URLSearchParams(
132
+ }, a = new URLSearchParams(
105
133
  t.queryString ? u(t.queryString) : void 0
106
- ), o = n.size ? `?${n.toString()}` : "";
107
- (d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
134
+ );
135
+ a.size && (e.query = {}, a.forEach((r, o) => {
136
+ e.query[o] = r;
137
+ })), (i = t.headers) != null && i.length && (e.headers = {}, t.headers.forEach((r) => {
108
138
  e.headers[r.name] = r.value;
109
- })), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
139
+ })), (d = t.cookies) != null && d.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
110
140
  e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
111
141
  })), Object.keys(e).forEach((r) => {
112
142
  e[r] === void 0 && delete e[r];
113
- }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(
114
- JSON.parse(e.body)
115
- )})`));
116
- const c = Object.keys(e).length ? `, ${h(e)}` : "";
143
+ }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = JSON.parse(e.body)));
144
+ const s = Object.keys(e).length ? `, ${c(e)}` : "";
117
145
  return {
118
146
  target: "js",
119
- client: "fetch",
120
- code: `fetch('${t.url}${o}'${c})`
147
+ client: "ofetch",
148
+ code: `ofetch('${t.url}'${s})`
149
+ };
150
+ }
151
+ function S(n) {
152
+ var i, d;
153
+ const t = {
154
+ method: "GET",
155
+ ...n
156
+ };
157
+ t.method = t.method.toUpperCase();
158
+ const e = {
159
+ method: t.method === "GET" ? void 0 : t.method
160
+ }, a = new URLSearchParams(
161
+ t.queryString ? u(t.queryString) : void 0
162
+ );
163
+ a.size && (e.query = {}, a.forEach((r, o) => {
164
+ e.query[o] = r;
165
+ })), (i = t.headers) != null && i.length && (e.headers = {}, t.headers.forEach((r) => {
166
+ e.headers[r.name] = r.value;
167
+ })), (d = t.cookies) != null && d.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
168
+ e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
169
+ })), Object.keys(e).forEach((r) => {
170
+ e[r] === void 0 && delete e[r];
171
+ }), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = JSON.parse(e.body)));
172
+ const s = Object.keys(e).length ? `, ${c(e)}` : "";
173
+ return {
174
+ target: "node",
175
+ client: "ofetch",
176
+ code: `ofetch('${t.url}'${s})`
121
177
  };
122
178
  }
123
- function y() {
124
- const s = [$, g, m];
179
+ function v() {
180
+ const n = [m, $, g, y, S];
125
181
  return {
126
- get(t, e, n) {
127
- const o = this.findPlugin(t, e);
128
- if (o)
129
- return o(n);
182
+ get(t, e, a) {
183
+ const s = this.findPlugin(t, e);
184
+ if (s)
185
+ return s(a);
130
186
  },
131
- print(t, e, n) {
132
- var o;
133
- return (o = this.get(t, e, n)) == null ? void 0 : o.code;
187
+ print(t, e, a) {
188
+ var s;
189
+ return (s = this.get(t, e, a)) == null ? void 0 : s.code;
134
190
  },
135
191
  targets() {
136
- return s.map((t) => t().target).filter((t, e, n) => n.indexOf(t) === e);
192
+ return n.map((t) => t().target).filter((t, e, a) => a.indexOf(t) === e);
137
193
  },
138
194
  clients() {
139
- return s.map((t) => t().client);
195
+ return n.map((t) => t().client);
140
196
  },
141
197
  plugins() {
142
- return s.map((t) => {
198
+ return n.map((t) => {
143
199
  const e = t();
144
200
  return {
145
201
  target: e.target,
@@ -148,9 +204,9 @@ function y() {
148
204
  });
149
205
  },
150
206
  findPlugin(t, e) {
151
- return s.find((n) => {
152
- const o = n();
153
- return o.target === t && o.client === e;
207
+ return n.find((a) => {
208
+ const s = a();
209
+ return s.target === t && s.client === e;
154
210
  });
155
211
  },
156
212
  hasPlugin(t, e) {
@@ -159,5 +215,5 @@ function y() {
159
215
  };
160
216
  }
161
217
  export {
162
- y as snippetz
218
+ v as snippetz
163
219
  };
@@ -1,8 +1,8 @@
1
- (function(f,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(f=typeof globalThis<"u"?globalThis:f||self,u(f["@scalar/snippetz"]={}))})(this,function(f){"use strict";function u(s){return s.reduce((t,e)=>(t[e.name]=e.value,t),{})}function p(s){return/\s|-/.test(s)}function h(s,t=0){let e=[],r=" ".repeat(t),o=" ".repeat(t+2);for(const[c,i]of Object.entries(s)){let d=p(c)?`'${c}'`:c;if(Array.isArray(i)){const a=i.map(n=>typeof n=="string"?`'${n}'`:n&&typeof n=="object"?h(n,t+2):n).join(`, ${o}`);e.push(`${o}${d}: [${a}]`)}else if(i&&typeof i=="object")e.push(`${o}${d}: ${h(i,t+2)}`);else if(typeof i=="string"){let a=`${i}`;if(i.startsWith("JSON.stringify")){const n=i.split(`
2
- `);n.length>1&&(a=n.map((l,S)=>S===0?l:`${o}${l}`).join(`
3
- `))}else a=`'${i}'`;e.push(`${o}${d}: ${a}`)}else e.push(`${o}${d}: ${i}`)}return`{
1
+ (function(f,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(f=typeof globalThis<"u"?globalThis:f||self,u(f["@scalar/snippetz"]={}))})(this,function(f){"use strict";function u(a){return a.reduce((t,e)=>(t[e.name]=e.value,t),{})}function p(a){return/\s|-/.test(a)}function c(a,t=0){let e=[],r=" ".repeat(t),n=" ".repeat(t+2);for(const[h,i]of Object.entries(a)){let d=p(h)?`'${h}'`:h;if(Array.isArray(i)){const s=i.map(o=>typeof o=="string"?`'${o}'`:o&&typeof o=="object"?c(o,t+2):o).join(`, ${n}`);e.push(`${n}${d}: [${s}]`)}else if(i&&typeof i=="object")e.push(`${n}${d}: ${c(i,t+2)}`);else if(typeof i=="string"){let s=`${i}`;if(i.startsWith("JSON.stringify")){const o=i.split(`
2
+ `);o.length>1&&(s=o.map((l,v)=>v===0?l:`${n}${l}`).join(`
3
+ `))}else s=`'${i}'`;e.push(`${n}${d}: ${s}`)}else e.push(`${n}${d}: ${i}`)}return`{
4
4
  ${e.join(`,
5
5
  `)}
6
- ${r}}`}function $(s){var d,a;const t={method:"GET",...s};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),o=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(n=>{e.headers[n.name]=n.value})),(a=t.cookies)!=null&&a.length&&(e.headers=e.headers||{},t.cookies.forEach(n=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${n.name}=${n.value}`:`${n.name}=${n.value}`})),Object.keys(e).forEach(n=>{e[n]===void 0&&delete e[n]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${h(JSON.parse(e.body))})`));const c=Object.keys(e).length?`, ${h(e)}`:"";return{target:"node",client:"undici",code:`import { request } from 'undici'
6
+ ${r}}`}function m(a){var d,s;const t={method:"GET",...a};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),n=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(o=>{e.headers[o.name]=o.value})),(s=t.cookies)!=null&&s.length&&(e.headers=e.headers||{},t.cookies.forEach(o=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${o.name}=${o.value}`:`${o.name}=${o.value}`})),Object.keys(e).forEach(o=>{e[o]===void 0&&delete e[o]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${c(JSON.parse(e.body))})`));const h=Object.keys(e).length?`, ${c(e)}`:"";return{target:"node",client:"undici",code:`import { request } from 'undici'
7
7
 
8
- const { statusCode, body } = await request('${t.url}${o}'${c})`}}function g(s){var d,a;const t={method:"GET",...s};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),o=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(n=>{e.headers[n.name]=n.value})),(a=t.cookies)!=null&&a.length&&(e.headers=e.headers||{},t.cookies.forEach(n=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${n.name}=${n.value}`:`${n.name}=${n.value}`})),Object.keys(e).forEach(n=>{e[n]===void 0&&delete e[n]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${h(JSON.parse(e.body))})`));const c=Object.keys(e).length?`, ${h(e)}`:"";return{target:"node",client:"fetch",code:`fetch('${t.url}${o}'${c})`}}function m(s){var d,a;const t={method:"GET",...s};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),o=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(n=>{e.headers[n.name]=n.value})),(a=t.cookies)!=null&&a.length&&(e.headers=e.headers||{},t.cookies.forEach(n=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${n.name}=${n.value}`:`${n.name}=${n.value}`})),Object.keys(e).forEach(n=>{e[n]===void 0&&delete e[n]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${h(JSON.parse(e.body))})`));const c=Object.keys(e).length?`, ${h(e)}`:"";return{target:"js",client:"fetch",code:`fetch('${t.url}${o}'${c})`}}function y(){const s=[$,g,m];return{get(t,e,r){const o=this.findPlugin(t,e);if(o)return o(r)},print(t,e,r){var o;return(o=this.get(t,e,r))==null?void 0:o.code},targets(){return s.map(t=>t().target).filter((t,e,r)=>r.indexOf(t)===e)},clients(){return s.map(t=>t().client)},plugins(){return s.map(t=>{const e=t();return{target:e.target,client:e.client}})},findPlugin(t,e){return s.find(r=>{const o=r();return o.target===t&&o.client===e})},hasPlugin(t,e){return!!this.findPlugin(t,e)}}}f.snippetz=y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
8
+ const { statusCode, body } = await request('${t.url}${n}'${h})`}}function $(a){var d,s;const t={method:"GET",...a};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),n=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(o=>{e.headers[o.name]=o.value})),(s=t.cookies)!=null&&s.length&&(e.headers=e.headers||{},t.cookies.forEach(o=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${o.name}=${o.value}`:`${o.name}=${o.value}`})),Object.keys(e).forEach(o=>{e[o]===void 0&&delete e[o]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${c(JSON.parse(e.body))})`));const h=Object.keys(e).length?`, ${c(e)}`:"";return{target:"node",client:"fetch",code:`fetch('${t.url}${n}'${h})`}}function y(a){var d,s;const t={method:"GET",...a};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0),n=r.size?`?${r.toString()}`:"";(d=t.headers)!=null&&d.length&&(e.headers={},t.headers.forEach(o=>{e.headers[o.name]=o.value})),(s=t.cookies)!=null&&s.length&&(e.headers=e.headers||{},t.cookies.forEach(o=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${o.name}=${o.value}`:`${o.name}=${o.value}`})),Object.keys(e).forEach(o=>{e[o]===void 0&&delete e[o]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=`JSON.stringify(${c(JSON.parse(e.body))})`));const h=Object.keys(e).length?`, ${c(e)}`:"";return{target:"js",client:"fetch",code:`fetch('${t.url}${n}'${h})`}}function g(a){var i,d;const t={method:"GET",...a};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0);r.size&&(e.query={},r.forEach((s,o)=>{e.query[o]=s})),(i=t.headers)!=null&&i.length&&(e.headers={},t.headers.forEach(s=>{e.headers[s.name]=s.value})),(d=t.cookies)!=null&&d.length&&(e.headers=e.headers||{},t.cookies.forEach(s=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${s.name}=${s.value}`:`${s.name}=${s.value}`})),Object.keys(e).forEach(s=>{e[s]===void 0&&delete e[s]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=JSON.parse(e.body)));const n=Object.keys(e).length?`, ${c(e)}`:"";return{target:"js",client:"ofetch",code:`ofetch('${t.url}'${n})`}}function S(a){var i,d;const t={method:"GET",...a};t.method=t.method.toUpperCase();const e={method:t.method==="GET"?void 0:t.method},r=new URLSearchParams(t.queryString?u(t.queryString):void 0);r.size&&(e.query={},r.forEach((s,o)=>{e.query[o]=s})),(i=t.headers)!=null&&i.length&&(e.headers={},t.headers.forEach(s=>{e.headers[s.name]=s.value})),(d=t.cookies)!=null&&d.length&&(e.headers=e.headers||{},t.cookies.forEach(s=>{e.headers["Set-Cookie"]=e.headers["Set-Cookie"]?`${e.headers["Set-Cookie"]}; ${s.name}=${s.value}`:`${s.name}=${s.value}`})),Object.keys(e).forEach(s=>{e[s]===void 0&&delete e[s]}),t.postData&&(e.body=t.postData.text,t.postData.mimeType==="application/json"&&(e.body=JSON.parse(e.body)));const n=Object.keys(e).length?`, ${c(e)}`:"";return{target:"node",client:"ofetch",code:`ofetch('${t.url}'${n})`}}function b(){const a=[m,$,y,g,S];return{get(t,e,r){const n=this.findPlugin(t,e);if(n)return n(r)},print(t,e,r){var n;return(n=this.get(t,e,r))==null?void 0:n.code},targets(){return a.map(t=>t().target).filter((t,e,r)=>r.indexOf(t)===e)},clients(){return a.map(t=>t().client)},plugins(){return a.map(t=>{const e=t();return{target:e.target,client:e.client}})},findPlugin(t,e){return a.find(r=>{const n=r();return n.target===t&&n.client===e})},hasPlugin(t,e){return!!this.findPlugin(t,e)}}}f.snippetz=b,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"snippetz.d.ts","sourceRoot":"","sources":["../src/snippetz.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAA;AAI5D,wBAAgB,QAAQ;gBAIR,QAAQ,UAAU,QAAQ,WAAW,QAAQ,OAAO,CAAC;kBAOnD,QAAQ,UAAU,QAAQ,WAAW,QAAQ,OAAO,CAAC;;;;;;;uBAyBhD,QAAQ,UAAU,QAAQ;sBAO3B,MAAM,UAAU,QAAQ;EAI7C"}
1
+ {"version":3,"file":"snippetz.d.ts","sourceRoot":"","sources":["../src/snippetz.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAA;AAM5D,wBAAgB,QAAQ;gBAIR,QAAQ,UAAU,QAAQ,WAAW,QAAQ,OAAO,CAAC;kBAOnD,QAAQ,UAAU,QAAQ,WAAW,QAAQ,OAAO,CAAC;;;;;;;uBAyBhD,QAAQ,UAAU,QAAQ;sBAO3B,MAAM,UAAU,QAAQ;EAI7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalar/snippetz",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@vitest/ui": "^1.0.4",
@@ -9,10 +9,12 @@
9
9
  "vitest": "^1.0.4"
10
10
  },
11
11
  "dependencies": {
12
- "@scalar/snippetz-core": "0.1.3",
13
- "@scalar/snippetz-plugin-node-undici": "0.1.5",
14
- "@scalar/snippetz-plugin-node-fetch": "0.1.1",
15
- "@scalar/snippetz-plugin-js-fetch": "0.1.0"
12
+ "@scalar/snippetz-core": "0.1.4",
13
+ "@scalar/snippetz-plugin-node-fetch": "0.1.2",
14
+ "@scalar/snippetz-plugin-node-ofetch": "^0.1.1",
15
+ "@scalar/snippetz-plugin-node-undici": "0.1.6",
16
+ "@scalar/snippetz-plugin-js-ofetch": "^0.1.1",
17
+ "@scalar/snippetz-plugin-js-fetch": "0.1.1"
16
18
  },
17
19
  "files": [
18
20
  "dist"