@qqbrowser/qbot-claw-launcher 0.9.66 → 0.9.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/installer.js +9 -5
- package/dist/version.js +1 -1
- package/node_modules/is-extglob/package.json +48 -17
- package/node_modules/is-glob/package.json +61 -21
- package/node_modules/node-addon-api/README.md +1 -1
- package/node_modules/node-addon-api/napi-inl.h +61 -4
- package/node_modules/node-addon-api/napi.h +43 -6
- package/node_modules/node-addon-api/package.json +44 -20
- package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/README.md +41 -30
- package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/lib/constants.js +4 -0
- package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/lib/parse.js +301 -0
- package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/lib/picomatch.js +11 -3
- package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/package.json +57 -27
- package/package.json +1 -1
- /package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/LICENSE +0 -0
- /package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/index.js +0 -0
- /package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/lib/scan.js +0 -0
- /package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/lib/utils.js +0 -0
- /package/node_modules/{@parcel/watcher/node_modules/picomatch → picomatch}/posix.js +0 -0
package/dist/installer.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}catch{}}}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1,exports.PYTHON_DIR=u.default.join(
|
|
3
|
-
`);c.default.writeFileSync(t,
|
|
4
|
-
|
|
5
|
-
`)
|
|
1
|
+
"use strict";var A=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PYTHON_DIR=exports.isInstalling=exports.installState=void 0,exports.runQBotClaw=O,exports.configAndRunQBotClaw=E,exports.runInstall=B;const c=A(require("fs")),u=A(require("path")),_=require("child_process"),r=require("./config"),d=require("./utils"),p=require("./state"),f=require("./quarantine"),o=require("./reportLog"),w=require("./service"),P=require("./openai-proxy");function g(t,n,s,i){if(t&&t.writable){const a=n>0?Math.round(s/n*1e4)/100:0;try{t.write(JSON.stringify({status:"downloading",progress:a,totalSteps:n,currentStep:s,message:i})+`
|
|
2
|
+
`)}catch{}}}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1,exports.PYTHON_DIR=u.default.join(r.QBOT_CLAW_DIR,"python");function O(t,n){return new Promise(s=>{const i=(0,p.readState)(),a=(0,_.spawn)(r.QBOTCLAW_BIN,t,{stdio:["ignore","pipe","pipe"],env:{PATH:r.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${i.port}/v1`,QBOTCLAW_LLM_API_KEY:P.proxyApiKey}});(0,o.log)(`[QBotClaw] \u6267\u884C: QBotClaw ${t.join(" ")}`),a.stdout.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),a.stderr.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),a.on("close",e=>{(0,o.log)(`[QBotClaw] \u6267\u884C\u5B8C\u6210\uFF0C\u9000\u51FA\u7801: ${e}`),s()}),a.on("error",e=>{(0,o.log)(`[QBotClaw] \u542F\u52A8\u5931\u8D25: ${e.message}`),s()})})}function N(){c.default.existsSync(r.QBOT_CLAW_DIR)||c.default.mkdirSync(r.QBOT_CLAW_DIR,{recursive:!0})}function y(){const t=u.default.join(exports.PYTHON_DIR,"pip.conf");if(c.default.existsSync(t)){(0,o.log)("pip.conf \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");return}const n=["[global]","index-url = https://mirrors.tencent.com/pypi/simple/",`cache-dir = ${u.default.join(exports.PYTHON_DIR,".pip-cache")}`,"","[install]",`prefix = ${exports.PYTHON_DIR}`,""].join(`
|
|
3
|
+
`);c.default.writeFileSync(t,n,"utf-8"),(0,o.log)(`\u5DF2\u5199\u5165 pip.conf: ${t}`)}async function T(t){if(c.default.existsSync(r.MCPORTER_BIN)){(0,o.log)("mcporter \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7");return}(0,o.log)("\u5F00\u59CB\u5B89\u88C5 mcporter..."),await new Promise((n,s)=>{const i=(0,_.spawn)(r.NPM_BIN,["--userconfig",r.NPM_RC,"install","-g","mcporter"],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(r.NPM_BIN)}:${process.env.PATH}`}});i.stdout.on("data",a=>{const e=`[mcporter] ${a.toString().trim()}`;(0,o.log)(e),g(t,0,0,e)}),i.stderr.on("data",a=>{const e=`[mcporter] ${a.toString().trim()}`;(0,o.log)(e),g(t,0,0,e)}),i.on("close",a=>{a===0?((0,o.log)("mcporter \u5B89\u88C5\u6210\u529F"),n()):s(new Error(`mcporter \u5B89\u88C5\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${a}`))}),i.on("error",s)})}function C(t,n){return new Promise((s,i)=>{const a=(0,_.spawn)(r.NPM_BIN,["--userconfig",r.NPM_RC,...t],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(r.NPM_BIN)}:${process.env.PATH}`}});a.stdout.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,o.log)(l)}),a.stderr.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,o.log)(l)}),a.on("close",e=>{e===0?((0,o.log)(`${n} \u6210\u529F`),s()):i(new Error(`${n} \u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${e}`))}),a.on("error",i)})}async function I(t){const n=`${r.NPM_PACKAGE_NAME}@${t}`;(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${n}\uFF08--ignore-scripts\uFF0C\u4EC5\u4E0B\u8F7D\u89E3\u538B\uFF09...`),await C(["install","-g","--ignore-scripts",n],`${n} \u4E0B\u8F7D\u89E3\u538B`)}async function m(t){const n=`${r.NPM_PACKAGE_NAME}@${t}`;(0,o.log)("\u5F00\u59CB npm rebuild\uFF08\u6267\u884C postinstall \u811A\u672C\uFF09..."),await C(["rebuild","-g",r.NPM_PACKAGE_NAME],`${n} rebuild`),(0,o.log)(`${n} \u5B89\u88C5\u6210\u529F`)}async function L(t,n,s,i){let a;if((0,o.log)(`\u8986\u76D6\u7528\u6237\u5DF2\u6709\u914D\u7F6E: ${i}`),!i&&c.default.existsSync(r.QBOT_CLAW_CONFIG_PATH))a=r.QBOT_CLAW_CONFIG_PATH,(0,o.log)(`\u4F7F\u7528\u5DF2\u6709\u914D\u7F6E\u6587\u4EF6: ${a}`);else{const l=u.default.join(r.NPM_GLOBAL_MODULES,r.NPM_PACKAGE_NAME,"preset-config.json");if(!c.default.existsSync(l)){(0,o.log)(`npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165: ${l}`);return}a=l,(0,o.log)(`\u4F7F\u7528 npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E: ${a}`)}let e;try{e=JSON.parse(c.default.readFileSync(a,"utf-8")),(0,o.log)(`\u5DF2\u8BFB\u53D6\u914D\u7F6E: ${a}`)}catch(l){(0,o.log)(`\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25: ${a}\uFF0C${l.message}\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165`);return}t!==void 0&&(e.gateway={...e.gateway??{},port:t},(0,o.log)(`\u5DF2\u5C06 gateway.port=${t} \u5199\u5165\u914D\u7F6E`)),e.plugins=e.plugins??{},e.plugins.entries=e.plugins.entries??{},e.plugins.entries["x5use-browser-control"]=e.plugins.entries["x5use-browser-control"]??{},e.plugins.entries["x5use-browser-control"].config={...e.plugins.entries["x5use-browser-control"].config??{},wsPort:s,httpPort:n},(0,o.log)(`\u5DF2\u5C06 x5use-browser-control wsPort=${s}, httpPort=${n} \u5199\u5165\u914D\u7F6E`),c.default.writeFileSync(r.QBOT_CLAW_CONFIG_PATH,JSON.stringify(e,null,2),"utf-8"),(0,o.log)(`\u914D\u7F6E\u6587\u4EF6\u5DF2\u5199\u5165: ${r.QBOT_CLAW_CONFIG_PATH}`)}function $(t){const n=u.default.join(r.QBOT_CLAW_DIR,".env"),s=`OPENCLAW_GATEWAY_TOKEN=${t}
|
|
4
|
+
`;try{if(c.default.existsSync(n)){const e=c.default.readFileSync(n,"utf-8").split(`
|
|
5
|
+
`).filter(l=>!l.startsWith("OPENCLAW_GATEWAY_TOKEN=")).filter(l=>l!=="").join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`+s;c.default.writeFileSync(n,e,"utf-8")}else c.default.writeFileSync(n,s,"utf-8");(0,o.log)(`\u5DF2\u5C06 OPENCLAW_GATEWAY_TOKEN \u5199\u5165 ${n}`)}catch(i){(0,o.log)(`\u5199\u5165 .env \u6587\u4EF6\u5931\u8D25: ${i.message}`)}}async function E(t){const n=(0,p.readState)();let s;n.gatewayPort&&!await(0,p.isPortAvailable)(n.gatewayPort)?(s=n.gatewayPort,(0,o.log)(`\u68C0\u6D4B\u5230 QBotClaw gateway \u5DF2\u5728\u7AEF\u53E3 ${s} \u8FD0\u884C\uFF0C\u590D\u7528\u539F\u7AEF\u53E3`)):s=await(0,d.findAvailablePort)(),(0,o.log)(`\u540E\u53F0\u542F\u52A8 QBotClaw gateway run --port ${s} --force`);const i=await(0,d.findAvailablePort)(r.DEFAULT_MCP_HTTP_PORT),a=await(0,d.findAvailablePort)();await L(s,i,a,t),$((0,w.getOrCreateGatewayToken)());const e=(0,_.spawn)(r.QBOTCLAW_BIN,["gateway","run","--port",String(s),"--force"],{stdio:"ignore",env:{PATH:r.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_NO_RESPAWN:"true",VENUS_API_KEY:"E9isWWfAr4VIFuIa5RbJaPxD@2040",OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",OPENCLAW_GATEWAY_TOKEN:(0,w.getOrCreateGatewayToken)(),QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${n.port}/v1`,QBOTCLAW_LLM_API_KEY:P.proxyApiKey}});e.unref();const l=e.pid;(0,o.log)(`QBotClaw gateway \u5DF2\u5728\u540E\u53F0\u542F\u52A8\uFF0CPID: ${l}\uFF0C\u7AEF\u53E3: ${s}, token ${(0,w.getOrCreateGatewayToken)()}`),(0,p.writeState)({...(0,p.readState)(),gatewayPid:l,gatewayPort:s,mcpHttpPort:i,mcpWsPort:a})}function B(t,n,s){if(exports.isInstalling){if((0,o.log)("[runInstall] \u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u62D2\u7EDD\u91CD\u590D\u6267\u884C"),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:"\u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u8BF7\u52FF\u91CD\u590D\u64CD\u4F5C"})+`
|
|
8
|
+
`)}catch{}return}exports.isInstalling=!0,exports.installState={status:"downloading",message:"\u6B63\u5728\u5B89\u88C5...",startTime:new Date().toISOString()},(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${r.NPM_PACKAGE_NAME}@${n}`),(async()=>{try{(0,p.stopGateway)(),N(),y();const i=5;let a=0;g(t,i,a,"\u5F00\u59CB\u5B89\u88C5 mcporter..."),await T(t),a++,g(t,i,a,"\u5F00\u59CB\u4E0B\u8F7D\u89E3\u538B QBotClaw..."),await I(n),a++,g(t,i,a,"npmDownloadQBotClaw \u5B8C\u6210"),await(0,f.fullScanClearQuarantine)("npm install --ignore-scripts \u5B8C\u6210\u540E\uFF0Crebuild \u524D"),a++,await(0,f.watchWorkspaceQuarantine)().catch(e=>{(0,o.log)(`[quarantine] watchWorkspaceQuarantine \u542F\u52A8\u5F02\u5E38: ${e.message}`)}),g(t,i,a,"\u5F00\u59CB npm rebuild..."),await m(n),a++,g(t,i,a,"npmRebuildQBotClaw \u5B8C\u6210");try{c.default.existsSync(r.OPENCLAW_BIN)||(c.default.symlinkSync(r.QBOTCLAW_BIN,r.OPENCLAW_BIN),(0,o.log)(`\u5DF2\u521B\u5EFA\u8F6F\u94FE\u63A5: ${r.OPENCLAW_BIN} -> ${r.QBOTCLAW_BIN}`))}catch(e){(0,o.log)(`\u521B\u5EFA openclaw \u8F6F\u94FE\u63A5\u5931\u8D25: ${e.message}`)}if(await(0,f.stopWatchWorkspaceQuarantine)().catch(e=>{(0,o.log)(`[quarantine] stopWatchWorkspaceQuarantine \u5F02\u5E38: ${e.message}`)}),exports.installState={status:"success",message:"\u5B89\u88C5\u6210\u529F",endTime:new Date().toISOString()},(0,o.log)("\u5B89\u88C5\u6210\u529F"),(0,o.refreshClawVersion)(n),g(t,i,a,"\u5F00\u59CB\u914D\u7F6E\u5E76\u542F\u52A8 QBotClaw gateway..."),await E(s),a++,t.writable)try{const e=(0,w.getOrCreateGatewayToken)();t.end(JSON.stringify({status:"done",progress:100,message:"\u5B89\u88C5\u6210\u529F",gatewayToken:e})+`
|
|
9
|
+
`)}catch{}}catch(i){if(await(0,f.stopWatchWorkspaceQuarantine)().catch(()=>{}),exports.installState={status:"failed",message:i.message,endTime:new Date().toISOString()},(0,o.log)(`\u5B89\u88C5\u5931\u8D25: ${i.message}`),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:i.message})+`
|
|
6
10
|
`)}catch{}}finally{exports.isInstalling=!1}})()}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.9.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.9.68";
|
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
2
|
+
"_from": "is-extglob@^2.1.1",
|
|
3
|
+
"_id": "is-extglob@2.1.1",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
|
6
|
+
"_location": "/is-extglob",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "is-extglob@^2.1.1",
|
|
12
|
+
"name": "is-extglob",
|
|
13
|
+
"escapedName": "is-extglob",
|
|
14
|
+
"rawSpec": "^2.1.1",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "^2.1.1"
|
|
10
17
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"index.js"
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"/is-glob"
|
|
14
20
|
],
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
21
|
+
"_resolved": "https://mirrors.tencent.com/npm/is-extglob/-/is-extglob-2.1.1.tgz",
|
|
22
|
+
"_shasum": "a88c02535791f02ed37c76a1b9ea9773c833f8c2",
|
|
23
|
+
"_spec": "is-extglob@^2.1.1",
|
|
24
|
+
"_where": "/Volumes/data/workspace/node_modules/is-glob",
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Jon Schlinkert",
|
|
27
|
+
"url": "https://github.com/jonschlinkert"
|
|
18
28
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/jonschlinkert/is-extglob/issues"
|
|
21
31
|
},
|
|
32
|
+
"bundleDependencies": false,
|
|
33
|
+
"deprecated": false,
|
|
34
|
+
"description": "Returns true if a string has an extglob.",
|
|
22
35
|
"devDependencies": {
|
|
23
36
|
"gulp-format-md": "^0.1.10",
|
|
24
37
|
"mocha": "^3.0.2"
|
|
25
38
|
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=0.10.0"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"index.js"
|
|
44
|
+
],
|
|
45
|
+
"homepage": "https://github.com/jonschlinkert/is-extglob",
|
|
26
46
|
"keywords": [
|
|
27
47
|
"bash",
|
|
28
48
|
"braces",
|
|
@@ -42,6 +62,16 @@
|
|
|
42
62
|
"string",
|
|
43
63
|
"test"
|
|
44
64
|
],
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"main": "index.js",
|
|
67
|
+
"name": "is-extglob",
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/jonschlinkert/is-extglob.git"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"test": "mocha"
|
|
74
|
+
},
|
|
45
75
|
"verb": {
|
|
46
76
|
"toc": false,
|
|
47
77
|
"layout": "default",
|
|
@@ -65,5 +95,6 @@
|
|
|
65
95
|
"lint": {
|
|
66
96
|
"reflinks": true
|
|
67
97
|
}
|
|
68
|
-
}
|
|
98
|
+
},
|
|
99
|
+
"version": "2.1.1"
|
|
69
100
|
}
|
|
@@ -1,36 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
2
|
+
"_from": "is-glob@^4.0.3",
|
|
3
|
+
"_id": "is-glob@4.0.3",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
|
6
|
+
"_location": "/is-glob",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "is-glob@^4.0.3",
|
|
12
|
+
"name": "is-glob",
|
|
13
|
+
"escapedName": "is-glob",
|
|
14
|
+
"rawSpec": "^4.0.3",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "^4.0.3"
|
|
17
|
+
},
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"/@parcel/watcher"
|
|
11
20
|
],
|
|
12
|
-
"
|
|
21
|
+
"_resolved": "https://mirrors.tencent.com/npm/is-glob/-/is-glob-4.0.3.tgz",
|
|
22
|
+
"_shasum": "64f61e42cbbb2eec2071a9dac0b28ba1e65d5084",
|
|
23
|
+
"_spec": "is-glob@^4.0.3",
|
|
24
|
+
"_where": "/Volumes/data/workspace/parcel-watcher",
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Jon Schlinkert",
|
|
27
|
+
"url": "https://github.com/jonschlinkert"
|
|
28
|
+
},
|
|
13
29
|
"bugs": {
|
|
14
30
|
"url": "https://github.com/micromatch/is-glob/issues"
|
|
15
31
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
32
|
+
"bundleDependencies": false,
|
|
33
|
+
"contributors": [
|
|
34
|
+
{
|
|
35
|
+
"name": "Brian Woodward",
|
|
36
|
+
"url": "https://twitter.com/doowb"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "Daniel Perez",
|
|
40
|
+
"url": "https://tuvistavie.com"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Jon Schlinkert",
|
|
44
|
+
"url": "http://twitter.com/jonschlinkert"
|
|
45
|
+
}
|
|
19
46
|
],
|
|
20
|
-
"main": "index.js",
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=0.10.0"
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "mocha && node benchmark.js"
|
|
26
|
-
},
|
|
27
47
|
"dependencies": {
|
|
28
48
|
"is-extglob": "^2.1.1"
|
|
29
49
|
},
|
|
50
|
+
"deprecated": false,
|
|
51
|
+
"description": "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.",
|
|
30
52
|
"devDependencies": {
|
|
31
53
|
"gulp-format-md": "^0.1.10",
|
|
32
54
|
"mocha": "^3.0.2"
|
|
33
55
|
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=0.10.0"
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"index.js"
|
|
61
|
+
],
|
|
62
|
+
"homepage": "https://github.com/micromatch/is-glob",
|
|
34
63
|
"keywords": [
|
|
35
64
|
"bash",
|
|
36
65
|
"braces",
|
|
@@ -50,6 +79,16 @@
|
|
|
50
79
|
"string",
|
|
51
80
|
"test"
|
|
52
81
|
],
|
|
82
|
+
"license": "MIT",
|
|
83
|
+
"main": "index.js",
|
|
84
|
+
"name": "is-glob",
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "git+https://github.com/micromatch/is-glob.git"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"test": "mocha && node benchmark.js"
|
|
91
|
+
},
|
|
53
92
|
"verb": {
|
|
54
93
|
"layout": "default",
|
|
55
94
|
"plugins": [
|
|
@@ -77,5 +116,6 @@
|
|
|
77
116
|
"verb",
|
|
78
117
|
"vinyl"
|
|
79
118
|
]
|
|
80
|
-
}
|
|
119
|
+
},
|
|
120
|
+
"version": "4.0.3"
|
|
81
121
|
}
|
|
@@ -19,7 +19,7 @@ and exception handling semantics with low overhead.
|
|
|
19
19
|
API references are available in the [doc](doc/README.md) directory.
|
|
20
20
|
|
|
21
21
|
<!-- x-release-please-start-version -->
|
|
22
|
-
## Current version: 8.
|
|
22
|
+
## Current version: 8.7.0
|
|
23
23
|
<!-- x-release-please-end -->
|
|
24
24
|
|
|
25
25
|
(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
|
|
@@ -1199,6 +1199,13 @@ inline Date Date::New(napi_env env, double val) {
|
|
|
1199
1199
|
return Date(env, value);
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
|
+
inline Date Date::New(napi_env env, std::chrono::system_clock::time_point tp) {
|
|
1203
|
+
using namespace std::chrono;
|
|
1204
|
+
auto ms = static_cast<double>(
|
|
1205
|
+
duration_cast<milliseconds>(tp.time_since_epoch()).count());
|
|
1206
|
+
return Date::New(env, ms);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1202
1209
|
inline void Date::CheckCast(napi_env env, napi_value value) {
|
|
1203
1210
|
NAPI_CHECK(value != nullptr, "Date::CheckCast", "empty value");
|
|
1204
1211
|
|
|
@@ -1966,6 +1973,19 @@ inline MaybeOrValue<bool> Object::Seal() const {
|
|
|
1966
1973
|
}
|
|
1967
1974
|
#endif // NAPI_VERSION >= 8
|
|
1968
1975
|
|
|
1976
|
+
inline MaybeOrValue<Object> Object::GetPrototype() const {
|
|
1977
|
+
napi_value result;
|
|
1978
|
+
napi_status status = napi_get_prototype(_env, _value, &result);
|
|
1979
|
+
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, Object(_env, result), Object);
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
#ifdef NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE
|
|
1983
|
+
inline MaybeOrValue<bool> Object::SetPrototype(const Object& value) const {
|
|
1984
|
+
napi_status status = node_api_set_prototype(_env, _value, value);
|
|
1985
|
+
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1986
|
+
}
|
|
1987
|
+
#endif
|
|
1988
|
+
|
|
1969
1989
|
////////////////////////////////////////////////////////////////////////////////
|
|
1970
1990
|
// External class
|
|
1971
1991
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -2289,6 +2309,39 @@ inline DataView DataView::New(napi_env env,
|
|
|
2289
2309
|
return DataView(env, value);
|
|
2290
2310
|
}
|
|
2291
2311
|
|
|
2312
|
+
#ifdef NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER
|
|
2313
|
+
inline DataView DataView::New(napi_env env,
|
|
2314
|
+
Napi::SharedArrayBuffer arrayBuffer) {
|
|
2315
|
+
return New(env, arrayBuffer, 0, arrayBuffer.ByteLength());
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
inline DataView DataView::New(napi_env env,
|
|
2319
|
+
Napi::SharedArrayBuffer arrayBuffer,
|
|
2320
|
+
size_t byteOffset) {
|
|
2321
|
+
if (byteOffset > arrayBuffer.ByteLength()) {
|
|
2322
|
+
NAPI_THROW(RangeError::New(
|
|
2323
|
+
env, "Start offset is outside the bounds of the buffer"),
|
|
2324
|
+
DataView());
|
|
2325
|
+
}
|
|
2326
|
+
return New(
|
|
2327
|
+
env, arrayBuffer, byteOffset, arrayBuffer.ByteLength() - byteOffset);
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
inline DataView DataView::New(napi_env env,
|
|
2331
|
+
Napi::SharedArrayBuffer arrayBuffer,
|
|
2332
|
+
size_t byteOffset,
|
|
2333
|
+
size_t byteLength) {
|
|
2334
|
+
if (byteOffset + byteLength > arrayBuffer.ByteLength()) {
|
|
2335
|
+
NAPI_THROW(RangeError::New(env, "Invalid DataView length"), DataView());
|
|
2336
|
+
}
|
|
2337
|
+
napi_value value;
|
|
2338
|
+
napi_status status =
|
|
2339
|
+
napi_create_dataview(env, byteLength, arrayBuffer, byteOffset, &value);
|
|
2340
|
+
NAPI_THROW_IF_FAILED(env, status, DataView());
|
|
2341
|
+
return DataView(env, value);
|
|
2342
|
+
}
|
|
2343
|
+
#endif // NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER
|
|
2344
|
+
|
|
2292
2345
|
inline void DataView::CheckCast(napi_env env, napi_value value) {
|
|
2293
2346
|
NAPI_CHECK(value != nullptr, "DataView::CheckCast", "empty value");
|
|
2294
2347
|
|
|
@@ -2312,6 +2365,10 @@ inline DataView::DataView(napi_env env, napi_value value) : Object(env, value) {
|
|
|
2312
2365
|
}
|
|
2313
2366
|
|
|
2314
2367
|
inline Napi::ArrayBuffer DataView::ArrayBuffer() const {
|
|
2368
|
+
return Buffer().As<Napi::ArrayBuffer>();
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
inline Napi::Value DataView::Buffer() const {
|
|
2315
2372
|
napi_value arrayBuffer;
|
|
2316
2373
|
napi_status status = napi_get_dataview_info(_env,
|
|
2317
2374
|
_value /* dataView */,
|
|
@@ -2319,8 +2376,8 @@ inline Napi::ArrayBuffer DataView::ArrayBuffer() const {
|
|
|
2319
2376
|
nullptr /* data */,
|
|
2320
2377
|
&arrayBuffer /* arrayBuffer */,
|
|
2321
2378
|
nullptr /* byteOffset */);
|
|
2322
|
-
NAPI_THROW_IF_FAILED(_env, status, Napi::
|
|
2323
|
-
return Napi::
|
|
2379
|
+
NAPI_THROW_IF_FAILED(_env, status, Napi::Value());
|
|
2380
|
+
return Napi::Value(_env, arrayBuffer);
|
|
2324
2381
|
}
|
|
2325
2382
|
|
|
2326
2383
|
inline size_t DataView::ByteOffset() const {
|
|
@@ -3809,8 +3866,8 @@ inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
|
3809
3866
|
return Value().Set(utf8name, value);
|
|
3810
3867
|
}
|
|
3811
3868
|
|
|
3812
|
-
inline MaybeOrValue<bool> ObjectReference::Set(
|
|
3813
|
-
|
|
3869
|
+
inline MaybeOrValue<bool> ObjectReference::Set(
|
|
3870
|
+
const std::string& utf8name, const std::string& utf8value) const {
|
|
3814
3871
|
HandleScope scope(_env);
|
|
3815
3872
|
return Value().Set(utf8name, utf8value);
|
|
3816
3873
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#if NAPI_HAS_THREADS
|
|
18
18
|
#include <mutex>
|
|
19
19
|
#endif // NAPI_HAS_THREADS
|
|
20
|
+
#include <chrono>
|
|
20
21
|
#include <string>
|
|
21
22
|
#include <vector>
|
|
22
23
|
|
|
@@ -359,10 +360,10 @@ class BasicEnv {
|
|
|
359
360
|
// ... occurs when comparing foo.Env() == bar.Env() or foo.Env() == nullptr
|
|
360
361
|
bool operator==(const BasicEnv& other) const {
|
|
361
362
|
return _env == other._env;
|
|
362
|
-
}
|
|
363
|
+
}
|
|
363
364
|
bool operator==(std::nullptr_t /*other*/) const {
|
|
364
365
|
return _env == nullptr;
|
|
365
|
-
}
|
|
366
|
+
}
|
|
366
367
|
|
|
367
368
|
#if NAPI_VERSION > 2
|
|
368
369
|
template <typename Hook, typename Arg = void>
|
|
@@ -685,6 +686,12 @@ class Date : public Value {
|
|
|
685
686
|
double value ///< Number value
|
|
686
687
|
);
|
|
687
688
|
|
|
689
|
+
/// Creates a new Date value from a std::chrono::system_clock::time_point.
|
|
690
|
+
static Date New(
|
|
691
|
+
napi_env env, ///< Node-API environment
|
|
692
|
+
std::chrono::system_clock::time_point time_point ///< Time point value
|
|
693
|
+
);
|
|
694
|
+
|
|
688
695
|
static void CheckCast(napi_env env, napi_value value);
|
|
689
696
|
|
|
690
697
|
Date(); ///< Creates a new _empty_ Date instance.
|
|
@@ -1118,6 +1125,12 @@ class Object : public TypeTaggable {
|
|
|
1118
1125
|
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof
|
|
1119
1126
|
MaybeOrValue<bool> Seal() const;
|
|
1120
1127
|
#endif // NAPI_VERSION >= 8
|
|
1128
|
+
|
|
1129
|
+
MaybeOrValue<Object> GetPrototype() const;
|
|
1130
|
+
|
|
1131
|
+
#ifdef NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE
|
|
1132
|
+
MaybeOrValue<bool> SetPrototype(const Object& value) const;
|
|
1133
|
+
#endif
|
|
1121
1134
|
};
|
|
1122
1135
|
|
|
1123
1136
|
template <typename T>
|
|
@@ -1450,13 +1463,37 @@ class DataView : public Object {
|
|
|
1450
1463
|
size_t byteOffset,
|
|
1451
1464
|
size_t byteLength);
|
|
1452
1465
|
|
|
1466
|
+
#ifdef NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER
|
|
1467
|
+
static DataView New(napi_env env, Napi::SharedArrayBuffer arrayBuffer);
|
|
1468
|
+
static DataView New(napi_env env,
|
|
1469
|
+
Napi::SharedArrayBuffer arrayBuffer,
|
|
1470
|
+
size_t byteOffset);
|
|
1471
|
+
static DataView New(napi_env env,
|
|
1472
|
+
Napi::SharedArrayBuffer arrayBuffer,
|
|
1473
|
+
size_t byteOffset,
|
|
1474
|
+
size_t byteLength);
|
|
1475
|
+
#endif
|
|
1476
|
+
|
|
1453
1477
|
static void CheckCast(napi_env env, napi_value value);
|
|
1454
1478
|
|
|
1455
1479
|
DataView(); ///< Creates a new _empty_ DataView instance.
|
|
1456
1480
|
DataView(napi_env env,
|
|
1457
1481
|
napi_value value); ///< Wraps a Node-API value primitive.
|
|
1458
1482
|
|
|
1459
|
-
|
|
1483
|
+
// Gets the backing `ArrayBuffer`.
|
|
1484
|
+
//
|
|
1485
|
+
// If this `DataView` is not backed by an `ArrayBuffer`, this method will
|
|
1486
|
+
// terminate the process with a fatal error when using
|
|
1487
|
+
// `NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS` or exhibit undefined behavior
|
|
1488
|
+
// otherwise. Use `Buffer()` instead to get the backing buffer without
|
|
1489
|
+
// assuming its type.
|
|
1490
|
+
Napi::ArrayBuffer ArrayBuffer() const;
|
|
1491
|
+
|
|
1492
|
+
// Gets the backing buffer (an `ArrayBuffer` or `SharedArrayBuffer`).
|
|
1493
|
+
//
|
|
1494
|
+
// Use `IsArrayBuffer()` or `IsSharedArrayBuffer()` to check the type of the
|
|
1495
|
+
// backing buffer prior to casting with `As<T>()`.
|
|
1496
|
+
Napi::Value Buffer() const;
|
|
1460
1497
|
size_t ByteOffset()
|
|
1461
1498
|
const; ///< Gets the offset into the buffer where the array starts.
|
|
1462
1499
|
size_t ByteLength() const; ///< Gets the length of the array in bytes.
|
|
@@ -1733,7 +1770,7 @@ class ObjectReference : public Reference<Object> {
|
|
|
1733
1770
|
MaybeOrValue<bool> Set(const std::string& utf8name, napi_value value) const;
|
|
1734
1771
|
MaybeOrValue<bool> Set(const std::string& utf8name, Napi::Value value) const;
|
|
1735
1772
|
MaybeOrValue<bool> Set(const std::string& utf8name,
|
|
1736
|
-
std::string& utf8value) const;
|
|
1773
|
+
const std::string& utf8value) const;
|
|
1737
1774
|
MaybeOrValue<bool> Set(const std::string& utf8name, bool boolValue) const;
|
|
1738
1775
|
MaybeOrValue<bool> Set(const std::string& utf8name, double numberValue) const;
|
|
1739
1776
|
|
|
@@ -3126,8 +3163,8 @@ class AsyncProgressWorkerBase : public AsyncWorker {
|
|
|
3126
3163
|
|
|
3127
3164
|
AsyncProgressWorkerBase* asyncprogressworker() {
|
|
3128
3165
|
return _asyncprogressworker;
|
|
3129
|
-
}
|
|
3130
|
-
DataType* data() { return _data; }
|
|
3166
|
+
}
|
|
3167
|
+
DataType* data() { return _data; }
|
|
3131
3168
|
|
|
3132
3169
|
private:
|
|
3133
3170
|
AsyncProgressWorkerBase* _asyncprogressworker;
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
+
"_from": "node-addon-api@^8.6.0",
|
|
3
|
+
"_id": "node-addon-api@8.7.0",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha512-9MdFxmkKaOYVTV+XVRG8ArDwwQ77XIgIPyKASB1k3JPq3M8fGQQQE3YpMOrKm6g//Ktx8ivZr8xo1Qmtqub+GA==",
|
|
6
|
+
"_location": "/node-addon-api",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "node-addon-api@^8.6.0",
|
|
12
|
+
"name": "node-addon-api",
|
|
13
|
+
"escapedName": "node-addon-api",
|
|
14
|
+
"rawSpec": "^8.6.0",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "^8.6.0"
|
|
17
|
+
},
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"/@parcel/watcher"
|
|
20
|
+
],
|
|
21
|
+
"_resolved": "https://mirrors.tencent.com/npm/node-addon-api/-/node-addon-api-8.7.0.tgz",
|
|
22
|
+
"_shasum": "f64f8413456ecbe900221305a3f883c37666473f",
|
|
23
|
+
"_spec": "node-addon-api@^8.6.0",
|
|
24
|
+
"_where": "/Volumes/data/workspace/parcel-watcher",
|
|
2
25
|
"bugs": {
|
|
3
26
|
"url": "https://github.com/nodejs/node-addon-api/issues"
|
|
4
27
|
},
|
|
28
|
+
"bundleDependencies": false,
|
|
5
29
|
"contributors": [
|
|
6
30
|
{
|
|
7
31
|
"name": "Abhishek Kumar Singh",
|
|
@@ -416,6 +440,7 @@
|
|
|
416
440
|
"url": "https://github.com/tuhalf"
|
|
417
441
|
}
|
|
418
442
|
],
|
|
443
|
+
"deprecated": false,
|
|
419
444
|
"description": "Node.js API (Node-API)",
|
|
420
445
|
"devDependencies": {
|
|
421
446
|
"benchmark": "^2.1.4",
|
|
@@ -428,6 +453,14 @@
|
|
|
428
453
|
"semver": "^7.6.0"
|
|
429
454
|
},
|
|
430
455
|
"directories": {},
|
|
456
|
+
"engines": {
|
|
457
|
+
"node": "^18 || ^20 || >= 21"
|
|
458
|
+
},
|
|
459
|
+
"files": [
|
|
460
|
+
"*.{c,h,gyp,gypi}",
|
|
461
|
+
"package-support.json",
|
|
462
|
+
"tools/"
|
|
463
|
+
],
|
|
431
464
|
"gypfile": false,
|
|
432
465
|
"homepage": "https://github.com/nodejs/node-addon-api",
|
|
433
466
|
"keywords": [
|
|
@@ -444,37 +477,28 @@
|
|
|
444
477
|
"license": "MIT",
|
|
445
478
|
"main": "index.js",
|
|
446
479
|
"name": "node-addon-api",
|
|
447
|
-
"
|
|
480
|
+
"pre-commit": "lint",
|
|
448
481
|
"repository": {
|
|
449
482
|
"type": "git",
|
|
450
483
|
"url": "git://github.com/nodejs/node-addon-api.git"
|
|
451
484
|
},
|
|
452
|
-
"files": [
|
|
453
|
-
"*.{c,h,gyp,gypi}",
|
|
454
|
-
"package-support.json",
|
|
455
|
-
"tools/"
|
|
456
|
-
],
|
|
457
485
|
"scripts": {
|
|
458
|
-
"prebenchmark": "node-gyp rebuild -C benchmark",
|
|
459
486
|
"benchmark": "node benchmark",
|
|
460
487
|
"create-coverage": "npm test --coverage",
|
|
461
|
-
"report-coverage-html": "rm -rf coverage-html && mkdir coverage-html && gcovr -e test --merge-mode-functions merge-use-line-max --html-nested ./coverage-html/index.html test",
|
|
462
|
-
"report-coverage-xml": "rm -rf coverage-xml && mkdir coverage-xml && gcovr -e test --merge-mode-functions merge-use-line-max --xml -o ./coverage-xml/coverage-cxx.xml test",
|
|
463
|
-
"pretest": "node-gyp rebuild -C test",
|
|
464
|
-
"test": "node test",
|
|
465
|
-
"test:debug": "node-gyp rebuild -C test --debug && NODE_API_BUILD_CONFIG=Debug node ./test/index.js",
|
|
466
|
-
"predev": "node-gyp rebuild -C test --debug",
|
|
467
488
|
"dev": "node test",
|
|
468
|
-
"predev:incremental": "node-gyp configure build -C test --debug",
|
|
469
489
|
"dev:incremental": "node test",
|
|
470
490
|
"doc": "doxygen doc/Doxyfile",
|
|
471
491
|
"lint": "eslint && node tools/clang-format",
|
|
472
|
-
"lint:fix": "eslint --fix && node tools/clang-format --fix"
|
|
492
|
+
"lint:fix": "eslint --fix && node tools/clang-format --fix",
|
|
493
|
+
"prebenchmark": "node-gyp rebuild -C benchmark",
|
|
494
|
+
"predev": "node-gyp rebuild -C test --debug",
|
|
495
|
+
"predev:incremental": "node-gyp configure build -C test --debug",
|
|
496
|
+
"pretest": "node-gyp rebuild -C test",
|
|
497
|
+
"report-coverage-html": "rm -rf coverage-html && mkdir coverage-html && gcovr -e test --merge-mode-functions merge-use-line-max --html-nested ./coverage-html/index.html test",
|
|
498
|
+
"report-coverage-xml": "rm -rf coverage-xml && mkdir coverage-xml && gcovr -e test --merge-mode-functions merge-use-line-max --xml -o ./coverage-xml/coverage-cxx.xml test",
|
|
499
|
+
"test": "node test",
|
|
500
|
+
"test:debug": "node-gyp rebuild -C test --debug && NODE_API_BUILD_CONFIG=Debug node ./test/index.js"
|
|
473
501
|
},
|
|
474
|
-
"pre-commit": "lint",
|
|
475
|
-
"version": "8.6.0",
|
|
476
502
|
"support": true,
|
|
477
|
-
"
|
|
478
|
-
"node": "^18 || ^20 || >= 21"
|
|
479
|
-
}
|
|
503
|
+
"version": "8.7.0"
|
|
480
504
|
}
|
|
@@ -265,6 +265,17 @@ Compile a regular expression from the `state` object returned by the
|
|
|
265
265
|
* `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
266
266
|
* `returns` **{RegExp}**
|
|
267
267
|
|
|
268
|
+
**Example**
|
|
269
|
+
|
|
270
|
+
```js
|
|
271
|
+
const picomatch = require('picomatch');
|
|
272
|
+
const state = picomatch.parse('*.js');
|
|
273
|
+
// picomatch.compileRe(state[, options]);
|
|
274
|
+
|
|
275
|
+
console.log(picomatch.compileRe(state));
|
|
276
|
+
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
277
|
+
```
|
|
278
|
+
|
|
268
279
|
### [.makeRe](lib/picomatch.js#L285)
|
|
269
280
|
|
|
270
281
|
Create a regular expression from a parsed glob pattern.
|
|
@@ -281,10 +292,10 @@ Create a regular expression from a parsed glob pattern.
|
|
|
281
292
|
|
|
282
293
|
```js
|
|
283
294
|
const picomatch = require('picomatch');
|
|
284
|
-
|
|
285
|
-
// picomatch.compileRe(state[, options]);
|
|
295
|
+
// picomatch.makeRe(state[, options]);
|
|
286
296
|
|
|
287
|
-
|
|
297
|
+
const result = picomatch.makeRe('*.js');
|
|
298
|
+
console.log(result);
|
|
288
299
|
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
289
300
|
```
|
|
290
301
|
|
|
@@ -323,11 +334,9 @@ The following options may be used with the main `picomatch()` function or any of
|
|
|
323
334
|
| `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
|
|
324
335
|
| `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
|
|
325
336
|
| `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
|
|
326
|
-
| `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` |
|
|
327
337
|
| `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
|
|
328
338
|
| `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
|
|
329
339
|
| `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
|
|
330
|
-
| `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |
|
|
331
340
|
| `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
|
|
332
341
|
| `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
|
|
333
342
|
| [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
|
|
@@ -336,26 +345,23 @@ The following options may be used with the main `picomatch()` function or any of
|
|
|
336
345
|
| `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
|
|
337
346
|
| `matchBase` | `boolean` | `false` | Alias for `basename` |
|
|
338
347
|
| `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
|
|
348
|
+
| `maxExtglobRecursion` | `number\|boolean` | `0` | Limit nested quantified extglobs and other risky repeated extglob forms. When the limit is exceeded, the extglob is treated as a literal string instead of being compiled to regex. Set to `false` to disable this safeguard. |
|
|
339
349
|
| `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
|
|
340
350
|
| `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
|
|
341
351
|
| `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
|
|
342
|
-
| `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. |
|
|
343
352
|
| `noext` | `boolean` | `false` | Alias for `noextglob` |
|
|
344
353
|
| `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
|
|
345
354
|
| `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
|
|
346
355
|
| `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
|
|
347
|
-
| `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. |
|
|
348
356
|
| [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
|
|
349
357
|
| [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
|
|
350
358
|
| [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
|
|
351
359
|
| `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
|
|
352
|
-
| `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |
|
|
353
360
|
| `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
|
|
354
361
|
| `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
|
|
355
362
|
| `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
|
|
356
363
|
| `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
|
|
357
364
|
| `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
|
|
358
|
-
| `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |
|
|
359
365
|
| `windows` | `boolean` | `false` | Also accept backslashes as the path separator. |
|
|
360
366
|
|
|
361
367
|
### Scan Options
|
|
@@ -549,6 +555,13 @@ console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
|
|
|
549
555
|
|
|
550
556
|
// supports nested extglobs
|
|
551
557
|
console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
|
|
558
|
+
|
|
559
|
+
// risky quantified extglobs are treated literally by default
|
|
560
|
+
console.log(pm.makeRe('+(a|aa)'));
|
|
561
|
+
//=> /^(?:\+\(a\|aa\))$/
|
|
562
|
+
|
|
563
|
+
// increase the limit to allow a small amount of nested quantified extglobs
|
|
564
|
+
console.log(pm.isMatch('aaa', '+(+(a))', { maxExtglobRecursion: 1 })); // true
|
|
552
565
|
```
|
|
553
566
|
|
|
554
567
|
#### POSIX brackets
|
|
@@ -585,7 +598,7 @@ See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_no
|
|
|
585
598
|
|
|
586
599
|
### Braces
|
|
587
600
|
|
|
588
|
-
Picomatch does
|
|
601
|
+
Picomatch only does [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) of comma-delimited lists (e.g. `a/{b,c}/d`). For advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch), which supports advanced syntax such as ranges (e.g. `{01..03}`) and increments (e.g. `{2..10..2}`).
|
|
589
602
|
|
|
590
603
|
### Matching special characters as literals
|
|
591
604
|
|
|
@@ -629,44 +642,42 @@ The following table shows which features are supported by [minimatch](https://gi
|
|
|
629
642
|
|
|
630
643
|
Performance comparison of picomatch and minimatch.
|
|
631
644
|
|
|
632
|
-
_(Pay special attention to the last three benchmarks. Minimatch freezes on long ranges.)_
|
|
633
|
-
|
|
634
645
|
```
|
|
635
646
|
# .makeRe star (*)
|
|
636
|
-
picomatch x
|
|
637
|
-
minimatch x
|
|
647
|
+
picomatch x 3,251,247 ops/sec ±0.25% (95 runs sampled)
|
|
648
|
+
minimatch x 497,224 ops/sec ±0.11% (100 runs sampled)
|
|
638
649
|
|
|
639
650
|
# .makeRe star; dot=true (*)
|
|
640
|
-
picomatch x
|
|
641
|
-
minimatch x
|
|
651
|
+
picomatch x 2,624,035 ops/sec ±0.16% (98 runs sampled)
|
|
652
|
+
minimatch x 446,244 ops/sec ±0.63% (99 runs sampled)
|
|
642
653
|
|
|
643
654
|
# .makeRe globstar (**)
|
|
644
|
-
picomatch x
|
|
645
|
-
minimatch x 1,
|
|
655
|
+
picomatch x 2,524,465 ops/sec ±0.13% (99 runs sampled)
|
|
656
|
+
minimatch x 1,396,257 ops/sec ±0.58% (96 runs sampled)
|
|
646
657
|
|
|
647
658
|
# .makeRe globstars (**/**/**)
|
|
648
|
-
picomatch x
|
|
649
|
-
minimatch x 1,
|
|
659
|
+
picomatch x 2,545,674 ops/sec ±0.10% (99 runs sampled)
|
|
660
|
+
minimatch x 1,196,835 ops/sec ±0.63% (98 runs sampled)
|
|
650
661
|
|
|
651
662
|
# .makeRe with leading star (*.txt)
|
|
652
|
-
picomatch x
|
|
653
|
-
minimatch x
|
|
663
|
+
picomatch x 2,537,708 ops/sec ±0.11% (100 runs sampled)
|
|
664
|
+
minimatch x 345,284 ops/sec ±0.64% (96 runs sampled)
|
|
654
665
|
|
|
655
666
|
# .makeRe - basic braces ({a,b,c}*.txt)
|
|
656
|
-
picomatch x
|
|
657
|
-
minimatch x 107,
|
|
667
|
+
picomatch x 505,430 ops/sec ±1.04% (94 runs sampled)
|
|
668
|
+
minimatch x 107,991 ops/sec ±0.54% (99 runs sampled)
|
|
658
669
|
|
|
659
670
|
# .makeRe - short ranges ({a..z}*.txt)
|
|
660
|
-
picomatch x
|
|
661
|
-
minimatch x 14,
|
|
671
|
+
picomatch x 371,179 ops/sec ±2.91% (77 runs sampled)
|
|
672
|
+
minimatch x 14,104 ops/sec ±0.61% (99 runs sampled)
|
|
662
673
|
|
|
663
674
|
# .makeRe - medium ranges ({1..100000}*.txt)
|
|
664
|
-
picomatch x
|
|
665
|
-
minimatch x 2 ops/sec ±
|
|
675
|
+
picomatch x 384,958 ops/sec ±1.70% (82 runs sampled)
|
|
676
|
+
minimatch x 2.55 ops/sec ±3.22% (11 runs sampled)
|
|
666
677
|
|
|
667
678
|
# .makeRe - long ranges ({1..10000000}*.txt)
|
|
668
|
-
picomatch x
|
|
669
|
-
minimatch
|
|
679
|
+
picomatch x 382,552 ops/sec ±1.52% (71 runs sampled)
|
|
680
|
+
minimatch x 0.83 ops/sec ±5.67% (7 runs sampled))
|
|
670
681
|
```
|
|
671
682
|
|
|
672
683
|
<br>
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const WIN_SLASH = '\\\\/';
|
|
4
4
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
5
5
|
|
|
6
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Posix glob regex
|
|
8
10
|
*/
|
|
@@ -69,6 +71,7 @@ const WINDOWS_CHARS = {
|
|
|
69
71
|
*/
|
|
70
72
|
|
|
71
73
|
const POSIX_REGEX_SOURCE = {
|
|
74
|
+
__proto__: null,
|
|
72
75
|
alnum: 'a-zA-Z0-9',
|
|
73
76
|
alpha: 'a-zA-Z',
|
|
74
77
|
ascii: '\\x00-\\x7F',
|
|
@@ -86,6 +89,7 @@ const POSIX_REGEX_SOURCE = {
|
|
|
86
89
|
};
|
|
87
90
|
|
|
88
91
|
module.exports = {
|
|
92
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
89
93
|
MAX_LENGTH: 1024 * 64,
|
|
90
94
|
POSIX_REGEX_SOURCE,
|
|
91
95
|
|
|
@@ -45,6 +45,277 @@ const syntaxError = (type, char) => {
|
|
|
45
45
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const splitTopLevel = input => {
|
|
49
|
+
const parts = [];
|
|
50
|
+
let bracket = 0;
|
|
51
|
+
let paren = 0;
|
|
52
|
+
let quote = 0;
|
|
53
|
+
let value = '';
|
|
54
|
+
let escaped = false;
|
|
55
|
+
|
|
56
|
+
for (const ch of input) {
|
|
57
|
+
if (escaped === true) {
|
|
58
|
+
value += ch;
|
|
59
|
+
escaped = false;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (ch === '\\') {
|
|
64
|
+
value += ch;
|
|
65
|
+
escaped = true;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (ch === '"') {
|
|
70
|
+
quote = quote === 1 ? 0 : 1;
|
|
71
|
+
value += ch;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (quote === 0) {
|
|
76
|
+
if (ch === '[') {
|
|
77
|
+
bracket++;
|
|
78
|
+
} else if (ch === ']' && bracket > 0) {
|
|
79
|
+
bracket--;
|
|
80
|
+
} else if (bracket === 0) {
|
|
81
|
+
if (ch === '(') {
|
|
82
|
+
paren++;
|
|
83
|
+
} else if (ch === ')' && paren > 0) {
|
|
84
|
+
paren--;
|
|
85
|
+
} else if (ch === '|' && paren === 0) {
|
|
86
|
+
parts.push(value);
|
|
87
|
+
value = '';
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
value += ch;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
parts.push(value);
|
|
97
|
+
return parts;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const isPlainBranch = branch => {
|
|
101
|
+
let escaped = false;
|
|
102
|
+
|
|
103
|
+
for (const ch of branch) {
|
|
104
|
+
if (escaped === true) {
|
|
105
|
+
escaped = false;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (ch === '\\') {
|
|
110
|
+
escaped = true;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return true;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const normalizeSimpleBranch = branch => {
|
|
123
|
+
let value = branch.trim();
|
|
124
|
+
let changed = true;
|
|
125
|
+
|
|
126
|
+
while (changed === true) {
|
|
127
|
+
changed = false;
|
|
128
|
+
|
|
129
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
130
|
+
value = value.slice(2, -1);
|
|
131
|
+
changed = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!isPlainBranch(value)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return value.replace(/\\(.)/g, '$1');
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
143
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
144
|
+
|
|
145
|
+
for (let i = 0; i < values.length; i++) {
|
|
146
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
147
|
+
const a = values[i];
|
|
148
|
+
const b = values[j];
|
|
149
|
+
const char = a[0];
|
|
150
|
+
|
|
151
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return false;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
165
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let bracket = 0;
|
|
170
|
+
let paren = 0;
|
|
171
|
+
let quote = 0;
|
|
172
|
+
let escaped = false;
|
|
173
|
+
|
|
174
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
175
|
+
const ch = pattern[i];
|
|
176
|
+
|
|
177
|
+
if (escaped === true) {
|
|
178
|
+
escaped = false;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (ch === '\\') {
|
|
183
|
+
escaped = true;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (ch === '"') {
|
|
188
|
+
quote = quote === 1 ? 0 : 1;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (quote === 1) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (ch === '[') {
|
|
197
|
+
bracket++;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (ch === ']' && bracket > 0) {
|
|
202
|
+
bracket--;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (bracket > 0) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (ch === '(') {
|
|
211
|
+
paren++;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (ch === ')') {
|
|
216
|
+
paren--;
|
|
217
|
+
|
|
218
|
+
if (paren === 0) {
|
|
219
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
type: pattern[0],
|
|
225
|
+
body: pattern.slice(2, i),
|
|
226
|
+
end: i
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
234
|
+
let index = 0;
|
|
235
|
+
const chars = [];
|
|
236
|
+
|
|
237
|
+
while (index < pattern.length) {
|
|
238
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
239
|
+
|
|
240
|
+
if (!match || match.type !== '*') {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
245
|
+
if (branches.length !== 1) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
250
|
+
if (!branch || branch.length !== 1) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
chars.push(branch);
|
|
255
|
+
index += match.end + 1;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (chars.length < 1) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const source = chars.length === 1
|
|
263
|
+
? utils.escapeRegex(chars[0])
|
|
264
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
265
|
+
|
|
266
|
+
return `${source}*`;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const repeatedExtglobRecursion = pattern => {
|
|
270
|
+
let depth = 0;
|
|
271
|
+
let value = pattern.trim();
|
|
272
|
+
let match = parseRepeatedExtglob(value);
|
|
273
|
+
|
|
274
|
+
while (match) {
|
|
275
|
+
depth++;
|
|
276
|
+
value = match.body.trim();
|
|
277
|
+
match = parseRepeatedExtglob(value);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return depth;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
284
|
+
if (options.maxExtglobRecursion === false) {
|
|
285
|
+
return { risky: false };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const max =
|
|
289
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
290
|
+
? options.maxExtglobRecursion
|
|
291
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
292
|
+
|
|
293
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
294
|
+
|
|
295
|
+
if (branches.length > 1) {
|
|
296
|
+
if (
|
|
297
|
+
branches.some(branch => branch === '') ||
|
|
298
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
299
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
300
|
+
) {
|
|
301
|
+
return { risky: true };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
for (const branch of branches) {
|
|
306
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
307
|
+
if (safeOutput) {
|
|
308
|
+
return { risky: true, safeOutput };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
312
|
+
return { risky: true };
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return { risky: false };
|
|
317
|
+
};
|
|
318
|
+
|
|
48
319
|
/**
|
|
49
320
|
* Parse the given input string.
|
|
50
321
|
* @param {String} input
|
|
@@ -225,6 +496,8 @@ const parse = (input, options) => {
|
|
|
225
496
|
token.prev = prev;
|
|
226
497
|
token.parens = state.parens;
|
|
227
498
|
token.output = state.output;
|
|
499
|
+
token.startIndex = state.index;
|
|
500
|
+
token.tokensIndex = tokens.length;
|
|
228
501
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
229
502
|
|
|
230
503
|
increment('parens');
|
|
@@ -234,6 +507,34 @@ const parse = (input, options) => {
|
|
|
234
507
|
};
|
|
235
508
|
|
|
236
509
|
const extglobClose = token => {
|
|
510
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
511
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
512
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
513
|
+
|
|
514
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
515
|
+
const safeOutput = analysis.safeOutput
|
|
516
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
517
|
+
: undefined;
|
|
518
|
+
const open = tokens[token.tokensIndex];
|
|
519
|
+
|
|
520
|
+
open.type = 'text';
|
|
521
|
+
open.value = literal;
|
|
522
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
523
|
+
|
|
524
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
525
|
+
tokens[i].value = '';
|
|
526
|
+
tokens[i].output = '';
|
|
527
|
+
delete tokens[i].suffix;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
state.output = token.output + open.output;
|
|
531
|
+
state.backtrack = true;
|
|
532
|
+
|
|
533
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
534
|
+
decrement('parens');
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
237
538
|
let output = token.close + (opts.capture ? ')' : '');
|
|
238
539
|
let rest;
|
|
239
540
|
|
|
@@ -233,6 +233,14 @@ picomatch.scan = (input, options) => scan(input, options);
|
|
|
233
233
|
* Compile a regular expression from the `state` object returned by the
|
|
234
234
|
* [parse()](#parse) method.
|
|
235
235
|
*
|
|
236
|
+
* ```js
|
|
237
|
+
* const picomatch = require('picomatch');
|
|
238
|
+
* const state = picomatch.parse('*.js');
|
|
239
|
+
* // picomatch.compileRe(state[, options]);
|
|
240
|
+
*
|
|
241
|
+
* console.log(picomatch.compileRe(state));
|
|
242
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
243
|
+
* ```
|
|
236
244
|
* @param {Object} `state`
|
|
237
245
|
* @param {Object} `options`
|
|
238
246
|
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
@@ -268,10 +276,10 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
|
|
|
268
276
|
*
|
|
269
277
|
* ```js
|
|
270
278
|
* const picomatch = require('picomatch');
|
|
271
|
-
*
|
|
272
|
-
* // picomatch.compileRe(state[, options]);
|
|
279
|
+
* // picomatch.makeRe(state[, options]);
|
|
273
280
|
*
|
|
274
|
-
*
|
|
281
|
+
* const result = picomatch.makeRe('*.js');
|
|
282
|
+
* console.log(result);
|
|
275
283
|
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
276
284
|
* ```
|
|
277
285
|
* @param {String} `state` The object returned from the `.parse` method.
|
|
@@ -1,45 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
2
|
+
"_from": "picomatch@^4.0.3",
|
|
3
|
+
"_id": "picomatch@4.0.4",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
|
6
|
+
"_location": "/picomatch",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "picomatch@^4.0.3",
|
|
12
|
+
"name": "picomatch",
|
|
13
|
+
"escapedName": "picomatch",
|
|
14
|
+
"rawSpec": "^4.0.3",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "^4.0.3"
|
|
11
17
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"index.js",
|
|
15
|
-
"posix.js",
|
|
16
|
-
"lib"
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"/@parcel/watcher"
|
|
17
20
|
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
21
|
+
"_resolved": "https://mirrors.tencent.com/npm/picomatch/-/picomatch-4.0.4.tgz",
|
|
22
|
+
"_shasum": "fd6f5e00a143086e074dffe4c924b8fb293b0589",
|
|
23
|
+
"_spec": "picomatch@^4.0.3",
|
|
24
|
+
"_where": "/Volumes/data/workspace/parcel-watcher",
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Jon Schlinkert",
|
|
27
|
+
"url": "https://github.com/jonschlinkert"
|
|
22
28
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"mocha": "mocha --reporter dot",
|
|
26
|
-
"test": "npm run lint && npm run mocha",
|
|
27
|
-
"test:ci": "npm run test:cover",
|
|
28
|
-
"test:cover": "nyc npm run mocha"
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/micromatch/picomatch/issues"
|
|
29
31
|
},
|
|
32
|
+
"bundleDependencies": false,
|
|
33
|
+
"deprecated": false,
|
|
34
|
+
"description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
|
|
30
35
|
"devDependencies": {
|
|
31
36
|
"eslint": "^8.57.0",
|
|
32
37
|
"fill-range": "^7.0.1",
|
|
33
38
|
"gulp-format-md": "^2.0.0",
|
|
34
39
|
"mocha": "^10.4.0",
|
|
35
|
-
"nyc": "^15.1.0"
|
|
36
|
-
"time-require": "github:jonschlinkert/time-require"
|
|
40
|
+
"nyc": "^15.1.0"
|
|
37
41
|
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=12"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"index.js",
|
|
47
|
+
"posix.js",
|
|
48
|
+
"lib"
|
|
49
|
+
],
|
|
50
|
+
"funding": "https://github.com/sponsors/jonschlinkert",
|
|
51
|
+
"homepage": "https://github.com/micromatch/picomatch",
|
|
38
52
|
"keywords": [
|
|
39
53
|
"glob",
|
|
40
54
|
"match",
|
|
41
55
|
"picomatch"
|
|
42
56
|
],
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"main": "index.js",
|
|
59
|
+
"name": "picomatch",
|
|
43
60
|
"nyc": {
|
|
44
61
|
"reporter": [
|
|
45
62
|
"html",
|
|
@@ -47,6 +64,18 @@
|
|
|
47
64
|
"text-summary"
|
|
48
65
|
]
|
|
49
66
|
},
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "git+https://github.com/micromatch/picomatch.git"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .",
|
|
73
|
+
"mocha": "mocha --reporter dot",
|
|
74
|
+
"test": "npm run lint && npm run mocha",
|
|
75
|
+
"test:ci": "npm run test:cover",
|
|
76
|
+
"test:cover": "nyc npm run mocha"
|
|
77
|
+
},
|
|
78
|
+
"sideEffects": false,
|
|
50
79
|
"verb": {
|
|
51
80
|
"toc": {
|
|
52
81
|
"render": true,
|
|
@@ -79,5 +108,6 @@
|
|
|
79
108
|
"nanomatch",
|
|
80
109
|
"picomatch"
|
|
81
110
|
]
|
|
82
|
-
}
|
|
111
|
+
},
|
|
112
|
+
"version": "4.0.4"
|
|
83
113
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|