@powerlines/core 0.47.1 → 0.47.2
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/plugin-utils/index.cjs +1 -0
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.mts +2 -2
- package/dist/plugin-utils/index.mjs +2 -2
- package/dist/plugin-utils/virtual.cjs +33 -4
- package/dist/plugin-utils/virtual.d.cts +36 -1
- package/dist/plugin-utils/virtual.d.cts.map +1 -1
- package/dist/plugin-utils/virtual.d.mts +36 -1
- package/dist/plugin-utils/virtual.d.mts.map +1 -1
- package/dist/plugin-utils/virtual.mjs +32 -4
- package/dist/plugin-utils/virtual.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -71,6 +71,7 @@ exports.normalizeFilter = require_plugin_utils_filter.normalizeFilter;
|
|
|
71
71
|
exports.normalizeSingleFilter = require_plugin_utils_filter.normalizeSingleFilter;
|
|
72
72
|
exports.patternToCodeFilter = require_plugin_utils_filter.patternToCodeFilter;
|
|
73
73
|
exports.patternToIdFilter = require_plugin_utils_filter.patternToIdFilter;
|
|
74
|
+
exports.prefixRegex = require_plugin_utils_virtual.prefixRegex;
|
|
74
75
|
exports.removeVirtualPrefix = require_plugin_utils_virtual.removeVirtualPrefix;
|
|
75
76
|
exports.replacePathTokens = require_plugin_utils_paths.replacePathTokens;
|
|
76
77
|
exports.resolveLogLevel = require_plugin_utils_logging.resolveLogLevel;
|
|
@@ -12,5 +12,5 @@ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, cre
|
|
|
12
12
|
import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.cjs";
|
|
13
13
|
import { isBuiltinModule } from "./modules.cjs";
|
|
14
14
|
import { replacePathTokens } from "./paths.cjs";
|
|
15
|
-
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix } from "./virtual.cjs";
|
|
16
|
-
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
15
|
+
import { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩPrefixRegexOptions, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix } from "./virtual.cjs";
|
|
16
|
+
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, __ΩPrefixRegexOptions, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -12,5 +12,5 @@ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, cre
|
|
|
12
12
|
import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.mjs";
|
|
13
13
|
import { isBuiltinModule } from "./modules.mjs";
|
|
14
14
|
import { replacePathTokens } from "./paths.mjs";
|
|
15
|
-
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix } from "./virtual.mjs";
|
|
16
|
-
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
15
|
+
import { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩPrefixRegexOptions, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix } from "./virtual.mjs";
|
|
16
|
+
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, __ΩPrefixRegexOptions, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -6,7 +6,7 @@ import { combinePluginOptions, combinePlugins } from "./combine-plugins.mjs";
|
|
|
6
6
|
import { getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.mjs";
|
|
7
7
|
import { getDocsOutputPath } from "./docs-helper.mjs";
|
|
8
8
|
import { extend } from "./extend.mjs";
|
|
9
|
-
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix } from "./virtual.mjs";
|
|
9
|
+
import { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix } from "./virtual.mjs";
|
|
10
10
|
import { createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter } from "./filter.mjs";
|
|
11
11
|
import { formatConfig } from "./format.mjs";
|
|
12
12
|
import { formatPackageJson } from "./format-package-json.mjs";
|
|
@@ -14,4 +14,4 @@ import { getConfigPath } from "./get-config-path.mjs";
|
|
|
14
14
|
import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogFn, withLogger } from "./logging.mjs";
|
|
15
15
|
import { isBuiltinModule } from "./modules.mjs";
|
|
16
16
|
|
|
17
|
-
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
17
|
+
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _rolldown_pluginutils = require("@rolldown/pluginutils");
|
|
4
2
|
|
|
5
3
|
//#region src/plugin-utils/virtual.ts
|
|
4
|
+
const ESCAPE_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
|
|
5
|
+
function escapeRegex(str) {
|
|
6
|
+
return str.replace(ESCAPE_REGEX, "\\$&");
|
|
7
|
+
}
|
|
6
8
|
const VIRTUAL_MODULE_PREFIX = "\0";
|
|
7
|
-
const VIRTUAL_MODULE_PREFIX_REGEX =
|
|
9
|
+
const VIRTUAL_MODULE_PREFIX_REGEX = prefixRegex("\0");
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
16
|
+
* const plugin = {
|
|
17
|
+
* name: 'plugin',
|
|
18
|
+
* resolveId: {
|
|
19
|
+
* filter: { id: prefixRegex('foo') },
|
|
20
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param str - the string to match.
|
|
26
|
+
* @param options - options for the RegExp.
|
|
27
|
+
* @return a RegExp that matches the specified string with the specified prefix.
|
|
28
|
+
*/
|
|
29
|
+
function prefixRegex(str, options = {}) {
|
|
30
|
+
const { flags, prefix, isPrefixOptional = false } = options;
|
|
31
|
+
return new RegExp(`^${prefix ? isPrefixOptional ? `(${escapeRegex(prefix)})?` : `${escapeRegex(prefix)}` : ""}${escapeRegex(str)}`, flags);
|
|
32
|
+
}
|
|
8
33
|
/**
|
|
9
34
|
* Adds the virtual module prefix to the given ID.
|
|
10
35
|
*
|
|
@@ -39,7 +64,10 @@ function isVirtualModule(id) {
|
|
|
39
64
|
* @returns A regular expression that matches the given ID with the virtual module prefix.
|
|
40
65
|
*/
|
|
41
66
|
function createVirtualPrefixRegex(id) {
|
|
42
|
-
return
|
|
67
|
+
return prefixRegex(removeVirtualPrefix(id), {
|
|
68
|
+
prefix: "\0",
|
|
69
|
+
isPrefixOptional: true
|
|
70
|
+
});
|
|
43
71
|
}
|
|
44
72
|
|
|
45
73
|
//#endregion
|
|
@@ -48,4 +76,5 @@ exports.VIRTUAL_MODULE_PREFIX_REGEX = VIRTUAL_MODULE_PREFIX_REGEX;
|
|
|
48
76
|
exports.addVirtualPrefix = addVirtualPrefix;
|
|
49
77
|
exports.createVirtualPrefixRegex = createVirtualPrefixRegex;
|
|
50
78
|
exports.isVirtualModule = isVirtualModule;
|
|
79
|
+
exports.prefixRegex = prefixRegex;
|
|
51
80
|
exports.removeVirtualPrefix = removeVirtualPrefix;
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
//#region src/plugin-utils/virtual.d.ts
|
|
2
2
|
declare const VIRTUAL_MODULE_PREFIX = "\0";
|
|
3
3
|
declare const VIRTUAL_MODULE_PREFIX_REGEX: RegExp;
|
|
4
|
+
interface PrefixRegexOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Flags for the RegExp.
|
|
7
|
+
*/
|
|
8
|
+
flags?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The prefix to match. This will be escaped and used as the prefix in the generated RegExp.
|
|
11
|
+
*/
|
|
12
|
+
prefix?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the prefix is optional. If true, the generated RegExp will match both strings that start with the prefix and strings that do not start with the prefix. Default is false.
|
|
15
|
+
*/
|
|
16
|
+
isPrefixOptional?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
24
|
+
* const plugin = {
|
|
25
|
+
* name: 'plugin',
|
|
26
|
+
* resolveId: {
|
|
27
|
+
* filter: { id: prefixRegex('foo') },
|
|
28
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param str - the string to match.
|
|
34
|
+
* @param options - options for the RegExp.
|
|
35
|
+
* @return a RegExp that matches the specified string with the specified prefix.
|
|
36
|
+
*/
|
|
37
|
+
declare function prefixRegex(str: string, options?: PrefixRegexOptions): RegExp;
|
|
4
38
|
/**
|
|
5
39
|
* Adds the virtual module prefix to the given ID.
|
|
6
40
|
*
|
|
@@ -29,6 +63,7 @@ declare function isVirtualModule(id: string): boolean;
|
|
|
29
63
|
* @returns A regular expression that matches the given ID with the virtual module prefix.
|
|
30
64
|
*/
|
|
31
65
|
declare function createVirtualPrefixRegex(id: string): RegExp;
|
|
66
|
+
declare type __ΩPrefixRegexOptions = any[];
|
|
32
67
|
//#endregion
|
|
33
|
-
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix };
|
|
68
|
+
export { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩPrefixRegexOptions, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix };
|
|
34
69
|
//# sourceMappingURL=virtual.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.cts","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"virtual.d.cts","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"mappings":";cAuBa,qBAAA;AAAA,cACA,2BAAA,EAA2B,MAAA;AAAA,UAEvB,kBAAA;;;;EAIf,KAAA;EAN0D;;;EAW1D,MAAA;EATe;;;EAcf,gBAAA;AAAA;;;;;AAsBF;;;;;;;;;;AAwBA;;;;;iBAxBgB,WAAA,CACd,GAAA,UACA,OAAA,GAAS,kBAAA,GACR,MAAA;;;;;AAyCH;;iBApBgB,gBAAA,CAAiB,EAAA;;;AA8BjC;;;;iBApBgB,mBAAA,CAAoB,EAAA;;;;;;;iBAUpB,eAAA,CAAgB,EAAA;;;;;;;iBAUhB,wBAAA,CAAyB,EAAA,WAAa,MAAA;AAAA"}
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
//#region src/plugin-utils/virtual.d.ts
|
|
2
2
|
declare const VIRTUAL_MODULE_PREFIX = "\0";
|
|
3
3
|
declare const VIRTUAL_MODULE_PREFIX_REGEX: RegExp;
|
|
4
|
+
interface PrefixRegexOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Flags for the RegExp.
|
|
7
|
+
*/
|
|
8
|
+
flags?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The prefix to match. This will be escaped and used as the prefix in the generated RegExp.
|
|
11
|
+
*/
|
|
12
|
+
prefix?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the prefix is optional. If true, the generated RegExp will match both strings that start with the prefix and strings that do not start with the prefix. Default is false.
|
|
15
|
+
*/
|
|
16
|
+
isPrefixOptional?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
24
|
+
* const plugin = {
|
|
25
|
+
* name: 'plugin',
|
|
26
|
+
* resolveId: {
|
|
27
|
+
* filter: { id: prefixRegex('foo') },
|
|
28
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param str - the string to match.
|
|
34
|
+
* @param options - options for the RegExp.
|
|
35
|
+
* @return a RegExp that matches the specified string with the specified prefix.
|
|
36
|
+
*/
|
|
37
|
+
declare function prefixRegex(str: string, options?: PrefixRegexOptions): RegExp;
|
|
4
38
|
/**
|
|
5
39
|
* Adds the virtual module prefix to the given ID.
|
|
6
40
|
*
|
|
@@ -29,6 +63,7 @@ declare function isVirtualModule(id: string): boolean;
|
|
|
29
63
|
* @returns A regular expression that matches the given ID with the virtual module prefix.
|
|
30
64
|
*/
|
|
31
65
|
declare function createVirtualPrefixRegex(id: string): RegExp;
|
|
66
|
+
declare type __ΩPrefixRegexOptions = any[];
|
|
32
67
|
//#endregion
|
|
33
|
-
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix };
|
|
68
|
+
export { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, __ΩPrefixRegexOptions, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix };
|
|
34
69
|
//# sourceMappingURL=virtual.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.mts","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"virtual.d.mts","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"mappings":";cAuBa,qBAAA;AAAA,cACA,2BAAA,EAA2B,MAAA;AAAA,UAEvB,kBAAA;;;;EAIf,KAAA;EAN0D;;;EAW1D,MAAA;EATe;;;EAcf,gBAAA;AAAA;;;;;AAsBF;;;;;;;;;;AAwBA;;;;;iBAxBgB,WAAA,CACd,GAAA,UACA,OAAA,GAAS,kBAAA,GACR,MAAA;;;;;AAyCH;;iBApBgB,gBAAA,CAAiB,EAAA;;;AA8BjC;;;;iBApBgB,mBAAA,CAAoB,EAAA;;;;;;;iBAUpB,eAAA,CAAgB,EAAA;;;;;;;iBAUhB,wBAAA,CAAyB,EAAA,WAAa,MAAA;AAAA"}
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import { prefixRegex } from "@rolldown/pluginutils";
|
|
2
|
-
|
|
3
1
|
//#region src/plugin-utils/virtual.ts
|
|
2
|
+
const ESCAPE_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
|
|
3
|
+
function escapeRegex(str) {
|
|
4
|
+
return str.replace(ESCAPE_REGEX, "\\$&");
|
|
5
|
+
}
|
|
4
6
|
const VIRTUAL_MODULE_PREFIX = "\0";
|
|
5
7
|
const VIRTUAL_MODULE_PREFIX_REGEX = prefixRegex("\0");
|
|
6
8
|
/**
|
|
9
|
+
* Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
14
|
+
* const plugin = {
|
|
15
|
+
* name: 'plugin',
|
|
16
|
+
* resolveId: {
|
|
17
|
+
* filter: { id: prefixRegex('foo') },
|
|
18
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param str - the string to match.
|
|
24
|
+
* @param options - options for the RegExp.
|
|
25
|
+
* @return a RegExp that matches the specified string with the specified prefix.
|
|
26
|
+
*/
|
|
27
|
+
function prefixRegex(str, options = {}) {
|
|
28
|
+
const { flags, prefix, isPrefixOptional = false } = options;
|
|
29
|
+
return new RegExp(`^${prefix ? isPrefixOptional ? `(${escapeRegex(prefix)})?` : `${escapeRegex(prefix)}` : ""}${escapeRegex(str)}`, flags);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
7
32
|
* Adds the virtual module prefix to the given ID.
|
|
8
33
|
*
|
|
9
34
|
* @param id - The ID to add the virtual module prefix to.
|
|
@@ -37,9 +62,12 @@ function isVirtualModule(id) {
|
|
|
37
62
|
* @returns A regular expression that matches the given ID with the virtual module prefix.
|
|
38
63
|
*/
|
|
39
64
|
function createVirtualPrefixRegex(id) {
|
|
40
|
-
return prefixRegex(
|
|
65
|
+
return prefixRegex(removeVirtualPrefix(id), {
|
|
66
|
+
prefix: "\0",
|
|
67
|
+
isPrefixOptional: true
|
|
68
|
+
});
|
|
41
69
|
}
|
|
42
70
|
|
|
43
71
|
//#endregion
|
|
44
|
-
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, removeVirtualPrefix };
|
|
72
|
+
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix };
|
|
45
73
|
//# sourceMappingURL=virtual.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.mjs","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\
|
|
1
|
+
{"version":3,"file":"virtual.mjs","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst ESCAPE_REGEX = /[-/\\\\^$*+?.()|[\\]{}]/g;\nfunction escapeRegex(str: string): string {\n return str.replace(ESCAPE_REGEX, \"\\\\$&\");\n}\n\nexport const VIRTUAL_MODULE_PREFIX = \"\\0\";\nexport const VIRTUAL_MODULE_PREFIX_REGEX = prefixRegex(\"\\0\");\n\nexport interface PrefixRegexOptions {\n /**\n * Flags for the RegExp.\n */\n flags?: string;\n\n /**\n * The prefix to match. This will be escaped and used as the prefix in the generated RegExp.\n */\n prefix?: string;\n\n /**\n * Whether the prefix is optional. If true, the generated RegExp will match both strings that start with the prefix and strings that do not start with the prefix. Default is false.\n */\n isPrefixOptional?: boolean;\n}\n\n/**\n * Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.\n *\n * @example\n * ```ts\n * import { prefixRegex } from '@rolldown/pluginutils';\n * const plugin = {\n * name: 'plugin',\n * resolveId: {\n * filter: { id: prefixRegex('foo') },\n * handler(id) {} // will only be called for IDs starting with `foo`\n * }\n * }\n * ```\n *\n * @param str - the string to match.\n * @param options - options for the RegExp.\n * @return a RegExp that matches the specified string with the specified prefix.\n */\nexport function prefixRegex(\n str: string,\n options: PrefixRegexOptions = {}\n): RegExp {\n const { flags, prefix, isPrefixOptional = false } = options;\n\n return new RegExp(\n `^${\n prefix\n ? isPrefixOptional\n ? `(${escapeRegex(prefix)})?`\n : `${escapeRegex(prefix)}`\n : \"\"\n }${escapeRegex(str)}`,\n flags\n );\n}\n\n/**\n * Adds the virtual module prefix to the given ID.\n *\n * @param id - The ID to add the virtual module prefix to.\n * @returns The ID with the virtual module prefix added.\n */\nexport function addVirtualPrefix(id: string): string {\n return `${VIRTUAL_MODULE_PREFIX}${id}`;\n}\n\n/**\n * Removes the virtual module prefix from the given ID, if it exists.\n *\n * @param id - The ID to remove the virtual module prefix from.\n * @returns The ID without the virtual module prefix.\n */\nexport function removeVirtualPrefix(id: string): string {\n return id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\");\n}\n\n/**\n * Checks if the given ID is a virtual module by checking if it starts with the virtual module prefix.\n *\n * @param id - The ID to check.\n * @returns True if the ID is a virtual module, false otherwise.\n */\nexport function isVirtualModule(id: string): boolean {\n return id.startsWith(VIRTUAL_MODULE_PREFIX);\n}\n\n/**\n * Creates a regular expression that matches the given ID with the virtual module prefix.\n *\n * @param id - The ID to create a regular expression for.\n * @returns A regular expression that matches the given ID with the virtual module prefix.\n */\nexport function createVirtualPrefixRegex(id: string): RegExp {\n return prefixRegex(removeVirtualPrefix(id), {\n prefix: VIRTUAL_MODULE_PREFIX,\n isPrefixOptional: true\n });\n}\n"],"mappings":";AAkBA,MAAM,eAAe;AACrB,SAAS,YAAY,KAAqB;AACxC,QAAO,IAAI,QAAQ,cAAc,OAAO;;AAG1C,MAAa,wBAAwB;AACrC,MAAa,8BAA8B,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;AAsC5D,SAAgB,YACd,KACA,UAA8B,EAAE,EACxB;CACR,MAAM,EAAE,OAAO,QAAQ,mBAAmB,UAAU;AAEpD,QAAO,IAAI,OACT,IACE,SACI,mBACE,IAAI,YAAY,OAAO,CAAC,MACxB,GAAG,YAAY,OAAO,KACxB,KACH,YAAY,IAAI,IACnB,MACD;;;;;;;;AASH,SAAgB,iBAAiB,IAAoB;AACnD,QAAO,UAA2B;;;;;;;;AASpC,SAAgB,oBAAoB,IAAoB;AACtD,QAAO,GAAG,QAAQ,6BAA6B,GAAG;;;;;;;;AASpD,SAAgB,gBAAgB,IAAqB;AACnD,QAAO,GAAG,gBAAiC;;;;;;;;AAS7C,SAAgB,yBAAyB,IAAoB;AAC3D,QAAO,YAAY,oBAAoB,GAAG,EAAE;EAC1C;EACA,kBAAkB;EACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/core",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -242,5 +242,5 @@
|
|
|
242
242
|
"typescript": "^6.0.3"
|
|
243
243
|
},
|
|
244
244
|
"publishConfig": { "access": "public" },
|
|
245
|
-
"gitHead": "
|
|
245
|
+
"gitHead": "76fde74fd0b494596135ace273dd0d0072b7b8be"
|
|
246
246
|
}
|