@arcblock/result-html-pages 3.0.9 → 3.0.11

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/es/icons.js ADDED
@@ -0,0 +1,5 @@
1
+ const o = '<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(241, 110, 110); font-size: 72px;"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0a.9959.9959 0 010-1.41L10.59 12 7.7 9.11a.9959.9959 0 010-1.41c.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"></path></svg>', s = '<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(7, 117, 248); font-size: 72px;"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></svg>';
2
+ export {
3
+ o as ErrorIcon,
4
+ s as InfoIcon
5
+ };
package/es/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import s from "./template.js";
2
+ import p from "./translations.js";
3
+ import { InfoIcon as a, ErrorIcon as t } from "./icons.js";
4
+ const r = ({ type: e, locale: n, icon: c, ...i }) => {
5
+ const o = p[n] || p.en;
6
+ return s.render({
7
+ icon: c,
8
+ title: o[e].title,
9
+ description: o[e].description,
10
+ ...i
11
+ });
12
+ }, d = {
13
+ 404: ({ locale: e = "en", ...n }) => r({ type: 404, locale: e, icon: t, ...n }),
14
+ 403: ({ locale: e = "en", ...n }) => r({ type: 403, locale: e, icon: t, ...n }),
15
+ 500: ({ locale: e = "en", ...n }) => r({ type: 500, locale: e, icon: t, ...n }),
16
+ 502: ({ locale: e = "en", ...n }) => r({ type: 502, locale: e, icon: t, ...n }),
17
+ error: ({ locale: e = "en", ...n }) => r({ type: "error", locale: e, icon: t, ...n }),
18
+ maintenance: ({ locale: e = "en", ...n }) => r({ type: "maintenance", locale: e, icon: a, ...n }),
19
+ comingSoon: ({ locale: e = "en", ...n }) => r({ type: "comingSoon", locale: e, icon: a, ...n }),
20
+ info: (e) => s.render({
21
+ icon: a,
22
+ ...e
23
+ })
24
+ };
25
+ function u(e = {}) {
26
+ const { status: n, locale: c = "en", ...i } = e;
27
+ if (n) {
28
+ const o = d[n];
29
+ if (!o)
30
+ throw new Error(`Please provide a valid status. Valid values are: ${Object.keys(d).join(", ")}`);
31
+ return o({ locale: c, ...i });
32
+ }
33
+ return s.render({ ...i });
34
+ }
35
+ export {
36
+ u as render
37
+ };
package/es/template.js ADDED
@@ -0,0 +1,74 @@
1
+ function l({ pageTitle: e, title: t, icon: i, description: n, extra: r, hiddenText: o = "" }) {
2
+ if (!t)
3
+ throw new Error("title is required");
4
+ return e = e || `${t} - Blocklet Server`, `
5
+ <!DOCTYPE html>
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="UTF-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+ <title>${e}</title>
11
+ <style>
12
+ html {
13
+ box-sizing: border-box;
14
+ font-size: 16px;
15
+ }
16
+ *, *::before, *::after {
17
+ box-sizing: inherit;
18
+ }
19
+ html, body {
20
+ height: 100%;
21
+ }
22
+ body {
23
+ margin: 0;
24
+ }
25
+ .container {
26
+ display: flex;
27
+ flex-direction: column;
28
+ justify-content: center;
29
+ align-items: center;
30
+ height: 100%;
31
+ padding: 16px;
32
+ background-color: #f7f8fb;
33
+ }
34
+ .svg-wrapper > * {
35
+ fill: currentColor;
36
+ width: 1em;
37
+ height: 1em;
38
+ display: inline-block;
39
+ }
40
+ .title {
41
+ margin-top: 24px;
42
+ font-size: 22px;
43
+ font-weight: 400;
44
+ color: #47494E;
45
+ text-align: center;
46
+ }
47
+ .description {
48
+ margin-top: 8px;
49
+ font-size: 14px;
50
+ color: #7F828B;
51
+ text-align: center;
52
+ }
53
+ .extra {
54
+ margin-top: 24px;
55
+ }
56
+ </style>
57
+ </head>
58
+ <body>
59
+ <div class="container">
60
+ ${i ? `<span class="svg-wrapper">${i}</span>` : ""}
61
+ <div class="title">
62
+ ${t}
63
+ </div>
64
+ ${n ? `<div class="description">${n}</div>` : ""}
65
+ ${r ? `<div class="extra">${r}</div>` : ""}
66
+ ${o ? `<div style="display:none;">${o}</div>` : ""}
67
+ </div>
68
+ </body>
69
+ </html>`;
70
+ }
71
+ const a = { render: l };
72
+ export {
73
+ a as default
74
+ };
@@ -0,0 +1,65 @@
1
+ const e = {
2
+ en: {
3
+ 404: {
4
+ title: "404 - Page Not Found",
5
+ description: "Sorry about that, the page you are looking for does not exist or has been moved."
6
+ },
7
+ 403: {
8
+ title: "403 – Forbidden",
9
+ description: "Sorry, you are not authorized to access this page."
10
+ },
11
+ 500: {
12
+ title: "500 - Internal Server Error",
13
+ description: "An internal server error has occurred. Please try again later."
14
+ },
15
+ 502: {
16
+ title: "502 - Bad Gateway",
17
+ description: "Proxy to destination server failed. Please try again later."
18
+ },
19
+ error: {
20
+ title: "Application Error",
21
+ description: "Something went wrong. Please try again later."
22
+ },
23
+ maintenance: {
24
+ title: "Offline for maintenance",
25
+ description: "This app is undergoing maintenance right now. Please check back later."
26
+ },
27
+ comingSoon: {
28
+ title: "Coming Soon",
29
+ description: "Our website is under construction. We'll be here soon with our new website."
30
+ }
31
+ },
32
+ zh: {
33
+ 404: {
34
+ title: "404 - 页面未找到",
35
+ description: "很抱歉,您正在寻找的页面不存在或已被移动。"
36
+ },
37
+ 403: {
38
+ title: "403 – 禁止访问",
39
+ description: "很抱歉,您没有权限访问此页面。"
40
+ },
41
+ 500: {
42
+ title: "500 - 内部服务器错误",
43
+ description: "发生了一个内部服务器错误。请稍后再试。"
44
+ },
45
+ 502: {
46
+ title: "502 - 网关错误",
47
+ description: "无法代理到目的服务器。请稍后再试。"
48
+ },
49
+ error: {
50
+ title: "Application Error",
51
+ description: "出错了, 请稍后再试。"
52
+ },
53
+ maintenance: {
54
+ title: "维护中",
55
+ description: "应用程序正在进行维护。请稍后再查看。"
56
+ },
57
+ comingSoon: {
58
+ title: "即将上线",
59
+ description: "我们的网站正在建设中。我们很快就会在这里推出我们的新网站。"
60
+ }
61
+ }
62
+ };
63
+ export {
64
+ e as default
65
+ };
package/lib/icons.js CHANGED
@@ -1,5 +1 @@
1
- const o = '<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(241, 110, 110); font-size: 72px;"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0a.9959.9959 0 010-1.41L10.59 12 7.7 9.11a.9959.9959 0 010-1.41c.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"></path></svg>', s = '<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(7, 117, 248); font-size: 72px;"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></svg>';
2
- export {
3
- o as ErrorIcon,
4
- s as InfoIcon
5
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o='<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(241, 110, 110); font-size: 72px;"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0a.9959.9959 0 010-1.41L10.59 12 7.7 9.11a.9959.9959 0 010-1.41c.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41z"></path></svg>',e='<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" style="color: rgb(7, 117, 248); font-size: 72px;"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></svg>';exports.ErrorIcon=o;exports.InfoIcon=e;
package/lib/index.js CHANGED
@@ -1,37 +1 @@
1
- import s from "./template.js";
2
- import p from "./translations.js";
3
- import { InfoIcon as a, ErrorIcon as t } from "./icons.js";
4
- const r = ({ type: e, locale: n, icon: c, ...i }) => {
5
- const o = p[n] || p.en;
6
- return s.render({
7
- icon: c,
8
- title: o[e].title,
9
- description: o[e].description,
10
- ...i
11
- });
12
- }, d = {
13
- 404: ({ locale: e = "en", ...n }) => r({ type: 404, locale: e, icon: t, ...n }),
14
- 403: ({ locale: e = "en", ...n }) => r({ type: 403, locale: e, icon: t, ...n }),
15
- 500: ({ locale: e = "en", ...n }) => r({ type: 500, locale: e, icon: t, ...n }),
16
- 502: ({ locale: e = "en", ...n }) => r({ type: 502, locale: e, icon: t, ...n }),
17
- error: ({ locale: e = "en", ...n }) => r({ type: "error", locale: e, icon: t, ...n }),
18
- maintenance: ({ locale: e = "en", ...n }) => r({ type: "maintenance", locale: e, icon: a, ...n }),
19
- comingSoon: ({ locale: e = "en", ...n }) => r({ type: "comingSoon", locale: e, icon: a, ...n }),
20
- info: (e) => s.render({
21
- icon: a,
22
- ...e
23
- })
24
- };
25
- function u(e = {}) {
26
- const { status: n, locale: c = "en", ...i } = e;
27
- if (n) {
28
- const o = d[n];
29
- if (!o)
30
- throw new Error(`Please provide a valid status. Valid values are: ${Object.keys(d).join(", ")}`);
31
- return o({ locale: c, ...i });
32
- }
33
- return s.render({ ...i });
34
- }
35
- export {
36
- u as render
37
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./template.js"),a=require("./translations.js"),r=require("./icons.js"),o=({type:e,locale:n,icon:i,...c})=>{const t=a[n]||a.en;return s.render({icon:i,title:t[e].title,description:t[e].description,...c})},d={404:({locale:e="en",...n})=>o({type:404,locale:e,icon:r.ErrorIcon,...n}),403:({locale:e="en",...n})=>o({type:403,locale:e,icon:r.ErrorIcon,...n}),500:({locale:e="en",...n})=>o({type:500,locale:e,icon:r.ErrorIcon,...n}),502:({locale:e="en",...n})=>o({type:502,locale:e,icon:r.ErrorIcon,...n}),error:({locale:e="en",...n})=>o({type:"error",locale:e,icon:r.ErrorIcon,...n}),maintenance:({locale:e="en",...n})=>o({type:"maintenance",locale:e,icon:r.InfoIcon,...n}),comingSoon:({locale:e="en",...n})=>o({type:"comingSoon",locale:e,icon:r.InfoIcon,...n}),info:e=>s.render({icon:r.InfoIcon,...e})};function l(e={}){const{status:n,locale:i="en",...c}=e;if(n){const t=d[n];if(!t)throw new Error(`Please provide a valid status. Valid values are: ${Object.keys(d).join(", ")}`);return t({locale:i,...c})}return s.render({...c})}exports.render=l;
package/lib/template.js CHANGED
@@ -1,7 +1,4 @@
1
- function l({ pageTitle: e, title: t, icon: i, description: n, extra: r, hiddenText: o = "" }) {
2
- if (!t)
3
- throw new Error("title is required");
4
- return e = e || `${t} - Blocklet Server`, `
1
+ "use strict";function l({pageTitle:e,title:t,icon:i,description:n,extra:r,hiddenText:o=""}){if(!t)throw new Error("title is required");return e=e||`${t} - Blocklet Server`,`
5
2
  <!DOCTYPE html>
6
3
  <html lang="en">
7
4
  <head>
@@ -57,18 +54,13 @@ function l({ pageTitle: e, title: t, icon: i, description: n, extra: r, hiddenTe
57
54
  </head>
58
55
  <body>
59
56
  <div class="container">
60
- ${i ? `<span class="svg-wrapper">${i}</span>` : ""}
57
+ ${i?`<span class="svg-wrapper">${i}</span>`:""}
61
58
  <div class="title">
62
59
  ${t}
63
60
  </div>
64
- ${n ? `<div class="description">${n}</div>` : ""}
65
- ${r ? `<div class="extra">${r}</div>` : ""}
66
- ${o ? `<div style="display:none;">${o}</div>` : ""}
61
+ ${n?`<div class="description">${n}</div>`:""}
62
+ ${r?`<div class="extra">${r}</div>`:""}
63
+ ${o?`<div style="display:none;">${o}</div>`:""}
67
64
  </div>
68
65
  </body>
69
- </html>`;
70
- }
71
- const a = { render: l };
72
- export {
73
- a as default
74
- };
66
+ </html>`}const s={render:l};module.exports=s;
@@ -1,65 +1 @@
1
- const e = {
2
- en: {
3
- 404: {
4
- title: "404 - Page Not Found",
5
- description: "Sorry about that, the page you are looking for does not exist or has been moved."
6
- },
7
- 403: {
8
- title: "403 – Forbidden",
9
- description: "Sorry, you are not authorized to access this page."
10
- },
11
- 500: {
12
- title: "500 - Internal Server Error",
13
- description: "An internal server error has occurred. Please try again later."
14
- },
15
- 502: {
16
- title: "502 - Bad Gateway",
17
- description: "Proxy to destination server failed. Please try again later."
18
- },
19
- error: {
20
- title: "Application Error",
21
- description: "Something went wrong. Please try again later."
22
- },
23
- maintenance: {
24
- title: "Offline for maintenance",
25
- description: "This app is undergoing maintenance right now. Please check back later."
26
- },
27
- comingSoon: {
28
- title: "Coming Soon",
29
- description: "Our website is under construction. We'll be here soon with our new website."
30
- }
31
- },
32
- zh: {
33
- 404: {
34
- title: "404 - 页面未找到",
35
- description: "很抱歉,您正在寻找的页面不存在或已被移动。"
36
- },
37
- 403: {
38
- title: "403 – 禁止访问",
39
- description: "很抱歉,您没有权限访问此页面。"
40
- },
41
- 500: {
42
- title: "500 - 内部服务器错误",
43
- description: "发生了一个内部服务器错误。请稍后再试。"
44
- },
45
- 502: {
46
- title: "502 - 网关错误",
47
- description: "无法代理到目的服务器。请稍后再试。"
48
- },
49
- error: {
50
- title: "Application Error",
51
- description: "出错了, 请稍后再试。"
52
- },
53
- maintenance: {
54
- title: "维护中",
55
- description: "应用程序正在进行维护。请稍后再查看。"
56
- },
57
- comingSoon: {
58
- title: "即将上线",
59
- description: "我们的网站正在建设中。我们很快就会在这里推出我们的新网站。"
60
- }
61
- }
62
- };
63
- export {
64
- e as default
65
- };
1
+ "use strict";const e={en:{404:{title:"404 - Page Not Found",description:"Sorry about that, the page you are looking for does not exist or has been moved."},403:{title:"403 – Forbidden",description:"Sorry, you are not authorized to access this page."},500:{title:"500 - Internal Server Error",description:"An internal server error has occurred. Please try again later."},502:{title:"502 - Bad Gateway",description:"Proxy to destination server failed. Please try again later."},error:{title:"Application Error",description:"Something went wrong. Please try again later."},maintenance:{title:"Offline for maintenance",description:"This app is undergoing maintenance right now. Please check back later."},comingSoon:{title:"Coming Soon",description:"Our website is under construction. We'll be here soon with our new website."}},zh:{404:{title:"404 - 页面未找到",description:"很抱歉,您正在寻找的页面不存在或已被移动。"},403:{title:"403 – 禁止访问",description:"很抱歉,您没有权限访问此页面。"},500:{title:"500 - 内部服务器错误",description:"发生了一个内部服务器错误。请稍后再试。"},502:{title:"502 - 网关错误",description:"无法代理到目的服务器。请稍后再试。"},error:{title:"Application Error",description:"出错了, 请稍后再试。"},maintenance:{title:"维护中",description:"应用程序正在进行维护。请稍后再查看。"},comingSoon:{title:"即将上线",description:"我们的网站正在建设中。我们很快就会在这里推出我们的新网站。"}}};module.exports=e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/result-html-pages",
3
- "version": "3.0.9",
3
+ "version": "3.0.11",
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",
@@ -11,6 +11,7 @@
11
11
  "homepage": "https://github.com/ArcBlock/ux#readme",
12
12
  "license": "Apache-2.0",
13
13
  "main": "lib/index.js",
14
+ "module": "es/index.js",
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "git+https://github.com/ArcBlock/ux.git"
@@ -18,7 +19,8 @@
18
19
  "scripts": {
19
20
  "lint": "eslint src tests",
20
21
  "lint:fix": "npm run lint -- --fix",
21
- "build": "vite build",
22
+ "clean": "rm -rf lib es",
23
+ "build": "npm run clean && vite build",
22
24
  "watch": "vite build --watch",
23
25
  "precommit": "CI=1 npm run lint",
24
26
  "prepush": "CI=1 npm run lint",
@@ -36,5 +38,5 @@
36
38
  "eslint-plugin-react-hooks": "^4.6.2",
37
39
  "jest": "^29.7.0"
38
40
  },
39
- "gitHead": "e2283285cb6e99f09146cde5e1af002e55091619"
41
+ "gitHead": "3619d5d23622fb8074ace5f6c685bcc25c14c056"
40
42
  }
package/vite.config.mjs CHANGED
@@ -20,10 +20,10 @@ export default defineConfig({
20
20
  entry: fg.sync('src/**/*.{tsx,ts,jsx,js}', {
21
21
  ignore: ['**/stories/**', '**/demo/**', '**/*.d.ts', '**/*.stories.*'],
22
22
  }),
23
- formats: ['es'],
24
- fileName: (format, entryName) => `${entryName}.js`,
23
+ formats: ['es', 'cjs'],
24
+ fileName: (format, entryName) => `${format === 'es' ? 'es' : 'lib'}/${entryName}.js`,
25
25
  },
26
- outDir: 'lib',
27
- emptyOutDir: true,
26
+ outDir: './',
27
+ emptyOutDir: false,
28
28
  },
29
29
  });