@arcblock/result-html-pages 2.5.58 → 2.5.59

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/lib/index.js CHANGED
@@ -4,43 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.render = render;
7
-
8
7
  var _template = _interopRequireDefault(require("./template"));
9
-
10
8
  var _translations = _interopRequireDefault(require("./translations"));
11
-
12
9
  var _icons = require("./icons");
13
-
14
10
  const _excluded = ["type", "locale", "icon"],
15
- _excluded2 = ["locale"],
16
- _excluded3 = ["locale"],
17
- _excluded4 = ["locale"],
18
- _excluded5 = ["locale"],
19
- _excluded6 = ["locale"],
20
- _excluded7 = ["locale"],
21
- _excluded8 = ["locale"],
22
- _excluded9 = ["status", "locale"];
23
-
11
+ _excluded2 = ["locale"],
12
+ _excluded3 = ["locale"],
13
+ _excluded4 = ["locale"],
14
+ _excluded5 = ["locale"],
15
+ _excluded6 = ["locale"],
16
+ _excluded7 = ["locale"],
17
+ _excluded8 = ["locale"],
18
+ _excluded9 = ["status", "locale"];
24
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
20
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
21
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
22
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
32
25
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
33
-
34
26
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
35
-
36
27
  const renderHandler = _ref => {
37
28
  let {
38
- type,
39
- locale,
40
- icon
41
- } = _ref,
42
- rest = _objectWithoutProperties(_ref, _excluded);
43
-
29
+ type,
30
+ locale,
31
+ icon
32
+ } = _ref,
33
+ rest = _objectWithoutProperties(_ref, _excluded);
44
34
  const translation = _translations.default[locale] || _translations.default.en;
45
35
  return _template.default.render(_objectSpread({
46
36
  icon,
@@ -48,14 +38,12 @@ const renderHandler = _ref => {
48
38
  description: translation[type].description
49
39
  }, rest));
50
40
  };
