@windicss/plugin-utils
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -315,8 +315,14 @@ import * as windicss_types_interfaces from 'windicss/types/interfaces'; | ||
declare function resolveOptions(options?: UserOptions | ResolvedOptions, utilsOptions?: WindiPluginUtilsOptions, loadConfigFile?: boolean): Promise<ResolvedOptions>; | ||
declare function loadConfiguration(options: UserOptions, utilsOptions: WindiPluginUtilsOptions): Promise<{ | ||
interface LoadConfigurationOptions { | ||
name?: string; | ||
enableSucrase?: boolean; | ||
config?: FullConfig | string; | ||
root?: string; | ||
} | ||
declare function loadConfiguration(options: LoadConfigurationOptions): { | ||
error: Error | undefined; | ||
resolved: FullConfig; | ||
configFilePath: string | undefined; | ||
}>; | ||
}; | ||
export { Arrayable, CompletionsResult, DefaultExtractor, NestedArrayable, PugExtractor, ResolvedOptions, TagNames, Transformer, TransformerFunction, TransformerOptions, UserOptions, WindiPluginUtils, WindiPluginUtilsOptions, applyExtractors, configureFiles, createUtils, defaultAlias, defineConfig, exclude, flattenArray, getDefaultExtractors, htmlTags, include, isResolvedOptions, kebabCase, loadConfiguration, mergeArrays, preflightTags, resolveOptions, slash, toArray, transformGroups, transformGroupsWithSourcemap }; | ||
export { Arrayable, CompletionsResult, DefaultExtractor, LoadConfigurationOptions, NestedArrayable, PugExtractor, ResolvedOptions, TagNames, Transformer, TransformerFunction, TransformerOptions, UserOptions, WindiPluginUtils, WindiPluginUtilsOptions, applyExtractors, configureFiles, createUtils, defaultAlias, defineConfig, exclude, flattenArray, getDefaultExtractors, htmlTags, include, isResolvedOptions, kebabCase, loadConfiguration, mergeArrays, preflightTags, resolveOptions, slash, toArray, transformGroups, transformGroupsWithSourcemap }; |
@@ -194,4 +194,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty; | ||
var regexClassGroup = /([!\w+-][\w+:_/-]*?\w):\(([\w\s/-]*?)\)/gm; | ||
var regexClassCheck1 = /^[!a-z\d@<>.+-](?:\([\w-.]*\)|[\w:/\\.$-])*$/; | ||
var regexClassCheck2 = /[a-z].*[\w)]$/; | ||
var regexClassCheck1 = /^[!a-z\d@<>.+-](?:\([\w,.%#-]*\)|[\w:/\\,%#\[\].$-])*$/; | ||
var regexClassCheck2 = /[a-z].*[\w)\]]$/; | ||
var regexClassChecks = [ | ||
@@ -366,3 +366,3 @@ regexClassCheck1, | ||
async function resolveOptions(options = {}, utilsOptions = {}, loadConfigFile = false) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (isResolvedOptions(options)) | ||
@@ -374,3 +374,9 @@ return options; | ||
const debugOptions = _debug4.default.call(void 0, `${name}:options`); | ||
const {resolved: config, configFilePath} = loadConfigFile ? await loadConfiguration(options, utilsOptions) : {resolved: {}, configFilePath: {}}; | ||
let {resolved: config, configFilePath} = loadConfigFile ? loadConfiguration(__assign(__assign({}, utilsOptions), { | ||
root: utilsOptions.root || options.root, | ||
config: options.config | ||
})) : {resolved: {}, configFilePath: void 0}; | ||
const modifiedConfigs = await ((_a = options.onConfigResolved) == null ? void 0 : _a.call(options, config, configFilePath)); | ||
if (modifiedConfigs != null) | ||
config = modifiedConfigs; | ||
const { | ||
@@ -404,5 +410,5 @@ root = utilsOptions.root || process.cwd(), | ||
}, typeof scan === "boolean" ? {} : scan); | ||
scanOptions.exclude = mergeArrays((_a = config.extract) == null ? void 0 : _a.exclude, scanOptions.exclude).map((i) => slash(_path.resolve.call(void 0, root, i))); | ||
scanOptions.include = mergeArrays((_b = config.extract) == null ? void 0 : _b.include, scanOptions.include, ((_c = config.extract) == null ? void 0 : _c.include) ? [] : buildGlobs(scanOptions.dirs, scanOptions.fileExtensions)).map((i) => slash(_path.resolve.call(void 0, root, i))); | ||
scanOptions.extractors = mergeArrays(getDefaultExtractors(), (_d = config.extract) == null ? void 0 : _d.extractors); | ||
scanOptions.exclude = mergeArrays((_b = config.extract) == null ? void 0 : _b.exclude, scanOptions.exclude).map((i) => slash(_path.resolve.call(void 0, root, i))); | ||
scanOptions.include = mergeArrays((_c = config.extract) == null ? void 0 : _c.include, scanOptions.include, ((_d = config.extract) == null ? void 0 : _d.include) ? [] : buildGlobs(scanOptions.dirs, scanOptions.fileExtensions)).map((i) => slash(_path.resolve.call(void 0, root, i))); | ||
scanOptions.extractors = mergeArrays(getDefaultExtractors(), (_e = config.extract) == null ? void 0 : _e.extractors); | ||
const safelist = new Set(mergeArrays(config.safelist, options.safelist).flatMap((i) => i.split(" "))); | ||
@@ -435,3 +441,3 @@ const blocklist = new Set(mergeArrays(config.blocklist, options.blocklist).flatMap((i) => i.split(" "))); | ||
}); | ||
const modifiedOptions = await ((_e = resolvedOptions.onOptionsResolved) == null ? void 0 : _e.call(resolvedOptions, resolvedOptions)); | ||
const modifiedOptions = await ((_f = resolvedOptions.onOptionsResolved) == null ? void 0 : _f.call(resolvedOptions, resolvedOptions)); | ||
if (modifiedOptions != null && modifiedOptions !== resolvedOptions) | ||
@@ -442,4 +448,3 @@ resolvedOptions = Object.assign(resolvedOptions, modifiedOptions); | ||
} | ||
async function loadConfiguration(options, utilsOptions) { | ||
var _a; | ||
function loadConfiguration(options) { | ||
let resolved = {}; | ||
@@ -450,9 +455,7 @@ let configFilePath; | ||
name = "windicss-plugin-utils", | ||
enableSucrase = true | ||
} = utilsOptions; | ||
const debugConfig = _debug4.default.call(void 0, `${name}:config`); | ||
const { | ||
enableSucrase = true, | ||
config, | ||
root = utilsOptions.root || process.cwd() | ||
root = process.cwd() | ||
} = options; | ||
const debugConfig = _debug4.default.call(void 0, `${name}:config`); | ||
if (typeof config === "string" || !config) { | ||
@@ -498,5 +501,2 @@ if (!config) { | ||
} | ||
const modifiedConfigs = await ((_a = options.onConfigResolved) == null ? void 0 : _a.call(options, resolved, configFilePath)); | ||
if (modifiedConfigs != null) | ||
resolved = modifiedConfigs; | ||
debugConfig(resolved); | ||
@@ -503,0 +503,0 @@ return { |
{ | ||
"name": "@windicss/plugin-utils", | ||
"description": "Common utils for building integrations of Windi CSS", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"main": "dist/index.js", | ||
@@ -36,6 +36,6 @@ "module": "dist/index.mjs", | ||
"sucrase": "^3.17.1", | ||
"windicss": "^2.5.9" | ||
"windicss": "^2.5.11" | ||
}, | ||
"devDependencies": { | ||
"@antfu/ni": "^0.5.5", | ||
"@antfu/ni": "^0.5.6", | ||
"@types/debug": "^4.1.5", | ||
@@ -42,0 +42,0 @@ "@types/micromatch": "^4.0.1", |
Sorry, the diff of this file is not supported yet
59836
1841
Updatedwindicss@^2.5.11