@rolldown/pluginutils
Advanced tools
+12
-10
@@ -8,2 +8,9 @@ "use strict"; | ||
| } | ||
| function extractQueryWithoutFragment(url) { | ||
| const questionMarkIndex = url.indexOf("?"); | ||
| if (questionMarkIndex === -1) return ""; | ||
| const fragmentIndex = url.indexOf("#", questionMarkIndex); | ||
| if (fragmentIndex === -1) return url.substring(questionMarkIndex); | ||
| else return url.substring(questionMarkIndex, fragmentIndex); | ||
| } | ||
@@ -124,9 +131,4 @@ //#endregion | ||
| * @returns a `And` FilterExpression | ||
| * | ||
| * There are three kinds of conditions are supported: | ||
| * 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. | ||
| * 2. `string`: the key must exist and be equal to the value. | ||
| * 3. `RegExp`: the key must exist and match the value. | ||
| */ | ||
| function queryObjectToFilterExpr(queryFilter) { | ||
| function queries(queryFilter) { | ||
| let arr = Object.entries(queryFilter).map(([key, value]) => { | ||
@@ -179,3 +181,3 @@ return new Query(key, value); | ||
| if (!ctx.urlSearchParamsCache) { | ||
| let [_, queryString = ""] = id$1.split("?", 2); | ||
| let queryString = extractQueryWithoutFragment(id$1); | ||
| ctx.urlSearchParamsCache = new URLSearchParams(queryString); | ||
@@ -189,3 +191,3 @@ } | ||
| } | ||
| default: throw new Error(`Expression kind ${expr} is not expected.`); | ||
| default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`); | ||
| } | ||
@@ -257,3 +259,3 @@ } | ||
| exports.prefixRegex = prefixRegex | ||
| exports.query = query | ||
| exports.queryObjectToFilterExpr = queryObjectToFilterExpr | ||
| exports.queries = queries | ||
| exports.query = query |
+2
-7
@@ -76,9 +76,4 @@ //#region src/composable-filters.d.ts | ||
| * @returns a `And` FilterExpression | ||
| * | ||
| * There are three kinds of conditions are supported: | ||
| * 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. | ||
| * 2. `string`: the key must exist and be equal to the value. | ||
| * 3. `RegExp`: the key must exist and match the value. | ||
| */ | ||
| declare function queryObjectToFilterExpr(queryFilter: QueryFilterObject): And; | ||
| declare function queries(queryFilter: QueryFilterObject): And; | ||
| declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean; | ||
@@ -122,2 +117,2 @@ interface InterpreterCtx { | ||
| //#endregion | ||
| export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, query, queryObjectToFilterExpr }; | ||
| export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query }; |
+2
-7
@@ -76,9 +76,4 @@ //#region src/composable-filters.d.ts | ||
| * @returns a `And` FilterExpression | ||
| * | ||
| * There are three kinds of conditions are supported: | ||
| * 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. | ||
| * 2. `string`: the key must exist and be equal to the value. | ||
| * 3. `RegExp`: the key must exist and match the value. | ||
| */ | ||
| declare function queryObjectToFilterExpr(queryFilter: QueryFilterObject): And; | ||
| declare function queries(queryFilter: QueryFilterObject): And; | ||
| declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean; | ||
@@ -122,2 +117,2 @@ interface InterpreterCtx { | ||
| //#endregion | ||
| export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, query, queryObjectToFilterExpr }; | ||
| export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query }; |
+11
-9
@@ -6,2 +6,9 @@ //#region src/utils.ts | ||
| } | ||
| function extractQueryWithoutFragment(url) { | ||
| const questionMarkIndex = url.indexOf("?"); | ||
| if (questionMarkIndex === -1) return ""; | ||
| const fragmentIndex = url.indexOf("#", questionMarkIndex); | ||
| if (fragmentIndex === -1) return url.substring(questionMarkIndex); | ||
| else return url.substring(questionMarkIndex, fragmentIndex); | ||
| } | ||
@@ -122,9 +129,4 @@ //#endregion | ||
| * @returns a `And` FilterExpression | ||
| * | ||
| * There are three kinds of conditions are supported: | ||
| * 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. | ||
| * 2. `string`: the key must exist and be equal to the value. | ||
| * 3. `RegExp`: the key must exist and match the value. | ||
| */ | ||
| function queryObjectToFilterExpr(queryFilter) { | ||
| function queries(queryFilter) { | ||
| let arr = Object.entries(queryFilter).map(([key, value]) => { | ||
@@ -177,3 +179,3 @@ return new Query(key, value); | ||
| if (!ctx.urlSearchParamsCache) { | ||
| let [_, queryString = ""] = id$1.split("?", 2); | ||
| let queryString = extractQueryWithoutFragment(id$1); | ||
| ctx.urlSearchParamsCache = new URLSearchParams(queryString); | ||
@@ -187,3 +189,3 @@ } | ||
| } | ||
| default: throw new Error(`Expression kind ${expr} is not expected.`); | ||
| default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`); | ||
| } | ||
@@ -241,2 +243,2 @@ } | ||
| //#endregion | ||
| export { and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, query, queryObjectToFilterExpr }; | ||
| export { and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query }; |
+1
-1
| { | ||
| "name": "@rolldown/pluginutils", | ||
| "version": "1.0.0-beta.8-commit.985af6d", | ||
| "version": "1.0.0-beta.8-commit.bf53a10", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
23858
-2.81%599
-0.17%