From fc87c009806dcc98867f6b58efe29b042aa01dee Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 18 May 2026 23:10:59 +0800 Subject: node: update --- node_modules/stylehacks/src/plugin.js | 108 ---------------------------------- 1 file changed, 108 deletions(-) delete mode 100644 node_modules/stylehacks/src/plugin.js (limited to 'node_modules/stylehacks/src/plugin.js') diff --git a/node_modules/stylehacks/src/plugin.js b/node_modules/stylehacks/src/plugin.js deleted file mode 100644 index 15c6b5a9..00000000 --- a/node_modules/stylehacks/src/plugin.js +++ /dev/null @@ -1,108 +0,0 @@ -'use strict'; -/** - * @typedef {object} Plugin - * @prop {Set} targets - * @prop {Set} nodeTypes - * @prop {(node: import('postcss').Node) => void} detectAndResolve - * @prop {(node: import('postcss').Node) => void} detectAndWarn - */ - -/** - * @typedef {import('postcss').Node & {_stylehacks: { - message: string, - browsers: Set, - identifier: string, - hack: string }}} NodeWithInfo - */ - -module.exports = class BasePlugin { - /** - * @param {string[]} targets - * @param {string[]} nodeTypes - * @param {import('postcss').Result=} result - */ - constructor(targets, nodeTypes, result) { - /** @type {NodeWithInfo[]} */ - this.nodes = []; - this.targets = new Set(targets); - this.nodeTypes = new Set(nodeTypes); - this.result = result; - } - - /** - * @param {import('postcss').Node} node - * @param {{identifier: string, hack: string}} metadata - * @return {void} - */ - push(node, metadata) { - /** @type {NodeWithInfo} */ (node)._stylehacks = Object.assign( - {}, - metadata, - { - message: `Bad ${metadata.identifier}: ${metadata.hack}`, - browsers: this.targets, - } - ); - - this.nodes.push(/** @type {NodeWithInfo} */ (node)); - } - - /** - * @param {import('postcss').Node} node - * @return {boolean} - */ - any(node) { - if (this.nodeTypes.has(node.type)) { - this.detect(node); - - return /** @type {NodeWithInfo} */ (node)._stylehacks !== undefined; - } - - return false; - } - - /** - * @param {import('postcss').Node} node - * @return {void} - */ - detectAndResolve(node) { - this.nodes = []; - - this.detect(node); - - return this.resolve(); - } - - /** - * @param {import('postcss').Node} node - * @return {void} - */ - detectAndWarn(node) { - this.nodes = []; - - this.detect(node); - - return this.warn(); - } - /** @param {import('postcss').Node} node */ - // eslint-disable-next-line no-unused-vars - detect(node) { - throw new Error('You need to implement this method in a subclass.'); - } - - /** @return {void} */ - resolve() { - return this.nodes.forEach((node) => node.remove()); - } - - warn() { - return this.nodes.forEach((node) => { - const { message, browsers, identifier, hack } = node._stylehacks; - - return node.warn( - /** @type {import('postcss').Result} */ (this.result), - message + JSON.stringify({ browsers, identifier, hack }) - ); - }); - } -}; -- cgit v1.2.3