김대선

naver.js의 함수 분리

Showing 423 changed files with 3094 additions and 1 deletions
1 const express = require('express') 1 const express = require('express')
2 -const puppeteer = require('puppeteer') 2 +
3 +const naverRouter = require('./router/naver.js')
4 +
3 5
4 const app = express(); 6 const app = express();
7 +
5 const server = app.listen(3000,()=>{ 8 const server = app.listen(3000,()=>{
6 const host = server.address().address 9 const host = server.address().address
7 const port = server.address().port 10 const port = server.address().port
8 console.log("app listening at http://%s:%s", host, port) 11 console.log("app listening at http://%s:%s", host, port)
9 }) 12 })
10 13
14 +app.use('/naver', naverRouter)
15 +
16 +app.get('/naver', (req, res)=>{
17 + res.send("error")
18 +})
19 +
11 app.get('/', (req, res)=>{ 20 app.get('/', (req, res)=>{
12 res.send("this is home!") 21 res.send("this is home!")
13 }) 22 })
...\ No newline at end of file ...\ No newline at end of file
......
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../nanoid/bin/nanoid.cjs" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../nanoid/bin/nanoid.cjs" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\nanoid\bin\nanoid.cjs" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
This diff is collapsed. Click to expand it.
1 +#boolbase
2 +This very simple module provides two basic functions, one that always returns true (`trueFunc`) and one that always returns false (`falseFunc`).
3 +
4 +###WTF?
5 +
6 +By having only a single instance of these functions around, it's possible to do some nice optimizations. Eg. [`CSSselect`](https://github.com/fb55/CSSselect) uses these functions to determine whether a selector won't match any elements. If that's the case, the DOM doesn't even have to be touched.
7 +
8 +###And why is this a separate module?
9 +
10 +I'm trying to modularize `CSSselect` and most modules depend on these functions. IMHO, having a separate module is the easiest solution to this problem.
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = {
2 + trueFunc: function trueFunc(){
3 + return true;
4 + },
5 + falseFunc: function falseFunc(){
6 + return false;
7 + }
8 +};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "boolbase",
3 + "version": "1.0.0",
4 + "description": "two functions: One that returns true, one that returns false",
5 + "main": "index.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "repository": {
10 + "type": "git",
11 + "url": "https://github.com/fb55/boolbase"
12 + },
13 + "keywords": [
14 + "boolean",
15 + "function"
16 + ],
17 + "author": "Felix Boehm <me@feedic.com>",
18 + "license": "ISC",
19 + "bugs": {
20 + "url": "https://github.com/fb55/boolbase/issues"
21 + },
22 + "homepage": "https://github.com/fb55/boolbase"
23 +}
1 +Copyright (c) Felix Böhm
2 +All rights reserved.
3 +
4 +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 +
6 +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 +
8 +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 +
10 +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
11 +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 +# cheerio-select [![NPM version](http://img.shields.io/npm/v/cheerio-select.svg)](https://npmjs.org/package/cheerio-select) [![Build Status](https://travis-ci.org/cheeriojs/cheerio-select.svg?branch=master)](http://travis-ci.org/cheeriojs/cheerio-select) [![Downloads](https://img.shields.io/npm/dm/cheerio-select.svg)](https://npmjs.org/package/cheerio-select) [![Coverage](https://coveralls.io/repos/cheeriojs/cheerio-select/badge.svg?branch=master)](https://coveralls.io/r/cheeriojs/cheerio-select)
2 +
3 +CSS selector engine supporting jQuery selectors, based on [`css-select`](https://github.com/fb55/css-select).
4 +
5 +Supports all jQuery positional pseudo-selectors:
6 +
7 +- `:first`
8 +- `:last`
9 +- `:eq`
10 +- `:nth`
11 +- `:gt`
12 +- `:lt`
13 +- `:even`
14 +- `:odd`
15 +- `:not(:positional)`, where `:positional` is any of the above.
16 +
17 +This library is a thin wrapper around [`css-select`](https://github.com/fb55/css-select).
18 +Only use this module if you will actually use jQuery positional selectors.
1 +import type { NodeWithChildren } from "domhandler";
2 +import type { Selector } from "css-what";
3 +export declare function getDocumentRoot(node: NodeWithChildren): NodeWithChildren;
4 +export declare function groupSelectors(selectors: Selector[][]): [plain: Selector[][], filtered: Selector[][]];
5 +//# sourceMappingURL=helpers.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAGxE;AAED,wBAAgB,cAAc,CAC1B,SAAS,EAAE,QAAQ,EAAE,EAAE,GACxB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAa/C"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.groupSelectors = exports.getDocumentRoot = void 0;
4 +var positionals_1 = require("./positionals");
5 +function getDocumentRoot(node) {
6 + while (node.parent)
7 + node = node.parent;
8 + return node;
9 +}
10 +exports.getDocumentRoot = getDocumentRoot;
11 +function groupSelectors(selectors) {
12 + var filteredSelectors = [];
13 + var plainSelectors = [];
14 + for (var _i = 0, selectors_1 = selectors; _i < selectors_1.length; _i++) {
15 + var selector = selectors_1[_i];
16 + if (selector.some(positionals_1.isFilter)) {
17 + filteredSelectors.push(selector);
18 + }
19 + else {
20 + plainSelectors.push(selector);
21 + }
22 + }
23 + return [plainSelectors, filteredSelectors];
24 +}
25 +exports.groupSelectors = groupSelectors;
1 +import { Options as CSSSelectOptions } from "css-select";
2 +import type { Element, Node } from "domhandler";
3 +export { filters, pseudos, aliases } from "css-select";
4 +export declare type Options = CSSSelectOptions<Node, Element>;
5 +export declare function is(element: Element, selector: string | ((el: Element) => boolean), options?: Options): boolean;
6 +export declare function some(elements: Element[], selector: string | ((el: Element) => boolean), options?: Options): boolean;
7 +export declare function filter(selector: string, elements: Element[], options?: Options): Element[];
8 +export declare function select(selector: string | ((el: Element) => boolean), root: Node | Node[], options?: Options): Element[];
9 +//# sourceMappingURL=index.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,OAAO,IAAI,gBAAgB,EAE9B,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKhD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAYvD,oBAAY,OAAO,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAEtD,wBAAgB,EAAE,CACd,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAC7C,OAAO,GAAE,OAAY,GACtB,OAAO,CAWT;AAED,wBAAgB,IAAI,CAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAC7C,OAAO,GAAE,OAAY,GACtB,OAAO,CAWT;AAsCD,wBAAgB,MAAM,CAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,OAAY,GACtB,OAAO,EAAE,CAEX;AA0FD,wBAAgB,MAAM,CAClB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAC7C,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EACnB,OAAO,GAAE,OAAY,GACtB,OAAO,EAAE,CAuBX"}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +import type { Selector, PseudoSelector } from "css-what";
2 +export declare type Filter = "first" | "last" | "eq" | "nth" | "gt" | "lt" | "even" | "odd" | "not";
3 +export declare const filterNames: Set<string>;
4 +export interface CheerioSelector extends PseudoSelector {
5 + name: Filter;
6 + data: string | null;
7 +}
8 +export declare function isFilter(s: Selector): s is CheerioSelector;
9 +export declare function getLimit(filter: Filter, data: string | null): number;
10 +//# sourceMappingURL=positionals.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"positionals.d.ts","sourceRoot":"","sources":["../src/positionals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD,oBAAY,MAAM,GACZ,OAAO,GACP,MAAM,GACN,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,KAAK,GACL,KAAK,CAAC;AACZ,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CASlC,CAAC;AAEH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,eAAe,CAS1D;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBpE"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.getLimit = exports.isFilter = exports.filterNames = void 0;
4 +exports.filterNames = new Set([
5 + "first",
6 + "last",
7 + "eq",
8 + "gt",
9 + "nth",
10 + "lt",
11 + "even",
12 + "odd",
13 +]);
14 +function isFilter(s) {
15 + if (s.type !== "pseudo")
16 + return false;
17 + if (exports.filterNames.has(s.name))
18 + return true;
19 + if (s.name === "not" && Array.isArray(s.data)) {
20 + // Only consider `:not` with embedded filters
21 + return s.data.some(function (s) { return s.some(isFilter); });
22 + }
23 + return false;
24 +}
25 +exports.isFilter = isFilter;
26 +function getLimit(filter, data) {
27 + var num = data != null ? parseInt(data, 10) : NaN;
28 + switch (filter) {
29 + case "first":
30 + return 1;
31 + case "nth":
32 + case "eq":
33 + return isFinite(num) ? (num >= 0 ? num + 1 : Infinity) : 0;
34 + case "lt":
35 + return isFinite(num) ? (num >= 0 ? num : Infinity) : 0;
36 + case "gt":
37 + return isFinite(num) ? Infinity : 0;
38 + default:
39 + return Infinity;
40 + }
41 +}
42 +exports.getLimit = getLimit;
1 +{
2 + "name": "cheerio-select",
3 + "description": "CSS selector engine supporting jQuery selectors",
4 + "version": "1.4.0",
5 + "author": "Felix Boehm <me@feedic.com>",
6 + "funding": {
7 + "url": "https://github.com/sponsors/fb55"
8 + },
9 + "license": "BSD-2-Clause",
10 + "sideEffects": false,
11 + "repository": {
12 + "type": "git",
13 + "url": "git://github.com/cheeriojs/cheerio-select.git"
14 + },
15 + "directories": {
16 + "lib": "lib/"
17 + },
18 + "main": "lib/index.js",
19 + "types": "lib/index.d.ts",
20 + "files": [
21 + "lib/**/*"
22 + ],
23 + "scripts": {
24 + "test": "jest --coverage && npm run lint",
25 + "coverage": "cat coverage/lcov.info | coveralls",
26 + "lint": "npm run lint:es && npm run lint:prettier",
27 + "lint:es": "eslint src",
28 + "lint:prettier": "npm run format:prettier:raw -- --check",
29 + "format": "npm run format:es && npm run format:prettier",
30 + "format:es": "npm run lint:es -- --fix",
31 + "format:prettier": "npm run format:prettier:raw -- --write",
32 + "format:prettier:raw": "prettier '**/*.{ts,md,json,yml}'",
33 + "build": "tsc",
34 + "prepare": "npm run build"
35 + },
36 + "dependencies": {
37 + "css-select": "^4.1.2",
38 + "css-what": "^5.0.0",
39 + "domelementtype": "^2.2.0",
40 + "domhandler": "^4.2.0",
41 + "domutils": "^2.6.0"
42 + },
43 + "devDependencies": {
44 + "@types/jest": "^26.0.22",
45 + "@typescript-eslint/eslint-plugin": "^4.22.0",
46 + "@typescript-eslint/parser": "^4.22.0",
47 + "coveralls": "^3.1.0",
48 + "eslint": "^7.24.0",
49 + "eslint-config-prettier": "^8.2.0",
50 + "htmlparser2": "^6.1.0",
51 + "jest": "^26.6.3",
52 + "prettier": "^2.2.1",
53 + "ts-jest": "^26.5.5",
54 + "typescript": "^4.2.4"
55 + },
56 + "jest": {
57 + "preset": "ts-jest",
58 + "testEnvironment": "node"
59 + },
60 + "prettier": {
61 + "tabWidth": 4
62 + }
63 +}
This diff is collapsed. Click to expand it.
1 +MIT License
2 +
3 +Copyright (c) 2016 Matt Mueller
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/api/attributes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAmF1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EACF,MAAM,GACN,IAAI,GACJ,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,GAChE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GACpC,OAAO,CAAC,CAAC,CAAC,CAAC;AA8Ed,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,CAA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EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACxE,CAAC,CA0CH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAChE,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EACF,MAAM,GACN,CAAC,CACC,IAAI,EAAE,OAAO,EACb,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,OAAO,KACf,MAAM,CAAC,EAChB,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,CA+CH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,IAAI,EAC/B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,QAAQ,CAAC,EACL,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,GACpD,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,GACD,IAAI,GACP,OAAO,CAKT"}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +import type { Element, Node } from 'domhandler';
2 +import type { Cheerio } from '../cheerio';
3 +/**
4 + * Get the value of a style property for the first element in the set of matched elements.
5 + *
6 + * @category CSS
7 + * @param names - Optionally the names of the property of interest.
8 + * @returns A map of all of the style properties.
9 + * @see {@link https://api.jquery.com/css/}
10 + */
11 +export declare function css<T extends Node>(this: Cheerio<T>, names?: string[]): Record<string, string>;
12 +/**
13 + * Get the value of a style property for the first element in the set of matched elements.
14 + *
15 + * @category CSS
16 + * @param names - The name of the property.
17 + * @returns The property value for the given name.
18 + * @see {@link https://api.jquery.com/css/}
19 + */
20 +export declare function css<T extends Node>(this: Cheerio<T>, name: string): string | undefined;
21 +/**
22 + * Set one CSS property for every matched element.
23 + *
24 + * @category CSS
25 + * @param prop - The name of the property.
26 + * @param val - The new value.
27 + * @returns The instance itself.
28 + * @see {@link https://api.jquery.com/css/}
29 + */
30 +export declare function css<T extends Node>(this: Cheerio<T>, prop: string, val: string | ((this: Element, i: number, style: string) => string | undefined)): Cheerio<T>;
31 +/**
32 + * Set multiple CSS properties for every matched element.
33 + *
34 + * @category CSS
35 + * @param prop - The name of the property.
36 + * @param val - The new value.
37 + * @returns The instance itself.
38 + * @see {@link https://api.jquery.com/css/}
39 + */
40 +export declare function css<T extends Node>(this: Cheerio<T>, prop: Record<string, string>): Cheerio<T>;
41 +//# sourceMappingURL=css.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/api/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAAC;AACtB;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EACC,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACpE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.css = void 0;
4 +var utils_1 = require("../utils");
5 +function css(prop, val) {
6 + if ((prop != null && val != null) ||
7 + // When `prop` is a "plain" object
8 + (typeof prop === 'object' && !Array.isArray(prop))) {
9 + return utils_1.domEach(this, function (idx, el) {
10 + if (utils_1.isTag(el)) {
11 + // `prop` can't be an array here anymore.
12 + setCss(el, prop, val, idx);
13 + }
14 + });
15 + }
16 + return getCss(this[0], prop);
17 +}
18 +exports.css = css;
19 +/**
20 + * Set styles of all elements.
21 + *
22 + * @private
23 + * @param el - Element to set style of.
24 + * @param prop - Name of property.
25 + * @param value - Value to set property to.
26 + * @param idx - Optional index within the selection.
27 + */
28 +function setCss(el, prop, value, idx) {
29 + if (typeof prop === 'string') {
30 + var styles = getCss(el);
31 + var val = typeof value === 'function' ? value.call(el, idx, styles[prop]) : value;
32 + if (val === '') {
33 + delete styles[prop];
34 + }
35 + else if (val != null) {
36 + styles[prop] = val;
37 + }
38 + el.attribs.style = stringify(styles);
39 + }
40 + else if (typeof prop === 'object') {
41 + Object.keys(prop).forEach(function (k, i) {
42 + setCss(el, k, prop[k], i);
43 + });
44 + }
45 +}
46 +function getCss(el, prop) {
47 + if (!el || !utils_1.isTag(el))
48 + return;
49 + var styles = parse(el.attribs.style);
50 + if (typeof prop === 'string') {
51 + return styles[prop];
52 + }
53 + if (Array.isArray(prop)) {
54 + var newStyles_1 = {};
55 + prop.forEach(function (item) {
56 + if (styles[item] != null) {
57 + newStyles_1[item] = styles[item];
58 + }
59 + });
60 + return newStyles_1;
61 + }
62 + return styles;
63 +}
64 +/**
65 + * Stringify `obj` to styles.
66 + *
67 + * @private
68 + * @category CSS
69 + * @param obj - Object to stringify.
70 + * @returns The serialized styles.
71 + */
72 +function stringify(obj) {
73 + return Object.keys(obj).reduce(function (str, prop) { return "" + str + (str ? ' ' : '') + prop + ": " + obj[prop] + ";"; }, '');
74 +}
75 +/**
76 + * Parse `styles`.
77 + *
78 + * @private
79 + * @category CSS
80 + * @param styles - Styles to be parsed.
81 + * @returns The parsed styles.
82 + */
83 +function parse(styles) {
84 + styles = (styles || '').trim();
85 + if (!styles)
86 + return {};
87 + return styles.split(';').reduce(function (obj, str) {
88 + var n = str.indexOf(':');
89 + // Skip if there is no :, or if it is the first/last character
90 + if (n < 1 || n === str.length - 1)
91 + return obj;
92 + obj[str.slice(0, n).trim()] = str.slice(n + 1).trim();
93 + return obj;
94 + }, {});
95 +}
1 +import type { Node } from 'domhandler';
2 +import type { Cheerio } from '../cheerio';
3 +/**
4 + * Encode a set of form elements as a string for submission.
5 + *
6 + * @category Forms
7 + * @returns The serialized form.
8 + * @see {@link https://api.jquery.com/serialize/}
9 + */
10 +export declare function serialize<T extends Node>(this: Cheerio<T>): string;
11 +interface SerializedField {
12 + name: string;
13 + value: string;
14 +}
15 +/**
16 + * Encode a set of form elements as an array of names and values.
17 + *
18 + * @category Forms
19 + * @example
20 + *
21 + * ```js
22 + * $('<form><input name="foo" value="bar" /></form>').serializeArray();
23 + * //=> [ { name: 'foo', value: 'bar' } ]
24 + * ```
25 + *
26 + * @returns The serialized form.
27 + * @see {@link https://api.jquery.com/serializeArray/}
28 + */
29 +export declare function serializeArray<T extends Node>(this: Cheerio<T>): SerializedField[];
30 +export {};
31 +//# sourceMappingURL=forms.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/api/forms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,YAAY,CAAC;AAWtD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAYlE;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,IAAI,EAC3C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,eAAe,EAAE,CAuCnB"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.serializeArray = exports.serialize = void 0;
4 +var utils_1 = require("../utils");
5 +/*
6 + * https://github.com/jquery/jquery/blob/2.1.3/src/manipulation/var/rcheckableType.js
7 + * https://github.com/jquery/jquery/blob/2.1.3/src/serialize.js
8 + */
9 +var submittableSelector = 'input,select,textarea,keygen';
10 +var r20 = /%20/g;
11 +var rCRLF = /\r?\n/g;
12 +/**
13 + * Encode a set of form elements as a string for submission.
14 + *
15 + * @category Forms
16 + * @returns The serialized form.
17 + * @see {@link https://api.jquery.com/serialize/}
18 + */
19 +function serialize() {
20 + // Convert form elements into name/value objects
21 + var arr = this.serializeArray();
22 + // Serialize each element into a key/value string
23 + var retArr = arr.map(function (data) {
24 + return encodeURIComponent(data.name) + "=" + encodeURIComponent(data.value);
25 + });
26 + // Return the resulting serialization
27 + return retArr.join('&').replace(r20, '+');
28 +}
29 +exports.serialize = serialize;
30 +/**
31 + * Encode a set of form elements as an array of names and values.
32 + *
33 + * @category Forms
34 + * @example
35 + *
36 + * ```js
37 + * $('<form><input name="foo" value="bar" /></form>').serializeArray();
38 + * //=> [ { name: 'foo', value: 'bar' } ]
39 + * ```
40 + *
41 + * @returns The serialized form.
42 + * @see {@link https://api.jquery.com/serializeArray/}
43 + */
44 +function serializeArray() {
45 + // Resolve all form elements from either forms or collections of form elements
46 + var Cheerio = this.constructor;
47 + return this.map(function (_, elem) {
48 + var $elem = Cheerio(elem);
49 + if (utils_1.isTag(elem) && elem.name === 'form') {
50 + return $elem.find(submittableSelector).toArray();
51 + }
52 + return $elem.filter(submittableSelector).toArray();
53 + })
54 + .filter(
55 + // Verify elements have a name (`attr.name`) and are not disabled (`:enabled`)
56 + '[name!=""]:enabled' +
57 + // And cannot be clicked (`[type=submit]`) or are used in `x-www-form-urlencoded` (`[type=file]`)
58 + ':not(:submit, :button, :image, :reset, :file)' +
59 + // And are either checked/don't have a checkable state
60 + ':matches([checked], :not(:checkbox, :radio))'
61 + // Convert each of the elements to its value(s)
62 + )
63 + .map(function (_, elem) {
64 + var _a;
65 + var $elem = Cheerio(elem);
66 + var name = $elem.attr('name'); // We have filtered for elements with a name before.
67 + // If there is no value set (e.g. `undefined`, `null`), then default value to empty
68 + var value = (_a = $elem.val()) !== null && _a !== void 0 ? _a : '';
69 + // If we have an array of values (e.g. `<select multiple>`), return an array of key/value pairs
70 + if (Array.isArray(value)) {
71 + return value.map(function (val) {
72 + /*
73 + * We trim replace any line endings (e.g. `\r` or `\r\n` with `\r\n`) to guarantee consistency across platforms
74 + * These can occur inside of `<textarea>'s`
75 + */
76 + return ({ name: name, value: val.replace(rCRLF, '\r\n') });
77 + });
78 + }
79 + // Otherwise (e.g. `<input type="text">`, return only one key/value pair
80 + return { name: name, value: value.replace(rCRLF, '\r\n') };
81 + })
82 + .toArray();
83 +}
84 +exports.serializeArray = serializeArray;
This diff is collapsed. Click to expand it.
1 +{"version":3,"file":"manipulation.d.ts","sourceRoot":"","sources":["../../src/api/manipulation.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAmC,MAAM,YAAY,CAAC;AAKnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE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jE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAC/D,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,GAC9D,OAAO,CAAC,CAAC,CAAC,CAAC;AA6Bd;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAElE"}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +{"version":3,"file":"traversing.d.ts","sourceRoot":"","sources":["../../src/api/traversing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,IAAI,EACjC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GACvD,OAAO,CAAC,OAAO,CAAC,CA+BlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,IAAI,EACnC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EACh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,CAAC,CAAC,CAAC,CAEZ;AAkBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,EAChD,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EACpC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,GAC5B,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAIhB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,IAAI,EACpC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAIf"}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +import { CheerioOptions, InternalOptions } from './options';
2 +import type { Node, Document, Element } from 'domhandler';
3 +import * as Static from './static';
4 +import type { load } from './load';
5 +import { SelectorType, BasicAcceptedElems } from './types';
6 +import * as Attributes from './api/attributes';
7 +import * as Traversing from './api/traversing';
8 +import * as Manipulation from './api/manipulation';
9 +import * as Css from './api/css';
10 +import * as Forms from './api/forms';
11 +declare type AttributesType = typeof Attributes;
12 +declare type TraversingType = typeof Traversing;
13 +declare type ManipulationType = typeof Manipulation;
14 +declare type CssType = typeof Css;
15 +declare type FormsType = typeof Forms;
16 +export declare class Cheerio<T> implements ArrayLike<T> {
17 + length: number;
18 + [index: number]: T;
19 + options: InternalOptions;
20 + /**
21 + * The root of the document. Can be overwritten by using the `root` argument
22 + * of the constructor.
23 + *
24 + * @private
25 + */
26 + _root: Cheerio<Document> | undefined;
27 + /** @function */
28 + find: typeof Traversing.find;
29 + /**
30 + * The root the document was originally loaded with. Same as the static
31 + * `_root` property.
32 + *
33 + * @private
34 + */
35 + _originalRoot: Document | undefined;
36 + /**
37 + * The root the document was originally loaded with. Set in `.load`.
38 + *
39 + * @private
40 + */
41 + static _root: Document | undefined;
42 + /**
43 + * The options the document was originally loaded with. Set in `.load`.
44 + *
45 + * @private
46 + */
47 + static _options: InternalOptions | undefined;
48 + static html: typeof Static.html;
49 + static xml: typeof Static.xml;
50 + static text: typeof Static.text;
51 + static parseHTML: typeof Static.parseHTML;
52 + static root: typeof Static.root;
53 + static contains: typeof Static.contains;
54 + static merge: typeof Static.merge;
55 + static load: typeof load;
56 + /** Mimic jQuery's prototype alias for plugin authors. */
57 + static fn: Cheerio<any>;
58 + /**
59 + * Instance of cheerio. Methods are specified in the modules. Usage of this
60 + * constructor is not recommended. Please use $.load instead.
61 + *
62 + * @private
63 + * @param selector - The new selection.
64 + * @param context - Context of the selection.
65 + * @param root - Sets the root node.
66 + * @param options - Options for the instance.
67 + */
68 + constructor(selector?: T extends Node ? BasicAcceptedElems<T> : Cheerio<T> | T[], context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions);
69 + prevObject: Cheerio<Node> | undefined;
70 + /**
71 + * Make a cheerio object.
72 + *
73 + * @private
74 + * @param dom - The contents of the new object.
75 + * @param context - The context of the new object.
76 + * @returns The new cheerio object.
77 + */
78 + _make<T>(dom: Cheerio<T> | T[] | T | string, context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document> | undefined): Cheerio<T>;
79 + /**
80 + * Retrieve all the DOM elements contained in the jQuery set as an array.
81 + *
82 + * @example
83 + *
84 + * ```js
85 + * $('li').toArray();
86 + * //=> [ {...}, {...}, {...} ]
87 + * ```
88 + *
89 + * @returns The contained items.
90 + */
91 + toArray(): T[];
92 +}
93 +export interface Cheerio<T> extends AttributesType, TraversingType, ManipulationType, CssType, FormsType {
94 + cheerio: '[cheerio object]';
95 + splice: typeof Array.prototype.slice;
96 + [Symbol.iterator](): Iterator<T>;
97 +}
98 +declare type CheerioClassType = typeof Cheerio;
99 +/**
100 + * Wrapper around the `Cheerio` class, making it possible to create a new
101 + * instance without using `new`.
102 + */
103 +export interface CheerioAPI extends CheerioClassType {
104 + <T extends Node, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
105 +}
106 +declare const _default: CheerioAPI;
107 +export default _default;
108 +//# sourceMappingURL=cheerio.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"cheerio.d.ts","sourceRoot":"","sources":["../src/cheerio.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,eAAe,EAGhB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AAErC,aAAK,cAAc,GAAG,OAAO,UAAU,CAAC;AACxC,aAAK,cAAc,GAAG,OAAO,UAAU,CAAC;AACxC,aAAK,gBAAgB,GAAG,OAAO,YAAY,CAAC;AAC5C,aAAK,OAAO,GAAG,OAAO,GAAG,CAAC;AAC1B,aAAK,SAAS,GAAG,OA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,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,EAClC,OAAO,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,IAAI,EACzC,IAAI,GAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAsB,GAC1D,OAAO,CAAC,CAAC,CAAC;IAYb;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,CAAC,EAAE;CAGf;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,CACxB,SAAQ,cAAc,EACpB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,SAAS;IACX,OAAO,EAAE,kBAAkB,CAAC;IAE5B,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;IACrC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;CAClC;AAyBD,aAAK,gBAAgB,GAAG,OAAO,OAAO,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAClD,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,EAC/B,QAAQ,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACpC,OAAO,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,IAAI,EACzC,IAAI,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,SAAS,YAAY,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC;CAClD;;AAGD,wBAAkD"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.Cheerio = void 0;
4 +var tslib_1 = require("tslib");
5 +var parse_1 = tslib_1.__importDefault(require("./parse"));
6 +var options_1 = tslib_1.__importStar(require("./options"));
7 +var utils_1 = require("./utils");
8 +var Static = tslib_1.__importStar(require("./static"));
9 +var Attributes = tslib_1.__importStar(require("./api/attributes"));
10 +var Traversing = tslib_1.__importStar(require("./api/traversing"));
11 +var Manipulation = tslib_1.__importStar(require("./api/manipulation"));
12 +var Css = tslib_1.__importStar(require("./api/css"));
13 +var Forms = tslib_1.__importStar(require("./api/forms"));
14 +/*
15 + * The API
16 + */
17 +var api = [Attributes, Traversing, Manipulation, Css, Forms];
18 +var Cheerio = /** @class */ (function () {
19 + /**
20 + * Instance of cheerio. Methods are specified in the modules. Usage of this
21 + * constructor is not recommended. Please use $.load instead.
22 + *
23 + * @private
24 + * @param selector - The new selection.
25 + * @param context - Context of the selection.
26 + * @param root - Sets the root node.
27 + * @param options - Options for the instance.
28 + */
29 + function Cheerio(selector, context, root, options) {
30 + var _this = this;
31 + if (!(this instanceof Cheerio)) {
32 + return new Cheerio(selector, context, root, options);
33 + }
34 + this.length = 0;
35 + this.options = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, options_1.default), this.options), options_1.flatten(options));
36 + // $(), $(null), $(undefined), $(false)
37 + if (!selector)
38 + return this;
39 + if (root) {
40 + if (typeof root === 'string')
41 + root = parse_1.default(root, this.options, false);
42 + this._root = Cheerio.call(this, root);
43 + }
44 + // $($)
45 + if (utils_1.isCheerio(selector))
46 + return selector;
47 + var elements = typeof selector === 'string' && utils_1.isHtml(selector)
48 + ? // $(<html>)
49 + parse_1.default(selector, this.options, false).children
50 + : isNode(selector)
51 + ? // $(dom)
52 + [selector]
53 + : Array.isArray(selector)
54 + ? // $([dom])
55 + selector
56 + : null;
57 + if (elements) {
58 + elements.forEach(function (elem, idx) {
59 + _this[idx] = elem;
60 + });
61 + this.length = elements.length;
62 + return this;
63 + }
64 + // We know that our selector is a string now.
65 + var search = selector;
66 + var searchContext = !context
67 + ? // If we don't have a context, maybe we have a root, from loading
68 + this._root
69 + : typeof context === 'string'
70 + ? utils_1.isHtml(context)
71 + ? // $('li', '<ul>...</ul>')
72 + new Cheerio(parse_1.default(context, this.options, false))
73 + : // $('li', 'ul')
74 + ((search = context + " " + search), this._root)
75 + : utils_1.isCheerio(context)
76 + ? // $('li', $)
77 + context
78 + : // $('li', node), $('li', [nodes])
79 + new Cheerio(context);
80 + // If we still don't have a context, return
81 + if (!searchContext)
82 + return this;
83 + /*
84 + * #id, .class, tag
85 + */
86 + // @ts-expect-error No good way to type this — we will always return `Cheerio<Element>` here.
87 + return searchContext.find(search);
88 + }
89 + /**
90 + * Make a cheerio object.
91 + *
92 + * @private
93 + * @param dom - The contents of the new object.
94 + * @param context - The context of the new object.
95 + * @returns The new cheerio object.
96 + */
97 + Cheerio.prototype._make = function (dom, context, root) {
98 + if (root === void 0) { root = this._root; }
99 + var cheerio = new this.constructor(dom, context, root, this.options);
100 + cheerio.prevObject = this;
101 + return cheerio;
102 + };
103 + /**
104 + * Retrieve all the DOM elements contained in the jQuery set as an array.
105 + *
106 + * @example
107 + *
108 + * ```js
109 + * $('li').toArray();
110 + * //=> [ {...}, {...}, {...} ]
111 + * ```
112 + *
113 + * @returns The contained items.
114 + */
115 + Cheerio.prototype.toArray = function () {
116 + return this.get();
117 + };
118 + Cheerio.html = Static.html;
119 + Cheerio.xml = Static.xml;
120 + Cheerio.text = Static.text;
121 + Cheerio.parseHTML = Static.parseHTML;
122 + Cheerio.root = Static.root;
123 + Cheerio.contains = Static.contains;
124 + Cheerio.merge = Static.merge;
125 + /** Mimic jQuery's prototype alias for plugin authors. */
126 + Cheerio.fn = Cheerio.prototype;
127 + return Cheerio;
128 +}());
129 +exports.Cheerio = Cheerio;
130 +/** Set a signature of the object. */
131 +Cheerio.prototype.cheerio = '[cheerio object]';
132 +/*
133 + * Make cheerio an array-like object
134 + */
135 +Cheerio.prototype.splice = Array.prototype.splice;
136 +// Support for (const element of $(...)) iteration:
137 +Cheerio.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
138 +// Plug in the API
139 +api.forEach(function (mod) { return Object.assign(Cheerio.prototype, mod); });
140 +function isNode(obj) {
141 + return (!!obj.name ||
142 + obj.type === 'root' ||
143 + obj.type === 'text' ||
144 + obj.type === 'comment');
145 +}
146 +// Make it possible to call Cheerio without using `new`.
147 +exports.default = Cheerio;
1 +import Cheerio from './cheerio';
2 +/**
3 + * The default cheerio instance.
4 + *
5 + * @deprecated Use the function returned by `load` instead.
6 + */
7 +export default Cheerio;
8 +/**
9 + * The main types of Cheerio objects.
10 + *
11 + * @category Cheerio
12 + */
13 +export type { Cheerio, CheerioAPI } from './cheerio';
14 +/**
15 + * Types used in signatures of Cheerio methods.
16 + *
17 + * @category Cheerio
18 + */
19 +export * from './types';
20 +export type { CheerioOptions, HTMLParser2Options, Parse5Options, } from './options';
21 +/**
22 + * Re-exporting all of the node types.
23 + *
24 + * @category DOM Node
25 + */
26 +export type { Node, NodeWithChildren, Element, Document } from 'domhandler';
27 +export * from './load';
28 +import * as staticMethods from './static';
29 +/**
30 + * In order to promote consistency with the jQuery library, users are encouraged
31 + * to instead use the static method of the same name.
32 + *
33 + * @deprecated
34 + * @example
35 + *
36 + * ```js
37 + * const $ = cheerio.load('<div><p></p></div>');
38 + *
39 + * $.contains($('div').get(0), $('p').get(0));
40 + * //=> true
41 + *
42 + * $.contains($('p').get(0), $('div').get(0));
43 + * //=> false
44 + * ```
45 + *
46 + * @returns {boolean}
47 + */
48 +export declare const contains: typeof staticMethods.contains;
49 +/**
50 + * In order to promote consistency with the jQuery library, users are encouraged
51 + * to instead use the static method of the same name.
52 + *
53 + * @deprecated
54 + * @example
55 + *
56 + * ```js
57 + * const $ = cheerio.load('');
58 + *
59 + * $.merge([1, 2], [3, 4]);
60 + * //=> [1, 2, 3, 4]
61 + * ```
62 + */
63 +export declare const merge: typeof staticMethods.merge;
64 +/**
65 + * In order to promote consistency with the jQuery library, users are encouraged
66 + * to instead use the static method of the same name as it is defined on the
67 + * "loaded" Cheerio factory function.
68 + *
69 + * @deprecated See {@link static/parseHTML}.
70 + * @example
71 + *
72 + * ```js
73 + * const $ = cheerio.load('');
74 + * $.parseHTML('<b>markup</b>');
75 + * ```
76 + */
77 +export declare const parseHTML: typeof staticMethods.parseHTML;
78 +/**
79 + * Users seeking to access the top-level element of a parsed document should
80 + * instead use the `root` static method of a "loaded" Cheerio function.
81 + *
82 + * @deprecated
83 + * @example
84 + *
85 + * ```js
86 + * const $ = cheerio.load('');
87 + * $.root();
88 + * ```
89 + */
90 +export declare const root: typeof staticMethods.root;
91 +//# sourceMappingURL=index.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;GAIG;AACH,eAAe,OAAO,CAAC;AAEvB;;;;GAIG;AACH,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD;;;;GAIG;AACH,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,WAAW,CAAC;AACnB;;;;GAIG;AACH,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E,cAAc,QAAQ,CAAC;AAIvB,OAAO,KAAK,aAAa,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAQ,QAAQ,+BAAkB,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAQ,KAAK,4BAAkB,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAQ,SAAS,gCAAkB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAQ,IAAI,2BAAkB,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.root = exports.parseHTML = exports.merge = exports.contains = void 0;
4 +var tslib_1 = require("tslib");
5 +var cheerio_1 = tslib_1.__importDefault(require("./cheerio"));
6 +/**
7 + * The default cheerio instance.
8 + *
9 + * @deprecated Use the function returned by `load` instead.
10 + */
11 +exports.default = cheerio_1.default;
12 +/**
13 + * Types used in signatures of Cheerio methods.
14 + *
15 + * @category Cheerio
16 + */
17 +tslib_1.__exportStar(require("./types"), exports);
18 +tslib_1.__exportStar(require("./load"), exports);
19 +var load_1 = require("./load");
20 +// We add this here, to avoid a cyclic depenency
21 +cheerio_1.default.load = load_1.load;
22 +var staticMethods = tslib_1.__importStar(require("./static"));
23 +/**
24 + * In order to promote consistency with the jQuery library, users are encouraged
25 + * to instead use the static method of the same name.
26 + *
27 + * @deprecated
28 + * @example
29 + *
30 + * ```js
31 + * const $ = cheerio.load('<div><p></p></div>');
32 + *
33 + * $.contains($('div').get(0), $('p').get(0));
34 + * //=> true
35 + *
36 + * $.contains($('p').get(0), $('div').get(0));
37 + * //=> false
38 + * ```
39 + *
40 + * @returns {boolean}
41 + */
42 +exports.contains = staticMethods.contains;
43 +/**
44 + * In order to promote consistency with the jQuery library, users are encouraged
45 + * to instead use the static method of the same name.
46 + *
47 + * @deprecated
48 + * @example
49 + *
50 + * ```js
51 + * const $ = cheerio.load('');
52 + *
53 + * $.merge([1, 2], [3, 4]);
54 + * //=> [1, 2, 3, 4]
55 + * ```
56 + */
57 +exports.merge = staticMethods.merge;
58 +/**
59 + * In order to promote consistency with the jQuery library, users are encouraged
60 + * to instead use the static method of the same name as it is defined on the
61 + * "loaded" Cheerio factory function.
62 + *
63 + * @deprecated See {@link static/parseHTML}.
64 + * @example
65 + *
66 + * ```js
67 + * const $ = cheerio.load('');
68 + * $.parseHTML('<b>markup</b>');
69 + * ```
70 + */
71 +exports.parseHTML = staticMethods.parseHTML;
72 +/**
73 + * Users seeking to access the top-level element of a parsed document should
74 + * instead use the `root` static method of a "loaded" Cheerio function.
75 + *
76 + * @deprecated
77 + * @example
78 + *
79 + * ```js
80 + * const $ = cheerio.load('');
81 + * $.root();
82 + * ```
83 + */
84 +exports.root = staticMethods.root;
1 +/// <reference types="node" />
2 +import { CheerioOptions } from './options';
3 +import { CheerioAPI } from './cheerio';
4 +import type { Node } from 'domhandler';
5 +/**
6 + * Create a querying function, bound to a document created from the provided
7 + * markup. Note that similar to web browser contexts, this operation may
8 + * introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to
9 + * `false` to switch to fragment mode and disable this.
10 + *
11 + * See the README section titled "Loading" for additional usage information.
12 + *
13 + * @param content - Markup to be loaded.
14 + * @param options - Options for the created instance.
15 + * @param isDocument - Allows parser to be switched to fragment mode.
16 + * @returns The loaded document.
17 + */
18 +export declare function load(content: string | Node | Node[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean): CheerioAPI;
19 +//# sourceMappingURL=load.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,cAAc,EAGf,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAW,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAClB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,EACxC,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,EAC/B,UAAU,CAAC,EAAE,OAAO,GACnB,UAAU,CA8CZ"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.load = void 0;
4 +var tslib_1 = require("tslib");
5 +var options_1 = tslib_1.__importStar(require("./options"));
6 +var staticMethods = tslib_1.__importStar(require("./static"));
7 +var cheerio_1 = require("./cheerio");
8 +var parse_1 = tslib_1.__importDefault(require("./parse"));
9 +/**
10 + * Create a querying function, bound to a document created from the provided
11 + * markup. Note that similar to web browser contexts, this operation may
12 + * introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to
13 + * `false` to switch to fragment mode and disable this.
14 + *
15 + * See the README section titled "Loading" for additional usage information.
16 + *
17 + * @param content - Markup to be loaded.
18 + * @param options - Options for the created instance.
19 + * @param isDocument - Allows parser to be switched to fragment mode.
20 + * @returns The loaded document.
21 + */
22 +function load(content, options, isDocument) {
23 + if (content == null) {
24 + throw new Error('cheerio.load() expects a string');
25 + }
26 + options = tslib_1.__assign(tslib_1.__assign({}, options_1.default), options_1.flatten(options));
27 + if (typeof isDocument === 'undefined')
28 + isDocument = true;
29 + var root = parse_1.default(content, options, isDocument);
30 + var initialize = /** @class */ (function (_super) {
31 + tslib_1.__extends(initialize, _super);
32 + function initialize(selector, context, r, opts) {
33 + if (r === void 0) { r = root; }
34 + var _this = this;
35 + // @ts-expect-error Using `this` before calling the constructor.
36 + if (!(_this instanceof initialize)) {
37 + return new initialize(selector, context, r, opts);
38 + }
39 + _this = _super.call(this, selector, context, r, tslib_1.__assign(tslib_1.__assign({}, options), opts)) || this;
40 + return _this;
41 + }
42 + // Mimic jQuery's prototype alias for plugin authors.
43 + initialize.fn = initialize.prototype;
44 + return initialize;
45 + }(cheerio_1.Cheerio));
46 + /*
47 + * Keep a reference to the top-level scope so we can chain methods that implicitly
48 + * resolve selectors; e.g. $("<span>").(".bar"), which otherwise loses ._root
49 + */
50 + initialize.prototype._originalRoot = root;
51 + // Add in the static methods
52 + Object.assign(initialize, staticMethods, { load: load });
53 + // Add in the root
54 + initialize._root = root;
55 + // Store options
56 + initialize._options = options;
57 + return initialize;
58 +}
59 +exports.load = load;
1 +import type { DomHandlerOptions } from 'domhandler';
2 +import type { ParserOptions } from 'htmlparser2';
3 +/** Options accepted by htmlparser2, the default parser for XML. */
4 +export interface HTMLParser2Options extends DomHandlerOptions, ParserOptions {
5 +}
6 +/** Options for parse5, the default parser for HTML. */
7 +export interface Parse5Options {
8 + /** Disable scripting in parse5, so noscript tags would be parsed. */
9 + scriptingEnabled?: boolean;
10 + /** Enable location support for parse5. */
11 + sourceCodeLocationInfo?: boolean;
12 +}
13 +/** Internal options for Cheerio. */
14 +export interface InternalOptions extends HTMLParser2Options, Parse5Options {
15 + _useHtmlParser2?: boolean;
16 +}
17 +/**
18 + * Options accepted by Cheerio. Please note that parser-specific options are
19 + * *only recognized* if the relevant parser is used.
20 + */
21 +export interface CheerioOptions extends HTMLParser2Options, Parse5Options {
22 + /** Suggested way of configuring htmlparser2 when wanting to parse XML. */
23 + xml?: HTMLParser2Options | boolean;
24 +}
25 +declare const defaultOpts: CheerioOptions;
26 +/** Cheerio default options. */
27 +export default defaultOpts;
28 +export declare function flatten(options?: CheerioOptions | null): InternalOptions | undefined;
29 +//# sourceMappingURL=options.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,mEAAmE;AACnE,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,EAAE,aAAa;CAAG;AAC/E,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,oCAAoC;AACpC,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,aAAa;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,kBAAkB,EAAE,aAAa;IACvE,0EAA0E;IAC1E,GAAG,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC;CACpC;AAED,QAAA,MAAM,WAAW,EAAE,cAGlB,CAAC;AAEF,+BAA+B;AAC/B,eAAe,WAAW,CAAC;AAO3B,wBAAgB,OAAO,CACrB,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,GAC9B,eAAe,GAAG,SAAS,CAM7B"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.flatten = void 0;
4 +var tslib_1 = require("tslib");
5 +var defaultOpts = {
6 + xml: false,
7 + decodeEntities: true,
8 +};
9 +/** Cheerio default options. */
10 +exports.default = defaultOpts;
11 +var xmlModeDefault = {
12 + _useHtmlParser2: true,
13 + xmlMode: true,
14 +};
15 +function flatten(options) {
16 + return (options === null || options === void 0 ? void 0 : options.xml)
17 + ? typeof options.xml === 'boolean'
18 + ? xmlModeDefault
19 + : tslib_1.__assign(tslib_1.__assign({}, xmlModeDefault), options.xml)
20 + : options !== null && options !== void 0 ? options : undefined;
21 +}
22 +exports.flatten = flatten;
1 +/// <reference types="node" />
2 +import { Node, Document, NodeWithChildren } from 'domhandler';
3 +import type { InternalOptions } from './options';
4 +export default function parse(content: string | Document | Node | Node[] | Buffer, options: InternalOptions, isDocument: boolean): Document;
5 +/**
6 + * Update the dom structure, for one changed layer.
7 + *
8 + * @param newChilds - The new children.
9 + * @param parent - The new parent.
10 + * @returns The parent node.
11 + */
12 +export declare function update(newChilds: Node[] | Node, parent: NodeWithChildren | null): Node | null;
13 +//# sourceMappingURL=parse.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAKjD,MAAM,CAAC,OAAO,UAAU,KAAK,CAC3B,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,EACnD,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,GAClB,QAAQ,CAyBV;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,EACxB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,IAAI,GAAG,IAAI,CA+Bb"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.update = void 0;
4 +var htmlparser2_1 = require("htmlparser2");
5 +var htmlparser2_2 = require("./parsers/htmlparser2");
6 +var parse5_1 = require("./parsers/parse5");
7 +var domhandler_1 = require("domhandler");
8 +/*
9 + * Parser
10 + */
11 +function parse(content, options, isDocument) {
12 + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(content)) {
13 + content = content.toString();
14 + }
15 + if (typeof content === 'string') {
16 + return options.xmlMode || options._useHtmlParser2
17 + ? htmlparser2_2.parse(content, options)
18 + : parse5_1.parse(content, options, isDocument);
19 + }
20 + var doc = content;
21 + if (!Array.isArray(doc) && domhandler_1.isDocument(doc)) {
22 + // If `doc` is already a root, just return it
23 + return doc;
24 + }
25 + // Add conent to new root element
26 + var root = new domhandler_1.Document([]);
27 + // Update the DOM using the root
28 + update(doc, root);
29 + return root;
30 +}
31 +exports.default = parse;
32 +/**
33 + * Update the dom structure, for one changed layer.
34 + *
35 + * @param newChilds - The new children.
36 + * @param parent - The new parent.
37 + * @returns The parent node.
38 + */
39 +function update(newChilds, parent) {
40 + // Normalize
41 + var arr = Array.isArray(newChilds) ? newChilds : [newChilds];
42 + // Update parent
43 + if (parent) {
44 + parent.children = arr;
45 + }
46 + else {
47 + parent = null;
48 + }
49 + // Update neighbors
50 + for (var i = 0; i < arr.length; i++) {
51 + var node = arr[i];
52 + // Cleanly remove existing nodes from their previous structures.
53 + if (node.parent && node.parent.children !== arr) {
54 + htmlparser2_1.DomUtils.removeElement(node);
55 + }
56 + if (parent) {
57 + node.prev = arr[i - 1] || null;
58 + node.next = arr[i + 1] || null;
59 + }
60 + else {
61 + node.prev = node.next = null;
62 + }
63 + node.parent = parent;
64 + }
65 + return parent;
66 +}
67 +exports.update = update;
1 +export { parseDocument as parse } from 'htmlparser2';
2 +export { default as render } from 'dom-serializer';
3 +//# sourceMappingURL=htmlparser2.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"htmlparser2.d.ts","sourceRoot":"","sources":["../../src/parsers/htmlparser2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +var __importDefault = (this && this.__importDefault) || function (mod) {
3 + return (mod && mod.__esModule) ? mod : { "default": mod };
4 +};
5 +Object.defineProperty(exports, "__esModule", { value: true });
6 +exports.render = exports.parse = void 0;
7 +var htmlparser2_1 = require("htmlparser2");
8 +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return htmlparser2_1.parseDocument; } });
9 +var dom_serializer_1 = require("dom-serializer");
10 +Object.defineProperty(exports, "render", { enumerable: true, get: function () { return __importDefault(dom_serializer_1).default; } });
1 +import { Node, Document } from 'domhandler';
2 +import type { InternalOptions } from '../options';
3 +interface Parse5Options extends InternalOptions {
4 + context?: Node;
5 +}
6 +export declare function parse(content: string, options: Parse5Options, isDocument?: boolean): Document;
7 +export declare function render(dom: Node | ArrayLike<Node>): string;
8 +export {};
9 +//# sourceMappingURL=parse5.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"parse5.d.ts","sourceRoot":"","sources":["../../src/parsers/parse5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,UAAU,aAAc,SAAQ,eAAe;IAC7C,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,EACtB,UAAU,CAAC,EAAE,OAAO,GACnB,QAAQ,CAiBV;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAgB1D"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.render = exports.parse = void 0;
4 +var tslib_1 = require("tslib");
5 +var domhandler_1 = require("domhandler");
6 +var parse5_1 = require("parse5");
7 +var parse5_htmlparser2_tree_adapter_1 = tslib_1.__importDefault(require("parse5-htmlparser2-tree-adapter"));
8 +function parse(content, options, isDocument) {
9 + var opts = {
10 + scriptingEnabled: typeof options.scriptingEnabled === 'boolean'
11 + ? options.scriptingEnabled
12 + : true,
13 + treeAdapter: parse5_htmlparser2_tree_adapter_1.default,
14 + sourceCodeLocationInfo: options.sourceCodeLocationInfo,
15 + };
16 + var context = options.context;
17 + // @ts-expect-error The tree adapter unfortunately doesn't return the exact types.
18 + return isDocument
19 + ? parse5_1.parse(content, opts)
20 + : // @ts-expect-error Same issue again.
21 + parse5_1.parseFragment(context, content, opts);
22 +}
23 +exports.parse = parse;
24 +function render(dom) {
25 + var _a;
26 + /*
27 + * `dom-serializer` passes over the special "root" node and renders the
28 + * node's children in its place. To mimic this behavior with `parse5`, an
29 + * equivalent operation must be applied to the input array.
30 + */
31 + var nodes = 'length' in dom ? dom : [dom];
32 + for (var index = 0; index < nodes.length; index += 1) {
33 + var node = nodes[index];
34 + if (domhandler_1.isDocument(node)) {
35 + (_a = Array.prototype.splice).call.apply(_a, tslib_1.__spreadArray([nodes, index, 1], node.children));
36 + }
37 + }
38 + // @ts-expect-error Types don't align here either.
39 + return parse5_1.serialize({ children: nodes }, { treeAdapter: parse5_htmlparser2_tree_adapter_1.default });
40 +}
41 +exports.render = render;
1 +import type { Cheerio } from './cheerio';
2 +import { Node, Document } from 'domhandler';
3 +import { CheerioOptions } from './options';
4 +/**
5 + * Renders the document.
6 + *
7 + * @param options - Options for the renderer.
8 + * @returns The rendered document.
9 + */
10 +export declare function html(this: typeof Cheerio | void, options?: CheerioOptions): string;
11 +/**
12 + * Renders the document.
13 + *
14 + * @param dom - Element to render.
15 + * @param options - Options for the renderer.
16 + * @returns The rendered document.
17 + */
18 +export declare function html(this: typeof Cheerio | void, dom?: string | ArrayLike<Node> | Node, options?: CheerioOptions): string;
19 +/**
20 + * Render the document as XML.
21 + *
22 + * @param dom - Element to render.
23 + * @returns THe rendered document.
24 + */
25 +export declare function xml(this: typeof Cheerio, dom?: string | ArrayLike<Node> | Node): string;
26 +/**
27 + * Render the document as text.
28 + *
29 + * @param elements - Elements to render.
30 + * @returns The rendered document.
31 + */
32 +export declare function text(this: typeof Cheerio | void, elements?: ArrayLike<Node>): string;
33 +/**
34 + * Parses a string into an array of DOM nodes. The `context` argument has no
35 + * meaning for Cheerio, but it is maintained for API compatibility with jQuery.
36 + *
37 + * @param data - Markup that will be parsed.
38 + * @param context - Will be ignored. If it is a boolean it will be used as the
39 + * value of `keepScripts`.
40 + * @param keepScripts - If false all scripts will be removed.
41 + * @returns The parsed DOM.
42 + * @alias Cheerio.parseHTML
43 + * @see {@link https://api.jquery.com/jQuery.parseHTML/}
44 + */
45 +export declare function parseHTML(this: typeof Cheerio, data: string, context?: unknown | boolean, keepScripts?: boolean): Node[];
46 +export declare function parseHTML(this: typeof Cheerio, data?: '' | null): null;
47 +/**
48 + * Sometimes you need to work with the top-level root element. To query it, you
49 + * can use `$.root()`.
50 + *
51 + * @example
52 + *
53 + * ```js
54 + * $.root().append('<ul id="vegetables"></ul>').html();
55 + * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
56 + * ```
57 + *
58 + * @returns Cheerio instance wrapping the root node.
59 + * @alias Cheerio.root
60 + */
61 +export declare function root(this: typeof Cheerio): Cheerio<Document>;
62 +/**
63 + * Checks to see if the `contained` DOM element is a descendant of the
64 + * `container` DOM element.
65 + *
66 + * @param container - Potential parent node.
67 + * @param contained - Potential child node.
68 + * @returns Indicates if the nodes contain one another.
69 + * @alias Cheerio.contains
70 + * @see {@link https://api.jquery.com/jQuery.contains/}
71 + */
72 +export declare function contains(container: Node, contained: Node): boolean;
73 +interface WritableArrayLike<T> extends ArrayLike<T> {
74 + length: number;
75 + [n: number]: T;
76 +}
77 +/**
78 + * $.merge().
79 + *
80 + * @param arr1 - First array.
81 + * @param arr2 - Second array.
82 + * @returns `arr1`, with elements of `arr2` inserted.
83 + * @alias Cheerio.merge
84 + * @see {@link https://api.jquery.com/jQuery.merge/}
85 + */
86 +export declare function merge<T>(arr1: WritableArrayLike<T>, arr2: ArrayLike<T>): ArrayLike<T> | undefined;
87 +export {};
88 +//# sourceMappingURL=static.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEL,cAAc,EAGf,MAAM,WAAW,CAAC;AAoDnB;;;;;GAKG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,OAAO,OAAO,GAAG,IAAI,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAAC;AACV;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,OAAO,OAAO,GAAG,IAAI,EAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAAC;AAkCV;;;;;GAKG;AACH,wBAAgB,GAAG,CACjB,IAAI,EAAE,OAAO,OAAO,EACpB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,GACpC,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,OAAO,OAAO,GAAG,IAAI,EAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,GACzB,MAAM,CAmBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,OAAO,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAC3B,WAAW,CAAC,EAAE,OAAO,GACpB,IAAI,EAAE,CAAC;AACV,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AA8BxE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,OAAO,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAG5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CAmBlE;AAED,UAAU,iBAAiB,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC1B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAY1B"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.merge = exports.contains = exports.root = exports.parseHTML = exports.text = exports.xml = exports.html = void 0;
4 +var tslib_1 = require("tslib");
5 +var options_1 = tslib_1.__importStar(require("./options"));
6 +var cheerio_select_1 = require("cheerio-select");
7 +var htmlparser2_1 = require("htmlparser2");
8 +var parse5_1 = require("./parsers/parse5");
9 +var htmlparser2_2 = require("./parsers/htmlparser2");
10 +/**
11 + * Helper function to render a DOM.
12 + *
13 + * @param that - Cheerio instance to render.
14 + * @param dom - The DOM to render. Defaults to `that`'s root.
15 + * @param options - Options for rendering.
16 + * @returns The rendered document.
17 + */
18 +function render(that, dom, options) {
19 + var _a, _b;
20 + if (!dom) {
21 + if ((_a = that === null || that === void 0 ? void 0 : that._root) === null || _a === void 0 ? void 0 : _a.children) {
22 + dom = that._root.children;
23 + }
24 + else {
25 + return '';
26 + }
27 + }
28 + else if (typeof dom === 'string') {
29 + dom = cheerio_select_1.select(dom, (_b = that === null || that === void 0 ? void 0 : that._root) !== null && _b !== void 0 ? _b : [], options);
30 + }
31 + return options.xmlMode || options._useHtmlParser2
32 + ? // FIXME: Pull in new version of dom-serializer to fix this.
33 + htmlparser2_2.render(dom, options)
34 + : parse5_1.render(dom);
35 +}
36 +/**
37 + * Checks if a passed object is an options object.
38 + *
39 + * @param dom - Object to check if it is an options object.
40 + * @returns Whether the object is an options object.
41 + */
42 +function isOptions(dom) {
43 + return (typeof dom === 'object' &&
44 + dom != null &&
45 + !('length' in dom) &&
46 + !('type' in dom));
47 +}
48 +function html(dom, options) {
49 + /*
50 + * Be flexible about parameters, sometimes we call html(),
51 + * with options as only parameter
52 + * check dom argument for dom element specific properties
53 + * assume there is no 'length' or 'type' properties in the options object
54 + */
55 + if (!options && isOptions(dom)) {
56 + options = dom;
57 + dom = undefined;
58 + }
59 + /*
60 + * Sometimes `$.html()` is used without preloading html,
61 + * so fallback non-existing options to the default ones.
62 + */
63 + options = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, options_1.default), (this ? this._options : {})), options_1.flatten(options !== null && options !== void 0 ? options : {}));
64 + return render(this || undefined, dom, options);
65 +}
66 +exports.html = html;
67 +/**
68 + * Render the document as XML.
69 + *
70 + * @param dom - Element to render.
71 + * @returns THe rendered document.
72 + */
73 +function xml(dom) {
74 + var options = tslib_1.__assign(tslib_1.__assign({}, this._options), { xmlMode: true });
75 + return render(this, dom, options);
76 +}
77 +exports.xml = xml;
78 +/**
79 + * Render the document as text.
80 + *
81 + * @param elements - Elements to render.
82 + * @returns The rendered document.
83 + */
84 +function text(elements) {
85 + var elems = elements ? elements : this ? this.root() : [];
86 + var ret = '';
87 + for (var i = 0; i < elems.length; i++) {
88 + var elem = elems[i];
89 + if (htmlparser2_1.DomUtils.isText(elem))
90 + ret += elem.data;
91 + else if (htmlparser2_1.DomUtils.hasChildren(elem) &&
92 + elem.type !== htmlparser2_1.ElementType.Comment &&
93 + elem.type !== htmlparser2_1.ElementType.Script &&
94 + elem.type !== htmlparser2_1.ElementType.Style) {
95 + ret += text(elem.children);
96 + }
97 + }
98 + return ret;
99 +}
100 +exports.text = text;
101 +function parseHTML(data, context, keepScripts) {
102 + if (keepScripts === void 0) { keepScripts = typeof context === 'boolean' ? context : false; }
103 + if (!data || typeof data !== 'string') {
104 + return null;
105 + }
106 + if (typeof context === 'boolean') {
107 + keepScripts = context;
108 + }
109 + var parsed = this.load(data, options_1.default, false);
110 + if (!keepScripts) {
111 + parsed('script').remove();
112 + }
113 + /*
114 + * The `children` array is used by Cheerio internally to group elements that
115 + * share the same parents. When nodes created through `parseHTML` are
116 + * inserted into previously-existing DOM structures, they will be removed
117 + * from the `children` array. The results of `parseHTML` should remain
118 + * constant across these operations, so a shallow copy should be returned.
119 + */
120 + return parsed.root()[0].children.slice();
121 +}
122 +exports.parseHTML = parseHTML;
123 +/**
124 + * Sometimes you need to work with the top-level root element. To query it, you
125 + * can use `$.root()`.
126 + *
127 + * @example
128 + *
129 + * ```js
130 + * $.root().append('<ul id="vegetables"></ul>').html();
131 + * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
132 + * ```
133 + *
134 + * @returns Cheerio instance wrapping the root node.
135 + * @alias Cheerio.root
136 + */
137 +function root() {
138 + var fn = this;
139 + return fn(this._root);
140 +}
141 +exports.root = root;
142 +/**
143 + * Checks to see if the `contained` DOM element is a descendant of the
144 + * `container` DOM element.
145 + *
146 + * @param container - Potential parent node.
147 + * @param contained - Potential child node.
148 + * @returns Indicates if the nodes contain one another.
149 + * @alias Cheerio.contains
150 + * @see {@link https://api.jquery.com/jQuery.contains/}
151 + */
152 +function contains(container, contained) {
153 + // According to the jQuery API, an element does not "contain" itself
154 + if (contained === container) {
155 + return false;
156 + }
157 + /*
158 + * Step up the descendants, stopping when the root element is reached
159 + * (signaled by `.parent` returning a reference to the same object)
160 + */
161 + var next = contained;
162 + while (next && next !== next.parent) {
163 + next = next.parent;
164 + if (next === container) {
165 + return true;
166 + }
167 + }
168 + return false;
169 +}
170 +exports.contains = contains;
171 +/**
172 + * $.merge().
173 + *
174 + * @param arr1 - First array.
175 + * @param arr2 - Second array.
176 + * @returns `arr1`, with elements of `arr2` inserted.
177 + * @alias Cheerio.merge
178 + * @see {@link https://api.jquery.com/jQuery.merge/}
179 + */
180 +function merge(arr1, arr2) {
181 + if (!isArrayLike(arr1) || !isArrayLike(arr2)) {
182 + return;
183 + }
184 + var newLength = arr1.length;
185 + var len = +arr2.length;
186 + for (var i = 0; i < len; i++) {
187 + arr1[newLength++] = arr2[i];
188 + }
189 + arr1.length = newLength;
190 + return arr1;
191 +}
192 +exports.merge = merge;
193 +/**
194 + * @param item - Item to check.
195 + * @returns Indicates if the item is array-like.
196 + */
197 +function isArrayLike(item) {
198 + if (Array.isArray(item)) {
199 + return true;
200 + }
201 + if (typeof item !== 'object' ||
202 + !Object.prototype.hasOwnProperty.call(item, 'length') ||
203 + typeof item.length !== 'number' ||
204 + item.length < 0) {
205 + return false;
206 + }
207 + for (var i = 0; i < item.length; i++) {
208 + if (!(i in item)) {
209 + return false;
210 + }
211 + }
212 + return true;
213 +}
1 +declare type LowercaseLetters = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
2 +declare type AlphaNumeric = LowercaseLetters | Uppercase<LowercaseLetters> | `${number}`;
3 +declare type SelectorSpecial = '.' | '#' | ':' | '|' | '>' | '+' | '~' | '[';
4 +/**
5 + * Type for identifying selectors. Allows us to "upgrade" queries using
6 + * selectors to return `Element`s.
7 + */
8 +export declare type SelectorType = `${SelectorSpecial}${AlphaNumeric}${string}` | `${AlphaNumeric}${string}`;
9 +import type { Cheerio } from './cheerio';
10 +import type { Node, Element } from 'domhandler';
11 +/** Elements that can be passed to manipulation methods. */
12 +export declare type BasicAcceptedElems<T extends Node> = Cheerio<T> | T[] | T | string;
13 +/** Elements that can be passed to manipulation methods, including functions. */
14 +export declare type AcceptedElems<T extends Node> = BasicAcceptedElems<T> | ((this: T, i: number, el: T) => BasicAcceptedElems<T>);
15 +/** Function signature, for traversal methods. */
16 +export declare type FilterFunction<T> = (this: T, i: number, el: T) => boolean;
17 +/** Supported filter types, for traversal methods. */
18 +export declare type AcceptedFilters = string | FilterFunction<Element> | Node | Cheerio<Node>;
19 +export {};
20 +//# sourceMappingURL=types.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,gBAAgB,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER,aAAK,YAAY,GACb,gBAAgB,GAChB,SAAS,CAAC,gBAAgB,CAAC,GAC3B,GAAG,MAAM,EAAE,CAAC;AAEhB,aAAK,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACrE;;;GAGG;AACH,oBAAY,YAAY,GACpB,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,EAAE,GAC5C,GAAG,YAAY,GAAG,MAAM,EAAE,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhD,2DAA2D;AAC3D,oBAAY,kBAAkB,CAAC,CAAC,SAAS,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAC/E,gFAAgF;AAChF,oBAAY,aAAa,CAAC,CAAC,SAAS,IAAI,IACpC,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,iDAAiD;AACjD,oBAAY,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;AACvE,qDAAqD;AACrD,oBAAY,eAAe,GACvB,MAAM,GACN,cAAc,CAAC,OAAO,CAAC,GACvB,IAAI,GACJ,OAAO,CAAC,IAAI,CAAC,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
1 +import { DomUtils } from 'htmlparser2';
2 +import { Node } from 'domhandler';
3 +import type { Cheerio } from './cheerio';
4 +/**
5 + * Check if the DOM element is a tag.
6 + *
7 + * `isTag(type)` includes `<script>` and `<style>` tags.
8 + *
9 + * @private
10 + * @category Utils
11 + * @param type - DOM node to check.
12 + * @returns Whether the node is a tag.
13 + */
14 +export declare const isTag: typeof DomUtils.isTag;
15 +/**
16 + * Checks if an object is a Cheerio instance.
17 + *
18 + * @category Utils
19 + * @param maybeCheerio - The object to check.
20 + * @returns Whether the object is a Cheerio instance.
21 + */
22 +export declare function isCheerio<T>(maybeCheerio: any): maybeCheerio is Cheerio<T>;
23 +/**
24 + * Convert a string to camel case notation.
25 + *
26 + * @private
27 + * @category Utils
28 + * @param str - String to be converted.
29 + * @returns String in camel case notation.
30 + */
31 +export declare function camelCase(str: string): string;
32 +/**
33 + * Convert a string from camel case to "CSS case", where word boundaries are
34 + * described by hyphens ("-") and all characters are lower-case.
35 + *
36 + * @private
37 + * @category Utils
38 + * @param str - String to be converted.
39 + * @returns String in "CSS case".
40 + */
41 +export declare function cssCase(str: string): string;
42 +/**
43 + * Iterate over each DOM element without creating intermediary Cheerio instances.
44 + *
45 + * This is indented for use internally to avoid otherwise unnecessary memory
46 + * pressure introduced by _make.
47 + *
48 + * @category Utils
49 + * @param array - Array to iterate over.
50 + * @param fn - Function to call.
51 + * @returns The original instance.
52 + */
53 +export declare function domEach<T extends Node, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (index: number, elem: T) => void | false): Arr;
54 +/**
55 + * Create a deep copy of the given DOM structure. Sets the parents of the copies
56 + * of the passed nodes to `null`.
57 + *
58 + * @private
59 + * @category Utils
60 + * @param dom - The htmlparser2-compliant DOM structure.
61 + * @returns - The cloned DOM.
62 + */
63 +export declare function cloneDom<T extends Node>(dom: T | T[]): T[];
64 +/**
65 + * Check if string is HTML.
66 + *
67 + * @private
68 + * @category Utils
69 + * @param str - String to check.
70 + * @returns Indicates if `str` is HTML.
71 + */
72 +export declare function isHtml(str: string): boolean;
73 +//# sourceMappingURL=utils.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAuB,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAQ,KAAK,uBAAa,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,GAAG,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC3E,KAAK,EAAE,GAAG,EACV,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,GAC3C,GAAG,CAIL;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAa1D;AAUD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG3C"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.isHtml = exports.cloneDom = exports.domEach = exports.cssCase = exports.camelCase = exports.isCheerio = exports.isTag = void 0;
4 +var htmlparser2_1 = require("htmlparser2");
5 +var domhandler_1 = require("domhandler");
6 +/**
7 + * Check if the DOM element is a tag.
8 + *
9 + * `isTag(type)` includes `<script>` and `<style>` tags.
10 + *
11 + * @private
12 + * @category Utils
13 + * @param type - DOM node to check.
14 + * @returns Whether the node is a tag.
15 + */
16 +exports.isTag = htmlparser2_1.DomUtils.isTag;
17 +/**
18 + * Checks if an object is a Cheerio instance.
19 + *
20 + * @category Utils
21 + * @param maybeCheerio - The object to check.
22 + * @returns Whether the object is a Cheerio instance.
23 + */
24 +function isCheerio(maybeCheerio) {
25 + return maybeCheerio.cheerio != null;
26 +}
27 +exports.isCheerio = isCheerio;
28 +/**
29 + * Convert a string to camel case notation.
30 + *
31 + * @private
32 + * @category Utils
33 + * @param str - String to be converted.
34 + * @returns String in camel case notation.
35 + */
36 +function camelCase(str) {
37 + return str.replace(/[_.-](\w|$)/g, function (_, x) { return x.toUpperCase(); });
38 +}
39 +exports.camelCase = camelCase;
40 +/**
41 + * Convert a string from camel case to "CSS case", where word boundaries are
42 + * described by hyphens ("-") and all characters are lower-case.
43 + *
44 + * @private
45 + * @category Utils
46 + * @param str - String to be converted.
47 + * @returns String in "CSS case".
48 + */
49 +function cssCase(str) {
50 + return str.replace(/[A-Z]/g, '-$&').toLowerCase();
51 +}
52 +exports.cssCase = cssCase;
53 +/**
54 + * Iterate over each DOM element without creating intermediary Cheerio instances.
55 + *
56 + * This is indented for use internally to avoid otherwise unnecessary memory
57 + * pressure introduced by _make.
58 + *
59 + * @category Utils
60 + * @param array - Array to iterate over.
61 + * @param fn - Function to call.
62 + * @returns The original instance.
63 + */
64 +function domEach(array, fn) {
65 + var len = array.length;
66 + for (var i = 0; i < len && fn(i, array[i]) !== false; i++)
67 + ;
68 + return array;
69 +}
70 +exports.domEach = domEach;
71 +/**
72 + * Create a deep copy of the given DOM structure. Sets the parents of the copies
73 + * of the passed nodes to `null`.
74 + *
75 + * @private
76 + * @category Utils
77 + * @param dom - The htmlparser2-compliant DOM structure.
78 + * @returns - The cloned DOM.
79 + */
80 +function cloneDom(dom) {
81 + var clone = 'length' in dom
82 + ? Array.prototype.map.call(dom, function (el) { return domhandler_1.cloneNode(el, true); })
83 + : [domhandler_1.cloneNode(dom, true)];
84 + // Add a root node around the cloned nodes
85 + var root = new domhandler_1.Document(clone);
86 + clone.forEach(function (node) {
87 + node.parent = root;
88 + });
89 + return clone;
90 +}
91 +exports.cloneDom = cloneDom;
92 +/**
93 + * A simple way to check for HTML strings. Tests for a `<` within a string,
94 + * immediate followed by a letter and eventually followed by a `>`.
95 + *
96 + * @private
97 + */
98 +var quickExpr = /<[a-zA-Z][^]*>/;
99 +/**
100 + * Check if string is HTML.
101 + *
102 + * @private
103 + * @category Utils
104 + * @param str - String to check.
105 + * @returns Indicates if `str` is HTML.
106 + */
107 +function isHtml(str) {
108 + // Run the regex
109 + return quickExpr.test(str);
110 +}
111 +exports.isHtml = isHtml;
1 +{
2 + "name": "cheerio",
3 + "version": "1.0.0-rc.9",
4 + "description": "Tiny, fast, and elegant implementation of core jQuery designed specifically for the server",
5 + "author": "Matt Mueller <mattmuelle@gmail.com> (mat.io)",
6 + "funding": "https://github.com/cheeriojs/cheerio?sponsor=1",
7 + "license": "MIT",
8 + "keywords": [
9 + "htmlparser",
10 + "jquery",
11 + "selector",
12 + "scraper",
13 + "parser",
14 + "html"
15 + ],
16 + "repository": {
17 + "type": "git",
18 + "url": "git://github.com/cheeriojs/cheerio.git"
19 + },
20 + "bugs": {
21 + "url": "https://github.com/cheeriojs/cheerio/issues"
22 + },
23 + "homepage": "https://cheerio.js.org/",
24 + "main": "lib/index.js",
25 + "types": "lib/index.d.ts",
26 + "files": [
27 + "lib"
28 + ],
29 + "engines": {
30 + "node": ">= 6"
31 + },
32 + "dependencies": {
33 + "cheerio-select": "^1.4.0",
34 + "dom-serializer": "^1.3.1",
35 + "domhandler": "^4.2.0",
36 + "htmlparser2": "^6.1.0",
37 + "parse5": "^6.0.1",
38 + "parse5-htmlparser2-tree-adapter": "^6.0.1",
39 + "tslib": "^2.2.0"
40 + },
41 + "devDependencies": {
42 + "@octokit/graphql": "^4.6.1",
43 + "@types/benchmark": "^2.1.0",
44 + "@types/jest": "^26.0.23",
45 + "@types/jsdom": "^16.2.10",
46 + "@types/node": "^15.0.2",
47 + "@types/node-fetch": "^2.5.10",
48 + "@types/parse5": "^6.0.0",
49 + "@types/parse5-htmlparser2-tree-adapter": "^6.0.0",
50 + "@typescript-eslint/eslint-plugin": "^4.22.1",
51 + "@typescript-eslint/parser": "^4.22.1",
52 + "benchmark": "^2.1.4",
53 + "eslint": "^7.25.0",
54 + "eslint-config-prettier": "^8.3.0",
55 + "eslint-plugin-jest": "^24.3.6",
56 + "eslint-plugin-jsdoc": "^33.1.0",
57 + "eslint-plugin-node": "^11.1.0",
58 + "husky": "^4.3.8",
59 + "jest": "^26.6.3",
60 + "jquery": "^3.6.0",
61 + "jsdom": "^16.5.3",
62 + "lint-staged": "^10.5.4",
63 + "node-fetch": "^2.6.1",
64 + "prettier": "^2.2.1",
65 + "prettier-plugin-jsdoc": "0.3.22",
66 + "ts-jest": "^26.5.6",
67 + "ts-node": "^9.1.1",
68 + "typedoc": "^0.20.36",
69 + "typescript": "^4.2.4"
70 + },
71 + "scripts": {
72 + "test": "npm run lint && npm run test:jest",
73 + "test:jest": "jest",
74 + "test:jest:cov": "npm run test:jest -- --coverage",
75 + "lint": "npm run lint:es && npm run lint:prettier",
76 + "lint:es": "eslint --ignore-path .gitignore .",
77 + "lint:prettier": "npm run format:prettier:raw -- --check",
78 + "format": "npm run format:es && npm run format:prettier",
79 + "format:es": "npm run lint:es -- --fix",
80 + "format:prettier": "npm run format:prettier:raw -- --write",
81 + "format:prettier:raw": "prettier \"**/*.{js,ts,md,json,yml}\" --ignore-path .gitignore",
82 + "build:docs": "typedoc --hideGenerator src/index.ts",
83 + "benchmark": "ts-node benchmark/benchmark.ts --regex \"^(?!.*highmem)\"",
84 + "update-sponsors": "ts-node scripts/fetch-sponsors.ts",
85 + "bench": "npm run benchmark",
86 + "pre-commit": "lint-staged",
87 + "build": "tsc",
88 + "prepublishOnly": "npm run build"
89 + },
90 + "prettier": {
91 + "singleQuote": true,
92 + "tabWidth": 2,
93 + "tsdoc": true
94 + },
95 + "lint-staged": {
96 + "*.js": [
97 + "prettier --write",
98 + "npm run test:lint -- --fix"
99 + ],
100 + "*.{json,md,ts,yml}": [
101 + "prettier --write"
102 + ]
103 + },
104 + "jest": {
105 + "preset": "ts-jest",
106 + "testEnvironment": "node",
107 + "testPathIgnorePatterns": [
108 + "/__fixtures__/"
109 + ]
110 + }
111 +}
1 +Copyright © Jorge Bucaran <<https://jorgebucaran.com>>
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 +
5 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 +
7 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# Colorette
2 +
3 +> Easily set the color and style of text in the terminal.
4 +
5 +- No wonky prototype method-chain API.
6 +- Automatic color support detection.
7 +- Up to [2x faster](#benchmarks) than alternatives.
8 +- [`NO_COLOR`](https://no-color.org) friendly. 👌
9 +
10 +Here's the first example to get you started.
11 +
12 +```js
13 +import { blue, bold, underline } from "colorette"
14 +
15 +console.log(
16 + blue("I'm blue"),
17 + bold(blue("da ba dee")),
18 + underline(bold(blue("da ba daa")))
19 +)
20 +```
21 +
22 +Here's an example using [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).
23 +
24 +```js
25 +console.log(`
26 + There's a ${underline(blue("house"))},
27 + With a ${bold(blue("window"))},
28 + And a ${blue("corvette")}
29 + And everything is blue
30 +`)
31 +```
32 +
33 +Of course, you can nest styles without breaking existing color sequences.
34 +
35 +```js
36 +console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`))
37 +```
38 +
39 +Feeling adventurous? Try the [pipeline operator](https://github.com/tc39/proposal-pipeline-operator).
40 +
41 +```js
42 +console.log("Da ba dee da ba daa" |> blue |> bold)
43 +```
44 +
45 +## Installation
46 +
47 +```console
48 +npm install colorette
49 +```
50 +
51 +## API
52 +
53 +### `<style>(string)`
54 +
55 +```js
56 +import { blue } from "colorette"
57 +
58 +blue("I'm blue") //=> \x1b[34mI'm blue\x1b[39m
59 +```
60 +
61 +See [supported styles]().
62 +
63 +### `options.enabled`
64 +
65 +Colorette automatically detects if your terminal can display color, but you can toggle color as needed.
66 +
67 +```js
68 +import { options } from "colorette"
69 +
70 +options.enabled = false
71 +```
72 +
73 +You can also force the use of color globally by setting `FORCE_COLOR=` or `NO_COLOR=` from the CLI.
74 +
75 +```console
76 +$ FORCE_COLOR= node example.js >log
77 +$ NO_COLOR= node example.js
78 +```
79 +
80 +## Supported styles
81 +
82 +| Colors | Background Colors | Bright Colors | Bright Background Colors | Modifiers |
83 +| ------- | ----------------- | ------------- | ------------------------ | ----------------- |
84 +| black | bgBlack | blackBright | bgBlackBright | dim |
85 +| red | bgRed | redBright | bgRedBright | **bold** |
86 +| green | bgGreen | greenBright | bgGreenBright | hidden |
87 +| yellow | bgYellow | yellowBright | bgYellowBright | _italic_ |
88 +| blue | bgBlue | blueBright | bgBlueBright | <u>underline</u> |
89 +| magenta | bgMagenta | magentaBright | bgMagentaBright | ~~strikethrough~~ |
90 +| cyan | bgCyan | cyanBright | bgCyanBright | reset |
91 +| white | bgWhite | whiteBright | bgWhiteBright | |
92 +| gray | | | | |
93 +
94 +## Benchmarks
95 +
96 +```console
97 +npm --prefix bench start
98 +```
99 +
100 +## License
101 +
102 +[MIT](LICENSE.md)
1 +let enabled =
2 + !("NO_COLOR" in process.env) &&
3 + ("FORCE_COLOR" in process.env ||
4 + process.platform === "win32" ||
5 + (process.stdout != null &&
6 + process.stdout.isTTY &&
7 + process.env.TERM &&
8 + process.env.TERM !== "dumb"))
9 +
10 +const raw = (open, close, searchRegex, replaceValue) => (s) =>
11 + enabled
12 + ? open +
13 + (~(s += "").indexOf(close, 4) // skip opening \x1b[
14 + ? s.replace(searchRegex, replaceValue)
15 + : s) +
16 + close
17 + : s
18 +
19 +const init = (open, close) => {
20 + return raw(
21 + `\x1b[${open}m`,
22 + `\x1b[${close}m`,
23 + new RegExp(`\\x1b\\[${close}m`, "g"),
24 + `\x1b[${open}m`
25 + )
26 +}
27 +
28 +exports.options = Object.defineProperty({}, "enabled", {
29 + get: () => enabled,
30 + set: (value) => (enabled = value),
31 +})
32 +
33 +exports.reset = init(0, 0)
34 +exports.bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m")
35 +exports.dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m")
36 +exports.italic = init(3, 23)
37 +exports.underline = init(4, 24)
38 +exports.inverse = init(7, 27)
39 +exports.hidden = init(8, 28)
40 +exports.strikethrough = init(9, 29)
41 +exports.black = init(30, 39)
42 +exports.red = init(31, 39)
43 +exports.green = init(32, 39)
44 +exports.yellow = init(33, 39)
45 +exports.blue = init(34, 39)
46 +exports.magenta = init(35, 39)
47 +exports.cyan = init(36, 39)
48 +exports.white = init(37, 39)
49 +exports.gray = init(90, 39)
50 +exports.bgBlack = init(40, 49)
51 +exports.bgRed = init(41, 49)
52 +exports.bgGreen = init(42, 49)
53 +exports.bgYellow = init(43, 49)
54 +exports.bgBlue = init(44, 49)
55 +exports.bgMagenta = init(45, 49)
56 +exports.bgCyan = init(46, 49)
57 +exports.bgWhite = init(47, 49)
58 +exports.blackBright = init(90, 39)
59 +exports.redBright = init(91, 39)
60 +exports.greenBright = init(92, 39)
61 +exports.yellowBright = init(93, 39)
62 +exports.blueBright = init(94, 39)
63 +exports.magentaBright = init(95, 39)
64 +exports.cyanBright = init(96, 39)
65 +exports.whiteBright = init(97, 39)
66 +exports.bgBlackBright = init(100, 49)
67 +exports.bgRedBright = init(101, 49)
68 +exports.bgGreenBright = init(102, 49)
69 +exports.bgYellowBright = init(103, 49)
70 +exports.bgBlueBright = init(104, 49)
71 +exports.bgMagentaBright = init(105, 49)
72 +exports.bgCyanBright = init(106, 49)
73 +exports.bgWhiteBright = init(107, 49)
1 +interface Style {
2 + (string: string): string
3 +}
4 +
5 +export const options: {
6 + enabled: boolean
7 +}
8 +
9 +export const reset: Style
10 +export const bold: Style
11 +export const dim: Style
12 +export const italic: Style
13 +export const underline: Style
14 +export const inverse: Style
15 +export const hidden: Style
16 +export const strikethrough: Style
17 +export const black: Style
18 +export const red: Style
19 +export const green: Style
20 +export const yellow: Style
21 +export const blue: Style
22 +export const magenta: Style
23 +export const cyan: Style
24 +export const white: Style
25 +export const gray: Style
26 +export const bgBlack: Style
27 +export const bgRed: Style
28 +export const bgGreen: Style
29 +export const bgYellow: Style
30 +export const bgBlue: Style
31 +export const bgMagenta: Style
32 +export const bgCyan: Style
33 +export const bgWhite: Style
34 +export const blackBright: Style
35 +export const redBright: Style
36 +export const greenBright: Style
37 +export const yellowBright: Style
38 +export const blueBright: Style
39 +export const magentaBright: Style
40 +export const cyanBright: Style
41 +export const whiteBright: Style
42 +export const bgBlackBright: Style
43 +export const bgRedBright: Style
44 +export const bgGreenBright: Style
45 +export const bgYellowBright: Style
46 +export const bgBlueBright: Style
47 +export const bgMagentaBright: Style
48 +export const bgCyanBright: Style
49 +export const bgWhiteBright: Style
1 +let enabled =
2 + !("NO_COLOR" in process.env) &&
3 + ("FORCE_COLOR" in process.env ||
4 + process.platform === "win32" ||
5 + (process.stdout != null &&
6 + process.stdout.isTTY &&
7 + process.env.TERM &&
8 + process.env.TERM !== "dumb"))
9 +
10 +const raw = (open, close, searchRegex, replaceValue) => (s) =>
11 + enabled
12 + ? open +
13 + (~(s += "").indexOf(close, 4) // skip opening \x1b[
14 + ? s.replace(searchRegex, replaceValue)
15 + : s) +
16 + close
17 + : s
18 +
19 +const init = (open, close) => {
20 + return raw(
21 + `\x1b[${open}m`,
22 + `\x1b[${close}m`,
23 + new RegExp(`\\x1b\\[${close}m`, "g"),
24 + `\x1b[${open}m`
25 + )
26 +}
27 +
28 +export const options = Object.defineProperty({}, "enabled", {
29 + get: () => enabled,
30 + set: (value) => (enabled = value),
31 +})
32 +
33 +export const reset = init(0, 0)
34 +export const bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m")
35 +export const dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m")
36 +export const italic = init(3, 23)
37 +export const underline = init(4, 24)
38 +export const inverse = init(7, 27)
39 +export const hidden = init(8, 28)
40 +export const strikethrough = init(9, 29)
41 +export const black = init(30, 39)
42 +export const red = init(31, 39)
43 +export const green = init(32, 39)
44 +export const yellow = init(33, 39)
45 +export const blue = init(34, 39)
46 +export const magenta = init(35, 39)
47 +export const cyan = init(36, 39)
48 +export const white = init(37, 39)
49 +export const gray = init(90, 39)
50 +export const bgBlack = init(40, 49)
51 +export const bgRed = init(41, 49)
52 +export const bgGreen = init(42, 49)
53 +export const bgYellow = init(43, 49)
54 +export const bgBlue = init(44, 49)
55 +export const bgMagenta = init(45, 49)
56 +export const bgCyan = init(46, 49)
57 +export const bgWhite = init(47, 49)
58 +export const blackBright = init(90, 39)
59 +export const redBright = init(91, 39)
60 +export const greenBright = init(92, 39)
61 +export const yellowBright = init(93, 39)
62 +export const blueBright = init(94, 39)
63 +export const magentaBright = init(95, 39)
64 +export const cyanBright = init(96, 39)
65 +export const whiteBright = init(97, 39)
66 +export const bgBlackBright = init(100, 49)
67 +export const bgRedBright = init(101, 49)
68 +export const bgGreenBright = init(102, 49)
69 +export const bgYellowBright = init(103, 49)
70 +export const bgBlueBright = init(104, 49)
71 +export const bgMagentaBright = init(105, 49)
72 +export const bgCyanBright = init(106, 49)
73 +export const bgWhiteBright = init(107, 49)
1 +{
2 + "name": "colorette",
3 + "version": "1.2.2",
4 + "type": "module",
5 + "main": "index.cjs",
6 + "module": "index.js",
7 + "types": "index.d.ts",
8 + "description": "Easily set the color and style of text in the terminal.",
9 + "repository": "jorgebucaran/colorette",
10 + "license": "MIT",
11 + "exports": {
12 + "./package.json": "./package.json",
13 + ".": {
14 + "require": "./index.cjs",
15 + "import": "./index.js"
16 + }
17 + },
18 + "files": [
19 + "*.*(c)[tj]s*"
20 + ],
21 + "author": "Jorge Bucaran",
22 + "keywords": [
23 + "terminal",
24 + "styles",
25 + "color",
26 + "ansi"
27 + ],
28 + "scripts": {
29 + "test": "c8 twist tests/*.js",
30 + "build": "node -e \"fs.writeFileSync('index.cjs',fs.readFileSync('index.js','utf8').replace(/export const /g,'exports.'),'utf8')\"",
31 + "deploy": "npm test && git commit --all --message $tag && git tag --sign $tag --message $tag && git push && git push --tags",
32 + "release": "tag=$npm_package_version npm run deploy && npm publish --access public",
33 + "prepare": "npm run build"
34 + },
35 + "devDependencies": {
36 + "c8": "*",
37 + "twist": "*"
38 + }
39 +}
1 +Copyright (c) Felix Böhm
2 +All rights reserved.
3 +
4 +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 +
6 +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 +
8 +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 +
10 +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
11 +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed. Click to expand it.
1 +import { CompiledQuery, InternalOptions } from "./types";
2 +import type { AttributeSelector, AttributeAction } from "css-what";
3 +/**
4 + * Attribute selectors
5 + */
6 +export declare const attributeRules: Record<AttributeAction, <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, data: AttributeSelector, options: InternalOptions<Node, ElementNode>) => CompiledQuery<ElementNode>>;
7 +//# sourceMappingURL=attributes.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAanE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAC/B,eAAe,EACf,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC3B,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,KAC1C,aAAa,CAAC,WAAW,CAAC,CA8KlC,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.attributeRules = void 0;
4 +var boolbase_1 = require("boolbase");
5 +/**
6 + * All reserved characters in a regex, used for escaping.
7 + *
8 + * Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
9 + * https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
10 + */
11 +var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
12 +function escapeRegex(value) {
13 + return value.replace(reChars, "\\$&");
14 +}
15 +/**
16 + * Attribute selectors
17 + */
18 +exports.attributeRules = {
19 + equals: function (next, data, _a) {
20 + var adapter = _a.adapter;
21 + var name = data.name;
22 + var value = data.value;
23 + if (data.ignoreCase) {
24 + value = value.toLowerCase();
25 + return function (elem) {
26 + var attr = adapter.getAttributeValue(elem, name);
27 + return (attr != null &&
28 + attr.length === value.length &&
29 + attr.toLowerCase() === value &&
30 + next(elem));
31 + };
32 + }
33 + return function (elem) {
34 + return adapter.getAttributeValue(elem, name) === value && next(elem);
35 + };
36 + },
37 + hyphen: function (next, data, _a) {
38 + var adapter = _a.adapter;
39 + var name = data.name;
40 + var value = data.value;
41 + var len = value.length;
42 + if (data.ignoreCase) {
43 + value = value.toLowerCase();
44 + return function hyphenIC(elem) {
45 + var attr = adapter.getAttributeValue(elem, name);
46 + return (attr != null &&
47 + (attr.length === len || attr.charAt(len) === "-") &&
48 + attr.substr(0, len).toLowerCase() === value &&
49 + next(elem));
50 + };
51 + }
52 + return function hyphen(elem) {
53 + var attr = adapter.getAttributeValue(elem, name);
54 + return (attr != null &&
55 + (attr.length === len || attr.charAt(len) === "-") &&
56 + attr.substr(0, len) === value &&
57 + next(elem));
58 + };
59 + },
60 + element: function (next, _a, _b) {
61 + var name = _a.name, value = _a.value, ignoreCase = _a.ignoreCase;
62 + var adapter = _b.adapter;
63 + if (/\s/.test(value)) {
64 + return boolbase_1.falseFunc;
65 + }
66 + var regex = new RegExp("(?:^|\\s)" + escapeRegex(value) + "(?:$|\\s)", ignoreCase ? "i" : "");
67 + return function element(elem) {
68 + var attr = adapter.getAttributeValue(elem, name);
69 + return (attr != null &&
70 + attr.length >= value.length &&
71 + regex.test(attr) &&
72 + next(elem));
73 + };
74 + },
75 + exists: function (next, _a, _b) {
76 + var name = _a.name;
77 + var adapter = _b.adapter;
78 + return function (elem) { return adapter.hasAttrib(elem, name) && next(elem); };
79 + },
80 + start: function (next, data, _a) {
81 + var adapter = _a.adapter;
82 + var name = data.name;
83 + var value = data.value;
84 + var len = value.length;
85 + if (len === 0) {
86 + return boolbase_1.falseFunc;
87 + }
88 + if (data.ignoreCase) {
89 + value = value.toLowerCase();
90 + return function (elem) {
91 + var attr = adapter.getAttributeValue(elem, name);
92 + return (attr != null &&
93 + attr.length >= len &&
94 + attr.substr(0, len).toLowerCase() === value &&
95 + next(elem));
96 + };
97 + }
98 + return function (elem) {
99 + var _a;
100 + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
101 + next(elem);
102 + };
103 + },
104 + end: function (next, data, _a) {
105 + var adapter = _a.adapter;
106 + var name = data.name;
107 + var value = data.value;
108 + var len = -value.length;
109 + if (len === 0) {
110 + return boolbase_1.falseFunc;
111 + }
112 + if (data.ignoreCase) {
113 + value = value.toLowerCase();
114 + return function (elem) {
115 + var _a;
116 + return ((_a = adapter
117 + .getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
118 + };
119 + }
120 + return function (elem) {
121 + var _a;
122 + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
123 + next(elem);
124 + };
125 + },
126 + any: function (next, data, _a) {
127 + var adapter = _a.adapter;
128 + var name = data.name, value = data.value;
129 + if (value === "") {
130 + return boolbase_1.falseFunc;
131 + }
132 + if (data.ignoreCase) {
133 + var regex_1 = new RegExp(escapeRegex(value), "i");
134 + return function anyIC(elem) {
135 + var attr = adapter.getAttributeValue(elem, name);
136 + return (attr != null &&
137 + attr.length >= value.length &&
138 + regex_1.test(attr) &&
139 + next(elem));
140 + };
141 + }
142 + return function (elem) {
143 + var _a;
144 + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
145 + next(elem);
146 + };
147 + },
148 + not: function (next, data, _a) {
149 + var adapter = _a.adapter;
150 + var name = data.name;
151 + var value = data.value;
152 + if (value === "") {
153 + return function (elem) {
154 + return !!adapter.getAttributeValue(elem, name) && next(elem);
155 + };
156 + }
157 + else if (data.ignoreCase) {
158 + value = value.toLowerCase();
159 + return function (elem) {
160 + var attr = adapter.getAttributeValue(elem, name);
161 + return ((attr == null ||
162 + attr.length !== value.length ||
163 + attr.toLowerCase() !== value) &&
164 + next(elem));
165 + };
166 + }
167 + return function (elem) {
168 + return adapter.getAttributeValue(elem, name) !== value && next(elem);
169 + };
170 + },
171 +};
1 +import { InternalSelector } from "./types";
2 +import { Selector } from "css-what";
3 +import type { CompiledQuery, InternalOptions } from "./types";
4 +/**
5 + * Compiles a selector to an executable function.
6 + *
7 + * @param selector Selector to compile.
8 + * @param options Compilation options.
9 + * @param context Optional context for the selector.
10 + */
11 +export declare function compile<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
12 +export declare function compileUnsafe<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
13 +export declare function compileToken<Node, ElementNode extends Node>(token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
14 +//# sourceMappingURL=compile.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAS,QAAQ,EAAE,MAAM,UAAU,CAAC;AAS3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAClD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAG5B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACxD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAI5B;AA6CD,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CA2C5B"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +var __importDefault = (this && this.__importDefault) || function (mod) {
3 + return (mod && mod.__esModule) ? mod : { "default": mod };
4 +};
5 +Object.defineProperty(exports, "__esModule", { value: true });
6 +exports.compileToken = exports.compileUnsafe = exports.compile = void 0;
7 +var css_what_1 = require("css-what");
8 +var boolbase_1 = require("boolbase");
9 +var sort_1 = __importDefault(require("./sort"));
10 +var procedure_1 = require("./procedure");
11 +var general_1 = require("./general");
12 +var subselects_1 = require("./pseudo-selectors/subselects");
13 +/**
14 + * Compiles a selector to an executable function.
15 + *
16 + * @param selector Selector to compile.
17 + * @param options Compilation options.
18 + * @param context Optional context for the selector.
19 + */
20 +function compile(selector, options, context) {
21 + var next = compileUnsafe(selector, options, context);
22 + return subselects_1.ensureIsTag(next, options.adapter);
23 +}
24 +exports.compile = compile;
25 +function compileUnsafe(selector, options, context) {
26 + var token = typeof selector === "string" ? css_what_1.parse(selector, options) : selector;
27 + return compileToken(token, options, context);
28 +}
29 +exports.compileUnsafe = compileUnsafe;
30 +function includesScopePseudo(t) {
31 + return (t.type === "pseudo" &&
32 + (t.name === "scope" ||
33 + (Array.isArray(t.data) &&
34 + t.data.some(function (data) { return data.some(includesScopePseudo); }))));
35 +}
36 +var DESCENDANT_TOKEN = { type: "descendant" };
37 +var FLEXIBLE_DESCENDANT_TOKEN = {
38 + type: "_flexibleDescendant",
39 +};
40 +var SCOPE_TOKEN = { type: "pseudo", name: "scope", data: null };
41 +/*
42 + * CSS 4 Spec (Draft): 3.3.1. Absolutizing a Scope-relative Selector
43 + * http://www.w3.org/TR/selectors4/#absolutizing
44 + */
45 +function absolutize(token, _a, context) {
46 + var adapter = _a.adapter;
47 + // TODO Use better check if the context is a document
48 + var hasContext = !!(context === null || context === void 0 ? void 0 : context.every(function (e) {
49 + var parent = adapter.isTag(e) && adapter.getParent(e);
50 + return e === subselects_1.PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
51 + }));
52 + for (var _i = 0, token_1 = token; _i < token_1.length; _i++) {
53 + var t = token_1[_i];
54 + if (t.length > 0 && procedure_1.isTraversal(t[0]) && t[0].type !== "descendant") {
55 + // Don't continue in else branch
56 + }
57 + else if (hasContext && !t.some(includesScopePseudo)) {
58 + t.unshift(DESCENDANT_TOKEN);
59 + }
60 + else {
61 + continue;
62 + }
63 + t.unshift(SCOPE_TOKEN);
64 + }
65 +}
66 +function compileToken(token, options, context) {
67 + var _a;
68 + token = token.filter(function (t) { return t.length > 0; });
69 + token.forEach(sort_1.default);
70 + context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
71 + var isArrayContext = Array.isArray(context);
72 + var finalContext = context && (Array.isArray(context) ? context : [context]);
73 + absolutize(token, options, finalContext);
74 + var shouldTestNextSiblings = false;
75 + var query = token
76 + .map(function (rules) {
77 + if (rules.length >= 2) {
78 + var first = rules[0], second = rules[1];
79 + if (first.type !== "pseudo" || first.name !== "scope") {
80 + // Ignore
81 + }
82 + else if (isArrayContext && second.type === "descendant") {
83 + rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
84 + }
85 + else if (second.type === "adjacent" ||
86 + second.type === "sibling") {
87 + shouldTestNextSiblings = true;
88 + }
89 + }
90 + return compileRules(rules, options, finalContext);
91 + })
92 + .reduce(reduceRules, boolbase_1.falseFunc);
93 + query.shouldTestNextSiblings = shouldTestNextSiblings;
94 + return query;
95 +}
96 +exports.compileToken = compileToken;
97 +function compileRules(rules, options, context) {
98 + var _a;
99 + return rules.reduce(function (previous, rule) {
100 + return previous === boolbase_1.falseFunc
101 + ? boolbase_1.falseFunc
102 + : general_1.compileGeneralSelector(previous, rule, options, context, compileToken);
103 + }, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.trueFunc);
104 +}
105 +function reduceRules(a, b) {
106 + if (b === boolbase_1.falseFunc || a === boolbase_1.trueFunc) {
107 + return a;
108 + }
109 + if (a === boolbase_1.falseFunc || b === boolbase_1.trueFunc) {
110 + return b;
111 + }
112 + return function combine(elem) {
113 + return a(elem) || b(elem);
114 + };
115 +}
1 +import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types";
2 +export declare function compileGeneralSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: InternalSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
3 +//# sourceMappingURL=general.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../src/general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,SAAS,CAAC;AAMjB,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACjE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CAwH5B"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.compileGeneralSelector = void 0;
4 +var attributes_1 = require("./attributes");
5 +var pseudo_selectors_1 = require("./pseudo-selectors");
6 +/*
7 + * All available rules
8 + */
9 +function compileGeneralSelector(next, selector, options, context, compileToken) {
10 + var adapter = options.adapter, equals = options.equals;
11 + switch (selector.type) {
12 + case "pseudo-element":
13 + throw new Error("Pseudo-elements are not supported by css-select");
14 + case "attribute":
15 + return attributes_1.attributeRules[selector.action](next, selector, options);
16 + case "pseudo":
17 + return pseudo_selectors_1.compilePseudoSelector(next, selector, options, context, compileToken);
18 + // Tags
19 + case "tag":
20 + return function tag(elem) {
21 + return adapter.getName(elem) === selector.name && next(elem);
22 + };
23 + // Traversal
24 + case "descendant":
25 + if (options.cacheResults === false ||
26 + typeof WeakSet === "undefined") {
27 + return function descendant(elem) {
28 + var current = elem;
29 + while ((current = adapter.getParent(current))) {
30 + if (adapter.isTag(current) && next(current)) {
31 + return true;
32 + }
33 + }
34 + return false;
35 + };
36 + }
37 + // @ts-expect-error `ElementNode` is not extending object
38 + // eslint-disable-next-line no-case-declarations
39 + var isFalseCache_1 = new WeakSet();
40 + return function cachedDescendant(elem) {
41 + var current = elem;
42 + while ((current = adapter.getParent(current))) {
43 + if (!isFalseCache_1.has(current)) {
44 + if (adapter.isTag(current) && next(current)) {
45 + return true;
46 + }
47 + isFalseCache_1.add(current);
48 + }
49 + }
50 + return false;
51 + };
52 + case "_flexibleDescendant":
53 + // Include element itself, only used while querying an array
54 + return function flexibleDescendant(elem) {
55 + var current = elem;
56 + do {
57 + if (adapter.isTag(current) && next(current))
58 + return true;
59 + } while ((current = adapter.getParent(current)));
60 + return false;
61 + };
62 + case "parent":
63 + return function parent(elem) {
64 + return adapter
65 + .getChildren(elem)
66 + .some(function (elem) { return adapter.isTag(elem) && next(elem); });
67 + };
68 + case "child":
69 + return function child(elem) {
70 + var parent = adapter.getParent(elem);
71 + return parent != null && adapter.isTag(parent) && next(parent);
72 + };
73 + case "sibling":
74 + return function sibling(elem) {
75 + var siblings = adapter.getSiblings(elem);
76 + for (var i = 0; i < siblings.length; i++) {
77 + var currentSibling = siblings[i];
78 + if (equals(elem, currentSibling))
79 + break;
80 + if (adapter.isTag(currentSibling) && next(currentSibling)) {
81 + return true;
82 + }
83 + }
84 + return false;
85 + };
86 + case "adjacent":
87 + return function adjacent(elem) {
88 + var siblings = adapter.getSiblings(elem);
89 + var lastElement;
90 + for (var i = 0; i < siblings.length; i++) {
91 + var currentSibling = siblings[i];
92 + if (equals(elem, currentSibling))
93 + break;
94 + if (adapter.isTag(currentSibling)) {
95 + lastElement = currentSibling;
96 + }
97 + }
98 + return !!lastElement && next(lastElement);
99 + };
100 + case "universal":
101 + return next;
102 + }
103 +}
104 +exports.compileGeneralSelector = compileGeneralSelector;
1 +import type { CompiledQuery, Options, Query, Adapter } from "./types";
2 +export type { Options };
3 +/**
4 + * Compiles the query, returns a function.
5 + */
6 +export declare const compile: <Node_1, ElementNode extends Node_1>(selector: string | import("css-what").Selector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<ElementNode>;
7 +export declare const _compileUnsafe: <Node_1, ElementNode extends Node_1>(selector: string | import("css-what").Selector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<ElementNode>;
8 +export declare const _compileToken: <Node_1, ElementNode extends Node_1>(selector: import("./types").InternalSelector[][], options?: Options<Node_1, ElementNode> | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery<ElementNode>;
9 +export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
10 +/**
11 + * @template Node The generic Node type for the DOM adapter being used.
12 + * @template ElementNode The Node type for elements for the DOM adapter being used.
13 + * @param elems Elements to query. If it is an element, its children will be queried..
14 + * @param query can be either a CSS selector string or a compiled query function.
15 + * @param [options] options for querying the document.
16 + * @see compile for supported selector queries.
17 + * @returns All matching elements.
18 + *
19 + */
20 +export declare const selectAll: <Node_1, ElementNode extends Node_1>(query: Query<ElementNode>, elements: Node_1 | Node_1[], options?: Options<Node_1, ElementNode> | undefined) => ElementNode[];
21 +/**
22 + * @template Node The generic Node type for the DOM adapter being used.
23 + * @template ElementNode The Node type for elements for the DOM adapter being used.
24 + * @param elems Elements to query. If it is an element, its children will be queried..
25 + * @param query can be either a CSS selector string or a compiled query function.
26 + * @param [options] options for querying the document.
27 + * @see compile for supported selector queries.
28 + * @returns the first match, or null if there was no match.
29 + */
30 +export declare const selectOne: <Node_1, ElementNode extends Node_1>(query: Query<ElementNode>, elements: Node_1 | Node_1[], options?: Options<Node_1, ElementNode> | undefined) => ElementNode | null;
31 +/**
32 + * Tests whether or not an element is matched by query.
33 + *
34 + * @template Node The generic Node type for the DOM adapter being used.
35 + * @template ElementNode The Node type for elements for the DOM adapter being used.
36 + * @param elem The element to test if it matches the query.
37 + * @param query can be either a CSS selector string or a compiled query function.
38 + * @param [options] options for querying the document.
39 + * @see compile for supported selector queries.
40 + * @returns
41 + */
42 +export declare function is<Node, ElementNode extends Node>(elem: ElementNode, query: Query<ElementNode>, options?: Options<Node, ElementNode>): boolean;
43 +/**
44 + * Alias for selectAll(query, elems, options).
45 + * @see [compile] for supported selector queries.
46 + */
47 +export default selectAll;
48 +export { filters, pseudos, aliases } from "./pseudo-selectors";
49 +//# sourceMappingURL=index.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,qNAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,qNAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,mNAA4B,CAAC;AA6BvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACzD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,EACnC,sBAAsB,UAAQ,GAC/B,IAAI,EAAE,CAYR;AAgBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,mKASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,wKASrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC7C,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EACzB,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,OAAO,CAKT;AAED;;;GAGG;AACH,eAAe,SAAS,CAAC;AAGzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 + if (k2 === undefined) k2 = k;
4 + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5 +}) : (function(o, m, k, k2) {
6 + if (k2 === undefined) k2 = k;
7 + o[k2] = m[k];
8 +}));
9 +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 + Object.defineProperty(o, "default", { enumerable: true, value: v });
11 +}) : function(o, v) {
12 + o["default"] = v;
13 +});
14 +var __importStar = (this && this.__importStar) || function (mod) {
15 + if (mod && mod.__esModule) return mod;
16 + var result = {};
17 + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 + __setModuleDefault(result, mod);
19 + return result;
20 +};
21 +Object.defineProperty(exports, "__esModule", { value: true });
22 +exports.aliases = exports.pseudos = exports.filters = exports.is = exports.selectOne = exports.selectAll = exports.prepareContext = exports._compileToken = exports._compileUnsafe = exports.compile = void 0;
23 +var DomUtils = __importStar(require("domutils"));
24 +var boolbase_1 = require("boolbase");
25 +var compile_1 = require("./compile");
26 +var subselects_1 = require("./pseudo-selectors/subselects");
27 +var defaultEquals = function (a, b) { return a === b; };
28 +var defaultOptions = {
29 + adapter: DomUtils,
30 + equals: defaultEquals,
31 +};
32 +function convertOptionFormats(options) {
33 + var _a, _b, _c, _d;
34 + /*
35 + * We force one format of options to the other one.
36 + */
37 + // @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
38 + var opts = options !== null && options !== void 0 ? options : defaultOptions;
39 + // @ts-expect-error Same as above.
40 + (_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
41 + // @ts-expect-error `equals` does not exist on `Options`
42 + (_b = opts.equals) !== null && _b !== void 0 ? _b : (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals);
43 + return opts;
44 +}
45 +function wrapCompile(func) {
46 + return function addAdapter(selector, options, context) {
47 + var opts = convertOptionFormats(options);
48 + return func(selector, opts, context);
49 + };
50 +}
51 +/**
52 + * Compiles the query, returns a function.
53 + */
54 +exports.compile = wrapCompile(compile_1.compile);
55 +exports._compileUnsafe = wrapCompile(compile_1.compileUnsafe);
56 +exports._compileToken = wrapCompile(compile_1.compileToken);
57 +function getSelectorFunc(searchFunc) {
58 + return function select(query, elements, options) {
59 + var opts = convertOptionFormats(options);
60 + if (typeof query !== "function") {
61 + query = compile_1.compileUnsafe(query, opts, elements);
62 + }
63 + var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
64 + return searchFunc(query, filteredElements, opts);
65 + };
66 +}
67 +function prepareContext(elems, adapter, shouldTestNextSiblings) {
68 + if (shouldTestNextSiblings === void 0) { shouldTestNextSiblings = false; }
69 + /*
70 + * Add siblings if the query requires them.
71 + * See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
72 + */
73 + if (shouldTestNextSiblings) {
74 + elems = appendNextSiblings(elems, adapter);
75 + }
76 + return Array.isArray(elems)
77 + ? adapter.removeSubsets(elems)
78 + : adapter.getChildren(elems);
79 +}
80 +exports.prepareContext = prepareContext;
81 +function appendNextSiblings(elem, adapter) {
82 + // Order matters because jQuery seems to check the children before the siblings
83 + var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
84 + for (var i = 0; i < elems.length; i++) {
85 + var nextSiblings = subselects_1.getNextSiblings(elems[i], adapter);
86 + elems.push.apply(elems, nextSiblings);
87 + }
88 + return elems;
89 +}
90 +/**
91 + * @template Node The generic Node type for the DOM adapter being used.
92 + * @template ElementNode The Node type for elements for the DOM adapter being used.
93 + * @param elems Elements to query. If it is an element, its children will be queried..
94 + * @param query can be either a CSS selector string or a compiled query function.
95 + * @param [options] options for querying the document.
96 + * @see compile for supported selector queries.
97 + * @returns All matching elements.
98 + *
99 + */
100 +exports.selectAll = getSelectorFunc(function (query, elems, options) {
101 + return query === boolbase_1.falseFunc || !elems || elems.length === 0
102 + ? []
103 + : options.adapter.findAll(query, elems);
104 +});
105 +/**
106 + * @template Node The generic Node type for the DOM adapter being used.
107 + * @template ElementNode The Node type for elements for the DOM adapter being used.
108 + * @param elems Elements to query. If it is an element, its children will be queried..
109 + * @param query can be either a CSS selector string or a compiled query function.
110 + * @param [options] options for querying the document.
111 + * @see compile for supported selector queries.
112 + * @returns the first match, or null if there was no match.
113 + */
114 +exports.selectOne = getSelectorFunc(function (query, elems, options) {
115 + return query === boolbase_1.falseFunc || !elems || elems.length === 0
116 + ? null
117 + : options.adapter.findOne(query, elems);
118 +});
119 +/**
120 + * Tests whether or not an element is matched by query.
121 + *
122 + * @template Node The generic Node type for the DOM adapter being used.
123 + * @template ElementNode The Node type for elements for the DOM adapter being used.
124 + * @param elem The element to test if it matches the query.
125 + * @param query can be either a CSS selector string or a compiled query function.
126 + * @param [options] options for querying the document.
127 + * @see compile for supported selector queries.
128 + * @returns
129 + */
130 +function is(elem, query, options) {
131 + var opts = convertOptionFormats(options);
132 + return (typeof query === "function" ? query : compile_1.compile(query, opts))(elem);
133 +}
134 +exports.is = is;
135 +/**
136 + * Alias for selectAll(query, elems, options).
137 + * @see [compile] for supported selector queries.
138 + */
139 +exports.default = exports.selectAll;
140 +// Export filters, pseudos and aliases to allow users to supply their own.
141 +var pseudo_selectors_1 = require("./pseudo-selectors");
142 +Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return pseudo_selectors_1.filters; } });
143 +Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudo_selectors_1.pseudos; } });
144 +Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return pseudo_selectors_1.aliases; } });
1 +import type { Traversal } from "css-what";
2 +import type { InternalSelector } from "./types";
3 +export declare const procedure: Record<InternalSelector["type"], number>;
4 +export declare function isTraversal(t: InternalSelector): t is Traversal;
5 +//# sourceMappingURL=procedure.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../src/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAY9D,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,IAAI,SAAS,CAE/D"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.isTraversal = exports.procedure = void 0;
4 +exports.procedure = {
5 + universal: 50,
6 + tag: 30,
7 + attribute: 1,
8 + pseudo: 0,
9 + "pseudo-element": 0,
10 + descendant: -1,
11 + child: -1,
12 + parent: -1,
13 + sibling: -1,
14 + adjacent: -1,
15 + _flexibleDescendant: -1,
16 +};
17 +function isTraversal(t) {
18 + return exports.procedure[t.type] < 0;
19 +}
20 +exports.isTraversal = isTraversal;
1 +/**
2 + * Aliases are pseudos that are expressed as selectors.
3 + */
4 +export declare const aliases: Record<string, string>;
5 +//# sourceMappingURL=aliases.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.aliases = void 0;
4 +/**
5 + * Aliases are pseudos that are expressed as selectors.
6 + */
7 +exports.aliases = {
8 + // Links
9 + "any-link": ":is(a, area, link)[href]",
10 + link: ":any-link:not(:visited)",
11 + // Forms
12 + // https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
13 + disabled: ":is(\n :is(button, input, select, textarea, optgroup, option)[disabled],\n optgroup[disabled] > option,\n fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)\n )",
14 + enabled: ":not(:disabled)",
15 + checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
16 + required: ":is(input, select, textarea)[required]",
17 + optional: ":is(input, select, textarea):not([required])",
18 + // JQuery extensions
19 + // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
20 + selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
21 + checkbox: "[type=checkbox]",
22 + file: "[type=file]",
23 + password: "[type=password]",
24 + radio: "[type=radio]",
25 + reset: "[type=reset]",
26 + image: "[type=image]",
27 + submit: "[type=submit]",
28 + parent: ":not(:empty)",
29 + header: ":is(h1, h2, h3, h4, h5, h6)",
30 + button: ":is(button, input[type=button])",
31 + input: ":is(input, textarea, select, button)",
32 + text: "input:is(:not([type!='']), [type=text])",
33 +};
1 +import type { CompiledQuery, InternalOptions } from "../types";
2 +export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
3 +export declare const filters: Record<string, Filter>;
4 +//# sourceMappingURL=filters.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAExE,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,KACf,aAAa,CAAC,WAAW,CAAC,CAAC;AAYhC,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2I1C,CAAC"}
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +var __importDefault = (this && this.__importDefault) || function (mod) {
3 + return (mod && mod.__esModule) ? mod : { "default": mod };
4 +};
5 +Object.defineProperty(exports, "__esModule", { value: true });
6 +exports.filters = void 0;
7 +var nth_check_1 = __importDefault(require("nth-check"));
8 +var boolbase_1 = require("boolbase");
9 +function getChildFunc(next, adapter) {
10 + return function (elem) {
11 + var parent = adapter.getParent(elem);
12 + return parent != null && adapter.isTag(parent) && next(elem);
13 + };
14 +}
15 +exports.filters = {
16 + contains: function (next, text, _a) {
17 + var adapter = _a.adapter;
18 + return function contains(elem) {
19 + return next(elem) && adapter.getText(elem).includes(text);
20 + };
21 + },
22 + icontains: function (next, text, _a) {
23 + var adapter = _a.adapter;
24 + var itext = text.toLowerCase();
25 + return function icontains(elem) {
26 + return (next(elem) &&
27 + adapter.getText(elem).toLowerCase().includes(itext));
28 + };
29 + },
30 + // Location specific methods
31 + "nth-child": function (next, rule, _a) {
32 + var adapter = _a.adapter, equals = _a.equals;
33 + var func = nth_check_1.default(rule);
34 + if (func === boolbase_1.falseFunc)
35 + return boolbase_1.falseFunc;
36 + if (func === boolbase_1.trueFunc)
37 + return getChildFunc(next, adapter);
38 + return function nthChild(elem) {
39 + var siblings = adapter.getSiblings(elem);
40 + var pos = 0;
41 + for (var i = 0; i < siblings.length; i++) {
42 + if (equals(elem, siblings[i]))
43 + break;
44 + if (adapter.isTag(siblings[i])) {
45 + pos++;
46 + }
47 + }
48 + return func(pos) && next(elem);
49 + };
50 + },
51 + "nth-last-child": function (next, rule, _a) {
52 + var adapter = _a.adapter, equals = _a.equals;
53 + var func = nth_check_1.default(rule);
54 + if (func === boolbase_1.falseFunc)
55 + return boolbase_1.falseFunc;
56 + if (func === boolbase_1.trueFunc)
57 + return getChildFunc(next, adapter);
58 + return function nthLastChild(elem) {
59 + var siblings = adapter.getSiblings(elem);
60 + var pos = 0;
61 + for (var i = siblings.length - 1; i >= 0; i--) {
62 + if (equals(elem, siblings[i]))
63 + break;
64 + if (adapter.isTag(siblings[i])) {
65 + pos++;
66 + }
67 + }
68 + return func(pos) && next(elem);
69 + };
70 + },
71 + "nth-of-type": function (next, rule, _a) {
72 + var adapter = _a.adapter, equals = _a.equals;
73 + var func = nth_check_1.default(rule);
74 + if (func === boolbase_1.falseFunc)
75 + return boolbase_1.falseFunc;
76 + if (func === boolbase_1.trueFunc)
77 + return getChildFunc(next, adapter);
78 + return function nthOfType(elem) {
79 + var siblings = adapter.getSiblings(elem);
80 + var pos = 0;
81 + for (var i = 0; i < siblings.length; i++) {
82 + var currentSibling = siblings[i];
83 + if (equals(elem, currentSibling))
84 + break;
85 + if (adapter.isTag(currentSibling) &&
86 + adapter.getName(currentSibling) === adapter.getName(elem)) {
87 + pos++;
88 + }
89 + }
90 + return func(pos) && next(elem);
91 + };
92 + },
93 + "nth-last-of-type": function (next, rule, _a) {
94 + var adapter = _a.adapter, equals = _a.equals;
95 + var func = nth_check_1.default(rule);
96 + if (func === boolbase_1.falseFunc)
97 + return boolbase_1.falseFunc;
98 + if (func === boolbase_1.trueFunc)
99 + return getChildFunc(next, adapter);
100 + return function nthLastOfType(elem) {
101 + var siblings = adapter.getSiblings(elem);
102 + var pos = 0;
103 + for (var i = siblings.length - 1; i >= 0; i--) {
104 + var currentSibling = siblings[i];
105 + if (equals(elem, currentSibling))
106 + break;
107 + if (adapter.isTag(currentSibling) &&
108 + adapter.getName(currentSibling) === adapter.getName(elem)) {
109 + pos++;
110 + }
111 + }
112 + return func(pos) && next(elem);
113 + };
114 + },
115 + // TODO determine the actual root element
116 + root: function (next, _rule, _a) {
117 + var adapter = _a.adapter;
118 + return function (elem) {
119 + var parent = adapter.getParent(elem);
120 + return (parent == null || !adapter.isTag(parent)) && next(elem);
121 + };
122 + },
123 + scope: function (next, rule, options, context) {
124 + var equals = options.equals;
125 + if (!context || context.length === 0) {
126 + // Equivalent to :root
127 + return exports.filters.root(next, rule, options);
128 + }
129 + if (context.length === 1) {
130 + // NOTE: can't be unpacked, as :has uses this for side-effects
131 + return function (elem) { return equals(context[0], elem) && next(elem); };
132 + }
133 + return function (elem) { return context.includes(elem) && next(elem); };
134 + },
135 + hover: dynamicStatePseudo("isHovered"),
136 + visited: dynamicStatePseudo("isVisited"),
137 + active: dynamicStatePseudo("isActive"),
138 +};
139 +/**
140 + * Dynamic state pseudos. These depend on optional Adapter methods.
141 + *
142 + * @param name The name of the adapter method to call.
143 + * @returns Pseudo for the `filters` object.
144 + */
145 +function dynamicStatePseudo(name) {
146 + return function dynamicPseudo(next, _rule, _a) {
147 + var adapter = _a.adapter;
148 + var func = adapter[name];
149 + if (typeof func !== "function") {
150 + return boolbase_1.falseFunc;
151 + }
152 + return function active(elem) {
153 + return func(elem) && next(elem);
154 + };
155 + };
156 +}
1 +import type { CompiledQuery, InternalOptions, CompileToken } from "../types";
2 +import { PseudoSelector } from "css-what";
3 +import { filters } from "./filters";
4 +import { pseudos } from "./pseudos";
5 +import { aliases } from "./aliases";
6 +export { filters, pseudos, aliases };
7 +export declare function compilePseudoSelector<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, selector: PseudoSelector, options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>): CompiledQuery<ElementNode>;
8 +//# sourceMappingURL=index.d.ts.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CA6B5B"}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.