From a4760e2b26d8f22258aad1684639dc995645ebda Mon Sep 17 00:00:00 2001 From: Alexander Kachkaev Date: Sun, 28 Sep 2025 15:34:49 +0100 Subject: [PATCH 1/2] Update cheerio to rc.12 --- packages/litvis-integration-mume/package.json | 3 +- packages/narrative-schema-label/package.json | 3 +- packages/narrative-schema-rule/package.json | 3 +- .../narrative-schema-styling/package.json | 5 +- pnpm-lock.yaml | 184 +++++++++--------- 5 files changed, 91 insertions(+), 107 deletions(-) diff --git a/packages/litvis-integration-mume/package.json b/packages/litvis-integration-mume/package.json index f93b7a82..6cc9cbd7 100644 --- a/packages/litvis-integration-mume/package.json +++ b/packages/litvis-integration-mume/package.json @@ -17,7 +17,7 @@ "dependencies": { "block-attributes": "^0.5.0", "block-info": "^0.5.0", - "cheerio": "1.0.0-rc.3", + "cheerio": "1.0.0-rc.12", "elm-string-representation": "^2.0.0", "html-entities": "^2.6.0", "litvis": "^0.10.0", @@ -33,7 +33,6 @@ "yamljs": "^0.3.0" }, "devDependencies": { - "@types/cheerio": "0.22.21", "@types/lodash": "4.17.20", "@types/markdown-it": "14.1.2", "@types/object-hash": "3.0.6", diff --git a/packages/narrative-schema-label/package.json b/packages/narrative-schema-label/package.json index 9be8164e..1be19b62 100644 --- a/packages/narrative-schema-label/package.json +++ b/packages/narrative-schema-label/package.json @@ -13,7 +13,7 @@ "dependencies": { "block-attributes": "^0.5.0", "block-info": "^0.5.0", - "cheerio": "1.0.0-rc.3", + "cheerio": "1.0.0-rc.12", "data-with-position": "^0.5.0", "handlebars": "^4.7.8", "html-entities": "^2.6.0", @@ -26,7 +26,6 @@ "vfile": "^4.2.1" }, "devDependencies": { - "@types/cheerio": "0.22.21", "@types/lodash": "4.17.20", "@types/object-hash": "3.0.6", "@types/unist": "2.0.6", diff --git a/packages/narrative-schema-rule/package.json b/packages/narrative-schema-rule/package.json index b088a98a..ab14b9b6 100644 --- a/packages/narrative-schema-rule/package.json +++ b/packages/narrative-schema-rule/package.json @@ -13,7 +13,7 @@ "dependencies": { "block-attributes": "^0.5.0", "block-info": "^0.5.0", - "cheerio": "1.0.0-rc.3", + "cheerio": "1.0.0-rc.12", "data-with-position": "^0.5.0", "handlebars": "^4.7.8", "html-entities": "^2.6.0", @@ -24,7 +24,6 @@ "vfile": "^4.2.1" }, "devDependencies": { - "@types/cheerio": "0.22.21", "@types/lodash": "4.17.20" } } diff --git a/packages/narrative-schema-styling/package.json b/packages/narrative-schema-styling/package.json index 94a12ada..cabb334d 100644 --- a/packages/narrative-schema-styling/package.json +++ b/packages/narrative-schema-styling/package.json @@ -13,7 +13,7 @@ "dependencies": { "block-attributes": "^0.5.0", "block-info": "^0.5.0", - "cheerio": "1.0.0-rc.3", + "cheerio": "1.0.0-rc.12", "data-with-position": "^0.5.0", "handlebars": "^4.7.8", "html-entities": "^2.6.0", @@ -21,8 +21,5 @@ "narrative-schema-common": "^0.3.0", "unist-util-visit": "^2.0.3", "vfile": "^4.2.1" - }, - "devDependencies": { - "@types/cheerio": "0.22.21" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 32a778a6..308e8307 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -241,8 +241,8 @@ importers: specifier: ^0.5.0 version: link:../block-info cheerio: - specifier: 1.0.0-rc.3 - version: 1.0.0-rc.3 + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 elm-string-representation: specifier: ^2.0.0 version: link:../elm-string-representation @@ -283,9 +283,6 @@ importers: specifier: ^0.3.0 version: 0.3.0 devDependencies: - '@types/cheerio': - specifier: 0.22.21 - version: 0.22.21 '@types/lodash': specifier: 4.17.20 version: 4.17.20 @@ -367,8 +364,8 @@ importers: specifier: ^0.5.0 version: link:../block-info cheerio: - specifier: 1.0.0-rc.3 - version: 1.0.0-rc.3 + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 data-with-position: specifier: ^0.5.0 version: link:../data-with-position @@ -400,9 +397,6 @@ importers: specifier: ^4.2.1 version: 4.2.1 devDependencies: - '@types/cheerio': - specifier: 0.22.21 - version: 0.22.21 '@types/lodash': specifier: 4.17.20 version: 4.17.20 @@ -425,8 +419,8 @@ importers: specifier: ^0.5.0 version: link:../block-info cheerio: - specifier: 1.0.0-rc.3 - version: 1.0.0-rc.3 + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 data-with-position: specifier: ^0.5.0 version: link:../data-with-position @@ -452,9 +446,6 @@ importers: specifier: ^4.2.1 version: 4.2.1 devDependencies: - '@types/cheerio': - specifier: 0.22.21 - version: 0.22.21 '@types/lodash': specifier: 4.17.20 version: 4.17.20 @@ -468,8 +459,8 @@ importers: specifier: ^0.5.0 version: link:../block-info cheerio: - specifier: 1.0.0-rc.3 - version: 1.0.0-rc.3 + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 data-with-position: specifier: ^0.5.0 version: link:../data-with-position @@ -491,10 +482,6 @@ importers: vfile: specifier: ^4.2.1 version: 4.2.1 - devDependencies: - '@types/cheerio': - specifier: 0.22.21 - version: 0.22.21 packages: @@ -1316,9 +1303,6 @@ packages: '@types/babel__traverse@7.28.0': resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} - '@types/cheerio@0.22.21': - resolution: {integrity: sha512-aGI3DfswwqgKPiEOTaiHV2ZPC9KEhprpgEbJnv0fZl3SGX0cGgEva1126dGrMC6AJM6v/aihlUgJn9M5DbDZ/Q==} - '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -1877,9 +1861,12 @@ packages: chardet@2.1.0: resolution: {integrity: sha512-bNFETTG/pM5ryzQ9Ad0lJOTa6HWD/YsScAR3EnCPZRPlQh77JocYktSHOUHelyhm8IARL+o4c4F1bP5KVOjiRA==} - cheerio@1.0.0-rc.3: - resolution: {integrity: sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==} - engines: {node: '>= 0.6'} + cheerio-select@2.1.0: + resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} + + cheerio@1.0.0-rc.12: + resolution: {integrity: sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==} + engines: {node: '>= 6'} chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} @@ -2078,14 +2065,15 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - css-select@1.2.0: - resolution: {integrity: sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA==} + css-select@5.2.2: + resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==} css-selector-parser@1.4.1: resolution: {integrity: sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==} - css-what@2.1.3: - resolution: {integrity: sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==} + css-what@6.2.2: + resolution: {integrity: sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==} + engines: {node: '>= 6'} cssesc@3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} @@ -2223,20 +2211,18 @@ packages: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} engines: {node: '>=6.0.0'} - dom-serializer@0.1.1: - resolution: {integrity: sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==} - - domelementtype@1.3.1: - resolution: {integrity: sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==} + dom-serializer@2.0.0: + resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==} - domhandler@2.4.2: - resolution: {integrity: sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==} + domelementtype@2.3.0: + resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==} - domutils@1.5.1: - resolution: {integrity: sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==} + domhandler@5.0.3: + resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} + engines: {node: '>= 4'} - domutils@1.7.0: - resolution: {integrity: sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==} + domutils@3.2.2: + resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} dot-prop@5.3.0: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} @@ -2292,13 +2278,14 @@ packages: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} engines: {node: '>=8.6'} - entities@1.1.2: - resolution: {integrity: sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==} - entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} + entities@6.0.1: + resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} + engines: {node: '>=0.12'} + env-paths@2.2.1: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} engines: {node: '>=6'} @@ -2838,8 +2825,8 @@ packages: html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} - htmlparser2@3.10.1: - resolution: {integrity: sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==} + htmlparser2@8.0.2: + resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} http-cache-semantics@4.2.0: resolution: {integrity: sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==} @@ -3919,9 +3906,6 @@ packages: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - nth-check@1.0.2: - resolution: {integrity: sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==} - nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} @@ -4100,8 +4084,11 @@ packages: parse-url@8.1.0: resolution: {integrity: sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==} - parse5@3.0.3: - resolution: {integrity: sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==} + parse5-htmlparser2-tree-adapter@7.1.0: + resolution: {integrity: sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==} + + parse5@7.3.0: + resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} @@ -6353,10 +6340,6 @@ snapshots: dependencies: '@babel/types': 7.28.4 - '@types/cheerio@0.22.21': - dependencies: - '@types/node': 24.5.2 - '@types/debug@4.1.12': dependencies: '@types/ms': 2.1.0 @@ -6954,14 +6937,24 @@ snapshots: chardet@2.1.0: {} - cheerio@1.0.0-rc.3: + cheerio-select@2.1.0: dependencies: - css-select: 1.2.0 - dom-serializer: 0.1.1 - entities: 1.1.2 - htmlparser2: 3.10.1 - lodash: 4.17.21 - parse5: 3.0.3 + boolbase: 1.0.0 + css-select: 5.2.2 + css-what: 6.2.2 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + + cheerio@1.0.0-rc.12: + dependencies: + cheerio-select: 2.1.0 + dom-serializer: 2.0.0 + domhandler: 5.0.3 + domutils: 3.2.2 + htmlparser2: 8.0.2 + parse5: 7.3.0 + parse5-htmlparser2-tree-adapter: 7.1.0 chownr@2.0.0: {} @@ -7164,16 +7157,17 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - css-select@1.2.0: + css-select@5.2.2: dependencies: boolbase: 1.0.0 - css-what: 2.1.3 - domutils: 1.5.1 - nth-check: 1.0.2 + css-what: 6.2.2 + domhandler: 5.0.3 + domutils: 3.2.2 + nth-check: 2.1.1 css-selector-parser@1.4.1: {} - css-what@2.1.3: {} + css-what@6.2.2: {} cssesc@3.0.0: {} @@ -7276,26 +7270,23 @@ snapshots: dependencies: esutils: 2.0.3 - dom-serializer@0.1.1: + dom-serializer@2.0.0: dependencies: - domelementtype: 1.3.1 - entities: 1.1.2 - - domelementtype@1.3.1: {} + domelementtype: 2.3.0 + domhandler: 5.0.3 + entities: 4.5.0 - domhandler@2.4.2: - dependencies: - domelementtype: 1.3.1 + domelementtype@2.3.0: {} - domutils@1.5.1: + domhandler@5.0.3: dependencies: - dom-serializer: 0.1.1 - domelementtype: 1.3.1 + domelementtype: 2.3.0 - domutils@1.7.0: + domutils@3.2.2: dependencies: - dom-serializer: 0.1.1 - domelementtype: 1.3.1 + dom-serializer: 2.0.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 dot-prop@5.3.0: dependencies: @@ -7350,10 +7341,10 @@ snapshots: dependencies: ansi-colors: 4.1.3 - entities@1.1.2: {} - entities@4.5.0: {} + entities@6.0.1: {} + env-paths@2.2.1: {} envinfo@7.13.0: {} @@ -8020,14 +8011,12 @@ snapshots: html-escaper@2.0.2: {} - htmlparser2@3.10.1: + htmlparser2@8.0.2: dependencies: - domelementtype: 1.3.1 - domhandler: 2.4.2 - domutils: 1.7.0 - entities: 1.1.2 - inherits: 2.0.4 - readable-stream: 3.6.2 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + entities: 4.5.0 http-cache-semantics@4.2.0: {} @@ -9513,10 +9502,6 @@ snapshots: dependencies: path-key: 4.0.0 - nth-check@1.0.2: - dependencies: - boolbase: 1.0.0 - nth-check@2.1.1: dependencies: boolbase: 1.0.0 @@ -9783,9 +9768,14 @@ snapshots: dependencies: parse-path: 7.1.0 - parse5@3.0.3: + parse5-htmlparser2-tree-adapter@7.1.0: dependencies: - '@types/node': 24.5.2 + domhandler: 5.0.3 + parse5: 7.3.0 + + parse5@7.3.0: + dependencies: + entities: 6.0.1 path-exists@3.0.0: {} From 1b03a70d7bab1df36976bfcb68c5dfd2a00080ba Mon Sep 17 00:00:00 2001 From: Alexander Kachkaev Date: Sun, 28 Sep 2025 15:45:03 +0100 Subject: [PATCH 2/2] fix --- .../src/renderEnhancers/enhanceWithLitvis.ts | 3 +- .../enhanceWithLitvisLiterateElm.ts | 21 ++++++----- .../enhanceWithLitvisNarrativeSchemas.ts | 7 ++-- .../enhanceWithLitvisVegaBlockKeywords.ts | 11 +++--- .../postEnhanceWithLitvis.ts | 35 ++++++++++++++----- 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvis.ts b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvis.ts index 02a0e529..3e0f053d 100644 --- a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvis.ts +++ b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvis.ts @@ -1,3 +1,4 @@ +import type { CheerioAPI } from "cheerio"; import type { LitvisNarrative } from "litvis"; import type { LitvisEnhancerCache } from "../types"; @@ -8,7 +9,7 @@ import type { ParseMd } from "./helpers"; export const enhanceWithLitvis = async ( processedNarrative: LitvisNarrative, - $: CheerioStatic, + $: CheerioAPI, cache: LitvisEnhancerCache, parseMd: ParseMd, ): Promise => { diff --git a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisLiterateElm.ts b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisLiterateElm.ts index 429689a0..186c615b 100644 --- a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisLiterateElm.ts +++ b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisLiterateElm.ts @@ -1,4 +1,5 @@ import type { BlockInfo } from "block-info"; +import type { AnyNode, Cheerio, CheerioAPI } from "cheerio"; import cheerio from "cheerio"; import { encode } from "html-entities"; import type { @@ -26,7 +27,7 @@ const flattenJsonToRawMarkdown = (data: unknown): string => { return `${data}`; }; -const generate$output = (arrayOf$outputItems: Cheerio[]) => { +const generate$output = (arrayOf$outputItems: Array>) => { return cheerio( '
', ).append("", ...arrayOf$outputItems); @@ -99,7 +100,7 @@ const mapAutogeneratedContextNames = ( }; export const enhanceWithLitvisLiterateElm = async ( - $: CheerioStatic, + $: CheerioAPI, processedNarrative: LitvisNarrative, cache: LitvisEnhancerCache, parseMd: ParseMd, @@ -113,7 +114,7 @@ export const enhanceWithLitvisLiterateElm = async ( return; } - const info: BlockInfo = $container.data("parsedInfo"); + const info: BlockInfo = $container.data("parsedInfo") as BlockInfo; if (`${info.language}`.toLowerCase() !== "elm") { return; } @@ -134,8 +135,8 @@ export const enhanceWithLitvisLiterateElm = async ( $container.text(), ); - const arrayOf$outputItemsBeforeCodeBlock: Cheerio[] = []; - const arrayOf$outputItemsAfterCodeBlock: Cheerio[] = []; + const arrayOf$outputItemsBeforeCodeBlock: Array> = []; + const arrayOf$outputItemsAfterCodeBlock: Array> = []; let currentArrayOf$outputItems = arrayOf$outputItemsBeforeCodeBlock; derivativesWithResolvedExpressions.outputFormats.forEach((outputFormat) => { switch (outputFormat) { @@ -181,7 +182,7 @@ export const enhanceWithLitvisLiterateElm = async ( return; } - const arrayOf$outputItems: Cheerio[] = []; + const arrayOf$outputItems: Array> = []; derivatives.outputFormats.forEach((outputFormat) => { switch (outputFormat) { case "l": @@ -223,7 +224,9 @@ export const enhanceWithLitvisLiterateElm = async ( const mappedOutputItems = $outputItems.map(async (i, el) => { const $el = $(el); const contextName = $el.data("contextName"); - const outputFormat: OutputFormat | undefined = $el.data("outputFormat"); + const outputFormat: OutputFormat | undefined = $el.data("outputFormat") as + | OutputFormat + | undefined; const expressionText = $el.data("expression"); const interactive = $el.data("interactive"); const renderKey = hash({ @@ -235,7 +238,7 @@ export const enhanceWithLitvisLiterateElm = async ( ]!.path, }); const context = contextsByMumeContextName[ - contextName + contextName as string ] as ProcessedLitvisContext; // const evaluatedOutputExpressionsByText = keyBy(context.evaluatedOutputExpressions, oe => oe.data.text); try { @@ -268,7 +271,7 @@ export const enhanceWithLitvisLiterateElm = async ( ) { throw new Error(`Could not parse value of ${expressionText}`); } - let $result: Cheerio; + let $result: Cheerio; let resultNormalizedInfo: BlockInfo | null = null; switch (outputFormat) { case "r": diff --git a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisNarrativeSchemas.ts b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisNarrativeSchemas.ts index a9ec9166..fad04220 100644 --- a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisNarrativeSchemas.ts +++ b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisNarrativeSchemas.ts @@ -1,3 +1,4 @@ +import type { AnyNode, Cheerio, CheerioAPI } from "cheerio"; import type { LitvisNarrative } from "litvis"; import _ from "lodash"; import type { LabelNode } from "narrative-schema-label"; @@ -7,18 +8,18 @@ import { selectAll } from "unist-util-select"; import type { LitvisEnhancerCache } from "../types"; -const markLabelAsErroneous = ($el: Cheerio, message: string) => { +const markLabelAsErroneous = ($el: Cheerio, message: string) => { $el.children().attr("style", "background: #fdd"); $el.attr("title", message); }; export const enhanceWithLitvisNarrativeSchemas = async ( - $: CheerioStatic, + $: CheerioAPI, processedNarrative: LitvisNarrative, cache: LitvisEnhancerCache, ): Promise => { // add styling from narrative schema - const arrayOf$StyleTags: Cheerio[] = []; + const arrayOf$StyleTags: Array> = []; if (processedNarrative.composedNarrativeSchema) { arrayOf$StyleTags.push( ...getCssChunks(processedNarrative.composedNarrativeSchema).map( diff --git a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisVegaBlockKeywords.ts b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisVegaBlockKeywords.ts index a3f7aebc..b78683be 100644 --- a/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisVegaBlockKeywords.ts +++ b/packages/litvis-integration-mume/src/renderEnhancers/enhanceWithLitvisVegaBlockKeywords.ts @@ -1,4 +1,5 @@ import type { BlockInfo } from "block-info"; +import type { AnyNode, Cheerio, CheerioAPI } from "cheerio"; import type { LitvisNarrative } from "litvis"; import { extractAttributeDerivatives } from "litvis"; import YAML from "yamljs"; @@ -13,7 +14,7 @@ import type { LitvisEnhancerCache } from "../types"; * @param cache */ export const enhanceWithLitvisVegaBlockKeywords = async ( - $: CheerioStatic, + $: CheerioAPI, processedNarrative: LitvisNarrative, cache: LitvisEnhancerCache, ): Promise => { @@ -23,11 +24,13 @@ export const enhanceWithLitvisVegaBlockKeywords = async ( return; } - const info: BlockInfo = $container.data("parsedInfo"); + const info: BlockInfo = $container.data("parsedInfo") as BlockInfo; if (!info) { return; } - const normalizedInfo: BlockInfo = $container.data("normalizedInfo"); + const normalizedInfo: BlockInfo = $container.data( + "normalizedInfo", + ) as BlockInfo; if ( normalizedInfo.language !== "vega" && normalizedInfo.language !== "vega-lite" @@ -62,7 +65,7 @@ export const enhanceWithLitvisVegaBlockKeywords = async ( ) { return; } - let $result: Cheerio | undefined; + let $result: Cheerio | undefined; let resultNormalizedInfo: (BlockInfo & { style?: string }) | undefined; let resultText; switch (outputFormat) { diff --git a/packages/litvis-integration-mume/src/renderPostEnhancers/postEnhanceWithLitvis.ts b/packages/litvis-integration-mume/src/renderPostEnhancers/postEnhanceWithLitvis.ts index 7cd3e6e6..e86f49de 100644 --- a/packages/litvis-integration-mume/src/renderPostEnhancers/postEnhanceWithLitvis.ts +++ b/packages/litvis-integration-mume/src/renderPostEnhancers/postEnhanceWithLitvis.ts @@ -1,3 +1,4 @@ +import type { AnyNode, Cheerio, CheerioAPI } from "cheerio"; import cheerio from "cheerio"; import { decode } from "html-entities"; import type { LitvisDocument, LitvisNarrative } from "litvis"; @@ -8,10 +9,10 @@ import type { Position } from "unist"; import type { VFile } from "vfile"; const findOrFilter = ( - $: CheerioStatic, - func: (selector: string) => Cheerio, + $: CheerioAPI, + func: (selector: string) => Cheerio, selector: any, -): Cheerio => { +): Cheerio => { const cheerioSelectorParts: string[] = []; if (selector) { cheerioSelectorParts.push(`[ns-role="label"]`); @@ -23,18 +24,34 @@ const findOrFilter = ( let $result = func(cheerioSelectorParts.join("")); if (selector.trimmedContent) { $result = $result.filter( - (i, element) => $(element).text().trim() === selector.trimmedContent, + (i, element) => + $(element as AnyNode) + .text() + .trim() === selector.trimmedContent, ); } return $result; }; -const find = ($: CheerioStatic, $where: Cheerio, selector: any): Cheerio => { +const find = ( + $: CheerioAPI, + $where: Cheerio, + selector: any, +): Cheerio => { return findOrFilter($, $where.find.bind($where), selector); }; -const filter = ($: CheerioStatic, $what: Cheerio, selector: any): Cheerio => { - return findOrFilter($, $what.filter.bind($what), selector); +const filter = ( + $: CheerioAPI, + $what: Cheerio, + selector: any, +): Cheerio => { + return findOrFilter( + $, + // @ts-expect-error - investigate type mismatch + $what.filter.bind($what), + selector, + ); }; const ruleIsNotFollowed = ( position?: Position, @@ -49,7 +66,7 @@ const ruleIsNotFollowed = ( return result; }; -const elementPosition = ($el: Cheerio): Position | undefined => { +const elementPosition = ($el: Cheerio): Position | undefined => { const startColumn = parseInt($el.attr("ns-position-start-column") || "0", 10); const startLine = parseInt($el.attr("ns-position-start-line") || "0", 10); const endColumn = parseInt($el.attr("ns-position-end-column") || "0", 10); @@ -122,7 +139,7 @@ export const postEnhanceWithLitvis = ( // single-element rules $selection.each((i, el) => { - const $el = $(el); + const $el = $(el as AnyNode); // children.minimumTrimmedTextLength if ( ruleData.children &&