Cars project 3 do dokończenia

This commit is contained in:
aplikacje committed 2026-11-05 10:50:57 +01:00
1 parent 3b96ac1be8
commit b3be59a011
159 files changed
+9757 -3749

No files matched your search

+7 -10
View File
@@ -1,10 +1,7 @@
{"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"BRAK DANYCH","naped4x4":"NIE","model":"EN57","_id":"3WYiUbXyKdNCora2"} {"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"TAK","naped4x4":"NIE","model":"Ford Fiesta","_id":"2gdpmzYo0D3kQPWu"}
{"ubezpieczony":"NIE","benzyna":"BRAK DANYCH","uszkodzony":"TAK","naped4x4":"TAK","model":"Newag Impuls","_id":"Njg77UGgaUwa7BNO"} {"ubezpieczony":"NIE","benzyna":"TAK","uszkodzony":"TAK","naped4x4":"TAK","model":"Volvo V70","_id":"35rdbizIq28p0PwO"}
{"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"NIE","model":"Volvo S60","_id":"Ybsk8Tp8XVEx9YCI"} {"ubezpieczony":"TAK","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"NIE","model":"Volvo S60","_id":"DxpP3rVTymsW4Zsd"}
{"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"TAK","model":"Ford Fiesta","_id":"cTR4SUI0UrZM1MzX"} {"ubezpieczony":"TAK","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"NIE","model":"Volvo S60","_id":"ILJYjEqkiMuIqjWL"}
{"ubezpieczony":"TAK","benzyna":"TAK","uszkodzony":"TAK","naped4x4":"NIE","model":"Volkswagen Polo","_id":"eSeokpNe3Hr5xM92"} {"ubezpieczony":"NIE","benzyna":"TAK","uszkodzony":"TAK","naped4x4":"NIE","model":"Fiat Siesta","_id":"MZjzNBYD8klZGOwy"}
{"ubezpieczony":"NIE","benzyna":"TAK","uszkodzony":"TAK","naped4x4":"NIE","model":"Volvo S60","_id":"kpIYNiYxGkR0Pjeg"} {"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"NIE","model":"Ford Fiesta","_id":"VKKPOAVqTuz84yEa"}
{"ubezpieczony":"NIE","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"NIE","model":"Volvo V70","_id":"la6azGJJdcMGsuiq"} {"ubezpieczony":"TAK","benzyna":"NIE","uszkodzony":"TAK","naped4x4":"TAK","model":"Volkswagen Polo","_id":"rpO881mPXDqGMLFX"}
{"ubezpieczony":"NIE","benzyna":"TAK","uszkodzony":"TAK","naped4x4":"TAK","model":"Newag Impuls","_id":"q1epOgXNeFQCF5wb"}
{"ubezpieczony":"TAK","benzyna":"NIE","uszkodzony":"TAK","naped4x4":"NIE","model":"Ford Fiesta","_id":"qfpGtQuIRrCFPkJb"}
{"ubezpieczony":"TAK","benzyna":"NIE","uszkodzony":"NIE","naped4x4":"TAK","model":"Fiat Siesta","_id":"qiboa7ygHrMvH6I6"}
+3
View File
@@ -0,0 +1,3 @@
{"user_id":2,"car_id":"VKKPOAVqTuz84yEa","_id":"3LIJhKAqQwGy900g"}
{"user_id":2,"car_id":"DxpP3rVTymsW4Zsd","_id":"lcNcdJPQky8MYMbi"}
{"user_id":2,"car_id":"rpO881mPXDqGMLFX","_id":"nQArHJx10blxgheV"}
+167 -14
View File
@@ -3,6 +3,9 @@ const express = require('express');
const { create } = require('express-handlebars'); const { create } = require('express-handlebars');
const path = require('path'); const path = require('path');
const cookie_parser = require('cookie-parser');
const cookie_secret_key = 'SprzedamOplaZaDwaZlote';
const app = express(); const app = express();
const PORT = 3000; const PORT = 3000;
@@ -11,12 +14,20 @@ const DB = new DS({
autoload: true autoload: true
}); });
const favDB = new DS({
filename: 'data/favourites.db',
autoload: true
});
const hbs = create({ const hbs = create({
defaultLayout: 'main.hbs', defaultLayout: 'main.hbs',
extname: '.hbs', extname: '.hbs',
helpers: { helpers: {
equ(p, q) { equ(p, q) {
return p == q; return p == q;
},
gte(p, q) {
return p >= q;
} }
} }
}); });
@@ -25,9 +36,25 @@ app.engine('.hbs', hbs.engine);
app.set('view engine', '.hbs'); app.set('view engine', '.hbs');
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.use(cookie_parser(cookie_secret_key));
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use(express.json()); app.use(express.json());
const users = [
{
id: 1,
username: 'admin',
unsafe_password: '123',
privilege_level: 2
},
{
id: 2,
username: 'user',
unsafe_password: '123',
privilege_level: 1
}
];
const model = [ const model = [
"Ford Fiesta", "Ford Fiesta",
"Fiat Siesta", "Fiat Siesta",
@@ -37,13 +64,70 @@ const model = [
"Newag Impuls" "Newag Impuls"
]; ];
/// routingi // logowanie i walidacja użytkownika
app.get("/", function (req, res) { const get_privileges = function (req, res, next) {
res.render('index.hbs'); let privilege_level = 0;
if (req.signedCookies.user) {
let userIndex = users.findIndex(user => user.id == req.signedCookies.user.id);
privilege_level = users[userIndex].privilege_level;
}
req.privilege_level = privilege_level;
next();
};
app.post("/login", function (req, res) {
let user = users.find(user => user.username == req.body.login);
if (user && user.unsafe_password == req.body.password) {
res.cookie("user",
{
"id": user.id,
"username": user.username,
"privilege_level": user.privilege_level
},
{ signed: true, maxAge: 1000 * 60 * 60 * 24 * 30 }
)
} else {
return res.redirect("/login?badcreds=true");
}
res.redirect("/");
}); });
app.post("/add", function (req, res) { app.get("/login", get_privileges, function (req, res) {
let ctx = {
privilege_level: req.privilege_level
};
if (req.query.badcreds) {
ctx.badcreds = true;
}
res.render("login.hbs", ctx);
});
app.get("/logout", function (req, res) {
res.clearCookie("user");
res.redirect("/");
});
/// routingi
app.get("/", get_privileges, function (req, res) {
let ctx = {
privilege_level: req.privilege_level
};
res.render('index.hbs', ctx);
});
app.post("/add", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
let doc = { let doc = {
ubezpieczony: req.body.ubezpieczony ? "TAK" : "NIE", ubezpieczony: req.body.ubezpieczony ? "TAK" : "NIE",
benzyna: req.body.benzyna ? "TAK" : "NIE", benzyna: req.body.benzyna ? "TAK" : "NIE",
@@ -58,10 +142,14 @@ app.post("/add", function (req, res) {
}); });
}); });
app.get("/add", function (req, res) { app.get("/add", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
let r_model = model[Math.floor(Math.random() * model.length)] let r_model = model[Math.floor(Math.random() * model.length)]
let ctx = { let ctx = {
privilege_level: req.privilege_level,
"model": r_model "model": r_model
}; };
@@ -73,16 +161,63 @@ app.get("/add", function (req, res) {
res.render("add.hbs", ctx); res.render("add.hbs", ctx);
}); });
app.get("/list", function (req, res) { app.get("/list", get_privileges, function (req, res) {
DB.find({}, function (err, docs) { DB.find({}, function (err, docs) {
let ctx = { let ctx = {
car: docs privilege_level: req.privilege_level,
car: []
}; };
// sprawdz czy id jest w faworytach dla danego userid
res.render('list.hbs', ctx); res.render('list.hbs', ctx);
}); });
}); });
app.post("/delete", function (req, res) { app.get("/favourites", get_privileges, function (req, res) {
if (req.privilege_level < 1) {
return res.redirect("/");
}
let ctx = {
privilege_level: req.privilege_level
};
favDB.find({
user_id: req.signedCookies.user.id,
}, function (err, docs) {
let ids = [];
docs.forEach(doc => {
ids.push(doc.car_id);
})
DB.find({ _id: { $in: ids } }, function (err2, docs2) {
ctx.car = docs2;
res.render("favourites.hbs", ctx);
});
});
});
app.get("/fav", get_privileges, function (req, res) {
if (req.privilege_level < 1) {
return res.redirect("/");
}
let doc = {
user_id: req.signedCookies.user.id,
car_id: req.query.id
};
favDB.insert(doc, function (err, new_doc) {
res.redirect("/list");
});
});
app.post("/delete", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
console.log(req.body); console.log(req.body);
if (req.body.deletions) { if (req.body.deletions) {
@@ -100,16 +235,23 @@ app.post("/delete", function (req, res) {
res.redirect("/delete"); res.redirect("/delete");
}); });
app.get("/delete", function (req, res) { app.get("/delete", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
DB.find({}, function (err, docs) { DB.find({}, function (err, docs) {
let ctx = { let ctx = {
privilege_level: req.privilege_level,
car: docs car: docs
}; };
res.render('delete.hbs', ctx); res.render('delete.hbs', ctx);
}); });
}); });
app.get("/deleteSpecific", function (req, res) { app.get("/deleteSpecific", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
if (req.query.id) { if (req.query.id) {
DB.remove({ _id: req.query.id }, {}, function (err, numRemoved) { DB.remove({ _id: req.query.id }, {}, function (err, numRemoved) {
console.log("Usunięto " + numRemoved + " dokument."); console.log("Usunięto " + numRemoved + " dokument.");
@@ -119,7 +261,10 @@ app.get("/deleteSpecific", function (req, res) {
res.redirect("/delete"); res.redirect("/delete");
}); });
app.get("/deleteAll", function (req, res) { app.get("/deleteAll", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
DB.remove({}, { multi: true }, function (err, numRemoved) { DB.remove({}, { multi: true }, function (err, numRemoved) {
console.log("usunięto dokumentów: " + numRemoved); console.log("usunięto dokumentów: " + numRemoved);
}); });
@@ -127,7 +272,10 @@ app.get("/deleteAll", function (req, res) {
res.redirect("/delete"); res.redirect("/delete");
}); });
app.post("/edit", function (req, res) { app.post("/edit", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
DB.update({ _id: req.body._id }, { $set: req.body }, {}, function (err, numUpdated) { DB.update({ _id: req.body._id }, { $set: req.body }, {}, function (err, numUpdated) {
console.log('Zaktualizowano ' + numUpdated + ' dokumentów.'); console.log('Zaktualizowano ' + numUpdated + ' dokumentów.');
}); });
@@ -135,9 +283,13 @@ app.post("/edit", function (req, res) {
res.redirect("/edit"); res.redirect("/edit");
}); });
app.get("/edit", function (req, res) { app.get("/edit", get_privileges, function (req, res) {
if (req.privilege_level < 2) {
return res.redirect("/");
}
DB.find({}, function (err, docs) { DB.find({}, function (err, docs) {
let ctx = { let ctx = {
privilege_level: req.privilege_level,
car: [] car: []
}; };
@@ -158,9 +310,10 @@ app.post("/search", function (req, res) {
// do dokończenia tutaj // do dokończenia tutaj
}); });
app.get("/search", function (req, res) { app.get("/search", get_privileges, function (req, res) {
DB.find({}, function (err, docs) { DB.find({}, function (err, docs) {
let ctx = { let ctx = {
privilege_level: req.privilege_level,
car: docs car: docs
}; };
res.render('search.hbs', ctx); res.render('search.hbs', ctx);
+50 -24
View File
@@ -4,6 +4,12 @@
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"node_modules/@isaacs/nonrecursive-glob-match": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.0.3.tgz",
"integrity": "sha512-SI7kyKHq4XXDRozw+r9GlRZkia1ZkFrpLW98r2IC2Bpr8YkFGE3fvjzmxCG0x78A++69HmDNrDvSMYBZmHGpKA==",
"license": "BlueOak-1.0.0"
},
"node_modules/@seald-io/binary-search-tree": { "node_modules/@seald-io/binary-search-tree": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/@seald-io/binary-search-tree/-/binary-search-tree-1.0.3.tgz", "resolved": "https://registry.npmjs.org/@seald-io/binary-search-tree/-/binary-search-tree-1.0.3.tgz",
@@ -58,18 +64,18 @@
} }
}, },
"node_modules/body-parser": { "node_modules/body-parser": {
"version": "2.3.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"bytes": "^3.1.2", "bytes": "^3.1.2",
"content-type": "^2.0.0", "content-type": "^2.1.0",
"debug": "^4.4.3", "debug": "^4.4.3",
"http-errors": "^2.0.1", "http-errors": "^2.0.1",
"iconv-lite": "^0.7.2", "iconv-lite": "^0.7.3",
"on-finished": "^2.4.1", "on-finished": "^2.4.1",
"qs": "^6.15.2", "qs": "^6.16.1",
"raw-body": "^3.0.2", "raw-body": "^3.0.2",
"type-is": "^2.1.0" "type-is": "^2.1.0"
}, },
@@ -184,6 +190,25 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/cookie-parser": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz",
"integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==",
"license": "MIT",
"dependencies": {
"cookie": "0.7.2",
"cookie-signature": "1.0.6"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/cookie-parser/node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
"license": "MIT"
},
"node_modules/cookie-signature": { "node_modules/cookie-signature": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
@@ -354,17 +379,17 @@
} }
}, },
"node_modules/express-handlebars": { "node_modules/express-handlebars": {
"version": "9.0.2", "version": "9.0.4",
"resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-9.0.2.tgz", "resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-9.0.4.tgz",
"integrity": "sha512-SkcqBwc70F3z1kHAepnoXYYkBrYSPeSxIOYuVacUtV9XrfdysgRkGov8ToOjo8M1tKVX68su82UTxhJBNDSSog==", "integrity": "sha512-nwrDVURdu+6IRy7HYqPCQbVwBlu05sBG6WXNlxWRt5MdDU9ToWe2ruphDX4oIQ4dy/ylFR8m74CPQVG9YeALvQ==",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"glob": "^13.0.6", "glob": "^14.0.3",
"graceful-fs": "^4.2.11", "graceful-fs": "^4.2.11",
"handlebars": "^4.7.10" "handlebars": "^4.7.10"
}, },
"engines": { "engines": {
"node": ">=22.23.3" "node": ">=22.23.4"
} }
}, },
"node_modules/finalhandler": { "node_modules/finalhandler": {
@@ -477,14 +502,14 @@
} }
}, },
"node_modules/glob": { "node_modules/glob": {
"version": "13.0.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.3.tgz",
"integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", "integrity": "sha512-A1vjIwC3qpdCso45Iw127gnp7sPhqgY8lUQhDrArIs+GbmfaaVPFuoyy7WyLT9EPZCRZ7j7aLdwUhQmHWesEow==",
"license": "BlueOak-1.0.0", "license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"minimatch": "^10.2.2", "minimatch": "^11.0.2",
"minipass": "^7.1.3", "minipass": "^7.1.3",
"path-scurry": "^2.0.2" "path-scurry": "^3.0.0"
}, },
"engines": { "engines": {
"node": "18 || 20 || >=22" "node": "18 || 20 || >=22"
@@ -813,15 +838,16 @@
} }
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "10.2.6", "version": "11.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.4.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "integrity": "sha512-/UJ1dEoVQTjPNDh6SGlUo+ueLMmoHTas4q+8yaAR/5t6nLAIiBDJtoYUh20IYleix7ehiQkgczb84PE3uzHkxg==",
"license": "BlueOak-1.0.0", "license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"brace-expansion": "^5.0.8" "@isaacs/nonrecursive-glob-match": "^1.0.3",
"brace-expansion": "^5.0.12"
}, },
"engines": { "engines": {
"node": "18 || 20 || >=22" "node": "20 || >=22"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
@@ -916,9 +942,9 @@
} }
}, },
"node_modules/path-scurry": { "node_modules/path-scurry": {
"version": "2.0.2", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz",
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", "integrity": "sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==",
"license": "BlueOak-1.0.0", "license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"lru-cache": "^11.0.0", "lru-cache": "^11.0.0",
+55
View File
@@ -0,0 +1,55 @@
# Blue Oak Model License
Version 1.0.0
## Purpose
This license gives everyone as much permission to work with
this software as possible, while protecting contributors
from liability.
## Acceptance
In order to receive this license, you must agree to its
rules. The rules of this license are both obligations
under that agreement and conditions to your license.
You must not do anything with this software that triggers
a rule that you cannot or will not follow.
## Copyright
Each contributor licenses you to do everything with this
software that would otherwise infringe that contributor's
copyright in it.
## Notices
You must ensure that everyone who gets a copy of
any part of this software from you, with or without
changes, also gets the text of this license or a link to
<https://blueoakcouncil.org/license/1.0.0>.
## Excuse
If anyone notifies you in writing that you have not
complied with [Notices](#notices), you can keep your
license by taking all practical steps to comply within 30
days after the notice. If you do not do so, your license
ends immediately.
## Patent
Each contributor licenses you to do everything with this
software that would otherwise infringe any patent claims
they can license or become able to license.
## Reliability
No contributor can revoke this license.
## No Liability
***As far as the law allows, this software comes as is,
without any warranty or condition, and no contributor
will be liable to anyone for any damages related to this
software or this license, under any kind of legal claim.***
+333
View File
@@ -0,0 +1,333 @@
# @isaacs/nonrecursive-glob-match
This is a glob matcher that can be applied to a single path
portion (ie, not `/`), which completes in polynomial time because
it doesn't compile to Regular Expressions or any other
backtrack-dependent algorithm.
## USAGE
```ts
import { Matcher } from '@isaacs/nonrecursive-glob-match'
const m = new Matcher('a*a!(y|z)')
console.log(m.test('abcay')) // false
console.log(m.test('abcax')) // true
console.log(m.test('aa')) // true
```
The pattern and the tested string must be a single path portion.
If either one contains a `/` character, the matcher throws an
error.
If you already split a path on `/`, use `m.testUnchecked(s)`. It
gives the same result as `m.test(s)`, but it does not check `s`
for a `/` character. This can make it faster, because some
patterns, such as `*.js`, then do not need to look at each
character. If `s` has a `/`, the result is not defined.
## Why
Patterns like this frustrate most glob matchers: `a*a*a*a*a*a*a`.
They can be used to take down servers if applied to untrusted
input. Fixing these vulns is like playing whack-a-mole with the
whole internet.
If compiled to a regular expression like
`/^a[^/]*a[^/]*a[^/]*a[^/]*a[^/]*a[^/]*a$/`, and then applied to
a path portion like `aaaaaaaaaaaaaaaaaaab`, the engine must check
every possible path through the pattern, constantly rewinding
back to the first character each time and trying a different
number of `a` characters matched against the `[^/]*` to see if it
matches. Because nothing matches, it must test every possible
path before ultimately giving up.
In contrast, the algorithm presented here is based on the
Thompson NFA paper from 1968, which tests every possible path
through the string at the same time, so that it only has to walk
the string one time. This algorithm is also implemented in the
RegExp engines used by `egrep` and `awk`, which is why those
tools are so fast, even when matching complicated RegExps against
extremely large strings.
The `Matcher` objects have a `test` method which takes a string,
just like a `RegExp` object, and can be a drop-in replacement for
the regular expressions used in minimatch and other matchers.
However, they are _not_ a complete drop-in replacement for a
RegExp, so be careful when replacing one with the other. (For
example, they do not capture, do not track match indexes, no
fancy RegExp features, etc.)
## Patterns Supported
Here are the patterns supported, and their effective state
machines drawn in lovely ASCII diagrams.
### `*` 0 or more of any character, not starting with `.`
```
--+-------------------+->
v ^
+<------------------+
v ^
+-->any character-->+
```
### `?`
```
-->any character-->
```
### `[<set>]`
```
-->character in set-->
```
This covers named posix sets like `[[:alpha:]]` as well as
character classes like `[a-b]`. (In this case, a regular
expression actually is compiled, but it's not subject to ReDoS,
becuase it's just a `/[a-z]/` style pattern tested against one
character at a time.)
### `@(e1|e2|...)`
"One" extglob.
```
--+--> e1 -->+-->
v ^
+--> e2 -->+
v ^
+--> e3 -->+
v ... ^
```
### `?(e1|e2|...)`
"Zero or one" extglob.
```
--+--------->+-->
v ^
+--> e1 -->+
v ^
+--> e2 -->+
v ^
+--> e3 -->+
v ... ^
```
### `*(e1|e2|...)`
"Zero or more" extglob.
```
--+--------->+-->
v ^
+<---------+
v ^
+--> e1 -->+
v ^
+--> e2 -->+
v ^
+--> e3 -->+
v ... ^
```
### `+(e1|e2|...)`
"One or more" extglob.
```
+<---------+
v ^
--+--> e1 -->+-->
v ^
+--> e2 -->+
v ^
+--> e3 -->+
v ... ^
```
### `!(e1|e2|...)`
"Negative" extglob.
The challenge with negation is that it opens the door to a whole
heap of edge cases. Especially, _any_ expression can be nested
inside the negation, and it needs to match anything at all, as
long as it _doesn't_ match one of the supplied patterns. This is
where it gets complicated, and past attempts have run into
problems.
We handle this by starting a "Run" that technically does recurse,
and thus can push the performance out from `O(n * m)` to
`O(n * m * r)` where `n` is the string length, `m` is the pattern
length, and `r` is the number of negative extglob portions it
contains. In practice, this is limited by the pattern length, and
still doesn't allow ReDOS-style explosive recursive backtracking,
so this is fine.
## Unicode Normalization
A char such as `é` can be one code point (U+00E9), or `e`
followed by a combining accent (U+0301). Some file systems, such
as on macOS, can give file names in the second form. These two
forms do not match by default.
Set the `normalize` option to normalize the pattern and each
tested string to the same form. Use `'NFC'`, `'NFD'`, `'NFKC'`,
or `'NFKD'`. `true` means `'NFC'`.
```ts
const m = new Matcher('café', { normalize: true })
m.test('café') // true
```
- Use NFC if you are not sure. With NFD and NFKD, `é` is two
code points. Then `?` does not match `é`, and `[é]` can not
match it.
- NFKC and NFKD also fold compatibility chars. For example, `fi`
matches `fi`, and full-width `A` matches `A`.
- Syntax is parsed before normalization. So, a char that
normalizes to a syntax char stays a literal. For example, with
NFKC, full-width `*` matches only `*` or `*`, and it is not a
wildcard.
- Each run of literal chars normalizes as one string. Each member
of a `[...]` class normalizes on its own, and stays as it is if
its normal form is more than one code point.
- A combining mark after a wildcard is its own literal, and does
not compose with the char that the wildcard matches. So, with
NFC, `?́` does not match `é`. With NFD, it does match,
because `é` is also two code points in the string. Patterns
match code points, not grapheme clusters.
- With `nocase`, normalization comes first, then case folding.
- The `/` check uses the strings as given. So, full-width `/`
does not cause an error.
## Differences from Bash
Bash 5 is the reference for this module, with two known
deviations.
### Dotfiles
If `dot` is not set, a string that starts with `.` only matches
if a literal `.` in the pattern matches that first character.
Extglobs before that `.` can match the empty string, and the
pattern can still match. For example, `!(.a|js)@(.*)` matches
`.a`, `.a.js`, and `.js`, because `!(.a|js)` matches the empty
string, and `@(.*)` matches the rest. Bash does not match these
dotfiles. See [this bug
report](https://lists.gnu.org/archive/html/bug-bash/2026-03/msg00034.html).
A `*` can never match at the start of a dotfile, even if it
matches the empty string. So, `*.js` does not match `.js`, as in
Bash.
### Case-insensitive matching
Bash compares chars with the case functions of the C library for
the current locale. So, the results can change with the locale
and the platform.
With `nocase`, this module uses Unicode simple case folding, one
code point at a time. This is the same folding that a JavaScript
RegExp uses with the `iu` flags. It does not change with the
locale, and literals, `[...]` classes, and ranges all use it.
- `Σ`, `σ`, and final sigma `ς` all match each other.
- The micro sign `µ` matches `μ` and `Μ`. The Kelvin sign `K`
matches `k`. The Angstrom sign `Å` matches `å`.
- `ẞ` matches `ß`, but `ß` does not match `ss`. A fold never
changes the number of chars, so ligatures such as `fi` do not
match `fi`.
- There are no Turkish rules. `I` matches `i`, but dotted `İ`
and dotless `ı` only match themselves.
## Algorithm
A glob pattern is parsed and compiled into a series of attached
state machines.
For example, the glob patttern `*(a|[c-d]|+(x|y|z))z` would
compile to a state machine something like the following flow
diagram:
```
-->+----------------------->+-->8 LITERAL(z)-->9 end
v ^
+<-----------------------6
v ^
0-->LITERAL(a)---------->|
v |
1-->CLASS(c-d)---------->|
v |
2-->+<---------------+-->+
v ^
3-->LITERAL(x)-->7
v |
4-->LITERAL(y)-->|
v |
5-->LITERAL(z)-->+
```
Then, for each character in the string, we walk through the
resulting graph until we find a test node.
These test nodes are all executed on the current character, and
for any tests pass, their output nodes are added to the walk, and
we proceed to walk until hitting a test node again.
Because all routes eventually get to the exit, which only passes
when the string is at its last character, we are guaranteed to
eventually either fail (and have no more states to process), or
exit with a match.
At each branching point, effectively we increase the memory usage
by a tiny bit to track which nodes are being processed, but
importantly, we _don't_ have to try all the way to the exit and
then backtrack recursively, storing multiple states of the string
in an exponential explosion.
A pattern like `a*a*a*a*a*a*a*a*a*a*a`, which could be naively
converted into a Regular Expression
`^a.*a.*a.*a.*a.*a.*a.*a.*a.*a.*a$`, would take over 33 seconds
to match the string `'a'.repeat(50) + 'b'` using standard
JavaScript regular expressions, because it must attempt every
possible grouping of characters, backtracking after each failure.
By contrast, this implementation can solve this match for either
a pass or failure in roughly the same amount of time, which
is bound by `C * N`, where `C` is the number of states in the
machine, and `N` is the length of the string, finishing both
failure and success cases in polynomial time.
Even on the first rather naive implementation in JavaScript, with
no optimizations for repeated `*` or other common tweaks, this
finishes in 300-400 µs for the pathological case described, and
as the numbers increase, this time rises roughly linearly.
That's somewhat worse than RegExp's performance in the _success_
case, which is around 40µs, but as it's around 100,000x faster in
the failure case, this is already quite promising. And, future
iterations of this can likely bring that performance closer to
the native RegExp implementation.
## Acknowledgement
The algorithm and ideas in this implementation are inspired,
borrowed, and at times outright stolen from [Russ
Cox](https://research.swtch.com)'s explanation of Ken Thompson's
work in [Regular Expression Matching Can Be Simple And
Fast](https://swtch.com/~rsc/regexp/regexp1.html). I am both
impressed by and grateful for their work.
The code here in this library was written entirely by me, [Isaac
Z. Schlueter](https://izs.me), and so you should not blame either
of them (or anyone else) for any problems it might have. You
should also not blame me. It's open source, after all, no
warrantees express or implied, etc.
@@ -0,0 +1,114 @@
import { type Form } from './parse-class.js';
export type { Form };
export type MatcherOptions = {
/** perform a case-insensitive match */
nocase?: boolean;
/** do not treat strings starting with `.` specially */
dot?: boolean;
/** do not match extglobs (treat them as normal strings) */
noext?: boolean;
/**
* normalize unicode in the pattern and the tested strings, with
* this form. `true` means `'NFC'`.
*/
normalize?: boolean | Form;
};
export type Item = {
t: 'lit';
ch: string;
} | {
t: 'any' | 'star';
} | {
t: 'class';
re: RegExp;
} | {
t: 'ext';
type: string;
alts: Item[][];
};
export type Token = Item | {
t: 'open';
type: string;
} | {
t: 'bar';
} | {
t: 'close';
};
export type NegNode = {
t: 'neg';
id: number;
sub: Node;
next: Node;
};
export type SplitNode = {
t: 'split';
id: number;
out: Node[];
};
export type Node = ({
t: 'lit';
id: number;
next: Node;
} & Lit) | {
t: 'any' | 'star';
id: number;
next: Node;
} | {
t: 'class';
id: number;
re: RegExp;
next: Node;
} | SplitNode | NegNode | {
t: 'match';
id: number;
};
/**
* A literal char. With `nocase:true`, `re` folds case, and `ascii`
* holds its results for ASCII chars, by char code: 1 for a match,
* and 2 for not.
*/
export type Lit = {
ch: string;
re?: RegExp;
ascii?: Uint8Array;
};
/**
* For each node id, the gen of the last state that has the node as
* a thread, and of the last state that walked through it. A state is
* built to the end before the states around it go on, and the nodes
* of a negated sub-pattern are only in its states (other than the
* match node, which is never marked). So one mark for each node is
* enough to know if the state being built has it. The Sims of a
* matcher never run at the same time, so they share one Marks.
*/
export type Marks = {
has: Float64Array;
seen: Float64Array;
gen: number;
};
/**
* A node in a graph with no splits or negations. Such a graph is a
* chain of nodes that each match one char, or a `*`.
*/
export type LinearNode = Exclude<Node, SplitNode | NegNode | {
t: 'match';
}>;
export declare class Matcher {
#private;
pattern: string;
options: MatcherOptions;
constructor(pattern: string, options?: MatcherOptions);
test(s: string): boolean;
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s: string): boolean;
/** a readable listing of the state machine */
toString(): string;
}
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,kBAAkB,CAAA;AAExD,YAAY,EAAE,IAAI,EAAE,CAAA;AAEpB,MAAM,MAAM,cAAc,GAAG;IAC3B,uCAAuC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,uDAAuD;IACvD,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAC3B,CAAA;AAGD,MAAM,MAAM,IAAI,GACZ;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACxB;IAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,GACrB;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAA;CAAE,CA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AE,YAAY,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AA8P1E;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAC9B,IAAI,EACJ,SAAS,GAAG,OAAO,GAAG;IAAE,CAAC,EAAE,OAAO,CAAA;CAAE,CACrC,CAAA;AA8GD,qBAAa,OAAO;;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;gBAmCX,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAuDzD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAexB;;;;;;;OAOG;IACH,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAwFjC,8CAA8C;IAC9C,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,762 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Matcher = void 0;
const parse_class_js_1 = require("./parse-class.js");
// the end of the pattern, or of a negated sub-pattern
const MATCH = { t: 'match', id: 0 };
const extTypes = '!?+*@';
const lit = (ch) => ({ t: 'lit', ch });
const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&');
// a RegExp that only matches `s`, with unicode case folding
const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, 'iu');
// foldRe for one literal char. The same chars are in most patterns,
// so keep them. A RegExp without the `g` or `y` flag has no state to
// share.
const foldCache = new Map();
const foldRe = (ch) => {
let re = foldCache.get(ch);
if (!re) {
re = newFoldRe(ch);
if (foldCache.size >= 1000)
foldCache.clear();
foldCache.set(ch, re);
}
return re;
};
const litMatch = (l, c) => {
if (c === l.ch)
return true;
if (!l.re)
return false;
const code = c.charCodeAt(0);
if (code >= 128)
return l.re.test(c);
const ascii = (l.ascii ??= new Uint8Array(128));
ascii[code] ||= l.re.test(c) ? 1 : 2;
return ascii[code] === 1;
};
const tokenize = (p, nocase, noext, form) => {
const toks = [];
for (let i = 0; i < p.length;) {
const c = String.fromCodePoint(p.codePointAt(i));
if (c === '\\') {
// a trailing \ is a literal \
const e = p.codePointAt(i + 1);
const ch = e === undefined ? c : String.fromCodePoint(e);
toks.push(lit(ch));
i += 1 + ch.length;
continue;
}
if (c === '[') {
const [re, consumed] = (0, parse_class_js_1.parseClass)(p, i, nocase, form);
if (consumed) {
toks.push({ t: 'class', re });
i += consumed;
continue;
}
}
if (!noext && extTypes.includes(c) && p[i + 1] === '(') {
toks.push({ t: 'open', type: c });
i += 2;
continue;
}
toks.push(!noext && c === '|' ? { t: 'bar' }
: !noext && c === ')' ? { t: 'close' }
: c === '*' ? { t: 'star' }
: c === '?' ? { t: 'any' }
: lit(c));
i += c.length;
}
return toks;
};
// map each open token index to the index of its close token
const pair = (toks) => {
const pairs = new Map();
const stack = [];
toks.forEach((tok, i) => {
if (tok.t === 'open')
stack.push(i);
else if (tok.t === 'close' && stack.length)
pairs.set(stack.pop(), i);
});
return pairs;
};
// build the alternatives between start and end. An open token that
// is not closed is never inside a closed extglob, so bar and close
// tokens are only literal at the top level.
const build = (toks, pairs, start, end, top) => {
let seq = [];
const alts = [seq];
for (let i = start; i < end; i++) {
const tok = toks[i];
const close = pairs.get(i);
if (tok.t === 'open' && close !== undefined) {
const sub = build(toks, pairs, i + 1, close, false);
seq.push({ t: 'ext', type: tok.type, alts: sub });
i = close;
}
else if (tok.t === 'bar' && !top) {
alts.push((seq = []));
}
else if (tok.t === 'open') {
seq.push(lit(tok.type), lit('('));
}
else if (tok.t === 'bar') {
seq.push(lit('|'));
}
else if (tok.t === 'close') {
seq.push(lit(')'));
}
else {
seq.push(tok);
}
}
return alts;
};
// normalize each run of literal chars as one string, so that a char
// and the combining marks after it compose (or decompose) together.
// Syntax is already parsed, so a char that normalizes to a syntax
// char (such as full-width `*` in NFKC) stays a literal.
const normalize = (items, form) => {
const out = [];
let run = '';
const flush = () => {
for (const ch of run.normalize(form))
out.push(lit(ch));
run = '';
};
for (const it of items) {
if (it.t === 'lit') {
run += it.ch;
continue;
}
flush();
out.push(it.t === 'ext' ?
{ ...it, alts: it.alts.map(a => normalize(a, form)) }
: it);
}
flush();
return out;
};
// the start node, and the number of node ids. Ids are dense, from 0
// for the match node.
const compile = (items, nocase) => {
let id = 1;
const split = (out) => ({ t: 'split', id: id++, out });
const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
const item = (it, next) => {
switch (it.t) {
case 'lit':
const re = nocase ? foldRe(it.ch) : undefined;
return { t: 'lit', id: id++, ch: it.ch, re, next };
case 'any':
case 'star':
return { t: it.t, id: id++, next };
case 'class':
return { t: 'class', id: id++, re: it.re, next };
}
const alts = (next) => it.alts.map(a => seq(a, next));
switch (it.type) {
case '@':
return split(alts(next));
case '?':
return split([next, ...alts(next)]);
case '!':
return { t: 'neg', id: id++, sub: split(alts(MATCH)), next };
}
// * and +, loop back after each match
const after = split([]);
const entry = split(alts(after));
after.out.push(next, entry);
return it.type === '*' ? after : entry;
};
const start = seq(items, MATCH);
return [start, id];
};
// one line per node, in the order that a walk from the start
// reaches them. Edges point to node ids. The nodes of a negated
// sub-pattern are indented under their negation.
const show = (start) => {
const lines = [];
const seen = new Set();
const ref = (n) => (n.t === 'match' ? 'match' : String(n.id));
const walk = (n, indent) => {
if (n.t === 'match' || seen.has(n))
return;
seen.add(n);
const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
switch (n.t) {
case 'split':
line(`split -> ${n.out.map(ref).join(', ')}`);
for (const o of n.out)
walk(o, indent);
return;
case 'neg':
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
walk(n.sub, indent + ' ');
return walk(n.next, indent);
case 'lit':
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
break;
case 'class':
line(`${n.re} -> ${ref(n.next)}`);
break;
default:
line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`);
}
walk(n.next, indent);
};
walk(start, '');
return [`start -> ${ref(start)}`, ...lines].join('\n');
};
// The threads at one position in the string. Each node thread is
// only kept once, and runs with the same state are only kept once,
// so that identical threads merge. The match node is not in
// `threads`, because it can not step. It sets `match` instead.
class State {
// set by the Sim, to mark the nodes that this state has
gen;
threads = [];
match = false;
runs = [];
// the sorted ids of the threads, with 0 for a match, once the
// state is done
ids = [];
constructor(gen) {
this.gen = gen;
}
// no threads, so nothing more can match
get dead() {
return !this.threads.length && !this.match && !this.runs.length;
}
}
// true if the two states hold the same threads
const sameState = (a, b) => {
if (a.ids.length !== b.ids.length)
return false;
if (a.runs.length !== b.runs.length)
return false;
if (a.ids.some((id, i) => id !== b.ids[i]))
return false;
return a.runs.every(r => b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)));
};
const marks = (size) => ({
has: new Float64Array(size),
seen: new Float64Array(size),
gen: 0,
});
class Sim {
// `.` and `..` only match literal dots, even with `dot:true`
dots;
// the string starts with `.`, and `dot:true` is not set
dotStart;
#marks;
constructor(dots, dotStart, marks) {
this.dots = dots;
this.dotStart = dotStart;
this.#marks = marks;
}
state() {
return new State(++this.#marks.gen);
}
// sort the ids of a state, once it has all of its threads
done(state) {
state.ids = state.threads.map(n => n.id).sort((a, b) => a - b);
if (state.match)
state.ids.unshift(MATCH.id);
return state;
}
// true the first time that the state walks through the node, so
// that loops in the graph stop
#visit(state, node) {
const { seen } = this.#marks;
if (seen[node.id] === state.gen)
return false;
seen[node.id] = state.gen;
return true;
}
#addThread(state, node) {
const { has } = this.#marks;
if (has[node.id] === state.gen)
return false;
has[node.id] = state.gen;
state.threads.push(node);
return true;
}
// wildcards only match a leading dot if `dot:true`. In a negated
// sub-pattern, this does not apply, because the negation itself
// can not match a leading dot.
restricted(i, top) {
return top && (this.dots || (this.dotStart && i === 0));
}
add(state, node, i, top) {
switch (node.t) {
case 'split':
if (!this.#visit(state, node))
return;
for (const o of node.out)
this.add(state, o, i, top);
return;
case 'neg':
if (!this.#visit(state, node))
return;
const sub = this.state();
this.add(sub, node.sub, i, false);
this.done(sub);
return this.addRun(state, { t: 'run', neg: node, state: sub }, i, top);
case 'star':
// a * can not start a dotfile, even if it matches nothing
if (this.restricted(i, top))
return;
if (this.#addThread(state, node))
this.add(state, node.next, i, top);
return;
case 'match':
state.match = true;
return;
default:
this.#addThread(state, node);
}
}
addRun(state, run, i, top) {
for (const r of state.runs) {
if (r.neg === run.neg && sameState(r.state, run.state))
return;
}
state.runs.push(run);
if (!run.state.match) {
this.add(state, run.neg.next, i, top);
}
}
// the threads after char `c`, at index `i`
step(state, c, i, top) {
const next = this.state();
for (const th of state.threads) {
switch (th.t) {
case 'lit':
if (litMatch(th, c)) {
this.add(next, th.next, i + 1, top);
}
break;
case 'any':
if (!this.restricted(i, top))
this.add(next, th.next, i + 1, top);
break;
case 'class':
if (!this.restricted(i, top) && th.re.test(c)) {
this.add(next, th.next, i + 1, top);
}
break;
case 'star':
if (!this.restricted(i, top))
this.add(next, th, i + 1, top);
}
}
if (!this.restricted(i, top)) {
for (const run of state.runs) {
// a sub-pattern with no threads can not match again, so the
// run stays the same
if (run.state.dead) {
this.addRun(next, run, i + 1, top);
continue;
}
const sub = this.step(run.state, c, i, false);
this.addRun(next, { t: 'run', neg: run.neg, state: sub }, i + 1, top);
}
}
return this.done(next);
}
}
// A canonical key for the threads in a state. States with the same
// key hold the same threads, so they match the same strings.
const stateKey = (state) => {
const ids = state.ids.join();
if (!state.runs.length)
return ids;
const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`);
return `${ids}|${runs.sort().join('|')}`;
};
// The cache can hold about this many chars of state keys and
// transitions. When it is full, it is cleared, so that a pattern
// can not use an unbounded amount of memory.
const DFA_BUDGET = 1 << 18;
// A cache of the states that the simulation reaches, built as the
// matcher is used. Each char of a string is then one Map lookup,
// once the states that it leads to are known.
//
// The dot rules only restrict the first char of a dotfile (strings
// that are only `.` or `..` do not use the cache). So a dotfile
// starts at its own state, which takes its first step with the
// restriction, and every other state takes steps without it.
class Dfa {
#start;
#states = new Map();
#size = 0;
#plain;
#dotStart;
#sim;
#dotSim;
constructor(start, marks) {
this.#start = start;
this.#sim = new Sim(false, false, marks);
this.#dotSim = new Sim(false, true, marks);
}
#make(state) {
return {
state,
match: state.match,
dead: state.dead,
next: new Map(),
};
}
#intern(state) {
const key = stateKey(state);
const found = this.#states.get(key);
if (found)
return found;
if (this.#size > DFA_BUDGET)
this.#clear();
const d = this.#make(state);
this.#states.set(key, d);
this.#size += key.length + 1;
return d;
}
#clear() {
this.#states.clear();
this.#size = 0;
this.#plain = undefined;
this.#dotStart = undefined;
}
start(dotStart) {
if (dotStart) {
if (this.#dotStart)
return this.#dotStart;
const state = this.#dotSim.state();
this.#dotSim.add(state, this.#start, 0, true);
return (this.#dotStart = this.#make(this.#dotSim.done(state)));
}
if (this.#plain)
return this.#plain;
const state = this.#sim.state();
this.#sim.add(state, this.#start, 0, true);
return (this.#plain = this.#intern(this.#sim.done(state)));
}
// the next state, after a miss in `d.ascii`
next(d, c) {
const code = c.charCodeAt(0);
const found = code < 128 ? undefined : d.next.get(c);
if (found)
return found;
// the dotfile start is not in the cache, so it is never shared
const n = d === this.#dotStart ?
this.#intern(this.#dotSim.step(d.state, c, 0, true))
: this.#intern(this.#sim.step(d.state, c, 1, true));
if (code < 128) {
if (!d.ascii) {
d.ascii = new Array(128);
this.#size += 128;
}
d.ascii[code] = n;
}
else {
d.next.set(c, n);
}
this.#size++;
return n;
}
}
// the nodes in order, if the graph is a single chain
const linear = (start) => {
const nodes = [];
for (let n = start; n.t !== 'match'; n = n.next) {
if (n.t === 'split' || n.t === 'neg')
return undefined;
nodes.push(n);
}
return nodes;
};
// Match a chain of nodes. Each node other than `*` matches exactly
// one char, so on a failure it is enough to go back to the last `*`
// and let it match one more char. This takes at most
// nodes.length * chars.length steps.
const testLinear = (nodes, chars, start, end) => {
let ni = 0;
let ci = start;
let starNi = -1;
let starCi = 0;
while (ci < end) {
const n = nodes[ni];
if (n?.t === 'star') {
starNi = ni++;
starCi = ci;
continue;
}
const c = chars[ci];
if (n &&
(n.t === 'any' ||
(n.t === 'lit' && litMatch(n, c)) ||
(n.t === 'class' && n.re.test(c)))) {
ni++;
ci++;
continue;
}
if (starNi === -1)
return false;
ni = starNi + 1;
ci = ++starCi;
}
while (nodes[ni]?.t === 'star')
ni++;
return ni === nodes.length;
};
// The least and most chars that the items can match. These are only
// bounds: a negation can match a string of any length, so it counts
// as 0 to Infinity.
const lengths = (items) => {
let min = 0;
let max = 0;
for (const it of items) {
const [lo, hi] = itemLengths(it);
min += lo;
max += hi;
}
return [min, max];
};
const itemLengths = (it) => {
if (it.t === 'star')
return [0, Infinity];
if (it.t !== 'ext')
return [1, 1];
if (it.type === '!')
return [0, Infinity];
const alts = it.alts.map(lengths);
const min = Math.min(...alts.map(a => a[0]));
const max = Math.max(...alts.map(a => a[1]));
// a loop of alternatives that only match the empty string is empty
const loop = max === 0 ? 0 : Infinity;
return (it.type === '@' ? [min, max]
: it.type === '?' ? [0, max]
: it.type === '*' ? [0, loop]
: [min, loop]);
};
// true if the chars from `start` match the literals
const hasAffix = (lits, chars, start) => {
for (let j = 0; j < lits.length; j++) {
if (!litMatch(lits[j], chars[start + j]))
return false;
}
return true;
};
// a `/`, or half of a surrogate pair
const slashOrSurrogate = /[/\ud800-\udfff]/;
const surrogate = /[\ud800-\udfff]/;
// a string can be indexed by code point, unless it has surrogate
// pairs
const codePoints = (s) => surrogate.test(s) ? [...s] : s;
const noSlash = (s) => {
if (s.includes('/')) {
throw new Error('can only match a single path portion, got: ' + s);
}
};
class Matcher {
pattern;
options;
#start;
// the number of node ids
#size;
#marks;
// the Sim for strings that are only `.` or `..`
#dotsSim;
// the string to compare, if the pattern has no magic. With
// `nocase:true`, the RegExp that folds case is made when it is
// first used.
#literal;
#literalFold = false;
#literalRe;
// the nodes between the prefix and suffix, if the graph is a
// single chain
#linear;
// the linear nodes are only `*` and `?`, so the length bounds and
// the prefix and suffix decide the match
#wild = false;
// the least and most chars that a match can have
#min = 0;
#max = Infinity;
// the literals that a match must start and end with. Each one
// matches exactly one char, and they are distinct items in the
// pattern, so a string that does not have them can not match.
#prefix = [];
#suffix = [];
// the prefix and suffix as strings, if they do not fold case
#prefixStr;
#suffixStr;
// there is a prefix or suffix to check
#affix = false;
#dfa;
#form;
constructor(pattern, options = {}) {
if (pattern.includes('/')) {
throw new Error('can only match a single path portion, got pattern: ' + pattern);
}
this.pattern = pattern;
this.options = options;
const { nocase = false, noext = false, normalize: n } = options;
this.#form = n === true ? 'NFC' : n || undefined;
// a pattern that is only an empty extglob is a literal string,
// except for `!()`, which matches any non-empty string
const literal = /^[?*+@]\(\)$/.test(pattern);
const toks = tokenize(pattern, nocase, noext || literal, this.#form);
let [items] = build(toks, pair(toks), 0, toks.length, true);
if (this.#form)
items = normalize(items, this.#form);
const [start, size] = compile(items, nocase);
this.#start = start;
this.#size = size;
if (items.every(it => it.t === 'lit')) {
this.#literal = items.map(it => it.ch).join('');
this.#literalFold = nocase;
}
else {
const lit = (it) => it.t !== 'lit' ? undefined
: nocase ? { ch: it.ch, re: foldRe(it.ch) }
: { ch: it.ch };
for (const it of items) {
const l = lit(it);
if (!l)
break;
this.#prefix.push(l);
}
for (let j = items.length - 1; j >= 0; j--) {
const l = lit(items[j]);
if (!l)
break;
this.#suffix.unshift(l);
}
this.#affix = !!(this.#prefix.length || this.#suffix.length);
if (!nocase) {
this.#prefixStr = this.#prefix.map(l => l.ch).join('');
this.#suffixStr = this.#suffix.map(l => l.ch).join('');
}
this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || undefined);
this.#wild = !!this.#linear?.every(n => n.t === 'star' || n.t === 'any');
const [min, max] = lengths(items);
this.#min = min;
this.#max = max;
}
}
test(s) {
// The `/` check uses the string as given, so with normalization it
// is a separate step. Otherwise, one scan finds both a `/` and the
// surrogate pairs that stop the string being indexed by code point.
if (this.#form) {
noSlash(s);
return this.#test(s.normalize(this.#form));
}
if (slashOrSurrogate.test(s)) {
noSlash(s);
return this.#test(s, [...s]);
}
return this.#test(s, s);
}
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s) {
return this.#test(this.#form ? s.normalize(this.#form) : s);
}
// Test a string that has no `/`. `chars` indexes it by code point.
// If it is not given, it is only found if a step needs it.
#test(s, chars) {
if (this.#literal !== undefined) {
return this.#literalFold ?
(this.#literalRe ??= newFoldRe(this.#literal)).test(s)
: s === this.#literal;
}
// the length check means that the prefix and suffix do not
// overlap. Without the chars, the length in code points is from
// half of the UTF-16 length (if each one is a surrogate pair) to
// all of it, which is often enough to know.
const min = this.#min;
const max = this.#max;
if (chars === undefined) {
const most = s.length;
const least = (most + 1) >> 1;
if (most < min || least > max)
return false;
if (least < min || most > max)
chars = codePoints(s);
}
if (chars !== undefined &&
(chars.length < min || chars.length > max)) {
return false;
}
const prefix = this.#prefix.length;
if (this.#affix) {
if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {
if (!s.startsWith(this.#prefixStr) ||
!s.endsWith(this.#suffixStr)) {
return false;
}
}
else {
chars ??= codePoints(s);
const end = chars.length - this.#suffix.length;
if (!hasAffix(this.#prefix, chars, 0) ||
!hasAffix(this.#suffix, chars, end)) {
return false;
}
}
}
const dotStart = !this.options.dot && s.startsWith('.');
if (this.#linear) {
// `.` and `..` only match literal dots, even with `dot:true`
if (s === '.' || s === '..')
return false;
// only a literal can match the leading dot. A `*` can not
// start a dotfile, even if it matches nothing.
if (dotStart && !prefix)
return false;
if (this.#wild)
return true;
chars ??= codePoints(s);
const end = chars.length - this.#suffix.length;
return testLinear(this.#linear, chars, prefix, end);
}
chars ??= codePoints(s);
if (s === '.' || s === '..') {
this.#marks ??= marks(this.#size);
const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks));
const start = sim.state();
sim.add(start, this.#start, 0, true);
let state = sim.done(start);
for (let i = 0; i < chars.length; i++) {
state = sim.step(state, chars[i], i, true);
}
return state.match;
}
this.#marks ??= marks(this.#size);
const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks));
let d = dfa.start(dotStart);
// read char codes from the string, so that a one-char string is
// only made for a cache miss
const str = chars === s;
for (let i = 0; i < chars.length; i++) {
if (d.dead)
return false;
const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
}
return d.match;
}
/** a readable listing of the state machine */
toString() {
return show(this.#start);
}
}
exports.Matcher = Matcher;
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AAyCxD,sDAAsD;AACtD,MAAM,KAAK,GAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AAEzC,MAAM,QAAQ,GAAG,OAAO,CAAA;AAExB,MAAM,GAAG,GAAG,CAAC,EAAU,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AAEpD,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;AAEzE,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAErE,oEAAoE;AACpE,qEAAqE;AACrE,SAAS;AACT,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;AAC3C,MAAM,MAAM,GAAG,CAAC,EAAU,EAAE,EAAE;IAC5B,IAAI,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC,CAAA;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EAAE,CAAA;IACZ,MAAM,KAAK,GAAG,GAAG,EAAELine truncated
@@ -0,0 +1,3 @@
"use strict";var D=(i,t)=>()=>{try{return t||i((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var E=D(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.parseClass=void 0;var G={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}"],"[:alpha:]":["\\p{L}\\p{Nl}"],"[:ascii:]":["\\x00-\\x7f"],"[:blank:]":["\\p{Zs}\\t"],"[:cntrl:]":["\\p{Cc}"],"[:digit:]":["\\p{Nd}"],"[:graph:]":["\\p{Z}\\p{C}",!0],"[:lower:]":["\\p{Ll}"],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}\\p{S}"],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f"],"[:upper:]":["\\p{Lu}"],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],"[:xdigit:]":["A-Fa-f0-9"]},x=i=>i.replace(/[[\]\\-]/g,"\\$&"),A=/$./,H=(i,t,e=!1,s)=>{let h=p=>{let m=s?p.normalize(s):p;return[...m].length===1?m:p},n=t;if(i.charAt(n)!=="[")throw new Error("not in a brace expression");let o=[],a=[],r=n+1,l=!1,c=!1,u=!1,g=n,d="";t:for(;r<i.length;){let p=String.fromCodePoint(i.codePointAt(r));if((p==="!"||p==="^")&&r===n+1){u=!0,r++;continue}if(p==="]"&&l&&!c){g=r+1;break}if(l=!0,p==="\\"&&!c){c=!0,r++;continue}if(p==="["&&!c){for(let[R,[v,B]]of Object.entries(G))if(i.startsWith(R,r)){if(d)return[A,i.length-n];r+=R.length,B?a.push(v):o.push(v);continue t}}c=!1;let m=h(p);if(d){m.codePointAt(0)>d.codePointAt(0)?o.push(x(d)+"-"+x(m)):m===d&&o.push(x(m)),d="",r+=p.length;continue}if(i.startsWith("-]",r+p.length)){o.push(x(m+"-")),r+=p.length+1;continue}if(i.startsWith("-",r+p.length)){d=m,r+=p.length+1;continue}o.push(x(m)),r+=p.length}if(g<r)return[A,0];if(!o.length&&!a.length)return[A,i.length-n];let f="["+(u?"^":"")+o.join("")+"]",w="["+(u?"":"^")+a.join("")+"]",Z="^"+(o.length&&a.length?"("+f+"|"+w+")":o.length?f:w);return[new RegExp(Z,e?"iu":"u"),g-n]};S.parseClass=H});Object.defineProperty(exports,"__esModule",{value:!0});exports.Matcher=void 0;var J=E(),b={t:"match",id:0},K="!?+*@",y=i=>({t:"lit",ch:i}),Q=i=>i.replace(/[\\^$.*+?()[\]{}|/]/g,"\\$&"),L=i=>new RegExp(`^${Q(i)}$`,"iu"),C=new Map,W=i=>{let t=C.get(i);return t||(t=L(i),C.size>=1e3&&C.clear(),C.set(i,t)),t},z=(i,t)=>{if(t===i.ch)return!0;if(!i.re)return!1;let e=t.charCodeAt(0);if(e>=128)return i.re.test(t);let s=i.ascii??=new Uint8Array(128);return s[e]||=i.re.test(t)?1:2,s[e]===1},V=(i,t,e,s)=>{let h=[];for(let n=0;n<i.length;){let o=String.fromCodePoint(i.codePointAt(n));if(o==="\\"){let a=i.codePointAt(n+1),r=a===void 0?o:String.fromCodePoint(a);h.push(y(r)),n+=1+r.length;continue}if(o==="["){let[a,r]=(0,J.parseClass)(i,n,t,s);if(r){h.push({t:"class",re:a}),n+=r;continue}}if(!e&&K.includes(o)&&i[n+1]==="("){h.push({t:"open",type:o}),n+=2;continue}h.push(!e&&o==="|"?{t:"bar"}:!e&&o===")"?{t:"close"}:o==="*"?{t:"star"}:o==="?"?{t:"any"}:y(o)),n+=o.length}return h},X=i=>{let t=new Map,e=[];return i.forEach((s,h)=>{s.t==="open"?e.push(h):s.t==="close"&&e.length&&t.set(e.pop(),h)}),t},O=(i,t,e,s,h)=>{let n=[],o=[n];for(let a=e;a<s;a++){let r=i[a],l=t.get(a);if(r.t==="open"&&l!==void 0){let c=O(i,t,a+1,l,!1);n.push({t:"ext",type:r.type,alts:c}),a=l}else r.t==="bar"&&!h?o.push(n=[]):r.t==="open"?n.push(y(r.type),y("(")):r.t==="bar"?n.push(y("|")):r.t==="close"?n.push(y(")")):n.push(r)}return o},I=(i,t)=>{let e=[],s="",h=()=>{for(let n of s.normalize(t))e.push(y(n));s=""};for(let n of i){if(n.t==="lit"){s+=n.ch;continue}h(),e.push(n.t==="ext"?{...n,alts:n.alts.map(o=>I(o,t))}:n)}return h(),e},Y=(i,t)=>{let e=1,s=a=>({t:"split",id:e++,out:a}),h=(a,r)=>a.reduceRight((l,c)=>n(c,l),r),n=(a,r)=>{switch(a.t){case"lit":let g=t?W(a.ch):void 0;return{t:"lit",id:e++,ch:a.ch,re:g,next:r};case"any":case"star":return{t:a.t,id:e++,next:r};case"class":return{t:"class",id:e++,re:a.re,next:r}}let l=g=>a.alts.map(d=>h(d,g));switch(a.type){case"@":return s(l(r));case"?":return s([r,...l(r)]);case"!":return{t:"neg",id:e++,sub:s(l(b)),next:r}}let c=s([]),u=s(l(c));return c.out.push(r,u),a.type==="*"?c:u};return[h(i,b),e]},tt=i=>{let t=[],e=new Set,s=n=>n.t==="match"?"match":String(n.id),h=(n,o)=>{if(n.t==="match"||e.has(n))return;e.add(n);let a=r=>t.push(`${o}${n.id}: ${r}`);switch(n.t){case"split":a(`split -> ${n.out.map(s).join(", ")}`);for(let r of n.out)h(r,o);return;case"neg":return a(`!(${s(n.sub)}) -> ${s(n.next)}`),h(n.sub,o+" "),h(n.next,o);case"lit":a(`${JSON.stringify(n.ch)} -> ${s(n.next)}`);break;case"class":a(`${n.re} -> ${s(n.next)}`);break;default:a(`${n.t==="any"?"?":"*"} -> ${s(n.next)}`)}h(n.next,o)};return h(i,""),[`start -> ${s(i)}`,...t].join(`
`)},j=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(t){this.gen=t}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}},T=(i,t)=>i.ids.length!==t.ids.length||i.runs.length!==t.runs.length||i.ids.some((e,s)=>e!==t.ids[s])?!1:i.runs.every(e=>t.runs.some(s=>s.neg===e.neg&&T(s.state,e.state))),N=i=>({has:new Float64Array(i),seen:new Float64Array(i),gen:0}),$=class{dots;dotStart;#t;constructor(t,e,s){this.dots=t,this.dotStart=e,this.#t=s}state(){return new j(++this.#t.gen)}done(t){return t.ids=t.threads.map(e=>e.id).sort((e,s)=>e-s),t.match&&t.ids.unshift(b.id),t}#s(t,e){let{seen:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,!0)}#e(t,e){let{has:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,t.threads.push(e),!0)}restricted(t,e){return e&&(this.dots||this.dotStart&&t===0)}add(t,e,s,h){switch(e.t){case"split":if(!this.#s(t,e))return;for(let o of e.out)this.add(t,o,s,h);return;case"neg":if(!this.#s(t,e))return;let n=this.state();return this.add(n,e.sub,s,!1),this.done(n),this.addRun(t,{t:"run",neg:e,state:n},s,h);case"star":if(this.restricted(s,h))return;this.#e(t,e)&&this.add(t,e.next,s,h);return;case"match":t.match=!0;return;default:this.#e(t,e)}}addRun(t,e,s,h){for(let n of t.runs)if(n.neg===e.neg&&T(n.state,e.state))return;t.runs.push(e),e.state.match||this.add(t,e.neg.next,s,h)}step(t,e,s,h){let n=this.state();for(let o of t.threads)switch(o.t){case"lit":z(o,e)&&this.add(n,o.next,s+1,h);break;case"any":this.restricted(s,h)||this.add(n,o.next,s+1,h);break;case"class":!this.restricted(s,h)&&o.re.test(e)&&this.add(n,o.next,s+1,h);break;case"star":this.restricted(s,h)||this.add(n,o,s+1,h)}if(!this.restricted(s,h))for(let o of t.runs){if(o.state.dead){this.addRun(n,o,s+1,h);continue}let a=this.step(o.state,e,s,!1);this.addRun(n,{t:"run",neg:o.neg,state:a},s+1,h)}return this.done(n)}},q=i=>{let t=i.ids.join();if(!i.runs.length)return t;let e=i.runs.map(s=>`${s.neg.id}(${q(s.state)})`);return`${t}|${e.sort().join("|")}`},et=1<<18,P=class{#t;#s=new Map;#e=0;#c;#n;#i;#h;constructor(t,e){this.#t=t,this.#i=new $(!1,!1,e),this.#h=new $(!1,!0,e)}#o(t){return{state:t,match:t.match,dead:t.dead,next:new Map}}#u(t){let e=q(t),s=this.#s.get(e);if(s)return s;this.#e>et&&this.#f();let h=this.#o(t);return this.#s.set(e,h),this.#e+=e.length+1,h}#f(){this.#s.clear(),this.#e=0,this.#c=void 0,this.#n=void 0}start(t){if(t){if(this.#n)return this.#n;let s=this.#h.state();return this.#h.add(s,this.#t,0,!0),this.#n=this.#o(this.#h.done(s))}if(this.#c)return this.#c;let e=this.#i.state();return this.#i.add(e,this.#t,0,!0),this.#c=this.#u(this.#i.done(e))}next(t,e){let s=e.charCodeAt(0),h=s<128?void 0:t.next.get(e);if(h)return h;let n=t===this.#n?this.#u(this.#h.step(t.state,e,0,!0)):this.#u(this.#i.step(t.state,e,1,!0));return s<128?(t.ascii||(t.ascii=new Array(128),this.#e+=128),t.ascii[s]=n):t.next.set(e,n),this.#e++,n}},st=i=>{let t=[];for(let e=i;e.t!=="match";e=e.next){if(e.t==="split"||e.t==="neg")return;t.push(e)}return t},nt=(i,t,e,s)=>{let h=0,n=e,o=-1,a=0;for(;n<s;){let r=i[h];if(r?.t==="star"){o=h++,a=n;continue}let l=t[n];if(r&&(r.t==="any"||r.t==="lit"&&z(r,l)||r.t==="class"&&r.re.test(l))){h++,n++;continue}if(o===-1)return!1;h=o+1,n=++a}for(;i[h]?.t==="star";)h++;return h===i.length},U=i=>{let t=0,e=0;for(let s of i){let[h,n]=it(s);t+=h,e+=n}return[t,e]},it=i=>{if(i.t==="star")return[0,1/0];if(i.t!=="ext")return[1,1];if(i.type==="!")return[0,1/0];let t=i.alts.map(U),e=Math.min(...t.map(n=>n[0])),s=Math.max(...t.map(n=>n[1])),h=s===0?0:1/0;return i.type==="@"?[e,s]:i.type==="?"?[0,s]:i.type==="*"?[0,h]:[e,h]},_=(i,t,e)=>{for(let s=0;s<i.length;s++)if(!z(i[s],t[e+s]))return!1;return!0},rt=/[/\ud800-\udfff]/,ht=/[\ud800-\udfff]/,k=i=>ht.test(i)?[...i]:i,F=i=>{if(i.includes("/"))throw new Error("can only match a single path portion, got: "+i)},M=class{pattern;options;#t;#s;#e;#c;#n;#i=!1;#h;#o;#u=!1;#f=0;#m=1/0;#l=[];#a=[];#p;#g;#w=!1;#y;#r;constructor(t,e={}){if(t.includes("/"))throw new Error("can only match a single path portion, got pattern: "+t);this.pattern=t,this.options=e;let{nocase:s=!1,noext:h=!1,normalize:n}=e;this.#r=n===!0?"NFC":n||void 0;let o=/^[?*+@]\(\)$/.test(t),a=V(t,s,h||o,this.#r),[r]=O(a,X(a),0,a.length,!0);this.#r&&(r=I(r,this.#r));let[l,c]=Y(r,s);if(this.#t=l,this.#s=c,r.every(u=>u.t==="lit"))this.#n=r.map(u=>u.ch).join(""),this.#i=s;else{let u=f=>f.t!=="lit"?void 0:s?{ch:f.ch,re:W(f.ch)}:{ch:f.ch};for(let f of r){let w=u(f);if(!w)break;this.#l.push(w)}for(let f=r.length-1;f>=0;f--){let w=u(r[f]);if(!w)break;this.#a.unshift(w)}this.#w=!!(this.#l.length||this.#a.length),s||(this.#p=this.#l.map(f=>f.ch).join(""),this.#g=this.#a.map(f=>f.ch).join("")),this.#o=st(this.#t)?.slice(this.#l.length,-this.#a.length||void 0),this.#u=!!this.#o?.every(f=>f.t==="star"||f.t==="any");let[g,d]=U(r);this.#f=g,this.#m=d}}test(t){return this.#r?(F(t),this.#d(t.normalize(this.#r))):rt.test(t)?(F(t),this.#d(t,[...t])):this.#d(t,t)}testUnchecked(t){return this.#d(this.#r?t.normalize(this. Line truncated
//# sourceMappingURL=index.min.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../src/parse-class.ts", "../../src/index.ts"],
"sourcesContent": ["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolean] } = {\n '[:alnum:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}'],\n '[:alpha:]': ['\\\\p{L}\\\\p{Nl}'],\n '[:ascii:]': ['\\\\x' + '00-\\\\x' + '7f'],\n '[:blank:]': ['\\\\p{Zs}\\\\t'],\n '[:cntrl:]': ['\\\\p{Cc}'],\n '[:digit:]': ['\\\\p{Nd}'],\n '[:graph:]': ['\\\\p{Z}\\\\p{C}', true],\n '[:lower:]': ['\\\\p{Ll}'],\n '[:print:]': ['\\\\p{C}', true],\n '[:punct:]': ['\\\\p{P}\\\\p{S}'],\n '[:space:]': ['\\\\p{Z}\\\\t\\\\r\\\\n\\\\v\\\\f'],\n '[:upper:]': ['\\\\p{Lu}'],\n '[:word:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}'],\n '[:xdigit:]': ['A-Fa-f0-9'],\n}\n\n// only need to escape a few things inside of brace expressions\n// escapes: [ \\ ] -\nconst braceEscape = (s: string) => s.replace(/[[\\]\\\\-]/g, '\\\\$&')\n\nexport type ParseClassResult = [re: RegExp, consumed: number]\n\nexport type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD'\n\nconst noMatch = /$./\n\n// Takes a glob string at a posix brace expression. Returns a RegExp\n// that tests one character, and the number of glob chars consumed.\n// If the class is not closed, consumed is 0, and the `[` must be\n// treated as a literal character.\n// Out of order ranges are removed. If nothing is left, the RegExp\n// is `/$./`, and the rest of the glob is consumed, so that the\n// whole glob cannot match.\nexport const parseClass = (\n glob: string,\n position: number,\n nocase: boolean = false,\n form?: Form,\n): ParseClassResult => {\n // normalize one class member, if it stays one code point\n const norm = (c: string) => {\n const n = form ? c.normalize(form) : c\n return [...n].length === 1 ? n : c\n }\n const pos = position\n /* c8 ignore start */\n if (glob.charAt(pos) !== '[') {\n throw new Error('not in a brace expression')\n }\n /* c8 ignore stop */\n const ranges: string[] = []\n const negs: string[] = []\n\n let i = pos + 1\n let sawStart = false\n let escaping = false\n let negate = false\n let endPos = pos\n let rangeStart = ''\n WHILE: while (i < glob.length) {\n const c = String.fromCodePoint(glob.codePointAt(i)!)\n if ((c === '!' || c === '^') && i === pos + 1) {\n negate = true\n i++\n continue\n }\n\n if (c === ']' && sawStart && !escaping) {\n endPos = i + 1\n break\n }\n\n sawStart = true\n if (c === '\\\\') {\n if (!escaping) {\n escaping = true\n i++\n continue\n }\n // escaped \\ char, fall through and treat like normal char\n }\n if (c === '[' && !escaping) {\n // either a posix class, a collation equivalent, or just a [\n for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {\n if (glob.startsWith(cls, i)) {\n // invalid, [a-[] is fine, but not [a-[:alpha]]\n if (rangeStart) {\n return [noMatch, glob.length - pos]\n }\n i += cls.length\n if (neg) negs.push(unip)\n else ranges.push(unip)\n continue WHILE\n }\n }\n }\n\n // now it's just a normal character, effectively\n escaping = false\n const n = norm(c)\n if (rangeStart) {\n // throw this range away if it's not valid, but others\n // can still match.\n if (n.codePointAt(0)! > rangeStart.codePointAt(0)!) {\n ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n))\n } else if (n === rangeStart) {\n ranges.push(braceEscape(n))\n }\n rangeStart = ''\n i += c.length\n continue\n }\n\n // now might be the start of a range.\n // can be either c-d or c-] or c<more...>] or c] at this point\n if (glob.startsWith('-]', i + c.length)) {\n ranges.push(braceEscape(n + '-'))\n i += c.length + 1\n continue\n }\n if (glob.startsWith('-', i + c.length)) {\n rangeStart = n\n i += c.length + 1\n continue\n }\n\n // not the start of a range, just a single character\n ranges.push(braceEscape(n))\n i += c.length\n }\n\n if (endPos < i) {\n // didn't see the end of the class, not a valid class,\n // but might still be valid as a literal match.\n return [noMatch, 0]\n }\n\n // if we got no ranges and no negates, then we have a range that\n // cannot possibly match anything, and that poisons the whole glob\n if (!ranges.length && !negs.length) {\n return [noMatch, glob.length - pos]\n }\n\n const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']'\n const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']'\n const comb =\n '^' +\n (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'\n : ranges.length ? sranges\n : snegs)\n\n return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos]\n}\n", "import { type Form, parseClass } from './parse-class.js'\nLine truncated
"mappings": "0MAIA,IAAMA,EAA0D,CAC9D,YAAa,CAAC,sBAAsB,EACpC,YAAa,CAAC,eAAe,EAC7B,YAAa,CAAC,aAAuB,EACrC,YAAa,CAAC,YAAY,EAC1B,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,eAAgB,EAAI,EAClC,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAU,EAAI,EAC5B,YAAa,CAAC,cAAc,EAC5B,YAAa,CAAC,uBAAuB,EACrC,YAAa,CAAC,SAAS,EACvB,WAAY,CAAC,6BAA6B,EAC1C,aAAc,CAAC,WAAW,GAKtBC,EAAeC,GAAcA,EAAE,QAAQ,YAAa,MAAM,EAM1DC,EAAU,KASHC,EAAa,CACxBC,EACAC,EACAC,EAAkB,GAClBC,IACoB,CAEpB,IAAMC,EAAQC,GAAa,CACzB,IAAMC,EAAIH,EAAOE,EAAE,UAAUF,CAAI,EAAIE,EACrC,MAAO,CAAC,GAAGC,CAAC,EAAE,SAAW,EAAIA,EAAID,CACnC,EACME,EAAMN,EAEZ,GAAID,EAAK,OAAOO,CAAG,IAAM,IACvB,MAAM,IAAI,MAAM,2BAA2B,EAG7C,IAAMC,EAAmB,CAAA,EACnBC,EAAiB,CAAA,EAEnBC,EAAIH,EAAM,EACVI,EAAW,GACXC,EAAW,GACXC,EAAS,GACTC,EAASP,EACTQ,EAAa,GACjBC,EAAO,KAAON,EAAIV,EAAK,QAAQ,CAC7B,IAAMK,EAAI,OAAO,cAAcL,EAAK,YAAYU,CAAC,CAAE,EACnD,IAAKL,IAAM,KAAOA,IAAM,MAAQK,IAAMH,EAAM,EAAG,CAC7CM,EAAS,GACTH,IACA,QACF,CAEA,GAAIL,IAAM,KAAOM,GAAY,CAACC,EAAU,CACtCE,EAASJ,EAAI,EACb,KACF,CAGA,GAD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CAChC,IAAMM,EAAMP,EAAKC,CAAC,EACZa,EAAQT,EAAM,IAAIJ,CAAC,EACzB,GAAIM,EAAI,IAAM,QAAUO,IAAU,OAAW,CAC3C,IAAMC,EAAMP,EAAMR,EAAMK,EAAOJ,EAAI,EAAGa,EAAO,EAAK,EAClDF,EAAI,KAAK,CAAE,EAAG,MAAO,KAAML,EAAI,KAAM,KAAMQ,CAAG,CAAE,EAChDd,EAAIa,CACN,MAAWP,EAAI,IAAM,OAAS,CAACI,EAC7BE,EAAK,KAAMD,EAAM,CAAA,CAAG,EACXL,EAAI,IAAM,OACnBK,EAAI,KAAK9B,EAAIyB,EAAI,IAAI,EAAGzB,EAAI,GAAG,CAAC,EACvByB,EAAI,IAAM,MACnBK,EAAI,KAAK9B,EAAI,GAAG,CAAC,EACRyB,EAAI,IAAM,QACnBK,EAAI,KAAK9B,EAAI,GAAG,CAAC,EAEjB8B,EAAI,KAAKL,CAAG,CAEhB,CACA,OAAOM,CACT,EAMMG,EAAY,CAACC,EAAelB,IAAsB,CACtD,IAAMmB,EAAc,CAAA,EAChBC,EAAM,GACJC,EAAQ,IAAK,CACjB,QAAWrC,KAAMoC,EAAI,UAAUpB,CAAI,EAAGmB,EAAI,KAAKpC,EAAIC,CAAE,CAAC,EACtDoC,EAAM,EACR,EACA,QAAWE,KAAMJ,EAAO,CACtB,GAAII,EAAG,IAAM,MAAO,CAClBF,GAAOE,EAAG,GACV,QACF,CACAD,EAAK,EACLF,EAAI,KACFG,EAAG,IAAM,MACP,CAAE,GAAGA,EAAI,KAAMA,EAALine truncated
"names": ["posixClasses", "braceEscape", "s", "noMatch", "parseClass", "glob", "position", "nocase", "form", "norm", "c", "n", "pos", "ranges", "negs", "i", "sawStart", "escaping", "negate", "endPos", "rangeStart", "WHILE", "cls", "unip", "neg", "sranges", "snegs", "comb", "exports", "parse_class_js_1", "MATCH", "extTypes", "lit", "ch", "reEscape", "s", "newFoldRe", "foldCache", "foldRe", "re", "litMatch", "l", "c", "code", "ascii", "tokenize", "p", "nocase", "noext", "form", "toks", "i", "e", "consumed", "pair", "pairs", "stack", "tok", "build", "start", "end", "top", "seq", "alts", "close", "sub", "normalize", "items", "out", "run", "flush", "it", "a", "compile", "id", "split", "next", "item", "after", "entry", "show", "lines", "seen", "ref", "walk", "indent", "line", "desc", "o", "State", "gen", "sameState", "b", "r", "marks", "size", "Sim", "#marks", "dots", "dotStart", "state", "n", "#visit", "node", "#addThread", "has", "th", "stateKey", "ids", "runs", "DFA_BUDGET", "Dfa", "#start", "#states", "#size", "#plain", "#dotStart", "#sim", "#dotSim", "#make", "#intern", "key", "found", "#clear", "d", "linear", "nodes", "testLinear", "chars", "ni", "ci", "starNi", "starCi", "lengths", "min", "max", "lo", "hi", "itemLengths", "loop", "hasAffix", "lits", "j", "slashOrSurrogate", "surrogate", "codePoints", "noSlash", "Matcher", "#dotsSim", "#literal", "#literalFold", "#literalRe", "#linear", "#wild", "#min", "#max", "#prefix", "#suffix", "#prefixStr", "#suffixStr", "#affix", "#dfa", "#form", "pattern", "options", "literal", "#test", "most", "least", "prefix", "sim", "dfa", "str"]
}
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
@@ -0,0 +1,4 @@
export type ParseClassResult = [re: RegExp, consumed: number];
export type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
export declare const parseClass: (glob: string, position: number, nocase?: boolean, form?: Form) => ParseClassResult;
//# sourceMappingURL=parse-class.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"parse-class.d.ts","sourceRoot":"","sources":["../../src/parse-class.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AAE7D,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAWlD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,SAAQ,OAAe,EACvB,OAAO,IAAI,KACV,gBAkHF,CAAA"}
@@ -0,0 +1,142 @@
"use strict";
// translate the various posix character classes into unicode properties
// this works across all unicode locales
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseClass = void 0;
// { <posix class>: [<translation>, negated]
const posixClasses = {
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}'],
'[:alpha:]': ['\\p{L}\\p{Nl}'],
'[:ascii:]': ['\\x' + '00-\\x' + '7f'],
'[:blank:]': ['\\p{Zs}\\t'],
'[:cntrl:]': ['\\p{Cc}'],
'[:digit:]': ['\\p{Nd}'],
'[:graph:]': ['\\p{Z}\\p{C}', true],
'[:lower:]': ['\\p{Ll}'],
'[:print:]': ['\\p{C}', true],
'[:punct:]': ['\\p{P}\\p{S}'],
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f'],
'[:upper:]': ['\\p{Lu}'],
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}'],
'[:xdigit:]': ['A-Fa-f0-9'],
};
// only need to escape a few things inside of brace expressions
// escapes: [ \ ] -
const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
const noMatch = /$./;
// Takes a glob string at a posix brace expression. Returns a RegExp
// that tests one character, and the number of glob chars consumed.
// If the class is not closed, consumed is 0, and the `[` must be
// treated as a literal character.
// Out of order ranges are removed. If nothing is left, the RegExp
// is `/$./`, and the rest of the glob is consumed, so that the
// whole glob cannot match.
const parseClass = (glob, position, nocase = false, form) => {
// normalize one class member, if it stays one code point
const norm = (c) => {
const n = form ? c.normalize(form) : c;
return [...n].length === 1 ? n : c;
};
const pos = position;
/* c8 ignore start */
if (glob.charAt(pos) !== '[') {
throw new Error('not in a brace expression');
}
/* c8 ignore stop */
const ranges = [];
const negs = [];
let i = pos + 1;
let sawStart = false;
let escaping = false;
let negate = false;
let endPos = pos;
let rangeStart = '';
WHILE: while (i < glob.length) {
const c = String.fromCodePoint(glob.codePointAt(i));
if ((c === '!' || c === '^') && i === pos + 1) {
negate = true;
i++;
continue;
}
if (c === ']' && sawStart && !escaping) {
endPos = i + 1;
break;
}
sawStart = true;
if (c === '\\') {
if (!escaping) {
escaping = true;
i++;
continue;
}
// escaped \ char, fall through and treat like normal char
}
if (c === '[' && !escaping) {
// either a posix class, a collation equivalent, or just a [
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
if (glob.startsWith(cls, i)) {
// invalid, [a-[] is fine, but not [a-[:alpha]]
if (rangeStart) {
return [noMatch, glob.length - pos];
}
i += cls.length;
if (neg)
negs.push(unip);
else
ranges.push(unip);
continue WHILE;
}
}
}
// now it's just a normal character, effectively
escaping = false;
const n = norm(c);
if (rangeStart) {
// throw this range away if it's not valid, but others
// can still match.
if (n.codePointAt(0) > rangeStart.codePointAt(0)) {
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n));
}
else if (n === rangeStart) {
ranges.push(braceEscape(n));
}
rangeStart = '';
i += c.length;
continue;
}
// now might be the start of a range.
// can be either c-d or c-] or c<more...>] or c] at this point
if (glob.startsWith('-]', i + c.length)) {
ranges.push(braceEscape(n + '-'));
i += c.length + 1;
continue;
}
if (glob.startsWith('-', i + c.length)) {
rangeStart = n;
i += c.length + 1;
continue;
}
// not the start of a range, just a single character
ranges.push(braceEscape(n));
i += c.length;
}
if (endPos < i) {
// didn't see the end of the class, not a valid class,
// but might still be valid as a literal match.
return [noMatch, 0];
}
// if we got no ranges and no negates, then we have a range that
// cannot possibly match anything, and that poisons the whole glob
if (!ranges.length && !negs.length) {
return [noMatch, glob.length - pos];
}
const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']';
const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']';
const comb = '^' +
(ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
: ranges.length ? sranges
: snegs);
return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos];
};
exports.parseClass = parseClass;
//# sourceMappingURL=parse-class.js.map
@@ -0,0 +1 @@
{"version":3,"file":"parse-class.js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AAM,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAA;IAC7D,MAAM,IAAI,GACR,GAAG;QACH,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG;YACjE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;gBACzB,CAAC,CAAC,KAAK,CAAC,CAAA;IAEV,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;AAC9D,CAAC,CAAA;AAvHY,QAAA,UAAU,cAuHtB","sourcesContent":["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolLine truncated
@@ -0,0 +1,114 @@
import { type Form } from './parse-class.js';
export type { Form };
export type MatcherOptions = {
/** perform a case-insensitive match */
nocase?: boolean;
/** do not treat strings starting with `.` specially */
dot?: boolean;
/** do not match extglobs (treat them as normal strings) */
noext?: boolean;
/**
* normalize unicode in the pattern and the tested strings, with
* this form. `true` means `'NFC'`.
*/
normalize?: boolean | Form;
};
export type Item = {
t: 'lit';
ch: string;
} | {
t: 'any' | 'star';
} | {
t: 'class';
re: RegExp;
} | {
t: 'ext';
type: string;
alts: Item[][];
};
export type Token = Item | {
t: 'open';
type: string;
} | {
t: 'bar';
} | {
t: 'close';
};
export type NegNode = {
t: 'neg';
id: number;
sub: Node;
next: Node;
};
export type SplitNode = {
t: 'split';
id: number;
out: Node[];
};
export type Node = ({
t: 'lit';
id: number;
next: Node;
} & Lit) | {
t: 'any' | 'star';
id: number;
next: Node;
} | {
t: 'class';
id: number;
re: RegExp;
next: Node;
} | SplitNode | NegNode | {
t: 'match';
id: number;
};
/**
* A literal char. With `nocase:true`, `re` folds case, and `ascii`
* holds its results for ASCII chars, by char code: 1 for a match,
* and 2 for not.
*/
export type Lit = {
ch: string;
re?: RegExp;
ascii?: Uint8Array;
};
/**
* For each node id, the gen of the last state that has the node as
* a thread, and of the last state that walked through it. A state is
* built to the end before the states around it go on, and the nodes
* of a negated sub-pattern are only in its states (other than the
* match node, which is never marked). So one mark for each node is
* enough to know if the state being built has it. The Sims of a
* matcher never run at the same time, so they share one Marks.
*/
export type Marks = {
has: Float64Array;
seen: Float64Array;
gen: number;
};
/**
* A node in a graph with no splits or negations. Such a graph is a
* chain of nodes that each match one char, or a `*`.
*/
export type LinearNode = Exclude<Node, SplitNode | NegNode | {
t: 'match';
}>;
export declare class Matcher {
#private;
pattern: string;
options: MatcherOptions;
constructor(pattern: string, options?: MatcherOptions);
test(s: string): boolean;
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s: string): boolean;
/** a readable listing of the state machine */
toString(): string;
}
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,kBAAkB,CAAA;AAExD,YAAY,EAAE,IAAI,EAAE,CAAA;AAEpB,MAAM,MAAM,cAAc,GAAG;IAC3B,uCAAuC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,uDAAuD;IACvD,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,IAA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AAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAClD,SAAS,GACT,OAAO,GACP;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AA4B9B;;;;GAIG;AACH,MAAM,MAAM,GAAG,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,CAAA;AAgPjE;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AA8P1E;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAC9B,IAAI,EACJ,SAAS,GAAG,OAAO,GAAG;IAAE,CAAC,EAAE,OAAO,CAAA;CAAE,CACrC,CAAA;AA8GD,qBAAa,OAAO;;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;gBAmCX,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAuDzD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAexB;;;;;;;OAOG;IACH,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAwFjC,8CAA8C;IAC9C,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,758 @@
import { parseClass } from './parse-class.js';
// the end of the pattern, or of a negated sub-pattern
const MATCH = { t: 'match', id: 0 };
const extTypes = '!?+*@';
const lit = (ch) => ({ t: 'lit', ch });
const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&');
// a RegExp that only matches `s`, with unicode case folding
const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, 'iu');
// foldRe for one literal char. The same chars are in most patterns,
// so keep them. A RegExp without the `g` or `y` flag has no state to
// share.
const foldCache = new Map();
const foldRe = (ch) => {
let re = foldCache.get(ch);
if (!re) {
re = newFoldRe(ch);
if (foldCache.size >= 1000)
foldCache.clear();
foldCache.set(ch, re);
}
return re;
};
const litMatch = (l, c) => {
if (c === l.ch)
return true;
if (!l.re)
return false;
const code = c.charCodeAt(0);
if (code >= 128)
return l.re.test(c);
const ascii = (l.ascii ??= new Uint8Array(128));
ascii[code] ||= l.re.test(c) ? 1 : 2;
return ascii[code] === 1;
};
const tokenize = (p, nocase, noext, form) => {
const toks = [];
for (let i = 0; i < p.length;) {
const c = String.fromCodePoint(p.codePointAt(i));
if (c === '\\') {
// a trailing \ is a literal \
const e = p.codePointAt(i + 1);
const ch = e === undefined ? c : String.fromCodePoint(e);
toks.push(lit(ch));
i += 1 + ch.length;
continue;
}
if (c === '[') {
const [re, consumed] = parseClass(p, i, nocase, form);
if (consumed) {
toks.push({ t: 'class', re });
i += consumed;
continue;
}
}
if (!noext && extTypes.includes(c) && p[i + 1] === '(') {
toks.push({ t: 'open', type: c });
i += 2;
continue;
}
toks.push(!noext && c === '|' ? { t: 'bar' }
: !noext && c === ')' ? { t: 'close' }
: c === '*' ? { t: 'star' }
: c === '?' ? { t: 'any' }
: lit(c));
i += c.length;
}
return toks;
};
// map each open token index to the index of its close token
const pair = (toks) => {
const pairs = new Map();
const stack = [];
toks.forEach((tok, i) => {
if (tok.t === 'open')
stack.push(i);
else if (tok.t === 'close' && stack.length)
pairs.set(stack.pop(), i);
});
return pairs;
};
// build the alternatives between start and end. An open token that
// is not closed is never inside a closed extglob, so bar and close
// tokens are only literal at the top level.
const build = (toks, pairs, start, end, top) => {
let seq = [];
const alts = [seq];
for (let i = start; i < end; i++) {
const tok = toks[i];
const close = pairs.get(i);
if (tok.t === 'open' && close !== undefined) {
const sub = build(toks, pairs, i + 1, close, false);
seq.push({ t: 'ext', type: tok.type, alts: sub });
i = close;
}
else if (tok.t === 'bar' && !top) {
alts.push((seq = []));
}
else if (tok.t === 'open') {
seq.push(lit(tok.type), lit('('));
}
else if (tok.t === 'bar') {
seq.push(lit('|'));
}
else if (tok.t === 'close') {
seq.push(lit(')'));
}
else {
seq.push(tok);
}
}
return alts;
};
// normalize each run of literal chars as one string, so that a char
// and the combining marks after it compose (or decompose) together.
// Syntax is already parsed, so a char that normalizes to a syntax
// char (such as full-width `*` in NFKC) stays a literal.
const normalize = (items, form) => {
const out = [];
let run = '';
const flush = () => {
for (const ch of run.normalize(form))
out.push(lit(ch));
run = '';
};
for (const it of items) {
if (it.t === 'lit') {
run += it.ch;
continue;
}
flush();
out.push(it.t === 'ext' ?
{ ...it, alts: it.alts.map(a => normalize(a, form)) }
: it);
}
flush();
return out;
};
// the start node, and the number of node ids. Ids are dense, from 0
// for the match node.
const compile = (items, nocase) => {
let id = 1;
const split = (out) => ({ t: 'split', id: id++, out });
const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
const item = (it, next) => {
switch (it.t) {
case 'lit':
const re = nocase ? foldRe(it.ch) : undefined;
return { t: 'lit', id: id++, ch: it.ch, re, next };
case 'any':
case 'star':
return { t: it.t, id: id++, next };
case 'class':
return { t: 'class', id: id++, re: it.re, next };
}
const alts = (next) => it.alts.map(a => seq(a, next));
switch (it.type) {
case '@':
return split(alts(next));
case '?':
return split([next, ...alts(next)]);
case '!':
return { t: 'neg', id: id++, sub: split(alts(MATCH)), next };
}
// * and +, loop back after each match
const after = split([]);
const entry = split(alts(after));
after.out.push(next, entry);
return it.type === '*' ? after : entry;
};
const start = seq(items, MATCH);
return [start, id];
};
// one line per node, in the order that a walk from the start
// reaches them. Edges point to node ids. The nodes of a negated
// sub-pattern are indented under their negation.
const show = (start) => {
const lines = [];
const seen = new Set();
const ref = (n) => (n.t === 'match' ? 'match' : String(n.id));
const walk = (n, indent) => {
if (n.t === 'match' || seen.has(n))
return;
seen.add(n);
const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
switch (n.t) {
case 'split':
line(`split -> ${n.out.map(ref).join(', ')}`);
for (const o of n.out)
walk(o, indent);
return;
case 'neg':
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
walk(n.sub, indent + ' ');
return walk(n.next, indent);
case 'lit':
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
break;
case 'class':
line(`${n.re} -> ${ref(n.next)}`);
break;
default:
line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`);
}
walk(n.next, indent);
};
walk(start, '');
return [`start -> ${ref(start)}`, ...lines].join('\n');
};
// The threads at one position in the string. Each node thread is
// only kept once, and runs with the same state are only kept once,
// so that identical threads merge. The match node is not in
// `threads`, because it can not step. It sets `match` instead.
class State {
// set by the Sim, to mark the nodes that this state has
gen;
threads = [];
match = false;
runs = [];
// the sorted ids of the threads, with 0 for a match, once the
// state is done
ids = [];
constructor(gen) {
this.gen = gen;
}
// no threads, so nothing more can match
get dead() {
return !this.threads.length && !this.match && !this.runs.length;
}
}
// true if the two states hold the same threads
const sameState = (a, b) => {
if (a.ids.length !== b.ids.length)
return false;
if (a.runs.length !== b.runs.length)
return false;
if (a.ids.some((id, i) => id !== b.ids[i]))
return false;
return a.runs.every(r => b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)));
};
const marks = (size) => ({
has: new Float64Array(size),
seen: new Float64Array(size),
gen: 0,
});
class Sim {
// `.` and `..` only match literal dots, even with `dot:true`
dots;
// the string starts with `.`, and `dot:true` is not set
dotStart;
#marks;
constructor(dots, dotStart, marks) {
this.dots = dots;
this.dotStart = dotStart;
this.#marks = marks;
}
state() {
return new State(++this.#marks.gen);
}
// sort the ids of a state, once it has all of its threads
done(state) {
state.ids = state.threads.map(n => n.id).sort((a, b) => a - b);
if (state.match)
state.ids.unshift(MATCH.id);
return state;
}
// true the first time that the state walks through the node, so
// that loops in the graph stop
#visit(state, node) {
const { seen } = this.#marks;
if (seen[node.id] === state.gen)
return false;
seen[node.id] = state.gen;
return true;
}
#addThread(state, node) {
const { has } = this.#marks;
if (has[node.id] === state.gen)
return false;
has[node.id] = state.gen;
state.threads.push(node);
return true;
}
// wildcards only match a leading dot if `dot:true`. In a negated
// sub-pattern, this does not apply, because the negation itself
// can not match a leading dot.
restricted(i, top) {
return top && (this.dots || (this.dotStart && i === 0));
}
add(state, node, i, top) {
switch (node.t) {
case 'split':
if (!this.#visit(state, node))
return;
for (const o of node.out)
this.add(state, o, i, top);
return;
case 'neg':
if (!this.#visit(state, node))
return;
const sub = this.state();
this.add(sub, node.sub, i, false);
this.done(sub);
return this.addRun(state, { t: 'run', neg: node, state: sub }, i, top);
case 'star':
// a * can not start a dotfile, even if it matches nothing
if (this.restricted(i, top))
return;
if (this.#addThread(state, node))
this.add(state, node.next, i, top);
return;
case 'match':
state.match = true;
return;
default:
this.#addThread(state, node);
}
}
addRun(state, run, i, top) {
for (const r of state.runs) {
if (r.neg === run.neg && sameState(r.state, run.state))
return;
}
state.runs.push(run);
if (!run.state.match) {
this.add(state, run.neg.next, i, top);
}
}
// the threads after char `c`, at index `i`
step(state, c, i, top) {
const next = this.state();
for (const th of state.threads) {
switch (th.t) {
case 'lit':
if (litMatch(th, c)) {
this.add(next, th.next, i + 1, top);
}
break;
case 'any':
if (!this.restricted(i, top))
this.add(next, th.next, i + 1, top);
break;
case 'class':
if (!this.restricted(i, top) && th.re.test(c)) {
this.add(next, th.next, i + 1, top);
}
break;
case 'star':
if (!this.restricted(i, top))
this.add(next, th, i + 1, top);
}
}
if (!this.restricted(i, top)) {
for (const run of state.runs) {
// a sub-pattern with no threads can not match again, so the
// run stays the same
if (run.state.dead) {
this.addRun(next, run, i + 1, top);
continue;
}
const sub = this.step(run.state, c, i, false);
this.addRun(next, { t: 'run', neg: run.neg, state: sub }, i + 1, top);
}
}
return this.done(next);
}
}
// A canonical key for the threads in a state. States with the same
// key hold the same threads, so they match the same strings.
const stateKey = (state) => {
const ids = state.ids.join();
if (!state.runs.length)
return ids;
const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`);
return `${ids}|${runs.sort().join('|')}`;
};
// The cache can hold about this many chars of state keys and
// transitions. When it is full, it is cleared, so that a pattern
// can not use an unbounded amount of memory.
const DFA_BUDGET = 1 << 18;
// A cache of the states that the simulation reaches, built as the
// matcher is used. Each char of a string is then one Map lookup,
// once the states that it leads to are known.
//
// The dot rules only restrict the first char of a dotfile (strings
// that are only `.` or `..` do not use the cache). So a dotfile
// starts at its own state, which takes its first step with the
// restriction, and every other state takes steps without it.
class Dfa {
#start;
#states = new Map();
#size = 0;
#plain;
#dotStart;
#sim;
#dotSim;
constructor(start, marks) {
this.#start = start;
this.#sim = new Sim(false, false, marks);
this.#dotSim = new Sim(false, true, marks);
}
#make(state) {
return {
state,
match: state.match,
dead: state.dead,
next: new Map(),
};
}
#intern(state) {
const key = stateKey(state);
const found = this.#states.get(key);
if (found)
return found;
if (this.#size > DFA_BUDGET)
this.#clear();
const d = this.#make(state);
this.#states.set(key, d);
this.#size += key.length + 1;
return d;
}
#clear() {
this.#states.clear();
this.#size = 0;
this.#plain = undefined;
this.#dotStart = undefined;
}
start(dotStart) {
if (dotStart) {
if (this.#dotStart)
return this.#dotStart;
const state = this.#dotSim.state();
this.#dotSim.add(state, this.#start, 0, true);
return (this.#dotStart = this.#make(this.#dotSim.done(state)));
}
if (this.#plain)
return this.#plain;
const state = this.#sim.state();
this.#sim.add(state, this.#start, 0, true);
return (this.#plain = this.#intern(this.#sim.done(state)));
}
// the next state, after a miss in `d.ascii`
next(d, c) {
const code = c.charCodeAt(0);
const found = code < 128 ? undefined : d.next.get(c);
if (found)
return found;
// the dotfile start is not in the cache, so it is never shared
const n = d === this.#dotStart ?
this.#intern(this.#dotSim.step(d.state, c, 0, true))
: this.#intern(this.#sim.step(d.state, c, 1, true));
if (code < 128) {
if (!d.ascii) {
d.ascii = new Array(128);
this.#size += 128;
}
d.ascii[code] = n;
}
else {
d.next.set(c, n);
}
this.#size++;
return n;
}
}
// the nodes in order, if the graph is a single chain
const linear = (start) => {
const nodes = [];
for (let n = start; n.t !== 'match'; n = n.next) {
if (n.t === 'split' || n.t === 'neg')
return undefined;
nodes.push(n);
}
return nodes;
};
// Match a chain of nodes. Each node other than `*` matches exactly
// one char, so on a failure it is enough to go back to the last `*`
// and let it match one more char. This takes at most
// nodes.length * chars.length steps.
const testLinear = (nodes, chars, start, end) => {
let ni = 0;
let ci = start;
let starNi = -1;
let starCi = 0;
while (ci < end) {
const n = nodes[ni];
if (n?.t === 'star') {
starNi = ni++;
starCi = ci;
continue;
}
const c = chars[ci];
if (n &&
(n.t === 'any' ||
(n.t === 'lit' && litMatch(n, c)) ||
(n.t === 'class' && n.re.test(c)))) {
ni++;
ci++;
continue;
}
if (starNi === -1)
return false;
ni = starNi + 1;
ci = ++starCi;
}
while (nodes[ni]?.t === 'star')
ni++;
return ni === nodes.length;
};
// The least and most chars that the items can match. These are only
// bounds: a negation can match a string of any length, so it counts
// as 0 to Infinity.
const lengths = (items) => {
let min = 0;
let max = 0;
for (const it of items) {
const [lo, hi] = itemLengths(it);
min += lo;
max += hi;
}
return [min, max];
};
const itemLengths = (it) => {
if (it.t === 'star')
return [0, Infinity];
if (it.t !== 'ext')
return [1, 1];
if (it.type === '!')
return [0, Infinity];
const alts = it.alts.map(lengths);
const min = Math.min(...alts.map(a => a[0]));
const max = Math.max(...alts.map(a => a[1]));
// a loop of alternatives that only match the empty string is empty
const loop = max === 0 ? 0 : Infinity;
return (it.type === '@' ? [min, max]
: it.type === '?' ? [0, max]
: it.type === '*' ? [0, loop]
: [min, loop]);
};
// true if the chars from `start` match the literals
const hasAffix = (lits, chars, start) => {
for (let j = 0; j < lits.length; j++) {
if (!litMatch(lits[j], chars[start + j]))
return false;
}
return true;
};
// a `/`, or half of a surrogate pair
const slashOrSurrogate = /[/\ud800-\udfff]/;
const surrogate = /[\ud800-\udfff]/;
// a string can be indexed by code point, unless it has surrogate
// pairs
const codePoints = (s) => surrogate.test(s) ? [...s] : s;
const noSlash = (s) => {
if (s.includes('/')) {
throw new Error('can only match a single path portion, got: ' + s);
}
};
export class Matcher {
pattern;
options;
#start;
// the number of node ids
#size;
#marks;
// the Sim for strings that are only `.` or `..`
#dotsSim;
// the string to compare, if the pattern has no magic. With
// `nocase:true`, the RegExp that folds case is made when it is
// first used.
#literal;
#literalFold = false;
#literalRe;
// the nodes between the prefix and suffix, if the graph is a
// single chain
#linear;
// the linear nodes are only `*` and `?`, so the length bounds and
// the prefix and suffix decide the match
#wild = false;
// the least and most chars that a match can have
#min = 0;
#max = Infinity;
// the literals that a match must start and end with. Each one
// matches exactly one char, and they are distinct items in the
// pattern, so a string that does not have them can not match.
#prefix = [];
#suffix = [];
// the prefix and suffix as strings, if they do not fold case
#prefixStr;
#suffixStr;
// there is a prefix or suffix to check
#affix = false;
#dfa;
#form;
constructor(pattern, options = {}) {
if (pattern.includes('/')) {
throw new Error('can only match a single path portion, got pattern: ' + pattern);
}
this.pattern = pattern;
this.options = options;
const { nocase = false, noext = false, normalize: n } = options;
this.#form = n === true ? 'NFC' : n || undefined;
// a pattern that is only an empty extglob is a literal string,
// except for `!()`, which matches any non-empty string
const literal = /^[?*+@]\(\)$/.test(pattern);
const toks = tokenize(pattern, nocase, noext || literal, this.#form);
let [items] = build(toks, pair(toks), 0, toks.length, true);
if (this.#form)
items = normalize(items, this.#form);
const [start, size] = compile(items, nocase);
this.#start = start;
this.#size = size;
if (items.every(it => it.t === 'lit')) {
this.#literal = items.map(it => it.ch).join('');
this.#literalFold = nocase;
}
else {
const lit = (it) => it.t !== 'lit' ? undefined
: nocase ? { ch: it.ch, re: foldRe(it.ch) }
: { ch: it.ch };
for (const it of items) {
const l = lit(it);
if (!l)
break;
this.#prefix.push(l);
}
for (let j = items.length - 1; j >= 0; j--) {
const l = lit(items[j]);
if (!l)
break;
this.#suffix.unshift(l);
}
this.#affix = !!(this.#prefix.length || this.#suffix.length);
if (!nocase) {
this.#prefixStr = this.#prefix.map(l => l.ch).join('');
this.#suffixStr = this.#suffix.map(l => l.ch).join('');
}
this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || undefined);
this.#wild = !!this.#linear?.every(n => n.t === 'star' || n.t === 'any');
const [min, max] = lengths(items);
this.#min = min;
this.#max = max;
}
}
test(s) {
// The `/` check uses the string as given, so with normalization it
// is a separate step. Otherwise, one scan finds both a `/` and the
// surrogate pairs that stop the string being indexed by code point.
if (this.#form) {
noSlash(s);
return this.#test(s.normalize(this.#form));
}
if (slashOrSurrogate.test(s)) {
noSlash(s);
return this.#test(s, [...s]);
}
return this.#test(s, s);
}
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s) {
return this.#test(this.#form ? s.normalize(this.#form) : s);
}
// Test a string that has no `/`. `chars` indexes it by code point.
// If it is not given, it is only found if a step needs it.
#test(s, chars) {
if (this.#literal !== undefined) {
return this.#literalFold ?
(this.#literalRe ??= newFoldRe(this.#literal)).test(s)
: s === this.#literal;
}
// the length check means that the prefix and suffix do not
// overlap. Without the chars, the length in code points is from
// half of the UTF-16 length (if each one is a surrogate pair) to
// all of it, which is often enough to know.
const min = this.#min;
const max = this.#max;
if (chars === undefined) {
const most = s.length;
const least = (most + 1) >> 1;
if (most < min || least > max)
return false;
if (least < min || most > max)
chars = codePoints(s);
}
if (chars !== undefined &&
(chars.length < min || chars.length > max)) {
return false;
}
const prefix = this.#prefix.length;
if (this.#affix) {
if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {
if (!s.startsWith(this.#prefixStr) ||
!s.endsWith(this.#suffixStr)) {
return false;
}
}
else {
chars ??= codePoints(s);
const end = chars.length - this.#suffix.length;
if (!hasAffix(this.#prefix, chars, 0) ||
!hasAffix(this.#suffix, chars, end)) {
return false;
}
}
}
const dotStart = !this.options.dot && s.startsWith('.');
if (this.#linear) {
// `.` and `..` only match literal dots, even with `dot:true`
if (s === '.' || s === '..')
return false;
// only a literal can match the leading dot. A `*` can not
// start a dotfile, even if it matches nothing.
if (dotStart && !prefix)
return false;
if (this.#wild)
return true;
chars ??= codePoints(s);
const end = chars.length - this.#suffix.length;
return testLinear(this.#linear, chars, prefix, end);
}
chars ??= codePoints(s);
if (s === '.' || s === '..') {
this.#marks ??= marks(this.#size);
const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks));
const start = sim.state();
sim.add(start, this.#start, 0, true);
let state = sim.done(start);
for (let i = 0; i < chars.length; i++) {
state = sim.step(state, chars[i], i, true);
}
return state.match;
}
this.#marks ??= marks(this.#size);
const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks));
let d = dfa.start(dotStart);
// read char codes from the string, so that a one-char string is
// only made for a cache miss
const str = chars === s;
for (let i = 0; i < chars.length; i++) {
if (d.dead)
return false;
const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
}
return d.match;
}
/** a readable listing of the state machine */
toString() {
return show(this.#start);
}
}
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyCxD,sDAAsD;AACtD,MAAM,KAAK,GAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AAEzC,MAAM,QAAQ,GAAG,OAAO,CAAA;AAExB,MAAM,GAAG,GAAG,CAAC,EAAU,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AAEpD,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;AAEzE,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,I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C;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,oEAAoE;AACpE,oEAAoE;AACpE,kEAAkE;AAClE,yDAAyD;AACzD,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,IAAU,EAAU,EAAE;IACtD,MAAM,GAAG,GAAW,EAAE,CAAA;IACtB,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,MAALine truncated
@@ -0,0 +1,3 @@
var D={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}"],"[:alpha:]":["\\p{L}\\p{Nl}"],"[:ascii:]":["\\x00-\\x7f"],"[:blank:]":["\\p{Zs}\\t"],"[:cntrl:]":["\\p{Cc}"],"[:digit:]":["\\p{Nd}"],"[:graph:]":["\\p{Z}\\p{C}",!0],"[:lower:]":["\\p{Ll}"],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}\\p{S}"],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f"],"[:upper:]":["\\p{Lu}"],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],"[:xdigit:]":["A-Fa-f0-9"]},y=i=>i.replace(/[[\]\\-]/g,"\\$&"),A=/$./,E=(i,t,e=!1,s)=>{let h=p=>{let m=s?p.normalize(s):p;return[...m].length===1?m:p},n=t;if(i.charAt(n)!=="[")throw new Error("not in a brace expression");let o=[],a=[],r=n+1,l=!1,c=!1,u=!1,g=n,d="";t:for(;r<i.length;){let p=String.fromCodePoint(i.codePointAt(r));if((p==="!"||p==="^")&&r===n+1){u=!0,r++;continue}if(p==="]"&&l&&!c){g=r+1;break}if(l=!0,p==="\\"&&!c){c=!0,r++;continue}if(p==="["&&!c){for(let[z,[R,B]]of Object.entries(D))if(i.startsWith(z,r)){if(d)return[A,i.length-n];r+=z.length,B?a.push(R):o.push(R);continue t}}c=!1;let m=h(p);if(d){m.codePointAt(0)>d.codePointAt(0)?o.push(y(d)+"-"+y(m)):m===d&&o.push(y(m)),d="",r+=p.length;continue}if(i.startsWith("-]",r+p.length)){o.push(y(m+"-")),r+=p.length+1;continue}if(i.startsWith("-",r+p.length)){d=m,r+=p.length+1;continue}o.push(y(m)),r+=p.length}if(g<r)return[A,0];if(!o.length&&!a.length)return[A,i.length-n];let f="["+(u?"^":"")+o.join("")+"]",w="["+(u?"":"^")+a.join("")+"]",q="^"+(o.length&&a.length?"("+f+"|"+w+")":o.length?f:w);return[new RegExp(q,e?"iu":"u"),g-n]};var C={t:"match",id:0},G="!?+*@",x=i=>({t:"lit",ch:i}),H=i=>i.replace(/[\\^$.*+?()[\]{}|/]/g,"\\$&"),W=i=>new RegExp(`^${H(i)}$`,"iu"),S=new Map,v=i=>{let t=S.get(i);return t||(t=W(i),S.size>=1e3&&S.clear(),S.set(i,t)),t},P=(i,t)=>{if(t===i.ch)return!0;if(!i.re)return!1;let e=t.charCodeAt(0);if(e>=128)return i.re.test(t);let s=i.ascii??=new Uint8Array(128);return s[e]||=i.re.test(t)?1:2,s[e]===1},J=(i,t,e,s)=>{let h=[];for(let n=0;n<i.length;){let o=String.fromCodePoint(i.codePointAt(n));if(o==="\\"){let a=i.codePointAt(n+1),r=a===void 0?o:String.fromCodePoint(a);h.push(x(r)),n+=1+r.length;continue}if(o==="["){let[a,r]=E(i,n,t,s);if(r){h.push({t:"class",re:a}),n+=r;continue}}if(!e&&G.includes(o)&&i[n+1]==="("){h.push({t:"open",type:o}),n+=2;continue}h.push(!e&&o==="|"?{t:"bar"}:!e&&o===")"?{t:"close"}:o==="*"?{t:"star"}:o==="?"?{t:"any"}:x(o)),n+=o.length}return h},K=i=>{let t=new Map,e=[];return i.forEach((s,h)=>{s.t==="open"?e.push(h):s.t==="close"&&e.length&&t.set(e.pop(),h)}),t},I=(i,t,e,s,h)=>{let n=[],o=[n];for(let a=e;a<s;a++){let r=i[a],l=t.get(a);if(r.t==="open"&&l!==void 0){let c=I(i,t,a+1,l,!1);n.push({t:"ext",type:r.type,alts:c}),a=l}else r.t==="bar"&&!h?o.push(n=[]):r.t==="open"?n.push(x(r.type),x("(")):r.t==="bar"?n.push(x("|")):r.t==="close"?n.push(x(")")):n.push(r)}return o},T=(i,t)=>{let e=[],s="",h=()=>{for(let n of s.normalize(t))e.push(x(n));s=""};for(let n of i){if(n.t==="lit"){s+=n.ch;continue}h(),e.push(n.t==="ext"?{...n,alts:n.alts.map(o=>T(o,t))}:n)}return h(),e},_=(i,t)=>{let e=1,s=a=>({t:"split",id:e++,out:a}),h=(a,r)=>a.reduceRight((l,c)=>n(c,l),r),n=(a,r)=>{switch(a.t){case"lit":let g=t?v(a.ch):void 0;return{t:"lit",id:e++,ch:a.ch,re:g,next:r};case"any":case"star":return{t:a.t,id:e++,next:r};case"class":return{t:"class",id:e++,re:a.re,next:r}}let l=g=>a.alts.map(d=>h(d,g));switch(a.type){case"@":return s(l(r));case"?":return s([r,...l(r)]);case"!":return{t:"neg",id:e++,sub:s(l(C)),next:r}}let c=s([]),u=s(l(c));return c.out.push(r,u),a.type==="*"?c:u};return[h(i,C),e]},Q=i=>{let t=[],e=new Set,s=n=>n.t==="match"?"match":String(n.id),h=(n,o)=>{if(n.t==="match"||e.has(n))return;e.add(n);let a=r=>t.push(`${o}${n.id}: ${r}`);switch(n.t){case"split":a(`split -> ${n.out.map(s).join(", ")}`);for(let r of n.out)h(r,o);return;case"neg":return a(`!(${s(n.sub)}) -> ${s(n.next)}`),h(n.sub,o+" "),h(n.next,o);case"lit":a(`${JSON.stringify(n.ch)} -> ${s(n.next)}`);break;case"class":a(`${n.re} -> ${s(n.next)}`);break;default:a(`${n.t==="any"?"?":"*"} -> ${s(n.next)}`)}h(n.next,o)};return h(i,""),[`start -> ${s(i)}`,...t].join(`
`)},b=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(t){this.gen=t}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}},O=(i,t)=>i.ids.length!==t.ids.length||i.runs.length!==t.runs.length||i.ids.some((e,s)=>e!==t.ids[s])?!1:i.runs.every(e=>t.runs.some(s=>s.neg===e.neg&&O(s.state,e.state))),N=i=>({has:new Float64Array(i),seen:new Float64Array(i),gen:0}),$=class{dots;dotStart;#t;constructor(t,e,s){this.dots=t,this.dotStart=e,this.#t=s}state(){return new b(++this.#t.gen)}done(t){return t.ids=t.threads.map(e=>e.id).sort((e,s)=>e-s),t.match&&t.ids.unshift(C.id),t}#s(t,e){let{seen:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,!0)}#e(t,e){let{has:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,t.threads.push(e),!0)}restricted(t,e){return e&&(this.dots||this.dotStart&&t===0)}add(t,e,s,h){switch(e.t){case"split":if(!this.#s(t,e))return;for(let o of e.out)this.add(t,o,s,h);return;case"neg":if(!this.#s(t,e))return;let n=this.state();return this.add(n,e.sub,s,!1),this.done(n),this.addRun(t,{t:"run",neg:e,state:n},s,h);case"star":if(this.restricted(s,h))return;this.#e(t,e)&&this.add(t,e.next,s,h);return;case"match":t.match=!0;return;default:this.#e(t,e)}}addRun(t,e,s,h){for(let n of t.runs)if(n.neg===e.neg&&O(n.state,e.state))return;t.runs.push(e),e.state.match||this.add(t,e.neg.next,s,h)}step(t,e,s,h){let n=this.state();for(let o of t.threads)switch(o.t){case"lit":P(o,e)&&this.add(n,o.next,s+1,h);break;case"any":this.restricted(s,h)||this.add(n,o.next,s+1,h);break;case"class":!this.restricted(s,h)&&o.re.test(e)&&this.add(n,o.next,s+1,h);break;case"star":this.restricted(s,h)||this.add(n,o,s+1,h)}if(!this.restricted(s,h))for(let o of t.runs){if(o.state.dead){this.addRun(n,o,s+1,h);continue}let a=this.step(o.state,e,s,!1);this.addRun(n,{t:"run",neg:o.neg,state:a},s+1,h)}return this.done(n)}},U=i=>{let t=i.ids.join();if(!i.runs.length)return t;let e=i.runs.map(s=>`${s.neg.id}(${U(s.state)})`);return`${t}|${e.sort().join("|")}`},V=1<<18,j=class{#t;#s=new Map;#e=0;#c;#n;#i;#h;constructor(t,e){this.#t=t,this.#i=new $(!1,!1,e),this.#h=new $(!1,!0,e)}#o(t){return{state:t,match:t.match,dead:t.dead,next:new Map}}#u(t){let e=U(t),s=this.#s.get(e);if(s)return s;this.#e>V&&this.#f();let h=this.#o(t);return this.#s.set(e,h),this.#e+=e.length+1,h}#f(){this.#s.clear(),this.#e=0,this.#c=void 0,this.#n=void 0}start(t){if(t){if(this.#n)return this.#n;let s=this.#h.state();return this.#h.add(s,this.#t,0,!0),this.#n=this.#o(this.#h.done(s))}if(this.#c)return this.#c;let e=this.#i.state();return this.#i.add(e,this.#t,0,!0),this.#c=this.#u(this.#i.done(e))}next(t,e){let s=e.charCodeAt(0),h=s<128?void 0:t.next.get(e);if(h)return h;let n=t===this.#n?this.#u(this.#h.step(t.state,e,0,!0)):this.#u(this.#i.step(t.state,e,1,!0));return s<128?(t.ascii||(t.ascii=new Array(128),this.#e+=128),t.ascii[s]=n):t.next.set(e,n),this.#e++,n}},X=i=>{let t=[];for(let e=i;e.t!=="match";e=e.next){if(e.t==="split"||e.t==="neg")return;t.push(e)}return t},Y=(i,t,e,s)=>{let h=0,n=e,o=-1,a=0;for(;n<s;){let r=i[h];if(r?.t==="star"){o=h++,a=n;continue}let l=t[n];if(r&&(r.t==="any"||r.t==="lit"&&P(r,l)||r.t==="class"&&r.re.test(l))){h++,n++;continue}if(o===-1)return!1;h=o+1,n=++a}for(;i[h]?.t==="star";)h++;return h===i.length},Z=i=>{let t=0,e=0;for(let s of i){let[h,n]=tt(s);t+=h,e+=n}return[t,e]},tt=i=>{if(i.t==="star")return[0,1/0];if(i.t!=="ext")return[1,1];if(i.type==="!")return[0,1/0];let t=i.alts.map(Z),e=Math.min(...t.map(n=>n[0])),s=Math.max(...t.map(n=>n[1])),h=s===0?0:1/0;return i.type==="@"?[e,s]:i.type==="?"?[0,s]:i.type==="*"?[0,h]:[e,h]},M=(i,t,e)=>{for(let s=0;s<i.length;s++)if(!P(i[s],t[e+s]))return!1;return!0},et=/[/\ud800-\udfff]/,st=/[\ud800-\udfff]/,k=i=>st.test(i)?[...i]:i,F=i=>{if(i.includes("/"))throw new Error("can only match a single path portion, got: "+i)},L=class{pattern;options;#t;#s;#e;#c;#n;#i=!1;#h;#o;#u=!1;#f=0;#m=1/0;#l=[];#a=[];#p;#g;#w=!1;#x;#r;constructor(t,e={}){if(t.includes("/"))throw new Error("can only match a single path portion, got pattern: "+t);this.pattern=t,this.options=e;let{nocase:s=!1,noext:h=!1,normalize:n}=e;this.#r=n===!0?"NFC":n||void 0;let o=/^[?*+@]\(\)$/.test(t),a=J(t,s,h||o,this.#r),[r]=I(a,K(a),0,a.length,!0);this.#r&&(r=T(r,this.#r));let[l,c]=_(r,s);if(this.#t=l,this.#s=c,r.every(u=>u.t==="lit"))this.#n=r.map(u=>u.ch).join(""),this.#i=s;else{let u=f=>f.t!=="lit"?void 0:s?{ch:f.ch,re:v(f.ch)}:{ch:f.ch};for(let f of r){let w=u(f);if(!w)break;this.#l.push(w)}for(let f=r.length-1;f>=0;f--){let w=u(r[f]);if(!w)break;this.#a.unshift(w)}this.#w=!!(this.#l.length||this.#a.length),s||(this.#p=this.#l.map(f=>f.ch).join(""),this.#g=this.#a.map(f=>f.ch).join("")),this.#o=X(this.#t)?.slice(this.#l.length,-this.#a.length||void 0),this.#u=!!this.#o?.every(f=>f.t==="star"||f.t==="any");let[g,d]=Z(r);this.#f=g,this.#m=d}}test(t){return this.#r?(F(t),this.#d(t.normalize(this.#r))):et.test(t)?(F(t),this.#d(t,[...t])):this.#d(t,t)}testUnchecked(t){return this.#d(this.#r?t.normalize(this.#r):t Line truncated
//# sourceMappingURL=index.min.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../src/parse-class.ts", "../../src/index.ts"],
"sourcesContent": ["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolean] } = {\n '[:alnum:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}'],\n '[:alpha:]': ['\\\\p{L}\\\\p{Nl}'],\n '[:ascii:]': ['\\\\x' + '00-\\\\x' + '7f'],\n '[:blank:]': ['\\\\p{Zs}\\\\t'],\n '[:cntrl:]': ['\\\\p{Cc}'],\n '[:digit:]': ['\\\\p{Nd}'],\n '[:graph:]': ['\\\\p{Z}\\\\p{C}', true],\n '[:lower:]': ['\\\\p{Ll}'],\n '[:print:]': ['\\\\p{C}', true],\n '[:punct:]': ['\\\\p{P}\\\\p{S}'],\n '[:space:]': ['\\\\p{Z}\\\\t\\\\r\\\\n\\\\v\\\\f'],\n '[:upper:]': ['\\\\p{Lu}'],\n '[:word:]': ['\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}'],\n '[:xdigit:]': ['A-Fa-f0-9'],\n}\n\n// only need to escape a few things inside of brace expressions\n// escapes: [ \\ ] -\nconst braceEscape = (s: string) => s.replace(/[[\\]\\\\-]/g, '\\\\$&')\n\nexport type ParseClassResult = [re: RegExp, consumed: number]\n\nexport type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD'\n\nconst noMatch = /$./\n\n// Takes a glob string at a posix brace expression. Returns a RegExp\n// that tests one character, and the number of glob chars consumed.\n// If the class is not closed, consumed is 0, and the `[` must be\n// treated as a literal character.\n// Out of order ranges are removed. If nothing is left, the RegExp\n// is `/$./`, and the rest of the glob is consumed, so that the\n// whole glob cannot match.\nexport const parseClass = (\n glob: string,\n position: number,\n nocase: boolean = false,\n form?: Form,\n): ParseClassResult => {\n // normalize one class member, if it stays one code point\n const norm = (c: string) => {\n const n = form ? c.normalize(form) : c\n return [...n].length === 1 ? n : c\n }\n const pos = position\n /* c8 ignore start */\n if (glob.charAt(pos) !== '[') {\n throw new Error('not in a brace expression')\n }\n /* c8 ignore stop */\n const ranges: string[] = []\n const negs: string[] = []\n\n let i = pos + 1\n let sawStart = false\n let escaping = false\n let negate = false\n let endPos = pos\n let rangeStart = ''\n WHILE: while (i < glob.length) {\n const c = String.fromCodePoint(glob.codePointAt(i)!)\n if ((c === '!' || c === '^') && i === pos + 1) {\n negate = true\n i++\n continue\n }\n\n if (c === ']' && sawStart && !escaping) {\n endPos = i + 1\n break\n }\n\n sawStart = true\n if (c === '\\\\') {\n if (!escaping) {\n escaping = true\n i++\n continue\n }\n // escaped \\ char, fall through and treat like normal char\n }\n if (c === '[' && !escaping) {\n // either a posix class, a collation equivalent, or just a [\n for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {\n if (glob.startsWith(cls, i)) {\n // invalid, [a-[] is fine, but not [a-[:alpha]]\n if (rangeStart) {\n return [noMatch, glob.length - pos]\n }\n i += cls.length\n if (neg) negs.push(unip)\n else ranges.push(unip)\n continue WHILE\n }\n }\n }\n\n // now it's just a normal character, effectively\n escaping = false\n const n = norm(c)\n if (rangeStart) {\n // throw this range away if it's not valid, but others\n // can still match.\n if (n.codePointAt(0)! > rangeStart.codePointAt(0)!) {\n ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n))\n } else if (n === rangeStart) {\n ranges.push(braceEscape(n))\n }\n rangeStart = ''\n i += c.length\n continue\n }\n\n // now might be the start of a range.\n // can be either c-d or c-] or c<more...>] or c] at this point\n if (glob.startsWith('-]', i + c.length)) {\n ranges.push(braceEscape(n + '-'))\n i += c.length + 1\n continue\n }\n if (glob.startsWith('-', i + c.length)) {\n rangeStart = n\n i += c.length + 1\n continue\n }\n\n // not the start of a range, just a single character\n ranges.push(braceEscape(n))\n i += c.length\n }\n\n if (endPos < i) {\n // didn't see the end of the class, not a valid class,\n // but might still be valid as a literal match.\n return [noMatch, 0]\n }\n\n // if we got no ranges and no negates, then we have a range that\n // cannot possibly match anything, and that poisons the whole glob\n if (!ranges.length && !negs.length) {\n return [noMatch, glob.length - pos]\n }\n\n const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']'\n const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']'\n const comb =\n '^' +\n (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'\n : ranges.length ? sranges\n : snegs)\n\n return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos]\n}\n", "import { type Form, parseClass } from './parse-class.js'\nLine truncated
"mappings": "AAIA,IAAMA,EAA0D,CAC9D,YAAa,CAAC,sBAAsB,EACpC,YAAa,CAAC,eAAe,EAC7B,YAAa,CAAC,aAAuB,EACrC,YAAa,CAAC,YAAY,EAC1B,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,eAAgB,EAAI,EAClC,YAAa,CAAC,SAAS,EACvB,YAAa,CAAC,SAAU,EAAI,EAC5B,YAAa,CAAC,cAAc,EAC5B,YAAa,CAAC,uBAAuB,EACrC,YAAa,CAAC,SAAS,EACvB,WAAY,CAAC,6BAA6B,EAC1C,aAAc,CAAC,WAAW,GAKtBC,EAAeC,GAAcA,EAAE,QAAQ,YAAa,MAAM,EAM1DC,EAAU,KASHC,EAAa,CACxBC,EACAC,EACAC,EAAkB,GAClBC,IACoB,CAEpB,IAAMC,EAAQC,GAAa,CACzB,IAAMC,EAAIH,EAAOE,EAAE,UAAUF,CAAI,EAAIE,EACrC,MAAO,CAAC,GAAGC,CAAC,EAAE,SAAW,EAAIA,EAAID,CACnC,EACME,EAAMN,EAEZ,GAAID,EAAK,OAAOO,CAAG,IAAM,IACvB,MAAM,IAAI,MAAM,2BAA2B,EAG7C,IAAMC,EAAmB,CAAA,EACnBC,EAAiB,CAAA,EAEnBC,EAAIH,EAAM,EACVI,EAAW,GACXC,EAAW,GACXC,EAAS,GACTC,EAASP,EACTQ,EAAa,GACjBC,EAAO,KAAON,EAAIV,EAAK,QAAQ,CAC7B,IAAMK,EAAI,OAAO,cAAcL,EAAK,YAAYU,CAAC,CAAE,EACnD,IAAKL,IAAM,KAAOA,IAAM,MAAQK,IAAMH,EAAM,EAAG,CAC7CM,EAAS,GACTH,IACA,QACF,CAEA,GAAI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OT,EAAIU,EAAKV,IAAK,CAChC,IAAMO,EAAMR,EAAKC,CAAC,EACZc,EAAQT,EAAM,IAAIL,CAAC,EACzB,GAAIO,EAAI,IAAM,QAAUO,IAAU,OAAW,CAC3C,IAAMC,EAAMP,EAAMT,EAAMM,EAAOL,EAAI,EAAGc,EAAO,EAAK,EAClDF,EAAI,KAAK,CAAE,EAAG,MAAO,KAAML,EAAI,KAAM,KAAMQ,CAAG,CAAE,EAChDf,EAAIc,CACN,MAAWP,EAAI,IAAM,OAAS,CAACI,EAC7BE,EAAK,KAAMD,EAAM,CAAA,CAAG,EACXL,EAAI,IAAM,OACnBK,EAAI,KAAK/B,EAAI0B,EAAI,IAAI,EAAG1B,EAAI,GAAG,CAAC,EACvB0B,EAAI,IAAM,MACnBK,EAAI,KAAK/B,EAAI,GAAG,CAAC,EACR0B,EAAI,IAAM,QACnBK,EAAI,KAAK/B,EAAI,GAAG,CAAC,EAEjB+B,EAAI,KAAKL,CAAG,CAEhB,CACA,OAAOM,CACT,EAMMG,EAAY,CAACC,EAAenB,IAAsB,CACtD,IAAMoB,EAAc,CAAA,EAChBC,EAAM,GACJC,EAAQ,IAAK,CACjB,QAAWtC,KAAMqC,EAAI,UAAUrB,CAAI,EAAGoB,EAAI,KAAKrC,EAAIC,CAAE,CAAC,EACtDqC,EAAM,EACR,EACA,QAAWE,KAAMJ,EAAO,CACtB,GAAII,EAAG,IAAM,MAAO,CAClBF,GAAOE,EAAG,GACV,QACF,CACAD,EAAK,EACLF,EAAI,KACFG,EAAG,IAAM,MACP,CAAE,GAAGA,EAAI,KAAMA,EAAG,KAAK,IAAIC,GAAKN,EAAUM,EAAGxB,CAAI,CAAC,Line truncated
"names": ["posixClasses", "braceEscape", "s", "noMatch", "parseClass", "glob", "position", "nocase", "form", "norm", "c", "n", "pos", "ranges", "negs", "i", "sawStart", "escaping", "negate", "endPos", "rangeStart", "WHILE", "cls", "unip", "neg", "sranges", "snegs", "comb", "MATCH", "extTypes", "lit", "ch", "reEscape", "s", "newFoldRe", "foldCache", "foldRe", "re", "litMatch", "l", "c", "code", "ascii", "tokenize", "p", "nocase", "noext", "form", "toks", "i", "e", "consumed", "parseClass", "pair", "pairs", "stack", "tok", "build", "start", "end", "top", "seq", "alts", "close", "sub", "normalize", "items", "out", "run", "flush", "it", "a", "compile", "id", "split", "next", "item", "after", "entry", "show", "lines", "seen", "ref", "walk", "indent", "line", "desc", "o", "State", "gen", "sameState", "b", "r", "marks", "size", "Sim", "#marks", "dots", "dotStart", "state", "n", "#visit", "node", "#addThread", "has", "th", "stateKey", "ids", "runs", "DFA_BUDGET", "Dfa", "#start", "#states", "#size", "#plain", "#dotStart", "#sim", "#dotSim", "#make", "#intern", "key", "found", "#clear", "d", "linear", "nodes", "testLinear", "chars", "ni", "ci", "starNi", "starCi", "lengths", "min", "max", "lo", "hi", "itemLengths", "loop", "hasAffix", "lits", "j", "slashOrSurrogate", "surrogate", "codePoints", "noSlash", "Matcher", "#dotsSim", "#literal", "#literalFold", "#literalRe", "#linear", "#wild", "#min", "#max", "#prefix", "#suffix", "#prefixStr", "#suffixStr", "#affix", "#dfa", "#form", "pattern", "options", "literal", "#test", "most", "least", "prefix", "sim", "dfa", "str"]
}
@@ -0,0 +1,3 @@
{
"type": "module"
}
@@ -0,0 +1,4 @@
export type ParseClassResult = [re: RegExp, consumed: number];
export type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
export declare const parseClass: (glob: string, position: number, nocase?: boolean, form?: Form) => ParseClassResult;
//# sourceMappingURL=parse-class.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"parse-class.d.ts","sourceRoot":"","sources":["../../src/parse-class.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AAE7D,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAWlD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,SAAQ,OAAe,EACvB,OAAO,IAAI,KACV,gBAkHF,CAAA"}
@@ -0,0 +1,138 @@
// translate the various posix character classes into unicode properties
// this works across all unicode locales
// { <posix class>: [<translation>, negated]
const posixClasses = {
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}'],
'[:alpha:]': ['\\p{L}\\p{Nl}'],
'[:ascii:]': ['\\x' + '00-\\x' + '7f'],
'[:blank:]': ['\\p{Zs}\\t'],
'[:cntrl:]': ['\\p{Cc}'],
'[:digit:]': ['\\p{Nd}'],
'[:graph:]': ['\\p{Z}\\p{C}', true],
'[:lower:]': ['\\p{Ll}'],
'[:print:]': ['\\p{C}', true],
'[:punct:]': ['\\p{P}\\p{S}'],
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f'],
'[:upper:]': ['\\p{Lu}'],
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}'],
'[:xdigit:]': ['A-Fa-f0-9'],
};
// only need to escape a few things inside of brace expressions
// escapes: [ \ ] -
const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
const noMatch = /$./;
// Takes a glob string at a posix brace expression. Returns a RegExp
// that tests one character, and the number of glob chars consumed.
// If the class is not closed, consumed is 0, and the `[` must be
// treated as a literal character.
// Out of order ranges are removed. If nothing is left, the RegExp
// is `/$./`, and the rest of the glob is consumed, so that the
// whole glob cannot match.
export const parseClass = (glob, position, nocase = false, form) => {
// normalize one class member, if it stays one code point
const norm = (c) => {
const n = form ? c.normalize(form) : c;
return [...n].length === 1 ? n : c;
};
const pos = position;
/* c8 ignore start */
if (glob.charAt(pos) !== '[') {
throw new Error('not in a brace expression');
}
/* c8 ignore stop */
const ranges = [];
const negs = [];
let i = pos + 1;
let sawStart = false;
let escaping = false;
let negate = false;
let endPos = pos;
let rangeStart = '';
WHILE: while (i < glob.length) {
const c = String.fromCodePoint(glob.codePointAt(i));
if ((c === '!' || c === '^') && i === pos + 1) {
negate = true;
i++;
continue;
}
if (c === ']' && sawStart && !escaping) {
endPos = i + 1;
break;
}
sawStart = true;
if (c === '\\') {
if (!escaping) {
escaping = true;
i++;
continue;
}
// escaped \ char, fall through and treat like normal char
}
if (c === '[' && !escaping) {
// either a posix class, a collation equivalent, or just a [
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
if (glob.startsWith(cls, i)) {
// invalid, [a-[] is fine, but not [a-[:alpha]]
if (rangeStart) {
return [noMatch, glob.length - pos];
}
i += cls.length;
if (neg)
negs.push(unip);
else
ranges.push(unip);
continue WHILE;
}
}
}
// now it's just a normal character, effectively
escaping = false;
const n = norm(c);
if (rangeStart) {
// throw this range away if it's not valid, but others
// can still match.
if (n.codePointAt(0) > rangeStart.codePointAt(0)) {
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n));
}
else if (n === rangeStart) {
ranges.push(braceEscape(n));
}
rangeStart = '';
i += c.length;
continue;
}
// now might be the start of a range.
// can be either c-d or c-] or c<more...>] or c] at this point
if (glob.startsWith('-]', i + c.length)) {
ranges.push(braceEscape(n + '-'));
i += c.length + 1;
continue;
}
if (glob.startsWith('-', i + c.length)) {
rangeStart = n;
i += c.length + 1;
continue;
}
// not the start of a range, just a single character
ranges.push(braceEscape(n));
i += c.length;
}
if (endPos < i) {
// didn't see the end of the class, not a valid class,
// but might still be valid as a literal match.
return [noMatch, 0];
}
// if we got no ranges and no negates, then we have a range that
// cannot possibly match anything, and that poisons the whole glob
if (!ranges.length && !negs.length) {
return [noMatch, glob.length - pos];
}
const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']';
const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']';
const comb = '^' +
(ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
: ranges.length ? sranges
: snegs);
return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos];
};
//# sourceMappingURL=parse-class.js.map
@@ -0,0 +1 @@
{"version":3,"file":"parse-class.js","sourceR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jE,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAA;IAC7D,MAAM,IAAI,GACR,GAAG;QACH,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG;YACjE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;gBACzB,CAAC,CAAC,KAAK,CAAC,CAAA;IAEV,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["// translate the various posix character classes into unicode properties\n// this works across all unicode locales\n\n// { <posix class>: [<translation>, negated]\nconst posixClasses: { [k: string]: [e: string, n?: boolean] } = {\n '[Line truncated
+56
View File
@@ -0,0 +1,56 @@
{
"name": "@isaacs/nonrecursive-glob-match",
"description": "a single-path-portion glob matcher not subject to recursive backtracking ReDoS",
"version": "1.0.3",
"license": "BlueOak-1.0.0",
"files": [
"dist",
"src"
],
"devDependencies": {
"esbuild": "^0.28.2",
"prettier": "^3.9.10",
"tap": "^21.8.0",
"tshy": "^4.1.3",
"typedoc": "^0.28.20"
},
"scripts": {
"format": "prettier --write .",
"test": "tap",
"snap": "tap",
"typedoc": "typedoc",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"prepare": "tshy && bash scripts/build.sh",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags"
},
"type": "module",
"tshy": {
"selfLink": false,
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js",
"allowScripts": {
"[email protected]": true
}
}
+900
View File
@@ -0,0 +1,900 @@
import { type Form, parseClass } from './parse-class.js'
export type { Form }
export type MatcherOptions = {
/** perform a case-insensitive match */
nocase?: boolean
/** do not treat strings starting with `.` specially */
dot?: boolean
/** do not match extglobs (treat them as normal strings) */
noext?: boolean
/**
* normalize unicode in the pattern and the tested strings, with
* this form. `true` means `'NFC'`.
*/
normalize?: boolean | Form
}
// parsed pattern items
export type Item =
| { t: 'lit'; ch: string }
| { t: 'any' | 'star' }
| { t: 'class'; re: RegExp }
| { t: 'ext'; type: string; alts: Item[][] }
// extglob syntax tokens become literals if they are not part of a
// closed extglob
export type Token =
Item | { t: 'open'; type: string } | { t: 'bar' } | { t: 'close' }
// state machine nodes
export type NegNode = { t: 'neg'; id: number; sub: Node; next: Node }
export type SplitNode = { t: 'split'; id: number; out: Node[] }
export type Node =
| ({ t: 'lit'; id: number; next: Node } & Lit)
| { t: 'any' | 'star'; id: number; next: Node }
| { t: 'class'; id: number; re: RegExp; next: Node }
| SplitNode
| NegNode
| { t: 'match'; id: number }
// the end of the pattern, or of a negated sub-pattern
const MATCH: Node = { t: 'match', id: 0 }
const extTypes = '!?+*@'
const lit = (ch: string): Item => ({ t: 'lit', ch })
const reEscape = (s: string) => s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&')
// a RegExp that only matches `s`, with unicode case folding
const newFoldRe = (s: string) => new RegExp(`^${reEscape(s)}$`, 'iu')
// foldRe for one literal char. The same chars are in most patterns,
// so keep them. A RegExp without the `g` or `y` flag has no state to
// share.
const foldCache = new Map<string, RegExp>()
const foldRe = (ch: string) => {
let re = foldCache.get(ch)
if (!re) {
re = newFoldRe(ch)
if (foldCache.size >= 1000) foldCache.clear()
foldCache.set(ch, re)
}
return re
}
/**
* A literal char. With `nocase:true`, `re` folds case, and `ascii`
* holds its results for ASCII chars, by char code: 1 for a match,
* and 2 for not.
*/
export type Lit = { ch: string; re?: RegExp; ascii?: Uint8Array }
const litMatch = (l: Lit, c: string) => {
if (c === l.ch) return true
if (!l.re) return false
const code = c.charCodeAt(0)
if (code >= 128) return l.re.test(c)
const ascii = (l.ascii ??= new Uint8Array(128))
ascii[code] ||= l.re.test(c) ? 1 : 2
return ascii[code] === 1
}
const tokenize = (
p: string,
nocase: boolean,
noext: boolean,
form?: Form,
) => {
const toks: Token[] = []
for (let i = 0; i < p.length;) {
const c = String.fromCodePoint(p.codePointAt(i)!)
if (c === '\\') {
// a trailing \ is a literal \
const e = p.codePointAt(i + 1)
const ch = e === undefined ? c : String.fromCodePoint(e)
toks.push(lit(ch))
i += 1 + ch.length
continue
}
if (c === '[') {
const [re, consumed] = parseClass(p, i, nocase, form)
if (consumed) {
toks.push({ t: 'class', re })
i += consumed
continue
}
}
if (!noext && extTypes.includes(c) && p[i + 1] === '(') {
toks.push({ t: 'open', type: c })
i += 2
continue
}
toks.push(
!noext && c === '|' ? { t: 'bar' }
: !noext && c === ')' ? { t: 'close' }
: c === '*' ? { t: 'star' }
: c === '?' ? { t: 'any' }
: lit(c),
)
i += c.length
}
return toks
}
// map each open token index to the index of its close token
const pair = (toks: Token[]) => {
const pairs = new Map<number, number>()
const stack: number[] = []
toks.forEach((tok, i) => {
if (tok.t === 'open') stack.push(i)
else if (tok.t === 'close' && stack.length) pairs.set(stack.pop()!, i)
})
return pairs
}
// build the alternatives between start and end. An open token that
// is not closed is never inside a closed extglob, so bar and close
// tokens are only literal at the top level.
const build = (
toks: Token[],
pairs: Map<number, number>,
start: number,
end: number,
top: boolean,
): Item[][] => {
let seq: Item[] = []
const alts = [seq]
for (let i = start; i < end; i++) {
const tok = toks[i]!
const close = pairs.get(i)
if (tok.t === 'open' && close !== undefined) {
const sub = build(toks, pairs, i + 1, close, false)
seq.push({ t: 'ext', type: tok.type, alts: sub })
i = close
} else if (tok.t === 'bar' && !top) {
alts.push((seq = []))
} else if (tok.t === 'open') {
seq.push(lit(tok.type), lit('('))
} else if (tok.t === 'bar') {
seq.push(lit('|'))
} else if (tok.t === 'close') {
seq.push(lit(')'))
} else {
seq.push(tok)
}
}
return alts
}
// normalize each run of literal chars as one string, so that a char
// and the combining marks after it compose (or decompose) together.
// Syntax is already parsed, so a char that normalizes to a syntax
// char (such as full-width `*` in NFKC) stays a literal.
const normalize = (items: Item[], form: Form): Item[] => {
const out: Item[] = []
let run = ''
const flush = () => {
for (const ch of run.normalize(form)) out.push(lit(ch))
run = ''
}
for (const it of items) {
if (it.t === 'lit') {
run += it.ch
continue
}
flush()
out.push(
it.t === 'ext' ?
{ ...it, alts: it.alts.map(a => normalize(a, form)) }
: it,
)
}
flush()
return out
}
// the start node, and the number of node ids. Ids are dense, from 0
// for the match node.
const compile = (
items: Item[],
nocase: boolean,
): [start: Node, size: number] => {
let id = 1
const split = (out: Node[]): SplitNode => ({ t: 'split', id: id++, out })
const seq = (items: Item[], next: Node): Node =>
items.reduceRight((next, it) => item(it, next), next)
const item = (it: Item, next: Node): Node => {
switch (it.t) {
case 'lit':
const re = nocase ? foldRe(it.ch) : undefined
return { t: 'lit', id: id++, ch: it.ch, re, next }
case 'any':
case 'star':
return { t: it.t, id: id++, next }
case 'class':
return { t: 'class', id: id++, re: it.re, next }
}
const alts = (next: Node) => it.alts.map(a => seq(a, next))
switch (it.type) {
case '@':
return split(alts(next))
case '?':
return split([next, ...alts(next)])
case '!':
return { t: 'neg', id: id++, sub: split(alts(MATCH)), next }
}
// * and +, loop back after each match
const after = split([])
const entry = split(alts(after))
after.out.push(next, entry)
return it.type === '*' ? after : entry
}
const start = seq(items, MATCH)
return [start, id]
}
// one line per node, in the order that a walk from the start
// reaches them. Edges point to node ids. The nodes of a negated
// sub-pattern are indented under their negation.
const show = (start: Node): string => {
const lines: string[] = []
const seen = new Set<Node>()
const ref = (n: Node) => (n.t === 'match' ? 'match' : String(n.id))
const walk = (n: Node, indent: string) => {
if (n.t === 'match' || seen.has(n)) return
seen.add(n)
const line = (desc: string) => lines.push(`${indent}${n.id}: ${desc}`)
switch (n.t) {
case 'split':
line(`split -> ${n.out.map(ref).join(', ')}`)
for (const o of n.out) walk(o, indent)
return
case 'neg':
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`)
walk(n.sub, indent + ' ')
return walk(n.next, indent)
case 'lit':
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`)
break
case 'class':
line(`${n.re} -> ${ref(n.next)}`)
break
default:
line(`${n.t === 'any' ? '?' : '*'} -> ${ref(n.next)}`)
}
walk(n.next, indent)
}
walk(start, '')
return [`start -> ${ref(start)}`, ...lines].join('\n')
}
// A thread inside a !(...) negation. It holds the threads of the
// negated sub-pattern, started where the negation started. The
// negation matches the chars so far if the sub-pattern does not.
type Run = { t: 'run'; neg: NegNode; state: State }
// The threads at one position in the string. Each node thread is
// only kept once, and runs with the same state are only kept once,
// so that identical threads merge. The match node is not in
// `threads`, because it can not step. It sets `match` instead.
class State {
// set by the Sim, to mark the nodes that this state has
gen: number
threads: Node[] = []
match = false
runs: Run[] = []
// the sorted ids of the threads, with 0 for a match, once the
// state is done
ids: number[] = []
constructor(gen: number) {
this.gen = gen
}
// no threads, so nothing more can match
get dead() {
return !this.threads.length && !this.match && !this.runs.length
}
}
// true if the two states hold the same threads
const sameState = (a: State, b: State): boolean => {
if (a.ids.length !== b.ids.length) return false
if (a.runs.length !== b.runs.length) return false
if (a.ids.some((id, i) => id !== b.ids[i])) return false
return a.runs.every(r =>
b.runs.some(o => o.neg === r.neg && sameState(o.state, r.state)),
)
}
/**
* For each node id, the gen of the last state that has the node as
* a thread, and of the last state that walked through it. A state is
* built to the end before the states around it go on, and the nodes
* of a negated sub-pattern are only in its states (other than the
* match node, which is never marked). So one mark for each node is
* enough to know if the state being built has it. The Sims of a
* matcher never run at the same time, so they share one Marks.
*/
export type Marks = { has: Float64Array; seen: Float64Array; gen: number }
const marks = (size: number): Marks => ({
has: new Float64Array(size),
seen: new Float64Array(size),
gen: 0,
})
class Sim {
// `.` and `..` only match literal dots, even with `dot:true`
dots: boolean
// the string starts with `.`, and `dot:true` is not set
dotStart: boolean
#marks: Marks
constructor(dots: boolean, dotStart: boolean, marks: Marks) {
this.dots = dots
this.dotStart = dotStart
this.#marks = marks
}
state() {
return new State(++this.#marks.gen)
}
// sort the ids of a state, once it has all of its threads
done(state: State) {
state.ids = state.threads.map(n => n.id).sort((a, b) => a - b)
if (state.match) state.ids.unshift(MATCH.id)
return state
}
// true the first time that the state walks through the node, so
// that loops in the graph stop
#visit(state: State, node: Node) {
const { seen } = this.#marks
if (seen[node.id] === state.gen) return false
seen[node.id] = state.gen
return true
}
#addThread(state: State, node: Node) {
const { has } = this.#marks
if (has[node.id] === state.gen) return false
has[node.id] = state.gen
state.threads.push(node)
return true
}
// wildcards only match a leading dot if `dot:true`. In a negated
// sub-pattern, this does not apply, because the negation itself
// can not match a leading dot.
restricted(i: number, top: boolean) {
return top && (this.dots || (this.dotStart && i === 0))
}
add(state: State, node: Node, i: number, top: boolean): void {
switch (node.t) {
case 'split':
if (!this.#visit(state, node)) return
for (const o of node.out) this.add(state, o, i, top)
return
case 'neg':
if (!this.#visit(state, node)) return
const sub = this.state()
this.add(sub, node.sub, i, false)
this.done(sub)
return this.addRun(
state,
{ t: 'run', neg: node, state: sub },
i,
top,
)
case 'star':
// a * can not start a dotfile, even if it matches nothing
if (this.restricted(i, top)) return
if (this.#addThread(state, node))
this.add(state, node.next, i, top)
return
case 'match':
state.match = true
return
default:
this.#addThread(state, node)
}
}
addRun(state: State, run: Run, i: number, top: boolean) {
for (const r of state.runs) {
if (r.neg === run.neg && sameState(r.state, run.state)) return
}
state.runs.push(run)
if (!run.state.match) {
this.add(state, run.neg.next, i, top)
}
}
// the threads after char `c`, at index `i`
step(state: State, c: string, i: number, top: boolean): State {
const next = this.state()
for (const th of state.threads) {
switch (th.t) {
case 'lit':
if (litMatch(th, c)) {
this.add(next, th.next, i + 1, top)
}
break
case 'any':
if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top)
break
case 'class':
if (!this.restricted(i, top) && th.re.test(c)) {
this.add(next, th.next, i + 1, top)
}
break
case 'star':
if (!this.restricted(i, top)) this.add(next, th, i + 1, top)
}
}
if (!this.restricted(i, top)) {
for (const run of state.runs) {
// a sub-pattern with no threads can not match again, so the
// run stays the same
if (run.state.dead) {
this.addRun(next, run, i + 1, top)
continue
}
const sub = this.step(run.state, c, i, false)
this.addRun(
next,
{ t: 'run', neg: run.neg, state: sub },
i + 1,
top,
)
}
}
return this.done(next)
}
}
// A canonical key for the threads in a state. States with the same
// key hold the same threads, so they match the same strings.
const stateKey = (state: State): string => {
const ids = state.ids.join()
if (!state.runs.length) return ids
const runs = state.runs.map(r => `${r.neg.id}(${stateKey(r.state)})`)
return `${ids}|${runs.sort().join('|')}`
}
// A cached state of the simulation, and the states that each char
// leads to.
type DState = {
state: State
match: boolean
// no threads, so nothing more can match
dead: boolean
// the next state for each ASCII char, by char code, and for the
// other chars
ascii?: (DState | undefined)[]
next: Map<string, DState>
}
// The cache can hold about this many chars of state keys and
// transitions. When it is full, it is cleared, so that a pattern
// can not use an unbounded amount of memory.
const DFA_BUDGET = 1 << 18
// A cache of the states that the simulation reaches, built as the
// matcher is used. Each char of a string is then one Map lookup,
// once the states that it leads to are known.
//
// The dot rules only restrict the first char of a dotfile (strings
// that are only `.` or `..` do not use the cache). So a dotfile
// starts at its own state, which takes its first step with the
// restriction, and every other state takes steps without it.
class Dfa {
#start: Node
#states = new Map<string, DState>()
#size = 0
#plain?: DState
#dotStart?: DState
#sim: Sim
#dotSim: Sim
constructor(start: Node, marks: Marks) {
this.#start = start
this.#sim = new Sim(false, false, marks)
this.#dotSim = new Sim(false, true, marks)
}
#make(state: State): DState {
return {
state,
match: state.match,
dead: state.dead,
next: new Map(),
}
}
#intern(state: State): DState {
const key = stateKey(state)
const found = this.#states.get(key)
if (found) return found
if (this.#size > DFA_BUDGET) this.#clear()
const d = this.#make(state)
this.#states.set(key, d)
this.#size += key.length + 1
return d
}
#clear() {
this.#states.clear()
this.#size = 0
this.#plain = undefined
this.#dotStart = undefined
}
start(dotStart: boolean): DState {
if (dotStart) {
if (this.#dotStart) return this.#dotStart
const state = this.#dotSim.state()
this.#dotSim.add(state, this.#start, 0, true)
return (this.#dotStart = this.#make(this.#dotSim.done(state)))
}
if (this.#plain) return this.#plain
const state = this.#sim.state()
this.#sim.add(state, this.#start, 0, true)
return (this.#plain = this.#intern(this.#sim.done(state)))
}
// the next state, after a miss in `d.ascii`
next(d: DState, c: string): DState {
const code = c.charCodeAt(0)
const found = code < 128 ? undefined : d.next.get(c)
if (found) return found
// the dotfile start is not in the cache, so it is never shared
const n =
d === this.#dotStart ?
this.#intern(this.#dotSim.step(d.state, c, 0, true))
: this.#intern(this.#sim.step(d.state, c, 1, true))
if (code < 128) {
if (!d.ascii) {
d.ascii = new Array(128)
this.#size += 128
}
d.ascii[code] = n
} else {
d.next.set(c, n)
}
this.#size++
return n
}
}
/**
* A node in a graph with no splits or negations. Such a graph is a
* chain of nodes that each match one char, or a `*`.
*/
export type LinearNode = Exclude<
Node,
SplitNode | NegNode | { t: 'match' }
>
// the nodes in order, if the graph is a single chain
const linear = (start: Node): LinearNode[] | undefined => {
const nodes: LinearNode[] = []
for (let n = start; n.t !== 'match'; n = n.next) {
if (n.t === 'split' || n.t === 'neg') return undefined
nodes.push(n)
}
return nodes
}
// Match a chain of nodes. Each node other than `*` matches exactly
// one char, so on a failure it is enough to go back to the last `*`
// and let it match one more char. This takes at most
// nodes.length * chars.length steps.
const testLinear = (
nodes: LinearNode[],
chars: ArrayLike<string>,
start: number,
end: number,
) => {
let ni = 0
let ci = start
let starNi = -1
let starCi = 0
while (ci < end) {
const n = nodes[ni]
if (n?.t === 'star') {
starNi = ni++
starCi = ci
continue
}
const c = chars[ci]!
if (
n &&
(n.t === 'any' ||
(n.t === 'lit' && litMatch(n, c)) ||
(n.t === 'class' && n.re.test(c)))
) {
ni++
ci++
continue
}
if (starNi === -1) return false
ni = starNi + 1
ci = ++starCi
}
while (nodes[ni]?.t === 'star') ni++
return ni === nodes.length
}
// The least and most chars that the items can match. These are only
// bounds: a negation can match a string of any length, so it counts
// as 0 to Infinity.
const lengths = (items: Item[]): [min: number, max: number] => {
let min = 0
let max = 0
for (const it of items) {
const [lo, hi] = itemLengths(it)
min += lo
max += hi
}
return [min, max]
}
const itemLengths = (it: Item): [min: number, max: number] => {
if (it.t === 'star') return [0, Infinity]
if (it.t !== 'ext') return [1, 1]
if (it.type === '!') return [0, Infinity]
const alts = it.alts.map(lengths)
const min = Math.min(...alts.map(a => a[0]))
const max = Math.max(...alts.map(a => a[1]))
// a loop of alternatives that only match the empty string is empty
const loop = max === 0 ? 0 : Infinity
return (
it.type === '@' ? [min, max]
: it.type === '?' ? [0, max]
: it.type === '*' ? [0, loop]
: [min, loop]
)
}
// true if the chars from `start` match the literals
const hasAffix = (
lits: Lit[],
chars: ArrayLike<string>,
start: number,
) => {
for (let j = 0; j < lits.length; j++) {
if (!litMatch(lits[j]!, chars[start + j]!)) return false
}
return true
}
// a `/`, or half of a surrogate pair
const slashOrSurrogate = /[/\ud800-\udfff]/
const surrogate = /[\ud800-\udfff]/
// a string can be indexed by code point, unless it has surrogate
// pairs
const codePoints = (s: string): ArrayLike<string> =>
surrogate.test(s) ? [...s] : s
const noSlash = (s: string) => {
if (s.includes('/')) {
throw new Error('can only match a single path portion, got: ' + s)
}
}
export class Matcher {
pattern: string
options: MatcherOptions
#start: Node
// the number of node ids
#size: number
#marks?: Marks
// the Sim for strings that are only `.` or `..`
#dotsSim?: Sim
// the string to compare, if the pattern has no magic. With
// `nocase:true`, the RegExp that folds case is made when it is
// first used.
#literal?: string
#literalFold = false
#literalRe?: RegExp
// the nodes between the prefix and suffix, if the graph is a
// single chain
#linear?: LinearNode[]
// the linear nodes are only `*` and `?`, so the length bounds and
// the prefix and suffix decide the match
#wild = false
// the least and most chars that a match can have
#min = 0
#max = Infinity
// the literals that a match must start and end with. Each one
// matches exactly one char, and they are distinct items in the
// pattern, so a string that does not have them can not match.
#prefix: Lit[] = []
#suffix: Lit[] = []
// the prefix and suffix as strings, if they do not fold case
#prefixStr?: string
#suffixStr?: string
// there is a prefix or suffix to check
#affix = false
#dfa?: Dfa
#form?: Form
constructor(pattern: string, options: MatcherOptions = {}) {
if (pattern.includes('/')) {
throw new Error(
'can only match a single path portion, got pattern: ' + pattern,
)
}
this.pattern = pattern
this.options = options
const { nocase = false, noext = false, normalize: n } = options
this.#form = n === true ? 'NFC' : n || undefined
// a pattern that is only an empty extglob is a literal string,
// except for `!()`, which matches any non-empty string
const literal = /^[?*+@]\(\)$/.test(pattern)
const toks = tokenize(pattern, nocase, noext || literal, this.#form)
let [items] = build(toks, pair(toks), 0, toks.length, true)
if (this.#form) items = normalize(items!, this.#form)
const [start, size] = compile(items!, nocase)
this.#start = start
this.#size = size
if (items!.every(it => it.t === 'lit')) {
this.#literal = items!.map(it => it.ch).join('')
this.#literalFold = nocase
} else {
const lit = (it: Item): Lit | undefined =>
it.t !== 'lit' ? undefined
: nocase ? { ch: it.ch, re: foldRe(it.ch) }
: { ch: it.ch }
for (const it of items!) {
const l = lit(it)
if (!l) break
this.#prefix.push(l)
}
for (let j = items!.length - 1; j >= 0; j--) {
const l = lit(items![j]!)
if (!l) break
this.#suffix.unshift(l)
}
this.#affix = !!(this.#prefix.length || this.#suffix.length)
if (!nocase) {
this.#prefixStr = this.#prefix.map(l => l.ch).join('')
this.#suffixStr = this.#suffix.map(l => l.ch).join('')
}
this.#linear = linear(this.#start)?.slice(
this.#prefix.length,
-this.#suffix.length || undefined,
)
this.#wild = !!this.#linear?.every(
n => n.t === 'star' || n.t === 'any',
)
const [min, max] = lengths(items!)
this.#min = min
this.#max = max
}
}
test(s: string): boolean {
// The `/` check uses the string as given, so with normalization it
// is a separate step. Otherwise, one scan finds both a `/` and the
// surrogate pairs that stop the string being indexed by code point.
if (this.#form) {
noSlash(s)
return this.#test(s.normalize(this.#form))
}
if (slashOrSurrogate.test(s)) {
noSlash(s)
return this.#test(s, [...s])
}
return this.#test(s, s)
}
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s: string): boolean {
return this.#test(this.#form ? s.normalize(this.#form) : s)
}
// Test a string that has no `/`. `chars` indexes it by code point.
// If it is not given, it is only found if a step needs it.
#test(s: string, chars?: ArrayLike<string>): boolean {
if (this.#literal !== undefined) {
return this.#literalFold ?
(this.#literalRe ??= newFoldRe(this.#literal)).test(s)
: s === this.#literal
}
// the length check means that the prefix and suffix do not
// overlap. Without the chars, the length in code points is from
// half of the UTF-16 length (if each one is a surrogate pair) to
// all of it, which is often enough to know.
const min = this.#min
const max = this.#max
if (chars === undefined) {
const most = s.length
const least = (most + 1) >> 1
if (most < min || least > max) return false
if (least < min || most > max) chars = codePoints(s)
}
if (
chars !== undefined &&
(chars.length < min || chars.length > max)
) {
return false
}
const prefix = this.#prefix.length
if (this.#affix) {
if (this.#prefixStr !== undefined && this.#suffixStr !== undefined) {
if (
!s.startsWith(this.#prefixStr) ||
!s.endsWith(this.#suffixStr)
) {
return false
}
} else {
chars ??= codePoints(s)
const end = chars.length - this.#suffix.length
if (
!hasAffix(this.#prefix, chars, 0) ||
!hasAffix(this.#suffix, chars, end)
) {
return false
}
}
}
const dotStart = !this.options.dot && s.startsWith('.')
if (this.#linear) {
// `.` and `..` only match literal dots, even with `dot:true`
if (s === '.' || s === '..') return false
// only a literal can match the leading dot. A `*` can not
// start a dotfile, even if it matches nothing.
if (dotStart && !prefix) return false
if (this.#wild) return true
chars ??= codePoints(s)
const end = chars.length - this.#suffix.length
return testLinear(this.#linear, chars, prefix, end)
}
chars ??= codePoints(s)
if (s === '.' || s === '..') {
this.#marks ??= marks(this.#size)
const sim = (this.#dotsSim ??= new Sim(true, false, this.#marks))
const start = sim.state()
sim.add(start, this.#start, 0, true)
let state = sim.done(start)
for (let i = 0; i < chars.length; i++) {
state = sim.step(state, chars[i]!, i, true)
}
return state.match
}
this.#marks ??= marks(this.#size)
const dfa = (this.#dfa ??= new Dfa(this.#start, this.#marks))
let d = dfa.start(dotStart)
// read char codes from the string, so that a one-char string is
// only made for a cache miss
const str = chars === s
for (let i = 0; i < chars.length; i++) {
if (d.dead) return false
const code = str ? s.charCodeAt(i) : chars[i]!.charCodeAt(0)
d = d.ascii?.[code] ?? dfa.next(d, chars[i]!)
}
return d.match
}
/** a readable listing of the state machine */
toString(): string {
return show(this.#start)
}
}
@@ -0,0 +1,158 @@
// translate the various posix character classes into unicode properties
// this works across all unicode locales
// { <posix class>: [<translation>, negated]
const posixClasses: { [k: string]: [e: string, n?: boolean] } = {
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}'],
'[:alpha:]': ['\\p{L}\\p{Nl}'],
'[:ascii:]': ['\\x' + '00-\\x' + '7f'],
'[:blank:]': ['\\p{Zs}\\t'],
'[:cntrl:]': ['\\p{Cc}'],
'[:digit:]': ['\\p{Nd}'],
'[:graph:]': ['\\p{Z}\\p{C}', true],
'[:lower:]': ['\\p{Ll}'],
'[:print:]': ['\\p{C}', true],
'[:punct:]': ['\\p{P}\\p{S}'],
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f'],
'[:upper:]': ['\\p{Lu}'],
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}'],
'[:xdigit:]': ['A-Fa-f0-9'],
}
// only need to escape a few things inside of brace expressions
// escapes: [ \ ] -
const braceEscape = (s: string) => s.replace(/[[\]\\-]/g, '\\$&')
export type ParseClassResult = [re: RegExp, consumed: number]
export type Form = 'NFC' | 'NFD' | 'NFKC' | 'NFKD'
const noMatch = /$./
// Takes a glob string at a posix brace expression. Returns a RegExp
// that tests one character, and the number of glob chars consumed.
// If the class is not closed, consumed is 0, and the `[` must be
// treated as a literal character.
// Out of order ranges are removed. If nothing is left, the RegExp
// is `/$./`, and the rest of the glob is consumed, so that the
// whole glob cannot match.
export const parseClass = (
glob: string,
position: number,
nocase: boolean = false,
form?: Form,
): ParseClassResult => {
// normalize one class member, if it stays one code point
const norm = (c: string) => {
const n = form ? c.normalize(form) : c
return [...n].length === 1 ? n : c
}
const pos = position
/* c8 ignore start */
if (glob.charAt(pos) !== '[') {
throw new Error('not in a brace expression')
}
/* c8 ignore stop */
const ranges: string[] = []
const negs: string[] = []
let i = pos + 1
let sawStart = false
let escaping = false
let negate = false
let endPos = pos
let rangeStart = ''
WHILE: while (i < glob.length) {
const c = String.fromCodePoint(glob.codePointAt(i)!)
if ((c === '!' || c === '^') && i === pos + 1) {
negate = true
i++
continue
}
if (c === ']' && sawStart && !escaping) {
endPos = i + 1
break
}
sawStart = true
if (c === '\\') {
if (!escaping) {
escaping = true
i++
continue
}
// escaped \ char, fall through and treat like normal char
}
if (c === '[' && !escaping) {
// either a posix class, a collation equivalent, or just a [
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
if (glob.startsWith(cls, i)) {
// invalid, [a-[] is fine, but not [a-[:alpha]]
if (rangeStart) {
return [noMatch, glob.length - pos]
}
i += cls.length
if (neg) negs.push(unip)
else ranges.push(unip)
continue WHILE
}
}
}
// now it's just a normal character, effectively
escaping = false
const n = norm(c)
if (rangeStart) {
// throw this range away if it's not valid, but others
// can still match.
if (n.codePointAt(0)! > rangeStart.codePointAt(0)!) {
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n))
} else if (n === rangeStart) {
ranges.push(braceEscape(n))
}
rangeStart = ''
i += c.length
continue
}
// now might be the start of a range.
// can be either c-d or c-] or c<more...>] or c] at this point
if (glob.startsWith('-]', i + c.length)) {
ranges.push(braceEscape(n + '-'))
i += c.length + 1
continue
}
if (glob.startsWith('-', i + c.length)) {
rangeStart = n
i += c.length + 1
continue
}
// not the start of a range, just a single character
ranges.push(braceEscape(n))
i += c.length
}
if (endPos < i) {
// didn't see the end of the class, not a valid class,
// but might still be valid as a literal match.
return [noMatch, 0]
}
// if we got no ranges and no negates, then we have a range that
// cannot possibly match anything, and that poisons the whole glob
if (!ranges.length && !negs.length) {
return [noMatch, glob.length - pos]
}
const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']'
const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']'
const comb =
'^' +
(ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
: ranges.length ? sranges
: snegs)
return [new RegExp(comb, nocase ? 'iu' : 'u'), endPos - pos]
}
+17 -13
View File
@@ -37,6 +37,10 @@ This module provides the following parsers:
* [Text body parser](#bodyparsertextoptions) * [Text body parser](#bodyparsertextoptions)
* [URL-encoded form body parser](#bodyparserurlencodedoptions) * [URL-encoded form body parser](#bodyparserurlencodedoptions)
All parsers support automatic inflation of `gzip`, `br` (brotli), `deflate`
and `zstd` encodings. `zstd` is available in Node.js `^22.15.0` and
`>=23.8.0`.
Other body parsers you might be interested in: Other body parsers you might be interested in:
- [body](https://www.npmjs.com/package/body#readme) - [body](https://www.npmjs.com/package/body#readme)
@@ -65,6 +69,12 @@ The `bodyParser` object exposes various factories to create middlewares. All
middlewares will populate the `req.body` property with the parsed body when middlewares will populate the `req.body` property with the parsed body when
the `Content-Type` request header matches the `type` option. the `Content-Type` request header matches the `type` option.
**Note** As of v2, `req.body` is left `undefined` when no body is parsed (for
example when the request has neither `Content-Length` nor `Transfer-Encoding`,
or when `Content-Type` does not match). In v1, `req.body` was always initialized
to `{}`. Code that assumes `req.body` is always an object should use optional
chaining (for example `req.body?.username`) or set a default.
The various errors returned by this module are described in the The various errors returned by this module are described in the
[errors section](#errors). [errors section](#errors).
@@ -72,8 +82,7 @@ The various errors returned by this module are described in the
Returns middleware that only parses `json` and only looks at requests where Returns middleware that only parses `json` and only looks at requests where
the `Content-Type` header matches the `type` option. This parser accepts any the `Content-Type` header matches the `type` option. This parser accepts any
Unicode encoding of the body and supports automatic inflation of `gzip`, Unicode encoding of the body.
`br` (brotli) and `deflate` encodings.
A new `body` object containing the parsed data is populated on the `request` A new `body` object containing the parsed data is populated on the `request`
object after the middleware (i.e. `req.body`). object after the middleware (i.e. `req.body`).
@@ -110,7 +119,7 @@ argument. You can find more information on this argument
##### strict ##### strict
When set to `true`, will only accept arrays and objects; when `false` will When set to `true`, it will only accept arrays and objects; when `false`, it will
accept anything `JSON.parse` accepts. Defaults to `true`. accept anything `JSON.parse` accepts. Defaults to `true`.
##### type ##### type
@@ -133,9 +142,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
### bodyParser.raw([options]) ### bodyParser.raw([options])
Returns middleware that parses all bodies as a `Buffer` and only looks at Returns middleware that parses all bodies as a `Buffer` and only looks at
requests where the `Content-Type` header matches the `type` option. This requests where the `Content-Type` header matches the `type` option.
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
encodings.
A new `body` object containing the parsed data is populated on the `request` A new `body` object containing the parsed data is populated on the `request`
object after the middleware (i.e. `req.body`). This will be a `Buffer` object object after the middleware (i.e. `req.body`). This will be a `Buffer` object
@@ -181,9 +188,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
### bodyParser.text([options]) ### bodyParser.text([options])
Returns middleware that parses all bodies as a string and only looks at Returns middleware that parses all bodies as a string and only looks at
requests where the `Content-Type` header matches the `type` option. This requests where the `Content-Type` header matches the `type` option.
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
encodings.
A new `body` string containing the parsed data is populated on the `request` A new `body` string containing the parsed data is populated on the `request`
object after the middleware (i.e. `req.body`). This will be a string of the object after the middleware (i.e. `req.body`). This will be a string of the
@@ -234,8 +239,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
Returns middleware that only parses `urlencoded` bodies and only looks at Returns middleware that only parses `urlencoded` bodies and only looks at
requests where the `Content-Type` header matches the `type` option. This requests where the `Content-Type` header matches the `type` option. This
parser accepts only UTF-8 and ISO-8859-1 encodings of the body and supports parser accepts only UTF-8 and ISO-8859-1 encodings of the body.
automatic inflation of `gzip`, `br` (brotli) and `deflate` encodings.
A new `body` object containing the parsed data is populated on the `request` A new `body` object containing the parsed data is populated on the `request`
object after the middleware (i.e. `req.body`). This object will contain object after the middleware (i.e. `req.body`). This object will contain
@@ -346,7 +350,7 @@ the entity value that failed parsing.
### entity verify failed ### entity verify failed
This error will occur when the request contained an entity that could not be This error will occur when the request contained an entity that could not be
failed verification by the defined `verify` option. The `status` property is verified by the defined `verify` option. The `status` property is
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
`body` property is set to the entity value that failed verification. `body` property is set to the entity value that failed verification.
@@ -413,7 +417,7 @@ property is set to the encoding that is unsupported.
### The input exceeded the depth ### The input exceeded the depth
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown. This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. With the default `depth` of `32`, an input with 33 or more levels of nesting gets this error.
## Examples ## Examples
+75 -58
View File
@@ -17,7 +17,7 @@ const iconv = require('iconv-lite')
const onFinished = require('on-finished') const onFinished = require('on-finished')
const zlib = require('node:zlib') const zlib = require('node:zlib')
const hasBody = require('type-is').hasBody const hasBody = require('type-is').hasBody
const { getCharset } = require('./utils') const contentType = require('content-type')
/** /**
* Module exports. * Module exports.
@@ -25,6 +25,12 @@ const { getCharset } = require('./utils')
module.exports = read module.exports = read
/**
* @const
* whether current node version has zstandard support
*/
const hasZstandardSupport = 'createZstdDecompress' in zlib
/** /**
* Read a request into a buffer and parse. * Read a request into a buffer and parse.
* *
@@ -79,38 +85,53 @@ function read (req, res, next, parse, debug, options) {
} }
let length let length
const opts = options
let stream let stream
// read options const verify = options.verify
const verify = opts.verify
try { // assert charset is supported before creating the decompression stream, so an
// get the content stream // unsupported charset cannot leave a decoder piped with no error listener
stream = contentstream(req, debug, opts.inflate) if (verify && encoding !== null && !iconv.encodingExists(encoding)) {
length = stream.length
stream.length = undefined
} catch (err) {
return next(err)
}
// set raw-body options
opts.length = length
opts.encoding = verify
? null
: encoding
// assert charset is supported
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
charset: encoding.toLowerCase(), charset: encoding.toLowerCase(),
type: 'charset.unsupported' type: 'charset.unsupported'
})) }))
} }
try {
const contentEncoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
debug('content-encoding "%s"', contentEncoding)
if (options.inflate === false && contentEncoding !== 'identity') {
throw createError(415, 'content encoding unsupported', {
encoding: contentEncoding,
type: 'encoding.unsupported'
})
}
// get the content stream
if (contentEncoding === 'identity') {
length = req.headers['content-length']
stream = req
} else {
stream = createDecompressionStream(contentEncoding, debug)
req.pipe(stream)
}
} catch (err) {
return next(err)
}
// set raw-body options
const rawBodyOptions = {
length,
encoding: verify ? null : encoding,
limit: options.limit
}
// read body // read body
debug('read body') debug('read body')
getBody(stream, opts, function (error, body) { getBody(stream, rawBodyOptions, function (error, body) {
if (error) { if (error) {
let _error let _error
@@ -138,6 +159,17 @@ function read (req, res, next, parse, debug, options) {
return return
} }
// detach and destroy the decompression stream to
// avoid decompression errors on the finished stream
if (stream !== req) {
req.unpipe(stream)
stream.on('error', () => {})
stream.destroy()
// consume any remaining bytes so the HTTP request can finish
req.resume()
}
// verify // verify
if (verify) { if (verify) {
try { try {
@@ -145,7 +177,7 @@ function read (req, res, next, parse, debug, options) {
verify(req, res, body, encoding) verify(req, res, body, encoding)
} catch (err) { } catch (err) {
next(createError(403, err, { next(createError(403, err, {
body: body, body,
type: err.type || 'entity.verify.failed' type: err.type || 'entity.verify.failed'
})) }))
return return
@@ -172,38 +204,6 @@ function read (req, res, next, parse, debug, options) {
}) })
} }
/**
* Get the content stream of the request.
*
* @param {Object} req
* @param {Function} debug
* @param {boolean} inflate
* @returns {Object}
* @private
*/
function contentstream (req, debug, inflate) {
const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
const length = req.headers['content-length']
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content encoding unsupported', {
encoding: encoding,
type: 'encoding.unsupported'
})
}
if (encoding === 'identity') {
req.length = length
return req
}
const stream = createDecompressionStream(encoding, debug)
req.pipe(stream)
return stream
}
/** /**
* Create a decompression stream for the given encoding. * Create a decompression stream for the given encoding.
* @param {string} encoding * @param {string} encoding
@@ -222,12 +222,16 @@ function createDecompressionStream (encoding, debug) {
case 'br': case 'br':
debug('brotli decompress body') debug('brotli decompress body')
return zlib.createBrotliDecompress() return zlib.createBrotliDecompress()
default: case 'zstd':
if (hasZstandardSupport) {
debug('zstd decompress body')
return zlib.createZstdDecompress()
}
}
throw createError(415, 'unsupported content encoding "' + encoding + '"', { throw createError(415, 'unsupported content encoding "' + encoding + '"', {
encoding: encoding, encoding,
type: 'encoding.unsupported' type: 'encoding.unsupported'
}) })
}
} }
/** /**
@@ -245,3 +249,16 @@ function dump (req, callback) {
req.resume() req.resume()
} }
} }
/**
* Get the charset of a request.
*
* @param {Object} req
* @returns {string | undefined}
* @private
*/
function getCharset (req) {
const header = req.headers['content-type']
if (!header) return undefined
return contentType.parse(header).parameters.charset?.toLowerCase()
}
+8 -8
View File
@@ -23,7 +23,7 @@ const { normalizeOptions } = require('../utils')
module.exports = json module.exports = json
/** /**
* RegExp to match the first non-space in a string. * RegExp to match the first non-whitespace character in a string.
* *
* Allowed whitespace is defined in RFC 7159: * Allowed whitespace is defined in RFC 7159:
* *
@@ -33,7 +33,7 @@ module.exports = json
* %x0A / ; Line feed or New line * %x0A / ; Line feed or New line
* %x0D ) ; Carriage return * %x0D ) ; Carriage return
*/ */
const FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex const FIRST_NON_WHITESPACE_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d]|$)/ // eslint-disable-line no-control-regex
const JSON_SYNTAX_CHAR = '#' const JSON_SYNTAX_CHAR = '#'
const JSON_SYNTAX_REGEXP = /#+/g const JSON_SYNTAX_REGEXP = /#+/g
@@ -80,11 +80,13 @@ function createJsonParser (options) {
return {} return {}
} }
const first = firstchar(body) if (body[0] !== '{' && body[0] !== '[') {
const first = firstNonWhitespaceChar(body)
if (first !== '{' && first !== '[') { if (first !== '{' && first !== '[') {
debug('strict violation') debug('strict violation')
throw createStrictSyntaxError(body, first) throw createStrictSyntaxError(body, first)
} }
}
try { try {
debug('parse json') debug('parse json')
@@ -152,12 +154,10 @@ function createStrictSyntaxError (str, char) {
* @returns {string|undefined} * @returns {string|undefined}
* @private * @private
*/ */
function firstchar (str) { function firstNonWhitespaceChar (str) {
const match = FIRST_CHAR_REGEXP.exec(str) const match = FIRST_NON_WHITESPACE_REGEXP.exec(str)
return match return match && match[1] ? match[1] : undefined
? match[1]
: undefined
} }
/** /**
+5 -5
View File
@@ -98,12 +98,12 @@ function createQueryParser (options) {
try { try {
return qs.parse(body, { return qs.parse(body, {
allowPrototypes: true, allowPrototypes: true,
arrayLimit: arrayLimit, arrayLimit,
depth: depth, depth,
charsetSentinel: charsetSentinel, charsetSentinel,
interpretNumericEntities: interpretNumericEntities, interpretNumericEntities,
charset: encoding, charset: encoding,
parameterLimit: parameterLimit, parameterLimit,
strictDepth: true strictDepth: true
}) })
} catch (err) { } catch (err) {
-15
View File
@@ -5,31 +5,16 @@
*/ */
const bytes = require('bytes') const bytes = require('bytes')
const contentType = require('content-type')
const typeis = require('type-is') const typeis = require('type-is')
/** /**
* Module exports. * Module exports.
*/ */
module.exports = { module.exports = {
getCharset,
normalizeOptions, normalizeOptions,
passthrough passthrough
} }
/**
* Get the charset of a request.
*
* @param {Object} req
* @returns {string | undefined}
* @private
*/
function getCharset (req) {
const header = req.headers['content-type']
if (!header) return undefined
return contentType.parse(header).parameters.charset?.toLowerCase()
}
/** /**
* Get the simple type checker. * Get the simple type checker.
* *
+7 -12
View File
@@ -1,7 +1,7 @@
{ {
"name": "body-parser", "name": "body-parser",
"description": "Node.js body parsing middleware", "description": "Node.js body parsing middleware",
"version": "2.3.0", "version": "2.4.0",
"contributors": [ "contributors": [
"Douglas Christopher Wilson <[email protected]>", "Douglas Christopher Wilson <[email protected]>",
"Jonathan Ong <[email protected]> (http://jongleberry.com)" "Jonathan Ong <[email protected]> (http://jongleberry.com)"
@@ -27,26 +27,21 @@
}, },
"dependencies": { "dependencies": {
"bytes": "^3.1.2", "bytes": "^3.1.2",
"content-type": "^2.0.0", "content-type": "^2.1.0",
"debug": "^4.4.3", "debug": "^4.4.3",
"http-errors": "^2.0.1", "http-errors": "^2.0.1",
"iconv-lite": "^0.7.2", "iconv-lite": "^0.7.3",
"on-finished": "^2.4.1", "on-finished": "^2.4.1",
"qs": "^6.15.2", "qs": "^6.16.1",
"raw-body": "^3.0.2", "raw-body": "^3.0.2",
"type-is": "^2.1.0" "type-is": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.57.1", "eslint": "^9.39.5",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.6.0",
"eslint-plugin-standard": "^4.1.0",
"mocha": "^11.7.6", "mocha": "^11.7.6",
"neostandard": "^0.13.0",
"nyc": "^17.1.0", "nyc": "^17.1.0",
"supertest": "^7.2.2" "supertest": "7.3.0"
}, },
"files": [ "files": [
"lib/", "lib/",
+124
View File
@@ -0,0 +1,124 @@
1.4.7 / 2024-10-08
==========
* deps: cookie@0.7.2
- Fix object assignment of `hasOwnProperty`
* deps: cookie@0.7.1
- Allow leading dot for domain
- Although not permitted in the spec, some users expect this to work and user agents ignore the leading dot according to spec
- Add fast path for `serialize` without options, use `obj.hasOwnProperty` when parsing
* deps: cookie@0.7.0
- perf: parse cookies ~10% faster
- fix: narrow the validation of cookies to match RFC6265
- fix: add `main` to `package.json` for rspack
* deps: cookie@0.6.0
- Add `partitioned` option
* deps: cookie@0.5.0
- Add `priority` option
- Fix `expires` option to reject invalid dates
- pref: improve default decode speed
- pref: remove slow string split in parse
* deps: cookie@0.4.2
- pref: read value only when assigning in parse
- pref: remove unnecessary regexp in parse
1.4.6 / 2021-11-16
==================
* deps: cookie@0.4.1
1.4.5 / 2020-03-14
==================
* deps: cookie@0.4.0
1.4.4 / 2019-02-12
==================
* perf: normalize `secret` argument only once
1.4.3 / 2016-05-26
==================
* deps: cookie@0.3.1
- perf: use for loop in parse
1.4.2 / 2016-05-20
==================
* deps: cookie@0.2.4
- perf: enable strict mode
- perf: use for loop in parse
- perf: use string concatenation for serialization
1.4.1 / 2016-01-11
==================
* deps: cookie@0.2.3
* perf: enable strict mode
1.4.0 / 2015-09-18
==================
* Accept array of secrets in addition to a single secret
* Fix `JSONCookie` to return `undefined` for non-string arguments
* Fix `signedCookie` to return `undefined` for non-string arguments
* deps: cookie@0.2.2
1.3.5 / 2015-05-19
==================
* deps: cookie@0.1.3
- Slight optimizations
1.3.4 / 2015-02-15
==================
* deps: cookie-signature@1.0.6
1.3.3 / 2014-09-05
==================
* deps: cookie-signature@1.0.5
1.3.2 / 2014-06-26
==================
* deps: cookie-signature@1.0.4
- fix for timing attacks
1.3.1 / 2014-06-17
==================
* actually export `signedCookie`
1.3.0 / 2014-06-17
==================
* add `signedCookie` export for single cookie unsigning
1.2.0 / 2014-06-17
==================
* export parsing functions
* `req.cookies` and `req.signedCookies` are now plain objects
* slightly faster parsing of many cookies
1.1.0 / 2014-05-12
==================
* Support for NodeJS version 0.8
* deps: cookie@0.1.2
- Fix for maxAge == 0
- made compat with expires field
- tweak maxAge NaN error message
1.0.1 / 2014-02-20
==================
* add missing dependencies
1.0.0 / 2014-02-15
==================
* Genesis from `connect`
+23
View File
@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2014 TJ Holowaychuk <[email protected]>
Copyright (c) 2015 Douglas Christopher Wilson <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+119
View File
@@ -0,0 +1,119 @@
# cookie-parser
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Build Status][ci-image]][ci-url]
[![Test Coverage][coveralls-image]][coveralls-url]
Parse `Cookie` header and populate `req.cookies` with an object keyed by the
cookie names. Optionally you may enable signed cookie support by passing a
`secret` string, which assigns `req.secret` so it may be used by other
middleware.
## Installation
```sh
$ npm install cookie-parser
```
## API
```js
var cookieParser = require('cookie-parser')
```
### cookieParser(secret, options)
Create a new cookie parser middleware function using the given `secret` and
`options`.
- `secret` a string or array used for signing cookies. This is optional and if
not specified, will not parse signed cookies. If a string is provided, this
is used as the secret. If an array is provided, an attempt will be made to
unsign the cookie with each secret in order.
- `options` an object that is passed to `cookie.parse` as the second option. See
[cookie](https://www.npmjs.org/package/cookie) for more information.
- `decode` a function to decode the value of the cookie
The middleware will parse the `Cookie` header on the request and expose the
cookie data as the property `req.cookies` and, if a `secret` was provided, as
the property `req.signedCookies`. These properties are name value pairs of the
cookie name to cookie value.
When `secret` is provided, this module will unsign and validate any signed cookie
values and move those name value pairs from `req.cookies` into `req.signedCookies`.
A signed cookie is a cookie that has a value prefixed with `s:`. Signed cookies
that fail signature validation will have the value `false` instead of the tampered
value.
In addition, this module supports special "JSON cookies". These are cookie where
the value is prefixed with `j:`. When these values are encountered, the value will
be exposed as the result of `JSON.parse`. If parsing fails, the original value will
remain.
### cookieParser.JSONCookie(str)
Parse a cookie value as a JSON cookie. This will return the parsed JSON value
if it was a JSON cookie, otherwise, it will return the passed value.
### cookieParser.JSONCookies(cookies)
Given an object, this will iterate over the keys and call `JSONCookie` on each
value, replacing the original value with the parsed value. This returns the
same object that was passed in.
### cookieParser.signedCookie(str, secret)
Parse a cookie value as a signed cookie. This will return the parsed unsigned
value if it was a signed cookie and the signature was valid. If the value was
not signed, the original value is returned. If the value was signed but the
signature could not be validated, `false` is returned.
The `secret` argument can be an array or string. If a string is provided, this
is used as the secret. If an array is provided, an attempt will be made to
unsign the cookie with each secret in order.
### cookieParser.signedCookies(cookies, secret)
Given an object, this will iterate over the keys and check if any value is a
signed cookie. If it is a signed cookie and the signature is valid, the key
will be deleted from the object and added to the new object that is returned.
The `secret` argument can be an array or string. If a string is provided, this
is used as the secret. If an array is provided, an attempt will be made to
unsign the cookie with each secret in order.
## Example
```js
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/', function (req, res) {
// Cookies that have not been signed
console.log('Cookies: ', req.cookies)
// Cookies that have been signed
console.log('Signed Cookies: ', req.signedCookies)
})
app.listen(8080)
// curl command that sends an HTTP request with two cookies
// curl http://127.0.0.1:8080 --cookie "Cho=Kim;Greet=Hello"
```
## License
[MIT](LICENSE)
[ci-image]: https://badgen.net/github/checks/expressjs/cookie-parser/master?label=ci
[ci-url]: https://github.com/expressjs/cookie-parser/actions?query=workflow%3Aci
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/cookie-parser/master
[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master
[npm-downloads-image]: https://badgen.net/npm/dm/cookie-parser
[npm-url]: https://npmjs.org/package/cookie-parser
[npm-version-image]: https://badgen.net/npm/v/cookie-parser
+182
View File
@@ -0,0 +1,182 @@
/*!
* cookie-parser
* Copyright(c) 2014 TJ Holowaychuk
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Module dependencies.
* @private
*/
var cookie = require('cookie')
var signature = require('cookie-signature')
/**
* Module exports.
* @public
*/
module.exports = cookieParser
module.exports.JSONCookie = JSONCookie
module.exports.JSONCookies = JSONCookies
module.exports.signedCookie = signedCookie
module.exports.signedCookies = signedCookies
/**
* Parse Cookie header and populate `req.cookies`
* with an object keyed by the cookie names.
*
* @param {string|array} [secret] A string (or array of strings) representing cookie signing secret(s).
* @param {Object} [options]
* @return {Function}
* @public
*/
function cookieParser (secret, options) {
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]
return function cookieParser (req, res, next) {
if (req.cookies) {
return next()
}
var cookies = req.headers.cookie
req.secret = secrets[0]
req.cookies = Object.create(null)
req.signedCookies = Object.create(null)
// no cookies
if (!cookies) {
return next()
}
req.cookies = cookie.parse(cookies, options)
// parse signed cookies
if (secrets.length !== 0) {
req.signedCookies = signedCookies(req.cookies, secrets)
req.signedCookies = JSONCookies(req.signedCookies)
}
// parse JSON cookies
req.cookies = JSONCookies(req.cookies)
next()
}
}
/**
* Parse JSON cookie string.
*
* @param {String} str
* @return {Object} Parsed object or undefined if not json cookie
* @public
*/
function JSONCookie (str) {
if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') {
return undefined
}
try {
return JSON.parse(str.slice(2))
} catch (err) {
return undefined
}
}
/**
* Parse JSON cookies.
*
* @param {Object} obj
* @return {Object}
* @public
*/
function JSONCookies (obj) {
var cookies = Object.keys(obj)
var key
var val
for (var i = 0; i < cookies.length; i++) {
key = cookies[i]
val = JSONCookie(obj[key])
if (val) {
obj[key] = val
}
}
return obj
}
/**
* Parse a signed cookie string, return the decoded value.
*
* @param {String} str signed cookie string
* @param {string|array} secret
* @return {String} decoded value
* @public
*/
function signedCookie (str, secret) {
if (typeof str !== 'string') {
return undefined
}
if (str.substr(0, 2) !== 's:') {
return str
}
var secrets = !secret || Array.isArray(secret)
? (secret || [])
: [secret]
for (var i = 0; i < secrets.length; i++) {
var val = signature.unsign(str.slice(2), secrets[i])
if (val !== false) {
return val
}
}
return false
}
/**
* Parse signed cookies, returning an object containing the decoded key/value
* pairs, while removing the signed key from obj.
*
* @param {Object} obj
* @param {string|array} secret
* @return {Object}
* @public
*/
function signedCookies (obj, secret) {
var cookies = Object.keys(obj)
var dec
var key
var ret = Object.create(null)
var val
for (var i = 0; i < cookies.length; i++) {
key = cookies[i]
val = obj[key]
dec = signedCookie(val, secret)
if (val !== dec) {
ret[key] = dec
delete obj[key]
}
}
return ret
}
@@ -0,0 +1,4 @@
support
test
examples
*.sock
@@ -0,0 +1,38 @@
1.0.6 / 2015-02-03
==================
* use `npm test` instead of `make test` to run tests
* clearer assertion messages when checking input
1.0.5 / 2014-09-05
==================
* add license to package.json
1.0.4 / 2014-06-25
==================
* corrected avoidance of timing attacks (thanks @tenbits!)
1.0.3 / 2014-01-28
==================
* [incorrect] fix for timing attacks
1.0.2 / 2014-01-28
==================
* fix missing repository warning
* fix typo in test
1.0.1 / 2013-04-15
==================
* Revert "Changed underlying HMAC algo. to sha512."
* Revert "Fix for timing attacks on MAC verification."
0.0.1 / 2010-01-03
==================
* Initial release
@@ -0,0 +1,42 @@
# cookie-signature
Sign and unsign cookies.
## Example
```js
var cookie = require('cookie-signature');
var val = cookie.sign('hello', 'tobiiscool');
val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
var val = cookie.sign('hello', 'tobiiscool');
cookie.unsign(val, 'tobiiscool').should.equal('hello');
cookie.unsign(val, 'luna').should.be.false;
```
## License
(The MIT License)
Copyright (c) 2012 LearnBoost &lt;tj@learnboost.com&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
/**
* Module dependencies.
*/
var crypto = require('crypto');
/**
* Sign the given `val` with `secret`.
*
* @param {String} val
* @param {String} secret
* @return {String}
* @api private
*/
exports.sign = function(val, secret){
if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string.");
if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
return val + '.' + crypto
.createHmac('sha256', secret)
.update(val)
.digest('base64')
.replace(/\=+$/, '');
};
/**
* Unsign and decode the given `val` with `secret`,
* returning `false` if the signature is invalid.
*
* @param {String} val
* @param {String} secret
* @return {String|Boolean}
* @api private
*/
exports.unsign = function(val, secret){
if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided.");
if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
var str = val.slice(0, val.lastIndexOf('.'))
, mac = exports.sign(str, secret);
return sha1(mac) == sha1(val) ? str : false;
};
/**
* Private
*/
function sha1(str){
return crypto.createHash('sha1').update(str).digest('hex');
}
@@ -0,0 +1,18 @@
{
"name": "cookie-signature",
"version": "1.0.6",
"description": "Sign and unsign cookies",
"keywords": ["cookie", "sign", "unsign"],
"author": "TJ Holowaychuk <[email protected]>",
"license": "MIT",
"repository": { "type": "git", "url": "https://github.com/visionmedia/node-cookie-signature.git"},
"dependencies": {},
"devDependencies": {
"mocha": "*",
"should": "*"
},
"scripts": {
"test": "mocha --require should --reporter spec"
},
"main": "index"
}
+45
View File
@@ -0,0 +1,45 @@
{
"name": "cookie-parser",
"description": "Parse HTTP request cookies",
"version": "1.4.7",
"author": "TJ Holowaychuk <[email protected]> (http://tjholowaychuk.com)",
"contributors": [
"Douglas Christopher Wilson <[email protected]>"
],
"license": "MIT",
"repository": "expressjs/cookie-parser",
"keywords": [
"cookie",
"middleware"
],
"dependencies": {
"cookie": "0.7.2",
"cookie-signature": "1.0.6"
},
"devDependencies": {
"eslint": "7.32.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.3.1",
"eslint-plugin-standard": "4.1.0",
"mocha": "9.2.1",
"nyc": "15.1.0",
"supertest": "6.1.6"
},
"files": [
"LICENSE",
"HISTORY.md",
"index.js"
],
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}
+14
View File
@@ -1,3 +1,17 @@
## [9.0.4](https://github.com/express-handlebars/express-handlebars/compare/v9.0.3...v9.0.4) (2026-10-28)
### Bug Fixes
* **deps:** update dependency glob to ^14.0.3 ([#1310](https://github.com/express-handlebars/express-handlebars/issues/1310)) ([8465d26](https://github.com/express-handlebars/express-handlebars/commit/8465d2605c29074b5fdd142d13387ef07d7e1b13))
## [9.0.3](https://github.com/express-handlebars/express-handlebars/compare/v9.0.2...v9.0.3) (2026-10-28)
### Bug Fixes
* **deps:** update dependency glob to v14 ([#1308](https://github.com/express-handlebars/express-handlebars/issues/1308)) ([5f11ed7](https://github.com/express-handlebars/express-handlebars/commit/5f11ed76713cfe700e10c6be3a4176152476f615))
## [9.0.2](https://github.com/express-handlebars/express-handlebars/compare/v9.0.1...v9.0.2) (2026-10-06) ## [9.0.2](https://github.com/express-handlebars/express-handlebars/compare/v9.0.1...v9.0.2) (2026-10-06)
+7 -7
View File
@@ -1,7 +1,7 @@
{ {
"name": "express-handlebars", "name": "express-handlebars",
"description": "A Handlebars view engine for Express which doesn't suck.", "description": "A Handlebars view engine for Express which doesn't suck.",
"version": "9.0.2", "version": "9.0.4",
"homepage": "https://github.com/express-handlebars/express-handlebars", "homepage": "https://github.com/express-handlebars/express-handlebars",
"keywords": [ "keywords": [
"express", "express",
@@ -21,10 +21,10 @@
"url": "https://github.com/express-handlebars/express-handlebars/issues" "url": "https://github.com/express-handlebars/express-handlebars/issues"
}, },
"engines": { "engines": {
"node": ">=22.23.3" "node": ">=22.23.4"
}, },
"dependencies": { "dependencies": {
"glob": "^13.0.6", "glob": "^14.0.3",
"graceful-fs": "^4.2.11", "graceful-fs": "^4.2.11",
"handlebars": "^4.7.10" "handlebars": "^4.7.10"
}, },
@@ -41,14 +41,14 @@
"@semantic-release/npm": "^13.2.0", "@semantic-release/npm": "^13.2.0",
"@semantic-release/release-notes-generator": "^14.1.1", "@semantic-release/release-notes-generator": "^14.1.1",
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^25.9.9", "@types/node": "^26.6.5",
"eslint": "^10.12.0", "eslint": "^10.13.0",
"globals": "^17.13.0", "globals": "^17.13.0",
"jest-cli": "^30.5.2", "jest-cli": "^30.5.2",
"semantic-release": "^25.0.9", "semantic-release": "^25.0.9",
"ts-jest": "^29.4.14", "ts-jest": "^29.4.15",
"typescript": "^6.0.3", "typescript": "^6.0.3",
"typescript-eslint": "^8.71.1" "typescript-eslint": "^8.72.1"
}, },
"release": { "release": {
"plugins": [ "plugins": [
+388 -214
View File
@@ -2,9 +2,10 @@
Match files using the patterns the shell uses. Match files using the patterns the shell uses.
The most correct and second fastest glob implementation in The safest ([no ReDoS](#redos-protection)), most correct, and
JavaScript. (See [**Comparison to Other JavaScript Glob second fastest glob implementation in JavaScript. (See
Implementations**](#comparisons-to-other-fnmatchglob-implementations) [**Comparison to Other JavaScript Glob
Implementations**](#comparison-to-other-javascript-glob-implementations)
at the bottom of this readme.) at the bottom of this readme.)
![a fun cartoon logo made of glob ![a fun cartoon logo made of glob
@@ -381,6 +382,17 @@ share the previously loaded cache.
- `noext` Do not match "extglob" patterns such as `+(a|b)`. - `noext` Do not match "extglob" patterns such as `+(a|b)`.
- `normalize` Normalize unicode in the pattern, and in the file
names that it is matched against, with this form: `'NFC'`,
`'NFD'`, `'NFKC'`, or `'NFKD'`. `true` means `'NFC'`. A char
such as `é` can be one code point, or `e` followed by a
combining accent, and some file systems (such as on macOS) can
give names in either form. This is passed to minimatch, so it
applies to the portions of the pattern with magic, and to the
`ignore` patterns. The portions of the pattern without magic
are looked up with path-scurry, which already compares the
names of the entries that it knows in their `'NFKD'` form.
- `nocase` Perform a case-insensitive match. This defaults to - `nocase` Perform a case-insensitive match. This defaults to
`true` on macOS and Windows systems, and `false` on all others. `true` on macOS and Windows systems, and `false` on all others.
@@ -391,9 +403,9 @@ share the previously loaded cache.
> `false` on case-insensitive file systems, then the walk may > `false` on case-insensitive file systems, then the walk may
> return more or less results than expected. > return more or less results than expected.
> >
> As a shortcut to avoid excessive `RegExp` creations, `Glob` > As a shortcut, `Glob` will use string portions as-is to
> will use string portions as-is to `readdir()` calls while doing > `readdir()` calls while doing its traversal, in place of making
> its traversal. If you are setting a `nocase: true` match on a > a case-insensitive matcher for each of them. If you are setting a `nocase: true` match on a
> file system that is in fact case sensitive, then this will > file system that is in fact case sensitive, then this will
> result in matches not being found that you might expect, > result in matches not being found that you might expect,
> because for example the pattern `Foo/*` will fail to read the > because for example the pattern `Foo/*` will fail to read the
@@ -440,6 +452,8 @@ share the previously loaded cache.
a glob pattern or array of glob patterns to exclude from a glob pattern or array of glob patterns to exclude from
matches. To ignore all children within a directory, as well matches. To ignore all children within a directory, as well
as the entry itself, append `'/**'` to the ignore pattern. as the entry itself, append `'/**'` to the ignore pattern.
Ignore patterns that start with `/` start at the same place as
other patterns that start with `/` (see the `root` option).
If an object is provided that has `ignored(path)` and/or If an object is provided that has `ignored(path)` and/or
`childrenIgnored(path)` methods, then these methods will be `childrenIgnored(path)` methods, then these methods will be
@@ -545,8 +559,8 @@ share the previously loaded cache.
'a/b/c/d/e/f', 'a/b/c/d/e/f',
// this pattern is more complicated! It must to various readdir() // this pattern is more complicated! It must to various readdir()
// calls and test the results against a regular expression, and that // calls and test the results against the pattern, and that is
// is certainly going to take a little bit longer. // certainly going to take a little bit longer.
// //
// So, later on, it encounters a match at 'a/b/c/d/e', but it's too // So, later on, it encounters a match at 'a/b/c/d/e', but it's too
// late to ignore a/b/c/d/e/f, because it's already been emitted. // late to ignore a/b/c/d/e/f, because it's already been emitted.
@@ -632,9 +646,8 @@ path separators (ie, `/` on all platforms, and `\` on Windows).
### Dots ### Dots
If a file or directory path portion has a `.` as the first If a file or directory path portion has a `.` as the first
character, then it will not match any glob pattern unless that character, then it will only match a portion of the pattern if a
pattern's corresponding path part also has a `.` as its first literal `.` in the pattern matches that first character.
character.
For example, the pattern `a/.*/c` would match the file at For example, the pattern `a/.*/c` would match the file at
`a/.b/c`. However the pattern `a/*/c` would not, because `*` does `a/.b/c`. However the pattern `a/*/c` would not, because `*` does
@@ -696,6 +709,28 @@ classes) style class patterns are supported and Unicode-aware,
but `[=c=]` (locale-specific character collation weight), and but `[=c=]` (locale-specific character collation weight), and
`[.symbol.]` (collating symbol), are not. `[.symbol.]` (collating symbol), are not.
Each portion of a pattern is matched by
[minimatch](https://github.com/isaacs/minimatch), with Bash 5 as
the reference, and patterns are never compiled to regular
expressions. These are the known differences from Bash:
- If `dot` is not set, a portion of a pattern can match a file
name that starts with `.` when extglobs before a literal `.`
match the empty string. For example, `@(|x).*` matches `.a`.
Bash does not match these dotfiles.
- If an extglob such as `?(a` is not closed, Bash matches the
whole pattern as a literal string. In this module, only the
`?(` is literal, and the rest of the pattern is still matched
as a glob.
- A pattern is split into portions on every `/`, including a `/`
inside an extglob, so `@(a|b/c)/*` has an extglob that is not
closed. Bash keeps the extglob whole, and drops each alternative
with a `/` in it, as no file name can contain a `/`. So in Bash,
`@(a|b/c)/*` is the same as `@(a)/*`.
- With `nocase`, case is folded with Unicode simple case folding,
one code point at a time. Bash uses the case functions of the C
library for the current locale.
### Repeated Slashes ### Repeated Slashes
Unlike Bash and zsh, repeated `/` are always coalesced into a Unlike Bash and zsh, repeated `/` are always coalesced into a
@@ -767,6 +802,56 @@ starts with `/`, then the traversal will run on the root of the
drive provided as the `cwd` option. (That is, it is the result of drive provided as the `cwd` option. (That is, it is the result of
`path.resolve('/')`.) `path.resolve('/')`.)
## ReDoS Protection
Many glob implementations make a regular expression from each
pattern. A pattern such as `a*a*a*a*a*a*a*a*a*a*a`, tested against
a name such as `aaaaaaaaaaaaaaaaaaaaaaaaaaaaab` that does not
match, can make a backtracking regular expression engine try each
way that the `*` characters can split the name. The time that
this takes grows exponentially with the length of the name, so a
pattern from an untrusted source can stop a process for minutes
or more. This is a Regular Expression Denial of Service (ReDoS).
This module never makes a regular expression from a pattern.
Each portion of a pattern between `/` characters that has magic
is matched by a `Matcher` from
[@isaacs/nonrecursive-glob-match](http://npm.im/@isaacs/nonrecursive-glob-match).
A `Matcher` is not a `RegExp`, and it does not backtrack. It tests
all of the ways that the pattern can match at the same time, in
one pass over the name, so no pattern can make it try the ways one
after another. The time to match a name grows no faster than its
length times the size of the portion of the pattern, for each
kind of pattern, including nested and negated extglobs such as
`+(a|*(b|!(c)))`. The pattern above matches or fails in about a
millisecond.
The only regular expressions that a `Matcher` uses are for `[...]`
classes and case folding, and each of them only tests one
character at a time, so they can not backtrack over a name.
These limits also apply:
- The states that a `Matcher` reaches are cached, so that names
are matched faster, but the cache has a fixed size. When it is
full, it is cleared.
- Brace expansion makes no more than `braceExpandMax` patterns
(10,000 by default), so a pattern such as `{1..1000000}` can not
use an unbounded amount of memory.
- A pattern can have at most 65,536 characters. A longer pattern
throws an error.
- An `ignore` pattern with many `**` portions that are not next to
each other is matched with a limit on how deeply minimatch
recurses (200 by default). Past that limit, a path is not
treated as a match, so that path is not ignored.
The time that a walk takes still depends on the file system. A
pattern such as `**` walks every directory under the `cwd`, so if
the patterns come from an untrusted source, set the `cwd` to the
folder that they can search, and use `maxDepth` and an abort
`signal` to limit the walk. Symbolic links to directories are not
followed by `**` unless the `follow` option is set.
## Race Conditions ## Race Conditions
Glob searching, by its very nature, is susceptible to race Glob searching, by its very nature, is susceptible to race
@@ -821,6 +906,10 @@ npm run test-regen
# run the benchmarks # run the benchmarks
npm run bench npm run bench
# run the benchmarks in a Docker container that is limited to 4
# CPUs and 8GB of memory, a few times, and print the medians
npm run bench:docker
# to profile javascript # to profile javascript
npm run prof npm run prof
``` ```
@@ -833,8 +922,8 @@ npm run prof
Bash pattern expansion semantics, and as fast as possible Bash pattern expansion semantics, and as fast as possible
within that constraint, _use this module_. within that constraint, _use this module_.
- If you are reasonably sure that the patterns you will encounter - If you are reasonably sure that the patterns you will encounter
are relatively simple, and want the absolutely fastest glob are relatively simple, and want the fastest sync glob matcher
matcher out there, _use [fast-glob](http://npm.im/fast-glob)_. out there, _use [fast-glob](http://npm.im/fast-glob)_.
- If you are reasonably sure that the patterns you will encounter - If you are reasonably sure that the patterns you will encounter
are relatively simple, and want the convenience of are relatively simple, and want the convenience of
automatically respecting `.gitignore` files, _use automatically respecting `.gitignore` files, _use
@@ -855,15 +944,17 @@ benefits and drawbacks.
Both have very nice APIs and are reasonably fast. Both have very nice APIs and are reasonably fast.
`fast-glob` is, as far as I am aware, the fastest glob `fast-glob` is, as far as I am aware, the fastest sync glob
implementation in JavaScript today. However, there are many implementation in JavaScript today. However, there are many
cases where the choices that `fast-glob` makes in pursuit of cases where the choices that `fast-glob` makes in pursuit of
speed mean that its results differ from the results returned by speed mean that its results differ from the results returned by
Bash and other sh-like shells, which may be surprising. Bash and other sh-like shells, which may be surprising.
In my testing, `fast-glob` is around 10-20% faster than this In the [benchmarks below](#benchmark-results), which walk over
module when walking over 200k files nested 4 directories 200k files nested 4 directories deep, the sync `fast-glob` takes
deep[1](#fn-webscale). However, there are some inconsistencies about 25% less time than this module, and the async `fast-glob`
takes about 5% more, for the patterns where they return the same
results[1](#fn-webscale). However, there are some inconsistencies
with Bash matching behavior that this module does not suffer with Bash matching behavior that this module does not suffer
from: from:
@@ -878,10 +969,12 @@ from:
- Extglob patterns are allowed to contain `/` characters. - Extglob patterns are allowed to contain `/` characters.
Globby exhibits all of the same pattern semantics as fast-glob, Globby exhibits all of the same pattern semantics as fast-glob,
(as it is a wrapper around fast-glob) and is slightly slower than (as it is a wrapper around fast-glob). In the benchmarks below,
node-glob (by about 10-20% in the benchmark test set, or in other the sync `globby` takes about 10% less time than this module, and
words, anywhere from 20-50% slower than fast-glob). However, it the async `globby` takes about 15% more, for the patterns where
adds some API conveniences that may be worth the costs. they return the same results. It takes about 10-20% more time
than `fast-glob`. However, it adds some API conveniences that may
be worth the costs.
- Support for `.gitignore` and other ignore files. - Support for `.gitignore` and other ignore files.
- Support for negated globs (ie, patterns starting with `!` - Support for negated globs (ie, patterns starting with `!`
@@ -908,296 +1001,377 @@ course.</small>
### Benchmark Results ### Benchmark Results
These are from `npm run bench:docker`, which runs the benchmarks
in a Linux Docker container that is limited to 4 CPUs and 8GB of
memory, with the test files in memory. Each time is the median of
3 runs, and includes starting node.
The first number is time, smaller is better. The first number is time, smaller is better.
The second number is the count of results returned. The second number is the count of results returned. The totals at
the end are over all of the patterns, including the ones where the
implementations return different results.
``` ```
--- pattern: '{0000,0,1111,1}/{0000,0,1111,1}/{0000,0,1111,1}/**' ---
~~ sync ~~
fast-glob sync 0m0.046s 1600
globby sync 0m0.050s 1600
fs.globSync 0m0.040s 1776
current globSync mjs 0m0.048s 1776
current glob syncStream 0m0.046s 1776
~~ async ~~
fast-glob async 0m0.047s 1600
globby async 0m0.053s 1600
fs.glob 0m0.054s 1776
current glob async mjs 0m0.050s 1776
current glob stream 0m0.051s 1776
--- pattern: '**' --- --- pattern: '**' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.598s 200364 fast-glob sync 0m0.340s 200002
node globby sync 0m0.765s 200364 globby sync 0m0.423s 200002
node current globSync mjs 0m0.683s 222656 fs.globSync 0m0.692s 222223
node current glob syncStream 0m0.649s 222656 current globSync mjs 0m0.437s 222223
current glob syncStream 0m0.408s 222223
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.350s 200364 fast-glob async 0m0.491s 200002
node globby async 0m0.509s 200364 globby async 0m0.569s 200002
node current glob async mjs 0m0.463s 222656 fs.glob 0m1.889s 222223
node current glob stream 0m0.411s 222656 current glob async mjs 0m0.464s 222223
current glob stream 0m0.442s 222223
--- pattern: '**/..' --- --- pattern: '**/..' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.486s 0 fast-glob sync 0m0.260s 0
node globby sync 0m0.769s 200364 globby sync 0m0.432s 200002
node current globSync mjs 0m0.564s 2242 fs.globSync 0m0.531s 2222
node current glob syncStream 0m0.583s 2242 current globSync mjs 0m0.351s 2222
current glob syncStream 0m0.347s 2222
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.283s 0 fast-glob async 0m0.381s 0
node globby async 0m0.512s 200364 globby async 0m0.569s 200002
node current glob async mjs 0m0.299s 2242 fs.glob 0m1.632s 2222
node current glob stream 0m0.312s 2242 current glob async mjs 0m0.373s 2222
current glob stream 0m0.366s 2222
--- pattern: './**/0/**/0/**/0/**/0/**/*.txt' --- --- pattern: './**/0/**/0/**/0/**/0/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.490s 10 fast-glob sync 0m0.263s 10
node globby sync 0m0.517s 10 globby sync 0m0.267s 10
node current globSync mjs 0m0.540s 10 fs.globSync 0m0.547s 10
node current glob syncStream 0m0.550s 10 current globSync mjs 0m0.335s 10
current glob syncStream 0m0.334s 10
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.290s 10 fast-glob async 0m0.374s 10
node globby async 0m0.296s 10 globby async 0m0.388s 10
node current glob async mjs 0m0.278s 10 fs.glob 0m1.676s 10
node current glob stream 0m0.302s 10 current glob async mjs 0m0.342s 10
current glob stream 0m0.340s 10
--- pattern: './**/[01]/**/[12]/**/[23]/**/[45]/**/*.txt' --- --- pattern: './**/[01]/**/[12]/**/[23]/**/[45]/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.500s 160 fast-glob sync 0m0.270s 160
node globby sync 0m0.528s 160 globby sync 0m0.269s 160
node current globSync mjs 0m0.556s 160 fs.globSync 0m0.588s 160
node current glob syncStream 0m0.573s 160 current globSync mjs 0m0.344s 160
current glob syncStream 0m0.348s 160
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.283s 160 fast-glob async 0m0.380s 160
node globby async 0m0.301s 160 globby async 0m0.401s 160
node current glob async mjs 0m0.306s 160 fs.glob 0m1.715s 160
node current glob stream 0m0.322s 160 current glob async mjs 0m0.346s 160
current glob stream 0m0.345s 160
--- pattern: './**/0/**/0/**/*.txt' --- --- pattern: './**/0/**/0/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.502s 5230 fast-glob sync 0m0.269s 5230
node globby sync 0m0.527s 5230 globby sync 0m0.276s 5230
node current globSync mjs 0m0.544s 5230 fs.globSync 0m0.555s 5230
node current glob syncStream 0m0.557s 5230 current globSync mjs 0m0.343s 5230
current glob syncStream 0m0.340s 5230
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.285s 5230 fast-glob async 0m0.381s 5230
node globby async 0m0.305s 5230 globby async 0m0.399s 5230
node current glob async mjs 0m0.304s 5230 fs.glob 0m1.662s 5230
node current glob stream 0m0.310s 5230 current glob async mjs 0m0.345s 5230
current glob stream 0m0.344s 5230
--- pattern: '**/*.txt' --- --- pattern: '**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.580s 200023 fast-glob sync 0m0.336s 200000
node globby sync 0m0.771s 200023 globby sync 0m0.425s 200000
node current globSync mjs 0m0.685s 200023 fs.globSync 0m0.697s 200000
node current glob syncStream 0m0.649s 200023 current globSync mjs 0m0.438s 200000
current glob syncStream 0m0.411s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.349s 200023 fast-glob async 0m0.489s 200000
node globby async 0m0.509s 200023 globby async 0m0.563s 200000
node current glob async mjs 0m0.427s 200023 fs.glob 0m1.866s 200000
node current glob stream 0m0.388s 200023 current glob async mjs 0m0.467s 200000
current glob stream 0m0.429s 200000
--- pattern: '{**/*.txt,**/?/**/*.txt,**/?/**/?/**/*.txt,**/?/**/?/**/?/**/*.txt,**/?/**/?/**/?/**/?/**/*.txt}' --- --- pattern: '{**/*.txt,**/?/**/*.txt,**/?/**/?/**/*.txt,**/?/**/?/**/?/**/*.txt,**/?/**/?/**/?/**/?/**/*.txt}' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.589s 200023 fast-glob sync 0m0.339s 200000
node globby sync 0m0.771s 200023 globby sync 0m0.428s 200000
node current globSync mjs 0m0.716s 200023 fs.globSync 0m1.093s 200000
node current glob syncStream 0m0.684s 200023 current globSync mjs 0m0.463s 200000
current glob syncStream 0m0.436s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.351s 200023 fast-glob async 0m0.485s 200000
node globby async 0m0.518s 200023 globby async 0m0.570s 200000
node current glob async mjs 0m0.462s 200023 fs.glob 0m2.303s 200000
node current glob stream 0m0.468s 200023 current glob async mjs 0m0.499s 200000
current glob stream 0m0.480s 200000
--- pattern: '**/5555/0000/*.txt' --- --- pattern: '**/5555/0000/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.496s 1000 fast-glob sync 0m0.265s 1000
node globby sync 0m0.519s 1000 globby sync 0m0.269s 1000
node current globSync mjs 0m0.539s 1000 fs.globSync 0m0.525s 1000
node current glob syncStream 0m0.567s 1000 current globSync mjs 0m0.356s 1000
current glob syncStream 0m0.360s 1000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.285s 1000 fast-glob async 0m0.375s 1000
node globby async 0m0.299s 1000 globby async 0m0.383s 1000
node current glob async mjs 0m0.305s 1000 fs.glob 0m1.592s 1000
node current glob stream 0m0.301s 1000 current glob async mjs 0m0.361s 1000
current glob stream 0m0.366s 1000
--- pattern: './**/0/**/../[01]/**/0/../**/0/*.txt' --- --- pattern: './**/0/**/../[01]/**/0/../**/0/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.484s 0 fast-glob sync 0m0.261s 0
node globby sync 0m0.507s 0 globby sync 0m0.263s 0
node current globSync mjs 0m0.577s 4880 fs.globSync 0m0.754s 4880
node current glob syncStream 0m0.586s 4880 current globSync mjs 0m0.351s 4880
current glob syncStream 0m0.350s 4880
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.280s 0 fast-glob async 0m0.363s 0
node globby async 0m0.298s 0 globby async 0m0.382s 0
node current glob async mjs 0m0.327s 4880 fs.glob 0m1.869s 4880
node current glob stream 0m0.324s 4880 current glob async mjs 0m0.370s 4880
current glob stream 0m0.367s 4880
--- pattern: '**/????/????/????/????/*.txt' --- --- pattern: '**/????/????/????/????/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.547s 100000 fast-glob sync 0m0.297s 100000
node globby sync 0m0.673s 100000 globby sync 0m0.349s 100000
node current globSync mjs 0m0.626s 100000 fs.globSync 0m0.681s 100000
node current glob syncStream 0m0.618s 100000 current globSync mjs 0m0.404s 100000
current glob syncStream 0m0.399s 100000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.315s 100000 fast-glob async 0m0.440s 100000
node globby async 0m0.414s 100000 globby async 0m0.484s 100000
node current glob async mjs 0m0.366s 100000 fs.glob 0m1.805s 100000
node current glob stream 0m0.345s 100000 current glob async mjs 0m0.418s 100000
current glob stream 0m0.413s 100000
--- pattern: './{**/?{/**/?{/**/?{/**/?,,,,},,,,},,,,},,,}/**/*.txt' --- --- pattern: './{**/?{/**/?{/**/?{/**/?,,,,},,,,},,,,},,,}/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.588s 100000 fast-glob sync 0m0.337s 200000
node globby sync 0m0.670s 100000 globby sync 0m0.427s 200000
node current globSync mjs 0m0.717s 200023 fs.globSync 0m1.264s 200000
node current glob syncStream 0m0.687s 200023 current globSync mjs 0m0.465s 200000
current glob syncStream 0m0.446s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.343s 100000 fast-glob async 0m0.491s 200000
node globby async 0m0.418s 100000 globby async 0m0.562s 200000
node current glob async mjs 0m0.519s 200023 fs.glob 0m2.508s 200000
node current glob stream 0m0.451s 200023 current glob async mjs 0m0.494s 200000
current glob stream 0m0.473s 200000
--- pattern: '**/!(0|9).txt' --- --- pattern: '**/!(0|9).txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.573s 160023 fast-glob sync 0m0.327s 160000
node globby sync 0m0.731s 160023 globby sync 0m0.404s 160000
node current globSync mjs 0m0.680s 180023 fs.globSync 0m0.687s 180000
node current glob syncStream 0m0.659s 180023 current globSync mjs 0m0.462s 180000
current glob syncStream 0m0.418s 180000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.345s 160023 fast-glob async 0m0.474s 160000
node globby async 0m0.476s 160023 globby async 0m0.552s 160000
node current glob async mjs 0m0.427s 180023 fs.glob 0m1.876s 180000
node current glob stream 0m0.388s 180023 current glob async mjs 0m0.465s 180000
current glob stream 0m0.436s 180000
--- pattern: './{*/**/../{*/**/../{*/**/../{*/**/../{*/**,,,,},,,,},,,,},,,,},,,,}/*.txt' --- --- pattern: './{*/**/../{*/**/../{*/**/../{*/**/../{*/**,,,,},,,,},,,,},,,,},,,,}/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.483s 0 fast-glob sync 0m0.262s 0
node globby sync 0m0.512s 0 globby sync 0m0.264s 0
node current globSync mjs 0m0.811s 200023 fs.globSync 0m0.933s 200000
node current glob syncStream 0m0.773s 200023 current globSync mjs 0m0.557s 200000
current glob syncStream 0m0.541s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.280s 0 fast-glob async 0m0.377s 0
node globby async 0m0.299s 0 globby async 0m0.414s 0
node current glob async mjs 0m0.617s 200023 fs.glob 0m2.135s 200000
node current glob stream 0m0.568s 200023 current glob async mjs 0m0.662s 200000
current glob stream 0m0.639s 200000
--- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/*.txt' --- --- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.485s 0 fast-glob sync 0m0.256s 0
node globby sync 0m0.507s 0 globby sync 0m0.262s 0
node current globSync mjs 0m0.759s 200023 fs.globSync 0m0.716s 200000
node current glob syncStream 0m0.740s 200023 current globSync mjs 0m0.519s 200000
current glob syncStream 0m0.494s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.281s 0 fast-glob async 0m0.363s 0
node globby async 0m0.297s 0 globby async 0m0.374s 0
node current glob async mjs 0m0.544s 200023 fs.glob 0m1.870s 200000
node current glob stream 0m0.464s 200023 current glob async mjs 0m0.565s 200000
current glob stream 0m0.542s 200000
--- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/*.txt' --- --- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.486s 0 fast-glob sync 0m0.259s 0
node globby sync 0m0.513s 0 globby sync 0m0.262s 0
node current globSync mjs 0m0.734s 200023 fs.globSync 0m0.725s 200000
node current glob syncStream 0m0.696s 200023 current globSync mjs 0m0.488s 200000
current glob syncStream 0m0.459s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.286s 0 fast-glob async 0m0.366s 0
node globby async 0m0.296s 0 globby async 0m0.379s 0
node current glob async mjs 0m0.506s 200023 fs.glob 0m1.878s 200000
node current glob stream 0m0.483s 200023 current glob async mjs 0m0.522s 200000
current glob stream 0m0.495s 200000
--- pattern: './0/**/../1/**/../2/**/../3/**/../4/**/../5/**/../6/**/../7/**/*.txt' --- --- pattern: './0/**/../1/**/../2/**/../3/**/../4/**/../5/**/../6/**/../7/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.060s 0 fast-glob sync 0m0.050s 0
node globby sync 0m0.074s 0 globby sync 0m0.055s 0
node current globSync mjs 0m0.067s 0 fs.globSync 0m1.134s 28970
node current glob syncStream 0m0.066s 0 current globSync mjs 0m0.290s 28970
current glob syncStream 0m0.287s 28970
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.060s 0 fast-glob async 0m0.055s 0
node globby async 0m0.075s 0 globby async 0m0.064s 0
node current glob async mjs 0m0.066s 0 fs.glob 0m1.745s 28970
node current glob stream 0m0.067s 0 current glob async mjs 0m0.307s 28970
current glob stream 0m0.301s 28970
--- pattern: './**/?/**/?/**/?/**/?/**/*.txt' --- --- pattern: './**/?/**/?/**/?/**/?/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.568s 100000 fast-glob sync 0m0.305s 100000
node globby sync 0m0.651s 100000 globby sync 0m0.353s 100000
node current globSync mjs 0m0.619s 100000 fs.globSync 0m0.750s 100000
node current glob syncStream 0m0.617s 100000 current globSync mjs 0m0.400s 100000
current glob syncStream 0m0.403s 100000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.332s 100000 fast-glob async 0m0.466s 100000
node globby async 0m0.409s 100000 globby async 0m0.513s 100000
node current glob async mjs 0m0.372s 100000 fs.glob 0m1.900s 100000
node current glob stream 0m0.351s 100000 current glob async mjs 0m0.415s 100000
current glob stream 0m0.412s 100000
--- pattern: '**/*/**/*/**/*/**/*/**' --- --- pattern: '**/*/**/*/**/*/**/*/**' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.603s 200113 fast-glob sync 0m0.371s 200000
node globby sync 0m0.798s 200113 globby sync 0m0.470s 200000
node current globSync mjs 0m0.730s 222137 fs.globSync 0m0.907s 220000
node current glob syncStream 0m0.693s 222137 current globSync mjs 0m0.476s 220000
current glob syncStream 0m0.452s 220000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.356s 200113 fast-glob async 0m0.526s 200000
node globby async 0m0.525s 200113 globby async 0m0.611s 200000
node current glob async mjs 0m0.508s 222137 fs.glob 0m2.094s 220000
node current glob stream 0m0.455s 222137 current glob async mjs 0m0.521s 220000
current glob stream 0m0.498s 220000
--- pattern: './**/*/**/*/**/*/**/*/**/*.txt' --- --- pattern: './**/*/**/*/**/*/**/*/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.622s 200000 fast-glob sync 0m0.367s 200000
node globby sync 0m0.792s 200000 globby sync 0m0.459s 200000
node current globSync mjs 0m0.722s 200000 fs.globSync 0m0.911s 200000
node current glob syncStream 0m0.695s 200000 current globSync mjs 0m0.481s 200000
current glob syncStream 0m0.454s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.369s 200000 fast-glob async 0m0.519s 200000
node globby async 0m0.527s 200000 globby async 0m0.596s 200000
node current glob async mjs 0m0.502s 200000 fs.glob 0m2.140s 200000
node current glob stream 0m0.481s 200000 current glob async mjs 0m0.508s 200000
current glob stream 0m0.483s 200000
--- pattern: '**/*.txt' --- --- pattern: '**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.588s 200023 fast-glob sync 0m0.336s 200000
node globby sync 0m0.771s 200023 globby sync 0m0.425s 200000
node current globSync mjs 0m0.684s 200023 fs.globSync 0m0.698s 200000
node current glob syncStream 0m0.658s 200023 current globSync mjs 0m0.437s 200000
current glob syncStream 0m0.430s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.352s 200023 fast-glob async 0m0.483s 200000
node globby async 0m0.516s 200023 globby async 0m0.565s 200000
node current glob async mjs 0m0.432s 200023 fs.glob 0m1.874s 200000
node current glob stream 0m0.384s 200023 current glob async mjs 0m0.462s 200000
current glob stream 0m0.468s 200000
--- pattern: './**/**/**/**/**/**/**/**/*.txt' --- --- pattern: './**/**/**/**/**/**/**/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.589s 200023 fast-glob sync 0m0.346s 200000
node globby sync 0m0.766s 200023 globby sync 0m0.442s 200000
node current globSync mjs 0m0.682s 200023 fs.globSync 0m0.721s 200000
node current glob syncStream 0m0.652s 200023 current globSync mjs 0m0.437s 200000
current glob syncStream 0m0.417s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.352s 200023 fast-glob async 0m0.522s 200000
node globby async 0m0.523s 200023 globby async 0m0.595s 200000
node current glob async mjs 0m0.436s 200023 fs.glob 0m1.892s 200000
node current glob stream 0m0.380s 200023 current glob async mjs 0m0.486s 200000
current glob stream 0m0.468s 200000
--- pattern: '**/*/*.txt' --- --- pattern: '**/*/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.592s 200023 fast-glob sync 0m0.343s 200000
node globby sync 0m0.776s 200023 globby sync 0m0.434s 200000
node current globSync mjs 0m0.691s 200023 fs.globSync 0m0.753s 200000
node current glob syncStream 0m0.659s 200023 current globSync mjs 0m0.448s 200000
current glob syncStream 0m0.446s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.357s 200023 fast-glob async 0m0.516s 200000
node globby async 0m0.513s 200023 globby async 0m0.576s 200000
node current glob async mjs 0m0.471s 200023 fs.glob 0m1.936s 200000
node current glob stream 0m0.424s 200023 current glob async mjs 0m0.492s 200000
current glob stream 0m0.465s 200000
--- pattern: '**/*/**/*.txt' --- --- pattern: '**/*/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.585s 200023 fast-glob sync 0m0.341s 200000
node globby sync 0m0.766s 200023 globby sync 0m0.429s 200000
node current globSync mjs 0m0.694s 200023 fs.globSync 0m0.772s 200000
node current glob syncStream 0m0.664s 200023 current globSync mjs 0m0.451s 200000
current glob syncStream 0m0.434s 200000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.350s 200023 fast-glob async 0m0.492s 200000
node globby async 0m0.514s 200023 globby async 0m0.565s 200000
node current glob async mjs 0m0.472s 200023 fs.glob 0m1.927s 200000
node current glob stream 0m0.424s 200023 current glob async mjs 0m0.480s 200000
current glob stream 0m0.447s 200000
--- pattern: '**/[0-9]/**/*.txt' --- --- pattern: '**/[0-9]/**/*.txt' ---
~~ sync ~~ ~~ sync ~~
node fast-glob sync 0m0.544s 100000 fast-glob sync 0m0.307s 100000
node globby sync 0m0.636s 100000 globby sync 0m0.347s 100000
node current globSync mjs 0m0.626s 100000 fs.globSync 0m0.667s 100000
node current glob syncStream 0m0.621s 100000 current globSync mjs 0m0.393s 100000
current glob syncStream 0m0.396s 100000
~~ async ~~ ~~ async ~~
node fast-glob async 0m0.322s 100000 fast-glob async 0m0.458s 100000
node globby async 0m0.404s 100000 globby async 0m0.490s 100000
node current glob async mjs 0m0.360s 100000 fs.glob 0m1.894s 100000
node current glob stream 0m0.352s 100000 current glob async mjs 0m0.433s 100000
current glob stream 0m0.426s 100000
--- total of the medians ---
fast-glob sync (sync) 7.153s
globby sync (sync) 8.484s
fs.globSync (sync) 18.341s
current globSync mjs (sync) 10.174s
current glob syncStream (sync) 9.856s
fast-glob async (async) 10.314s
globby async (async) 11.617s
fs.glob (async) 45.732s
current glob async mjs (async) 10.847s
current glob stream (async) 10.496s
``` ```
+20 -11
View File
@@ -1,7 +1,9 @@
import type { Form } from 'minimatch';
import { Minimatch } from 'minimatch'; import { Minimatch } from 'minimatch';
import { Minipass } from 'minipass'; import type { Minipass } from 'minipass';
import { FSOption, Path, PathScurry } from 'path-scurry'; import type { FSOption, Path } from 'path-scurry';
import { IgnoreLike } from './ignore.js'; import { PathScurry } from 'path-scurry';
import type { IgnoreLike } from './ignore.js';
import { Pattern } from './pattern.js'; import { Pattern } from './pattern.js';
export type MatchSet = Minimatch['set']; export type MatchSet = Minimatch['set'];
export type GlobParts = Exclude<Minimatch['globParts'], undefined>; export type GlobParts = Exclude<Minimatch['globParts'], undefined>;
@@ -89,7 +91,7 @@ export interface GlobOptions {
* determine whether any Path is a match or if its children should be * determine whether any Path is a match or if its children should be
* traversed, respectively. * traversed, respectively.
*/ */
ignore?: string | string[] | IgnoreLike; readonly ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>;
/** /**
* Treat brace expansion like `{a,b}` as a "magic" pattern. Has no * Treat brace expansion like `{a,b}` as a "magic" pattern. Has no
* effect if {@link nobrace} is set. * effect if {@link nobrace} is set.
@@ -139,6 +141,18 @@ export interface GlobOptions {
* Do not match "extglob" patterns such as `+(a|b)`. * Do not match "extglob" patterns such as `+(a|b)`.
*/ */
noext?: boolean; noext?: boolean;
/**
* Normalize unicode in the pattern, and in the file names that it is
* matched against, with this form: `'NFC'`, `'NFD'`, `'NFKC'`, or
* `'NFKD'`. `true` means `'NFC'`. This is passed to minimatch, so it
* applies to the portions of the pattern with magic, and to the
* `ignore` patterns.
*
* The portions of the pattern without magic are looked up with
* path-scurry, which already compares the names of the entries
* that it knows in their `'NFKD'` form.
*/
normalize?: boolean | Form;
/** /**
* Do not match `**` against multiple filenames. (Ie, treat it as a normal * Do not match `**` against multiple filenames. (Ie, treat it as a normal
* `*` instead.) * `*` instead.)
@@ -232,11 +246,6 @@ export interface GlobOptions {
* http://npm.im/path-scurry for details about what can be overridden. * http://npm.im/path-scurry for details about what can be overridden.
*/ */
fs?: FSOption; fs?: FSOption;
/**
* Just passed along to Minimatch. Note that this makes all pattern
* matching operations slower and *extremely* noisy.
*/
debug?: boolean;
/** /**
* Return `/` delimited paths, even on Windows. * Return `/` delimited paths, even on Windows.
* *
@@ -324,7 +333,7 @@ export declare class Glob<Opts extends GlobOptions> implements GlobOptions {
dot: boolean; dot: boolean;
dotRelative: boolean; dotRelative: boolean;
follow: boolean; follow: boolean;
ignore?: string | string[] | IgnoreLike; ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>;
magicalBraces: boolean; magicalBraces: boolean;
mark?: boolean; mark?: boolean;
matchBase: boolean; matchBase: boolean;
@@ -334,7 +343,7 @@ export declare class Glob<Opts extends GlobOptions> implements GlobOptions {
nodir: boolean; nodir: boolean;
noext: boolean; noext: boolean;
noglobstar: boolean; noglobstar: boolean;
pattern: string[]; pattern: string[] | ReadonlyArray<string>;
platform: NodeJS.Platform; platform: NodeJS.Platform;
realpath: boolean; realpath: boolean;
scurry: PathScurry; scurry: PathScurry;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,UAAU,EAIX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;AACvC,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,CAAA;AAalE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OA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AAI,CAAC;IAczB;;OAEG;IACH,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAc9C;;OAEG;IACH,UAAU,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAclD;;;OAGG;IACH,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IAGlD,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;;OAGG;IACH,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IAGnD,CAAC,MAAM,CAAC,aAAa,CAAC;CAGvB"}
+8 -15
View File
@@ -97,23 +97,21 @@ class Glob {
if (this.withFileTypes && this.absolute !== undefined) { if (this.withFileTypes && this.absolute !== undefined) {
throw new Error('cannot set absolute and withFileTypes:true'); throw new Error('cannot set absolute and withFileTypes:true');
} }
if (typeof pattern === 'string') { let p = typeof pattern === 'string' ? [pattern] : pattern;
pattern = [pattern];
}
this.windowsPathsNoEscape = this.windowsPathsNoEscape =
!!opts.windowsPathsNoEscape || !!opts.windowsPathsNoEscape ||
opts.allowWindowsEscape === opts.allowWindowsEscape ===
false; false;
if (this.windowsPathsNoEscape) { if (this.windowsPathsNoEscape) {
pattern = pattern.map(p => p.replace(/\\/g, '/')); p = p.map(p => p.replace(/\\/g, '/'));
} }
if (this.matchBase) { if (this.matchBase) {
if (opts.noglobstar) { if (opts.noglobstar) {
throw new TypeError('base matching requires globstar'); throw new TypeError('base matching requires globstar');
} }
pattern = pattern.map(p => (p.includes('/') ? p : `./**/${p}`)); p = p.map(p => (p.includes('/') ? p : `./**/${p}`));
} }
this.pattern = pattern; this.pattern = p;
this.platform = opts.platform || defaultPlatform; this.platform = opts.platform || defaultPlatform;
this.opts = { ...opts, platform: this.platform }; this.opts = { ...opts, platform: this.platform };
if (opts.scurry) { if (opts.scurry) {
@@ -154,7 +152,6 @@ class Glob {
optimizationLevel: 2, optimizationLevel: 2,
platform: this.platform, platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape, windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug,
}; };
const mms = this.pattern.map(p => new minimatch_1.Minimatch(p, mmo)); const mms = this.pattern.map(p => new minimatch_1.Minimatch(p, mmo));
const [matchSet, globParts] = mms.reduce((set, m) => { const [matchSet, globParts] = mms.reduce((set, m) => {
@@ -176,8 +173,7 @@ class Glob {
// coerce them into the right shape. It will have already called // coerce them into the right shape. It will have already called
// realpath() if the option was set to do so, so we know that's cached. // realpath() if the option was set to do so, so we know that's cached.
// start out knowing the cwd, at least // start out knowing the cwd, at least
return [ return await new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...(await new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts, ...this.opts,
maxDepth: this.maxDepth !== Infinity ? maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth() this.maxDepth + this.scurry.cwd.depth()
@@ -185,12 +181,10 @@ class Glob {
platform: this.platform, platform: this.platform,
nocase: this.nocase, nocase: this.nocase,
includeChildMatches: this.includeChildMatches, includeChildMatches: this.includeChildMatches,
}).walk()), }).walk();
];
} }
walkSync() { walkSync() {
return [ return new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts, ...this.opts,
maxDepth: this.maxDepth !== Infinity ? maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth() this.maxDepth + this.scurry.cwd.depth()
@@ -198,8 +192,7 @@ class Glob {
platform: this.platform, platform: this.platform,
nocase: this.nocase, nocase: this.nocase,
includeChildMatches: this.includeChildMatches, includeChildMatches: this.includeChildMatches,
}).walkSync(), }).walkSync();
];
} }
stream() { stream() {
return new walker_js_1.GlobStream(this.patterns, this.scurry.cwd, { return new walker_js_1.GlobStream(this.patterns, this.scurry.cwd, {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/glob.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAEvD,uCAAwC;AACxC,6CAOoB;AAEpB,6CAAsC;AACtC,2CAAoD;AAKpD,4CAA4C;AAC5C,gDAAgD;AAChD,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,OAAO,CAAA;AAkWX;;GAEG;AACH,MAAa,IAAI;IACf,QAAQ,CAAU;IAClB,GAAG,CAAQ;IACX,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,WAAW,CAAS;IACpB,MAAM,CAAS;IACf,MAAM,CAAiC;IACvC,aAAa,CAAS;IACtB,IAAI,CAAU;IACd,SAAS,CAAS;IAClB,QAAQ,CAAQ;IAChB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,KAAK,CAAS;IACd,UAAU,CAAS;IACnB,OAAO,CAAU;IACjB,QAAQ,CAAiB;IACzB,QAAQ,CAAS;IACjB,MAAM,CAAY;IAClB,IAAI,CAAS;IACb,MAAM,CAAc;IACpB,oBAAoB,CAAS;IAC7B,aAAa,CAAiB;IAC9B,mBAAmB,CAAS;IAE5B;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,QAAQ,CAAW;IAEnB;;;;;;;;;;;OAWG;IACH,YAAY,OAA0B,EAAE,IAAU;QAChD,qBAAqB;QACrB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAA;QACvD,oBAAoB;QACpB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,aAAgC,CAAA;QAC5D,IAAI,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,EAAE,CAAC;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAA;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,qBAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QACxD,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CACtC,CAAC,GAA0B,EAAE,CAAC,EAAE,EAAE;YAChC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;YACrB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;YAC3B,OAAO,GAAG,CAAA;QACZ,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,CAAC,CACT,CAAA;QACD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,Line truncated
+1 -1
View File
@@ -1,4 +1,4 @@
import { GlobOptions } from './glob.js'; import type { GlobOptions } from './glob.js';
/** /**
* Return true if the patterns provided contain any magic glob characters, * Return true if the patterns provided contain any magic glob characters,
* given the options provided. * given the options provided.
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"has-magic.d.ts","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GACnB,SAAS,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAS,WAAgB,KACxB,OAQF,CAAA"} {"version":3,"file":"has-magic.d.ts","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GACnB,SAAS,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAS,WAAgB,KACxB,OAKF,CAAA"}
+1 -4
View File
@@ -14,10 +14,7 @@ const minimatch_1 = require("minimatch");
* is in the options, brace expansion _is_ treated as a pattern having magic. * is in the options, brace expansion _is_ treated as a pattern having magic.
*/ */
const hasMagic = (pattern, options = {}) => { const hasMagic = (pattern, options = {}) => {
if (!Array.isArray(pattern)) { for (const p of Array.isArray(pattern) ? pattern : [pattern]) {
pattern = [pattern];
}
for (const p of pattern) {
if (new minimatch_1.Minimatch(p, options).hasMagic()) if (new minimatch_1.Minimatch(p, options).hasMagic())
return true; return true;
} }
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"has-magic.js","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAGrC;;;;;;;;;;GAUG;AACI,MAAM,QAAQ,GAAG,CACtB,OAA0B,EAC1B,UAAuB,EAAE,EAChB,EAAE;IACX,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,IAAI,qBAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;YAAE,OAAO,IAAI,CAAA;IACvD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAXY,QAAA,QAAQ,YAWpB","sourcesContent":["import { Minimatch } from 'minimatch'\nimport { GlobOptions } from './glob.js'\n\n/**\n * Return true if the patterns provided contain any magic glob characters,\n * given the options provided.\n *\n * Brace expansion is not considered \"magic\" unless the `magicalBraces` option\n * is set, as brace expansion just turns one string into an array of strings.\n * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and\n * `'xby'` both do not contain any magic glob characters, and it's treated the\n * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`\n * is in the options, brace expansion _is_ treated as a pattern having magic.\n */\nexport const hasMagic = (\n pattern: string | string[],\n options: GlobOptions = {},\n): boolean => {\n if (!Array.isArray(pattern)) {\n pattern = [pattern]\n }\n for (const p of pattern) {\n if (new Minimatch(p, options).hasMagic()) return true\n }\n return false\n}\n"]} {"version":3,"file":"has-magic.js","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAGrC;;;;;;;;;;GAUG;AACI,MAAM,QAAQ,GAAG,CACtB,OAA0B,EAC1B,UAAuB,EAAE,EAChB,EAAE;IACX,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,IAAI,IAAI,qBAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;YAAE,OAAO,IAAI,CAAA;IACvD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB","sourcesContent":["import { Minimatch } from 'minimatch'\nimport type { GlobOptions } from './glob.js'\n\n/**\n * Return true if the patterns provided contain any magic glob characters,\n * given the options provided.\n *\n * Brace expansion is not considered \"magic\" unless the `magicalBraces` option\n * is set, as brace expansion just turns one string into an array of strings.\n * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and\n * `'xby'` both do not contain any magic glob characters, and it's treated the\n * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`\n * is in the options, brace expansion _is_ treated as a pattern having magic.\n */\nexport const hasMagic = (\n pattern: string | string[],\n options: GlobOptions = {},\n): boolean => {\n for (const p of Array.isArray(pattern) ? pattern : [pattern]) {\n if (new Minimatch(p, options).hasMagic()) return true\n }\n return false\n}\n"]}
+16 -4
View File
@@ -1,6 +1,7 @@
import { Minimatch, MinimatchOptions } from 'minimatch'; import type { MinimatchOptions } from 'minimatch';
import { Path } from 'path-scurry'; import { Minimatch } from 'minimatch';
import { GlobWalkerOpts } from './walker.js'; import type { Path } from 'path-scurry';
import type { GlobWalkerOpts } from './walker.js';
export interface IgnoreLike { export interface IgnoreLike {
ignored?: (p: Path) => boolean; ignored?: (p: Path) => boolean;
childrenIgnored?: (p: Path) => boolean; childrenIgnored?: (p: Path) => boolean;
@@ -16,7 +17,18 @@ export declare class Ignore implements IgnoreLike {
absoluteChildren: Minimatch[]; absoluteChildren: Minimatch[];
platform: NodeJS.Platform; platform: NodeJS.Platform;
mmopts: MinimatchOptions; mmopts: MinimatchOptions;
constructor(ignored: string[], { nobrace, nocase, noext, noglobstar, platform, }: GlobWalkerOpts); /**
* The escaped glob for the directory that a pattern starting with
* `/` is rooted at, with no trailing `/`.
*/
slashRoot: string;
/**
* Patterns that start with `/` (but not drive letters or UNC paths
* on Windows) start at the `root` option if it is set, or else at
* the root of `cwd`, the same as non-ignored patterns. If `cwd` is
* not provided, they start at `/`.
*/
constructor(ignored: string[], { nobrace, nocase, noext, noglobstar, normalize, platform, root, windowsPathsNoEscape, allowWindowsEscape, }: GlobWalkerOpts, cwd?: Path);
add(ign: string): void; add(ign: string): void;
ignored(p: Path): boolean; ignored(p: Path): boolean;
childrenIgnored(p: Path): boolean; childrenIgnored(p: Path): boolean;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAA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UAAU;IACvC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAA;IACzB,MAAM,EAAE,gBAAgB,CAAA;IACxB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EAAE,EACjB,EACE,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAA0B,EAC1B,IAAI,EACJ,oBAAoB,EACpB,kBAAkB,GACnB,EAAE,cAAc,EACjB,GAAG,CAAC,EAAE,IAAI;IA8BZ,GAAG,CAAC,GAAG,EAAE,MAAM;IA6Cf,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;IAczB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;CAWlC"}
+24 -4
View File
@@ -22,23 +22,40 @@ class Ignore {
absoluteChildren; absoluteChildren;
platform; platform;
mmopts; mmopts;
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform, }) { /**
* The escaped glob for the directory that a pattern starting with
* `/` is rooted at, with no trailing `/`.
*/
slashRoot;
/**
* Patterns that start with `/` (but not drive letters or UNC paths
* on Windows) start at the `root` option if it is set, or else at
* the root of `cwd`, the same as non-ignored patterns. If `cwd` is
* not provided, they start at `/`.
*/
constructor(ignored, { nobrace, nocase, noext, noglobstar, normalize, platform = defaultPlatform, root, windowsPathsNoEscape, allowWindowsEscape, }, cwd) {
this.relative = []; this.relative = [];
this.absolute = []; this.absolute = [];
this.relativeChildren = []; this.relativeChildren = [];
this.absoluteChildren = []; this.absoluteChildren = [];
this.platform = platform; this.platform = platform;
windowsPathsNoEscape =
!!windowsPathsNoEscape || allowWindowsEscape === false;
this.mmopts = { this.mmopts = {
dot: true, dot: true,
nobrace, nobrace,
nocase, nocase,
noext, noext,
noglobstar, noglobstar,
normalize,
optimizationLevel: 2, optimizationLevel: 2,
platform, platform,
nocomment: true, nocomment: true,
nonegate: true, nonegate: true,
windowsPathsNoEscape,
}; };
const slashRoot = cwd?.resolve(root ?? '/').fullpath() ?? '/';
this.slashRoot = (0, minimatch_1.escape)(slashRoot.replace(/\\/g, '/').replace(/\/$/, ''), { windowsPathsNoEscape });
for (const ign of ignored) for (const ign of ignored)
this.add(ign); this.add(ign);
} }
@@ -71,7 +88,10 @@ class Ignore {
} }
/* c8 ignore stop */ /* c8 ignore stop */
const p = new pattern_js_1.Pattern(parsed, globParts, 0, this.platform); const p = new pattern_js_1.Pattern(parsed, globParts, 0, this.platform);
const m = new minimatch_1.Minimatch(p.globString(), this.mmopts); const glob = p.root() === '/' ?
`${this.slashRoot}/${p.rest()?.globString() ?? ''}`
: p.globString();
const m = new minimatch_1.Minimatch(glob, this.mmopts);
const children = globParts[globParts.length - 1] === '**'; const children = globParts[globParts.length - 1] === '**';
const absolute = p.isAbsolute(); const absolute = p.isAbsolute();
if (absolute) if (absolute)
@@ -102,8 +122,8 @@ class Ignore {
return false; return false;
} }
childrenIgnored(p) { childrenIgnored(p) {
const fullpath = p.fullpath() + '/'; const fullpath = `${p.fullpath()}/`;
const relative = (p.relative() || '.') + '/'; const relative = `${p.relative() || '.'}/`;
for (const m of this.relativeChildren) { for (const m of this.relativeChildren) {
if (m.match(relative)) if (m.match(relative))
return true; return true;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,kEAAkE;AAClE,6CAA6C;;;AAE7C,yCAAuD;AAEvD,6CAAsC;AAStC,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;I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if the pattern ends in /**\n// Ignores are always parsed in dot:true mode\n\nimport { Minimatch, MinimatchOptions } from 'minimatch'\nimport { Path } from 'path-scurry'\nimport { Pattern } from './pattern.js'\nimport { GlobWalkerOpts } from './walker.js'\n\nexport interface IgnoreLike {\n ignored?: (p: Path) => boolean\n childrenIgnored?: (p: Path) => boolean\n add?: (ignore: string) => void\n}\n\nconst defaultPlatform: NodeJS.Platform =\n (\n typeof process === 'object' &&\n process &&\n typeof process.platform === 'string'\n ) ?\n process.platform\n : 'linux'\n\n/**\n * Class used to process ignored patterns\n */\nexport class Ignore implements IgnoreLike {\n relative: Minimatch[]\n relativeChildren: Minimatch[]\n absolute: Minimatch[]\n absoluteChildren: Minimatch[]\n platform: NodeJS.Platform\n mmopts: MinimatchOptions\n\n constructor(\n ignored: string[],\n {\n nobrace,\n nocase,\n noext,\n noglobstar,\n platform = defaultPlatform,\n }: GlobWalkerOpts,\n ) {\n this.relative = []\n this.absolute = []\n this.relativeChildren = []\n this.absoluteChildren = []\n this.platform = platform\n this.mmopts = {\n dot: true,\n nobrace,\n nocase,\n noext,\n noglobstar,\n optimizationLevel: 2,\n platform,\n nocomment: true,\n nonegate: true,\n }\n for (const ign of ignored) this.add(ign)\n }\n\n add(ign: string) {\n // this is a little weirdLine truncated {"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,kCAAkC;AAClC,kEAAkE;AAClE,6CAA6C;;;AAG7C,yCAA6C;AAE7C,6CAAsC;AAStC,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,OAAO,CAAA;AAEX;;GAEG;AACH,MAAa,MAAM;IACjB,QAAQ,CAAa;IACrB,gBAAgB,CAAa;IAC7B,QAAQ,CAAa;IACrB,gBAAgB,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,CAAC,QAAQ,EAAE,GAAG,CAAA;QACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,GAAG,GAAG,CAAA;QAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AApID,wBAoIC","sourcesContent":["// give it a pattern, and it'll be able to tell you if\n// a given path should be ignored.\n// Ignoring a path ignores its children if the pattern ends in /**\n// Ignores are always parsed in dot:true mode\n\nimport type { MinimatchOptions } from 'minimatch'\nimport { escape, Minimatch } from 'minimatch'\nimport type { Path } from 'path-scurry'\nimport { Pattern } from './pattern.js'\nimport type { GlobWalkerOpts } from './walker.js'\n\nexport interface IgnoreLike {\n ignored?: (p: Path) => boolean\n childrenIgnored?: (p: Path) => boolean\n add?: (ignore: string) => void\n}\n\nconst defaultPlatform: NodeJS.Platform =\n (\n typeof process === 'object' &&\n process &&\n typeof process.platform === 'string'\n ) ?\n process.platform\n : 'linux'\n\n/**\n * Class used to process ignored patterns\n */\nexport class Ignore implements IgnoreLike {\n relative: Minimatch[]\n relativeChildren: Minimatch[]\n absolute: Minimatch[]\n absoluteChildren: Minimatch[]\n platform: NodeJS.Platform\n mmopts: MinimatchLine truncated
+3 -2
View File
@@ -1,8 +1,9 @@
import { Minipass } from 'minipass'; import type { Minipass } from 'minipass';
import { Path } from 'path-scurry'; import type { Path } from 'path-scurry';
import type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset } from './glob.js'; import type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset } from './glob.js';
import { Glob } from './glob.js'; import { Glob } from './glob.js';
export { escape, unescape } from 'minimatch'; export { escape, unescape } from 'minimatch';
export type { Form } from 'minimatch';
export type { FSOption, Path, WalkOptions, WalkOptionsWithFileTypesTrue, WalkOptionsWithFileTypesUnset, } from 'path-scurry'; export type { FSOption, Path, WalkOptions, WalkOptionsWithFileTypesTrue, WalkOptionsWithFileTypesUnset, } from 'path-scurry';
export { Glob } from './glob.js'; export { Glob } from './glob.js';
export type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset, } from './glob.js'; export type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset, } from './glob.js';
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,KAAK,EACV,WAAW,EACX,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,YAAY,EACV,WAAW,EACX,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,O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unescape } from 'minimatch'\nimport { Minipass } from 'minipass'\nimport { Path } from 'path-scurry'\nimport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nimport { Glob } from './glob.js'\nimport { hasMagic } from './has-magic.js'\n\nexport { escape, unescape } from 'minimatch'\nexport type {\n FSOption,\n Path,\n WalkOptions,\n WalkOptionsWithFileTypesTrue,\n WalkOptionsWithFileTypesUnset,\n} from 'path-scurry'\nexport { Glob } from './glob.js'\nexport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nexport { hasMagic } from './has-magic.js'\nexport { Ignore } from './ignore.js'\nexport type { IgnoreLike } from './ignore.js'\nexport type { MatchStream } from './walker.js'\n\n/**\n * Syncronous form of {@link globStream}. Will read all the matches as fast as\n * you consume them, even all in a single tick if you consume them immediately,\n * but will still respond to backpressure if they're not consumed immediately.\n */\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesUnset,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).streamSync()\n}\n\n/**\n * Return a stream that emits all the strings or `Path` objects and\n * then emits `end` when completed.\n */\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStream(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).stream()\n}\n\n/**\n * Synchronous form of {@link glob}\n */\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Path[]\nexport function globSync(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobOptions,\n): Path[] | string[]\nexLine truncated {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAsDA,wCAKC;AAsBD,gCAKC;AAqBD,4BAKC;AAkDD,0CAKC;AAqBD,kCAKC;AAjMD,yCAA4C;AAS5C,uCAAgC;AAChC,iDAAyC;AAEzC,uCAA4C;AAAnC,mGAAA,MAAM,OAAA;AAAE,qGAAA,QAAQ,OAAA;AASzB,qCAAgC;AAAvB,+FAAA,IAAI,OAAA;AAOb,+CAAyC;AAAhC,wGAAA,QAAQ,OAAA;AACjB,yCAAoC;AAA3B,mGAAA,MAAM,OAAA;AAyBf,SAAgB,cAAc,CAC5B,OAA0B,EAC1B,UAAuB,EAAE;IAEzB,OAAO,IAAI,cAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,UAAU,EAAE,CAAA;AAChD,CAAC;AAsBD,SAAgB,UAAU,CACxB,OAA0B,EAC1B,UAAuB,EAAE;IAEzB,OAAO,IAAI,cAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;AAC5C,CAAC;AAqBD,SAAgB,QAAQ,CACtB,OAA0B,EAC1B,UAAuB,EAAE;IAEzB,OAAO,IAAI,cAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC9C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;CACT,CAAC,CAAA;AACF,YAAI,CAAC,IAAI,GAAG,YAAI,CAAA","sourcesContent":["import { escape, unescape } from 'minimatch'\nimport type { Minipass } from 'minipass'\nimport type { Path } from 'path-scurry'\nimport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nimport { Glob } from './glob.js'\nimport { hasMagic } from './has-magic.js'\n\nexport { escape, unescape } from 'minimatch'\nexport type { Form } from 'minimatch'\nexport type {\n FSOption,\n Path,\n WalkOptions,\n WalkOptionsWithFileTypesTrue,\n WalkOptionsWithFileTypesUnset,\n} from 'path-scurry'\nexport { Glob } from './glob.js'\nexport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nexport { hasMagic } from './has-magic.js'\nexport { Ignore } from './ignore.js'\nexport type { IgnoreLike } from './ignore.js'\nexport type { MatchStream } from './walker.js'\n\n/**\n * Syncronous form of {@link globStream}. Will read all the matches as fast as\n * you consume them, even all in a single tick if you consume them immediately,\n * but will still respond to backpressure if they're not consumed immediately.\n */\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesUnset,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).streamSync()\n}\n\n/**\n * Return a stream that emits all the strings or `Path` objects and\n * then emits `end` when completed.\n */\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStream(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).stream()\n}\n\n/**\n * Synchronous form of {@link glob}\n */\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Path[]\nexport function globSync(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): string[]\nexport function globSync(\n pattern: string | string[],\nLine truncated
+2 -3
View File
@@ -1,4 +1,3 @@
"use strict";var R=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Ge=R(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.range=Y.balanced=void 0;var Gs=(n,t,e)=>{let s=n instanceof RegExp?Ie(n,e):n,i=t instanceof RegExp?Ie(t,e):t,r=s!==null&&i!=null&&(0,Y.range)(s,i,e);return r&&{start:r[0],end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+s.length,r[1]),post:e.slice(r[1]+i.length)}};Y.balanced=Gs;var Ie=(n,t)=>{let e=t.match(n);return e?e[0]:null},zs=(n,t,e)=>{let s,i,r,h,o,a=e.indexOf(n),l=e.indexOf(t,a+1),f=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;f>=0&&!o;){if(f===a)s.push(f),a=e.indexOf(n,f+1);else if(s.length===1){let c=s.pop();c!==void 0&&(o=[c,l])}else i=s.pop(),i!==void 0&&i<r&&(r=i,h=l),l=e.indexOf(t,f+1);f=a<l&&a>=0?a:l}s.length&&h!==void 0&&(o=[r,h])}return o};Y.range=zs});var Ke=R(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.EXPANSION_MAX=void 0;it.expand=ei;var ze=Ge(),Ue="\0SLASH"+Math.random()+"\0",$e="\0OPEN"+Math.random()+"\0",ue="\0CLOSE"+Math.random()+"\0",qe="\0COMMA"+Math.random()+"\0",He="\0PERIOD"+Math.random()+"\0",Us=new RegExp(Ue,"g"),$s=new RegExp($e,"g"),qs=new RegExp(ue,"g"),Hs=new RegExp(qe,"g"),Vs=new RegExp(He,"g"),Ks=/\\\\/g,Xs=/\\{/g,Ys=/\\}/g,Js=/\\,/g,Zs=/\\./g;it.EXPANSION_MAX=1e5;function ce(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function Qs(n){return n.replace(Ks,Ue).replace(Xs,$e).replace(Ys,ue).replace(Js,qe).replace(Zs,He)}function ti(n){return n.replace(Us,"\\").replace($s,"{").replace(qs,"}").replace(Hs,",").replace(Vs,".")}function Ve(n){if(!n)return[""];let t=[],e=(0,ze.balanced)("{","}",n);if(!e)return n.split(",");let{pre:s,body:i,post:r}=e,h=s.split(",");h[h.length-1]+="{"+i+"}";let o=Ve(r);return r.length&&(h[h.length-1]+=o.shift(),h.push.apply(h,o)),t.push.apply(t,h),t}function ei(n,t={}){if(!n)return[];let{max:e=it.EXPANSION_MAX}=t;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),ht(Qs(n),e,!0).map(ti)}function si(n){return"{"+n+"}"}function ii(n){return/^-?0\d/.test(n)}function ri(n,t){return n<=t}function ni(n,t){return n>=t}function ht(n,t,e){let s=[],i=(0,ze.balanced)("{","}",n);if(!i)return[n];let r=i.pre,h=i.post.length?ht(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let o=0;o<h.length&&o<t;o++){let a=r+"{"+i.body+"}"+h[o];s.push(a)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=o||a,f=i.body.indexOf(",")>=0;if(!l&&!f)return i.post.match(/,(?!,).*\}/)?(n=i.pre+"{"+i.body+ue+i.post,ht(n,t,!0)):[n];let c;if(l)c=i.body.split(/\.\./);else if(c=Ve(i.body),c.length===1&&c[0]!==void 0&&(c=ht(c[0],t,!1).map(si),c.length===1))return h.map(u=>i.pre+c[0]+u);let d;if(l&&c[0]!==void 0&&c[1]!==void 0){let u=ce(c[0]),m=ce(c[1]),p=Math.max(c[0].length,c[1].length),b=c.length===3&&c[2]!==void 0?Math.abs(ce(c[2])):1,w=ri;m<u&&(b*=-1,w=ni);let E=c.some(ii);d=[];for(let y=u;w(y,m);y+=b){let S;if(a)S=String.fromCharCode(y),S==="\\"&&(S="");else if(S=String(y),E){let B=p-S.length;if(B>0){let U=new Array(B+1).join("0");y<0?S="-"+U+S.slice(1):S=U+S}}d.push(S)}}else{d=[];for(let u=0;u<c.length;u++)d.push.apply(d,ht(c[u],t,!1))}for(let u=0;u<d.length;u++)for(let m=0;m<h.length&&s.length<t;m++){let p=r+d[u]+h[m];(!e||l||p)&&s.push(p)}}return s}});var Xe=R(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.assertValidPattern=void 0;var hi=1024*64,oi=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>hi)throw new TypeError("pattern is too long")};Ct.assertValidPattern=oi});var Je=R(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.parseClass=void 0;var ai={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ot=n=>n.replace(/[[\]\\-]/g,"\\$&"),li=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ye=n=>n.join(""),ci=(n,t)=>{let e=t;if(n.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=e+1,h=!1,o=!1,a=!1,l=!1,f=e,c="";t:for(;r<n.length;){let p=n.charAt(r);if((p==="!"||p==="^")&&r===e+1){l=!0,r++;continue}if(p==="]"&&h&&!a){f=r+1;break}if(h=!0,p==="\\"&&!a){a=!0,r++;continue}if(p==="["&&!a){for(let[b,[w,v,E]]of Object.entries(ai))if(n.startsWith(b,r)){if(c)return["$.",!1,n.length-e,!0];r+=b.length,E?i.push(w):s.push(w),o=o||v;continue t}}if(a=!1,c){p>c?s.push(ot(c)+"-"+ot(p)):p===c&&s.push(ot(p)),c="",r++;continue}if(n.startsWith("-]",r+1)){s.push(ot(p+"-")),r+=2;continue}if(n.startsWith("-",r+1)){c=p,r+=2;continue}s.push(ot(p)),r++}if(f<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,n.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(sLine truncated "use strict";var x=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var ls=x(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.range=tt.balanced=void 0;var di=(n,t,e)=>{let s=n instanceof RegExp?as(n,e):n,i=t instanceof RegExp?as(t,e):t,r=s!==null&&i!=null&&(0,tt.range)(s,i,e);return r&&{start:r[0],end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+s.length,r[1]),post:e.slice(r[1]+i.length)}};tt.balanced=di;var as=(n,t)=>{let e=t.match(n);return e?e[0]:null},pi=(n,t,e)=>{let s,i,r,h,a,o=e.indexOf(n),l=e.indexOf(t,o+1),c=o;if(o>=0&&l>0){if(n===t)return[o,l];for(s=[],r=e.length;c>=0&&!a;){if(c===o)s.push(c),o=e.indexOf(n,c+1);else if(s.length===1){let u=s.pop();u!==void 0&&(a=[u,l])}else i=s.pop(),i!==void 0&&i<r&&(r=i,h=l),l=e.indexOf(t,c+1);c=o<l&&o>=0?o:l}s.length&&h!==void 0&&(a=[r,h])}return a};tt.range=pi});var ms=x(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.EXPANSION_MAX_REWRITES=T.EXPANSION_MAX_DEPTH=T.EXPANSION_MAX_LENGTH=T.EXPANSION_MAX=void 0;T.expand=Mi;var cs=ls(),us="\0SLASH"+Math.random()+"\0",fs="\0OPEN"+Math.random()+"\0",ve="\0CLOSE"+Math.random()+"\0",ds="\0COMMA"+Math.random()+"\0",ps="\0PERIOD"+Math.random()+"\0",mi=new RegExp(us,"g"),gi=new RegExp(fs,"g"),wi=new RegExp(ve,"g"),bi=new RegExp(ds,"g"),yi=new RegExp(ps,"g"),Si=/\\\\/g,vi=/\\{/g,_i=/\\}/g,Ei=/\\,/g,Oi=/\\\./g;T.EXPANSION_MAX=1e5;T.EXPANSION_MAX_LENGTH=4e6;T.EXPANSION_MAX_DEPTH=1e3;T.EXPANSION_MAX_REWRITES=1e3;function be(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function Ci(n){return n.replace(Si,us).replace(vi,fs).replace(_i,ve).replace(Ei,ds).replace(Oi,ps)}function Ai(n){return n.replace(mi,"\\").replace(gi,"{").replace(wi,"}").replace(bi,",").replace(yi,".")}function ye(n,t){for(let e=0;e<t.length;e++)n.push(t[e])}function ki(n){let t=[],e="";for(;;){let s=(0,cs.balanced)("{","}",n);if(!s){let o=n.split(",");return o[0]=e+o[0],ye(t,o),t}let{pre:i,body:r,post:h}=s,a=i.split(",");if(a[0]=e+a[0],a[a.length-1]+="{"+r+"}",!h.length)return ye(t,a),t;e=a.pop(),ye(t,a),n=h}}function Mi(n,t={}){if(!n)return[];let{max:e=T.EXPANSION_MAX,maxLength:s=T.EXPANSION_MAX_LENGTH,maxDepth:i=T.EXPANSION_MAX_DEPTH,maxRewrites:r=T.EXPANSION_MAX_REWRITES}=t;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),Se(Ci(n),e,s,i,0,r,!0).map(Ai)}function xi(n){return"{"+n+"}"}function Ri(n){return/^-?0\d/.test(n)}function Pi(n,t){return n<=t}function Ti(n,t){return n>=t}function lt(n,t,e,s,i,r){let h=[],a=0;for(let o=0;o<n.length;o++)for(let l=0;l<e.length;l++){if(h.length>=s)return h;let c=n[o]+t+e[l];if(!(r&&!c)){if(a+c.length>i)return h;h.push(c),a+=c.length}}return h}function Fi(n,t,e,s){let i=n.split(/\.\./),r=[];if(i[0]===void 0||i[1]===void 0)return r;let h=be(i[0]),a=be(i[1]),o=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(be(i[2])),1):1,c=Pi;a<h&&(l*=-1,c=Ti);let p=i.some(Ri),d=0;for(let g=h;c(g,a)&&r.length<e;g+=l){let f;if(t)f=String.fromCharCode(g),f==="\\"&&(f="");else if(f=String(g),p){let b=o-f.length;if(b>0){let m=new Array(b+1).join("0");g<0?f="-"+m+f.slice(1):f=m+f}}if(d+f.length>s)break;r.push(f),d+=f.length}return r}function Se(n,t,e,s,i,r,h){if(i>s)return[n];let a=[""],o=0,l=!1,c=!0;for(;;){let u=(0,cs.balanced)("{","}",n);if(!u)return lt(a,n,[""],t,e,l);let p=u.pre;if(/\$$/.test(p)){if(a=lt(a,p+"{"+u.body+"}",[""],t,e,l&&!u.post.length),c=!1,!u.post.length)break;n=u.post;continue}let d=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(u.body),g=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(u.body),f=d||g,b=u.body.indexOf(",")>=0;if(!f&&!b){if(o<r&&u.post.match(/,(?!,).*\}/)){o++,n=u.pre+"{"+u.body+ve+u.post,h=!0;continue}return lt(a,p+"{"+u.body+"}"+u.post,[""],t,e,l)}c&&(l=h&&!f,c=!1);let m;if(f)m=Fi(u.body,g,t,e);else{let y=ki(u.body);if(y.length===1&&y[0]!==void 0&&(y=Se(y[0],t,e,s,i+1,r,!1).map(xi),y.length===1)){if(a=lt(a,p+y[0],[""],t,e,l&&!u.post.length),!u.post.length)break;n=u.post;continue}let _=l&&!u.post.length&&!p;for(let S=0;_&&S<a.length;S++)a[S]&&(_=!1);m=[];let v=0;t:for(let S=0;S<y.length;S++){let K=Se(y[S],t,e,s,i+1,r,!1);for(let z=0;z<K.length;z++){let $=K[z];if(!(_&&!$)){if(m.length>=t||v+$.length>e)break t;m.push($),v+=$.length}}}}if(a=lt(a,p,m,t,e,l&&!u.post.length),!u.post.length)break;n=u.post}return a}});var gs=x(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.parseClass=void 0;var ji={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}"],"[:alpha:]":["\\p{L}\\p{Nl}"],"[:ascii:]":["\\x00-\\x7f"],"[:blank:]":["\\p{Zs}\\t"],"[:cntrl:]":["\\p{Cc}"],"[:digit:]":["\\p{Nd}"],"[:graph:]":["\\p{Z}\\p{C}",!0],"[:lower:]":["\\p{Ll}"],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}\\p{S}"],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f"],"[:upper:]":["\\p{Lu}"],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],"[:xdigit:]":["A-Fa-f0-9"]},ct=n=>n.replace(/[[\]\\-]/g,"\\$&"),_e=/$./,Di=(n,t,e=!1,s)=>{let i=m=>{let y=s?m.normalize(s):m;return[...y].length===1?y:m},r=t;if(n.charAt(r)!=="[")throw new Error("not in a brace Line truncated
globstar while`,t,d,e,u,m),this.matchOne(t.slice(d),e.slice(u),s))return this.debug("globstar found match!",d,a,m),!0;if(m==="."||m===".."||!i.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,d,e,u);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(s&&(this.debug(` `)},Ce=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(t){this.gen=t}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}},_s=(n,t)=>n.ids.length!==t.ids.length||n.runs.length!==t.runs.length||n.ids.some((e,s)=>e!==t.ids[s])?!1:n.runs.every(e=>t.runs.some(s=>s.neg===e.neg&&_s(s.state,e.state))),ws=n=>({has:new Float64Array(n),seen:new Float64Array(n),gen:0}),ut=class{dots;dotStart;#t;constructor(t,e,s){this.dots=t,this.dotStart=e,this.#t=s}state(){return new Ce(++this.#t.gen)}done(t){return t.ids=t.threads.map(e=>e.id).sort((e,s)=>e-s),t.match&&t.ids.unshift(Ee.id),t}#i(t,e){let{seen:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,!0)}#e(t,e){let{has:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,t.threads.push(e),!0)}restricted(t,e){return e&&(this.dots||this.dotStart&&t===0)}add(t,e,s,i){switch(e.t){case"split":if(!this.#i(t,e))return;for(let h of e.out)this.add(t,h,s,i);return;case"neg":if(!this.#i(t,e))return;let r=this.state();return this.add(r,e.sub,s,!1),this.done(r),this.addRun(t,{t:"run",neg:e,state:r},s,i);case"star":if(this.restricted(s,i))return;this.#e(t,e)&&this.add(t,e.next,s,i);return;case"match":t.match=!0;return;default:this.#e(t,e)}}addRun(t,e,s,i){for(let r of t.runs)if(r.neg===e.neg&&_s(r.state,e.state))return;t.runs.push(e),e.state.match||this.add(t,e.neg.next,s,i)}step(t,e,s,i){let r=this.state();for(let h of t.threads)switch(h.t){case"lit":Me(h,e)&&this.add(r,h.next,s+1,i);break;case"any":this.restricted(s,i)||this.add(r,h.next,s+1,i);break;case"class":!this.restricted(s,i)&&h.re.test(e)&&this.add(r,h.next,s+1,i);break;case"star":this.restricted(s,i)||this.add(r,h,s+1,i)}if(!this.restricted(s,i))for(let h of t.runs){if(h.state.dead){this.addRun(r,h,s+1,i);continue}let a=this.step(h.state,e,s,!1);this.addRun(r,{t:"run",neg:h.neg,state:a},s+1,i)}return this.done(r)}},Es=n=>{let t=n.ids.join();if(!n.runs.length)return t;let e=n.runs.map(s=>`${s.neg.id}(${Es(s.state)})`);return`${t}|${e.sort().join("|")}`},Ui=1<<18,Ae=class{#t;#i=new Map;#e=0;#h;#n;#d;#c;constructor(t,e){this.#t=t,this.#d=new ut(!1,!1,e),this.#c=new ut(!1,!0,e)}#p(t){return{state:t,match:t.match,dead:t.dead,next:new Map}}#o(t){let e=Es(t),s=this.#i.get(e);if(s)return s;this.#e>Ui&&this.#m();let i=this.#p(t);return this.#i.set(e,i),this.#e+=e.length+1,i}#m(){this.#i.clear(),this.#e=0,this.#h=void 0,this.#n=void 0}start(t){if(t){if(this.#n)return this.#n;let s=this.#c.state();return this.#c.add(s,this.#t,0,!0),this.#n=this.#p(this.#c.done(s))}if(this.#h)return this.#h;let e=this.#d.state();return this.#d.add(e,this.#t,0,!0),this.#h=this.#o(this.#d.done(e))}next(t,e){let s=e.charCodeAt(0),i=s<128?void 0:t.next.get(e);if(i)return i;let r=t===this.#n?this.#o(this.#c.step(t.state,e,0,!0)):this.#o(this.#d.step(t.state,e,1,!0));return s<128?(t.ascii||(t.ascii=new Array(128),this.#e+=128),t.ascii[s]=r):t.next.set(e,r),this.#e++,r}},$i=n=>{let t=[];for(let e=n;e.t!=="match";e=e.next){if(e.t==="split"||e.t==="neg")return;t.push(e)}return t},qi=(n,t,e,s)=>{let i=0,r=e,h=-1,a=0;for(;r<s;){let o=n[i];if(o?.t==="star"){h=i++,a=r;continue}let l=t[r];if(o&&(o.t==="any"||o.t==="lit"&&Me(o,l)||o.t==="class"&&o.re.test(l))){i++,r++;continue}if(h===-1)return!1;i=h+1,r=++a}for(;n[i]?.t==="star";)i++;return i===n.length},Os=n=>{let t=0,e=0;for(let s of n){let[i,r]=Hi(s);t+=i,e+=r}return[t,e]},Hi=n=>{if(n.t==="star")return[0,1/0];if(n.t!=="ext")return[1,1];if(n.type==="!")return[0,1/0];let t=n.alts.map(Os),e=Math.min(...t.map(r=>r[0])),s=Math.max(...t.map(r=>r[1])),i=s===0?0:1/0;return n.type==="@"?[e,s]:n.type==="?"?[0,s]:n.type==="*"?[0,i]:[e,i]},bs=(n,t,e)=>{for(let s=0;s<n.length;s++)if(!Me(n[s],t[e+s]))return!1;return!0},Xi=/[/\ud800-\udfff]/,Ki=/[\ud800-\udfff]/,Ft=n=>Ki.test(n)?[...n]:n,ys=n=>{if(n.includes("/"))throw new Error("can only match a single path portion, got: "+n)},ke=class{pattern;options;#t;#i;#e;#h;#n;#d;#c;#p=!1;#o=0;#m=1/0;#a=[];#l=[];#r;#w;#_=!1;#b;#u;constructor(t,e={}){if(t.includes("/"))throw new Error("can only match a single path portion, got pattern: "+t);this.pattern=t,this.options=e;let{nocase:s=!1,noext:i=!1,normalize:r}=e;this.#u=r===!0?"NFC":r||void 0;let h=/^[?*+@]\(\)$/.test(t),a=Bi(t,s,i||h,this.#u),[o]=Ss(a,zi(a),0,a.length,!0);this.#u&&(o=vs(o,this.#u));let[l,c]=Gi(o,s);if(this.#t=l,this.#i=c,o.every(u=>u.t==="lit"))this.#n=o.map(u=>u.ch).join(""),s&&(this.#d=Oe(this.#n));else{let u=g=>g.t!=="lit"?void 0:s?{ch:g.ch,re:Oe(g.ch)}:{ch:g.ch};for(let g of o){let f=u(g);if(!f)break;this.#a.push(f)}for(let g=o.length-1;g>=0;g--){let f=u(o[g]);if(!f)break;this.#l.unshift(f)}this.#_=!!(this.#a.length||this.#l.length),s||(this.#r=this.#a.map(g=>g.ch).join(""),this.#w=this.#l.map(g=>g.ch).join("")),this.#c=$i(this.#t)?.slice(this.#a.length,-this.#l.length||void 0),this.#p=!!this.#c?.every(g=>g.t==="star"||g.t==="any");let[p,d]=Os(o);this.#o=p,this.#m=d}}test(t){return this.#u?(ys(t),this.#v(t.normalize(this.#u))):Xi.test(t)?(ys(t),this.#v(t,[...t])):this.#v(t,t)}testUnchecked(t) Line truncated
>>> no match, partial?`,t,d,e,u),d===a))}let p;if(typeof f=="string"?(p=c===f,this.debug("string match",f,c,p)):(p=f.test(c),this.debug("pattern match",f,c,p)),!p)return!1}if(h===a&&o===l)return!0;if(h===a)return s;if(o===l)return h===a-1&&t[h]==="";throw new Error("wtf?")}braceExpand(){return(0,g.braceExpand)(this.pattern,this.options)}parse(t){(0,jt.assertValidPattern)(t);let e=this.options;if(t==="**")return g.GLOBSTAR;if(t==="")return"";let s,i=null;(s=t.match(Fi))?i=e.dot?Ni:ji:(s=t.match(Oi))?i=(e.nocase?e.dot?Ri:Ci:e.dot?Ti:xi)(s[1]):(s=t.match(Li))?i=(e.nocase?e.dot?Bi:Wi:e.dot?Ii:Gi)(s):(s=t.match(Ai))?i=e.dot?Mi:ki:(s=t.match(Pi))&&(i=Di);let r=is.AST.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Ui:e.dot?$i:qi,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(c=>{if(c instanceof RegExp)for(let d of c.flags.split(""))i.add(d);return typeof c=="string"?Ji(c):c===g.GLOBSTAR?g.GLOBSTAR:c._src});l.forEach((c,d)=>{let u=l[d+1],m=l[d-1];c!==g.GLOBSTAR||m===g.GLOBSTAR||(m===void 0?u!==void 0&&u!==g.GLOBSTAR?l[d+1]="(?:\\/|"+s+"\\/)?"+u:l[d]=s:u===void 0?l[d-1]=m+"(?:\\/|\\/"+s+")?":u!==g.GLOBSTAR&&(l[d-1]=m+"(?:\\/|\\/"+s+"\\/)"+u,l[d+1]=g.GLOBSTAR))});let f=l.filter(c=>c!==g.GLOBSTAR);if(this.partial&&f.length>=1){let c=[];for(let d=1;d<=f.length;d++)c.push(f.slice(0,d).join("/"));return"(?:"+c.join("|")+")"}return f.join("/")}).join("|"),[h,o]=t.length>1?["(?:",")"]:["",""];r="^"+h+r+o+"$",this.partial&&(r="^(?:\\/|"+h+r.slice(1,-1)+o+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let h=i[i.length-1];if(!h)for(let o=i.length-2;!h&&o>=0;o--)h=i[o];for(let o=0;o<r.length;o++){let a=r[o],l=i;if(s.matchBase&&a.length===1&&(l=[h]),this.matchOne(l,a,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return g.minimatch.defaults(t).Minimatch}};g.Minimatch=J;var Zi=pe();Object.defineProperty(g,"AST",{enumerable:!0,get:function(){return Zi.AST}});var Qi=me();Object.defineProperty(g,"escape",{enumerable:!0,get:function(){return Qi.escape}});var tr=kt();Object.defineProperty(g,"unescape",{enumerable:!0,get:function(){return tr.unescape}});g.minimatch.AST=is.AST;g.minimatch.Minimatch=J;g.minimatch.escape=vi.escape;g.minimatch.unescape=Ei.unescape});var fs=R(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.LRUCache=void 0;var er=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,as=new Set,ge=typeof process=="object"&&process?process:{},ls=(n,t,e,s)=>{typeof ge.emitWarning=="function"?ge.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},Lt=globalThis.AbortController,os=globalThis.AbortSignal;if(typeof Lt>"u"){os=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,s){this._onabort.push(s)}},Lt=class{constructor(){t()}signal=new os;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let s of this.signal._onabort)s(e);this.signal.onabort?.(e)}}};let n=ge.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,ls("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var sr=n=>!as.has(n),V=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),cs=n=>V(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Nt:null:null,Nt=class extends Array{constructor(n){super(n),this.fill(0)}},ir=class at{heap;length;static#t=!1;static create(t){let e=cs(t);if(!e)return[];at.#t=!0;let s=new at(t,e);return at.#t=!1,s}constructor(t,e){if(!at.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},rr=class us{#t;#s;#n;#r;#h;#S;#w;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDele Line truncated
//# sourceMappingURL=index.min.js.map //# sourceMappingURL=index.min.js.map
+4 -4
View File
@@ -1,7 +1,7 @@
{ {
"version": 3, "version": 3,
"sources": ["../../node_modules/balanced-match/src/index.ts", "../../node_modules/brace-expansion/src/index.ts", "../../node_modules/minimatch/src/assert-valid-pattern.ts", "../../node_modules/minimatch/src/brace-expressions.ts", "../../node_modules/minimatch/src/unescape.ts", "../../node_modules/minimatch/src/ast.ts", "../../node_modules/minimatch/src/escape.ts", "../../node_modules/minimatch/src/index.ts", "../../node_modules/lru-cache/src/index.ts", "../../node_modules/minipass/src/index.ts", "../../node_modules/path-scurry/src/index.ts", "../../src/pattern.ts", "../../src/ignore.ts", "../../src/processor.ts", "../../src/walker.ts", "../../src/glob.ts", "../../src/has-magic.ts", "../../src/index.ts"], "sources": ["../../node_modules/balanced-match/src/index.ts", "../../node_modules/brace-expansion/src/index.ts", "../../node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts", "../../node_modules/@isaacs/nonrecursive-glob-match/src/index.ts", "../../node_modules/minimatch/src/assert-valid-pattern.ts", "../../node_modules/minimatch/src/escape.ts", "../../node_modules/minimatch/src/unescape.ts", "../../node_modules/minimatch/src/index.ts", "../../node_modules/lru-cache/src/diagnostics-channel-node.ts", "../../node_modules/lru-cache/src/perf.ts", "../../node_modules/lru-cache/src/index.ts", "../../node_modules/minipass/src/index.ts", "../../node_modules/path-scurry/src/index.ts", "../../src/pattern.ts", "../../src/ignore.ts", "../../src/processor.ts", "../../src/walker.ts", "../../src/glob.ts", "../../src/has-magic.ts", "../../src/index.ts"],
"sourcesContent": ["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n", "import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n if (!str) {\n return ['']\n }\n\n const parts: string[] = []\n const m = balanced('{', '}', str)\n\n if (!m) {\n return str.split(',')\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n\n p[p.length - 1] += '{' + body + '}'\n const postParts = parseCommaParts(post)\n if (post.length) {\n ;(p[p.length - 1] as string) += postParts.shift()\n p.push.apply(p, postParts)\n }\n\n parts.push.apply(parts, p)\n\n return parts\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const { max = EXPANSION_MAX } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(escapeBraces(str), max, true).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\nfunction expand_(str: string, max: number, isTop: boolean): string[] {\n /** @type {string[]} */\n const expansions: string[] = []\n\n const m = balanced('{', '}', str)\n if (!m) return [str]\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n Line truncated "sourcesContent": ["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n", "import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\n// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An\n// input like `'{a,b}'.repeat(1500)` stays under that count - its output is\n// truncated to 100k results - while making every result ~1500 characters\n// long. The result set, and the intermediate arrays built while combining\n// brace sets, then grow large enough to exhaust memory and crash the process\n// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of\n// characters the accumulator may hold at any point, so memory stays flat no\n// matter how many brace groups are chained. The limit sits well above any\n// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M\n// characters) so legitimate input is unaffected.\nexport const EXPANSION_MAX_LENGTH = 4_000_000\n\n// `expand_` recurses once per level of brace *nesting* - both when expanding a\n// set's comma members and when re-wrapping a set whose body is a single part.\n// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one\n// level per chained group), which left nesting depth unbounded: about 3,100\n// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack\n// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser\n// will follow nesting. It sits far above any realistic pattern and well below\n// the depth at which the stack runs out.\nexport const EXPANSION_MAX_DEPTH = 1_000\n\n// Bash keeps a quirk where a brace group followed by a comma set still expands\n// (`{a},b}`). The parser implements it by rewriting the string and restarting\n// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`\n// full passes over a string that itself grows by one `escClose` sentinel each\n// time - quadratic in `n`, with a ~26x constant from the sentinel's length.\n// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27\n// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many\n// times the scan may restart. Real `{a},b}` input needs a handful.\nexport const EXPANSION_MAX_REWRITES = 1_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPatLine truncated
"mappings": "gLAAO,IAAMA,GAAW,CACtBC,EACAC,EACAC,IACE,CACF,IAAMC,EAAKH,aAAa,OAASI,GAAWJ,EAAGE,CAAG,EAAIF,EAChDK,EAAKJ,aAAa,OAASG,GAAWH,EAAGC,CAAG,EAAID,EAEhD,EAAIE,IAAO,MAAQE,GAAM,SAAQC,EAAA,OAAMH,EAAIE,EAAIH,CAAG,EAExD,OACE,GAAK,CACH,MAAO,EAAE,CAAC,EACV,IAAK,EAAE,CAAC,EACR,IAAKA,EAAI,MAAM,EAAG,EAAE,CAAC,CAAC,EACtB,KAAMA,EAAI,MAAM,EAAE,CAAC,EAAIC,EAAG,OAAQ,EAAE,CAAC,CAAC,EACtC,KAAMD,EAAI,MAAM,EAAE,CAAC,EAAIG,EAAG,MAAM,EAGtC,EAnBaC,EAAA,SAAQP,GAqBrB,IAAMK,GAAa,CAACG,EAAaL,IAAe,CAC9C,IAAMM,EAAIN,EAAI,MAAMK,CAAG,EACvB,OAAOC,EAAIA,EAAE,CAAC,EAAI,IACpB,EAEaC,GAAQ,CACnBT,EACAC,EACAC,IACgC,CAChC,IAAIQ,EACFC,EACAC,EACAC,EACAC,EACEC,EAAKb,EAAI,QAAQF,CAAC,EAClBgB,EAAKd,EAAI,QAAQD,EAAGc,EAAK,CAAC,EAC1BE,EAAIF,EAER,GAAIA,GAAM,GAAKC,EAAK,EAAG,CACrB,GAAIhB,IAAMC,EACR,MAAO,CAACc,EAAIC,CAAE,EAKhB,IAHAN,EAAO,CAAA,EACPE,EAAOV,EAAI,OAEJe,GAAK,GAAK,CAACH,GAAQ,CACxB,GAAIG,IAAMF,EACRL,EAAK,KAAKO,CAAC,EACXF,EAAKb,EAAI,QAAQF,EAAGiB,EAAI,CAAC,UAChBP,EAAK,SAAW,EAAG,CAC5B,IAAMQ,EAAIR,EAAK,IAAG,EACdQ,IAAM,SAAWJ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I,OAAO,aAAaxC,CAAC,EACrBwC,IAAM,OACRA,EAAI,YAGNA,EAAI,OAAOxC,CAAC,EACRuC,EAAK,CACP,IAAME,EAAOL,EAAQI,EAAE,OACvB,GAAIC,EAAO,EAAG,CACZ,IAAMC,EAAI,IAAI,MAAMD,EAAO,CAAC,EAAE,KAAK,GAAG,EAClCzC,EAAI,EACNwC,EAAI,IAAME,EAAIF,EAAE,MAAM,CAAC,EAEvBA,EAAIE,EAAIF,CAEZ,CACF,CAEF,GAAIb,EAASa,EAAE,OAAS5B,EAAW,MACnCsB,EAAE,KAAKM,CAAC,EACRb,GAAUa,EAAE,MACd,CACA,OAAON,CACT,CAEA,SAASnB,GACPrB,EACAiB,EACAC,EACAC,EACA8B,EACA7B,EACA8B,EAAc,CAKd,GAAID,EAAQ9B,EACV,MAAO,CAACnB,CAAG,EASb,IAAI6B,EAAgB,CAAC,EAAE,EAQnBsB,EAAW,EACXpB,EAAc,GACdqB,EAAa,GAEjB,OAAS,CACP,IAAM1C,KAAI3B,GAAA,UAAS,IAAK,IAAKiB,CAAG,Line truncated
"names": ["balanced", "a", "b", "str", "ma", "maybeMatch", "mb", "exports", "reg", "m", "range", "begs", "beg", "left", "right", "result", "ai", "bi", "i", "r", "exports", "expand", "balanced_match_1", "escSlash", "escOpen", "escClose", "escComma", "escPeriod", "escSlashPattern", "escOpenPattern", "escClosePattern", "escCommaPattern", "escPeriodPattern", "slashPattern", "openPattern", "closePattern", "commaPattern", "periodPattern", "numeric", "str", "escapeBraces", "unescapeBraces", "parseCommaParts", "parts", "m", "pre", "body", "post", "p", "postParts", "options", "max", "expand_", "embrace", "isPadded", "el", "lte", "i", "y", "gte", "isTop", "expansions", "k", "expansion", "isNumericSequence", "isAlphaSequence", "isSequence", "isOptions", "n", "N", "x", "width", "incr", "test", "pad", "c", "need", "z", "j", "MAX_PATTERN_LENGTH", "assertValidPattern", "pattern", "exports", "posixClasses", "braceEscape", "s", "regexpEscape", "rangesToString", "ranges", "parseClass", "glob", "position", "pos", "negs", "i", "sawStart", "uflag", "escaping", "negate", "endPos", "rangeStart", "WHILE", "c", "cls", "unip", "u", "neg", "r", "sranges", "snegs", "exports", "unescape", "s", "windowsPathsNoEscape", "magicalBraces", "exports", "brace_expressions_js_1", "unescape_js_1", "types", "isExtglobType", "c", "startNoTraversal", "startNoDot", "addPatternStart", "justDots", "reSpecials", "regExpEscape", "s", "qmark", "star", "starNoEmpty", "AST", "_AST", "#root", "#hasMagic", "#uflag", "#parts", "#parent", "#parentIndex", "#negs", "#filledNegs", "#options", "#toString", "#emptyExt", "type", "parent", "options", "p", "#fillNegs", "n", "pp", "part", "parts", "ret", "i", "pl", "#parseAST", "str", "ast", "pos", "opt", "escaping", "inBrace", "braceStart", "braceNeg", "acc", "ext", "pattern", "glob", "re", "body", "hasMagic", "uflag", "flags", "allowDot", "dot", "noEmpty", "src", "_", "#parseGlob", "start", "aps", "needNoTrav", "needNoDot", "end", "repeated", "#partsToRegExp", "bodyDotAllowed", "final", "close", "_hasMagic", "inStar", "needUflag", "consumed", "magic", "exports", "escape", "s", "windowsPathsNoEscape", "magicalBraces", "exports", "brace_expansion_1", "assert_valid_pattern_js_1", "ast_js_1", "escape_js_1", "unescape_js_1", "minimatch", "p", "pattern", "options", "Minimatch", "exports", "starDotExtRE", "starDotExtTest", "ext", "f", "starDotExtTestDot", "starDotExtTestNocase", "starDotExtTestNocaseDot", "starDotStarRE", "starDotStarTest", "starDotStarTestDot", "dotStarRE", "dotStarTest", "starRE", "starTest", "starTestDot", "qmarksRE", "qmarksTestNocase", "$0", "noext", "qmarksTestNoExt", "qmarksTestNocaseDot", "qmarksTestNoExtDot", "qmarksTestDot", "qmarksTest", "len", "defaultPlatform", "path", "qmark", "star", "twoStarDot", "twoStarNoDot", "filter", "a", "b", "defaults", "def", "orig", "type", "parent", "list", "braceExpand", "makeRe", "match", "mm", "globMagic", "regExpEscape", "s", "awe", "part", "_", "args", "rawGlobParts", "set", "__", "isUNC", "isDrive", "ss", "i", "globParts", "j", "optimizationLevel", "parts", "gs", "prev", "didSomething", "dd", "gss", "next", "p2", "other", "splin", "matched", "emptyGSMatch", "ai", "bi", "result", "which", "negate", "negateOffset", "file", "partial", "fileDrive", "fileUNC", "patternDrive", "patternUNC", "fdi", "pdi", "fd", "pd", "fi", "pi", "fl", "pl", "fr", "pr", "swallowee", "hit", "m", "fastTest", "re", "twoStar", "flags", "pp", "filtered", "prefixes", "open", "close", "ff", "filename", "ast_js_2", "escape_js_2", "unescape_js_2", "defaultPerf", "warned", "PROCESS", "emitWarning", "msg", "type", "code", "fn", "AC", "AS", "_", "warnACPolyfill", "reason", "printACPolyfillWarning", "shouldWarn", "isPosInt", "n", "getUintArray", "max", "ZeroArray", "size", "Stack", "_Stack", "#constructing", "HeapCls", "s", "LRUCache", "_LRUCache", "#max", "#maxSize", "#dispose", "#onInsert", "#disposeAfter", "#fetchMethod", "#memoMethod", "#perf", "#size", "#calculatedSize", "#keyMap", "#keyList", "#valList", "#next", "#prev", "#head", "#tail", "#free", "#disposed", "#sizes", "#starts", "#ttls", "#autopurgeTimers", "#hasDispose", "#hasFetchMethod", "#hasDisposeAfter", "#hasOnInsert", "c", "p", "#isBackgroundFetch", "k", "index", "options", "context", "#backgroundFetch", "#moveToTail", "#indexes", "#rindexes", "#isStale", "ttl", "ttlResolution", "ttlAutopurge", "updateAgeOnGet", "updateAgeOnHas", "allowStale", "dispose", "onInsert", "disposeAfter", "noDisposeOnSet", "noUpdateTTL", "maxSize", "maxEntrySize", "sizeCalculation", "fetchMethod", "memoMethod", "noDeleteOnFetchRejection", "noDeleteOnStaleGet", "allowStaleOnFetchRejection", "allowStaleOnFetchAbort", "ignoreFetchAbort", "perf", "UintArray", "#initializeSizeTracking", "#initializeTTLTracking", "key", "ttls", "starts", "purgeTimers", "#setItemTTL", "start", "t", "#delete", "#updateItemAge", "#statusTTL", "status", "cachedNow", "getNow", "age", "sizes", "#removeItemSize", "#requireSize", "v", "#addItemSize", "#evict", "_i", "_s", "_st", "_Line truncated "names": ["balanced", "a", "b", "str", "ma", "maybeMatch", "mb", "exports", "reg", "m", "range", "begs", "beg", "left", "right", "result", "ai", "bi", "i", "r", "exports", "expand", "balanced_match_1", "escSlash", "escOpen", "escClose", "escComma", "escPeriod", "escSlashPattern", "escOpenPattern", "escClosePattern", "escCommaPattern", "escPeriodPattern", "slashPattern", "openPattern", "closePattern", "commaPattern", "periodPattern", "numeric", "str", "escapeBraces", "unescapeBraces", "pushAll", "target", "items", "i", "parseCommaParts", "parts", "carry", "m", "tail", "pre", "body", "post", "p", "options", "max", "maxLength", "maxDepth", "maxRewrites", "expand_", "embrace", "isPadded", "el", "lte", "y", "gte", "combine", "acc", "values", "dropEmpties", "out", "length", "a", "v", "expansion", "expandSequence", "isAlphaSequence", "n", "N", "x", "width", "incr", "test", "pad", "c", "need", "z", "depth", "isTop", "rewrites", "firstGroup", "isNumericSequence", "isSequence", "isOptions", "dropsEmpties", "d", "valuesLength", "outer", "j", "expanded", "k", "posixClasses", "braceEscape", "s", "noMatch", "parseClass", "glob", "position", "nocase", "form", "norm", "c", "n", "pos", "ranges", "negs", "i", "sawStart", "escaping", "negate", "endPos", "rangeStart", "WHILE", "cls", "unip", "neg", "sranges", "snegs", "comb", "exports", "parse_class_js_1", "MATCH", "extTypes", "lit", "ch", "reEscape", "s", "foldRe", "litMatch", "l", "c", "code", "ascii", "tokenize", "p", "nocase", "noext", "form", "toks", "i", "e", "re", "consumed", "pair", "pairs", "stack", "tok", "build", "start", "end", "top", "seq", "alts", "close", "sub", "normalize", "items", "out", "run", "flush", "it", "a", "compile", "id", "split", "next", "item", "after", "entry", "show", "lines", "seen", "ref", "n", "walk", "indent", "line", "desc", "State", "gen", "sameState", "b", "r", "o", "marks", "size", "Sim", "#marks", "dots", "dotStart", "state", "#visit", "node", "#addThread", "has", "th", "stateKey", "ids", "runs", "DFA_BUDGET", "Dfa", "#start", "#states", "#size", "#plain", "#dotStart", "#sim", "#dotSim", "#make", "#intern", "key", "found", "#clear", "d", "linear", "nodes", "testLinear", "chars", "ni", "ci", "starNi", "starCi", "lengths", "min", "max", "lo", "hi", "itemLengths", "loop", "hasAffix", "lits", "j", "slashOrSurrogate", "surrogate", "codePoints", "noSlash", "Matcher", "#dotsSim", "#literal", "#literalRe", "#linear", "#wild", "#min", "#max", "#prefix", "#suffix", "#prefixStr", "#suffixStr", "#affix", "#dfa", "#form", "pattern", "options", "literal", "#test", "most", "least", "prefix", "sim", "dfa", "str", "exports", "MAX_PATTERN_LENGTH", "assertValidPattern", "pattern", "exports", "escape", "s", "windowsPathsNoEscape", "magicalBraces", "exports", "unescape", "s", "windowsPathsNoEscape", "magicalBraces", "exports", "brace_expansion_1", "nonrecursive_glob_match_1", "assert_valid_pattern_js_1", "escape_js_1", "unescape_js_1", "minimatch", "p", "pattern", "options", "Minimatch", "exports", "defaultPlatform", "path", "filter", "ext", "a", "b", "defaults", "def", "orig", "list", "braceExpand", "match", "mm", "f", "globMagic", "classEnd", "start", "i", "sawStart", "c", "literal", "noext", "lit", "close", "body", "extSafe", "depth", "lastSplit", "lastChecked", "portionMatch", "endIndex", "last", "lastStart", "prev", "prevStart", "isDots", "isDrive", "isLongUNC", "uncHost", "h", "host", "share", "walkable", "dot", "dotPortion", "end", "sep", "k", "n", "isSep", "s", "nextSep", "from", "lastSep", "#endCheck", "#literalCheck", "#level2", "#form", "#literals", "#shapes", "#endRows", "#matchers", "#globstarParts", "awe", "drives", "row", "#rootIndex", "r", "lits", "l", "p0", "p1", "p2", "#norm", "part", "rawGlobParts", "#slashSplit", "set", "_", "__", "isUNC", "ss", "merged", "len", "groups", "parts", "key", "g", "drop", "first", "rest", "glob", "globParts", "partset", "j", "optimizationLevel", "gs", "root", "#canMatch", "ends", "ROWS", "resolves", "tailStart", "shape", "m", "#walk", "#matchShape", "file", "x", "t", "head", "e", "next", "#cachedSplit", "#split", "isWindows", "preserveMultipleSlashes", "normalize", "#levelTwoFileOptimize", "didSomething", "dd", "braceExpandMax", "gss", "other", "splin", "matched", "emptyGSMatch", "ai", "bi", "result", "which", "negate", "negateOffset", "#matchRow", "resolved", "partial", "fileStartIndex", "patternStartIndex", "fh", "ph", "fileDrive", "fileUNC", "patternDrive", "patternUNC", "fdi", "pdi", "fd", "pd", "#matchGlobstar", "#matchOne", "fileIndex", "patternIndex", "tail", "segments", "#getGlobstarParts", "headEnd", "fileTailMatch", "sawSome", "#matchGlobStarBodySections", "byStart", "found", "firstgs", "lastgs", "current", "nonGsParts", "nonGsPartsSums", "bodySegments", "fileLength", "bodyIndex", "globStarDepth", "sawTail", "tried", "bs", "need", "after", "sub", "fileEnd", "fi", "pi", "pl", "fl", "nocase", "nocaseMagicOnly", "split", "can", "ff", "filename", "escape_js_2", "unescape_js_2", "node_diagnostics_channLine truncated
} }
+10 -3
View File
@@ -1,5 +1,12 @@
import type { ParseReturnFiltered } from 'minimatch';
import { GLOBSTAR } from 'minimatch'; import { GLOBSTAR } from 'minimatch';
export type MMPattern = string | RegExp | typeof GLOBSTAR; /**
* One portion of a parsed minimatch pattern: a string, a Matcher for
* a portion with magic, or GLOBSTAR for `**`.
*/
export type MMPattern = ParseReturnFiltered;
/** The Matcher that minimatch makes for a portion with magic. */
export type MMMatcher = Exclude<MMPattern, string | typeof GLOBSTAR>;
export type PatternList = [p: MMPattern, ...rest: MMPattern[]]; export type PatternList = [p: MMPattern, ...rest: MMPattern[]];
export type UNCPatternList = [ export type UNCPatternList = [
p0: '', p0: '',
@@ -34,9 +41,9 @@ export declare class Pattern {
*/ */
isGlobstar(): boolean; isGlobstar(): boolean;
/** /**
* true if pattern() returns a regexp * true if pattern() returns a Matcher, for a portion with magic
*/ */
isRegExp(): boolean; isMatcher(): boolean;
/** /**
* The /-joined set of glob parts that make up this pattern * The /-joined set of glob parts that make up this pattern
*/ */
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/pattern.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAA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,CAAC,MAAM,EAAE,MAAM,CAAA;gBAUrB,WAAW,EAAE,SAAS,EAAE,EACxB,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;IAkE3B,CAAC,aAAa,CAAC;IAIf;;OAEG;IACH,OAAO,IAAI,SAAS;IAIpB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAGnB;;OAEG;IACH,UAAU,IAAI,OAAO;IAGrB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,UAAU,IAAI,MAAM;IAUpB;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,IAAI,IAAI,OAAO,GAAG,IAAI;IAuBtB;;OAEG;IACH,KAAK,IAAI,OAAO;IAsBhB;;OAEG;IACH,OAAO,IAAI,OAAO;IAelB;;OAEG;IACH,UAAU,IAAI,OAAO;IAUrB;;OAEG;IACH,IAAI,IAAI,MAAM;IASd;;;OAGG;IACH,mBAAmB,IAAI,OAAO;IAQ9B;;OAEG;IACH,kBAAkB,IAAI,OAAO;CAM9B"}
+27 -15
View File
@@ -48,19 +48,24 @@ class Pattern {
// //host/share => ['//host/share/'] // //host/share => ['//host/share/']
// //host/share/ => ['//host/share/'] // //host/share/ => ['//host/share/']
// //host/share/x => ['//host/share/', 'x'] // //host/share/x => ['//host/share/', 'x']
// //?/UNC/host/share/x => ['//?/UNC/host/share/', 'x']
// /etc => ['/', 'etc'] // /etc => ['/', 'etc']
// / => ['/'] // / => ['/']
if (this.isUNC()) { if (this.isUNC()) {
// '' / '' / 'host' / 'share' // '' / '' / 'host' / 'share', or
const [p0, p1, p2, p3, ...prest] = this.#patternList; // '' / '' / '?' / 'UNC' / 'host' / 'share'
const [g0, g1, g2, g3, ...grest] = this.#globList; const n = this.#isLongUNC() ? 6 : 4;
const proot = this.#patternList.slice(0, n);
const groot = this.#globList.slice(0, n);
const prest = this.#patternList.slice(n);
const grest = this.#globList.slice(n);
if (prest[0] === '') { if (prest[0] === '') {
// ends in / // ends in /
prest.shift(); prest.shift();
grest.shift(); grest.shift();
} }
const p = [p0, p1, p2, p3, ''].join('/'); const p = [...proot, ''].join('/');
const g = [g0, g1, g2, g3, ''].join('/'); const g = [...groot, ''].join('/');
this.#patternList = [p, ...prest]; this.#patternList = [p, ...prest];
this.#globList = [g, ...grest]; this.#globList = [g, ...grest];
this.length = this.#patternList.length; this.length = this.#patternList.length;
@@ -73,8 +78,8 @@ class Pattern {
prest.shift(); prest.shift();
grest.shift(); grest.shift();
} }
const p = p1 + '/'; const p = `${p1}/`;
const g = g1 + '/'; const g = `${g1}/`;
this.#patternList = [p, ...prest]; this.#patternList = [p, ...prest];
this.#globList = [g, ...grest]; this.#globList = [g, ...grest];
this.length = this.#patternList.length; this.length = this.#patternList.length;
@@ -82,7 +87,7 @@ class Pattern {
} }
} }
[customInspect]() { [customInspect]() {
return 'Pattern <' + this.#globList.slice(this.#index).join('/') + '>'; return `Pattern <${this.#globList.slice(this.#index).join('/')}>`;
} }
/** /**
* The first entry in the parsed list of patterns * The first entry in the parsed list of patterns
@@ -103,10 +108,10 @@ class Pattern {
return this.#patternList[this.#index] === minimatch_1.GLOBSTAR; return this.#patternList[this.#index] === minimatch_1.GLOBSTAR;
} }
/** /**
* true if pattern() returns a regexp * true if pattern() returns a Matcher, for a portion with magic
*/ */
isRegExp() { isMatcher() {
return this.#patternList[this.#index] instanceof RegExp; return typeof this.#patternList[this.#index] === 'object';
} }
/** /**
* The /-joined set of glob parts that make up this pattern * The /-joined set of glob parts that make up this pattern
@@ -140,11 +145,18 @@ class Pattern {
this.#rest.#isDrive = this.#isDrive; this.#rest.#isDrive = this.#isDrive;
return this.#rest; return this.#rest;
} }
// the root is //?/UNC/host/share, the same as //host/share
#isLongUNC() {
const pl = this.#patternList;
return (pl[2] === '?' && typeof pl[3] === 'string' && /^unc$/i.test(pl[3]));
}
/** /**
* true if the pattern represents a //unc/path/ on windows * true if the pattern represents a //unc/path/ on windows
*/ */
isUNC() { isUNC() {
const pl = this.#patternList; const pl = this.#patternList;
// the host and share, after //?/UNC/ in a long UNC path
const h = this.#isLongUNC() ? 4 : 2;
return this.#isUNC !== undefined ? return this.#isUNC !== undefined ?
this.#isUNC this.#isUNC
: (this.#isUNC = : (this.#isUNC =
@@ -152,10 +164,10 @@ class Pattern {
this.#index === 0 && this.#index === 0 &&
pl[0] === '' && pl[0] === '' &&
pl[1] === '' && pl[1] === '' &&
typeof pl[2] === 'string' && typeof pl[h] === 'string' &&
!!pl[2] && !!pl[h] &&
typeof pl[3] === 'string' && typeof pl[h + 1] === 'string' &&
!!pl[3]); !!pl[h + 1]);
} }
// pattern like C:/... // pattern like C:/...
// split = ['C:', ...] // split = ['C:', ...]
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/pattern.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE,yCAAoC;AAgBpC,MAAM,aAAa,GAAG,CAAC,EAAe,EAAqB,EAAE,CAC3D,EAAE,CAAC,MAAM,IAAI,CAAC,CAAA;AAChB,MAAM,UAAU,GAAG,CAAC,EAAY,EAAkB,EAAE,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,CAAA;AAEnE,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE9D;;;GAGG;AACH,MAAa,OAAO;IACT,YAAY,CAAa;IACzB,SAAS,CAAU;IACnB,MAAM,CAAQ;IACd,MAAM,CAAQ;IACd,SAAS,CAAiB;IACnC,KAAK,CAAiB;IACtB,WAAW,CAAS;IACpB,QAAQ,CAAU;IAClB,MAAM,CAAU;IAChB,WAAW,CAAU;IACrB,eAAe,GAAY,IAAI,CAAA;IAE/B,YACE,WAAwB,EACxB,QAAkB,EAClB,KAAa,EACb,QAAyB;QAEzB,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAA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CAAA;QAC/C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,CACtB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,GAAG,CAAC,EACf,IAAI,CAAC,SAAS,CACf,CAAA;QACD,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACzC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QACnC,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,2DAA2D;IAC3D,UAAU;QACR,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAA;QAC5B,OAAO,CACL,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CACnE,CAAA;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAA;QAC5B,wDAAwD;QACxD,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM;YACb,CAAC,CAALine truncated
+23 -10
View File
@@ -1,26 +1,39 @@
import { MMRegExp } from 'minimatch'; import type { Path } from 'path-scurry';
import { Path } from 'path-scurry'; import type { MMMatcher, Pattern } from './pattern.js';
import { Pattern } from './pattern.js'; import type { GlobWalkerOpts } from './walker.js';
import { GlobWalkerOpts } from './walker.js';
/** /**
* A cache of which patterns have been processed for a given Path * A cache of which patterns have been processed for a given Path, in
* this walk step and the steps that led to it.
*
* A step only adds to it before it makes the caches for the next
* steps, so a copy can look up the chain of caches before it, in
* place of copying their entries. A pattern for a path that a cache
* up the chain has already seen is added to that cache's set, so that
* the other steps that share it see it too. Paths are keyed by their
* full path, because path-scurry can make a new Path object for the
* same path once its cache of children is full.
*/ */
export declare class HasWalkedCache { export declare class HasWalkedCache {
store: Map<string, Set<string>>; #private;
constructor(store?: Map<string, Set<string>>); parent?: HasWalkedCache;
store?: Map<string, Set<string>>;
constructor(parent?: HasWalkedCache);
copy(): HasWalkedCache; copy(): HasWalkedCache;
hasWalked(target: Path, pattern: Pattern): boolean | undefined; hasWalked(target: Path, pattern: Pattern): boolean;
storeWalked(target: Path, pattern: Pattern): void; storeWalked(target: Path, pattern: Pattern): void;
} }
/** /**
* A record of which paths have been matched in a given walk step, * A record of which paths have been matched in a given walk step,
* and whether they only are considered a match if they are a directory, * and whether they only are considered a match if they are a directory,
* and whether their absolute or relative path should be returned. * and whether their absolute or relative path should be returned.
* The store maps each path to {@link MatchRecord.ABSOLUTE} and
* {@link MatchRecord.IF_DIR} flags.
*/ */
export declare class MatchRecord { export declare class MatchRecord {
static readonly ABSOLUTE = 2;
static readonly IF_DIR = 1;
store: Map<Path, number>; store: Map<Path, number>;
add(target: Path, absolute: boolean, ifDir: boolean): void; add(target: Path, absolute: boolean, ifDir: boolean): void;
entries(): [Path, boolean, boolean][];
} }
/** /**
* A collection of patterns that must be processed in a subsequent step * A collection of patterns that must be processed in a subsequent step
@@ -53,7 +66,7 @@ export declare class Processor {
child(): Processor; child(): Processor;
filterEntries(parent: Path, entries: Path[]): Processor; filterEntries(parent: Path, entries: Path[]): Processor;
testGlobstar(e: Path, pattern: Pattern, rest: Pattern | null, absolute: boolean): void; testGlobstar(e: Path, pattern: Pattern, rest: Pattern | null, absolute: boolean): void;
testRegExp(e: Path, p: MMRegExp, rest: Pattern | null, absolute: boolean): void; testMatcher(e: Path, p: MMMatcher, rest: Pattern | null, absolute: boolean): void;
testString(e: Path, p: string, rest: Pattern | null, absolute: boolean): void; testString(e: Path, p: string, rest: Pattern | null, absolute: boolean): void;
} }
//# sourceMappingURL=processor.d.ts.map //# sourceMappingURL=processor.d.ts.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../src/processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C;;GAEG;AACH,qBAAa,cAAc;IACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;gBACnB,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAGvD,IAAI;IAGJ,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;IAGxC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;CAM3C;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACtB,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAY;IACpC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;IAMnD,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;CAOtC;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAY;IACvC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO;IAWl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c;IAQjE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;IAmGjD,cAAc,IAAI,IAAI,EAAE;IAIxB,KAAK;IAQL,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS;IAqBvD,YAAY,CACV,CAAC,EAAE,IAAI,EACP,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,QAAQ,EAAE,OAAO;IA8CnB,WAAW,CACT,CAAC,EAAE,IAAI,EACP,CAAC,EAAE,SAAS,EACZ,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,QAAQ,EAAE,OAAO;IAWnB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO;CASvE"}
+36 -23
View File
@@ -4,26 +4,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.Processor = exports.SubWalks = exports.MatchRecord = exports.HasWalkedCache = void 0; exports.Processor = exports.SubWalks = exports.MatchRecord = exports.HasWalkedCache = void 0;
const minimatch_1 = require("minimatch"); const minimatch_1 = require("minimatch");
/** /**
* A cache of which patterns have been processed for a given Path * A cache of which patterns have been processed for a given Path, in
* this walk step and the steps that led to it.
*
* A step only adds to it before it makes the caches for the next
* steps, so a copy can look up the chain of caches before it, in
* place of copying their entries. A pattern for a path that a cache
* up the chain has already seen is added to that cache's set, so that
* the other steps that share it see it too. Paths are keyed by their
* full path, because path-scurry can make a new Path object for the
* same path once its cache of children is full.
*/ */
class HasWalkedCache { class HasWalkedCache {
parent;
store; store;
constructor(store = new Map()) { constructor(parent) {
this.store = store; this.parent = parent;
} }
copy() { copy() {
return new HasWalkedCache(new Map(this.store)); return new HasWalkedCache(this);
}
// the set for the path in this cache, or the closest one before it
#find(fullpath) {
const set = this.store?.get(fullpath);
return set || !this.parent ? set : this.parent.#find(fullpath);
} }
hasWalked(target, pattern) { hasWalked(target, pattern) {
return this.store.get(target.fullpath())?.has(pattern.globString()); return !!this.#find(target.fullpath())?.has(pattern.globString());
} }
storeWalked(target, pattern) { storeWalked(target, pattern) {
const fullpath = target.fullpath(); const fullpath = target.fullpath();
const cached = this.store.get(fullpath); const cached = this.#find(fullpath);
if (cached) if (cached)
cached.add(pattern.globString()); cached.add(pattern.globString());
else else
this.store.set(fullpath, new Set([pattern.globString()])); (this.store ??= new Map()).set(fullpath, new Set([pattern.globString()]));
} }
} }
exports.HasWalkedCache = HasWalkedCache; exports.HasWalkedCache = HasWalkedCache;
@@ -31,22 +46,19 @@ exports.HasWalkedCache = HasWalkedCache;
* A record of which paths have been matched in a given walk step, * A record of which paths have been matched in a given walk step,
* and whether they only are considered a match if they are a directory, * and whether they only are considered a match if they are a directory,
* and whether their absolute or relative path should be returned. * and whether their absolute or relative path should be returned.
* The store maps each path to {@link MatchRecord.ABSOLUTE} and
* {@link MatchRecord.IF_DIR} flags.
*/ */
class MatchRecord { class MatchRecord {
static ABSOLUTE = 2;
static IF_DIR = 1;
store = new Map(); store = new Map();
add(target, absolute, ifDir) { add(target, absolute, ifDir) {
const n = (absolute ? 2 : 0) | (ifDir ? 1 : 0); const n = (absolute ? MatchRecord.ABSOLUTE : 0) |
(ifDir ? MatchRecord.IF_DIR : 0);
const current = this.store.get(target); const current = this.store.get(target);
this.store.set(target, current === undefined ? n : n & current); this.store.set(target, current === undefined ? n : n & current);
} }
// match, absolute, ifdir
entries() {
return [...this.store.entries()].map(([path, n]) => [
path,
!!(n & 2),
!!(n & 1),
]);
}
} }
exports.MatchRecord = MatchRecord; exports.MatchRecord = MatchRecord;
/** /**
@@ -191,7 +203,7 @@ class Processor {
} }
} }
} }
else if (p instanceof RegExp) { else if (typeof p === 'object') {
this.subwalks.add(t, pattern); this.subwalks.add(t, pattern);
} }
} }
@@ -219,8 +231,8 @@ class Processor {
if (p === minimatch_1.GLOBSTAR) { if (p === minimatch_1.GLOBSTAR) {
results.testGlobstar(e, pattern, rest, absolute); results.testGlobstar(e, pattern, rest, absolute);
} }
else if (p instanceof RegExp) { else if (typeof p === 'object') {
results.testRegExp(e, p, rest, absolute); results.testMatcher(e, p, rest, absolute);
} }
else { else {
results.testString(e, p, rest, absolute); results.testString(e, p, rest, absolute);
@@ -270,13 +282,14 @@ class Processor {
/* c8 ignore stop */ /* c8 ignore stop */
this.subwalks.add(ep, rest); this.subwalks.add(ep, rest);
} }
else if (rp instanceof RegExp) { else if (typeof rp === 'object') {
this.testRegExp(e, rp, rest.rest(), absolute); this.testMatcher(e, rp, rest.rest(), absolute);
} }
} }
} }
testRegExp(e, p, rest, absolute) { testMatcher(e, p, rest, absolute) {
if (!p.test(e.name)) // an entry name is one path portion, with no `/`
if (!p.testUnchecked(e.name))
return; return;
if (!rest) { if (!rest) {
this.matches.add(e, absolute, false); this.matches.add(e, absolute, false);
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"processor.js","sourceRoot":"","sources":["../../src/processor.ts"],"names":[],"mappings":";AAAA,qEAAqE;;;AAErE,yCAA8C;AAK9C;;GAEG;AACH,MAAa,cAAc;IACzB,KAAK,CAA0B;IAC/B,YAAY,QAAkC,IAAI,GAAG,EAAE;QACrD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IACD,IAAI;QACF,OAAO,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,SAAS,CAAC,MAAY,EAAE,OAAgB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACrE,CAAC;IACD,WAAW,CAAC,MAAY,EAAE,OAAgB;QACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,MAAM,GAAG,IA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*/
import { Minipass } from 'minipass'; import { Minipass } from 'minipass';
import { Path } from 'path-scurry'; import type { Form } from 'minimatch';
import { IgnoreLike } from './ignore.js'; import type { Path } from 'path-scurry';
import { Pattern } from './pattern.js'; import type { IgnoreLike } from './ignore.js';
import type { Pattern } from './pattern.js';
import { Processor } from './processor.js'; import { Processor } from './processor.js';
export interface GlobWalkerOpts { export interface GlobWalkerOpts {
absolute?: boolean; absolute?: boolean;
@@ -16,7 +17,7 @@ export interface GlobWalkerOpts {
dot?: boolean; dot?: boolean;
dotRelative?: boolean; dotRelative?: boolean;
follow?: boolean; follow?: boolean;
ignore?: string | string[] | IgnoreLike; ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>;
mark?: boolean; mark?: boolean;
matchBase?: boolean; matchBase?: boolean;
maxDepth?: number; maxDepth?: number;
@@ -25,6 +26,7 @@ export interface GlobWalkerOpts {
nodir?: boolean; nodir?: boolean;
noext?: boolean; noext?: boolean;
noglobstar?: boolean; noglobstar?: boolean;
normalize?: boolean | Form;
platform?: NodeJS.Platform; platform?: NodeJS.Platform;
posix?: boolean; posix?: boolean;
realpath?: boolean; realpath?: boolean;
@@ -45,7 +47,7 @@ export type GWOFileTypesUnset = GlobWalkerOpts & {
withFileTypes?: undefined; withFileTypes?: undefined;
}; };
export type Result<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Path : O extends GWOFileTypesFalse ? string : O extends GWOFileTypesUnset ? string : Path | string; export type Result<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Path : O extends GWOFileTypesFalse ? string : O extends GWOFileTypesUnset ? string : Path | string;
export type Matches<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Set<Path> : O extends GWOFileTypesFalse ? Set<string> : O extends GWOFileTypesUnset ? Set<string> : Set<Path | string>; export type Matches<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Path[] : O extends GWOFileTypesFalse ? string[] : O extends GWOFileTypesUnset ? string[] : (Path | string)[];
export type MatchStream<O extends GlobWalkerOpts> = Minipass<Result<O>, Result<O>>; export type MatchStream<O extends GlobWalkerOpts> = Minipass<Result<O>, Result<O>>;
/** /**
* basic walking utilities that all the glob walker types use * basic walking utilities that all the glob walker types use
@@ -64,28 +66,28 @@ export declare abstract class GlobUtil<O extends GlobWalkerOpts = GlobWalkerOpts
constructor(patterns: Pattern[], path: Path, opts: O); constructor(patterns: Pattern[], path: Path, opts: O);
pause(): void; pause(): void;
resume(): void; resume(): void;
onResume(fn: () => any): void; onResume(fn: () => unknown): void;
matchCheck(e: Path, ifDir: boolean): Promise<Path | undefined>; matchCheck(inPath: Path, ifDir: boolean): Promise<Path | undefined>;
matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined; matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined;
matchCheckSync(e: Path, ifDir: boolean): Path | undefined; matchCheckSync(inPath: Path, ifDir: boolean): Path | undefined;
abstract matchEmit(p: Result<O>): void; abstract matchEmit(p: Result<O>): void;
abstract matchEmit(p: string | Path): void; abstract matchEmit(p: string | Path): void;
matchFinish(e: Path, absolute: boolean): void; matchFinish(e: Path, absolute: boolean): void;
match(e: Path, absolute: boolean, ifDir: boolean): Promise<void>; match(e: Path, absolute: boolean, ifDir: boolean): Promise<void>;
matchSync(e: Path, absolute: boolean, ifDir: boolean): void; matchSync(e: Path, absolute: boolean, ifDir: boolean): void;
walkCB(target: Path, patterns: Pattern[], cb: () => any): void; walkCB(target: Path, patterns: Pattern[], cb: () => unknown): unknown;
walkCB2(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any; walkCB2(target: Path, patterns: Pattern[], processor: Processor, cb: () => unknown): unknown;
walkCB3(target: Path, entries: Path[], processor: Processor, cb: () => any): void; walkCB3(target: Path, entries: Path[], processorx: Processor, cb: () => unknown): void;
walkCBSync(target: Path, patterns: Pattern[], cb: () => any): void; walkCBSync(target: Path, patterns: Pattern[], cb: () => unknown): unknown;
walkCB2Sync(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any; walkCB2Sync(target: Path, patterns: Pattern[], processor: Processor, cb: () => unknown): unknown;
walkCB3Sync(target: Path, entries: Path[], processor: Processor, cb: () => any): void; walkCB3Sync(target: Path, entries: Path[], processor: Processor, cb: () => unknown): void;
} }
export declare class GlobWalker<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> { export declare class GlobWalker<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> {
matches: Set<Result<O>>; matches: Result<O>[];
constructor(patterns: Pattern[], path: Path, opts: O); constructor(patterns: Pattern[], path: Path, opts: O);
matchEmit(e: Result<O>): void; matchEmit(e: Result<O>): void;
walk(): Promise<Set<Result<O>>>; walk(): Promise<Result<O>[]>;
walkSync(): Set<Result<O>>; walkSync(): Result<O>[];
} }
export declare class GlobStream<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> { export declare class GlobStream<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> {
results: Minipass<Result<O>, Result<O>>; results: Minipass<Result<O>, Result<O>>;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"walker.d.ts","sourceRoot":"","sources":["../../src/walker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAU,UAAU,EAAE,MAAM,aAAa,CAAA;AAOhD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CA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Ac,GAAG,cAAc,CACzC,SAAQ,QAAQ,CAAC,CAAC,CAAC;IAGnB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAK;gBAEb,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAIpD,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAIvB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAiBlC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;CAWxB;AAED,qBAAa,UAAU,CACrB,CAAC,SAAS,cAAc,GAAG,cAAc,CACzC,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACnB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;gBAE3B,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAUpD,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAK7B,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAYxB,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC;CAO7B"}
+50 -35
View File
@@ -10,8 +10,9 @@ exports.GlobStream = exports.GlobWalker = exports.GlobUtil = void 0;
const minipass_1 = require("minipass"); const minipass_1 = require("minipass");
const ignore_js_1 = require("./ignore.js"); const ignore_js_1 = require("./ignore.js");
const processor_js_1 = require("./processor.js"); const processor_js_1 = require("./processor.js");
const makeIgnore = (ignore, opts) => typeof ignore === 'string' ? new ignore_js_1.Ignore([ignore], opts) const { ABSOLUTE, IF_DIR } = processor_js_1.MatchRecord;
: Array.isArray(ignore) ? new ignore_js_1.Ignore(ignore, opts) const makeIgnore = (ignore, opts, cwd) => typeof ignore === 'string' ? new ignore_js_1.Ignore([ignore], opts, cwd)
: Array.isArray(ignore) ? new ignore_js_1.Ignore(ignore, opts, cwd)
: ignore; : ignore;
/** /**
* basic walking utilities that all the glob walker types use * basic walking utilities that all the glob walker types use
@@ -36,7 +37,7 @@ class GlobUtil {
this.#sep = !opts.posix && opts.platform === 'win32' ? '\\' : '/'; this.#sep = !opts.posix && opts.platform === 'win32' ? '\\' : '/';
this.includeChildMatches = opts.includeChildMatches !== false; this.includeChildMatches = opts.includeChildMatches !== false;
if (opts.ignore || !this.includeChildMatches) { if (opts.ignore || !this.includeChildMatches) {
this.#ignore = makeIgnore(opts.ignore ?? [], opts); this.#ignore = makeIgnore(opts.ignore ?? [], opts, path);
if (!this.includeChildMatches && if (!this.includeChildMatches &&
typeof this.#ignore.add !== 'function') { typeof this.#ignore.add !== 'function') {
const m = 'cannot ignore child matches, ignore lacks add() method.'; const m = 'cannot ignore child matches, ignore lacks add() method.';
@@ -77,8 +78,6 @@ class GlobUtil {
} }
} }
onResume(fn) { onResume(fn) {
if (this.signal?.aborted)
return;
/* c8 ignore start */ /* c8 ignore start */
if (!this.paused) { if (!this.paused) {
fn(); fn();
@@ -90,16 +89,20 @@ class GlobUtil {
} }
// do the requisite realpath/stat checking, and return the path // do the requisite realpath/stat checking, and return the path
// to add or undefined to filter it out. // to add or undefined to filter it out.
async matchCheck(e, ifDir) { async matchCheck(inPath, ifDir) {
if (ifDir && this.opts.nodir) if (ifDir && this.opts.nodir)
return undefined; return undefined;
let rpc; let rpc;
let e;
if (this.opts.realpath) { if (this.opts.realpath) {
rpc = e.realpathCached() || (await e.realpath()); rpc = inPath.realpathCached() || (await inPath.realpath());
if (!rpc) if (!rpc)
return undefined; return undefined;
e = rpc; e = rpc;
} }
else {
e = inPath;
}
const needStat = e.isUnknown() || this.opts.stat; const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? await e.lstat() : e; const s = needStat ? await e.lstat() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) { if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
@@ -125,16 +128,20 @@ class GlobUtil {
e e
: undefined; : undefined;
} }
matchCheckSync(e, ifDir) { matchCheckSync(inPath, ifDir) {
if (ifDir && this.opts.nodir) if (ifDir && this.opts.nodir)
return undefined; return undefined;
let rpc; let rpc;
let e;
if (this.opts.realpath) { if (this.opts.realpath) {
rpc = e.realpathCached() || e.realpathSync(); rpc = inPath.realpathCached() || inPath.realpathSync();
if (!rpc) if (!rpc)
return undefined; return undefined;
e = rpc; e = rpc;
} }
else {
e = inPath;
}
const needStat = e.isUnknown() || this.opts.stat; const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? e.lstatSync() : e; const s = needStat ? e.lstatSync() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) { if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
@@ -148,6 +155,10 @@ class GlobUtil {
matchFinish(e, absolute) { matchFinish(e, absolute) {
if (this.#ignored(e)) if (this.#ignored(e))
return; return;
this.#matchEmitChecked(e, absolute);
}
// emit a match that is known to not be seen or ignored yet
#matchEmitChecked(e, absolute) {
// we know we have an ignore if this is false, but TS doesn't // we know we have an ignore if this is false, but TS doesn't
if (!this.includeChildMatches && this.#ignore?.add) { if (!this.includeChildMatches && this.#ignore?.add) {
const ign = `${e.relativePosix()}/**`; const ign = `${e.relativePosix()}/**`;
@@ -166,10 +177,10 @@ class GlobUtil {
} }
else { else {
const rel = this.opts.posix ? e.relativePosix() : e.relative(); const rel = this.opts.posix ? e.relativePosix() : e.relative();
const pre = this.opts.dotRelative && !rel.startsWith('..' + this.#sep) ? const pre = this.opts.dotRelative && !rel.startsWith(`..${this.#sep}`) ?
'.' + this.#sep `.${this.#sep}`
: ''; : '';
this.matchEmit(!rel ? '.' + mark : pre + rel + mark); this.matchEmit(!rel ? `.${mark}` : pre + rel + mark);
} }
} }
async match(e, absolute, ifDir) { async match(e, absolute, ifDir) {
@@ -178,14 +189,16 @@ class GlobUtil {
this.matchFinish(p, absolute); this.matchFinish(p, absolute);
} }
matchSync(e, absolute, ifDir) { matchSync(e, absolute, ifDir) {
// matchCheckSync just checked that it is not seen or ignored, and
// nothing can have changed since
const p = this.matchCheckSync(e, ifDir); const p = this.matchCheckSync(e, ifDir);
if (p) if (p)
this.matchFinish(p, absolute); this.#matchEmitChecked(p, absolute);
} }
walkCB(target, patterns, cb) { walkCB(target, patterns, cb) {
/* c8 ignore start */ /* c8 ignore start */
if (this.signal?.aborted) if (this.signal?.aborted)
cb(); return cb();
/* c8 ignore stop */ /* c8 ignore stop */
this.walkCB2(target, patterns, new processor_js_1.Processor(this.opts), cb); this.walkCB2(target, patterns, new processor_js_1.Processor(this.opts), cb);
} }
@@ -193,7 +206,7 @@ class GlobUtil {
if (this.#childrenIgnored(target)) if (this.#childrenIgnored(target))
return cb(); return cb();
if (this.signal?.aborted) if (this.signal?.aborted)
cb(); return cb();
if (this.paused) { if (this.paused) {
this.onResume(() => this.walkCB2(target, patterns, processor, cb)); this.onResume(() => this.walkCB2(target, patterns, processor, cb));
return; return;
@@ -207,11 +220,11 @@ class GlobUtil {
if (--tasks === 0) if (--tasks === 0)
cb(); cb();
}; };
for (const [m, absolute, ifDir] of processor.matches.entries()) { for (const [m, n] of processor.matches.store) {
if (this.#ignored(m)) if (this.#ignored(m))
continue; continue;
tasks++; tasks++;
this.match(m, absolute, ifDir).then(() => next()); void this.match(m, !!(n & ABSOLUTE), !!(n & IF_DIR)).then(() => next());
} }
for (const t of processor.subwalkTargets()) { for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) { if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
@@ -227,29 +240,29 @@ class GlobUtil {
} }
next(); next();
} }
walkCB3(target, entries, processor, cb) { walkCB3(target, entries, processorx, cb) {
processor = processor.filterEntries(target, entries); const proc = processorx.filterEntries(target, entries);
let tasks = 1; let tasks = 1;
const next = () => { const next = () => {
if (--tasks === 0) if (--tasks === 0)
cb(); cb();
}; };
for (const [m, absolute, ifDir] of processor.matches.entries()) { for (const [m, n] of proc.matches.store) {
if (this.#ignored(m)) if (this.#ignored(m))
continue; continue;
tasks++; tasks++;
this.match(m, absolute, ifDir).then(() => next()); void this.match(m, !!(n & ABSOLUTE), !!(n & IF_DIR)).then(() => next());
} }
for (const [target, patterns] of processor.subwalks.entries()) { for (const [target, patterns] of proc.subwalks.entries()) {
tasks++; tasks++;
this.walkCB2(target, patterns, processor.child(), next); this.walkCB2(target, patterns, proc.child(), next);
} }
next(); next();
} }
walkCBSync(target, patterns, cb) { walkCBSync(target, patterns, cb) {
/* c8 ignore start */ /* c8 ignore start */
if (this.signal?.aborted) if (this.signal?.aborted)
cb(); return cb();
/* c8 ignore stop */ /* c8 ignore stop */
this.walkCB2Sync(target, patterns, new processor_js_1.Processor(this.opts), cb); this.walkCB2Sync(target, patterns, new processor_js_1.Processor(this.opts), cb);
} }
@@ -257,7 +270,7 @@ class GlobUtil {
if (this.#childrenIgnored(target)) if (this.#childrenIgnored(target))
return cb(); return cb();
if (this.signal?.aborted) if (this.signal?.aborted)
cb(); return cb();
if (this.paused) { if (this.paused) {
this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb)); this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb));
return; return;
@@ -271,10 +284,10 @@ class GlobUtil {
if (--tasks === 0) if (--tasks === 0)
cb(); cb();
}; };
for (const [m, absolute, ifDir] of processor.matches.entries()) { for (const [m, n] of processor.matches.store) {
if (this.#ignored(m)) if (this.#ignored(m))
continue; continue;
this.matchSync(m, absolute, ifDir); this.matchSync(m, !!(n & ABSOLUTE), !!(n & IF_DIR));
} }
for (const t of processor.subwalkTargets()) { for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) { if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
@@ -287,32 +300,34 @@ class GlobUtil {
next(); next();
} }
walkCB3Sync(target, entries, processor, cb) { walkCB3Sync(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries); const proc = processor.filterEntries(target, entries);
let tasks = 1; let tasks = 1;
const next = () => { const next = () => {
if (--tasks === 0) if (--tasks === 0)
cb(); cb();
}; };
for (const [m, absolute, ifDir] of processor.matches.entries()) { for (const [m, n] of proc.matches.store) {
if (this.#ignored(m)) if (this.#ignored(m))
continue; continue;
this.matchSync(m, absolute, ifDir); this.matchSync(m, !!(n & ABSOLUTE), !!(n & IF_DIR));
} }
for (const [target, patterns] of processor.subwalks.entries()) { for (const [target, patterns] of proc.subwalks.entries()) {
tasks++; tasks++;
this.walkCB2Sync(target, patterns, processor.child(), next); this.walkCB2Sync(target, patterns, proc.child(), next);
} }
next(); next();
} }
} }
exports.GlobUtil = GlobUtil; exports.GlobUtil = GlobUtil;
class GlobWalker extends GlobUtil { class GlobWalker extends GlobUtil {
matches = new Set(); // each Path is only emitted once (see GlobUtil.seen), so the results
// do not need to be deduped
matches = [];
constructor(patterns, path, opts) { constructor(patterns, path, opts) {
super(patterns, path, opts); super(patterns, path, opts);
} }
matchEmit(e) { matchEmit(e) {
this.matches.add(e); this.matches.push(e);
} }
async walk() { async walk() {
if (this.signal?.aborted) if (this.signal?.aborted)
@@ -366,7 +381,7 @@ class GlobStream extends GlobUtil {
stream() { stream() {
const target = this.path; const target = this.path;
if (target.isUnknown()) { if (target.isUnknown()) {
target.lstat().then(() => { void target.lstat().then(() => {
this.walkCB(target, this.patterns, () => this.results.end()); this.walkCB(target, this.patterns, () => this.results.end());
}); });
} }
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"walker.js","sourceRoot":"","sources":["../../src/walker.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,uCAAmC;AAEnC,2CAAgD;AAQhD,iDAA0C;AA0D1C,MAAM,UAAU,GAAG,CACjB,MAAsC,EACtC,IAAoB,EACR,EAAE,CACd,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,kBAAM,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,C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;YAC/D,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,EAAE,CAAA;YAC/B,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtD,MAAM,CAAC,SAAS,EAAE,CAAA;YACpB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACtC,CAAC;IAKD,WAAW,CLine truncated
+20 -11
View File
@@ -1,7 +1,9 @@
import type { Form } from 'minimatch';
import { Minimatch } from 'minimatch'; import { Minimatch } from 'minimatch';
import { Minipass } from 'minipass'; import type { Minipass } from 'minipass';
import { FSOption, Path, PathScurry } from 'path-scurry'; import type { FSOption, Path } from 'path-scurry';
import { IgnoreLike } from './ignore.js'; import { PathScurry } from 'path-scurry';
import type { IgnoreLike } from './ignore.js';
import { Pattern } from './pattern.js'; import { Pattern } from './pattern.js';
export type MatchSet = Minimatch['set']; export type MatchSet = Minimatch['set'];
export type GlobParts = Exclude<Minimatch['globParts'], undefined>; export type GlobParts = Exclude<Minimatch['globParts'], undefined>;
@@ -89,7 +91,7 @@ export interface GlobOptions {
* determine whether any Path is a match or if its children should be * determine whether any Path is a match or if its children should be
* traversed, respectively. * traversed, respectively.
*/ */
ignore?: string | string[] | IgnoreLike; readonly ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>;
/** /**
* Treat brace expansion like `{a,b}` as a "magic" pattern. Has no * Treat brace expansion like `{a,b}` as a "magic" pattern. Has no
* effect if {@link nobrace} is set. * effect if {@link nobrace} is set.
@@ -139,6 +141,18 @@ export interface GlobOptions {
* Do not match "extglob" patterns such as `+(a|b)`. * Do not match "extglob" patterns such as `+(a|b)`.
*/ */
noext?: boolean; noext?: boolean;
/**
* Normalize unicode in the pattern, and in the file names that it is
* matched against, with this form: `'NFC'`, `'NFD'`, `'NFKC'`, or
* `'NFKD'`. `true` means `'NFC'`. This is passed to minimatch, so it
* applies to the portions of the pattern with magic, and to the
* `ignore` patterns.
*
* The portions of the pattern without magic are looked up with
* path-scurry, which already compares the names of the entries
* that it knows in their `'NFKD'` form.
*/
normalize?: boolean | Form;
/** /**
* Do not match `**` against multiple filenames. (Ie, treat it as a normal * Do not match `**` against multiple filenames. (Ie, treat it as a normal
* `*` instead.) * `*` instead.)
@@ -232,11 +246,6 @@ export interface GlobOptions {
* http://npm.im/path-scurry for details about what can be overridden. * http://npm.im/path-scurry for details about what can be overridden.
*/ */
fs?: FSOption; fs?: FSOption;
/**
* Just passed along to Minimatch. Note that this makes all pattern
* matching operations slower and *extremely* noisy.
*/
debug?: boolean;
/** /**
* Return `/` delimited paths, even on Windows. * Return `/` delimited paths, even on Windows.
* *
@@ -324,7 +333,7 @@ export declare class Glob<Opts extends GlobOptions> implements GlobOptions {
dot: boolean; dot: boolean;
dotRelative: boolean; dotRelative: boolean;
follow: boolean; follow: boolean;
ignore?: string | string[] | IgnoreLike; ignore?: string | string[] | IgnoreLike | ReadonlyArray<string>;
magicalBraces: boolean; magicalBraces: boolean;
mark?: boolean; mark?: boolean;
matchBase: boolean; matchBase: boolean;
@@ -334,7 +343,7 @@ export declare class Glob<Opts extends GlobOptions> implements GlobOptions {
nodir: boolean; nodir: boolean;
noext: boolean; noext: boolean;
noglobstar: boolean; noglobstar: boolean;
pattern: string[]; pattern: string[] | ReadonlyArray<string>;
platform: NodeJS.Platform; platform: NodeJS.Platform;
realpath: boolean; realpath: boolean;
scurry: PathScurry; scurry: PathScurry;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,UAAU,EAIX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE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C7B,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IAC9B,mBAAmB,EAAE,OAAO,CAAA;IAE5B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAA;IAEnB;;;;;;;;;;;OAWG;gBACS,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI;IAyHlD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAkBpC;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAczB;;OAEG;IACH,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAc9C;;OAEG;IACH,UAAU,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAclD;;;OAGG;IACH,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IAGlD,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;;OAGG;IACH,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;IAGnD,CAAC,MAAM,CAAC,aAAa,CAAC;CAGvB"}
+8 -15
View File
@@ -94,23 +94,21 @@ export class Glob {
if (this.withFileTypes && this.absolute !== undefined) { if (this.withFileTypes && this.absolute !== undefined) {
throw new Error('cannot set absolute and withFileTypes:true'); throw new Error('cannot set absolute and withFileTypes:true');
} }
if (typeof pattern === 'string') { let p = typeof pattern === 'string' ? [pattern] : pattern;
pattern = [pattern];
}
this.windowsPathsNoEscape = this.windowsPathsNoEscape =
!!opts.windowsPathsNoEscape || !!opts.windowsPathsNoEscape ||
opts.allowWindowsEscape === opts.allowWindowsEscape ===
false; false;
if (this.windowsPathsNoEscape) { if (this.windowsPathsNoEscape) {
pattern = pattern.map(p => p.replace(/\\/g, '/')); p = p.map(p => p.replace(/\\/g, '/'));
} }
if (this.matchBase) { if (this.matchBase) {
if (opts.noglobstar) { if (opts.noglobstar) {
throw new TypeError('base matching requires globstar'); throw new TypeError('base matching requires globstar');
} }
pattern = pattern.map(p => (p.includes('/') ? p : `./**/${p}`)); p = p.map(p => (p.includes('/') ? p : `./**/${p}`));
} }
this.pattern = pattern; this.pattern = p;
this.platform = opts.platform || defaultPlatform; this.platform = opts.platform || defaultPlatform;
this.opts = { ...opts, platform: this.platform }; this.opts = { ...opts, platform: this.platform };
if (opts.scurry) { if (opts.scurry) {
@@ -151,7 +149,6 @@ export class Glob {
optimizationLevel: 2, optimizationLevel: 2,
platform: this.platform, platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape, windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug,
}; };
const mms = this.pattern.map(p => new Minimatch(p, mmo)); const mms = this.pattern.map(p => new Minimatch(p, mmo));
const [matchSet, globParts] = mms.reduce((set, m) => { const [matchSet, globParts] = mms.reduce((set, m) => {
@@ -173,8 +170,7 @@ export class Glob {
// coerce them into the right shape. It will have already called // coerce them into the right shape. It will have already called
// realpath() if the option was set to do so, so we know that's cached. // realpath() if the option was set to do so, so we know that's cached.
// start out knowing the cwd, at least // start out knowing the cwd, at least
return [ return await new GlobWalker(this.patterns, this.scurry.cwd, {
...(await new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts, ...this.opts,
maxDepth: this.maxDepth !== Infinity ? maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth() this.maxDepth + this.scurry.cwd.depth()
@@ -182,12 +178,10 @@ export class Glob {
platform: this.platform, platform: this.platform,
nocase: this.nocase, nocase: this.nocase,
includeChildMatches: this.includeChildMatches, includeChildMatches: this.includeChildMatches,
}).walk()), }).walk();
];
} }
walkSync() { walkSync() {
return [ return new GlobWalker(this.patterns, this.scurry.cwd, {
...new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts, ...this.opts,
maxDepth: this.maxDepth !== Infinity ? maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth() this.maxDepth + this.scurry.cwd.depth()
@@ -195,8 +189,7 @@ export class Glob {
platform: this.platform, platform: this.platform,
nocase: this.nocase, nocase: this.nocase,
includeChildMatches: this.includeChildMatches, includeChildMatches: this.includeChildMatches,
}).walkSync(), }).walkSync();
];
} }
stream() { stream() {
return new GlobStream(this.patterns, this.scurry.cwd, { return new GlobStream(this.patterns, this.scurry.cwd, {
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAGL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKpD,4CAA4C;AAC5C,gDAAgD;AAChD,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,OAAO,CAAA;AAkWX;;GAEG;AACH,MAAM,OAAO,IAAI;IACf,QAAQ,CAAU;IAClB,GAAG,CAAQ;IACX,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,WAAW,CAAS;IACpB,MAAM,CAAS;IACf,MAAM,CAAiC;IACvC,aAAa,CAAS;IACtB,IAAI,CAAU;IACd,SAAS,CAAS;IAClB,QAAQ,CAAQ;IAChB,OAAO,CAA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AI,CAAC,MAAM,CAAC,MAAM,CAAA;QAEhC,8DAA8D;QAC9D,0DAA0D;QAC1D,6DAA6D;QAC7D,kCAAkC;QAClC,MAAM,eAAe,GACnB,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAA;QAEzD,MAAM,GAAG,GAAqB;YAC5B,cAAc,EAAE,MAAM;YACtB,GAAG,IAAI;YACP,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,mCAAmC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe;YACf,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI;YACd,iBAAiB,EAAE,CAAC;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAA;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QACxD,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CACtC,CAAC,GAA0B,EAAE,CAAC,EAAE,EAAE;YAChC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;YACrB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;YAC3B,Line truncated
+1 -1
View File
@@ -1,4 +1,4 @@
import { GlobOptions } from './glob.js'; import type { GlobOptions } from './glob.js';
/** /**
* Return true if the patterns provided contain any magic glob characters, * Return true if the patterns provided contain any magic glob characters,
* given the options provided. * given the options provided.
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"has-magic.d.ts","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GACnB,SAAS,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAS,WAAgB,KACxB,OAQF,CAAA"} {"version":3,"file":"has-magic.d.ts","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GACnB,SAAS,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAS,WAAgB,KACxB,OAKF,CAAA"}
+1 -4
View File
@@ -11,10 +11,7 @@ import { Minimatch } from 'minimatch';
* is in the options, brace expansion _is_ treated as a pattern having magic. * is in the options, brace expansion _is_ treated as a pattern having magic.
*/ */
export const hasMagic = (pattern, options = {}) => { export const hasMagic = (pattern, options = {}) => {
if (!Array.isArray(pattern)) { for (const p of Array.isArray(pattern) ? pattern : [pattern]) {
pattern = [pattern];
}
for (const p of pattern) {
if (new Minimatch(p, options).hasMagic()) if (new Minimatch(p, options).hasMagic())
return true; return true;
} }
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"has-magic.js","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAA0B,EAC1B,UAAuB,EAAE,EAChB,EAAE;IACX,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;YAAE,OAAO,IAAI,CAAA;IACvD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { Minimatch } from 'minimatch'\nimport { GlobOptions } from './glob.js'\n\n/**\n * Return true if the patterns provided contain any magic glob characters,\n * given the options provided.\n *\n * Brace expansion is not considered \"magic\" unless the `magicalBraces` option\n * is set, as brace expansion just turns one string into an array of strings.\n * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and\n * `'xby'` both do not contain any magic glob characters, and it's treated the\n * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`\n * is in the options, brace expansion _is_ treated as a pattern having magic.\n */\nexport const hasMagic = (\n pattern: string | string[],\n options: GlobOptions = {},\n): boolean => {\n if (!Array.isArray(pattern)) {\n pattern = [pattern]\n }\n for (const p of pattern) {\n if (new Minimatch(p, options).hasMagic()) return true\n }\n return false\n}\n"]} {"version":3,"file":"has-magic.js","sourceRoot":"","sources":["../../src/has-magic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAA0B,EAC1B,UAAuB,EAAE,EAChB,EAAE;IACX,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,IAAI,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE;YAAE,OAAO,IAAI,CAAA;IACvD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { Minimatch } from 'minimatch'\nimport type { GlobOptions } from './glob.js'\n\n/**\n * Return true if the patterns provided contain any magic glob characters,\n * given the options provided.\n *\n * Brace expansion is not considered \"magic\" unless the `magicalBraces` option\n * is set, as brace expansion just turns one string into an array of strings.\n * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and\n * `'xby'` both do not contain any magic glob characters, and it's treated the\n * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`\n * is in the options, brace expansion _is_ treated as a pattern having magic.\n */\nexport const hasMagic = (\n pattern: string | string[],\n options: GlobOptions = {},\n): boolean => {\n for (const p of Array.isArray(pattern) ? pattern : [pattern]) {\n if (new Minimatch(p, options).hasMagic()) return true\n }\n return false\n}\n"]}
+16 -4
View File
@@ -1,6 +1,7 @@
import { Minimatch, MinimatchOptions } from 'minimatch'; import type { MinimatchOptions } from 'minimatch';
import { Path } from 'path-scurry'; import { Minimatch } from 'minimatch';
import { GlobWalkerOpts } from './walker.js'; import type { Path } from 'path-scurry';
import type { GlobWalkerOpts } from './walker.js';
export interface IgnoreLike { export interface IgnoreLike {
ignored?: (p: Path) => boolean; ignored?: (p: Path) => boolean;
childrenIgnored?: (p: Path) => boolean; childrenIgnored?: (p: Path) => boolean;
@@ -16,7 +17,18 @@ export declare class Ignore implements IgnoreLike {
absoluteChildren: Minimatch[]; absoluteChildren: Minimatch[];
platform: NodeJS.Platform; platform: NodeJS.Platform;
mmopts: MinimatchOptions; mmopts: MinimatchOptions;
constructor(ignored: string[], { nobrace, nocase, noext, noglobstar, platform, }: GlobWalkerOpts); /**
* The escaped glob for the directory that a pattern starting with
* `/` is rooted at, with no trailing `/`.
*/
slashRoot: string;
/**
* Patterns that start with `/` (but not drive letters or UNC paths
* on Windows) start at the `root` option if it is set, or else at
* the root of `cwd`, the same as non-ignored patterns. If `cwd` is
* not provided, they start at `/`.
*/
constructor(ignored: string[], { nobrace, nocase, noext, noglobstar, normalize, platform, root, windowsPathsNoEscape, allowWindowsEscape, }: GlobWalkerOpts, cwd?: Path);
add(ign: string): void; add(ign: string): void;
ignored(p: Path): boolean; ignored(p: Path): boolean;
childrenIgnored(p: Path): boolean; childrenIgnored(p: Path): boolean;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;IACtC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAWD;;GAEG;AACH,qBAAa,MAAO,YAAW,UAAU;IACvC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAA;IACzB,MAAM,EAAE,gBAAgB,CAAA;gBAGtB,OAAO,EAAE,MAAM,EAAE,EACjB,EACE,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,QAA0B,GAC3B,EAAE,cAAc;IAqBnB,GAAG,CAAC,GAAG,EAAE,MAAM;IAyCf,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;IAczB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;CAWlC"} {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAU,SAAS,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;IACtC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAWD;;GAEG;AACH,qBAAa,MAAO,YAAW,UAAU;IACvC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,SAAS,EAAE,CAAA;IAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAA;IACzB,MAAM,EAAE,gBAAgB,CAAA;IACxB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EAAE,EACjB,EACE,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAA0B,EAC1B,IAAI,EACJ,oBAAoB,EACpB,kBAAkB,GACnB,EAAE,cAAc,EACjB,GAAG,CAAC,EAAE,IAAI;IA8BZ,GAAG,CAAC,GAAG,EAAE,MAAM;IA6Cf,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;IAczB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO;CAWlC"}
+25 -5
View File
@@ -2,7 +2,7 @@
// a given path should be ignored. // a given path should be ignored.
// Ignoring a path ignores its children if the pattern ends in /** // Ignoring a path ignores its children if the pattern ends in /**
// Ignores are always parsed in dot:true mode // Ignores are always parsed in dot:true mode
import { Minimatch } from 'minimatch'; import { escape, Minimatch } from 'minimatch';
import { Pattern } from './pattern.js'; import { Pattern } from './pattern.js';
const defaultPlatform = (typeof process === 'object' && const defaultPlatform = (typeof process === 'object' &&
process && process &&
@@ -19,23 +19,40 @@ export class Ignore {
absoluteChildren; absoluteChildren;
platform; platform;
mmopts; mmopts;
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform, }) { /**
* The escaped glob for the directory that a pattern starting with
* `/` is rooted at, with no trailing `/`.
*/
slashRoot;
/**
* Patterns that start with `/` (but not drive letters or UNC paths
* on Windows) start at the `root` option if it is set, or else at
* the root of `cwd`, the same as non-ignored patterns. If `cwd` is
* not provided, they start at `/`.
*/
constructor(ignored, { nobrace, nocase, noext, noglobstar, normalize, platform = defaultPlatform, root, windowsPathsNoEscape, allowWindowsEscape, }, cwd) {
this.relative = []; this.relative = [];
this.absolute = []; this.absolute = [];
this.relativeChildren = []; this.relativeChildren = [];
this.absoluteChildren = []; this.absoluteChildren = [];
this.platform = platform; this.platform = platform;
windowsPathsNoEscape =
!!windowsPathsNoEscape || allowWindowsEscape === false;
this.mmopts = { this.mmopts = {
dot: true, dot: true,
nobrace, nobrace,
nocase, nocase,
noext, noext,
noglobstar, noglobstar,
normalize,
optimizationLevel: 2, optimizationLevel: 2,
platform, platform,
nocomment: true, nocomment: true,
nonegate: true, nonegate: true,
windowsPathsNoEscape,
}; };
const slashRoot = cwd?.resolve(root ?? '/').fullpath() ?? '/';
this.slashRoot = escape(slashRoot.replace(/\\/g, '/').replace(/\/$/, ''), { windowsPathsNoEscape });
for (const ign of ignored) for (const ign of ignored)
this.add(ign); this.add(ign);
} }
@@ -68,7 +85,10 @@ export class Ignore {
} }
/* c8 ignore stop */ /* c8 ignore stop */
const p = new Pattern(parsed, globParts, 0, this.platform); const p = new Pattern(parsed, globParts, 0, this.platform);
const m = new Minimatch(p.globString(), this.mmopts); const glob = p.root() === '/' ?
`${this.slashRoot}/${p.rest()?.globString() ?? ''}`
: p.globString();
const m = new Minimatch(glob, this.mmopts);
const children = globParts[globParts.length - 1] === '**'; const children = globParts[globParts.length - 1] === '**';
const absolute = p.isAbsolute(); const absolute = p.isAbsolute();
if (absolute) if (absolute)
@@ -99,8 +119,8 @@ export class Ignore {
return false; return false;
} }
childrenIgnored(p) { childrenIgnored(p) {
const fullpath = p.fullpath() + '/'; const fullpath = `${p.fullpath()}/`;
const relative = (p.relative() || '.') + '/'; const relative = `${p.relative() || '.'}/`;
for (const m of this.relativeChildren) { for (const m of this.relativeChildren) {
if (m.match(relative)) if (m.match(relative))
return true; return true;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,kCAAkC;AAClC,kEAAkE;AAClE,6CAA6C;AAE7C,OAAO,EAAE,SAAS,EAAoB,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAStC,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,OAAO,CAAA;AAEX;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,QAAQ,CAAa;IACrB,gBAAgB,CAAa;IAC7B,QAAQ,CAAa;IACrB,gBAAgB,CAAa;IAC7B,QAAQ,CAAiB;IACzB,MAAM,CAAkB;IAExB,YACE,OAAiB,EACjB,EACE,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,QAAQ,GAAG,eAAe,GACX;QAEjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,IAAI;YACT,O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D,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,eAAe,CAAC,CAAO;QACrB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAA;QACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,GAAG,GAAG,CAAA;QAC5C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["// give it a pattern, and it'll be able to tell you if\n// a given path should be ignored.\n// Ignoring a path ignores its children if the pattern ends in /**\n// Ignores are always parsed in dot:true mode\n\nimport { Minimatch, MinimatchOptions } from 'minimatch'\nimport { Path } from 'path-scurry'\nimport { Pattern } from './pattern.js'\nimport { GlobWalkerOpts } from './walker.js'\n\nexport interface IgnoreLike {\n ignored?: (p: Path) => boolean\n childrenIgnored?: (p: Path) => boolean\n add?: (ignore: string) => void\n}\n\nconst defaultPlatform: NodeJS.Platform =\n (\n typeof process === 'object' &&\n process &&\n typeof process.platform === 'string'\n ) ?\n process.platform\n : 'linux'\n\n/**\n * Class used to process ignored patterns\n */\nexport class Ignore implements IgnoreLike {\n relative: Minimatch[]\n relativeChildren: Minimatch[]\n absolute: Minimatch[]\n absoluteChildren: Minimatch[]\n platform: NodeJS.Platform\n mmopts: MinimatchOptions\n\n constructor(\n ignored: string[],\n {\n nobrace,\n nocase,\n noext,\n noglobstar,\n platform = defaultPlatform,\n }: GlobWalkerOpts,\n ) {\n this.relative = []\n this.absolute = []\n this.relativeChildren = []\n this.absoluteChildren = []\n this.platform = platform\n this.mmopts = {\n dot: true,\n nobrace,\n nocase,\n noext,\n noglobstar,\n optimizationLevel: 2,\n platform,\n nocomment: true,\n nonegate: true,\n }\n for (const ign of ignored) this.add(ign)\n }\n\n add(igLine truncated {"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/ignore.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,kCAAkC;AAClC,kEAAkE;AAClE,6CAA6C;AAG7C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAStC,MAAM,eAAe,GACnB,CACE,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAC,CAAC;IACD,OAAO,CAAC,QAAQ;IAClB,CAAC,CAAC,OAAO,CAAA;AAEX;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,QAAQ,CAAa;IACrB,gBAAgB,CAAa;IAC7B,QAAQ,CAAa;IACrB,gBAAgB,CAAa;IAC7B,QAAQ,CAAiB;IACzB,MAAM,CAAkB;IACxB;;;OAGG;IACH,SAAS,CAAQ;IAEjB;;;;;OAKG;IACH,YACE,OAAiB,EACjB,EACE,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,GAAG,eAAe,EAC1B,IAAI,EACJ,oBAAoB,EACpB,kBAAkB,GACH,EACjB,GAAU;QAEV,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,oBAAoB;YAClB,CAAC,CAAC,oBAAoB,IAAI,kBAAkB,KAA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GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC7B,MAAM,SAAS,GAAG,GAAG,QAAQ,GAAG,CAAA;QAChC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAA;QACpC,MAAM,SAAS,GAAG,GAAG,QAAQ,GAAG,CAAA;QAChC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;gBAAE,OAAO,IAAI,CAAA;QAC1D,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;gBAAE,OAAO,IAAI,CAAA;QAC1D,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,eAAe,CAAC,CAAO;QACrB,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAA;QACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,GAAG,GAAG,CAAA;QAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["// give it a pattern, and it'll be able to tell you if\n// a given path should be ignored.\n// Ignoring a path ignores its children if the pattern ends in /**\n// Ignores are always parsed in dot:true mode\n\nimport type { MinimatchOptions } from 'minimatch'\nimport { escape, Minimatch } from 'minimatch'\nimport type { Path } from 'path-scurry'\nimport { Pattern } from './pattern.js'\nimport type { GlobWalkerOpts } from './walker.js'\n\nexport interface IgnoreLike {\n ignored?: (p: Path) => boolean\n childrenIgnored?: (p: Path) => boolean\n add?: (ignore: string) => void\n}\n\nconst defaultPlatform: NodeJS.Platform =\n (\n typeof process === 'object' &&\n process &&\n typeof process.platform === 'string'\n ) ?\n process.platform\n : 'linux'\n\n/**\n * Class used to process ignored patterns\n */\nexport class Ignore implements IgnoreLike {\n relative: Minimatch[]\n relativeChildren: Minimatch[]\n absolute: Minimatch[]\n absoluteChildren: Minimatch[]\n Line truncated
+3 -2
View File
@@ -1,8 +1,9 @@
import { Minipass } from 'minipass'; import type { Minipass } from 'minipass';
import { Path } from 'path-scurry'; import type { Path } from 'path-scurry';
import type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset } from './glob.js'; import type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset } from './glob.js';
import { Glob } from './glob.js'; import { Glob } from './glob.js';
export { escape, unescape } from 'minimatch'; export { escape, unescape } from 'minimatch';
export type { Form } from 'minimatch';
export type { FSOption, Path, WalkOptions, WalkOptionsWithFileTypesTrue, WalkOptionsWithFileTypesUnset, } from 'path-scurry'; export type { FSOption, Path, WalkOptions, WalkOptionsWithFileTypesTrue, WalkOptionsWithFileTypesUnset, } from 'path-scurry';
export { Glob } from './glob.js'; export { Glob } from './glob.js';
export type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset, } from './glob.js'; export type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset, } from './glob.js';
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":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EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAA;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IAChD,IAAI,EAAE,eAAe;CACtB,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC1C,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,eAAe;CACzB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,KAAK;IACX,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,MAAM;IACN,cAAc;IACd,UAAU;IACV,WAAW;IACX,OAAO;IACP,eAAe;IACf,WAAW;IACX,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,QAAQ;CACT,CAAC,CAAA;AACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA","sourcesContent":["import { escape, unescape } from 'minimatch'\nimport { Minipass } from 'minipass'\nimport { Path } from 'path-scurry'\nimport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nimport { Glob } from './glob.js'\nimport { hasMagic } from './has-magic.js'\n\nexport { escape, unescape } from 'minimatch'\nexport type {\n FSOption,\n Path,\n WalkOptions,\n WalkOptionsWithFileTypesTrue,\n WalkOptionsWithFileTypesUnset,\n} from 'path-scurry'\nexport { Glob } from './glob.js'\nexport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nexport { hasMagic } from './has-magic.js'\nexport { Ignore } from './ignore.js'\nexport type { IgnoreLike } from './ignore.js'\nexport type { MatchStream } from './walker.js'\n\n/**\n * Syncronous form of {@link globStream}. Will read all the matches as fast as\n * you consume them, even all in a single tick if you consume them immediately,\n * but will still respond to backpressure if they're not consumed immediately.\n */\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesUnset,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).streamSync()\n}\n\n/**\n * Return a stream that emits all the strings or `Path` objects and\n * then emits `end` when completed.\n */\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStream(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).stream()\n}\n\n/**\n * Synchronous form of {@link glob}\n */\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Path[]\nexport function globSync(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobLine truncated {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAS5C,OAAO,EAAE,IAAI,EAAE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M,UAAU,GAAG,cAAc,CAAA;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAA;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IAChD,IAAI,EAAE,eAAe;CACtB,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC1C,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,eAAe;CACzB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,KAAK;IACX,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,MAAM;IACN,cAAc;IACd,UAAU;IACV,WAAW;IACX,OAAO;IACP,eAAe;IACf,WAAW;IACX,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,QAAQ;CACT,CAAC,CAAA;AACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA","sourcesContent":["import { escape, unescape } from 'minimatch'\nimport type { Minipass } from 'minipass'\nimport type { Path } from 'path-scurry'\nimport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nimport { Glob } from './glob.js'\nimport { hasMagic } from './has-magic.js'\n\nexport { escape, unescape } from 'minimatch'\nexport type { Form } from 'minimatch'\nexport type {\n FSOption,\n Path,\n WalkOptions,\n WalkOptionsWithFileTypesTrue,\n WalkOptionsWithFileTypesUnset,\n} from 'path-scurry'\nexport { Glob } from './glob.js'\nexport type {\n GlobOptions,\n GlobOptionsWithFileTypesFalse,\n GlobOptionsWithFileTypesTrue,\n GlobOptionsWithFileTypesUnset,\n} from './glob.js'\nexport { hasMagic } from './has-magic.js'\nexport { Ignore } from './ignore.js'\nexport type { IgnoreLike } from './ignore.js'\nexport type { MatchStream } from './walker.js'\n\n/**\n * Syncronous form of {@link globStream}. Will read all the matches as fast as\n * you consume them, even all in a single tick if you consume them immediately,\n * but will still respond to backpressure if they're not consumed immediately.\n */\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesUnset,\n): Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStreamSync(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).streamSync()\n}\n\n/**\n * Return a stream that emits all the strings or `Path` objects and\n * then emits `end` when completed.\n */\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Minipass<Path, Path>\nexport function globStream(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions,\n): Minipass<Path, Path> | Minipass<string, string>\nexport function globStream(\n pattern: string | string[],\n options: GlobOptions = {},\n) {\n return new Glob(pattern, options).stream()\n}\n\n/**\n * Synchronous form of {@link glob}\n */\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesFalse,\n): string[]\nexport function globSync(\n pattern: string | string[],\n options: GlobOptionsWithFileTypesTrue,\n): Path[]\nexport function globSync(\n pattern: string | string[],\n options?: GlobOptionsWithFileTypesUnset | undefined,\n): string[]\nexport function globSyncLine truncated
+2 -3
View File
@@ -1,4 +1,3 @@
var Gt=(n,t,e)=>{let s=n instanceof RegExp?ce(n,e):n,i=t instanceof RegExp?ce(t,e):t,r=s!==null&&i!=null&&ss(s,i,e);return r&&{start:r[0],end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+s.length,r[1]),post:e.slice(r[1]+i.length)}},ce=(n,t)=>{let e=t.match(n);return e?e[0]:null},ss=(n,t,e)=>{let s,i,r,o,h,a=e.indexOf(n),l=e.indexOf(t,a+1),u=a;if(a>=0&&l>0){if(n===t)return[a,l];for(s=[],r=e.length;u>=0&&!h;){if(u===a)s.push(u),a=e.indexOf(n,u+1);else if(s.length===1){let c=s.pop();c!==void 0&&(h=[c,l])}else i=s.pop(),i!==void 0&&i<r&&(r=i,o=l),l=e.indexOf(t,u+1);u=a<l&&a>=0?a:l}s.length&&o!==void 0&&(h=[r,o])}return h};var fe="\0SLASH"+Math.random()+"\0",ue="\0OPEN"+Math.random()+"\0",qt="\0CLOSE"+Math.random()+"\0",de="\0COMMA"+Math.random()+"\0",pe="\0PERIOD"+Math.random()+"\0",is=new RegExp(fe,"g"),rs=new RegExp(ue,"g"),ns=new RegExp(qt,"g"),os=new RegExp(de,"g"),hs=new RegExp(pe,"g"),as=/\\\\/g,ls=/\\{/g,cs=/\\}/g,fs=/\\,/g,us=/\\./g,ds=1e5;function Ht(n){return isNaN(n)?n.charCodeAt(0):parseInt(n,10)}function ps(n){return n.replace(as,fe).replace(ls,ue).replace(cs,qt).replace(fs,de).replace(us,pe)}function ms(n){return n.replace(is,"\\").replace(rs,"{").replace(ns,"}").replace(os,",").replace(hs,".")}function me(n){if(!n)return[""];let t=[],e=Gt("{","}",n);if(!e)return n.split(",");let{pre:s,body:i,post:r}=e,o=s.split(",");o[o.length-1]+="{"+i+"}";let h=me(r);return r.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),t.push.apply(t,o),t}function ge(n,t={}){if(!n)return[];let{max:e=ds}=t;return n.slice(0,2)==="{}"&&(n="\\{\\}"+n.slice(2)),ht(ps(n),e,!0).map(ms)}function gs(n){return"{"+n+"}"}function ws(n){return/^-?0\d/.test(n)}function ys(n,t){return n<=t}function bs(n,t){return n>=t}function ht(n,t,e){let s=[],i=Gt("{","}",n);if(!i)return[n];let r=i.pre,o=i.post.length?ht(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let h=0;h<o.length&&h<t;h++){let a=r+"{"+i.body+"}"+o[h];s.push(a)}else{let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=h||a,u=i.body.indexOf(",")>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(n=i.pre+"{"+i.body+qt+i.post,ht(n,t,!0)):[n];let c;if(l)c=i.body.split(/\.\./);else if(c=me(i.body),c.length===1&&c[0]!==void 0&&(c=ht(c[0],t,!1).map(gs),c.length===1))return o.map(f=>i.pre+c[0]+f);let d;if(l&&c[0]!==void 0&&c[1]!==void 0){let f=Ht(c[0]),m=Ht(c[1]),p=Math.max(c[0].length,c[1].length),w=c.length===3&&c[2]!==void 0?Math.abs(Ht(c[2])):1,g=ys;m<f&&(w*=-1,g=bs);let E=c.some(ws);d=[];for(let y=f;g(y,m);y+=w){let b;if(a)b=String.fromCharCode(y),b==="\\"&&(b="");else if(b=String(y),E){let z=p-b.length;if(z>0){let $=new Array(z+1).join("0");y<0?b="-"+$+b.slice(1):b=$+b}}d.push(b)}}else{d=[];for(let f=0;f<c.length;f++)d.push.apply(d,ht(c[f],t,!1))}for(let f=0;f<d.length;f++)for(let m=0;m<o.length&&s.length<t;m++){let p=r+d[f]+o[m];(!e||l||p)&&s.push(p)}}return s}var at=n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")};var Ss={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},lt=n=>n.replace(/[[\]\\-]/g,"\\$&"),Es=n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),we=n=>n.join(""),ye=(n,t)=>{let e=t;if(n.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=e+1,o=!1,h=!1,a=!1,l=!1,u=e,c="";t:for(;r<n.length;){let p=n.charAt(r);if((p==="!"||p==="^")&&r===e+1){l=!0,r++;continue}if(p==="]"&&o&&!a){u=r+1;break}if(o=!0,p==="\\"&&!a){a=!0,r++;continue}if(p==="["&&!a){for(let[w,[g,S,E]]of Object.entries(Ss))if(n.startsWith(w,r)){if(c)return["$.",!1,n.length-e,!0];r+=w.length,E?i.push(g):s.push(g),h=h||S;continue t}}if(a=!1,c){p>c?s.push(lt(c)+"-"+lt(p)):p===c&&s.push(lt(p)),c="",r++;continue}if(n.startsWith("-]",r+1)){s.push(lt(p+"-")),r+=2;continue}if(n.startsWith("-",r+1)){c=p,r+=2;continue}s.push(lt(p)),r++}if(u<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,n.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!l){let p=s[0].length===2?s[0].slice(-1):s[0];return[Es(p),!1,u-e,!1]}let d="["+(l?"^":"")+we(s)+"]",f="["+(l?"":"^")+we(i)+"]";return[s.length&&i.length?"("+d+"|"+f+")":s.length?d:f,h,u-e,!0]};var W=(n,{windowsPathsNoEscape:t=!1,magicalBraces:e=!0}={})=>e?t?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?n.replace(/\[([^\/\\{}])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var xs=new Set(["!","?","+","*","@"]),be=n=>xs.has(n),vs="(?!(?:^|/)\\.\\.?(?:$|/))",Ct="(?!\\.)",Cs=new Set(["[","."]),Ts=new Set(["..","."]),As=newLine truncated var se=(r,t,e)=>{let s=r instanceof RegExp?De(r,e):r,i=t instanceof RegExp?De(t,e):t,n=s!==null&&i!=null&&Ms(s,i,e);return n&&{start:n[0],end:n[1],pre:e.slice(0,n[0]),body:e.slice(n[0]+s.length,n[1]),post:e.slice(n[1]+i.length)}},De=(r,t)=>{let e=t.match(r);return e?e[0]:null},Ms=(r,t,e)=>{let s,i,n,o,a,h=e.indexOf(r),l=e.indexOf(t,h+1),c=h;if(h>=0&&l>0){if(r===t)return[h,l];for(s=[],n=e.length;c>=0&&!a;){if(c===h)s.push(c),h=e.indexOf(r,c+1);else if(s.length===1){let f=s.pop();f!==void 0&&(a=[f,l])}else i=s.pop(),i!==void 0&&i<n&&(n=i,o=l),l=e.indexOf(t,c+1);c=h<l&&h>=0?h:l}s.length&&o!==void 0&&(a=[n,o])}return a};var Ne="\0SLASH"+Math.random()+"\0",Pe="\0OPEN"+Math.random()+"\0",oe="\0CLOSE"+Math.random()+"\0",ze="\0COMMA"+Math.random()+"\0",Le="\0PERIOD"+Math.random()+"\0",Ts=new RegExp(Ne,"g"),Fs=new RegExp(Pe,"g"),_s=new RegExp(oe,"g"),Ds=new RegExp(ze,"g"),Ns=new RegExp(Le,"g"),Ps=/\\\\/g,zs=/\\{/g,Ls=/\\}/g,js=/\\,/g,Ws=/\\\./g,$s=1e5,Bs=4e6,Is=1e3,Us=1e3;function ie(r){return isNaN(r)?r.charCodeAt(0):parseInt(r,10)}function Gs(r){return r.replace(Ps,Ne).replace(zs,Pe).replace(Ls,oe).replace(js,ze).replace(Ws,Le)}function Hs(r){return r.replace(Ts,"\\").replace(Fs,"{").replace(_s,"}").replace(Ds,",").replace(Ns,".")}function ne(r,t){for(let e=0;e<t.length;e++)r.push(t[e])}function qs(r){let t=[],e="";for(;;){let s=se("{","}",r);if(!s){let h=r.split(",");return h[0]=e+h[0],ne(t,h),t}let{pre:i,body:n,post:o}=s,a=i.split(",");if(a[0]=e+a[0],a[a.length-1]+="{"+n+"}",!o.length)return ne(t,a),t;e=a.pop(),ne(t,a),r=o}}function je(r,t={}){if(!r)return[];let{max:e=$s,maxLength:s=Bs,maxDepth:i=Is,maxRewrites:n=Us}=t;return r.slice(0,2)==="{}"&&(r="\\{\\}"+r.slice(2)),re(Gs(r),e,s,i,0,n,!0).map(Hs)}function Ks(r){return"{"+r+"}"}function Xs(r){return/^-?0\d/.test(r)}function Vs(r,t){return r<=t}function Ys(r,t){return r>=t}function lt(r,t,e,s,i,n){let o=[],a=0;for(let h=0;h<r.length;h++)for(let l=0;l<e.length;l++){if(o.length>=s)return o;let c=r[h]+t+e[l];if(!(n&&!c)){if(a+c.length>i)return o;o.push(c),a+=c.length}}return o}function Zs(r,t,e,s){let i=r.split(/\.\./),n=[];if(i[0]===void 0||i[1]===void 0)return n;let o=ie(i[0]),a=ie(i[1]),h=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(ie(i[2])),1):1,c=Vs;a<o&&(l*=-1,c=Ys);let p=i.some(Xs),d=0;for(let g=o;c(g,a)&&n.length<e;g+=l){let u;if(t)u=String.fromCharCode(g),u==="\\"&&(u="");else if(u=String(g),p){let w=h-u.length;if(w>0){let m=new Array(w+1).join("0");g<0?u="-"+m+u.slice(1):u=m+u}}if(d+u.length>s)break;n.push(u),d+=u.length}return n}function re(r,t,e,s,i,n,o){if(i>s)return[r];let a=[""],h=0,l=!1,c=!0;for(;;){let f=se("{","}",r);if(!f)return lt(a,r,[""],t,e,l);let p=f.pre;if(/\$$/.test(p)){if(a=lt(a,p+"{"+f.body+"}",[""],t,e,l&&!f.post.length),c=!1,!f.post.length)break;r=f.post;continue}let d=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(f.body),g=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(f.body),u=d||g,w=f.body.indexOf(",")>=0;if(!u&&!w){if(h<n&&f.post.match(/,(?!,).*\}/)){h++,r=f.pre+"{"+f.body+oe+f.post,o=!0;continue}return lt(a,p+"{"+f.body+"}"+f.post,[""],t,e,l)}c&&(l=o&&!u,c=!1);let m;if(u)m=Zs(f.body,g,t,e);else{let b=qs(f.body);if(b.length===1&&b[0]!==void 0&&(b=re(b[0],t,e,s,i+1,n,!1).map(Ks),b.length===1)){if(a=lt(a,p+b[0],[""],t,e,l&&!f.post.length),!f.post.length)break;r=f.post;continue}let v=l&&!f.post.length&&!p;for(let y=0;v&&y<a.length;y++)a[y]&&(v=!1);m=[];let S=0;t:for(let y=0;y<b.length;y++){let q=re(b[y],t,e,s,i+1,n,!1);for(let W=0;W<q.length;W++){let I=q[W];if(!(v&&!I)){if(m.length>=t||S+I.length>e)break t;m.push(I),S+=I.length}}}}if(a=lt(a,p,m,t,e,l&&!f.post.length),!f.post.length)break;r=f.post}return a}var Js={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}"],"[:alpha:]":["\\p{L}\\p{Nl}"],"[:ascii:]":["\\x00-\\x7f"],"[:blank:]":["\\p{Zs}\\t"],"[:cntrl:]":["\\p{Cc}"],"[:digit:]":["\\p{Nd}"],"[:graph:]":["\\p{Z}\\p{C}",!0],"[:lower:]":["\\p{Ll}"],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}\\p{S}"],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f"],"[:upper:]":["\\p{Lu}"],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],"[:xdigit:]":["A-Fa-f0-9"]},ct=r=>r.replace(/[[\]\\-]/g,"\\$&"),he=/$./,We=(r,t,e=!1,s)=>{let i=m=>{let b=s?m.normalize(s):m;return[...b].length===1?b:m},n=t;if(r.charAt(n)!=="[")throw new Error("not in a brace expression");let o=[],a=[],h=n+1,l=!1,c=!1,f=!1,p=n,d="";t:for(;h<r.length;){let m=String.fromCodePoint(r.codePointAt(h));if((m==="!"||m==="^")&&h===n+1){f=!0,h++;continue}if(m==="]"&&l&&!c){p=h+1;break}if(l=!0,m==="\\"&&!c){c=!0,h++;continue}if(m==="["&&!c){for(let[v,[S,y]]of Object.entries(Js))if(r.startsWith(v,h)){if(d)return[he,r.length-n];h+=v.length,y?a.push(S):o.push(S);continue t}}c=!1;let b=i(m);if(d){b.codePointAt(0)>d.codePointAt(0)?o.push(ct(d)+"-"+ct(b)):b===d&&o.push(ct(b)),d="",h+=m.length;continue}if(r.startsWith("-]",h+m.length)){o.push(ct(b+"-")),h+=m.length+1;continue}if(r.startsWith("-",h+m.length)){d=b,h+=m.length+1;continue}o.push(ct(b)),h+=m.length}if(p<h)return[he,0];if(!o.length&&!a.leLine truncated
globstar while`,t,d,e,f,m),this.matchOne(t.slice(d),e.slice(f),s))return this.debug("globstar found match!",d,a,m),!0;if(m==="."||m===".."||!i.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,d,e,f);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(s&&(this.debug(` `)},ce=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(t){this.gen=t}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}},He=(r,t)=>r.ids.length!==t.ids.length||r.runs.length!==t.runs.length||r.ids.some((e,s)=>e!==t.ids[s])?!1:r.runs.every(e=>t.runs.some(s=>s.neg===e.neg&&He(s.state,e.state))),$e=r=>({has:new Float64Array(r),seen:new Float64Array(r),gen:0}),ft=class{dots;dotStart;#t;constructor(t,e,s){this.dots=t,this.dotStart=e,this.#t=s}state(){return new ce(++this.#t.gen)}done(t){return t.ids=t.threads.map(e=>e.id).sort((e,s)=>e-s),t.match&&t.ids.unshift(ae.id),t}#i(t,e){let{seen:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,!0)}#e(t,e){let{has:s}=this.#t;return s[e.id]===t.gen?!1:(s[e.id]=t.gen,t.threads.push(e),!0)}restricted(t,e){return e&&(this.dots||this.dotStart&&t===0)}add(t,e,s,i){switch(e.t){case"split":if(!this.#i(t,e))return;for(let o of e.out)this.add(t,o,s,i);return;case"neg":if(!this.#i(t,e))return;let n=this.state();return this.add(n,e.sub,s,!1),this.done(n),this.addRun(t,{t:"run",neg:e,state:n},s,i);case"star":if(this.restricted(s,i))return;this.#e(t,e)&&this.add(t,e.next,s,i);return;case"match":t.match=!0;return;default:this.#e(t,e)}}addRun(t,e,s,i){for(let n of t.runs)if(n.neg===e.neg&&He(n.state,e.state))return;t.runs.push(e),e.state.match||this.add(t,e.neg.next,s,i)}step(t,e,s,i){let n=this.state();for(let o of t.threads)switch(o.t){case"lit":ue(o,e)&&this.add(n,o.next,s+1,i);break;case"any":this.restricted(s,i)||this.add(n,o.next,s+1,i);break;case"class":!this.restricted(s,i)&&o.re.test(e)&&this.add(n,o.next,s+1,i);break;case"star":this.restricted(s,i)||this.add(n,o,s+1,i)}if(!this.restricted(s,i))for(let o of t.runs){if(o.state.dead){this.addRun(n,o,s+1,i);continue}let a=this.step(o.state,e,s,!1);this.addRun(n,{t:"run",neg:o.neg,state:a},s+1,i)}return this.done(n)}},qe=r=>{let t=r.ids.join();if(!r.runs.length)return t;let e=r.runs.map(s=>`${s.neg.id}(${qe(s.state)})`);return`${t}|${e.sort().join("|")}`},ri=1<<18,fe=class{#t;#i=new Map;#e=0;#o;#r;#d;#c;constructor(t,e){this.#t=t,this.#d=new ft(!1,!1,e),this.#c=new ft(!1,!0,e)}#p(t){return{state:t,match:t.match,dead:t.dead,next:new Map}}#h(t){let e=qe(t),s=this.#i.get(e);if(s)return s;this.#e>ri&&this.#m();let i=this.#p(t);return this.#i.set(e,i),this.#e+=e.length+1,i}#m(){this.#i.clear(),this.#e=0,this.#o=void 0,this.#r=void 0}start(t){if(t){if(this.#r)return this.#r;let s=this.#c.state();return this.#c.add(s,this.#t,0,!0),this.#r=this.#p(this.#c.done(s))}if(this.#o)return this.#o;let e=this.#d.state();return this.#d.add(e,this.#t,0,!0),this.#o=this.#h(this.#d.done(e))}next(t,e){let s=e.charCodeAt(0),i=s<128?void 0:t.next.get(e);if(i)return i;let n=t===this.#r?this.#h(this.#c.step(t.state,e,0,!0)):this.#h(this.#d.step(t.state,e,1,!0));return s<128?(t.ascii||(t.ascii=new Array(128),this.#e+=128),t.ascii[s]=n):t.next.set(e,n),this.#e++,n}},oi=r=>{let t=[];for(let e=r;e.t!=="match";e=e.next){if(e.t==="split"||e.t==="neg")return;t.push(e)}return t},hi=(r,t,e,s)=>{let i=0,n=e,o=-1,a=0;for(;n<s;){let h=r[i];if(h?.t==="star"){o=i++,a=n;continue}let l=t[n];if(h&&(h.t==="any"||h.t==="lit"&&ue(h,l)||h.t==="class"&&h.re.test(l))){i++,n++;continue}if(o===-1)return!1;i=o+1,n=++a}for(;r[i]?.t==="star";)i++;return i===r.length},Ke=r=>{let t=0,e=0;for(let s of r){let[i,n]=ai(s);t+=i,e+=n}return[t,e]},ai=r=>{if(r.t==="star")return[0,1/0];if(r.t!=="ext")return[1,1];if(r.type==="!")return[0,1/0];let t=r.alts.map(Ke),e=Math.min(...t.map(n=>n[0])),s=Math.max(...t.map(n=>n[1])),i=s===0?0:1/0;return r.type==="@"?[e,s]:r.type==="?"?[0,s]:r.type==="*"?[0,i]:[e,i]},Be=(r,t,e)=>{for(let s=0;s<r.length;s++)if(!ue(r[s],t[e+s]))return!1;return!0},li=/[/\ud800-\udfff]/,ci=/[\ud800-\udfff]/,Ft=r=>ci.test(r)?[...r]:r,Ie=r=>{if(r.includes("/"))throw new Error("can only match a single path portion, got: "+r)},ut=class{pattern;options;#t;#i;#e;#o;#r;#d;#c;#p=!1;#h=0;#m=1/0;#a=[];#l=[];#n;#w;#x=!1;#b;#f;constructor(t,e={}){if(t.includes("/"))throw new Error("can only match a single path portion, got pattern: "+t);this.pattern=t,this.options=e;let{nocase:s=!1,noext:i=!1,normalize:n}=e;this.#f=n===!0?"NFC":n||void 0;let o=/^[?*+@]\(\)$/.test(t),a=ei(t,s,i||o,this.#f),[h]=Ue(a,si(a),0,a.length,!0);this.#f&&(h=Ge(h,this.#f));let[l,c]=ii(h,s);if(this.#t=l,this.#i=c,h.every(f=>f.t==="lit"))this.#r=h.map(f=>f.ch).join(""),s&&(this.#d=le(this.#r));else{let f=g=>g.t!=="lit"?void 0:s?{ch:g.ch,re:le(g.ch)}:{ch:g.ch};for(let g of h){let u=f(g);if(!u)break;this.#a.push(u)}for(let g=h.length-1;g>=0;g--){let u=f(h[g]);if(!u)break;this.#l.unshift(u)}this.#x=!!(this.#a.length||this.#l.length),s||(this.#n=this.#a.map(g=>g.ch).join(""),this.#w=this.#l.map(g=>g.ch).join("")),this.#c=oi(this.#t)?.slice(this.#a.length,-this.#l.length||void 0),this.#p=!!this.#c?.every(g=>g.t==="star"||g.t==="any");let[p,d]=Ke(h);this.#h=p,this.#m=d}}test(t){return this.#f?(Ie(t),this.#v(t.normalize(this.#f))):li.test(t)?(Ie(t),this.#v(t,[...t])):this.#v(t,t)}testUnchecked(t) Line truncated
>>> no match, partial?`,t,d,e,f),d===a))}let p;if(typeof u=="string"?(p=c===u,this.debug("string match",u,c,p)):(p=u.test(c),this.debug("pattern match",u,c,p)),!p)return!1}if(o===a&&h===l)return!0;if(o===a)return s;if(h===l)return o===a-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return ke(this.pattern,this.options)}parse(t){at(t);let e=this.options;if(t==="**")return A;if(t==="")return"";let s,i=null;(s=t.match(js))?i=e.dot?zs:Is:(s=t.match(Rs))?i=(e.nocase?e.dot?Ms:Ds:e.dot?Fs:Os)(s[1]):(s=t.match(Bs))?i=(e.nocase?e.dot?$s:Us:e.dot?Gs:Hs)(s):(s=t.match(Ns))?i=e.dot?Ls:_s:(s=t.match(Ws))&&(i=Ps);let r=Q.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Vs:e.dot?Ys:Xs,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(c=>{if(c instanceof RegExp)for(let d of c.flags.split(""))i.add(d);return typeof c=="string"?ei(c):c===A?A:c._src});l.forEach((c,d)=>{let f=l[d+1],m=l[d-1];c!==A||m===A||(m===void 0?f!==void 0&&f!==A?l[d+1]="(?:\\/|"+s+"\\/)?"+f:l[d]=s:f===void 0?l[d-1]=m+"(?:\\/|\\/"+s+")?":f!==A&&(l[d-1]=m+"(?:\\/|\\/"+s+"\\/)"+f,l[d+1]=A))});let u=l.filter(c=>c!==A);if(this.partial&&u.length>=1){let c=[];for(let d=1;d<=u.length;d++)c.push(u.slice(0,d).join("/"));return"(?:"+c.join("|")+")"}return u.join("/")}).join("|"),[o,h]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+h+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+h+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let h=i.length-2;!o&&h>=0;h--)o=i[h];for(let h=0;h<r.length;h++){let a=r[h],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return O.defaults(t).Minimatch}};O.AST=Q;O.Minimatch=D;O.escape=tt;O.unescape=W;import{fileURLToPath as Wi}from"node:url";var si=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Oe=new Set,Vt=typeof process=="object"&&process?process:{},Fe=(n,t,e,s)=>{typeof Vt.emitWarning=="function"?Vt.emitWarning(n,t,e,s):console.error(`[${e}] ${t}: ${n}`)},At=globalThis.AbortController,Re=globalThis.AbortSignal;if(typeof At>"u"){Re=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,s){this._onabort.push(s)}},At=class{constructor(){t()}signal=new Re;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let s of this.signal._onabort)s(e);this.signal.onabort?.(e)}}};let n=Vt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{n&&(n=!1,Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var ii=n=>!Oe.has(n);var q=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),De=n=>q(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(n){super(n),this.fill(0)}},ri=class ct{heap;length;static#t=!1;static create(t){let e=De(t);if(!e)return[];ct.#t=!0;let s=new ct(t,e);return ct.#t=!1,s}constructor(t,e){if(!ct.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ft=class Me{#t;#s;#n;#r;#o;#S;#w;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#h;#u;#f;#a;#i;#d;#E;#b;#p;#R;#m;#C;#T;#g;#y;#x;#A;#e;#_;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#C,keyMap:t.#f,keyList:t.#a,valList:t.#i,next:t.#d,prev:t.#E,get head(){return t.#b},get tail(){return t.#p},free:t.#R,isBackgroundFetch:e=>t.#l(e),backgroundFetch:(e,s,i,r)=>t.#U(e,s,i,r),moveToTail:e=>t.#W(e),indexes:e=>t.#F(e),rindexes:e=>t.#D(e),isStale:e=>t.#v(e)}}get max(){return this. Line truncated
//# sourceMappingURL=index.min.js.map //# sourceMappingURL=index.min.js.map
+4 -4
View File
@@ -1,7 +1,7 @@
{ {
"version": 3, "version": 3,
"sources": ["../../node_modules/balanced-match/src/index.ts", "../../node_modules/brace-expansion/src/index.ts", "../../node_modules/minimatch/src/assert-valid-pattern.ts", "../../node_modules/minimatch/src/brace-expressions.ts", "../../node_modules/minimatch/src/unescape.ts", "../../node_modules/minimatch/src/ast.ts", "../../node_modules/minimatch/src/escape.ts", "../../node_modules/minimatch/src/index.ts", "../../src/glob.ts", "../../node_modules/lru-cache/src/index.ts", "../../node_modules/path-scurry/src/index.ts", "../../node_modules/minipass/src/index.ts", "../../src/pattern.ts", "../../src/ignore.ts", "../../src/processor.ts", "../../src/walker.ts", "../../src/has-magic.ts", "../../src/index.ts"], "sources": ["../../node_modules/balanced-match/src/index.ts", "../../node_modules/brace-expansion/src/index.ts", "../../node_modules/@isaacs/nonrecursive-glob-match/src/parse-class.ts", "../../node_modules/@isaacs/nonrecursive-glob-match/src/index.ts", "../../node_modules/minimatch/src/assert-valid-pattern.ts", "../../node_modules/minimatch/src/escape.ts", "../../node_modules/minimatch/src/unescape.ts", "../../node_modules/minimatch/src/index.ts", "../../src/glob.ts", "../../node_modules/lru-cache/src/diagnostics-channel-node.ts", "../../node_modules/lru-cache/src/perf.ts", "../../node_modules/lru-cache/src/index.ts", "../../node_modules/path-scurry/src/index.ts", "../../node_modules/minipass/src/index.ts", "../../src/pattern.ts", "../../src/ignore.ts", "../../src/processor.ts", "../../src/walker.ts", "../../src/has-magic.ts", "../../src/index.ts"],
"sourcesContent": ["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n", "import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n if (!str) {\n return ['']\n }\n\n const parts: string[] = []\n const m = balanced('{', '}', str)\n\n if (!m) {\n return str.split(',')\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n\n p[p.length - 1] += '{' + body + '}'\n const postParts = parseCommaParts(post)\n if (post.length) {\n ;(p[p.length - 1] as string) += postParts.shift()\n p.push.apply(p, postParts)\n }\n\n parts.push.apply(parts, p)\n\n return parts\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const { max = EXPANSION_MAX } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(escapeBraces(str), max, true).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\nfunction expand_(str: string, max: number, isTop: boolean): string[] {\n /** @type {string[]} */\n const expansions: string[] = []\n\n const m = balanced('{', '}', str)\n if (!m) return [str]\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n Line truncated "sourcesContent": ["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n", "import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\n// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An\n// input like `'{a,b}'.repeat(1500)` stays under that count - its output is\n// truncated to 100k results - while making every result ~1500 characters\n// long. The result set, and the intermediate arrays built while combining\n// brace sets, then grow large enough to exhaust memory and crash the process\n// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of\n// characters the accumulator may hold at any point, so memory stays flat no\n// matter how many brace groups are chained. The limit sits well above any\n// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M\n// characters) so legitimate input is unaffected.\nexport const EXPANSION_MAX_LENGTH = 4_000_000\n\n// `expand_` recurses once per level of brace *nesting* - both when expanding a\n// set's comma members and when re-wrapping a set whose body is a single part.\n// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one\n// level per chained group), which left nesting depth unbounded: about 3,100\n// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack\n// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser\n// will follow nesting. It sits far above any realistic pattern and well below\n// the depth at which the stack runs out.\nexport const EXPANSION_MAX_DEPTH = 1_000\n\n// Bash keeps a quirk where a brace group followed by a comma set still expands\n// (`{a},b}`). The parser implements it by rewriting the string and restarting\n// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`\n// full passes over a string that itself grows by one `escClose` sentinel each\n// time - quadratic in `n`, with a ~26x constant from the sentinel's length.\n// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27\n// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many\n// times the scan may restart. Real `{a},b}` input needs a handful.\nexport const EXPANSION_MAX_REWRITES = 1_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPatLine truncated
"mappings": "AAAO,IAAMA,GAAW,CACtBC,EACAC,EACAC,IACE,CACF,IAAMC,EAAKH,aAAa,OAASI,GAAWJ,EAAGE,CAAG,EAAIF,EAChDK,EAAKJ,aAAa,OAASG,GAAWH,EAAGC,CAAG,EAAID,EAEhD,EAAIE,IAAO,MAAQE,GAAM,MAAQC,GAAMH,EAAIE,EAAIH,CAAG,EAExD,OACE,GAAK,CACH,MAAO,EAAE,CAAC,EACV,IAAK,EAAE,CAAC,EACR,IAAKA,EAAI,MAAM,EAAG,EAAE,CAAC,CAAC,EACtB,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B,EAAc,GACdqB,EAAa,GAEjB,OAAS,CACP,IAAM5C,EAAIC,GAAS,IAAK,IAAKX,CAAG,EAGhC,GAAI,CAACU,EACH,OAAOoB,GAAQC,EAAK/B,EAAK,CAAC,EAAE,EAAGmB,EAAKC,EAAWa,CAAW,EAI5D,IAAMpB,EAAMH,EAAE,IAEd,GAAI,MAAM,KAAKG,CAAG,EAALine truncated
"names": ["balanced", "a", "b", "str", "ma", "maybeMatch", "mb", "range", "reg", "m", "begs", "beg", "left", "right", "result", "ai", "bi", "i", "r", "escSlash", "escOpen", "escClose", "escComma", "escPeriod", "escSlashPattern", "escOpenPattern", "escClosePattern", "escCommaPattern", "escPeriodPattern", "slashPattern", "openPattern", "closePattern", "commaPattern", "periodPattern", "EXPANSION_MAX", "numeric", "str", "escapeBraces", "unescapeBraces", "parseCommaParts", "parts", "m", "balanced", "pre", "body", "post", "p", "postParts", "expand", "options", "max", "expand_", "embrace", "isPadded", "el", "lte", "i", "y", "gte", "isTop", "expansions", "k", "expansion", "isNumericSequence", "isAlphaSequence", "isSequence", "isOptions", "n", "N", "x", "width", "incr", "test", "pad", "c", "need", "z", "j", "assertValidPattern", "pattern", "posixClasses", "braceEscape", "s", "regexpEscape", "rangesToString", "ranges", "parseClass", "glob", "position", "pos", "negs", "i", "sawStart", "uflag", "escaping", "negate", "endPos", "rangeStart", "WHILE", "c", "cls", "unip", "u", "neg", "r", "sranges", "snegs", "unescape", "s", "windowsPathsNoEscape", "magicalBraces", "types", "isExtglobType", "c", "startNoTraversal", "startNoDot", "addPatternStart", "justDots", "reSpecials", "regExpEscape", "s", "qmark", "star", "starNoEmpty", "AST", "_AST", "#root", "#hasMagic", "#uflag", "#parts", "#parent", "#parentIndex", "#negs", "#filledNegs", "#options", "#toString", "#emptyExt", "type", "parent", "options", "p", "#fillNegs", "n", "pp", "part", "parts", "ret", "i", "pl", "#parseAST", "str", "ast", "pos", "opt", "escaping", "inBrace", "braceStart", "braceNeg", "acc", "ext", "pattern", "glob", "re", "body", "hasMagic", "uflag", "flags", "allowDot", "dot", "noEmpty", "src", "_", "#parseGlob", "start", "aps", "needNoTrav", "needNoDot", "end", "unescape", "repeated", "#partsToRegExp", "bodyDotAllowed", "final", "close", "_hasMagic", "inStar", "needUflag", "consumed", "magic", "parseClass", "escape", "s", "windowsPathsNoEscape", "magicalBraces", "minimatch", "p", "pattern", "options", "assertValidPattern", "Minimatch", "starDotExtRE", "starDotExtTest", "ext", "f", "starDotExtTestDot", "starDotExtTestNocase", "starDotExtTestNocaseDot", "starDotStarRE", "starDotStarTest", "starDotStarTestDot", "dotStarRE", "dotStarTest", "starRE", "starTest", "starTestDot", "qmarksRE", "qmarksTestNocase", "$0", "noext", "qmarksTestNoExt", "qmarksTestNocaseDot", "qmarksTestNoExtDot", "qmarksTestDot", "qmarksTest", "len", "defaultPlatform", "path", "sep", "GLOBSTAR", "qmark", "star", "twoStarDot", "twoStarNoDot", "filter", "a", "b", "defaults", "def", "orig", "type", "parent", "list", "braceExpand", "expand", "makeRe", "match", "mm", "globMagic", "regExpEscape", "s", "awe", "part", "_", "args", "rawGlobParts", "set", "__", "isUNC", "isDrive", "ss", "i", "globParts", "j", "optimizationLevel", "parts", "gs", "prev", "didSomething", "dd", "gss", "next", "p2", "other", "splin", "matched", "emptyGSMatch", "ai", "bi", "result", "which", "negate", "negateOffset", "file", "partial", "fileDrive", "fileUNC", "patternDrive", "patternUNC", "fdi", "pdi", "fd", "pd", "fi", "pi", "fl", "pl", "fr", "pr", "swallowee", "hit", "m", "fastTest", "re", "AST", "twoStar", "flags", "pp", "filtered", "prefixes", "open", "close", "ff", "filename", "escape", "unescape", "fileURLToPath", "defaultPerf", "warned", "PROCESS", "emitWarning", "msg", "type", "code", "fn", "AC", "AS", "_", "warnACPolyfill", "reason", "printACPolyfillWarning", "shouldWarn", "isPosInt", "n", "getUintArray", "max", "ZeroArray", "size", "Stack", "_Stack", "#constructing", "HeapCls", "s", "LRUCache", "_LRUCache", "#max", "#maxSize", "#dispose", "#onInsert", "#disposeAfter", "#fetchMethod", "#memoMethod", "#perf", "#size", "#calculatedSize", "#keyMap", "#keyList", "#valList", "#next", "#prev", "#head", "#tail", "#free", "#disposed", "#sizes", "#starts", "#ttls", "#autopurgeTimers", "#hasDispose", "#hasFetchMethod", "#hasDisposeAfter", "#hasOnInsert", "c", "p", "#isBackgroundFetch", "k", "index", "options", "context", "#backgroundFetch", "#moveToTail", "#indexes", "#rindexes", "#isStale", "ttl", "ttlResolution", "ttlAutopurge", "updateAgeOnGet", "updateAgeOnHas", "allowStale", "dispose", "onInsert", "disposeAfter", "noDisposeOnSet", "noUpdateTTL", "maxSize", "maxEntrySize", "sizeCalculation", "fetchMethod", "memoMethod", "noDeleteOnFetchRejection", "noDeleteOnStaleGet", "allowStaleOnFetchRejection", "allowStaleOnFetchAbort", "ignoreFetchAbort", "perf", "defaultPerf", "UintArray", "#initializeSizeTracking", "#initializeTTLTracking", "code", "shouldWarn", "warned", "emitWarning", "key", "ttls", "starts", "purgeTimers", "#setItemTTL", "start", "t", "#delete", "#updateItemAge", "#statusTTL", "status", "cachedNow", "getNow", "age", "sizes", "#removeItemSize", "#requireSize", "v", "#addItemSize", "#evict", "_i", "_s", "_st", "_k", "_v", "i", "#isValidIndex", "fn", "getOptions", "value", "thisp", "deleted", "entry", "remainLine truncated "names": ["balanced", "a", "b", "str", "ma", "maybeMatch", "mb", "r", "range", "reg", "m", "begs", "beg", "left", "right", "result", "ai", "bi", "i", "escSlash", "escOpen", "escClose", "escComma", "escPeriod", "escSlashPattern", "escOpenPattern", "escClosePattern", "escCommaPattern", "escPeriodPattern", "slashPattern", "openPattern", "closePattern", "commaPattern", "periodPattern", "EXPANSION_MAX", "EXPANSION_MAX_LENGTH", "EXPANSION_MAX_DEPTH", "EXPANSION_MAX_REWRITES", "numeric", "str", "escapeBraces", "unescapeBraces", "pushAll", "target", "items", "i", "parseCommaParts", "parts", "carry", "m", "balanced", "tail", "pre", "body", "post", "p", "expand", "options", "max", "maxLength", "maxDepth", "maxRewrites", "expand_", "embrace", "isPadded", "el", "lte", "y", "gte", "combine", "acc", "values", "dropEmpties", "out", "length", "a", "v", "expansion", "expandSequence", "isAlphaSequence", "n", "N", "x", "width", "incr", "test", "pad", "c", "need", "z", "depth", "isTop", "rewrites", "firstGroup", "isNumericSequence", "isSequence", "isOptions", "dropsEmpties", "d", "valuesLength", "outer", "j", "expanded", "k", "posixClasses", "braceEscape", "s", "noMatch", "parseClass", "glob", "position", "nocase", "form", "norm", "c", "n", "pos", "ranges", "negs", "i", "sawStart", "escaping", "negate", "endPos", "rangeStart", "WHILE", "cls", "unip", "neg", "sranges", "snegs", "comb", "MATCH", "extTypes", "lit", "ch", "reEscape", "s", "foldRe", "litMatch", "l", "c", "code", "ascii", "tokenize", "p", "nocase", "noext", "form", "toks", "i", "e", "re", "consumed", "parseClass", "pair", "pairs", "stack", "tok", "build", "start", "end", "top", "seq", "alts", "close", "sub", "normalize", "items", "out", "run", "flush", "it", "a", "compile", "id", "split", "next", "item", "after", "entry", "show", "lines", "seen", "ref", "walk", "indent", "line", "desc", "o", "State", "gen", "sameState", "b", "r", "marks", "size", "Sim", "#marks", "dots", "dotStart", "state", "n", "#visit", "node", "#addThread", "has", "th", "stateKey", "ids", "runs", "DFA_BUDGET", "Dfa", "#start", "#states", "#size", "#plain", "#dotStart", "#sim", "#dotSim", "#make", "#intern", "key", "found", "#clear", "d", "linear", "nodes", "testLinear", "chars", "ni", "ci", "starNi", "starCi", "lengths", "min", "max", "lo", "hi", "itemLengths", "loop", "hasAffix", "lits", "j", "slashOrSurrogate", "surrogate", "codePoints", "noSlash", "Matcher", "#dotsSim", "#literal", "#literalRe", "#linear", "#wild", "#min", "#max", "#prefix", "#suffix", "#prefixStr", "#suffixStr", "#affix", "#dfa", "#form", "pattern", "options", "literal", "#test", "most", "least", "prefix", "sim", "dfa", "str", "assertValidPattern", "pattern", "escape", "s", "windowsPathsNoEscape", "magicalBraces", "unescape", "s", "windowsPathsNoEscape", "magicalBraces", "minimatch", "p", "pattern", "options", "assertValidPattern", "Minimatch", "defaultPlatform", "path", "sep", "GLOBSTAR", "filter", "ext", "a", "b", "defaults", "def", "orig", "list", "braceExpand", "expand", "match", "mm", "f", "globMagic", "classEnd", "start", "i", "sawStart", "c", "literal", "noext", "lit", "close", "body", "extSafe", "depth", "lastSplit", "lastChecked", "portionMatch", "endIndex", "last", "lastStart", "prev", "prevStart", "isDots", "isDrive", "isLongUNC", "uncHost", "h", "host", "share", "walkable", "dot", "dotPortion", "end", "k", "n", "isSep", "s", "nextSep", "from", "lastSep", "#endCheck", "#literalCheck", "#level2", "#form", "#literals", "#shapes", "#endRows", "#matchers", "#globstarParts", "awe", "drives", "row", "#rootIndex", "r", "lits", "l", "p0", "p1", "p2", "#norm", "part", "rawGlobParts", "#slashSplit", "set", "_", "__", "isUNC", "ss", "merged", "len", "groups", "Matcher", "parts", "key", "g", "drop", "first", "rest", "glob", "globParts", "partset", "j", "optimizationLevel", "gs", "root", "#canMatch", "ends", "ROWS", "resolves", "tailStart", "shape", "m", "#walk", "#matchShape", "file", "x", "t", "head", "e", "next", "#cachedSplit", "#split", "isWindows", "preserveMultipleSlashes", "normalize", "#levelTwoFileOptimize", "didSomething", "dd", "braceExpandMax", "gss", "other", "splin", "matched", "emptyGSMatch", "ai", "bi", "result", "which", "negate", "negateOffset", "#matchRow", "resolved", "partial", "fileStartIndex", "patternStartIndex", "fh", "ph", "fileDrive", "fileUNC", "patternDrive", "patternUNC", "fdi", "pdi", "fd", "pd", "#matchGlobstar", "#matchOne", "fileIndex", "patternIndex", "tail", "segments", "#getGlobstarParts", "headEnd", "fileTailMatch", "sawSome", "#matchGlobStarBodySections", "byStart", "found", "firstgs", "lastgs", "current", "nonGsParts", "nonGsPartsSums", "bodySegments", "fileLength", "bodyIndex", "globStarDepth", "sawTail", "tried", "bs", "need", "after", "sub", "fileEnd", "fi", "pi", "pl", "fl", "nocase", "nocaseMagicOnly", "split", "can", "ff", "filename", "escape", "unescape", "fileURLToPath", "tracingChannel", "channel", "metrics", "tracing", "defaultPerf", "hasSubscribers", "warned", "PROCESS", "Line truncated
} }
+10 -3
View File
@@ -1,5 +1,12 @@
import type { ParseReturnFiltered } from 'minimatch';
import { GLOBSTAR } from 'minimatch'; import { GLOBSTAR } from 'minimatch';
export type MMPattern = string | RegExp | typeof GLOBSTAR; /**
* One portion of a parsed minimatch pattern: a string, a Matcher for
* a portion with magic, or GLOBSTAR for `**`.
*/
export type MMPattern = ParseReturnFiltered;
/** The Matcher that minimatch makes for a portion with magic. */
export type MMMatcher = Exclude<MMPattern, string | typeof GLOBSTAR>;
export type PatternList = [p: MMPattern, ...rest: MMPattern[]]; export type PatternList = [p: MMPattern, ...rest: MMPattern[]];
export type UNCPatternList = [ export type UNCPatternList = [
p0: '', p0: '',
@@ -34,9 +41,9 @@ export declare class Pattern {
*/ */
isGlobstar(): boolean; isGlobstar(): boolean;
/** /**
* true if pattern() returns a regexp * true if pattern() returns a Matcher, for a portion with magic
*/ */
isRegExp(): boolean; isMatcher(): boolean;
/** /**
* The /-joined set of glob parts that make up this pattern * The /-joined set of glob parts that make up this pattern
*/ */
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/pattern.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,QAAQ,CAAA;AAGzD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;AAC9D,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,MAAM;IACV,GAAG,IAAI,EAAE,SAAS,EAAE;CACrB,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG,CAA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AI,OAAO;IAIlB;;OAEG;IACH,IAAI,IAAI,OAAO,GAAG,IAAI;IAuBtB;;OAEG;IACH,KAAK,IAAI,OAAO;IAsBhB;;OAEG;IACH,OAAO,IAAI,OAAO;IAelB;;OAEG;IACH,UAAU,IAAI,OAAO;IAUrB;;OAEG;IACH,IAAI,IAAI,MAAM;IASd;;;OAGG;IACH,mBAAmB,IAAI,OAAO;IAQ9B;;OAEG;IACH,kBAAkB,IAAI,OAAO;CAM9B"}
+27 -15
View File
@@ -45,19 +45,24 @@ export class Pattern {
// //host/share => ['//host/share/'] // //host/share => ['//host/share/']
// //host/share/ => ['//host/share/'] // //host/share/ => ['//host/share/']
// //host/share/x => ['//host/share/', 'x'] // //host/share/x => ['//host/share/', 'x']
// //?/UNC/host/share/x => ['//?/UNC/host/share/', 'x']
// /etc => ['/', 'etc'] // /etc => ['/', 'etc']
// / => ['/'] // / => ['/']
if (this.isUNC()) { if (this.isUNC()) {
// '' / '' / 'host' / 'share' // '' / '' / 'host' / 'share', or
const [p0, p1, p2, p3, ...prest] = this.#patternList; // '' / '' / '?' / 'UNC' / 'host' / 'share'
const [g0, g1, g2, g3, ...grest] = this.#globList; const n = this.#isLongUNC() ? 6 : 4;
const proot = this.#patternList.slice(0, n);
const groot = this.#globList.slice(0, n);
const prest = this.#patternList.slice(n);
const grest = this.#globList.slice(n);
if (prest[0] === '') { if (prest[0] === '') {
// ends in / // ends in /
prest.shift(); prest.shift();
grest.shift(); grest.shift();
} }
const p = [p0, p1, p2, p3, ''].join('/'); const p = [...proot, ''].join('/');
const g = [g0, g1, g2, g3, ''].join('/'); const g = [...groot, ''].join('/');
this.#patternList = [p, ...prest]; this.#patternList = [p, ...prest];
this.#globList = [g, ...grest]; this.#globList = [g, ...grest];
this.length = this.#patternList.length; this.length = this.#patternList.length;
@@ -70,8 +75,8 @@ export class Pattern {
prest.shift(); prest.shift();
grest.shift(); grest.shift();
} }
const p = p1 + '/'; const p = `${p1}/`;
const g = g1 + '/'; const g = `${g1}/`;
this.#patternList = [p, ...prest]; this.#patternList = [p, ...prest];
this.#globList = [g, ...grest]; this.#globList = [g, ...grest];
this.length = this.#patternList.length; this.length = this.#patternList.length;
@@ -79,7 +84,7 @@ export class Pattern {
} }
} }
[customInspect]() { [customInspect]() {
return 'Pattern <' + this.#globList.slice(this.#index).join('/') + '>'; return `Pattern <${this.#globList.slice(this.#index).join('/')}>`;
} }
/** /**
* The first entry in the parsed list of patterns * The first entry in the parsed list of patterns
@@ -100,10 +105,10 @@ export class Pattern {
return this.#patternList[this.#index] === GLOBSTAR; return this.#patternList[this.#index] === GLOBSTAR;
} }
/** /**
* true if pattern() returns a regexp * true if pattern() returns a Matcher, for a portion with magic
*/ */
isRegExp() { isMatcher() {
return this.#patternList[this.#index] instanceof RegExp; return typeof this.#patternList[this.#index] === 'object';
} }
/** /**
* The /-joined set of glob parts that make up this pattern * The /-joined set of glob parts that make up this pattern
@@ -137,11 +142,18 @@ export class Pattern {
this.#rest.#isDrive = this.#isDrive; this.#rest.#isDrive = this.#isDrive;
return this.#rest; return this.#rest;
} }
// the root is //?/UNC/host/share, the same as //host/share
#isLongUNC() {
const pl = this.#patternList;
return (pl[2] === '?' && typeof pl[3] === 'string' && /^unc$/i.test(pl[3]));
}
/** /**
* true if the pattern represents a //unc/path/ on windows * true if the pattern represents a //unc/path/ on windows
*/ */
isUNC() { isUNC() {
const pl = this.#patternList; const pl = this.#patternList;
// the host and share, after //?/UNC/ in a long UNC path
const h = this.#isLongUNC() ? 4 : 2;
return this.#isUNC !== undefined ? return this.#isUNC !== undefined ?
this.#isUNC this.#isUNC
: (this.#isUNC = : (this.#isUNC =
@@ -149,10 +161,10 @@ export class Pattern {
this.#index === 0 && this.#index === 0 &&
pl[0] === '' && pl[0] === '' &&
pl[1] === '' && pl[1] === '' &&
typeof pl[2] === 'string' && typeof pl[h] === 'string' &&
!!pl[2] && !!pl[h] &&
typeof pl[3] === 'string' && typeof pl[h + 1] === 'string' &&
!!pl[3]); !!pl[h + 1]);
} }
// pattern like C:/... // pattern like C:/...
// split = ['C:', ...] // split = ['C:', ...]
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/pattern.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAgBpC,MAAM,aAAa,GAAG,CAAC,EAAe,EAAqB,EAAE,CAC3D,EAAE,CAAC,MAAM,IAAI,CAAC,CAAA;AAChB,MAAM,UAAU,GAAG,CAAC,EAAY,EAAkB,EAAE,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,CAAA;AAEnE,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE9D;;;GAGG;AACH,MAAM,OAAO,OAAO;IACT,YAAY,CAAa;IACzB,SAAS,CAAU;IACnB,MAAM,CAAQ;IACd,MAAM,CAAQ;IACd,SAAS,CAAiB;IACnC,KAAK,CAAiB;IACtB,WAAW,CAAS;IACpB,QAAQ,CAAU;IAClB,MAAM,CAAU;IAChB,WAAW,CAAU;IACrB,eAAe,GAAY,IAAI,CAAA;IAE/B,YACE,WAAwB,EACxB,QAAkB,EAClB,KAAa,EACb,QAAyB;QAEzB,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAAC,oBAAoB,CAAC,CAAA;QAC3C,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;QACxC,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3C,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAA;QACtE,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAA;QAChC,IAAI,KAAK,GAAG,CAAC,IA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,GAAG,IAAI,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QACnC,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,2DAA2D;IAC3D,UAAU;QACR,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAA;QAC5B,OAAO,CACL,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CACnE,CAAA;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAA;QAC5B,wDAAwD;QACxD,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;YAC9BLine truncated
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff. Show more