@rolldown/pluginutils 1.0.0-beta.10-commit.ac4e5db → 1.0.0-beta.10-commit.87188ed

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.cjs CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
 
3
2
  //#region src/utils.ts
4
3
  const postfixRE = /[?#].*$/;
@@ -218,11 +217,7 @@ function escapeRegex(str) {
218
217
  return str.replace(escapeRegexRE, "\\$&");
219
218
  }
220
219
  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
- );
220
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
226
221
  return input.map((i) => makeIdFilterToMatchWithQuery(i));
227
222
  }
228
223
  function makeIdFilterToMatchWithQuery(input) {
@@ -230,11 +225,7 @@ function makeIdFilterToMatchWithQuery(input) {
230
225
  return makeRegexIdFilterToMatchWithQuery(input);
231
226
  }
232
227
  function makeRegexIdFilterToMatchWithQuery(input) {
233
- return new RegExp(
234
- // replace `$` with `(?:\?.*)?$` (ignore `\$`)
235
- input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"),
236
- input.flags
237
- );
228
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
238
229
  }
239
230
 
240
231
  //#endregion
package/dist/index.d.cts CHANGED
@@ -1,5 +1,8 @@
1
1
  //#region src/composable-filters.d.ts
2
2
  type StringOrRegExp = string | RegExp;
3
+ // Inline this type to avoid import it from `rolldown`.
4
+ // The only downside is we need to keep it in sync with `rolldown` manually,
5
+ // it is alright since it is pretty stable now.
3
6
  type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
4
7
  type FilterExpressionKind = FilterExpression["kind"];
5
8
  type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
@@ -63,6 +66,12 @@ declare function not(expr: FilterExpression): Not;
63
66
  declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
64
67
  declare function moduleType(pattern: PluginModuleType): ModuleType;
65
68
  declare function code(pattern: StringOrRegExp): Code;
69
+ /*
70
+ * There are three kinds of conditions are supported:
71
+ * 1. `boolean`: if the value is `true`, the key must exist and be truthy. if the value is `false`, the key must not exist or be falsy.
72
+ * 2. `string`: the key must exist and be equal to the value.
73
+ * 3. `RegExp`: the key must exist and match the value.
74
+ */
66
75
  declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
67
76
  declare function include(expr: FilterExpression): Include;
68
77
  declare function exclude(expr: FilterExpression): Exclude;
@@ -81,7 +90,6 @@ interface InterpreterCtx {
81
90
  }
82
91
  declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
83
92
  declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
84
-
85
93
  //#endregion
86
94
  //#region src/simple-filters.d.ts
87
95
  /**
@@ -111,6 +119,5 @@ type WidenString<T> = T extends string ? string : T;
111
119
  declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
112
120
  declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
113
121
  declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
114
-
115
122
  //#endregion
116
123
  export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  //#region src/composable-filters.d.ts
2
2
  type StringOrRegExp = string | RegExp;
3
+ // Inline this type to avoid import it from `rolldown`.
4
+ // The only downside is we need to keep it in sync with `rolldown` manually,
5
+ // it is alright since it is pretty stable now.
3
6
  type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
4
7
  type FilterExpressionKind = FilterExpression["kind"];
5
8
  type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
@@ -63,6 +66,12 @@ declare function not(expr: FilterExpression): Not;
63
66
  declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
64
67
  declare function moduleType(pattern: PluginModuleType): ModuleType;
65
68
  declare function code(pattern: StringOrRegExp): Code;
69
+ /*
70
+ * There are three kinds of conditions are supported:
71
+ * 1. `boolean`: if the value is `true`, the key must exist and be truthy. if the value is `false`, the key must not exist or be falsy.
72
+ * 2. `string`: the key must exist and be equal to the value.
73
+ * 3. `RegExp`: the key must exist and match the value.
74
+ */
66
75
  declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
67
76
  declare function include(expr: FilterExpression): Include;
68
77
  declare function exclude(expr: FilterExpression): Exclude;
@@ -81,7 +90,6 @@ interface InterpreterCtx {
81
90
  }
82
91
  declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
83
92
  declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
84
-
85
93
  //#endregion
86
94
  //#region src/simple-filters.d.ts
87
95
  /**
@@ -111,6 +119,5 @@ type WidenString<T> = T extends string ? string : T;
111
119
  declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
112
120
  declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
113
121
  declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
114
-
115
122
  //#endregion
116
123
  export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
package/dist/index.js CHANGED
@@ -216,11 +216,7 @@ function escapeRegex(str) {
216
216
  return str.replace(escapeRegexRE, "\\$&");
217
217
  }
218
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
- );
219
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
224
220
  return input.map((i) => makeIdFilterToMatchWithQuery(i));
225
221
  }
226
222
  function makeIdFilterToMatchWithQuery(input) {
@@ -228,11 +224,7 @@ function makeIdFilterToMatchWithQuery(input) {
228
224
  return makeRegexIdFilterToMatchWithQuery(input);
229
225
  }
230
226
  function makeRegexIdFilterToMatchWithQuery(input) {
231
- return new RegExp(
232
- // replace `$` with `(?:\?.*)?$` (ignore `\$`)
233
- input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"),
234
- input.flags
235
- );
227
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
236
228
  }
237
229
 
238
230
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolldown/pluginutils",
3
- "version": "1.0.0-beta.10-commit.ac4e5db",
3
+ "version": "1.0.0-beta.10-commit.87188ed",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@types/picomatch": "^4.0.0",
28
28
  "picomatch": "^4.0.2",
29
- "tsdown": "0.11.11",
29
+ "tsdown": "0.12.4",
30
30
  "vitest": "^3.0.1"
31
31
  },
32
32
  "scripts": {