mirror of
https://github.com/clarencechaan/ufc-cal.git
synced 2026-10-19 00:38:30 -07:00
Compare commits
9
Commits
b6add40246
..
api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
087de8de41 | ||
|
|
6b3b55efdb | ||
|
|
a2ec15795d | ||
|
|
2f5a30fadf | ||
|
|
18aa02a074 | ||
|
|
cb8e32be66 | ||
|
|
426097ec7d | ||
|
|
f299b1ff44 | ||
|
|
0abdf42280 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
name: GitHub Self-Updating Repository
|
||||
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: "0 */4 * * *"
|
||||
|
||||
@@ -15,12 +16,11 @@ jobs:
|
||||
ref: ics
|
||||
- name: Create UFC.ics
|
||||
run: |
|
||||
npm install
|
||||
npm start
|
||||
- name: Push to repository
|
||||
run: |
|
||||
git config --global user.name "Clarence Chan"
|
||||
git config --global user.email "[email protected]"
|
||||
git add UFC.ics UFC-PPV.ics
|
||||
git commit -m "Update UFC.ics and UFC-PPV.ics"
|
||||
git add UFC.ics
|
||||
git commit -m "Update UFC.ics"
|
||||
git push -u origin ics
|
||||
@@ -2,34 +2,6 @@
|
||||
|
||||
[Subscribe to this calendar to keep track of UFC events](https://clarencechaan.github.io/ufc-cal/)
|
||||
|
||||
Or subscribe manually from your calendar app using this URL:
|
||||
Or subscribe manually from your calendar app:
|
||||
|
||||
`webcal://raw.githubusercontent.com/clarencechaan/ufc-cal/ics/UFC.ics`
|
||||
|
||||
## What is this?
|
||||
|
||||
A calendar feed that automatically adds UFC events to your calendar app of choice as each event gets announced and updated over time.
|
||||
|
||||
This feed is not affiliated with the UFC.
|
||||
|
||||
## Why is it better than other feeds?
|
||||
|
||||
The three biggest points that this aims to address, which I found lacking in other calendar feeds:
|
||||
|
||||
- **Always kept up to date**: events are added and card details are updated within a day of any changes posted by the UFC, including new events, fight additions, or removals
|
||||
- **Event times are accurate**: event times reflect your local timezone, and always match the times posted by the UFC
|
||||
- **Card details**: without leaving your calendar, you can see every (announced) fight on the card, whether it's on the main card, prelims, or early prelims
|
||||
|
||||
## Example event
|
||||
|
||||

|
||||
|
||||
## Info for nerds
|
||||
|
||||
**How does it work?**
|
||||
|
||||
- Using a GitHub Action, the UFC's website is scraped several times each day, and the `UFC.ics` file (from the URL above) is updated with any new information found
|
||||
|
||||
**To run locally:**
|
||||
|
||||
- Clone this repo, run the commands `npm install`, then `npm start`, and out spits your `UFC.ics` file with all the relevant UFC events
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
PRODID:adamgibbons/ics
|
||||
METHOD:PUBLISH
|
||||
X-WR-CALNAME:UFC-PPV
|
||||
X-PUBLISHED-TTL:PT1H
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-332
|
||||
SUMMARY:UFC 332: Silva vs Wang
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261004T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Natalia Silva (#1) vs. Wang
|
||||
Cong (#8) @125\n• Deiveson Figueiredo (#9) vs. Payton Talbott (#12) @135\n
|
||||
• King Green vs. Esteban Ribovics @155\n• Roberto Soldić vs. Khaos William
|
||||
s @170\n• Ateba Gautier vs. Roman Kopylov @185\n\nPrelims (2 hrs before Ma
|
||||
in)\n--------------------\n• Imanol Rodriguez vs. Alden Coria @125\n• Dami
|
||||
an Pinas vs. Andrey Pulyaev @185\n• Marcus McGhee vs. Anthony Romero @145\
|
||||
n• Anthony Wint vs. Lucas Armand @265\n\nEarly Prelims (4 hrs before Main)
|
||||
\n--------------------\n• Johnny Walker vs. Mick Parkin @265\n• Jacobe Smi
|
||||
th vs. Bruce Whitehead @170\n• Rafael Dos Anjos vs. Alexander Hernandez @1
|
||||
55\n• Marvin Vettori vs. Ismail Naurdiev @185\n• Court McGee vs. Eric Nola
|
||||
n @170\n\nhttps://www.ufc.com/event/ufc-332\n\nAccurate as of Sep 30\, 7:2
|
||||
6 PM EDT
|
||||
LOCATION:Delta Center\, Salt Lake City\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-333
|
||||
SUMMARY:UFC 333: Volkanovski vs Evloev
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261024T180000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Alexander Volkanovski (C) vs
|
||||
. Movsar Evloev (#1) @145\n• Petr Yan (C) vs. Merab Dvalishvili (#1) @135\
|
||||
n• Lone’er Kavanagh (#6) vs. Ramazan Temirov (#10) @125\n• Alexander Volko
|
||||
v (#2) vs. Rizvan Kuniev (#7) @265\n• Arnold Allen (#7) vs. Aaron Pico (#1
|
||||
1) @145\n\nPrelims (2 hrs before Main)\n--------------------\n• Azamat Mur
|
||||
zakanov (#8) vs. Dominick Reyes (#10) @205\n• Nikita Krylov (#15) vs. Abdu
|
||||
l Rakhman Yakhyaev @205\n• Abus Magomedov (#12) vs. Cam Rowston @185\n• Gr
|
||||
ant Dawson vs. Nurullo Aliev @155\n\nhttps://www.ufc.com/event/ufc-333\n\n
|
||||
Accurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Etihad Arena\, Yas Island/Yas West\, United Arab Emirates
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-334
|
||||
SUMMARY:UFC 334: Gane vs Hokit
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261115T020000Z
|
||||
DESCRIPTION:• Ciryl Gane (C) vs. Josh Hokit (#4) @265\n• Kayla Harrison (C)
|
||||
vs. Amanda Nunes @135\n• Caio Borralho (#5) vs. Yousri Belgaroui @185\n•
|
||||
Uroš Medić (#12) vs. Kevin Holland @170\n• Bilal Hasan vs. Luis Gurule @12
|
||||
5\n• Drew Dober vs. Chris Duncan @155\n• Stephen Thompson vs. Charles Radt
|
||||
ke @170\n• Donte Johnson vs. Baisangur Susurkaev @185\n• Jim Miller vs. Te
|
||||
rrance McKinney @155\n• Macy Chiasson (#8) vs. Bia Mesquita (#11) @135\n•
|
||||
Adrian Yanez vs. Juan Diaz @135\n• Nazim Sadykhov vs. Jefferson Nascimento
|
||||
@155\n\nhttps://www.ufc.com/event/ufc-334\n\nAccurate as of Sep 30\, 7:26
|
||||
PM EDT
|
||||
LOCATION:Madison Square Garden\, New York\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/cryptocom-ufc-331
|
||||
SUMMARY:UFC 331: Van vs Pantoja 2
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260920T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Joshua Van (C) vs. Alexandre
|
||||
Pantoja (#1) @125\n• Arman Tsarukyan (#2) vs. Mauricio Ruffy (#7) @155\n•
|
||||
Patricio Pitbull (#15) vs. Dooho Choi @145\n• Gable Steveson vs. Sean Sha
|
||||
raf @265\n• Alonzo Menifield (#14) vs. Iwo Baraniewski @205\n\nPrelims (2
|
||||
hrs before Main)\n--------------------\n• Marlon Vera (#10) vs. Charles Jo
|
||||
urdain @135\n• Tai Tuivasa vs. Robelis Despaigne @265\n• Michael Aswell Jr
|
||||
. vs. JooSang Yoo @145\n• Ryan Gandra vs. Ozzy Diaz @185\n\nEarly Prelims
|
||||
(3.5 hrs before Main)\n--------------------\n• Edmen Shahbazyan vs. Brunno
|
||||
Ferreira @185\n• Casey O'Neill (#12) vs. Eduarda Moura (#13) @125\n• Giga
|
||||
Chikadze vs. Joanderson Brito @145\n\nhttps://www.ufc.com/event/cryptocom
|
||||
-ufc-331\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Crypto.com Arena\, Los Angeles\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-september-12-2026
|
||||
SUMMARY:Noche UFC: Silva vs Delgado
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260912T210000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Jean Silva (#6) vs. Jose Mig
|
||||
uel Delgado @145\n• Brandon Moreno (#8) vs. Joseph Morales @125\n• Tommy M
|
||||
cMillen vs. Marwan Rahiki @145\n• Manon Fiorot (#2) vs. Alexa Grasso (#3)
|
||||
@125\n• Waldo Cortes Acosta (#5) vs. Curtis Blaydes (#6) @265\n• David Mar
|
||||
tinez (#8) vs. Dan Ige @135\n\nPrelims (3 hrs before Main)\n--------------
|
||||
------\n• Tim Elliott vs. Edgar Chairez @CW\n• Ignacio Bahamondes vs. Musl
|
||||
im Salikhov @170\n• Yousri Belgaroui vs. Djorden Santos @185\n• Drakkar Kl
|
||||
ose vs. Tommy Gantt @155\n• Rafa Garcia vs. Rongzhu @155\n• Sean King III
|
||||
vs. Jessie Rosas @145\n• JJ Aldrich (#15) vs. Regina Tarin @125\n\nhttps:/
|
||||
/www.ufc.com/event/ufc-fight-night-september-12-2026\n\nAccurate as of Sep
|
||||
30\, 7:26 PM EDT
|
||||
LOCATION:Desert Diamond Arena\, Glendale\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/road-to-ufc-season-5-semifinals
|
||||
SUMMARY:Road To UFC: Maheshate vs Flowers
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260828T090000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n\n\n\nhttps://www.ufc.com/even
|
||||
t/road-to-ufc-season-5-semifinals\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-330
|
||||
SUMMARY:UFC 330: Makhachev vs Machado Garry
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260816T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Islam Makhachev (C) vs. Ian
|
||||
Machado Garry (#1) @170\n• Mackenzie Dern (C) vs. Gillian Robertson (#5) @
|
||||
115\n• Jalin Turner vs. Kauê Fernandes @155\n• Mansur Abdul-Malik vs. Dust
|
||||
in Stoltzfus @185\n• Edson Barboza vs. Esteban Ribovics @155\n\nPrelims (2
|
||||
hrs before Main)\n--------------------\n• Chidi Njokuani vs. Joel Álvarez
|
||||
@170\n• Charles Johnson vs. Eduardo Chapolin @CW\n• Donte Johnson vs. Eri
|
||||
c McConico @185\n• Vicente Luque vs. Tresean Gore @185\n\nEarly Prelims (3
|
||||
.5 hrs before Main)\n--------------------\n• Rafael Tobias vs. Lucas Ferna
|
||||
ndo @205\n• Neil Magny vs. Ramiz Brahimaj @170\n• Jeremiah Wells vs. Mykty
|
||||
bek Orolbai @170\n\nhttps://www.ufc.com/event/ufc-330\n\nAccurate as of Se
|
||||
p 30\, 7:26 PM EDT
|
||||
LOCATION:Xfinity Mobile Arena\, Philadelphia\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-335
|
||||
SUMMARY:UFC 335: TBD vs TBD
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261213T020000Z
|
||||
DESCRIPTION:https://www.ufc.com/event/ufc-335\n\nAccurate as of Sep 30\, 7:
|
||||
26 PM EDT
|
||||
LOCATION:T-Mobile Arena\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-329
|
||||
SUMMARY:UFC 329: McGregor vs Holloway 2
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260712T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Conor McGregor vs. Max Hollo
|
||||
way @170\n• Benoît Saint Denis (#5) vs. Paddy Pimblett (#6) @155\n• Cory S
|
||||
andhagen (#4) vs. Mario Bautista (#7) @135\n• Brandon Royval (#4) vs. Lone
|
||||
’er Kavanagh (#6) @125\n• King Green vs. Terrance McKinney @155\n\nPrelims
|
||||
(2 hrs before Main)\n--------------------\n• Nikita Krylov (#12) vs. Robe
|
||||
rt Whittaker @205\n• Gable Steveson vs. Elisha Ellison @265\n• Cody Garbra
|
||||
ndt vs. Adrian Yanez @135\n• Luke Riley vs. Kai Kamaka III @145\n\nEarly P
|
||||
relims (4 hrs before Main)\n--------------------\n• Tracy Cortez (#8) vs.
|
||||
Wang Cong (#12) @125\n• Damian Pinas vs. Cesar Almeida @185\n• Farid Basha
|
||||
rat (#15) vs. John Garza @135\n• Ryan Gandra vs. Zachary Reese @185\n• Ale
|
||||
ssandro Costa vs. Cody Durden @125\n\nhttps://www.ufc.com/event/ufc-329\n\
|
||||
nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:T-Mobile Arena\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-freedom-250
|
||||
SUMMARY:UFC Freedom 250: Topuria vs Gaethje
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260615T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Ilia Topuria (C) vs. Justin
|
||||
Gaethje (C) @155\n• Alex Pereira vs. Ciryl Gane (#1) @265\n• Sean O'Malley
|
||||
(#3) vs. Aiemann Zahabi (#6) @135\n• Josh Hokit (#5) vs. Derrick Lewis (#
|
||||
9) @265\n• Mauricio Ruffy (#9) vs. Michael Chandler (#13) @155\n• Bo Nicka
|
||||
l vs. Kyle Daukaus @185\n• Diego Lopes (#2) vs. Steve Garcia (#9) @145\n\n
|
||||
https://www.ufc.com/event/ufc-freedom-250\n\nAccurate as of Sep 30\, 7:26
|
||||
PM EDT
|
||||
LOCATION:The White House\, Washington\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
@@ -1,454 +0,0 @@
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
PRODID:adamgibbons/ics
|
||||
METHOD:PUBLISH
|
||||
X-WR-CALNAME:UFC
|
||||
X-PUBLISHED-TTL:PT1H
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-332
|
||||
SUMMARY:UFC 332: Silva vs Wang
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261004T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Natalia Silva (#1) vs. Wang
|
||||
Cong (#8) @125\n• Deiveson Figueiredo (#9) vs. Payton Talbott (#12) @135\n
|
||||
• King Green vs. Esteban Ribovics @155\n• Roberto Soldić vs. Khaos William
|
||||
s @170\n• Ateba Gautier vs. Roman Kopylov @185\n\nPrelims (2 hrs before Ma
|
||||
in)\n--------------------\n• Imanol Rodriguez vs. Alden Coria @125\n• Dami
|
||||
an Pinas vs. Andrey Pulyaev @185\n• Marcus McGhee vs. Anthony Romero @145\
|
||||
n• Anthony Wint vs. Lucas Armand @265\n\nEarly Prelims (4 hrs before Main)
|
||||
\n--------------------\n• Johnny Walker vs. Mick Parkin @265\n• Jacobe Smi
|
||||
th vs. Bruce Whitehead @170\n• Rafael Dos Anjos vs. Alexander Hernandez @1
|
||||
55\n• Marvin Vettori vs. Ismail Naurdiev @185\n• Court McGee vs. Eric Nola
|
||||
n @170\n\nhttps://www.ufc.com/event/ufc-332\n\nAccurate as of Sep 30\, 7:2
|
||||
6 PM EDT
|
||||
LOCATION:Delta Center\, Salt Lake City\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-october-10-2026
|
||||
SUMMARY:UFC Fight Night: Allen vs Duncan
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261011T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Brendan Allen (#4) vs. Chris
|
||||
tian Leroy Duncan (#10) @185\n• Matheus Camilo vs. Jai Herbert @155\n• Loo
|
||||
py Godinez (#8) vs. Ketlen Souza @115\n• Andre Fili vs. Kai Kamaka III @14
|
||||
5\n• Julius Walker vs. Gerald Meerschaert @205\n• Malcolm Wellmaker vs. Ot
|
||||
ari Tanzilovi @135\n\nPrelims (3 hrs before Main)\n--------------------\n•
|
||||
Francisco Prado vs. Ismael Bonfim @155\n• Niko Price vs. Leon Shahbazyan
|
||||
@170\n• Felipe Franco vs. Brendson Ribeiro @205\n• Allen Frye Jr. vs. RJ H
|
||||
arris @265\n• Alice Pereira vs. Daria Zhelezniakova @135\n• Ernesta Kareck
|
||||
aitė vs. Melissa Gatto @125\n\nhttps://www.ufc.com/event/ufc-fight-night-o
|
||||
ctober-10-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-october-17-2026
|
||||
SUMMARY:UFC Fight Night: Buckley vs Malott
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261018T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Joaquin Buckley (#10) vs. Mi
|
||||
ke Malott (#13) @170\n• Erin Blanchfield (#4) vs. Jasmine Jasudavicius (#7
|
||||
) @125\n• Kyle Nelson vs. Cristian Perez Gonzalez @155\n• Marc-Andre Barri
|
||||
ault vs. Kyle Daukaus @185\n• Louis Jourdain vs. Timmy Cuamba @135\n• Mand
|
||||
el Nallo vs. Nate Landwehr @155\n\nPrelims (3 hrs before Main)\n----------
|
||||
----------\n• Tanner Boser vs. Jhonata Diniz @265\n• Julien Leblanc vs. Gi
|
||||
lbert Urbina @185\n• Javad Mahjoub vs. Louie Sutherland @265\n• Jamey-Lyn
|
||||
Horth vs. Katlyn Cerminara @125\n• Chad Anheliger vs. Steven Koslow @135\n
|
||||
• Melissa Croden (#15) vs. Chelsea Chandler @135\n• Cody Chovancek vs. SuY
|
||||
oung You @135\n\nhttps://www.ufc.com/event/ufc-fight-night-october-17-2026
|
||||
\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Rogers Place\, Edmonton\, Canada
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-333
|
||||
SUMMARY:UFC 333: Volkanovski vs Evloev
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261024T180000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Alexander Volkanovski (C) vs
|
||||
. Movsar Evloev (#1) @145\n• Petr Yan (C) vs. Merab Dvalishvili (#1) @135\
|
||||
n• Lone’er Kavanagh (#6) vs. Ramazan Temirov (#10) @125\n• Alexander Volko
|
||||
v (#2) vs. Rizvan Kuniev (#7) @265\n• Arnold Allen (#7) vs. Aaron Pico (#1
|
||||
1) @145\n\nPrelims (2 hrs before Main)\n--------------------\n• Azamat Mur
|
||||
zakanov (#8) vs. Dominick Reyes (#10) @205\n• Nikita Krylov (#15) vs. Abdu
|
||||
l Rakhman Yakhyaev @205\n• Abus Magomedov (#12) vs. Cam Rowston @185\n• Gr
|
||||
ant Dawson vs. Nurullo Aliev @155\n\nhttps://www.ufc.com/event/ufc-333\n\n
|
||||
Accurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Etihad Arena\, Yas Island/Yas West\, United Arab Emirates
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-october-31-2026
|
||||
SUMMARY:UFC Fight Night: Moicano vs Nolan
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261101T000000Z
|
||||
DESCRIPTION:• Renato Moicano (#12) vs. Tom Nolan (#14) @155\n• Randy Brown
|
||||
vs. Carlos Leal @170\n• Lucia Szabova vs. Tainara Lisboa @125\n• Yana Sant
|
||||
os (#6) vs. Luana Santos (#7) @135\n• Talita Alencar vs. Piera Rodriguez @
|
||||
115\n• Nick Klein vs. Joseph Kropschot @185\n• Rodrigo Sezinando vs. Theod
|
||||
or Berggren @170\n• Jean-Paul Lebosnoyani vs. Farman Hasanov @170\n• Azama
|
||||
t Bekoev vs. Andre Petroski @185\n• Julian Erosa vs. JeongYeong Lee @145\n
|
||||
• Francis Marshall vs. Gaston Bolanos @145\n\nhttps://www.ufc.com/event/uf
|
||||
c-fight-night-october-31-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-november-07-2026
|
||||
SUMMARY:UFC Fight Night: Bonfim vs Brady
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261107T220000Z
|
||||
DESCRIPTION:• Gabriel Bonfim (#5) vs. Sean Brady (#6) @170\n• Tatiana Suare
|
||||
z (#2) vs. Virna Jandiroba (#3) @115\n• Mantas Kondratavičius vs. Wes Schu
|
||||
ltz @185\n• Billy Elekana vs. Lucas Fernando @205\n• Austin Bashi vs. Luca
|
||||
s Brennan @145\n• Karine Silva (#11) vs. Gabriella Fernandes (#15) @125\n•
|
||||
Priscila Cachoeira vs. Nina Milošević @135\n• Keiichiro Nakamura vs. Olli
|
||||
e Schmid @145\n• Seokhyeon Ko vs. Wellington Turman @170\n• Jonny Parsons
|
||||
vs. José Souza @170\n• Davey Grant vs. Elijah Smith @135\n• Jose Delano vs
|
||||
. Murtazali Magomedov @145\n• Gabriel Lorenco vs. Alvin Hines @265\n\nhttp
|
||||
s://www.ufc.com/event/ufc-fight-night-november-07-2026\n\nAccurate as of S
|
||||
ep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-334
|
||||
SUMMARY:UFC 334: Gane vs Hokit
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261115T020000Z
|
||||
DESCRIPTION:• Ciryl Gane (C) vs. Josh Hokit (#4) @265\n• Kayla Harrison (C)
|
||||
vs. Amanda Nunes @135\n• Caio Borralho (#5) vs. Yousri Belgaroui @185\n•
|
||||
Uroš Medić (#12) vs. Kevin Holland @170\n• Bilal Hasan vs. Luis Gurule @12
|
||||
5\n• Drew Dober vs. Chris Duncan @155\n• Stephen Thompson vs. Charles Radt
|
||||
ke @170\n• Donte Johnson vs. Baisangur Susurkaev @185\n• Jim Miller vs. Te
|
||||
rrance McKinney @155\n• Macy Chiasson (#8) vs. Bia Mesquita (#11) @135\n•
|
||||
Adrian Yanez vs. Juan Diaz @135\n• Nazim Sadykhov vs. Jefferson Nascimento
|
||||
@155\n\nhttps://www.ufc.com/event/ufc-334\n\nAccurate as of Sep 30\, 7:26
|
||||
PM EDT
|
||||
LOCATION:Madison Square Garden\, New York\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-november-21-2026
|
||||
SUMMARY:UFC Fight Night: Prochazka vs Stirling
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261121T180000Z
|
||||
DESCRIPTION:• Jiří Procházka (#2) vs. Navajo Stirling (#5) @205\n• Aljamain
|
||||
Sterling (#4) vs. Kevin Vallejos (#9) @145\n• Dan Hooker (#13) vs. Brian
|
||||
Ortega @155\n• Jared Cannonier (#11) vs. Ikram Aliskerov (#13) @185\n• Sha
|
||||
mil Gaziev vs. Tallison Teixeira @265\n• Jake Matthews vs. Tahir Abdullaye
|
||||
v @170\n• Aleksandre Topuria vs. Santiago Luna @135\n• Asu Almabayev (#7)
|
||||
vs. Kyoji Horiguchi (#5) @125\n• Amir Albazi (#9) vs. Alessandro Costa @12
|
||||
5\n\nhttps://www.ufc.com/event/ufc-fight-night-november-21-2026\n\nAccurat
|
||||
e as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:ABHA Arena\, Doha\, Qatar
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-september-26-2026
|
||||
SUMMARY:UFC Fight Night: Rosas Jr. vs Barcelos
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260927T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Raul Rosas Jr. (#12) vs. Rao
|
||||
ni Barcelos (#13) @135\n• Norma Dumont (#4) vs. Ailin Perez (#5) @135\n• L
|
||||
uis Hernandez vs. Sedriques Dumas @205\n• Mahammadali Osmanli vs. Ilimbek
|
||||
Akylbek @135\n• Melissa Amaya vs. Tina Black @115\n\nPrelims (3 hrs before
|
||||
Main)\n--------------------\n• Brady Hiestand vs. Rinya Nakamura @135\n•
|
||||
Rodolfo Vieira vs. Robert Bryczek @185\n• Rodolfo Bellato vs. Christian Ed
|
||||
wards @205\n• Elves Brener vs. Josiah Harrell @155\n• Montel Jackson vs. R
|
||||
icky Simon @135\n• John Castaneda vs. Alatengheili @135\n• Vanessa Demopou
|
||||
los vs. Yazmin Jauregui @115\n\nhttps://www.ufc.com/event/ufc-fight-night-
|
||||
september-26-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/cryptocom-ufc-331
|
||||
SUMMARY:UFC 331: Van vs Pantoja 2
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260920T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Joshua Van (C) vs. Alexandre
|
||||
Pantoja (#1) @125\n• Arman Tsarukyan (#2) vs. Mauricio Ruffy (#7) @155\n•
|
||||
Patricio Pitbull (#15) vs. Dooho Choi @145\n• Gable Steveson vs. Sean Sha
|
||||
raf @265\n• Alonzo Menifield (#14) vs. Iwo Baraniewski @205\n\nPrelims (2
|
||||
hrs before Main)\n--------------------\n• Marlon Vera (#10) vs. Charles Jo
|
||||
urdain @135\n• Tai Tuivasa vs. Robelis Despaigne @265\n• Michael Aswell Jr
|
||||
. vs. JooSang Yoo @145\n• Ryan Gandra vs. Ozzy Diaz @185\n\nEarly Prelims
|
||||
(3.5 hrs before Main)\n--------------------\n• Edmen Shahbazyan vs. Brunno
|
||||
Ferreira @185\n• Casey O'Neill (#12) vs. Eduarda Moura (#13) @125\n• Giga
|
||||
Chikadze vs. Joanderson Brito @145\n\nhttps://www.ufc.com/event/cryptocom
|
||||
-ufc-331\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Crypto.com Arena\, Los Angeles\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-september-12-2026
|
||||
SUMMARY:Noche UFC: Silva vs Delgado
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260912T210000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Jean Silva (#6) vs. Jose Mig
|
||||
uel Delgado @145\n• Brandon Moreno (#8) vs. Joseph Morales @125\n• Tommy M
|
||||
cMillen vs. Marwan Rahiki @145\n• Manon Fiorot (#2) vs. Alexa Grasso (#3)
|
||||
@125\n• Waldo Cortes Acosta (#5) vs. Curtis Blaydes (#6) @265\n• David Mar
|
||||
tinez (#8) vs. Dan Ige @135\n\nPrelims (3 hrs before Main)\n--------------
|
||||
------\n• Tim Elliott vs. Edgar Chairez @CW\n• Ignacio Bahamondes vs. Musl
|
||||
im Salikhov @170\n• Yousri Belgaroui vs. Djorden Santos @185\n• Drakkar Kl
|
||||
ose vs. Tommy Gantt @155\n• Rafa Garcia vs. Rongzhu @155\n• Sean King III
|
||||
vs. Jessie Rosas @145\n• JJ Aldrich (#15) vs. Regina Tarin @125\n\nhttps:/
|
||||
/www.ufc.com/event/ufc-fight-night-september-12-2026\n\nAccurate as of Sep
|
||||
30\, 7:26 PM EDT
|
||||
LOCATION:Desert Diamond Arena\, Glendale\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-september-05-2026
|
||||
SUMMARY:UFC Fight Night: Hooker vs Parnasse
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260905T190000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Dan Hooker (#10) vs. Salahdi
|
||||
ne Parnasse @155\n• Farès Ziam vs. Axel Sola @155\n• Michael Venom Page (#
|
||||
15) vs. Nursulton Ruziboev @185\n• Daniil Donchenko vs. Punahele Soriano @
|
||||
170\n• Kurtis Campbell vs. Trevor Peek @145\n• Losene Keita vs. Muhammad N
|
||||
aimov @145\n\nPrelims (3 hrs before Main)\n--------------------\n• Morgan
|
||||
Charriere vs. Felipe Lima @145\n• Mario Pinto vs. Ryan Spann @265\n• Oumar
|
||||
Sy vs. Modestas Bukauskas @205\n• Nathaniel Wood vs. Pavel Andrusca @145\
|
||||
n• Michael Aljarouj vs. Fabia Sintes @125\n• Nora Cornolle (#13) vs. Klaud
|
||||
ia Syguła @135\n• Matthieu Duclos vs. Luis Felipe Dias @185\n• Delphine Be
|
||||
nouaich vs. Sofia Montenegro @115\n\nhttps://www.ufc.com/event/ufc-fight-n
|
||||
ight-september-05-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Accor Arena\, Paris\, France
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-august-29-2026
|
||||
SUMMARY:UFC Fight Night: Nurmagomedov vs Song
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260829T100000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Umar Nurmagomedov (#3) vs. S
|
||||
ong Yadong (#6) @135\n• Yan Xiaonan (#4) vs. Denise Gomes (#14) @115\n• Ao
|
||||
riqileng vs. Kai Asakura @135\n• Alex Perez (#11) vs. Sumudaerji @125\n• L
|
||||
iu Ce vs. Levi Rodrigues Jr. @205\n• Bilal Hasan vs. Nilson Rojas @125\n\n
|
||||
Prelims (3 hrs before Main)\n--------------------\n• Namsrai Batbayar vs.
|
||||
Andre Lima @125\n• Rei Tsuruya vs. Kevin Borjas @125\n• Jack Jenkins vs. S
|
||||
ean Woodson @145\n• Xiao Long vs. Francesco Nuzzi @135\n• Lawrence Lui vs.
|
||||
Hector Santiago @135\n• Xiong Jingnan vs. Julia Polastri @115\n• Ding Men
|
||||
g vs. Cam Nelson @170\n\nhttps://www.ufc.com/event/ufc-fight-night-august-
|
||||
29-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Oriental Sports Center\, Pudong District\, China
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/road-to-ufc-season-5-semifinals
|
||||
SUMMARY:Road To UFC: Maheshate vs Flowers
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260828T090000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n\n\n\nhttps://www.ufc.com/even
|
||||
t/road-to-ufc-season-5-semifinals\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-august-22-2026
|
||||
SUMMARY:UFC Fight Night: Hernandez vs Rodrigues
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260823T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Anthony Hernandez (#6) vs. G
|
||||
regory Rodrigues (#11) @185\n• Serghei Spivac (#6) vs. Vitor Petrino @265\
|
||||
n• Reinier de Ridder vs. Roman Dolidze @205\n• MarQuel Mederos vs. Mason J
|
||||
ones @155\n• Carli Judice vs. Jeisla Chaves @125\n• Anthony Wint vs. Terra
|
||||
nce Chatman @265\n\nPrelims (3 hrs before Main)\n--------------------\n• J
|
||||
amall Emmers vs. Lerryan Douglas @145\n• Kennedy Nzechukwu vs. Shamil Gazi
|
||||
ev @265\n• Chris Padilla vs. Nasrat Haqparast @155\n• Marcio Barbosa vs. R
|
||||
yan Kuse @145\n• Gauge Young vs. Stan Dorsainvil @155\n• Wes Schultz vs. J
|
||||
ackson McVey @185\n• Shanelle Dyer vs. Elise Reed @115\n\nhttps://www.ufc.
|
||||
com/event/ufc-fight-night-august-22-2026\n\nAccurate as of Sep 30\, 7:26 P
|
||||
M EDT
|
||||
LOCATION:Golden 1 Center\, Sacramento\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-330
|
||||
SUMMARY:UFC 330: Makhachev vs Machado Garry
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260816T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Islam Makhachev (C) vs. Ian
|
||||
Machado Garry (#1) @170\n• Mackenzie Dern (C) vs. Gillian Robertson (#5) @
|
||||
115\n• Jalin Turner vs. Kauê Fernandes @155\n• Mansur Abdul-Malik vs. Dust
|
||||
in Stoltzfus @185\n• Edson Barboza vs. Esteban Ribovics @155\n\nPrelims (2
|
||||
hrs before Main)\n--------------------\n• Chidi Njokuani vs. Joel Álvarez
|
||||
@170\n• Charles Johnson vs. Eduardo Chapolin @CW\n• Donte Johnson vs. Eri
|
||||
c McConico @185\n• Vicente Luque vs. Tresean Gore @185\n\nEarly Prelims (3
|
||||
.5 hrs before Main)\n--------------------\n• Rafael Tobias vs. Lucas Ferna
|
||||
ndo @205\n• Neil Magny vs. Ramiz Brahimaj @170\n• Jeremiah Wells vs. Mykty
|
||||
bek Orolbai @170\n\nhttps://www.ufc.com/event/ufc-330\n\nAccurate as of Se
|
||||
p 30\, 7:26 PM EDT
|
||||
LOCATION:Xfinity Mobile Arena\, Philadelphia\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-335
|
||||
SUMMARY:UFC 335: TBD vs TBD
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20261213T020000Z
|
||||
DESCRIPTION:https://www.ufc.com/event/ufc-335\n\nAccurate as of Sep 30\, 7:
|
||||
26 PM EDT
|
||||
LOCATION:T-Mobile Arena\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-february-06-2027
|
||||
SUMMARY:UFC Fight Night: TBD vs TBD
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20270206T220000Z
|
||||
DESCRIPTION:https://www.ufc.com/event/ufc-fight-night-february-06-2027\n\nA
|
||||
ccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Afterpay Arena\, Sydney Olympic Park\, Australia
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-august-08-2026
|
||||
SUMMARY:UFC Fight Night: Gamrot vs Salkilld
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260809T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Mateusz Gamrot (#8) vs. Quil
|
||||
lan Salkilld (#12) @155\n• Diego Ferreira vs. Billy Quarantillo @155\n• Da
|
||||
rren Elkins vs. Yadier del Valle @145\n• Amanda Lemos (#8) vs. Alexia Thai
|
||||
nara (#12) @115\n• Billy Ray Goff vs. Ty Miller @170\n\nPrelims (3 hrs bef
|
||||
ore Main)\n--------------------\n• Steven Asplund vs. Guilherme Pat @265\n
|
||||
• Diyar Nurgozhay vs. Bruno Lopes @205\n• Louie Sutherland vs. José Montan
|
||||
ha @265\n• Manoel Sousa vs. Richie Miranda @155\n• Miles Johns vs. Gianni
|
||||
Vazquez @145\n• Juliana Miller vs. Ravena Oliveira @125\n• Gigi Canuto vs.
|
||||
Carol Foro @115\n\nhttps://www.ufc.com/event/ufc-fight-night-august-08-20
|
||||
26\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-august-01-2026
|
||||
SUMMARY:UFC Fight Night: Medic vs Rodriguez
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260801T170000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Uroš Medić (#14) vs. Daniel
|
||||
Rodriguez (#15) @170\n• Jan Błachowicz (#4) vs. Navajo Stirling (#15) @205
|
||||
\n• Aleksandar Rakić vs. Marcin Tybura (#12) @265\n• Duško Todorović vs. R
|
||||
obert Valentin @185\n• Vlasto Čepo vs. Gilbert Urbina @185\n• Miloš Janiči
|
||||
ć vs. Noah Gugnon @155\n\nPrelims (3 hrs before Main)\n-------------------
|
||||
-\n• Ludovít Klein vs. Tofiq Musayev @155\n• Oban Elliott vs. Michael Oliv
|
||||
eira @170\n• Borislav Nikolić vs. Mark Vologdin @135\n• Dennis Buzukja vs.
|
||||
Bogdan Grad @145\n• Mateusz Rębecki vs. Kyle Prepolec @155\n• Nina Miloše
|
||||
vić vs. Hailey Cowan @135\n• Jovan Leka vs. Alexander Poppeck @265\n• Mari
|
||||
na Spasić vs. Stephanie Luciano @115\n\nhttps://www.ufc.com/event/ufc-figh
|
||||
t-night-august-01-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Belgrade Arena\, BG\, Serbia
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-july-25-2026
|
||||
SUMMARY:UFC Fight Night: Ankalaev vs Guskov
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260725T160000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Magomed Ankalaev (#1) vs. Bo
|
||||
gdan Guskov (#9) @205\n• Steve Erceg (#10) vs. Ramazan Temirov @125\n• Mag
|
||||
omed Zaynukov vs. Damian Rzepecki @155\n• Rizvan Kuniev (#8) vs. Tyrell Fo
|
||||
rtune (#9) @265\n• Abubakar Vagaev vs. Saygid Izagakhmaev @170\n• Ismael B
|
||||
onfim vs. Axel Sola @155\n\nPrelims (3 hrs before Main)\n-----------------
|
||||
---\n• Valter Walker (#13) vs. Thomas Petersen @265\n• Dustin Jacoby vs. M
|
||||
uhammad Saidov @205\n• Santiago Ponzinibbio vs. Sam Patterson @170\n• Mago
|
||||
med Tuchalov vs. Brendson Ribeiro @205\n• Nurullo Aliev vs. Mike Davis @15
|
||||
5\n• Cody Gibson vs. Abdul Hussein @135\n\nhttps://www.ufc.com/event/ufc-f
|
||||
ight-night-july-25-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Etihad Arena\, Yas Island/Yas West\, United Arab Emirates
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-july-18-2026
|
||||
SUMMARY:UFC Fight Night: Du Plessis vs Usman
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260719T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Dricus Du Plessis (#2) vs. K
|
||||
amaru Usman (#9) @185\n• Jared Cannonier (#10) vs. Christian Leroy Duncan
|
||||
(#12) @185\n• Chase Hooper vs. Mitch Ramirez @155\n• Tabatha Ricci (#8) vs
|
||||
. Fatima Kline (#11) @115\n• Tommy McMillen vs. Alberto Montes @145\n\nPre
|
||||
lims (3 hrs before Main)\n--------------------\n• Austin Bashi vs. Jose Mi
|
||||
guel Delgado @145\n• Jean-Paul Lebosnoyani vs. Seokhyeon Ko @170\n• Levi R
|
||||
odrigues Jr. vs. Felipe Franco @205\n• Ezra Elliot vs. Damien Anderson @14
|
||||
5\n• Alden Coria vs. Stewart Nicoll @125\n• RJ Harris vs. Alvin Hines @265
|
||||
\n• Anna Melisano vs. Dione Barbosa @125\n\nhttps://www.ufc.com/event/ufc-
|
||||
fight-night-july-18-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Paycom Center\, Oklahoma City\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-329
|
||||
SUMMARY:UFC 329: McGregor vs Holloway 2
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260712T010000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Conor McGregor vs. Max Hollo
|
||||
way @170\n• Benoît Saint Denis (#5) vs. Paddy Pimblett (#6) @155\n• Cory S
|
||||
andhagen (#4) vs. Mario Bautista (#7) @135\n• Brandon Royval (#4) vs. Lone
|
||||
’er Kavanagh (#6) @125\n• King Green vs. Terrance McKinney @155\n\nPrelims
|
||||
(2 hrs before Main)\n--------------------\n• Nikita Krylov (#12) vs. Robe
|
||||
rt Whittaker @205\n• Gable Steveson vs. Elisha Ellison @265\n• Cody Garbra
|
||||
ndt vs. Adrian Yanez @135\n• Luke Riley vs. Kai Kamaka III @145\n\nEarly P
|
||||
relims (4 hrs before Main)\n--------------------\n• Tracy Cortez (#8) vs.
|
||||
Wang Cong (#12) @125\n• Damian Pinas vs. Cesar Almeida @185\n• Farid Basha
|
||||
rat (#15) vs. John Garza @135\n• Ryan Gandra vs. Zachary Reese @185\n• Ale
|
||||
ssandro Costa vs. Cody Durden @125\n\nhttps://www.ufc.com/event/ufc-329\n\
|
||||
nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:T-Mobile Arena\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-june-27-2026
|
||||
SUMMARY:UFC Fight Night: Fiziev vs Torres
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260627T160000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Rafael Fiziev (#11) vs. Manu
|
||||
el Torres (#15) @155\n• Shara Magomedov vs. Michel Pereira @185\n• Nazim S
|
||||
adykhov vs. Matheus Camilo @155\n• Asu Almabayev (#9) vs. Charles Johnson
|
||||
(#14) @125\n• Ikram Aliskerov vs. Brunno Ferreira @185\n• Abus Magomedov v
|
||||
s. Michal Oleksiejczuk @185\n\nPrelims (3 hrs before Main)\n--------------
|
||||
------\n• Farman Hasanov vs. Eric Nolan @170\n• Abdul Rakhman Yakhyaev vs.
|
||||
Julius Walker @205\n• Nursulton Ruziboev vs. Andrey Pulyaev @185\n• Kaan
|
||||
Ofli vs. Javier Reyes @145\n• Daniil Donchenko vs. Theodor Berggren @170\n
|
||||
• Bekzat Almakhan vs. Jean Matsumoto @135\n• Tahir Abdullayev vs. Jefferso
|
||||
n Nascimento @170\n\nhttps://www.ufc.com/event/ufc-fight-night-june-27-202
|
||||
6\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:National Gymnastics Arena\, Baku\, Azerbaijan
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-fight-night-june-20-2026
|
||||
SUMMARY:UFC Fight Night: Kape vs Horiguchi
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260621T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Manel Kape (#2) vs. Kyoji Ho
|
||||
riguchi (#5) @125\n• Ion Cutelaba vs. Navajo Stirling @205\n• Hyder Amil v
|
||||
s. Christian Rodriguez @145\n• Melsik Baghdasaryan vs. Murtazali Magomedov
|
||||
@145\n• Vinicius Oliveira vs. Andre Fili @145\n\nPrelims (3 hrs before Ma
|
||||
in)\n--------------------\n• Andre Lima vs. Kevin Borjas @125\n• Bia Mesqu
|
||||
ita (#13) vs. Melissa Mullins @135\n• Allan Nascimento vs. Mitch Raposo @1
|
||||
25\n• Gaston Bolanos vs. Michael Aswell Jr. @145\n• Leon Shahbazyan vs. Le
|
||||
van Chokheli @170\n• Karol Rosa (#8) vs. Luana Santos (#11) @135\n• Shane
|
||||
Collins vs. Otari Tanzilovi @145\n\nhttps://www.ufc.com/event/ufc-fight-ni
|
||||
ght-june-20-2026\n\nAccurate as of Sep 30\, 7:26 PM EDT
|
||||
LOCATION:Meta APEX\, Las Vegas\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:https://www.ufc.com/event/ufc-freedom-250
|
||||
SUMMARY:UFC Freedom 250: Topuria vs Gaethje
|
||||
DTSTAMP:20260930T232638Z
|
||||
DTSTART:20260615T000000Z
|
||||
DESCRIPTION:Main Card\n--------------------\n• Ilia Topuria (C) vs. Justin
|
||||
Gaethje (C) @155\n• Alex Pereira vs. Ciryl Gane (#1) @265\n• Sean O'Malley
|
||||
(#3) vs. Aiemann Zahabi (#6) @135\n• Josh Hokit (#5) vs. Derrick Lewis (#
|
||||
9) @265\n• Mauricio Ruffy (#9) vs. Michael Chandler (#13) @155\n• Bo Nicka
|
||||
l vs. Kyle Daukaus @185\n• Diego Lopes (#2) vs. Steve Garcia (#9) @145\n\n
|
||||
https://www.ufc.com/event/ufc-freedom-250\n\nAccurate as of Sep 30\, 7:26
|
||||
PM EDT
|
||||
LOCATION:The White House\, Washington\, United States
|
||||
DURATION:PT3H
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
@@ -0,0 +1,158 @@
|
||||
import { writeFile, readFile } from "fs/promises";
|
||||
|
||||
/**
|
||||
* Returns the details of a UFC event given its event ID and using the UFC API
|
||||
*
|
||||
* @param {number} eventId - The ID of a UFC event
|
||||
* @returns {Promise<object>} - A Promise that resolves with the details of
|
||||
* a UFC event
|
||||
*/
|
||||
async function fetchEvent(eventId) {
|
||||
try {
|
||||
const url =
|
||||
"https://d29dxerjsp82wz.cloudfront.net/api/v3/event/live/" +
|
||||
eventId +
|
||||
".json";
|
||||
const response = await fetch(url);
|
||||
const event = await response.json();
|
||||
return event;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Using the UFC API, search for the latest event ID, then request each event
|
||||
* preceding it until we reach an event that occurred 90 days before now, then
|
||||
* create events.json containing these events.
|
||||
* Finally return an array of these events
|
||||
*
|
||||
* @returns {Promise<Array<object>>} - A Promise that resolves with the array
|
||||
* of details of recent and upcoming UFC events
|
||||
*/
|
||||
async function initializeEvents() {
|
||||
// Binary search for the event with the highest valid event ID
|
||||
let min = 1180;
|
||||
let max = 2000; // Values should be updated when we reach UFC event ID 2000
|
||||
let mid = Math.ceil((min + max) / 2);
|
||||
|
||||
console.log("Intializing events.json");
|
||||
console.log("Finding latest event ID...");
|
||||
|
||||
try {
|
||||
while (min < max) {
|
||||
const event = await fetchEvent(mid);
|
||||
if (event.LiveEventDetail.EventId) min = mid;
|
||||
else max = mid - 1;
|
||||
mid = Math.ceil((min + max) / 2);
|
||||
}
|
||||
|
||||
console.log("Fetching recent and upcoming events:");
|
||||
|
||||
// Fetch all events starting from the latest event ID, moving backwards
|
||||
// until we reach an event that occured 90 days before now
|
||||
let eventId = mid;
|
||||
let fetchedEvents = [];
|
||||
let event;
|
||||
|
||||
do {
|
||||
console.log("Event ID:", eventId);
|
||||
|
||||
event = await fetchEvent(eventId);
|
||||
|
||||
// Only filter in UFC events
|
||||
if (event.LiveEventDetail.Organization.OrganizationId === 1)
|
||||
fetchedEvents.push(event);
|
||||
|
||||
eventId--;
|
||||
} while (
|
||||
new Date(event.LiveEventDetail.StartTime) >
|
||||
Date.now() - 1000 * 60 * 60 * 24 * 90
|
||||
);
|
||||
|
||||
console.log("Creating events.json");
|
||||
|
||||
// Write the fetched events to events.json
|
||||
const json = JSON.stringify(fetchedEvents, null, 2);
|
||||
writeFile("./events.json", json);
|
||||
|
||||
return fetchedEvents;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update upcoming events in events.json, and add newly found events to events.json
|
||||
* Return an array of these events
|
||||
*
|
||||
* @returns {Promise<Array<object>>} - A Promise that resolves with the array
|
||||
* of details of recent and upcoming UFC events
|
||||
*/
|
||||
async function updateEventsFile() {
|
||||
try {
|
||||
let events = JSON.parse(await readFile("./events.json"));
|
||||
|
||||
// Update upcoming events
|
||||
for (let i = 0; i < events.length; i++) {
|
||||
// Skip past events
|
||||
if (events[i].LiveEventDetail.Status === "Final") continue;
|
||||
|
||||
console.log("Updating event", events[i].LiveEventDetail.EventId);
|
||||
events[i] = fetchEvent(events[i].LiveEventDetail.EventId);
|
||||
}
|
||||
|
||||
events = await Promise.all(events);
|
||||
|
||||
// Starting from the latest event ID previously found, find and add any
|
||||
// new events
|
||||
let eventId = events[0].LiveEventDetail.EventId;
|
||||
let event;
|
||||
do {
|
||||
eventId++;
|
||||
|
||||
event = await fetchEvent(eventId);
|
||||
|
||||
// Only filter in UFC events
|
||||
if (
|
||||
event.LiveEventDetail.EventId &&
|
||||
event.LiveEventDetail.Organization.OrganizationId === 1
|
||||
) {
|
||||
console.log("Found new event", event.LiveEventDetail.EventId);
|
||||
events.unshift(event);
|
||||
}
|
||||
} while (event?.LiveEventDetail.EventId);
|
||||
|
||||
console.log("Updating events.json");
|
||||
|
||||
// Write the newly added and updated events to events.json
|
||||
const json = JSON.stringify(events, null, 2);
|
||||
writeFile("./events.json", json);
|
||||
|
||||
return events;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create events.json if it does not exist, otherwise update events.json.
|
||||
* Return an array of recent and upcoming events
|
||||
*
|
||||
* @returns {Promise<Array<object>>} - A Promise that resolves with the array
|
||||
* of details of recent and upcoming UFC events
|
||||
*/
|
||||
async function getEvents() {
|
||||
let events;
|
||||
|
||||
try {
|
||||
events = await updateEventsFile();
|
||||
if (!events) events = await initializeEvents();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
export { getEvents };
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5
-62
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>UFC Calendar</title>
|
||||
<link rel="icon" type="image/x-icon" href="./src/assets/favicon.ico" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
@@ -20,27 +20,6 @@
|
||||
background-color: rgb(243, 243, 243);
|
||||
font-family: "Inter", sans-serif;
|
||||
}
|
||||
.calendar-type-selector {
|
||||
margin: 20px 0;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
.calendar-type-selector label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
.calendar-type-selector input[type="radio"] {
|
||||
cursor: pointer;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin: 0;
|
||||
}
|
||||
.links {
|
||||
margin: 40px 20px;
|
||||
display: flex;
|
||||
@@ -86,47 +65,24 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Subscribe to this calendar to keep track of UFC events</h1>
|
||||
<div class="calendar-type-selector">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="calendar-type"
|
||||
value="all"
|
||||
checked
|
||||
onchange="updateCalendarLinks('all')"
|
||||
/>
|
||||
<span>All UFC Events</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="calendar-type"
|
||||
value="ppv"
|
||||
onchange="updateCalendarLinks('ppv')"
|
||||
/>
|
||||
<span>PPV Events Only</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="links">
|
||||
<a
|
||||
class="sub-link"
|
||||
id="apple-link"
|
||||
href="webcal://raw.githubusercontent.com/clarencechaan/ufc-cal/ics/UFC.ics"
|
||||
><img src="./src/assets/apple.svg" alt="apple" />
|
||||
><img src="apple.svg" alt="apple" />
|
||||
<div>Apple</div>
|
||||
</a>
|
||||
<a
|
||||
class="sub-link"
|
||||
id="google-link"
|
||||
href="https://calendar.google.com/calendar/u/0/r?cid=webcal://raw.githubusercontent.com/clarencechaan/ufc-cal/ics/UFC.ics"
|
||||
><img src="./src/assets/google.svg" alt="google" />
|
||||
><img src="google.svg" alt="google" />
|
||||
<div>Google</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="sub-manual">
|
||||
<p>Or subscribe manually from your calendar app using this URL:</p>
|
||||
<p>Or subscribe manually from your calendar app:</p>
|
||||
<div class="code-wrapper">
|
||||
<code id="manual-url"
|
||||
<code
|
||||
>webcal://raw.githubusercontent.com/clarencechaan/ufc-cal/ics/UFC.ics</code
|
||||
>
|
||||
</div>
|
||||
@@ -137,18 +93,5 @@
|
||||
>Source code on GitHub</a
|
||||
>
|
||||
</p>
|
||||
<script>
|
||||
function updateCalendarLinks(type) {
|
||||
const filename = type === "ppv" ? "UFC-PPV.ics" : "UFC.ics";
|
||||
const baseUrl =
|
||||
"webcal://raw.githubusercontent.com/clarencechaan/ufc-cal/ics/";
|
||||
const fullUrl = baseUrl + filename;
|
||||
|
||||
document.getElementById("apple-link").href = fullUrl;
|
||||
document.getElementById("google-link").href =
|
||||
"https://calendar.google.com/calendar/u/0/r?cid=" + fullUrl;
|
||||
document.getElementById("manual-url").textContent = fullUrl;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,199 @@
|
||||
import { getAllDetailedEvents } from "./scrape.js";
|
||||
import { getEvents } from "./api.js";
|
||||
import { writeFile } from "fs/promises";
|
||||
import { createEvents } from "ics";
|
||||
|
||||
/**
|
||||
* Extracts the details of recent and upcoming UFC events by scraping the
|
||||
* UFC website, then creates an ICS file named "UFC.ics" in the current
|
||||
* directory containing these events
|
||||
*
|
||||
* @returns {Promise<void>} - A Promise that resolves when the ICS file is created
|
||||
*/
|
||||
async function createICSFromScrape() {
|
||||
// Creating ICS by scraping the UFC website
|
||||
|
||||
try {
|
||||
let events = await getAllDetailedEvents();
|
||||
if (!events.length) throw new Error("No events retrieved");
|
||||
|
||||
// Get current date and time to communicate to the user how up-to-date
|
||||
// the event details are
|
||||
let currentDateTime = new Date();
|
||||
let dateTimestr = currentDateTime.toLocaleString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
timeZone: "America/Toronto",
|
||||
timeZoneName: "short",
|
||||
});
|
||||
|
||||
// Convert event details in the format in accordance with the ICS generator
|
||||
events = events.map((event) => {
|
||||
let date = new Date(parseInt(event.date) * 1000);
|
||||
let start = [
|
||||
date.getFullYear(),
|
||||
date.getMonth() + 1,
|
||||
date.getDate(),
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
];
|
||||
let duration = { hours: 3 };
|
||||
let title = event.name;
|
||||
let description = "";
|
||||
|
||||
// Distinguish between main card and prelims if this information has been
|
||||
// announced by the UFC, otherwise list all fights without categorizing
|
||||
if (event.fightCard.length)
|
||||
description += event.fightCard.join("\n") + "\n";
|
||||
if (event.mainCard.length)
|
||||
description +=
|
||||
"Main Card\n----------\n" + event.mainCard.join("\n") + "\n";
|
||||
if (event.prelims.length)
|
||||
description +=
|
||||
"\nPrelims\n----------\n" + event.prelims.join("\n") + "\n";
|
||||
|
||||
description += "\n" + event.url;
|
||||
description += "\n\nAccurate as of " + dateTimestr;
|
||||
|
||||
let location = event.location;
|
||||
let uid = event.url;
|
||||
let calName = "UFC";
|
||||
return {
|
||||
start,
|
||||
duration,
|
||||
title,
|
||||
description,
|
||||
location,
|
||||
uid,
|
||||
calName,
|
||||
};
|
||||
});
|
||||
|
||||
console.log("\nDetailed events:");
|
||||
console.log(events);
|
||||
|
||||
// Create UFC.ics
|
||||
writeFile(`UFC.ics`, createEvents(events).value);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the details of recent and upcoming UFC events by using the UFC API,
|
||||
* then creates an ICS file named "UFC.ics" in the current directory containing
|
||||
* these events
|
||||
*
|
||||
* @returns {Promise<void>} - A Promise that resolves when the ICS file is created
|
||||
*/
|
||||
async function createICSFromAPI() {
|
||||
// Creating ICS by using the UFC API
|
||||
|
||||
let events;
|
||||
try {
|
||||
events = await getEvents();
|
||||
if (!events.length) throw new Error("No events retrieved");
|
||||
|
||||
// Get current date and time to communicate to the user how up-to-date
|
||||
// the event details are
|
||||
let currentDateTime = new Date();
|
||||
let dateTimestr = currentDateTime.toLocaleString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
timeZone: "America/Toronto",
|
||||
timeZoneName: "short",
|
||||
});
|
||||
|
||||
// Convert event details in the format in accordance with the ICS generator
|
||||
events = events.map((event) => {
|
||||
let date = new Date(
|
||||
event.LiveEventDetail.FightCard[0].CardSegmentStartTime ||
|
||||
event.LiveEventDetail.StartTime
|
||||
);
|
||||
let start = [
|
||||
date.getFullYear(),
|
||||
date.getMonth() + 1,
|
||||
date.getDate(),
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
];
|
||||
let duration = { hours: 3 };
|
||||
let title = event.LiveEventDetail.Name;
|
||||
let description = "";
|
||||
|
||||
let mainCard = [];
|
||||
let prelims = [];
|
||||
let fightCard = [];
|
||||
|
||||
// Helper function to convert fight to a string line to be displayed
|
||||
// in the calendar
|
||||
function fightToStr(fight) {
|
||||
return (
|
||||
"• " +
|
||||
fight.Fighters[0].Name.FirstName +
|
||||
" " +
|
||||
fight.Fighters[0].Name.LastName +
|
||||
" vs. " +
|
||||
fight.Fighters[1].Name.FirstName +
|
||||
" " +
|
||||
fight.Fighters[1].Name.LastName +
|
||||
" @" +
|
||||
(fight.WeightClass.CatchWeight || fight.WeightClass.Weight.slice(-3))
|
||||
);
|
||||
}
|
||||
|
||||
if (event.LiveEventDetail.FightCard.every((fight) => fight.CardSegment)) {
|
||||
for (const fight of event.LiveEventDetail.FightCard)
|
||||
if (fight.CardSegment === "Main") mainCard.push(fightToStr(fight));
|
||||
else prelims.push(fightToStr(fight));
|
||||
} else {
|
||||
for (const fight of event.LiveEventDetail.FightCard)
|
||||
fightCard.push(fightToStr(fight));
|
||||
}
|
||||
|
||||
// Distinguish between main card and prelims if this information has been
|
||||
// announced by the UFC, otherwise list all fights without categorizing
|
||||
if (fightCard.length) description += fightCard.join("\n") + "\n";
|
||||
if (mainCard.length)
|
||||
description += "Main Card\n----------\n" + mainCard.join("\n") + "\n";
|
||||
if (prelims.length)
|
||||
description += "\nPrelims\n----------\n" + prelims.join("\n") + "\n";
|
||||
|
||||
description +=
|
||||
"\nhttps://www.google.com/search?q=" + title.replaceAll(" ", "+");
|
||||
description += "\n\nAccurate as of " + dateTimestr;
|
||||
|
||||
let location =
|
||||
event.LiveEventDetail.Location.Venue +
|
||||
", " +
|
||||
event.LiveEventDetail.Location.City +
|
||||
", " +
|
||||
event.LiveEventDetail.Location.Country;
|
||||
let uid = "ufc-id-" + event.LiveEventDetail.EventId;
|
||||
let calName = "UFC";
|
||||
return {
|
||||
start,
|
||||
duration,
|
||||
title,
|
||||
description,
|
||||
location,
|
||||
uid,
|
||||
calName,
|
||||
};
|
||||
});
|
||||
|
||||
console.log("\nDetailed events:");
|
||||
console.log(events);
|
||||
|
||||
// Create UFC.ics
|
||||
writeFile(`UFC.ics`, createEvents(events).value);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
createICSFromAPI();
|
||||
+1
@@ -0,0 +1 @@
|
||||
../he/bin/he
|
||||
+1
@@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
{
|
||||
"name": "ufc-cal",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
|
||||
"integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"nth-check": "^2.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/css-what": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz",
|
||||
"integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"entities": "^4.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domelementtype": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
|
||||
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/domhandler": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
|
||||
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz",
|
||||
"integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"he": "bin/he"
|
||||
}
|
||||
},
|
||||
"node_modules/html-entities": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz",
|
||||
"integrity": "sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/mdevils"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://patreon.com/mdevils"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/ics": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ics/-/ics-3.4.0.tgz",
|
||||
"integrity": "sha512-ewKO7nF5BKhVKas3XmjB1siXdhJ7OvojY+HmD1ik/lozuzcZdy+Wt6IbB2San2gvHZAMUZhTa4UQyCE1I8e+sw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.1.23",
|
||||
"yup": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.6",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
|
||||
"integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/node-html-parser": {
|
||||
"version": "6.1.9",
|
||||
"resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.9.tgz",
|
||||
"integrity": "sha512-nQ+MRf0PmRTLcMalVqMsWvceSaBydBCBlnQSL78HVk/E8e0Aazyao4SI9aB67XAAgOgHMsw7q5dJBUPPt9XE3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"css-select": "^5.1.0",
|
||||
"he": "1.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nth-check": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
|
||||
"integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"boolbase": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/nth-check?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/property-expr": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.5.tgz",
|
||||
"integrity": "sha512-IJUkICM5dP5znhCckHSv30Q4b5/JA5enCtkRHYaOVOAocnH/1BQEYTC5NMfT3AVl/iXKdr3aqQbQn9DxyWknwA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/tiny-case": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tiny-case/-/tiny-case-1.0.3.tgz",
|
||||
"integrity": "sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/toposort": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz",
|
||||
"integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/type-fest": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz",
|
||||
"integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12.20"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/yup": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/yup/-/yup-1.2.0.tgz",
|
||||
"integrity": "sha512-PPqYKSAXjpRCgLgLKVGPA33v5c/WgEx3wi6NFjIiegz90zSwyMpvTFp/uGcVnnbx6to28pgnzp/q8ih3QRjLMQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"property-expr": "^2.0.5",
|
||||
"tiny-case": "^1.0.3",
|
||||
"toposort": "^2.0.2",
|
||||
"type-fest": "^2.19.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#boolbase
|
||||
This very simple module provides two basic functions, one that always returns true (`trueFunc`) and one that always returns false (`falseFunc`).
|
||||
|
||||
###WTF?
|
||||
|
||||
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.
|
||||
|
||||
###And why is this a separate module?
|
||||
|
||||
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.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
trueFunc: function trueFunc(){
|
||||
return true;
|
||||
},
|
||||
falseFunc: function falseFunc(){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "boolbase",
|
||||
"version": "1.0.0",
|
||||
"description": "two functions: One that returns true, one that returns false",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fb55/boolbase"
|
||||
},
|
||||
"keywords": [
|
||||
"boolean",
|
||||
"function"
|
||||
],
|
||||
"author": "Felix Boehm <[email protected]>",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/fb55/boolbase/issues"
|
||||
},
|
||||
"homepage": "https://github.com/fb55/boolbase"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
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.
|
||||
|
||||
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,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
# css-select [](https://npmjs.org/package/css-select) [](http://travis-ci.com/fb55/css-select) [](https://npmjs.org/package/css-select) [](https://coveralls.io/r/fb55/css-select)
|
||||
|
||||
A CSS selector compiler and engine
|
||||
|
||||
## What?
|
||||
|
||||
As a **compiler**, css-select turns CSS selectors into functions that tests if
|
||||
elements match them.
|
||||
|
||||
As an **engine**, css-select looks through a DOM tree, searching for elements.
|
||||
Elements are tested "from the top", similar to how browsers execute CSS
|
||||
selectors.
|
||||
|
||||
In its default configuration, css-select queries the DOM structure of the
|
||||
[`domhandler`](https://github.com/fb55/domhandler) module (also known as
|
||||
htmlparser2 DOM). To query alternative DOM structures, see [`Options`](#options)
|
||||
below.
|
||||
|
||||
**Features:**
|
||||
|
||||
- 🔬 Full implementation of CSS3 selectors, as well as most CSS4 selectors
|
||||
- 🧪 Partial implementation of jQuery/Sizzle extensions (see
|
||||
[cheerio-select](https://github.com/cheeriojs/cheerio-select) for the
|
||||
remaining selectors)
|
||||
- 🧑🔬 High test coverage, including the full test suites from
|
||||
[`Sizzle`](https://github.com/jquery/sizzle),
|
||||
[`Qwery`](https://github.com/ded/qwery) and
|
||||
[`NWMatcher`](https://github.com/dperini/nwmatcher/) and .
|
||||
- 🥼 Reliably great performance
|
||||
|
||||
## Why?
|
||||
|
||||
Most CSS engines written in JavaScript execute selectors left-to-right. That
|
||||
means thet execute every component of the selector in order, from left to right.
|
||||
As an example: For the selector `a b`, these engines will first query for `a`
|
||||
elements, then search these for `b` elements. (That's the approach of eg.
|
||||
[`Sizzle`](https://github.com/jquery/sizzle),
|
||||
[`Qwery`](https://github.com/ded/qwery) and
|
||||
[`NWMatcher`](https://github.com/dperini/nwmatcher/).)
|
||||
|
||||
While this works, it has some downsides: Children of `a`s will be checked
|
||||
multiple times; first, to check if they are also `a`s, then, for every superior
|
||||
`a` once, if they are `b`s. Using
|
||||
[Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be
|
||||
`O(n^(k+1))`, where `k` is the number of descendant selectors (that's the space
|
||||
in the example above).
|
||||
|
||||
The far more efficient approach is to first look for `b` elements, then check if
|
||||
they have superior `a` elements: Using big O notation again, that would be
|
||||
`O(n)`. That's called right-to-left execution.
|
||||
|
||||
And that's what css-select does – and why it's quite performant.
|
||||
|
||||
## How does it work?
|
||||
|
||||
By building a stack of functions.
|
||||
|
||||
_Wait, what?_
|
||||
|
||||
Okay, so let's suppose we want to compile the selector `a b`, for right-to-left
|
||||
execution. We start by _parsing_ the selector. This turns the selector into an
|
||||
array of the building blocks. That's what the
|
||||
[`css-what`](https://github.com/fb55/css-what) module is for, if you want to
|
||||
have a look.
|
||||
|
||||
Anyway, after parsing, we end up with an array like this one:
|
||||
|
||||
```js
|
||||
[
|
||||
{ type: "tag", name: "a" },
|
||||
{ type: "descendant" },
|
||||
{ type: "tag", name: "b" },
|
||||
];
|
||||
```
|
||||
|
||||
(Actually, this array is wrapped in another array, but that's another story,
|
||||
involving commas in selectors.)
|
||||
|
||||
Now that we know the meaning of every part of the selector, we can compile it.
|
||||
That is where things become interesting.
|
||||
|
||||
The basic idea is to turn every part of the selector into a function, which
|
||||
takes an element as its only argument. The function checks whether a passed
|
||||
element matches its part of the selector: If it does, the element is passed to
|
||||
the next function representing the next part of the selector. That function does
|
||||
the same. If an element is accepted by all parts of the selector, it _matches_
|
||||
the selector and double rainbow ALL THE WAY.
|
||||
|
||||
As said before, we want to do right-to-left execution with all the big O
|
||||
improvements. That means elements are passed from the rightmost part of the
|
||||
selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course
|
||||
`a`).
|
||||
|
||||
For traversals, such as the _descendant_ operating the space between `a` and
|
||||
`b`, we walk up the DOM tree, starting from the element passed as argument.
|
||||
|
||||
_//TODO: More in-depth description. Implementation details. Build a spaceship._
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const CSSselect = require("css-select");
|
||||
```
|
||||
|
||||
**Note:** css-select throws errors when invalid selectors are passed to it. This
|
||||
is done to aid with writing css selectors, but can be unexpected when processing
|
||||
arbitrary strings.
|
||||
|
||||
#### `CSSselect.selectAll(query, elems, options)`
|
||||
|
||||
Queries `elems`, returns an array containing all matches.
|
||||
|
||||
- `query` can be either a CSS selector or a function.
|
||||
- `elems` can be either an array of elements, or a single element. If it is an
|
||||
element, its children will be queried.
|
||||
- `options` is described below.
|
||||
|
||||
Aliases: `default` export, `CSSselect.iterate(query, elems)`.
|
||||
|
||||
#### `CSSselect.compile(query, options)`
|
||||
|
||||
Compiles the query, returns a function.
|
||||
|
||||
#### `CSSselect.is(elem, query, options)`
|
||||
|
||||
Tests whether or not an element is matched by `query`. `query` can be either a
|
||||
CSS selector or a function.
|
||||
|
||||
#### `CSSselect.selectOne(query, elems, options)`
|
||||
|
||||
Arguments are the same as for `CSSselect.selectAll(query, elems)`. Only returns
|
||||
the first match, or `null` if there was no match.
|
||||
|
||||
### Options
|
||||
|
||||
All options are optional.
|
||||
|
||||
- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`.
|
||||
- `rootFunc`: The last function in the stack, will be called with the last
|
||||
element that's looked at.
|
||||
- `adapter`: The adapter to use when interacting with the backing DOM
|
||||
structure. By default it uses the `domutils` module.
|
||||
- `context`: The context of the current query. Used to limit the scope of
|
||||
searches. Can be matched directly using the `:scope` pseudo-class.
|
||||
- `relativeSelector`: By default, selectors are relative to the `context`,
|
||||
which means that no parent elements of the context will be matched. (Eg.
|
||||
`a b c` with context `b` will never give any results.) If `relativeSelector`
|
||||
is set to `false`, selectors won't be
|
||||
[absolutized](http://www.w3.org/TR/selectors4/#absolutizing) and selectors
|
||||
can test for parent elements outside of the `context`.
|
||||
- `cacheResults`: Allow css-select to cache results for some selectors,
|
||||
sometimes greatly improving querying performance. Disable this if your
|
||||
document can change in between queries with the same compiled selector.
|
||||
Default: `true`.
|
||||
- `pseudos`: A map of pseudo-class names to functions or strings.
|
||||
|
||||
#### Custom Adapters
|
||||
|
||||
A custom adapter must match the interface described
|
||||
[here](https://github.com/fb55/css-select/blob/1aa44bdd64aaf2ebdfd7f338e2e76bed36521957/src/types.ts#L6-L96).
|
||||
|
||||
You may want to have a look at [`domutils`](https://github.com/fb55/domutils) to
|
||||
see the default implementation, or at
|
||||
[`css-select-browser-adapter`](https://github.com/nrkn/css-select-browser-adapter/blob/master/index.js)
|
||||
for an implementation backed by the DOM.
|
||||
|
||||
## Supported selectors
|
||||
|
||||
_As defined by CSS 4 and / or jQuery._
|
||||
|
||||
- [Selector lists](https://developer.mozilla.org/en-US/docs/Web/CSS/Selector_list)
|
||||
(`,`)
|
||||
- [Universal](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors)
|
||||
(`*`)
|
||||
- [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors)
|
||||
(`<tagname>`)
|
||||
- [Descendant](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator)
|
||||
(` `)
|
||||
- [Child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator)
|
||||
(`>`)
|
||||
- Parent (`<`)
|
||||
- [Adjacent sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator)
|
||||
(`+`)
|
||||
- [General sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator)
|
||||
(`~`)
|
||||
- [Attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
|
||||
(`[attr=foo]`), with supported comparisons:
|
||||
- `[attr]` (existential)
|
||||
- `=`
|
||||
- `~=`
|
||||
- `|=`
|
||||
- `*=`
|
||||
- `^=`
|
||||
- `$=`
|
||||
- `!=`
|
||||
- `i` and `s` can be added after the comparison to make the comparison
|
||||
case-insensitive or case-sensitive (eg. `[attr=foo i]`). If neither is
|
||||
supplied, css-select will follow the HTML spec's
|
||||
[case-sensitivity rules](https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors).
|
||||
- Pseudos:
|
||||
- [`:not`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)
|
||||
- [`:contains`](https://api.jquery.com/contains-selector)
|
||||
- `:icontains` (case-insensitive version of `:contains`)
|
||||
- [`:has`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has)
|
||||
- [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root)
|
||||
- [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty)
|
||||
- [`:parent`](https://api.jquery.com/parent-selector)
|
||||
- [`:first-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-child),
|
||||
[`:last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-child),
|
||||
[`:first-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-of-type),
|
||||
[`:last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-of-type)
|
||||
- [`:only-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-of-type),
|
||||
[`:only-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child)
|
||||
- [`:nth-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child),
|
||||
[`:nth-last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child),
|
||||
[`:nth-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type),
|
||||
[`:nth-last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-of-type),
|
||||
- [`:link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:link),
|
||||
[`:any-link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link)
|
||||
- [`:visited`](https://developer.mozilla.org/en-US/docs/Web/CSS/:visited),
|
||||
[`:hover`](https://developer.mozilla.org/en-US/docs/Web/CSS/:hover),
|
||||
[`:active`](https://developer.mozilla.org/en-US/docs/Web/CSS/:active)
|
||||
(these depend on optional `Adapter` methods, so these will only match
|
||||
elements if implemented in `Adapter`)
|
||||
- [`:selected`](https://api.jquery.com/selected-selector),
|
||||
[`:checked`](https://developer.mozilla.org/en-US/docs/Web/CSS/:checked)
|
||||
- [`:enabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled),
|
||||
[`:disabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled)
|
||||
- [`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required),
|
||||
[`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional)
|
||||
- [`:header`](https://api.jquery.com/header-selector),
|
||||
[`:button`](https://api.jquery.com/button-selector),
|
||||
[`:input`](https://api.jquery.com/input-selector),
|
||||
[`:text`](https://api.jquery.com/text-selector),
|
||||
[`:checkbox`](https://api.jquery.com/checkbox-selector),
|
||||
[`:file`](https://api.jquery.com/file-selector),
|
||||
[`:password`](https://api.jquery.com/password-selector),
|
||||
[`:reset`](https://api.jquery.com/reset-selector),
|
||||
[`:radio`](https://api.jquery.com/radio-selector) etc.
|
||||
- [`:is`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is), plus its
|
||||
legacy alias `:matches`
|
||||
- [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope)
|
||||
(uses the context from the passed options)
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security). Tidelift will
|
||||
coordinate the fix and disclosure.
|
||||
|
||||
## `css-select` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `css-select` and thousands of other packages are working with
|
||||
Tidelift to deliver commercial support and maintenance for the open source
|
||||
dependencies you use to build your applications. Save time, reduce risk, and
|
||||
improve code health, while paying the maintainers of the exact dependencies you
|
||||
use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/npm-css-select?utm_source=npm-css-select&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { CompiledQuery, InternalOptions } from "./types.js";
|
||||
import type { AttributeSelector, AttributeAction } from "css-what";
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
export declare const attributeRules: Record<AttributeAction, <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, data: AttributeSelector, options: InternalOptions<Node, ElementNode>) => CompiledQuery<ElementNode>>;
|
||||
//# sourceMappingURL=attributes.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"attributes.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["attributes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+EnE;;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,CAsLlC,CAAC"}
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.attributeRules = void 0;
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
/**
|
||||
* All reserved characters in a regex, used for escaping.
|
||||
*
|
||||
* Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
|
||||
* https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
|
||||
*/
|
||||
var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
||||
function escapeRegex(value) {
|
||||
return value.replace(reChars, "\\$&");
|
||||
}
|
||||
/**
|
||||
* Attributes that are case-insensitive in HTML.
|
||||
*
|
||||
* @private
|
||||
* @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
|
||||
*/
|
||||
var caseInsensitiveAttributes = new Set([
|
||||
"accept",
|
||||
"accept-charset",
|
||||
"align",
|
||||
"alink",
|
||||
"axis",
|
||||
"bgcolor",
|
||||
"charset",
|
||||
"checked",
|
||||
"clear",
|
||||
"codetype",
|
||||
"color",
|
||||
"compact",
|
||||
"declare",
|
||||
"defer",
|
||||
"dir",
|
||||
"direction",
|
||||
"disabled",
|
||||
"enctype",
|
||||
"face",
|
||||
"frame",
|
||||
"hreflang",
|
||||
"http-equiv",
|
||||
"lang",
|
||||
"language",
|
||||
"link",
|
||||
"media",
|
||||
"method",
|
||||
"multiple",
|
||||
"nohref",
|
||||
"noresize",
|
||||
"noshade",
|
||||
"nowrap",
|
||||
"readonly",
|
||||
"rel",
|
||||
"rev",
|
||||
"rules",
|
||||
"scope",
|
||||
"scrolling",
|
||||
"selected",
|
||||
"shape",
|
||||
"target",
|
||||
"text",
|
||||
"type",
|
||||
"valign",
|
||||
"valuetype",
|
||||
"vlink",
|
||||
]);
|
||||
function shouldIgnoreCase(selector, options) {
|
||||
return typeof selector.ignoreCase === "boolean"
|
||||
? selector.ignoreCase
|
||||
: selector.ignoreCase === "quirks"
|
||||
? !!options.quirksMode
|
||||
: !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
|
||||
}
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
exports.attributeRules = {
|
||||
equals: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length === value.length &&
|
||||
attr.toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return adapter.getAttributeValue(elem, name) === value && next(elem);
|
||||
};
|
||||
},
|
||||
hyphen: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
var len = value.length;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function hyphenIC(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function hyphen(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len) === value &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
element: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name, value = data.value;
|
||||
if (/\s/.test(value)) {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
var regex = new RegExp("(?:^|\\s)".concat(escapeRegex(value), "(?:$|\\s)"), shouldIgnoreCase(data, options) ? "i" : "");
|
||||
return function element(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
exists: function (next, _a, _b) {
|
||||
var name = _a.name;
|
||||
var adapter = _b.adapter;
|
||||
return function (elem) { return adapter.hasAttrib(elem, name) && next(elem); };
|
||||
},
|
||||
start: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
var len = value.length;
|
||||
if (len === 0) {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= len &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
end: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
var len = -value.length;
|
||||
if (len === 0) {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return ((_a = adapter
|
||||
.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
any: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name, value = data.value;
|
||||
if (value === "") {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
var regex_1 = new RegExp(escapeRegex(value), "i");
|
||||
return function anyIC(elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex_1.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
not: function (next, data, options) {
|
||||
var adapter = options.adapter;
|
||||
var name = data.name;
|
||||
var value = data.value;
|
||||
if (value === "") {
|
||||
return function (elem) {
|
||||
return !!adapter.getAttributeValue(elem, name) && next(elem);
|
||||
};
|
||||
}
|
||||
else if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function (elem) {
|
||||
var attr = adapter.getAttributeValue(elem, name);
|
||||
return ((attr == null ||
|
||||
attr.length !== value.length ||
|
||||
attr.toLowerCase() !== value) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return adapter.getAttributeValue(elem, name) !== value && next(elem);
|
||||
};
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=attributes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"attributes.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["attributes.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAgC;AAIhC;;;;;GAKG;AACH,IAAM,OAAO,GAAG,0BAA0B,CAAC;AAC3C,SAAS,WAAW,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,IAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACtC,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,SAAS;IACT,SAAS;IACT,OAAO;IACP,UAAU;IACV,OAAO;IACP,SAAS;IACT,SAAS;IACT,OAAO;IACP,KAAK;IACL,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;IACN,OAAO;IACP,UAAU;IACV,YAAY;IACZ,MAAM;IACN,UAAU;IACV,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,UAAU;IACV,SAAS;IACT,QAAQ;IACR,UAAU;IACV,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,WAAW;IACX,UAAU;IACV,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,OAAO;CACV,CAAC,CAAC;AAEH,SAAS,gBAAgB,CACrB,QAA2B,EAC3B,OAA2C;IAE3C,O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I,CAAC,CAAC;gBACnD,OAAO,CACH,IAAI,IAAI,IAAI;oBACZ,IAAI,CAAC,MAAM,IAAI,GAAG;oBAClB,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK;oBAC3C,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACN,CAAC,CAAC;SACL;QAED,OAAO,UAAC,IAAI;;YACR,OAAA,CAAC,CAAC,CAAA,MAAA,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,0CAAE,UAAU,CAAC,KAAK,CAAC,CAAA;gBAC1D,IAAI,CAAC,IAAI,CAAC,CAAA;SAAA,CAAC;IACnB,CAAC;IACD,GAAG,YAAC,IAAI,EAAE,IAAI,EAAE,OAAO;QACX,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QACpB,IAAA,IAAI,GAAK,IAAI,KAAT,CAAU;QAChB,IAAA,KAAK,GAAK,IAAI,MAAT,CAAU;QACrB,IAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;QAE1B,IAAI,GAAG,KAAK,CAAC,EAAE;YACX,OAAO,kBAAQ,CAAC,SAAS,CAAC;SAC7B;QAED,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;YACjC,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YAE5B,OAAO,UAAC,IAAI;;gBACR,OAAA,CAAA,MAAA,OAAO;qBACF,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,0CAC5B,MAAM,CAAC,GAAG,EACX,WAAW,EAAE,MAAK,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;aAAA,CAAC;SAClD;QAED,OAAO,UAAC,IAAI;;YACR,OAAA,Line truncated
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector } from "./types.js";
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
export declare function compile<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<Node>;
|
||||
export declare function compileUnsafe<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
export declare function compileToken<Node, ElementNode extends Node>(token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"compile.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAgB,MAAM,UAAU,CAAC;AAQzD,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;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,IAAI,CAAC,CAGrB;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,CAG5B;AAqDD,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,CAsD5B"}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileToken = exports.compileUnsafe = exports.compile = void 0;
|
||||
var css_what_1 = require("css-what");
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
var sort_js_1 = __importStar(require("./sort.js"));
|
||||
var general_js_1 = require("./general.js");
|
||||
var subselects_js_1 = require("./pseudo-selectors/subselects.js");
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
function compile(selector, options, context) {
|
||||
var next = compileUnsafe(selector, options, context);
|
||||
return (0, subselects_js_1.ensureIsTag)(next, options.adapter);
|
||||
}
|
||||
exports.compile = compile;
|
||||
function compileUnsafe(selector, options, context) {
|
||||
var token = typeof selector === "string" ? (0, css_what_1.parse)(selector) : selector;
|
||||
return compileToken(token, options, context);
|
||||
}
|
||||
exports.compileUnsafe = compileUnsafe;
|
||||
function includesScopePseudo(t) {
|
||||
return (t.type === css_what_1.SelectorType.Pseudo &&
|
||||
(t.name === "scope" ||
|
||||
(Array.isArray(t.data) &&
|
||||
t.data.some(function (data) { return data.some(includesScopePseudo); }))));
|
||||
}
|
||||
var DESCENDANT_TOKEN = { type: css_what_1.SelectorType.Descendant };
|
||||
var FLEXIBLE_DESCENDANT_TOKEN = {
|
||||
type: "_flexibleDescendant",
|
||||
};
|
||||
var SCOPE_TOKEN = {
|
||||
type: css_what_1.SelectorType.Pseudo,
|
||||
name: "scope",
|
||||
data: null,
|
||||
};
|
||||
/*
|
||||
* CSS 4 Spec (Draft): 3.4.1. Absolutizing a Relative Selector
|
||||
* http://www.w3.org/TR/selectors4/#absolutizing
|
||||
*/
|
||||
function absolutize(token, _a, context) {
|
||||
var adapter = _a.adapter;
|
||||
// TODO Use better check if the context is a document
|
||||
var hasContext = !!(context === null || context === void 0 ? void 0 : context.every(function (e) {
|
||||
var parent = adapter.isTag(e) && adapter.getParent(e);
|
||||
return e === subselects_js_1.PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
|
||||
}));
|
||||
for (var _i = 0, token_1 = token; _i < token_1.length; _i++) {
|
||||
var t = token_1[_i];
|
||||
if (t.length > 0 &&
|
||||
(0, sort_js_1.isTraversal)(t[0]) &&
|
||||
t[0].type !== css_what_1.SelectorType.Descendant) {
|
||||
// Don't continue in else branch
|
||||
}
|
||||
else if (hasContext && !t.some(includesScopePseudo)) {
|
||||
t.unshift(DESCENDANT_TOKEN);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
t.unshift(SCOPE_TOKEN);
|
||||
}
|
||||
}
|
||||
function compileToken(token, options, context) {
|
||||
var _a;
|
||||
token.forEach(sort_js_1.default);
|
||||
context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
|
||||
var isArrayContext = Array.isArray(context);
|
||||
var finalContext = context && (Array.isArray(context) ? context : [context]);
|
||||
// Check if the selector is relative
|
||||
if (options.relativeSelector !== false) {
|
||||
absolutize(token, options, finalContext);
|
||||
}
|
||||
else if (token.some(function (t) { return t.length > 0 && (0, sort_js_1.isTraversal)(t[0]); })) {
|
||||
throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
|
||||
}
|
||||
var shouldTestNextSiblings = false;
|
||||
var query = token
|
||||
.map(function (rules) {
|
||||
if (rules.length >= 2) {
|
||||
var first = rules[0], second = rules[1];
|
||||
if (first.type !== css_what_1.SelectorType.Pseudo ||
|
||||
first.name !== "scope") {
|
||||
// Ignore
|
||||
}
|
||||
else if (isArrayContext &&
|
||||
second.type === css_what_1.SelectorType.Descendant) {
|
||||
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
|
||||
}
|
||||
else if (second.type === css_what_1.SelectorType.Adjacent ||
|
||||
second.type === css_what_1.SelectorType.Sibling) {
|
||||
shouldTestNextSiblings = true;
|
||||
}
|
||||
}
|
||||
return compileRules(rules, options, finalContext);
|
||||
})
|
||||
.reduce(reduceRules, boolbase_1.default.falseFunc);
|
||||
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
||||
return query;
|
||||
}
|
||||
exports.compileToken = compileToken;
|
||||
function compileRules(rules, options, context) {
|
||||
var _a;
|
||||
return rules.reduce(function (previous, rule) {
|
||||
return previous === boolbase_1.default.falseFunc
|
||||
? boolbase_1.default.falseFunc
|
||||
: (0, general_js_1.compileGeneralSelector)(previous, rule, options, context, compileToken);
|
||||
}, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.default.trueFunc);
|
||||
}
|
||||
function reduceRules(a, b) {
|
||||
if (b === boolbase_1.default.falseFunc || a === boolbase_1.default.trueFunc) {
|
||||
return a;
|
||||
}
|
||||
if (a === boolbase_1.default.falseFunc || b === boolbase_1.default.trueFunc) {
|
||||
return b;
|
||||
}
|
||||
return function combine(elem) {
|
||||
return a(elem) || b(elem);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=compile.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"compile.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["compile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyD;AACzD,sDAAgC;AAChC,mDAAmD;AACnD,2CAAsD;AACtD,kEAG0C;AAO1C;;;;;;GAMG;AACH,SAAgB,OAAO,CACnB,QAA+B,EAC/B,OAA2C,EAC3C,OAAuB;IAEvB,IAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,IAAA,2BAAW,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,0BAOC;AAED,SAAgB,aAAa,CACzB,QAA+B,EAC/B,OAA2C,EAC3C,OAAuB;IAEvB,IAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxE,OAAO,YAAY,CAAoB,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC;AAPD,sCAOC;AAED,SAAS,mBAAmB,CAAC,CAAmB;IAC5C,OAAO,CACH,CAA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AC,KAAK,kBAAQ,CAAC,SAAS,IAAI,CAAC,KAAK,kBAAQ,CAAC,QAAQ,EAAE;QACrD,OAAO,CAAC,CAAC;KACZ;IAED,OAAO,SAAS,OAAO,CAAC,IAAI;QACxB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC;AACN,CAAC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { CompiledQuery, InternalOptions } from "./types.js";
|
||||
import type { AttributeSelector, AttributeAction } from "css-what";
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
export declare const attributeRules: Record<AttributeAction, <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, data: AttributeSelector, options: InternalOptions<Node, ElementNode>) => CompiledQuery<ElementNode>>;
|
||||
//# sourceMappingURL=attributes.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"attributes.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["attributes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+EnE;;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,CAsLlC,CAAC"}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
import boolbase from "boolbase";
|
||||
/**
|
||||
* All reserved characters in a regex, used for escaping.
|
||||
*
|
||||
* Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
|
||||
* https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
|
||||
*/
|
||||
const reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
||||
function escapeRegex(value) {
|
||||
return value.replace(reChars, "\\$&");
|
||||
}
|
||||
/**
|
||||
* Attributes that are case-insensitive in HTML.
|
||||
*
|
||||
* @private
|
||||
* @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
|
||||
*/
|
||||
const caseInsensitiveAttributes = new Set([
|
||||
"accept",
|
||||
"accept-charset",
|
||||
"align",
|
||||
"alink",
|
||||
"axis",
|
||||
"bgcolor",
|
||||
"charset",
|
||||
"checked",
|
||||
"clear",
|
||||
"codetype",
|
||||
"color",
|
||||
"compact",
|
||||
"declare",
|
||||
"defer",
|
||||
"dir",
|
||||
"direction",
|
||||
"disabled",
|
||||
"enctype",
|
||||
"face",
|
||||
"frame",
|
||||
"hreflang",
|
||||
"http-equiv",
|
||||
"lang",
|
||||
"language",
|
||||
"link",
|
||||
"media",
|
||||
"method",
|
||||
"multiple",
|
||||
"nohref",
|
||||
"noresize",
|
||||
"noshade",
|
||||
"nowrap",
|
||||
"readonly",
|
||||
"rel",
|
||||
"rev",
|
||||
"rules",
|
||||
"scope",
|
||||
"scrolling",
|
||||
"selected",
|
||||
"shape",
|
||||
"target",
|
||||
"text",
|
||||
"type",
|
||||
"valign",
|
||||
"valuetype",
|
||||
"vlink",
|
||||
]);
|
||||
function shouldIgnoreCase(selector, options) {
|
||||
return typeof selector.ignoreCase === "boolean"
|
||||
? selector.ignoreCase
|
||||
: selector.ignoreCase === "quirks"
|
||||
? !!options.quirksMode
|
||||
: !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
|
||||
}
|
||||
/**
|
||||
* Attribute selectors
|
||||
*/
|
||||
export const attributeRules = {
|
||||
equals(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length === value.length &&
|
||||
attr.toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => adapter.getAttributeValue(elem, name) === value && next(elem);
|
||||
},
|
||||
hyphen(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = value.length;
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return function hyphenIC(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return function hyphen(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
(attr.length === len || attr.charAt(len) === "-") &&
|
||||
attr.substr(0, len) === value &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
element(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name, value } = data;
|
||||
if (/\s/.test(value)) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
const regex = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data, options) ? "i" : "");
|
||||
return function element(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
},
|
||||
exists(next, { name }, { adapter }) {
|
||||
return (elem) => adapter.hasAttrib(elem, name) && next(elem);
|
||||
},
|
||||
start(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = value.length;
|
||||
if (len === 0) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= len &&
|
||||
attr.substr(0, len).toLowerCase() === value &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
end(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
const len = -value.length;
|
||||
if (len === 0) {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return ((_a = adapter
|
||||
.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
any(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name, value } = data;
|
||||
if (value === "") {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
if (shouldIgnoreCase(data, options)) {
|
||||
const regex = new RegExp(escapeRegex(value), "i");
|
||||
return function anyIC(elem) {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return (attr != null &&
|
||||
attr.length >= value.length &&
|
||||
regex.test(attr) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => {
|
||||
var _a;
|
||||
return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
|
||||
next(elem);
|
||||
};
|
||||
},
|
||||
not(next, data, options) {
|
||||
const { adapter } = options;
|
||||
const { name } = data;
|
||||
let { value } = data;
|
||||
if (value === "") {
|
||||
return (elem) => !!adapter.getAttributeValue(elem, name) && next(elem);
|
||||
}
|
||||
else if (shouldIgnoreCase(data, options)) {
|
||||
value = value.toLowerCase();
|
||||
return (elem) => {
|
||||
const attr = adapter.getAttributeValue(elem, name);
|
||||
return ((attr == null ||
|
||||
attr.length !== value.length ||
|
||||
attr.toLowerCase() !== value) &&
|
||||
next(elem));
|
||||
};
|
||||
}
|
||||
return (elem) => adapter.getAttributeValue(elem, name) !== value && next(elem);
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=attributes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"attributes.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["attributes.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAIhC;;;;;GAKG;AACH,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAC3C,SAAS,WAAW,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACtC,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,SAAS;IACT,SAAS;IACT,OAAO;IACP,UAAU;IACV,OAAO;IACP,SAAS;IACT,SAAS;IACT,OAAO;IACP,KAAK;IACL,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;IACN,OAAO;IACP,UAAU;IACV,YAAY;IACZ,MAAM;IACN,UAAU;IACV,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,UAAU;IACV,SAAS;IACT,QAAQ;IACR,UAAU;IACV,KAAK;IACL,K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CAAC,IAAI,EAAE,IAAI,CAAC,0CAC5B,MAAM,CAAC,GAAG,EACX,WAAW,Line truncated
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector } from "./types.js";
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
export declare function compile<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<Node>;
|
||||
export declare function compileUnsafe<Node, ElementNode extends Node>(selector: string | Selector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
export declare function compileToken<Node, ElementNode extends Node>(token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node): CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=compile.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"compile.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAgB,MAAM,UAAU,CAAC;AAQzD,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;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,IAAI,CAAC,CAGrB;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,CAG5B;AAqDD,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,CAsD5B"}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
import { parse, SelectorType } from "css-what";
|
||||
import boolbase from "boolbase";
|
||||
import sortRules, { isTraversal } from "./sort.js";
|
||||
import { compileGeneralSelector } from "./general.js";
|
||||
import { ensureIsTag, PLACEHOLDER_ELEMENT, } from "./pseudo-selectors/subselects.js";
|
||||
/**
|
||||
* Compiles a selector to an executable function.
|
||||
*
|
||||
* @param selector Selector to compile.
|
||||
* @param options Compilation options.
|
||||
* @param context Optional context for the selector.
|
||||
*/
|
||||
export function compile(selector, options, context) {
|
||||
const next = compileUnsafe(selector, options, context);
|
||||
return ensureIsTag(next, options.adapter);
|
||||
}
|
||||
export function compileUnsafe(selector, options, context) {
|
||||
const token = typeof selector === "string" ? parse(selector) : selector;
|
||||
return compileToken(token, options, context);
|
||||
}
|
||||
function includesScopePseudo(t) {
|
||||
return (t.type === SelectorType.Pseudo &&
|
||||
(t.name === "scope" ||
|
||||
(Array.isArray(t.data) &&
|
||||
t.data.some((data) => data.some(includesScopePseudo)))));
|
||||
}
|
||||
const DESCENDANT_TOKEN = { type: SelectorType.Descendant };
|
||||
const FLEXIBLE_DESCENDANT_TOKEN = {
|
||||
type: "_flexibleDescendant",
|
||||
};
|
||||
const SCOPE_TOKEN = {
|
||||
type: SelectorType.Pseudo,
|
||||
name: "scope",
|
||||
data: null,
|
||||
};
|
||||
/*
|
||||
* CSS 4 Spec (Draft): 3.4.1. Absolutizing a Relative Selector
|
||||
* http://www.w3.org/TR/selectors4/#absolutizing
|
||||
*/
|
||||
function absolutize(token, { adapter }, context) {
|
||||
// TODO Use better check if the context is a document
|
||||
const hasContext = !!(context === null || context === void 0 ? void 0 : context.every((e) => {
|
||||
const parent = adapter.isTag(e) && adapter.getParent(e);
|
||||
return e === PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
|
||||
}));
|
||||
for (const t of token) {
|
||||
if (t.length > 0 &&
|
||||
isTraversal(t[0]) &&
|
||||
t[0].type !== SelectorType.Descendant) {
|
||||
// Don't continue in else branch
|
||||
}
|
||||
else if (hasContext && !t.some(includesScopePseudo)) {
|
||||
t.unshift(DESCENDANT_TOKEN);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
t.unshift(SCOPE_TOKEN);
|
||||
}
|
||||
}
|
||||
export function compileToken(token, options, context) {
|
||||
var _a;
|
||||
token.forEach(sortRules);
|
||||
context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
|
||||
const isArrayContext = Array.isArray(context);
|
||||
const finalContext = context && (Array.isArray(context) ? context : [context]);
|
||||
// Check if the selector is relative
|
||||
if (options.relativeSelector !== false) {
|
||||
absolutize(token, options, finalContext);
|
||||
}
|
||||
else if (token.some((t) => t.length > 0 && isTraversal(t[0]))) {
|
||||
throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
|
||||
}
|
||||
let shouldTestNextSiblings = false;
|
||||
const query = token
|
||||
.map((rules) => {
|
||||
if (rules.length >= 2) {
|
||||
const [first, second] = rules;
|
||||
if (first.type !== SelectorType.Pseudo ||
|
||||
first.name !== "scope") {
|
||||
// Ignore
|
||||
}
|
||||
else if (isArrayContext &&
|
||||
second.type === SelectorType.Descendant) {
|
||||
rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
|
||||
}
|
||||
else if (second.type === SelectorType.Adjacent ||
|
||||
second.type === SelectorType.Sibling) {
|
||||
shouldTestNextSiblings = true;
|
||||
}
|
||||
}
|
||||
return compileRules(rules, options, finalContext);
|
||||
})
|
||||
.reduce(reduceRules, boolbase.falseFunc);
|
||||
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
||||
return query;
|
||||
}
|
||||
function compileRules(rules, options, context) {
|
||||
var _a;
|
||||
return rules.reduce((previous, rule) => previous === boolbase.falseFunc
|
||||
? boolbase.falseFunc
|
||||
: compileGeneralSelector(previous, rule, options, context, compileToken), (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase.trueFunc);
|
||||
}
|
||||
function reduceRules(a, b) {
|
||||
if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
|
||||
return a;
|
||||
}
|
||||
if (a === boolbase.falseFunc || b === boolbase.trueFunc) {
|
||||
return b;
|
||||
}
|
||||
return function combine(elem) {
|
||||
return a(elem) || b(elem);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=compile.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"compile.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACH,WAAW,EACX,mBAAmB,GACtB,MAAM,kCAAkC,CAAC;AAO1C;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CACnB,QAA+B,EAC/B,OAA2C,EAC3C,OAAuB;IAEvB,MAAM,IAAI,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,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EACP,OAAO,EACP,YAAY,CACf,EACX,MAAA,OAAO,CAAC,QAAQ,mCAAI,QAAQ,CAAC,QAAQ,CACxC,CAAC;AACN,CAAC;AAED,SAAS,WAAW,CAChB,CAA6B,EAC7B,CAA6B;IAE7B,IAAI,CAAC,KAAK,QAAQ,CAAC,SAAS,IAAI,CAAC,KAAK,QAAQ,CAAC,QAAQ,EAAE;QACrD,OAAO,CAAC,CAAC;KACZ;IACD,IAAI,CAAC,KAAK,QAAQ,CAAC,SAAS,IAAI,CAAC,KAAK,QAAQ,CAAC,QAAQ,EAAE;QACrD,OAAO,CAAC,CAAC;KACZ;IAED,OAAO,SAAS,OAAO,CAAC,IAAI;QACxB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC;AACN,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types.js";
|
||||
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>;
|
||||
//# sourceMappingURL=general.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"general.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,YAAY,CAAC;AAkBpB,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,CAiK5B"}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
import { attributeRules } from "./attributes.js";
|
||||
import { compilePseudoSelector } from "./pseudo-selectors/index.js";
|
||||
import { SelectorType } from "css-what";
|
||||
function getElementParent(node, adapter) {
|
||||
const parent = adapter.getParent(node);
|
||||
if (parent && adapter.isTag(parent)) {
|
||||
return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* All available rules
|
||||
*/
|
||||
export function compileGeneralSelector(next, selector, options, context, compileToken) {
|
||||
const { adapter, equals } = options;
|
||||
switch (selector.type) {
|
||||
case SelectorType.PseudoElement: {
|
||||
throw new Error("Pseudo-elements are not supported by css-select");
|
||||
}
|
||||
case SelectorType.ColumnCombinator: {
|
||||
throw new Error("Column combinators are not yet supported by css-select");
|
||||
}
|
||||
case SelectorType.Attribute: {
|
||||
if (selector.namespace != null) {
|
||||
throw new Error("Namespaced attributes are not yet supported by css-select");
|
||||
}
|
||||
if (!options.xmlMode || options.lowerCaseAttributeNames) {
|
||||
selector.name = selector.name.toLowerCase();
|
||||
}
|
||||
return attributeRules[selector.action](next, selector, options);
|
||||
}
|
||||
case SelectorType.Pseudo: {
|
||||
return compilePseudoSelector(next, selector, options, context, compileToken);
|
||||
}
|
||||
// Tags
|
||||
case SelectorType.Tag: {
|
||||
if (selector.namespace != null) {
|
||||
throw new Error("Namespaced tag names are not yet supported by css-select");
|
||||
}
|
||||
let { name } = selector;
|
||||
if (!options.xmlMode || options.lowerCaseTags) {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
return function tag(elem) {
|
||||
return adapter.getName(elem) === name && next(elem);
|
||||
};
|
||||
}
|
||||
// Traversal
|
||||
case SelectorType.Descendant: {
|
||||
if (options.cacheResults === false ||
|
||||
typeof WeakSet === "undefined") {
|
||||
return function descendant(elem) {
|
||||
let current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (next(current)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// @ts-expect-error `ElementNode` is not extending object
|
||||
const isFalseCache = new WeakSet();
|
||||
return function cachedDescendant(elem) {
|
||||
let current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (!isFalseCache.has(current)) {
|
||||
if (adapter.isTag(current) && next(current)) {
|
||||
return true;
|
||||
}
|
||||
isFalseCache.add(current);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case "_flexibleDescendant": {
|
||||
// Include element itself, only used while querying an array
|
||||
return function flexibleDescendant(elem) {
|
||||
let current = elem;
|
||||
do {
|
||||
if (next(current))
|
||||
return true;
|
||||
} while ((current = getElementParent(current, adapter)));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case SelectorType.Parent: {
|
||||
return function parent(elem) {
|
||||
return adapter
|
||||
.getChildren(elem)
|
||||
.some((elem) => adapter.isTag(elem) && next(elem));
|
||||
};
|
||||
}
|
||||
case SelectorType.Child: {
|
||||
return function child(elem) {
|
||||
const parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(parent);
|
||||
};
|
||||
}
|
||||
case SelectorType.Sibling: {
|
||||
return function sibling(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case SelectorType.Adjacent: {
|
||||
if (adapter.prevElementSibling) {
|
||||
return function adjacent(elem) {
|
||||
const previous = adapter.prevElementSibling(elem);
|
||||
return previous != null && next(previous);
|
||||
};
|
||||
}
|
||||
return function adjacent(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let lastElement;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling)) {
|
||||
lastElement = currentSibling;
|
||||
}
|
||||
}
|
||||
return !!lastElement && next(lastElement);
|
||||
};
|
||||
}
|
||||
case SelectorType.Universal: {
|
||||
if (selector.namespace != null && selector.namespace !== "*") {
|
||||
throw new Error("Namespaced universal selectors are not yet supported by css-select");
|
||||
}
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=general.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"general.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAQpE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,SAAS,gBAAgB,CACrB,IAAiB,EACjB,OAAmC;IAEnC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACjC,OAAO,MAAM,CAAC;KACjB;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;GAEG;AAEH,MAAM,UAAU,sBAAsB,CAClC,IAAgC,EAChC,QAA0B,EAC1B,OAA2C,EAC3C,OAA2B,EAC3B,YAA6C;IAE7C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACnB,KAAK,YAAY,CAAC,aAAa,CAAC,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,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,CAAC;oBACnD,OAAO,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC9C,CAAC,CAAC;aACL;YAED,OAAO,SAAS,QAAQ,CAAC,IAAiB;gBACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,WAAW,CAAC;gBAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACtC,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACnC,IAAI,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC;wBAAE,MAAM;oBACxC,IAAI,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;wBAC/B,WAAW,GAAG,cAAc,CAAC;qBAChC;iBACJ;gBAED,OAAO,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;YAC9C,CAAC,CAAC;SACL;QACD,KAAK,YAAY,CAAC,SAAS,CAAC,CAAC;YACzB,IAAI,QAAQ,CAAC,SAAS,IAAI,IAAI,IAAI,QAAQ,CAAC,SAAS,KAAK,GAAG,EAAE;gBAC1D,MAAM,IAAI,KAAK,CACX,oEAAoE,CACvE,CAAC;aACL;YAED,OAAO,IAAI,CAAC;SACf;KACJ;AACL,CAAC"}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import type { CompiledQuery, Options, Query, Adapter } from "./types.js";
|
||||
export type { Options };
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export declare const compile: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<Node>;
|
||||
export declare const _compileUnsafe: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare const _compileToken: <Node, ElementNode extends Node>(selector: import("./types.js").InternalSelector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export declare const selectAll: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export declare const selectOne: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode | null;
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export declare function is<Node, ElementNode extends Node>(elem: ElementNode, query: Query<ElementNode>, options?: Options<Node, ElementNode>): boolean;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,oMAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,2MAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,4MAA4B,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;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,yJASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,8JASrB,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,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
import * as DomUtils from "domutils";
|
||||
import boolbase from "boolbase";
|
||||
import { compile as compileRaw, compileUnsafe, compileToken, } from "./compile.js";
|
||||
import { getNextSiblings } from "./pseudo-selectors/subselects.js";
|
||||
const defaultEquals = (a, b) => a === b;
|
||||
const defaultOptions = {
|
||||
adapter: DomUtils,
|
||||
equals: defaultEquals,
|
||||
};
|
||||
function convertOptionFormats(options) {
|
||||
var _a, _b, _c, _d;
|
||||
/*
|
||||
* We force one format of options to the other one.
|
||||
*/
|
||||
// @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
|
||||
const opts = options !== null && options !== void 0 ? options : defaultOptions;
|
||||
// @ts-expect-error Same as above.
|
||||
(_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
|
||||
// @ts-expect-error `equals` does not exist on `Options`
|
||||
(_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);
|
||||
return opts;
|
||||
}
|
||||
function wrapCompile(func) {
|
||||
return function addAdapter(selector, options, context) {
|
||||
const opts = convertOptionFormats(options);
|
||||
return func(selector, opts, context);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export const compile = wrapCompile(compileRaw);
|
||||
export const _compileUnsafe = wrapCompile(compileUnsafe);
|
||||
export const _compileToken = wrapCompile(compileToken);
|
||||
function getSelectorFunc(searchFunc) {
|
||||
return function select(query, elements, options) {
|
||||
const opts = convertOptionFormats(options);
|
||||
if (typeof query !== "function") {
|
||||
query = compileUnsafe(query, opts, elements);
|
||||
}
|
||||
const filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
|
||||
return searchFunc(query, filteredElements, opts);
|
||||
};
|
||||
}
|
||||
export function prepareContext(elems, adapter, shouldTestNextSiblings = false) {
|
||||
/*
|
||||
* Add siblings if the query requires them.
|
||||
* See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
|
||||
*/
|
||||
if (shouldTestNextSiblings) {
|
||||
elems = appendNextSiblings(elems, adapter);
|
||||
}
|
||||
return Array.isArray(elems)
|
||||
? adapter.removeSubsets(elems)
|
||||
: adapter.getChildren(elems);
|
||||
}
|
||||
function appendNextSiblings(elem, adapter) {
|
||||
// Order matters because jQuery seems to check the children before the siblings
|
||||
const elems = Array.isArray(elem) ? elem.slice(0) : [elem];
|
||||
const elemsLength = elems.length;
|
||||
for (let i = 0; i < elemsLength; i++) {
|
||||
const nextSiblings = getNextSiblings(elems[i], adapter);
|
||||
elems.push(...nextSiblings);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export const selectAll = getSelectorFunc((query, elems, options) => query === boolbase.falseFunc || !elems || elems.length === 0
|
||||
? []
|
||||
: options.adapter.findAll(query, elems));
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export const selectOne = getSelectorFunc((query, elems, options) => query === boolbase.falseFunc || !elems || elems.length === 0
|
||||
? null
|
||||
: options.adapter.findOne(query, elems));
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export function is(elem, query, options) {
|
||||
const opts = convertOptionFormats(options);
|
||||
return (typeof query === "function" ? query : compileRaw(query, opts))(elem);
|
||||
}
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
// Export filters, pseudos and aliases to allow users to supply their own.
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAKhC,OAAO,EACH,OAAO,IAAI,UAAU,EACrB,aAAa,EACb,YAAY,GACf,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,MAAM,aAAa,GAAG,CAAO,CAAO,EAAE,CAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1D,MAAM,cAAc,GAAuD;IACvE,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,aAAa;CACxB,CAAC;AAEF,SAAS,oBAAoB,CACzB,OAAoC;;IAEpC;;OAEG;IACH,iFAAiF;IACjF,MAAM,IAAI,GAA+B,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc,CAAC;IACnE,kCAAkC;IAClC,MAAA,IAAI,CAAC,OAAO,oCAAZ,IAAI,CAAC,OAAO,GAA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zB,EAAE,CACpB,KAAK,KAAK,QAAQ,CAAC,SAAS,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;IACxD,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAClD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,EAAE,CACd,IAAiB,EACjB,KAAyB,EACzB,OAAoC;IAEpC,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAClE,IAAI,CACP,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,eAAe,SAAS,CAAC;AAEzB,0EAA0E;AAC1E,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
export declare const aliases: Record<string, string>;
|
||||
//# sourceMappingURL=aliases.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aliases.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
export const aliases = {
|
||||
// Links
|
||||
"any-link": ":is(a, area, link)[href]",
|
||||
link: ":any-link:not(:visited)",
|
||||
// Forms
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
|
||||
disabled: `:is(
|
||||
:is(button, input, select, textarea, optgroup, option)[disabled],
|
||||
optgroup[disabled] > option,
|
||||
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
|
||||
)`,
|
||||
enabled: ":not(:disabled)",
|
||||
checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
|
||||
required: ":is(input, select, textarea)[required]",
|
||||
optional: ":is(input, select, textarea):not([required])",
|
||||
// JQuery extensions
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
|
||||
selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
||||
checkbox: "[type=checkbox]",
|
||||
file: "[type=file]",
|
||||
password: "[type=password]",
|
||||
radio: "[type=radio]",
|
||||
reset: "[type=reset]",
|
||||
image: "[type=image]",
|
||||
submit: "[type=submit]",
|
||||
parent: ":not(:empty)",
|
||||
header: ":is(h1, h2, h3, h4, h5, h6)",
|
||||
button: ":is(button, input[type=button])",
|
||||
input: ":is(input, textarea, select, button)",
|
||||
text: "input:is(:not([type!='']), [type=text])",
|
||||
};
|
||||
//# sourceMappingURL=aliases.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aliases.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC3C,QAAQ;IAER,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,yBAAyB;IAE/B,QAAQ;IAER,0EAA0E;IAC1E,QAAQ,EAAE;;;;MAIR;IACF,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EACH,6EAA6E;IACjF,QAAQ,EAAE,wCAAwC;IAClD,QAAQ,EAAE,8CAA8C;IAExD,oBAAoB;IAEpB,wFAAwF;IACxF,QAAQ,EACJ,8FAA8F;IAElG,QAAQ,EAAE,iBAAiB;IAC3B,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,iBAAiB;IAC3B,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,eAAe;IAEvB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,6BAA6B;IAErC,MAAM,EAAE,iCAAiC;IACzC,KAAK,EAAE,sCAAsC;IAC7C,IAAI,EAAE,yCAAyC;CAClD,CAAC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
|
||||
export declare const filters: Record<string, Filter>;
|
||||
//# sourceMappingURL=filters.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filters.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,aAAa,CAAC;AAE3E,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"}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
import getNCheck from "nth-check";
|
||||
import boolbase from "boolbase";
|
||||
function getChildFunc(next, adapter) {
|
||||
return (elem) => {
|
||||
const parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(elem);
|
||||
};
|
||||
}
|
||||
export const filters = {
|
||||
contains(next, text, { adapter }) {
|
||||
return function contains(elem) {
|
||||
return next(elem) && adapter.getText(elem).includes(text);
|
||||
};
|
||||
},
|
||||
icontains(next, text, { adapter }) {
|
||||
const itext = text.toLowerCase();
|
||||
return function icontains(elem) {
|
||||
return (next(elem) &&
|
||||
adapter.getText(elem).toLowerCase().includes(itext));
|
||||
};
|
||||
},
|
||||
// Location specific methods
|
||||
"nth-child"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthChild(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-child"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastChild(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-of-type"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthOfType(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-of-type"(next, rule, { adapter, equals }) {
|
||||
const func = getNCheck(rule);
|
||||
if (func === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
if (func === boolbase.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastOfType(elem) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
let pos = 0;
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
// TODO determine the actual root element
|
||||
root(next, _rule, { adapter }) {
|
||||
return (elem) => {
|
||||
const parent = adapter.getParent(elem);
|
||||
return (parent == null || !adapter.isTag(parent)) && next(elem);
|
||||
};
|
||||
},
|
||||
scope(next, rule, options, context) {
|
||||
const { equals } = options;
|
||||
if (!context || context.length === 0) {
|
||||
// Equivalent to :root
|
||||
return filters["root"](next, rule, options);
|
||||
}
|
||||
if (context.length === 1) {
|
||||
// NOTE: can't be unpacked, as :has uses this for side-effects
|
||||
return (elem) => equals(context[0], elem) && next(elem);
|
||||
}
|
||||
return (elem) => context.includes(elem) && next(elem);
|
||||
},
|
||||
hover: dynamicStatePseudo("isHovered"),
|
||||
visited: dynamicStatePseudo("isVisited"),
|
||||
active: dynamicStatePseudo("isActive"),
|
||||
};
|
||||
/**
|
||||
* Dynamic state pseudos. These depend on optional Adapter methods.
|
||||
*
|
||||
* @param name The name of the adapter method to call.
|
||||
* @returns Pseudo for the `filters` object.
|
||||
*/
|
||||
function dynamicStatePseudo(name) {
|
||||
return function dynamicPseudo(next, _rule, { adapter }) {
|
||||
const func = adapter[name];
|
||||
if (typeof func !== "function") {
|
||||
return boolbase.falseFunc;
|
||||
}
|
||||
return function active(elem) {
|
||||
return func(elem) && next(elem);
|
||||
};
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=filters.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filters.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/filters.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAUhC,SAAS,YAAY,CACjB,IAAgC,EAChC,OAAmC;IAEnC,OAAO,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC3C,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE;QAC5B,OAAO,SAAS,QAAQ,CAAC,IAAI;YACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,C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AAC;IAED,KAAK,EAAE,kBAAkB,CAAC,WAAW,CAAC;IACtC,OAAO,EAAE,kBAAkB,CAAC,WAAW,CAAC;IACxC,MAAM,EAAE,kBAAkB,CAAC,UAAU,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,SAAS,kBAAkB,CACvB,ILine truncated
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import type { CompiledQuery, InternalOptions, CompileToken } from "../types.js";
|
||||
import { PseudoSelector } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
export { filters, pseudos, aliases };
|
||||
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>;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,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,CA4C5B"}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { parse } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos, verifyPseudoArgs } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
import { subselects } from "./subselects.js";
|
||||
export { filters, pseudos, aliases };
|
||||
export function compilePseudoSelector(next, selector, options, context, compileToken) {
|
||||
var _a;
|
||||
const { name, data } = selector;
|
||||
if (Array.isArray(data)) {
|
||||
if (!(name in subselects)) {
|
||||
throw new Error(`Unknown pseudo-class :${name}(${data})`);
|
||||
}
|
||||
return subselects[name](next, data, options, context, compileToken);
|
||||
}
|
||||
const userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
|
||||
const stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases[name];
|
||||
if (typeof stringPseudo === "string") {
|
||||
if (data != null) {
|
||||
throw new Error(`Pseudo ${name} doesn't have any arguments`);
|
||||
}
|
||||
// The alias has to be parsed here, to make sure options are respected.
|
||||
const alias = parse(stringPseudo);
|
||||
return subselects["is"](next, alias, options, context, compileToken);
|
||||
}
|
||||
if (typeof userPseudo === "function") {
|
||||
verifyPseudoArgs(userPseudo, name, data, 1);
|
||||
return (elem) => userPseudo(elem, data) && next(elem);
|
||||
}
|
||||
if (name in filters) {
|
||||
return filters[name](next, data, options, context);
|
||||
}
|
||||
if (name in pseudos) {
|
||||
const pseudo = pseudos[name];
|
||||
verifyPseudoArgs(pseudo, name, data, 2);
|
||||
return (elem) => pseudo(elem, options, data) && next(elem);
|
||||
}
|
||||
throw new Error(`Unknown pseudo-class :${name}`);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAkB,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAErC,MAAM,UAAU,qBAAqB,CACjC,IAAgC,EAChC,QAAwB,EACxB,OAA2C,EAC3C,OAA2B,EAC3B,YAA6C;;IAE7C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACrB,IAAI,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC;SAC7D;QAED,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACvE;IAED,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAG,IAAI,CAAC,CAAC;IAE3C,MAAM,YAAY,GACd,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QAClC,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,6BAA6B,CAAC,CAAC;SAChE;QAED,uEAAuE;QACvE,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;QAClC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACxE;IAED,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;QAClC,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE5C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;KACzD;IAED,IAAI,IAAI,IAAI,OAAO,EAAE;QACjB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAChE;IAED,IAAI,IAAI,IAAI,OAAO,EAAE;QACjB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAExC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;KAC9D;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { PseudoSelector } from "css-what";
|
||||
import type { InternalOptions } from "../types.js";
|
||||
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: string | null) => boolean;
|
||||
export declare const pseudos: Record<string, Pseudo>;
|
||||
export declare function verifyPseudoArgs<T extends Array<unknown>>(func: (...args: T) => boolean, name: string, subselect: PseudoSelector["data"], argIndex: number): void;
|
||||
//# sourceMappingURL=pseudos.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pseudos.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC;AAGb,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkF1C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACrD,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,EACjC,QAAQ,EAAE,MAAM,GACjB,IAAI,CAQN"}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// While filters are precompiled, pseudos get called when they are needed
|
||||
export const pseudos = {
|
||||
empty(elem, { adapter }) {
|
||||
return !adapter.getChildren(elem).some((elem) =>
|
||||
// FIXME: `getText` call is potentially expensive.
|
||||
adapter.isTag(elem) || adapter.getText(elem) !== "");
|
||||
},
|
||||
"first-child"(elem, { adapter, equals }) {
|
||||
if (adapter.prevElementSibling) {
|
||||
return adapter.prevElementSibling(elem) == null;
|
||||
}
|
||||
const firstChild = adapter
|
||||
.getSiblings(elem)
|
||||
.find((elem) => adapter.isTag(elem));
|
||||
return firstChild != null && equals(elem, firstChild);
|
||||
},
|
||||
"last-child"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
return true;
|
||||
if (adapter.isTag(siblings[i]))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"first-of-type"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
const elemName = adapter.getName(elem);
|
||||
for (let i = 0; i < siblings.length; i++) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"last-of-type"(elem, { adapter, equals }) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
const elemName = adapter.getName(elem);
|
||||
for (let i = siblings.length - 1; i >= 0; i--) {
|
||||
const currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"only-of-type"(elem, { adapter, equals }) {
|
||||
const elemName = adapter.getName(elem);
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every((sibling) => equals(elem, sibling) ||
|
||||
!adapter.isTag(sibling) ||
|
||||
adapter.getName(sibling) !== elemName);
|
||||
},
|
||||
"only-child"(elem, { adapter, equals }) {
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every((sibling) => equals(elem, sibling) || !adapter.isTag(sibling));
|
||||
},
|
||||
};
|
||||
export function verifyPseudoArgs(func, name, subselect, argIndex) {
|
||||
if (subselect === null) {
|
||||
if (func.length > argIndex) {
|
||||
throw new Error(`Pseudo-class :${name} requires an argument`);
|
||||
}
|
||||
}
|
||||
else if (func.length === argIndex) {
|
||||
throw new Error(`Pseudo-class :${name} doesn't have any arguments`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=pseudos.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pseudos.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AASA,yEAAyE;AACzE,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC3C,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE;QACnB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAClC,CAAC,IAAI,EAAE,EAAE;QACL,kDAAkD;QAClD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAC1D,CAAC;IACN,CAAC;IAED,aAAa,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACnC,IAAI,OAAO,CAAC,kBAAkB,EAAE;YAC5B,OAAO,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;SACnD;QAED,MAAM,UAAU,GAAG,OAAO;aACrB,WAAW,CAAC,IAAI,CAAC;aACjB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,UAAU,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IACD,YAAY,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IA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KACvE;AACL,CAAC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import type { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, CompileToken, Adapter } from "../types.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export declare const PLACEHOLDER_ELEMENT: {};
|
||||
export declare function ensureIsTag<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, adapter: Adapter<Node, ElementNode>): CompiledQuery<Node>;
|
||||
export declare type Subselect = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, subselect: Selector[][], options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>) => CompiledQuery<ElementNode>;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare const subselects: Record<string, Subselect>;
|
||||
//# sourceMappingURL=subselects.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subselects.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/subselects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,YAAY,EACZ,OAAO,EACV,MAAM,aAAa,CAAC;AAGrB,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACtD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACnD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,KAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,WAAW,EAAE,CAMf;AAiCD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAgEhD,CAAC"}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
import boolbase from "boolbase";
|
||||
import { isTraversal } from "../sort.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export const PLACEHOLDER_ELEMENT = {};
|
||||
export function ensureIsTag(next, adapter) {
|
||||
if (next === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
return (elem) => adapter.isTag(elem) && next(elem);
|
||||
}
|
||||
export function getNextSiblings(elem, adapter) {
|
||||
const siblings = adapter.getSiblings(elem);
|
||||
if (siblings.length <= 1)
|
||||
return [];
|
||||
const elemIndex = siblings.indexOf(elem);
|
||||
if (elemIndex < 0 || elemIndex === siblings.length - 1)
|
||||
return [];
|
||||
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
|
||||
}
|
||||
function copyOptions(options) {
|
||||
// Not copied: context, rootFunc
|
||||
return {
|
||||
xmlMode: !!options.xmlMode,
|
||||
lowerCaseAttributeNames: !!options.lowerCaseAttributeNames,
|
||||
lowerCaseTags: !!options.lowerCaseTags,
|
||||
quirksMode: !!options.quirksMode,
|
||||
cacheResults: !!options.cacheResults,
|
||||
pseudos: options.pseudos,
|
||||
adapter: options.adapter,
|
||||
equals: options.equals,
|
||||
};
|
||||
}
|
||||
const is = (next, token, options, context, compileToken) => {
|
||||
const func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase.trueFunc
|
||||
? next
|
||||
: func === boolbase.falseFunc
|
||||
? boolbase.falseFunc
|
||||
: (elem) => func(elem) && next(elem);
|
||||
};
|
||||
/*
|
||||
* :not, :has, :is, :matches and :where have to compile selectors
|
||||
* doing this in src/pseudos.ts would lead to circular dependencies,
|
||||
* so we add them here
|
||||
*/
|
||||
export const subselects = {
|
||||
is,
|
||||
/**
|
||||
* `:matches` and `:where` are aliases for `:is`.
|
||||
*/
|
||||
matches: is,
|
||||
where: is,
|
||||
not(next, token, options, context, compileToken) {
|
||||
const func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase.falseFunc
|
||||
? next
|
||||
: func === boolbase.trueFunc
|
||||
? boolbase.falseFunc
|
||||
: (elem) => !func(elem) && next(elem);
|
||||
},
|
||||
has(next, subselect, options, _context, compileToken) {
|
||||
const { adapter } = options;
|
||||
const opts = copyOptions(options);
|
||||
opts.relativeSelector = true;
|
||||
const context = subselect.some((s) => s.some(isTraversal))
|
||||
? // Used as a placeholder. Will be replaced with the actual element.
|
||||
[PLACEHOLDER_ELEMENT]
|
||||
: undefined;
|
||||
const compiled = compileToken(subselect, opts, context);
|
||||
if (compiled === boolbase.falseFunc)
|
||||
return boolbase.falseFunc;
|
||||
const hasElement = ensureIsTag(compiled, adapter);
|
||||
// If `compiled` is `trueFunc`, we can skip this.
|
||||
if (context && compiled !== boolbase.trueFunc) {
|
||||
/*
|
||||
* `shouldTestNextSiblings` will only be true if the query starts with
|
||||
* a traversal (sibling or adjacent). That means we will always have a context.
|
||||
*/
|
||||
const { shouldTestNextSiblings = false } = compiled;
|
||||
return (elem) => {
|
||||
if (!next(elem))
|
||||
return false;
|
||||
context[0] = elem;
|
||||
const childs = adapter.getChildren(elem);
|
||||
const nextElements = shouldTestNextSiblings
|
||||
? [...childs, ...getNextSiblings(elem, adapter)]
|
||||
: childs;
|
||||
return adapter.existsOne(hasElement, nextElements);
|
||||
};
|
||||
}
|
||||
return (elem) => next(elem) &&
|
||||
adapter.existsOne(hasElement, adapter.getChildren(elem));
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=subselects.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subselects.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/subselects.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAOhC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,MAAM,UAAU,WAAW,CACvB,IAAgC,EAChC,OAAmC;IAEnC,IAAI,IAAI,KAAK,QAAQ,CAAC,SAAS;QAAE,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC3D,OAAO,CAAC,IAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAUD,MAAM,UAAU,eAAe,CAC3B,IAAU,EACV,OAAmC;IAEnC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,W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AAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACzC,MAAM,YAAY,GAAG,sBAAsB;oBACvC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAChD,CAAC,CAAC,MAAM,CAAC;gBAEb,OAAO,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;YACvD,CAAC,CAAC;SACL;QAED,OAAO,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,CAAC,IAAI,CAAC;YACV,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;CACJ,CAAC"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import type { InternalSelector } from "./types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector,
|
||||
* as there is potential for optimization
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export default function sortByProcedure(arr: InternalSelector[]): void;
|
||||
//# sourceMappingURL=sort.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sort.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AASzE,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,SAAS,CAEvE;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAerE"}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import { AttributeAction, SelectorType } from "css-what";
|
||||
const procedure = new Map([
|
||||
[SelectorType.Universal, 50],
|
||||
[SelectorType.Tag, 30],
|
||||
[SelectorType.Attribute, 1],
|
||||
[SelectorType.Pseudo, 0],
|
||||
]);
|
||||
export function isTraversal(token) {
|
||||
return !procedure.has(token.type);
|
||||
}
|
||||
const attributes = new Map([
|
||||
[AttributeAction.Exists, 10],
|
||||
[AttributeAction.Equals, 8],
|
||||
[AttributeAction.Not, 7],
|
||||
[AttributeAction.Start, 6],
|
||||
[AttributeAction.End, 6],
|
||||
[AttributeAction.Any, 5],
|
||||
]);
|
||||
/**
|
||||
* Sort the parts of the passed selector,
|
||||
* as there is potential for optimization
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export default function sortByProcedure(arr) {
|
||||
const procs = arr.map(getProcedure);
|
||||
for (let i = 1; i < arr.length; i++) {
|
||||
const procNew = procs[i];
|
||||
if (procNew < 0)
|
||||
continue;
|
||||
for (let j = i - 1; j >= 0 && procNew < procs[j]; j--) {
|
||||
const token = arr[j + 1];
|
||||
arr[j + 1] = arr[j];
|
||||
arr[j] = token;
|
||||
procs[j + 1] = procs[j];
|
||||
procs[j] = procNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getProcedure(token) {
|
||||
var _a, _b;
|
||||
let proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
|
||||
if (token.type === SelectorType.Attribute) {
|
||||
proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
|
||||
if (token.action === AttributeAction.Equals && token.name === "id") {
|
||||
// Prefer ID selectors (eg. #ID)
|
||||
proc = 9;
|
||||
}
|
||||
if (token.ignoreCase) {
|
||||
/*
|
||||
* IgnoreCase adds some overhead, prefer "normal" token
|
||||
* this is a binary operation, to ensure it's still an int
|
||||
*/
|
||||
proc >>= 1;
|
||||
}
|
||||
}
|
||||
else if (token.type === SelectorType.Pseudo) {
|
||||
if (!token.data) {
|
||||
proc = 3;
|
||||
}
|
||||
else if (token.name === "has" || token.name === "contains") {
|
||||
proc = 0; // Expensive in any case
|
||||
}
|
||||
else if (Array.isArray(token.data)) {
|
||||
// Eg. :matches, :not
|
||||
proc = Math.min(...token.data.map((d) => Math.min(...d.map(getProcedure))));
|
||||
// If we have traversals, try to avoid executing this selector
|
||||
if (proc < 0) {
|
||||
proc = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
proc = 2;
|
||||
}
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
//# sourceMappingURL=sort.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sort.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AAEzE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAmC;IACxD,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC;IAC5B,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC;IACtB,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3B,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,UAAU,WAAW,CAAC,KAAuB;IAC/C,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAA0B;IAChD,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;IAC5B,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3B,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;IACxB,CAAC,eAAe,CAAC,KAAK,EAAE,CA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I,KAAK,CAAC,MAAM,KAAK,eAAe,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;YAChE,gCAAgC;YAChC,IAAI,GAAG,CAAC,CAAC;SACZ;QAED,IAAI,KAAK,CAAC,UAAU,EAAE;YAClB;;;eAGG;YACH,IAAI,KAAK,CAAC,CAAC;SACd;KACJ;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,MAAM,EAAE;QAC3C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACb,IAAI,GAAG,CAAC,CAAC;SACZ;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;YAC1D,IAAI,GAAG,CAAC,CAAC,CAAC,wBAAwB;SACrC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAClC,qBAAqB;YACrB,IAAI,GAAG,IAAI,CAAC,GAAG,CACX,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAC7D,CAAC;YAEF,8DAA8D;YAC9D,IAAI,IAAI,GAAG,CAAC,EAAE;gBACV,IAAI,GAAG,CAAC,CAAC;aACZ;SACJ;aAAM;YACH,IAAI,GAAG,CAAC,CAAC;SACZ;KACJ;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
import type { Selector } from "css-what";
|
||||
export declare type InternalSelector = Selector | {
|
||||
type: "_flexibleDescendant";
|
||||
};
|
||||
export declare type Predicate<Value> = (v: Value) => boolean;
|
||||
export interface Adapter<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* Is the node a tag?
|
||||
*/
|
||||
isTag: (node: Node) => node is ElementNode;
|
||||
/**
|
||||
* Does at least one of passed element nodes pass the test predicate?
|
||||
*/
|
||||
existsOne: (test: Predicate<ElementNode>, elems: Node[]) => boolean;
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
getAttributeValue: (elem: ElementNode, name: string) => string | undefined;
|
||||
/**
|
||||
* Get the node's children
|
||||
*/
|
||||
getChildren: (node: Node) => Node[];
|
||||
/**
|
||||
* Get the name of the tag
|
||||
*/
|
||||
getName: (elem: ElementNode) => string;
|
||||
/**
|
||||
* Get the parent of the node
|
||||
*/
|
||||
getParent: (node: ElementNode) => Node | null;
|
||||
/**
|
||||
* Get the siblings of the node. Note that unlike jQuery's `siblings` method,
|
||||
* this is expected to include the current node as well
|
||||
*/
|
||||
getSiblings: (node: Node) => Node[];
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*/
|
||||
prevElementSibling?: (node: Node) => ElementNode | null;
|
||||
/**
|
||||
* Get the text content of the node, and its children if it has any.
|
||||
*/
|
||||
getText: (node: Node) => string;
|
||||
/**
|
||||
* Does the element have the named attribute?
|
||||
*/
|
||||
hasAttrib: (elem: ElementNode, name: string) => boolean;
|
||||
/**
|
||||
* Takes an array of nodes, and removes any duplicates, as well as any
|
||||
* nodes whose ancestors are also in the array.
|
||||
*/
|
||||
removeSubsets: (nodes: Node[]) => Node[];
|
||||
/**
|
||||
* Finds all of the element nodes in the array that match the test predicate,
|
||||
* as well as any of their children that match it.
|
||||
*/
|
||||
findAll: (test: Predicate<ElementNode>, nodes: Node[]) => ElementNode[];
|
||||
/**
|
||||
* Finds the first node in the array that matches the test predicate, or one
|
||||
* of its children.
|
||||
*/
|
||||
findOne: (test: Predicate<ElementNode>, elems: Node[]) => ElementNode | null;
|
||||
/**
|
||||
* The adapter can also optionally include an equals method, if your DOM
|
||||
* structure needs a custom equality test to compare two objects which refer
|
||||
* to the same underlying node. If not provided, `css-select` will fall back to
|
||||
* `a === b`.
|
||||
*/
|
||||
equals?: (a: Node, b: Node) => boolean;
|
||||
/**
|
||||
* Is the element in hovered state?
|
||||
*/
|
||||
isHovered?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in visited state?
|
||||
*/
|
||||
isVisited?: (elem: ElementNode) => boolean;
|
||||
/**
|
||||
* Is the element in active state?
|
||||
*/
|
||||
isActive?: (elem: ElementNode) => boolean;
|
||||
}
|
||||
export interface Options<Node, ElementNode extends Node> {
|
||||
/**
|
||||
* When enabled, tag names will be case-sensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
/**
|
||||
* Lower-case attribute names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseAttributeNames?: boolean;
|
||||
/**
|
||||
* Lower-case tag names.
|
||||
*
|
||||
* @default !xmlMode
|
||||
*/
|
||||
lowerCaseTags?: boolean;
|
||||
/**
|
||||
* Is the document in quirks mode?
|
||||
*
|
||||
* This will lead to .className and #id being case-insensitive.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
quirksMode?: boolean;
|
||||
/**
|
||||
* Pseudo-classes that override the default ones.
|
||||
*
|
||||
* Maps from names to either strings of functions.
|
||||
* - A string value is a selector that the element must match to be selected.
|
||||
* - A function is called with the element as its first argument, and optional
|
||||
* parameters second. If it returns true, the element is selected.
|
||||
*/
|
||||
pseudos?: Record<string, string | ((elem: ElementNode, value?: string | null) => boolean)> | undefined;
|
||||
/**
|
||||
* The last function in the stack, will be called with the last element
|
||||
* that's looked at.
|
||||
*/
|
||||
rootFunc?: (element: ElementNode) => boolean;
|
||||
/**
|
||||
* The adapter to use when interacting with the backing DOM structure. By
|
||||
* default it uses the `domutils` module.
|
||||
*/
|
||||
adapter?: Adapter<Node, ElementNode>;
|
||||
/**
|
||||
* The context of the current query. Used to limit the scope of searches.
|
||||
* Can be matched directly using the `:scope` pseudo-class.
|
||||
*/
|
||||
context?: Node | Node[];
|
||||
/**
|
||||
* Indicates whether to consider the selector as a relative selector.
|
||||
*
|
||||
* Relative selectors that don't include a `:scope` pseudo-class behave
|
||||
* as if they have a `:scope ` prefix (a `:scope` pseudo-class, followed by
|
||||
* a descendant selector).
|
||||
*
|
||||
* If relative selectors are disabled, selectors starting with a traversal
|
||||
* will lead to an error.
|
||||
*
|
||||
* @default true
|
||||
* @see {@link https://www.w3.org/TR/selectors-4/#relative}
|
||||
*/
|
||||
relativeSelector?: boolean;
|
||||
/**
|
||||
* Allow css-select to cache results for some selectors, sometimes greatly
|
||||
* improving querying performance. Disable this if your document can
|
||||
* change in between queries with the same compiled selector.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
cacheResults?: boolean;
|
||||
}
|
||||
export interface InternalOptions<Node, ElementNode extends Node> extends Options<Node, ElementNode> {
|
||||
adapter: Adapter<Node, ElementNode>;
|
||||
equals: (a: Node, b: Node) => boolean;
|
||||
}
|
||||
export interface CompiledQuery<ElementNode> {
|
||||
(node: ElementNode): boolean;
|
||||
shouldTestNextSiblings?: boolean;
|
||||
}
|
||||
export declare type Query<ElementNode> = string | CompiledQuery<ElementNode> | Selector[][];
|
||||
export declare type CompileToken<Node, ElementNode extends Node> = (token: InternalSelector[][], options: InternalOptions<Node, ElementNode>, context?: Node[] | Node) => CompiledQuery<ElementNode>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,oBAAY,gBAAgB,GAAG,QAAQ,GAAG;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAE1E,oBAAY,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC;AACrD,MAAM,WAAW,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI;IACnD;;OAEG;IACH,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AAO,CAAC,IAAI,EAAE,WAAW,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;CACzC;AAED,MAAM,WAAW,aAAa,CAAC,WAAW;IACtC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AACD,oBAAY,KAAK,CAAC,WAAW,IACvB,MAAM,GACN,aAAa,CAAC,WAAW,CAAC,GAC1B,QAAQ,EAAE,EAAE,CAAC;AACnB,oBAAY,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,IAAI,CACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,KACtB,aAAa,CAAC,WAAW,CAAC,CAAC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["types.ts"],"names":[],"mappings":""}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types.js";
|
||||
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>;
|
||||
//# sourceMappingURL=general.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"general.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,YAAY,CAAC;AAkBpB,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,CAiK5B"}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileGeneralSelector = void 0;
|
||||
var attributes_js_1 = require("./attributes.js");
|
||||
var index_js_1 = require("./pseudo-selectors/index.js");
|
||||
var css_what_1 = require("css-what");
|
||||
function getElementParent(node, adapter) {
|
||||
var parent = adapter.getParent(node);
|
||||
if (parent && adapter.isTag(parent)) {
|
||||
return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* All available rules
|
||||
*/
|
||||
function compileGeneralSelector(next, selector, options, context, compileToken) {
|
||||
var adapter = options.adapter, equals = options.equals;
|
||||
switch (selector.type) {
|
||||
case css_what_1.SelectorType.PseudoElement: {
|
||||
throw new Error("Pseudo-elements are not supported by css-select");
|
||||
}
|
||||
case css_what_1.SelectorType.ColumnCombinator: {
|
||||
throw new Error("Column combinators are not yet supported by css-select");
|
||||
}
|
||||
case css_what_1.SelectorType.Attribute: {
|
||||
if (selector.namespace != null) {
|
||||
throw new Error("Namespaced attributes are not yet supported by css-select");
|
||||
}
|
||||
if (!options.xmlMode || options.lowerCaseAttributeNames) {
|
||||
selector.name = selector.name.toLowerCase();
|
||||
}
|
||||
return attributes_js_1.attributeRules[selector.action](next, selector, options);
|
||||
}
|
||||
case css_what_1.SelectorType.Pseudo: {
|
||||
return (0, index_js_1.compilePseudoSelector)(next, selector, options, context, compileToken);
|
||||
}
|
||||
// Tags
|
||||
case css_what_1.SelectorType.Tag: {
|
||||
if (selector.namespace != null) {
|
||||
throw new Error("Namespaced tag names are not yet supported by css-select");
|
||||
}
|
||||
var name_1 = selector.name;
|
||||
if (!options.xmlMode || options.lowerCaseTags) {
|
||||
name_1 = name_1.toLowerCase();
|
||||
}
|
||||
return function tag(elem) {
|
||||
return adapter.getName(elem) === name_1 && next(elem);
|
||||
};
|
||||
}
|
||||
// Traversal
|
||||
case css_what_1.SelectorType.Descendant: {
|
||||
if (options.cacheResults === false ||
|
||||
typeof WeakSet === "undefined") {
|
||||
return function descendant(elem) {
|
||||
var current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (next(current)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// @ts-expect-error `ElementNode` is not extending object
|
||||
var isFalseCache_1 = new WeakSet();
|
||||
return function cachedDescendant(elem) {
|
||||
var current = elem;
|
||||
while ((current = getElementParent(current, adapter))) {
|
||||
if (!isFalseCache_1.has(current)) {
|
||||
if (adapter.isTag(current) && next(current)) {
|
||||
return true;
|
||||
}
|
||||
isFalseCache_1.add(current);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case "_flexibleDescendant": {
|
||||
// Include element itself, only used while querying an array
|
||||
return function flexibleDescendant(elem) {
|
||||
var current = elem;
|
||||
do {
|
||||
if (next(current))
|
||||
return true;
|
||||
} while ((current = getElementParent(current, adapter)));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Parent: {
|
||||
return function parent(elem) {
|
||||
return adapter
|
||||
.getChildren(elem)
|
||||
.some(function (elem) { return adapter.isTag(elem) && next(elem); });
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Child: {
|
||||
return function child(elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(parent);
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Sibling: {
|
||||
return function sibling(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Adjacent: {
|
||||
if (adapter.prevElementSibling) {
|
||||
return function adjacent(elem) {
|
||||
var previous = adapter.prevElementSibling(elem);
|
||||
return previous != null && next(previous);
|
||||
};
|
||||
}
|
||||
return function adjacent(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var lastElement;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling)) {
|
||||
lastElement = currentSibling;
|
||||
}
|
||||
}
|
||||
return !!lastElement && next(lastElement);
|
||||
};
|
||||
}
|
||||
case css_what_1.SelectorType.Universal: {
|
||||
if (selector.namespace != null && selector.namespace !== "*") {
|
||||
throw new Error("Namespaced universal selectors are not yet supported by css-select");
|
||||
}
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.compileGeneralSelector = compileGeneralSelector;
|
||||
//# sourceMappingURL=general.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"general.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["general.ts"],"names":[],"mappings":";;;AAAA,iDAAiD;AACjD,wDAAoE;AAQpE,qCAAwC;AAExC,SAAS,gBAAgB,CACrB,IAAiB,EAC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AC,SAAS,IAAI,IAAI,IAAI,QAAQ,CAAC,SAAS,KAAK,GAAG,EAAE;gBAC1D,MAAM,IAAI,KAAK,CACX,oEAAoE,CACvE,CAAC;aACL;YAED,OAAO,IAAI,CAAC;SACf;KACJ;AACL,CAAC;AAvKD,wDAuKC"}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import type { CompiledQuery, Options, Query, Adapter } from "./types.js";
|
||||
export type { Options };
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
export declare const compile: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<Node>;
|
||||
export declare const _compileUnsafe: <Node, ElementNode extends Node>(selector: string | import("css-what").Selector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare const _compileToken: <Node, ElementNode extends Node>(selector: import("./types.js").InternalSelector[][], options?: Options<Node, ElementNode> | undefined, context?: Node | Node[] | undefined) => CompiledQuery<ElementNode>;
|
||||
export declare function prepareContext<Node, ElementNode extends Node>(elems: Node | Node[], adapter: Adapter<Node, ElementNode>, shouldTestNextSiblings?: boolean): Node[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
export declare const selectAll: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode[];
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
export declare const selectOne: <Node, ElementNode extends Node>(query: Query<ElementNode>, elements: Node | Node[], options?: Options<Node, ElementNode> | undefined) => ElementNode | null;
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
export declare function is<Node, ElementNode extends Node>(elem: ElementNode, query: Query<ElementNode>, options?: Options<Node, ElementNode>): boolean;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
export default selectAll;
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
export { filters, pseudos, aliases } from "./pseudo-selectors/index.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,oMAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,2MAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,4MAA4B,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;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,yJASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,8JASrB,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,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.aliases = exports.pseudos = exports.filters = exports.is = exports.selectOne = exports.selectAll = exports.prepareContext = exports._compileToken = exports._compileUnsafe = exports.compile = void 0;
|
||||
var DomUtils = __importStar(require("domutils"));
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
var compile_js_1 = require("./compile.js");
|
||||
var subselects_js_1 = require("./pseudo-selectors/subselects.js");
|
||||
var defaultEquals = function (a, b) { return a === b; };
|
||||
var defaultOptions = {
|
||||
adapter: DomUtils,
|
||||
equals: defaultEquals,
|
||||
};
|
||||
function convertOptionFormats(options) {
|
||||
var _a, _b, _c, _d;
|
||||
/*
|
||||
* We force one format of options to the other one.
|
||||
*/
|
||||
// @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
|
||||
var opts = options !== null && options !== void 0 ? options : defaultOptions;
|
||||
// @ts-expect-error Same as above.
|
||||
(_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
|
||||
// @ts-expect-error `equals` does not exist on `Options`
|
||||
(_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);
|
||||
return opts;
|
||||
}
|
||||
function wrapCompile(func) {
|
||||
return function addAdapter(selector, options, context) {
|
||||
var opts = convertOptionFormats(options);
|
||||
return func(selector, opts, context);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Compiles the query, returns a function.
|
||||
*/
|
||||
exports.compile = wrapCompile(compile_js_1.compile);
|
||||
exports._compileUnsafe = wrapCompile(compile_js_1.compileUnsafe);
|
||||
exports._compileToken = wrapCompile(compile_js_1.compileToken);
|
||||
function getSelectorFunc(searchFunc) {
|
||||
return function select(query, elements, options) {
|
||||
var opts = convertOptionFormats(options);
|
||||
if (typeof query !== "function") {
|
||||
query = (0, compile_js_1.compileUnsafe)(query, opts, elements);
|
||||
}
|
||||
var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings);
|
||||
return searchFunc(query, filteredElements, opts);
|
||||
};
|
||||
}
|
||||
function prepareContext(elems, adapter, shouldTestNextSiblings) {
|
||||
if (shouldTestNextSiblings === void 0) { shouldTestNextSiblings = false; }
|
||||
/*
|
||||
* Add siblings if the query requires them.
|
||||
* See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
|
||||
*/
|
||||
if (shouldTestNextSiblings) {
|
||||
elems = appendNextSiblings(elems, adapter);
|
||||
}
|
||||
return Array.isArray(elems)
|
||||
? adapter.removeSubsets(elems)
|
||||
: adapter.getChildren(elems);
|
||||
}
|
||||
exports.prepareContext = prepareContext;
|
||||
function appendNextSiblings(elem, adapter) {
|
||||
// Order matters because jQuery seems to check the children before the siblings
|
||||
var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
|
||||
var elemsLength = elems.length;
|
||||
for (var i = 0; i < elemsLength; i++) {
|
||||
var nextSiblings = (0, subselects_js_1.getNextSiblings)(elems[i], adapter);
|
||||
elems.push.apply(elems, nextSiblings);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns All matching elements.
|
||||
*
|
||||
*/
|
||||
exports.selectAll = getSelectorFunc(function (query, elems, options) {
|
||||
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
|
||||
? []
|
||||
: options.adapter.findAll(query, elems);
|
||||
});
|
||||
/**
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elems Elements to query. If it is an element, its children will be queried..
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns the first match, or null if there was no match.
|
||||
*/
|
||||
exports.selectOne = getSelectorFunc(function (query, elems, options) {
|
||||
return query === boolbase_1.default.falseFunc || !elems || elems.length === 0
|
||||
? null
|
||||
: options.adapter.findOne(query, elems);
|
||||
});
|
||||
/**
|
||||
* Tests whether or not an element is matched by query.
|
||||
*
|
||||
* @template Node The generic Node type for the DOM adapter being used.
|
||||
* @template ElementNode The Node type for elements for the DOM adapter being used.
|
||||
* @param elem The element to test if it matches the query.
|
||||
* @param query can be either a CSS selector string or a compiled query function.
|
||||
* @param [options] options for querying the document.
|
||||
* @see compile for supported selector queries.
|
||||
* @returns
|
||||
*/
|
||||
function is(elem, query, options) {
|
||||
var opts = convertOptionFormats(options);
|
||||
return (typeof query === "function" ? query : (0, compile_js_1.compile)(query, opts))(elem);
|
||||
}
|
||||
exports.is = is;
|
||||
/**
|
||||
* Alias for selectAll(query, elems, options).
|
||||
* @see [compile] for supported selector queries.
|
||||
*/
|
||||
exports.default = exports.selectAll;
|
||||
// Export filters, pseudos and aliases to allow users to supply their own.
|
||||
/** @deprecated Use the `pseudos` option instead. */
|
||||
var index_js_1 = require("./pseudo-selectors/index.js");
|
||||
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return index_js_1.filters; } });
|
||||
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return index_js_1.pseudos; } });
|
||||
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return index_js_1.aliases; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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expressed as selectors.
|
||||
*/
|
||||
export declare const aliases: Record<string, string>;
|
||||
//# sourceMappingURL=aliases.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aliases.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.aliases = void 0;
|
||||
/**
|
||||
* Aliases are pseudos that are expressed as selectors.
|
||||
*/
|
||||
exports.aliases = {
|
||||
// Links
|
||||
"any-link": ":is(a, area, link)[href]",
|
||||
link: ":any-link:not(:visited)",
|
||||
// Forms
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
|
||||
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 )",
|
||||
enabled: ":not(:disabled)",
|
||||
checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
|
||||
required: ":is(input, select, textarea)[required]",
|
||||
optional: ":is(input, select, textarea):not([required])",
|
||||
// JQuery extensions
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
|
||||
selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
||||
checkbox: "[type=checkbox]",
|
||||
file: "[type=file]",
|
||||
password: "[type=password]",
|
||||
radio: "[type=radio]",
|
||||
reset: "[type=reset]",
|
||||
image: "[type=image]",
|
||||
submit: "[type=submit]",
|
||||
parent: ":not(:empty)",
|
||||
header: ":is(h1, h2, h3, h4, h5, h6)",
|
||||
button: ":is(button, input[type=button])",
|
||||
input: ":is(input, textarea, select, button)",
|
||||
text: "input:is(:not([type!='']), [type=text])",
|
||||
};
|
||||
//# sourceMappingURL=aliases.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aliases.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/aliases.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,OAAO,GAA2B;IAC3C,QAAQ;IAER,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,yBAAyB;IAE/B,QAAQ;IAER,0EAA0E;IAC1E,QAAQ,EAAE,yMAIR;IACF,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EACH,6EAA6E;IACjF,QAAQ,EAAE,wCAAwC;IAClD,QAAQ,EAAE,8CAA8C;IAExD,oBAAoB;IAEpB,wFAAwF;IACxF,QAAQ,EACJ,8FAA8F;IAElG,QAAQ,EAAE,iBAAiB;IAC3B,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,iBAAiB;IAC3B,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,eAAe;IAEvB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,6BAA6B;IAErC,MAAM,EAAE,iCAAiC;IACzC,KAAK,EAAE,sCAAsC;IAC7C,IAAI,EAAE,yCAAyC;CAClD,CAAC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { CompiledQuery, InternalOptions } from "../types.js";
|
||||
export declare type Filter = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, text: string, options: InternalOptions<Node, ElementNode>, context?: Node[]) => CompiledQuery<ElementNode>;
|
||||
export declare const filters: Record<string, Filter>;
|
||||
//# sourceMappingURL=filters.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filters.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,aAAa,CAAC;AAE3E,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"}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.filters = void 0;
|
||||
var nth_check_1 = __importDefault(require("nth-check"));
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
function getChildFunc(next, adapter) {
|
||||
return function (elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return parent != null && adapter.isTag(parent) && next(elem);
|
||||
};
|
||||
}
|
||||
exports.filters = {
|
||||
contains: function (next, text, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return function contains(elem) {
|
||||
return next(elem) && adapter.getText(elem).includes(text);
|
||||
};
|
||||
},
|
||||
icontains: function (next, text, _a) {
|
||||
var adapter = _a.adapter;
|
||||
var itext = text.toLowerCase();
|
||||
return function icontains(elem) {
|
||||
return (next(elem) &&
|
||||
adapter.getText(elem).toLowerCase().includes(itext));
|
||||
};
|
||||
},
|
||||
// Location specific methods
|
||||
"nth-child": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var func = (0, nth_check_1.default)(rule);
|
||||
if (func === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
if (func === boolbase_1.default.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthChild(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var pos = 0;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-child": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var func = (0, nth_check_1.default)(rule);
|
||||
if (func === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
if (func === boolbase_1.default.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastChild(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var pos = 0;
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
break;
|
||||
if (adapter.isTag(siblings[i])) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-of-type": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var func = (0, nth_check_1.default)(rule);
|
||||
if (func === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
if (func === boolbase_1.default.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthOfType(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var pos = 0;
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
"nth-last-of-type": function (next, rule, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var func = (0, nth_check_1.default)(rule);
|
||||
if (func === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
if (func === boolbase_1.default.trueFunc)
|
||||
return getChildFunc(next, adapter);
|
||||
return function nthLastOfType(elem) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var pos = 0;
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
break;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === adapter.getName(elem)) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return func(pos) && next(elem);
|
||||
};
|
||||
},
|
||||
// TODO determine the actual root element
|
||||
root: function (next, _rule, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return function (elem) {
|
||||
var parent = adapter.getParent(elem);
|
||||
return (parent == null || !adapter.isTag(parent)) && next(elem);
|
||||
};
|
||||
},
|
||||
scope: function (next, rule, options, context) {
|
||||
var equals = options.equals;
|
||||
if (!context || context.length === 0) {
|
||||
// Equivalent to :root
|
||||
return exports.filters["root"](next, rule, options);
|
||||
}
|
||||
if (context.length === 1) {
|
||||
// NOTE: can't be unpacked, as :has uses this for side-effects
|
||||
return function (elem) { return equals(context[0], elem) && next(elem); };
|
||||
}
|
||||
return function (elem) { return context.includes(elem) && next(elem); };
|
||||
},
|
||||
hover: dynamicStatePseudo("isHovered"),
|
||||
visited: dynamicStatePseudo("isVisited"),
|
||||
active: dynamicStatePseudo("isActive"),
|
||||
};
|
||||
/**
|
||||
* Dynamic state pseudos. These depend on optional Adapter methods.
|
||||
*
|
||||
* @param name The name of the adapter method to call.
|
||||
* @returns Pseudo for the `filters` object.
|
||||
*/
|
||||
function dynamicStatePseudo(name) {
|
||||
return function dynamicPseudo(next, _rule, _a) {
|
||||
var adapter = _a.adapter;
|
||||
var func = adapter[name];
|
||||
if (typeof func !== "function") {
|
||||
return boolbase_1.default.falseFunc;
|
||||
}
|
||||
return function active(elem) {
|
||||
return func(elem) && next(elem);
|
||||
};
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=filters.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filters.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/filters.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAkC;AAClC,sDAAgC;AAUhC,SAAS,YAAY,CACjB,IAAgC,EAChC,OAAmC;IAEnC,OAAO,UAAC,IAAI;QACR,IAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC;AACN,CAAC;AAEY,QAAA,OAAO,GAA2B;IAC3C,QAAQ,YAAC,IAAI,EAAE,IAAI,EAAE,EAAW;YAAT,OAAO,aAAA;QAC1B,OAAO,SAAS,QAAQ,CAAC,IAAI;YACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC;IACN,CAAC;IACD,SAAS,YAAC,IAAI,EAAE,IAAI,EAAE,EAAW;YAAT,OAAO,aAAA;QAC3B,IAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEjC,OAAO,SAAS,SAAS,CAAC,IAAI;YAC1B,OAAO,CACH,IAAI,CAAC,IAAI,CAAC;gBACV,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CA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CompileToken } from "../types.js";
|
||||
import { PseudoSelector } from "css-what";
|
||||
import { filters } from "./filters.js";
|
||||
import { pseudos } from "./pseudos.js";
|
||||
import { aliases } from "./aliases.js";
|
||||
export { filters, pseudos, aliases };
|
||||
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>;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,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,CA4C5B"}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0;
|
||||
var css_what_1 = require("css-what");
|
||||
var filters_js_1 = require("./filters.js");
|
||||
Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return filters_js_1.filters; } });
|
||||
var pseudos_js_1 = require("./pseudos.js");
|
||||
Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudos_js_1.pseudos; } });
|
||||
var aliases_js_1 = require("./aliases.js");
|
||||
Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return aliases_js_1.aliases; } });
|
||||
var subselects_js_1 = require("./subselects.js");
|
||||
function compilePseudoSelector(next, selector, options, context, compileToken) {
|
||||
var _a;
|
||||
var name = selector.name, data = selector.data;
|
||||
if (Array.isArray(data)) {
|
||||
if (!(name in subselects_js_1.subselects)) {
|
||||
throw new Error("Unknown pseudo-class :".concat(name, "(").concat(data, ")"));
|
||||
}
|
||||
return subselects_js_1.subselects[name](next, data, options, context, compileToken);
|
||||
}
|
||||
var userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
|
||||
var stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases_js_1.aliases[name];
|
||||
if (typeof stringPseudo === "string") {
|
||||
if (data != null) {
|
||||
throw new Error("Pseudo ".concat(name, " doesn't have any arguments"));
|
||||
}
|
||||
// The alias has to be parsed here, to make sure options are respected.
|
||||
var alias = (0, css_what_1.parse)(stringPseudo);
|
||||
return subselects_js_1.subselects["is"](next, alias, options, context, compileToken);
|
||||
}
|
||||
if (typeof userPseudo === "function") {
|
||||
(0, pseudos_js_1.verifyPseudoArgs)(userPseudo, name, data, 1);
|
||||
return function (elem) { return userPseudo(elem, data) && next(elem); };
|
||||
}
|
||||
if (name in filters_js_1.filters) {
|
||||
return filters_js_1.filters[name](next, data, options, context);
|
||||
}
|
||||
if (name in pseudos_js_1.pseudos) {
|
||||
var pseudo_1 = pseudos_js_1.pseudos[name];
|
||||
(0, pseudos_js_1.verifyPseudoArgs)(pseudo_1, name, data, 2);
|
||||
return function (elem) { return pseudo_1(elem, options, data) && next(elem); };
|
||||
}
|
||||
throw new Error("Unknown pseudo-class :".concat(name));
|
||||
}
|
||||
exports.compilePseudoSelector = compilePseudoSelector;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/index.ts"],"names":[],"mappings":";;;AAeA,qCAAiD;AACjD,2CAAuC;AAK9B,wFALA,oBAAO,OAKA;AAJhB,2CAAyD;AAIvC,wFAJT,oBAAO,OAIS;AAHzB,2CAAuC;AAGZ,wFAHlB,oBAAO,OAGkB;AAFlC,iDAA6C;AAI7C,SAAgB,qBAAqB,CACjC,IAAgC,EAChC,QAAwB,EACxB,OAA2C,EAC3C,OAA2B,EAC3B,YAA6C;;IAErC,IAAA,IAAI,GAAW,QAAQ,KAAnB,EAAE,IAAI,GAAK,QAAQ,KAAb,CAAc;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACrB,IAAI,CAAC,CAAC,IAAI,IAAI,0BAAU,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,gCAAyB,IAAI,cAAI,IAAI,MAAG,CAAC,CAAC;SAC7D;QAED,OAAO,0BAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACvE;IAED,IAAM,UAAU,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAG,IAAI,CAAC,CAAC;IAE3C,IAAM,YAAY,GACd,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,oBAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QAClC,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,iBAAU,IAAI,gCAA6B,CAAC,CAAC;SAChE;QAED,uEAAuE;QACvE,IAAM,KAAK,GAAG,IAAA,gBAAK,EAAC,YAAY,CAAC,CAAC;QAClC,OAAO,0BAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACxE;IAED,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;QAClC,IAAA,6BAAgB,EAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE5C,OAAO,UAAC,IAAI,IAAK,OAAA,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAApC,CAAoC,CAAC;KACzD;IAED,IAAI,IAAI,IAAI,oBAAO,EAAE;QACjB,OAAO,oBAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAChE;IAED,IAAI,IAAI,IAAI,oBAAO,EAAE;QACjB,IAAM,QAAM,GAAG,oBAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAA,6BAAgB,EAAC,QAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAExC,OAAO,UAAC,IAAI,IAAK,OAAA,QAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAzC,CAAyC,CAAC;KAC9D;IAED,MAAM,IAAI,KAAK,CAAC,gCAAyB,IAAI,CAAE,CAAC,CAAC;AACrD,CAAC;AAlDD,sDAkDC"}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { PseudoSelector } from "css-what";
|
||||
import type { InternalOptions } from "../types.js";
|
||||
export declare type Pseudo = <Node, ElementNode extends Node>(elem: ElementNode, options: InternalOptions<Node, ElementNode>, subselect?: string | null) => boolean;
|
||||
export declare const pseudos: Record<string, Pseudo>;
|
||||
export declare function verifyPseudoArgs<T extends Array<unknown>>(func: (...args: T) => boolean, name: string, subselect: PseudoSelector["data"], argIndex: number): void;
|
||||
//# sourceMappingURL=pseudos.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pseudos.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC;AAGb,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkF1C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EACrD,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,EACjC,QAAQ,EAAE,MAAM,GACjB,IAAI,CAQN"}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.verifyPseudoArgs = exports.pseudos = void 0;
|
||||
// While filters are precompiled, pseudos get called when they are needed
|
||||
exports.pseudos = {
|
||||
empty: function (elem, _a) {
|
||||
var adapter = _a.adapter;
|
||||
return !adapter.getChildren(elem).some(function (elem) {
|
||||
// FIXME: `getText` call is potentially expensive.
|
||||
return adapter.isTag(elem) || adapter.getText(elem) !== "";
|
||||
});
|
||||
},
|
||||
"first-child": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
if (adapter.prevElementSibling) {
|
||||
return adapter.prevElementSibling(elem) == null;
|
||||
}
|
||||
var firstChild = adapter
|
||||
.getSiblings(elem)
|
||||
.find(function (elem) { return adapter.isTag(elem); });
|
||||
return firstChild != null && equals(elem, firstChild);
|
||||
},
|
||||
"last-child": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
if (equals(elem, siblings[i]))
|
||||
return true;
|
||||
if (adapter.isTag(siblings[i]))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"first-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var elemName = adapter.getName(elem);
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"last-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
var elemName = adapter.getName(elem);
|
||||
for (var i = siblings.length - 1; i >= 0; i--) {
|
||||
var currentSibling = siblings[i];
|
||||
if (equals(elem, currentSibling))
|
||||
return true;
|
||||
if (adapter.isTag(currentSibling) &&
|
||||
adapter.getName(currentSibling) === elemName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"only-of-type": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
var elemName = adapter.getName(elem);
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every(function (sibling) {
|
||||
return equals(elem, sibling) ||
|
||||
!adapter.isTag(sibling) ||
|
||||
adapter.getName(sibling) !== elemName;
|
||||
});
|
||||
},
|
||||
"only-child": function (elem, _a) {
|
||||
var adapter = _a.adapter, equals = _a.equals;
|
||||
return adapter
|
||||
.getSiblings(elem)
|
||||
.every(function (sibling) { return equals(elem, sibling) || !adapter.isTag(sibling); });
|
||||
},
|
||||
};
|
||||
function verifyPseudoArgs(func, name, subselect, argIndex) {
|
||||
if (subselect === null) {
|
||||
if (func.length > argIndex) {
|
||||
throw new Error("Pseudo-class :".concat(name, " requires an argument"));
|
||||
}
|
||||
}
|
||||
else if (func.length === argIndex) {
|
||||
throw new Error("Pseudo-class :".concat(name, " doesn't have any arguments"));
|
||||
}
|
||||
}
|
||||
exports.verifyPseudoArgs = verifyPseudoArgs;
|
||||
//# sourceMappingURL=pseudos.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pseudos.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/pseudos.ts"],"names":[],"mappings":";;;AASA,yEAAyE;AAC5D,QAAA,OAAO,GAA2B;IAC3C,KAAK,YAAC,IAAI,EAAE,EAAW;YAAT,OAAO,aAAA;QACjB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAClC,UAAC,IAAI;YACD,kDAAkD;YAClD,OAAA,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;QAAnD,CAAmD,CAC1D,CAAC;IACN,CAAC;IAED,aAAa,YAAC,IAAI,EAAE,EAAmB;YAAjB,OAAO,aAAA,EAAE,MAAM,YAAA;QACjC,IAAI,OAAO,CAAC,kBAAkB,EAAE;YAC5B,OAAO,OAAO,CAAC,kBAAkB,CAAC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M,YAAA;QAChC,OAAO,OAAO;aACT,WAAW,CAAC,IAAI,CAAC;aACjB,KAAK,CACF,UAAC,OAAO,IAAK,OAAA,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAhD,CAAgD,CAChE,CAAC;IACV,CAAC;CACJ,CAAC;AAEF,SAAgB,gBAAgB,CAC5B,IAA6B,EAC7B,IAAY,EACZ,SAAiC,EACjC,QAAgB;IAEhB,IAAI,SAAS,KAAK,IAAI,EAAE;QACpB,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,wBAAiB,IAAI,0BAAuB,CAAC,CAAC;SACjE;KACJ;SAAM,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,wBAAiB,IAAI,gCAA6B,CAAC,CAAC;KACvE;AACL,CAAC;AAbD,4CAaC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import type { Selector } from "css-what";
|
||||
import type { CompiledQuery, InternalOptions, CompileToken, Adapter } from "../types.js";
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
export declare const PLACEHOLDER_ELEMENT: {};
|
||||
export declare function ensureIsTag<Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, adapter: Adapter<Node, ElementNode>): CompiledQuery<Node>;
|
||||
export declare type Subselect = <Node, ElementNode extends Node>(next: CompiledQuery<ElementNode>, subselect: Selector[][], options: InternalOptions<Node, ElementNode>, context: Node[] | undefined, compileToken: CompileToken<Node, ElementNode>) => CompiledQuery<ElementNode>;
|
||||
export declare function getNextSiblings<Node, ElementNode extends Node>(elem: Node, adapter: Adapter<Node, ElementNode>): ElementNode[];
|
||||
export declare const subselects: Record<string, Subselect>;
|
||||
//# sourceMappingURL=subselects.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subselects.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/subselects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,YAAY,EACZ,OAAO,EACV,MAAM,aAAa,CAAC;AAGrB,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACtD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACnD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,KAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,WAAW,EAAE,CAMf;AAiCD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAgEhD,CAAC"}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.subselects = exports.getNextSiblings = exports.ensureIsTag = exports.PLACEHOLDER_ELEMENT = void 0;
|
||||
var boolbase_1 = __importDefault(require("boolbase"));
|
||||
var sort_js_1 = require("../sort.js");
|
||||
/** Used as a placeholder for :has. Will be replaced with the actual element. */
|
||||
exports.PLACEHOLDER_ELEMENT = {};
|
||||
function ensureIsTag(next, adapter) {
|
||||
if (next === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
return function (elem) { return adapter.isTag(elem) && next(elem); };
|
||||
}
|
||||
exports.ensureIsTag = ensureIsTag;
|
||||
function getNextSiblings(elem, adapter) {
|
||||
var siblings = adapter.getSiblings(elem);
|
||||
if (siblings.length <= 1)
|
||||
return [];
|
||||
var elemIndex = siblings.indexOf(elem);
|
||||
if (elemIndex < 0 || elemIndex === siblings.length - 1)
|
||||
return [];
|
||||
return siblings.slice(elemIndex + 1).filter(adapter.isTag);
|
||||
}
|
||||
exports.getNextSiblings = getNextSiblings;
|
||||
function copyOptions(options) {
|
||||
// Not copied: context, rootFunc
|
||||
return {
|
||||
xmlMode: !!options.xmlMode,
|
||||
lowerCaseAttributeNames: !!options.lowerCaseAttributeNames,
|
||||
lowerCaseTags: !!options.lowerCaseTags,
|
||||
quirksMode: !!options.quirksMode,
|
||||
cacheResults: !!options.cacheResults,
|
||||
pseudos: options.pseudos,
|
||||
adapter: options.adapter,
|
||||
equals: options.equals,
|
||||
};
|
||||
}
|
||||
var is = function (next, token, options, context, compileToken) {
|
||||
var func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase_1.default.trueFunc
|
||||
? next
|
||||
: func === boolbase_1.default.falseFunc
|
||||
? boolbase_1.default.falseFunc
|
||||
: function (elem) { return func(elem) && next(elem); };
|
||||
};
|
||||
/*
|
||||
* :not, :has, :is, :matches and :where have to compile selectors
|
||||
* doing this in src/pseudos.ts would lead to circular dependencies,
|
||||
* so we add them here
|
||||
*/
|
||||
exports.subselects = {
|
||||
is: is,
|
||||
/**
|
||||
* `:matches` and `:where` are aliases for `:is`.
|
||||
*/
|
||||
matches: is,
|
||||
where: is,
|
||||
not: function (next, token, options, context, compileToken) {
|
||||
var func = compileToken(token, copyOptions(options), context);
|
||||
return func === boolbase_1.default.falseFunc
|
||||
? next
|
||||
: func === boolbase_1.default.trueFunc
|
||||
? boolbase_1.default.falseFunc
|
||||
: function (elem) { return !func(elem) && next(elem); };
|
||||
},
|
||||
has: function (next, subselect, options, _context, compileToken) {
|
||||
var adapter = options.adapter;
|
||||
var opts = copyOptions(options);
|
||||
opts.relativeSelector = true;
|
||||
var context = subselect.some(function (s) { return s.some(sort_js_1.isTraversal); })
|
||||
? // Used as a placeholder. Will be replaced with the actual element.
|
||||
[exports.PLACEHOLDER_ELEMENT]
|
||||
: undefined;
|
||||
var compiled = compileToken(subselect, opts, context);
|
||||
if (compiled === boolbase_1.default.falseFunc)
|
||||
return boolbase_1.default.falseFunc;
|
||||
var hasElement = ensureIsTag(compiled, adapter);
|
||||
// If `compiled` is `trueFunc`, we can skip this.
|
||||
if (context && compiled !== boolbase_1.default.trueFunc) {
|
||||
/*
|
||||
* `shouldTestNextSiblings` will only be true if the query starts with
|
||||
* a traversal (sibling or adjacent). That means we will always have a context.
|
||||
*/
|
||||
var _a = compiled.shouldTestNextSiblings, shouldTestNextSiblings_1 = _a === void 0 ? false : _a;
|
||||
return function (elem) {
|
||||
if (!next(elem))
|
||||
return false;
|
||||
context[0] = elem;
|
||||
var childs = adapter.getChildren(elem);
|
||||
var nextElements = shouldTestNextSiblings_1
|
||||
? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs;
|
||||
return adapter.existsOne(hasElement, nextElements);
|
||||
};
|
||||
}
|
||||
return function (elem) {
|
||||
return next(elem) &&
|
||||
adapter.existsOne(hasElement, adapter.getChildren(elem));
|
||||
};
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=subselects.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subselects.js","sourceRoot":"https://raw.githubusercontent.com/fb55/css-select/0f0725a9dfeddd2fdb54eda9656cdbab5bbf6be6/src/","sources":["pseudo-selectors/subselects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,sDAAgC;AAOhC,sCAAyC;AAEzC,gFAAgF;AACnE,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEtC,SAAgB,WAAW,CACvB,IAAgC,EAChC,OAAmC;IAEnC,IAAI,IAAI,KAAK,kBAAQ,CAAC,SAAS;QAAE,OAAO,kBAAQ,CAAC,SAAS,CAAC;IAC3D,OAAO,UAAC,IAAU,IAAK,OAAA,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAjC,CAAiC,CAAC;AAC7D,CAAC;AAND,kCAMC;AAUD,SAAgB,eAAe,CAC3B,IAAU,EACV,OAAmC;IAEnC,IAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AATD,0CASC;AA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,GAAG,IAAI,CAAC;gBAClB,IAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACzC,IAAM,YAAY,GAAG,wBAAsB;oBACvC,CAAC,iCAAK,MAAM,SAAK,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,QAC/C,CAAC,CAAC,MAAM,CAAC;gBAEb,OAAO,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;YACvD,CAAC,CAAC;SACL;QAED,OAAO,UAAC,IAAI;YACR,OAAA,IAAI,CAAC,IAAI,CAAC;gBACV,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QADxD,CACwD,CAAC;IACjE,CAAC;CACJ,CAAC"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import type { InternalSelector } from "./types.js";
|
||||
import { type Traversal } from "css-what";
|
||||
export declare function isTraversal(token: InternalSelector): token is Traversal;
|
||||
/**
|
||||
* Sort the parts of the passed selector,
|
||||
* as there is potential for optimization
|
||||
* (some types of selectors are faster than others)
|
||||
*
|
||||
* @param arr Selector to sort
|
||||
*/
|
||||
export default function sortByProcedure(arr: InternalSelector[]): void;
|
||||
//# sourceMappingURL=sort.d.ts.map
|
||||
Loaded 100 of 548 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user