@rolldown/pluginutils 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.1

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/index.d.ts CHANGED
@@ -1,116 +1 @@
1
- //#region src/composable-filters.d.ts
2
- type StringOrRegExp = string | RegExp;
3
- type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
4
- type FilterExpressionKind = FilterExpression["kind"];
5
- type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
6
- type TopLevelFilterExpression = Include | Exclude;
7
- declare class And {
8
- kind: "and";
9
- args: FilterExpression[];
10
- constructor(...args: FilterExpression[]);
11
- }
12
- declare class Or {
13
- kind: "or";
14
- args: FilterExpression[];
15
- constructor(...args: FilterExpression[]);
16
- }
17
- declare class Not {
18
- kind: "not";
19
- expr: FilterExpression;
20
- constructor(expr: FilterExpression);
21
- }
22
- interface QueryFilterObject {
23
- [key: string]: StringOrRegExp | boolean;
24
- }
25
- interface IdParams {
26
- cleanUrl?: boolean;
27
- }
28
- declare class Id {
29
- kind: "id";
30
- pattern: StringOrRegExp;
31
- params: IdParams;
32
- constructor(pattern: StringOrRegExp, params?: IdParams);
33
- }
34
- declare class ModuleType {
35
- kind: "moduleType";
36
- pattern: PluginModuleType;
37
- constructor(pattern: PluginModuleType);
38
- }
39
- declare class Code {
40
- kind: "code";
41
- pattern: StringOrRegExp;
42
- constructor(expr: StringOrRegExp);
43
- }
44
- declare class Query {
45
- kind: "query";
46
- key: string;
47
- pattern: StringOrRegExp | boolean;
48
- constructor(key: string, pattern: StringOrRegExp | boolean);
49
- }
50
- declare class Include {
51
- kind: "include";
52
- expr: FilterExpression;
53
- constructor(expr: FilterExpression);
54
- }
55
- declare class Exclude {
56
- kind: "exclude";
57
- expr: FilterExpression;
58
- constructor(expr: FilterExpression);
59
- }
60
- declare function and(...args: FilterExpression[]): And;
61
- declare function or(...args: FilterExpression[]): Or;
62
- declare function not(expr: FilterExpression): Not;
63
- declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
64
- declare function moduleType(pattern: PluginModuleType): ModuleType;
65
- declare function code(pattern: StringOrRegExp): Code;
66
- declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
67
- declare function include(expr: FilterExpression): Include;
68
- declare function exclude(expr: FilterExpression): Exclude;
69
- /**
70
- * convert a queryObject to FilterExpression like
71
- * ```js
72
- * and(query(k1, v1), query(k2, v2))
73
- * ```
74
- * @param queryFilterObject The query filter object needs to be matched.
75
- * @returns a `And` FilterExpression
76
- */
77
- declare function queries(queryFilter: QueryFilterObject): And;
78
- declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean;
79
- interface InterpreterCtx {
80
- urlSearchParamsCache?: URLSearchParams;
81
- }
82
- declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
83
- declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
84
-
85
- //#endregion
86
- //#region src/simple-filters.d.ts
87
- /**
88
- * Constructs a RegExp that matches the exact string specified.
89
- *
90
- * This is useful for plugin hook filters.
91
- *
92
- * @param str the string to match.
93
- * @param flags flags for the RegExp.
94
- */
95
- declare function exactRegex(str: string, flags?: string): RegExp;
96
- /**
97
- * Constructs a RegExp that matches a value that has the specified prefix.
98
- *
99
- * This is useful for plugin hook filters.
100
- *
101
- * @param str the string to match.
102
- * @param flags flags for the RegExp.
103
- */
104
- declare function prefixRegex(str: string, flags?: string): RegExp;
105
- type WidenString<T> = T extends string ? string : T;
106
- /**
107
- * Converts a id filter to match with an id with a query.
108
- *
109
- * @param input the id filters to convert.
110
- */
111
- declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
112
- declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
113
- declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
114
-
115
- //#endregion
116
- export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
1
+ export * from './filter/index.ts';
package/dist/index.js CHANGED
@@ -1,239 +1 @@
1
- //#region src/utils.ts
2
- const postfixRE = /[?#].*$/;
3
- function cleanUrl(url) {
4
- return url.replace(postfixRE, "");
5
- }
6
- function extractQueryWithoutFragment(url) {
7
- const questionMarkIndex = url.indexOf("?");
8
- if (questionMarkIndex === -1) return "";
9
- const fragmentIndex = url.indexOf("#", questionMarkIndex);
10
- if (fragmentIndex === -1) return url.substring(questionMarkIndex);
11
- else return url.substring(questionMarkIndex, fragmentIndex);
12
- }
13
-
14
- //#endregion
15
- //#region src/composable-filters.ts
16
- var And = class {
17
- kind;
18
- args;
19
- constructor(...args) {
20
- if (args.length === 0) throw new Error("`And` expects at least one operand");
21
- this.args = args;
22
- this.kind = "and";
23
- }
24
- };
25
- var Or = class {
26
- kind;
27
- args;
28
- constructor(...args) {
29
- if (args.length === 0) throw new Error("`Or` expects at least one operand");
30
- this.args = args;
31
- this.kind = "or";
32
- }
33
- };
34
- var Not = class {
35
- kind;
36
- expr;
37
- constructor(expr) {
38
- this.expr = expr;
39
- this.kind = "not";
40
- }
41
- };
42
- var Id = class {
43
- kind;
44
- pattern;
45
- params;
46
- constructor(pattern, params) {
47
- this.pattern = pattern;
48
- this.kind = "id";
49
- this.params = params ?? { cleanUrl: false };
50
- }
51
- };
52
- var ModuleType = class {
53
- kind;
54
- pattern;
55
- constructor(pattern) {
56
- this.pattern = pattern;
57
- this.kind = "moduleType";
58
- }
59
- };
60
- var Code = class {
61
- kind;
62
- pattern;
63
- constructor(expr) {
64
- this.pattern = expr;
65
- this.kind = "code";
66
- }
67
- };
68
- var Query = class {
69
- kind;
70
- key;
71
- pattern;
72
- constructor(key, pattern) {
73
- this.pattern = pattern;
74
- this.key = key;
75
- this.kind = "query";
76
- }
77
- };
78
- var Include = class {
79
- kind;
80
- expr;
81
- constructor(expr) {
82
- this.expr = expr;
83
- this.kind = "include";
84
- }
85
- };
86
- var Exclude = class {
87
- kind;
88
- expr;
89
- constructor(expr) {
90
- this.expr = expr;
91
- this.kind = "exclude";
92
- }
93
- };
94
- function and(...args) {
95
- return new And(...args);
96
- }
97
- function or(...args) {
98
- return new Or(...args);
99
- }
100
- function not(expr) {
101
- return new Not(expr);
102
- }
103
- function id(pattern, params) {
104
- return new Id(pattern, params);
105
- }
106
- function moduleType(pattern) {
107
- return new ModuleType(pattern);
108
- }
109
- function code(pattern) {
110
- return new Code(pattern);
111
- }
112
- function query(key, pattern) {
113
- return new Query(key, pattern);
114
- }
115
- function include(expr) {
116
- return new Include(expr);
117
- }
118
- function exclude(expr) {
119
- return new Exclude(expr);
120
- }
121
- /**
122
- * convert a queryObject to FilterExpression like
123
- * ```js
124
- * and(query(k1, v1), query(k2, v2))
125
- * ```
126
- * @param queryFilterObject The query filter object needs to be matched.
127
- * @returns a `And` FilterExpression
128
- */
129
- function queries(queryFilter) {
130
- let arr = Object.entries(queryFilter).map(([key, value]) => {
131
- return new Query(key, value);
132
- });
133
- return and(...arr);
134
- }
135
- function interpreter(exprs, code$1, id$1, moduleType$1) {
136
- let arr = [];
137
- if (Array.isArray(exprs)) arr = exprs;
138
- else arr = [exprs];
139
- return interpreterImpl(arr, code$1, id$1, moduleType$1);
140
- }
141
- function interpreterImpl(expr, code$1, id$1, moduleType$1, ctx = {}) {
142
- let hasInclude = false;
143
- for (const e of expr) switch (e.kind) {
144
- case "include": {
145
- hasInclude = true;
146
- if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, ctx)) return true;
147
- break;
148
- }
149
- case "exclude": {
150
- if (exprInterpreter(e.expr, code$1, id$1, moduleType$1)) return false;
151
- break;
152
- }
153
- }
154
- return !hasInclude;
155
- }
156
- function exprInterpreter(expr, code$1, id$1, moduleType$1, ctx = {}) {
157
- switch (expr.kind) {
158
- case "and": return expr.args.every((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
159
- case "or": return expr.args.some((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
160
- case "not": return !exprInterpreter(expr.expr, code$1, id$1, moduleType$1, ctx);
161
- case "id": {
162
- if (id$1 === void 0) throw new Error("`id` is required for `id` expression");
163
- if (expr.params.cleanUrl) id$1 = cleanUrl(id$1);
164
- return typeof expr.pattern === "string" ? id$1 === expr.pattern : expr.pattern.test(id$1);
165
- }
166
- case "moduleType": {
167
- if (moduleType$1 === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
168
- return moduleType$1 === expr.pattern;
169
- }
170
- case "code": {
171
- if (code$1 === void 0) throw new Error("`code` is required for `code` expression");
172
- return typeof expr.pattern === "string" ? code$1.includes(expr.pattern) : expr.pattern.test(code$1);
173
- }
174
- case "query": {
175
- if (id$1 === void 0) throw new Error("`id` is required for `Query` expression");
176
- if (!ctx.urlSearchParamsCache) {
177
- let queryString = extractQueryWithoutFragment(id$1);
178
- ctx.urlSearchParamsCache = new URLSearchParams(queryString);
179
- }
180
- let urlParams = ctx.urlSearchParamsCache;
181
- if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
182
- else return !urlParams.has(expr.key);
183
- else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
184
- else return expr.pattern.test(urlParams.get(expr.key) ?? "");
185
- }
186
- default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
187
- }
188
- }
189
-
190
- //#endregion
191
- //#region src/simple-filters.ts
192
- /**
193
- * Constructs a RegExp that matches the exact string specified.
194
- *
195
- * This is useful for plugin hook filters.
196
- *
197
- * @param str the string to match.
198
- * @param flags flags for the RegExp.
199
- */
200
- function exactRegex(str, flags) {
201
- return new RegExp(`^${escapeRegex(str)}$`, flags);
202
- }
203
- /**
204
- * Constructs a RegExp that matches a value that has the specified prefix.
205
- *
206
- * This is useful for plugin hook filters.
207
- *
208
- * @param str the string to match.
209
- * @param flags flags for the RegExp.
210
- */
211
- function prefixRegex(str, flags) {
212
- return new RegExp(`^${escapeRegex(str)}`, flags);
213
- }
214
- const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
215
- function escapeRegex(str) {
216
- return str.replace(escapeRegexRE, "\\$&");
217
- }
218
- function makeIdFiltersToMatchWithQuery(input) {
219
- if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(
220
- // Array.isArray cannot narrow the type
221
- // https://github.com/microsoft/TypeScript/issues/17002
222
- input
223
- );
224
- return input.map((i) => makeIdFilterToMatchWithQuery(i));
225
- }
226
- function makeIdFilterToMatchWithQuery(input) {
227
- if (typeof input === "string") return `${input}{?*,}`;
228
- return makeRegexIdFilterToMatchWithQuery(input);
229
- }
230
- function makeRegexIdFilterToMatchWithQuery(input) {
231
- return new RegExp(
232
- // replace `$` with `(?:\?.*)?$` (ignore `\$`)
233
- input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"),
234
- input.flags
235
- );
236
- }
237
-
238
- //#endregion
239
- export { and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
1
+ export * from "./filter/index.js";
@@ -0,0 +1,2 @@
1
+ export declare function cleanUrl(url: string): string;
2
+ export declare function extractQueryWithoutFragment(url: string): string;
package/dist/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ const postfixRE = /[?#].*$/;
2
+ export function cleanUrl(url) {
3
+ return url.replace(postfixRE, '');
4
+ }
5
+ export function extractQueryWithoutFragment(url) {
6
+ const questionMarkIndex = url.indexOf('?');
7
+ if (questionMarkIndex === -1) {
8
+ return '';
9
+ }
10
+ const fragmentIndex = url.indexOf('#', questionMarkIndex); // Search for # after ?
11
+ if (fragmentIndex === -1) {
12
+ return url.substring(questionMarkIndex);
13
+ }
14
+ else {
15
+ return url.substring(questionMarkIndex, fragmentIndex);
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,36 +1,37 @@
1
1
  {
2
2
  "name": "@rolldown/pluginutils",
3
- "version": "1.0.0-beta.9-commit.0ec9e7d",
3
+ "version": "1.0.0-rc.1",
4
+ "homepage": "https://rolldown.rs/",
4
5
  "license": "MIT",
5
- "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/rolldown/rolldown.git",
9
9
  "directory": "packages/pluginutils"
10
10
  },
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "main": "./dist/index.cjs",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "main": "./dist/index.js",
15
16
  "module": "./dist/index.js",
16
17
  "types": "./dist/index.d.ts",
17
18
  "exports": {
18
- ".": {
19
- "import": "./dist/index.js",
20
- "require": "./dist/index.cjs"
21
- }
19
+ ".": "./dist/index.js",
20
+ "./filter": "./dist/filter/index.js",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
22
25
  },
23
- "files": [
24
- "dist"
25
- ],
26
26
  "devDependencies": {
27
27
  "@types/picomatch": "^4.0.0",
28
28
  "picomatch": "^4.0.2",
29
- "tsdown": "0.11.11",
30
- "vitest": "^3.0.1"
29
+ "typescript": "^5.8.3",
30
+ "vitest": "^4.0.15"
31
31
  },
32
32
  "scripts": {
33
- "build": "tsdown",
34
- "test": "vitest --typecheck"
33
+ "build": "tsc",
34
+ "test": "vitest --typecheck",
35
+ "publint": "publint ."
35
36
  }
36
37
  }
package/dist/index.cjs DELETED
@@ -1,256 +0,0 @@
1
- "use strict";
2
-
3
- //#region src/utils.ts
4
- const postfixRE = /[?#].*$/;
5
- function cleanUrl(url) {
6
- return url.replace(postfixRE, "");
7
- }
8
- function extractQueryWithoutFragment(url) {
9
- const questionMarkIndex = url.indexOf("?");
10
- if (questionMarkIndex === -1) return "";
11
- const fragmentIndex = url.indexOf("#", questionMarkIndex);
12
- if (fragmentIndex === -1) return url.substring(questionMarkIndex);
13
- else return url.substring(questionMarkIndex, fragmentIndex);
14
- }
15
-
16
- //#endregion
17
- //#region src/composable-filters.ts
18
- var And = class {
19
- kind;
20
- args;
21
- constructor(...args) {
22
- if (args.length === 0) throw new Error("`And` expects at least one operand");
23
- this.args = args;
24
- this.kind = "and";
25
- }
26
- };
27
- var Or = class {
28
- kind;
29
- args;
30
- constructor(...args) {
31
- if (args.length === 0) throw new Error("`Or` expects at least one operand");
32
- this.args = args;
33
- this.kind = "or";
34
- }
35
- };
36
- var Not = class {
37
- kind;
38
- expr;
39
- constructor(expr) {
40
- this.expr = expr;
41
- this.kind = "not";
42
- }
43
- };
44
- var Id = class {
45
- kind;
46
- pattern;
47
- params;
48
- constructor(pattern, params) {
49
- this.pattern = pattern;
50
- this.kind = "id";
51
- this.params = params ?? { cleanUrl: false };
52
- }
53
- };
54
- var ModuleType = class {
55
- kind;
56
- pattern;
57
- constructor(pattern) {
58
- this.pattern = pattern;
59
- this.kind = "moduleType";
60
- }
61
- };
62
- var Code = class {
63
- kind;
64
- pattern;
65
- constructor(expr) {
66
- this.pattern = expr;
67
- this.kind = "code";
68
- }
69
- };
70
- var Query = class {
71
- kind;
72
- key;
73
- pattern;
74
- constructor(key, pattern) {
75
- this.pattern = pattern;
76
- this.key = key;
77
- this.kind = "query";
78
- }
79
- };
80
- var Include = class {
81
- kind;
82
- expr;
83
- constructor(expr) {
84
- this.expr = expr;
85
- this.kind = "include";
86
- }
87
- };
88
- var Exclude = class {
89
- kind;
90
- expr;
91
- constructor(expr) {
92
- this.expr = expr;
93
- this.kind = "exclude";
94
- }
95
- };
96
- function and(...args) {
97
- return new And(...args);
98
- }
99
- function or(...args) {
100
- return new Or(...args);
101
- }
102
- function not(expr) {
103
- return new Not(expr);
104
- }
105
- function id(pattern, params) {
106
- return new Id(pattern, params);
107
- }
108
- function moduleType(pattern) {
109
- return new ModuleType(pattern);
110
- }
111
- function code(pattern) {
112
- return new Code(pattern);
113
- }
114
- function query(key, pattern) {
115
- return new Query(key, pattern);
116
- }
117
- function include(expr) {
118
- return new Include(expr);
119
- }
120
- function exclude(expr) {
121
- return new Exclude(expr);
122
- }
123
- /**
124
- * convert a queryObject to FilterExpression like
125
- * ```js
126
- * and(query(k1, v1), query(k2, v2))
127
- * ```
128
- * @param queryFilterObject The query filter object needs to be matched.
129
- * @returns a `And` FilterExpression
130
- */
131
- function queries(queryFilter) {
132
- let arr = Object.entries(queryFilter).map(([key, value]) => {
133
- return new Query(key, value);
134
- });
135
- return and(...arr);
136
- }
137
- function interpreter(exprs, code$1, id$1, moduleType$1) {
138
- let arr = [];
139
- if (Array.isArray(exprs)) arr = exprs;
140
- else arr = [exprs];
141
- return interpreterImpl(arr, code$1, id$1, moduleType$1);
142
- }
143
- function interpreterImpl(expr, code$1, id$1, moduleType$1, ctx = {}) {
144
- let hasInclude = false;
145
- for (const e of expr) switch (e.kind) {
146
- case "include": {
147
- hasInclude = true;
148
- if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, ctx)) return true;
149
- break;
150
- }
151
- case "exclude": {
152
- if (exprInterpreter(e.expr, code$1, id$1, moduleType$1)) return false;
153
- break;
154
- }
155
- }
156
- return !hasInclude;
157
- }
158
- function exprInterpreter(expr, code$1, id$1, moduleType$1, ctx = {}) {
159
- switch (expr.kind) {
160
- case "and": return expr.args.every((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
161
- case "or": return expr.args.some((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
162
- case "not": return !exprInterpreter(expr.expr, code$1, id$1, moduleType$1, ctx);
163
- case "id": {
164
- if (id$1 === void 0) throw new Error("`id` is required for `id` expression");
165
- if (expr.params.cleanUrl) id$1 = cleanUrl(id$1);
166
- return typeof expr.pattern === "string" ? id$1 === expr.pattern : expr.pattern.test(id$1);
167
- }
168
- case "moduleType": {
169
- if (moduleType$1 === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
170
- return moduleType$1 === expr.pattern;
171
- }
172
- case "code": {
173
- if (code$1 === void 0) throw new Error("`code` is required for `code` expression");
174
- return typeof expr.pattern === "string" ? code$1.includes(expr.pattern) : expr.pattern.test(code$1);
175
- }
176
- case "query": {
177
- if (id$1 === void 0) throw new Error("`id` is required for `Query` expression");
178
- if (!ctx.urlSearchParamsCache) {
179
- let queryString = extractQueryWithoutFragment(id$1);
180
- ctx.urlSearchParamsCache = new URLSearchParams(queryString);
181
- }
182
- let urlParams = ctx.urlSearchParamsCache;
183
- if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
184
- else return !urlParams.has(expr.key);
185
- else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
186
- else return expr.pattern.test(urlParams.get(expr.key) ?? "");
187
- }
188
- default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
189
- }
190
- }
191
-
192
- //#endregion
193
- //#region src/simple-filters.ts
194
- /**
195
- * Constructs a RegExp that matches the exact string specified.
196
- *
197
- * This is useful for plugin hook filters.
198
- *
199
- * @param str the string to match.
200
- * @param flags flags for the RegExp.
201
- */
202
- function exactRegex(str, flags) {
203
- return new RegExp(`^${escapeRegex(str)}$`, flags);
204
- }
205
- /**
206
- * Constructs a RegExp that matches a value that has the specified prefix.
207
- *
208
- * This is useful for plugin hook filters.
209
- *
210
- * @param str the string to match.
211
- * @param flags flags for the RegExp.
212
- */
213
- function prefixRegex(str, flags) {
214
- return new RegExp(`^${escapeRegex(str)}`, flags);
215
- }
216
- const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
217
- function escapeRegex(str) {
218
- return str.replace(escapeRegexRE, "\\$&");
219
- }
220
- function makeIdFiltersToMatchWithQuery(input) {
221
- if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(
222
- // Array.isArray cannot narrow the type
223
- // https://github.com/microsoft/TypeScript/issues/17002
224
- input
225
- );
226
- return input.map((i) => makeIdFilterToMatchWithQuery(i));
227
- }
228
- function makeIdFilterToMatchWithQuery(input) {
229
- if (typeof input === "string") return `${input}{?*,}`;
230
- return makeRegexIdFilterToMatchWithQuery(input);
231
- }
232
- function makeRegexIdFilterToMatchWithQuery(input) {
233
- return new RegExp(
234
- // replace `$` with `(?:\?.*)?$` (ignore `\$`)
235
- input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"),
236
- input.flags
237
- );
238
- }
239
-
240
- //#endregion
241
- exports.and = and;
242
- exports.code = code;
243
- exports.exactRegex = exactRegex;
244
- exports.exclude = exclude;
245
- exports.exprInterpreter = exprInterpreter;
246
- exports.id = id;
247
- exports.include = include;
248
- exports.interpreter = interpreter;
249
- exports.interpreterImpl = interpreterImpl;
250
- exports.makeIdFiltersToMatchWithQuery = makeIdFiltersToMatchWithQuery;
251
- exports.moduleType = moduleType;
252
- exports.not = not;
253
- exports.or = or;
254
- exports.prefixRegex = prefixRegex;
255
- exports.queries = queries;
256
- exports.query = query;