From aa6ff8812b4e1d1f38cb2ebdf53f69eeff41f81e Mon Sep 17 00:00:00 2001 From: Titus Date: Mon, 16 Jan 2023 16:28:09 +0100 Subject: [PATCH 01/10] Use Node 16 in Actions Signed-off-by: Titus --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee318ca..fb63387 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,5 +17,5 @@ jobs: strategy: matrix: node: - - lts/hydrogen + - lts/gallium - node From 935e5d477a4f9a4665e6c43fc15859b8151dfc10 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:03:20 +0200 Subject: [PATCH 02/10] Update dev-dependencies --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 54a684c..c97134c 100644 --- a/package.json +++ b/package.json @@ -36,19 +36,19 @@ "hast-util-is-element": "^2.0.0" }, "devDependencies": { - "@types/node": "^18.0.0", - "c8": "^7.0.0", - "prettier": "^2.0.0", + "@types/node": "^20.0.0", + "c8": "^8.0.0", + "prettier": "^3.0.0", "remark-cli": "^11.0.0", "remark-preset-wooorm": "^9.0.0", "type-coverage": "^2.0.0", - "typescript": "^4.0.0", - "xo": "^0.53.0" + "typescript": "^5.0.0", + "xo": "^0.55.0" }, "scripts": { "prepack": "npm run build && npm run format", "build": "tsc --build --clean && tsc --build && type-coverage", - "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", + "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", "test-api": "node --conditions development test.js", "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", "test": "npm run build && npm run format && npm run test-coverage" From f22ce5d36b611b26e79c963e85a51c40431ad156 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:06:29 +0200 Subject: [PATCH 03/10] Update `@types/hast`, utilities --- lib/index.js | 34 ++++++++++++++++++++-------------- package.json | 3 ++- test.js | 1 + 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/index.js b/lib/index.js index e05db06..2262c1c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,7 +7,6 @@ import {convertElement} from 'hast-util-is-element' /** * Check if a node is a *embedded content*. * - * @type {import('hast-util-is-element').AssertPredicate} * @param value * Thing to check (typically `Node`). * @returns @@ -16,16 +15,23 @@ import {convertElement} from 'hast-util-is-element' * The elements `audio`, `canvas`, `embed`, `iframe`, `img`, `math`, * `object`, `picture`, `svg`, and `video` are embedded content. */ -// @ts-expect-error Sure, the assertion matches. -export const embedded = convertElement([ - 'audio', - 'canvas', - 'embed', - 'iframe', - 'img', - 'math', - 'object', - 'picture', - 'svg', - 'video' -]) +export const embedded = convertElement( + /** + * @param element + * @returns {element is Element & {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}} + */ + function (element) { + return ( + element.tagName === 'audio' || + element.tagName === 'canvas' || + element.tagName === 'embed' || + element.tagName === 'iframe' || + element.tagName === 'img' || + element.tagName === 'math' || + element.tagName === 'object' || + element.tagName === 'picture' || + element.tagName === 'svg' || + element.tagName === 'video' + ) + } +) diff --git a/package.json b/package.json index c97134c..3ed8ede 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "index.js" ], "dependencies": { - "hast-util-is-element": "^2.0.0" + "@types/hast": "^3.0.0", + "hast-util-is-element": "^3.0.0" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/test.js b/test.js index a3f751e..ff13df1 100644 --- a/test.js +++ b/test.js @@ -10,6 +10,7 @@ test('embedded', () => { 'should expose the public api' ) + // @ts-expect-error: check how a missing node is handled. assert.equal(embedded(), false, 'should return `false` without node') assert.equal(embedded(null), false, 'should return `false` with `null`') From 02b0faf7d1ffb080dec3a7e5fc0b231236103977 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:06:54 +0200 Subject: [PATCH 04/10] Refactor `package.json`, `tsconfig.json` --- package.json | 19 ++++++++++--------- tsconfig.json | 10 ++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 3ed8ede..d858281 100644 --- a/package.json +++ b/package.json @@ -51,28 +51,29 @@ "build": "tsc --build --clean && tsc --build && type-coverage", "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", "test-api": "node --conditions development test.js", - "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", + "test-coverage": "c8 --100 --reporter lcov npm run test-api", "test": "npm run build && npm run format && npm run test-coverage" }, "prettier": { - "tabWidth": 2, - "useTabs": false, - "singleQuote": true, "bracketSpacing": false, "semi": false, - "trailingComma": "none" - }, - "xo": { - "prettier": true + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "none", + "useTabs": false }, "remarkConfig": { "plugins": [ - "preset-wooorm" + "remark-preset-wooorm" ] }, "typeCoverage": { "atLeast": 100, "detail": true, + "ignoreCatch": true, "strict": true + }, + "xo": { + "prettier": true } } diff --git a/tsconfig.json b/tsconfig.json index 1bc9e99..870d82c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,15 @@ { - "include": ["**/**.js"], - "exclude": ["coverage/", "node_modules/"], "compilerOptions": { "checkJs": true, + "customConditions": ["development"], "declaration": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, - "forceConsistentCasingInFileNames": true, "lib": ["es2020"], "module": "node16", - "newLine": "lf", - "skipLibCheck": true, "strict": true, "target": "es2020" - } + }, + "exclude": ["coverage/", "node_modules/"], + "include": ["**/*.js"] } From 696e6f5d90af2dab6f687daf402d9fe0437eed72 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:07:07 +0200 Subject: [PATCH 05/10] Refactor `.npmrc` --- .npmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.npmrc b/.npmrc index 9951b11..3757b30 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,2 @@ -package-lock=false ignore-scripts=true +package-lock=false From 85ce03b4af0fd7aa62aa673ba5afa57b35d3a7c1 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:11:16 +0200 Subject: [PATCH 06/10] Refactor code-style --- lib/index.js | 6 +--- test.js | 81 +++++++++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2262c1c..2caf1ab 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,3 @@ -/** - * @typedef {import('hast').Element} Element - */ - import {convertElement} from 'hast-util-is-element' /** @@ -18,7 +14,7 @@ import {convertElement} from 'hast-util-is-element' export const embedded = convertElement( /** * @param element - * @returns {element is Element & {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}} + * @returns {element is {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}} */ function (element) { return ( diff --git a/test.js b/test.js index ff13df1..441d684 100644 --- a/test.js +++ b/test.js @@ -3,49 +3,58 @@ import test from 'node:test' import {embedded} from './index.js' import * as mod from './index.js' -test('embedded', () => { - assert.deepEqual( - Object.keys(mod).sort(), - ['embedded'], - 'should expose the public api' - ) +test('embedded', async function (t) { + await t.test('should expose the public api', async function () { + assert.deepEqual(Object.keys(mod).sort(), ['embedded']) + }) - // @ts-expect-error: check how a missing node is handled. - assert.equal(embedded(), false, 'should return `false` without node') + await t.test('should return `false` without node', async function () { + // @ts-expect-error: check how a missing node is handled. + assert.equal(embedded(), false) + }) - assert.equal(embedded(null), false, 'should return `false` with `null`') + await t.test('should return `false` with `null`', async function () { + assert.equal(embedded(null), false) + }) - assert.equal( - embedded({type: 'text'}), - false, - 'should return `false` when without `element`' + await t.test( + 'should return `false` when without `element`', + async function () { + assert.equal(embedded({type: 'text'}), false) + } ) - assert.equal( - embedded({type: 'element'}), - false, - 'should return `false` when with invalid `element`' + await t.test( + 'should return `false` when with invalid `element`', + async function () { + assert.equal(embedded({type: 'element'}), false) + } ) - assert.equal( - embedded({ - type: 'element', - tagName: 'a', - properties: {href: '#alpha', title: 'Bravo'}, - children: [{type: 'text', value: 'Charlie'}] - }), - false, - 'should return `false` when without not embedded' + await t.test( + 'should return `false` when without not embedded', + async function () { + assert.equal( + embedded({ + type: 'element', + tagName: 'a', + properties: {href: '#alpha', title: 'Bravo'}, + children: [{type: 'text', value: 'Charlie'}] + }), + false + ) + } ) - assert.equal( - embedded({ - type: 'element', - tagName: 'audio', - properties: {src: 'delta.ogg'}, - children: [] - }), - true, - 'should return `true` when with embedded' - ) + await t.test('should return `true` when with embedded', async function () { + assert.equal( + embedded({ + type: 'element', + tagName: 'audio', + properties: {src: 'delta.ogg'}, + children: [] + }), + true + ) + }) }) From 74b9b40631b5c643483f12faa5d51e1e3d56e88c Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:14:35 +0200 Subject: [PATCH 07/10] Refactor docs --- readme.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 8a54164..3df29a6 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ looking for! ## Install This package is [ESM only][esm]. -In Node.js (version 14.14+ and 16.0+), install with [npm][]: +In Node.js (version 16+), install with [npm][]: ```sh npm install hast-util-embedded @@ -82,7 +82,7 @@ embedded({ ## API -This package exports the identifier [`embedded`][embedded]. +This package exports the identifier [`embedded`][api-embedded]. There is no default export. ### `embedded(value)` @@ -108,10 +108,13 @@ It exports no additional types. ## Compatibility -Projects maintained by the unified collective are compatible with all maintained +Projects maintained by the unified collective are compatible with maintained versions of Node.js. -As of now, that is Node.js 14.14+ and 16.0+. -Our projects sometimes work with older versions, but this is not guaranteed. + +When we cut a new major release, we drop support for unmaintained versions of +Node. +This means we try to keep the current release line, `hast-util-embedded@^2`, +compatible with Node.js 12. ## Security @@ -179,9 +182,9 @@ abide by its terms. [downloads]: https://www.npmjs.com/package/hast-util-embedded -[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-embedded.svg +[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-embedded -[size]: https://bundlephobia.com/result?p=hast-util-embedded +[size]: https://bundlejs.com/?q=hast-util-embedded [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg @@ -221,4 +224,4 @@ abide by its terms. [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting -[embedded]: #embeddedvalue +[api-embedded]: #embeddedvalue From e5bd27e05a6f8db44aef058988286a2ef94adeab Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:15:10 +0200 Subject: [PATCH 08/10] Change to use `exports` --- package.json | 3 +-- test.js | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d858281..4bad7b4 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ ], "sideEffects": false, "type": "module", - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/test.js b/test.js index 441d684..57de024 100644 --- a/test.js +++ b/test.js @@ -1,11 +1,12 @@ import assert from 'node:assert/strict' import test from 'node:test' -import {embedded} from './index.js' -import * as mod from './index.js' +import {embedded} from 'hast-util-embedded' test('embedded', async function (t) { await t.test('should expose the public api', async function () { - assert.deepEqual(Object.keys(mod).sort(), ['embedded']) + assert.deepEqual(Object.keys(await import('hast-util-embedded')).sort(), [ + 'embedded' + ]) }) await t.test('should return `false` without node', async function () { From 445f09b69be1e730839b58fe67d0a3aa091f62ff Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:15:49 +0200 Subject: [PATCH 09/10] Change to require Node.js 16 --- readme.md | 4 ++-- tsconfig.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 3df29a6..596118f 100644 --- a/readme.md +++ b/readme.md @@ -113,8 +113,8 @@ versions of Node.js. When we cut a new major release, we drop support for unmaintained versions of Node. -This means we try to keep the current release line, `hast-util-embedded@^2`, -compatible with Node.js 12. +This means we try to keep the current release line, `hast-util-embedded@^3`, +compatible with Node.js 16. ## Security diff --git a/tsconfig.json b/tsconfig.json index 870d82c..82cc749 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,10 +5,10 @@ "declaration": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, - "lib": ["es2020"], + "lib": ["es2022"], "module": "node16", "strict": true, - "target": "es2020" + "target": "es2022" }, "exclude": ["coverage/", "node_modules/"], "include": ["**/*.js"] From 79c68d31fc7dd133c086a1a483583fbc02b48636 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 1 Aug 2023 12:16:08 +0200 Subject: [PATCH 10/10] 3.0.0 --- package.json | 2 +- readme.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4bad7b4..f081896 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hast-util-embedded", - "version": "2.0.1", + "version": "3.0.0", "description": "hast utility to check if a node is an embedded element", "license": "MIT", "keywords": [ diff --git a/readme.md b/readme.md index 596118f..0719aa8 100644 --- a/readme.md +++ b/readme.md @@ -47,14 +47,14 @@ npm install hast-util-embedded In Deno with [`esm.sh`][esmsh]: ```js -import {embedded} from 'https://esm.sh/hast-util-embedded@2' +import {embedded} from 'https://esm.sh/hast-util-embedded@3' ``` In browsers with [`esm.sh`][esmsh]: ```html ``` pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy