{"name":"css-selector-parser","version":"2.3.0","description":"Powerful and compliant CSS selector parser.","keywords":["css","css selector","css selector parser","pseudo-classes","pseudo-elements","css attributes","css tags","css classes"],"author":{"name":"Marat Dulin","email":"mdevils@yandex.ru"},"funding":[{"type":"github","url":"https://github.com/sponsors/mdevils"},{"type":"patreon","url":"https://patreon.com/mdevils"}],"devDependencies":{"@commitlint/cli":"^17.6.6","@commitlint/config-conventional":"^17.6.6","@types/jest":"^29.5.2","@typescript-eslint/eslint-plugin":"^5.60.0","@typescript-eslint/parser":"^5.60.0","eslint":"^8.43.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.27.5","eslint-plugin-prettier":"^4.2.1","husky":"^4.3.8","jest":"^29.5.0","prettier":"^2.2.1","standard-version":"^9.5.0","ts-jest":"^29.1.0","ts-node":"^10.9.1","typedoc":"^0.24.8","typedoc-plugin-markdown":"^3.15.3","typescript":"^4.9.0"},"repository":{"type":"git","url":"git+https://github.com/mdevils/css-selector-parser.git"},"main":"./dist/cjs/index.js","module":"./dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"typings":"./dist/cjs/index","types":"./dist/cjs/index","license":"MIT","scripts":{"build":"rm -Rf dist && tsc -p tsconfig.json && tsc -p tsconfig.mjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json && echo '{\"type\": \"module\"}' > dist/mjs/package.json","build:docs":"rm -Rf docs && typedoc --excludeInternal --excludeExternals --disableSources --plugin typedoc-plugin-markdown --entryDocument ../README.md --out docs src/index.ts && ts-node tools/cleanup-docs.ts","test":"jest test","test:dist":"TEST_DIST=cjs npm run test","lint":"eslint src/**.ts","lint:fix":"eslint --fix src/**.ts","benchmark":"ts-node benchmark/benchmark.ts","release":"standard-version","prepublishOnly":"npm run build"},"husky":{"hooks":{"pre-commit":"npm run lint && npm run test","commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"commitlint":{"extends":["@commitlint/config-conventional"],"rules":{"subject-case":[2,"never",["start-case","pascal-case"]]}},"gitHead":"7fa7b7dcc2c23783c45e36a9cbab245ff1288e39","bugs":{"url":"https://github.com/mdevils/css-selector-parser/issues"},"homepage":"https://github.com/mdevils/css-selector-parser#readme","_id":"css-selector-parser@2.3.0","_nodeVersion":"20.2.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-N+HWItTARBQC/PLYTRRIMxZSzR5ty+/rNuvVVNQ8CYOe0wLo1A7kwaS51G4TU4LjPGFMmNtU4n3izeDCh2TCOA==","shasum":"cfed63ab343366a3023769568c3fff0546104878","tarball":"http://registry-npm.ywwl.com/css-selector-parser/download/css-selector-parser-2.3.0.tgz","fileCount":3,"unpackedSize":7466,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDE8PXrm/y8VziYEq09OlTsCf9srxN1ahoQT8PiquvZ8gIgAbKHkEcXzkfn/QMB5ns3EjXhs0mS6Mxq7CUh0niaBXs="}],"size":2925,"noattachment":false,"key":"/css-selector-parser/-/css-selector-parser-2.3.0.tgz"},"_npmUser":{"name":"mdevils","email":"mdevils@yandex.ru"},"directories":{},"maintainers":[{"name":"mdevils","email":"mdevils@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-selector-parser_2.3.0_1687643721264_0.12672353268518455"},"_hasShrinkwrap":false,"deprecated":"version was incorrectly published","readme":"css-selector-parser\n===================\n\n* Fast and low memory CSS selector parser.\n* Parses CSS selector into object-model (AST).\n* Compliant with all historical and modern CSS specs.\n* Covered with tests.\n* Documented.\n* Supported CSS selector standards:\n    * `css1`: https://www.w3.org/TR/CSS1/\n    * `css2`: https://www.w3.org/TR/CSS2/\n    * `css3`/`selectors-3`: https://www.w3.org/TR/selectors-3/\n    * `selectors-4`: https://www.w3.org/TR/selectors-4/\n    * `latest`: refers to `selectors-4`\n    * `progressive`: `latest` + accepts unknown psudo-classes, psudo-elements and attribute case sensitivity modifiers\n\n**Important:**\n * [Migrating from 1.x to 3.x](CHANGELOG.md#migrating-from-1x-to-3x).\n * [Migrating from 2.x to 3.x](CHANGELOG.md#migrating-from-2x-to-3x).\n * [Migrating from 1.x to 2.x](CHANGELOG.md#220).\n\nLatest releases: [Changelog](CHANGELOG.md).\n\nInstallation\n------------\n\n```\nnpm install css-selector-parser\n```\n\nUsage\n-----\n\n### Parsing\n\n```javascript\nimport {createParser} from 'css-selector-parser';\n\nconst parse = createParser();\nconst selector = parse('a[href^=\"/\"], .container:has(nav) > a[href]:nth-child(2)::before');\n\nconsole.log(selector);\n```\n\nProduces:\n\n```javascript\n({\n    type: 'Selector',\n    rules: [\n        {\n            type: 'Rule',\n            items: [\n                { type: 'TagName', name: 'a' },\n                {\n                    type: 'Attribute',\n                    name: 'href',\n                    operator: '^=',\n                    value: { type: 'String', value: '/' }\n                }\n            ]\n        },\n        {\n            type: 'Rule',\n            items: [\n                { type: 'ClassName', name: 'container' },\n                {\n                    type: 'PseudoClass',\n                    name: 'has',\n                    argument: {\n                        type: 'Selector',\n                        rules: [\n                            {\n                                type: 'Rule',\n                                items: [ { type: 'TagName', name: 'nav' } ]\n                            }\n                        ]\n                    }\n                }\n            ],\n            nestedRule: {\n                type: 'Rule',\n                items: [\n                    { type: 'TagName', name: 'a' },\n                    { type: 'Attribute', name: 'href' },\n                    {\n                        type: 'PseudoClass',\n                        name: 'nth-child',\n                        argument: { type: 'Formula', a: 0, b: 2 }\n                    },\n                    {\n                        type: 'PseudoElement',\n                        name: 'before'\n                    }\n                ],\n                combinator: '>'\n            }\n        }\n    ]\n})\n```\n\n### Constructing AST and rendering\n\n```javascript\nimport {ast, render} from 'css-selector-parser';\n\nconst selector = ast.selector({\n    rules: [\n        ast.rule({\n            items: [\n                ast.tagName({name: 'a'}),\n                ast.attribute({name: 'href', operator: '^=', value: ast.string({value: '/'})})\n            ]\n        }),\n        ast.rule({\n            items: [\n                ast.className({name: 'container'}),\n                ast.pseudoClass({\n                    name: 'has',\n                    argument: ast.selector({\n                        rules: [ast.rule({items: [ast.tagName({name: 'nav'})]})]\n                    })\n                })\n            ],\n            nestedRule: ast.rule({\n                combinator: '>',\n                items: [\n                    ast.tagName({name: 'a'}),\n                    ast.attribute({name: 'href'}),\n                    ast.pseudoClass({\n                        name: 'nth-child',\n                        argument: ast.formula({a: 0, b: 2})\n                    }),\n                    ast.pseudoElement({name: 'before'})\n                ]\n            })\n        })\n    ]\n});\n\nconsole.log(render(selector)); // a[href^=\"/\"], .container:has(nav) > a[href]:nth-child(2)::before\n```\n\nAPI\n---\n\n* [Full API Documentation](docs/modules.md)\n* [Parsing CSS selectors](docs/modules.md#createParser)\n* [Constructing CSS AST](docs/modules.md#ast)\n* [Rendering CSS AST](docs/modules.md#render)\n\nLICENSE\n-------\n\nMIT\n\n## Security contact information\n\nTo report a security vulnerability, please use the\n[Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure.\n","publish_time":1687643721446,"_cnpm_publish_time":1687643721446,"dist-tags":{"latest":"3.3.0"}}