@modern-js/create-request 2.7.0 → 2.8.1-alpha.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.
package/README.md CHANGED
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
19
19
 
20
20
  ## Contributing
21
21
 
22
- Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
22
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
23
23
 
24
24
  ## License
25
25
 
26
- Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
26
+ Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
@@ -1,4 +1,4 @@
1
1
  import nodeFetch from 'node-fetch';
2
2
  import type { RequestCreator, IOptions } from './types';
3
3
  export declare const configure: (options: IOptions<typeof nodeFetch>) => void;
4
- export declare const createRequest: RequestCreator;
4
+ export declare const createRequest: RequestCreator<typeof nodeFetch>;
@@ -1,4 +1,3 @@
1
- import type nodeFetch from 'node-fetch';
2
1
  import type { HttpMethodDecider } from '@modern-js/types';
3
2
  export type BFFRequestPayload = {
4
3
  params?: Record<string, any>;
@@ -10,12 +9,11 @@ export type BFFRequestPayload = {
10
9
  headers?: Record<string, any>;
11
10
  cookies?: Record<string, any>;
12
11
  };
13
- export type Fetch = typeof fetch | typeof nodeFetch;
14
- export type Sender = ((...args: any[]) => Promise<any>) & {
15
- fetch?: Fetch;
12
+ export type Sender<F = typeof fetch> = ((...args: any[]) => Promise<any>) & {
13
+ fetch?: F;
16
14
  };
17
- export type RequestCreator = (path: string, method: string, port: number, httpMethodDecider: HttpMethodDecider, fetch?: Fetch) => Sender;
18
- export type IOptions<F = Fetch> = {
15
+ export type RequestCreator<F = typeof fetch> = (path: string, method: string, port: number, httpMethodDecider: HttpMethodDecider, fetch?: F) => Sender;
16
+ export type IOptions<F = typeof fetch> = {
19
17
  request?: F;
20
18
  interceptor?: (request: F) => F;
21
19
  allowedHeaders?: string[];
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@modern-js/create-request",
3
3
  "description": "A Progressive React Framework for modern web development.",
4
4
  "homepage": "https://modernjs.dev",
5
- "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
- "repository": "modern-js-dev/modern.js",
5
+ "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
+ "repository": "web-infra-dev/modern.js",
7
7
  "license": "MIT",
8
8
  "keywords": [
9
9
  "react",
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.7.0",
14
+ "version": "2.8.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/cjs/index.js",
@@ -24,10 +24,12 @@
24
24
  "exports": {
25
25
  ".": {
26
26
  "node": "./dist/esm/node.js",
27
+ "types": "./dist/types/index.d.ts",
27
28
  "default": "./dist/esm/browser.js"
28
29
  },
29
30
  "./client": {
30
31
  "jsnext:source": "./src/browser.ts",
32
+ "types": "./dist/types/browser.d.ts",
31
33
  "default": "./dist/esm/browser.js"
32
34
  },
33
35
  "./modern": {
@@ -36,11 +38,8 @@
36
38
  },
37
39
  "./server": {
38
40
  "jsnext:source": "./src/node.ts",
41
+ "types": "./dist/types/node.d.ts",
39
42
  "default": "./dist/cjs/node.js"
40
- },
41
- "./hook": {
42
- "jsnext:source": "./src/hook.ts",
43
- "default": "./dist/cjs/hook.js"
44
43
  }
45
44
  },
46
45
  "typesVersions": {
@@ -61,7 +60,7 @@
61
60
  "node-fetch": "^2.6.1",
62
61
  "path-to-regexp": "^6.2.0",
63
62
  "query-string": "^7.1.1",
64
- "@modern-js/utils": "2.7.0"
63
+ "@modern-js/utils": "2.8.1-alpha.0"
65
64
  },
66
65
  "devDependencies": {
67
66
  "@types/jest": "^27",
@@ -71,9 +70,9 @@
71
70
  "jest": "^27",
72
71
  "nock": "^13.2.1",
73
72
  "typescript": "^4",
74
- "@modern-js/types": "2.7.0",
75
- "@scripts/jest-config": "2.7.0",
76
- "@scripts/build": "2.7.0"
73
+ "@modern-js/types": "2.8.0",
74
+ "@scripts/build": "2.8.0",
75
+ "@scripts/jest-config": "2.8.0"
77
76
  },
78
77
  "sideEffects": false,
79
78
  "publishConfig": {
package/dist/cjs/index.js DELETED
@@ -1,29 +0,0 @@
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 src_exports = {};
19
- __export(src_exports, {
20
- default: () => src_default
21
- });
22
- module.exports = __toCommonJS(src_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;
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {});
package/dist/esm/index.js DELETED
@@ -1,36 +0,0 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
- }
9
- function _iterableToArray(iter) {
10
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
- }
12
- function _nonIterableSpread() {
13
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
- }
15
- function _toConsumableArray(arr) {
16
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
- }
18
- function _unsupportedIterableToArray(o, minLen) {
19
- if (!o) return;
20
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
- var n = Object.prototype.toString.call(o).slice(8, -1);
22
- if (n === "Object" && o.constructor) n = o.constructor.name;
23
- if (n === "Map" || n === "Set") return Array.from(n);
24
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
- }
26
- import { isBrowser } from "@modern-js/utils";
27
- import { createRequest as browser } from "./browser";
28
- import { createRequest as node } from "./node";
29
- var createRequest = function() {
30
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
31
- args[_key] = arguments[_key];
32
- }
33
- return isBrowser() ? browser.apply(void 0, _toConsumableArray(args)) : node.apply(void 0, _toConsumableArray(args));
34
- };
35
- var src_default = createRequest;
36
- export { src_default as default };
@@ -1,8 +0,0 @@
1
- import { isBrowser } from "@modern-js/utils";
2
- import { createRequest as browser } from "./browser";
3
- import { createRequest as node } from "./node";
4
- const createRequest = (...args) => isBrowser() ? browser(...args) : node(...args);
5
- var src_default = createRequest;
6
- export {
7
- src_default as default
8
- };
@@ -1,4 +0,0 @@
1
- import { RequestCreator, IOptions } from './types';
2
- declare const createRequest: RequestCreator;
3
- export declare const configure: (options: IOptions) => void;
4
- export default createRequest;