@qwik.dev/devtools 0.0.3 → 0.0.4
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/LICENSE +21 -0
- package/README.md +1 -47
- package/dist/component/_virtual/_commonjsHelpers.qwik.cjs +6 -0
- package/dist/component/_virtual/_commonjsHelpers.qwik.mjs +6 -0
- package/{lib → dist/component}/devtools.qwik.cjs +19 -20
- package/{lib → dist/component}/devtools.qwik.mjs +11 -12
- package/{lib → dist/component}/index.qwik.cjs +0 -2
- package/dist/component/index.qwik.mjs +4 -0
- package/{lib-types → dist/component/lib-types/devtools/src}/index.d.ts +0 -1
- package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/hi.qwik.qwik.cjs +60 -0
- package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/hi.qwik.qwik.mjs +60 -0
- package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/lu.qwik.qwik.cjs +32 -0
- package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/lu.qwik.qwik.mjs +32 -0
- package/dist/component/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.qwik.cjs +54 -0
- package/dist/component/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.qwik.mjs +54 -0
- package/dist/component/node_modules/.pnpm/birpc@0.2.19/node_modules/birpc/dist/index.qwik.cjs +128 -0
- package/dist/component/node_modules/.pnpm/birpc@0.2.19/node_modules/birpc/dist/index.qwik.mjs +128 -0
- package/dist/component/node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.qwik.cjs +149 -0
- package/dist/component/node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.qwik.mjs +150 -0
- package/dist/component/node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.qwik.cjs +36 -0
- package/dist/component/node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.qwik.mjs +36 -0
- package/dist/component/node_modules/.pnpm/dree@5.1.5/node_modules/dree/bundled/lib/esm/index.esm.qwik.cjs +12 -0
- package/dist/component/node_modules/.pnpm/dree@5.1.5/node_modules/dree/bundled/lib/esm/index.esm.qwik.mjs +12 -0
- package/dist/component/node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.qwik.cjs +17 -0
- package/dist/component/node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.qwik.mjs +17 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/assert-valid-pattern.qwik.cjs +12 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/assert-valid-pattern.qwik.mjs +12 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/ast.qwik.cjs +513 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/ast.qwik.mjs +513 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/brace-expressions.qwik.cjs +110 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/brace-expressions.qwik.mjs +110 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/escape.qwik.cjs +6 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/escape.qwik.mjs +6 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.qwik.cjs +738 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.qwik.mjs +738 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/unescape.qwik.cjs +6 -0
- package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/unescape.qwik.mjs +6 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.qwik.cjs +120 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.qwik.mjs +120 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.qwik.cjs +23 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.qwik.mjs +23 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.qwik.cjs +18 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.qwik.mjs +18 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.qwik.cjs +23 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.qwik.mjs +23 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.qwik.cjs +91 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.qwik.mjs +91 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.qwik.cjs +51 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.qwik.mjs +51 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.qwik.cjs +30 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.qwik.mjs +30 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.qwik.cjs +148 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.qwik.mjs +148 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.qwik.cjs +28 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.qwik.mjs +28 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.qwik.cjs +203 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.qwik.mjs +203 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.qwik.cjs +47 -0
- package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.qwik.mjs +47 -0
- package/dist/component/node_modules/.pnpm/vite-hot-client@0.2.4_vite@5.4.10_@types_node@20.14.11_/node_modules/vite-hot-client/dist/index.qwik.cjs +35 -0
- package/dist/component/node_modules/.pnpm/vite-hot-client@0.2.4_vite@5.4.10_@types_node@20.14.11_/node_modules/vite-hot-client/dist/index.qwik.mjs +35 -0
- package/{lib/kit → dist/component/packages/kit/src}/client.qwik.cjs +5 -5
- package/{lib/kit → dist/component/packages/kit/src}/client.qwik.mjs +2 -2
- package/{lib/kit → dist/component/packages/kit/src}/context.qwik.cjs +0 -12
- package/{lib/kit → dist/component/packages/kit/src}/context.qwik.mjs +2 -14
- package/{lib/kit → dist/component/packages/kit/src}/globals.qwik.cjs +0 -4
- package/dist/component/packages/kit/src/globals.qwik.mjs +6 -0
- package/dist/plugin/index.cjs +10504 -0
- package/dist/plugin/index.mjs +10492 -0
- package/package.json +26 -41
- package/lib/index.qwik.mjs +0 -6
- package/lib/kit/globals.qwik.mjs +0 -10
- package/lib/kit/server.qwik.cjs +0 -18
- package/lib/kit/server.qwik.mjs +0 -18
- package/lib/plugin/assets/index.qwik.cjs +0 -67
- package/lib/plugin/assets/index.qwik.mjs +0 -67
- package/lib/plugin/index.qwik.cjs +0 -49
- package/lib/plugin/index.qwik.mjs +0 -49
- package/lib/plugin/npm/index.qwik.cjs +0 -19
- package/lib/plugin/npm/index.qwik.mjs +0 -19
- package/lib/plugin/routes/index.qwik.cjs +0 -17
- package/lib/plugin/routes/index.qwik.mjs +0 -17
- package/lib/plugin/rpc/index.qwik.cjs +0 -14
- package/lib/plugin/rpc/index.qwik.mjs +0 -14
- package/lib/utils/location.qwik.cjs +0 -9
- package/lib/utils/location.qwik.mjs +0 -9
- package/lib-types/plugin/assets/index.d.ts +0 -5
- package/lib-types/plugin/components/index.d.ts +0 -0
- package/lib-types/plugin/index.d.ts +0 -2
- package/lib-types/plugin/npm/index.d.ts +0 -5
- package/lib-types/plugin/routes/index.d.ts +0 -5
- package/lib-types/plugin/rpc/index.d.ts +0 -3
- package/lib-types/plugin/types/index.d.ts +0 -5
- package/src/devtools.css +0 -558
- package/src/devtools.tsx +0 -404
- package/src/entry.dev.tsx +0 -17
- package/src/entry.ssr.tsx +0 -25
- package/src/index.ts +0 -2
- package/src/kit/client.ts +0 -21
- package/src/kit/constants.ts +0 -1
- package/src/kit/context.ts +0 -42
- package/src/kit/globals.ts +0 -22
- package/src/kit/index.ts +0 -4
- package/src/kit/server.ts +0 -21
- package/src/kit/shared.ts +0 -11
- package/src/kit/types.ts +0 -48
- package/src/plugin/assets/index.ts +0 -126
- package/src/plugin/components/index.ts +0 -0
- package/src/plugin/index.ts +0 -50
- package/src/plugin/npm/index.ts +0 -24
- package/src/plugin/routes/index.ts +0 -16
- package/src/plugin/rpc/index.ts +0 -14
- package/src/plugin/types/index.ts +0 -6
- package/src/root.tsx +0 -15
- package/src/utils/location.ts +0 -9
- /package/{lib → dist/component}/devtools.css.qwik.cjs +0 -0
- /package/{lib → dist/component}/devtools.css.qwik.mjs +0 -0
- /package/{lib-types → dist/component/lib-types/devtools/src}/devtools.d.ts +0 -0
- /package/{lib-types → dist/component/lib-types/devtools/src}/entry.dev.d.ts +0 -0
- /package/{lib-types → dist/component/lib-types/devtools/src}/entry.ssr.d.ts +0 -0
- /package/{lib-types → dist/component/lib-types/devtools/src}/root.d.ts +0 -0
- /package/{lib-types → dist/component/lib-types/devtools/src}/utils/location.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/client.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/constants.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/context.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/globals.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/index.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/server.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/shared.d.ts +0 -0
- /package/{lib-types/kit → dist/component/lib-types/kit/src}/types.d.ts +0 -0
- /package/{lib/kit → dist/component/packages/kit/src}/constants.qwik.cjs +0 -0
- /package/{lib/kit → dist/component/packages/kit/src}/constants.qwik.mjs +0 -0
- /package/{lib/kit → dist/component/packages/kit/src}/shared.qwik.cjs +0 -0
- /package/{lib/kit → dist/component/packages/kit/src}/shared.qwik.mjs +0 -0
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import expand from "../../../../../brace-expansion@2.0.1/node_modules/brace-expansion/index.qwik.mjs";
|
|
5
|
+
import { assertValidPattern } from "./assert-valid-pattern.qwik.mjs";
|
|
6
|
+
import { AST } from "./ast.qwik.mjs";
|
|
7
|
+
import { escape } from "./escape.qwik.mjs";
|
|
8
|
+
import { unescape } from "./unescape.qwik.mjs";
|
|
9
|
+
const minimatch = (p, pattern, options = {}) => {
|
|
10
|
+
assertValidPattern(pattern);
|
|
11
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return new Minimatch(pattern, options).match(p);
|
|
15
|
+
};
|
|
16
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
17
|
+
const starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
18
|
+
const starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
19
|
+
const starDotExtTestNocase = (ext2) => {
|
|
20
|
+
ext2 = ext2.toLowerCase();
|
|
21
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
22
|
+
};
|
|
23
|
+
const starDotExtTestNocaseDot = (ext2) => {
|
|
24
|
+
ext2 = ext2.toLowerCase();
|
|
25
|
+
return (f) => f.toLowerCase().endsWith(ext2);
|
|
26
|
+
};
|
|
27
|
+
const starDotStarRE = /^\*+\.\*+$/;
|
|
28
|
+
const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
29
|
+
const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
30
|
+
const dotStarRE = /^\.\*+$/;
|
|
31
|
+
const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
32
|
+
const starRE = /^\*+$/;
|
|
33
|
+
const starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
34
|
+
const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
35
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
36
|
+
const qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
37
|
+
const noext = qmarksTestNoExt([$0]);
|
|
38
|
+
if (!ext2)
|
|
39
|
+
return noext;
|
|
40
|
+
ext2 = ext2.toLowerCase();
|
|
41
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
42
|
+
};
|
|
43
|
+
const qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
44
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
45
|
+
if (!ext2)
|
|
46
|
+
return noext;
|
|
47
|
+
ext2 = ext2.toLowerCase();
|
|
48
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
49
|
+
};
|
|
50
|
+
const qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
51
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
52
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
53
|
+
};
|
|
54
|
+
const qmarksTest = ([$0, ext2 = ""]) => {
|
|
55
|
+
const noext = qmarksTestNoExt([$0]);
|
|
56
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
57
|
+
};
|
|
58
|
+
const qmarksTestNoExt = ([$0]) => {
|
|
59
|
+
const len = $0.length;
|
|
60
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
61
|
+
};
|
|
62
|
+
const qmarksTestNoExtDot = ([$0]) => {
|
|
63
|
+
const len = $0.length;
|
|
64
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
65
|
+
};
|
|
66
|
+
const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
67
|
+
const path = {
|
|
68
|
+
win32: { sep: "\\" },
|
|
69
|
+
posix: { sep: "/" }
|
|
70
|
+
};
|
|
71
|
+
const sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
72
|
+
minimatch.sep = sep;
|
|
73
|
+
const GLOBSTAR = Symbol("globstar **");
|
|
74
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
75
|
+
const qmark = "[^/]";
|
|
76
|
+
const star = qmark + "*?";
|
|
77
|
+
const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
78
|
+
const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
79
|
+
const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
80
|
+
minimatch.filter = filter;
|
|
81
|
+
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
82
|
+
const defaults = (def) => {
|
|
83
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
84
|
+
return minimatch;
|
|
85
|
+
}
|
|
86
|
+
const orig = minimatch;
|
|
87
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
88
|
+
return Object.assign(m, {
|
|
89
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
90
|
+
constructor(pattern, options = {}) {
|
|
91
|
+
super(pattern, ext(def, options));
|
|
92
|
+
}
|
|
93
|
+
static defaults(options) {
|
|
94
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
AST: class AST extends orig.AST {
|
|
98
|
+
/* c8 ignore start */
|
|
99
|
+
constructor(type, parent, options = {}) {
|
|
100
|
+
super(type, parent, ext(def, options));
|
|
101
|
+
}
|
|
102
|
+
/* c8 ignore stop */
|
|
103
|
+
static fromGlob(pattern, options = {}) {
|
|
104
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
108
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
109
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
110
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
111
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
112
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
113
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
114
|
+
sep: orig.sep,
|
|
115
|
+
GLOBSTAR
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
minimatch.defaults = defaults;
|
|
119
|
+
const braceExpand = (pattern, options = {}) => {
|
|
120
|
+
assertValidPattern(pattern);
|
|
121
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
122
|
+
return [pattern];
|
|
123
|
+
}
|
|
124
|
+
return expand(pattern);
|
|
125
|
+
};
|
|
126
|
+
minimatch.braceExpand = braceExpand;
|
|
127
|
+
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
128
|
+
minimatch.makeRe = makeRe;
|
|
129
|
+
const match = (list, pattern, options = {}) => {
|
|
130
|
+
const mm = new Minimatch(pattern, options);
|
|
131
|
+
list = list.filter((f) => mm.match(f));
|
|
132
|
+
if (mm.options.nonull && !list.length) {
|
|
133
|
+
list.push(pattern);
|
|
134
|
+
}
|
|
135
|
+
return list;
|
|
136
|
+
};
|
|
137
|
+
minimatch.match = match;
|
|
138
|
+
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
139
|
+
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
140
|
+
class Minimatch {
|
|
141
|
+
constructor(pattern, options = {}) {
|
|
142
|
+
__publicField(this, "options");
|
|
143
|
+
__publicField(this, "set");
|
|
144
|
+
__publicField(this, "pattern");
|
|
145
|
+
__publicField(this, "windowsPathsNoEscape");
|
|
146
|
+
__publicField(this, "nonegate");
|
|
147
|
+
__publicField(this, "negate");
|
|
148
|
+
__publicField(this, "comment");
|
|
149
|
+
__publicField(this, "empty");
|
|
150
|
+
__publicField(this, "preserveMultipleSlashes");
|
|
151
|
+
__publicField(this, "partial");
|
|
152
|
+
__publicField(this, "globSet");
|
|
153
|
+
__publicField(this, "globParts");
|
|
154
|
+
__publicField(this, "nocase");
|
|
155
|
+
__publicField(this, "isWindows");
|
|
156
|
+
__publicField(this, "platform");
|
|
157
|
+
__publicField(this, "windowsNoMagicRoot");
|
|
158
|
+
__publicField(this, "regexp");
|
|
159
|
+
assertValidPattern(pattern);
|
|
160
|
+
options = options || {};
|
|
161
|
+
this.options = options;
|
|
162
|
+
this.pattern = pattern;
|
|
163
|
+
this.platform = options.platform || defaultPlatform;
|
|
164
|
+
this.isWindows = this.platform === "win32";
|
|
165
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
166
|
+
if (this.windowsPathsNoEscape) {
|
|
167
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
168
|
+
}
|
|
169
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
170
|
+
this.regexp = null;
|
|
171
|
+
this.negate = false;
|
|
172
|
+
this.nonegate = !!options.nonegate;
|
|
173
|
+
this.comment = false;
|
|
174
|
+
this.empty = false;
|
|
175
|
+
this.partial = !!options.partial;
|
|
176
|
+
this.nocase = !!this.options.nocase;
|
|
177
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
178
|
+
this.globSet = [];
|
|
179
|
+
this.globParts = [];
|
|
180
|
+
this.set = [];
|
|
181
|
+
this.make();
|
|
182
|
+
}
|
|
183
|
+
hasMagic() {
|
|
184
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
for (const pattern of this.set) {
|
|
188
|
+
for (const part of pattern) {
|
|
189
|
+
if (typeof part !== "string")
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
debug(..._) {
|
|
196
|
+
}
|
|
197
|
+
make() {
|
|
198
|
+
const pattern = this.pattern;
|
|
199
|
+
const options = this.options;
|
|
200
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
201
|
+
this.comment = true;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (!pattern) {
|
|
205
|
+
this.empty = true;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.parseNegate();
|
|
209
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
210
|
+
if (options.debug) {
|
|
211
|
+
this.debug = (...args) => console.error(...args);
|
|
212
|
+
}
|
|
213
|
+
this.debug(this.pattern, this.globSet);
|
|
214
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
215
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
216
|
+
this.debug(this.pattern, this.globParts);
|
|
217
|
+
let set = this.globParts.map((s, _, __) => {
|
|
218
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
219
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
220
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
221
|
+
if (isUNC) {
|
|
222
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
223
|
+
} else if (isDrive) {
|
|
224
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return s.map((ss) => this.parse(ss));
|
|
228
|
+
});
|
|
229
|
+
this.debug(this.pattern, set);
|
|
230
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
231
|
+
if (this.isWindows) {
|
|
232
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
233
|
+
const p = this.set[i];
|
|
234
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
235
|
+
p[2] = "?";
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
this.debug(this.pattern, this.set);
|
|
240
|
+
}
|
|
241
|
+
// various transforms to equivalent pattern sets that are
|
|
242
|
+
// faster to process in a filesystem walk. The goal is to
|
|
243
|
+
// eliminate what we can, and push all ** patterns as far
|
|
244
|
+
// to the right as possible, even if it increases the number
|
|
245
|
+
// of patterns that we have to process.
|
|
246
|
+
preprocess(globParts) {
|
|
247
|
+
if (this.options.noglobstar) {
|
|
248
|
+
for (let i = 0; i < globParts.length; i++) {
|
|
249
|
+
for (let j = 0; j < globParts[i].length; j++) {
|
|
250
|
+
if (globParts[i][j] === "**") {
|
|
251
|
+
globParts[i][j] = "*";
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const { optimizationLevel = 1 } = this.options;
|
|
257
|
+
if (optimizationLevel >= 2) {
|
|
258
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
259
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
260
|
+
} else if (optimizationLevel >= 1) {
|
|
261
|
+
globParts = this.levelOneOptimize(globParts);
|
|
262
|
+
} else {
|
|
263
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
264
|
+
}
|
|
265
|
+
return globParts;
|
|
266
|
+
}
|
|
267
|
+
// just get rid of adjascent ** portions
|
|
268
|
+
adjascentGlobstarOptimize(globParts) {
|
|
269
|
+
return globParts.map((parts) => {
|
|
270
|
+
let gs = -1;
|
|
271
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
272
|
+
let i = gs;
|
|
273
|
+
while (parts[i + 1] === "**") {
|
|
274
|
+
i++;
|
|
275
|
+
}
|
|
276
|
+
if (i !== gs) {
|
|
277
|
+
parts.splice(gs, i - gs);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return parts;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// get rid of adjascent ** and resolve .. portions
|
|
284
|
+
levelOneOptimize(globParts) {
|
|
285
|
+
return globParts.map((parts) => {
|
|
286
|
+
parts = parts.reduce((set, part) => {
|
|
287
|
+
const prev = set[set.length - 1];
|
|
288
|
+
if (part === "**" && prev === "**") {
|
|
289
|
+
return set;
|
|
290
|
+
}
|
|
291
|
+
if (part === "..") {
|
|
292
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
293
|
+
set.pop();
|
|
294
|
+
return set;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
set.push(part);
|
|
298
|
+
return set;
|
|
299
|
+
}, []);
|
|
300
|
+
return parts.length === 0 ? [""] : parts;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
levelTwoFileOptimize(parts) {
|
|
304
|
+
if (!Array.isArray(parts)) {
|
|
305
|
+
parts = this.slashSplit(parts);
|
|
306
|
+
}
|
|
307
|
+
let didSomething = false;
|
|
308
|
+
do {
|
|
309
|
+
didSomething = false;
|
|
310
|
+
if (!this.preserveMultipleSlashes) {
|
|
311
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
312
|
+
const p = parts[i];
|
|
313
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
314
|
+
continue;
|
|
315
|
+
if (p === "." || p === "") {
|
|
316
|
+
didSomething = true;
|
|
317
|
+
parts.splice(i, 1);
|
|
318
|
+
i--;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
322
|
+
didSomething = true;
|
|
323
|
+
parts.pop();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
let dd = 0;
|
|
327
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
328
|
+
const p = parts[dd - 1];
|
|
329
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
330
|
+
didSomething = true;
|
|
331
|
+
parts.splice(dd - 1, 2);
|
|
332
|
+
dd -= 2;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} while (didSomething);
|
|
336
|
+
return parts.length === 0 ? [""] : parts;
|
|
337
|
+
}
|
|
338
|
+
// First phase: single-pattern processing
|
|
339
|
+
// <pre> is 1 or more portions
|
|
340
|
+
// <rest> is 1 or more portions
|
|
341
|
+
// <p> is any portion other than ., .., '', or **
|
|
342
|
+
// <e> is . or ''
|
|
343
|
+
//
|
|
344
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
345
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
346
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
347
|
+
// or most strings (other than .., ., and '') can be.
|
|
348
|
+
//
|
|
349
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
350
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
351
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
352
|
+
// **/**/<rest> -> **/<rest>
|
|
353
|
+
//
|
|
354
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
355
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
356
|
+
firstPhasePreProcess(globParts) {
|
|
357
|
+
let didSomething = false;
|
|
358
|
+
do {
|
|
359
|
+
didSomething = false;
|
|
360
|
+
for (let parts of globParts) {
|
|
361
|
+
let gs = -1;
|
|
362
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
363
|
+
let gss = gs;
|
|
364
|
+
while (parts[gss + 1] === "**") {
|
|
365
|
+
gss++;
|
|
366
|
+
}
|
|
367
|
+
if (gss > gs) {
|
|
368
|
+
parts.splice(gs + 1, gss - gs);
|
|
369
|
+
}
|
|
370
|
+
let next = parts[gs + 1];
|
|
371
|
+
const p = parts[gs + 2];
|
|
372
|
+
const p2 = parts[gs + 3];
|
|
373
|
+
if (next !== "..")
|
|
374
|
+
continue;
|
|
375
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
didSomething = true;
|
|
379
|
+
parts.splice(gs, 1);
|
|
380
|
+
const other = parts.slice(0);
|
|
381
|
+
other[gs] = "**";
|
|
382
|
+
globParts.push(other);
|
|
383
|
+
gs--;
|
|
384
|
+
}
|
|
385
|
+
if (!this.preserveMultipleSlashes) {
|
|
386
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
387
|
+
const p = parts[i];
|
|
388
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
389
|
+
continue;
|
|
390
|
+
if (p === "." || p === "") {
|
|
391
|
+
didSomething = true;
|
|
392
|
+
parts.splice(i, 1);
|
|
393
|
+
i--;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
397
|
+
didSomething = true;
|
|
398
|
+
parts.pop();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let dd = 0;
|
|
402
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
403
|
+
const p = parts[dd - 1];
|
|
404
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
405
|
+
didSomething = true;
|
|
406
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
407
|
+
const splin = needDot ? ["."] : [];
|
|
408
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
409
|
+
if (parts.length === 0)
|
|
410
|
+
parts.push("");
|
|
411
|
+
dd -= 2;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} while (didSomething);
|
|
416
|
+
return globParts;
|
|
417
|
+
}
|
|
418
|
+
// second phase: multi-pattern dedupes
|
|
419
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
420
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
421
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
422
|
+
//
|
|
423
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
424
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
425
|
+
secondPhasePreProcess(globParts) {
|
|
426
|
+
for (let i = 0; i < globParts.length - 1; i++) {
|
|
427
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
428
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
429
|
+
if (matched) {
|
|
430
|
+
globParts[i] = [];
|
|
431
|
+
globParts[j] = matched;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return globParts.filter((gs) => gs.length);
|
|
437
|
+
}
|
|
438
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
439
|
+
let ai = 0;
|
|
440
|
+
let bi = 0;
|
|
441
|
+
let result = [];
|
|
442
|
+
let which = "";
|
|
443
|
+
while (ai < a.length && bi < b.length) {
|
|
444
|
+
if (a[ai] === b[bi]) {
|
|
445
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
446
|
+
ai++;
|
|
447
|
+
bi++;
|
|
448
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
449
|
+
result.push(a[ai]);
|
|
450
|
+
ai++;
|
|
451
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
452
|
+
result.push(b[bi]);
|
|
453
|
+
bi++;
|
|
454
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
455
|
+
if (which === "b")
|
|
456
|
+
return false;
|
|
457
|
+
which = "a";
|
|
458
|
+
result.push(a[ai]);
|
|
459
|
+
ai++;
|
|
460
|
+
bi++;
|
|
461
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
462
|
+
if (which === "a")
|
|
463
|
+
return false;
|
|
464
|
+
which = "b";
|
|
465
|
+
result.push(b[bi]);
|
|
466
|
+
ai++;
|
|
467
|
+
bi++;
|
|
468
|
+
} else {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return a.length === b.length && result;
|
|
473
|
+
}
|
|
474
|
+
parseNegate() {
|
|
475
|
+
if (this.nonegate)
|
|
476
|
+
return;
|
|
477
|
+
const pattern = this.pattern;
|
|
478
|
+
let negate = false;
|
|
479
|
+
let negateOffset = 0;
|
|
480
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
481
|
+
negate = !negate;
|
|
482
|
+
negateOffset++;
|
|
483
|
+
}
|
|
484
|
+
if (negateOffset)
|
|
485
|
+
this.pattern = pattern.slice(negateOffset);
|
|
486
|
+
this.negate = negate;
|
|
487
|
+
}
|
|
488
|
+
// set partial to true to test if, for example,
|
|
489
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
490
|
+
// Partial means, if you run out of file before you run
|
|
491
|
+
// out of pattern, then that's fine, as long as all
|
|
492
|
+
// the parts match.
|
|
493
|
+
matchOne(file, pattern, partial = false) {
|
|
494
|
+
const options = this.options;
|
|
495
|
+
if (this.isWindows) {
|
|
496
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
497
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
498
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
499
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
500
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
501
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
502
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
503
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
504
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
505
|
+
pattern[pdi] = fd;
|
|
506
|
+
if (pdi > fdi) {
|
|
507
|
+
pattern = pattern.slice(pdi);
|
|
508
|
+
} else if (fdi > pdi) {
|
|
509
|
+
file = file.slice(fdi);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
const { optimizationLevel = 1 } = this.options;
|
|
515
|
+
if (optimizationLevel >= 2) {
|
|
516
|
+
file = this.levelTwoFileOptimize(file);
|
|
517
|
+
}
|
|
518
|
+
this.debug("matchOne", this, { file, pattern });
|
|
519
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
520
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
521
|
+
this.debug("matchOne loop");
|
|
522
|
+
var p = pattern[pi];
|
|
523
|
+
var f = file[fi];
|
|
524
|
+
this.debug(pattern, p, f);
|
|
525
|
+
if (p === false) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
if (p === GLOBSTAR) {
|
|
529
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
530
|
+
var fr = fi;
|
|
531
|
+
var pr = pi + 1;
|
|
532
|
+
if (pr === pl) {
|
|
533
|
+
this.debug("** at the end");
|
|
534
|
+
for (; fi < fl; fi++) {
|
|
535
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
while (fr < fl) {
|
|
541
|
+
var swallowee = file[fr];
|
|
542
|
+
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
543
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
544
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
545
|
+
return true;
|
|
546
|
+
} else {
|
|
547
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
548
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
this.debug("globstar swallow a segment, and continue");
|
|
552
|
+
fr++;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (partial) {
|
|
556
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
557
|
+
if (fr === fl) {
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
let hit;
|
|
564
|
+
if (typeof p === "string") {
|
|
565
|
+
hit = f === p;
|
|
566
|
+
this.debug("string match", p, f, hit);
|
|
567
|
+
} else {
|
|
568
|
+
hit = p.test(f);
|
|
569
|
+
this.debug("pattern match", p, f, hit);
|
|
570
|
+
}
|
|
571
|
+
if (!hit)
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
if (fi === fl && pi === pl) {
|
|
575
|
+
return true;
|
|
576
|
+
} else if (fi === fl) {
|
|
577
|
+
return partial;
|
|
578
|
+
} else if (pi === pl) {
|
|
579
|
+
return fi === fl - 1 && file[fi] === "";
|
|
580
|
+
} else {
|
|
581
|
+
throw new Error("wtf?");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
braceExpand() {
|
|
585
|
+
return braceExpand(this.pattern, this.options);
|
|
586
|
+
}
|
|
587
|
+
parse(pattern) {
|
|
588
|
+
assertValidPattern(pattern);
|
|
589
|
+
const options = this.options;
|
|
590
|
+
if (pattern === "**")
|
|
591
|
+
return GLOBSTAR;
|
|
592
|
+
if (pattern === "")
|
|
593
|
+
return "";
|
|
594
|
+
let m;
|
|
595
|
+
let fastTest = null;
|
|
596
|
+
if (m = pattern.match(starRE)) {
|
|
597
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
598
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
599
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
600
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
601
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
602
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
603
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
604
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
605
|
+
fastTest = dotStarTest;
|
|
606
|
+
}
|
|
607
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
608
|
+
if (fastTest && typeof re === "object") {
|
|
609
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
610
|
+
}
|
|
611
|
+
return re;
|
|
612
|
+
}
|
|
613
|
+
makeRe() {
|
|
614
|
+
if (this.regexp || this.regexp === false)
|
|
615
|
+
return this.regexp;
|
|
616
|
+
const set = this.set;
|
|
617
|
+
if (!set.length) {
|
|
618
|
+
this.regexp = false;
|
|
619
|
+
return this.regexp;
|
|
620
|
+
}
|
|
621
|
+
const options = this.options;
|
|
622
|
+
const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
|
623
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
624
|
+
let re = set.map((pattern) => {
|
|
625
|
+
const pp = pattern.map((p) => {
|
|
626
|
+
if (p instanceof RegExp) {
|
|
627
|
+
for (const f of p.flags.split(""))
|
|
628
|
+
flags.add(f);
|
|
629
|
+
}
|
|
630
|
+
return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
631
|
+
});
|
|
632
|
+
pp.forEach((p, i) => {
|
|
633
|
+
const next = pp[i + 1];
|
|
634
|
+
const prev = pp[i - 1];
|
|
635
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (prev === void 0) {
|
|
639
|
+
if (next !== void 0 && next !== GLOBSTAR) {
|
|
640
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
641
|
+
} else {
|
|
642
|
+
pp[i] = twoStar;
|
|
643
|
+
}
|
|
644
|
+
} else if (next === void 0) {
|
|
645
|
+
pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
646
|
+
} else if (next !== GLOBSTAR) {
|
|
647
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
648
|
+
pp[i + 1] = GLOBSTAR;
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
return pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
652
|
+
}).join("|");
|
|
653
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
654
|
+
re = "^" + open + re + close + "$";
|
|
655
|
+
if (this.negate)
|
|
656
|
+
re = "^(?!" + re + ").+$";
|
|
657
|
+
try {
|
|
658
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
659
|
+
} catch (ex) {
|
|
660
|
+
this.regexp = false;
|
|
661
|
+
}
|
|
662
|
+
return this.regexp;
|
|
663
|
+
}
|
|
664
|
+
slashSplit(p) {
|
|
665
|
+
if (this.preserveMultipleSlashes) {
|
|
666
|
+
return p.split("/");
|
|
667
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
668
|
+
return ["", ...p.split(/\/+/)];
|
|
669
|
+
} else {
|
|
670
|
+
return p.split(/\/+/);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
match(f, partial = this.partial) {
|
|
674
|
+
this.debug("match", f, this.pattern);
|
|
675
|
+
if (this.comment) {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
if (this.empty) {
|
|
679
|
+
return f === "";
|
|
680
|
+
}
|
|
681
|
+
if (f === "/" && partial) {
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
const options = this.options;
|
|
685
|
+
if (this.isWindows) {
|
|
686
|
+
f = f.split("\\").join("/");
|
|
687
|
+
}
|
|
688
|
+
const ff = this.slashSplit(f);
|
|
689
|
+
this.debug(this.pattern, "split", ff);
|
|
690
|
+
const set = this.set;
|
|
691
|
+
this.debug(this.pattern, "set", set);
|
|
692
|
+
let filename = ff[ff.length - 1];
|
|
693
|
+
if (!filename) {
|
|
694
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
695
|
+
filename = ff[i];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
for (let i = 0; i < set.length; i++) {
|
|
699
|
+
const pattern = set[i];
|
|
700
|
+
let file = ff;
|
|
701
|
+
if (options.matchBase && pattern.length === 1) {
|
|
702
|
+
file = [filename];
|
|
703
|
+
}
|
|
704
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
705
|
+
if (hit) {
|
|
706
|
+
if (options.flipNegate) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
return !this.negate;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (options.flipNegate) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
return this.negate;
|
|
716
|
+
}
|
|
717
|
+
static defaults(def) {
|
|
718
|
+
return minimatch.defaults(def).Minimatch;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
minimatch.AST = AST;
|
|
722
|
+
minimatch.Minimatch = Minimatch;
|
|
723
|
+
minimatch.escape = escape;
|
|
724
|
+
minimatch.unescape = unescape;
|
|
725
|
+
export {
|
|
726
|
+
AST,
|
|
727
|
+
GLOBSTAR,
|
|
728
|
+
Minimatch,
|
|
729
|
+
braceExpand,
|
|
730
|
+
defaults,
|
|
731
|
+
escape,
|
|
732
|
+
filter,
|
|
733
|
+
makeRe,
|
|
734
|
+
match,
|
|
735
|
+
minimatch,
|
|
736
|
+
sep,
|
|
737
|
+
unescape
|
|
738
|
+
};
|