diff --git a/package-lock.json b/package-lock.json index 3b79a62..37059ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,8 @@ "@types/react": "16.9.50", "jest": "26.6.3", "jest-fetch-mock": "3.0.3", + "patch-package": "^8.0.1", + "postinstall-postinstall": "^2.1.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-native": "^0.63.0", @@ -2693,6 +2695,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true, + "license": "BSD-2-Clause" + }, "node_modules/abab": { "version": "2.0.6", "dev": true, @@ -4808,6 +4817,16 @@ "node": ">=8" } }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "micromatch": "^4.0.2" + } + }, "node_modules/for-in": { "version": "1.0.2", "dev": true, @@ -5581,7 +5600,6 @@ "version": "2.2.1", "dev": true, "license": "MIT", - "optional": true, "bin": { "is-docker": "cli.js" }, @@ -6647,6 +6665,16 @@ "graceful-fs": "^4.1.9" } }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, "node_modules/kleur": { "version": "3.0.3", "dev": true, @@ -9408,6 +9436,201 @@ "node": ">=0.10.0" } }, + "node_modules/patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/patch-package/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/patch-package/node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/jsonfile": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", + "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/patch-package/node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/patch-package/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/patch-package/node_modules/tmp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", + "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/patch-package/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/path": { "version": "0.12.7", "license": "MIT", @@ -9583,6 +9806,14 @@ "url": "https://opencollective.com/postcss/" } }, + "node_modules/postinstall-postinstall": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz", + "integrity": "sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT" + }, "node_modules/prelude-ls": { "version": "1.1.2", "dev": true, @@ -12053,6 +12284,19 @@ "dev": true, "license": "ISC" }, + "node_modules/yaml": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + } + }, "node_modules/yargs": { "version": "15.4.1", "dev": true, @@ -13954,6 +14198,12 @@ "version": "21.0.0", "dev": true }, + "@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true + }, "abab": { "version": "2.0.6", "dev": true @@ -15477,6 +15727,15 @@ "path-exists": "^4.0.0" } }, + "find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "requires": { + "micromatch": "^4.0.2" + } + }, "for-in": { "version": "1.0.2", "dev": true @@ -16008,8 +16267,7 @@ }, "is-docker": { "version": "2.2.1", - "dev": true, - "optional": true + "dev": true }, "is-extendable": { "version": "0.1.1", @@ -16742,6 +17000,15 @@ "graceful-fs": "^4.1.9" } }, + "klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11" + } + }, "kleur": { "version": "3.0.3", "dev": true @@ -18943,6 +19210,132 @@ "version": "0.1.1", "dev": true }, + "patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "dev": true, + "requires": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "dependencies": { + "ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", + "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "requires": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, + "tmp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", + "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", + "dev": true + }, + "universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true + } + } + }, "path": { "version": "0.12.7", "requires": { @@ -19057,6 +19450,12 @@ "source-map": "^0.6.1" } }, + "postinstall-postinstall": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz", + "integrity": "sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==", + "dev": true + }, "prelude-ls": { "version": "1.1.2", "dev": true @@ -20866,6 +21265,12 @@ "version": "4.0.0", "dev": true }, + "yaml": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "dev": true + }, "yargs": { "version": "15.4.1", "dev": true, diff --git a/package.json b/package.json index bad89f8..9530571 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "scripts": { "test": "jest -u", "build": "tsc", - "postbuild": "(mkdir build/types) | true && cp -r src/types/*.d.ts build/types/" + "postbuild": "(mkdir build/types) | true && cp -r src/types/*.d.ts build/types/", + "postinstall": "patch-package" }, "author": "Jeffrey Mendez ", "license": "MIT", @@ -41,6 +42,8 @@ "@types/react": "16.9.50", "jest": "26.6.3", "jest-fetch-mock": "3.0.3", + "patch-package": "^8.0.1", + "postinstall-postinstall": "^2.1.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-native": "^0.63.0", diff --git a/patches/clean-html-js+1.3.16.patch b/patches/clean-html-js+1.3.16.patch new file mode 100644 index 0000000..6bb73e6 --- /dev/null +++ b/patches/clean-html-js+1.3.16.patch @@ -0,0 +1,225 @@ +diff --git a/node_modules/clean-html-js/dist/clean-html-css.js b/node_modules/clean-html-js/dist/clean-html-css.js +index 4c1e375..41ea21d 100644 +--- a/node_modules/clean-html-js/dist/clean-html-css.js ++++ b/node_modules/clean-html-js/dist/clean-html-css.js +@@ -1,28 +1,32 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.nonTextTags = exports.allowedTags = void 0; ++ + const nonTextTags = [ +- "style", +- "script", +- "textarea", +- "noscript", +- "html", +- "body", +- "div", +- "span", ++ "style", ++ "script", ++ "textarea", ++ "noscript", ++ "html", ++ "body", ++ "div", ++ "span", + ]; + exports.nonTextTags = nonTextTags; ++ + const allowedTags = [ +- "html", +- "body", +- "p", +- "h1", +- "h2", +- "h3", +- "h4", +- "section", +- "div", +- "span", ++ "html", ++ "body", ++ "p", ++ "h1", ++ "h2", ++ "h3", ++ "h4", ++ "section", ++ "div", ++ "span", ++ "a", // ✅ allow anchor tags + ]; + exports.allowedTags = allowedTags; ++ + //# sourceMappingURL=clean-html-css.js.map +\ No newline at end of file +diff --git a/node_modules/clean-html-js/dist/clean-html.js b/node_modules/clean-html-js/dist/clean-html.js +index d433ead..fbad38c 100644 +--- a/node_modules/clean-html-js/dist/clean-html.js ++++ b/node_modules/clean-html-js/dist/clean-html.js +@@ -1,6 +1,6 @@ + "use strict"; + var __importDefault = (this && this.__importDefault) || function (mod) { +- return (mod && mod.__esModule) ? mod : { "default": mod }; ++ return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + const readability_node_1 = require("readability-node"); +@@ -9,79 +9,92 @@ const url_parse_1 = __importDefault(require("url-parse")); + const sanitize_html_1 = __importDefault(require("sanitize-html")); + const clean_html_css_1 = require("./clean-html-css"); + const fetch_1 = require("./fetch"); ++ + function convertHtmlToXhtml(html) { +- try { +- const xmlSerializer = new xmldom_silent_1.XMLSerializer(); +- const xhtmlDocument = new xmldom_silent_1.DOMParser({ +- errorHandler: function (level, msg) { +- if (level === "error") { +- throw new Error(`Unable to convert HTML to XHTML: ${msg}`); +- } +- } +- }).parseFromString(html, "text/html"); +- return xmlSerializer.serializeToString(xhtmlDocument); +- } +- catch (e) { +- console.error(e); +- } ++ try { ++ const xmlSerializer = new xmldom_silent_1.XMLSerializer(); ++ const xhtmlDocument = new xmldom_silent_1.DOMParser({ ++ errorHandler: function (level, msg) { ++ if (level === "error") { ++ throw new Error(`Unable to convert HTML to XHTML: ${msg}`); ++ } ++ }, ++ }).parseFromString(html, "text/html"); ++ return xmlSerializer.serializeToString(xhtmlDocument); ++ } catch (e) { ++ console.error(e); ++ } + } ++ + function createJsDomDocument(xhtml) { +- try { +- const jsDomParser = new readability_node_1.JSDOMParser(); +- jsDomParser.parse(xhtml.trim()); +- if (jsDomParser.errorState) { +- throw new Error(`Unable to parse XHTML into JsDom ${jsDomParser.errorState}`); +- } +- return jsDomParser.doc; +- } +- catch (e) { +- console.error(e); ++ try { ++ const jsDomParser = new readability_node_1.JSDOMParser(); ++ jsDomParser.parse(xhtml.trim()); ++ if (jsDomParser.errorState) { ++ throw new Error( ++ `Unable to parse XHTML into JsDom ${jsDomParser.errorState}` ++ ); + } ++ return jsDomParser.doc; ++ } catch (e) { ++ console.error(e); ++ } + } ++ + function createReadabilityUrl(sourceUrl) { +- const sourceUrlParsed = new url_parse_1.default(sourceUrl); +- if (!sourceUrlParsed || sourceUrlParsed.host.length === 0) { +- throw new Error("Invalid or no source url provided"); +- } +- return { +- spec: sourceUrlParsed.href, +- host: sourceUrlParsed.host, +- scheme: sourceUrlParsed.protocol.slice(0, -1), +- prePath: `${sourceUrlParsed.protocol}//${sourceUrlParsed.host}`, +- pathBase: `${sourceUrlParsed.protocol}//${sourceUrlParsed.host}${sourceUrlParsed.pathname.substring(0, sourceUrlParsed.pathname.lastIndexOf("/") + 1)}` +- }; ++ const sourceUrlParsed = new url_parse_1.default(sourceUrl); ++ if (!sourceUrlParsed || sourceUrlParsed.host.length === 0) { ++ throw new Error("Invalid or no source url provided"); ++ } ++ return { ++ spec: sourceUrlParsed.href, ++ host: sourceUrlParsed.host, ++ scheme: sourceUrlParsed.protocol.slice(0, -1), ++ prePath: `${sourceUrlParsed.protocol}//${sourceUrlParsed.host}`, ++ pathBase: `${sourceUrlParsed.protocol}//${sourceUrlParsed.host}${sourceUrlParsed.pathname.substring( ++ 0, ++ sourceUrlParsed.pathname.lastIndexOf("/") + 1 ++ )}`, ++ }; + } ++ + async function cleanHtml(html, sourceUrl, config = { allowedTags: [], nonTextTags: [] }) { ++ try { ++ html = !html && sourceUrl ? await (0, fetch_1.fetchHtml)(sourceUrl) : html; ++ } catch (e) { ++ console.error(e); ++ } ++ ++ html = (0, sanitize_html_1.default)(html, { ++ allowedTags: [ ++ ...clean_html_css_1.allowedTags, ++ ...((config && config.allowedTags) ? config.allowedTags : []), ++ ], ++ nonTextTags: [ ++ ...clean_html_css_1.nonTextTags, ++ ...((config && config.nonTextTags) ? config.nonTextTags : []), ++ ], ++ allowedAttributes: { ++ a: ["href"], // ✅ preserve href on links ++ }, ++ }); ++ ++ return new Promise((resolve) => { + try { +- html = !html && sourceUrl ? await fetch_1.fetchHtml(sourceUrl) : html; +- } +- catch (e) { +- console.error(e); ++ if (!html) { ++ throw new Error( ++ "Invalid url or no html provided, please use a html string or url" ++ ); ++ } ++ const readabilityUrl = createReadabilityUrl(sourceUrl); ++ const xhtml = convertHtmlToXhtml(html); ++ const document = createJsDomDocument(xhtml); ++ resolve(new readability_node_1.Readability(readabilityUrl, document).parse()); ++ } catch (error) { ++ throw new Error("Unable to clean HTML, an issue occurred"); + } +- html = sanitize_html_1.default(html, { +- allowedTags: [ +- ...clean_html_css_1.allowedTags, +- ...((config === null || config === void 0 ? void 0 : config.allowedTags) ? config === null || config === void 0 ? void 0 : config.allowedTags : []) +- ], +- nonTextTags: [ +- ...clean_html_css_1.nonTextTags, +- ...((config === null || config === void 0 ? void 0 : config.nonTextTags) ? config === null || config === void 0 ? void 0 : config.nonTextTags : []) +- ] +- }); +- return new Promise(resolve => { +- try { +- if (!html) { +- throw new Error("Invalid url or no html provided, please use a html string or url"); +- } +- const readabilityUrl = createReadabilityUrl(sourceUrl); +- const xhtml = convertHtmlToXhtml(html); +- const document = createJsDomDocument(xhtml); +- resolve(new readability_node_1.Readability(readabilityUrl, document).parse()); +- } +- catch (error) { +- throw new Error("Unable to clean HTML an issue occured"); +- } +- }); ++ }); + } ++ + exports.default = cleanHtml; + //# sourceMappingURL=clean-html.js.map +\ No newline at end of file diff --git a/patches/react-native-fast-htmlview+0.0.3.patch b/patches/react-native-fast-htmlview+0.0.3.patch new file mode 100644 index 0000000..f0b16f4 --- /dev/null +++ b/patches/react-native-fast-htmlview+0.0.3.patch @@ -0,0 +1,25 @@ +diff --git a/node_modules/react-native-fast-htmlview/HTMLView.js b/node_modules/react-native-fast-htmlview/HTMLView.js +index 5e0e046..3317b73 100644 +--- a/node_modules/react-native-fast-htmlview/HTMLView.js ++++ b/node_modules/react-native-fast-htmlview/HTMLView.js +@@ -59,8 +59,18 @@ class HtmlView extends PureComponent { + } + + componentDidUpdate(prevProps) { +- if (this.props.value !== prevProps.value || this.props.stylesheet !== prevProps.stylesheet || this.props.textComponentProps !== prevProps.textComponentProps || this.props.nodeComponentProps !== prevProps.nodeComponentProps) { +- this.startHtmlRender(this.props.value, this.props.stylesheet, this.props.textComponentProps, this.props.nodeComponentProps); ++ if ( ++ this.props.value !== prevProps.value || ++ this.props.stylesheet !== prevProps.stylesheet || ++ this.props.textComponentProps !== prevProps.textComponentProps || ++ this.props.nodeComponentProps !== prevProps.nodeComponentProps ++ ) { ++ this.startHtmlRender( ++ this.props.value, ++ this.props.stylesheet, ++ this.props.textComponentProps, ++ this.props.nodeComponentProps ++ ); + } + } + diff --git a/src/reader.tsx b/src/reader.tsx index 24d391a..26bdbd2 100644 --- a/src/reader.tsx +++ b/src/reader.tsx @@ -12,81 +12,49 @@ class ReadabilityView extends PureComponent { constructor(props: Props) { super(props); this.parseHtml = this.parseHtml.bind(this); + this.state = { + cleanHtmlSource: undefined, + } as any; } componentDidMount() { this.mounted = true; - if (!this.props.lazy) { - this.parseHtml(); - } - } - - componentWillUnmount() { - this.mounted = false; + this.parseHtml(); } - componentDidUpdate(prevProps) { - if ( - this.props.url !== prevProps.url || - this.props.html !== prevProps.html || - this.props.lazy !== prevProps.lazy - ) { + componentDidUpdate(prevProps: Props) { + if (prevProps.url !== this.props.url || prevProps.html !== this.props.html) { this.parseHtml(); } } - async getData() { - const { url } = this.props; - - try { - const response = await fetch(url); - return await response.text(); - } catch (error) { - this.logError(error); - } + componentWillUnmount() { + this.mounted = false; } - async parseHtml() { - const { config, url, html } = this.props; - - let htmlContent = html; - - if (!htmlContent) { - try { - htmlContent = await this.getData(); - } catch (error) { - this.logError(error); - } - } +private async parseHtml() { + const { url, html, config } = this.props; + let source: string | undefined; - if (htmlContent) { - try { - const readabilityArticle = await cleanHtml(htmlContent, url, config); - this.setView(readabilityArticle); - } catch (error) { - this.logError(error); - } + try { + if (html && html.trim().length > 0) { + const article: any = await cleanHtml(html, url, config); + source = article && typeof article.content === "string" ? article.content : undefined; + } else { + source = undefined; } + } catch (e) { + console.warn("Error cleaning HTML:", e); + source = html; } - setView(readabilityArticle) { - this.mounted && - this.setState({ - cleanHtmlSource: !readabilityArticle - ? this.props.errorPage || - `

Sorry, issue parsing ${this.props.url}

` - : readabilityArticle.content, - }); - } - - logError(error) { - const { onError } = this.props; - typeof onError === "function" ? onError(error) : console.error(error); - this.setView(null); + if (this.mounted) { + this.setState({ cleanHtmlSource: source }); } +} render() { - const cleanHtmlSource = this.state && this.state.cleanHtmlSource; + const { cleanHtmlSource } = this.state as any; const props = { ...this.props, styles }; return ( @@ -103,4 +71,4 @@ class ReadabilityView extends PureComponent { } } -export default ReadabilityView; +export default ReadabilityView; \ No newline at end of file