@modern-js/create-request 2.0.0-beta.3 → 2.0.0-beta.4

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,44 +1,51 @@
1
- import { compile, pathToRegexp } from 'path-to-regexp';
2
- import qs from 'query-string';
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { compile, pathToRegexp } from "path-to-regexp";
22
+ import qs from "query-string";
3
23
  import { handleRes } from "./handleRes";
4
24
  let realRequest;
5
25
  let realAllowedHeaders;
6
26
  const originFetch = (...params) => fetch(...params).then(handleRes);
7
- export const configure = options => {
8
- const {
9
- request,
10
- interceptor,
11
- allowedHeaders
12
- } = options;
27
+ const configure = (options) => {
28
+ const { request, interceptor, allowedHeaders } = options;
13
29
  realRequest = request || originFetch;
14
30
  if (interceptor && !request) {
15
31
  realRequest = interceptor(fetch);
16
32
  }
17
33
  if (Array.isArray(allowedHeaders)) {
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
34
  realAllowedHeaders = allowedHeaders;
20
35
  }
21
36
  };
22
- export const createRequest = (path, method, port,
23
- // 后续可能要修改,暂时先保留
24
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- fetch = originFetch) => {
26
- const getFinalPath = compile(path, {
27
- encode: encodeURIComponent
28
- });
37
+ const createRequest = (path, method, port, fetch2 = originFetch) => {
38
+ const getFinalPath = compile(path, { encode: encodeURIComponent });
29
39
  const keys = [];
30
40
  pathToRegexp(path, keys);
31
- const sender = async (...args) => {
41
+ const sender = (...args) => __async(void 0, null, function* () {
32
42
  const fetcher = realRequest || originFetch;
33
- const payload = typeof args[args.length - 1] === 'object' ? args[args.length - 1] : {};
43
+ const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
34
44
  payload.params = payload.params || {};
35
45
  const requestParams = args[0];
36
- // 这种场景下是使用 schema,所以 params 要从 args[0] 中获取
37
- if (typeof requestParams === 'object' && requestParams.params) {
38
- const {
39
- params
40
- } = requestParams;
41
- keys.forEach(key => {
46
+ if (typeof requestParams === "object" && requestParams.params) {
47
+ const { params } = requestParams;
48
+ keys.forEach((key) => {
42
49
  payload.params[key.name] = params[key.name];
43
50
  });
44
51
  } else {
@@ -49,26 +56,18 @@ fetch = originFetch) => {
49
56
  const finalPath = getFinalPath(payload.params);
50
57
  const finalURL = payload.query ? `${finalPath}?${qs.stringify(payload.query)}` : finalPath;
51
58
  const headers = payload.headers || {};
52
- let body = payload.data && typeof payload.data === 'object' ? JSON.stringify(payload.data) : payload.body;
59
+ let body = payload.data && typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.body;
53
60
  if (payload.data) {
54
- headers['Content-Type'] = 'application/json';
55
- body = typeof payload.data === 'object' ? JSON.stringify(payload.data) : payload.body;
61
+ headers["Content-Type"] = "application/json";
62
+ body = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.body;
56
63
  } else if (payload.body) {
57
- headers['Content-Type'] = 'text/plain';
58
- // eslint-disable-next-line prefer-destructuring
64
+ headers["Content-Type"] = "text/plain";
59
65
  body = payload.body;
60
66
  } else if (payload.formData) {
61
67
  body = payload.formData;
62
- // https://stackoverflow.com/questions/44919424/bad-content-type-header-no-multipart-boundary-nodejs
63
- // need multipart boundary aotu attached by browser when multipart is true
64
- // headers['Content-Type'] = 'multipart/form-data';
65
68
  } else if (payload.formUrlencoded) {
66
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
67
- if (typeof payload.formUrlencoded === 'object' &&
68
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
69
- // @ts-expect-error
70
- // eslint-disable-next-line node/prefer-global/url-search-params,node/no-unsupported-features/node-builtins
71
- !(payload.formUrlencoded instanceof URLSearchParams)) {
69
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
70
+ if (typeof payload.formUrlencoded === "object" && !(payload.formUrlencoded instanceof URLSearchParams)) {
72
71
  body = qs.stringify(payload.formUrlencoded);
73
72
  } else {
74
73
  body = payload.formUrlencoded;
@@ -79,6 +78,10 @@ fetch = originFetch) => {
79
78
  body,
80
79
  headers
81
80
  });
82
- };
81
+ });
83
82
  return sender;
84
- };
83
+ };
84
+ export {
85
+ configure,
86
+ createRequest
87
+ };
@@ -1,24 +1,44 @@
1
- const handleRes = async res => {
2
- const contentType = res.headers.get('content-type');
3
-
4
- // https://developer.mozilla.org/en-US/docs/Web/API/Response/ok
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ const handleRes = (res) => __async(void 0, null, function* () {
22
+ const contentType = res.headers.get("content-type");
5
23
  if (!res.ok) {
6
- const data = await res.json();
24
+ const data = yield res.json();
7
25
  res.data = data;
8
26
  throw res;
9
27
  }
10
- if (contentType !== null && contentType !== void 0 && contentType.includes('application/json') || contentType !== null && contentType !== void 0 && contentType.includes('text/json')) {
28
+ if ((contentType == null ? void 0 : contentType.includes("application/json")) || (contentType == null ? void 0 : contentType.includes("text/json"))) {
11
29
  return res.json();
12
30
  }
13
- if (contentType !== null && contentType !== void 0 && contentType.includes('text/html') || contentType !== null && contentType !== void 0 && contentType.includes('text/plain')) {
31
+ if ((contentType == null ? void 0 : contentType.includes("text/html")) || (contentType == null ? void 0 : contentType.includes("text/plain"))) {
14
32
  return res.text();
15
33
  }
16
- if ((contentType !== null && contentType !== void 0 && contentType.includes('application/x-www-form-urlencoded') || contentType !== null && contentType !== void 0 && contentType.includes('multipart/form-data')) && res instanceof Response) {
34
+ if (((contentType == null ? void 0 : contentType.includes("application/x-www-form-urlencoded")) || (contentType == null ? void 0 : contentType.includes("multipart/form-data"))) && res instanceof Response) {
17
35
  return res.formData();
18
36
  }
19
- if (contentType !== null && contentType !== void 0 && contentType.includes('application/octet-stream')) {
37
+ if (contentType == null ? void 0 : contentType.includes("application/octet-stream")) {
20
38
  return res.arrayBuffer();
21
39
  }
22
40
  return res.text();
41
+ });
42
+ export {
43
+ handleRes
23
44
  };
24
- export { handleRes };
@@ -1,5 +1,8 @@
1
- import { isBrowser } from '@modern-js/utils';
1
+ import { isBrowser } from "@modern-js/utils";
2
2
  import { createRequest as browser } from "./browser";
3
3
  import { createRequest as node } from "./node";
4
4
  const createRequest = (...args) => isBrowser() ? browser(...args) : node(...args);
5
- export default createRequest;
5
+ var src_default = createRequest;
6
+ export {
7
+ src_default as default
8
+ };
@@ -1,17 +1,13 @@
1
- import nodeFetch from 'node-fetch';
2
- import { compile, pathToRegexp } from 'path-to-regexp';
3
- import { useHeaders } from '@modern-js/utils/ssr';
4
- import qs from 'query-string';
1
+ import nodeFetch from "node-fetch";
2
+ import { compile, pathToRegexp } from "path-to-regexp";
3
+ import { useHeaders } from "@modern-js/utils/ssr";
4
+ import qs from "query-string";
5
5
  import { handleRes } from "./handleRes";
6
6
  let realRequest;
7
7
  let realAllowedHeaders = [];
8
8
  const originFetch = (...params) => nodeFetch(...params).then(handleRes);
9
- export const configure = options => {
10
- const {
11
- request,
12
- interceptor,
13
- allowedHeaders
14
- } = options;
9
+ const configure = (options) => {
10
+ const { request, interceptor, allowedHeaders } = options;
15
11
  realRequest = request || originFetch;
16
12
  if (interceptor && !request) {
17
13
  realRequest = interceptor(nodeFetch);
@@ -20,26 +16,18 @@ export const configure = options => {
20
16
  realAllowedHeaders = allowedHeaders;
21
17
  }
22
18
  };
23
- export const createRequest = (path, method, port,
24
- // 后续可能要修改,暂时先保留
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- fetch = nodeFetch) => {
27
- const getFinalPath = compile(path, {
28
- encode: encodeURIComponent
29
- });
19
+ const createRequest = (path, method, port, fetch = nodeFetch) => {
20
+ const getFinalPath = compile(path, { encode: encodeURIComponent });
30
21
  const keys = [];
31
22
  pathToRegexp(path, keys);
32
23
  const sender = (...args) => {
33
24
  const webRequestHeaders = useHeaders();
34
- const payload = typeof args[args.length - 1] === 'object' ? args[args.length - 1] : {};
25
+ const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
35
26
  payload.params = payload.params || {};
36
27
  const requestParams = args[0];
37
- // 这种场景下是使用 schema,所以 params 要从 args[0] 中获取
38
- if (typeof requestParams === 'object' && requestParams.params) {
39
- const {
40
- params
41
- } = requestParams;
42
- keys.forEach(key => {
28
+ if (typeof requestParams === "object" && requestParams.params) {
29
+ const { params } = requestParams;
30
+ keys.forEach((key) => {
43
31
  payload.params[key.name] = params[key.name];
44
32
  });
45
33
  } else {
@@ -52,25 +40,21 @@ fetch = nodeFetch) => {
52
40
  const headers = payload.headers || {};
53
41
  let body;
54
42
  for (const key of realAllowedHeaders) {
55
- if (typeof webRequestHeaders[key] !== 'undefined') {
43
+ if (typeof webRequestHeaders[key] !== "undefined") {
56
44
  headers[key] = webRequestHeaders[key];
57
45
  }
58
46
  }
59
47
  if (payload.data) {
60
- headers['Content-Type'] = 'application/json';
61
- body = typeof payload.data === 'object' ? JSON.stringify(payload.data) : payload.body;
48
+ headers["Content-Type"] = "application/json";
49
+ body = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.body;
62
50
  } else if (payload.body) {
63
- headers['Content-Type'] = 'text/plain';
64
- // eslint-disable-next-line prefer-destructuring
51
+ headers["Content-Type"] = "text/plain";
65
52
  body = payload.body;
66
53
  } else if (payload.formData) {
67
54
  body = payload.formData;
68
- // https://stackoverflow.com/questions/44919424/bad-content-type-header-no-multipart-boundary-nodejs
69
- // need multipart boundary auto attached by node-fetch when multipart is true
70
- // headers['Content-Type'] = 'multipart/form-data';
71
55
  } else if (payload.formUrlencoded) {
72
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
73
- if (typeof payload.formUrlencoded === 'object') {
56
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
57
+ if (typeof payload.formUrlencoded === "object") {
74
58
  body = qs.stringify(payload.formUrlencoded);
75
59
  } else {
76
60
  body = payload.formUrlencoded;
@@ -78,11 +62,11 @@ fetch = nodeFetch) => {
78
62
  }
79
63
  const url = `http://localhost:${port}${finalPath}`;
80
64
  const fetcher = realRequest || originFetch;
81
- return fetcher(url, {
82
- method,
83
- body,
84
- headers
85
- });
65
+ return fetcher(url, { method, body, headers });
86
66
  };
87
67
  return sender;
88
- };
68
+ };
69
+ export {
70
+ configure,
71
+ createRequest
72
+ };
@@ -1,52 +1,80 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var stdin_exports = {};
25
+ __export(stdin_exports, {
26
+ configure: () => configure,
27
+ createRequest: () => createRequest
5
28
  });
6
- exports.createRequest = exports.configure = void 0;
7
- var _pathToRegexp = require("path-to-regexp");
8
- var _queryString = _interopRequireDefault(require("query-string"));
9
- var _handleRes = require("./handleRes");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ module.exports = __toCommonJS(stdin_exports);
30
+ var import_path_to_regexp = require("path-to-regexp");
31
+ var import_query_string = __toESM(require("query-string"));
32
+ var import_handleRes = require("./handleRes");
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
11
53
  let realRequest;
12
54
  let realAllowedHeaders;
13
- const originFetch = (...params) => fetch(...params).then(_handleRes.handleRes);
14
- const configure = options => {
15
- const {
16
- request,
17
- interceptor,
18
- allowedHeaders
19
- } = options;
55
+ const originFetch = (...params) => fetch(...params).then(import_handleRes.handleRes);
56
+ const configure = (options) => {
57
+ const { request, interceptor, allowedHeaders } = options;
20
58
  realRequest = request || originFetch;
21
59
  if (interceptor && !request) {
22
60
  realRequest = interceptor(fetch);
23
61
  }
24
62
  if (Array.isArray(allowedHeaders)) {
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
63
  realAllowedHeaders = allowedHeaders;
27
64
  }
28
65
  };
29
- exports.configure = configure;
30
- const createRequest = (path, method, port,
31
- // 后续可能要修改,暂时先保留
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- fetch = originFetch) => {
34
- const getFinalPath = (0, _pathToRegexp.compile)(path, {
35
- encode: encodeURIComponent
36
- });
66
+ const createRequest = (path, method, port, fetch2 = originFetch) => {
67
+ const getFinalPath = (0, import_path_to_regexp.compile)(path, { encode: encodeURIComponent });
37
68
  const keys = [];
38
- (0, _pathToRegexp.pathToRegexp)(path, keys);
39
- const sender = async (...args) => {
69
+ (0, import_path_to_regexp.pathToRegexp)(path, keys);
70
+ const sender = (...args) => __async(void 0, null, function* () {
40
71
  const fetcher = realRequest || originFetch;
41
- const payload = typeof args[args.length - 1] === 'object' ? args[args.length - 1] : {};
72
+ const payload = typeof args[args.length - 1] === "object" ? args[args.length - 1] : {};
42
73
  payload.params = payload.params || {};
43
74
  const requestParams = args[0];
44
- // 这种场景下是使用 schema,所以 params 要从 args[0] 中获取
45
- if (typeof requestParams === 'object' && requestParams.params) {
46
- const {
47
- params
48
- } = requestParams;
49
- keys.forEach(key => {
75
+ if (typeof requestParams === "object" && requestParams.params) {
76
+ const { params } = requestParams;
77
+ keys.forEach((key) => {
50
78
  payload.params[key.name] = params[key.name];
51
79
  });
52
80
  } else {
@@ -55,29 +83,21 @@ fetch = originFetch) => {
55
83
  });
56
84
  }
57
85
  const finalPath = getFinalPath(payload.params);
58
- const finalURL = payload.query ? `${finalPath}?${_queryString.default.stringify(payload.query)}` : finalPath;
86
+ const finalURL = payload.query ? `${finalPath}?${import_query_string.default.stringify(payload.query)}` : finalPath;
59
87
  const headers = payload.headers || {};
60
- let body = payload.data && typeof payload.data === 'object' ? JSON.stringify(payload.data) : payload.body;
88
+ let body = payload.data && typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.body;
61
89
  if (payload.data) {
62
- headers['Content-Type'] = 'application/json';
63
- body = typeof payload.data === 'object' ? JSON.stringify(payload.data) : payload.body;
90
+ headers["Content-Type"] = "application/json";
91
+ body = typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.body;
64
92
  } else if (payload.body) {
65
- headers['Content-Type'] = 'text/plain';
66
- // eslint-disable-next-line prefer-destructuring
93
+ headers["Content-Type"] = "text/plain";
67
94
  body = payload.body;
68
95
  } else if (payload.formData) {
69
96
  body = payload.formData;
70
- // https://stackoverflow.com/questions/44919424/bad-content-type-header-no-multipart-boundary-nodejs
71
- // need multipart boundary aotu attached by browser when multipart is true
72
- // headers['Content-Type'] = 'multipart/form-data';
73
97
  } else if (payload.formUrlencoded) {
74
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
75
- if (typeof payload.formUrlencoded === 'object' &&
76
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
77
- // @ts-expect-error
78
- // eslint-disable-next-line node/prefer-global/url-search-params,node/no-unsupported-features/node-builtins
79
- !(payload.formUrlencoded instanceof URLSearchParams)) {
80
- body = _queryString.default.stringify(payload.formUrlencoded);
98
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
99
+ if (typeof payload.formUrlencoded === "object" && !(payload.formUrlencoded instanceof URLSearchParams)) {
100
+ body = import_query_string.default.stringify(payload.formUrlencoded);
81
101
  } else {
82
102
  body = payload.formUrlencoded;
83
103
  }
@@ -87,7 +107,6 @@ fetch = originFetch) => {
87
107
  body,
88
108
  headers
89
109
  });
90
- };
110
+ });
91
111
  return sender;
92
112
  };
93
- exports.createRequest = createRequest;
@@ -1,30 +1,63 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ handleRes: () => handleRes
5
21
  });
6
- exports.handleRes = void 0;
7
- const handleRes = async res => {
8
- const contentType = res.headers.get('content-type');
9
-
10
- // https://developer.mozilla.org/en-US/docs/Web/API/Response/ok
22
+ module.exports = __toCommonJS(stdin_exports);
23
+ var __async = (__this, __arguments, generator) => {
24
+ return new Promise((resolve, reject) => {
25
+ var fulfilled = (value) => {
26
+ try {
27
+ step(generator.next(value));
28
+ } catch (e) {
29
+ reject(e);
30
+ }
31
+ };
32
+ var rejected = (value) => {
33
+ try {
34
+ step(generator.throw(value));
35
+ } catch (e) {
36
+ reject(e);
37
+ }
38
+ };
39
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
40
+ step((generator = generator.apply(__this, __arguments)).next());
41
+ });
42
+ };
43
+ const handleRes = (res) => __async(void 0, null, function* () {
44
+ const contentType = res.headers.get("content-type");
11
45
  if (!res.ok) {
12
- const data = await res.json();
46
+ const data = yield res.json();
13
47
  res.data = data;
14
48
  throw res;
15
49
  }
16
- if (contentType !== null && contentType !== void 0 && contentType.includes('application/json') || contentType !== null && contentType !== void 0 && contentType.includes('text/json')) {
50
+ if ((contentType == null ? void 0 : contentType.includes("application/json")) || (contentType == null ? void 0 : contentType.includes("text/json"))) {
17
51
  return res.json();
18
52
  }
19
- if (contentType !== null && contentType !== void 0 && contentType.includes('text/html') || contentType !== null && contentType !== void 0 && contentType.includes('text/plain')) {
53
+ if ((contentType == null ? void 0 : contentType.includes("text/html")) || (contentType == null ? void 0 : contentType.includes("text/plain"))) {
20
54
  return res.text();
21
55
  }
22
- if ((contentType !== null && contentType !== void 0 && contentType.includes('application/x-www-form-urlencoded') || contentType !== null && contentType !== void 0 && contentType.includes('multipart/form-data')) && res instanceof Response) {
56
+ if (((contentType == null ? void 0 : contentType.includes("application/x-www-form-urlencoded")) || (contentType == null ? void 0 : contentType.includes("multipart/form-data"))) && res instanceof Response) {
23
57
  return res.formData();
24
58
  }
25
- if (contentType !== null && contentType !== void 0 && contentType.includes('application/octet-stream')) {
59
+ if (contentType == null ? void 0 : contentType.includes("application/octet-stream")) {
26
60
  return res.arrayBuffer();
27
61
  }
28
62
  return res.text();
29
- };
30
- exports.handleRes = handleRes;
63
+ });
@@ -1,12 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ default: () => src_default
5
21
  });
6
- exports.default = void 0;
7
- var _utils = require("@modern-js/utils");
8
- var _browser = require("./browser");
9
- var _node = require("./node");
10
- const createRequest = (...args) => (0, _utils.isBrowser)() ? (0, _browser.createRequest)(...args) : (0, _node.createRequest)(...args);
11
- var _default = createRequest;
12
- exports.default = _default;
22
+ module.exports = __toCommonJS(stdin_exports);
23
+ var import_utils = require("@modern-js/utils");
24
+ var import_browser = require("./browser");
25
+ var import_node = require("./node");
26
+ const createRequest = (...args) => (0, import_utils.isBrowser)() ? (0, import_browser.createRequest)(...args) : (0, import_node.createRequest)(...args);
27
+ var src_default = createRequest;