perf!: reduce the bundle size of /encoders-decoders/html

BREAKING CHANGE: ' -> '
This commit is contained in:
rusconn
2023-06-15 17:33:15 +09:00
parent 497991f133
commit 6612a3be2d
3 changed files with 18 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
"use client"; "use client";
import { useCallback, useMemo, useState } from "react"; import { useCallback, useMemo, useState } from "react";
import { decode, encode } from "html-entities"; import { escape, unescape } from "html-escaper";
import { toolGroups } from "@/config/tools"; import { toolGroups } from "@/config/tools";
import { Textarea, TextareaProps } from "@/components/ui/textarea"; import { Textarea, TextareaProps } from "@/components/ui/textarea";
@@ -16,20 +16,20 @@ import { PageSection } from "@/components/page-section";
export default function Page() { export default function Page() {
const [form, setForm] = useState({ const [form, setForm] = useState({
decoded: '> It\'s "HTML escaping".', decoded: '> It\'s "HTML escaping".',
encoded: "> It's "HTML escaping".", encoded: "> It's "HTML escaping".",
}); });
const setDecodedReactively = useCallback((text: string) => { const setDecodedReactively = useCallback((text: string) => {
setForm({ setForm({
decoded: text, decoded: text,
encoded: encode(text), encoded: escape(text),
}); });
}, []); }, []);
const setEncodedReactively = useCallback((text: string) => { const setEncodedReactively = useCallback((text: string) => {
setForm({ setForm({
encoded: text, encoded: text,
decoded: decode(text), decoded: unescape(text),
}); });
}, []); }, []);

View File

@@ -35,7 +35,7 @@
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"fp-ts": "^2.16.0", "fp-ts": "^2.16.0",
"fuse.js": "^6.6.2", "fuse.js": "^6.6.2",
"html-entities": "^2.3.3", "html-escaper": "^3.0.3",
"io-ts": "^2.2.20", "io-ts": "^2.2.20",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
@@ -55,6 +55,7 @@
"@ianvs/prettier-plugin-sort-imports": "^4.0.1", "@ianvs/prettier-plugin-sort-imports": "^4.0.1",
"@next/bundle-analyzer": "13.4.4", "@next/bundle-analyzer": "13.4.4",
"@types/create-hash": "^1.2.2", "@types/create-hash": "^1.2.2",
"@types/html-escaper": "^3.0.0",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
"@types/node": "~18.16.16", "@types/node": "~18.16.16",
"@types/react": "~18.2.7", "@types/react": "~18.2.7",

17
pnpm-lock.yaml generated
View File

@@ -43,9 +43,9 @@ dependencies:
fuse.js: fuse.js:
specifier: ^6.6.2 specifier: ^6.6.2
version: 6.6.2 version: 6.6.2
html-entities: html-escaper:
specifier: ^2.3.3 specifier: ^3.0.3
version: 2.3.3 version: 3.0.3
io-ts: io-ts:
specifier: ^2.2.20 specifier: ^2.2.20
version: 2.2.20(fp-ts@2.16.0) version: 2.2.20(fp-ts@2.16.0)
@@ -99,6 +99,9 @@ devDependencies:
'@types/create-hash': '@types/create-hash':
specifier: ^1.2.2 specifier: ^1.2.2
version: 1.2.2 version: 1.2.2
'@types/html-escaper':
specifier: ^3.0.0
version: 3.0.0
'@types/js-yaml': '@types/js-yaml':
specifier: ^4.0.5 specifier: ^4.0.5
version: 4.0.5 version: 4.0.5
@@ -1446,6 +1449,10 @@ packages:
'@types/node': 18.16.16 '@types/node': 18.16.16
dev: true dev: true
/@types/html-escaper@3.0.0:
resolution: {integrity: sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw==}
dev: true
/@types/js-yaml@4.0.5: /@types/js-yaml@4.0.5:
resolution: {integrity: sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==} resolution: {integrity: sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==}
dev: true dev: true
@@ -2991,8 +2998,8 @@ packages:
safe-buffer: 5.2.1 safe-buffer: 5.2.1
dev: false dev: false
/html-entities@2.3.3: /html-escaper@3.0.3:
resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==} resolution: {integrity: sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==}
dev: false dev: false
/human-signals@2.1.0: /human-signals@2.1.0: