@modern-js/bff-core 2.14.0 → 2.16.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.
@@ -26,9 +26,7 @@ const createStorage = () => {
26
26
  }
27
27
  const context = storage.getStore();
28
28
  if (!context) {
29
- throw new Error(
30
- `Can't call useContext out of scope, it should be placed in the bff function`
31
- );
29
+ throw new Error(`Can't call useContext out of scope, it should be placed in the bff function`);
32
30
  }
33
31
  return context;
34
32
  };
@@ -37,6 +35,4 @@ const createStorage = () => {
37
35
  useContext
38
36
  };
39
37
  };
40
- export {
41
- createStorage
42
- };
38
+ export { createStorage };
@@ -1,20 +1,24 @@
1
1
  import util from "util";
2
- const getTypeErrorMessage = (actual) => {
3
- var _a;
2
+ export const getTypeErrorMessage = (actual) => {
4
3
  let msg = "";
5
4
  if (actual == null) {
6
5
  msg += `. Received ${actual}`;
7
6
  } else if (typeof actual === "function" && actual.name) {
8
7
  msg += `. Received function ${actual.name}`;
9
8
  } else if (typeof actual === "object") {
10
- if ((_a = actual.constructor) == null ? void 0 : _a.name) {
9
+ var _actual_constructor;
10
+ if ((_actual_constructor = actual.constructor) === null || _actual_constructor === void 0 ? void 0 : _actual_constructor.name) {
11
11
  msg += `. Received an instance of ${actual.constructor.name}`;
12
12
  } else {
13
- const inspected = util.inspect(actual, { depth: -1 });
13
+ const inspected = util.inspect(actual, {
14
+ depth: -1
15
+ });
14
16
  msg += `. Received ${inspected}`;
15
17
  }
16
18
  } else {
17
- let inspected = util.inspect(actual, { colors: false });
19
+ let inspected = util.inspect(actual, {
20
+ colors: false
21
+ });
18
22
  if (inspected.length > 25) {
19
23
  inspected = `${inspected.slice(0, 25)}...`;
20
24
  }
@@ -22,22 +26,15 @@ const getTypeErrorMessage = (actual) => {
22
26
  }
23
27
  return msg;
24
28
  };
25
- class ERR_INVALID_ARG_TYPE extends Error {
29
+ export class ERR_INVALID_ARG_TYPE extends Error {
26
30
  constructor(funcName, expectedType, actual) {
27
- const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
28
- actual
29
- )}`;
31
+ const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(actual)}`;
30
32
  super(message);
31
33
  }
32
34
  }
33
- const validateFunction = (maybeFunc, name) => {
35
+ export const validateFunction = (maybeFunc, name) => {
34
36
  if (typeof maybeFunc !== "function") {
35
37
  throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
36
38
  }
37
39
  return true;
38
40
  };
39
- export {
40
- ERR_INVALID_ARG_TYPE,
41
- getTypeErrorMessage,
42
- validateFunction
43
- };
package/package.json CHANGED
@@ -3,7 +3,11 @@
3
3
  "description": "A Progressive React Framework for modern web development.",
4
4
  "homepage": "https://modernjs.dev",
5
5
  "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
- "repository": "web-infra-dev/modern.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/web-infra-dev/modern.js",
9
+ "directory": "packages/server/bff-core"
10
+ },
7
11
  "license": "MIT",
8
12
  "keywords": [
9
13
  "react",
@@ -11,7 +15,7 @@
11
15
  "modern",
12
16
  "modern.js"
13
17
  ],
14
- "version": "2.14.0",
18
+ "version": "2.16.0",
15
19
  "jsnext:source": "./src/index.ts",
16
20
  "types": "./dist/types/index.d.ts",
17
21
  "main": "./dist/cjs/index.js",
@@ -27,8 +31,8 @@
27
31
  "@babel/runtime": "^7.18.0",
28
32
  "koa-compose": "^4.1.0",
29
33
  "reflect-metadata": "^0.1.13",
30
- "@modern-js/bff-runtime": "2.14.0",
31
- "@modern-js/utils": "2.14.0"
34
+ "@modern-js/bff-runtime": "2.16.0",
35
+ "@modern-js/utils": "2.16.0"
32
36
  },
33
37
  "devDependencies": {
34
38
  "@types/jest": "^29",
@@ -40,9 +44,9 @@
40
44
  "type-fest": "2.15.0",
41
45
  "typescript": "^4",
42
46
  "zod": "^3.17.3",
43
- "@modern-js/types": "2.14.0",
44
- "@scripts/build": "2.14.0",
45
- "@scripts/jest-config": "2.14.0"
47
+ "@modern-js/types": "2.16.0",
48
+ "@scripts/build": "2.16.0",
49
+ "@scripts/jest-config": "2.16.0"
46
50
  },
47
51
  "peerDependencies": {
48
52
  "zod": "^3.17.3",