51
-
52
41
  const renderers = {
53
42
  404: _ref2 => {
54
43
  let {
55
- locale = 'en'
56
- } = _ref2,
57
- rest = _objectWithoutProperties(_ref2, _excluded2);
58
-
44
+ locale = 'en'
45
+ } = _ref2,
46
+ rest = _objectWithoutProperties(_ref2, _excluded2);
59
47
  return renderHandler(_objectSpread({
60
48
  type: 404,
61
49
  locale,
@@ -64,10 +52,9 @@ const renderers = {
64
52
  },
65
53
  403: _ref3 => {
66
54
  let {
67
- locale = 'en'
68
- } = _ref3,
69
- rest = _objectWithoutProperties(_ref3, _excluded3);
70
-
55
+ locale = 'en'
56
+ } = _ref3,
57
+ rest = _objectWithoutProperties(_ref3, _excluded3);
71
58
  return renderHandler(_objectSpread({
72
59
  type: 403,
73
60
  locale,
@@ -76,10 +63,9 @@ const renderers = {
76
63
  },
77
64
  500: _ref4 => {
78
65
  let {
79
- locale = 'en'
80
- } = _ref4,
81
- rest = _objectWithoutProperties(_ref4, _excluded4);
82
-
66
+ locale = 'en'
67
+ } = _ref4,
68
+ rest = _objectWithoutProperties(_ref4, _excluded4);
83
69
  return renderHandler(_objectSpread({
84
70
  type: 500,
85
71
  locale,
@@ -88,10 +74,9 @@ const renderers = {
88
74
  },
89
75
  502: _ref5 => {
90
76
  let {
91
- locale = 'en'
92
- } = _ref5,
93
- rest = _objectWithoutProperties(_ref5, _excluded5);
94
-
77
+ locale = 'en'
78
+ } = _ref5,
79
+ rest = _objectWithoutProperties(_ref5, _excluded5);
95
80
  return renderHandler(_objectSpread({
96
81
  type: 502,
97
82
  locale,
@@ -100,10 +85,9 @@ const renderers = {
100
85
  },
101
86
  error: _ref6 => {
102
87
  let {
103
- locale = 'en'
104
- } = _ref6,
105
- rest = _objectWithoutProperties(_ref6, _excluded6);
106
-
88
+ locale = 'en'
89
+ } = _ref6,
90
+ rest = _objectWithoutProperties(_ref6, _excluded6);
107
91
  return renderHandler(_objectSpread({
108
92
  type: 'error',
109
93
  locale,
@@ -112,10 +96,9 @@ const renderers = {
112
96
  },
113
97
  maintenance: _ref7 => {
114
98
  let {
115
- locale = 'en'
116
- } = _ref7,
117
- rest = _objectWithoutProperties(_ref7, _excluded7);
118
-
99
+ locale = 'en'
100
+ } = _ref7,
101
+ rest = _objectWithoutProperties(_ref7, _excluded7);
119
102
  return renderHandler(_objectSpread({
120
103
  type: 'maintenance',
121
104
  locale,
@@ -124,10 +107,9 @@ const renderers = {
124
107
  },
125
108
  comingSoon: _ref8 => {
126
109
  let {
127
- locale = 'en'
128
- } = _ref8,
129
- rest = _objectWithoutProperties(_ref8, _excluded8);
130
-
110
+ locale = 'en'
111
+ } = _ref8,
112
+ rest = _objectWithoutProperties(_ref8, _excluded8);
131
113
  return renderHandler(_objectSpread({
132
114
  type: 'comingSoon',
133
115
  locale,
@@ -139,28 +121,24 @@ const renderers = {
139
121
  icon: _icons.InfoIcon
140
122
  }, props));
141
123
  }
142
- }; // eslint-disable-next-line import/prefer-default-export
124
+ };
143
125
 
126
+ // eslint-disable-next-line import/prefer-default-export
144
127
  function render() {
145
128
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
146
-
147
129
  const {
148
- status,
149
- locale = 'en'
150
- } = options,
151
- rest = _objectWithoutProperties(options, _excluded9);
152
-
130
+ status,
131
+ locale = 'en'
132
+ } = options,
133
+ rest = _objectWithoutProperties(options, _excluded9);
153
134
  if (status) {
154
135
  const renderer = renderers[status];
155
-
156
136
  if (!renderer) {
157
137
  throw new Error("Please provide a valid status. Valid values are: ".concat(Object.keys(renderers).join(', ')));
158
138
  }
159
-
160
139
  return renderer(_objectSpread({
161
140
  locale
162
141
  }, rest));
163
142
  }
164
-
165
143
  return _template.default.render(_objectSpread({}, rest));
166
144
  }
package/lib/template.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function render(_ref) {
9
8
  let {
10
9
  pageTitle,
@@ -14,16 +13,13 @@ function render(_ref) {
14
13
  extra,
15
14
  hiddenText = ''
16
15
  } = _ref;
17
-
18
16
  if (!title) {
19
17
  throw new Error('title is required');
20
- } // eslint-disable-next-line no-param-reassign
21
-
22
-
18
+ }
19
+ // eslint-disable-next-line no-param-reassign
23
20
  pageTitle = pageTitle || "".concat(title, " - Blocklet Server");
24
21
  return "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>".concat(pageTitle, "</title>\n <style>\n html {\n box-sizing: border-box;\n font-size: 16px;\n }\n *, *::before, *::after {\n box-sizing: inherit;\n }\n html, body {\n height: 100%;\n }\n body {\n margin: 0;\n }\n .container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 100%;\n padding: 16px;\n background-color: #f7f8fb;\n }\n .svg-wrapper > * {\n fill: currentColor;\n width: 1em;\n height: 1em;\n display: inline-block;\n }\n .title {\n margin-top: 24px;\n font-size: 22px;\n font-weight: 400;\n color: #47494E;\n text-align: center;\n }\n .description {\n margin-top: 8px;\n font-size: 14px;\n color: #7F828B;\n text-align: center;\n }\n .extra {\n margin-top: 24px;\n }\n </style>\n </head>\n <body>\n <div class=\"container\">\n ").concat(icon ? "<span class=\"svg-wrapper\">".concat(icon, "</span>") : '', "\n <div class=\"title\">\n ").concat(title, "\n </div>\n ").concat(description ? "<div class=\"description\">".concat(description, "</div>") : '', "\n ").concat(extra ? "<div class=\"extra\">".concat(extra, "</div>") : '', "\n ").concat(hiddenText ? "<div style=\"display:none;\">".concat(hiddenText, "</div>") : '', "\n </div>\n </body>\n </html>");
25
22
  }
26
-
27
23
  var _default = {
28
24
  render
29
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/result-html-pages",
3
- "version": "2.5.58",
3
+ "version": "2.5.59",
4
4
  "description": "This package provide a function that generates html code for common error pages such as 404, 500, etc.",
5
5
  "keywords": [
6
6
  "arcblock",
@@ -40,5 +40,5 @@
40
40
  "eslint-plugin-react-hooks": "^4.6.0",
41
41
  "jest": "^28.1.3"
42
42
  },
43
- "gitHead": "ac16776460613a0e3a004ebb66fba2b98f3e0d86"
43
+ "gitHead": "f50c420e5f06ae108d59636cfdcfde88d1e10f4c"
44
44
  }